@editora/plugins 1.0.10 → 1.0.11

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 (138) hide show
  1. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  2. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  3. package/dist/a11y-checker.cjs.js +12 -12
  4. package/dist/a11y-checker.esm.js +80 -98
  5. package/dist/anchor.cjs.js +12 -12
  6. package/dist/anchor.esm.js +115 -128
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +40 -40
  10. package/dist/approval-workflow.esm.js +208 -249
  11. package/dist/background-color.cjs.js +2 -2
  12. package/dist/background-color.esm.js +55 -68
  13. package/dist/blockquote.esm.js +1 -2
  14. package/dist/blocks-library.cjs.js +45 -45
  15. package/dist/blocks-library.esm.js +178 -245
  16. package/dist/capitalization.esm.js +1 -2
  17. package/dist/checklist.cjs.js +1 -1
  18. package/dist/checklist.esm.js +58 -82
  19. package/dist/citations.cjs.js +37 -37
  20. package/dist/citations.esm.js +439 -512
  21. package/dist/clear-formatting.cjs.js +1 -1
  22. package/dist/clear-formatting.esm.js +27 -33
  23. package/dist/code-sample.cjs.js +14 -14
  24. package/dist/code-sample.esm.js +82 -93
  25. package/dist/code.cjs.js +32 -32
  26. package/dist/code.esm.js +501 -506
  27. package/dist/comments.cjs.js +6 -6
  28. package/dist/comments.esm.js +116 -158
  29. package/dist/conditional-content.cjs.js +90 -90
  30. package/dist/conditional-content.esm.js +371 -432
  31. package/dist/content-rules.cjs.js +7 -7
  32. package/dist/content-rules.esm.js +105 -159
  33. package/dist/data-binding.cjs.js +46 -46
  34. package/dist/data-binding.esm.js +328 -368
  35. package/dist/direction.esm.js +9 -18
  36. package/dist/doc-schema.cjs.js +29 -29
  37. package/dist/doc-schema.esm.js +240 -308
  38. package/dist/document-manager.cjs.js +1 -1
  39. package/dist/document-manager.esm.js +4 -5
  40. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  41. package/dist/documentManager-Jf0RbSks.js +17 -0
  42. package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
  43. package/dist/embed-iframe.cjs.js +4 -4
  44. package/dist/embed-iframe.esm.js +73 -81
  45. package/dist/emojis.cjs.js +8 -8
  46. package/dist/emojis.esm.js +65 -77
  47. package/dist/enterprise.cjs.js +1 -1
  48. package/dist/enterprise.esm.js +54 -56
  49. package/dist/font-family.cjs.js +1 -1
  50. package/dist/font-family.esm.js +39 -47
  51. package/dist/font-size.cjs.js +1 -1
  52. package/dist/font-size.esm.js +37 -53
  53. package/dist/footnote.cjs.js +2 -2
  54. package/dist/footnote.esm.js +76 -117
  55. package/dist/history.cjs.js +1 -1
  56. package/dist/history.esm.js +70 -92
  57. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  58. package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
  59. package/dist/indent.cjs.js +1 -1
  60. package/dist/indent.esm.js +12 -24
  61. package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
  62. package/dist/index-CvJk4DKa.js +221 -0
  63. package/dist/index-D3CycEFU.mjs +16543 -0
  64. package/dist/index-tqLTHcO6.js +1 -0
  65. package/dist/index.cjs.js +1 -1
  66. package/dist/index.es-CE_A4QSm.js +5 -0
  67. package/dist/index.es-DQ78mYYo.mjs +6665 -0
  68. package/dist/index.esm.js +125 -128
  69. package/dist/italic.cjs.js +1 -1
  70. package/dist/italic.esm.js +8 -9
  71. package/dist/jspdf.es.min-BoS80556.js +77 -0
  72. package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
  73. package/dist/line-height.cjs.js +1 -1
  74. package/dist/line-height.esm.js +11 -24
  75. package/dist/link.cjs.js +5 -5
  76. package/dist/link.esm.js +24 -30
  77. package/dist/list.cjs.js +1 -1
  78. package/dist/list.esm.js +20 -25
  79. package/dist/lite.cjs.js +1 -1
  80. package/dist/lite.esm.js +59 -61
  81. package/dist/math.cjs.js +21 -21
  82. package/dist/math.esm.js +139 -146
  83. package/dist/media-manager.cjs.js +31 -31
  84. package/dist/media-manager.esm.js +285 -300
  85. package/dist/mentions.cjs.js +9 -9
  86. package/dist/mentions.esm.js +238 -286
  87. package/dist/merge-tag.cjs.js +2 -2
  88. package/dist/merge-tag.esm.js +177 -216
  89. package/dist/page-break.cjs.js +2 -2
  90. package/dist/page-break.esm.js +33 -49
  91. package/dist/pii-redaction.cjs.js +19 -19
  92. package/dist/pii-redaction.esm.js +393 -463
  93. package/dist/plugins.css +1 -0
  94. package/dist/preview.esm.js +5 -10
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +17 -20
  97. package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
  98. package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
  99. package/dist/slash-commands.cjs.js +2 -2
  100. package/dist/slash-commands.esm.js +39 -75
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +280 -336
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +61 -69
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +97 -123
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +14 -19
  109. package/dist/table.cjs.js +4 -4
  110. package/dist/table.esm.js +191 -225
  111. package/dist/template.cjs.js +21 -20
  112. package/dist/template.esm.js +715 -196
  113. package/dist/text-alignment.cjs.js +1 -1
  114. package/dist/text-alignment.esm.js +21 -27
  115. package/dist/text-color.cjs.js +3 -3
  116. package/dist/text-color.esm.js +70 -87
  117. package/dist/track-changes.cjs.js +2 -2
  118. package/dist/track-changes.esm.js +100 -162
  119. package/dist/translation-workflow.cjs.js +74 -74
  120. package/dist/translation-workflow.esm.js +602 -678
  121. package/dist/version-diff.cjs.js +14 -14
  122. package/dist/version-diff.esm.js +128 -157
  123. package/package.json +1 -1
  124. package/dist/_commonjsHelpers-6763f629.js +0 -1
  125. package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
  126. package/dist/anchoredPopover-33f1358d.mjs +0 -109
  127. package/dist/anchoredPopover-8151d535.js +0 -1
  128. package/dist/documentManager-25b6203c.mjs +0 -9122
  129. package/dist/documentManager-b69e7054.js +0 -17
  130. package/dist/html2canvas.esm-09133e29.js +0 -22
  131. package/dist/index-656d224b.js +0 -231
  132. package/dist/index-6a8c48bb.js +0 -1
  133. package/dist/index-d027b7e2.mjs +0 -16859
  134. package/dist/index.es-730f2d98.mjs +0 -5775
  135. package/dist/index.es-dd40173b.js +0 -18
  136. package/dist/jspdf.es.min-90db2c97.js +0 -243
  137. package/dist/style.css +0 -1
  138. /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=new WeakMap;let g=null,S=!1,k=0;const E="User";function v(t){return k+=1,`${t}-${Date.now()}-${k}`}function y(t){if(!t)return null;const e=t instanceof Element?t:t.parentElement;return e?e.closest("[data-editora-editor]")||e.closest(".rte-editor")||e.closest(".editora-editor"):null}function A(t){const e=(t==null?void 0:t.editorElement)||(t==null?void 0:t.contentElement)||null;if(!(e instanceof HTMLElement))return;const r=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);r&&(g=r)}function w(t,e){return e.contains(t.commonAncestorContainer)}function H(){if(typeof window<"u"){const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement){const a=o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?o:null);if(a)return g=a,window.__editoraCommandEditorRoot=null,a}}const t=document.activeElement,e=t?y(t):null;if(e)return e;const r=window.getSelection();if(r&&r.rangeCount>0){const o=y(r.getRangeAt(0).commonAncestorContainer);if(o)return o}return g}function $(t){const e=C.get(t);if(e)return e;const r={root:t,comments:new Map,panelVisible:!1,panelElement:null,expandedComments:new Set,replyTexts:{},savedSelection:null,newCommentText:"",selectionChangeListener:null};return C.set(t,r),r}function f(){const t=H();return t?(g=t,$(t)):null}function R(t){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const r=e.getRangeAt(0);return w(r,t)?r.cloneRange():null}function I(t,e){if(!e.anchorId)return;const r=t.root.querySelector(`#${e.anchorId}`);r&&r.classList.toggle("rte-comment-anchor-resolved",e.resolved)}function h(t,e,r){const o=t.comments.get(e);if(!o||!o.anchorId)return;const a=t.root.querySelector(`#${o.anchorId}`);a&&a.classList.toggle("highlighted",r)}function q(t,e,r){e.onclick=o=>{o.preventDefault(),o.stopPropagation(),g=t.root,t.expandedComments.add(r),b(t,!0),m(t)}}function N(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}function b(t,e){if(t.panelVisible=e,e){Z(),z(t),t.root.setAttribute("data-rte-comments-open","true"),t.panelElement&&(t.panelElement.classList.add("is-open"),t.panelElement.setAttribute("aria-hidden","false")),V(t);return}t.root.removeAttribute("data-rte-comments-open"),M(t),t.panelElement&&(t.panelElement.remove(),t.panelElement=null)}function z(t){if(t.panelElement)return;const e=document.createElement("aside");e.className="rte-comments-panel",e.setAttribute("role","complementary"),e.setAttribute("aria-label","Comments"),e.setAttribute("aria-hidden","true"),window.getComputedStyle(t.root).position==="static"&&(t.root.style.position="relative"),t.root.appendChild(e),t.panelElement=e}function V(t){t.selectionChangeListener||(t.selectionChangeListener=()=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const r=e.getRangeAt(0);w(r,t.root)&&(t.savedSelection=r.cloneRange(),g=t.root)},document.addEventListener("selectionchange",t.selectionChangeListener))}function M(t){t.selectionChangeListener&&(document.removeEventListener("selectionchange",t.selectionChangeListener),t.selectionChangeListener=null)}function B(t){return Array.from(t.comments.values()).sort((e,r)=>r.createdAt.localeCompare(e.createdAt))}function L(t){return new Date(t).toLocaleString()}function D(t,e){const r=t.expandedComments.has(e.id),o=document.createElement("article");o.className=`rte-comment-item${e.resolved?" resolved":""}`,o.innerHTML=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=new WeakMap;let x=null,S=!1,k=0;const E="User";function v(t){return k+=1,`${t}-${Date.now()}-${k}`}function y(t){if(!t)return null;const e=t instanceof Element?t:t.parentElement;return e?e.closest("[data-editora-editor]")||e.closest(".rte-editor")||e.closest(".editora-editor"):null}function A(t){const e=t?.editorElement||t?.contentElement||null;if(!(e instanceof HTMLElement))return;const r=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);r&&(x=r)}function w(t,e){return e.contains(t.commonAncestorContainer)}function B(){if(typeof window<"u"){const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement){const a=o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?o:null);if(a)return x=a,window.__editoraCommandEditorRoot=null,a}}const t=document.activeElement,e=t?y(t):null;if(e)return e;const r=window.getSelection();if(r&&r.rangeCount>0){const o=y(r.getRangeAt(0).commonAncestorContainer);if(o)return o}return x}function H(t){const e=C.get(t);if(e)return e;const r={root:t,comments:new Map,panelVisible:!1,panelElement:null,expandedComments:new Set,replyTexts:{},savedSelection:null,newCommentText:"",selectionChangeListener:null};return C.set(t,r),r}function u(){const t=B();return t?(x=t,H(t)):null}function R(t){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const r=e.getRangeAt(0);return w(r,t)?r.cloneRange():null}function I(t,e){if(!e.anchorId)return;const r=t.root.querySelector(`#${e.anchorId}`);r&&r.classList.toggle("rte-comment-anchor-resolved",e.resolved)}function h(t,e,r){const o=t.comments.get(e);if(!o||!o.anchorId)return;const a=t.root.querySelector(`#${o.anchorId}`);a&&a.classList.toggle("highlighted",r)}function $(t,e,r){e.onclick=o=>{o.preventDefault(),o.stopPropagation(),x=t.root,t.expandedComments.add(r),g(t,!0),m(t)}}function q(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}function g(t,e){if(t.panelVisible=e,e){Z(),N(t),t.root.setAttribute("data-rte-comments-open","true"),t.panelElement&&(t.panelElement.classList.add("is-open"),t.panelElement.setAttribute("aria-hidden","false")),z(t);return}t.root.removeAttribute("data-rte-comments-open"),V(t),t.panelElement&&(t.panelElement.remove(),t.panelElement=null)}function N(t){if(t.panelElement)return;const e=document.createElement("aside");e.className="rte-comments-panel",e.setAttribute("role","complementary"),e.setAttribute("aria-label","Comments"),e.setAttribute("aria-hidden","true"),window.getComputedStyle(t.root).position==="static"&&(t.root.style.position="relative"),t.root.appendChild(e),t.panelElement=e}function z(t){t.selectionChangeListener||(t.selectionChangeListener=()=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const r=e.getRangeAt(0);w(r,t.root)&&(t.savedSelection=r.cloneRange(),x=t.root)},document.addEventListener("selectionchange",t.selectionChangeListener))}function V(t){t.selectionChangeListener&&(document.removeEventListener("selectionchange",t.selectionChangeListener),t.selectionChangeListener=null)}function M(t){return Array.from(t.comments.values()).sort((e,r)=>r.createdAt.localeCompare(e.createdAt))}function L(t){return new Date(t).toLocaleString()}function D(t,e){const r=t.expandedComments.has(e.id),o=document.createElement("article");o.className=`rte-comment-item${e.resolved?" resolved":""}`,o.innerHTML=`
2
2
  <header class="rte-comment-header">
3
3
  <div class="rte-comment-meta">
4
4
  <strong class="rte-comment-author">${e.author}</strong>
@@ -11,16 +11,16 @@
11
11
  <div class="rte-comment-text"></div>
12
12
  ${e.selectedText?`<blockquote class="rte-comment-selection">${e.selectedText}</blockquote>`:""}
13
13
  <section class="rte-comment-expanded${r?" show":""}"></section>
14
- `;const a=o.querySelector(".rte-comment-text");a&&(a.textContent=e.text);const i=o.querySelector(".rte-comment-expand");i==null||i.addEventListener("click",()=>{t.expandedComments.has(e.id)?t.expandedComments.delete(e.id):t.expandedComments.add(e.id),m(t)});const u=o.querySelector(".rte-comment-expanded");if(u&&r){if(e.replies.length>0){const n=document.createElement("div");n.className="rte-comment-replies",e.replies.forEach(s=>{const p=document.createElement("div");p.className="rte-comment-reply",p.innerHTML=`
14
+ `;const a=o.querySelector(".rte-comment-text");a&&(a.textContent=e.text),o.querySelector(".rte-comment-expand")?.addEventListener("click",()=>{t.expandedComments.has(e.id)?t.expandedComments.delete(e.id):t.expandedComments.add(e.id),m(t)});const p=o.querySelector(".rte-comment-expanded");if(p&&r){if(e.replies.length>0){const n=document.createElement("div");n.className="rte-comment-replies",e.replies.forEach(s=>{const l=document.createElement("div");l.className="rte-comment-reply",l.innerHTML=`
15
15
  <div class="rte-comment-reply-header">
16
16
  <strong>${s.author}</strong>
17
17
  <time>${L(s.createdAt)}</time>
18
18
  </div>
19
19
  <div class="rte-comment-reply-text"></div>
20
- `;const d=p.querySelector(".rte-comment-reply-text");d&&(d.textContent=s.text),n.appendChild(p)}),u.appendChild(n)}if(!e.resolved){const n=document.createElement("div");n.className="rte-comment-reply-composer",n.innerHTML=`
20
+ `;const f=l.querySelector(".rte-comment-reply-text");f&&(f.textContent=s.text),n.appendChild(l)}),p.appendChild(n)}if(!e.resolved){const n=document.createElement("div");n.className="rte-comment-reply-composer",n.innerHTML=`
21
21
  <textarea class="rte-comment-reply-textarea" rows="2" placeholder="Reply..."></textarea>
22
22
  <button type="button" class="rte-comment-btn primary">Reply</button>
23
- `;const s=n.querySelector(".rte-comment-reply-textarea"),p=n.querySelector(".rte-comment-btn.primary");if(s&&p){s.value=t.replyTexts[e.id]||"";const d=()=>{const x=!!s.value.trim();p.disabled=!x};d(),s.addEventListener("input",()=>{t.replyTexts[e.id]=s.value,d()}),p.addEventListener("click",()=>{const x=s.value.trim();x&&(F(e.id,E,x),t.replyTexts[e.id]="",m(t))})}u.appendChild(n)}const l=document.createElement("div");if(l.className="rte-comment-actions",e.anchorId){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Jump to text",n.onclick=()=>{const s=t.root.querySelector(`#${e.anchorId}`);s&&(s.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),h(t,e.id,!0),window.setTimeout(()=>h(t,e.id,!1),1200))},l.appendChild(n)}if(e.resolved){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Reopen",n.onclick=()=>_(e.id),l.appendChild(n)}else{const n=document.createElement("button");n.type="button",n.className="rte-comment-btn success",n.textContent="Resolve",n.onclick=()=>P(e.id,E),l.appendChild(n)}const c=document.createElement("button");c.type="button",c.className="rte-comment-btn danger",c.textContent="Delete",c.onclick=()=>j(e.id),l.appendChild(c),u.appendChild(l)}return o.addEventListener("mouseenter",()=>h(t,e.id,!0)),o.addEventListener("mouseleave",()=>h(t,e.id,!1)),o}function m(t){const e=t||f();if(!(e!=null&&e.panelElement))return;const r=B(e);e.panelElement.innerHTML=`
23
+ `;const s=n.querySelector(".rte-comment-reply-textarea"),l=n.querySelector(".rte-comment-btn.primary");if(s&&l){s.value=t.replyTexts[e.id]||"";const f=()=>{const b=!!s.value.trim();l.disabled=!b};f(),s.addEventListener("input",()=>{t.replyTexts[e.id]=s.value,f()}),l.addEventListener("click",()=>{const b=s.value.trim();b&&(F(e.id,E,b),t.replyTexts[e.id]="",m(t))})}p.appendChild(n)}const c=document.createElement("div");if(c.className="rte-comment-actions",e.anchorId){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Jump to text",n.onclick=()=>{const s=t.root.querySelector(`#${e.anchorId}`);s&&(s.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),h(t,e.id,!0),window.setTimeout(()=>h(t,e.id,!1),1200))},c.appendChild(n)}if(e.resolved){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Reopen",n.onclick=()=>_(e.id),c.appendChild(n)}else{const n=document.createElement("button");n.type="button",n.className="rte-comment-btn success",n.textContent="Resolve",n.onclick=()=>P(e.id,E),c.appendChild(n)}const i=document.createElement("button");i.type="button",i.className="rte-comment-btn danger",i.textContent="Delete",i.onclick=()=>j(e.id),c.appendChild(i),p.appendChild(c)}return o.addEventListener("mouseenter",()=>h(t,e.id,!0)),o.addEventListener("mouseleave",()=>h(t,e.id,!1)),o}function m(t){const e=t||u();if(!e?.panelElement)return;const r=M(e);e.panelElement.innerHTML=`
24
24
  <div class="rte-comments-header">
25
25
  <div>
26
26
  <h3>Comments (${r.length})</h3>
@@ -35,7 +35,7 @@
35
35
  </div>
36
36
  </div>
37
37
  ${r.length===0?'<div class="rte-comments-empty">No comments yet.</div>':'<div class="rte-comments-list"></div>'}
38
- `;const o=e.panelElement.querySelector(".rte-comments-close");o==null||o.addEventListener("click",()=>{b(e,!1)});const a=e.panelElement.querySelector(".new-comment-textarea"),i=e.panelElement.querySelector(".add-comment-btn");if(a&&i){a.value=e.newCommentText;const l=()=>{const c=!!a.value.trim();i.disabled=!c};l(),a.addEventListener("input",()=>{e.newCommentText=a.value,l()}),a.addEventListener("keydown",c=>{(c.ctrlKey||c.metaKey)&&c.key==="Enter"&&(c.preventDefault(),i.click())}),i.addEventListener("click",()=>{const c=a.value.trim();if(!c)return;const n=!!e.savedSelection;O(E,c,!n),e.newCommentText="",m(e)})}const u=e.panelElement.querySelector(".rte-comments-list");u&&r.forEach(l=>{u.appendChild(D(e,l))})}function T(){S||(S=!0,document.addEventListener("focusin",t=>{const e=y(t.target);e&&(g=e)}),document.addEventListener("selectionchange",()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0),r=y(e.commonAncestorContainer);if(!r)return;g=r;const o=C.get(r);!o||t.isCollapsed||w(e,r)&&(o.savedSelection=e.cloneRange())}),document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const e=f();!e||!e.panelVisible||(t.preventDefault(),t.stopPropagation(),b(e,!1))},!0))}function O(t,e,r=!1){var p;const o=f();if(!o)return"";const a=e.trim();if(!a)return"";if(r){const d=v("comment");return o.comments.set(d,{id:d,anchorId:"",selectedText:"",author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),m(o),d}const i=o.savedSelection||R(o.root);if(!i||!w(i,o.root))return"";const u=i.toString().trim();if(!u)return"";const l=v("comment"),c=v("comment-anchor"),n=document.createElement("span");n.id=c,n.className="rte-comment-anchor",n.setAttribute("data-comment-id",l),n.setAttribute("title","Commented text");try{const d=i.cloneRange(),x=d.extractContents();if(!((p=x.textContent)!=null&&p.trim()))return"";n.appendChild(x),d.insertNode(n)}catch{return""}q(o,n,l),o.comments.set(l,{id:l,anchorId:c,selectedText:u,author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),o.savedSelection=null;const s=window.getSelection();return s==null||s.removeAllRanges(),m(o),l}function P(t,e){const r=f();if(!r)return;const o=r.comments.get(t);o&&(o.resolved=!0,o.resolvedBy=e,o.resolvedAt=new Date().toISOString(),I(r,o),m(r))}function _(t){const e=f();if(!e)return;const r=e.comments.get(t);r&&(r.resolved=!1,r.resolvedBy=void 0,r.resolvedAt=void 0,I(e,r),m(e))}function j(t){const e=f();if(!e)return;const r=e.comments.get(t);if(r){if(r.anchorId){const o=e.root.querySelector(`#${r.anchorId}`);o&&N(o)}e.comments.delete(t),e.expandedComments.delete(t),delete e.replyTexts[t],m(e)}}function F(t,e,r){const o=f();if(!o)return;const a=o.comments.get(t);if(!a)return;const i=r.trim();i&&(a.replies.push({id:v("reply"),author:e,text:i,createdAt:new Date().toISOString()}),m(o))}function Z(){if(document.getElementById("rte-comments-panel-styles"))return;const t=document.createElement("style");t.id="rte-comments-panel-styles",t.textContent=`
38
+ `,e.panelElement.querySelector(".rte-comments-close")?.addEventListener("click",()=>{g(e,!1)});const a=e.panelElement.querySelector(".new-comment-textarea"),d=e.panelElement.querySelector(".add-comment-btn");if(a&&d){a.value=e.newCommentText;const c=()=>{const i=!!a.value.trim();d.disabled=!i};c(),a.addEventListener("input",()=>{e.newCommentText=a.value,c()}),a.addEventListener("keydown",i=>{(i.ctrlKey||i.metaKey)&&i.key==="Enter"&&(i.preventDefault(),d.click())}),d.addEventListener("click",()=>{const i=a.value.trim();if(!i)return;const n=!!e.savedSelection;O(E,i,!n),e.newCommentText="",m(e)})}const p=e.panelElement.querySelector(".rte-comments-list");p&&r.forEach(c=>{p.appendChild(D(e,c))})}function T(){S||(S=!0,document.addEventListener("focusin",t=>{const e=y(t.target);e&&(x=e)}),document.addEventListener("selectionchange",()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0),r=y(e.commonAncestorContainer);if(!r)return;x=r;const o=C.get(r);!o||t.isCollapsed||w(e,r)&&(o.savedSelection=e.cloneRange())}),document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const e=u();!e||!e.panelVisible||(t.preventDefault(),t.stopPropagation(),g(e,!1))},!0))}function O(t,e,r=!1){const o=u();if(!o)return"";const a=e.trim();if(!a)return"";if(r){const l=v("comment");return o.comments.set(l,{id:l,anchorId:"",selectedText:"",author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),m(o),l}const d=o.savedSelection||R(o.root);if(!d||!w(d,o.root))return"";const p=d.toString().trim();if(!p)return"";const c=v("comment"),i=v("comment-anchor"),n=document.createElement("span");n.id=i,n.className="rte-comment-anchor",n.setAttribute("data-comment-id",c),n.setAttribute("title","Commented text");try{const l=d.cloneRange(),f=l.extractContents();if(!f.textContent?.trim())return"";n.appendChild(f),l.insertNode(n)}catch{return""}return $(o,n,c),o.comments.set(c,{id:c,anchorId:i,selectedText:p,author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),o.savedSelection=null,window.getSelection()?.removeAllRanges(),m(o),c}function P(t,e){const r=u();if(!r)return;const o=r.comments.get(t);o&&(o.resolved=!0,o.resolvedBy=e,o.resolvedAt=new Date().toISOString(),I(r,o),m(r))}function _(t){const e=u();if(!e)return;const r=e.comments.get(t);r&&(r.resolved=!1,r.resolvedBy=void 0,r.resolvedAt=void 0,I(e,r),m(e))}function j(t){const e=u();if(!e)return;const r=e.comments.get(t);if(r){if(r.anchorId){const o=e.root.querySelector(`#${r.anchorId}`);o&&q(o)}e.comments.delete(t),e.expandedComments.delete(t),delete e.replyTexts[t],m(e)}}function F(t,e,r){const o=u();if(!o)return;const a=o.comments.get(t);if(!a)return;const d=r.trim();d&&(a.replies.push({id:v("reply"),author:e,text:d,createdAt:new Date().toISOString()}),m(o))}function Z(){if(document.getElementById("rte-comments-panel-styles"))return;const t=document.createElement("style");t.id="rte-comments-panel-styles",t.textContent=`
39
39
  .rte-comments-panel {
40
40
  --rte-comments-panel-width: min(360px, 42vw);
41
41
  position: absolute;
@@ -351,4 +351,4 @@
351
351
  margin-right: 0;
352
352
  }
353
353
  }
354
- `,document.head.appendChild(t)}const K=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect class="cls-1" width="32" height="32"></rect></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path><path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path></svg>'}],commands:{addComment:(t,e)=>{var a;A(e),T();const r=f();if(!r)return!1;if(r.savedSelection=R(r.root),r.savedSelection){const i=window.getSelection();i==null||i.removeAllRanges()}b(r,!0),m(r);const o=(a=r.panelElement)==null?void 0:a.querySelector(".new-comment-textarea");return o==null||o.focus({preventScroll:!0}),!0},toggleComments:(t,e)=>{A(e),T();const r=f();return r?(b(r,!r.panelVisible),r.panelVisible&&m(r),!0):!1}},keymap:{}});exports.CommentsPlugin=K;
354
+ `,document.head.appendChild(t)}const K=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect class="cls-1" width="32" height="32"></rect></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path><path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path></svg>'}],commands:{addComment:(t,e)=>{A(e),T();const r=u();return r?(r.savedSelection=R(r.root),r.savedSelection&&window.getSelection()?.removeAllRanges(),g(r,!0),m(r),r.panelElement?.querySelector(".new-comment-textarea")?.focus({preventScroll:!0}),!0):!1},toggleComments:(t,e)=>{A(e),T();const r=u();return r?(g(r,!r.panelVisible),r.panelVisible&&m(r),!0):!1}},keymap:{}});exports.CommentsPlugin=K;
@@ -5,22 +5,20 @@ function v(t) {
5
5
  return k += 1, `${t}-${Date.now()}-${k}`;
6
6
  }
7
7
  function y(t) {
8
- if (!t)
9
- return null;
8
+ if (!t) return null;
10
9
  const e = t instanceof Element ? t : t.parentElement;
11
10
  return e ? e.closest("[data-editora-editor]") || e.closest(".rte-editor") || e.closest(".editora-editor") : null;
12
11
  }
13
12
  function A(t) {
14
- const e = (t == null ? void 0 : t.editorElement) || (t == null ? void 0 : t.contentElement) || null;
15
- if (!(e instanceof HTMLElement))
16
- return;
13
+ const e = t?.editorElement || t?.contentElement || null;
14
+ if (!(e instanceof HTMLElement)) return;
17
15
  const r = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
18
16
  r && (x = r);
19
17
  }
20
18
  function w(t, e) {
21
19
  return e.contains(t.commonAncestorContainer);
22
20
  }
23
- function H() {
21
+ function B() {
24
22
  if (typeof window < "u") {
25
23
  const o = window.__editoraCommandEditorRoot;
26
24
  if (o instanceof HTMLElement) {
@@ -30,22 +28,19 @@ function H() {
30
28
  }
31
29
  }
32
30
  const t = document.activeElement, e = t ? y(t) : null;
33
- if (e)
34
- return e;
31
+ if (e) return e;
35
32
  const r = window.getSelection();
36
33
  if (r && r.rangeCount > 0) {
37
34
  const o = y(
38
35
  r.getRangeAt(0).commonAncestorContainer
39
36
  );
40
- if (o)
41
- return o;
37
+ if (o) return o;
42
38
  }
43
39
  return x;
44
40
  }
45
- function $(t) {
41
+ function H(t) {
46
42
  const e = C.get(t);
47
- if (e)
48
- return e;
43
+ if (e) return e;
49
44
  const r = {
50
45
  root: t,
51
46
  comments: /* @__PURE__ */ new Map(),
@@ -59,36 +54,33 @@ function $(t) {
59
54
  };
60
55
  return C.set(t, r), r;
61
56
  }
62
- function f() {
63
- const t = H();
64
- return t ? (x = t, $(t)) : null;
57
+ function u() {
58
+ const t = B();
59
+ return t ? (x = t, H(t)) : null;
65
60
  }
66
61
  function R(t) {
67
62
  const e = window.getSelection();
68
- if (!e || e.rangeCount === 0 || e.isCollapsed)
69
- return null;
63
+ if (!e || e.rangeCount === 0 || e.isCollapsed) return null;
70
64
  const r = e.getRangeAt(0);
71
65
  return w(r, t) ? r.cloneRange() : null;
72
66
  }
73
67
  function I(t, e) {
74
- if (!e.anchorId)
75
- return;
68
+ if (!e.anchorId) return;
76
69
  const r = t.root.querySelector(`#${e.anchorId}`);
77
70
  r && r.classList.toggle("rte-comment-anchor-resolved", e.resolved);
78
71
  }
79
72
  function h(t, e, r) {
80
73
  const o = t.comments.get(e);
81
- if (!o || !o.anchorId)
82
- return;
74
+ if (!o || !o.anchorId) return;
83
75
  const a = t.root.querySelector(`#${o.anchorId}`);
84
76
  a && a.classList.toggle("highlighted", r);
85
77
  }
86
- function q(t, e, r) {
78
+ function $(t, e, r) {
87
79
  e.onclick = (o) => {
88
- o.preventDefault(), o.stopPropagation(), x = t.root, t.expandedComments.add(r), b(t, !0), m(t);
80
+ o.preventDefault(), o.stopPropagation(), x = t.root, t.expandedComments.add(r), g(t, !0), m(t);
89
81
  };
90
82
  }
91
- function N(t) {
83
+ function q(t) {
92
84
  const e = t.parentNode;
93
85
  if (e) {
94
86
  for (; t.firstChild; )
@@ -96,29 +88,27 @@ function N(t) {
96
88
  t.remove();
97
89
  }
98
90
  }
99
- function b(t, e) {
91
+ function g(t, e) {
100
92
  if (t.panelVisible = e, e) {
101
- Z(), z(t), t.root.setAttribute("data-rte-comments-open", "true"), t.panelElement && (t.panelElement.classList.add("is-open"), t.panelElement.setAttribute("aria-hidden", "false")), V(t);
93
+ Z(), N(t), t.root.setAttribute("data-rte-comments-open", "true"), t.panelElement && (t.panelElement.classList.add("is-open"), t.panelElement.setAttribute("aria-hidden", "false")), z(t);
102
94
  return;
103
95
  }
104
- t.root.removeAttribute("data-rte-comments-open"), B(t), t.panelElement && (t.panelElement.remove(), t.panelElement = null);
96
+ t.root.removeAttribute("data-rte-comments-open"), V(t), t.panelElement && (t.panelElement.remove(), t.panelElement = null);
105
97
  }
106
- function z(t) {
107
- if (t.panelElement)
108
- return;
98
+ function N(t) {
99
+ if (t.panelElement) return;
109
100
  const e = document.createElement("aside");
110
101
  e.className = "rte-comments-panel", e.setAttribute("role", "complementary"), e.setAttribute("aria-label", "Comments"), e.setAttribute("aria-hidden", "true"), window.getComputedStyle(t.root).position === "static" && (t.root.style.position = "relative"), t.root.appendChild(e), t.panelElement = e;
111
102
  }
112
- function V(t) {
103
+ function z(t) {
113
104
  t.selectionChangeListener || (t.selectionChangeListener = () => {
114
105
  const e = window.getSelection();
115
- if (!e || e.rangeCount === 0 || e.isCollapsed)
116
- return;
106
+ if (!e || e.rangeCount === 0 || e.isCollapsed) return;
117
107
  const r = e.getRangeAt(0);
118
108
  w(r, t.root) && (t.savedSelection = r.cloneRange(), x = t.root);
119
109
  }, document.addEventListener("selectionchange", t.selectionChangeListener));
120
110
  }
121
- function B(t) {
111
+ function V(t) {
122
112
  t.selectionChangeListener && (document.removeEventListener("selectionchange", t.selectionChangeListener), t.selectionChangeListener = null);
123
113
  }
124
114
  function M(t) {
@@ -146,27 +136,25 @@ function D(t, e) {
146
136
  <section class="rte-comment-expanded${r ? " show" : ""}"></section>
147
137
  `;
148
138
  const a = o.querySelector(".rte-comment-text");
149
- a && (a.textContent = e.text);
150
- const i = o.querySelector(".rte-comment-expand");
151
- i == null || i.addEventListener("click", () => {
139
+ a && (a.textContent = e.text), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
152
140
  t.expandedComments.has(e.id) ? t.expandedComments.delete(e.id) : t.expandedComments.add(e.id), m(t);
153
141
  });
154
- const u = o.querySelector(".rte-comment-expanded");
155
- if (u && r) {
142
+ const p = o.querySelector(".rte-comment-expanded");
143
+ if (p && r) {
156
144
  if (e.replies.length > 0) {
157
145
  const n = document.createElement("div");
158
146
  n.className = "rte-comment-replies", e.replies.forEach((s) => {
159
- const p = document.createElement("div");
160
- p.className = "rte-comment-reply", p.innerHTML = `
147
+ const l = document.createElement("div");
148
+ l.className = "rte-comment-reply", l.innerHTML = `
161
149
  <div class="rte-comment-reply-header">
162
150
  <strong>${s.author}</strong>
163
151
  <time>${L(s.createdAt)}</time>
164
152
  </div>
165
153
  <div class="rte-comment-reply-text"></div>
166
154
  `;
167
- const d = p.querySelector(".rte-comment-reply-text");
168
- d && (d.textContent = s.text), n.appendChild(p);
169
- }), u.appendChild(n);
155
+ const f = l.querySelector(".rte-comment-reply-text");
156
+ f && (f.textContent = s.text), n.appendChild(l);
157
+ }), p.appendChild(n);
170
158
  }
171
159
  if (!e.resolved) {
172
160
  const n = document.createElement("div");
@@ -176,48 +164,47 @@ function D(t, e) {
176
164
  `;
177
165
  const s = n.querySelector(
178
166
  ".rte-comment-reply-textarea"
179
- ), p = n.querySelector(
167
+ ), l = n.querySelector(
180
168
  ".rte-comment-btn.primary"
181
169
  );
182
- if (s && p) {
170
+ if (s && l) {
183
171
  s.value = t.replyTexts[e.id] || "";
184
- const d = () => {
185
- const g = !!s.value.trim();
186
- p.disabled = !g;
172
+ const f = () => {
173
+ const b = !!s.value.trim();
174
+ l.disabled = !b;
187
175
  };
188
- d(), s.addEventListener("input", () => {
189
- t.replyTexts[e.id] = s.value, d();
190
- }), p.addEventListener("click", () => {
191
- const g = s.value.trim();
192
- g && (F(e.id, E, g), t.replyTexts[e.id] = "", m(t));
176
+ f(), s.addEventListener("input", () => {
177
+ t.replyTexts[e.id] = s.value, f();
178
+ }), l.addEventListener("click", () => {
179
+ const b = s.value.trim();
180
+ b && (F(e.id, E, b), t.replyTexts[e.id] = "", m(t));
193
181
  });
194
182
  }
195
- u.appendChild(n);
183
+ p.appendChild(n);
196
184
  }
197
- const l = document.createElement("div");
198
- if (l.className = "rte-comment-actions", e.anchorId) {
185
+ const c = document.createElement("div");
186
+ if (c.className = "rte-comment-actions", e.anchorId) {
199
187
  const n = document.createElement("button");
200
188
  n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Jump to text", n.onclick = () => {
201
189
  const s = t.root.querySelector(`#${e.anchorId}`);
202
190
  s && (s.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), h(t, e.id, !0), window.setTimeout(() => h(t, e.id, !1), 1200));
203
- }, l.appendChild(n);
191
+ }, c.appendChild(n);
204
192
  }
205
193
  if (e.resolved) {
206
194
  const n = document.createElement("button");
207
- n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => _(e.id), l.appendChild(n);
195
+ n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => _(e.id), c.appendChild(n);
208
196
  } else {
209
197
  const n = document.createElement("button");
210
- n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => P(e.id, E), l.appendChild(n);
198
+ n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => P(e.id, E), c.appendChild(n);
211
199
  }
212
- const c = document.createElement("button");
213
- c.type = "button", c.className = "rte-comment-btn danger", c.textContent = "Delete", c.onclick = () => j(e.id), l.appendChild(c), u.appendChild(l);
200
+ const i = document.createElement("button");
201
+ i.type = "button", i.className = "rte-comment-btn danger", i.textContent = "Delete", i.onclick = () => j(e.id), c.appendChild(i), p.appendChild(c);
214
202
  }
215
203
  return o.addEventListener("mouseenter", () => h(t, e.id, !0)), o.addEventListener("mouseleave", () => h(t, e.id, !1)), o;
216
204
  }
217
205
  function m(t) {
218
- const e = t || f();
219
- if (!(e != null && e.panelElement))
220
- return;
206
+ const e = t || u();
207
+ if (!e?.panelElement) return;
221
208
  const r = M(e);
222
209
  e.panelElement.innerHTML = `
223
210
  <div class="rte-comments-header">
@@ -234,37 +221,34 @@ function m(t) {
234
221
  </div>
235
222
  </div>
236
223
  ${r.length === 0 ? '<div class="rte-comments-empty">No comments yet.</div>' : '<div class="rte-comments-list"></div>'}
237
- `;
238
- const o = e.panelElement.querySelector(".rte-comments-close");
239
- o == null || o.addEventListener("click", () => {
240
- b(e, !1);
224
+ `, e.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
225
+ g(e, !1);
241
226
  });
242
227
  const a = e.panelElement.querySelector(
243
228
  ".new-comment-textarea"
244
- ), i = e.panelElement.querySelector(
229
+ ), d = e.panelElement.querySelector(
245
230
  ".add-comment-btn"
246
231
  );
247
- if (a && i) {
232
+ if (a && d) {
248
233
  a.value = e.newCommentText;
249
- const l = () => {
250
- const c = !!a.value.trim();
251
- i.disabled = !c;
234
+ const c = () => {
235
+ const i = !!a.value.trim();
236
+ d.disabled = !i;
252
237
  };
253
- l(), a.addEventListener("input", () => {
254
- e.newCommentText = a.value, l();
255
- }), a.addEventListener("keydown", (c) => {
256
- (c.ctrlKey || c.metaKey) && c.key === "Enter" && (c.preventDefault(), i.click());
257
- }), i.addEventListener("click", () => {
258
- const c = a.value.trim();
259
- if (!c)
260
- return;
238
+ c(), a.addEventListener("input", () => {
239
+ e.newCommentText = a.value, c();
240
+ }), a.addEventListener("keydown", (i) => {
241
+ (i.ctrlKey || i.metaKey) && i.key === "Enter" && (i.preventDefault(), d.click());
242
+ }), d.addEventListener("click", () => {
243
+ const i = a.value.trim();
244
+ if (!i) return;
261
245
  const n = !!e.savedSelection;
262
- O(E, c, !n), e.newCommentText = "", m(e);
246
+ O(E, i, !n), e.newCommentText = "", m(e);
263
247
  });
264
248
  }
265
- const u = e.panelElement.querySelector(".rte-comments-list");
266
- u && r.forEach((l) => {
267
- u.appendChild(D(e, l));
249
+ const p = e.panelElement.querySelector(".rte-comments-list");
250
+ p && r.forEach((c) => {
251
+ p.appendChild(D(e, c));
268
252
  });
269
253
  }
270
254
  function T() {
@@ -273,37 +257,31 @@ function T() {
273
257
  e && (x = e);
274
258
  }), document.addEventListener("selectionchange", () => {
275
259
  const t = window.getSelection();
276
- if (!t || t.rangeCount === 0)
277
- return;
260
+ if (!t || t.rangeCount === 0) return;
278
261
  const e = t.getRangeAt(0), r = y(e.commonAncestorContainer);
279
- if (!r)
280
- return;
262
+ if (!r) return;
281
263
  x = r;
282
264
  const o = C.get(r);
283
265
  !o || t.isCollapsed || w(e, r) && (o.savedSelection = e.cloneRange());
284
266
  }), document.addEventListener(
285
267
  "keydown",
286
268
  (t) => {
287
- if (t.key !== "Escape")
288
- return;
289
- const e = f();
290
- !e || !e.panelVisible || (t.preventDefault(), t.stopPropagation(), b(e, !1));
269
+ if (t.key !== "Escape") return;
270
+ const e = u();
271
+ !e || !e.panelVisible || (t.preventDefault(), t.stopPropagation(), g(e, !1));
291
272
  },
292
273
  !0
293
274
  ));
294
275
  }
295
276
  function O(t, e, r = !1) {
296
- var p;
297
- const o = f();
298
- if (!o)
299
- return "";
277
+ const o = u();
278
+ if (!o) return "";
300
279
  const a = e.trim();
301
- if (!a)
302
- return "";
280
+ if (!a) return "";
303
281
  if (r) {
304
- const d = v("comment");
305
- return o.comments.set(d, {
306
- id: d,
282
+ const l = v("comment");
283
+ return o.comments.set(l, {
284
+ id: l,
307
285
  anchorId: "",
308
286
  selectedText: "",
309
287
  author: t,
@@ -311,82 +289,71 @@ function O(t, e, r = !1) {
311
289
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
312
290
  resolved: !1,
313
291
  replies: []
314
- }), m(o), d;
292
+ }), m(o), l;
315
293
  }
316
- const i = o.savedSelection || R(o.root);
317
- if (!i || !w(i, o.root))
318
- return "";
319
- const u = i.toString().trim();
320
- if (!u)
321
- return "";
322
- const l = v("comment"), c = v("comment-anchor"), n = document.createElement("span");
323
- n.id = c, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", l), n.setAttribute("title", "Commented text");
294
+ const d = o.savedSelection || R(o.root);
295
+ if (!d || !w(d, o.root)) return "";
296
+ const p = d.toString().trim();
297
+ if (!p) return "";
298
+ const c = v("comment"), i = v("comment-anchor"), n = document.createElement("span");
299
+ n.id = i, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", c), n.setAttribute("title", "Commented text");
324
300
  try {
325
- const d = i.cloneRange(), g = d.extractContents();
326
- if (!((p = g.textContent) != null && p.trim()))
327
- return "";
328
- n.appendChild(g), d.insertNode(n);
301
+ const l = d.cloneRange(), f = l.extractContents();
302
+ if (!f.textContent?.trim()) return "";
303
+ n.appendChild(f), l.insertNode(n);
329
304
  } catch {
330
305
  return "";
331
306
  }
332
- q(o, n, l), o.comments.set(l, {
333
- id: l,
334
- anchorId: c,
335
- selectedText: u,
307
+ return $(o, n, c), o.comments.set(c, {
308
+ id: c,
309
+ anchorId: i,
310
+ selectedText: p,
336
311
  author: t,
337
312
  text: a,
338
313
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
339
314
  resolved: !1,
340
315
  replies: []
341
- }), o.savedSelection = null;
342
- const s = window.getSelection();
343
- return s == null || s.removeAllRanges(), m(o), l;
316
+ }), o.savedSelection = null, window.getSelection()?.removeAllRanges(), m(o), c;
344
317
  }
345
318
  function P(t, e) {
346
- const r = f();
347
- if (!r)
348
- return;
319
+ const r = u();
320
+ if (!r) return;
349
321
  const o = r.comments.get(t);
350
322
  o && (o.resolved = !0, o.resolvedBy = e, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), I(r, o), m(r));
351
323
  }
352
324
  function _(t) {
353
- const e = f();
354
- if (!e)
355
- return;
325
+ const e = u();
326
+ if (!e) return;
356
327
  const r = e.comments.get(t);
357
328
  r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, I(e, r), m(e));
358
329
  }
359
330
  function j(t) {
360
- const e = f();
361
- if (!e)
362
- return;
331
+ const e = u();
332
+ if (!e) return;
363
333
  const r = e.comments.get(t);
364
334
  if (r) {
365
335
  if (r.anchorId) {
366
336
  const o = e.root.querySelector(`#${r.anchorId}`);
367
- o && N(o);
337
+ o && q(o);
368
338
  }
369
339
  e.comments.delete(t), e.expandedComments.delete(t), delete e.replyTexts[t], m(e);
370
340
  }
371
341
  }
372
342
  function F(t, e, r) {
373
- const o = f();
374
- if (!o)
375
- return;
343
+ const o = u();
344
+ if (!o) return;
376
345
  const a = o.comments.get(t);
377
- if (!a)
378
- return;
379
- const i = r.trim();
380
- i && (a.replies.push({
346
+ if (!a) return;
347
+ const d = r.trim();
348
+ d && (a.replies.push({
381
349
  id: v("reply"),
382
350
  author: e,
383
- text: i,
351
+ text: d,
384
352
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
385
353
  }), m(o));
386
354
  }
387
355
  function Z() {
388
- if (document.getElementById("rte-comments-panel-styles"))
389
- return;
356
+ if (document.getElementById("rte-comments-panel-styles")) return;
390
357
  const t = document.createElement("style");
391
358
  t.id = "rte-comments-panel-styles", t.textContent = `
392
359
  .rte-comments-panel {
@@ -724,25 +691,16 @@ const K = () => ({
724
691
  ],
725
692
  commands: {
726
693
  addComment: (t, e) => {
727
- var a;
728
694
  A(e), T();
729
- const r = f();
730
- if (!r)
731
- return !1;
732
- if (r.savedSelection = R(r.root), r.savedSelection) {
733
- const i = window.getSelection();
734
- i == null || i.removeAllRanges();
735
- }
736
- b(r, !0), m(r);
737
- const o = (a = r.panelElement) == null ? void 0 : a.querySelector(
695
+ const r = u();
696
+ return r ? (r.savedSelection = R(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), g(r, !0), m(r), r.panelElement?.querySelector(
738
697
  ".new-comment-textarea"
739
- );
740
- return o == null || o.focus({ preventScroll: !0 }), !0;
698
+ )?.focus({ preventScroll: !0 }), !0) : !1;
741
699
  },
742
700
  toggleComments: (t, e) => {
743
701
  A(e), T();
744
- const r = f();
745
- return r ? (b(r, !r.panelVisible), r.panelVisible && m(r), !0) : !1;
702
+ const r = u();
703
+ return r ? (g(r, !r.panelVisible), r.panelVisible && m(r), !0) : !1;
746
704
  }
747
705
  },
748
706
  keymap: {}