@editora/plugins 1.0.1 → 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.
Files changed (105) hide show
  1. package/README.md +173 -110
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +598 -0
  21. package/dist/code.esm.js +2034 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-D86di_ZO.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-Cw420fPO.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B4xMKvwd.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-lzohzZmW.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +217 -5
  103. package/LICENSE +0 -21
  104. package/dist/index-CnEGPLxN.js +0 -3752
  105. package/dist/index-xwiBh2x6.mjs +0 -11739
@@ -0,0 +1,397 @@
1
+ const R = ".rte-content, .editora-content", C = '.rte-footnotes[data-type="footnotes"]', m = ".rte-footnote-ref[data-footnote-id]", b = 'li.rte-footnote-item[data-type="footnote"]', x = "__editoraCommandEditorRoot";
2
+ let y = !1, S = !1, A = 0;
3
+ function M() {
4
+ if (y || typeof document > "u") return;
5
+ y = !0;
6
+ const t = document.createElement("style");
7
+ t.id = "editora-footnote-plugin-styles", t.textContent = `
8
+ .rte-footnote-ref {
9
+ display: inline-block;
10
+ font-size: 0.72em;
11
+ line-height: 1;
12
+ vertical-align: super;
13
+ margin-left: 1px;
14
+ color: #1f4dbd;
15
+ cursor: pointer;
16
+ user-select: none;
17
+ border-radius: 4px;
18
+ padding: 0 2px;
19
+ outline: none;
20
+ font-weight: 600;
21
+ }
22
+
23
+ .rte-footnote-ref:focus,
24
+ .rte-footnote-ref:focus-visible,
25
+ .rte-footnote-ref.rte-footnote-selected {
26
+ background: rgba(31, 77, 189, 0.12);
27
+ box-shadow: 0 0 0 2px rgba(31, 77, 189, 0.24);
28
+ }
29
+
30
+ .rte-footnotes {
31
+ margin-top: 16px;
32
+ padding-top: 10px;
33
+ border-top: 1px solid #d1d5db;
34
+ }
35
+
36
+ .rte-footnotes ol {
37
+ margin: 0;
38
+ padding-left: 24px;
39
+ }
40
+
41
+ .rte-footnote-item {
42
+ margin: 0 0 8px;
43
+ color: inherit;
44
+ }
45
+
46
+ .rte-footnote-content {
47
+ display: inline;
48
+ outline: none;
49
+ }
50
+
51
+ .rte-footnote-backref {
52
+ margin-left: 8px;
53
+ color: #1f4dbd;
54
+ text-decoration: none;
55
+ font-size: 0.9em;
56
+ user-select: none;
57
+ }
58
+
59
+ .rte-footnote-backref:hover,
60
+ .rte-footnote-backref:focus {
61
+ text-decoration: underline;
62
+ }
63
+
64
+ .rte-footnote-highlighted {
65
+ animation: rte-footnote-flash 1s ease;
66
+ }
67
+
68
+ @keyframes rte-footnote-flash {
69
+ 0% { background-color: rgba(255, 234, 143, 0.9); }
70
+ 100% { background-color: transparent; }
71
+ }
72
+
73
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref {
74
+ color: #8ab4ff;
75
+ }
76
+
77
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref:focus,
78
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref:focus-visible,
79
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-ref.rte-footnote-selected {
80
+ background: rgba(138, 180, 255, 0.16);
81
+ box-shadow: 0 0 0 2px rgba(138, 180, 255, 0.3);
82
+ }
83
+
84
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnotes {
85
+ border-top-color: #4b5563;
86
+ }
87
+
88
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-footnote-backref {
89
+ color: #8ab4ff;
90
+ }
91
+ `, document.head.appendChild(t);
92
+ }
93
+ function v(t) {
94
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
95
+ }
96
+ function _(t) {
97
+ if (!t) return null;
98
+ const e = t.querySelector('[contenteditable="true"]');
99
+ return e instanceof HTMLElement ? e : null;
100
+ }
101
+ function q() {
102
+ if (typeof window > "u") return null;
103
+ const t = window[x];
104
+ if (!(t instanceof HTMLElement)) return null;
105
+ window[x] = null;
106
+ 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);
107
+ if (e) {
108
+ const o = _(e);
109
+ if (o) return o;
110
+ if (e.getAttribute("contenteditable") === "true") return e;
111
+ }
112
+ if (t.getAttribute("contenteditable") === "true")
113
+ return t;
114
+ const n = t.closest('[contenteditable="true"]');
115
+ return n instanceof HTMLElement ? n : null;
116
+ }
117
+ function $(t) {
118
+ const e = t.closest('[contenteditable="true"]');
119
+ if (!e) return null;
120
+ let n = e, o = n.parentElement;
121
+ for (; o; )
122
+ o.getAttribute("contenteditable") === "true" && (n = o), o = o.parentElement;
123
+ return n;
124
+ }
125
+ function u(t) {
126
+ const e = v(t);
127
+ if (!e) return null;
128
+ const n = e.closest(R);
129
+ return n || $(e);
130
+ }
131
+ function B() {
132
+ const t = window.getSelection();
133
+ return !t || t.rangeCount === 0 ? null : u(t.getRangeAt(0).startContainer);
134
+ }
135
+ function H() {
136
+ const t = q();
137
+ if (t && document.contains(t))
138
+ return t;
139
+ const e = B();
140
+ if (e) return e;
141
+ const n = document.activeElement, o = n ? u(n) : null;
142
+ if (o) return o;
143
+ const r = document.querySelector(R);
144
+ return r || document.querySelector('[contenteditable="true"]');
145
+ }
146
+ function z() {
147
+ const t = document.createElement("section");
148
+ t.className = "rte-footnotes", t.setAttribute("data-type", "footnotes"), t.setAttribute("contenteditable", "false");
149
+ const e = document.createElement("ol");
150
+ return t.appendChild(e), t;
151
+ }
152
+ function g(t, e) {
153
+ let n = t.querySelector(C);
154
+ return !n && e && (n = z(), t.appendChild(n)), n ? (n.querySelector("ol") || n.appendChild(document.createElement("ol")), n) : null;
155
+ }
156
+ function O(t) {
157
+ let e = t.querySelector("ol");
158
+ return e || (e = document.createElement("ol"), t.appendChild(e)), e;
159
+ }
160
+ function P(t) {
161
+ const e = document.createElement("sup");
162
+ return e.className = "rte-footnote-ref", e.setAttribute("data-footnote-id", t), e.setAttribute("data-number", "0"), e.setAttribute("contenteditable", "false"), e.setAttribute("tabindex", "0"), e.setAttribute("role", "doc-noteref"), e.id = `ref-${t}`, e.textContent = "0", e;
163
+ }
164
+ function F(t, e) {
165
+ const n = document.createElement("li");
166
+ n.id = t, n.className = "rte-footnote-item", n.setAttribute("data-type", "footnote"), n.setAttribute("data-number", "0"), n.setAttribute("contenteditable", "false");
167
+ const o = document.createElement("div");
168
+ o.className = "rte-footnote-content", o.setAttribute("contenteditable", "true"), o.textContent = e;
169
+ const r = document.createElement("a");
170
+ return r.className = "rte-footnote-backref", r.href = `#ref-${t}`, r.setAttribute("aria-label", "Back to reference"), r.setAttribute("contenteditable", "false"), r.textContent = "↩", n.appendChild(o), n.appendChild(r), n;
171
+ }
172
+ function j(t) {
173
+ let e = "";
174
+ do
175
+ A += 1, e = `fn-${Date.now().toString(36)}-${A.toString(36)}`;
176
+ while (t.querySelector(`#${CSS.escape(e)}`));
177
+ return e;
178
+ }
179
+ function k(t) {
180
+ t.classList.remove("rte-footnote-highlighted"), t.classList.add("rte-footnote-highlighted"), window.setTimeout(() => {
181
+ t.classList.remove("rte-footnote-highlighted");
182
+ }, 1e3);
183
+ }
184
+ function L(t) {
185
+ t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
186
+ }
187
+ function I(t, e) {
188
+ if (!t || e === t.innerHTML) return;
189
+ const n = window.execEditorCommand || window.executeEditorCommand;
190
+ if (typeof n == "function")
191
+ try {
192
+ n("recordDomTransaction", t, e, t.innerHTML);
193
+ } catch {
194
+ }
195
+ }
196
+ function X(t, e) {
197
+ return Array.from(t.querySelectorAll(m)).find((o) => o.getAttribute("data-footnote-id") === e) || null;
198
+ }
199
+ function V(t) {
200
+ const e = window.getSelection();
201
+ if (!e)
202
+ throw new Error("Selection unavailable");
203
+ let n = null;
204
+ if (e.rangeCount > 0) {
205
+ const r = e.getRangeAt(0);
206
+ t.contains(r.commonAncestorContainer) && (n = r.cloneRange());
207
+ }
208
+ if (!n) {
209
+ n = document.createRange();
210
+ const r = g(t, !1);
211
+ r ? (n.setStartBefore(r), n.collapse(!0)) : (n.selectNodeContents(t), n.collapse(!1));
212
+ }
213
+ if (v(n.commonAncestorContainer)?.closest(C)) {
214
+ const r = g(t, !0);
215
+ r && (n.setStartBefore(r), n.collapse(!0));
216
+ }
217
+ return e.removeAllRanges(), e.addRange(n), n;
218
+ }
219
+ function w(t) {
220
+ const e = t.parentNode;
221
+ if (!e) return;
222
+ const n = Array.from(e.childNodes).indexOf(t);
223
+ if (n < 0) return;
224
+ const o = window.getSelection();
225
+ if (!o) return;
226
+ const r = document.createRange();
227
+ r.setStart(e, n), r.setEnd(e, n + 1), o.removeAllRanges(), o.addRange(r), t.focus({ preventScroll: !0 });
228
+ }
229
+ function T(t, e) {
230
+ const n = window.getSelection();
231
+ if (!n) return;
232
+ const o = Math.max(0, Math.min(e, t.childNodes.length)), r = document.createRange();
233
+ r.setStart(t, o), r.collapse(!0), n.removeAllRanges(), n.addRange(r);
234
+ }
235
+ function K(t) {
236
+ if (t.collapsed || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1 || !(t.startContainer instanceof Element || t.startContainer instanceof DocumentFragment))
237
+ return null;
238
+ const e = t.startContainer.childNodes[t.startOffset];
239
+ return !(e instanceof HTMLElement) || !e.matches(m) ? null : e;
240
+ }
241
+ function p(t, e, n) {
242
+ const { startContainer: o, startOffset: r } = t;
243
+ if (o.nodeType === Node.ELEMENT_NODE) {
244
+ const i = o;
245
+ if (n === "previous") {
246
+ if (r > 0) return i.childNodes[r - 1] || null;
247
+ } else if (r < i.childNodes.length)
248
+ return i.childNodes[r] || null;
249
+ }
250
+ if (o.nodeType === Node.TEXT_NODE && (n === "previous" && r < o.data.length || n === "next" && r > 0))
251
+ return null;
252
+ let c = o;
253
+ for (; c && c !== e; ) {
254
+ const i = n === "previous" ? c.previousSibling : c.nextSibling;
255
+ if (i) return i;
256
+ c = c.parentNode;
257
+ }
258
+ return null;
259
+ }
260
+ function Y(t, e, n) {
261
+ if (!t.collapsed) return null;
262
+ const o = (i) => i instanceof HTMLElement && i.matches(m) ? i : null, { startContainer: r, startOffset: c } = t;
263
+ if (r.nodeType === Node.ELEMENT_NODE) {
264
+ const i = r;
265
+ return n === "Backspace" && c > 0 ? o(i.childNodes[c - 1] || null) : n === "Delete" ? o(i.childNodes[c] || null) : null;
266
+ }
267
+ if (r.nodeType === Node.TEXT_NODE) {
268
+ const i = r;
269
+ if (n === "Backspace" && c === 0) {
270
+ const a = o(i.previousSibling);
271
+ return a || o(p(t, e, "previous"));
272
+ }
273
+ if (n === "Delete" && c === i.data.length) {
274
+ const a = o(i.nextSibling);
275
+ return a || o(p(t, e, "next"));
276
+ }
277
+ }
278
+ return o(n === "Backspace" ? p(t, e, "previous") : p(t, e, "next"));
279
+ }
280
+ function D(t) {
281
+ const e = Array.from(t.querySelectorAll(m)).filter((a) => !a.closest(C)), n = g(t, e.length > 0);
282
+ if (!n) return;
283
+ const o = O(n), r = Array.from(o.querySelectorAll(b)), c = /* @__PURE__ */ new Map();
284
+ r.forEach((a) => c.set(a.id, a));
285
+ const i = [];
286
+ e.forEach((a, f) => {
287
+ const l = a.getAttribute("data-footnote-id");
288
+ if (!l) return;
289
+ const s = f + 1;
290
+ a.setAttribute("data-number", String(s)), a.id = `ref-${l}`, a.textContent = String(s);
291
+ let d = c.get(l);
292
+ d || (d = F(l, `Footnote ${s}`)), d.setAttribute("data-number", String(s));
293
+ const h = d.querySelector(".rte-footnote-content");
294
+ h && !(h.textContent || "").trim() && (h.textContent = `Footnote ${s}`);
295
+ const E = d.querySelector(".rte-footnote-backref");
296
+ E && (E.href = `#ref-${l}`, E.setAttribute("aria-label", `Back to reference ${s}`)), i.push(d);
297
+ }), o.innerHTML = "", i.forEach((a) => o.appendChild(a)), i.length === 0 && n.remove();
298
+ }
299
+ function N(t, e) {
300
+ const n = u(t), o = t.parentNode;
301
+ if (!n || !o) return !1;
302
+ const r = n.innerHTML, c = Array.from(o.childNodes).indexOf(t);
303
+ if (c < 0) return !1;
304
+ const i = t.getAttribute("data-footnote-id") || "";
305
+ return t.remove(), i && n.querySelector(
306
+ `${b}#${CSS.escape(i)}`
307
+ )?.remove(), T(o, c), D(n), I(n, r), L(n), !0;
308
+ }
309
+ function G() {
310
+ S || typeof document > "u" || (S = !0, document.addEventListener("click", (t) => {
311
+ const e = t.target;
312
+ if (!e) return;
313
+ const n = e.closest(m);
314
+ if (n) {
315
+ const f = u(n);
316
+ if (!f || !f.contains(n)) return;
317
+ t.preventDefault(), t.stopPropagation(), w(n), n.classList.add("rte-footnote-selected"), window.setTimeout(() => n.classList.remove("rte-footnote-selected"), 1200);
318
+ const l = n.getAttribute("data-footnote-id");
319
+ if (!l) return;
320
+ const s = f.querySelector(
321
+ `${b}#${CSS.escape(l)}`
322
+ );
323
+ if (!s) return;
324
+ s.scrollIntoView({ behavior: "smooth", block: "center" }), k(s);
325
+ return;
326
+ }
327
+ const o = e.closest(".rte-footnote-backref");
328
+ if (!o) return;
329
+ const r = o.closest(b);
330
+ if (!r) return;
331
+ const c = u(r);
332
+ if (!c || !c.contains(r)) return;
333
+ t.preventDefault(), t.stopPropagation();
334
+ const i = r.id;
335
+ if (!i) return;
336
+ const a = X(c, i);
337
+ a && (a.scrollIntoView({ behavior: "smooth", block: "center" }), k(a), w(a));
338
+ }), document.addEventListener("keydown", (t) => {
339
+ if (t.key !== "Backspace" && t.key !== "Delete") return;
340
+ const e = window.getSelection();
341
+ if (!e || e.rangeCount === 0) return;
342
+ const n = e.getRangeAt(0), o = u(n.commonAncestorContainer);
343
+ if (!o || !o.contains(n.commonAncestorContainer)) return;
344
+ const r = K(n);
345
+ if (r) {
346
+ t.preventDefault(), t.stopPropagation(), N(r, t.key);
347
+ return;
348
+ }
349
+ const c = Y(
350
+ n,
351
+ o,
352
+ t.key
353
+ );
354
+ c && (t.preventDefault(), t.stopPropagation(), N(c, t.key));
355
+ }));
356
+ }
357
+ const J = (t = "") => {
358
+ const e = H();
359
+ if (!e) return !1;
360
+ const n = e.innerHTML, o = window.getSelection();
361
+ if (!o) return !1;
362
+ let r;
363
+ try {
364
+ r = V(e);
365
+ } catch {
366
+ return !1;
367
+ }
368
+ r.collapsed || (r.collapse(!1), o.removeAllRanges(), o.addRange(r));
369
+ const c = j(e), i = P(c);
370
+ try {
371
+ r.insertNode(i);
372
+ } catch {
373
+ return !1;
374
+ }
375
+ const a = document.createRange();
376
+ a.setStartAfter(i), a.collapse(!0), o.removeAllRanges(), o.addRange(a);
377
+ const f = g(e, !0);
378
+ if (!f) return !1;
379
+ const l = O(f), s = t.trim() || "Footnote";
380
+ return l.appendChild(F(c, s)), D(e), I(e, n), L(e), !0;
381
+ }, Q = () => (M(), G(), {
382
+ name: "footnote",
383
+ toolbar: [
384
+ {
385
+ label: "Footnote",
386
+ command: "insertFootnote",
387
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><rect x="3" y="4" width="14" height="2" rx="1"></rect><rect x="3" y="8" width="18" height="2" rx="1"></rect><rect x="3" y="12" width="16" height="2" rx="1"></rect><rect x="3" y="16" width="10" height="1.5" rx="0.75"></rect><text x="19" y="11" font-size="9" font-weight="600" fill="currentColor" font-family="system-ui, sans-serif">1</text></svg>'
388
+ }
389
+ ],
390
+ commands: {
391
+ insertFootnote: () => J()
392
+ },
393
+ keymap: {}
394
+ });
395
+ export {
396
+ Q as FootnotePlugin
397
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=new WeakMap,a="rte-fullscreen-active",t=e=>(o.has(e)||o.set(e,{isFullscreen:!1,fullscreenButton:null}),o.get(e)),y=(e,s)=>{if(e.classList.add(a),e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.width="100%",e.style.height="100%",e.style.maxWidth="100%",e.style.maxHeight="100%",e.style.borderRadius="0",e.style.zIndex="9999",e.style.margin="0",e.style.padding="0",e.style.boxShadow="none",e.style.display="flex",e.style.flexDirection="column",e.style.background="white",document.body.style.overflow="hidden",document.body.classList.add("fullscreen-active"),s.fullscreenButton){s.fullscreenButton.setAttribute("data-active","true"),s.fullscreenButton.style.backgroundColor="var(--rte-color-primary, #007bff)",s.fullscreenButton.style.color="white";const l=s.fullscreenButton.querySelector("svg");l&&(l.style.fill="white",l.style.stroke="white")}},c=(e,s)=>{if(e.classList.remove(a),e.style.position="",e.style.top="",e.style.left="",e.style.right="",e.style.bottom="",e.style.width="",e.style.height="",e.style.maxWidth="",e.style.maxHeight="",e.style.borderRadius="",e.style.zIndex="",e.style.margin="",e.style.padding="",e.style.boxShadow="",e.style.display="",e.style.flexDirection="",e.style.background="",document.body.style.overflow="",document.body.classList.remove("fullscreen-active"),s.fullscreenButton){s.fullscreenButton.setAttribute("data-active","false"),s.fullscreenButton.style.backgroundColor="",s.fullscreenButton.style.color="";const l=s.fullscreenButton.querySelector("svg");l&&(l.style.fill="",l.style.stroke="")}},f=e=>{try{if(!e){const l=document.activeElement;l&&l.closest("[data-editora-editor]")&&(e=l.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e)return console.warn("Editor element not found"),!1;const s=t(e);return s.fullscreenButton||(s.fullscreenButton=e.querySelector('[data-command="toggleFullscreen"]')),s.isFullscreen=!s.isFullscreen,s.isFullscreen?y(e,s):c(e,s),!0}catch(s){return console.error("Fullscreen toggle failed:",s),!1}},i=e=>{if(!e){document.querySelectorAll("[data-editora-editor]").forEach(l=>{const u=l,n=t(u);n.isFullscreen&&(n.isFullscreen=!1,c(u,n))});return}const s=t(e);s.isFullscreen&&(s.isFullscreen=!1,c(e,s))},d=e=>t(e).isFullscreen,r=()=>{const e=s=>{s.key==="Escape"&&i()};return typeof window<"u"&&window.addEventListener("keydown",e),()=>{typeof window<"u"&&window.removeEventListener("keydown",e)}};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r):r());const g=()=>({name:"fullscreen",toolbar:[{label:"Fullscreen",command:"toggleFullscreen",type:"button",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>'}],commands:{toggleFullscreen:f},keymap:{Escape:()=>{const e=document.querySelectorAll("[data-editora-editor]");for(const s of e)if(d(s))return i(s),!0;return!1}}});exports.FullscreenPlugin=g;
@@ -0,0 +1,73 @@
1
+ const o = /* @__PURE__ */ new WeakMap(), a = "rte-fullscreen-active", t = (s) => (o.has(s) || o.set(s, {
2
+ isFullscreen: !1,
3
+ fullscreenButton: null
4
+ }), o.get(s)), y = (s, e) => {
5
+ if (s.classList.add(a), s.style.position = "fixed", s.style.top = "0", s.style.left = "0", s.style.right = "0", s.style.bottom = "0", s.style.width = "100%", s.style.height = "100%", s.style.maxWidth = "100%", s.style.maxHeight = "100%", s.style.borderRadius = "0", s.style.zIndex = "9999", s.style.margin = "0", s.style.padding = "0", s.style.boxShadow = "none", s.style.display = "flex", s.style.flexDirection = "column", s.style.background = "white", document.body.style.overflow = "hidden", document.body.classList.add("fullscreen-active"), e.fullscreenButton) {
6
+ e.fullscreenButton.setAttribute("data-active", "true"), e.fullscreenButton.style.backgroundColor = "var(--rte-color-primary, #007bff)", e.fullscreenButton.style.color = "white";
7
+ const l = e.fullscreenButton.querySelector("svg");
8
+ l && (l.style.fill = "white", l.style.stroke = "white");
9
+ }
10
+ }, c = (s, e) => {
11
+ if (s.classList.remove(a), s.style.position = "", s.style.top = "", s.style.left = "", s.style.right = "", s.style.bottom = "", s.style.width = "", s.style.height = "", s.style.maxWidth = "", s.style.maxHeight = "", s.style.borderRadius = "", s.style.zIndex = "", s.style.margin = "", s.style.padding = "", s.style.boxShadow = "", s.style.display = "", s.style.flexDirection = "", s.style.background = "", document.body.style.overflow = "", document.body.classList.remove("fullscreen-active"), e.fullscreenButton) {
12
+ e.fullscreenButton.setAttribute("data-active", "false"), e.fullscreenButton.style.backgroundColor = "", e.fullscreenButton.style.color = "";
13
+ const l = e.fullscreenButton.querySelector("svg");
14
+ l && (l.style.fill = "", l.style.stroke = "");
15
+ }
16
+ }, i = (s) => {
17
+ try {
18
+ if (!s) {
19
+ const l = document.activeElement;
20
+ l && l.closest("[data-editora-editor]") && (s = l.closest("[data-editora-editor]"));
21
+ }
22
+ if (s || (s = document.querySelector("[data-editora-editor]")), !s)
23
+ return console.warn("Editor element not found"), !1;
24
+ const e = t(s);
25
+ return e.fullscreenButton || (e.fullscreenButton = s.querySelector('[data-command="toggleFullscreen"]')), e.isFullscreen = !e.isFullscreen, e.isFullscreen ? y(s, e) : c(s, e), !0;
26
+ } catch (e) {
27
+ return console.error("Fullscreen toggle failed:", e), !1;
28
+ }
29
+ }, f = (s) => {
30
+ if (!s) {
31
+ document.querySelectorAll("[data-editora-editor]").forEach((l) => {
32
+ const u = l, n = t(u);
33
+ n.isFullscreen && (n.isFullscreen = !1, c(u, n));
34
+ });
35
+ return;
36
+ }
37
+ const e = t(s);
38
+ e.isFullscreen && (e.isFullscreen = !1, c(s, e));
39
+ }, d = (s) => t(s).isFullscreen, r = () => {
40
+ const s = (e) => {
41
+ e.key === "Escape" && f();
42
+ };
43
+ return typeof window < "u" && window.addEventListener("keydown", s), () => {
44
+ typeof window < "u" && window.removeEventListener("keydown", s);
45
+ };
46
+ };
47
+ typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r) : r());
48
+ const g = () => ({
49
+ name: "fullscreen",
50
+ toolbar: [
51
+ {
52
+ label: "Fullscreen",
53
+ command: "toggleFullscreen",
54
+ type: "button",
55
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>'
56
+ }
57
+ ],
58
+ commands: {
59
+ toggleFullscreen: i
60
+ },
61
+ keymap: {
62
+ Escape: () => {
63
+ const s = document.querySelectorAll("[data-editora-editor]");
64
+ for (const e of s)
65
+ if (d(e))
66
+ return f(e), !0;
67
+ return !1;
68
+ }
69
+ }
70
+ });
71
+ export {
72
+ g as FullscreenPlugin
73
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=()=>{const e=a=>{try{return document.execCommand("formatBlock",!1,a),!0}catch(l){return console.error(`Failed to set block type to ${a}:`,l),!1}};return{name:"heading",toolbar:[{label:"Heading",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:a=>a?e(a):!1,setHeading1:()=>e("h1"),setHeading2:()=>e("h2"),setHeading3:()=>e("h3"),setParagraph:()=>e("p")},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}}};exports.HeadingPlugin=t;
@@ -0,0 +1,63 @@
1
+ const t = () => {
2
+ const e = (a) => {
3
+ try {
4
+ return document.execCommand("formatBlock", !1, a), !0;
5
+ } catch (l) {
6
+ return console.error(`Failed to set block type to ${a}:`, l), !1;
7
+ }
8
+ };
9
+ return {
10
+ name: "heading",
11
+ // Toolbar button configuration with dropdown
12
+ toolbar: [
13
+ {
14
+ label: "Heading",
15
+ command: "setBlockType",
16
+ type: "dropdown",
17
+ options: [
18
+ { value: "p", label: "Paragraph" },
19
+ { value: "h1", label: "Heading 1" },
20
+ { value: "h2", label: "Heading 2" },
21
+ { value: "h3", label: "Heading 3" },
22
+ { value: "h4", label: "Heading 4" },
23
+ { value: "h5", label: "Heading 5" },
24
+ { value: "h6", label: "Heading 6" }
25
+ ],
26
+ icon: '<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'
27
+ }
28
+ ],
29
+ // Native command implementations
30
+ commands: {
31
+ /**
32
+ * Set block type to specific heading level or paragraph
33
+ */
34
+ setBlockType: (a) => a ? e(a) : !1,
35
+ /**
36
+ * Set heading level 1
37
+ */
38
+ setHeading1: () => e("h1"),
39
+ /**
40
+ * Set heading level 2
41
+ */
42
+ setHeading2: () => e("h2"),
43
+ /**
44
+ * Set heading level 3
45
+ */
46
+ setHeading3: () => e("h3"),
47
+ /**
48
+ * Set to paragraph
49
+ */
50
+ setParagraph: () => e("p")
51
+ },
52
+ // Keyboard shortcuts
53
+ keymap: {
54
+ "Mod-Alt-1": "setHeading1",
55
+ "Mod-Alt-2": "setHeading2",
56
+ "Mod-Alt-3": "setHeading3",
57
+ "Mod-Alt-0": "setParagraph"
58
+ }
59
+ };
60
+ };
61
+ export {
62
+ t as HeadingPlugin
63
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=".rte-content, .editora-content",y=100,T="__editoraCommandEditorRoot",d=new Map,E={};let h=!1,c=null;function I(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function z(){if(typeof window>"u")return null;const t=window[T];if(!(t instanceof HTMLElement))return null;window[T]=null;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);if(e){const o=I(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function F(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function a(t){const e=F(t);if(!e)return null;const n=e.closest(v);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function l(){const t=z();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=a(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=a(n);if(i)return i}if(c?.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(v);return r||document.querySelector('[contenteditable="true"]')}function A(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function C(t){A();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function s(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function M(t){return t?t.innerHTML:""}function m(t,e){if(!t)return;const n=C(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y),c=t}function L(t,e="undo"){if(A(),t?.isConnected)return t;const n=l();if(n?.isConnected)return n;if(c?.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function w(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function H(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(E[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{E[o]=r},window.registerEditorCommand(t,e))}const S=(t,...e)=>{const n=E[t];return n?n(...e):!1};function p(){h||typeof window>"u"||(h=!0,window.execEditorCommand||(window.execEditorCommand=S),window.executeEditorCommand||(window.executeEditorCommand=S),u("undo",k),u("redo",D),u("setAttribute",O),u("setText",N),u("autoFixA11y",R),u("recordDomTransaction",_),u("undoDom",b),u("redoDom",g))}function x(t,e){const n=e||l(),o=M(n);n?.focus({preventScroll:!0});let r=!1;try{r=!!document.execCommand(t,!1)}catch{r=!1}const i=M(n),f=o!==i;return f&&s(n),{executed:r,changed:f}}const k=()=>{const t=l();return x("undo",t).changed?!0:b(t)},D=()=>{const t=l();return x("redo",t).changed?!0:g(t)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=a(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),m(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),s(o)},N=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=a(t),o=t.textContent??"";t.textContent=e,m(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),s(n)},R=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=a(e),o=window.a11yRuleRegistry?.find(f=>f.id===t.rule);if(!o||typeof o.fix!="function")return;const r=w(e);o.fix(t);const i=w(e);m(n,{undo:()=>{e.isConnected&&H(e,r)},redo:()=>{e.isConnected&&H(e,i)}}),s(n)},_=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(m(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},b=t=>{const e=L(t,"undo");if(!e)return!1;const n=C(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,s(e),!0):!1},g=t=>{const e=L(t,"redo");if(!e)return!1;const n=C(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,s(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p,{once:!0}):p());const Z=()=>(p(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:k,redo:D,setAttribute:O,setText:N,autoFixA11y:R,recordDomTransaction:_,undoDom:b,redoDom:g},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=Z;