@editora/plugins 1.0.8 → 1.0.10

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 (141) hide show
  1. package/README.md +27 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +447 -0
  11. package/dist/approval-workflow.esm.js +1111 -0
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +442 -0
  16. package/dist/blocks-library.esm.js +1384 -0
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +548 -0
  21. package/dist/citations.esm.js +1530 -0
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +626 -0
  31. package/dist/conditional-content.esm.js +1421 -0
  32. package/dist/content-rules.cjs.js +408 -0
  33. package/dist/content-rules.esm.js +1147 -0
  34. package/dist/data-binding.cjs.js +321 -0
  35. package/dist/data-binding.esm.js +953 -0
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +398 -0
  38. package/dist/doc-schema.esm.js +1378 -0
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -0
  49. package/dist/enterprise.esm.js +58 -0
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +124 -93
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +105 -0
  87. package/dist/mentions.esm.js +774 -0
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +67 -51
  92. package/dist/pii-redaction.cjs.js +436 -0
  93. package/dist/pii-redaction.esm.js +1447 -0
  94. package/dist/preview.cjs.js +3 -3
  95. package/dist/preview.esm.js +37 -32
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +20 -17
  98. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  99. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  100. package/dist/slash-commands.cjs.js +90 -0
  101. package/dist/slash-commands.esm.js +788 -0
  102. package/dist/smart-paste.cjs.js +398 -0
  103. package/dist/smart-paste.esm.js +1444 -0
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +69 -61
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +123 -97
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +19 -14
  110. package/dist/style.css +1 -0
  111. package/dist/table.cjs.js +4 -4
  112. package/dist/table.esm.js +225 -191
  113. package/dist/template.cjs.js +11 -11
  114. package/dist/template.esm.js +153 -124
  115. package/dist/text-alignment.cjs.js +1 -1
  116. package/dist/text-alignment.esm.js +27 -21
  117. package/dist/text-color.cjs.js +3 -3
  118. package/dist/text-color.esm.js +87 -70
  119. package/dist/track-changes.cjs.js +77 -0
  120. package/dist/track-changes.esm.js +817 -0
  121. package/dist/translation-workflow.cjs.js +626 -0
  122. package/dist/translation-workflow.esm.js +1794 -0
  123. package/dist/version-diff.cjs.js +362 -0
  124. package/dist/version-diff.esm.js +797 -0
  125. package/index.d.ts +798 -0
  126. package/package.json +114 -9
  127. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  128. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  129. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  130. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  131. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  132. package/dist/documentManager-Jf0RbSks.js +0 -17
  133. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  134. package/dist/index-CvJk4DKa.js +0 -221
  135. package/dist/index-D3CycEFU.mjs +0 -16543
  136. package/dist/index-tqLTHcO6.js +0 -1
  137. package/dist/index.es-CE_A4QSm.js +0 -5
  138. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  139. package/dist/jspdf.es.min-BoS80556.js +0 -77
  140. package/dist/plugins.css +0 -1
  141. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("./purify.es-T2a3nLiC.js");let n=null,d=null,u=null,o=null,m="",g="",v="insert",x=null,s=null,E=null;function N(t,e){if(e===t.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,t.innerHTML)}catch{}}function V(t){if(!t)return null;let e=t.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}return null}const I=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const V=require("./purify.es-a8d731c6.js");let n=null,c=null,f=null,o=null,h="",v="",w="insert",E=null,d=null,b=null;function P(t,e){if(e===t.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,t.innerHTML)}catch{}}function z(t){if(!t)return null;let e=t.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}return null}const _=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
2
2
  <p>{{ Today }}</p>
3
3
  <p>Dear {{ first_name }} {{ last_name }},</p>
4
4
  <p>I hope this letter finds you well. [Your letter content here]</p>
@@ -40,7 +40,7 @@
40
40
  <h3>Q: How do I get started?</h3>
41
41
  <p>A: [Answer here]</p>
42
42
  <h3>Q: What are the requirements?</h3>
43
- <p>A: [Answer here]</p>`}];let b=[...I];const L=()=>b,z=t=>b.filter(e=>e.category===t),C=()=>{const t=new Set(b.map(e=>e.category));return Array.from(t)},P=t=>{const e=t.toLowerCase();return b.filter(r=>r.name.toLowerCase().includes(e)||r.description?.toLowerCase().includes(e)||r.tags?.some(l=>l.toLowerCase().includes(e)))},A=t=>q.default.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]}),B=t=>b.some(e=>e.id===t.id)?(console.warn(`Template with ID ${t.id} already exists`),!1):(b.push(t),!0),F=t=>!!(t.id&&t.name&&t.category&&t.html&&t.html.trim().length>0);function O(t){d=document.createElement("div"),d.className="rte-dialog-overlay",Z(t)&&d.classList.add("rte-ui-theme-dark"),d.addEventListener("click",()=>c()),n=document.createElement("div"),n.className="rte-dialog rte-template-dialog",n.addEventListener("click",r=>r.stopPropagation());const e=C();e.length>0&&!m&&(m=e[0]),y(),d.appendChild(n),document.body.appendChild(d),Q(),X()}function Q(){_(),x=t=>{t.key==="Escape"&&(!d||!n||(t.preventDefault(),t.stopPropagation(),c()))},document.addEventListener("keydown",x,!0)}function _(){x&&(document.removeEventListener("keydown",x,!0),x=null)}const W='[data-theme="dark"], .dark, .editora-theme-dark',R=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},Z=t=>{const e=t||R();return e?!!e.closest(W):!1};function S(){const t=V(u);if(t)return t;if(E?.isConnected)return E;const e=R();return e||document.querySelector(".rte-content, .editora-content")}function y(){if(!n)return;const t=C(),e=M();n.innerHTML=`
43
+ <p>A: [Answer here]</p>`}];let x=[..._];const C=()=>x,F=t=>x.filter(e=>e.category===t),A=()=>{const t=new Set(x.map(e=>e.category));return Array.from(t)},$=t=>{const e=t.toLowerCase();return x.filter(r=>{var a,p;return r.name.toLowerCase().includes(e)||((a=r.description)==null?void 0:a.toLowerCase().includes(e))||((p=r.tags)==null?void 0:p.some(s=>s.toLowerCase().includes(e)))})},S=t=>V.default.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]}),I=t=>x.some(e=>e.id===t.id)?(console.warn(`Template with ID ${t.id} already exists`),!1):(x.push(t),!0),O=t=>!!(t.id&&t.name&&t.category&&t.html&&t.html.trim().length>0);function Q(t){c=document.createElement("div"),c.className="rte-dialog-overlay",G(t)&&c.classList.add("rte-ui-theme-dark"),c.addEventListener("click",()=>u()),n=document.createElement("div"),n.className="rte-dialog rte-template-dialog",n.addEventListener("click",r=>r.stopPropagation());const e=A();e.length>0&&!h&&(h=e[0]),k(),c.appendChild(n),document.body.appendChild(c),W(),X()}function W(){j(),E=t=>{t.key==="Escape"&&(!c||!n||(t.preventDefault(),t.stopPropagation(),u()))},document.addEventListener("keydown",E,!0)}function j(){E&&(document.removeEventListener("keydown",E,!0),E=null)}const Z='[data-theme="dark"], .dark, .editora-theme-dark',M=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode,r=e instanceof HTMLElement?e:e==null?void 0:e.parentElement;return(r==null?void 0:r.closest(".rte-content, .editora-content"))||null},G=t=>{const e=t||M();return e?!!e.closest(Z):!1};function D(){const t=z(f);if(t)return t;if(b!=null&&b.isConnected)return b;const e=M();return e||document.querySelector(".rte-content, .editora-content")}function k(){if(!n)return;const t=A(),e=H();n.innerHTML=`
44
44
  <div class="rte-dialog-header">
45
45
  <h2>Insert Template</h2>
46
46
  <button class="rte-dialog-close" aria-label="Close">✕</button>
@@ -51,7 +51,7 @@
51
51
  <input
52
52
  type="text"
53
53
  placeholder="Search templates..."
54
- value="${g}"
54
+ value="${v}"
55
55
  class="rte-input rte-template-search"
56
56
  aria-label="Search templates"
57
57
  />
@@ -59,7 +59,7 @@
59
59
  <!-- Category Tabs -->
60
60
  <div class="rte-tabs">
61
61
  ${t.map(r=>`
62
- <button class="rte-tab ${m===r?"active":""}" data-category="${r}">
62
+ <button class="rte-tab ${h===r?"active":""}" data-category="${r}">
63
63
  ${r}
64
64
  </button>
65
65
  `).join("")}
@@ -69,7 +69,7 @@
69
69
  <div class="rte-template-list">
70
70
  ${e.length>0?e.map(r=>`
71
71
  <div
72
- class="rte-template-item ${o?.id===r.id?"selected":""}"
72
+ class="rte-template-item ${(o==null?void 0:o.id)===r.id?"selected":""}"
73
73
  data-template-id="${r.id}"
74
74
  >
75
75
  <div class="template-name">${r.name}</div>
@@ -89,11 +89,11 @@
89
89
  <!-- Insert Mode Toggle -->
90
90
  <div class="rte-insert-mode">
91
91
  <label>
92
- <input type="radio" name="insertMode" value="insert" ${v==="insert"?"checked":""} />
92
+ <input type="radio" name="insertMode" value="insert" ${w==="insert"?"checked":""} />
93
93
  Insert at cursor
94
94
  </label>
95
95
  <label>
96
- <input type="radio" name="insertMode" value="replace" ${v==="replace"?"checked":""} />
96
+ <input type="radio" name="insertMode" value="replace" ${w==="replace"?"checked":""} />
97
97
  Replace document
98
98
  </label>
99
99
  </div>
@@ -102,10 +102,10 @@
102
102
  <div class="rte-dialog-footer">
103
103
  <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
104
104
  <button class="rte-button-primary rte-insert-btn" ${o?"":"disabled"}>
105
- ${v==="insert"?"Insert":"Replace"}
105
+ ${w==="insert"?"Insert":"Replace"}
106
106
  </button>
107
107
  </div>
108
- `,K()}function G(){if(!n)return;n.innerHTML=`
108
+ `,B()}function K(){if(!n)return;n.innerHTML=`
109
109
  <div class="rte-dialog-header">
110
110
  <h2>Replace Document?</h2>
111
111
  </div>
@@ -116,7 +116,7 @@
116
116
  <button class="rte-button-secondary rte-cancel-warning-btn">Cancel</button>
117
117
  <button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
118
118
  </div>
119
- `;const t=n.querySelector(".rte-cancel-warning-btn"),e=n.querySelector(".rte-confirm-replace-btn");t?.addEventListener("click",()=>y()),e?.addEventListener("click",()=>Y())}function M(){const t=L();return g.trim()?P(g):m?t.filter(e=>e.category===m):t}function K(){if(!n)return;n.querySelector(".rte-dialog-close")?.addEventListener("click",()=>c()),n.querySelector(".rte-cancel-btn")?.addEventListener("click",()=>c()),n.querySelector(".rte-insert-btn")?.addEventListener("click",()=>k());const l=n.querySelector(".rte-template-search");l?.addEventListener("input",a=>{s!==null&&cancelAnimationFrame(s),g=a.target.value,s=requestAnimationFrame(()=>{s=null,H()})}),l?.addEventListener("keydown",a=>{a.key==="Enter"&&o?k():a.key==="Escape"&&c()}),n.querySelector(".rte-tabs")?.addEventListener("click",a=>{const f=a.target.closest(".rte-tab");if(!f)return;const h=f.getAttribute("data-category");h&&(m=h,g="",s!==null&&(cancelAnimationFrame(s),s=null),H())});const T=n.querySelector(".rte-template-list"),p=a=>{const f=a.target.closest(".rte-template-item");if(!f)return null;const h=f.getAttribute("data-template-id");return h&&L().find(j=>j.id===h)||null};T?.addEventListener("click",a=>{const i=p(a);i&&(o=i,y())}),T?.addEventListener("dblclick",a=>{const i=p(a);i&&(o=i,k())}),n.querySelector(".rte-insert-mode")?.addEventListener("change",a=>{const i=a.target;!i||i.name!=="insertMode"||(v=i.value,y())})}function H(){const t=M();t.length>0?(!o||!t.find(e=>e.id===o.id))&&(o=t[0]):o=null,y()}function k(){if(o)if(v==="replace"){if(S()?.innerHTML?.trim()){G();return}$(o),c()}else J(o),c()}function Y(){o&&($(o),c())}function J(t){const e=window.getSelection();if(!e)return;const r=S();if(!r)return;if(u)e.removeAllRanges(),e.addRange(u);else{const w=document.createRange();w.selectNodeContents(r),w.collapse(!1),e.removeAllRanges(),e.addRange(w)}if(e.rangeCount===0)return;const l=e.getRangeAt(0),D=r?.innerHTML??"",T=document.createRange().createContextualFragment(A(t.html));l.deleteContents(),l.insertNode(T);const p=document.createRange();p.setStartAfter(l.endContainer),p.collapse(!0),e.removeAllRanges(),e.addRange(p),r&&(N(r,D),r.dispatchEvent(new Event("input",{bubbles:!0})))}function $(t){const e=S();if(e){const r=e.innerHTML;e.innerHTML=A(t.html),N(e,r),e.dispatchEvent(new Event("input",{bubbles:!0}))}}function c(){_(),s!==null&&(cancelAnimationFrame(s),s=null),d&&(d.remove(),d=null),n=null,u=null,g="",E=null}function U(t){const e=window.getSelection();e&&e.rangeCount>0?u=e.getRangeAt(0).cloneRange():u=null;const r=M();r.length>0&&!o&&(o=r[0]);const l=t?.contentElement instanceof HTMLElement?t.contentElement:R();E=l||null,O(l)}function X(){if(typeof document>"u")return;const t="template-plugin-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
119
+ `;const t=n.querySelector(".rte-cancel-warning-btn"),e=n.querySelector(".rte-confirm-replace-btn");t==null||t.addEventListener("click",()=>k()),e==null||e.addEventListener("click",()=>Y())}function H(){const t=C();return v.trim()?$(v):h?t.filter(e=>e.category===h):t}function B(){if(!n)return;const t=n.querySelector(".rte-dialog-close");t==null||t.addEventListener("click",()=>u());const e=n.querySelector(".rte-cancel-btn");e==null||e.addEventListener("click",()=>u());const r=n.querySelector(".rte-insert-btn");r==null||r.addEventListener("click",()=>L());const a=n.querySelector(".rte-template-search");a==null||a.addEventListener("input",l=>{d!==null&&cancelAnimationFrame(d),v=l.target.value,d=requestAnimationFrame(()=>{d=null,R()})}),a==null||a.addEventListener("keydown",l=>{l.key==="Enter"&&o?L():l.key==="Escape"&&u()});const p=n.querySelector(".rte-tabs");p==null||p.addEventListener("click",l=>{const y=l.target.closest(".rte-tab");if(!y)return;const T=y.getAttribute("data-category");T&&(h=T,v="",d!==null&&(cancelAnimationFrame(d),d=null),R())});const s=n.querySelector(".rte-template-list"),g=l=>{const y=l.target.closest(".rte-template-item");if(!y)return null;const T=y.getAttribute("data-template-id");return T&&C().find(N=>N.id===T)||null};s==null||s.addEventListener("click",l=>{const i=g(l);i&&(o=i,k())}),s==null||s.addEventListener("dblclick",l=>{const i=g(l);i&&(o=i,L())});const m=n.querySelector(".rte-insert-mode");m==null||m.addEventListener("change",l=>{const i=l.target;!i||i.name!=="insertMode"||(w=i.value,k())})}function R(){const t=H();t.length>0?(!o||!t.find(e=>e.id===o.id))&&(o=t[0]):o=null,k()}function L(){var t;if(o)if(w==="replace"){const e=D();if((t=e==null?void 0:e.innerHTML)!=null&&t.trim()){K();return}q(o),u()}else J(o),u()}function Y(){o&&(q(o),u())}function J(t){const e=window.getSelection();if(!e)return;const r=D();if(!r)return;if(f)e.removeAllRanges(),e.addRange(f);else{const m=document.createRange();m.selectNodeContents(r),m.collapse(!1),e.removeAllRanges(),e.addRange(m)}if(e.rangeCount===0)return;const a=e.getRangeAt(0),p=(r==null?void 0:r.innerHTML)??"",s=document.createRange().createContextualFragment(S(t.html));a.deleteContents(),a.insertNode(s);const g=document.createRange();g.setStartAfter(a.endContainer),g.collapse(!0),e.removeAllRanges(),e.addRange(g),r&&(P(r,p),r.dispatchEvent(new Event("input",{bubbles:!0})))}function q(t){const e=D();if(e){const r=e.innerHTML;e.innerHTML=S(t.html),P(e,r),e.dispatchEvent(new Event("input",{bubbles:!0}))}}function u(){j(),d!==null&&(cancelAnimationFrame(d),d=null),c&&(c.remove(),c=null),n=null,f=null,v="",b=null}function U(t){const e=window.getSelection();e&&e.rangeCount>0?f=e.getRangeAt(0).cloneRange():f=null;const r=H();r.length>0&&!o&&(o=r[0]);const a=(t==null?void 0:t.contentElement)instanceof HTMLElement?t.contentElement:M();b=a||null,Q(a)}function X(){if(typeof document>"u")return;const t="template-plugin-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
120
120
  .rte-dialog-overlay {
121
121
  --rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);
122
122
  --rte-tmpl-dialog-bg: #fff;
@@ -353,4 +353,4 @@
353
353
  .rte-button-secondary:hover {
354
354
  background-color: var(--rte-tmpl-subtle-hover);
355
355
  }
356
- `,document.head.appendChild(e)}const ee=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:(t,e)=>(U(e),!0)},keymap:{}});exports.PREDEFINED_TEMPLATES=I;exports.TemplatePlugin=ee;exports.addCustomTemplate=B;exports.getAllTemplates=L;exports.getTemplateCategories=C;exports.getTemplatesByCategory=z;exports.sanitizeTemplate=A;exports.searchTemplates=P;exports.validateTemplate=F;
356
+ `,document.head.appendChild(e)}const ee=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:(t,e)=>(U(e),!0)},keymap:{}});exports.PREDEFINED_TEMPLATES=_;exports.TemplatePlugin=ee;exports.addCustomTemplate=I;exports.getAllTemplates=C;exports.getTemplateCategories=A;exports.getTemplatesByCategory=F;exports.sanitizeTemplate=S;exports.searchTemplates=$;exports.validateTemplate=O;
@@ -1,7 +1,8 @@
1
- import j from "./purify.es-DHhaBdbu.mjs";
2
- let n = null, d = null, u = null, o = null, m = "", g = "", v = "insert", x = null, s = null, E = null;
3
- function M(t, e) {
4
- if (e === t.innerHTML) return;
1
+ import N from "./purify.es-35a15df8.mjs";
2
+ let n = null, c = null, f = null, o = null, h = "", v = "", T = "insert", k = null, d = null, b = null;
3
+ function H(t, e) {
4
+ if (e === t.innerHTML)
5
+ return;
5
6
  const r = window.execEditorCommand || window.executeEditorCommand;
6
7
  if (typeof r == "function")
7
8
  try {
@@ -9,8 +10,9 @@ function M(t, e) {
9
10
  } catch {
10
11
  }
11
12
  }
12
- function q(t) {
13
- if (!t) return null;
13
+ function z(t) {
14
+ if (!t)
15
+ return null;
14
16
  let e = t.startContainer;
15
17
  for (; e && e !== document.body; ) {
16
18
  if (e.nodeType === Node.ELEMENT_NODE) {
@@ -22,7 +24,7 @@ function q(t) {
22
24
  }
23
25
  return null;
24
26
  }
25
- const z = [
27
+ const F = [
26
28
  {
27
29
  id: "formal-letter",
28
30
  name: "Formal Letter",
@@ -94,53 +96,60 @@ const z = [
94
96
  <p>A: [Answer here]</p>`
95
97
  }
96
98
  ];
97
- let b = [...z];
98
- const H = () => b, U = (t) => b.filter((e) => e.category === t), D = () => {
99
- const t = new Set(b.map((e) => e.category));
99
+ let x = [...F];
100
+ const D = () => x, U = (t) => x.filter((e) => e.category === t), R = () => {
101
+ const t = new Set(x.map((e) => e.category));
100
102
  return Array.from(t);
101
- }, B = (t) => {
103
+ }, P = (t) => {
102
104
  const e = t.toLowerCase();
103
- return b.filter(
104
- (r) => r.name.toLowerCase().includes(e) || r.description?.toLowerCase().includes(e) || r.tags?.some((l) => l.toLowerCase().includes(e))
105
+ return x.filter(
106
+ (r) => {
107
+ var a, p;
108
+ return r.name.toLowerCase().includes(e) || ((a = r.description) == null ? void 0 : a.toLowerCase().includes(e)) || ((p = r.tags) == null ? void 0 : p.some((s) => s.toLowerCase().includes(e)));
109
+ }
105
110
  );
106
- }, N = (t) => j.sanitize(t, {
111
+ }, $ = (t) => N.sanitize(t, {
107
112
  ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
108
113
  ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
109
- }), X = (t) => b.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (b.push(t), !0), ee = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
110
- function F(t) {
111
- d = document.createElement("div"), d.className = "rte-dialog-overlay", Q(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => c()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
112
- const e = D();
113
- e.length > 0 && !m && (m = e[0]), y(), d.appendChild(n), document.body.appendChild(d), P(), Y();
114
+ }), X = (t) => x.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (x.push(t), !0), ee = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
115
+ function _(t) {
116
+ c = document.createElement("div"), c.className = "rte-dialog-overlay", O(t) && c.classList.add("rte-ui-theme-dark"), c.addEventListener("click", () => u()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
117
+ const e = R();
118
+ e.length > 0 && !h && (h = e[0]), E(), c.appendChild(n), document.body.appendChild(c), I(), Y();
114
119
  }
115
- function P() {
116
- $(), x = (t) => {
117
- t.key === "Escape" && (!d || !n || (t.preventDefault(), t.stopPropagation(), c()));
118
- }, document.addEventListener("keydown", x, !0);
120
+ function I() {
121
+ V(), k = (t) => {
122
+ t.key === "Escape" && (!c || !n || (t.preventDefault(), t.stopPropagation(), u()));
123
+ }, document.addEventListener("keydown", k, !0);
119
124
  }
120
- function $() {
121
- x && (document.removeEventListener("keydown", x, !0), x = null);
125
+ function V() {
126
+ k && (document.removeEventListener("keydown", k, !0), k = null);
122
127
  }
123
- const _ = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
128
+ const Q = '[data-theme="dark"], .dark, .editora-theme-dark', C = () => {
124
129
  const t = window.getSelection();
125
- if (!t || t.rangeCount === 0) return null;
126
- const e = t.anchorNode;
127
- return (e instanceof HTMLElement ? e : e?.parentElement)?.closest(
130
+ if (!t || t.rangeCount === 0)
131
+ return null;
132
+ const e = t.anchorNode, r = e instanceof HTMLElement ? e : e == null ? void 0 : e.parentElement;
133
+ return (r == null ? void 0 : r.closest(
128
134
  ".rte-content, .editora-content"
129
- ) || null;
130
- }, Q = (t) => {
131
- const e = t || L();
132
- return e ? !!e.closest(_) : !1;
135
+ )) || null;
136
+ }, O = (t) => {
137
+ const e = t || C();
138
+ return e ? !!e.closest(Q) : !1;
133
139
  };
134
- function C() {
135
- const t = q(u);
136
- if (t) return t;
137
- if (E?.isConnected) return E;
138
- const e = L();
140
+ function A() {
141
+ const t = z(f);
142
+ if (t)
143
+ return t;
144
+ if (b != null && b.isConnected)
145
+ return b;
146
+ const e = C();
139
147
  return e || document.querySelector(".rte-content, .editora-content");
140
148
  }
141
- function y() {
142
- if (!n) return;
143
- const t = D(), e = A();
149
+ function E() {
150
+ if (!n)
151
+ return;
152
+ const t = R(), e = S();
144
153
  n.innerHTML = `
145
154
  <div class="rte-dialog-header">
146
155
  <h2>Insert Template</h2>
@@ -152,7 +161,7 @@ function y() {
152
161
  <input
153
162
  type="text"
154
163
  placeholder="Search templates..."
155
- value="${g}"
164
+ value="${v}"
156
165
  class="rte-input rte-template-search"
157
166
  aria-label="Search templates"
158
167
  />
@@ -160,7 +169,7 @@ function y() {
160
169
  <!-- Category Tabs -->
161
170
  <div class="rte-tabs">
162
171
  ${t.map((r) => `
163
- <button class="rte-tab ${m === r ? "active" : ""}" data-category="${r}">
172
+ <button class="rte-tab ${h === r ? "active" : ""}" data-category="${r}">
164
173
  ${r}
165
174
  </button>
166
175
  `).join("")}
@@ -170,7 +179,7 @@ function y() {
170
179
  <div class="rte-template-list">
171
180
  ${e.length > 0 ? e.map((r) => `
172
181
  <div
173
- class="rte-template-item ${o?.id === r.id ? "selected" : ""}"
182
+ class="rte-template-item ${(o == null ? void 0 : o.id) === r.id ? "selected" : ""}"
174
183
  data-template-id="${r.id}"
175
184
  >
176
185
  <div class="template-name">${r.name}</div>
@@ -190,11 +199,11 @@ function y() {
190
199
  <!-- Insert Mode Toggle -->
191
200
  <div class="rte-insert-mode">
192
201
  <label>
193
- <input type="radio" name="insertMode" value="insert" ${v === "insert" ? "checked" : ""} />
202
+ <input type="radio" name="insertMode" value="insert" ${T === "insert" ? "checked" : ""} />
194
203
  Insert at cursor
195
204
  </label>
196
205
  <label>
197
- <input type="radio" name="insertMode" value="replace" ${v === "replace" ? "checked" : ""} />
206
+ <input type="radio" name="insertMode" value="replace" ${T === "replace" ? "checked" : ""} />
198
207
  Replace document
199
208
  </label>
200
209
  </div>
@@ -203,13 +212,14 @@ function y() {
203
212
  <div class="rte-dialog-footer">
204
213
  <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
205
214
  <button class="rte-button-primary rte-insert-btn" ${o ? "" : "disabled"}>
206
- ${v === "insert" ? "Insert" : "Replace"}
215
+ ${T === "insert" ? "Insert" : "Replace"}
207
216
  </button>
208
217
  </div>
209
- `, W();
218
+ `, Z();
210
219
  }
211
- function O() {
212
- if (!n) return;
220
+ function W() {
221
+ if (!n)
222
+ return;
213
223
  n.innerHTML = `
214
224
  <div class="rte-dialog-header">
215
225
  <h2>Replace Document?</h2>
@@ -223,102 +233,121 @@ function O() {
223
233
  </div>
224
234
  `;
225
235
  const t = n.querySelector(".rte-cancel-warning-btn"), e = n.querySelector(".rte-confirm-replace-btn");
226
- t?.addEventListener("click", () => y()), e?.addEventListener("click", () => Z());
236
+ t == null || t.addEventListener("click", () => E()), e == null || e.addEventListener("click", () => G());
227
237
  }
228
- function A() {
229
- const t = H();
230
- return g.trim() ? B(g) : m ? t.filter((e) => e.category === m) : t;
238
+ function S() {
239
+ const t = D();
240
+ return v.trim() ? P(v) : h ? t.filter((e) => e.category === h) : t;
231
241
  }
232
- function W() {
233
- if (!n) return;
234
- n.querySelector(".rte-dialog-close")?.addEventListener("click", () => c()), n.querySelector(".rte-cancel-btn")?.addEventListener("click", () => c()), n.querySelector(".rte-insert-btn")?.addEventListener("click", () => k());
235
- const l = n.querySelector(".rte-template-search");
236
- l?.addEventListener("input", (a) => {
237
- s !== null && cancelAnimationFrame(s), g = a.target.value, s = requestAnimationFrame(() => {
238
- s = null, S();
242
+ function Z() {
243
+ if (!n)
244
+ return;
245
+ const t = n.querySelector(".rte-dialog-close");
246
+ t == null || t.addEventListener("click", () => u());
247
+ const e = n.querySelector(".rte-cancel-btn");
248
+ e == null || e.addEventListener("click", () => u());
249
+ const r = n.querySelector(".rte-insert-btn");
250
+ r == null || r.addEventListener("click", () => L());
251
+ const a = n.querySelector(".rte-template-search");
252
+ a == null || a.addEventListener("input", (l) => {
253
+ d !== null && cancelAnimationFrame(d), v = l.target.value, d = requestAnimationFrame(() => {
254
+ d = null, M();
239
255
  });
240
- }), l?.addEventListener("keydown", (a) => {
241
- a.key === "Enter" && o ? k() : a.key === "Escape" && c();
242
- }), n.querySelector(".rte-tabs")?.addEventListener("click", (a) => {
243
- const f = a.target.closest(".rte-tab");
244
- if (!f) return;
245
- const h = f.getAttribute("data-category");
246
- h && (m = h, g = "", s !== null && (cancelAnimationFrame(s), s = null), S());
256
+ }), a == null || a.addEventListener("keydown", (l) => {
257
+ l.key === "Enter" && o ? L() : l.key === "Escape" && u();
258
+ });
259
+ const p = n.querySelector(".rte-tabs");
260
+ p == null || p.addEventListener("click", (l) => {
261
+ const y = l.target.closest(".rte-tab");
262
+ if (!y)
263
+ return;
264
+ const w = y.getAttribute("data-category");
265
+ w && (h = w, v = "", d !== null && (cancelAnimationFrame(d), d = null), M());
247
266
  });
248
- const w = n.querySelector(".rte-template-list"), p = (a) => {
249
- const f = a.target.closest(".rte-template-item");
250
- if (!f) return null;
251
- const h = f.getAttribute("data-template-id");
252
- return h && H().find((V) => V.id === h) || null;
267
+ const s = n.querySelector(".rte-template-list"), g = (l) => {
268
+ const y = l.target.closest(".rte-template-item");
269
+ if (!y)
270
+ return null;
271
+ const w = y.getAttribute("data-template-id");
272
+ return w && D().find((q) => q.id === w) || null;
253
273
  };
254
- w?.addEventListener("click", (a) => {
255
- const i = p(a);
256
- i && (o = i, y());
257
- }), w?.addEventListener("dblclick", (a) => {
258
- const i = p(a);
259
- i && (o = i, k());
260
- }), n.querySelector(".rte-insert-mode")?.addEventListener("change", (a) => {
261
- const i = a.target;
262
- !i || i.name !== "insertMode" || (v = i.value, y());
274
+ s == null || s.addEventListener("click", (l) => {
275
+ const i = g(l);
276
+ i && (o = i, E());
277
+ }), s == null || s.addEventListener("dblclick", (l) => {
278
+ const i = g(l);
279
+ i && (o = i, L());
280
+ });
281
+ const m = n.querySelector(".rte-insert-mode");
282
+ m == null || m.addEventListener("change", (l) => {
283
+ const i = l.target;
284
+ !i || i.name !== "insertMode" || (T = i.value, E());
263
285
  });
264
286
  }
265
- function S() {
266
- const t = A();
267
- t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, y();
287
+ function M() {
288
+ const t = S();
289
+ t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, E();
268
290
  }
269
- function k() {
291
+ function L() {
292
+ var t;
270
293
  if (o)
271
- if (v === "replace") {
272
- if (C()?.innerHTML?.trim()) {
273
- O();
294
+ if (T === "replace") {
295
+ const e = A();
296
+ if ((t = e == null ? void 0 : e.innerHTML) != null && t.trim()) {
297
+ W();
274
298
  return;
275
299
  }
276
- I(o), c();
300
+ j(o), u();
277
301
  } else
278
- G(o), c();
302
+ K(o), u();
279
303
  }
280
- function Z() {
281
- o && (I(o), c());
304
+ function G() {
305
+ o && (j(o), u());
282
306
  }
283
- function G(t) {
307
+ function K(t) {
284
308
  const e = window.getSelection();
285
- if (!e) return;
286
- const r = C();
287
- if (!r) return;
288
- if (u)
289
- e.removeAllRanges(), e.addRange(u);
309
+ if (!e)
310
+ return;
311
+ const r = A();
312
+ if (!r)
313
+ return;
314
+ if (f)
315
+ e.removeAllRanges(), e.addRange(f);
290
316
  else {
291
- const T = document.createRange();
292
- T.selectNodeContents(r), T.collapse(!1), e.removeAllRanges(), e.addRange(T);
317
+ const m = document.createRange();
318
+ m.selectNodeContents(r), m.collapse(!1), e.removeAllRanges(), e.addRange(m);
293
319
  }
294
- if (e.rangeCount === 0) return;
295
- const l = e.getRangeAt(0), R = r?.innerHTML ?? "", w = document.createRange().createContextualFragment(N(t.html));
296
- l.deleteContents(), l.insertNode(w);
297
- const p = document.createRange();
298
- p.setStartAfter(l.endContainer), p.collapse(!0), e.removeAllRanges(), e.addRange(p), r && (M(r, R), r.dispatchEvent(new Event("input", { bubbles: !0 })));
320
+ if (e.rangeCount === 0)
321
+ return;
322
+ const a = e.getRangeAt(0), p = (r == null ? void 0 : r.innerHTML) ?? "", s = document.createRange().createContextualFragment($(t.html));
323
+ a.deleteContents(), a.insertNode(s);
324
+ const g = document.createRange();
325
+ g.setStartAfter(a.endContainer), g.collapse(!0), e.removeAllRanges(), e.addRange(g), r && (H(r, p), r.dispatchEvent(new Event("input", { bubbles: !0 })));
299
326
  }
300
- function I(t) {
301
- const e = C();
327
+ function j(t) {
328
+ const e = A();
302
329
  if (e) {
303
330
  const r = e.innerHTML;
304
- e.innerHTML = N(t.html), M(e, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
331
+ e.innerHTML = $(t.html), H(e, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
305
332
  }
306
333
  }
307
- function c() {
308
- $(), s !== null && (cancelAnimationFrame(s), s = null), d && (d.remove(), d = null), n = null, u = null, g = "", E = null;
334
+ function u() {
335
+ V(), d !== null && (cancelAnimationFrame(d), d = null), c && (c.remove(), c = null), n = null, f = null, v = "", b = null;
309
336
  }
310
- function K(t) {
337
+ function B(t) {
311
338
  const e = window.getSelection();
312
- e && e.rangeCount > 0 ? u = e.getRangeAt(0).cloneRange() : u = null;
313
- const r = A();
339
+ e && e.rangeCount > 0 ? f = e.getRangeAt(0).cloneRange() : f = null;
340
+ const r = S();
314
341
  r.length > 0 && !o && (o = r[0]);
315
- const l = t?.contentElement instanceof HTMLElement ? t.contentElement : L();
316
- E = l || null, F(l);
342
+ const a = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : C();
343
+ b = a || null, _(a);
317
344
  }
318
345
  function Y() {
319
- if (typeof document > "u") return;
346
+ if (typeof document > "u")
347
+ return;
320
348
  const t = "template-plugin-dialog-styles";
321
- if (document.getElementById(t)) return;
349
+ if (document.getElementById(t))
350
+ return;
322
351
  const e = document.createElement("style");
323
352
  e.id = t, e.textContent = `
324
353
  .rte-dialog-overlay {
@@ -569,18 +598,18 @@ const te = () => ({
569
598
  }
570
599
  ],
571
600
  commands: {
572
- insertTemplate: (t, e) => (K(e), !0)
601
+ insertTemplate: (t, e) => (B(e), !0)
573
602
  },
574
603
  keymap: {}
575
604
  });
576
605
  export {
577
- z as PREDEFINED_TEMPLATES,
606
+ F as PREDEFINED_TEMPLATES,
578
607
  te as TemplatePlugin,
579
608
  X as addCustomTemplate,
580
- H as getAllTemplates,
581
- D as getTemplateCategories,
609
+ D as getAllTemplates,
610
+ R as getTemplateCategories,
582
611
  U as getTemplatesByCategory,
583
- N as sanitizeTemplate,
584
- B as searchTemplates,
612
+ $ as sanitizeTemplate,
613
+ P as searchTemplates,
585
614
  ee as validateTemplate
586
615
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TD","TH"];function d(n){let t=n;if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(a.includes(e.tagName))return e}for(;t;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(a.includes(e.tagName))return e;if(e.hasAttribute("contenteditable"))return null}t=t.parentNode}return null}function g(n){const t=[],e=d(n.startContainer),i=d(n.endContainer);if(!e&&!i)return t;if(n.collapsed)return e&&t.push(e),t;if(e===i)e&&t.push(e);else{let o=e;const s=new Set;for(e&&(t.push(e),s.add(e));o&&o!==i&&!s.has(i);){let r=o.nextElementSibling;for(;r;){if(a.includes(r.tagName)){o=r,s.has(o)||(t.push(o),s.add(o));break}r=r.nextElementSibling}if(!r)break}i&&!t.includes(i)&&t.push(i)}return t}function h(n){const t=n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement;return t?t.closest(".rte-content, .editora-content")||t.closest('[contenteditable="true"]'):null}function f(n,t){if(!n||t===n.innerHTML)return;const e=window.execEditorCommand||window.executeEditorCommand;if(typeof e=="function")try{e("recordDomTransaction",n,t,n.innerHTML)}catch{}}const E=n=>{if(!n||!["left","center","right","justify"].includes(n))return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const i=e.getRangeAt(0).cloneRange(),o=h(i),s=o?.innerHTML||"",r=g(i);if(r.length>0)r.forEach(l=>{l&&(l.style.textAlign=n)}),e.removeAllRanges(),e.addRange(i),f(o,s),o&&o.dispatchEvent(new Event("input",{bubbles:!0}));else try{const l=document.createElement("div");l.style.textAlign=n;const m=i.extractContents();l.appendChild(m),i.insertNode(l);const u=document.createRange();u.selectNodeContents(l),e.removeAllRanges(),e.addRange(u);const c=l.closest(".rte-content, .editora-content")||l.closest('[contenteditable="true"]');f(c||o,s),(c||o)&&(c||o)?.dispatchEvent(new Event("input",{bubbles:!0}))}catch(l){return console.error("Failed to wrap content for alignment:",l),!1}return!0},b=()=>({name:"textAlignment",toolbar:[{label:"Text Alignment",command:"setTextAlignment",type:"inline-menu",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"},{label:"Justify",value:"justify"}],icon:'<svg width="24" height="24" focusable="false"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"></path></svg>'}],commands:{setTextAlignment:E},keymap:{}});exports.TextAlignmentPlugin=b;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TD","TH"];function f(n){let t=n;if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(a.includes(e.tagName))return e}for(;t;){if(t.nodeType===Node.ELEMENT_NODE){const e=t;if(a.includes(e.tagName))return e;if(e.hasAttribute("contenteditable"))return null}t=t.parentNode}return null}function h(n){const t=[],e=f(n.startContainer),i=f(n.endContainer);if(!e&&!i)return t;if(n.collapsed)return e&&t.push(e),t;if(e===i)e&&t.push(e);else{let o=e;const s=new Set;for(e&&(t.push(e),s.add(e));o&&o!==i&&!s.has(i);){let r=o.nextElementSibling;for(;r;){if(a.includes(r.tagName)){o=r,s.has(o)||(t.push(o),s.add(o));break}r=r.nextElementSibling}if(!r)break}i&&!t.includes(i)&&t.push(i)}return t}function E(n){const t=n.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?n.commonAncestorContainer:n.commonAncestorContainer.parentElement;return t?t.closest(".rte-content, .editora-content")||t.closest('[contenteditable="true"]'):null}function m(n,t){if(!n||t===n.innerHTML)return;const e=window.execEditorCommand||window.executeEditorCommand;if(typeof e=="function")try{e("recordDomTransaction",n,t,n.innerHTML)}catch{}}const b=n=>{var u;if(!n||!["left","center","right","justify"].includes(n))return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const i=e.getRangeAt(0).cloneRange(),o=E(i),s=(o==null?void 0:o.innerHTML)||"",r=h(i);if(r.length>0)r.forEach(l=>{l&&(l.style.textAlign=n)}),e.removeAllRanges(),e.addRange(i),m(o,s),o&&o.dispatchEvent(new Event("input",{bubbles:!0}));else try{const l=document.createElement("div");l.style.textAlign=n;const g=i.extractContents();l.appendChild(g),i.insertNode(l);const d=document.createRange();d.selectNodeContents(l),e.removeAllRanges(),e.addRange(d);const c=l.closest(".rte-content, .editora-content")||l.closest('[contenteditable="true"]');m(c||o,s),(c||o)&&((u=c||o)==null||u.dispatchEvent(new Event("input",{bubbles:!0})))}catch(l){return console.error("Failed to wrap content for alignment:",l),!1}return!0},p=()=>({name:"textAlignment",toolbar:[{label:"Text Alignment",command:"setTextAlignment",type:"inline-menu",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"},{label:"Justify",value:"justify"}],icon:'<svg width="24" height="24" focusable="false"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"></path></svg>'}],commands:{setTextAlignment:b},keymap:{}});exports.TextAlignmentPlugin=p;