@editora/core 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
- package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
- package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
- package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-0Zari_zp.mjs} +329 -310
- package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
- package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
- package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
- package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
- package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
- package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
- package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
- package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
- package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
- package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
- package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
- package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
- package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
- package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
- package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
- package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
- package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
- package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
- package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
- package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
- package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
- package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
- package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
- package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
- package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
- package/dist/core.css +1 -1
- package/dist/editora.min.js +31 -29
- package/dist/editora.umd.js +31 -29
- package/dist/index-CqWQFb3D.js +10 -0
- package/dist/index-OwnkG39N.mjs +2227 -0
- package/dist/index.cjs.js +14 -18
- package/dist/index.esm.js +204 -521
- package/dist/plugin-loader.js +26 -26
- package/dist/webcomponent-core.js +1286 -295
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +100 -75
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +1252 -261
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +3616 -2109
- package/index.d.ts +355 -0
- package/package.json +19 -17
- package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
- package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
- package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
- package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
- package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
- package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
- package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
- package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
- package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
- package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
- package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
- package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
- package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
- package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
- package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
- package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
- package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
- package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
- package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
- package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
- package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
- package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
- package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
- package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
- package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
- package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
- package/dist/documentManager-irzj9n3V.mjs.map +0 -1
- package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
- package/dist/editora.min.js.map +0 -1
- package/dist/editora.umd.js.map +0 -1
- package/dist/index-BF5RBhL9.js +0 -4
- package/dist/index-BF5RBhL9.js.map +0 -1
- package/dist/index-BPsf460l.mjs +0 -1243
- package/dist/index-BPsf460l.mjs.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es-CuicffkQ.mjs.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/plugin-loader.js.map +0 -1
- package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
- package/dist/webcomponent-core.js.map +0 -1
- package/dist/webcomponent-core.min.js.map +0 -1
- package/dist/webcomponent.cjs.js.map +0 -1
- package/dist/webcomponent.esm.js.map +0 -1
- package/dist/webcomponent.js.map +0 -1
- package/dist/webcomponent.min.js.map +0 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
const N = "__editoraCommandEditorRoot", w = (t) => {
|
|
2
|
+
if (!t) return null;
|
|
3
|
+
const e = t.querySelector('[contenteditable="true"]');
|
|
4
|
+
return e instanceof HTMLElement ? e : null;
|
|
5
|
+
}, A = () => {
|
|
6
|
+
if (typeof window == "undefined") return null;
|
|
7
|
+
const t = window[N];
|
|
8
|
+
if (!(t instanceof HTMLElement)) return null;
|
|
9
|
+
window[N] = null;
|
|
10
|
+
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);
|
|
11
|
+
if (e) {
|
|
12
|
+
const n = w(e);
|
|
13
|
+
if (n) return n;
|
|
14
|
+
if (e.getAttribute("contenteditable") === "true") return e;
|
|
15
|
+
}
|
|
16
|
+
if (t.getAttribute("contenteditable") === "true")
|
|
17
|
+
return t;
|
|
18
|
+
const r = t.closest('[contenteditable="true"]');
|
|
19
|
+
return r instanceof HTMLElement ? r : null;
|
|
20
|
+
}, _ = () => {
|
|
21
|
+
const t = A();
|
|
22
|
+
if (t && document.contains(t))
|
|
23
|
+
return t;
|
|
24
|
+
const e = window.getSelection();
|
|
25
|
+
if (e && e.rangeCount > 0) {
|
|
26
|
+
let n = e.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
|
+
}, H = (t) => t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null, S = (t) => {
|
|
45
|
+
const e = window.getSelection();
|
|
46
|
+
if (!e || e.rangeCount === 0) return null;
|
|
47
|
+
const r = e.getRangeAt(0);
|
|
48
|
+
return t.contains(r.commonAncestorContainer) ? r : null;
|
|
49
|
+
}, y = (t) => {
|
|
50
|
+
t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
51
|
+
}, M = (t, e) => {
|
|
52
|
+
if (e === t.innerHTML) return;
|
|
53
|
+
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
54
|
+
if (typeof r == "function")
|
|
55
|
+
try {
|
|
56
|
+
r("recordDomTransaction", t, e, t.innerHTML);
|
|
57
|
+
} catch (n) {
|
|
58
|
+
}
|
|
59
|
+
}, k = (t, e) => {
|
|
60
|
+
if (!t.isConnected) {
|
|
61
|
+
e.focus({ preventScroll: !0 });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const r = window.getSelection();
|
|
65
|
+
if (!r) return;
|
|
66
|
+
const n = document.createRange();
|
|
67
|
+
n.selectNodeContents(t), n.collapse(!1), r.removeAllRanges();
|
|
68
|
+
try {
|
|
69
|
+
r.addRange(n);
|
|
70
|
+
} catch (o) {
|
|
71
|
+
e.focus({ preventScroll: !0 });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
e.focus({ preventScroll: !0 });
|
|
75
|
+
}, I = (t) => {
|
|
76
|
+
let e = t.querySelector(":scope > p");
|
|
77
|
+
if (!e) {
|
|
78
|
+
e = document.createElement("p");
|
|
79
|
+
const r = [];
|
|
80
|
+
t.childNodes.forEach((n) => {
|
|
81
|
+
n.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(n.tagName) || r.push(n);
|
|
82
|
+
}), r.forEach((n) => e.appendChild(n)), t.insertBefore(e, t.firstChild);
|
|
83
|
+
}
|
|
84
|
+
return e.innerHTML.trim() || (e.innerHTML = "<br>"), e;
|
|
85
|
+
}, C = (t) => {
|
|
86
|
+
const e = document.createElement("li");
|
|
87
|
+
e.setAttribute("data-type", "checklist-item"), e.setAttribute("data-checked", "false");
|
|
88
|
+
const r = document.createElement("p");
|
|
89
|
+
return r.innerHTML = t.trim() || "<br>", e.appendChild(r), e;
|
|
90
|
+
}, T = (t) => Array.from(t.children).filter(
|
|
91
|
+
(e) => e instanceof HTMLLIElement
|
|
92
|
+
), R = /* @__PURE__ */ new Set([
|
|
93
|
+
"P",
|
|
94
|
+
"DIV",
|
|
95
|
+
"H1",
|
|
96
|
+
"H2",
|
|
97
|
+
"H3",
|
|
98
|
+
"H4",
|
|
99
|
+
"H5",
|
|
100
|
+
"H6",
|
|
101
|
+
"BLOCKQUOTE",
|
|
102
|
+
"PRE",
|
|
103
|
+
"LI"
|
|
104
|
+
]), b = (t) => R.has(t.tagName) && t.getAttribute("contenteditable") !== "true", v = (t, e) => {
|
|
105
|
+
const r = [], n = /* @__PURE__ */ new Set(), o = (a) => {
|
|
106
|
+
!a || n.has(a) || e.contains(a) && b(a) && (a.closest("ul, ol") || (n.add(a), r.push(a)));
|
|
107
|
+
}, u = (a) => {
|
|
108
|
+
let l = a;
|
|
109
|
+
for (; l && l !== document.body; ) {
|
|
110
|
+
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
111
|
+
const h = l;
|
|
112
|
+
if (b(h)) return h;
|
|
113
|
+
if (h.getAttribute("contenteditable") === "true") break;
|
|
114
|
+
}
|
|
115
|
+
l = l.parentNode;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
};
|
|
119
|
+
if (t.collapsed)
|
|
120
|
+
return o(u(t.startContainer)), r;
|
|
121
|
+
const d = document.createTreeWalker(
|
|
122
|
+
e,
|
|
123
|
+
NodeFilter.SHOW_ELEMENT,
|
|
124
|
+
{
|
|
125
|
+
acceptNode: (a) => {
|
|
126
|
+
const l = a;
|
|
127
|
+
if (!b(l) || l.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
|
|
128
|
+
if (typeof t.intersectsNode == "function")
|
|
129
|
+
return t.intersectsNode(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
130
|
+
const h = document.createRange();
|
|
131
|
+
return h.selectNodeContents(l), t.compareBoundaryPoints(Range.END_TO_START, h) > 0 && t.compareBoundaryPoints(Range.START_TO_END, h) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
let i = d.nextNode();
|
|
136
|
+
for (; i; )
|
|
137
|
+
o(i), i = d.nextNode();
|
|
138
|
+
if (r.length === 0 && o(u(t.commonAncestorContainer)), r.length <= 1)
|
|
139
|
+
return r;
|
|
140
|
+
const m = r.filter((a) => !r.some((l) => l !== a && a.contains(l)));
|
|
141
|
+
return m.length > 0 ? m : r;
|
|
142
|
+
}, O = (t) => {
|
|
143
|
+
const e = [], r = document.createElement("div"), n = () => {
|
|
144
|
+
const o = r.innerHTML.trim();
|
|
145
|
+
if (!o) return;
|
|
146
|
+
const u = document.createElement("p");
|
|
147
|
+
u.innerHTML = o, e.push(u), r.innerHTML = "";
|
|
148
|
+
};
|
|
149
|
+
if (t.childNodes.forEach((o) => {
|
|
150
|
+
if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
|
|
151
|
+
n();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
|
|
155
|
+
n();
|
|
156
|
+
const u = o.innerHTML.trim(), d = document.createElement("p");
|
|
157
|
+
d.innerHTML = u || "<br>", e.push(d);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
|
|
161
|
+
}), n(), e.length === 0) {
|
|
162
|
+
const o = document.createElement("p");
|
|
163
|
+
o.innerHTML = "<br>", e.push(o);
|
|
164
|
+
}
|
|
165
|
+
return e;
|
|
166
|
+
}, D = () => ({
|
|
167
|
+
name: "checklist",
|
|
168
|
+
// Initialize click handler when plugin is loaded
|
|
169
|
+
init: () => {
|
|
170
|
+
if (typeof document == "undefined" || typeof window == "undefined" || window.__checklistPluginClickInitialized) return;
|
|
171
|
+
window.__checklistPluginClickInitialized = !0;
|
|
172
|
+
const t = (e) => {
|
|
173
|
+
const n = e.target.closest('li[data-type="checklist-item"]');
|
|
174
|
+
if (!n) return;
|
|
175
|
+
const o = n.getBoundingClientRect();
|
|
176
|
+
if (!(e.clientX - o.left < 32)) return;
|
|
177
|
+
e.preventDefault(), e.stopPropagation();
|
|
178
|
+
const i = n.closest("[contenteditable], .rte-content, .editora-content");
|
|
179
|
+
if ((i == null ? void 0 : i.getAttribute("contenteditable")) === "false" || !!(i != null && i.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))) return;
|
|
180
|
+
const a = (i == null ? void 0 : i.innerHTML) || "", l = n.getAttribute("data-checked") === "true";
|
|
181
|
+
n.setAttribute("data-checked", (!l).toString()), i && (M(i, a), y(i));
|
|
182
|
+
};
|
|
183
|
+
document.addEventListener("click", t);
|
|
184
|
+
},
|
|
185
|
+
// Schema definition for checklist nodes
|
|
186
|
+
nodes: {
|
|
187
|
+
checklist: {
|
|
188
|
+
content: "checklistItem+",
|
|
189
|
+
group: "block",
|
|
190
|
+
parseDOM: [{ tag: 'ul[data-type="checklist"]' }],
|
|
191
|
+
toDOM: () => ["ul", { "data-type": "checklist" }, 0]
|
|
192
|
+
},
|
|
193
|
+
checklistItem: {
|
|
194
|
+
content: "paragraph",
|
|
195
|
+
attrs: {
|
|
196
|
+
checked: { default: !1 }
|
|
197
|
+
},
|
|
198
|
+
parseDOM: [
|
|
199
|
+
{
|
|
200
|
+
tag: 'li[data-type="checklist-item"]',
|
|
201
|
+
getAttrs: (t) => ({
|
|
202
|
+
checked: t.getAttribute("data-checked") === "true"
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
toDOM: (t) => {
|
|
207
|
+
var e;
|
|
208
|
+
return [
|
|
209
|
+
"li",
|
|
210
|
+
{
|
|
211
|
+
"data-type": "checklist-item",
|
|
212
|
+
"data-checked": (e = t == null ? void 0 : t.attrs) != null && e.checked ? "true" : "false"
|
|
213
|
+
},
|
|
214
|
+
0
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
toolbar: [
|
|
220
|
+
{
|
|
221
|
+
label: "Checklist",
|
|
222
|
+
command: "toggleChecklist",
|
|
223
|
+
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>',
|
|
224
|
+
shortcut: "Mod-Shift-9"
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
commands: {
|
|
228
|
+
toggleChecklist: () => {
|
|
229
|
+
try {
|
|
230
|
+
const t = _();
|
|
231
|
+
if (!t) return !1;
|
|
232
|
+
const e = t.innerHTML, r = () => (M(t, e), y(t), !0), n = S(t);
|
|
233
|
+
if (!n) return !1;
|
|
234
|
+
const o = H(n.startContainer);
|
|
235
|
+
if (!o) return !1;
|
|
236
|
+
const u = o.closest('ul[data-type="checklist"]');
|
|
237
|
+
if (u && t.contains(u)) {
|
|
238
|
+
const c = T(u);
|
|
239
|
+
if (c.length === 0) return !1;
|
|
240
|
+
const p = document.createDocumentFragment();
|
|
241
|
+
let s = null;
|
|
242
|
+
return c.forEach((f, g) => {
|
|
243
|
+
const E = O(f);
|
|
244
|
+
E.forEach((L) => {
|
|
245
|
+
p.appendChild(L), !s && (f.contains(n.startContainer) || g === 0) && (s = L);
|
|
246
|
+
}), !s && g === 0 && E[0] && (s = E[0]);
|
|
247
|
+
}), u.replaceWith(p), s && k(s, t), r();
|
|
248
|
+
}
|
|
249
|
+
const d = o.closest("ul, ol");
|
|
250
|
+
if (d && t.contains(d)) {
|
|
251
|
+
let c;
|
|
252
|
+
if (d.tagName.toLowerCase() === "ul")
|
|
253
|
+
c = d;
|
|
254
|
+
else {
|
|
255
|
+
for (c = document.createElement("ul"); d.firstChild; )
|
|
256
|
+
c.appendChild(d.firstChild);
|
|
257
|
+
d.replaceWith(c);
|
|
258
|
+
}
|
|
259
|
+
c.setAttribute("data-type", "checklist");
|
|
260
|
+
let p = T(c);
|
|
261
|
+
p.length === 0 && (c.appendChild(C("")), p = T(c));
|
|
262
|
+
let s = null;
|
|
263
|
+
p.forEach((g) => {
|
|
264
|
+
g.setAttribute("data-type", "checklist-item"), g.hasAttribute("data-checked") || g.setAttribute("data-checked", "false");
|
|
265
|
+
const E = I(g);
|
|
266
|
+
g.contains(n.startContainer) && (s = E);
|
|
267
|
+
});
|
|
268
|
+
const f = c.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
269
|
+
return k(s || f || c, t), r();
|
|
270
|
+
}
|
|
271
|
+
const i = v(n, t);
|
|
272
|
+
if (i.length > 1) {
|
|
273
|
+
const c = document.createElement("ul");
|
|
274
|
+
c.setAttribute("data-type", "checklist"), i.forEach((f) => {
|
|
275
|
+
c.appendChild(C(f.innerHTML));
|
|
276
|
+
}), i[0].replaceWith(c), i.slice(1).forEach((f) => {
|
|
277
|
+
f.isConnected && f.remove();
|
|
278
|
+
});
|
|
279
|
+
const s = c.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
280
|
+
return s && k(s, t), r();
|
|
281
|
+
}
|
|
282
|
+
const m = i[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
|
|
283
|
+
if (m && m !== t) {
|
|
284
|
+
const c = document.createElement("ul");
|
|
285
|
+
c.setAttribute("data-type", "checklist");
|
|
286
|
+
const p = C(m.innerHTML);
|
|
287
|
+
c.appendChild(p), m.replaceWith(c);
|
|
288
|
+
const s = p.querySelector(":scope > p");
|
|
289
|
+
return s && k(s, t), r();
|
|
290
|
+
}
|
|
291
|
+
const a = document.createElement("ul");
|
|
292
|
+
a.setAttribute("data-type", "checklist");
|
|
293
|
+
const l = C("");
|
|
294
|
+
a.appendChild(l), n.deleteContents(), n.insertNode(a);
|
|
295
|
+
const h = l.querySelector(":scope > p");
|
|
296
|
+
return h && k(h, t), r();
|
|
297
|
+
} catch (t) {
|
|
298
|
+
return console.error("Failed to toggle checklist:", t), !1;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
keymap: {
|
|
303
|
+
"Mod-Shift-9": "toggleChecklist"
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
export {
|
|
307
|
+
D as ChecklistPlugin
|
|
308
|
+
};
|
|
309
|
+
//# sourceMappingURL=ChecklistPlugin.native-nuSSEFNI.mjs.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const p = () => ({
|
|
2
|
+
name: "clearFormatting",
|
|
3
|
+
// Toolbar button configuration
|
|
4
|
+
toolbar: [
|
|
5
|
+
{
|
|
6
|
+
label: "Clear Formatting",
|
|
7
|
+
command: "clearFormatting",
|
|
8
|
+
icon: '<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',
|
|
9
|
+
shortcut: "Mod-\\"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
// Native command implementations
|
|
13
|
+
commands: {
|
|
14
|
+
/**
|
|
15
|
+
* Remove all formatting from current selection
|
|
16
|
+
*/
|
|
17
|
+
clearFormatting: () => {
|
|
18
|
+
const t = f();
|
|
19
|
+
if (!t) return !1;
|
|
20
|
+
const n = window.getSelection();
|
|
21
|
+
if (!n || n.rangeCount === 0) return !1;
|
|
22
|
+
const o = n.getRangeAt(0);
|
|
23
|
+
if (!t.contains(o.commonAncestorContainer)) return !1;
|
|
24
|
+
const e = o.cloneRange();
|
|
25
|
+
return t.focus({ preventScroll: !0 }), document.execCommand("unlink", !1), document.execCommand("removeFormat", !1), h(t, e), m(t, e), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
// Keyboard shortcuts
|
|
29
|
+
keymap: {
|
|
30
|
+
"Mod-\\": "clearFormatting"
|
|
31
|
+
}
|
|
32
|
+
}), l = /* @__PURE__ */ new Set([
|
|
33
|
+
"A",
|
|
34
|
+
"B",
|
|
35
|
+
"STRONG",
|
|
36
|
+
"I",
|
|
37
|
+
"EM",
|
|
38
|
+
"U",
|
|
39
|
+
"S",
|
|
40
|
+
"STRIKE",
|
|
41
|
+
"DEL",
|
|
42
|
+
"FONT",
|
|
43
|
+
"MARK",
|
|
44
|
+
"CODE",
|
|
45
|
+
"SUB",
|
|
46
|
+
"SUP"
|
|
47
|
+
]), u = /* @__PURE__ */ new Set([
|
|
48
|
+
"H1",
|
|
49
|
+
"H2",
|
|
50
|
+
"H3",
|
|
51
|
+
"H4",
|
|
52
|
+
"H5",
|
|
53
|
+
"H6",
|
|
54
|
+
"BLOCKQUOTE",
|
|
55
|
+
"PRE"
|
|
56
|
+
]), d = [
|
|
57
|
+
"color",
|
|
58
|
+
"background-color",
|
|
59
|
+
"font-size",
|
|
60
|
+
"font-family",
|
|
61
|
+
"font-weight",
|
|
62
|
+
"font-style",
|
|
63
|
+
"text-decoration",
|
|
64
|
+
"text-transform",
|
|
65
|
+
"line-height",
|
|
66
|
+
"letter-spacing",
|
|
67
|
+
"word-spacing",
|
|
68
|
+
"vertical-align",
|
|
69
|
+
"text-align",
|
|
70
|
+
"padding-left"
|
|
71
|
+
];
|
|
72
|
+
function f() {
|
|
73
|
+
const t = window.getSelection();
|
|
74
|
+
if (t && t.rangeCount > 0) {
|
|
75
|
+
const o = t.getRangeAt(0).startContainer, e = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement, r = e == null ? void 0 : e.closest('[contenteditable="true"], .rte-content, .editora-content');
|
|
76
|
+
if (r) return r;
|
|
77
|
+
}
|
|
78
|
+
const n = document.activeElement;
|
|
79
|
+
return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
|
|
80
|
+
}
|
|
81
|
+
function s(t, n) {
|
|
82
|
+
try {
|
|
83
|
+
if (typeof t.intersectsNode == "function")
|
|
84
|
+
return t.intersectsNode(n);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
}
|
|
87
|
+
const o = document.createRange();
|
|
88
|
+
return n.nodeType === Node.ELEMENT_NODE ? o.selectNodeContents(n) : o.selectNode(n), t.compareBoundaryPoints(Range.END_TO_START, o) > 0 && t.compareBoundaryPoints(Range.START_TO_END, o) < 0;
|
|
89
|
+
}
|
|
90
|
+
function i(t) {
|
|
91
|
+
let n = 0, o = t;
|
|
92
|
+
for (; o && o.parentNode; )
|
|
93
|
+
n += 1, o = o.parentNode;
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
function g(t) {
|
|
97
|
+
d.forEach((n) => {
|
|
98
|
+
t.style.removeProperty(n);
|
|
99
|
+
}), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class");
|
|
100
|
+
}
|
|
101
|
+
function c(t) {
|
|
102
|
+
const n = t.parentNode;
|
|
103
|
+
if (n) {
|
|
104
|
+
for (; t.firstChild; )
|
|
105
|
+
n.insertBefore(t.firstChild, t);
|
|
106
|
+
n.removeChild(t);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function h(t, n) {
|
|
110
|
+
Array.from(
|
|
111
|
+
t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")
|
|
112
|
+
).forEach((e) => {
|
|
113
|
+
var a;
|
|
114
|
+
if (!s(n, e) || !u.has(e.tagName)) return;
|
|
115
|
+
const r = document.createElement("p");
|
|
116
|
+
for (; e.firstChild; )
|
|
117
|
+
r.appendChild(e.firstChild);
|
|
118
|
+
(a = e.parentNode) == null || a.replaceChild(r, e);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function m(t, n) {
|
|
122
|
+
const o = Array.from(
|
|
123
|
+
t.querySelectorAll(
|
|
124
|
+
"a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
o.sort((e, r) => i(r) - i(e)), o.forEach((e) => {
|
|
128
|
+
if (e.isConnected && s(n, e) && !(e.getAttribute("contenteditable") === "false" || e.closest('[contenteditable="false"]'))) {
|
|
129
|
+
if (g(e), l.has(e.tagName)) {
|
|
130
|
+
c(e);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
e.tagName === "SPAN" && e.attributes.length === 0 && c(e);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
p as ClearFormattingPlugin
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=ClearFormattingPlugin.native-Bq_XcTh2.mjs.map
|