@editora/core 1.0.5 → 1.0.7

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 (43) hide show
  1. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  2. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  3. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  4. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  5. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  6. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  7. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  8. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  9. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  10. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  11. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  12. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
  13. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  14. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  15. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  16. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  17. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  18. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  19. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  20. package/dist/editora.min.js +10 -10
  21. package/dist/editora.umd.js +10 -10
  22. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  23. package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
  24. package/dist/index-BslAFzmv.mjs +16544 -0
  25. package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
  26. package/dist/index.cjs.js +1 -1
  27. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  28. package/dist/index.esm.js +2 -2
  29. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  30. package/dist/plugin-loader.js +15 -15
  31. package/dist/webcomponent-core.js +241 -224
  32. package/dist/webcomponent-core.min.css +1 -1
  33. package/dist/webcomponent-core.min.js +86 -106
  34. package/dist/webcomponent.cjs.js +1 -1
  35. package/dist/webcomponent.esm.js +1 -1
  36. package/dist/webcomponent.js +205 -188
  37. package/dist/webcomponent.min.css +1 -1
  38. package/dist/webcomponent.min.js +477 -402
  39. package/package.json +16 -10
  40. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  41. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  42. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  43. package/dist/documentManager-irzj9n3V.mjs +0 -37627
@@ -1,6 +1,28 @@
1
- import S from "./purify.es-CKpwg8Tk.mjs";
2
- let a = null, d = null, s = null, o = null, u = "", g = "", f = "insert";
3
- const M = [
1
+ import N from "./purify.es-CKpwg8Tk.mjs";
2
+ let n = null, c = null, f = null, o = null, h = "", v = "", T = "insert", k = null, d = null, b = null;
3
+ function H(t, e) {
4
+ if (e === t.innerHTML) return;
5
+ const r = window.execEditorCommand || window.executeEditorCommand;
6
+ if (typeof r == "function")
7
+ try {
8
+ r("recordDomTransaction", t, e, t.innerHTML);
9
+ } catch (l) {
10
+ }
11
+ }
12
+ function z(t) {
13
+ if (!t) return null;
14
+ let e = t.startContainer;
15
+ for (; e && e !== document.body; ) {
16
+ if (e.nodeType === Node.ELEMENT_NODE) {
17
+ const r = e;
18
+ if (r.getAttribute("contenteditable") === "true")
19
+ return r;
20
+ }
21
+ e = e.parentNode;
22
+ }
23
+ return null;
24
+ }
25
+ const F = [
4
26
  {
5
27
  id: "formal-letter",
6
28
  name: "Formal Letter",
@@ -72,42 +94,57 @@ const M = [
72
94
  <p>A: [Answer here]</p>`
73
95
  }
74
96
  ];
75
- let b = [...M];
76
- const w = () => b, O = (t) => b.filter((e) => e.category === t), E = () => {
77
- const t = new Set(b.map((e) => e.category));
97
+ let x = [...F];
98
+ const D = () => x, U = (t) => x.filter((e) => e.category === t), R = () => {
99
+ const t = new Set(x.map((e) => e.category));
78
100
  return Array.from(t);
79
- }, R = (t) => {
101
+ }, P = (t) => {
80
102
  const e = t.toLowerCase();
81
- return b.filter(
103
+ return x.filter(
82
104
  (r) => {
83
- var n, c;
84
- return r.name.toLowerCase().includes(e) || ((n = r.description) == null ? void 0 : n.toLowerCase().includes(e)) || ((c = r.tags) == null ? void 0 : c.some((m) => m.toLowerCase().includes(e)));
105
+ var l, p;
106
+ return r.name.toLowerCase().includes(e) || ((l = r.description) == null ? void 0 : l.toLowerCase().includes(e)) || ((p = r.tags) == null ? void 0 : p.some((s) => s.toLowerCase().includes(e)));
85
107
  }
86
108
  );
87
- }, C = (t) => S.sanitize(t, {
109
+ }, $ = (t) => N.sanitize(t, {
88
110
  ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
89
111
  ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
90
- }), Q = (t) => b.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (b.push(t), !0), F = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
91
- function D(t) {
92
- d = document.createElement("div"), d.className = "rte-dialog-overlay", N(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => p()), a = document.createElement("div"), a.className = "rte-dialog rte-template-dialog", a.addEventListener("click", (r) => r.stopPropagation());
93
- const e = E();
94
- e.length > 0 && !u && (u = e[0]), v(), d.appendChild(a), document.body.appendChild(d), z();
112
+ }), X = (t) => x.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (x.push(t), !0), ee = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
113
+ function _(t) {
114
+ c = document.createElement("div"), c.className = "rte-dialog-overlay", O(t) && c.classList.add("rte-ui-theme-dark"), c.addEventListener("click", () => u()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
115
+ const e = R();
116
+ e.length > 0 && !h && (h = e[0]), E(), c.appendChild(n), document.body.appendChild(c), I(), Y();
117
+ }
118
+ function I() {
119
+ V(), k = (t) => {
120
+ t.key === "Escape" && (!c || !n || (t.preventDefault(), t.stopPropagation(), u()));
121
+ }, document.addEventListener("keydown", k, !0);
95
122
  }
96
- const H = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
123
+ function V() {
124
+ k && (document.removeEventListener("keydown", k, !0), k = null);
125
+ }
126
+ const Q = '[data-theme="dark"], .dark, .editora-theme-dark', C = () => {
97
127
  const t = window.getSelection();
98
128
  if (!t || t.rangeCount === 0) return null;
99
129
  const e = t.anchorNode, r = e instanceof HTMLElement ? e : e == null ? void 0 : e.parentElement;
100
130
  return (r == null ? void 0 : r.closest(
101
131
  ".rte-content, .editora-content"
102
132
  )) || null;
103
- }, N = (t) => {
104
- const e = t || L();
105
- return e ? !!e.closest(H) : !1;
133
+ }, O = (t) => {
134
+ const e = t || C();
135
+ return e ? !!e.closest(Q) : !1;
106
136
  };
107
- function v() {
108
- if (!a) return;
109
- const t = E(), e = T();
110
- a.innerHTML = `
137
+ function A() {
138
+ const t = z(f);
139
+ if (t) return t;
140
+ if (b != null && b.isConnected) return b;
141
+ const e = C();
142
+ return e || document.querySelector(".rte-content, .editora-content");
143
+ }
144
+ function E() {
145
+ if (!n) return;
146
+ const t = R(), e = S();
147
+ n.innerHTML = `
111
148
  <div class="rte-dialog-header">
112
149
  <h2>Insert Template</h2>
113
150
  <button class="rte-dialog-close" aria-label="Close">✕</button>
@@ -118,7 +155,7 @@ function v() {
118
155
  <input
119
156
  type="text"
120
157
  placeholder="Search templates..."
121
- value="${g}"
158
+ value="${v}"
122
159
  class="rte-input rte-template-search"
123
160
  aria-label="Search templates"
124
161
  />
@@ -126,7 +163,7 @@ function v() {
126
163
  <!-- Category Tabs -->
127
164
  <div class="rte-tabs">
128
165
  ${t.map((r) => `
129
- <button class="rte-tab ${u === r ? "active" : ""}" data-category="${r}">
166
+ <button class="rte-tab ${h === r ? "active" : ""}" data-category="${r}">
130
167
  ${r}
131
168
  </button>
132
169
  `).join("")}
@@ -156,11 +193,11 @@ function v() {
156
193
  <!-- Insert Mode Toggle -->
157
194
  <div class="rte-insert-mode">
158
195
  <label>
159
- <input type="radio" name="insertMode" value="insert" ${f === "insert" ? "checked" : ""} />
196
+ <input type="radio" name="insertMode" value="insert" ${T === "insert" ? "checked" : ""} />
160
197
  Insert at cursor
161
198
  </label>
162
199
  <label>
163
- <input type="radio" name="insertMode" value="replace" ${f === "replace" ? "checked" : ""} />
200
+ <input type="radio" name="insertMode" value="replace" ${T === "replace" ? "checked" : ""} />
164
201
  Replace document
165
202
  </label>
166
203
  </div>
@@ -169,14 +206,14 @@ function v() {
169
206
  <div class="rte-dialog-footer">
170
207
  <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
171
208
  <button class="rte-button-primary rte-insert-btn" ${o ? "" : "disabled"}>
172
- ${f === "insert" ? "Insert" : "Replace"}
209
+ ${T === "insert" ? "Insert" : "Replace"}
173
210
  </button>
174
211
  </div>
175
- `, V();
212
+ `, Z();
176
213
  }
177
- function $() {
178
- if (!a) return;
179
- a.innerHTML = `
214
+ function W() {
215
+ if (!n) return;
216
+ n.innerHTML = `
180
217
  <div class="rte-dialog-header">
181
218
  <h2>Replace Document?</h2>
182
219
  </div>
@@ -188,125 +225,112 @@ function $() {
188
225
  <button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
189
226
  </div>
190
227
  `;
191
- const t = a.querySelector(".rte-cancel-warning-btn"), e = a.querySelector(".rte-confirm-replace-btn");
192
- t == null || t.addEventListener("click", () => v()), e == null || e.addEventListener("click", () => j());
228
+ const t = n.querySelector(".rte-cancel-warning-btn"), e = n.querySelector(".rte-confirm-replace-btn");
229
+ t == null || t.addEventListener("click", () => E()), e == null || e.addEventListener("click", () => G());
193
230
  }
194
- function T() {
195
- const t = w();
196
- return g.trim() ? R(g) : u ? t.filter((e) => e.category === u) : t;
231
+ function S() {
232
+ const t = D();
233
+ return v.trim() ? P(v) : h ? t.filter((e) => e.category === h) : t;
197
234
  }
198
- function V() {
199
- if (!a) return;
200
- const t = a.querySelector(".rte-dialog-close");
201
- t == null || t.addEventListener("click", () => p());
202
- const e = a.querySelector(".rte-cancel-btn");
203
- e == null || e.addEventListener("click", () => p());
204
- const r = a.querySelector(".rte-insert-btn");
205
- r == null || r.addEventListener("click", () => y());
206
- const n = a.querySelector(".rte-template-search");
207
- n == null || n.addEventListener("input", (l) => {
208
- g = l.target.value, k();
209
- }), n == null || n.addEventListener("keydown", (l) => {
210
- l.key === "Enter" && o ? y() : l.key === "Escape" && p();
211
- }), a.querySelectorAll(".rte-tab").forEach((l) => {
212
- l.addEventListener("click", () => {
213
- const i = l.getAttribute("data-category");
214
- i && (u = i, g = "", k());
215
- });
216
- }), a.querySelectorAll(".rte-template-item").forEach((l) => {
217
- l.addEventListener("click", () => {
218
- const i = l.getAttribute("data-template-id");
219
- if (i) {
220
- const h = w().find((x) => x.id === i);
221
- h && (o = h, v());
222
- }
223
- }), l.addEventListener("dblclick", () => {
224
- const i = l.getAttribute("data-template-id");
225
- if (i) {
226
- const h = w().find((x) => x.id === i);
227
- h && (o = h, y());
228
- }
229
- });
230
- }), a.querySelectorAll('input[name="insertMode"]').forEach((l) => {
231
- l.addEventListener("change", (i) => {
232
- f = i.target.value, v();
235
+ function Z() {
236
+ if (!n) return;
237
+ const t = n.querySelector(".rte-dialog-close");
238
+ t == null || t.addEventListener("click", () => u());
239
+ const e = n.querySelector(".rte-cancel-btn");
240
+ e == null || e.addEventListener("click", () => u());
241
+ const r = n.querySelector(".rte-insert-btn");
242
+ r == null || r.addEventListener("click", () => L());
243
+ const l = n.querySelector(".rte-template-search");
244
+ l == null || l.addEventListener("input", (a) => {
245
+ d !== null && cancelAnimationFrame(d), v = a.target.value, d = requestAnimationFrame(() => {
246
+ d = null, M();
233
247
  });
248
+ }), l == null || l.addEventListener("keydown", (a) => {
249
+ a.key === "Enter" && o ? L() : a.key === "Escape" && u();
250
+ });
251
+ const p = n.querySelector(".rte-tabs");
252
+ p == null || p.addEventListener("click", (a) => {
253
+ const y = a.target.closest(".rte-tab");
254
+ if (!y) return;
255
+ const w = y.getAttribute("data-category");
256
+ w && (h = w, v = "", d !== null && (cancelAnimationFrame(d), d = null), M());
257
+ });
258
+ const s = n.querySelector(".rte-template-list"), m = (a) => {
259
+ const y = a.target.closest(".rte-template-item");
260
+ if (!y) return null;
261
+ const w = y.getAttribute("data-template-id");
262
+ return w && D().find((q) => q.id === w) || null;
263
+ };
264
+ s == null || s.addEventListener("click", (a) => {
265
+ const i = m(a);
266
+ i && (o = i, E());
267
+ }), s == null || s.addEventListener("dblclick", (a) => {
268
+ const i = m(a);
269
+ i && (o = i, L());
270
+ });
271
+ const g = n.querySelector(".rte-insert-mode");
272
+ g == null || g.addEventListener("change", (a) => {
273
+ const i = a.target;
274
+ !i || i.name !== "insertMode" || (T = i.value, E());
234
275
  });
235
276
  }
236
- function k() {
237
- const t = T();
238
- t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, v();
277
+ function M() {
278
+ const t = S();
279
+ t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, E();
239
280
  }
240
- function y() {
281
+ function L() {
241
282
  var t;
242
283
  if (o)
243
- if (f === "replace") {
244
- let e = null;
245
- if (s) {
246
- let r = s.startContainer;
247
- for (; r && r !== document.body; ) {
248
- if (r.nodeType === Node.ELEMENT_NODE) {
249
- const n = r;
250
- if (n.getAttribute("contenteditable") === "true") {
251
- e = n;
252
- break;
253
- }
254
- }
255
- r = r.parentNode;
256
- }
257
- }
258
- if (e || (e = document.querySelector('[contenteditable="true"]')), (t = e == null ? void 0 : e.innerHTML) != null && t.trim()) {
259
- $();
284
+ if (T === "replace") {
285
+ const e = A();
286
+ if ((t = e == null ? void 0 : e.innerHTML) != null && t.trim()) {
287
+ W();
260
288
  return;
261
289
  }
262
- A(o), p();
290
+ j(o), u();
263
291
  } else
264
- q(o), p();
292
+ K(o), u();
265
293
  }
266
- function j() {
267
- o && (A(o), p());
294
+ function G() {
295
+ o && (j(o), u());
268
296
  }
269
- function q(t) {
270
- if (s) {
271
- const m = window.getSelection();
272
- m && (m.removeAllRanges(), m.addRange(s));
273
- }
297
+ function K(t) {
298
+ var g;
274
299
  const e = window.getSelection();
275
- if (!e || e.rangeCount === 0) return;
276
- const r = e.getRangeAt(0), n = document.createRange().createContextualFragment(C(t.html));
277
- r.deleteContents(), r.insertNode(n);
278
- const c = document.createRange();
279
- c.setStartAfter(r.endContainer), c.collapse(!0), e.removeAllRanges(), e.addRange(c);
300
+ if (!e) return;
301
+ const r = A();
302
+ if (!r) return;
303
+ if (f)
304
+ e.removeAllRanges(), e.addRange(f);
305
+ else {
306
+ const a = document.createRange();
307
+ a.selectNodeContents(r), a.collapse(!1), e.removeAllRanges(), e.addRange(a);
308
+ }
309
+ if (e.rangeCount === 0) return;
310
+ const l = e.getRangeAt(0), p = (g = r == null ? void 0 : r.innerHTML) != null ? g : "", s = document.createRange().createContextualFragment($(t.html));
311
+ l.deleteContents(), l.insertNode(s);
312
+ const m = document.createRange();
313
+ m.setStartAfter(l.endContainer), m.collapse(!0), e.removeAllRanges(), e.addRange(m), r && (H(r, p), r.dispatchEvent(new Event("input", { bubbles: !0 })));
280
314
  }
281
- function A(t) {
282
- let e = null;
283
- if (s) {
284
- let r = s.startContainer;
285
- for (; r && r !== document.body; ) {
286
- if (r.nodeType === Node.ELEMENT_NODE) {
287
- const n = r;
288
- if (n.getAttribute("contenteditable") === "true") {
289
- e = n;
290
- break;
291
- }
292
- }
293
- r = r.parentNode;
294
- }
315
+ function j(t) {
316
+ const e = A();
317
+ if (e) {
318
+ const r = e.innerHTML;
319
+ e.innerHTML = $(t.html), H(e, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
295
320
  }
296
- e || (e = document.querySelector('[contenteditable="true"]')), e && (e.innerHTML = C(t.html), e.dispatchEvent(new Event("input", { bubbles: !0 })));
297
321
  }
298
- function p() {
299
- d && (d.remove(), d = null), a = null, s = null, g = "";
322
+ function u() {
323
+ V(), d !== null && (cancelAnimationFrame(d), d = null), c && (c.remove(), c = null), n = null, f = null, v = "", b = null;
300
324
  }
301
- function I(t) {
325
+ function B(t) {
302
326
  const e = window.getSelection();
303
- e && e.rangeCount > 0 ? s = e.getRangeAt(0).cloneRange() : s = null;
304
- const r = T();
327
+ e && e.rangeCount > 0 ? f = e.getRangeAt(0).cloneRange() : f = null;
328
+ const r = S();
305
329
  r.length > 0 && !o && (o = r[0]);
306
- const n = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : L();
307
- D(n);
330
+ const l = (t == null ? void 0 : t.contentElement) instanceof HTMLElement ? t.contentElement : C();
331
+ b = l || null, _(l);
308
332
  }
309
- function z() {
333
+ function Y() {
310
334
  if (typeof document == "undefined") return;
311
335
  const t = "template-plugin-dialog-styles";
312
336
  if (document.getElementById(t)) return;
@@ -550,7 +574,7 @@ function z() {
550
574
  }
551
575
  `, document.head.appendChild(e);
552
576
  }
553
- const W = () => ({
577
+ const te = () => ({
554
578
  name: "template",
555
579
  toolbar: [
556
580
  {
@@ -560,19 +584,19 @@ const W = () => ({
560
584
  }
561
585
  ],
562
586
  commands: {
563
- insertTemplate: (t, e) => (I(e), !0)
587
+ insertTemplate: (t, e) => (B(e), !0)
564
588
  },
565
589
  keymap: {}
566
590
  });
567
591
  export {
568
- M as PREDEFINED_TEMPLATES,
569
- W as TemplatePlugin,
570
- Q as addCustomTemplate,
571
- w as getAllTemplates,
572
- E as getTemplateCategories,
573
- O as getTemplatesByCategory,
574
- C as sanitizeTemplate,
575
- R as searchTemplates,
576
- F as validateTemplate
592
+ F as PREDEFINED_TEMPLATES,
593
+ te as TemplatePlugin,
594
+ X as addCustomTemplate,
595
+ D as getAllTemplates,
596
+ R as getTemplateCategories,
597
+ U as getTemplatesByCategory,
598
+ $ as sanitizeTemplate,
599
+ P as searchTemplates,
600
+ ee as validateTemplate
577
601
  };
578
- //# sourceMappingURL=TemplatePlugin.native-4lKEm-WY.mjs.map
602
+ //# sourceMappingURL=TemplatePlugin.native-CrpfKRJ8.mjs.map