@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 w=require("./editorContainerHelpers-CFbfiOJI.js"),b=new Set,x='[data-theme="dark"], .dark, .editora-theme-dark';function $(t,c){if(c===t.innerHTML)return;const i=window.execEditorCommand||window.executeEditorCommand;if(typeof i=="function")try{i("recordDomTransaction",t,c,t.innerHTML)}catch{}}function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(c=>{c.forEach(i=>{i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const d=r;if(d.classList?.contains("rte-anchor")){const n=d.id;n&&b.delete(n)}d.querySelectorAll?.(".rte-anchor")?.forEach(n=>{const u=n.id;u&&b.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(t)?/^[a-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function M(){const t=w.findEditorContainerFromSelection();if(!t)return;const c=w.getContentElement(t);if(!c)return;const i=c.querySelectorAll(".rte-anchor"),r=new Set;i.forEach(d=>{const e=d.id;e&&r.add(e)}),b.clear(),r.forEach(d=>b.add(d))}function R(t){if(t){const r=t.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}const c=window.getSelection();if(c&&c.rangeCount>0){const r=c.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}return document.activeElement?.closest(x)?!0:document.body.matches(x)||document.documentElement.matches(x)}function H(t,c,i,r){M();const d=R(r),e=d?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},n=document.createElement("div");n.className="rte-anchor-dialog-overlay",n.style.cssText=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-36b8ddf3.js"),h=new Set,y='[data-theme="dark"], .dark, .editora-theme-dark';function $(t,l){if(l===t.innerHTML)return;const s=window.execEditorCommand||window.executeEditorCommand;if(typeof s=="function")try{s("recordDomTransaction",t,l,t.innerHTML)}catch{}}function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(l=>{l.forEach(s=>{s.removedNodes.forEach(d=>{var a,e;if(d.nodeType===Node.ELEMENT_NODE){const i=d;if((a=i.classList)!=null&&a.contains("rte-anchor")){const r=i.id;r&&h.delete(r)}const u=(e=i.querySelectorAll)==null?void 0:e.call(i,".rte-anchor");u==null||u.forEach(r=>{const f=r.id;f&&h.delete(f)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(t)?/^[a-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function M(){const t=w.findEditorContainerFromSelection();if(!t)return;const l=w.getContentElement(t);if(!l)return;const s=l.querySelectorAll(".rte-anchor"),d=new Set;s.forEach(a=>{const e=a.id;e&&d.add(e)}),h.clear(),d.forEach(a=>h.add(a))}function R(t){if(t){const d=t.startContainer,a=d.nodeType===Node.ELEMENT_NODE?d:d.parentElement;if(a!=null&&a.closest(y))return!0}const l=window.getSelection();if(l&&l.rangeCount>0){const d=l.getRangeAt(0).startContainer,a=d.nodeType===Node.ELEMENT_NODE?d:d.parentElement;if(a!=null&&a.closest(y))return!0}const s=document.activeElement;return s!=null&&s.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)}function H(t,l,s,d){M();const a=R(d),e=a?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldPlaceholder:"#94a3b8",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldPlaceholder:"#9ca3af",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},i=document.createElement("div");i.className="rte-anchor-dialog-overlay",i.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -19,7 +19,7 @@
19
19
  max-width: 450px;
20
20
  overflow: hidden;
21
21
  animation: rte-anchor-dialog-appear 0.2s ease;
22
- `,!document.getElementById("rte-anchor-dialog-styles")){const s=document.createElement("style");s.id="rte-anchor-dialog-styles",s.textContent=`
22
+ `,!document.getElementById("rte-anchor-dialog-styles")){const n=document.createElement("style");n.id="rte-anchor-dialog-styles",n.textContent=`
23
23
  @keyframes rte-anchor-dialog-appear {
24
24
  from { opacity: 0; transform: scale(0.95); }
25
25
  to { opacity: 1; transform: scale(1); }
@@ -27,14 +27,14 @@
27
27
  .rte-anchor-dialog input:focus {
28
28
  outline: none !important;
29
29
  }
30
- `,document.head.appendChild(s)}let l="";const h=document.createElement("div");h.style.cssText=`
30
+ `,document.head.appendChild(n)}let r="";const f=document.createElement("div");f.style.cssText=`
31
31
  display: flex;
32
32
  align-items: center;
33
33
  justify-content: space-between;
34
34
  padding: 16px 20px;
35
35
  border-bottom: 1px solid ${e.border};
36
36
  background: ${e.panelBg};
37
- `;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent="Add Anchor";const f=document.createElement("button");f.textContent="✕",f.style.cssText=`
37
+ `;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent=t==="add"?"Add Anchor":"Edit Anchor";const p=document.createElement("button");p.textContent="✕",p.style.cssText=`
38
38
  background: none;
39
39
  border: none;
40
40
  font-size: 24px;
@@ -48,7 +48,7 @@
48
48
  justify-content: center;
49
49
  border-radius: 4px;
50
50
  transition: all 0.2s ease;
51
- `,f.onmouseover=()=>{f.style.background=e.closeHoverBg,f.style.color="#f8fafc"},f.onmouseout=()=>{f.style.background="none",f.style.color=e.muted},h.appendChild(C),h.appendChild(f);const B=document.createElement("div");B.style.cssText="padding: 20px;";const m=document.createElement("div");m.style.cssText="margin-bottom: 0;";const y=document.createElement("label");y.textContent="Anchor ID",y.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,y.setAttribute("for","anchor-id-input");const o=document.createElement("input");o.id="anchor-id-input",o.type="text",o.placeholder="e.g., section-introduction",o.value="",o.style.cssText=`
51
+ `,p.onmouseover=()=>{p.style.background=e.closeHoverBg,p.style.color="#f8fafc"},p.onmouseout=()=>{p.style.background="none",p.style.color=e.muted},f.appendChild(C),f.appendChild(p);const B=document.createElement("div");B.style.cssText="padding: 20px;";const x=document.createElement("div");x.style.cssText="margin-bottom: 0;";const m=document.createElement("label");m.textContent="Anchor ID",m.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,m.setAttribute("for","anchor-id-input");const o=document.createElement("input");o.id="anchor-id-input",o.type="text",o.placeholder="e.g., section-introduction",o.value=l||"",o.style.cssText=`
52
52
  width: 100%;
53
53
  padding: 10px 12px;
54
54
  font-size: 14px;
@@ -59,19 +59,19 @@
59
59
  background: ${e.fieldBg};
60
60
  transition: all 0.2s ease;
61
61
  box-sizing: border-box;
62
- `,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=`
62
+ `,o.style.setProperty("caret-color",e.fieldText);const g=document.createElement("div");g.style.cssText=`
63
63
  color: #d32f2f;
64
64
  font-size: 12px;
65
65
  margin-top: 6px;
66
66
  display: none;
67
- `;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,m.appendChild(y),m.appendChild(o),m.appendChild(p),m.appendChild(k),B.appendChild(m);const v=document.createElement("div");v.style.cssText=`
67
+ `;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,x.appendChild(m),x.appendChild(o),x.appendChild(g),x.appendChild(k),B.appendChild(x);const v=document.createElement("div");v.style.cssText=`
68
68
  display: flex;
69
69
  gap: 12px;
70
70
  padding: 16px 20px;
71
71
  border-top: 1px solid ${e.border};
72
72
  background: ${e.panelBg};
73
73
  justify-content: flex-end;
74
- `;const g=document.createElement("button");g.textContent="Cancel",g.style.cssText=`
74
+ `;const b=document.createElement("button");b.textContent="Cancel",b.style.cssText=`
75
75
  padding: 8px 16px;
76
76
  font-size: 14px;
77
77
  font-weight: 500;
@@ -81,7 +81,7 @@
81
81
  transition: all 0.2s ease;
82
82
  background: ${e.cancelBg};
83
83
  color: ${e.cancelText};
84
- `,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const a=document.createElement("button");a.textContent="Add Anchor",a.style.cssText=`
84
+ `,b.onmouseover=()=>b.style.background=e.cancelHover,b.onmouseout=()=>b.style.background=e.cancelBg;const c=document.createElement("button");c.textContent=t==="add"?"Add Anchor":"Save Changes",c.style.cssText=`
85
85
  padding: 8px 16px;
86
86
  font-size: 14px;
87
87
  font-weight: 500;
@@ -91,11 +91,11 @@
91
91
  transition: all 0.2s ease;
92
92
  background: ${e.saveBg};
93
93
  color: white;
94
- `,a.disabled=!o.value.trim();const N=()=>{o.value.trim()?(a.disabled=!1,a.style.background=e.saveBg,a.style.color="white",a.style.cursor="pointer"):(a.disabled=!0,a.style.background=e.saveDisabledBg,a.style.color=e.saveDisabledText,a.style.cursor="not-allowed")};a.onmouseover=()=>{a.disabled||(a.style.background=e.saveHover,a.style.boxShadow=d?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},a.onmouseout=()=>{a.disabled||(a.style.background=e.saveBg,a.style.boxShadow="none")},v.appendChild(g),v.appendChild(a),o.oninput=()=>{const s=o.value;if(N(),s.trim()){const T=S(s);T.valid?b.has(s)?(l=`Anchor ID already exists: ${s}`,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(l="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(l=T.error,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg)}else p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg},o.onfocus=()=>{o.style.borderColor=l?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=l?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=l?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",l||(o.style.background=e.fieldBg)};const A=()=>{const s=o.value.trim();!s||!S(s).valid||b.has(s)||(i&&i(s),n.remove())},E=()=>{n.remove()};a.onclick=A,g.onclick=E,f.onclick=E,o.onkeydown=s=>{s.key==="Enter"?(s.preventDefault(),A()):s.key==="Escape"&&(s.preventDefault(),E())},n.onclick=s=>{s.target===n&&E()},u.appendChild(h),u.appendChild(B),u.appendChild(v),n.appendChild(u),document.body.appendChild(n),setTimeout(()=>o.focus(),100)}function _(t,c){let i;if(c)i=c;else{const l=window.getSelection();if(!l||l.rangeCount===0)return;i=l.getRangeAt(0)}let r=null,d=i.startContainer;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const l=d;if(l.getAttribute("contenteditable")==="true"){r=l;break}}d=d.parentNode}const e=r?.innerHTML??"",n=document.createElement("span");n.id=t,n.className="rte-anchor",n.setAttribute("data-type","anchor"),n.setAttribute("data-anchor-id",t),n.setAttribute("title",`Anchor: ${t}`),n.style.cssText=`
94
+ `,c.disabled=!o.value.trim();const N=()=>{o.value.trim()?(c.disabled=!1,c.style.background=e.saveBg,c.style.color="white",c.style.cursor="pointer"):(c.disabled=!0,c.style.background=e.saveDisabledBg,c.style.color=e.saveDisabledText,c.style.cursor="not-allowed")};c.onmouseover=()=>{c.disabled||(c.style.background=e.saveHover,c.style.boxShadow=a?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},c.onmouseout=()=>{c.disabled||(c.style.background=e.saveBg,c.style.boxShadow="none")},v.appendChild(b),v.appendChild(c),o.oninput=()=>{const n=o.value;if(N(),n.trim()){const T=S(n);T.valid?t==="add"&&h.has(n)?(r=`Anchor ID already exists: ${n}`,g.textContent="⚠ "+r,g.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):t==="edit"&&n!==l&&h.has(n)?(r=`Anchor ID already exists: ${n}`,g.textContent="⚠ "+r,g.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(r="",g.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(r=T.error,g.textContent="⚠ "+r,g.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg)}else g.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg},o.onfocus=()=>{o.style.borderColor=r?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=r?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=r?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",r||(o.style.background=e.fieldBg)};const A=()=>{const n=o.value.trim();!n||!S(n).valid||t==="add"&&h.has(n)||t==="edit"&&n!==l&&h.has(n)||(s&&s(n),i.remove())},E=()=>{i.remove()};c.onclick=A,b.onclick=E,p.onclick=E,o.onkeydown=n=>{n.key==="Enter"?(n.preventDefault(),A()):n.key==="Escape"&&(n.preventDefault(),E())},i.onclick=n=>{n.target===i&&E()},u.appendChild(f),u.appendChild(B),u.appendChild(v),i.appendChild(u),document.body.appendChild(i),setTimeout(()=>o.focus(),100)}function _(t,l){let s;if(l)s=l;else{const r=window.getSelection();if(!r||r.rangeCount===0)return;s=r.getRangeAt(0)}let d=null,a=s.startContainer;for(;a&&a!==document.body;){if(a.nodeType===Node.ELEMENT_NODE){const r=a;if(r.getAttribute("contenteditable")==="true"){d=r;break}}a=a.parentNode}const e=(d==null?void 0:d.innerHTML)??"",i=document.createElement("span");i.id=t,i.className="rte-anchor",i.setAttribute("data-type","anchor"),i.setAttribute("data-anchor-id",t),i.setAttribute("title",`Anchor: ${t}`),i.style.cssText=`
95
95
  display: inline;
96
96
  position: relative;
97
97
  cursor: pointer;
98
- `,i.insertNode(n),b.add(t),i.setStart(n.nextSibling||n.parentNode,0),i.collapse(!0);const u=window.getSelection();if(u&&(u.removeAllRanges(),u.addRange(i)),r)$(r,e),r.dispatchEvent(new Event("input",{bubbles:!0}));else{const l=w.findEditorContainerFromSelection();if(l){const h=w.getContentElement(l);h&&h.dispatchEvent(new Event("input",{bubbles:!0}))}}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
98
+ `,s.insertNode(i),h.add(t),s.setStart(i.nextSibling||i.parentNode,0),s.collapse(!0);const u=window.getSelection();if(u&&(u.removeAllRanges(),u.addRange(s)),d)$(d,e),d.dispatchEvent(new Event("input",{bubbles:!0}));else{const r=w.findEditorContainerFromSelection();if(r){const f=w.getContentElement(r);f&&f.dispatchEvent(new Event("input",{bubbles:!0}))}}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
99
99
  .rte-anchor {
100
100
  display: inline;
101
101
  position: relative;
@@ -173,4 +173,4 @@
173
173
  outline: 2px solid #0066cc;
174
174
  outline-offset: 2px;
175
175
  }
176
- `,document.head.appendChild(t)}const I=()=>(typeof window<"u"&&(z(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",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 d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const c=t.getRangeAt(0).cloneRange();return H("add","",i=>{_(i,c)},c),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=I;
176
+ `,document.head.appendChild(t)}const I=()=>(typeof window<"u"&&(z(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",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 d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const l=t.getRangeAt(0).cloneRange();return H("add","",s=>{_(s,l)},l),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=I;
@@ -1,28 +1,32 @@
1
- import { f as D, g as S } from "./editorContainerHelpers-C7kdWnS0.mjs";
2
- const b = /* @__PURE__ */ new Set(), x = '[data-theme="dark"], .dark, .editora-theme-dark';
3
- function z(t, c) {
4
- if (c === t.innerHTML) return;
5
- const i = window.execEditorCommand || window.executeEditorCommand;
6
- if (typeof i == "function")
1
+ import { f as D, g as S } from "./editorContainerHelpers-69585c07.mjs";
2
+ const h = /* @__PURE__ */ new Set(), y = '[data-theme="dark"], .dark, .editora-theme-dark';
3
+ function z(t, l) {
4
+ if (l === t.innerHTML)
5
+ return;
6
+ const s = window.execEditorCommand || window.executeEditorCommand;
7
+ if (typeof s == "function")
7
8
  try {
8
- i("recordDomTransaction", t, c, t.innerHTML);
9
+ s("recordDomTransaction", t, l, t.innerHTML);
9
10
  } catch {
10
11
  }
11
12
  }
12
13
  function R() {
13
- if (typeof window > "u" || window.__anchorObserverInitialized) return;
14
- window.__anchorObserverInitialized = !0, new MutationObserver((c) => {
15
- c.forEach((i) => {
16
- i.removedNodes.forEach((n) => {
17
- if (n.nodeType === Node.ELEMENT_NODE) {
18
- const d = n;
19
- if (d.classList?.contains("rte-anchor")) {
20
- const r = d.id;
21
- r && b.delete(r);
14
+ if (typeof window > "u" || window.__anchorObserverInitialized)
15
+ return;
16
+ window.__anchorObserverInitialized = !0, new MutationObserver((l) => {
17
+ l.forEach((s) => {
18
+ s.removedNodes.forEach((d) => {
19
+ var a, e;
20
+ if (d.nodeType === Node.ELEMENT_NODE) {
21
+ const i = d;
22
+ if ((a = i.classList) != null && a.contains("rte-anchor")) {
23
+ const r = i.id;
24
+ r && h.delete(r);
22
25
  }
23
- d.querySelectorAll?.(".rte-anchor")?.forEach((r) => {
24
- const u = r.id;
25
- u && b.delete(u);
26
+ const u = (e = i.querySelectorAll) == null ? void 0 : e.call(i, ".rte-anchor");
27
+ u == null || u.forEach((r) => {
28
+ const f = r.id;
29
+ f && h.delete(f);
26
30
  });
27
31
  }
28
32
  });
@@ -37,30 +41,35 @@ function A(t) {
37
41
  }
38
42
  function M() {
39
43
  const t = D();
40
- if (!t) return;
41
- const c = S(t);
42
- if (!c) return;
43
- const i = c.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set();
44
- i.forEach((d) => {
45
- const e = d.id;
46
- e && n.add(e);
47
- }), b.clear(), n.forEach((d) => b.add(d));
44
+ if (!t)
45
+ return;
46
+ const l = S(t);
47
+ if (!l)
48
+ return;
49
+ const s = l.querySelectorAll(".rte-anchor"), d = /* @__PURE__ */ new Set();
50
+ s.forEach((a) => {
51
+ const e = a.id;
52
+ e && d.add(e);
53
+ }), h.clear(), d.forEach((a) => h.add(a));
48
54
  }
49
55
  function H(t) {
50
56
  if (t) {
51
- const n = t.startContainer;
52
- if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
57
+ const d = t.startContainer, a = d.nodeType === Node.ELEMENT_NODE ? d : d.parentElement;
58
+ if (a != null && a.closest(y))
59
+ return !0;
53
60
  }
54
- const c = window.getSelection();
55
- if (c && c.rangeCount > 0) {
56
- const n = c.getRangeAt(0).startContainer;
57
- if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
61
+ const l = window.getSelection();
62
+ if (l && l.rangeCount > 0) {
63
+ const d = l.getRangeAt(0).startContainer, a = d.nodeType === Node.ELEMENT_NODE ? d : d.parentElement;
64
+ if (a != null && a.closest(y))
65
+ return !0;
58
66
  }
59
- return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
67
+ const s = document.activeElement;
68
+ return s != null && s.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
60
69
  }
61
- function _(t, c, i, n) {
70
+ function _(t, l, s, d) {
62
71
  M();
63
- const d = H(n), e = d ? {
72
+ const a = H(d), e = a ? {
64
73
  overlay: "rgba(0, 0, 0, 0.62)",
65
74
  dialogBg: "#1f2937",
66
75
  panelBg: "#222d3a",
@@ -72,6 +81,7 @@ function _(t, c, i, n) {
72
81
  fieldFocusBg: "#111827",
73
82
  fieldBorder: "#4b5563",
74
83
  fieldText: "#e2e8f0",
84
+ fieldPlaceholder: "#94a3b8",
75
85
  fieldErrorBg: "#3f2124",
76
86
  fieldErrorBorder: "#ef4444",
77
87
  cancelBg: "#334155",
@@ -96,6 +106,7 @@ function _(t, c, i, n) {
96
106
  fieldFocusBg: "#f9f9ff",
97
107
  fieldBorder: "#d0d0d0",
98
108
  fieldText: "#333333",
109
+ fieldPlaceholder: "#9ca3af",
99
110
  fieldErrorBg: "#ffebee",
100
111
  fieldErrorBorder: "#d32f2f",
101
112
  cancelBg: "#f0f0f0",
@@ -108,8 +119,8 @@ function _(t, c, i, n) {
108
119
  help: "#999999",
109
120
  focusRing: "rgba(0, 102, 204, 0.1)",
110
121
  errorRing: "rgba(211, 47, 47, 0.1)"
111
- }, r = document.createElement("div");
112
- r.className = "rte-anchor-dialog-overlay", r.style.cssText = `
122
+ }, i = document.createElement("div");
123
+ i.className = "rte-anchor-dialog-overlay", i.style.cssText = `
113
124
  position: fixed;
114
125
  top: 0;
115
126
  left: 0;
@@ -133,8 +144,8 @@ function _(t, c, i, n) {
133
144
  overflow: hidden;
134
145
  animation: rte-anchor-dialog-appear 0.2s ease;
135
146
  `, !document.getElementById("rte-anchor-dialog-styles")) {
136
- const s = document.createElement("style");
137
- s.id = "rte-anchor-dialog-styles", s.textContent = `
147
+ const n = document.createElement("style");
148
+ n.id = "rte-anchor-dialog-styles", n.textContent = `
138
149
  @keyframes rte-anchor-dialog-appear {
139
150
  from { opacity: 0; transform: scale(0.95); }
140
151
  to { opacity: 1; transform: scale(1); }
@@ -142,11 +153,11 @@ function _(t, c, i, n) {
142
153
  .rte-anchor-dialog input:focus {
143
154
  outline: none !important;
144
155
  }
145
- `, document.head.appendChild(s);
156
+ `, document.head.appendChild(n);
146
157
  }
147
- let l = "";
148
- const h = document.createElement("div");
149
- h.style.cssText = `
158
+ let r = "";
159
+ const f = document.createElement("div");
160
+ f.style.cssText = `
150
161
  display: flex;
151
162
  align-items: center;
152
163
  justify-content: space-between;
@@ -155,9 +166,9 @@ function _(t, c, i, n) {
155
166
  background: ${e.panelBg};
156
167
  `;
157
168
  const w = document.createElement("h3");
158
- w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor";
159
- const f = document.createElement("button");
160
- f.textContent = "✕", f.style.cssText = `
169
+ w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = t === "add" ? "Add Anchor" : "Edit Anchor";
170
+ const p = document.createElement("button");
171
+ p.textContent = "✕", p.style.cssText = `
161
172
  background: none;
162
173
  border: none;
163
174
  font-size: 24px;
@@ -171,19 +182,19 @@ function _(t, c, i, n) {
171
182
  justify-content: center;
172
183
  border-radius: 4px;
173
184
  transition: all 0.2s ease;
174
- `, f.onmouseover = () => {
175
- f.style.background = e.closeHoverBg, f.style.color = "#f8fafc";
176
- }, f.onmouseout = () => {
177
- f.style.background = "none", f.style.color = e.muted;
178
- }, h.appendChild(w), h.appendChild(f);
185
+ `, p.onmouseover = () => {
186
+ p.style.background = e.closeHoverBg, p.style.color = "#f8fafc";
187
+ }, p.onmouseout = () => {
188
+ p.style.background = "none", p.style.color = e.muted;
189
+ }, f.appendChild(w), f.appendChild(p);
179
190
  const C = document.createElement("div");
180
191
  C.style.cssText = "padding: 20px;";
181
- const m = document.createElement("div");
182
- m.style.cssText = "margin-bottom: 0;";
183
- const y = document.createElement("label");
184
- y.textContent = "Anchor ID", y.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, y.setAttribute("for", "anchor-id-input");
192
+ const x = document.createElement("div");
193
+ x.style.cssText = "margin-bottom: 0;";
194
+ const m = document.createElement("label");
195
+ m.textContent = "Anchor ID", m.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, m.setAttribute("for", "anchor-id-input");
185
196
  const o = document.createElement("input");
186
- o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value = "", o.style.cssText = `
197
+ o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value = l || "", o.style.cssText = `
187
198
  width: 100%;
188
199
  padding: 10px 12px;
189
200
  font-size: 14px;
@@ -195,15 +206,15 @@ function _(t, c, i, n) {
195
206
  transition: all 0.2s ease;
196
207
  box-sizing: border-box;
197
208
  `, o.style.setProperty("caret-color", e.fieldText);
198
- const p = document.createElement("div");
199
- p.style.cssText = `
209
+ const g = document.createElement("div");
210
+ g.style.cssText = `
200
211
  color: #d32f2f;
201
212
  font-size: 12px;
202
213
  margin-top: 6px;
203
214
  display: none;
204
215
  `;
205
216
  const B = document.createElement("div");
206
- B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`, m.appendChild(y), m.appendChild(o), m.appendChild(p), m.appendChild(B), C.appendChild(m);
217
+ B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`, x.appendChild(m), x.appendChild(o), x.appendChild(g), x.appendChild(B), C.appendChild(x);
207
218
  const v = document.createElement("div");
208
219
  v.style.cssText = `
209
220
  display: flex;
@@ -213,8 +224,8 @@ function _(t, c, i, n) {
213
224
  background: ${e.panelBg};
214
225
  justify-content: flex-end;
215
226
  `;
216
- const g = document.createElement("button");
217
- g.textContent = "Cancel", g.style.cssText = `
227
+ const b = document.createElement("button");
228
+ b.textContent = "Cancel", b.style.cssText = `
218
229
  padding: 8px 16px;
219
230
  font-size: 14px;
220
231
  font-weight: 500;
@@ -224,9 +235,9 @@ function _(t, c, i, n) {
224
235
  transition: all 0.2s ease;
225
236
  background: ${e.cancelBg};
226
237
  color: ${e.cancelText};
227
- `, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
228
- const a = document.createElement("button");
229
- a.textContent = "Add Anchor", a.style.cssText = `
238
+ `, b.onmouseover = () => b.style.background = e.cancelHover, b.onmouseout = () => b.style.background = e.cancelBg;
239
+ const c = document.createElement("button");
240
+ c.textContent = t === "add" ? "Add Anchor" : "Save Changes", c.style.cssText = `
230
241
  padding: 8px 16px;
231
242
  font-size: 14px;
232
243
  font-weight: 500;
@@ -236,78 +247,80 @@ function _(t, c, i, n) {
236
247
  transition: all 0.2s ease;
237
248
  background: ${e.saveBg};
238
249
  color: white;
239
- `, a.disabled = !o.value.trim();
250
+ `, c.disabled = !o.value.trim();
240
251
  const $ = () => {
241
- o.value.trim() ? (a.disabled = !1, a.style.background = e.saveBg, a.style.color = "white", a.style.cursor = "pointer") : (a.disabled = !0, a.style.background = e.saveDisabledBg, a.style.color = e.saveDisabledText, a.style.cursor = "not-allowed");
252
+ o.value.trim() ? (c.disabled = !1, c.style.background = e.saveBg, c.style.color = "white", c.style.cursor = "pointer") : (c.disabled = !0, c.style.background = e.saveDisabledBg, c.style.color = e.saveDisabledText, c.style.cursor = "not-allowed");
242
253
  };
243
- a.onmouseover = () => {
244
- a.disabled || (a.style.background = e.saveHover, a.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
245
- }, a.onmouseout = () => {
246
- a.disabled || (a.style.background = e.saveBg, a.style.boxShadow = "none");
247
- }, v.appendChild(g), v.appendChild(a), o.oninput = () => {
248
- const s = o.value;
249
- if ($(), s.trim()) {
250
- const k = A(s);
251
- k.valid ? b.has(s) ? (l = `Anchor ID already exists: ${s}`, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (l = "", p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (l = k.error, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg);
254
+ c.onmouseover = () => {
255
+ c.disabled || (c.style.background = e.saveHover, c.style.boxShadow = a ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
256
+ }, c.onmouseout = () => {
257
+ c.disabled || (c.style.background = e.saveBg, c.style.boxShadow = "none");
258
+ }, v.appendChild(b), v.appendChild(c), o.oninput = () => {
259
+ const n = o.value;
260
+ if ($(), n.trim()) {
261
+ const k = A(n);
262
+ k.valid ? t === "add" && h.has(n) ? (r = `Anchor ID already exists: ${n}`, g.textContent = "⚠ " + r, g.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : t === "edit" && n !== l && h.has(n) ? (r = `Anchor ID already exists: ${n}`, g.textContent = "⚠ " + r, g.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (r = "", g.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (r = k.error, g.textContent = "⚠ " + r, g.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg);
252
263
  } else
253
- p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg;
264
+ g.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg;
254
265
  }, o.onfocus = () => {
255
- o.style.borderColor = l ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = l ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = l ? e.fieldErrorBg : e.fieldFocusBg;
266
+ o.style.borderColor = r ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = r ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = r ? e.fieldErrorBg : e.fieldFocusBg;
256
267
  }, o.onblur = () => {
257
- o.style.boxShadow = "none", l || (o.style.background = e.fieldBg);
268
+ o.style.boxShadow = "none", r || (o.style.background = e.fieldBg);
258
269
  };
259
270
  const T = () => {
260
- const s = o.value.trim();
261
- !s || !A(s).valid || b.has(s) || (i && i(s), r.remove());
271
+ const n = o.value.trim();
272
+ !n || !A(n).valid || t === "add" && h.has(n) || t === "edit" && n !== l && h.has(n) || (s && s(n), i.remove());
262
273
  }, E = () => {
263
- r.remove();
274
+ i.remove();
264
275
  };
265
- a.onclick = T, g.onclick = E, f.onclick = E, o.onkeydown = (s) => {
266
- s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), E());
267
- }, r.onclick = (s) => {
268
- s.target === r && E();
269
- }, u.appendChild(h), u.appendChild(C), u.appendChild(v), r.appendChild(u), document.body.appendChild(r), setTimeout(() => o.focus(), 100);
276
+ c.onclick = T, b.onclick = E, p.onclick = E, o.onkeydown = (n) => {
277
+ n.key === "Enter" ? (n.preventDefault(), T()) : n.key === "Escape" && (n.preventDefault(), E());
278
+ }, i.onclick = (n) => {
279
+ n.target === i && E();
280
+ }, u.appendChild(f), u.appendChild(C), u.appendChild(v), i.appendChild(u), document.body.appendChild(i), setTimeout(() => o.focus(), 100);
270
281
  }
271
- function I(t, c) {
272
- let i;
273
- if (c)
274
- i = c;
282
+ function I(t, l) {
283
+ let s;
284
+ if (l)
285
+ s = l;
275
286
  else {
276
- const l = window.getSelection();
277
- if (!l || l.rangeCount === 0) return;
278
- i = l.getRangeAt(0);
287
+ const r = window.getSelection();
288
+ if (!r || r.rangeCount === 0)
289
+ return;
290
+ s = r.getRangeAt(0);
279
291
  }
280
- let n = null, d = i.startContainer;
281
- for (; d && d !== document.body; ) {
282
- if (d.nodeType === Node.ELEMENT_NODE) {
283
- const l = d;
284
- if (l.getAttribute("contenteditable") === "true") {
285
- n = l;
292
+ let d = null, a = s.startContainer;
293
+ for (; a && a !== document.body; ) {
294
+ if (a.nodeType === Node.ELEMENT_NODE) {
295
+ const r = a;
296
+ if (r.getAttribute("contenteditable") === "true") {
297
+ d = r;
286
298
  break;
287
299
  }
288
300
  }
289
- d = d.parentNode;
301
+ a = a.parentNode;
290
302
  }
291
- const e = n?.innerHTML ?? "", r = document.createElement("span");
292
- r.id = t, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", t), r.setAttribute("title", `Anchor: ${t}`), r.style.cssText = `
303
+ const e = (d == null ? void 0 : d.innerHTML) ?? "", i = document.createElement("span");
304
+ i.id = t, i.className = "rte-anchor", i.setAttribute("data-type", "anchor"), i.setAttribute("data-anchor-id", t), i.setAttribute("title", `Anchor: ${t}`), i.style.cssText = `
293
305
  display: inline;
294
306
  position: relative;
295
307
  cursor: pointer;
296
- `, i.insertNode(r), b.add(t), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
308
+ `, s.insertNode(i), h.add(t), s.setStart(i.nextSibling || i.parentNode, 0), s.collapse(!0);
297
309
  const u = window.getSelection();
298
- if (u && (u.removeAllRanges(), u.addRange(i)), n)
299
- z(n, e), n.dispatchEvent(new Event("input", { bubbles: !0 }));
310
+ if (u && (u.removeAllRanges(), u.addRange(s)), d)
311
+ z(d, e), d.dispatchEvent(new Event("input", { bubbles: !0 }));
300
312
  else {
301
- const l = D();
302
- if (l) {
303
- const h = S(l);
304
- h && h.dispatchEvent(new Event("input", { bubbles: !0 }));
313
+ const r = D();
314
+ if (r) {
315
+ const f = S(r);
316
+ f && f.dispatchEvent(new Event("input", { bubbles: !0 }));
305
317
  }
306
318
  }
307
319
  N();
308
320
  }
309
321
  function N() {
310
- if (document.getElementById("rte-anchor-styles")) return;
322
+ if (document.getElementById("rte-anchor-styles"))
323
+ return;
311
324
  const t = document.createElement("style");
312
325
  t.id = "rte-anchor-styles", t.textContent = `
313
326
  .rte-anchor {
@@ -405,10 +418,10 @@ const O = () => (typeof window < "u" && (R(), N()), {
405
418
  const t = window.getSelection();
406
419
  if (!t || t.rangeCount === 0)
407
420
  return alert("Please place your cursor where you want to insert the anchor."), !1;
408
- const c = t.getRangeAt(0).cloneRange();
409
- return _("add", "", (i) => {
410
- I(i, c);
411
- }, c), !0;
421
+ const l = t.getRangeAt(0).cloneRange();
422
+ return _("add", "", (s) => {
423
+ I(s, l);
424
+ }, l), !0;
412
425
  } catch (t) {
413
426
  return console.error("Failed to insert anchor:", t), !1;
414
427
  }
@@ -0,0 +1,109 @@
1
+ const b = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
2
+ function p(e) {
3
+ return !!e.cloneContents().querySelector(b);
4
+ }
5
+ function v(e, n) {
6
+ var o;
7
+ const t = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : (e == null ? void 0 : e.parentElement) ?? null;
8
+ return (t == null ? void 0 : t.closest('[contenteditable="true"]')) || ((o = n()) == null ? void 0 : o.querySelector('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
9
+ }
10
+ function C(e, n) {
11
+ const t = v(e, n);
12
+ t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
13
+ }
14
+ function A(e, n) {
15
+ let o = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
16
+ for (; o && o !== document.body; ) {
17
+ if (o.classList.contains(n)) {
18
+ const r = document.createRange();
19
+ if (r.selectNodeContents(o), r.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && r.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
20
+ return o;
21
+ }
22
+ o = o.parentElement;
23
+ }
24
+ return null;
25
+ }
26
+ function N(e) {
27
+ try {
28
+ if (e.savedRange) {
29
+ const c = window.getSelection();
30
+ c && (c.removeAllRanges(), c.addRange(e.savedRange.cloneRange()));
31
+ }
32
+ const n = window.getSelection();
33
+ if (!n || n.rangeCount === 0 || n.isCollapsed)
34
+ return !1;
35
+ const t = n.getRangeAt(0);
36
+ if (t.collapsed)
37
+ return !1;
38
+ const o = A(t, e.className);
39
+ if (o)
40
+ return e.styleProperty === "backgroundColor" ? o.style.backgroundColor = e.color : o.style.color = e.color, C(o, e.getActiveEditorRoot), !0;
41
+ const r = v(
42
+ t.commonAncestorContainer,
43
+ e.getActiveEditorRoot
44
+ );
45
+ r == null || r.focus({ preventScroll: !0 });
46
+ try {
47
+ document.execCommand("styleWithCSS", !1, "true");
48
+ } catch {
49
+ }
50
+ let l = !1;
51
+ if (e.commands.forEach((c) => {
52
+ l || (l = document.execCommand(c, !1, e.color));
53
+ }), !l && !p(t)) {
54
+ const c = document.createElement("span");
55
+ e.styleProperty === "backgroundColor" ? c.style.backgroundColor = e.color : c.style.color = e.color, c.className = e.className;
56
+ const a = t.extractContents();
57
+ c.appendChild(a), t.insertNode(c), t.setStartAfter(c), t.collapse(!0), n.removeAllRanges(), n.addRange(t), l = !0;
58
+ }
59
+ return l ? (C(t.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
60
+ } catch (n) {
61
+ return e.warnMessage ? console.error(e.warnMessage, n) : console.error("[ColorApply] Failed to apply color", n), !1;
62
+ }
63
+ }
64
+ function T({
65
+ popover: e,
66
+ anchor: n,
67
+ onClose: t,
68
+ gap: o = 6,
69
+ margin: r = 8,
70
+ zIndex: l = 1e4
71
+ }) {
72
+ e.style.position = "fixed", e.style.zIndex = `${l}`, e.style.visibility = "hidden";
73
+ const c = () => {
74
+ if (!e.isConnected || !n.isConnected) {
75
+ t();
76
+ return;
77
+ }
78
+ const s = n.getBoundingClientRect();
79
+ if (s.width === 0 && s.height === 0) {
80
+ t();
81
+ return;
82
+ }
83
+ const i = e.getBoundingClientRect(), w = i.width || e.offsetWidth || 220, f = i.height || e.offsetHeight || 260, y = window.innerWidth, E = window.innerHeight;
84
+ let u = s.left, d = s.bottom + o;
85
+ if (u + w > y - r && (u = y - w - r), u = Math.max(r, u), d + f > E - r) {
86
+ const g = s.top - f - o;
87
+ g >= r ? d = g : d = Math.max(r, E - f - r);
88
+ }
89
+ d < r && (d = r), e.style.left = `${Math.round(u)}px`, e.style.top = `${Math.round(d)}px`, e.style.visibility = "visible";
90
+ }, a = () => {
91
+ c();
92
+ }, h = (s) => {
93
+ const i = s.target;
94
+ i && (e.contains(i) || n.contains(i) || t());
95
+ }, m = (s) => {
96
+ s.key === "Escape" && t();
97
+ };
98
+ window.addEventListener("resize", a), window.addEventListener("scroll", a, !0), document.addEventListener("keydown", m);
99
+ const R = window.requestAnimationFrame(() => {
100
+ document.addEventListener("mousedown", h, !0);
101
+ });
102
+ return c(), { reposition: c, destroy: () => {
103
+ window.cancelAnimationFrame(R), window.removeEventListener("resize", a), window.removeEventListener("scroll", a, !0), document.removeEventListener("keydown", m), document.removeEventListener("mousedown", h, !0);
104
+ } };
105
+ }
106
+ export {
107
+ N as a,
108
+ T as b
109
+ };