@editora/plugins 1.0.9 → 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.
- package/README.md +5 -0
- package/dist/_commonjsHelpers-6763f629.js +1 -0
- package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +98 -80
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +128 -115
- package/dist/anchoredPopover-33f1358d.mjs +109 -0
- package/dist/anchoredPopover-8151d535.js +1 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +249 -208
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +68 -55
- package/dist/blockquote.esm.js +2 -1
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +245 -178
- package/dist/capitalization.esm.js +2 -1
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +82 -58
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +512 -439
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +33 -27
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +93 -82
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +653 -594
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +158 -116
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +432 -371
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +159 -105
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +368 -328
- package/dist/direction.esm.js +18 -9
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +308 -240
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +5 -4
- package/dist/documentManager-25b6203c.mjs +9122 -0
- package/dist/documentManager-b69e7054.js +17 -0
- package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +81 -73
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +77 -65
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +56 -54
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +47 -39
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +53 -37
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +117 -76
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +92 -70
- package/dist/html2canvas.esm-09133e29.js +22 -0
- package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +24 -12
- package/dist/index-656d224b.js +231 -0
- package/dist/index-6a8c48bb.js +1 -0
- package/dist/index-d027b7e2.mjs +16859 -0
- package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-730f2d98.mjs +5775 -0
- package/dist/index.es-dd40173b.js +18 -0
- package/dist/index.esm.js +128 -125
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +9 -8
- package/dist/jspdf.es.min-90db2c97.js +243 -0
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +24 -11
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +30 -24
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +25 -20
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +61 -59
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +146 -139
- package/dist/media-manager.cjs.js +38 -38
- package/dist/media-manager.esm.js +325 -308
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +286 -238
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +216 -177
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +49 -33
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +463 -393
- package/dist/preview.esm.js +10 -5
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +20 -17
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
- package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
- package/dist/slash-commands.cjs.js +3 -3
- package/dist/slash-commands.esm.js +212 -176
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +336 -280
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +69 -61
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +123 -97
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +19 -14
- package/dist/style.css +1 -0
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +225 -191
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +153 -124
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +27 -21
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +87 -70
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +162 -100
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +678 -602
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +157 -128
- package/package.json +13 -7
- package/LICENSE +0 -21
- package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
- package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/documentManager-CTqRftU8.mjs +0 -8369
- package/dist/documentManager-Jf0RbSks.js +0 -17
- package/dist/html2canvas.esm-B5qzocYs.js +0 -5
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-D3CycEFU.mjs +0 -16543
- package/dist/index-tqLTHcO6.js +0 -1
- package/dist/index.es-CE_A4QSm.js +0 -5
- package/dist/index.es-DQ78mYYo.mjs +0 -6665
- package/dist/jspdf.es.min-BoS80556.js +0 -77
- package/dist/plugins.css +0 -1
- /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
package/dist/font-size.esm.js
CHANGED
|
@@ -21,7 +21,10 @@ const O = () => ({
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
toDOM: (e) =>
|
|
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
|
-
|
|
73
|
+
var o;
|
|
74
|
+
if (!e)
|
|
75
|
+
return !1;
|
|
71
76
|
try {
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
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
|
|
119
|
-
|
|
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
|
|
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)
|
|
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),
|
|
141
|
-
if (!(!a && !f) && !(!a && !
|
|
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)
|
|
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
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
return
|
|
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
|
|
191
|
-
if (
|
|
192
|
-
return
|
|
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)
|
|
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)
|
|
210
|
-
|
|
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
|
|
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
|
-
|
|
236
|
+
l,
|
|
224
237
|
c,
|
|
225
238
|
f
|
|
226
239
|
);
|
|
227
|
-
if (
|
|
240
|
+
if (u && F) {
|
|
228
241
|
S(r), m(r);
|
|
229
242
|
return;
|
|
230
243
|
}
|
|
231
|
-
|
|
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)
|
|
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)
|
|
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)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
}
|
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]",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
|
|
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;
|
package/dist/footnote.esm.js
CHANGED
|
@@ -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")
|
|
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)
|
|
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")
|
|
104
|
+
if (typeof window > "u")
|
|
105
|
+
return null;
|
|
103
106
|
const t = window[x];
|
|
104
|
-
if (!(t instanceof HTMLElement))
|
|
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)
|
|
110
|
-
|
|
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)
|
|
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)
|
|
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)
|
|
148
|
+
if (e)
|
|
149
|
+
return e;
|
|
141
150
|
const n = document.activeElement, o = n ? u(n) : null;
|
|
142
|
-
if (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
|
|
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)
|
|
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 =
|
|
221
|
+
const r = h(t, !1);
|
|
211
222
|
r ? (n.setStartBefore(r), n.collapse(!0)) : (n.selectNodeContents(t), n.collapse(!1));
|
|
212
223
|
}
|
|
213
|
-
|
|
214
|
-
|
|
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)
|
|
233
|
+
if (!e)
|
|
234
|
+
return;
|
|
222
235
|
const n = Array.from(e.childNodes).indexOf(t);
|
|
223
|
-
if (n < 0)
|
|
236
|
+
if (n < 0)
|
|
237
|
+
return;
|
|
224
238
|
const o = window.getSelection();
|
|
225
|
-
if (!o)
|
|
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)
|
|
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)
|
|
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
|
|
253
|
-
for (;
|
|
254
|
-
const i = n === "previous" ?
|
|
255
|
-
if (i)
|
|
256
|
-
|
|
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)
|
|
262
|
-
|
|
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" &&
|
|
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" &&
|
|
270
|
-
const
|
|
271
|
-
return
|
|
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" &&
|
|
274
|
-
const
|
|
275
|
-
return
|
|
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((
|
|
282
|
-
if (!n)
|
|
283
|
-
|
|
284
|
-
|
|
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((
|
|
287
|
-
const l =
|
|
288
|
-
if (!l)
|
|
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
|
-
|
|
291
|
-
let d =
|
|
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
|
|
294
|
-
|
|
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((
|
|
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)
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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)
|
|
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))
|
|
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)
|
|
348
|
+
if (!l)
|
|
349
|
+
return;
|
|
320
350
|
const s = f.querySelector(
|
|
321
351
|
`${b}#${CSS.escape(l)}`
|
|
322
352
|
);
|
|
323
|
-
if (!s)
|
|
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)
|
|
359
|
+
if (!o)
|
|
360
|
+
return;
|
|
329
361
|
const r = o.closest(b);
|
|
330
|
-
if (!r)
|
|
331
|
-
|
|
332
|
-
|
|
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)
|
|
336
|
-
|
|
337
|
-
|
|
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")
|
|
374
|
+
if (t.key !== "Backspace" && t.key !== "Delete")
|
|
375
|
+
return;
|
|
340
376
|
const e = window.getSelection();
|
|
341
|
-
if (!e || e.rangeCount === 0)
|
|
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))
|
|
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
|
|
387
|
+
const a = Y(
|
|
350
388
|
n,
|
|
351
389
|
o,
|
|
352
390
|
t.key
|
|
353
391
|
);
|
|
354
|
-
|
|
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)
|
|
397
|
+
if (!e)
|
|
398
|
+
return !1;
|
|
360
399
|
const n = e.innerHTML, o = window.getSelection();
|
|
361
|
-
if (!o)
|
|
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
|
|
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
|
|
376
|
-
|
|
377
|
-
const f =
|
|
378
|
-
if (!f)
|
|
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(
|
|
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: [
|
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 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;
|