@editora/plugins 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/approval-workflow.cjs.js +14 -14
  2. package/dist/approval-workflow.esm.js +265 -262
  3. package/dist/blockquote.cjs.js +1 -1
  4. package/dist/blockquote.esm.js +177 -15
  5. package/dist/blocks-library.cjs.js +6 -6
  6. package/dist/blocks-library.esm.js +95 -92
  7. package/dist/bold.cjs.js +1 -1
  8. package/dist/bold.esm.js +10 -6
  9. package/dist/capitalization.cjs.js +1 -1
  10. package/dist/capitalization.esm.js +124 -44
  11. package/dist/checklist.cjs.js +1 -1
  12. package/dist/checklist.esm.js +251 -191
  13. package/dist/citations.cjs.js +4 -4
  14. package/dist/citations.esm.js +131 -128
  15. package/dist/clear-formatting.cjs.js +1 -1
  16. package/dist/clear-formatting.esm.js +68 -36
  17. package/dist/content-rules.cjs.js +5 -5
  18. package/dist/content-rules.esm.js +104 -101
  19. package/dist/data-binding.cjs.js +3 -3
  20. package/dist/data-binding.esm.js +51 -48
  21. package/dist/direction.cjs.js +1 -1
  22. package/dist/direction.esm.js +97 -74
  23. package/dist/doc-schema.cjs.js +4 -4
  24. package/dist/doc-schema.esm.js +104 -101
  25. package/dist/embed-iframe.cjs.js +21 -4
  26. package/dist/embed-iframe.esm.js +279 -116
  27. package/dist/heading.cjs.js +1 -1
  28. package/dist/heading.esm.js +239 -56
  29. package/dist/history.cjs.js +1 -1
  30. package/dist/history.esm.js +74 -89
  31. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  32. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  33. package/dist/italic.cjs.js +1 -1
  34. package/dist/italic.esm.js +12 -8
  35. package/dist/math.cjs.js +27 -21
  36. package/dist/math.esm.js +218 -146
  37. package/dist/merge-tag.cjs.js +8 -2
  38. package/dist/merge-tag.esm.js +130 -111
  39. package/dist/pii-redaction.cjs.js +6 -6
  40. package/dist/pii-redaction.esm.js +169 -166
  41. package/dist/smart-paste.cjs.js +5 -5
  42. package/dist/smart-paste.esm.js +120 -117
  43. package/dist/special-characters.cjs.js +6 -10
  44. package/dist/special-characters.esm.js +97 -75
  45. package/dist/strikethrough.cjs.js +1 -1
  46. package/dist/strikethrough.esm.js +11 -25
  47. package/dist/translation-workflow.cjs.js +7 -7
  48. package/dist/translation-workflow.esm.js +103 -100
  49. package/dist/underline.cjs.js +1 -1
  50. package/dist/underline.esm.js +7 -3
  51. package/package.json +3 -3
@@ -1,4 +1,21 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],m='[data-theme="dark"], .dark, .editora-theme-dark',u=new WeakMap,l=e=>(u.has(e)||u.set(e,{dialogElement:null,escapeHandler:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),u.get(e));function v(e){return e?.matches(m)||e?.closest(m)||document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}const x=()=>({name:"embedIframe",toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:e=>(y(e),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function y(e){if(!e){const o=document.activeElement;o&&o.closest("[data-editora-editor]")&&(e=o.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=l(e);t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const a=document.createElement("div");a.className="rte-dialog-overlay rte-embed-iframe-overlay",v(e)&&a.classList.add("rte-theme-dark"),a.onclick=()=>f(e);const r=document.createElement("div");r.className="rte-dialog-content embed-iframe-dialog",r.onclick=o=>o.stopPropagation(),r.innerHTML=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const D=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],u='[data-theme="dark"], .dark, .editora-theme-dark';let l=null;const v=new WeakMap,s=e=>(v.has(e)||v.set(e,{dialogElement:null,escapeHandler:null,savedRange:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),v.get(e));function C(e){return e?.matches(u)||e?.closest(u)||document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function x(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function R(e){const t=e?.editorElement;if(t instanceof HTMLElement)return t;const r=e?.contentElement;if(r instanceof HTMLElement){const i=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");return i instanceof HTMLElement?i:r}const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement)return o;const a=window.getSelection();if(a&&a.rangeCount>0){const c=x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(c instanceof HTMLElement)return c}const n=document.activeElement;if(n instanceof HTMLElement){const i=n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(i instanceof HTMLElement)return i}return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")}function w(e){return e.getAttribute("contenteditable")==="true"?e:e.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function h(e){return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]')}function L(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return!e.contains(r.startContainer)||!e.contains(r.endContainer)?null:r.cloneRange()}function k(e,t,r){if(t!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,t,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:r})}catch{}}}function I(e,t){let r=t;for(;r&&r.parentNode&&r.parentNode!==e;)r=r.parentNode;return r&&r.parentNode===e?r:null}function y(e,t){return e.tagName!=="P"?!1:Array.from(e.childNodes).every(r=>r===t?!0:r.nodeType===Node.ELEMENT_NODE?r.tagName==="BR":r.nodeType===Node.TEXT_NODE&&!r.textContent?.trim())}function T(e){if(!(e instanceof Element))return null;const t=e.closest("iframe");if(t instanceof HTMLIFrameElement){const n=h(t);if(!n)return null;const i=t.parentElement;return i&&i.parentElement===n&&y(i,t)?i:t}const r=e.closest("p");if(!(r instanceof HTMLElement))return null;const o=h(r);if(!o||r.parentElement!==o)return null;const a=Array.from(r.children).find(n=>n instanceof HTMLIFrameElement);return a&&y(r,a)?r:null}function f(){l&&(l.classList.remove("rte-selected-embed-object"),l.querySelector("iframe")?.removeAttribute("data-rte-selected-object"),l instanceof HTMLIFrameElement&&l.removeAttribute("data-rte-selected-object"),l=null)}function H(e){if(l===e)return;f(),l=e,e.classList.add("rte-selected-embed-object"),(e instanceof HTMLIFrameElement?e:e.querySelector("iframe"))?.setAttribute("data-rte-selected-object","true");const r=window.getSelection();if(!r)return;const o=document.createRange();o.selectNode(e),r.removeAllRanges(),r.addRange(o)}function N(e,t){const r=window.getSelection();if(!r)return;const o=document.createRange();t&&t.parentNode===e?o.setStartBefore(t):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),r.removeAllRanges(),r.addRange(o)}function q(e){if(e.childNodes.length>0)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),e.appendChild(t)}function A(){if(!l||!l.isConnected)return f(),!1;const e=l,t=h(e);if(!t)return f(),!1;const r=t.innerHTML,o=e.nextSibling;e.remove(),q(t),f(),N(t,o);const a=t.innerHTML;return k(t,r,a),t.dispatchEvent(new window.Event("input",{bubbles:!0})),r!==a}function E(){if(document.getElementById("embed-iframe-object-selection-styles"))return;const e=document.createElement("style");e.id="embed-iframe-object-selection-styles",e.textContent=`
2
+ .rte-selected-embed-object {
3
+ outline: 2px solid #2563eb;
4
+ outline-offset: 3px;
5
+ border-radius: 4px;
6
+ }
7
+
8
+ .rte-content iframe,
9
+ .editora-content iframe,
10
+ [contenteditable="true"] iframe {
11
+ pointer-events: none;
12
+ }
13
+
14
+ .rte-selected-embed-object iframe,
15
+ iframe.rte-selected-embed-object {
16
+ box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
17
+ }
18
+ `,document.head.appendChild(e)}function M(){typeof window>"u"||window.__embedIframeObjectSelectionInitialized||(window.__embedIframeObjectSelectionInitialized=!0,E(),document.addEventListener("pointerdown",e=>{const t=T(e.target);if(!t){e.target?.closest?.(".rte-embed-iframe-overlay")||f();return}e.preventDefault(),h(t)?.focus(),H(t)},!0),document.addEventListener("keydown",e=>{if(l){if(e.key==="Escape"){f();return}e.key!=="Backspace"&&e.key!=="Delete"||(e.preventDefault(),e.stopPropagation(),A())}},!0))}function z(e){try{const t=new URL(e),r=t.hostname.replace(/^www\./,"");if(r==="youtu.be"){const o=t.pathname.split("/").filter(Boolean)[0];if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`}if(r==="youtube.com"||r==="m.youtube.com"){const o=t.searchParams.get("v");if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`;const a=t.pathname.match(/^\/embed\/([^/]+)/);if(a?.[1])return`https://www.youtube.com/embed/${encodeURIComponent(a[1])}`}if(r==="vimeo.com"){const o=t.pathname.split("/").filter(Boolean)[0];if(o&&/^\d+$/.test(o))return`https://player.vimeo.com/video/${o}`}return e}catch{return e}}const j=()=>({name:"embedIframe",init:M,toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:(e,t)=>(P(R(t)||void 0),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function P(e){if(!e){const n=document.activeElement;n&&n.closest("[data-editora-editor]")&&(e=n.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=s(e),r=w(e);t.savedRange=r?L(r):null,t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const o=document.createElement("div");o.className="rte-dialog-overlay rte-embed-iframe-overlay",C(e)&&o.classList.add("rte-theme-dark"),o.onclick=()=>b(e);const a=document.createElement("div");a.className="rte-dialog-content embed-iframe-dialog",a.onclick=n=>n.stopPropagation(),a.innerHTML=`
2
19
  <div class="rte-dialog-header">
3
20
  <h3>Embed Iframe</h3>
4
21
  <button class="rte-dialog-close">×</button>
@@ -18,7 +35,7 @@
18
35
  <div class="rte-form-group">
19
36
  <label class="rte-form-label">Size</label>
20
37
  <select class="rte-form-select" id="iframe-size">
21
- ${g.map(o=>`<option value="${o.value}">${o.label}</option>`).join("")}
38
+ ${D.map(n=>`<option value="${n.value}">${n.label}</option>`).join("")}
22
39
  </select>
23
40
  </div>
24
41
  <div class="rte-form-row" id="dimensions-row">
@@ -72,7 +89,7 @@
72
89
  <button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
73
90
  <button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
74
91
  </div>
75
- `,a.appendChild(r),document.body.appendChild(a),t.dialogElement=a,t.escapeHandler=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),f(e))},document.addEventListener("keydown",t.escapeHandler,!0),k(r,e),z(),setTimeout(()=>{r.querySelector("#iframe-src")?.focus()},100)}function k(e,t){l(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>f(t)),e.querySelectorAll(".rte-tab-button").forEach(i=>{i.addEventListener("click",n=>{const c=n.target.getAttribute("data-tab");c&&w(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",i=>S(e,i.target.value,t));const r=e.querySelector("#iframe-width"),o=e.querySelector("#iframe-height");r?.addEventListener("input",i=>D(e,i.target.value,t)),o?.addEventListener("input",i=>q(e,i.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>E(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>f(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>L(e,t))}function w(e,t,a){const r=l(a);r.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(o=>{o.classList.toggle("active",o.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(o=>{o.style.display=o.getAttribute("data-panel")===t?"block":"none"})}function S(e,t,a){const r=l(a);r.formData.selectedSize=t;const o=e.querySelector("#dimensions-row"),i=e.querySelector("#iframe-width"),n=e.querySelector("#iframe-height");t==="inline"?(o.style.display="flex",i.value="100%",n.value="400px",r.formData.width="100%",r.formData.height="400px"):(o.style.display="none",r.formData.width="100%",r.formData.height="auto")}function D(e,t,a){const r=l(a);if(r.formData.width=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*9/16;r.formData.height=`${i}px`;const n=e.querySelector("#iframe-height");n&&(n.value=r.formData.height)}}}function q(e,t,a){const r=l(a);if(r.formData.height=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*16/9;r.formData.width=`${i}px`;const n=e.querySelector("#iframe-width");n&&(n.value=r.formData.width)}}}function E(e,t){const a=l(t);a.formData.constrainProportions=!a.formData.constrainProportions;const r=e.querySelector("#constrain-btn");r&&(r.textContent=a.formData.constrainProportions?"🔒":"🔓",r.className=`rte-constrain-btn ${a.formData.constrainProportions?"locked":"unlocked"}`,r.title=a.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function L(e,t){const a=l(t),r=e.querySelector("#iframe-src")?.value.trim();if(!r){alert("Please enter a source URL");return}if(!r.startsWith("https://")&&!r.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const o=e.querySelector("#iframe-name")?.value.trim(),i=e.querySelector("#iframe-title")?.value.trim(),n=e.querySelector("#iframe-longdesc")?.value.trim();e.querySelector("#iframe-desc-url")?.value.trim();const c=e.querySelector("#iframe-border")?.checked??!0,p=e.querySelector("#iframe-scrollbar")?.checked??!0;let s=a.formData.width,d=a.formData.height;a.formData.selectedSize!=="inline"&&(s="100%",d="auto"),I(t,{src:r,width:s,height:d,aspectRatio:a.formData.selectedSize,name:o||void 0,title:i||void 0,longDescription:n||void 0,showBorder:c,enableScrollbar:p}),f(t)}function I(e,t){const a=e.querySelector('[contenteditable="true"]');a&&(a.focus(),setTimeout(()=>{const r=[`src="${t.src}"`,`width="${t.width}"`,`height="${t.height}"`,"allowfullscreen",`frameborder="${t.showBorder?"1":"0"}"`,`scrolling="${t.enableScrollbar?"auto":"no"}"`];t.name&&r.push(`name="${t.name}"`),t.title&&r.push(`title="${t.title}"`),t.longDescription&&r.push(`longdesc="${t.longDescription}"`);const o=[];t.aspectRatio!=="inline"&&o.push(`rte-iframe-${t.aspectRatio}`);const i=o.length>0?`class="${o.join(" ")}"`:"",n=`data-aspect-ratio="${t.aspectRatio}"`,c=`<iframe ${r.join(" ")} ${i} ${n}></iframe>`;if(!document.execCommand("insertHTML",!1,c)){const s=window.getSelection();if(s&&s.rangeCount>0){const d=s.getRangeAt(0);d.deleteContents();const b=document.createElement("div");b.innerHTML=c;const h=document.createDocumentFragment();for(;b.firstChild;)h.appendChild(b.firstChild);d.insertNode(h)}}},10))}function f(e){const t=l(e);t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function z(){if(document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
92
+ `,o.appendChild(a),document.body.appendChild(o),t.dialogElement=o,t.escapeHandler=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),b(e))},document.addEventListener("keydown",t.escapeHandler,!0),O(a,e),W(),setTimeout(()=>{a.querySelector("#iframe-src")?.focus()},100)}function O(e,t){s(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>b(t)),e.querySelectorAll(".rte-tab-button").forEach(n=>{n.addEventListener("click",i=>{const c=i.target.getAttribute("data-tab");c&&_(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",n=>B(e,n.target.value,t));const o=e.querySelector("#iframe-width"),a=e.querySelector("#iframe-height");o?.addEventListener("input",n=>U(e,n.target.value,t)),a?.addEventListener("input",n=>$(e,n.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>F(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>b(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>Z(e,t))}function _(e,t,r){const o=s(r);o.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(a=>{a.style.display=a.getAttribute("data-panel")===t?"block":"none"})}function B(e,t,r){const o=s(r);o.formData.selectedSize=t;const a=e.querySelector("#dimensions-row"),n=e.querySelector("#iframe-width"),i=e.querySelector("#iframe-height");t==="inline"?(a.style.display="flex",n.value="100%",i.value="400px",o.formData.width="100%",o.formData.height="400px"):(a.style.display="none",o.formData.width="100%",o.formData.height="auto")}function U(e,t,r){const o=s(r);if(o.formData.width=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*9/16;o.formData.height=`${n}px`;const i=e.querySelector("#iframe-height");i&&(i.value=o.formData.height)}}}function $(e,t,r){const o=s(r);if(o.formData.height=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*16/9;o.formData.width=`${n}px`;const i=e.querySelector("#iframe-width");i&&(i.value=o.formData.width)}}}function F(e,t){const r=s(t);r.formData.constrainProportions=!r.formData.constrainProportions;const o=e.querySelector("#constrain-btn");o&&(o.textContent=r.formData.constrainProportions?"🔒":"🔓",o.className=`rte-constrain-btn ${r.formData.constrainProportions?"locked":"unlocked"}`,o.title=r.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function Z(e,t){const r=s(t),o=e.querySelector("#iframe-src")?.value.trim();if(!o){alert("Please enter a source URL");return}if(!o.startsWith("https://")&&!o.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const a=e.querySelector("#iframe-name")?.value.trim(),n=e.querySelector("#iframe-title")?.value.trim(),i=e.querySelector("#iframe-longdesc")?.value.trim(),c=e.querySelector("#iframe-desc-url")?.value.trim(),p=e.querySelector("#iframe-border")?.checked??!0,g=e.querySelector("#iframe-scrollbar")?.checked??!0;let d=r.formData.width,m=r.formData.height;r.formData.selectedSize!=="inline"&&(d="100%",m="auto"),V(t,{src:o,width:d,height:m,aspectRatio:r.formData.selectedSize,name:a||void 0,title:n||void 0,longDescription:i||void 0,descriptionUrl:c||void 0,showBorder:p,enableScrollbar:g}),b(t)}function V(e,t){const r=s(e),o=w(e);if(!o)return;const a=o.innerHTML,n=document.createElement("iframe");n.src=z(t.src),n.width=t.width,n.height=t.height,n.allowFullscreen=!0,n.setAttribute("frameborder",t.showBorder?"1":"0"),n.setAttribute("scrolling",t.enableScrollbar?"auto":"no"),n.setAttribute("data-aspect-ratio",t.aspectRatio),t.aspectRatio!=="inline"&&n.classList.add(`rte-iframe-${t.aspectRatio}`),t.name&&(n.name=t.name),t.title&&(n.title=t.title),t.longDescription&&n.setAttribute("data-long-description",t.longDescription),t.descriptionUrl&&n.setAttribute("longdesc",t.descriptionUrl);const i=document.createElement("p");i.appendChild(n),i.appendChild(document.createElement("br"));const c=r.savedRange&&o.contains(r.savedRange.commonAncestorContainer)?r.savedRange:document.createRange();(!r.savedRange||!o.contains(r.savedRange.commonAncestorContainer))&&(c.selectNodeContents(o),c.collapse(!1));const p=I(o,c.startContainer),g=p?p.nextSibling:null;o.insertBefore(i,g);const d=document.createRange();d.setStartAfter(i),d.collapse(!0);const m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(d)),r.savedRange=null;const S=o.innerHTML;k(o,a,S),o.dispatchEvent(new window.Event("input",{bubbles:!0}))}function b(e){const t=s(e);t.savedRange=null,t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function W(){if(E(),document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
76
93
  /* Embed Iframe Dialog Styles */
77
94
  .embed-iframe-dialog {
78
95
  max-width: 600px;
@@ -358,4 +375,4 @@
358
375
  width: 100%;
359
376
  height: 100%;
360
377
  }
361
- `,document.head.appendChild(e)}exports.EmbedIframePlugin=x;
378
+ `,document.head.appendChild(e)}exports.EmbedIframePlugin=j;
@@ -1,12 +1,15 @@
1
- const g = [
1
+ const D = [
2
2
  { label: "Inline Value", value: "inline" },
3
3
  { label: "Responsive - 21x9", value: "21x9" },
4
4
  { label: "Responsive - 16x9", value: "16x9" },
5
5
  { label: "Responsive - 4x3", value: "4x3" },
6
6
  { label: "Responsive - 1x1", value: "1x1" }
7
- ], m = '[data-theme="dark"], .dark, .editora-theme-dark', u = /* @__PURE__ */ new WeakMap(), l = (e) => (u.has(e) || u.set(e, {
7
+ ], u = '[data-theme="dark"], .dark, .editora-theme-dark';
8
+ let c = null;
9
+ const v = /* @__PURE__ */ new WeakMap(), s = (e) => (v.has(e) || v.set(e, {
8
10
  dialogElement: null,
9
11
  escapeHandler: null,
12
+ savedRange: null,
10
13
  activeTab: "general",
11
14
  formData: {
12
15
  src: "",
@@ -21,12 +24,185 @@ const g = [
21
24
  showBorder: !0,
22
25
  enableScrollbar: !0
23
26
  }
24
- }), u.get(e));
25
- function v(e) {
26
- return e?.matches(m) || e?.closest(m) || document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
27
+ }), v.get(e));
28
+ function C(e) {
29
+ return e?.matches(u) || e?.closest(u) || document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
27
30
  }
28
- const I = () => ({
31
+ function x(e) {
32
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
33
+ }
34
+ function R(e) {
35
+ const t = e?.editorElement;
36
+ if (t instanceof HTMLElement) return t;
37
+ const r = e?.contentElement;
38
+ if (r instanceof HTMLElement) {
39
+ const i = r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
40
+ return i instanceof HTMLElement ? i : r;
41
+ }
42
+ const o = window.__editoraCommandEditorRoot;
43
+ if (o instanceof HTMLElement) return o;
44
+ const a = window.getSelection();
45
+ if (a && a.rangeCount > 0) {
46
+ const l = x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
47
+ if (l instanceof HTMLElement) return l;
48
+ }
49
+ const n = document.activeElement;
50
+ if (n instanceof HTMLElement) {
51
+ const i = n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
52
+ if (i instanceof HTMLElement) return i;
53
+ }
54
+ return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
55
+ }
56
+ function w(e) {
57
+ return e.getAttribute("contenteditable") === "true" ? e : e.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
58
+ }
59
+ function h(e) {
60
+ return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
61
+ }
62
+ function L(e) {
63
+ const t = window.getSelection();
64
+ if (!t || t.rangeCount === 0) return null;
65
+ const r = t.getRangeAt(0);
66
+ return !e.contains(r.startContainer) || !e.contains(r.endContainer) ? null : r.cloneRange();
67
+ }
68
+ function k(e, t, r) {
69
+ if (t !== r) {
70
+ if (typeof window.execEditorCommand == "function") {
71
+ window.execEditorCommand("recordDomTransaction", e, t, r);
72
+ return;
73
+ }
74
+ if (typeof window.executeEditorCommand == "function")
75
+ try {
76
+ window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
77
+ } catch {
78
+ }
79
+ }
80
+ }
81
+ function I(e, t) {
82
+ let r = t;
83
+ for (; r && r.parentNode && r.parentNode !== e; )
84
+ r = r.parentNode;
85
+ return r && r.parentNode === e ? r : null;
86
+ }
87
+ function y(e, t) {
88
+ return e.tagName !== "P" ? !1 : Array.from(e.childNodes).every((r) => r === t ? !0 : r.nodeType === Node.ELEMENT_NODE ? r.tagName === "BR" : r.nodeType === Node.TEXT_NODE && !r.textContent?.trim());
89
+ }
90
+ function T(e) {
91
+ if (!(e instanceof Element)) return null;
92
+ const t = e.closest("iframe");
93
+ if (t instanceof HTMLIFrameElement) {
94
+ const n = h(t);
95
+ if (!n) return null;
96
+ const i = t.parentElement;
97
+ return i && i.parentElement === n && y(i, t) ? i : t;
98
+ }
99
+ const r = e.closest("p");
100
+ if (!(r instanceof HTMLElement)) return null;
101
+ const o = h(r);
102
+ if (!o || r.parentElement !== o) return null;
103
+ const a = Array.from(r.children).find(
104
+ (n) => n instanceof HTMLIFrameElement
105
+ );
106
+ return a && y(r, a) ? r : null;
107
+ }
108
+ function f() {
109
+ c && (c.classList.remove("rte-selected-embed-object"), c.querySelector("iframe")?.removeAttribute("data-rte-selected-object"), c instanceof HTMLIFrameElement && c.removeAttribute("data-rte-selected-object"), c = null);
110
+ }
111
+ function H(e) {
112
+ if (c === e) return;
113
+ f(), c = e, e.classList.add("rte-selected-embed-object"), (e instanceof HTMLIFrameElement ? e : e.querySelector("iframe"))?.setAttribute("data-rte-selected-object", "true");
114
+ const r = window.getSelection();
115
+ if (!r) return;
116
+ const o = document.createRange();
117
+ o.selectNode(e), r.removeAllRanges(), r.addRange(o);
118
+ }
119
+ function N(e, t) {
120
+ const r = window.getSelection();
121
+ if (!r) return;
122
+ const o = document.createRange();
123
+ t && t.parentNode === e ? o.setStartBefore(t) : (o.selectNodeContents(e), o.collapse(!1)), o.collapse(!0), r.removeAllRanges(), r.addRange(o);
124
+ }
125
+ function q(e) {
126
+ if (e.childNodes.length > 0) return;
127
+ const t = document.createElement("p");
128
+ t.appendChild(document.createElement("br")), e.appendChild(t);
129
+ }
130
+ function A() {
131
+ if (!c || !c.isConnected)
132
+ return f(), !1;
133
+ const e = c, t = h(e);
134
+ if (!t)
135
+ return f(), !1;
136
+ const r = t.innerHTML, o = e.nextSibling;
137
+ e.remove(), q(t), f(), N(t, o);
138
+ const a = t.innerHTML;
139
+ return k(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
140
+ }
141
+ function E() {
142
+ if (document.getElementById("embed-iframe-object-selection-styles")) return;
143
+ const e = document.createElement("style");
144
+ e.id = "embed-iframe-object-selection-styles", e.textContent = `
145
+ .rte-selected-embed-object {
146
+ outline: 2px solid #2563eb;
147
+ outline-offset: 3px;
148
+ border-radius: 4px;
149
+ }
150
+
151
+ .rte-content iframe,
152
+ .editora-content iframe,
153
+ [contenteditable="true"] iframe {
154
+ pointer-events: none;
155
+ }
156
+
157
+ .rte-selected-embed-object iframe,
158
+ iframe.rte-selected-embed-object {
159
+ box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
160
+ }
161
+ `, document.head.appendChild(e);
162
+ }
163
+ function M() {
164
+ typeof window > "u" || window.__embedIframeObjectSelectionInitialized || (window.__embedIframeObjectSelectionInitialized = !0, E(), document.addEventListener("pointerdown", (e) => {
165
+ const t = T(e.target);
166
+ if (!t) {
167
+ e.target?.closest?.(".rte-embed-iframe-overlay") || f();
168
+ return;
169
+ }
170
+ e.preventDefault(), h(t)?.focus(), H(t);
171
+ }, !0), document.addEventListener("keydown", (e) => {
172
+ if (c) {
173
+ if (e.key === "Escape") {
174
+ f();
175
+ return;
176
+ }
177
+ e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), A());
178
+ }
179
+ }, !0));
180
+ }
181
+ function z(e) {
182
+ try {
183
+ const t = new URL(e), r = t.hostname.replace(/^www\./, "");
184
+ if (r === "youtu.be") {
185
+ const o = t.pathname.split("/").filter(Boolean)[0];
186
+ if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
187
+ }
188
+ if (r === "youtube.com" || r === "m.youtube.com") {
189
+ const o = t.searchParams.get("v");
190
+ if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
191
+ const a = t.pathname.match(/^\/embed\/([^/]+)/);
192
+ if (a?.[1]) return `https://www.youtube.com/embed/${encodeURIComponent(a[1])}`;
193
+ }
194
+ if (r === "vimeo.com") {
195
+ const o = t.pathname.split("/").filter(Boolean)[0];
196
+ if (o && /^\d+$/.test(o)) return `https://player.vimeo.com/video/${o}`;
197
+ }
198
+ return e;
199
+ } catch {
200
+ return e;
201
+ }
202
+ }
203
+ const W = () => ({
29
204
  name: "embedIframe",
205
+ init: M,
30
206
  toolbar: [
31
207
  {
32
208
  label: "Embed Content",
@@ -37,23 +213,23 @@ const I = () => ({
37
213
  }
38
214
  ],
39
215
  commands: {
40
- openEmbedIframeDialog: (e) => (x(e), !0)
216
+ openEmbedIframeDialog: (e, t) => (j(R(t) || void 0), !0)
41
217
  },
42
218
  keymap: {
43
219
  "Mod-Shift-e": "openEmbedIframeDialog"
44
220
  }
45
221
  });
46
- function x(e) {
222
+ function j(e) {
47
223
  if (!e) {
48
- const o = document.activeElement;
49
- o && o.closest("[data-editora-editor]") && (e = o.closest("[data-editora-editor]"));
224
+ const n = document.activeElement;
225
+ n && n.closest("[data-editora-editor]") && (e = n.closest("[data-editora-editor]"));
50
226
  }
51
227
  if (e || (e = document.querySelector("[data-editora-editor]")), !e) {
52
228
  console.warn("Editor element not found");
53
229
  return;
54
230
  }
55
- const t = l(e);
56
- t.formData = {
231
+ const t = s(e), r = w(e);
232
+ t.savedRange = r ? L(r) : null, t.formData = {
57
233
  src: "",
58
234
  selectedSize: "inline",
59
235
  width: "100%",
@@ -66,10 +242,10 @@ function x(e) {
66
242
  showBorder: !0,
67
243
  enableScrollbar: !0
68
244
  }, t.activeTab = "general";
245
+ const o = document.createElement("div");
246
+ o.className = "rte-dialog-overlay rte-embed-iframe-overlay", C(e) && o.classList.add("rte-theme-dark"), o.onclick = () => b(e);
69
247
  const a = document.createElement("div");
70
- a.className = "rte-dialog-overlay rte-embed-iframe-overlay", v(e) && a.classList.add("rte-theme-dark"), a.onclick = () => f(e);
71
- const r = document.createElement("div");
72
- r.className = "rte-dialog-content embed-iframe-dialog", r.onclick = (o) => o.stopPropagation(), r.innerHTML = `
248
+ a.className = "rte-dialog-content embed-iframe-dialog", a.onclick = (n) => n.stopPropagation(), a.innerHTML = `
73
249
  <div class="rte-dialog-header">
74
250
  <h3>Embed Iframe</h3>
75
251
  <button class="rte-dialog-close">×</button>
@@ -89,7 +265,7 @@ function x(e) {
89
265
  <div class="rte-form-group">
90
266
  <label class="rte-form-label">Size</label>
91
267
  <select class="rte-form-select" id="iframe-size">
92
- ${g.map((o) => `<option value="${o.value}">${o.label}</option>`).join("")}
268
+ ${D.map((n) => `<option value="${n.value}">${n.label}</option>`).join("")}
93
269
  </select>
94
270
  </div>
95
271
  <div class="rte-form-row" id="dimensions-row">
@@ -143,128 +319,115 @@ function x(e) {
143
319
  <button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
144
320
  <button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
145
321
  </div>
146
- `, a.appendChild(r), document.body.appendChild(a), t.dialogElement = a, t.escapeHandler = (o) => {
147
- o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), f(e));
148
- }, document.addEventListener("keydown", t.escapeHandler, !0), y(r, e), z(), setTimeout(() => {
149
- r.querySelector("#iframe-src")?.focus();
322
+ `, o.appendChild(a), document.body.appendChild(o), t.dialogElement = o, t.escapeHandler = (n) => {
323
+ n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), b(e));
324
+ }, document.addEventListener("keydown", t.escapeHandler, !0), P(a, e), V(), setTimeout(() => {
325
+ a.querySelector("#iframe-src")?.focus();
150
326
  }, 100);
151
327
  }
152
- function y(e, t) {
153
- l(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => f(t)), e.querySelectorAll(".rte-tab-button").forEach((i) => {
154
- i.addEventListener("click", (n) => {
155
- const c = n.target.getAttribute("data-tab");
156
- c && k(e, c, t);
328
+ function P(e, t) {
329
+ s(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => b(t)), e.querySelectorAll(".rte-tab-button").forEach((n) => {
330
+ n.addEventListener("click", (i) => {
331
+ const l = i.target.getAttribute("data-tab");
332
+ l && O(e, l, t);
157
333
  });
158
- }), e.querySelector("#iframe-size")?.addEventListener("change", (i) => w(e, i.target.value, t));
159
- const r = e.querySelector("#iframe-width"), o = e.querySelector("#iframe-height");
160
- r?.addEventListener("input", (i) => S(e, i.target.value, t)), o?.addEventListener("input", (i) => D(e, i.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => q(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => f(t)), e.querySelector("#save-btn")?.addEventListener("click", () => E(e, t));
334
+ }), e.querySelector("#iframe-size")?.addEventListener("change", (n) => B(e, n.target.value, t));
335
+ const o = e.querySelector("#iframe-width"), a = e.querySelector("#iframe-height");
336
+ o?.addEventListener("input", (n) => U(e, n.target.value, t)), a?.addEventListener("input", (n) => _(e, n.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => $(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => b(t)), e.querySelector("#save-btn")?.addEventListener("click", () => F(e, t));
161
337
  }
162
- function k(e, t, a) {
163
- const r = l(a);
164
- r.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((o) => {
165
- o.classList.toggle("active", o.getAttribute("data-tab") === t);
166
- }), e.querySelectorAll(".rte-tab-panel").forEach((o) => {
167
- o.style.display = o.getAttribute("data-panel") === t ? "block" : "none";
338
+ function O(e, t, r) {
339
+ const o = s(r);
340
+ o.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((a) => {
341
+ a.classList.toggle("active", a.getAttribute("data-tab") === t);
342
+ }), e.querySelectorAll(".rte-tab-panel").forEach((a) => {
343
+ a.style.display = a.getAttribute("data-panel") === t ? "block" : "none";
168
344
  });
169
345
  }
170
- function w(e, t, a) {
171
- const r = l(a);
172
- r.formData.selectedSize = t;
173
- const o = e.querySelector("#dimensions-row"), i = e.querySelector("#iframe-width"), n = e.querySelector("#iframe-height");
174
- t === "inline" ? (o.style.display = "flex", i.value = "100%", n.value = "400px", r.formData.width = "100%", r.formData.height = "400px") : (o.style.display = "none", r.formData.width = "100%", r.formData.height = "auto");
346
+ function B(e, t, r) {
347
+ const o = s(r);
348
+ o.formData.selectedSize = t;
349
+ const a = e.querySelector("#dimensions-row"), n = e.querySelector("#iframe-width"), i = e.querySelector("#iframe-height");
350
+ t === "inline" ? (a.style.display = "flex", n.value = "100%", i.value = "400px", o.formData.width = "100%", o.formData.height = "400px") : (a.style.display = "none", o.formData.width = "100%", o.formData.height = "auto");
175
351
  }
176
- function S(e, t, a) {
177
- const r = l(a);
178
- if (r.formData.width = t, r.formData.constrainProportions && r.formData.selectedSize === "inline") {
179
- const o = parseFloat(t);
180
- if (!isNaN(o)) {
181
- const i = o * 9 / 16;
182
- r.formData.height = `${i}px`;
183
- const n = e.querySelector("#iframe-height");
184
- n && (n.value = r.formData.height);
352
+ function U(e, t, r) {
353
+ const o = s(r);
354
+ if (o.formData.width = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
355
+ const a = parseFloat(t);
356
+ if (!isNaN(a)) {
357
+ const n = a * 9 / 16;
358
+ o.formData.height = `${n}px`;
359
+ const i = e.querySelector("#iframe-height");
360
+ i && (i.value = o.formData.height);
185
361
  }
186
362
  }
187
363
  }
188
- function D(e, t, a) {
189
- const r = l(a);
190
- if (r.formData.height = t, r.formData.constrainProportions && r.formData.selectedSize === "inline") {
191
- const o = parseFloat(t);
192
- if (!isNaN(o)) {
193
- const i = o * 16 / 9;
194
- r.formData.width = `${i}px`;
195
- const n = e.querySelector("#iframe-width");
196
- n && (n.value = r.formData.width);
364
+ function _(e, t, r) {
365
+ const o = s(r);
366
+ if (o.formData.height = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
367
+ const a = parseFloat(t);
368
+ if (!isNaN(a)) {
369
+ const n = a * 16 / 9;
370
+ o.formData.width = `${n}px`;
371
+ const i = e.querySelector("#iframe-width");
372
+ i && (i.value = o.formData.width);
197
373
  }
198
374
  }
199
375
  }
200
- function q(e, t) {
201
- const a = l(t);
202
- a.formData.constrainProportions = !a.formData.constrainProportions;
203
- const r = e.querySelector("#constrain-btn");
204
- r && (r.textContent = a.formData.constrainProportions ? "🔒" : "🔓", r.className = `rte-constrain-btn ${a.formData.constrainProportions ? "locked" : "unlocked"}`, r.title = a.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
376
+ function $(e, t) {
377
+ const r = s(t);
378
+ r.formData.constrainProportions = !r.formData.constrainProportions;
379
+ const o = e.querySelector("#constrain-btn");
380
+ o && (o.textContent = r.formData.constrainProportions ? "🔒" : "🔓", o.className = `rte-constrain-btn ${r.formData.constrainProportions ? "locked" : "unlocked"}`, o.title = r.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
205
381
  }
206
- function E(e, t) {
207
- const a = l(t), r = e.querySelector("#iframe-src")?.value.trim();
208
- if (!r) {
382
+ function F(e, t) {
383
+ const r = s(t), o = e.querySelector("#iframe-src")?.value.trim();
384
+ if (!o) {
209
385
  alert("Please enter a source URL");
210
386
  return;
211
387
  }
212
- if (!r.startsWith("https://") && !r.startsWith("http://")) {
388
+ if (!o.startsWith("https://") && !o.startsWith("http://")) {
213
389
  alert("Please enter a valid URL starting with https:// or http://");
214
390
  return;
215
391
  }
216
- const o = e.querySelector("#iframe-name")?.value.trim(), i = e.querySelector("#iframe-title")?.value.trim(), n = e.querySelector("#iframe-longdesc")?.value.trim();
217
- e.querySelector("#iframe-desc-url")?.value.trim();
218
- const c = e.querySelector("#iframe-border")?.checked ?? !0, p = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
219
- let s = a.formData.width, d = a.formData.height;
220
- a.formData.selectedSize !== "inline" && (s = "100%", d = "auto"), L(t, {
221
- src: r,
222
- width: s,
223
- height: d,
224
- aspectRatio: a.formData.selectedSize,
225
- name: o || void 0,
226
- title: i || void 0,
227
- longDescription: n || void 0,
228
- showBorder: c,
229
- enableScrollbar: p
230
- }), f(t);
392
+ const a = e.querySelector("#iframe-name")?.value.trim(), n = e.querySelector("#iframe-title")?.value.trim(), i = e.querySelector("#iframe-longdesc")?.value.trim(), l = e.querySelector("#iframe-desc-url")?.value.trim(), p = e.querySelector("#iframe-border")?.checked ?? !0, g = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
393
+ let d = r.formData.width, m = r.formData.height;
394
+ r.formData.selectedSize !== "inline" && (d = "100%", m = "auto"), Z(t, {
395
+ src: o,
396
+ width: d,
397
+ height: m,
398
+ aspectRatio: r.formData.selectedSize,
399
+ name: a || void 0,
400
+ title: n || void 0,
401
+ longDescription: i || void 0,
402
+ descriptionUrl: l || void 0,
403
+ showBorder: p,
404
+ enableScrollbar: g
405
+ }), b(t);
231
406
  }
232
- function L(e, t) {
233
- const a = e.querySelector('[contenteditable="true"]');
234
- a && (a.focus(), setTimeout(() => {
235
- const r = [
236
- `src="${t.src}"`,
237
- `width="${t.width}"`,
238
- `height="${t.height}"`,
239
- "allowfullscreen",
240
- `frameborder="${t.showBorder ? "1" : "0"}"`,
241
- `scrolling="${t.enableScrollbar ? "auto" : "no"}"`
242
- ];
243
- t.name && r.push(`name="${t.name}"`), t.title && r.push(`title="${t.title}"`), t.longDescription && r.push(`longdesc="${t.longDescription}"`);
244
- const o = [];
245
- t.aspectRatio !== "inline" && o.push(`rte-iframe-${t.aspectRatio}`);
246
- const i = o.length > 0 ? `class="${o.join(" ")}"` : "", n = `data-aspect-ratio="${t.aspectRatio}"`, c = `<iframe ${r.join(" ")} ${i} ${n}></iframe>`;
247
- if (!document.execCommand("insertHTML", !1, c)) {
248
- const s = window.getSelection();
249
- if (s && s.rangeCount > 0) {
250
- const d = s.getRangeAt(0);
251
- d.deleteContents();
252
- const b = document.createElement("div");
253
- b.innerHTML = c;
254
- const h = document.createDocumentFragment();
255
- for (; b.firstChild; )
256
- h.appendChild(b.firstChild);
257
- d.insertNode(h);
258
- }
259
- }
260
- }, 10));
407
+ function Z(e, t) {
408
+ const r = s(e), o = w(e);
409
+ if (!o) return;
410
+ const a = o.innerHTML, n = document.createElement("iframe");
411
+ n.src = z(t.src), n.width = t.width, n.height = t.height, n.allowFullscreen = !0, n.setAttribute("frameborder", t.showBorder ? "1" : "0"), n.setAttribute("scrolling", t.enableScrollbar ? "auto" : "no"), n.setAttribute("data-aspect-ratio", t.aspectRatio), t.aspectRatio !== "inline" && n.classList.add(`rte-iframe-${t.aspectRatio}`), t.name && (n.name = t.name), t.title && (n.title = t.title), t.longDescription && n.setAttribute("data-long-description", t.longDescription), t.descriptionUrl && n.setAttribute("longdesc", t.descriptionUrl);
412
+ const i = document.createElement("p");
413
+ i.appendChild(n), i.appendChild(document.createElement("br"));
414
+ const l = r.savedRange && o.contains(r.savedRange.commonAncestorContainer) ? r.savedRange : document.createRange();
415
+ (!r.savedRange || !o.contains(r.savedRange.commonAncestorContainer)) && (l.selectNodeContents(o), l.collapse(!1));
416
+ const p = I(o, l.startContainer), g = p ? p.nextSibling : null;
417
+ o.insertBefore(i, g);
418
+ const d = document.createRange();
419
+ d.setStartAfter(i), d.collapse(!0);
420
+ const m = window.getSelection();
421
+ m && (m.removeAllRanges(), m.addRange(d)), r.savedRange = null;
422
+ const S = o.innerHTML;
423
+ k(o, a, S), o.dispatchEvent(new window.Event("input", { bubbles: !0 }));
261
424
  }
262
- function f(e) {
263
- const t = l(e);
264
- t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
425
+ function b(e) {
426
+ const t = s(e);
427
+ t.savedRange = null, t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
265
428
  }
266
- function z() {
267
- if (document.getElementById("embed-iframe-dialog-styles")) return;
429
+ function V() {
430
+ if (E(), document.getElementById("embed-iframe-dialog-styles")) return;
268
431
  const e = document.createElement("style");
269
432
  e.id = "embed-iframe-dialog-styles", e.textContent = `
270
433
  /* Embed Iframe Dialog Styles */
@@ -555,5 +718,5 @@ function z() {
555
718
  `, document.head.appendChild(e);
556
719
  }
557
720
  export {
558
- I as EmbedIframePlugin
721
+ W as EmbedIframePlugin
559
722
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=()=>{const e=a=>{try{return document.execCommand("formatBlock",!1,a),!0}catch(l){return console.error(`Failed to set block type to ${a}:`,l),!1}};return{name:"heading",toolbar:[{label:"Heading",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:a=>a?e(a):!1,setHeading1:()=>e("h1"),setHeading2:()=>e("h2"),setHeading3:()=>e("h3"),setParagraph:()=>e("p")},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}}};exports.HeadingPlugin=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",g=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",B=new Set(["p","h1","h2","h3","h4","h5","h6"]);function H(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function S(e){const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const a=t.querySelector(f);if(a instanceof HTMLElement)return a;if(t.getAttribute("contenteditable")==="true")return t}const r=window.getSelection();if(r&&r.rangeCount>0){const a=H(r.getRangeAt(0).startContainer),i=a?.closest(f);if(i instanceof HTMLElement)return i;const u=a?.closest(y)?.querySelector(f);if(u instanceof HTMLElement)return u}const o=document.activeElement?.closest(f);return o instanceof HTMLElement?o:document.querySelector(f)}function N(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t}function T(e,n){let t=H(n);if(!t||t===e||!e.contains(t))return null;for(;t.parentElement&&t.parentElement!==e;)t=t.parentElement;if(t.parentElement!==e)return null;if(t.matches(E))return t;const r=t.closest(E);return r instanceof HTMLElement&&r.parentElement===e?r:t}function v(e,n){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0}function w(e,n){const t=T(e,n.startContainer),r=T(e,n.endContainer);if(!t)return[];if(!r||t===r)return[t];const o=Array.from(e.children).filter(a=>a instanceof HTMLElement).filter(a=>v(n,a));return o.length>0?o:[t]}function A(e,n){Array.from(e.attributes).forEach(t=>{n.setAttribute(t.name,t.value)})}function p(e,n){for(;e.firstChild;)n.appendChild(e.firstChild)}function R(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function d(e,n){const t=document.createElement(e);return n&&A(n,t),t}function C(e,n){const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function _(e){const n=e.cloneNode(!1);return n instanceof HTMLElement?n:document.createElement(e.tagName.toLowerCase())}function L(e,n,t){const r=e.parentNode;if(!r)return[];const s=document.createDocumentFragment(),o=[];let a=null;const i=()=>{a&&a.children.length>0&&s.appendChild(a),a=null};return Array.from(e.children).forEach(c=>{if(c instanceof HTMLLIElement){if(n.has(c)){i();const u=C(c,t);s.appendChild(u),o.push(u);return}a||(a=_(e)),a.appendChild(c)}}),i(),r.insertBefore(s,e),r.removeChild(e),o}function I(e,n){if(e.tagName.toLowerCase()===n)return[e];const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),e.parentNode?.replaceChild(t,e),[t]}function O(e,n){const t=e.parentNode;if(!t)return[];const r=document.createDocumentFragment(),s=[];return Array.from(e.childNodes).forEach(o=>{if(o instanceof HTMLElement&&R(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(i=>{if(!(i instanceof HTMLLIElement))return;const c=C(i,n);r.appendChild(c),s.push(c)}),o.remove();return}if(o instanceof HTMLElement&&g.has(o.tagName)){const i=d(n,o);p(o,i),r.appendChild(i),s.push(i);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=d(n,e);a.appendChild(o),r.appendChild(a),s.push(a)}),t.insertBefore(r,e),t.removeChild(e),s}function b(e){const n=window.getSelection();if(!n)return;const t=document.createRange(),r=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;t.selectNodeContents(r),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}function k(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function P(e,n,t){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",e,n,t);return}const s=window.executeEditorCommand;typeof s=="function"&&s("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}function x(e,n){const t=new Map;return Array.from(e.querySelectorAll("li")).filter(s=>s instanceof HTMLLIElement&&v(n,s)).forEach(s=>{const o=s.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===e&&(t.has(o)||t.set(o,new Set),t.get(o)?.add(s))}),t}function m(e,n){const t=e.toLowerCase();if(!B.has(t))return!1;const r=S(n);if(!r)return!1;const s=N(r);if(!s)return!1;const o=r.innerHTML,a=[],i=x(r,s);i.size>0?i.forEach((u,l)=>{a.push(...L(l,u,t))}):w(r,s).forEach(l=>{if(l instanceof HTMLUListElement||l instanceof HTMLOListElement){const h=new Set(Array.from(l.children).filter(M=>M instanceof HTMLLIElement));a.push(...L(l,h,t));return}if(g.has(l.tagName)){const h=l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...h?O(l,t):I(l,t))}});const c=r.innerHTML;return o===c||a.length===0?!1:(P(r,o,c),k(r),b(a[0]),!0)}const D=()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(e,n)=>e?m(e,n):!1,setHeading1:(e,n)=>m("h1",n),setHeading2:(e,n)=>m("h2",n),setHeading3:(e,n)=>m("h3",n),setParagraph:(e,n)=>m("p",n)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}});exports.HeadingPlugin=D;