@editora/core 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 +1 -1
- package/dist/{A11yCheckerPlugin.native-58d12bed.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +12 -23
- package/dist/{AnchorPlugin.native-289a112a.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +102 -112
- package/dist/{ApprovalWorkflowPlugin.native-449ce66c.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +173 -209
- package/dist/{BackgroundColorPlugin.native-8aceb5cc.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +9 -16
- package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
- package/dist/{BlocksLibraryPlugin.native-1cc51e63.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +149 -205
- package/dist/{BoldPlugin.native-f9d7f8e4.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
- package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
- package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
- package/dist/{CitationsPlugin.native-169fb1e8.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +196 -261
- package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
- package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
- package/dist/{CodeSamplePlugin.native-6cc0148e.mjs → CodeSamplePlugin.native-CgGoH-X4.mjs} +10 -19
- package/dist/{CommentsPlugin.native-03659874.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +28 -55
- package/dist/{ConditionalContentPlugin.native-4983143a.mjs → ConditionalContentPlugin.native-CfhY46rU.mjs} +51 -108
- package/dist/{ContentRulesPlugin.native-63ed405b.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +153 -200
- package/dist/{DataBindingPlugin.native-427e9d75.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +88 -124
- package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
- package/dist/{DocSchemaPlugin.native-8e41eda0.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +112 -166
- package/dist/{DocumentManagerPlugin.native-e69895ad.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +4 -4
- package/dist/EmbedIframePlugin.native-BF_-LjTq.mjs +740 -0
- package/dist/{EmojisPlugin.native-65c5ac47.mjs → EmojisPlugin.native-CitxxlWX.mjs} +6 -11
- package/dist/{FontFamilyPlugin.native-f9bc255a.mjs → FontFamilyPlugin.native-j8hMTbg4.mjs} +4 -7
- package/dist/{FontSizePlugin.native-f5647872.mjs → FontSizePlugin.native-B_jCh7dY.mjs} +10 -19
- package/dist/{FootnotePlugin.native-494657b3.mjs → FootnotePlugin.native-D730OGRm.mjs} +39 -77
- package/dist/{FullscreenPlugin.native-87ce92e9.mjs → FullscreenPlugin.native-ChXyxeNw.mjs} +1 -1
- package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
- package/dist/{HistoryPlugin.native-92ed4be4.mjs → HistoryPlugin.native-D2wl32jV.mjs} +107 -143
- package/dist/{IndentPlugin.native-e4ee902b.mjs → IndentPlugin.native-BHixp8sP.mjs} +12 -23
- package/dist/{ItalicPlugin.native-7c95cfbc.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
- package/dist/{LineHeightPlugin.native-5668f78c.mjs → LineHeightPlugin.native-CM7iXdQj.mjs} +10 -19
- package/dist/{LinkPlugin.native-6df29111.mjs → LinkPlugin.native-DYCIcdTm.mjs} +5 -9
- package/dist/{ListPlugin.native-fe2e115a.mjs → ListPlugin.native-V7EZC1lM.mjs} +5 -9
- package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
- package/dist/{MediaManagerPlugin.native-3cf48a00.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +11 -21
- package/dist/{MentionPlugin.native-3b1e8c05.mjs → MentionPlugin.native-BMDlOqur.mjs} +45 -89
- package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
- package/dist/{PIIRedactionPlugin.native-7ab10b9f.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +210 -260
- package/dist/{PageBreakPlugin.native-1794c5fb.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +16 -31
- package/dist/{PreviewPlugin.native-f7b67cc0.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +6 -11
- package/dist/{PrintPlugin.native-f6a168c2.mjs → PrintPlugin.native-7qt5v7L5.mjs} +3 -5
- package/dist/{SlashCommandsPlugin.native-8d45e511.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +36 -71
- package/dist/{SmartPastePlugin.native-a6c5efec.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +173 -219
- package/dist/{SpecialCharactersPlugin.native-7f06d4ba.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +101 -85
- package/dist/{SpellCheckPlugin.native-04e20834.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +21 -41
- package/dist/{StrikethroughPlugin.native-905e9501.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -30
- package/dist/{TablePlugin.native-7d5458c1.mjs → TablePlugin.native-DrHX-efe.mjs} +30 -58
- package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
- package/dist/{TextAlignmentPlugin.native-9357b3ed.mjs → TextAlignmentPlugin.native-sM_1s00t.mjs} +6 -11
- package/dist/{TextColorPlugin.native-d53ed459.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +14 -26
- package/dist/{TrackChangesPlugin.native-e96da509.mjs → TrackChangesPlugin.native-Bghu2q4a.mjs} +58 -115
- package/dist/{TranslationWorkflowPlugin.native-4e711b1e.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +191 -257
- package/dist/{UnderlinePlugin.native-8080c998.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
- package/dist/{VersionDiffPlugin.native-5bbeff85.mjs → VersionDiffPlugin.native-Bvxgy--t.mjs} +26 -51
- package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
- package/dist/{anchoredPopover-5cca53ba.mjs → anchoredPopover-Bxds0VoB.mjs} +1 -1
- package/dist/core.css +1 -0
- package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +2 -3
- package/dist/editora.min.js +13 -14
- package/dist/editora.umd.js +13 -14
- package/dist/{html2canvas.esm-c51cb3b9.mjs → html2canvas.esm-AYkPY5LS.mjs} +894 -978
- package/dist/index-BslAFzmv.mjs +16544 -0
- package/dist/index-CPMGUZfB.js +10 -0
- package/dist/{index-7da30697.mjs → index-DBoj6QfW.mjs} +127 -164
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-BYD2KEo6.mjs +6666 -0
- package/dist/index.esm.js +7 -12
- package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
- package/dist/{jspdf.es.min-780c82db.mjs → jspdf.es.min-BJGtOnRT.mjs} +3784 -4808
- package/dist/plugin-loader.js +67 -67
- package/dist/{purify.es-3bdbcfc5.mjs → purify.es-CKpwg8Tk.mjs} +10 -20
- package/dist/webcomponent-core.js +131 -168
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +139 -63
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +191 -228
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1240 -1344
- package/package.json +1 -1
- package/dist/BlockquotePlugin.native-3541c714.mjs +0 -49
- package/dist/CapitalizationPlugin.native-42c135dc.mjs +0 -80
- package/dist/ChecklistPlugin.native-3b397ee9.mjs +0 -330
- package/dist/ClearFormattingPlugin.native-77baa514.mjs +0 -145
- package/dist/CodePlugin.native-989cf0aa.mjs +0 -2740
- package/dist/DirectionPlugin.native-4e742f42.mjs +0 -139
- package/dist/EmbedIframePlugin.native-55209c87.mjs +0 -568
- package/dist/HeadingPlugin.native-e38c4a16.mjs +0 -64
- package/dist/MathPlugin.native-735bbac2.mjs +0 -296
- package/dist/MergeTagPlugin.native-31cf7d48.mjs +0 -584
- package/dist/TemplatePlugin.native-580f0f63.mjs +0 -617
- package/dist/_commonjsHelpers-69d58be2.mjs +0 -31
- package/dist/documentManager-8327fb6e.mjs +0 -9166
- package/dist/index-072ef022.js +0 -11
- package/dist/index-49d31221.mjs +0 -16860
- package/dist/index.es-b47a189f.mjs +0 -5782
- package/dist/style.css +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as l } from "./inlineFormatting-DJ0-NZtx.mjs";
|
|
2
|
+
const g = () => ({
|
|
2
3
|
name: "bold",
|
|
3
4
|
// Schema definition for bold mark
|
|
4
5
|
marks: {
|
|
@@ -8,9 +9,9 @@ const e = () => ({
|
|
|
8
9
|
{ tag: "b" },
|
|
9
10
|
{
|
|
10
11
|
style: "font-weight",
|
|
11
|
-
getAttrs: (
|
|
12
|
-
const
|
|
13
|
-
return /^(bold(er)?|[5-9]\d{2,})$/.test(
|
|
12
|
+
getAttrs: (o) => {
|
|
13
|
+
const t = typeof o == "string" ? o : o.style.fontWeight;
|
|
14
|
+
return /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
],
|
|
@@ -31,7 +32,10 @@ const e = () => ({
|
|
|
31
32
|
/**
|
|
32
33
|
* Toggle bold formatting on current selection
|
|
33
34
|
*/
|
|
34
|
-
toggleBold: () => (
|
|
35
|
+
toggleBold: (o, t) => l({
|
|
36
|
+
command: "bold",
|
|
37
|
+
context: t
|
|
38
|
+
})
|
|
35
39
|
},
|
|
36
40
|
// Keyboard shortcuts
|
|
37
41
|
keymap: {
|
|
@@ -40,6 +44,6 @@ const e = () => ({
|
|
|
40
44
|
}
|
|
41
45
|
});
|
|
42
46
|
export {
|
|
43
|
-
|
|
47
|
+
g as BoldPlugin
|
|
44
48
|
};
|
|
45
|
-
//# sourceMappingURL=BoldPlugin.native-
|
|
49
|
+
//# sourceMappingURL=BoldPlugin.native-CSh_LiIJ.mjs.map
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", h = (t) => t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null, v = (t) => {
|
|
2
|
+
const e = t == null ? void 0 : t.contentElement;
|
|
3
|
+
if (e instanceof HTMLElement) return e;
|
|
4
|
+
const n = t == null ? void 0 : t.editorElement;
|
|
5
|
+
if (n instanceof HTMLElement) {
|
|
6
|
+
const a = n.querySelector(f);
|
|
7
|
+
if (a instanceof HTMLElement) return a;
|
|
8
|
+
if (n.getAttribute("contenteditable") === "true") return n;
|
|
9
|
+
}
|
|
10
|
+
const r = window.__editoraCommandEditorRoot;
|
|
11
|
+
if (r instanceof HTMLElement) {
|
|
12
|
+
const a = r.querySelector(f);
|
|
13
|
+
if (a instanceof HTMLElement) return a;
|
|
14
|
+
if (r.getAttribute("contenteditable") === "true") return r;
|
|
15
|
+
}
|
|
16
|
+
const c = window.getSelection();
|
|
17
|
+
if (c && c.rangeCount > 0) {
|
|
18
|
+
const a = h(c.getRangeAt(0).startContainer), s = a == null ? void 0 : a.closest(f);
|
|
19
|
+
if (s instanceof HTMLElement) return s;
|
|
20
|
+
const o = a == null ? void 0 : a.closest(w), i = o == null ? void 0 : o.querySelector(f);
|
|
21
|
+
if (i instanceof HTMLElement) return i;
|
|
22
|
+
}
|
|
23
|
+
const l = document.activeElement, u = l instanceof HTMLElement ? l.closest(f) : null;
|
|
24
|
+
return u instanceof HTMLElement ? u : document.querySelector(f);
|
|
25
|
+
}, S = (t) => {
|
|
26
|
+
const e = window.getSelection();
|
|
27
|
+
if (!e || e.rangeCount === 0 || e.isCollapsed) return null;
|
|
28
|
+
const n = e.getRangeAt(0);
|
|
29
|
+
return !t.contains(n.startContainer) || !t.contains(n.endContainer) ? null : n;
|
|
30
|
+
}, R = (t, e) => {
|
|
31
|
+
if (!e.data) return !1;
|
|
32
|
+
if (typeof t.intersectsNode == "function")
|
|
33
|
+
try {
|
|
34
|
+
return t.intersectsNode(e);
|
|
35
|
+
} catch (r) {
|
|
36
|
+
return !1;
|
|
37
|
+
}
|
|
38
|
+
const n = document.createRange();
|
|
39
|
+
return n.selectNodeContents(e), t.compareBoundaryPoints(Range.END_TO_START, n) < 0 && t.compareBoundaryPoints(Range.START_TO_END, n) > 0;
|
|
40
|
+
}, L = (t, e) => {
|
|
41
|
+
const n = [], r = document.createTreeWalker(t, NodeFilter.SHOW_TEXT);
|
|
42
|
+
let c = r.nextNode();
|
|
43
|
+
for (; c; ) {
|
|
44
|
+
const l = c;
|
|
45
|
+
if (R(e, l)) {
|
|
46
|
+
const u = l === e.startContainer ? e.startOffset : 0, a = l === e.endContainer ? e.endOffset : l.data.length;
|
|
47
|
+
u < a && n.push({
|
|
48
|
+
node: l,
|
|
49
|
+
start: u,
|
|
50
|
+
end: a,
|
|
51
|
+
text: l.data.slice(u, a)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
c = r.nextNode();
|
|
55
|
+
}
|
|
56
|
+
return n;
|
|
57
|
+
}, y = (t) => /\p{L}/u.test(t), _ = (t) => /[\p{M}'’-]/u.test(t), M = () => {
|
|
58
|
+
let t = !1;
|
|
59
|
+
return (e) => {
|
|
60
|
+
let n = "";
|
|
61
|
+
return Array.from(e.text).forEach((r) => {
|
|
62
|
+
if (y(r)) {
|
|
63
|
+
n += t ? r.toLocaleLowerCase() : r.toLocaleUpperCase(), t = !0;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
n += r, _(r) || (t = !1);
|
|
67
|
+
}), n;
|
|
68
|
+
};
|
|
69
|
+
}, H = (t) => {
|
|
70
|
+
if (t.length === 0) return;
|
|
71
|
+
const e = t[0], n = t[t.length - 1], r = window.getSelection();
|
|
72
|
+
if (!r) return;
|
|
73
|
+
const c = document.createRange();
|
|
74
|
+
c.setStart(e.node, e.start), c.setEnd(n.node, n.end), r.removeAllRanges(), r.addRange(c);
|
|
75
|
+
}, N = (t, e, n) => {
|
|
76
|
+
if (e !== n) {
|
|
77
|
+
if (typeof window.execEditorCommand == "function") {
|
|
78
|
+
window.execEditorCommand("recordDomTransaction", t, e, n);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (typeof window.executeEditorCommand == "function")
|
|
82
|
+
try {
|
|
83
|
+
window.executeEditorCommand("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
|
|
84
|
+
} catch (r) {
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}, b = () => {
|
|
88
|
+
const t = (s, o) => {
|
|
89
|
+
try {
|
|
90
|
+
const i = v(o);
|
|
91
|
+
if (!i) return !1;
|
|
92
|
+
const m = S(i);
|
|
93
|
+
if (!m) return !1;
|
|
94
|
+
const p = L(i, m);
|
|
95
|
+
if (p.length === 0) return !1;
|
|
96
|
+
const C = i.innerHTML;
|
|
97
|
+
p.forEach((d, T) => {
|
|
98
|
+
const E = s(d, T);
|
|
99
|
+
d.node.replaceData(d.start, d.end - d.start, E), d.end = d.start + E.length;
|
|
100
|
+
});
|
|
101
|
+
const g = i.innerHTML;
|
|
102
|
+
return C === g ? !1 : (N(i, C, g), i.dispatchEvent(new window.Event("input", { bubbles: !0 })), H(p), !0);
|
|
103
|
+
} catch (i) {
|
|
104
|
+
return console.error("Failed to transform capitalization:", i), !1;
|
|
105
|
+
}
|
|
106
|
+
}, e = (s, o) => t((i) => i.text.toLocaleUpperCase(), o), n = (s, o) => t((i) => i.text.toLocaleLowerCase(), o), r = (s, o) => t(M(), o), c = (s, o) => {
|
|
107
|
+
if (!s) return !1;
|
|
108
|
+
switch (s) {
|
|
109
|
+
case "uppercase":
|
|
110
|
+
return e(void 0, o);
|
|
111
|
+
case "lowercase":
|
|
112
|
+
return n(void 0, o);
|
|
113
|
+
case "titlecase":
|
|
114
|
+
return r(void 0, o);
|
|
115
|
+
default:
|
|
116
|
+
return !1;
|
|
117
|
+
}
|
|
118
|
+
}, l = (s, o) => typeof s == "string" ? { value: s, context: o } : typeof o == "string" ? { value: o } : {
|
|
119
|
+
value: void 0,
|
|
120
|
+
context: o
|
|
121
|
+
}, u = (s, o) => {
|
|
122
|
+
if (o && typeof o == "object" && !o.doc)
|
|
123
|
+
return o;
|
|
124
|
+
}, a = (s) => (o, i) => s(void 0, u(o, i));
|
|
125
|
+
return {
|
|
126
|
+
name: "capitalization",
|
|
127
|
+
toolbar: [
|
|
128
|
+
{
|
|
129
|
+
label: "Capitalization",
|
|
130
|
+
command: "setCapitalization",
|
|
131
|
+
type: "inline-menu",
|
|
132
|
+
options: [
|
|
133
|
+
{ label: "lowercase", value: "lowercase" },
|
|
134
|
+
{ label: "UPPERCASE", value: "uppercase" },
|
|
135
|
+
{ label: "Title Case", value: "titlecase" }
|
|
136
|
+
],
|
|
137
|
+
icon: '<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" class="cls-1" width="32" height="32"></rect></g></svg>'
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
commands: {
|
|
141
|
+
setCapitalization: (s, o) => {
|
|
142
|
+
const { value: i, context: m } = l(s, o);
|
|
143
|
+
return c(i, m);
|
|
144
|
+
},
|
|
145
|
+
toUpperCase: a(e),
|
|
146
|
+
toLowerCase: a(n),
|
|
147
|
+
toTitleCase: a(r)
|
|
148
|
+
},
|
|
149
|
+
keymap: {
|
|
150
|
+
"Mod-Shift-u": "toUpperCase",
|
|
151
|
+
"Mod-Shift-k": "toLowerCase",
|
|
152
|
+
"Mod-Shift-t": "toTitleCase"
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export {
|
|
157
|
+
b as CapitalizationPlugin
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=CapitalizationPlugin.native-DLV4oPmB.mjs.map
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
2
|
+
if (!e) return null;
|
|
3
|
+
const t = e.querySelector('[contenteditable="true"]');
|
|
4
|
+
return t instanceof HTMLElement ? t : null;
|
|
5
|
+
}, R = () => {
|
|
6
|
+
if (typeof window == "undefined") return null;
|
|
7
|
+
const e = window[M];
|
|
8
|
+
if (!(e instanceof HTMLElement)) return null;
|
|
9
|
+
window[M] = null;
|
|
10
|
+
const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
|
|
11
|
+
if (t) {
|
|
12
|
+
const n = H(t);
|
|
13
|
+
if (n) return n;
|
|
14
|
+
if (t.getAttribute("contenteditable") === "true") return t;
|
|
15
|
+
}
|
|
16
|
+
if (e.getAttribute("contenteditable") === "true")
|
|
17
|
+
return e;
|
|
18
|
+
const r = e.closest('[contenteditable="true"]');
|
|
19
|
+
return r instanceof HTMLElement ? r : null;
|
|
20
|
+
}, _ = () => {
|
|
21
|
+
const e = R();
|
|
22
|
+
if (e && document.contains(e))
|
|
23
|
+
return e;
|
|
24
|
+
const t = window.getSelection();
|
|
25
|
+
if (t && t.rangeCount > 0) {
|
|
26
|
+
let n = t.getRangeAt(0).startContainer;
|
|
27
|
+
for (; n && n !== document.body; ) {
|
|
28
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
29
|
+
const o = n;
|
|
30
|
+
if (o.getAttribute("contenteditable") === "true")
|
|
31
|
+
return o;
|
|
32
|
+
}
|
|
33
|
+
n = n.parentNode;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const r = document.activeElement;
|
|
37
|
+
if (r) {
|
|
38
|
+
if (r.getAttribute("contenteditable") === "true")
|
|
39
|
+
return r;
|
|
40
|
+
const n = r.closest('[contenteditable="true"]');
|
|
41
|
+
if (n) return n;
|
|
42
|
+
}
|
|
43
|
+
return document.querySelector('[contenteditable="true"]');
|
|
44
|
+
}, A = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, I = (e) => {
|
|
45
|
+
const t = window.getSelection();
|
|
46
|
+
if (!t || t.rangeCount === 0) return null;
|
|
47
|
+
const r = t.getRangeAt(0);
|
|
48
|
+
return e.contains(r.commonAncestorContainer) ? r : null;
|
|
49
|
+
}, T = (e) => {
|
|
50
|
+
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
51
|
+
}, b = (e, t) => {
|
|
52
|
+
if (t === e.innerHTML) return;
|
|
53
|
+
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
54
|
+
if (typeof r == "function")
|
|
55
|
+
try {
|
|
56
|
+
r("recordDomTransaction", e, t, e.innerHTML);
|
|
57
|
+
} catch (n) {
|
|
58
|
+
}
|
|
59
|
+
}, C = (e, t) => {
|
|
60
|
+
if (!e.isConnected) {
|
|
61
|
+
t.focus({ preventScroll: !0 });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const r = window.getSelection();
|
|
65
|
+
if (!r) return;
|
|
66
|
+
const n = document.createRange();
|
|
67
|
+
n.selectNodeContents(e), n.collapse(!1), r.removeAllRanges();
|
|
68
|
+
try {
|
|
69
|
+
r.addRange(n);
|
|
70
|
+
} catch (o) {
|
|
71
|
+
t.focus({ preventScroll: !0 });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
t.focus({ preventScroll: !0 });
|
|
75
|
+
}, N = (e) => {
|
|
76
|
+
let t = e.querySelector(":scope > p");
|
|
77
|
+
if (!t) {
|
|
78
|
+
t = document.createElement("p");
|
|
79
|
+
const r = [];
|
|
80
|
+
e.childNodes.forEach((n) => {
|
|
81
|
+
n.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(n.tagName) || r.push(n);
|
|
82
|
+
}), r.forEach((n) => t.appendChild(n)), e.insertBefore(t, e.firstChild);
|
|
83
|
+
}
|
|
84
|
+
return t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
|
|
85
|
+
}, v = (e) => (e.textContent || "").replace(/\u200B/g, "").trim() ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol"), x = () => {
|
|
86
|
+
const e = document.createElement("p");
|
|
87
|
+
return e.innerHTML = "<br>", e;
|
|
88
|
+
}, S = (e, t) => {
|
|
89
|
+
if (!e.isConnected) {
|
|
90
|
+
t.focus({ preventScroll: !0 });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const r = window.getSelection();
|
|
94
|
+
if (!r) return;
|
|
95
|
+
const n = document.createRange();
|
|
96
|
+
n.selectNodeContents(e), n.collapse(!0), r.removeAllRanges();
|
|
97
|
+
try {
|
|
98
|
+
r.addRange(n);
|
|
99
|
+
} catch (o) {
|
|
100
|
+
t.focus({ preventScroll: !0 });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
t.focus({ preventScroll: !0 });
|
|
104
|
+
}, P = (e, t) => {
|
|
105
|
+
e.appendChild(t), e.innerHTML.trim() || (e.innerHTML = "<br>");
|
|
106
|
+
}, D = (e, t, r) => {
|
|
107
|
+
var o;
|
|
108
|
+
const n = x();
|
|
109
|
+
(o = t.parentNode) == null || o.insertBefore(n, t.nextSibling), r.remove(), y(t).length === 0 && t.remove(), S(n, e);
|
|
110
|
+
}, O = (e, t, r) => {
|
|
111
|
+
var i;
|
|
112
|
+
const n = N(t), o = r.cloneRange();
|
|
113
|
+
o.deleteContents();
|
|
114
|
+
const a = document.createRange();
|
|
115
|
+
a.setStart(o.startContainer, o.startOffset), a.setEndAfter(n.lastChild || n);
|
|
116
|
+
const d = document.createDocumentFragment();
|
|
117
|
+
try {
|
|
118
|
+
d.appendChild(a.extractContents());
|
|
119
|
+
} catch (l) {
|
|
120
|
+
}
|
|
121
|
+
n.innerHTML.trim() || (n.innerHTML = "<br>");
|
|
122
|
+
const c = document.createElement("li");
|
|
123
|
+
c.setAttribute("data-type", "checklist-item"), c.setAttribute("data-checked", "false");
|
|
124
|
+
const h = document.createElement("p");
|
|
125
|
+
P(h, d), c.appendChild(h), (i = t.parentNode) == null || i.insertBefore(c, t.nextSibling), S(h, e);
|
|
126
|
+
}, k = (e) => {
|
|
127
|
+
const t = document.createElement("li");
|
|
128
|
+
t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
|
|
129
|
+
const r = document.createElement("p");
|
|
130
|
+
return r.innerHTML = e.trim() || "<br>", t.appendChild(r), t;
|
|
131
|
+
}, y = (e) => Array.from(e.children).filter(
|
|
132
|
+
(t) => t instanceof HTMLLIElement
|
|
133
|
+
), F = /* @__PURE__ */ new Set([
|
|
134
|
+
"P",
|
|
135
|
+
"DIV",
|
|
136
|
+
"H1",
|
|
137
|
+
"H2",
|
|
138
|
+
"H3",
|
|
139
|
+
"H4",
|
|
140
|
+
"H5",
|
|
141
|
+
"H6",
|
|
142
|
+
"BLOCKQUOTE",
|
|
143
|
+
"PRE",
|
|
144
|
+
"LI"
|
|
145
|
+
]), L = (e) => F.has(e.tagName) && e.getAttribute("contenteditable") !== "true", B = (e, t) => {
|
|
146
|
+
const r = [], n = /* @__PURE__ */ new Set(), o = (i) => {
|
|
147
|
+
!i || n.has(i) || t.contains(i) && L(i) && (i.closest("ul, ol") || (n.add(i), r.push(i)));
|
|
148
|
+
}, a = (i) => {
|
|
149
|
+
let l = i;
|
|
150
|
+
for (; l && l !== document.body; ) {
|
|
151
|
+
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
152
|
+
const p = l;
|
|
153
|
+
if (L(p)) return p;
|
|
154
|
+
if (p.getAttribute("contenteditable") === "true") break;
|
|
155
|
+
}
|
|
156
|
+
l = l.parentNode;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
};
|
|
160
|
+
if (e.collapsed)
|
|
161
|
+
return o(a(e.startContainer)), r;
|
|
162
|
+
const d = document.createTreeWalker(
|
|
163
|
+
t,
|
|
164
|
+
NodeFilter.SHOW_ELEMENT,
|
|
165
|
+
{
|
|
166
|
+
acceptNode: (i) => {
|
|
167
|
+
const l = i;
|
|
168
|
+
if (!L(l) || l.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
|
|
169
|
+
if (typeof e.intersectsNode == "function")
|
|
170
|
+
return e.intersectsNode(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
171
|
+
const p = document.createRange();
|
|
172
|
+
return p.selectNodeContents(l), e.compareBoundaryPoints(Range.END_TO_START, p) > 0 && e.compareBoundaryPoints(Range.START_TO_END, p) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
let c = d.nextNode();
|
|
177
|
+
for (; c; )
|
|
178
|
+
o(c), c = d.nextNode();
|
|
179
|
+
if (r.length === 0 && o(a(e.commonAncestorContainer)), r.length <= 1)
|
|
180
|
+
return r;
|
|
181
|
+
const h = r.filter((i) => !r.some((l) => l !== i && i.contains(l)));
|
|
182
|
+
return h.length > 0 ? h : r;
|
|
183
|
+
}, K = (e) => {
|
|
184
|
+
const t = [], r = document.createElement("div"), n = () => {
|
|
185
|
+
const o = r.innerHTML.trim();
|
|
186
|
+
if (!o) return;
|
|
187
|
+
const a = document.createElement("p");
|
|
188
|
+
a.innerHTML = o, t.push(a), r.innerHTML = "";
|
|
189
|
+
};
|
|
190
|
+
if (e.childNodes.forEach((o) => {
|
|
191
|
+
if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
|
|
192
|
+
n();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
|
|
196
|
+
n();
|
|
197
|
+
const a = o.innerHTML.trim(), d = document.createElement("p");
|
|
198
|
+
d.innerHTML = a || "<br>", t.push(d);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
|
|
202
|
+
}), n(), t.length === 0) {
|
|
203
|
+
const o = document.createElement("p");
|
|
204
|
+
o.innerHTML = "<br>", t.push(o);
|
|
205
|
+
}
|
|
206
|
+
return t;
|
|
207
|
+
}, z = () => ({
|
|
208
|
+
name: "checklist",
|
|
209
|
+
// Initialize click handler when plugin is loaded
|
|
210
|
+
init: () => {
|
|
211
|
+
if (!(typeof document == "undefined" || typeof window == "undefined")) {
|
|
212
|
+
if (!window.__checklistPluginClickInitialized) {
|
|
213
|
+
window.__checklistPluginClickInitialized = !0;
|
|
214
|
+
const e = (t) => {
|
|
215
|
+
const n = t.target.closest('li[data-type="checklist-item"]');
|
|
216
|
+
if (!n) return;
|
|
217
|
+
const o = n.getBoundingClientRect();
|
|
218
|
+
if (!(t.clientX - o.left < 32)) return;
|
|
219
|
+
t.preventDefault(), t.stopPropagation();
|
|
220
|
+
const c = n.closest("[contenteditable], .rte-content, .editora-content");
|
|
221
|
+
if ((c == null ? void 0 : c.getAttribute("contenteditable")) === "false" || !!(c != null && c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))) return;
|
|
222
|
+
const i = (c == null ? void 0 : c.innerHTML) || "", l = n.getAttribute("data-checked") === "true";
|
|
223
|
+
n.setAttribute("data-checked", (!l).toString()), c && (b(c, i), T(c));
|
|
224
|
+
};
|
|
225
|
+
document.addEventListener("click", e);
|
|
226
|
+
}
|
|
227
|
+
if (!window.__checklistPluginKeydownInitialized) {
|
|
228
|
+
window.__checklistPluginKeydownInitialized = !0;
|
|
229
|
+
const e = (t) => {
|
|
230
|
+
if (t.key !== "Enter" || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || t.defaultPrevented) return;
|
|
231
|
+
const r = window.getSelection();
|
|
232
|
+
if (!r || r.rangeCount === 0) return;
|
|
233
|
+
const n = r.getRangeAt(0), o = A(n.startContainer), a = o == null ? void 0 : o.closest('li[data-type="checklist-item"]');
|
|
234
|
+
if (!a) return;
|
|
235
|
+
const d = a.closest('ul[data-type="checklist"]');
|
|
236
|
+
if (!d) return;
|
|
237
|
+
const c = a.closest("[contenteditable], .rte-content, .editora-content");
|
|
238
|
+
if (!c || c.getAttribute("contenteditable") === "false" || !!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
|
|
239
|
+
t.preventDefault();
|
|
240
|
+
const i = c.innerHTML, l = N(a);
|
|
241
|
+
v(l) ? D(c, d, a) : O(c, a, n), b(c, i), T(c);
|
|
242
|
+
};
|
|
243
|
+
document.addEventListener("keydown", e);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
// Schema definition for checklist nodes
|
|
248
|
+
nodes: {
|
|
249
|
+
checklist: {
|
|
250
|
+
content: "checklistItem+",
|
|
251
|
+
group: "block",
|
|
252
|
+
parseDOM: [{ tag: 'ul[data-type="checklist"]' }],
|
|
253
|
+
toDOM: () => ["ul", { "data-type": "checklist" }, 0]
|
|
254
|
+
},
|
|
255
|
+
checklistItem: {
|
|
256
|
+
content: "paragraph",
|
|
257
|
+
attrs: {
|
|
258
|
+
checked: { default: !1 }
|
|
259
|
+
},
|
|
260
|
+
parseDOM: [
|
|
261
|
+
{
|
|
262
|
+
tag: 'li[data-type="checklist-item"]',
|
|
263
|
+
getAttrs: (e) => ({
|
|
264
|
+
checked: e.getAttribute("data-checked") === "true"
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
toDOM: (e) => {
|
|
269
|
+
var t;
|
|
270
|
+
return [
|
|
271
|
+
"li",
|
|
272
|
+
{
|
|
273
|
+
"data-type": "checklist-item",
|
|
274
|
+
"data-checked": (t = e == null ? void 0 : e.attrs) != null && t.checked ? "true" : "false"
|
|
275
|
+
},
|
|
276
|
+
0
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
toolbar: [
|
|
282
|
+
{
|
|
283
|
+
label: "Checklist",
|
|
284
|
+
command: "toggleChecklist",
|
|
285
|
+
icon: '<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',
|
|
286
|
+
shortcut: "Mod-Shift-9"
|
|
287
|
+
}
|
|
288
|
+
],
|
|
289
|
+
commands: {
|
|
290
|
+
toggleChecklist: () => {
|
|
291
|
+
try {
|
|
292
|
+
const e = _();
|
|
293
|
+
if (!e) return !1;
|
|
294
|
+
const t = e.innerHTML, r = () => (b(e, t), T(e), !0), n = I(e);
|
|
295
|
+
if (!n) return !1;
|
|
296
|
+
const o = A(n.startContainer);
|
|
297
|
+
if (!o) return !1;
|
|
298
|
+
const a = o.closest('ul[data-type="checklist"]');
|
|
299
|
+
if (a && e.contains(a)) {
|
|
300
|
+
const s = y(a);
|
|
301
|
+
if (s.length === 0) return !1;
|
|
302
|
+
const f = document.createDocumentFragment();
|
|
303
|
+
let u = null;
|
|
304
|
+
return s.forEach((m, g) => {
|
|
305
|
+
const E = K(m);
|
|
306
|
+
E.forEach((w) => {
|
|
307
|
+
f.appendChild(w), !u && (m.contains(n.startContainer) || g === 0) && (u = w);
|
|
308
|
+
}), !u && g === 0 && E[0] && (u = E[0]);
|
|
309
|
+
}), a.replaceWith(f), u && C(u, e), r();
|
|
310
|
+
}
|
|
311
|
+
const d = o.closest("ul, ol");
|
|
312
|
+
if (d && e.contains(d)) {
|
|
313
|
+
let s;
|
|
314
|
+
if (d.tagName.toLowerCase() === "ul")
|
|
315
|
+
s = d;
|
|
316
|
+
else {
|
|
317
|
+
for (s = document.createElement("ul"); d.firstChild; )
|
|
318
|
+
s.appendChild(d.firstChild);
|
|
319
|
+
d.replaceWith(s);
|
|
320
|
+
}
|
|
321
|
+
s.setAttribute("data-type", "checklist");
|
|
322
|
+
let f = y(s);
|
|
323
|
+
f.length === 0 && (s.appendChild(k("")), f = y(s));
|
|
324
|
+
let u = null;
|
|
325
|
+
f.forEach((g) => {
|
|
326
|
+
g.setAttribute("data-type", "checklist-item"), g.hasAttribute("data-checked") || g.setAttribute("data-checked", "false");
|
|
327
|
+
const E = N(g);
|
|
328
|
+
g.contains(n.startContainer) && (u = E);
|
|
329
|
+
});
|
|
330
|
+
const m = s.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
331
|
+
return C(u || m || s, e), r();
|
|
332
|
+
}
|
|
333
|
+
const c = B(n, e);
|
|
334
|
+
if (c.length > 1) {
|
|
335
|
+
const s = document.createElement("ul");
|
|
336
|
+
s.setAttribute("data-type", "checklist"), c.forEach((m) => {
|
|
337
|
+
s.appendChild(k(m.innerHTML));
|
|
338
|
+
}), c[0].replaceWith(s), c.slice(1).forEach((m) => {
|
|
339
|
+
m.isConnected && m.remove();
|
|
340
|
+
});
|
|
341
|
+
const u = s.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
342
|
+
return u && C(u, e), r();
|
|
343
|
+
}
|
|
344
|
+
const h = c[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
|
|
345
|
+
if (h && h !== e) {
|
|
346
|
+
const s = document.createElement("ul");
|
|
347
|
+
s.setAttribute("data-type", "checklist");
|
|
348
|
+
const f = k(h.innerHTML);
|
|
349
|
+
s.appendChild(f), h.replaceWith(s);
|
|
350
|
+
const u = f.querySelector(":scope > p");
|
|
351
|
+
return u && C(u, e), r();
|
|
352
|
+
}
|
|
353
|
+
const i = document.createElement("ul");
|
|
354
|
+
i.setAttribute("data-type", "checklist");
|
|
355
|
+
const l = k("");
|
|
356
|
+
i.appendChild(l), n.deleteContents(), n.insertNode(i);
|
|
357
|
+
const p = l.querySelector(":scope > p");
|
|
358
|
+
return p && C(p, e), r();
|
|
359
|
+
} catch (e) {
|
|
360
|
+
return console.error("Failed to toggle checklist:", e), !1;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
keymap: {
|
|
365
|
+
"Mod-Shift-9": "toggleChecklist"
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
export {
|
|
369
|
+
z as ChecklistPlugin
|
|
370
|
+
};
|
|
371
|
+
//# sourceMappingURL=ChecklistPlugin.native-BS-kMz9O.mjs.map
|