@editora/plugins 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +501 -506
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
package/dist/font-size.esm.js
CHANGED
|
@@ -21,10 +21,7 @@ const O = () => ({
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
toDOM: (e) => {
|
|
25
|
-
var o;
|
|
26
|
-
return ["span", { style: `font-size: ${(o = e.attrs) == null ? void 0 : o.size}` }, 0];
|
|
27
|
-
}
|
|
24
|
+
toDOM: (e) => ["span", { style: `font-size: ${e.attrs?.size}` }, 0]
|
|
28
25
|
}
|
|
29
26
|
},
|
|
30
27
|
toolbar: [
|
|
@@ -70,17 +67,14 @@ const O = () => ({
|
|
|
70
67
|
}
|
|
71
68
|
},
|
|
72
69
|
setFontSize: (e) => {
|
|
73
|
-
|
|
74
|
-
if (!e)
|
|
75
|
-
return !1;
|
|
70
|
+
if (!e) return !1;
|
|
76
71
|
try {
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return console.error("Failed to set font size:", t), !1;
|
|
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;
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
},
|
|
@@ -114,28 +108,25 @@ function b(e) {
|
|
|
114
108
|
return !!e.cloneContents().querySelector(A);
|
|
115
109
|
}
|
|
116
110
|
function x(e) {
|
|
117
|
-
|
|
118
|
-
return (o == null ? void 0 : o.closest('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
|
|
111
|
+
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
119
112
|
}
|
|
120
113
|
function m(e) {
|
|
121
114
|
e && e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
122
115
|
}
|
|
123
116
|
function w(e, o) {
|
|
124
|
-
var i;
|
|
125
117
|
const t = document.createElement("span");
|
|
126
|
-
for (const
|
|
127
|
-
|
|
118
|
+
for (const i of Array.from(e.attributes))
|
|
119
|
+
i.name === "size" || i.name === "style" || t.setAttribute(i.name, i.value);
|
|
128
120
|
const n = e.getAttribute("style");
|
|
129
121
|
for (n && t.setAttribute("style", n), t.style.fontSize = o; e.firstChild; )
|
|
130
122
|
t.appendChild(e.firstChild);
|
|
131
|
-
|
|
123
|
+
e.parentNode?.replaceChild(t, e);
|
|
132
124
|
}
|
|
133
125
|
function E(e, o, t, n) {
|
|
134
126
|
const i = Array.from(
|
|
135
127
|
e.querySelectorAll("font[size], [style*='font-size']")
|
|
136
128
|
), r = (s) => {
|
|
137
|
-
if (!n || !s.isConnected)
|
|
138
|
-
return !1;
|
|
129
|
+
if (!n || !s.isConnected) return !1;
|
|
139
130
|
try {
|
|
140
131
|
if (typeof n.intersectsNode == "function")
|
|
141
132
|
return n.intersectsNode(s);
|
|
@@ -146,8 +137,8 @@ function E(e, o, t, n) {
|
|
|
146
137
|
};
|
|
147
138
|
let c = !1;
|
|
148
139
|
return i.forEach((s) => {
|
|
149
|
-
const a = !o.has(s),
|
|
150
|
-
if (!(!a && !f) && !(!a && !
|
|
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)) {
|
|
151
142
|
if (c = !0, s.tagName === "FONT") {
|
|
152
143
|
w(s, t);
|
|
153
144
|
return;
|
|
@@ -177,8 +168,7 @@ function T(e, o, t) {
|
|
|
177
168
|
}
|
|
178
169
|
function y(e) {
|
|
179
170
|
const o = window.getSelection();
|
|
180
|
-
if (!o || o.rangeCount === 0)
|
|
181
|
-
return;
|
|
171
|
+
if (!o || o.rangeCount === 0) return;
|
|
182
172
|
const { value: t, unit: n } = h();
|
|
183
173
|
let i = e;
|
|
184
174
|
(n === "em" || n === "rem") && (i = e * 0.125);
|
|
@@ -186,28 +176,26 @@ function y(e) {
|
|
|
186
176
|
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);
|
|
187
177
|
}
|
|
188
178
|
function h() {
|
|
189
|
-
var i;
|
|
190
179
|
const e = window.getSelection();
|
|
191
180
|
if (!e || e.rangeCount === 0)
|
|
192
181
|
return { value: 14, unit: "px" };
|
|
193
182
|
const t = e.getRangeAt(0).startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t;
|
|
194
183
|
if (n) {
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
return
|
|
184
|
+
const i = n.style?.fontSize;
|
|
185
|
+
if (i) {
|
|
186
|
+
const a = p(i);
|
|
187
|
+
if (a)
|
|
188
|
+
return a;
|
|
200
189
|
}
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
return
|
|
190
|
+
const c = window.getComputedStyle(n).fontSize, s = p(c);
|
|
191
|
+
if (s)
|
|
192
|
+
return s;
|
|
204
193
|
}
|
|
205
194
|
return { value: 14, unit: "px" };
|
|
206
195
|
}
|
|
207
196
|
function C(e, o = "px") {
|
|
208
197
|
const t = window.getSelection();
|
|
209
|
-
if (!t || t.rangeCount === 0)
|
|
210
|
-
return;
|
|
198
|
+
if (!t || t.rangeCount === 0) return;
|
|
211
199
|
const n = t.getRangeAt(0), i = n.cloneRange(), r = x(n.commonAncestorContainer);
|
|
212
200
|
if (n.collapsed)
|
|
213
201
|
return;
|
|
@@ -218,9 +206,8 @@ function C(e, o = "px") {
|
|
|
218
206
|
d.selectNodeContents(a), t.removeAllRanges(), t.addRange(d);
|
|
219
207
|
return;
|
|
220
208
|
}
|
|
221
|
-
if (!r)
|
|
222
|
-
|
|
223
|
-
const l = new Set(
|
|
209
|
+
if (!r) return;
|
|
210
|
+
const u = new Set(
|
|
224
211
|
Array.from(
|
|
225
212
|
r.querySelectorAll("font[size], [style*='font-size']")
|
|
226
213
|
)
|
|
@@ -230,18 +217,18 @@ function C(e, o = "px") {
|
|
|
230
217
|
document.execCommand("styleWithCSS", !1, "true");
|
|
231
218
|
} catch {
|
|
232
219
|
}
|
|
233
|
-
let
|
|
220
|
+
let l = document.execCommand("fontSize", !1, "7");
|
|
234
221
|
const f = t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() : i, F = E(
|
|
235
222
|
r,
|
|
236
|
-
|
|
223
|
+
u,
|
|
237
224
|
c,
|
|
238
225
|
f
|
|
239
226
|
);
|
|
240
|
-
if (
|
|
227
|
+
if (l && F) {
|
|
241
228
|
S(r), m(r);
|
|
242
229
|
return;
|
|
243
230
|
}
|
|
244
|
-
|
|
231
|
+
l = T(i, t, c), l && (S(r), m(r));
|
|
245
232
|
}
|
|
246
233
|
function R(e) {
|
|
247
234
|
let o = e;
|
|
@@ -262,8 +249,7 @@ function v(e, o) {
|
|
|
262
249
|
function z() {
|
|
263
250
|
setTimeout(() => {
|
|
264
251
|
const { value: e, unit: o } = h(), t = window.getSelection();
|
|
265
|
-
if (!t || t.rangeCount === 0)
|
|
266
|
-
return;
|
|
252
|
+
if (!t || t.rangeCount === 0) return;
|
|
267
253
|
let n = null, r = t.getRangeAt(0).startContainer;
|
|
268
254
|
for (; r; ) {
|
|
269
255
|
if (r instanceof HTMLElement && (r.classList.contains("rte-editor") || r.classList.contains("editora-editor") || r.hasAttribute("data-editora-editor"))) {
|
|
@@ -272,8 +258,7 @@ function z() {
|
|
|
272
258
|
}
|
|
273
259
|
r = r.parentNode;
|
|
274
260
|
}
|
|
275
|
-
if (!n)
|
|
276
|
-
return;
|
|
261
|
+
if (!n) return;
|
|
277
262
|
const c = n.querySelector(
|
|
278
263
|
".rte-toolbar-wrapper, .editora-toolbar-container"
|
|
279
264
|
) || n, s = Array.from(
|
|
@@ -281,11 +266,10 @@ function z() {
|
|
|
281
266
|
'input[data-command="setFontSize"], input.editora-toolbar-input.font-size, input.rte-toolbar-input.font-size, input[title="Font Size"]'
|
|
282
267
|
)
|
|
283
268
|
);
|
|
284
|
-
if (s.length === 0)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
u.value = l;
|
|
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;
|
|
289
273
|
});
|
|
290
274
|
}, 10);
|
|
291
275
|
}
|
package/dist/footnote.cjs.js
CHANGED
|
@@ -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]",
|
|
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=`
|
|
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
|
|
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;
|
package/dist/footnote.esm.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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")
|
|
5
|
-
return;
|
|
4
|
+
if (y || typeof document > "u") return;
|
|
6
5
|
y = !0;
|
|
7
6
|
const t = document.createElement("style");
|
|
8
7
|
t.id = "editora-footnote-plugin-styles", t.textContent = `
|
|
@@ -95,25 +94,20 @@ function v(t) {
|
|
|
95
94
|
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
|
|
96
95
|
}
|
|
97
96
|
function _(t) {
|
|
98
|
-
if (!t)
|
|
99
|
-
return null;
|
|
97
|
+
if (!t) return null;
|
|
100
98
|
const e = t.querySelector('[contenteditable="true"]');
|
|
101
99
|
return e instanceof HTMLElement ? e : null;
|
|
102
100
|
}
|
|
103
101
|
function q() {
|
|
104
|
-
if (typeof window > "u")
|
|
105
|
-
return null;
|
|
102
|
+
if (typeof window > "u") return null;
|
|
106
103
|
const t = window[x];
|
|
107
|
-
if (!(t instanceof HTMLElement))
|
|
108
|
-
return null;
|
|
104
|
+
if (!(t instanceof HTMLElement)) return null;
|
|
109
105
|
window[x] = null;
|
|
110
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);
|
|
111
107
|
if (e) {
|
|
112
108
|
const o = _(e);
|
|
113
|
-
if (o)
|
|
114
|
-
|
|
115
|
-
if (e.getAttribute("contenteditable") === "true")
|
|
116
|
-
return e;
|
|
109
|
+
if (o) return o;
|
|
110
|
+
if (e.getAttribute("contenteditable") === "true") return e;
|
|
117
111
|
}
|
|
118
112
|
if (t.getAttribute("contenteditable") === "true")
|
|
119
113
|
return t;
|
|
@@ -122,8 +116,7 @@ function q() {
|
|
|
122
116
|
}
|
|
123
117
|
function $(t) {
|
|
124
118
|
const e = t.closest('[contenteditable="true"]');
|
|
125
|
-
if (!e)
|
|
126
|
-
return null;
|
|
119
|
+
if (!e) return null;
|
|
127
120
|
let n = e, o = n.parentElement;
|
|
128
121
|
for (; o; )
|
|
129
122
|
o.getAttribute("contenteditable") === "true" && (n = o), o = o.parentElement;
|
|
@@ -131,8 +124,7 @@ function $(t) {
|
|
|
131
124
|
}
|
|
132
125
|
function u(t) {
|
|
133
126
|
const e = v(t);
|
|
134
|
-
if (!e)
|
|
135
|
-
return null;
|
|
127
|
+
if (!e) return null;
|
|
136
128
|
const n = e.closest(R);
|
|
137
129
|
return n || $(e);
|
|
138
130
|
}
|
|
@@ -145,11 +137,9 @@ function H() {
|
|
|
145
137
|
if (t && document.contains(t))
|
|
146
138
|
return t;
|
|
147
139
|
const e = B();
|
|
148
|
-
if (e)
|
|
149
|
-
return e;
|
|
140
|
+
if (e) return e;
|
|
150
141
|
const n = document.activeElement, o = n ? u(n) : null;
|
|
151
|
-
if (o)
|
|
152
|
-
return o;
|
|
142
|
+
if (o) return o;
|
|
153
143
|
const r = document.querySelector(R);
|
|
154
144
|
return r || document.querySelector('[contenteditable="true"]');
|
|
155
145
|
}
|
|
@@ -159,7 +149,7 @@ function z() {
|
|
|
159
149
|
const e = document.createElement("ol");
|
|
160
150
|
return t.appendChild(e), t;
|
|
161
151
|
}
|
|
162
|
-
function
|
|
152
|
+
function g(t, e) {
|
|
163
153
|
let n = t.querySelector(C);
|
|
164
154
|
return !n && e && (n = z(), t.appendChild(n)), n ? (n.querySelector("ol") || n.appendChild(document.createElement("ol")), n) : null;
|
|
165
155
|
}
|
|
@@ -195,8 +185,7 @@ function L(t) {
|
|
|
195
185
|
t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
196
186
|
}
|
|
197
187
|
function I(t, e) {
|
|
198
|
-
if (!t || e === t.innerHTML)
|
|
199
|
-
return;
|
|
188
|
+
if (!t || e === t.innerHTML) return;
|
|
200
189
|
const n = window.execEditorCommand || window.executeEditorCommand;
|
|
201
190
|
if (typeof n == "function")
|
|
202
191
|
try {
|
|
@@ -218,33 +207,28 @@ function V(t) {
|
|
|
218
207
|
}
|
|
219
208
|
if (!n) {
|
|
220
209
|
n = document.createRange();
|
|
221
|
-
const r =
|
|
210
|
+
const r = g(t, !1);
|
|
222
211
|
r ? (n.setStartBefore(r), n.collapse(!0)) : (n.selectNodeContents(t), n.collapse(!1));
|
|
223
212
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const r = h(t, !0);
|
|
213
|
+
if (v(n.commonAncestorContainer)?.closest(C)) {
|
|
214
|
+
const r = g(t, !0);
|
|
227
215
|
r && (n.setStartBefore(r), n.collapse(!0));
|
|
228
216
|
}
|
|
229
217
|
return e.removeAllRanges(), e.addRange(n), n;
|
|
230
218
|
}
|
|
231
219
|
function w(t) {
|
|
232
220
|
const e = t.parentNode;
|
|
233
|
-
if (!e)
|
|
234
|
-
return;
|
|
221
|
+
if (!e) return;
|
|
235
222
|
const n = Array.from(e.childNodes).indexOf(t);
|
|
236
|
-
if (n < 0)
|
|
237
|
-
return;
|
|
223
|
+
if (n < 0) return;
|
|
238
224
|
const o = window.getSelection();
|
|
239
|
-
if (!o)
|
|
240
|
-
return;
|
|
225
|
+
if (!o) return;
|
|
241
226
|
const r = document.createRange();
|
|
242
227
|
r.setStart(e, n), r.setEnd(e, n + 1), o.removeAllRanges(), o.addRange(r), t.focus({ preventScroll: !0 });
|
|
243
228
|
}
|
|
244
229
|
function T(t, e) {
|
|
245
230
|
const n = window.getSelection();
|
|
246
|
-
if (!n)
|
|
247
|
-
return;
|
|
231
|
+
if (!n) return;
|
|
248
232
|
const o = Math.max(0, Math.min(e, t.childNodes.length)), r = document.createRange();
|
|
249
233
|
r.setStart(t, o), r.collapse(!0), n.removeAllRanges(), n.addRange(r);
|
|
250
234
|
}
|
|
@@ -259,146 +243,122 @@ function p(t, e, n) {
|
|
|
259
243
|
if (o.nodeType === Node.ELEMENT_NODE) {
|
|
260
244
|
const i = o;
|
|
261
245
|
if (n === "previous") {
|
|
262
|
-
if (r > 0)
|
|
263
|
-
return i.childNodes[r - 1] || null;
|
|
246
|
+
if (r > 0) return i.childNodes[r - 1] || null;
|
|
264
247
|
} else if (r < i.childNodes.length)
|
|
265
248
|
return i.childNodes[r] || null;
|
|
266
249
|
}
|
|
267
250
|
if (o.nodeType === Node.TEXT_NODE && (n === "previous" && r < o.data.length || n === "next" && r > 0))
|
|
268
251
|
return null;
|
|
269
|
-
let
|
|
270
|
-
for (;
|
|
271
|
-
const i = n === "previous" ?
|
|
272
|
-
if (i)
|
|
273
|
-
|
|
274
|
-
a = a.parentNode;
|
|
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;
|
|
275
257
|
}
|
|
276
258
|
return null;
|
|
277
259
|
}
|
|
278
260
|
function Y(t, e, n) {
|
|
279
|
-
if (!t.collapsed)
|
|
280
|
-
|
|
281
|
-
const o = (i) => i instanceof HTMLElement && i.matches(m) ? i : null, { startContainer: r, startOffset: a } = t;
|
|
261
|
+
if (!t.collapsed) return null;
|
|
262
|
+
const o = (i) => i instanceof HTMLElement && i.matches(m) ? i : null, { startContainer: r, startOffset: c } = t;
|
|
282
263
|
if (r.nodeType === Node.ELEMENT_NODE) {
|
|
283
264
|
const i = r;
|
|
284
|
-
return n === "Backspace" &&
|
|
265
|
+
return n === "Backspace" && c > 0 ? o(i.childNodes[c - 1] || null) : n === "Delete" ? o(i.childNodes[c] || null) : null;
|
|
285
266
|
}
|
|
286
267
|
if (r.nodeType === Node.TEXT_NODE) {
|
|
287
268
|
const i = r;
|
|
288
|
-
if (n === "Backspace" &&
|
|
289
|
-
const
|
|
290
|
-
return
|
|
269
|
+
if (n === "Backspace" && c === 0) {
|
|
270
|
+
const a = o(i.previousSibling);
|
|
271
|
+
return a || o(p(t, e, "previous"));
|
|
291
272
|
}
|
|
292
|
-
if (n === "Delete" &&
|
|
293
|
-
const
|
|
294
|
-
return
|
|
273
|
+
if (n === "Delete" && c === i.data.length) {
|
|
274
|
+
const a = o(i.nextSibling);
|
|
275
|
+
return a || o(p(t, e, "next"));
|
|
295
276
|
}
|
|
296
277
|
}
|
|
297
278
|
return o(n === "Backspace" ? p(t, e, "previous") : p(t, e, "next"));
|
|
298
279
|
}
|
|
299
280
|
function D(t) {
|
|
300
|
-
const e = Array.from(t.querySelectorAll(m)).filter((
|
|
301
|
-
if (!n)
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
r.forEach((c) => a.set(c.id, c));
|
|
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));
|
|
305
285
|
const i = [];
|
|
306
|
-
e.forEach((
|
|
307
|
-
const l =
|
|
308
|
-
if (!l)
|
|
309
|
-
return;
|
|
286
|
+
e.forEach((a, f) => {
|
|
287
|
+
const l = a.getAttribute("data-footnote-id");
|
|
288
|
+
if (!l) return;
|
|
310
289
|
const s = f + 1;
|
|
311
|
-
|
|
312
|
-
let d =
|
|
290
|
+
a.setAttribute("data-number", String(s)), a.id = `ref-${l}`, a.textContent = String(s);
|
|
291
|
+
let d = c.get(l);
|
|
313
292
|
d || (d = F(l, `Footnote ${s}`)), d.setAttribute("data-number", String(s));
|
|
314
|
-
const
|
|
315
|
-
|
|
293
|
+
const h = d.querySelector(".rte-footnote-content");
|
|
294
|
+
h && !(h.textContent || "").trim() && (h.textContent = `Footnote ${s}`);
|
|
316
295
|
const E = d.querySelector(".rte-footnote-backref");
|
|
317
296
|
E && (E.href = `#ref-${l}`, E.setAttribute("aria-label", `Back to reference ${s}`)), i.push(d);
|
|
318
|
-
}), o.innerHTML = "", i.forEach((
|
|
297
|
+
}), o.innerHTML = "", i.forEach((a) => o.appendChild(a)), i.length === 0 && n.remove();
|
|
319
298
|
}
|
|
320
299
|
function N(t, e) {
|
|
321
300
|
const n = u(t), o = t.parentNode;
|
|
322
|
-
if (!n || !o)
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (a < 0)
|
|
326
|
-
return !1;
|
|
301
|
+
if (!n || !o) return !1;
|
|
302
|
+
const r = n.innerHTML, c = Array.from(o.childNodes).indexOf(t);
|
|
303
|
+
if (c < 0) return !1;
|
|
327
304
|
const i = t.getAttribute("data-footnote-id") || "";
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
);
|
|
332
|
-
c == null || c.remove();
|
|
333
|
-
}
|
|
334
|
-
return T(o, a), D(n), I(n, r), L(n), !0;
|
|
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;
|
|
335
308
|
}
|
|
336
309
|
function G() {
|
|
337
310
|
S || typeof document > "u" || (S = !0, document.addEventListener("click", (t) => {
|
|
338
311
|
const e = t.target;
|
|
339
|
-
if (!e)
|
|
340
|
-
return;
|
|
312
|
+
if (!e) return;
|
|
341
313
|
const n = e.closest(m);
|
|
342
314
|
if (n) {
|
|
343
315
|
const f = u(n);
|
|
344
|
-
if (!f || !f.contains(n))
|
|
345
|
-
return;
|
|
316
|
+
if (!f || !f.contains(n)) return;
|
|
346
317
|
t.preventDefault(), t.stopPropagation(), w(n), n.classList.add("rte-footnote-selected"), window.setTimeout(() => n.classList.remove("rte-footnote-selected"), 1200);
|
|
347
318
|
const l = n.getAttribute("data-footnote-id");
|
|
348
|
-
if (!l)
|
|
349
|
-
return;
|
|
319
|
+
if (!l) return;
|
|
350
320
|
const s = f.querySelector(
|
|
351
321
|
`${b}#${CSS.escape(l)}`
|
|
352
322
|
);
|
|
353
|
-
if (!s)
|
|
354
|
-
return;
|
|
323
|
+
if (!s) return;
|
|
355
324
|
s.scrollIntoView({ behavior: "smooth", block: "center" }), k(s);
|
|
356
325
|
return;
|
|
357
326
|
}
|
|
358
327
|
const o = e.closest(".rte-footnote-backref");
|
|
359
|
-
if (!o)
|
|
360
|
-
return;
|
|
328
|
+
if (!o) return;
|
|
361
329
|
const r = o.closest(b);
|
|
362
|
-
if (!r)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (!a || !a.contains(r))
|
|
366
|
-
return;
|
|
330
|
+
if (!r) return;
|
|
331
|
+
const c = u(r);
|
|
332
|
+
if (!c || !c.contains(r)) return;
|
|
367
333
|
t.preventDefault(), t.stopPropagation();
|
|
368
334
|
const i = r.id;
|
|
369
|
-
if (!i)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
c && (c.scrollIntoView({ behavior: "smooth", block: "center" }), k(c), w(c));
|
|
335
|
+
if (!i) return;
|
|
336
|
+
const a = X(c, i);
|
|
337
|
+
a && (a.scrollIntoView({ behavior: "smooth", block: "center" }), k(a), w(a));
|
|
373
338
|
}), document.addEventListener("keydown", (t) => {
|
|
374
|
-
if (t.key !== "Backspace" && t.key !== "Delete")
|
|
375
|
-
return;
|
|
339
|
+
if (t.key !== "Backspace" && t.key !== "Delete") return;
|
|
376
340
|
const e = window.getSelection();
|
|
377
|
-
if (!e || e.rangeCount === 0)
|
|
378
|
-
return;
|
|
341
|
+
if (!e || e.rangeCount === 0) return;
|
|
379
342
|
const n = e.getRangeAt(0), o = u(n.commonAncestorContainer);
|
|
380
|
-
if (!o || !o.contains(n.commonAncestorContainer))
|
|
381
|
-
return;
|
|
343
|
+
if (!o || !o.contains(n.commonAncestorContainer)) return;
|
|
382
344
|
const r = K(n);
|
|
383
345
|
if (r) {
|
|
384
346
|
t.preventDefault(), t.stopPropagation(), N(r, t.key);
|
|
385
347
|
return;
|
|
386
348
|
}
|
|
387
|
-
const
|
|
349
|
+
const c = Y(
|
|
388
350
|
n,
|
|
389
351
|
o,
|
|
390
352
|
t.key
|
|
391
353
|
);
|
|
392
|
-
|
|
354
|
+
c && (t.preventDefault(), t.stopPropagation(), N(c, t.key));
|
|
393
355
|
}));
|
|
394
356
|
}
|
|
395
357
|
const J = (t = "") => {
|
|
396
358
|
const e = H();
|
|
397
|
-
if (!e)
|
|
398
|
-
return !1;
|
|
359
|
+
if (!e) return !1;
|
|
399
360
|
const n = e.innerHTML, o = window.getSelection();
|
|
400
|
-
if (!o)
|
|
401
|
-
return !1;
|
|
361
|
+
if (!o) return !1;
|
|
402
362
|
let r;
|
|
403
363
|
try {
|
|
404
364
|
r = V(e);
|
|
@@ -406,19 +366,18 @@ const J = (t = "") => {
|
|
|
406
366
|
return !1;
|
|
407
367
|
}
|
|
408
368
|
r.collapsed || (r.collapse(!1), o.removeAllRanges(), o.addRange(r));
|
|
409
|
-
const
|
|
369
|
+
const c = j(e), i = P(c);
|
|
410
370
|
try {
|
|
411
371
|
r.insertNode(i);
|
|
412
372
|
} catch {
|
|
413
373
|
return !1;
|
|
414
374
|
}
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
const f =
|
|
418
|
-
if (!f)
|
|
419
|
-
return !1;
|
|
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;
|
|
420
379
|
const l = O(f), s = t.trim() || "Footnote";
|
|
421
|
-
return l.appendChild(F(
|
|
380
|
+
return l.appendChild(F(c, s)), D(e), I(e, n), L(e), !0;
|
|
422
381
|
}, Q = () => (M(), G(), {
|
|
423
382
|
name: "footnote",
|
|
424
383
|
toolbar: [
|
package/dist/history.cjs.js
CHANGED
|
@@ -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
|
|
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;
|