@editora/plugins 1.0.2 → 1.0.4

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 (105) hide show
  1. package/README.md +30 -5
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +598 -0
  21. package/dist/code.esm.js +2034 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +218 -6
  103. package/LICENSE +0 -21
  104. package/dist/index-BbORIHoM.mjs +0 -11763
  105. package/dist/index-C-OCBS_6.js +0 -3753
@@ -0,0 +1,176 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./editorContainerHelpers-CFbfiOJI.js"),h=new Set,m='[data-theme="dark"], .dark, .editora-theme-dark';function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(d=>{d.forEach(s=>{s.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(l.classList?.contains("rte-anchor")){const a=l.id;a&&h.delete(a)}l.querySelectorAll?.(".rte-anchor")?.forEach(a=>{const u=a.id;u&&h.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(o){return!o||o.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:o.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(o)?/^[a-z0-9\-_]+$/.test(o)?{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 R(){const o=w.findEditorContainerFromSelection();if(!o)return;const d=w.getContentElement(o);if(!d)return;const s=d.querySelectorAll(".rte-anchor"),r=new Set;s.forEach(l=>{const e=l.id;e&&r.add(e)}),h.clear(),r.forEach(l=>h.add(l))}function N(o){if(o){const r=o.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(m))return!0}const d=window.getSelection();if(d&&d.rangeCount>0){const r=d.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(m))return!0}return document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}function M(o,d,s,r){R();const l=N(r),e=l?{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)"},a=document.createElement("div");a.className="rte-anchor-dialog-overlay",a.style.cssText=`
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background: ${e.overlay};
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ z-index: 10000;
12
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
13
+ `;const u=document.createElement("div");if(u.className="rte-anchor-dialog",u.style.cssText=`
14
+ background: ${e.dialogBg};
15
+ border: 1px solid ${e.border};
16
+ border-radius: 8px;
17
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
18
+ width: 90%;
19
+ max-width: 450px;
20
+ overflow: hidden;
21
+ animation: rte-anchor-dialog-appear 0.2s ease;
22
+ `,!document.getElementById("rte-anchor-dialog-styles")){const i=document.createElement("style");i.id="rte-anchor-dialog-styles",i.textContent=`
23
+ @keyframes rte-anchor-dialog-appear {
24
+ from { opacity: 0; transform: scale(0.95); }
25
+ to { opacity: 1; transform: scale(1); }
26
+ }
27
+ .rte-anchor-dialog input:focus {
28
+ outline: none !important;
29
+ }
30
+ `,document.head.appendChild(i)}let p="";const x=document.createElement("div");x.style.cssText=`
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: space-between;
34
+ padding: 16px 20px;
35
+ border-bottom: 1px solid ${e.border};
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 c=document.createElement("button");c.textContent="✕",c.style.cssText=`
38
+ background: none;
39
+ border: none;
40
+ font-size: 24px;
41
+ color: ${e.muted};
42
+ cursor: pointer;
43
+ padding: 0;
44
+ width: 32px;
45
+ height: 32px;
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ border-radius: 4px;
50
+ transition: all 0.2s ease;
51
+ `,c.onmouseover=()=>{c.style.background=e.closeHoverBg,c.style.color="#f8fafc"},c.onmouseout=()=>{c.style.background="none",c.style.color=e.muted},x.appendChild(C),x.appendChild(c);const B=document.createElement("div");B.style.cssText="padding: 20px;";const b=document.createElement("div");b.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 t=document.createElement("input");t.id="anchor-id-input",t.type="text",t.placeholder="e.g., section-introduction",t.value="",t.style.cssText=`
52
+ width: 100%;
53
+ padding: 10px 12px;
54
+ font-size: 14px;
55
+ border: 1px solid ${e.fieldBorder};
56
+ border-radius: 4px;
57
+ font-family: 'Courier New', monospace;
58
+ color: ${e.fieldText};
59
+ background: ${e.fieldBg};
60
+ transition: all 0.2s ease;
61
+ box-sizing: border-box;
62
+ `,t.style.setProperty("caret-color",e.fieldText);const f=document.createElement("div");f.style.cssText=`
63
+ color: #d32f2f;
64
+ font-size: 12px;
65
+ margin-top: 6px;
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;`,b.appendChild(y),b.appendChild(t),b.appendChild(f),b.appendChild(k),B.appendChild(b);const v=document.createElement("div");v.style.cssText=`
68
+ display: flex;
69
+ gap: 12px;
70
+ padding: 16px 20px;
71
+ border-top: 1px solid ${e.border};
72
+ background: ${e.panelBg};
73
+ justify-content: flex-end;
74
+ `;const g=document.createElement("button");g.textContent="Cancel",g.style.cssText=`
75
+ padding: 8px 16px;
76
+ font-size: 14px;
77
+ font-weight: 500;
78
+ border: none;
79
+ border-radius: 4px;
80
+ cursor: pointer;
81
+ transition: all 0.2s ease;
82
+ background: ${e.cancelBg};
83
+ color: ${e.cancelText};
84
+ `,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const n=document.createElement("button");n.textContent="Add Anchor",n.style.cssText=`
85
+ padding: 8px 16px;
86
+ font-size: 14px;
87
+ font-weight: 500;
88
+ border: none;
89
+ border-radius: 4px;
90
+ cursor: pointer;
91
+ transition: all 0.2s ease;
92
+ background: ${e.saveBg};
93
+ color: white;
94
+ `,n.disabled=!t.value.trim();const $=()=>{t.value.trim()?(n.disabled=!1,n.style.background=e.saveBg,n.style.color="white",n.style.cursor="pointer"):(n.disabled=!0,n.style.background=e.saveDisabledBg,n.style.color=e.saveDisabledText,n.style.cursor="not-allowed")};n.onmouseover=()=>{n.disabled||(n.style.background=e.saveHover,n.style.boxShadow=l?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},n.onmouseout=()=>{n.disabled||(n.style.background=e.saveBg,n.style.boxShadow="none")},v.appendChild(g),v.appendChild(n),t.oninput=()=>{const i=t.value;if($(),i.trim()){const T=S(i);T.valid?h.has(i)?(p=`Anchor ID already exists: ${i}`,f.textContent="⚠ "+p,f.style.display="block",t.style.borderColor=e.fieldErrorBorder,t.style.background=e.fieldErrorBg):(p="",f.style.display="none",t.style.borderColor=e.fieldBorder,t.style.background=e.fieldBg):(p=T.error,f.textContent="⚠ "+p,f.style.display="block",t.style.borderColor=e.fieldErrorBorder,t.style.background=e.fieldErrorBg)}else f.style.display="none",t.style.borderColor=e.fieldBorder,t.style.background=e.fieldBg},t.onfocus=()=>{t.style.borderColor=p?e.fieldErrorBorder:e.saveBg,t.style.boxShadow=p?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,t.style.background=p?e.fieldErrorBg:e.fieldFocusBg},t.onblur=()=>{t.style.boxShadow="none",p||(t.style.background=e.fieldBg)};const A=()=>{const i=t.value.trim();!i||!S(i).valid||h.has(i)||(s&&s(i),a.remove())},E=()=>{a.remove()};n.onclick=A,g.onclick=E,c.onclick=E,t.onkeydown=i=>{i.key==="Enter"?(i.preventDefault(),A()):i.key==="Escape"&&(i.preventDefault(),E())},a.onclick=i=>{i.target===a&&E()},u.appendChild(x),u.appendChild(B),u.appendChild(v),a.appendChild(u),document.body.appendChild(a),setTimeout(()=>t.focus(),100)}function H(o,d){let s;if(d)s=d;else{const a=window.getSelection();if(!a||a.rangeCount===0)return;s=a.getRangeAt(0)}const r=document.createElement("span");r.id=o,r.className="rte-anchor",r.setAttribute("data-type","anchor"),r.setAttribute("data-anchor-id",o),r.setAttribute("title",`Anchor: ${o}`),r.style.cssText=`
95
+ display: inline;
96
+ position: relative;
97
+ cursor: pointer;
98
+ `,s.insertNode(r),h.add(o),s.setStart(r.nextSibling||r.parentNode,0),s.collapse(!0);const l=window.getSelection();l&&(l.removeAllRanges(),l.addRange(s));const e=w.findEditorContainerFromSelection();if(e){const a=w.getContentElement(e);a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const o=document.createElement("style");o.id="rte-anchor-styles",o.textContent=`
99
+ .rte-anchor {
100
+ display: inline;
101
+ position: relative;
102
+ cursor: pointer;
103
+ transition: all 0.2s ease;
104
+ }
105
+
106
+ .rte-anchor:hover::before {
107
+ content: '⚓';
108
+ position: absolute;
109
+ top: -1.2em;
110
+ left: 0;
111
+ background: #333;
112
+ color: #fff;
113
+ padding: 2px 6px;
114
+ border-radius: 3px;
115
+ font-size: 0.8em;
116
+ white-space: nowrap;
117
+ z-index: 100;
118
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
119
+ }
120
+
121
+ .rte-anchor:hover::after {
122
+ content: attr(data-anchor-id);
123
+ position: absolute;
124
+ top: -1.2em;
125
+ left: 1.4em;
126
+ background: #333;
127
+ color: #fff;
128
+ padding: 2px 6px;
129
+ border-radius: 3px;
130
+ font-size: 0.75em;
131
+ font-family: 'Courier New', monospace;
132
+ white-space: nowrap;
133
+ z-index: 100;
134
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
135
+ }
136
+
137
+ [contenteditable='true'] .rte-anchor::before {
138
+ content: '';
139
+ position: absolute;
140
+ width: 8px;
141
+ height: 8px;
142
+ background: #0066cc;
143
+ border-radius: 50%;
144
+ top: -3px;
145
+ left: 0;
146
+ opacity: 0.5;
147
+ transition: opacity 0.2s ease;
148
+ }
149
+
150
+ [contenteditable='true'] .rte-anchor:hover::before {
151
+ opacity: 1;
152
+ width: auto;
153
+ height: auto;
154
+ background: #333;
155
+ border-radius: 3px;
156
+ top: -1.2em;
157
+ padding: 2px 6px;
158
+ font-size: 0.8em;
159
+ content: '⚓';
160
+ }
161
+
162
+ @media print {
163
+ .rte-anchor::before,
164
+ .rte-anchor::after {
165
+ display: none;
166
+ }
167
+ .rte-anchor {
168
+ cursor: auto;
169
+ }
170
+ }
171
+
172
+ .rte-anchor:focus {
173
+ outline: 2px solid #0066cc;
174
+ outline-offset: 2px;
175
+ }
176
+ `,document.head.appendChild(o)}const _=()=>(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 o=window.getSelection();if(!o||o.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const d=o.getRangeAt(0).cloneRange();return M("add","",s=>{H(s,d)},d),!0}catch(o){return console.error("Failed to insert anchor:",o),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=_;
@@ -0,0 +1,400 @@
1
+ import { f as S, g as D } from "./editorContainerHelpers-C7kdWnS0.mjs";
2
+ const h = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark';
3
+ function R() {
4
+ if (typeof window > "u" || window.__anchorObserverInitialized) return;
5
+ window.__anchorObserverInitialized = !0, new MutationObserver((l) => {
6
+ l.forEach((i) => {
7
+ i.removedNodes.forEach((r) => {
8
+ if (r.nodeType === Node.ELEMENT_NODE) {
9
+ const d = r;
10
+ if (d.classList?.contains("rte-anchor")) {
11
+ const a = d.id;
12
+ a && h.delete(a);
13
+ }
14
+ d.querySelectorAll?.(".rte-anchor")?.forEach((a) => {
15
+ const u = a.id;
16
+ u && h.delete(u);
17
+ });
18
+ }
19
+ });
20
+ });
21
+ }).observe(document.body, {
22
+ childList: !0,
23
+ subtree: !0
24
+ });
25
+ }
26
+ function A(o) {
27
+ return !o || o.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : o.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[a-z_]/.test(o) ? /^[a-z0-9\-_]+$/.test(o) ? { 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" };
28
+ }
29
+ function N() {
30
+ const o = S();
31
+ if (!o) return;
32
+ const l = D(o);
33
+ if (!l) return;
34
+ const i = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
35
+ i.forEach((d) => {
36
+ const e = d.id;
37
+ e && r.add(e);
38
+ }), h.clear(), r.forEach((d) => h.add(d));
39
+ }
40
+ function M(o) {
41
+ if (o) {
42
+ const r = o.startContainer;
43
+ if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
44
+ }
45
+ const l = window.getSelection();
46
+ if (l && l.rangeCount > 0) {
47
+ const r = l.getRangeAt(0).startContainer;
48
+ if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
49
+ }
50
+ return document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
51
+ }
52
+ function _(o, l, i, r) {
53
+ N();
54
+ const d = M(r), e = d ? {
55
+ overlay: "rgba(0, 0, 0, 0.62)",
56
+ dialogBg: "#1f2937",
57
+ panelBg: "#222d3a",
58
+ border: "#3b4657",
59
+ text: "#e2e8f0",
60
+ muted: "#94a3b8",
61
+ closeHoverBg: "#334155",
62
+ fieldBg: "#111827",
63
+ fieldFocusBg: "#111827",
64
+ fieldBorder: "#4b5563",
65
+ fieldText: "#e2e8f0",
66
+ fieldErrorBg: "#3f2124",
67
+ fieldErrorBorder: "#ef4444",
68
+ cancelBg: "#334155",
69
+ cancelHover: "#475569",
70
+ cancelText: "#e2e8f0",
71
+ saveBg: "#3b82f6",
72
+ saveHover: "#2563eb",
73
+ saveDisabledBg: "#374151",
74
+ saveDisabledText: "#7f8ca1",
75
+ help: "#9fb0c6",
76
+ focusRing: "rgba(88, 166, 255, 0.25)",
77
+ errorRing: "rgba(239, 68, 68, 0.25)"
78
+ } : {
79
+ overlay: "rgba(0, 0, 0, 0.5)",
80
+ dialogBg: "#ffffff",
81
+ panelBg: "#f9f9f9",
82
+ border: "#e0e0e0",
83
+ text: "#333333",
84
+ muted: "#999999",
85
+ closeHoverBg: "#e0e0e0",
86
+ fieldBg: "#ffffff",
87
+ fieldFocusBg: "#f9f9ff",
88
+ fieldBorder: "#d0d0d0",
89
+ fieldText: "#333333",
90
+ fieldErrorBg: "#ffebee",
91
+ fieldErrorBorder: "#d32f2f",
92
+ cancelBg: "#f0f0f0",
93
+ cancelHover: "#e0e0e0",
94
+ cancelText: "#333333",
95
+ saveBg: "#0066cc",
96
+ saveHover: "#0052a3",
97
+ saveDisabledBg: "#d0d0d0",
98
+ saveDisabledText: "#999999",
99
+ help: "#999999",
100
+ focusRing: "rgba(0, 102, 204, 0.1)",
101
+ errorRing: "rgba(211, 47, 47, 0.1)"
102
+ }, a = document.createElement("div");
103
+ a.className = "rte-anchor-dialog-overlay", a.style.cssText = `
104
+ position: fixed;
105
+ top: 0;
106
+ left: 0;
107
+ right: 0;
108
+ bottom: 0;
109
+ background: ${e.overlay};
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: center;
113
+ z-index: 10000;
114
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
115
+ `;
116
+ const u = document.createElement("div");
117
+ if (u.className = "rte-anchor-dialog", u.style.cssText = `
118
+ background: ${e.dialogBg};
119
+ border: 1px solid ${e.border};
120
+ border-radius: 8px;
121
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
122
+ width: 90%;
123
+ max-width: 450px;
124
+ overflow: hidden;
125
+ animation: rte-anchor-dialog-appear 0.2s ease;
126
+ `, !document.getElementById("rte-anchor-dialog-styles")) {
127
+ const s = document.createElement("style");
128
+ s.id = "rte-anchor-dialog-styles", s.textContent = `
129
+ @keyframes rte-anchor-dialog-appear {
130
+ from { opacity: 0; transform: scale(0.95); }
131
+ to { opacity: 1; transform: scale(1); }
132
+ }
133
+ .rte-anchor-dialog input:focus {
134
+ outline: none !important;
135
+ }
136
+ `, document.head.appendChild(s);
137
+ }
138
+ let p = "";
139
+ const x = document.createElement("div");
140
+ x.style.cssText = `
141
+ display: flex;
142
+ align-items: center;
143
+ justify-content: space-between;
144
+ padding: 16px 20px;
145
+ border-bottom: 1px solid ${e.border};
146
+ background: ${e.panelBg};
147
+ `;
148
+ const w = document.createElement("h3");
149
+ w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor";
150
+ const c = document.createElement("button");
151
+ c.textContent = "✕", c.style.cssText = `
152
+ background: none;
153
+ border: none;
154
+ font-size: 24px;
155
+ color: ${e.muted};
156
+ cursor: pointer;
157
+ padding: 0;
158
+ width: 32px;
159
+ height: 32px;
160
+ display: flex;
161
+ align-items: center;
162
+ justify-content: center;
163
+ border-radius: 4px;
164
+ transition: all 0.2s ease;
165
+ `, c.onmouseover = () => {
166
+ c.style.background = e.closeHoverBg, c.style.color = "#f8fafc";
167
+ }, c.onmouseout = () => {
168
+ c.style.background = "none", c.style.color = e.muted;
169
+ }, x.appendChild(w), x.appendChild(c);
170
+ const C = document.createElement("div");
171
+ C.style.cssText = "padding: 20px;";
172
+ const b = document.createElement("div");
173
+ b.style.cssText = "margin-bottom: 0;";
174
+ const y = document.createElement("label");
175
+ 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");
176
+ const t = document.createElement("input");
177
+ t.id = "anchor-id-input", t.type = "text", t.placeholder = "e.g., section-introduction", t.value = "", t.style.cssText = `
178
+ width: 100%;
179
+ padding: 10px 12px;
180
+ font-size: 14px;
181
+ border: 1px solid ${e.fieldBorder};
182
+ border-radius: 4px;
183
+ font-family: 'Courier New', monospace;
184
+ color: ${e.fieldText};
185
+ background: ${e.fieldBg};
186
+ transition: all 0.2s ease;
187
+ box-sizing: border-box;
188
+ `, t.style.setProperty("caret-color", e.fieldText);
189
+ const f = document.createElement("div");
190
+ f.style.cssText = `
191
+ color: #d32f2f;
192
+ font-size: 12px;
193
+ margin-top: 6px;
194
+ display: none;
195
+ `;
196
+ const B = document.createElement("div");
197
+ 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;`, b.appendChild(y), b.appendChild(t), b.appendChild(f), b.appendChild(B), C.appendChild(b);
198
+ const v = document.createElement("div");
199
+ v.style.cssText = `
200
+ display: flex;
201
+ gap: 12px;
202
+ padding: 16px 20px;
203
+ border-top: 1px solid ${e.border};
204
+ background: ${e.panelBg};
205
+ justify-content: flex-end;
206
+ `;
207
+ const g = document.createElement("button");
208
+ g.textContent = "Cancel", g.style.cssText = `
209
+ padding: 8px 16px;
210
+ font-size: 14px;
211
+ font-weight: 500;
212
+ border: none;
213
+ border-radius: 4px;
214
+ cursor: pointer;
215
+ transition: all 0.2s ease;
216
+ background: ${e.cancelBg};
217
+ color: ${e.cancelText};
218
+ `, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
219
+ const n = document.createElement("button");
220
+ n.textContent = "Add Anchor", n.style.cssText = `
221
+ padding: 8px 16px;
222
+ font-size: 14px;
223
+ font-weight: 500;
224
+ border: none;
225
+ border-radius: 4px;
226
+ cursor: pointer;
227
+ transition: all 0.2s ease;
228
+ background: ${e.saveBg};
229
+ color: white;
230
+ `, n.disabled = !t.value.trim();
231
+ const z = () => {
232
+ t.value.trim() ? (n.disabled = !1, n.style.background = e.saveBg, n.style.color = "white", n.style.cursor = "pointer") : (n.disabled = !0, n.style.background = e.saveDisabledBg, n.style.color = e.saveDisabledText, n.style.cursor = "not-allowed");
233
+ };
234
+ n.onmouseover = () => {
235
+ n.disabled || (n.style.background = e.saveHover, n.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
236
+ }, n.onmouseout = () => {
237
+ n.disabled || (n.style.background = e.saveBg, n.style.boxShadow = "none");
238
+ }, v.appendChild(g), v.appendChild(n), t.oninput = () => {
239
+ const s = t.value;
240
+ if (z(), s.trim()) {
241
+ const k = A(s);
242
+ k.valid ? h.has(s) ? (p = `Anchor ID already exists: ${s}`, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg) : (p = "", f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg) : (p = k.error, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg);
243
+ } else
244
+ f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg;
245
+ }, t.onfocus = () => {
246
+ t.style.borderColor = p ? e.fieldErrorBorder : e.saveBg, t.style.boxShadow = p ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, t.style.background = p ? e.fieldErrorBg : e.fieldFocusBg;
247
+ }, t.onblur = () => {
248
+ t.style.boxShadow = "none", p || (t.style.background = e.fieldBg);
249
+ };
250
+ const T = () => {
251
+ const s = t.value.trim();
252
+ !s || !A(s).valid || h.has(s) || (i && i(s), a.remove());
253
+ }, E = () => {
254
+ a.remove();
255
+ };
256
+ n.onclick = T, g.onclick = E, c.onclick = E, t.onkeydown = (s) => {
257
+ s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), E());
258
+ }, a.onclick = (s) => {
259
+ s.target === a && E();
260
+ }, u.appendChild(x), u.appendChild(C), u.appendChild(v), a.appendChild(u), document.body.appendChild(a), setTimeout(() => t.focus(), 100);
261
+ }
262
+ function H(o, l) {
263
+ let i;
264
+ if (l)
265
+ i = l;
266
+ else {
267
+ const a = window.getSelection();
268
+ if (!a || a.rangeCount === 0) return;
269
+ i = a.getRangeAt(0);
270
+ }
271
+ const r = document.createElement("span");
272
+ r.id = o, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", o), r.setAttribute("title", `Anchor: ${o}`), r.style.cssText = `
273
+ display: inline;
274
+ position: relative;
275
+ cursor: pointer;
276
+ `, i.insertNode(r), h.add(o), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
277
+ const d = window.getSelection();
278
+ d && (d.removeAllRanges(), d.addRange(i));
279
+ const e = S();
280
+ if (e) {
281
+ const a = D(e);
282
+ a && a.dispatchEvent(new Event("input", { bubbles: !0 }));
283
+ }
284
+ $();
285
+ }
286
+ function $() {
287
+ if (document.getElementById("rte-anchor-styles")) return;
288
+ const o = document.createElement("style");
289
+ o.id = "rte-anchor-styles", o.textContent = `
290
+ .rte-anchor {
291
+ display: inline;
292
+ position: relative;
293
+ cursor: pointer;
294
+ transition: all 0.2s ease;
295
+ }
296
+
297
+ .rte-anchor:hover::before {
298
+ content: '⚓';
299
+ position: absolute;
300
+ top: -1.2em;
301
+ left: 0;
302
+ background: #333;
303
+ color: #fff;
304
+ padding: 2px 6px;
305
+ border-radius: 3px;
306
+ font-size: 0.8em;
307
+ white-space: nowrap;
308
+ z-index: 100;
309
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
310
+ }
311
+
312
+ .rte-anchor:hover::after {
313
+ content: attr(data-anchor-id);
314
+ position: absolute;
315
+ top: -1.2em;
316
+ left: 1.4em;
317
+ background: #333;
318
+ color: #fff;
319
+ padding: 2px 6px;
320
+ border-radius: 3px;
321
+ font-size: 0.75em;
322
+ font-family: 'Courier New', monospace;
323
+ white-space: nowrap;
324
+ z-index: 100;
325
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
326
+ }
327
+
328
+ [contenteditable='true'] .rte-anchor::before {
329
+ content: '';
330
+ position: absolute;
331
+ width: 8px;
332
+ height: 8px;
333
+ background: #0066cc;
334
+ border-radius: 50%;
335
+ top: -3px;
336
+ left: 0;
337
+ opacity: 0.5;
338
+ transition: opacity 0.2s ease;
339
+ }
340
+
341
+ [contenteditable='true'] .rte-anchor:hover::before {
342
+ opacity: 1;
343
+ width: auto;
344
+ height: auto;
345
+ background: #333;
346
+ border-radius: 3px;
347
+ top: -1.2em;
348
+ padding: 2px 6px;
349
+ font-size: 0.8em;
350
+ content: '⚓';
351
+ }
352
+
353
+ @media print {
354
+ .rte-anchor::before,
355
+ .rte-anchor::after {
356
+ display: none;
357
+ }
358
+ .rte-anchor {
359
+ cursor: auto;
360
+ }
361
+ }
362
+
363
+ .rte-anchor:focus {
364
+ outline: 2px solid #0066cc;
365
+ outline-offset: 2px;
366
+ }
367
+ `, document.head.appendChild(o);
368
+ }
369
+ const O = () => (typeof window < "u" && (R(), $()), {
370
+ name: "anchor",
371
+ toolbar: [
372
+ {
373
+ label: "Anchor",
374
+ command: "insertAnchor",
375
+ 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>',
376
+ shortcut: "Mod-Shift-k"
377
+ }
378
+ ],
379
+ commands: {
380
+ insertAnchor: () => {
381
+ try {
382
+ const o = window.getSelection();
383
+ if (!o || o.rangeCount === 0)
384
+ return alert("Please place your cursor where you want to insert the anchor."), !1;
385
+ const l = o.getRangeAt(0).cloneRange();
386
+ return _("add", "", (i) => {
387
+ H(i, l);
388
+ }, l), !0;
389
+ } catch (o) {
390
+ return console.error("Failed to insert anchor:", o), !1;
391
+ }
392
+ }
393
+ },
394
+ keymap: {
395
+ "Mod-Shift-k": "insertAnchor"
396
+ }
397
+ });
398
+ export {
399
+ O as AnchorPlugin
400
+ };