@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
@@ -0,0 +1,352 @@
1
+ import { i as M } from "./dialogHelpers-DBf7WqYH.mjs";
2
+ import { r as k } from "./historyHelpers-B0-4mq1E.mjs";
3
+ let a = null, m = "", g = !1, l = null;
4
+ const y = '[data-theme="dark"], .dark, .editora-theme-dark', O = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:", "sms:", "ftp:"]), C = "Enter a valid URL, e.g. https://example.com, /page, #section or mailto:name@example.com", R = (e) => {
5
+ const t = e.trim();
6
+ if (!t) return { error: "Please enter a URL." };
7
+ if (/\s/.test(t)) return { error: "The URL cannot contain spaces." };
8
+ if (/^(#|\/(?!\/)|\?|\.{1,2}\/)/.test(t)) return { url: t };
9
+ if (/^localhost(:\d+)?([/?#]|$)/i.test(t) || /^[^\s/:@]+:\d+([/?#]|$)/.test(t))
10
+ return { url: `https://${t}` };
11
+ const o = t.match(/^([a-z][a-z0-9+.-]*):/i);
12
+ if (o) {
13
+ const r = `${o[1].toLowerCase()}:`;
14
+ if (!O.has(r))
15
+ return { error: "Links must use http, https, mailto or tel." };
16
+ if (r === "http:" || r === "https:" || r === "ftp:")
17
+ try {
18
+ if (!new URL(t).hostname) return { error: C };
19
+ } catch (d) {
20
+ return { error: C };
21
+ }
22
+ return { url: t };
23
+ }
24
+ return t.startsWith("//") ? { url: `https:${t}` } : /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(t) ? { url: `mailto:${t}` } : /^[^\s/]+\.[^\s/]+/.test(t) ? { url: `https://${t}` } : { error: C };
25
+ }, q = "p, div, ul, ol, li, table, blockquote, pre, h1, h2, h3, h4, h5, h6", H = (e, t) => e.replace(/[\r\n]+/g, "") === t.replace(/[\r\n]+/g, ""), x = (e) => {
26
+ e == null || e.dispatchEvent(new Event("input", { bubbles: !0 }));
27
+ }, v = (e) => {
28
+ if (!e) return null;
29
+ let t = e;
30
+ for (; t; ) {
31
+ if (t.hasAttribute("contenteditable") && t.getAttribute("contenteditable") === "true" || t.hasAttribute("data-editora-content"))
32
+ return t;
33
+ t = t.parentElement;
34
+ }
35
+ return null;
36
+ }, I = (e) => {
37
+ if (e) {
38
+ const o = e.startContainer, r = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement;
39
+ if (r != null && r.closest(y)) return !0;
40
+ }
41
+ const t = document.activeElement;
42
+ return t != null && t.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
43
+ }, $ = () => {
44
+ if (document.getElementById("rte-link-dialog-theme-styles")) return;
45
+ const e = document.createElement("style");
46
+ e.id = "rte-link-dialog-theme-styles", e.textContent = `
47
+ .link-dialog-overlay.rte-theme-dark .link-dialog {
48
+ background: #1f2937 !important;
49
+ border: 1px solid #4b5563 !important;
50
+ color: #e2e8f0 !important;
51
+ box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6) !important;
52
+ }
53
+
54
+ .link-dialog-overlay.rte-theme-dark .link-dialog-header {
55
+ border-bottom-color: #3b4657 !important;
56
+ background: #222d3a !important;
57
+ }
58
+
59
+ .link-dialog-overlay.rte-theme-dark .link-dialog-header h3,
60
+ .link-dialog-overlay.rte-theme-dark label {
61
+ color: #e2e8f0 !important;
62
+ }
63
+
64
+ .link-dialog-overlay.rte-theme-dark .link-dialog-close {
65
+ color: #94a3b8 !important;
66
+ }
67
+
68
+ .link-dialog-overlay.rte-theme-dark .link-dialog-close:hover {
69
+ background: #334155 !important;
70
+ color: #f8fafc !important;
71
+ border-radius: 4px;
72
+ }
73
+
74
+ .link-dialog-overlay.rte-theme-dark .link-dialog-footer {
75
+ border-top-color: #3b4657 !important;
76
+ background: #222d3a !important;
77
+ }
78
+
79
+ .link-dialog-overlay.rte-theme-dark input[type='text'],
80
+ .link-dialog-overlay.rte-theme-dark input[type='url'] {
81
+ background: #111827 !important;
82
+ border-color: #4b5563 !important;
83
+ color: #e2e8f0 !important;
84
+ }
85
+
86
+ .link-dialog-overlay.rte-theme-dark input[type='text']::placeholder,
87
+ .link-dialog-overlay.rte-theme-dark input[type='url']::placeholder {
88
+ color: #94a3b8 !important;
89
+ }
90
+
91
+ .link-dialog-overlay.rte-theme-dark .btn-cancel {
92
+ background: #334155 !important;
93
+ border-color: #4b5563 !important;
94
+ color: #e2e8f0 !important;
95
+ }
96
+
97
+ .link-dialog-overlay.rte-theme-dark .btn-cancel:hover {
98
+ background: #475569 !important;
99
+ border-color: #64748b !important;
100
+ }
101
+
102
+ .link-dialog-overlay.rte-theme-dark .btn-submit {
103
+ background: #3b82f6 !important;
104
+ }
105
+
106
+ .link-dialog-overlay.rte-theme-dark .btn-submit:hover {
107
+ background: #2563eb !important;
108
+ }
109
+ `, document.head.appendChild(e);
110
+ }, U = (e) => {
111
+ if (!a) {
112
+ console.warn("No selection range stored");
113
+ return;
114
+ }
115
+ const t = a.startContainer, o = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, r = v(o);
116
+ if (!r) return;
117
+ const d = r.innerHTML;
118
+ if (g && l) {
119
+ l.setAttribute("href", e.url), l.textContent !== e.text && (l.textContent = e.text), l.target = e.target, e.target === "_blank" ? l.setAttribute("rel", "noopener noreferrer") : l.removeAttribute("rel"), e.title ? l.title = e.title : l.removeAttribute("title");
120
+ const n = document.createRange();
121
+ n.selectNodeContents(l);
122
+ const i = window.getSelection();
123
+ i && (i.removeAllRanges(), i.addRange(n));
124
+ } else {
125
+ const n = document.createElement("a");
126
+ n.setAttribute("href", e.url), n.textContent = e.text, n.target = e.target, e.target === "_blank" && n.setAttribute("rel", "noopener noreferrer"), e.title && (n.title = e.title);
127
+ const i = !a.collapsed && !!a.cloneContents().querySelector(q);
128
+ if (i && H(e.text, m)) {
129
+ const E = new Set(Array.from(r.querySelectorAll("a"))), f = window.getSelection();
130
+ f && (f.removeAllRanges(), f.addRange(a)), r.focus(), document.execCommand("createLink", !1, e.url), r.querySelectorAll("a").forEach((c) => {
131
+ E.has(c) || (c.setAttribute("target", e.target), e.target === "_blank" && c.setAttribute("rel", "noopener noreferrer"), e.title && c.setAttribute("title", e.title));
132
+ }), k(r, d), x(r), a = null, m = "", g = !1, l = null;
133
+ return;
134
+ }
135
+ !a.collapsed && e.text === m && !i ? (n.textContent = "", n.appendChild(a.extractContents())) : a.deleteContents(), a.insertNode(n), a.setStartAfter(n), a.setEndAfter(n);
136
+ const b = window.getSelection();
137
+ b && (b.removeAllRanges(), b.addRange(a));
138
+ }
139
+ r.focus(), k(r, d), x(r), a = null, m = "", g = !1, l = null;
140
+ }, S = (e, t) => {
141
+ document.querySelectorAll(".link-dialog-overlay").forEach((s) => s.remove()), $();
142
+ const o = document.createElement("div");
143
+ M(o), o.className = "link-dialog-overlay", t && o.classList.add("rte-theme-dark"), o.style.cssText = `
144
+ position: fixed;
145
+ top: 0;
146
+ left: 0;
147
+ right: 0;
148
+ bottom: 0;
149
+ background: rgba(0, 0, 0, 0.5);
150
+ display: flex;
151
+ align-items: center;
152
+ justify-content: center;
153
+ z-index: 10000;
154
+ `;
155
+ const r = document.createElement("div");
156
+ r.className = "link-dialog", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-labelledby", "link-dialog-title"), r.style.cssText = `
157
+ background: white;
158
+ color: #1f2937;
159
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
160
+ border-radius: 8px;
161
+ width: 500px;
162
+ max-width: 90%;
163
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
164
+ `, r.innerHTML = `
165
+ <div class="link-dialog-header" style="padding: 16px 20px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center;">
166
+ <h3 id="link-dialog-title" style="margin: 0; font-size: 18px;">${e.isEditing ? "Edit Link" : "Insert Link"}</h3>
167
+ <button type="button" class="link-dialog-close" aria-label="Close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
168
+ </div>
169
+ <form id="link-form" novalidate>
170
+ <div class="link-dialog-body" style="padding: 20px;">
171
+ <div class="form-group" style="margin-bottom: 16px;">
172
+ <label for="link-text" style="display: block; margin-bottom: 6px; font-weight: 500;">Link Text:</label>
173
+ <input
174
+ id="link-text"
175
+ type="text"
176
+ placeholder="Enter link text"
177
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
178
+ />
179
+ </div>
180
+ <div class="form-group" style="margin-bottom: 16px;">
181
+ <label for="link-url" style="display: block; margin-bottom: 6px; font-weight: 500;">URL:</label>
182
+ <input
183
+ id="link-url"
184
+ type="text"
185
+ inputmode="url"
186
+ autocapitalize="off"
187
+ spellcheck="false"
188
+ placeholder="https://example.com"
189
+ aria-describedby="link-url-error"
190
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
191
+ />
192
+ <div id="link-url-error" role="alert" hidden style="margin-top: 4px; font-size: 12px; color: #c62828;"></div>
193
+ </div>
194
+ <div class="form-group" style="margin-bottom: 16px;">
195
+ <label for="link-title" style="display: block; margin-bottom: 6px; font-weight: 500;">Title (optional):</label>
196
+ <input
197
+ id="link-title"
198
+ type="text"
199
+ placeholder="Link tooltip text"
200
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
201
+ />
202
+ </div>
203
+ <div class="form-group" style="margin-bottom: 0;">
204
+ <label style="display: flex; align-items: center; cursor: pointer;">
205
+ <input
206
+ id="link-target"
207
+ type="checkbox"
208
+ ${e.target === "_blank" ? "checked" : ""}
209
+ style="margin-right: 8px;"
210
+ />
211
+ Open in new window/tab
212
+ </label>
213
+ </div>
214
+ </div>
215
+ <div class="link-dialog-footer" style="padding: 12px 20px; border-top: 1px solid #ddd; display: flex; justify-content: flex-end; gap: 10px;">
216
+ ${e.isEditing ? '<button type="button" class="btn-remove" style="padding: 8px 16px; border: 1px solid #dc3545; background: white; color: #dc3545; border-radius: 4px; cursor: pointer; margin-right: auto;">Remove Link</button>' : ""}
217
+ <button type="button" class="btn-cancel" style="padding: 8px 16px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer;">Cancel</button>
218
+ <button type="submit" class="btn-submit" style="padding: 8px 16px; border: none; background: #007bff; color: white; border-radius: 4px; cursor: pointer;">
219
+ ${e.isEditing ? "Update Link" : "Insert Link"}
220
+ </button>
221
+ </div>
222
+ </form>
223
+ `, o.appendChild(r), document.body.appendChild(o);
224
+ const d = r.querySelector("#link-form"), n = r.querySelector("#link-text"), i = r.querySelector("#link-url"), L = r.querySelector("#link-title"), b = r.querySelector("#link-target"), E = r.querySelector(".link-dialog-close"), f = r.querySelector(".btn-cancel"), c = r.querySelector(".btn-remove"), w = r.querySelector("#link-url-error");
225
+ n.value = e.text || "", i.value = e.url || "", L.value = e.title || "", i.addEventListener("input", () => {
226
+ w.hidden = !0, i.removeAttribute("aria-invalid");
227
+ });
228
+ const A = (s) => {
229
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), p());
230
+ }, p = () => {
231
+ document.removeEventListener("keydown", A, !0), o.remove();
232
+ };
233
+ E.addEventListener("click", p), f.addEventListener("click", p), c == null || c.addEventListener("click", () => {
234
+ if (l) {
235
+ const s = v(l), h = s ? s.innerHTML : "", u = l.parentNode;
236
+ if (u) {
237
+ for (; l.firstChild; )
238
+ u.insertBefore(l.firstChild, l);
239
+ u.removeChild(l);
240
+ }
241
+ s && (k(s, h), x(s));
242
+ }
243
+ a = null, m = "", g = !1, l = null, p();
244
+ }), o.addEventListener("click", (s) => {
245
+ s.target === o && p();
246
+ }), document.addEventListener("keydown", A, !0), d.addEventListener("submit", (s) => {
247
+ s.preventDefault();
248
+ const h = R(i.value);
249
+ if ("error" in h) {
250
+ w.textContent = h.error, w.hidden = !1, i.setAttribute("aria-invalid", "true"), i.focus();
251
+ return;
252
+ }
253
+ const u = h.url;
254
+ i.value = u, U({
255
+ text: n.value.trim() || u,
256
+ url: u,
257
+ target: b.checked ? "_blank" : "_self",
258
+ title: L.value.trim() || void 0
259
+ }), p();
260
+ }), setTimeout(() => n.focus(), 100);
261
+ }, _ = () => {
262
+ const e = window.getSelection();
263
+ if (!e || e.rangeCount === 0) return !1;
264
+ const t = e.getRangeAt(0).cloneRange();
265
+ a = t;
266
+ const o = I(t), r = e.toString() || "";
267
+ m = r;
268
+ const d = t.startContainer, n = d.nodeType === Node.TEXT_NODE ? d.parentElement : d, i = n == null ? void 0 : n.closest("a");
269
+ return i ? (g = !0, l = i, S({
270
+ text: i.textContent || "",
271
+ // The attribute, not the resolved .href - otherwise editing a relative or
272
+ // in-page link silently rewrites it to an absolute URL.
273
+ url: i.getAttribute("href") || "",
274
+ target: i.target || "_self",
275
+ title: i.title || "",
276
+ isEditing: !0
277
+ }, o)) : (g = !1, l = null, S({
278
+ text: r,
279
+ url: "",
280
+ target: "_self",
281
+ isEditing: !1
282
+ }, o)), !0;
283
+ }, z = () => {
284
+ const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null, o = t && t.nodeType === Node.TEXT_NODE ? t.parentElement : t, r = v(o), d = r ? r.innerHTML : "";
285
+ return document.execCommand("unlink", !1), r && (k(r, d), x(r)), !0;
286
+ }, T = (e, t) => {
287
+ var o;
288
+ typeof window != "undefined" && ((o = window.registerEditorCommand) == null || o.call(window, e, t));
289
+ }, N = () => {
290
+ T("openLinkDialog", _), T("removeLink", z), T("createLink", (e) => {
291
+ if (!e) return;
292
+ const t = R(e);
293
+ if ("error" in t) return;
294
+ const o = window.getSelection(), r = o && o.rangeCount > 0 ? o.getRangeAt(0).startContainer : null, d = r && r.nodeType === Node.TEXT_NODE ? r.parentElement : r, n = v(d), i = n ? n.innerHTML : "";
295
+ document.execCommand("createLink", !1, t.url), n && (k(n, i), x(n));
296
+ });
297
+ };
298
+ typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", N) : N());
299
+ const K = () => ({
300
+ name: "link",
301
+ marks: {
302
+ link: {
303
+ attrs: {
304
+ href: {},
305
+ title: { default: null },
306
+ target: { default: null }
307
+ },
308
+ parseDOM: [
309
+ {
310
+ tag: "a[href]",
311
+ getAttrs: (e) => ({
312
+ href: e.getAttribute("href"),
313
+ title: e.getAttribute("title"),
314
+ target: e.getAttribute("target")
315
+ })
316
+ }
317
+ ],
318
+ toDOM: (e) => [
319
+ "a",
320
+ {
321
+ href: e.attrs.href,
322
+ title: e.attrs.title,
323
+ target: e.attrs.target,
324
+ rel: e.attrs.target === "_blank" ? "noopener noreferrer" : null
325
+ },
326
+ 0
327
+ ]
328
+ }
329
+ },
330
+ toolbar: [
331
+ {
332
+ label: "Link",
333
+ command: "openLinkDialog",
334
+ type: "button",
335
+ icon: '<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',
336
+ shortcut: "Mod-k"
337
+ }
338
+ ],
339
+ commands: {
340
+ openLinkDialog: _,
341
+ removeLink: z
342
+ },
343
+ keymap: {
344
+ "Mod-k": "openLinkDialog"
345
+ }
346
+ });
347
+ export {
348
+ K as LinkPlugin,
349
+ _ as openLinkDialog,
350
+ z as removeLink
351
+ };
352
+ //# sourceMappingURL=LinkPlugin.native-BsQXYsK6.mjs.map
@@ -1,58 +1,91 @@
1
+ import { r as f } from "./historyHelpers-B0-4mq1E.mjs";
1
2
  const d = () => m("insertUnorderedList"), u = () => m("insertOrderedList");
2
3
  function g() {
3
4
  const o = window.getSelection();
4
5
  if (o && o.rangeCount > 0) {
5
- const t = o.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement, e = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
6
- if (e) return e;
6
+ const e = o.getRangeAt(0).startContainer, r = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, n = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
7
+ if (n) return n;
7
8
  }
8
- const n = document.activeElement;
9
- return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
9
+ const t = document.activeElement;
10
+ return t ? t.getAttribute("contenteditable") === "true" ? t : t.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
10
11
  }
11
- function f(o) {
12
- o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach((t) => {
13
- Array.from(t.childNodes).forEach((e) => {
14
- if (e.nodeType === Node.TEXT_NODE) {
15
- const l = (e.textContent || "").trim();
12
+ function p(o) {
13
+ o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach((e) => {
14
+ Array.from(e.childNodes).forEach((n) => {
15
+ if (n.nodeType === Node.TEXT_NODE) {
16
+ const l = (n.textContent || "").trim();
16
17
  if (!l) {
17
- t.removeChild(e);
18
+ e.removeChild(n);
18
19
  return;
19
20
  }
20
21
  const s = document.createElement("li");
21
- s.textContent = l, t.replaceChild(s, e);
22
+ s.textContent = l, e.replaceChild(s, n);
22
23
  return;
23
24
  }
24
- if (!(e instanceof HTMLElement)) {
25
- t.removeChild(e);
25
+ if (!(n instanceof HTMLElement)) {
26
+ e.removeChild(n);
26
27
  return;
27
28
  }
28
- if (e.tagName === "LI")
29
+ if (n.tagName === "LI")
29
30
  return;
30
31
  const i = document.createElement("li");
31
- for (; e.firstChild; )
32
- i.appendChild(e.firstChild);
33
- t.replaceChild(i, e);
32
+ for (; n.firstChild; )
33
+ i.appendChild(n.firstChild);
34
+ e.replaceChild(i, n);
34
35
  });
35
36
  });
36
37
  }
38
+ const h = /* @__PURE__ */ new Set([
39
+ "P",
40
+ "DIV",
41
+ "UL",
42
+ "OL",
43
+ "LI",
44
+ "BLOCKQUOTE",
45
+ "H1",
46
+ "H2",
47
+ "H3",
48
+ "H4",
49
+ "H5",
50
+ "H6",
51
+ "TABLE",
52
+ "PRE",
53
+ "FIGURE",
54
+ "SECTION",
55
+ "ARTICLE",
56
+ "HEADER",
57
+ "FOOTER"
58
+ ]);
59
+ function E(o) {
60
+ let t = null;
61
+ Array.from(o.childNodes).forEach((e) => {
62
+ if (e.nodeType === Node.ELEMENT_NODE && h.has(e.tagName)) {
63
+ t = null;
64
+ return;
65
+ }
66
+ e.nodeType === Node.TEXT_NODE && !(e.textContent || "").trim() || (t || (t = document.createElement("p"), o.insertBefore(t, e)), t.appendChild(e));
67
+ });
68
+ }
37
69
  function m(o) {
38
- const n = g();
39
- if (!n) return !1;
40
- const t = window.getSelection();
41
- if (!t || t.rangeCount === 0) return !1;
42
- const r = t.getRangeAt(0);
43
- if (!n.contains(r.commonAncestorContainer)) return !1;
44
- n.focus({ preventScroll: !0 });
45
- const e = document.execCommand(o, !1);
46
- return f(n), n.dispatchEvent(new Event("input", { bubbles: !0 })), e !== !1;
70
+ const t = g();
71
+ if (!t) return !1;
72
+ const e = window.getSelection();
73
+ if (!e || e.rangeCount === 0) return !1;
74
+ const r = e.getRangeAt(0);
75
+ if (!t.contains(r.commonAncestorContainer)) return !1;
76
+ const n = t.innerHTML;
77
+ t.focus({ preventScroll: !0 });
78
+ const i = document.execCommand(o, !1);
79
+ return p(t), E(t), f(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 })), i !== !1;
47
80
  }
48
- const c = (o, n) => {
49
- var t;
50
- typeof window != "undefined" && ((t = window.registerEditorCommand) == null || t.call(window, o, n));
51
- }, a = () => {
52
- c("toggleBulletList", d), c("toggleOrderedList", u);
81
+ const a = (o, t) => {
82
+ var e;
83
+ typeof window != "undefined" && ((e = window.registerEditorCommand) == null || e.call(window, o, t));
84
+ }, c = () => {
85
+ a("toggleBulletList", d), a("toggleOrderedList", u);
53
86
  };
54
- typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a) : a());
55
- const h = () => ({
87
+ typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c) : c());
88
+ const C = () => ({
56
89
  name: "list",
57
90
  nodes: {
58
91
  bulletList: {
@@ -99,8 +132,8 @@ const h = () => ({
99
132
  }
100
133
  });
101
134
  export {
102
- h as ListPlugin,
135
+ C as ListPlugin,
103
136
  d as toggleBulletList,
104
137
  u as toggleOrderedList
105
138
  };
106
- //# sourceMappingURL=ListPlugin.native-V7EZC1lM.mjs.map
139
+ //# sourceMappingURL=ListPlugin.native-Bt0LANbO.mjs.map