@editora/core 1.0.15 → 1.0.16

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 (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-B1_vtXRz.mjs +3910 -0
  48. package/dist/index-C6BoNR2t.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2039 -473
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2208 -641
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -54,16 +54,16 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
54
54
  c = r.nextNode();
55
55
  }
56
56
  return n;
57
- }, y = (t) => /\p{L}/u.test(t), _ = (t) => /[\p{M}'’-]/u.test(t), M = () => {
57
+ }, _ = (t) => /\p{L}/u.test(t), y = (t) => /[\p{M}'’-]/u.test(t), M = () => {
58
58
  let t = !1;
59
59
  return (e) => {
60
60
  let n = "";
61
61
  return Array.from(e.text).forEach((r) => {
62
- if (y(r)) {
62
+ if (_(r)) {
63
63
  n += t ? r.toLocaleLowerCase() : r.toLocaleUpperCase(), t = !0;
64
64
  return;
65
65
  }
66
- n += r, _(r) || (t = !1);
66
+ n += r, y(r) || (t = !1);
67
67
  }), n;
68
68
  };
69
69
  }, H = (t) => {
@@ -134,7 +134,12 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
134
134
  { label: "UPPERCASE", value: "uppercase" },
135
135
  { label: "Title Case", value: "titlecase" }
136
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="&lt;Transparent Rectangle&gt;" class="cls-1" width="32" height="32"></rect></g></svg>'
137
+ // Inlined fill="none" on the bounding rect instead of the upstream
138
+ // SVGRepo export's class-based <defs><style>.cls-1{...}</style>
139
+ // block - that style tag applies document-wide once inserted via
140
+ // raw innerHTML into light-DOM toolbar content, so it can collide
141
+ // with any other icon reusing the same auto-generated class name.
142
+ 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"><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="&lt;Transparent Rectangle&gt;" fill="none" width="32" height="32"></rect></g></svg>'
138
143
  }
139
144
  ],
140
145
  commands: {
@@ -156,4 +161,4 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
156
161
  export {
157
162
  b as CapitalizationPlugin
158
163
  };
159
- //# sourceMappingURL=CapitalizationPlugin.native-DLV4oPmB.mjs.map
164
+ //# sourceMappingURL=CapitalizationPlugin.native-C-HRbXGh.mjs.map
@@ -1,15 +1,15 @@
1
- const M = "__editoraCommandEditorRoot", H = (e) => {
1
+ const A = "__editoraCommandEditorRoot", S = (e) => {
2
2
  if (!e) return null;
3
3
  const t = e.querySelector('[contenteditable="true"]');
4
4
  return t instanceof HTMLElement ? t : null;
5
- }, R = () => {
5
+ }, H = () => {
6
6
  if (typeof window == "undefined") return null;
7
- const e = window[M];
7
+ const e = window[A];
8
8
  if (!(e instanceof HTMLElement)) return null;
9
- window[M] = null;
9
+ window[A] = null;
10
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
11
  if (t) {
12
- const n = H(t);
12
+ const n = S(t);
13
13
  if (n) return n;
14
14
  if (t.getAttribute("contenteditable") === "true") return t;
15
15
  }
@@ -18,7 +18,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
18
18
  const r = e.closest('[contenteditable="true"]');
19
19
  return r instanceof HTMLElement ? r : null;
20
20
  }, _ = () => {
21
- const e = R();
21
+ const e = H();
22
22
  if (e && document.contains(e))
23
23
  return e;
24
24
  const t = window.getSelection();
@@ -41,14 +41,14 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
41
41
  if (n) return n;
42
42
  }
43
43
  return document.querySelector('[contenteditable="true"]');
44
- }, A = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, I = (e) => {
44
+ }, M = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, O = (e) => {
45
45
  const t = window.getSelection();
46
46
  if (!t || t.rangeCount === 0) return null;
47
47
  const r = t.getRangeAt(0);
48
48
  return e.contains(r.commonAncestorContainer) ? r : null;
49
- }, T = (e) => {
49
+ }, y = (e) => {
50
50
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
51
- }, b = (e, t) => {
51
+ }, L = (e, t) => {
52
52
  if (t === e.innerHTML) return;
53
53
  const r = window.execEditorCommand || window.executeEditorCommand;
54
54
  if (typeof r == "function")
@@ -72,7 +72,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
72
72
  return;
73
73
  }
74
74
  t.focus({ preventScroll: !0 });
75
- }, N = (e) => {
75
+ }, b = (e) => {
76
76
  let t = e.querySelector(":scope > p");
77
77
  if (!t) {
78
78
  t = document.createElement("p");
@@ -82,10 +82,10 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
82
82
  }), r.forEach((n) => t.appendChild(n)), e.insertBefore(t, e.firstChild);
83
83
  }
84
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 = () => {
85
+ }, I = (e) => (e.textContent || "").replace(/\u200B/g, "").trim() ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol"), v = () => {
86
86
  const e = document.createElement("p");
87
87
  return e.innerHTML = "<br>", e;
88
- }, S = (e, t) => {
88
+ }, R = (e, t) => {
89
89
  if (!e.isConnected) {
90
90
  t.focus({ preventScroll: !0 });
91
91
  return;
@@ -101,36 +101,36 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
101
101
  return;
102
102
  }
103
103
  t.focus({ preventScroll: !0 });
104
- }, P = (e, t) => {
104
+ }, D = (e, t) => {
105
105
  e.appendChild(t), e.innerHTML.trim() || (e.innerHTML = "<br>");
106
- }, D = (e, t, r) => {
106
+ }, x = (e, t, r) => {
107
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) => {
108
+ const n = v();
109
+ (o = t.parentNode) == null || o.insertBefore(n, t.nextSibling), r.remove(), T(t).length === 0 && t.remove(), R(n, e);
110
+ }, P = (e, t, r) => {
111
111
  var i;
112
- const n = N(t), o = r.cloneRange();
112
+ const n = b(t), o = r.cloneRange();
113
113
  o.deleteContents();
114
114
  const a = document.createRange();
115
115
  a.setStart(o.startContainer, o.startOffset), a.setEndAfter(n.lastChild || n);
116
- const d = document.createDocumentFragment();
116
+ const s = document.createDocumentFragment();
117
117
  try {
118
- d.appendChild(a.extractContents());
119
- } catch (l) {
118
+ s.appendChild(a.extractContents());
119
+ } catch (d) {
120
120
  }
121
121
  n.innerHTML.trim() || (n.innerHTML = "<br>");
122
122
  const c = document.createElement("li");
123
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);
124
+ const u = document.createElement("p");
125
+ D(u, s), c.appendChild(u), (i = t.parentNode) == null || i.insertBefore(c, t.nextSibling), R(u, e);
126
126
  }, k = (e) => {
127
127
  const t = document.createElement("li");
128
128
  t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
129
129
  const r = document.createElement("p");
130
130
  return r.innerHTML = e.trim() || "<br>", t.appendChild(r), t;
131
- }, y = (e) => Array.from(e.children).filter(
131
+ }, T = (e) => Array.from(e.children).filter(
132
132
  (t) => t instanceof HTMLLIElement
133
- ), F = /* @__PURE__ */ new Set([
133
+ ), B = /* @__PURE__ */ new Set([
134
134
  "P",
135
135
  "DIV",
136
136
  "H1",
@@ -142,45 +142,82 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
142
142
  "BLOCKQUOTE",
143
143
  "PRE",
144
144
  "LI"
145
- ]), L = (e) => F.has(e.tagName) && e.getAttribute("contenteditable") !== "true", B = (e, t) => {
145
+ ]), N = (e) => B.has(e.tagName) && e.getAttribute("contenteditable") !== "true", F = (e, t) => {
146
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)));
147
+ !i || n.has(i) || t.contains(i) && N(i) && (i.closest("ul, ol") || (n.add(i), r.push(i)));
148
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;
149
+ let d = i;
150
+ for (; d && d !== document.body; ) {
151
+ if (d.nodeType === Node.ELEMENT_NODE) {
152
+ const p = d;
153
+ if (N(p)) return p;
154
154
  if (p.getAttribute("contenteditable") === "true") break;
155
155
  }
156
- l = l.parentNode;
156
+ d = d.parentNode;
157
157
  }
158
158
  return null;
159
159
  };
160
160
  if (e.collapsed)
161
161
  return o(a(e.startContainer)), r;
162
- const d = document.createTreeWalker(
162
+ const s = document.createTreeWalker(
163
163
  t,
164
164
  NodeFilter.SHOW_ELEMENT,
165
165
  {
166
166
  acceptNode: (i) => {
167
- const l = i;
168
- if (!L(l) || l.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
167
+ const d = i;
168
+ if (!N(d) || d.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
169
169
  if (typeof e.intersectsNode == "function")
170
- return e.intersectsNode(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
170
+ return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
171
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;
172
+ return p.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, p) > 0 && e.compareBoundaryPoints(Range.START_TO_END, p) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
173
173
  }
174
174
  }
175
175
  );
176
- let c = d.nextNode();
176
+ let c = s.nextNode();
177
177
  for (; c; )
178
- o(c), c = d.nextNode();
178
+ o(c), c = s.nextNode();
179
179
  if (r.length === 0 && o(a(e.commonAncestorContainer)), r.length <= 1)
180
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) => {
181
+ const u = r.filter((i) => !r.some((d) => d !== i && i.contains(d)));
182
+ return u.length > 0 ? u : r;
183
+ }, K = /* @__PURE__ */ new Set([
184
+ "P",
185
+ "DIV",
186
+ "UL",
187
+ "OL",
188
+ "LI",
189
+ "BLOCKQUOTE",
190
+ "H1",
191
+ "H2",
192
+ "H3",
193
+ "H4",
194
+ "H5",
195
+ "H6",
196
+ "TABLE",
197
+ "PRE",
198
+ "FIGURE",
199
+ "SECTION",
200
+ "ARTICLE",
201
+ "HEADER",
202
+ "FOOTER",
203
+ "HR"
204
+ ]), z = (e, t) => {
205
+ const r = t.startContainer, n = t.startOffset, o = t.endContainer, a = t.endOffset;
206
+ let s = null, c = !1;
207
+ if (Array.from(e.childNodes).forEach((i) => {
208
+ if (i.nodeType === Node.ELEMENT_NODE && K.has(i.tagName)) {
209
+ s = null;
210
+ return;
211
+ }
212
+ i.nodeType === Node.TEXT_NODE && !(i.textContent || "").trim() || i.nodeType !== Node.TEXT_NODE && i.nodeType !== Node.ELEMENT_NODE || (s || (s = document.createElement("p"), e.insertBefore(s, i)), s.appendChild(i), c = !0);
213
+ }), !c) return;
214
+ try {
215
+ r === e ? t.setStart(e, 0) : r.isConnected && t.setStart(r, n), o === e ? t.setEnd(e, e.childNodes.length) : o.isConnected && t.setEnd(o, a);
216
+ } catch (i) {
217
+ }
218
+ const u = window.getSelection();
219
+ u && (u.removeAllRanges(), u.addRange(t));
220
+ }, q = (e) => {
184
221
  const t = [], r = document.createElement("div"), n = () => {
185
222
  const o = r.innerHTML.trim();
186
223
  if (!o) return;
@@ -194,8 +231,8 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
194
231
  }
195
232
  if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
196
233
  n();
197
- const a = o.innerHTML.trim(), d = document.createElement("p");
198
- d.innerHTML = a || "<br>", t.push(d);
234
+ const a = o.innerHTML.trim(), s = document.createElement("p");
235
+ s.innerHTML = a || "<br>", t.push(s);
199
236
  return;
200
237
  }
201
238
  o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
@@ -204,7 +241,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
204
241
  o.innerHTML = "<br>", t.push(o);
205
242
  }
206
243
  return t;
207
- }, z = () => ({
244
+ }, V = () => ({
208
245
  name: "checklist",
209
246
  // Initialize click handler when plugin is loaded
210
247
  init: () => {
@@ -219,8 +256,8 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
219
256
  t.preventDefault(), t.stopPropagation();
220
257
  const c = n.closest("[contenteditable], .rte-content, .editora-content");
221
258
  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));
259
+ const i = (c == null ? void 0 : c.innerHTML) || "", d = n.getAttribute("data-checked") === "true";
260
+ n.setAttribute("data-checked", (!d).toString()), c && (L(c, i), y(c));
224
261
  };
225
262
  document.addEventListener("click", e);
226
263
  }
@@ -230,15 +267,15 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
230
267
  if (t.key !== "Enter" || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || t.defaultPrevented) return;
231
268
  const r = window.getSelection();
232
269
  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"]');
270
+ const n = r.getRangeAt(0), o = M(n.startContainer), a = o == null ? void 0 : o.closest('li[data-type="checklist-item"]');
234
271
  if (!a) return;
235
- const d = a.closest('ul[data-type="checklist"]');
236
- if (!d) return;
272
+ const s = a.closest('ul[data-type="checklist"]');
273
+ if (!s) return;
237
274
  const c = a.closest("[contenteditable], .rte-content, .editora-content");
238
275
  if (!c || c.getAttribute("contenteditable") === "false" || !!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
239
276
  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);
277
+ const i = c.innerHTML, d = b(a);
278
+ I(d) ? x(c, s, a) : P(c, a, n), L(c, i), y(c);
242
279
  };
243
280
  document.addEventListener("keydown", e);
244
281
  }
@@ -291,70 +328,71 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
291
328
  try {
292
329
  const e = _();
293
330
  if (!e) return !1;
294
- const t = e.innerHTML, r = () => (b(e, t), T(e), !0), n = I(e);
331
+ const t = e.innerHTML, r = () => (L(e, t), y(e), !0), n = O(e);
295
332
  if (!n) return !1;
296
- const o = A(n.startContainer);
333
+ z(e, n);
334
+ const o = M(n.startContainer);
297
335
  if (!o) return !1;
298
336
  const a = o.closest('ul[data-type="checklist"]');
299
337
  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();
338
+ const l = T(a);
339
+ if (l.length === 0) return !1;
340
+ const h = document.createDocumentFragment();
341
+ let f = null;
342
+ return l.forEach((m, E) => {
343
+ const g = q(m);
344
+ g.forEach((w) => {
345
+ h.appendChild(w), !f && (m.contains(n.startContainer) || E === 0) && (f = w);
346
+ }), !f && E === 0 && g[0] && (f = g[0]);
347
+ }), a.replaceWith(h), f && C(f, e), r();
310
348
  }
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;
349
+ const s = o.closest("ul, ol");
350
+ if (s && e.contains(s)) {
351
+ let l;
352
+ if (s.tagName.toLowerCase() === "ul")
353
+ l = s;
316
354
  else {
317
- for (s = document.createElement("ul"); d.firstChild; )
318
- s.appendChild(d.firstChild);
319
- d.replaceWith(s);
355
+ for (l = document.createElement("ul"); s.firstChild; )
356
+ l.appendChild(s.firstChild);
357
+ s.replaceWith(l);
320
358
  }
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);
359
+ l.setAttribute("data-type", "checklist");
360
+ let h = T(l);
361
+ h.length === 0 && (l.appendChild(k("")), h = T(l));
362
+ let f = null;
363
+ h.forEach((E) => {
364
+ E.setAttribute("data-type", "checklist-item"), E.hasAttribute("data-checked") || E.setAttribute("data-checked", "false");
365
+ const g = b(E);
366
+ E.contains(n.startContainer) && (f = g);
329
367
  });
330
- const m = s.querySelector(':scope > li[data-type="checklist-item"] > p');
331
- return C(u || m || s, e), r();
368
+ const m = l.querySelector(':scope > li[data-type="checklist-item"] > p');
369
+ return C(f || m || l, e), r();
332
370
  }
333
- const c = B(n, e);
371
+ const c = F(n, e);
334
372
  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) => {
373
+ const l = document.createElement("ul");
374
+ l.setAttribute("data-type", "checklist"), c.forEach((m) => {
375
+ l.appendChild(k(m.innerHTML));
376
+ }), c[0].replaceWith(l), c.slice(1).forEach((m) => {
339
377
  m.isConnected && m.remove();
340
378
  });
341
- const u = s.querySelector(':scope > li[data-type="checklist-item"] > p');
342
- return u && C(u, e), r();
379
+ const f = l.querySelector(':scope > li[data-type="checklist-item"] > p');
380
+ return f && C(f, e), r();
343
381
  }
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();
382
+ const u = c[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
383
+ if (u && u !== e) {
384
+ const l = document.createElement("ul");
385
+ l.setAttribute("data-type", "checklist");
386
+ const h = k(u.innerHTML);
387
+ l.appendChild(h), u.replaceWith(l);
388
+ const f = h.querySelector(":scope > p");
389
+ return f && C(f, e), r();
352
390
  }
353
391
  const i = document.createElement("ul");
354
392
  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");
393
+ const d = k("");
394
+ i.appendChild(d), n.deleteContents(), n.insertNode(i);
395
+ const p = d.querySelector(":scope > p");
358
396
  return p && C(p, e), r();
359
397
  } catch (e) {
360
398
  return console.error("Failed to toggle checklist:", e), !1;
@@ -366,6 +404,6 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
366
404
  }
367
405
  });
368
406
  export {
369
- z as ChecklistPlugin
407
+ V as ChecklistPlugin
370
408
  };
371
- //# sourceMappingURL=ChecklistPlugin.native-BS-kMz9O.mjs.map
409
+ //# sourceMappingURL=ChecklistPlugin.native-NVrBUkaL.mjs.map