@editora/core 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 (133) hide show
  1. package/README.md +42 -4
  2. package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
  3. package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
  4. package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
  5. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
  6. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
  7. package/dist/CodePlugin.native-0Zari_zp.mjs +2041 -0
  8. package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
  9. package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
  10. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
  11. package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
  12. package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
  13. package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
  14. package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
  15. package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
  16. package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
  17. package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
  18. package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
  19. package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
  20. package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
  21. package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
  22. package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
  23. package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
  24. package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
  25. package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
  26. package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
  27. package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
  28. package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
  29. package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
  30. package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
  31. package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
  32. package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
  33. package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
  34. package/dist/core.css +1 -1
  35. package/dist/editora.min.js +31 -29
  36. package/dist/editora.umd.js +31 -29
  37. package/dist/index-CqWQFb3D.js +10 -0
  38. package/dist/index-OwnkG39N.mjs +2227 -0
  39. package/dist/index.cjs.js +14 -18
  40. package/dist/index.esm.js +204 -521
  41. package/dist/plugin-loader.js +26 -26
  42. package/dist/webcomponent-core.js +1286 -295
  43. package/dist/webcomponent-core.min.css +1 -1
  44. package/dist/webcomponent-core.min.js +116 -106
  45. package/dist/webcomponent.cjs.js +1 -1
  46. package/dist/webcomponent.esm.js +1 -1
  47. package/dist/webcomponent.js +1252 -261
  48. package/dist/webcomponent.min.css +1 -1
  49. package/dist/webcomponent.min.js +2980 -1488
  50. package/index.d.ts +355 -0
  51. package/package.json +21 -19
  52. package/LICENSE +0 -21
  53. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
  54. package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
  55. package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
  56. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
  57. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
  58. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
  59. package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
  60. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
  61. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
  62. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
  63. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
  64. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
  65. package/dist/CodePlugin.native-DD9xFIid.mjs +0 -1679
  66. package/dist/CodePlugin.native-DD9xFIid.mjs.map +0 -1
  67. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
  68. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
  69. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
  70. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
  71. package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
  72. package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
  73. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
  74. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
  75. package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
  76. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
  77. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
  78. package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
  79. package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
  80. package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
  81. package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
  82. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
  83. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
  84. package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
  85. package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
  86. package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
  87. package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
  88. package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
  89. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
  90. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
  91. package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
  92. package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
  93. package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
  94. package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
  95. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
  96. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
  97. package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
  98. package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
  99. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
  100. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
  101. package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
  102. package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
  103. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
  104. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
  105. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
  106. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
  107. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
  108. package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
  109. package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
  110. package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
  111. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
  112. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
  113. package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
  114. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
  115. package/dist/documentManager-irzj9n3V.mjs.map +0 -1
  116. package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
  117. package/dist/editora.min.js.map +0 -1
  118. package/dist/editora.umd.js.map +0 -1
  119. package/dist/index-BF5RBhL9.js +0 -4
  120. package/dist/index-BF5RBhL9.js.map +0 -1
  121. package/dist/index-BPsf460l.mjs +0 -1243
  122. package/dist/index-BPsf460l.mjs.map +0 -1
  123. package/dist/index.cjs.js.map +0 -1
  124. package/dist/index.es-CuicffkQ.mjs.map +0 -1
  125. package/dist/index.esm.js.map +0 -1
  126. package/dist/plugin-loader.js.map +0 -1
  127. package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
  128. package/dist/webcomponent-core.js.map +0 -1
  129. package/dist/webcomponent-core.min.js.map +0 -1
  130. package/dist/webcomponent.cjs.js.map +0 -1
  131. package/dist/webcomponent.esm.js.map +0 -1
  132. package/dist/webcomponent.js.map +0 -1
  133. package/dist/webcomponent.min.js.map +0 -1
@@ -0,0 +1,286 @@
1
+ const O = () => ({
2
+ name: "fontSize",
3
+ marks: {
4
+ fontSize: {
5
+ attrs: {
6
+ size: { default: null }
7
+ },
8
+ parseDOM: [
9
+ {
10
+ tag: 'span[style*="font-size"]',
11
+ getAttrs: (e) => {
12
+ const t = e.style.fontSize;
13
+ return t ? { size: t } : !1;
14
+ }
15
+ },
16
+ {
17
+ tag: "font[size]",
18
+ getAttrs: (e) => {
19
+ const t = e.getAttribute("size");
20
+ return t ? { size: t } : !1;
21
+ }
22
+ }
23
+ ],
24
+ toDOM: (e) => {
25
+ var o;
26
+ return ["span", { style: `font-size: ${(o = e.attrs) == null ? void 0 : o.size}` }, 0];
27
+ }
28
+ }
29
+ },
30
+ toolbar: [
31
+ {
32
+ label: "Font Size",
33
+ command: "fontSize",
34
+ type: "group",
35
+ items: [
36
+ {
37
+ label: "Decrease Font Size",
38
+ command: "decreaseFontSize",
39
+ icon: "−",
40
+ type: "button"
41
+ },
42
+ {
43
+ label: "Font Size",
44
+ command: "setFontSize",
45
+ type: "input",
46
+ placeholder: "14"
47
+ },
48
+ {
49
+ label: "Increase Font Size",
50
+ command: "increaseFontSize",
51
+ icon: "+",
52
+ type: "button"
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ commands: {
58
+ decreaseFontSize: () => {
59
+ try {
60
+ return y(-2), z(), !0;
61
+ } catch (e) {
62
+ return console.error("Failed to decrease font size:", e), !1;
63
+ }
64
+ },
65
+ increaseFontSize: () => {
66
+ try {
67
+ return y(2), z(), !0;
68
+ } catch (e) {
69
+ return console.error("Failed to increase font size:", e), !1;
70
+ }
71
+ },
72
+ setFontSize: (e) => {
73
+ var o;
74
+ if (!e) return !1;
75
+ try {
76
+ const n = e.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);
77
+ if (!n) return !1;
78
+ const i = parseFloat(n[1]), r = ((o = n[2]) == null ? void 0 : o.toLowerCase()) || "px";
79
+ return r === "px" && (i < 8 || i > 72) || (r === "em" || r === "rem") && (i < 0.5 || i > 5) ? !1 : (C(i, r), !0);
80
+ } catch (t) {
81
+ return console.error("Failed to set font size:", t), !1;
82
+ }
83
+ }
84
+ },
85
+ keymap: {}
86
+ }), A = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre", g = {
87
+ "xx-small": 9,
88
+ "x-small": 10,
89
+ small: 13,
90
+ medium: 16,
91
+ large: 18,
92
+ "x-large": 24,
93
+ "xx-large": 32,
94
+ "xxx-large": 48,
95
+ smaller: 13,
96
+ larger: 18
97
+ };
98
+ function p(e) {
99
+ const o = e.trim().toLowerCase(), t = o.match(/^(\d+(?:\.\d+)?)(px|em|rem)$/i);
100
+ if (t)
101
+ return {
102
+ value: parseFloat(t[1]),
103
+ unit: t[2].toLowerCase()
104
+ };
105
+ const n = g[o];
106
+ return n ? { value: n, unit: "px" } : null;
107
+ }
108
+ function N(e) {
109
+ return e.trim().toLowerCase() in g;
110
+ }
111
+ function b(e) {
112
+ return !!e.cloneContents().querySelector(A);
113
+ }
114
+ function x(e) {
115
+ const o = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
116
+ return (o == null ? void 0 : o.closest('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
117
+ }
118
+ function d(e) {
119
+ e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
120
+ }
121
+ function w(e, o) {
122
+ var i;
123
+ const t = document.createElement("span");
124
+ for (const r of Array.from(e.attributes))
125
+ r.name === "size" || r.name === "style" || t.setAttribute(r.name, r.value);
126
+ const n = e.getAttribute("style");
127
+ for (n && t.setAttribute("style", n), t.style.fontSize = o; e.firstChild; )
128
+ t.appendChild(e.firstChild);
129
+ (i = e.parentNode) == null || i.replaceChild(t, e);
130
+ }
131
+ function E(e, o, t, n) {
132
+ const i = Array.from(
133
+ e.querySelectorAll("font[size], [style*='font-size']")
134
+ ), r = (s) => {
135
+ if (!n || !s.isConnected) return !1;
136
+ try {
137
+ if (typeof n.intersectsNode == "function")
138
+ return n.intersectsNode(s);
139
+ } catch (l) {
140
+ }
141
+ const a = document.createRange();
142
+ return a.selectNodeContents(s), n.compareBoundaryPoints(Range.END_TO_START, a) > 0 && n.compareBoundaryPoints(Range.START_TO_END, a) < 0;
143
+ };
144
+ let c = !1;
145
+ return i.forEach((s) => {
146
+ const a = !o.has(s), l = s.tagName === "FONT", u = N(s.style.fontSize || ""), f = r(s);
147
+ if (!(!a && !f) && !(!a && !l && !u)) {
148
+ if (c = !0, s.tagName === "FONT") {
149
+ w(s, t);
150
+ return;
151
+ }
152
+ s.style.fontSize = t;
153
+ }
154
+ }), c;
155
+ }
156
+ function S(e) {
157
+ e.querySelectorAll("span").forEach((t) => {
158
+ t.childElementCount > 0 || (t.textContent || "").trim().length > 0 || t.remove();
159
+ });
160
+ }
161
+ function T(e, o, t) {
162
+ if (b(e))
163
+ return !1;
164
+ const n = document.createElement("span");
165
+ n.style.fontSize = t;
166
+ try {
167
+ e.surroundContents(n);
168
+ } catch (r) {
169
+ const c = e.extractContents();
170
+ n.appendChild(c), e.insertNode(n);
171
+ }
172
+ const i = document.createRange();
173
+ return i.selectNodeContents(n), o.removeAllRanges(), o.addRange(i), !0;
174
+ }
175
+ function y(e) {
176
+ const o = window.getSelection();
177
+ if (!o || o.rangeCount === 0) return;
178
+ const { value: t, unit: n } = h();
179
+ let i = e;
180
+ (n === "em" || n === "rem") && (i = e * 0.125);
181
+ let r;
182
+ n === "px" ? r = e < 0 ? Math.max(8, t + e) : Math.min(72, t + e) : r = e < 0 ? Math.max(0.5, t + i) : Math.min(5, t + i), C(r, n);
183
+ }
184
+ function h() {
185
+ var i;
186
+ const e = window.getSelection();
187
+ if (!e || e.rangeCount === 0)
188
+ return { value: 14, unit: "px" };
189
+ const t = e.getRangeAt(0).startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
190
+ if (n) {
191
+ const r = (i = n.style) == null ? void 0 : i.fontSize;
192
+ if (r) {
193
+ const l = p(r);
194
+ if (l)
195
+ return l;
196
+ }
197
+ const s = window.getComputedStyle(n).fontSize, a = p(s);
198
+ if (a)
199
+ return a;
200
+ }
201
+ return { value: 14, unit: "px" };
202
+ }
203
+ function C(e, o = "px") {
204
+ const t = window.getSelection();
205
+ if (!t || t.rangeCount === 0) return;
206
+ const n = t.getRangeAt(0), i = n.cloneRange(), r = x(n.commonAncestorContainer);
207
+ if (n.collapsed)
208
+ return;
209
+ const c = `${e}${o}`, s = n.commonAncestorContainer, a = R(s);
210
+ if (a && v(n, a)) {
211
+ a.style.fontSize = c, d(r);
212
+ const m = document.createRange();
213
+ m.selectNodeContents(a), t.removeAllRanges(), t.addRange(m);
214
+ return;
215
+ }
216
+ if (!r) return;
217
+ const l = new Set(
218
+ Array.from(
219
+ r.querySelectorAll("font[size], [style*='font-size']")
220
+ )
221
+ );
222
+ r.focus({ preventScroll: !0 });
223
+ try {
224
+ document.execCommand("styleWithCSS", !1, "true");
225
+ } catch (m) {
226
+ }
227
+ let u = document.execCommand("fontSize", !1, "7");
228
+ const f = t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() : i, F = E(
229
+ r,
230
+ l,
231
+ c,
232
+ f
233
+ );
234
+ if (u && F) {
235
+ S(r), d(r);
236
+ return;
237
+ }
238
+ u = T(i, t, c), u && (S(r), d(r));
239
+ }
240
+ function R(e) {
241
+ let o = e;
242
+ for (; o && o !== document.body; ) {
243
+ if (o.nodeType === Node.ELEMENT_NODE) {
244
+ const t = o;
245
+ if (t.tagName === "SPAN" && t.style.fontSize)
246
+ return t;
247
+ }
248
+ o = o.parentNode;
249
+ }
250
+ return null;
251
+ }
252
+ function v(e, o) {
253
+ const t = e.startContainer, n = e.endContainer;
254
+ return o.contains(t) && o.contains(n);
255
+ }
256
+ function z() {
257
+ setTimeout(() => {
258
+ const { value: e, unit: o } = h(), t = window.getSelection();
259
+ if (!t || t.rangeCount === 0) return;
260
+ let n = null, r = t.getRangeAt(0).startContainer;
261
+ for (; r; ) {
262
+ if (r instanceof HTMLElement && (r.classList.contains("rte-editor") || r.classList.contains("editora-editor") || r.hasAttribute("data-editora-editor"))) {
263
+ n = r;
264
+ break;
265
+ }
266
+ r = r.parentNode;
267
+ }
268
+ if (!n) return;
269
+ const c = n.querySelector(
270
+ ".rte-toolbar-wrapper, .editora-toolbar-container"
271
+ ) || n, s = Array.from(
272
+ c.querySelectorAll(
273
+ 'input[data-command="setFontSize"], input.editora-toolbar-input.font-size, input.rte-toolbar-input.font-size, input[title="Font Size"]'
274
+ )
275
+ );
276
+ if (s.length === 0) return;
277
+ const l = `${e % 1 === 0 ? e.toString() : e.toFixed(2).replace(/\.?0+$/, "")}${o}`;
278
+ s.forEach((u) => {
279
+ u.value = l;
280
+ });
281
+ }, 10);
282
+ }
283
+ export {
284
+ O as FontSizePlugin
285
+ };
286
+ //# sourceMappingURL=FontSizePlugin.native-B_jCh7dY.mjs.map
@@ -0,0 +1,425 @@
1
+ const C = ".rte-content, .editora-content", x = '.rte-footnotes[data-type="footnotes"]', p = ".rte-footnote-ref[data-footnote-id]", h = 'li.rte-footnote-item[data-type="footnote"]', k = "__editoraCommandEditorRoot";
2
+ let w = !1, T = !1, N = 0;
3
+ function _() {
4
+ if (w || typeof document == "undefined") return;
5
+ w = !0;
6
+ const t = document.createElement("style");
7
+ t.id = "editora-footnote-plugin-styles", t.textContent = `
8
+ .rte-footnote-ref {
9
+ display: inline-block;
10
+ font-size: 0.72em;
11
+ line-height: 1;
12
+ vertical-align: super;
13
+ margin-left: 1px;
14
+ color: #1f4dbd;
15
+ cursor: pointer;
16
+ user-select: none;
17
+ border-radius: 4px;
18
+ padding: 0 2px;
19
+ outline: none;
20
+ font-weight: 600;
21
+ }
22
+
23
+ .rte-footnote-ref:focus,
24
+ .rte-footnote-ref:focus-visible,
25
+ .rte-footnote-ref.rte-footnote-selected {
26
+ background: rgba(31, 77, 189, 0.12);
27
+ box-shadow: 0 0 0 2px rgba(31, 77, 189, 0.24);
28
+ }
29
+
30
+ .rte-footnotes {
31
+ margin-top: 16px;
32
+ padding-top: 10px;
33
+ border-top: 1px solid #d1d5db;
34
+ }
35
+
36
+ .rte-footnotes ol {
37
+ margin: 0;
38
+ padding-left: 24px;
39
+ }
40
+
41
+ .rte-footnote-item {
42
+ margin: 0 0 8px;
43
+ color: inherit;
44
+ }
45
+
46
+ .rte-footnote-content {
47
+ display: inline;
48
+ outline: none;
49
+ }
50
+
51
+ .rte-footnote-backref {
52
+ margin-left: 8px;
53
+ color: #1f4dbd;
54
+ text-decoration: none;
55
+ font-size: 0.9em;
56
+ user-select: none;
57
+ }
58
+
59
+ .rte-footnote-backref:hover,
60
+ .rte-footnote-backref:focus {
61
+ text-decoration: underline;
62
+ }
63
+
64
+ .rte-footnote-highlighted {
65
+ animation: rte-footnote-flash 1s ease;
66
+ }
67
+
68
+ @keyframes rte-footnote-flash {
69
+ 0% { background-color: rgba(255, 234, 143, 0.9); }
70
+ 100% { background-color: transparent; }
71
+ }
72
+
73
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref {
74
+ color: #8ab4ff;
75
+ }
76
+
77
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref:focus,
78
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref:focus-visible,
79
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref.rte-footnote-selected {
80
+ background: rgba(138, 180, 255, 0.16);
81
+ box-shadow: 0 0 0 2px rgba(138, 180, 255, 0.3);
82
+ }
83
+
84
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnotes {
85
+ border-top-color: #4b5563;
86
+ }
87
+
88
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-backref {
89
+ color: #8ab4ff;
90
+ }
91
+ `, document.head.appendChild(t);
92
+ }
93
+ function L(t) {
94
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
95
+ }
96
+ function q(t) {
97
+ if (!t) return null;
98
+ const e = t.querySelector('[contenteditable="true"]');
99
+ return e instanceof HTMLElement ? e : null;
100
+ }
101
+ function H() {
102
+ if (typeof window == "undefined") return null;
103
+ const t = window[k];
104
+ if (!(t instanceof HTMLElement)) return null;
105
+ window[k] = null;
106
+ const e = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null);
107
+ if (e) {
108
+ const o = q(e);
109
+ if (o) return o;
110
+ if (e.getAttribute("contenteditable") === "true") return e;
111
+ }
112
+ if (t.getAttribute("contenteditable") === "true")
113
+ return t;
114
+ const n = t.closest('[contenteditable="true"]');
115
+ return n instanceof HTMLElement ? n : null;
116
+ }
117
+ function B(t) {
118
+ const e = t.closest('[contenteditable="true"]');
119
+ if (!e) return null;
120
+ let n = e, o = n.parentElement;
121
+ for (; o; )
122
+ o.getAttribute("contenteditable") === "true" && (n = o), o = o.parentElement;
123
+ return n;
124
+ }
125
+ function u(t) {
126
+ const e = L(t);
127
+ if (!e) return null;
128
+ const n = e.closest(C);
129
+ return n || B(e);
130
+ }
131
+ function $() {
132
+ const t = window.getSelection();
133
+ return !t || t.rangeCount === 0 ? null : u(t.getRangeAt(0).startContainer);
134
+ }
135
+ function M() {
136
+ const t = H();
137
+ if (t && document.contains(t))
138
+ return t;
139
+ const e = $();
140
+ if (e) return e;
141
+ const n = document.activeElement, o = n ? u(n) : null;
142
+ if (o) return o;
143
+ const r = document.querySelector(C);
144
+ return r || document.querySelector('[contenteditable="true"]');
145
+ }
146
+ function z() {
147
+ const t = document.createElement("section");
148
+ t.className = "rte-footnotes", t.setAttribute("data-type", "footnotes"), t.setAttribute("contenteditable", "false");
149
+ const e = document.createElement("ol");
150
+ return t.appendChild(e), t;
151
+ }
152
+ function g(t, e) {
153
+ let n = t.querySelector(x);
154
+ return !n && e && (n = z(), t.appendChild(n)), n ? (n.querySelector("ol") || n.appendChild(document.createElement("ol")), n) : null;
155
+ }
156
+ function D(t) {
157
+ let e = t.querySelector("ol");
158
+ return e || (e = document.createElement("ol"), t.appendChild(e)), e;
159
+ }
160
+ function P(t) {
161
+ const e = document.createElement("sup");
162
+ return e.className = "rte-footnote-ref", e.setAttribute("data-footnote-id", t), e.setAttribute("data-number", "0"), e.setAttribute("contenteditable", "false"), e.setAttribute("tabindex", "0"), e.setAttribute("role", "doc-noteref"), e.id = `ref-${t}`, e.textContent = "0", e;
163
+ }
164
+ function I(t, e) {
165
+ const n = document.createElement("li");
166
+ n.id = t, n.className = "rte-footnote-item", n.setAttribute("data-type", "footnote"), n.setAttribute("data-number", "0"), n.setAttribute("contenteditable", "false");
167
+ const o = document.createElement("div");
168
+ o.className = "rte-footnote-content", o.setAttribute("contenteditable", "true"), o.textContent = e;
169
+ const r = document.createElement("a");
170
+ return r.className = "rte-footnote-backref", r.href = `#ref-${t}`, r.setAttribute("aria-label", "Back to reference"), r.setAttribute("contenteditable", "false"), r.textContent = "↩", n.appendChild(o), n.appendChild(r), n;
171
+ }
172
+ function j(t) {
173
+ let e = "";
174
+ do
175
+ N += 1, e = `fn-${Date.now().toString(36)}-${N.toString(36)}`;
176
+ while (t.querySelector(`#${CSS.escape(e)}`));
177
+ return e;
178
+ }
179
+ function v(t) {
180
+ t.classList.remove("rte-footnote-highlighted"), t.classList.add("rte-footnote-highlighted"), window.setTimeout(() => {
181
+ t.classList.remove("rte-footnote-highlighted");
182
+ }, 1e3);
183
+ }
184
+ function A(t) {
185
+ t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
186
+ }
187
+ function S(t, e) {
188
+ if (!t || e === t.innerHTML) return;
189
+ const n = window.execEditorCommand || window.executeEditorCommand;
190
+ if (typeof n == "function")
191
+ try {
192
+ n("recordDomTransaction", t, e, t.innerHTML);
193
+ } catch (o) {
194
+ }
195
+ }
196
+ function X(t, e) {
197
+ return Array.from(t.querySelectorAll(p)).find((o) => o.getAttribute("data-footnote-id") === e) || null;
198
+ }
199
+ function V(t) {
200
+ const e = window.getSelection();
201
+ if (!e)
202
+ throw new Error("Selection unavailable");
203
+ let n = null;
204
+ if (e.rangeCount > 0) {
205
+ const r = e.getRangeAt(0);
206
+ t.contains(r.commonAncestorContainer) && (n = r.cloneRange());
207
+ }
208
+ if (!n) {
209
+ n = document.createRange();
210
+ const r = g(t, !1);
211
+ r ? (n.setStartBefore(r), n.collapse(!0)) : (n.selectNodeContents(t), n.collapse(!1));
212
+ }
213
+ const o = L(n.commonAncestorContainer);
214
+ if (o != null && o.closest(x)) {
215
+ const r = g(t, !0);
216
+ r && (n.setStartBefore(r), n.collapse(!0));
217
+ }
218
+ return e.removeAllRanges(), e.addRange(n), n;
219
+ }
220
+ function R(t) {
221
+ const e = t.parentNode;
222
+ if (!e) return;
223
+ const n = Array.from(e.childNodes).indexOf(t);
224
+ if (n < 0) return;
225
+ const o = window.getSelection();
226
+ if (!o) return;
227
+ const r = document.createRange();
228
+ r.setStart(e, n), r.setEnd(e, n + 1), o.removeAllRanges(), o.addRange(r), t.focus({ preventScroll: !0 });
229
+ }
230
+ function O(t, e) {
231
+ const n = window.getSelection();
232
+ if (!n) return;
233
+ const o = Math.max(0, Math.min(e, t.childNodes.length)), r = document.createRange();
234
+ r.setStart(t, o), r.collapse(!0), n.removeAllRanges(), n.addRange(r);
235
+ }
236
+ function K(t) {
237
+ if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
238
+ return null;
239
+ const e = t.startContainer.childNodes[t.startOffset];
240
+ return !(e instanceof HTMLElement) || !e.matches(p) ? null : e;
241
+ }
242
+ function b(t, e, n) {
243
+ const { startContainer: o, startOffset: r } = t;
244
+ if (o.nodeType === Node.ELEMENT_NODE) {
245
+ const c = o;
246
+ if (n === "previous") {
247
+ if (r > 0) return c.childNodes[r - 1] || null;
248
+ } else if (r < c.childNodes.length)
249
+ return c.childNodes[r] || null;
250
+ }
251
+ if (o.nodeType === Node.TEXT_NODE && (n === "previous" && r < o.data.length || n === "next" && r > 0))
252
+ return null;
253
+ let i = o;
254
+ for (; i && i !== e; ) {
255
+ const c = n === "previous" ? i.previousSibling : i.nextSibling;
256
+ if (c) return c;
257
+ i = i.parentNode;
258
+ }
259
+ return null;
260
+ }
261
+ function Y(t, e, n) {
262
+ if (!t.collapsed) return null;
263
+ const o = (c) => c instanceof HTMLElement && c.matches(p) ? c : null, { startContainer: r, startOffset: i } = t;
264
+ if (r.nodeType === Node.ELEMENT_NODE) {
265
+ const c = r;
266
+ return n === "Backspace" && i > 0 ? o(c.childNodes[i - 1] || null) : n === "Delete" ? o(c.childNodes[i] || null) : null;
267
+ }
268
+ if (r.nodeType === Node.TEXT_NODE) {
269
+ const c = r;
270
+ if (n === "Backspace" && i === 0) {
271
+ const a = o(c.previousSibling);
272
+ return a || o(b(t, e, "previous"));
273
+ }
274
+ if (n === "Delete" && i === c.data.length) {
275
+ const a = o(c.nextSibling);
276
+ return a || o(b(t, e, "next"));
277
+ }
278
+ }
279
+ return o(n === "Backspace" ? b(t, e, "previous") : b(t, e, "next"));
280
+ }
281
+ function m(t) {
282
+ const e = Array.from(t.querySelectorAll(p)).filter((a) => !a.closest(x)), n = g(t, e.length > 0);
283
+ if (!n) return;
284
+ const o = D(n), r = Array.from(o.querySelectorAll(h)), i = /* @__PURE__ */ new Map();
285
+ r.forEach((a) => i.set(a.id, a));
286
+ const c = [];
287
+ e.forEach((a, f) => {
288
+ const l = a.getAttribute("data-footnote-id");
289
+ if (!l) return;
290
+ const s = f + 1;
291
+ a.setAttribute("data-number", String(s)), a.id = `ref-${l}`, a.textContent = String(s);
292
+ let d = i.get(l);
293
+ d || (d = I(l, `Footnote ${s}`)), d.setAttribute("data-number", String(s));
294
+ const E = d.querySelector(".rte-footnote-content");
295
+ E && !(E.textContent || "").trim() && (E.textContent = `Footnote ${s}`);
296
+ const y = d.querySelector(".rte-footnote-backref");
297
+ y && (y.href = `#ref-${l}`, y.setAttribute("aria-label", `Back to reference ${s}`)), c.push(d);
298
+ }), o.innerHTML = "", c.forEach((a) => o.appendChild(a)), c.length === 0 && n.remove();
299
+ }
300
+ function F(t, e) {
301
+ const n = u(t), o = t.parentNode;
302
+ if (!n || !o) return !1;
303
+ const r = n.innerHTML, i = Array.from(o.childNodes).indexOf(t);
304
+ if (i < 0) return !1;
305
+ const c = t.getAttribute("data-footnote-id") || "";
306
+ if (t.remove(), c) {
307
+ const a = n.querySelector(
308
+ `${h}#${CSS.escape(c)}`
309
+ );
310
+ a == null || a.remove();
311
+ }
312
+ return O(o, i), m(n), S(n, r), A(n), !0;
313
+ }
314
+ function G() {
315
+ T || typeof document == "undefined" || (T = !0, document.addEventListener("click", (t) => {
316
+ const e = t.target;
317
+ if (!e) return;
318
+ const n = e.closest(p);
319
+ if (n) {
320
+ const f = u(n);
321
+ if (!f || !f.contains(n)) return;
322
+ t.preventDefault(), t.stopPropagation(), R(n), n.classList.add("rte-footnote-selected"), window.setTimeout(() => n.classList.remove("rte-footnote-selected"), 1200);
323
+ const l = n.getAttribute("data-footnote-id");
324
+ if (!l) return;
325
+ const s = f.querySelector(
326
+ `${h}#${CSS.escape(l)}`
327
+ );
328
+ if (!s) return;
329
+ s.scrollIntoView({ behavior: "smooth", block: "center" }), v(s);
330
+ return;
331
+ }
332
+ const o = e.closest(".rte-footnote-backref");
333
+ if (!o) return;
334
+ const r = o.closest(h);
335
+ if (!r) return;
336
+ const i = u(r);
337
+ if (!i || !i.contains(r)) return;
338
+ t.preventDefault(), t.stopPropagation();
339
+ const c = r.id;
340
+ if (!c) return;
341
+ const a = X(i, c);
342
+ a && (a.scrollIntoView({ behavior: "smooth", block: "center" }), v(a), R(a));
343
+ }), document.addEventListener("keydown", (t) => {
344
+ if (t.key !== "Backspace" && t.key !== "Delete") return;
345
+ const e = window.getSelection();
346
+ if (!e || e.rangeCount === 0) return;
347
+ const n = e.getRangeAt(0), o = u(n.commonAncestorContainer);
348
+ if (!o || !o.contains(n.commonAncestorContainer)) return;
349
+ const r = K(n);
350
+ if (r) {
351
+ t.preventDefault(), t.stopPropagation(), F(r, t.key);
352
+ return;
353
+ }
354
+ const i = Y(
355
+ n,
356
+ o,
357
+ t.key
358
+ );
359
+ i && (t.preventDefault(), t.stopPropagation(), F(i, t.key));
360
+ }));
361
+ }
362
+ const J = (t = "") => {
363
+ const e = M();
364
+ if (!e) return !1;
365
+ const n = e.innerHTML, o = window.getSelection();
366
+ if (!o) return !1;
367
+ let r;
368
+ try {
369
+ r = V(e);
370
+ } catch (d) {
371
+ return !1;
372
+ }
373
+ r.collapsed || (r.collapse(!1), o.removeAllRanges(), o.addRange(r));
374
+ const i = j(e), c = P(i);
375
+ try {
376
+ r.insertNode(c);
377
+ } catch (d) {
378
+ return !1;
379
+ }
380
+ const a = document.createRange();
381
+ a.setStartAfter(c), a.collapse(!0), o.removeAllRanges(), o.addRange(a);
382
+ const f = g(e, !0);
383
+ if (!f) return !1;
384
+ const l = D(f), s = t.trim() || "Footnote";
385
+ return l.appendChild(I(i, s)), m(e), S(e, n), A(e), !0;
386
+ }, Q = () => {
387
+ const t = M();
388
+ if (t) {
389
+ m(t);
390
+ return;
391
+ }
392
+ const e = Array.from(document.querySelectorAll(C));
393
+ if (e.length > 0) {
394
+ e.forEach((o) => m(o));
395
+ return;
396
+ }
397
+ const n = document.querySelector('[contenteditable="true"]');
398
+ n && m(n);
399
+ }, U = (t) => {
400
+ if (!t) return;
401
+ const e = Array.from(document.querySelectorAll(p)).find((i) => i.getAttribute("data-footnote-id") === t) || null, n = document.getElementById(t), o = u(e || n);
402
+ if (!o) return;
403
+ const r = o.innerHTML;
404
+ e == null || e.remove(), n == null || n.remove(), m(o), S(o, r), A(o);
405
+ }, W = () => (_(), G(), {
406
+ name: "footnote",
407
+ toolbar: [
408
+ {
409
+ label: "Footnote",
410
+ command: "insertFootnote",
411
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><rect x="3" y="4" width="14" height="2" rx="1"></rect><rect x="3" y="8" width="18" height="2" rx="1"></rect><rect x="3" y="12" width="16" height="2" rx="1"></rect><rect x="3" y="16" width="10" height="1.5" rx="0.75"></rect><text x="19" y="11" font-size="9" font-weight="600" fill="currentColor" font-family="system-ui, sans-serif">1</text></svg>'
412
+ }
413
+ ],
414
+ commands: {
415
+ insertFootnote: () => J()
416
+ },
417
+ keymap: {}
418
+ });
419
+ export {
420
+ W as FootnotePlugin,
421
+ U as deleteFootnote,
422
+ J as insertFootnoteCommand,
423
+ Q as renumberAllFootnotes
424
+ };
425
+ //# sourceMappingURL=FootnotePlugin.native-D730OGRm.mjs.map