@editora/plugins 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/approval-workflow.cjs.js +14 -14
  3. package/dist/approval-workflow.esm.js +265 -262
  4. package/dist/blockquote.cjs.js +1 -1
  5. package/dist/blockquote.esm.js +177 -15
  6. package/dist/blocks-library.cjs.js +6 -6
  7. package/dist/blocks-library.esm.js +95 -92
  8. package/dist/bold.cjs.js +1 -1
  9. package/dist/bold.esm.js +10 -6
  10. package/dist/capitalization.cjs.js +1 -1
  11. package/dist/capitalization.esm.js +124 -44
  12. package/dist/checklist.cjs.js +1 -1
  13. package/dist/checklist.esm.js +251 -191
  14. package/dist/citations.cjs.js +4 -4
  15. package/dist/citations.esm.js +131 -128
  16. package/dist/clear-formatting.cjs.js +1 -1
  17. package/dist/clear-formatting.esm.js +68 -36
  18. package/dist/code.cjs.js +121 -44
  19. package/dist/code.esm.js +2694 -889
  20. package/dist/content-rules.cjs.js +5 -5
  21. package/dist/content-rules.esm.js +104 -101
  22. package/dist/data-binding.cjs.js +3 -3
  23. package/dist/data-binding.esm.js +51 -48
  24. package/dist/direction.cjs.js +1 -1
  25. package/dist/direction.esm.js +97 -74
  26. package/dist/doc-schema.cjs.js +4 -4
  27. package/dist/doc-schema.esm.js +104 -101
  28. package/dist/embed-iframe.cjs.js +21 -4
  29. package/dist/embed-iframe.esm.js +279 -116
  30. package/dist/heading.cjs.js +1 -1
  31. package/dist/heading.esm.js +239 -56
  32. package/dist/history.cjs.js +1 -1
  33. package/dist/history.esm.js +74 -89
  34. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  35. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  36. package/dist/italic.cjs.js +1 -1
  37. package/dist/italic.esm.js +12 -8
  38. package/dist/math.cjs.js +27 -21
  39. package/dist/math.esm.js +218 -146
  40. package/dist/merge-tag.cjs.js +8 -2
  41. package/dist/merge-tag.esm.js +130 -111
  42. package/dist/pii-redaction.cjs.js +6 -6
  43. package/dist/pii-redaction.esm.js +169 -166
  44. package/dist/smart-paste.cjs.js +5 -5
  45. package/dist/smart-paste.esm.js +120 -117
  46. package/dist/special-characters.cjs.js +6 -10
  47. package/dist/special-characters.esm.js +97 -75
  48. package/dist/strikethrough.cjs.js +1 -1
  49. package/dist/strikethrough.esm.js +11 -25
  50. package/dist/translation-workflow.cjs.js +7 -7
  51. package/dist/translation-workflow.esm.js +103 -100
  52. package/dist/underline.cjs.js +1 -1
  53. package/dist/underline.esm.js +7 -3
  54. package/package.json +3 -3
@@ -1,95 +1,134 @@
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 = () => {
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
6
  if (typeof window > "u") 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 r = w(e);
13
- if (r) return r;
14
- if (e.getAttribute("contenteditable") === "true") return e;
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
15
  }
16
- if (t.getAttribute("contenteditable") === "true")
17
- return t;
18
- const n = t.closest('[contenteditable="true"]');
19
- return n instanceof HTMLElement ? n : null;
16
+ if (e.getAttribute("contenteditable") === "true")
17
+ return e;
18
+ const r = e.closest('[contenteditable="true"]');
19
+ return r instanceof HTMLElement ? r : null;
20
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 r = e.getRangeAt(0).startContainer;
27
- for (; r && r !== document.body; ) {
28
- if (r.nodeType === Node.ELEMENT_NODE) {
29
- const o = r;
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
30
  if (o.getAttribute("contenteditable") === "true")
31
31
  return o;
32
32
  }
33
- r = r.parentNode;
33
+ n = n.parentNode;
34
34
  }
35
35
  }
36
- const n = document.activeElement;
37
- if (n) {
38
- if (n.getAttribute("contenteditable") === "true")
39
- return n;
40
- const r = n.closest('[contenteditable="true"]');
41
- if (r) return r;
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
42
  }
43
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 n = e.getRangeAt(0);
48
- return t.contains(n.commonAncestorContainer) ? n : null;
49
- }, y = (t) => {
50
- t.dispatchEvent(new Event("input", { bubbles: !0 }));
51
- }, M = (t, e) => {
52
- if (e === t.innerHTML) return;
53
- const n = window.execEditorCommand || window.executeEditorCommand;
54
- if (typeof n == "function")
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
55
  try {
56
- n("recordDomTransaction", t, e, t.innerHTML);
56
+ r("recordDomTransaction", e, t, e.innerHTML);
57
57
  } catch {
58
58
  }
59
- }, k = (t, e) => {
60
- if (!t.isConnected) {
61
- e.focus({ preventScroll: !0 });
59
+ }, C = (e, t) => {
60
+ if (!e.isConnected) {
61
+ t.focus({ preventScroll: !0 });
62
62
  return;
63
63
  }
64
- const n = window.getSelection();
65
- if (!n) return;
66
- const r = document.createRange();
67
- r.selectNodeContents(t), r.collapse(!1), n.removeAllRanges();
64
+ const r = window.getSelection();
65
+ if (!r) return;
66
+ const n = document.createRange();
67
+ n.selectNodeContents(e), n.collapse(!1), r.removeAllRanges();
68
68
  try {
69
- n.addRange(r);
69
+ r.addRange(n);
70
70
  } catch {
71
- e.focus({ preventScroll: !0 });
71
+ t.focus({ preventScroll: !0 });
72
72
  return;
73
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 n = [];
80
- t.childNodes.forEach((r) => {
81
- r.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(r.tagName) || n.push(r);
82
- }), n.forEach((r) => e.appendChild(r)), t.insertBefore(e, t.firstChild);
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
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 n = document.createElement("p");
89
- return n.innerHTML = t.trim() || "<br>", e.appendChild(n), e;
90
- }, T = (t) => Array.from(t.children).filter(
91
- (e) => e instanceof HTMLLIElement
92
- ), R = /* @__PURE__ */ new Set([
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 {
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
+ const n = x();
108
+ t.parentNode?.insertBefore(n, t.nextSibling), r.remove(), y(t).length === 0 && t.remove(), S(n, e);
109
+ }, O = (e, t, r) => {
110
+ const n = N(t), o = r.cloneRange();
111
+ o.deleteContents();
112
+ const i = document.createRange();
113
+ i.setStart(o.startContainer, o.startOffset), i.setEndAfter(n.lastChild || n);
114
+ const d = document.createDocumentFragment();
115
+ try {
116
+ d.appendChild(i.extractContents());
117
+ } catch {
118
+ }
119
+ n.innerHTML.trim() || (n.innerHTML = "<br>");
120
+ const c = document.createElement("li");
121
+ c.setAttribute("data-type", "checklist-item"), c.setAttribute("data-checked", "false");
122
+ const h = document.createElement("p");
123
+ P(h, d), c.appendChild(h), t.parentNode?.insertBefore(c, t.nextSibling), S(h, e);
124
+ }, k = (e) => {
125
+ const t = document.createElement("li");
126
+ t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
127
+ const r = document.createElement("p");
128
+ return r.innerHTML = e.trim() || "<br>", t.appendChild(r), t;
129
+ }, y = (e) => Array.from(e.children).filter(
130
+ (t) => t instanceof HTMLLIElement
131
+ ), F = /* @__PURE__ */ new Set([
93
132
  "P",
94
133
  "DIV",
95
134
  "H1",
@@ -101,86 +140,107 @@ const N = "__editoraCommandEditorRoot", w = (t) => {
101
140
  "BLOCKQUOTE",
102
141
  "PRE",
103
142
  "LI"
104
- ]), b = (t) => R.has(t.tagName) && t.getAttribute("contenteditable") !== "true", v = (t, e) => {
105
- const n = [], r = /* @__PURE__ */ new Set(), o = (i) => {
106
- !i || r.has(i) || e.contains(i) && b(i) && (i.closest("ul, ol") || (r.add(i), n.push(i)));
107
- }, u = (i) => {
108
- let a = i;
109
- for (; a && a !== document.body; ) {
110
- if (a.nodeType === Node.ELEMENT_NODE) {
111
- const h = a;
112
- if (b(h)) return h;
113
- if (h.getAttribute("contenteditable") === "true") break;
143
+ ]), L = (e) => F.has(e.tagName) && e.getAttribute("contenteditable") !== "true", B = (e, t) => {
144
+ const r = [], n = /* @__PURE__ */ new Set(), o = (s) => {
145
+ !s || n.has(s) || t.contains(s) && L(s) && (s.closest("ul, ol") || (n.add(s), r.push(s)));
146
+ }, i = (s) => {
147
+ let l = s;
148
+ for (; l && l !== document.body; ) {
149
+ if (l.nodeType === Node.ELEMENT_NODE) {
150
+ const p = l;
151
+ if (L(p)) return p;
152
+ if (p.getAttribute("contenteditable") === "true") break;
114
153
  }
115
- a = a.parentNode;
154
+ l = l.parentNode;
116
155
  }
117
156
  return null;
118
157
  };
119
- if (t.collapsed)
120
- return o(u(t.startContainer)), n;
158
+ if (e.collapsed)
159
+ return o(i(e.startContainer)), r;
121
160
  const d = document.createTreeWalker(
122
- e,
161
+ t,
123
162
  NodeFilter.SHOW_ELEMENT,
124
163
  {
125
- acceptNode: (i) => {
126
- const a = i;
127
- if (!b(a) || a.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
128
- if (typeof t.intersectsNode == "function")
129
- return t.intersectsNode(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
130
- const h = document.createRange();
131
- return h.selectNodeContents(a), t.compareBoundaryPoints(Range.END_TO_START, h) > 0 && t.compareBoundaryPoints(Range.START_TO_END, h) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
164
+ acceptNode: (s) => {
165
+ const l = s;
166
+ if (!L(l) || l.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
167
+ if (typeof e.intersectsNode == "function")
168
+ return e.intersectsNode(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
169
+ const p = document.createRange();
170
+ 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;
132
171
  }
133
172
  }
134
173
  );
135
- let l = d.nextNode();
136
- for (; l; )
137
- o(l), l = d.nextNode();
138
- if (n.length === 0 && o(u(t.commonAncestorContainer)), n.length <= 1)
139
- return n;
140
- const m = n.filter((i) => !n.some((a) => a !== i && i.contains(a)));
141
- return m.length > 0 ? m : n;
142
- }, O = (t) => {
143
- const e = [], n = document.createElement("div"), r = () => {
144
- const o = n.innerHTML.trim();
174
+ let c = d.nextNode();
175
+ for (; c; )
176
+ o(c), c = d.nextNode();
177
+ if (r.length === 0 && o(i(e.commonAncestorContainer)), r.length <= 1)
178
+ return r;
179
+ const h = r.filter((s) => !r.some((l) => l !== s && s.contains(l)));
180
+ return h.length > 0 ? h : r;
181
+ }, K = (e) => {
182
+ const t = [], r = document.createElement("div"), n = () => {
183
+ const o = r.innerHTML.trim();
145
184
  if (!o) return;
146
- const u = document.createElement("p");
147
- u.innerHTML = o, e.push(u), n.innerHTML = "";
185
+ const i = document.createElement("p");
186
+ i.innerHTML = o, t.push(i), r.innerHTML = "";
148
187
  };
149
- if (t.childNodes.forEach((o) => {
188
+ if (e.childNodes.forEach((o) => {
150
189
  if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
151
- r();
190
+ n();
152
191
  return;
153
192
  }
154
193
  if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
155
- r();
156
- const u = o.innerHTML.trim(), d = document.createElement("p");
157
- d.innerHTML = u || "<br>", e.push(d);
194
+ n();
195
+ const i = o.innerHTML.trim(), d = document.createElement("p");
196
+ d.innerHTML = i || "<br>", t.push(d);
158
197
  return;
159
198
  }
160
- o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || n.appendChild(o.cloneNode(!0));
161
- }), r(), e.length === 0) {
199
+ o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
200
+ }), n(), t.length === 0) {
162
201
  const o = document.createElement("p");
163
- o.innerHTML = "<br>", e.push(o);
202
+ o.innerHTML = "<br>", t.push(o);
164
203
  }
165
- return e;
166
- }, D = () => ({
204
+ return t;
205
+ }, z = () => ({
167
206
  name: "checklist",
168
207
  // Initialize click handler when plugin is loaded
169
208
  init: () => {
170
- if (typeof document > "u" || typeof window > "u" || window.__checklistPluginClickInitialized) return;
171
- window.__checklistPluginClickInitialized = !0;
172
- const t = (e) => {
173
- const r = e.target.closest('li[data-type="checklist-item"]');
174
- if (!r) return;
175
- const o = r.getBoundingClientRect();
176
- if (!(e.clientX - o.left < 32)) return;
177
- e.preventDefault(), e.stopPropagation();
178
- const l = r.closest("[contenteditable], .rte-content, .editora-content");
179
- if (l?.getAttribute("contenteditable") === "false" || !!l?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
180
- const i = l?.innerHTML || "", a = r.getAttribute("data-checked") === "true";
181
- r.setAttribute("data-checked", (!a).toString()), l && (M(l, i), y(l));
182
- };
183
- document.addEventListener("click", t);
209
+ if (!(typeof document > "u" || typeof window > "u")) {
210
+ if (!window.__checklistPluginClickInitialized) {
211
+ window.__checklistPluginClickInitialized = !0;
212
+ const e = (t) => {
213
+ const n = t.target.closest('li[data-type="checklist-item"]');
214
+ if (!n) return;
215
+ const o = n.getBoundingClientRect();
216
+ if (!(t.clientX - o.left < 32)) return;
217
+ t.preventDefault(), t.stopPropagation();
218
+ const c = n.closest("[contenteditable], .rte-content, .editora-content");
219
+ if (c?.getAttribute("contenteditable") === "false" || !!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
220
+ const s = c?.innerHTML || "", l = n.getAttribute("data-checked") === "true";
221
+ n.setAttribute("data-checked", (!l).toString()), c && (b(c, s), T(c));
222
+ };
223
+ document.addEventListener("click", e);
224
+ }
225
+ if (!window.__checklistPluginKeydownInitialized) {
226
+ window.__checklistPluginKeydownInitialized = !0;
227
+ const e = (t) => {
228
+ if (t.key !== "Enter" || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || t.defaultPrevented) return;
229
+ const r = window.getSelection();
230
+ if (!r || r.rangeCount === 0) return;
231
+ const n = r.getRangeAt(0), i = A(n.startContainer)?.closest('li[data-type="checklist-item"]');
232
+ if (!i) return;
233
+ const d = i.closest('ul[data-type="checklist"]');
234
+ if (!d) return;
235
+ const c = i.closest("[contenteditable], .rte-content, .editora-content");
236
+ if (!c || c.getAttribute("contenteditable") === "false" || !!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
237
+ t.preventDefault();
238
+ const s = c.innerHTML, l = N(i);
239
+ v(l) ? D(c, d, i) : O(c, i, n), b(c, s), T(c);
240
+ };
241
+ document.addEventListener("keydown", e);
242
+ }
243
+ }
184
244
  },
185
245
  // Schema definition for checklist nodes
186
246
  nodes: {
@@ -198,16 +258,16 @@ const N = "__editoraCommandEditorRoot", w = (t) => {
198
258
  parseDOM: [
199
259
  {
200
260
  tag: 'li[data-type="checklist-item"]',
201
- getAttrs: (t) => ({
202
- checked: t.getAttribute("data-checked") === "true"
261
+ getAttrs: (e) => ({
262
+ checked: e.getAttribute("data-checked") === "true"
203
263
  })
204
264
  }
205
265
  ],
206
- toDOM: (t) => [
266
+ toDOM: (e) => [
207
267
  "li",
208
268
  {
209
269
  "data-type": "checklist-item",
210
- "data-checked": t?.attrs?.checked ? "true" : "false"
270
+ "data-checked": e?.attrs?.checked ? "true" : "false"
211
271
  },
212
272
  0
213
273
  ]
@@ -224,75 +284,75 @@ const N = "__editoraCommandEditorRoot", w = (t) => {
224
284
  commands: {
225
285
  toggleChecklist: () => {
226
286
  try {
227
- const t = _();
228
- if (!t) return !1;
229
- const e = t.innerHTML, n = () => (M(t, e), y(t), !0), r = S(t);
230
- if (!r) return !1;
231
- const o = H(r.startContainer);
287
+ const e = _();
288
+ if (!e) return !1;
289
+ const t = e.innerHTML, r = () => (b(e, t), T(e), !0), n = I(e);
290
+ if (!n) return !1;
291
+ const o = A(n.startContainer);
232
292
  if (!o) return !1;
233
- const u = o.closest('ul[data-type="checklist"]');
234
- if (u && t.contains(u)) {
235
- const c = T(u);
236
- if (c.length === 0) return !1;
237
- const p = document.createDocumentFragment();
238
- let s = null;
239
- return c.forEach((f, g) => {
240
- const E = O(f);
241
- E.forEach((L) => {
242
- p.appendChild(L), !s && (f.contains(r.startContainer) || g === 0) && (s = L);
243
- }), !s && g === 0 && E[0] && (s = E[0]);
244
- }), u.replaceWith(p), s && k(s, t), n();
293
+ const i = o.closest('ul[data-type="checklist"]');
294
+ if (i && e.contains(i)) {
295
+ const a = y(i);
296
+ if (a.length === 0) return !1;
297
+ const f = document.createDocumentFragment();
298
+ let u = null;
299
+ return a.forEach((m, g) => {
300
+ const E = K(m);
301
+ E.forEach((w) => {
302
+ f.appendChild(w), !u && (m.contains(n.startContainer) || g === 0) && (u = w);
303
+ }), !u && g === 0 && E[0] && (u = E[0]);
304
+ }), i.replaceWith(f), u && C(u, e), r();
245
305
  }
246
306
  const d = o.closest("ul, ol");
247
- if (d && t.contains(d)) {
248
- let c;
307
+ if (d && e.contains(d)) {
308
+ let a;
249
309
  if (d.tagName.toLowerCase() === "ul")
250
- c = d;
310
+ a = d;
251
311
  else {
252
- for (c = document.createElement("ul"); d.firstChild; )
253
- c.appendChild(d.firstChild);
254
- d.replaceWith(c);
312
+ for (a = document.createElement("ul"); d.firstChild; )
313
+ a.appendChild(d.firstChild);
314
+ d.replaceWith(a);
255
315
  }
256
- c.setAttribute("data-type", "checklist");
257
- let p = T(c);
258
- p.length === 0 && (c.appendChild(C("")), p = T(c));
259
- let s = null;
260
- p.forEach((g) => {
316
+ a.setAttribute("data-type", "checklist");
317
+ let f = y(a);
318
+ f.length === 0 && (a.appendChild(k("")), f = y(a));
319
+ let u = null;
320
+ f.forEach((g) => {
261
321
  g.setAttribute("data-type", "checklist-item"), g.hasAttribute("data-checked") || g.setAttribute("data-checked", "false");
262
- const E = I(g);
263
- g.contains(r.startContainer) && (s = E);
322
+ const E = N(g);
323
+ g.contains(n.startContainer) && (u = E);
264
324
  });
265
- const f = c.querySelector(':scope > li[data-type="checklist-item"] > p');
266
- return k(s || f || c, t), n();
325
+ const m = a.querySelector(':scope > li[data-type="checklist-item"] > p');
326
+ return C(u || m || a, e), r();
267
327
  }
268
- const l = v(r, t);
269
- if (l.length > 1) {
270
- const c = document.createElement("ul");
271
- c.setAttribute("data-type", "checklist"), l.forEach((f) => {
272
- c.appendChild(C(f.innerHTML));
273
- }), l[0].replaceWith(c), l.slice(1).forEach((f) => {
274
- f.isConnected && f.remove();
328
+ const c = B(n, e);
329
+ if (c.length > 1) {
330
+ const a = document.createElement("ul");
331
+ a.setAttribute("data-type", "checklist"), c.forEach((m) => {
332
+ a.appendChild(k(m.innerHTML));
333
+ }), c[0].replaceWith(a), c.slice(1).forEach((m) => {
334
+ m.isConnected && m.remove();
275
335
  });
276
- const s = c.querySelector(':scope > li[data-type="checklist-item"] > p');
277
- return s && k(s, t), n();
336
+ const u = a.querySelector(':scope > li[data-type="checklist-item"] > p');
337
+ return u && C(u, e), r();
278
338
  }
279
- const m = l[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
280
- if (m && m !== t) {
281
- const c = document.createElement("ul");
282
- c.setAttribute("data-type", "checklist");
283
- const p = C(m.innerHTML);
284
- c.appendChild(p), m.replaceWith(c);
285
- const s = p.querySelector(":scope > p");
286
- return s && k(s, t), n();
339
+ const h = c[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
340
+ if (h && h !== e) {
341
+ const a = document.createElement("ul");
342
+ a.setAttribute("data-type", "checklist");
343
+ const f = k(h.innerHTML);
344
+ a.appendChild(f), h.replaceWith(a);
345
+ const u = f.querySelector(":scope > p");
346
+ return u && C(u, e), r();
287
347
  }
288
- const i = document.createElement("ul");
289
- i.setAttribute("data-type", "checklist");
290
- const a = C("");
291
- i.appendChild(a), r.deleteContents(), r.insertNode(i);
292
- const h = a.querySelector(":scope > p");
293
- return h && k(h, t), n();
294
- } catch (t) {
295
- return console.error("Failed to toggle checklist:", t), !1;
348
+ const s = document.createElement("ul");
349
+ s.setAttribute("data-type", "checklist");
350
+ const l = k("");
351
+ s.appendChild(l), n.deleteContents(), n.insertNode(s);
352
+ const p = l.querySelector(":scope > p");
353
+ return p && C(p, e), r();
354
+ } catch (e) {
355
+ return console.error("Failed to toggle checklist:", e), !1;
296
356
  }
297
357
  }
298
358
  },
@@ -301,5 +361,5 @@ const N = "__editoraCommandEditorRoot", w = (t) => {
301
361
  }
302
362
  });
303
363
  export {
304
- D as ChecklistPlugin
364
+ z as ChecklistPlugin
305
365
  };