HTML EDITOR PREMIUM
מסמך HTML ראשי
טקסט וכותרות
קישורים, תמונות, אלמנטים ורכיבים
רשימות וטבלאות
טפסים ושדות קלט
לוח קוד HTML
תצוגה מקדימה אמיתית
`); } /* תגיות HTML */ function insertTag(tag,selfClosing=false) { if(selfClosing) { addCode(`<${tag}>`); } else { addCode(`<${tag}> `); } } /* תגיות טקסט */ function insertText(tag) { currentAction = { type: "text", tag: tag }; showModal("הכנסת טקסט",[ { id:"text", placeholder:"הכנס את הטקסט שיופיע באתר" } ]); } /* קישור */ function insertLink() { currentAction = { type:"link" }; showModal("יצירת קישור",[ { id:"url", placeholder:"כתובת הקישור" }, { id:"text", placeholder:"טקסט הקישור" } ],true); } /* תמונה */ function insertImage() { currentAction = { type:"image" }; showModal("הוספת תמונה",[ { id:"url", placeholder:"כתובת התמונה" }, { id:"alt", placeholder:"תיאור התמונה" } ]); } /* וידאו */ function insertVideo() { currentAction = { type:"video" }; showModal("הוספת סרטון",[ { id:"url", placeholder:"כתובת הסרטון" } ]); } /* אודיו */ function insertAudio() { currentAction = { type:"audio" }; showModal("הוספת קובץ שמע",[ { id:"url", placeholder:"כתובת קובץ השמע" } ]); } /* שדות קלט */ function insertInput(type) { addCode(``); } /* חלונית קלט */ function showModal(title,fields,target=false) { document.getElementById("modalTitle").textContent = title; const container = document.getElementById("modalFields"); container.innerHTML = ""; fields.forEach(field => { const input = document.createElement("input"); input.type = "text"; input.id = "field_" + field.id; input.placeholder = field.placeholder; container.appendChild(input); }); if(target) { const label = document.createElement("label"); const checkbox = document.createElement("input"); checkbox.type = "checkbox"; checkbox.id = "newTab"; label.appendChild(checkbox); label.append(" פתיחה בלשונית חדשה"); container.appendChild(label); } document.getElementById("modal").style.display = "flex"; } /* אישור הכנסת נתונים */ function confirmModal() { if(!currentAction) return; let code = ""; const get = id => { return document.getElementById("field_"+id)?.value || ""; }; if(currentAction.type === "text") { const tag = currentAction.tag; code = `<${tag}>${escapeHTML(get("text"))}`; } if(currentAction.type === "link") { const url = escapeHTML(get("url")); const text = escapeHTML(get("text")); const newTab = document.getElementById("newTab").checked; code = `${text}`; } if(currentAction.type === "image") { code = `${escapeHTML(get(`; } if(currentAction.type === "video") { code = ``; } if(currentAction.type === "audio") { code = ``; } addCode(code); closeModal(); } /* הגנה על טקסט */ function escapeHTML(text) { return text.replace(/[&<>"']/g,char => ({ "&":"&", "<":"<", ">":">", '"':""", "'":"'" })[char]); } /* סגירת חלונית */ function closeModal() { document.getElementById("modal").style.display = "none"; currentAction = null; } /* תצוגה ראשונית */ updatePreview();