@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
@@ -21,7 +21,10 @@ const O = () => ({
21
21
  }
22
22
  }
23
23
  ],
24
- toDOM: (e) => ["span", { style: `font-size: ${e.attrs?.size}` }, 0]
24
+ toDOM: (e) => {
25
+ var o;
26
+ return ["span", { style: `font-size: ${(o = e.attrs) == null ? void 0 : o.size}` }, 0];
27
+ }
25
28
  }
26
29
  },
27
30
  toolbar: [
@@ -67,14 +70,17 @@ const O = () => ({
67
70
  }
68
71
  },
69
72
  setFontSize: (e) => {
70
- if (!e) return !1;
73
+ var o;
74
+ if (!e)
75
+ return !1;
71
76
  try {
72
- const t = e.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);
73
- if (!t) return !1;
74
- const n = parseFloat(t[1]), i = t[2]?.toLowerCase() || "px";
75
- return i === "px" && (n < 8 || n > 72) || (i === "em" || i === "rem") && (n < 0.5 || n > 5) ? !1 : (C(n, i), !0);
76
- } catch (o) {
77
- return console.error("Failed to set font size:", o), !1;
77
+ const n = e.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);
78
+ if (!n)
79
+ return !1;
80
+ const i = parseFloat(n[1]), r = ((o = n[2]) == null ? void 0 : o.toLowerCase()) || "px";
81
+ return r === "px" && (i < 8 || i > 72) || (r === "em" || r === "rem") && (i < 0.5 || i > 5) ? !1 : (C(i, r), !0);
82
+ } catch (t) {
83
+ return console.error("Failed to set font size:", t), !1;
78
84
  }
79
85
  }
80
86
  },
@@ -108,25 +114,28 @@ function b(e) {
108
114
  return !!e.cloneContents().querySelector(A);
109
115
  }
110
116
  function x(e) {
111
- return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
117
+ const o = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
118
+ return (o == null ? void 0 : o.closest('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
112
119
  }
113
120
  function m(e) {
114
121
  e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
115
122
  }
116
123
  function w(e, o) {
124
+ var i;
117
125
  const t = document.createElement("span");
118
- for (const i of Array.from(e.attributes))
119
- i.name === "size" || i.name === "style" || t.setAttribute(i.name, i.value);
126
+ for (const r of Array.from(e.attributes))
127
+ r.name === "size" || r.name === "style" || t.setAttribute(r.name, r.value);
120
128
  const n = e.getAttribute("style");
121
129
  for (n && t.setAttribute("style", n), t.style.fontSize = o; e.firstChild; )
122
130
  t.appendChild(e.firstChild);
123
- e.parentNode?.replaceChild(t, e);
131
+ (i = e.parentNode) == null || i.replaceChild(t, e);
124
132
  }
125
133
  function E(e, o, t, n) {
126
134
  const i = Array.from(
127
135
  e.querySelectorAll("font[size], [style*='font-size']")
128
136
  ), r = (s) => {
129
- if (!n || !s.isConnected) return !1;
137
+ if (!n || !s.isConnected)
138
+ return !1;
130
139
  try {
131
140
  if (typeof n.intersectsNode == "function")
132
141
  return n.intersectsNode(s);
@@ -137,8 +146,8 @@ function E(e, o, t, n) {
137
146
  };
138
147
  let c = !1;
139
148
  return i.forEach((s) => {
140
- const a = !o.has(s), u = s.tagName === "FONT", l = N(s.style.fontSize || ""), f = r(s);
141
- if (!(!a && !f) && !(!a && !u && !l)) {
149
+ const a = !o.has(s), l = s.tagName === "FONT", u = N(s.style.fontSize || ""), f = r(s);
150
+ if (!(!a && !f) && !(!a && !l && !u)) {
142
151
  if (c = !0, s.tagName === "FONT") {
143
152
  w(s, t);
144
153
  return;
@@ -168,7 +177,8 @@ function T(e, o, t) {
168
177
  }
169
178
  function y(e) {
170
179
  const o = window.getSelection();
171
- if (!o || o.rangeCount === 0) return;
180
+ if (!o || o.rangeCount === 0)
181
+ return;
172
182
  const { value: t, unit: n } = h();
173
183
  let i = e;
174
184
  (n === "em" || n === "rem") && (i = e * 0.125);
@@ -176,26 +186,28 @@ function y(e) {
176
186
  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);
177
187
  }
178
188
  function h() {
189
+ var i;
179
190
  const e = window.getSelection();
180
191
  if (!e || e.rangeCount === 0)
181
192
  return { value: 14, unit: "px" };
182
193
  const t = e.getRangeAt(0).startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
183
194
  if (n) {
184
- const i = n.style?.fontSize;
185
- if (i) {
186
- const a = p(i);
187
- if (a)
188
- return a;
195
+ const r = (i = n.style) == null ? void 0 : i.fontSize;
196
+ if (r) {
197
+ const l = p(r);
198
+ if (l)
199
+ return l;
189
200
  }
190
- const c = window.getComputedStyle(n).fontSize, s = p(c);
191
- if (s)
192
- return s;
201
+ const s = window.getComputedStyle(n).fontSize, a = p(s);
202
+ if (a)
203
+ return a;
193
204
  }
194
205
  return { value: 14, unit: "px" };
195
206
  }
196
207
  function C(e, o = "px") {
197
208
  const t = window.getSelection();
198
- if (!t || t.rangeCount === 0) return;
209
+ if (!t || t.rangeCount === 0)
210
+ return;
199
211
  const n = t.getRangeAt(0), i = n.cloneRange(), r = x(n.commonAncestorContainer);
200
212
  if (n.collapsed)
201
213
  return;
@@ -206,8 +218,9 @@ function C(e, o = "px") {
206
218
  d.selectNodeContents(a), t.removeAllRanges(), t.addRange(d);
207
219
  return;
208
220
  }
209
- if (!r) return;
210
- const u = new Set(
221
+ if (!r)
222
+ return;
223
+ const l = new Set(
211
224
  Array.from(
212
225
  r.querySelectorAll("font[size], [style*='font-size']")
213
226
  )
@@ -217,18 +230,18 @@ function C(e, o = "px") {
217
230
  document.execCommand("styleWithCSS", !1, "true");
218
231
  } catch {
219
232
  }
220
- let l = document.execCommand("fontSize", !1, "7");
233
+ let u = document.execCommand("fontSize", !1, "7");
221
234
  const f = t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() : i, F = E(
222
235
  r,
223
- u,
236
+ l,
224
237
  c,
225
238
  f
226
239
  );
227
- if (l && F) {
240
+ if (u && F) {
228
241
  S(r), m(r);
229
242
  return;
230
243
  }
231
- l = T(i, t, c), l && (S(r), m(r));
244
+ u = T(i, t, c), u && (S(r), m(r));
232
245
  }
233
246
  function R(e) {
234
247
  let o = e;
@@ -249,7 +262,8 @@ function v(e, o) {
249
262
  function z() {
250
263
  setTimeout(() => {
251
264
  const { value: e, unit: o } = h(), t = window.getSelection();
252
- if (!t || t.rangeCount === 0) return;
265
+ if (!t || t.rangeCount === 0)
266
+ return;
253
267
  let n = null, r = t.getRangeAt(0).startContainer;
254
268
  for (; r; ) {
255
269
  if (r instanceof HTMLElement && (r.classList.contains("rte-editor") || r.classList.contains("editora-editor") || r.hasAttribute("data-editora-editor"))) {
@@ -258,7 +272,8 @@ function z() {
258
272
  }
259
273
  r = r.parentNode;
260
274
  }
261
- if (!n) return;
275
+ if (!n)
276
+ return;
262
277
  const c = n.querySelector(
263
278
  ".rte-toolbar-wrapper, .editora-toolbar-container"
264
279
  ) || n, s = Array.from(
@@ -266,10 +281,11 @@ function z() {
266
281
  'input[data-command="setFontSize"], input.editora-toolbar-input.font-size, input.rte-toolbar-input.font-size, input[title="Font Size"]'
267
282
  )
268
283
  );
269
- if (s.length === 0) return;
270
- const u = `${e % 1 === 0 ? e.toString() : e.toFixed(2).replace(/\.?0+$/, "")}${o}`;
271
- s.forEach((l) => {
272
- l.value = u;
284
+ if (s.length === 0)
285
+ return;
286
+ const l = `${e % 1 === 0 ? e.toString() : e.toFixed(2).replace(/\.?0+$/, "")}${o}`;
287
+ s.forEach((u) => {
288
+ u.value = l;
273
289
  });
274
290
  }, 10);
275
291
  }
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",C='.rte-footnotes[data-type="footnotes"]',m=".rte-footnote-ref[data-footnote-id]",g='li.rte-footnote-item[data-type="footnote"]',x="__editoraCommandEditorRoot";let y=!1,S=!1,A=0;function D(){if(y||typeof document>"u")return;y=!0;const t=document.createElement("style");t.id="editora-footnote-plugin-styles",t.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",C='.rte-footnotes[data-type="footnotes"]',m=".rte-footnote-ref[data-footnote-id]",b='li.rte-footnote-item[data-type="footnote"]',x="__editoraCommandEditorRoot";let y=!1,S=!1,A=0;function D(){if(y||typeof document>"u")return;y=!0;const t=document.createElement("style");t.id="editora-footnote-plugin-styles",t.textContent=`
2
2
  .rte-footnote-ref {
3
3
  display: inline-block;
4
4
  font-size: 0.72em;
@@ -82,4 +82,4 @@
82
82
  :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-backref {
83
83
  color: #8ab4ff;
84
84
  }
85
- `,document.head.appendChild(t)}function R(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function _(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function q(){if(typeof window>"u")return null;const t=window[x];if(!(t instanceof HTMLElement))return null;window[x]=null;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);if(e){const o=_(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function $(t){const e=t.closest('[contenteditable="true"]');if(!e)return null;let n=e,o=n.parentElement;for(;o;)o.getAttribute("contenteditable")==="true"&&(n=o),o=o.parentElement;return n}function u(t){const e=R(t);if(!e)return null;const n=e.closest(v);return n||$(e)}function B(){const t=window.getSelection();return!t||t.rangeCount===0?null:u(t.getRangeAt(0).startContainer)}function H(){const t=q();if(t&&document.contains(t))return t;const e=B();if(e)return e;const n=document.activeElement,o=n?u(n):null;if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function P(){const t=document.createElement("section");t.className="rte-footnotes",t.setAttribute("data-type","footnotes"),t.setAttribute("contenteditable","false");const e=document.createElement("ol");return t.appendChild(e),t}function b(t,e){let n=t.querySelector(C);return!n&&e&&(n=P(),t.appendChild(n)),n?(n.querySelector("ol")||n.appendChild(document.createElement("ol")),n):null}function O(t){let e=t.querySelector("ol");return e||(e=document.createElement("ol"),t.appendChild(e)),e}function z(t){const e=document.createElement("sup");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}function F(t,e){const n=document.createElement("li");n.id=t,n.className="rte-footnote-item",n.setAttribute("data-type","footnote"),n.setAttribute("data-number","0"),n.setAttribute("contenteditable","false");const o=document.createElement("div");o.className="rte-footnote-content",o.setAttribute("contenteditable","true"),o.textContent=e;const r=document.createElement("a");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}function j(t){let e="";do A+=1,e=`fn-${Date.now().toString(36)}-${A.toString(36)}`;while(t.querySelector(`#${CSS.escape(e)}`));return e}function k(t){t.classList.remove("rte-footnote-highlighted"),t.classList.add("rte-footnote-highlighted"),window.setTimeout(()=>{t.classList.remove("rte-footnote-highlighted")},1e3)}function L(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function I(t,e){if(!t||e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch{}}function X(t,e){return Array.from(t.querySelectorAll(m)).find(o=>o.getAttribute("data-footnote-id")===e)||null}function V(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");let n=null;if(e.rangeCount>0){const r=e.getRangeAt(0);t.contains(r.commonAncestorContainer)&&(n=r.cloneRange())}if(!n){n=document.createRange();const r=b(t,!1);r?(n.setStartBefore(r),n.collapse(!0)):(n.selectNodeContents(t),n.collapse(!1))}if(R(n.commonAncestorContainer)?.closest(C)){const r=b(t,!0);r&&(n.setStartBefore(r),n.collapse(!0))}return e.removeAllRanges(),e.addRange(n),n}function w(t){const e=t.parentNode;if(!e)return;const n=Array.from(e.childNodes).indexOf(t);if(n<0)return;const o=window.getSelection();if(!o)return;const r=document.createRange();r.setStart(e,n),r.setEnd(e,n+1),o.removeAllRanges(),o.addRange(r),t.focus({preventScroll:!0})}function T(t,e){const n=window.getSelection();if(!n)return;const o=Math.max(0,Math.min(e,t.childNodes.length)),r=document.createRange();r.setStart(t,o),r.collapse(!0),n.removeAllRanges(),n.addRange(r)}function K(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(m)?null:e}function p(t,e,n){const{startContainer:o,startOffset:r}=t;if(o.nodeType===Node.ELEMENT_NODE){const i=o;if(n==="previous"){if(r>0)return i.childNodes[r-1]||null}else if(r<i.childNodes.length)return i.childNodes[r]||null}if(o.nodeType===Node.TEXT_NODE&&(n==="previous"&&r<o.data.length||n==="next"&&r>0))return null;let c=o;for(;c&&c!==e;){const i=n==="previous"?c.previousSibling:c.nextSibling;if(i)return i;c=c.parentNode}return null}function Y(t,e,n){if(!t.collapsed)return null;const o=i=>i instanceof HTMLElement&&i.matches(m)?i:null,{startContainer:r,startOffset:c}=t;if(r.nodeType===Node.ELEMENT_NODE){const i=r;return n==="Backspace"&&c>0?o(i.childNodes[c-1]||null):n==="Delete"?o(i.childNodes[c]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;if(n==="Backspace"&&c===0){const a=o(i.previousSibling);return a||o(p(t,e,"previous"))}if(n==="Delete"&&c===i.data.length){const a=o(i.nextSibling);return a||o(p(t,e,"next"))}}return o(n==="Backspace"?p(t,e,"previous"):p(t,e,"next"))}function M(t){const e=Array.from(t.querySelectorAll(m)).filter(a=>!a.closest(C)),n=b(t,e.length>0);if(!n)return;const o=O(n),r=Array.from(o.querySelectorAll(g)),c=new Map;r.forEach(a=>c.set(a.id,a));const i=[];e.forEach((a,f)=>{const l=a.getAttribute("data-footnote-id");if(!l)return;const s=f+1;a.setAttribute("data-number",String(s)),a.id=`ref-${l}`,a.textContent=String(s);let d=c.get(l);d||(d=F(l,`Footnote ${s}`)),d.setAttribute("data-number",String(s));const h=d.querySelector(".rte-footnote-content");h&&!(h.textContent||"").trim()&&(h.textContent=`Footnote ${s}`);const E=d.querySelector(".rte-footnote-backref");E&&(E.href=`#ref-${l}`,E.setAttribute("aria-label",`Back to reference ${s}`)),i.push(d)}),o.innerHTML="",i.forEach(a=>o.appendChild(a)),i.length===0&&n.remove()}function N(t,e){const n=u(t),o=t.parentNode;if(!n||!o)return!1;const r=n.innerHTML,c=Array.from(o.childNodes).indexOf(t);if(c<0)return!1;const i=t.getAttribute("data-footnote-id")||"";return t.remove(),i&&n.querySelector(`${g}#${CSS.escape(i)}`)?.remove(),T(o,c),M(n),I(n,r),L(n),!0}function G(){S||typeof document>"u"||(S=!0,document.addEventListener("click",t=>{const e=t.target;if(!e)return;const n=e.closest(m);if(n){const f=u(n);if(!f||!f.contains(n))return;t.preventDefault(),t.stopPropagation(),w(n),n.classList.add("rte-footnote-selected"),window.setTimeout(()=>n.classList.remove("rte-footnote-selected"),1200);const l=n.getAttribute("data-footnote-id");if(!l)return;const s=f.querySelector(`${g}#${CSS.escape(l)}`);if(!s)return;s.scrollIntoView({behavior:"smooth",block:"center"}),k(s);return}const o=e.closest(".rte-footnote-backref");if(!o)return;const r=o.closest(g);if(!r)return;const c=u(r);if(!c||!c.contains(r))return;t.preventDefault(),t.stopPropagation();const i=r.id;if(!i)return;const a=X(c,i);a&&(a.scrollIntoView({behavior:"smooth",block:"center"}),k(a),w(a))}),document.addEventListener("keydown",t=>{if(t.key!=="Backspace"&&t.key!=="Delete")return;const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0),o=u(n.commonAncestorContainer);if(!o||!o.contains(n.commonAncestorContainer))return;const r=K(n);if(r){t.preventDefault(),t.stopPropagation(),N(r,t.key);return}const c=Y(n,o,t.key);c&&(t.preventDefault(),t.stopPropagation(),N(c,t.key))}))}const J=(t="")=>{const e=H();if(!e)return!1;const n=e.innerHTML,o=window.getSelection();if(!o)return!1;let r;try{r=V(e)}catch{return!1}r.collapsed||(r.collapse(!1),o.removeAllRanges(),o.addRange(r));const c=j(e),i=z(c);try{r.insertNode(i)}catch{return!1}const a=document.createRange();a.setStartAfter(i),a.collapse(!0),o.removeAllRanges(),o.addRange(a);const f=b(e,!0);if(!f)return!1;const l=O(f),s=t.trim()||"Footnote";return l.appendChild(F(c,s)),M(e),I(e,n),L(e),!0},Q=()=>(D(),G(),{name:"footnote",toolbar:[{label:"Footnote",command:"insertFootnote",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>'}],commands:{insertFootnote:()=>J()},keymap:{}});exports.FootnotePlugin=Q;
85
+ `,document.head.appendChild(t)}function R(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function _(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function q(){if(typeof window>"u")return null;const t=window[x];if(!(t instanceof HTMLElement))return null;window[x]=null;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);if(e){const o=_(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function $(t){const e=t.closest('[contenteditable="true"]');if(!e)return null;let n=e,o=n.parentElement;for(;o;)o.getAttribute("contenteditable")==="true"&&(n=o),o=o.parentElement;return n}function u(t){const e=R(t);if(!e)return null;const n=e.closest(v);return n||$(e)}function B(){const t=window.getSelection();return!t||t.rangeCount===0?null:u(t.getRangeAt(0).startContainer)}function H(){const t=q();if(t&&document.contains(t))return t;const e=B();if(e)return e;const n=document.activeElement,o=n?u(n):null;if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function P(){const t=document.createElement("section");t.className="rte-footnotes",t.setAttribute("data-type","footnotes"),t.setAttribute("contenteditable","false");const e=document.createElement("ol");return t.appendChild(e),t}function g(t,e){let n=t.querySelector(C);return!n&&e&&(n=P(),t.appendChild(n)),n?(n.querySelector("ol")||n.appendChild(document.createElement("ol")),n):null}function O(t){let e=t.querySelector("ol");return e||(e=document.createElement("ol"),t.appendChild(e)),e}function z(t){const e=document.createElement("sup");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}function F(t,e){const n=document.createElement("li");n.id=t,n.className="rte-footnote-item",n.setAttribute("data-type","footnote"),n.setAttribute("data-number","0"),n.setAttribute("contenteditable","false");const o=document.createElement("div");o.className="rte-footnote-content",o.setAttribute("contenteditable","true"),o.textContent=e;const r=document.createElement("a");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}function j(t){let e="";do A+=1,e=`fn-${Date.now().toString(36)}-${A.toString(36)}`;while(t.querySelector(`#${CSS.escape(e)}`));return e}function k(t){t.classList.remove("rte-footnote-highlighted"),t.classList.add("rte-footnote-highlighted"),window.setTimeout(()=>{t.classList.remove("rte-footnote-highlighted")},1e3)}function L(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function I(t,e){if(!t||e===t.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",t,e,t.innerHTML)}catch{}}function X(t,e){return Array.from(t.querySelectorAll(m)).find(o=>o.getAttribute("data-footnote-id")===e)||null}function V(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");let n=null;if(e.rangeCount>0){const r=e.getRangeAt(0);t.contains(r.commonAncestorContainer)&&(n=r.cloneRange())}if(!n){n=document.createRange();const r=g(t,!1);r?(n.setStartBefore(r),n.collapse(!0)):(n.selectNodeContents(t),n.collapse(!1))}const o=R(n.commonAncestorContainer);if(o!=null&&o.closest(C)){const r=g(t,!0);r&&(n.setStartBefore(r),n.collapse(!0))}return e.removeAllRanges(),e.addRange(n),n}function w(t){const e=t.parentNode;if(!e)return;const n=Array.from(e.childNodes).indexOf(t);if(n<0)return;const o=window.getSelection();if(!o)return;const r=document.createRange();r.setStart(e,n),r.setEnd(e,n+1),o.removeAllRanges(),o.addRange(r),t.focus({preventScroll:!0})}function T(t,e){const n=window.getSelection();if(!n)return;const o=Math.max(0,Math.min(e,t.childNodes.length)),r=document.createRange();r.setStart(t,o),r.collapse(!0),n.removeAllRanges(),n.addRange(r)}function K(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(m)?null:e}function p(t,e,n){const{startContainer:o,startOffset:r}=t;if(o.nodeType===Node.ELEMENT_NODE){const i=o;if(n==="previous"){if(r>0)return i.childNodes[r-1]||null}else if(r<i.childNodes.length)return i.childNodes[r]||null}if(o.nodeType===Node.TEXT_NODE&&(n==="previous"&&r<o.data.length||n==="next"&&r>0))return null;let a=o;for(;a&&a!==e;){const i=n==="previous"?a.previousSibling:a.nextSibling;if(i)return i;a=a.parentNode}return null}function Y(t,e,n){if(!t.collapsed)return null;const o=i=>i instanceof HTMLElement&&i.matches(m)?i:null,{startContainer:r,startOffset:a}=t;if(r.nodeType===Node.ELEMENT_NODE){const i=r;return n==="Backspace"&&a>0?o(i.childNodes[a-1]||null):n==="Delete"?o(i.childNodes[a]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;if(n==="Backspace"&&a===0){const c=o(i.previousSibling);return c||o(p(t,e,"previous"))}if(n==="Delete"&&a===i.data.length){const c=o(i.nextSibling);return c||o(p(t,e,"next"))}}return o(n==="Backspace"?p(t,e,"previous"):p(t,e,"next"))}function M(t){const e=Array.from(t.querySelectorAll(m)).filter(c=>!c.closest(C)),n=g(t,e.length>0);if(!n)return;const o=O(n),r=Array.from(o.querySelectorAll(b)),a=new Map;r.forEach(c=>a.set(c.id,c));const i=[];e.forEach((c,f)=>{const l=c.getAttribute("data-footnote-id");if(!l)return;const s=f+1;c.setAttribute("data-number",String(s)),c.id=`ref-${l}`,c.textContent=String(s);let d=a.get(l);d||(d=F(l,`Footnote ${s}`)),d.setAttribute("data-number",String(s));const h=d.querySelector(".rte-footnote-content");h&&!(h.textContent||"").trim()&&(h.textContent=`Footnote ${s}`);const E=d.querySelector(".rte-footnote-backref");E&&(E.href=`#ref-${l}`,E.setAttribute("aria-label",`Back to reference ${s}`)),i.push(d)}),o.innerHTML="",i.forEach(c=>o.appendChild(c)),i.length===0&&n.remove()}function N(t,e){const n=u(t),o=t.parentNode;if(!n||!o)return!1;const r=n.innerHTML,a=Array.from(o.childNodes).indexOf(t);if(a<0)return!1;const i=t.getAttribute("data-footnote-id")||"";if(t.remove(),i){const c=n.querySelector(`${b}#${CSS.escape(i)}`);c==null||c.remove()}return T(o,a),M(n),I(n,r),L(n),!0}function G(){S||typeof document>"u"||(S=!0,document.addEventListener("click",t=>{const e=t.target;if(!e)return;const n=e.closest(m);if(n){const f=u(n);if(!f||!f.contains(n))return;t.preventDefault(),t.stopPropagation(),w(n),n.classList.add("rte-footnote-selected"),window.setTimeout(()=>n.classList.remove("rte-footnote-selected"),1200);const l=n.getAttribute("data-footnote-id");if(!l)return;const s=f.querySelector(`${b}#${CSS.escape(l)}`);if(!s)return;s.scrollIntoView({behavior:"smooth",block:"center"}),k(s);return}const o=e.closest(".rte-footnote-backref");if(!o)return;const r=o.closest(b);if(!r)return;const a=u(r);if(!a||!a.contains(r))return;t.preventDefault(),t.stopPropagation();const i=r.id;if(!i)return;const c=X(a,i);c&&(c.scrollIntoView({behavior:"smooth",block:"center"}),k(c),w(c))}),document.addEventListener("keydown",t=>{if(t.key!=="Backspace"&&t.key!=="Delete")return;const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=e.getRangeAt(0),o=u(n.commonAncestorContainer);if(!o||!o.contains(n.commonAncestorContainer))return;const r=K(n);if(r){t.preventDefault(),t.stopPropagation(),N(r,t.key);return}const a=Y(n,o,t.key);a&&(t.preventDefault(),t.stopPropagation(),N(a,t.key))}))}const J=(t="")=>{const e=H();if(!e)return!1;const n=e.innerHTML,o=window.getSelection();if(!o)return!1;let r;try{r=V(e)}catch{return!1}r.collapsed||(r.collapse(!1),o.removeAllRanges(),o.addRange(r));const a=j(e),i=z(a);try{r.insertNode(i)}catch{return!1}const c=document.createRange();c.setStartAfter(i),c.collapse(!0),o.removeAllRanges(),o.addRange(c);const f=g(e,!0);if(!f)return!1;const l=O(f),s=t.trim()||"Footnote";return l.appendChild(F(a,s)),M(e),I(e,n),L(e),!0},Q=()=>(D(),G(),{name:"footnote",toolbar:[{label:"Footnote",command:"insertFootnote",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>'}],commands:{insertFootnote:()=>J()},keymap:{}});exports.FootnotePlugin=Q;
@@ -1,7 +1,8 @@
1
1
  const R = ".rte-content, .editora-content", C = '.rte-footnotes[data-type="footnotes"]', m = ".rte-footnote-ref[data-footnote-id]", b = 'li.rte-footnote-item[data-type="footnote"]', x = "__editoraCommandEditorRoot";
2
2
  let y = !1, S = !1, A = 0;
3
3
  function M() {
4
- if (y || typeof document > "u") return;
4
+ if (y || typeof document > "u")
5
+ return;
5
6
  y = !0;
6
7
  const t = document.createElement("style");
7
8
  t.id = "editora-footnote-plugin-styles", t.textContent = `
@@ -94,20 +95,25 @@ function v(t) {
94
95
  return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
95
96
  }
96
97
  function _(t) {
97
- if (!t) return null;
98
+ if (!t)
99
+ return null;
98
100
  const e = t.querySelector('[contenteditable="true"]');
99
101
  return e instanceof HTMLElement ? e : null;
100
102
  }
101
103
  function q() {
102
- if (typeof window > "u") return null;
104
+ if (typeof window > "u")
105
+ return null;
103
106
  const t = window[x];
104
- if (!(t instanceof HTMLElement)) return null;
107
+ if (!(t instanceof HTMLElement))
108
+ return null;
105
109
  window[x] = null;
106
110
  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
111
  if (e) {
108
112
  const o = _(e);
109
- if (o) return o;
110
- if (e.getAttribute("contenteditable") === "true") return e;
113
+ if (o)
114
+ return o;
115
+ if (e.getAttribute("contenteditable") === "true")
116
+ return e;
111
117
  }
112
118
  if (t.getAttribute("contenteditable") === "true")
113
119
  return t;
@@ -116,7 +122,8 @@ function q() {
116
122
  }
117
123
  function $(t) {
118
124
  const e = t.closest('[contenteditable="true"]');
119
- if (!e) return null;
125
+ if (!e)
126
+ return null;
120
127
  let n = e, o = n.parentElement;
121
128
  for (; o; )
122
129
  o.getAttribute("contenteditable") === "true" && (n = o), o = o.parentElement;
@@ -124,7 +131,8 @@ function $(t) {
124
131
  }
125
132
  function u(t) {
126
133
  const e = v(t);
127
- if (!e) return null;
134
+ if (!e)
135
+ return null;
128
136
  const n = e.closest(R);
129
137
  return n || $(e);
130
138
  }
@@ -137,9 +145,11 @@ function H() {
137
145
  if (t && document.contains(t))
138
146
  return t;
139
147
  const e = B();
140
- if (e) return e;
148
+ if (e)
149
+ return e;
141
150
  const n = document.activeElement, o = n ? u(n) : null;
142
- if (o) return o;
151
+ if (o)
152
+ return o;
143
153
  const r = document.querySelector(R);
144
154
  return r || document.querySelector('[contenteditable="true"]');
145
155
  }
@@ -149,7 +159,7 @@ function z() {
149
159
  const e = document.createElement("ol");
150
160
  return t.appendChild(e), t;
151
161
  }
152
- function g(t, e) {
162
+ function h(t, e) {
153
163
  let n = t.querySelector(C);
154
164
  return !n && e && (n = z(), t.appendChild(n)), n ? (n.querySelector("ol") || n.appendChild(document.createElement("ol")), n) : null;
155
165
  }
@@ -185,7 +195,8 @@ function L(t) {
185
195
  t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
186
196
  }
187
197
  function I(t, e) {
188
- if (!t || e === t.innerHTML) return;
198
+ if (!t || e === t.innerHTML)
199
+ return;
189
200
  const n = window.execEditorCommand || window.executeEditorCommand;
190
201
  if (typeof n == "function")
191
202
  try {
@@ -207,28 +218,33 @@ function V(t) {
207
218
  }
208
219
  if (!n) {
209
220
  n = document.createRange();
210
- const r = g(t, !1);
221
+ const r = h(t, !1);
211
222
  r ? (n.setStartBefore(r), n.collapse(!0)) : (n.selectNodeContents(t), n.collapse(!1));
212
223
  }
213
- if (v(n.commonAncestorContainer)?.closest(C)) {
214
- const r = g(t, !0);
224
+ const o = v(n.commonAncestorContainer);
225
+ if (o != null && o.closest(C)) {
226
+ const r = h(t, !0);
215
227
  r && (n.setStartBefore(r), n.collapse(!0));
216
228
  }
217
229
  return e.removeAllRanges(), e.addRange(n), n;
218
230
  }
219
231
  function w(t) {
220
232
  const e = t.parentNode;
221
- if (!e) return;
233
+ if (!e)
234
+ return;
222
235
  const n = Array.from(e.childNodes).indexOf(t);
223
- if (n < 0) return;
236
+ if (n < 0)
237
+ return;
224
238
  const o = window.getSelection();
225
- if (!o) return;
239
+ if (!o)
240
+ return;
226
241
  const r = document.createRange();
227
242
  r.setStart(e, n), r.setEnd(e, n + 1), o.removeAllRanges(), o.addRange(r), t.focus({ preventScroll: !0 });
228
243
  }
229
244
  function T(t, e) {
230
245
  const n = window.getSelection();
231
- if (!n) return;
246
+ if (!n)
247
+ return;
232
248
  const o = Math.max(0, Math.min(e, t.childNodes.length)), r = document.createRange();
233
249
  r.setStart(t, o), r.collapse(!0), n.removeAllRanges(), n.addRange(r);
234
250
  }
@@ -243,122 +259,146 @@ function p(t, e, n) {
243
259
  if (o.nodeType === Node.ELEMENT_NODE) {
244
260
  const i = o;
245
261
  if (n === "previous") {
246
- if (r > 0) return i.childNodes[r - 1] || null;
262
+ if (r > 0)
263
+ return i.childNodes[r - 1] || null;
247
264
  } else if (r < i.childNodes.length)
248
265
  return i.childNodes[r] || null;
249
266
  }
250
267
  if (o.nodeType === Node.TEXT_NODE && (n === "previous" && r < o.data.length || n === "next" && r > 0))
251
268
  return null;
252
- let c = o;
253
- for (; c && c !== e; ) {
254
- const i = n === "previous" ? c.previousSibling : c.nextSibling;
255
- if (i) return i;
256
- c = c.parentNode;
269
+ let a = o;
270
+ for (; a && a !== e; ) {
271
+ const i = n === "previous" ? a.previousSibling : a.nextSibling;
272
+ if (i)
273
+ return i;
274
+ a = a.parentNode;
257
275
  }
258
276
  return null;
259
277
  }
260
278
  function Y(t, e, n) {
261
- if (!t.collapsed) return null;
262
- const o = (i) => i instanceof HTMLElement && i.matches(m) ? i : null, { startContainer: r, startOffset: c } = t;
279
+ if (!t.collapsed)
280
+ return null;
281
+ const o = (i) => i instanceof HTMLElement && i.matches(m) ? i : null, { startContainer: r, startOffset: a } = t;
263
282
  if (r.nodeType === Node.ELEMENT_NODE) {
264
283
  const i = r;
265
- return n === "Backspace" && c > 0 ? o(i.childNodes[c - 1] || null) : n === "Delete" ? o(i.childNodes[c] || null) : null;
284
+ return n === "Backspace" && a > 0 ? o(i.childNodes[a - 1] || null) : n === "Delete" ? o(i.childNodes[a] || null) : null;
266
285
  }
267
286
  if (r.nodeType === Node.TEXT_NODE) {
268
287
  const i = r;
269
- if (n === "Backspace" && c === 0) {
270
- const a = o(i.previousSibling);
271
- return a || o(p(t, e, "previous"));
288
+ if (n === "Backspace" && a === 0) {
289
+ const c = o(i.previousSibling);
290
+ return c || o(p(t, e, "previous"));
272
291
  }
273
- if (n === "Delete" && c === i.data.length) {
274
- const a = o(i.nextSibling);
275
- return a || o(p(t, e, "next"));
292
+ if (n === "Delete" && a === i.data.length) {
293
+ const c = o(i.nextSibling);
294
+ return c || o(p(t, e, "next"));
276
295
  }
277
296
  }
278
297
  return o(n === "Backspace" ? p(t, e, "previous") : p(t, e, "next"));
279
298
  }
280
299
  function D(t) {
281
- const e = Array.from(t.querySelectorAll(m)).filter((a) => !a.closest(C)), n = g(t, e.length > 0);
282
- if (!n) return;
283
- const o = O(n), r = Array.from(o.querySelectorAll(b)), c = /* @__PURE__ */ new Map();
284
- r.forEach((a) => c.set(a.id, a));
300
+ const e = Array.from(t.querySelectorAll(m)).filter((c) => !c.closest(C)), n = h(t, e.length > 0);
301
+ if (!n)
302
+ return;
303
+ const o = O(n), r = Array.from(o.querySelectorAll(b)), a = /* @__PURE__ */ new Map();
304
+ r.forEach((c) => a.set(c.id, c));
285
305
  const i = [];
286
- e.forEach((a, f) => {
287
- const l = a.getAttribute("data-footnote-id");
288
- if (!l) return;
306
+ e.forEach((c, f) => {
307
+ const l = c.getAttribute("data-footnote-id");
308
+ if (!l)
309
+ return;
289
310
  const s = f + 1;
290
- a.setAttribute("data-number", String(s)), a.id = `ref-${l}`, a.textContent = String(s);
291
- let d = c.get(l);
311
+ c.setAttribute("data-number", String(s)), c.id = `ref-${l}`, c.textContent = String(s);
312
+ let d = a.get(l);
292
313
  d || (d = F(l, `Footnote ${s}`)), d.setAttribute("data-number", String(s));
293
- const h = d.querySelector(".rte-footnote-content");
294
- h && !(h.textContent || "").trim() && (h.textContent = `Footnote ${s}`);
314
+ const g = d.querySelector(".rte-footnote-content");
315
+ g && !(g.textContent || "").trim() && (g.textContent = `Footnote ${s}`);
295
316
  const E = d.querySelector(".rte-footnote-backref");
296
317
  E && (E.href = `#ref-${l}`, E.setAttribute("aria-label", `Back to reference ${s}`)), i.push(d);
297
- }), o.innerHTML = "", i.forEach((a) => o.appendChild(a)), i.length === 0 && n.remove();
318
+ }), o.innerHTML = "", i.forEach((c) => o.appendChild(c)), i.length === 0 && n.remove();
298
319
  }
299
320
  function N(t, e) {
300
321
  const n = u(t), o = t.parentNode;
301
- if (!n || !o) return !1;
302
- const r = n.innerHTML, c = Array.from(o.childNodes).indexOf(t);
303
- if (c < 0) return !1;
322
+ if (!n || !o)
323
+ return !1;
324
+ const r = n.innerHTML, a = Array.from(o.childNodes).indexOf(t);
325
+ if (a < 0)
326
+ return !1;
304
327
  const i = t.getAttribute("data-footnote-id") || "";
305
- return t.remove(), i && n.querySelector(
306
- `${b}#${CSS.escape(i)}`
307
- )?.remove(), T(o, c), D(n), I(n, r), L(n), !0;
328
+ if (t.remove(), i) {
329
+ const c = n.querySelector(
330
+ `${b}#${CSS.escape(i)}`
331
+ );
332
+ c == null || c.remove();
333
+ }
334
+ return T(o, a), D(n), I(n, r), L(n), !0;
308
335
  }
309
336
  function G() {
310
337
  S || typeof document > "u" || (S = !0, document.addEventListener("click", (t) => {
311
338
  const e = t.target;
312
- if (!e) return;
339
+ if (!e)
340
+ return;
313
341
  const n = e.closest(m);
314
342
  if (n) {
315
343
  const f = u(n);
316
- if (!f || !f.contains(n)) return;
344
+ if (!f || !f.contains(n))
345
+ return;
317
346
  t.preventDefault(), t.stopPropagation(), w(n), n.classList.add("rte-footnote-selected"), window.setTimeout(() => n.classList.remove("rte-footnote-selected"), 1200);
318
347
  const l = n.getAttribute("data-footnote-id");
319
- if (!l) return;
348
+ if (!l)
349
+ return;
320
350
  const s = f.querySelector(
321
351
  `${b}#${CSS.escape(l)}`
322
352
  );
323
- if (!s) return;
353
+ if (!s)
354
+ return;
324
355
  s.scrollIntoView({ behavior: "smooth", block: "center" }), k(s);
325
356
  return;
326
357
  }
327
358
  const o = e.closest(".rte-footnote-backref");
328
- if (!o) return;
359
+ if (!o)
360
+ return;
329
361
  const r = o.closest(b);
330
- if (!r) return;
331
- const c = u(r);
332
- if (!c || !c.contains(r)) return;
362
+ if (!r)
363
+ return;
364
+ const a = u(r);
365
+ if (!a || !a.contains(r))
366
+ return;
333
367
  t.preventDefault(), t.stopPropagation();
334
368
  const i = r.id;
335
- if (!i) return;
336
- const a = X(c, i);
337
- a && (a.scrollIntoView({ behavior: "smooth", block: "center" }), k(a), w(a));
369
+ if (!i)
370
+ return;
371
+ const c = X(a, i);
372
+ c && (c.scrollIntoView({ behavior: "smooth", block: "center" }), k(c), w(c));
338
373
  }), document.addEventListener("keydown", (t) => {
339
- if (t.key !== "Backspace" && t.key !== "Delete") return;
374
+ if (t.key !== "Backspace" && t.key !== "Delete")
375
+ return;
340
376
  const e = window.getSelection();
341
- if (!e || e.rangeCount === 0) return;
377
+ if (!e || e.rangeCount === 0)
378
+ return;
342
379
  const n = e.getRangeAt(0), o = u(n.commonAncestorContainer);
343
- if (!o || !o.contains(n.commonAncestorContainer)) return;
380
+ if (!o || !o.contains(n.commonAncestorContainer))
381
+ return;
344
382
  const r = K(n);
345
383
  if (r) {
346
384
  t.preventDefault(), t.stopPropagation(), N(r, t.key);
347
385
  return;
348
386
  }
349
- const c = Y(
387
+ const a = Y(
350
388
  n,
351
389
  o,
352
390
  t.key
353
391
  );
354
- c && (t.preventDefault(), t.stopPropagation(), N(c, t.key));
392
+ a && (t.preventDefault(), t.stopPropagation(), N(a, t.key));
355
393
  }));
356
394
  }
357
395
  const J = (t = "") => {
358
396
  const e = H();
359
- if (!e) return !1;
397
+ if (!e)
398
+ return !1;
360
399
  const n = e.innerHTML, o = window.getSelection();
361
- if (!o) return !1;
400
+ if (!o)
401
+ return !1;
362
402
  let r;
363
403
  try {
364
404
  r = V(e);
@@ -366,18 +406,19 @@ const J = (t = "") => {
366
406
  return !1;
367
407
  }
368
408
  r.collapsed || (r.collapse(!1), o.removeAllRanges(), o.addRange(r));
369
- const c = j(e), i = P(c);
409
+ const a = j(e), i = P(a);
370
410
  try {
371
411
  r.insertNode(i);
372
412
  } catch {
373
413
  return !1;
374
414
  }
375
- const a = document.createRange();
376
- a.setStartAfter(i), a.collapse(!0), o.removeAllRanges(), o.addRange(a);
377
- const f = g(e, !0);
378
- if (!f) return !1;
415
+ const c = document.createRange();
416
+ c.setStartAfter(i), c.collapse(!0), o.removeAllRanges(), o.addRange(c);
417
+ const f = h(e, !0);
418
+ if (!f)
419
+ return !1;
379
420
  const l = O(f), s = t.trim() || "Footnote";
380
- return l.appendChild(F(c, s)), D(e), I(e, n), L(e), !0;
421
+ return l.appendChild(F(a, s)), D(e), I(e, n), L(e), !0;
381
422
  }, Q = () => (M(), G(), {
382
423
  name: "footnote",
383
424
  toolbar: [
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",y=100,M="__editoraCommandEditorRoot",d=new Map,E={};let T=!1,c=null;function I(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function z(){if(typeof window>"u")return null;const t=window[M];if(!(t instanceof HTMLElement))return null;window[M]=null;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);if(e){const o=I(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function F(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function a(t){const e=F(t);if(!e)return null;const n=e.closest(v);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function l(){const t=z();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=a(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=a(n);if(i)return i}if(c?.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function A(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function C(t){A();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function s(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function h(t){return t?t.innerHTML:""}function m(t,e){if(!t)return;const n=C(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y),c=t}function L(t,e="undo"){if(A(),t?.isConnected)return t;const n=l();if(n?.isConnected)return n;if(c?.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function w(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function H(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(E[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{E[o]=r},window.registerEditorCommand(t,e))}const S=(t,...e)=>{const n=E[t];return n?n(...e):!1};function p(){T||typeof window>"u"||(T=!0,window.execEditorCommand||(window.execEditorCommand=S),window.executeEditorCommand||(window.executeEditorCommand=S),u("undo",k),u("redo",D),u("setAttribute",O),u("setText",_),u("autoFixA11y",N),u("recordDomTransaction",R),u("undoDom",b),u("redoDom",g))}function x(t,e){const n=e||l(),o=h(n);n?.focus({preventScroll:!0});let r=!1;try{r=!!document.execCommand(t,!1)}catch{r=!1}const i=h(n),f=o!==i;return f&&s(n),{executed:r,changed:f}}const k=()=>{const t=l();return x("undo",t).changed?!0:b(t??void 0)},D=()=>{const t=l();return x("redo",t).changed?!0:g(t??void 0)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=a(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),m(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),s(o)},_=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=a(t),o=t.textContent??"";t.textContent=e,m(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),s(n)},N=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=a(e),o=window.a11yRuleRegistry?.find(f=>f.id===t.rule);if(!o||typeof o.fix!="function")return;const r=w(e);o.fix(t);const i=w(e);m(n,{undo:()=>{e.isConnected&&H(e,r)},redo:()=>{e.isConnected&&H(e,i)}}),s(n)},R=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(m(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},b=t=>{const e=L(t,"undo");if(!e)return!1;const n=C(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,s(e),!0):!1},g=t=>{const e=L(t,"redo");if(!e)return!1;const n=C(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,s(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p,{once:!0}):p());const Z=()=>(p(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:k,redo:D,setAttribute:O,setText:_,autoFixA11y:N,recordDomTransaction:R,undoDom:b,redoDom:g},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=Z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",y=100,M="__editoraCommandEditorRoot",d=new Map,E={};let T=!1,c=null;function z(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function F(){if(typeof window>"u")return null;const t=window[M];if(!(t instanceof HTMLElement))return null;window[M]=null;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);if(e){const o=z(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function Z(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function f(t){const e=Z(t);if(!e)return null;const n=e.closest(v);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function l(){const t=F();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=f(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=f(n);if(i)return i}if(c!=null&&c.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function A(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function b(t){A();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function s(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function h(t){return t?t.innerHTML:""}function m(t,e){if(!t)return;const n=b(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y),c=t}function L(t,e="undo"){if(A(),t!=null&&t.isConnected)return t;const n=l();if(n!=null&&n.isConnected)return n;if(c!=null&&c.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function w(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function H(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(E[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{E[o]=r},window.registerEditorCommand(t,e))}const S=(t,...e)=>{const n=E[t];return n?n(...e):!1};function C(){T||typeof window>"u"||(T=!0,window.execEditorCommand||(window.execEditorCommand=S),window.executeEditorCommand||(window.executeEditorCommand=S),u("undo",k),u("redo",D),u("setAttribute",O),u("setText",_),u("autoFixA11y",N),u("recordDomTransaction",R),u("undoDom",g),u("redoDom",p))}function x(t,e){const n=e||l(),o=h(n);n==null||n.focus({preventScroll:!0});let r=!1;try{r=!!document.execCommand(t,!1)}catch{r=!1}const i=h(n),a=o!==i;return a&&s(n),{executed:r,changed:a}}const k=()=>{const t=l();return x("undo",t).changed?!0:g(t??void 0)},D=()=>{const t=l();return x("redo",t).changed?!0:p(t??void 0)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=f(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),m(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),s(o)},_=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=f(t),o=t.textContent??"";t.textContent=e,m(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),s(n)},N=t=>{var a;const e=t==null?void 0:t.element;if(!(e instanceof HTMLElement))return;const n=f(e),o=(a=window.a11yRuleRegistry)==null?void 0:a.find(I=>I.id===t.rule);if(!o||typeof o.fix!="function")return;const r=w(e);o.fix(t);const i=w(e);m(n,{undo:()=>{e.isConnected&&H(e,r)},redo:()=>{e.isConnected&&H(e,i)}}),s(n)},R=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(m(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},g=t=>{const e=L(t,"undo");if(!e)return!1;const n=b(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,s(e),!0):!1},p=t=>{const e=L(t,"redo");if(!e)return!1;const n=b(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,s(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C,{once:!0}):C());const j=()=>(C(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:k,redo:D,setAttribute:O,setText:_,autoFixA11y:N,recordDomTransaction:R,undoDom:g,redoDom:p},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=j;