@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
@@ -17,16 +17,16 @@ class x {
17
17
  const o = this.pluginRegistry.get(t);
18
18
  if (!o)
19
19
  return console.warn(`Plugin not found: ${t}`), null;
20
- const r = await o();
21
- return e && this.applyPluginConfig(r, e), this.loadedPlugins.set(t, r), r;
20
+ const i = await o();
21
+ return e && this.applyPluginConfig(i, e), this.loadedPlugins.set(t, i), i;
22
22
  }
23
23
  /**
24
24
  * Load multiple plugins
25
25
  */
26
26
  async loadMultiple(t, e) {
27
27
  return (await Promise.all(
28
- t.map((r) => this.load(r, e))
29
- )).filter((r) => r !== null);
28
+ t.map((i) => this.load(i, e))
29
+ )).filter((i) => i !== null);
30
30
  }
31
31
  /**
32
32
  * Parse plugin string "lists link image media"
@@ -105,14 +105,14 @@ class S {
105
105
  if (t.initialize)
106
106
  try {
107
107
  t.initialize(o);
108
- } catch (r) {
109
- console.error(`Failed to initialize plugin "${t.name}":`, r);
108
+ } catch (i) {
109
+ console.error(`Failed to initialize plugin "${t.name}":`, i);
110
110
  }
111
111
  if (t.init && t.init !== t.initialize)
112
112
  try {
113
113
  t.init(o);
114
- } catch (r) {
115
- console.error(`Failed to run init hook for plugin "${t.name}":`, r);
114
+ } catch (i) {
115
+ console.error(`Failed to run init hook for plugin "${t.name}":`, i);
116
116
  }
117
117
  }
118
118
  unregister(t) {
@@ -147,27 +147,27 @@ class S {
147
147
  * Execute plugin command with mode awareness
148
148
  */
149
149
  async executePluginCommand(t, e, ...o) {
150
- const r = this.getPlugin(t);
151
- if (!r)
150
+ const i = this.getPlugin(t);
151
+ if (!i)
152
152
  throw new Error(`Plugin not found: ${t}`);
153
- const i = this.getPluginConfig(t) || r.config || {}, n = i.mode || "local";
153
+ const r = this.getPluginConfig(t) || i.config || {}, n = r.mode || "local";
154
154
  try {
155
155
  switch (n) {
156
156
  case "local":
157
- return r.executeLocal ? r.executeLocal(e, ...o) : null;
157
+ return i.executeLocal ? i.executeLocal(e, ...o) : null;
158
158
  case "api":
159
- if (!r.executeAPI)
159
+ if (!i.executeAPI)
160
160
  throw new Error(`Plugin ${t} does not support API mode`);
161
- return await r.executeAPI(e, ...o);
161
+ return await i.executeAPI(e, ...o);
162
162
  case "hybrid":
163
- if (r.executeHybrid)
164
- return await r.executeHybrid(e, ...o);
163
+ if (i.executeHybrid)
164
+ return await i.executeHybrid(e, ...o);
165
165
  try {
166
- if (r.executeAPI)
167
- return await r.executeAPI(e, ...o);
166
+ if (i.executeAPI)
167
+ return await i.executeAPI(e, ...o);
168
168
  } catch (a) {
169
- if (console.warn(`API execution failed for ${t}, falling back to local`, a), r.executeLocal && i.fallbackToLocal !== !1)
170
- return r.executeLocal(e, ...o);
169
+ if (console.warn(`API execution failed for ${t}, falling back to local`, a), i.executeLocal && r.fallbackToLocal !== !1)
170
+ return i.executeLocal(e, ...o);
171
171
  throw a;
172
172
  }
173
173
  break;
@@ -186,7 +186,7 @@ class S {
186
186
  await Promise.all(t), this.plugins = [], this.pluginConfigs.clear();
187
187
  }
188
188
  }
189
- class M {
189
+ class L {
190
190
  constructor(t = {}) {
191
191
  this.commands = /* @__PURE__ */ new Map(), Object.entries(t).forEach(([e, o]) => {
192
192
  this.register(e, o);
@@ -229,11 +229,11 @@ class M {
229
229
  this.commands.clear();
230
230
  }
231
231
  }
232
- class A {
232
+ class M {
233
233
  constructor(t = {}) {
234
234
  this.listeners = /* @__PURE__ */ new Map(), this.isReadonly = !1, this.isDestroyed = !1, this.isReadonly = t.readonly || !1, this.pluginManager = new S(), t.plugins && Array.isArray(t.plugins) && t.plugins.forEach((o) => this.pluginManager.register(o));
235
235
  const e = this.pluginManager.buildSchema();
236
- this.state = b.create(e), this.commandRegistry = new M(this.pluginManager.getCommands());
236
+ this.state = b.create(e), this.commandRegistry = new L(this.pluginManager.getCommands());
237
237
  }
238
238
  /**
239
239
  * Execute a command
@@ -246,12 +246,12 @@ class A {
246
246
  const o = this.commandRegistry.get(t);
247
247
  if (!o)
248
248
  return console.warn(`Command not found: ${t}`), !1;
249
- let r;
250
- return e !== void 0 ? r = o(this.state, e) : r = o(this.state), r instanceof Promise ? (r.then((i) => {
251
- i && typeof i == "object" && "doc" in i && "selection" in i && (this.setState(i), this.emit("change", this.state));
252
- }).catch((i) => {
253
- console.error(`Async command failed: ${t}`, i);
254
- }), !0) : r && typeof r == "object" && "doc" in r && "selection" in r ? (this.setState(r), this.emit("change", this.state), !0) : r !== !1 && r != null;
249
+ let i;
250
+ return e !== void 0 ? i = o(this.state, e) : i = o(this.state), i instanceof Promise ? (i.then((r) => {
251
+ r && typeof r == "object" && "doc" in r && "selection" in r && (this.setState(r), this.emit("change", this.state));
252
+ }).catch((r) => {
253
+ console.error(`Async command failed: ${t}`, r);
254
+ }), !0) : i && typeof i == "object" && "doc" in i && "selection" in i ? (this.setState(i), this.emit("change", this.state), !0) : i !== !1 && i != null;
255
255
  }
256
256
  /**
257
257
  * Update editor state
@@ -284,8 +284,8 @@ class A {
284
284
  return this.listeners.has(t) || this.listeners.set(t, []), this.listeners.get(t).push(e), () => {
285
285
  const o = this.listeners.get(t);
286
286
  if (o) {
287
- const r = o.indexOf(e);
288
- r > -1 && o.splice(r, 1);
287
+ const i = o.indexOf(e);
288
+ i > -1 && o.splice(i, 1);
289
289
  }
290
290
  };
291
291
  }
@@ -294,11 +294,11 @@ class A {
294
294
  */
295
295
  emit(t, ...e) {
296
296
  const o = this.listeners.get(t);
297
- o && o.forEach((r) => {
297
+ o && o.forEach((i) => {
298
298
  try {
299
- r(...e);
300
- } catch (i) {
301
- console.error(`Error in ${t} handler:`, i);
299
+ i(...e);
300
+ } catch (r) {
301
+ console.error(`Error in ${t} handler:`, r);
302
302
  }
303
303
  });
304
304
  }
@@ -315,8 +315,13 @@ class A {
315
315
  return this.isDestroyed;
316
316
  }
317
317
  }
318
- class L {
318
+ class A {
319
319
  // PluginLoader instance to get all registered plugins
320
+ setLastCommandTrigger(t, e) {
321
+ if (typeof window == "undefined" || !t) return;
322
+ const o = e || t.getAttribute("data-command") || void 0;
323
+ o && (window.__editoraLastCommandButton = t, window.__editoraLastCommand = o);
324
+ }
320
325
  constructor(t, e, o) {
321
326
  this.config = t, this.plugins = e, this.pluginLoader = o;
322
327
  }
@@ -330,9 +335,9 @@ class L {
330
335
  * Parse toolbar string into button groups
331
336
  */
332
337
  parseToolbarString(t) {
333
- const e = [], o = t.split("|").map((a) => a.trim()), r = this.getAvailableToolbarItems(), i = /* @__PURE__ */ new Map();
334
- r.forEach((a) => {
335
- a.command && i.set(a.command, a), a.type === "group" && a.label && i.set(a.label, a);
338
+ const e = [], o = t.split("|").map((a) => a.trim()), i = this.getAvailableToolbarItems(), r = /* @__PURE__ */ new Map();
339
+ i.forEach((a) => {
340
+ a.command && r.set(a.command, a), a.type === "group" && a.label && r.set(a.label, a);
336
341
  });
337
342
  const n = {
338
343
  bold: "toggleBold",
@@ -389,7 +394,7 @@ class L {
389
394
  const l = [];
390
395
  a.split(/\s+/).filter(Boolean).forEach((d) => {
391
396
  if (d === "direction") {
392
- const u = i.get("setDirectionLTR"), h = i.get("setDirectionRTL");
397
+ const u = r.get("setDirectionLTR"), h = r.get("setDirectionRTL");
393
398
  u && l.push({
394
399
  id: "directionLTR",
395
400
  label: u.label,
@@ -408,7 +413,7 @@ class L {
408
413
  return;
409
414
  }
410
415
  if (d === "comments") {
411
- const u = i.get("addComment"), h = i.get("toggleComments");
416
+ const u = r.get("addComment"), h = r.get("toggleComments");
412
417
  u && l.push({
413
418
  id: "addComment",
414
419
  label: u.label,
@@ -427,8 +432,8 @@ class L {
427
432
  return;
428
433
  }
429
434
  const g = n[d] || d;
430
- let p = i.get(g);
431
- p || (p = i.get(d)), p && l.push({
435
+ let p = r.get(g);
436
+ p || (p = r.get(d)), p && l.push({
432
437
  id: d,
433
438
  label: p.label,
434
439
  command: p.command,
@@ -452,11 +457,11 @@ class L {
452
457
  render(t) {
453
458
  this.container = t, t.innerHTML = "", t.className = "editora-toolbar", this.config.sticky && t.classList.add("editora-toolbar-sticky"), this.config.position && t.classList.add(`editora-toolbar-${this.config.position}`);
454
459
  const e = this.config.items || this.getDefaultToolbarString(), o = this.parseToolbarString(e);
455
- o.forEach((r, i) => {
460
+ o.forEach((i, r) => {
456
461
  const n = document.createElement("div");
457
- if (n.className = "editora-toolbar-group", r.forEach((a) => {
462
+ if (n.className = "editora-toolbar-group", i.forEach((a) => {
458
463
  this.appendToolbarButton(n, a);
459
- }), t.appendChild(n), i < o.length - 1) {
464
+ }), t.appendChild(n), r < o.length - 1) {
460
465
  const a = document.createElement("div");
461
466
  a.className = "editora-toolbar-separator", t.appendChild(a);
462
467
  }
@@ -499,8 +504,8 @@ class L {
499
504
  e.innerHTML = t.icon;
500
505
  if (t.items && t.items.length) {
501
506
  const o = document.createElement("div");
502
- o.className = "editora-toolbar-group-items", t.items.forEach((r) => {
503
- this.appendToolbarButton(o, r);
507
+ o.className = "editora-toolbar-group-items", t.items.forEach((i) => {
508
+ this.appendToolbarButton(o, i);
504
509
  }), e.appendChild(o);
505
510
  }
506
511
  return e;
@@ -511,7 +516,7 @@ class L {
511
516
  createInput(t) {
512
517
  const e = document.createElement("input");
513
518
  return e.className = `editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g, "-")}`, e.type = "text", e.title = t.label, e.placeholder = t.placeholder || "", t.command && e.setAttribute("data-command", t.command), t.active && e.classList.add("active"), t.disabled && (e.disabled = !0), e.addEventListener("click", (o) => {
514
- o.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command);
519
+ o.preventDefault(), this.setLastCommandTrigger(e, t.command), this.commandHandler && t.command && this.commandHandler(t.command);
515
520
  }), e;
516
521
  }
517
522
  /**
@@ -539,23 +544,25 @@ class L {
539
544
  e.className = "editora-toolbar-dropdown";
540
545
  const o = document.createElement("button");
541
546
  o.className = "editora-toolbar-button editora-toolbar-dropdown-trigger", o.type = "button", o.textContent = t.label;
542
- const r = document.createElement("div");
543
- r.className = "editora-toolbar-dropdown-menu", r.style.display = "none", t.options && t.options.forEach((n) => {
544
- const a = document.createElement("button");
545
- a.className = "editora-toolbar-dropdown-item", a.type = "button", a.textContent = n.label, a.setAttribute("data-value", n.value), a.addEventListener("click", (l) => {
546
- l.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command, n.value), r.style.display = "none";
547
- }), r.appendChild(a);
548
- }), o.addEventListener("click", (n) => {
549
- n.preventDefault(), n.stopPropagation();
550
- const a = r.style.display === "block";
551
- r.style.display = a ? "none" : "block";
547
+ const i = document.createElement("div");
548
+ i.className = "editora-toolbar-dropdown-menu", i.style.display = "none", t.options && t.options.forEach((a) => {
549
+ const l = document.createElement("button");
550
+ l.className = "editora-toolbar-dropdown-item", l.type = "button", l.textContent = a.label, l.setAttribute("data-value", a.value), l.addEventListener("click", (c) => {
551
+ c.preventDefault(), this.setLastCommandTrigger(o, t.command), this.commandHandler && t.command && this.commandHandler(t.command, a.value), i.style.display = "none";
552
+ }), i.appendChild(l);
553
+ }), o.addEventListener("click", (a) => {
554
+ a.preventDefault(), a.stopPropagation(), this.setLastCommandTrigger(o, t.command);
555
+ const l = i.style.display === "block";
556
+ i.style.display = l ? "none" : "block";
552
557
  });
553
- const i = (n) => {
554
- e.contains(n.target) || (r.style.display = "none");
558
+ const r = (a) => {
559
+ e.contains(a.target) || (i.style.display = "none");
560
+ }, n = (a) => {
561
+ a.key === "Escape" && (i.style.display = "none");
555
562
  };
556
- return document.addEventListener("click", i), e._cleanupDropdown = () => {
557
- document.removeEventListener("click", i);
558
- }, e.appendChild(o), e.appendChild(r), e;
563
+ return document.addEventListener("mousedown", r, !0), document.addEventListener("keydown", n), e._cleanupDropdown = () => {
564
+ document.removeEventListener("mousedown", r, !0), document.removeEventListener("keydown", n);
565
+ }, e.appendChild(o), e.appendChild(i), e;
559
566
  }
560
567
  /**
561
568
  * Create an inline menu element (like dropdown but triggered by button click)
@@ -566,30 +573,36 @@ class L {
566
573
  const o = document.createElement("button");
567
574
  if (o.className = "editora-toolbar-button", o.type = "button", o.title = t.label, t.icon)
568
575
  if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
569
- const i = document.createElement("span");
570
- i.className = "editora-toolbar-icon", i.innerHTML = t.icon, o.appendChild(i);
576
+ const a = document.createElement("span");
577
+ a.className = "editora-toolbar-icon", a.innerHTML = t.icon, o.appendChild(a);
571
578
  } else
572
579
  o.innerHTML = t.icon;
573
580
  else
574
581
  o.textContent = t.label;
575
- const r = document.createElement("div");
576
- return r.className = "editora-toolbar-dropdown-menu", r.style.display = "none", t.options && t.options.forEach((i) => {
577
- const n = document.createElement("button");
578
- n.className = "editora-toolbar-dropdown-item", n.type = "button", n.textContent = i.label, n.setAttribute("data-value", i.value), n.addEventListener("click", (a) => {
579
- a.preventDefault(), a.stopPropagation(), this.commandHandler && t.command && this.commandHandler(t.command, i.value), r.style.display = "none";
580
- }), r.appendChild(n);
581
- }), o.addEventListener("click", (i) => {
582
- var a;
583
- i.preventDefault(), i.stopPropagation();
584
- const n = (a = this.container) == null ? void 0 : a.querySelectorAll(
582
+ const i = document.createElement("div");
583
+ i.className = "editora-toolbar-dropdown-menu", i.style.display = "none", t.options && t.options.forEach((a) => {
584
+ const l = document.createElement("button");
585
+ l.className = "editora-toolbar-dropdown-item", l.type = "button", l.textContent = a.label, l.setAttribute("data-value", a.value), l.addEventListener("click", (c) => {
586
+ c.preventDefault(), c.stopPropagation(), this.setLastCommandTrigger(o, t.command), this.commandHandler && t.command && this.commandHandler(t.command, a.value), i.style.display = "none";
587
+ }), i.appendChild(l);
588
+ }), o.addEventListener("click", (a) => {
589
+ var c;
590
+ a.preventDefault(), a.stopPropagation(), this.setLastCommandTrigger(o, t.command);
591
+ const l = (c = this.container) == null ? void 0 : c.querySelectorAll(
585
592
  ".editora-toolbar-dropdown-menu"
586
593
  );
587
- n == null || n.forEach((l) => {
588
- l !== r && (l.style.display = "none");
589
- }), r.style.display = r.style.display === "none" ? "block" : "none";
590
- }), document.addEventListener("click", (i) => {
591
- e.contains(i.target) || (r.style.display = "none");
592
- }), e.appendChild(o), e.appendChild(r), e;
594
+ l == null || l.forEach((d) => {
595
+ d !== i && (d.style.display = "none");
596
+ }), i.style.display = i.style.display === "none" ? "block" : "none";
597
+ });
598
+ const r = (a) => {
599
+ e.contains(a.target) || (i.style.display = "none");
600
+ }, n = (a) => {
601
+ a.key === "Escape" && (i.style.display = "none");
602
+ };
603
+ return document.addEventListener("mousedown", r, !0), document.addEventListener("keydown", n), e._cleanupDropdown = () => {
604
+ document.removeEventListener("mousedown", r, !0), document.removeEventListener("keydown", n);
605
+ }, e.appendChild(o), e.appendChild(i), e;
593
606
  }
594
607
  /**
595
608
  * Get default toolbar string if none provided
@@ -688,25 +701,25 @@ class I {
688
701
  e.className = "editora-statusbar-right";
689
702
  const o = [];
690
703
  if (this.statusInfo.selectionInfo) {
691
- const i = this.statusInfo.selectionInfo;
692
- i.startLine === i.endLine && i.startColumn === i.endColumn ? o.push(`Ln ${i.startLine}, Col ${i.startColumn}`) : (i.startLine === i.endLine ? o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`) : o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`), o.push(`${i.selectedChars} chars selected`));
704
+ const r = this.statusInfo.selectionInfo;
705
+ r.startLine === r.endLine && r.startColumn === r.endColumn ? o.push(`Ln ${r.startLine}, Col ${r.startColumn}`) : (r.startLine === r.endLine ? o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`) : o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`), o.push(`${r.selectedChars} chars selected`));
693
706
  } else if (this.statusInfo.cursorPosition) {
694
- const i = this.statusInfo.cursorPosition;
695
- o.push(`Ln ${i.line}, Col ${i.column}`);
707
+ const r = this.statusInfo.cursorPosition;
708
+ o.push(`Ln ${r.line}, Col ${r.column}`);
696
709
  }
697
710
  this.statusInfo.language && o.push(this.statusInfo.language);
698
- const r = [];
699
- this.statusInfo.wordCount !== void 0 && r.push(`${this.statusInfo.wordCount} words`), this.statusInfo.charCount !== void 0 && r.push(`${this.statusInfo.charCount} chars`), this.statusInfo.lineCount !== void 0 && r.push(`${this.statusInfo.lineCount} lines`), this.statusInfo.custom && Object.entries(this.statusInfo.custom).forEach(([i, n]) => {
700
- r.push(`${i}: ${n}`);
701
- }), o.forEach((i, n) => {
711
+ const i = [];
712
+ this.statusInfo.wordCount !== void 0 && i.push(`${this.statusInfo.wordCount} words`), this.statusInfo.charCount !== void 0 && i.push(`${this.statusInfo.charCount} chars`), this.statusInfo.lineCount !== void 0 && i.push(`${this.statusInfo.lineCount} lines`), this.statusInfo.custom && Object.entries(this.statusInfo.custom).forEach(([r, n]) => {
713
+ i.push(`${r}: ${n}`);
714
+ }), o.forEach((r, n) => {
702
715
  const a = document.createElement("span");
703
- if (a.className = "editora-statusbar-item", a.textContent = i, t.appendChild(a), n < o.length - 1) {
716
+ if (a.className = "editora-statusbar-item", a.textContent = r, t.appendChild(a), n < o.length - 1) {
704
717
  const l = document.createElement("span");
705
718
  l.className = "editora-statusbar-separator", l.textContent = "|", t.appendChild(l);
706
719
  }
707
- }), r.forEach((i, n) => {
720
+ }), i.forEach((r, n) => {
708
721
  const a = document.createElement("span");
709
- if (a.className = "editora-statusbar-item", a.textContent = i, e.appendChild(a), n < r.length - 1) {
722
+ if (a.className = "editora-statusbar-item", a.textContent = r, e.appendChild(a), n < i.length - 1) {
710
723
  const l = document.createElement("span");
711
724
  l.className = "editora-statusbar-separator", l.textContent = "|", e.appendChild(l);
712
725
  }
@@ -720,36 +733,36 @@ class I {
720
733
  }
721
734
  }
722
735
  function D(s, t) {
723
- const e = s.textContent || "", o = P(s, t.startContainer, t.startOffset), i = e.substring(0, o).split(`
724
- `), n = i.length, a = i[i.length - 1].length + 1;
736
+ const e = s.textContent || "", o = P(s, t.startContainer, t.startOffset), r = e.substring(0, o).split(`
737
+ `), n = r.length, a = r[r.length - 1].length + 1;
725
738
  return { line: n, column: a };
726
739
  }
727
740
  function P(s, t, e) {
728
741
  var n;
729
742
  let o = 0;
730
- const r = document.createTreeWalker(
743
+ const i = document.createTreeWalker(
731
744
  s,
732
745
  NodeFilter.SHOW_TEXT,
733
746
  null
734
747
  );
735
- let i = r.firstChild();
736
- for (; i; ) {
737
- if (i === t) {
748
+ let r = i.firstChild();
749
+ for (; r; ) {
750
+ if (r === t) {
738
751
  o += e;
739
752
  break;
740
- } else i.nodeType === Node.TEXT_NODE && (o += ((n = i.textContent) == null ? void 0 : n.length) || 0);
741
- i = r.nextNode();
753
+ } else r.nodeType === Node.TEXT_NODE && (o += ((n = r.textContent) == null ? void 0 : n.length) || 0);
754
+ r = i.nextNode();
742
755
  }
743
756
  return o;
744
757
  }
745
758
  function N(s) {
746
- var o, r;
759
+ var o, i;
747
760
  const t = s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");
748
761
  let e = 1;
749
762
  if (t.length > 0) {
750
763
  e = t.length;
751
- const i = t[t.length - 1];
752
- (i.tagName === "BR" || ((o = i.innerHTML) == null ? void 0 : o.trim()) === "" || ((r = i.textContent) == null ? void 0 : r.trim()) === "") && e++;
764
+ const r = t[t.length - 1];
765
+ (r.tagName === "BR" || ((o = r.innerHTML) == null ? void 0 : o.trim()) === "" || ((i = r.textContent) == null ? void 0 : i.trim()) === "") && e++;
753
766
  } else {
754
767
  const n = (s.textContent || "").split(`
755
768
  `).length;
@@ -1060,8 +1073,8 @@ class O {
1060
1073
  }
1061
1074
  handleKeyDown(t, e) {
1062
1075
  if (!this.enabled) return !1;
1063
- const o = this.getEventKey(t), r = this.shortcuts.get(o);
1064
- return r ? (r.preventDefault !== !1 && (t.preventDefault(), t.stopPropagation()), e(r.command, r.params), !0) : !1;
1076
+ const o = this.getEventKey(t), i = this.shortcuts.get(o);
1077
+ return i ? (i.preventDefault !== !1 && (t.preventDefault(), t.stopPropagation()), e(i.command, i.params), !0) : !1;
1065
1078
  }
1066
1079
  enable() {
1067
1080
  this.enabled = !0;
@@ -1086,17 +1099,17 @@ class O {
1086
1099
  }
1087
1100
  getShortcutsHelp() {
1088
1101
  const t = this.getAllShortcuts(), e = /* @__PURE__ */ new Map();
1089
- t.forEach((r) => {
1090
- const i = this.getShortcutCategory(r.command);
1091
- e.has(i) || e.set(i, []), e.get(i).push(r);
1102
+ t.forEach((i) => {
1103
+ const r = this.getShortcutCategory(i.command);
1104
+ e.has(r) || e.set(r, []), e.get(r).push(i);
1092
1105
  });
1093
1106
  let o = `# Keyboard Shortcuts
1094
1107
 
1095
1108
  `;
1096
- return e.forEach((r, i) => {
1097
- o += `## ${i}
1109
+ return e.forEach((i, r) => {
1110
+ o += `## ${r}
1098
1111
 
1099
- `, r.forEach((n) => {
1112
+ `, i.forEach((n) => {
1100
1113
  const a = this.getShortcutDescription(n);
1101
1114
  o += `- **${a}**: ${n.description || n.command}
1102
1115
  `;
@@ -1159,25 +1172,25 @@ const H = [
1159
1172
  function w(s, t, e) {
1160
1173
  if ((t == null ? void 0 : t.sanitize) === !1)
1161
1174
  return s;
1162
- const o = t != null && t.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : H, i = !!(t != null && t.allowedAttributes) && Object.keys(t.allowedAttributes).length > 0 ? t.allowedAttributes : j, n = document.createElement("div");
1163
- return n.innerHTML = s, C(n, o, i), n.innerHTML;
1175
+ const o = t != null && t.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : H, r = !!(t != null && t.allowedAttributes) && Object.keys(t.allowedAttributes).length > 0 ? t.allowedAttributes : j, n = document.createElement("div");
1176
+ return n.innerHTML = s, C(n, o, r), n.innerHTML;
1164
1177
  }
1165
1178
  function C(s, t, e) {
1166
1179
  const o = Array.from(s.childNodes);
1167
- for (const r of o)
1168
- if (r.nodeType === Node.ELEMENT_NODE) {
1169
- const i = r, n = i.tagName.toLowerCase();
1180
+ for (const i of o)
1181
+ if (i.nodeType === Node.ELEMENT_NODE) {
1182
+ const r = i, n = r.tagName.toLowerCase();
1170
1183
  if (!t.includes(n)) {
1171
- for (; i.firstChild; )
1172
- s.insertBefore(i.firstChild, i);
1173
- s.removeChild(i);
1184
+ for (; r.firstChild; )
1185
+ s.insertBefore(r.firstChild, r);
1186
+ s.removeChild(r);
1174
1187
  continue;
1175
1188
  }
1176
- R(i, e), C(i, t, e);
1177
- } else r.nodeType !== Node.TEXT_NODE && s.removeChild(r);
1189
+ R(r, e), C(r, t, e);
1190
+ } else i.nodeType !== Node.TEXT_NODE && s.removeChild(i);
1178
1191
  }
1179
1192
  function R(s, t) {
1180
- const e = s.tagName.toLowerCase(), o = Array.from(s.attributes), r = t[e] || [], i = t["*"] || [], n = [...r, ...i];
1193
+ const e = s.tagName.toLowerCase(), o = Array.from(s.attributes), i = t[e] || [], r = t["*"] || [], n = [...i, ...r];
1181
1194
  for (const a of o) {
1182
1195
  const l = a.name.toLowerCase();
1183
1196
  let c = !1;
@@ -1249,35 +1262,35 @@ const k = class k {
1249
1262
  const n = typeof e.language == "object" && e.language ? { ...e.language } : {};
1250
1263
  e.languageLocale !== void 0 && (n.locale = e.languageLocale), e.languageDirection !== void 0 && (n.direction = e.languageDirection), e.language = n;
1251
1264
  }
1252
- const r = { locale: "en", direction: "ltr" };
1265
+ const i = { locale: "en", direction: "ltr" };
1253
1266
  if (typeof e.language == "string" ? e.language = {
1254
1267
  locale: e.language,
1255
- direction: r.direction
1268
+ direction: i.direction
1256
1269
  } : typeof e.language == "object" && e.language ? e.language = {
1257
- ...r,
1270
+ ...i,
1258
1271
  ...e.language
1259
- } : e.language = r, e.spellcheckEnabled !== void 0 || e.spellcheckProvider !== void 0 || e.spellcheckApiUrl !== void 0) {
1272
+ } : e.language = i, e.spellcheckEnabled !== void 0 || e.spellcheckProvider !== void 0 || e.spellcheckApiUrl !== void 0) {
1260
1273
  const n = typeof e.spellcheck == "object" && e.spellcheck ? { ...e.spellcheck } : {};
1261
1274
  e.spellcheckEnabled !== void 0 && (n.enabled = !!e.spellcheckEnabled), e.spellcheckProvider !== void 0 && (n.provider = e.spellcheckProvider), e.spellcheckApiUrl !== void 0 && (n.apiUrl = e.spellcheckApiUrl), e.spellcheck = n;
1262
1275
  }
1263
- const i = {
1276
+ const r = {
1264
1277
  enabled: !1,
1265
1278
  provider: "browser",
1266
1279
  apiUrl: ""
1267
1280
  };
1268
1281
  if (typeof e.spellcheck == "boolean")
1269
1282
  e.spellcheck = {
1270
- ...i,
1283
+ ...r,
1271
1284
  enabled: e.spellcheck
1272
1285
  };
1273
1286
  else if (typeof e.spellcheck == "object" && e.spellcheck) {
1274
1287
  const n = {
1275
- ...i,
1288
+ ...r,
1276
1289
  ...e.spellcheck
1277
1290
  };
1278
1291
  !n.provider && n.mode && (n.provider = n.mode === "local" ? "browser" : "api"), n.enabled === void 0 && (n.enabled = !!(n.mode || n.provider || n.apiUrl)), e.spellcheck = n;
1279
1292
  } else
1280
- e.spellcheck = i;
1293
+ e.spellcheck = r;
1281
1294
  return e.contextMenuEnabled !== void 0 && (e.contextMenu = {
1282
1295
  enabled: !!e.contextMenuEnabled
1283
1296
  }), typeof e.contextMenu == "boolean" ? e.contextMenu = { enabled: e.contextMenu } : typeof e.contextMenu == "object" && e.contextMenu ? e.contextMenu = {
@@ -1337,9 +1350,9 @@ const k = class k {
1337
1350
  */
1338
1351
  static parseAttributes(t) {
1339
1352
  const e = {};
1340
- for (const [o, r] of Object.entries(t)) {
1341
- const i = this.kebabToCamel(o);
1342
- e[i] = this.parseAttributeValue(r);
1353
+ for (const [o, i] of Object.entries(t)) {
1354
+ const r = this.kebabToCamel(o);
1355
+ e[r] = this.parseAttributeValue(i);
1343
1356
  }
1344
1357
  return e;
1345
1358
  }
@@ -1387,8 +1400,8 @@ const k = class k {
1387
1400
  static merge(...t) {
1388
1401
  const e = {};
1389
1402
  for (const o of t)
1390
- for (const [r, i] of Object.entries(o))
1391
- i != null && (typeof i == "object" && !Array.isArray(i) && e[r] ? e[r] = this.merge(e[r], i) : e[r] = i);
1403
+ for (const [i, r] of Object.entries(o))
1404
+ r != null && (typeof r == "object" && !Array.isArray(r) && e[i] ? e[i] = this.merge(e[i], r) : e[i] = r);
1392
1405
  return e;
1393
1406
  }
1394
1407
  };
@@ -1452,7 +1465,7 @@ function W() {
1452
1465
  t.id = s, t.textContent = U, document.head.appendChild(t);
1453
1466
  }
1454
1467
  }
1455
- function K() {
1468
+ function _() {
1456
1469
  if (!m) {
1457
1470
  const s = f.__globalPluginLoader;
1458
1471
  s ? m = s : m = new x();
@@ -1461,7 +1474,7 @@ function K() {
1461
1474
  }
1462
1475
  class f extends HTMLElement {
1463
1476
  constructor() {
1464
- if (super(), this.pluginLoader = K(), this.config = {}, this.isInitialized = !1, this.keyboardShortcutManager = new O(), this.lastAutosavedContent = "", this.loadedPlugins = [], W(), !this.hasAttribute("data-initial-content")) {
1477
+ if (super(), this.pluginLoader = _(), this.config = {}, this.isInitialized = !1, this.keyboardShortcutManager = new O(), this.lastAutosavedContent = "", this.loadedPlugins = [], W(), !this.hasAttribute("data-initial-content")) {
1465
1478
  const t = this.innerHTML.trim();
1466
1479
  t && this.setAttribute("data-initial-content", t);
1467
1480
  }
@@ -1564,16 +1577,16 @@ class f extends HTMLElement {
1564
1577
  if (this.querySelector(".editora-toolbar") || this.isInitialized) return;
1565
1578
  this.setAttribute("data-editora-editor", "true"), this.config.height && (this.style.height = typeof this.config.height == "number" ? `${this.config.height}px` : this.config.height), this.config.width && (this.style.width = typeof this.config.width == "number" ? `${this.config.width}px` : this.config.width), this.classList.add("editora-editor"), this.config.theme && this.classList.add(`editora-theme-${this.config.theme}`);
1566
1579
  const t = await this.loadPlugins();
1567
- this.loadedPlugins = t, t.forEach((r) => {
1568
- if (r.init && typeof r.init == "function")
1580
+ this.loadedPlugins = t, t.forEach((i) => {
1581
+ if (i.init && typeof i.init == "function")
1569
1582
  try {
1570
- r.init({ editorElement: this });
1571
- } catch (i) {
1572
- console.error(`[RichTextEditor] Error initializing plugin ${r.name}:`, i);
1583
+ i.init({ editorElement: this });
1584
+ } catch (r) {
1585
+ console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`, r);
1573
1586
  }
1574
1587
  });
1575
1588
  const e = (o = this.restoreAutosavedContent()) != null ? o : this.getAttribute("data-initial-content") || "";
1576
- this.engine = new A({
1589
+ this.engine = new M({
1577
1590
  content: e,
1578
1591
  plugins: t,
1579
1592
  readonly: this.config.readonly
@@ -1596,30 +1609,30 @@ class f extends HTMLElement {
1596
1609
  */
1597
1610
  async loadPlugins() {
1598
1611
  this.pluginLoader || await this.waitForPluginLoader();
1599
- const t = [], e = this.config.plugins && (typeof this.config.plugins == "string" && this.config.plugins.length > 0 || Array.isArray(this.config.plugins) && this.config.plugins.length > 0), r = this.getAccessibilityConfig().checker === !0;
1612
+ const t = [], e = this.config.plugins && (typeof this.config.plugins == "string" && this.config.plugins.length > 0 || Array.isArray(this.config.plugins) && this.config.plugins.length > 0), i = this.getAccessibilityConfig().checker === !0;
1600
1613
  if (e) {
1601
1614
  if (typeof this.config.plugins == "string") {
1602
- const i = this.config.plugins.split(/\s+/).filter(Boolean);
1603
- r && !i.includes("a11yChecker") && i.push("a11yChecker");
1604
- for (const n of i) {
1615
+ const r = this.config.plugins.split(/\s+/).filter(Boolean);
1616
+ i && !r.includes("a11yChecker") && r.push("a11yChecker");
1617
+ for (const n of r) {
1605
1618
  const a = await this.pluginLoader.load(n, this.getPluginLoadConfig(n));
1606
1619
  a && t.push(a);
1607
1620
  }
1608
1621
  } else if (Array.isArray(this.config.plugins)) {
1609
- for (const i of this.config.plugins)
1610
- if (typeof i == "string") {
1611
- const n = await this.pluginLoader.load(i, this.getPluginLoadConfig(i));
1622
+ for (const r of this.config.plugins)
1623
+ if (typeof r == "string") {
1624
+ const n = await this.pluginLoader.load(r, this.getPluginLoadConfig(r));
1612
1625
  n && t.push(n);
1613
1626
  } else
1614
- t.push(i);
1615
- if (r && !t.some((i) => (i == null ? void 0 : i.name) === "a11yChecker")) {
1616
- const i = await this.pluginLoader.load("a11yChecker", this.getPluginLoadConfig("a11yChecker"));
1617
- i && t.push(i);
1627
+ t.push(r);
1628
+ if (i && !t.some((r) => (r == null ? void 0 : r.name) === "a11yChecker")) {
1629
+ const r = await this.pluginLoader.load("a11yChecker", this.getPluginLoadConfig("a11yChecker"));
1630
+ r && t.push(r);
1618
1631
  }
1619
1632
  }
1620
1633
  } else {
1621
- const i = this.pluginLoader.getRegisteredPluginNames();
1622
- for (const n of i) {
1634
+ const r = this.pluginLoader.getRegisteredPluginNames();
1635
+ for (const n of r) {
1623
1636
  const a = await this.pluginLoader.load(n, this.getPluginLoadConfig(n));
1624
1637
  a && t.push(a);
1625
1638
  }
@@ -1742,14 +1755,18 @@ class f extends HTMLElement {
1742
1755
  executeCommand(t, e) {
1743
1756
  var r;
1744
1757
  typeof window != "undefined" && (window.__editoraCommandEditorRoot = this);
1745
- const o = this.loadedPlugins.find((i) => i.commands && i.commands[t]);
1746
- if (o && o.commands) {
1747
- const i = o.commands[t];
1748
- if (typeof i == "function")
1758
+ const o = {
1759
+ editorElement: this,
1760
+ contentElement: this.contentElement,
1761
+ toolbarElement: this.toolbarElement
1762
+ }, i = this.loadedPlugins.find((n) => n.commands && n.commands[t]);
1763
+ if (i && i.commands) {
1764
+ const n = i.commands[t];
1765
+ if (typeof n == "function")
1749
1766
  try {
1750
- return i(t === "toggleFullscreen" ? this : e), !0;
1751
- } catch (n) {
1752
- return console.error(`[RichTextEditor] Error executing native command ${t}:`, n), !1;
1767
+ return n(t === "toggleFullscreen" ? this : e, o), !0;
1768
+ } catch (a) {
1769
+ return console.error(`[RichTextEditor] Error executing native command ${t}:`, a), !1;
1753
1770
  }
1754
1771
  }
1755
1772
  return ((r = this.engine) == null ? void 0 : r.execCommand(t, e)) || !1;
@@ -1757,19 +1774,19 @@ class f extends HTMLElement {
1757
1774
  getPluginLoadConfig(t) {
1758
1775
  const e = this.config.pluginConfig;
1759
1776
  if (e && typeof e == "object") {
1760
- const i = e[t];
1761
- if (i && typeof i == "object")
1762
- return i;
1777
+ const r = e[t];
1778
+ if (r && typeof r == "object")
1779
+ return r;
1763
1780
  }
1764
1781
  const o = {
1765
1782
  spellCheck: ["spellcheck", "spellCheck"]
1766
- }, r = [
1783
+ }, i = [
1767
1784
  t,
1768
1785
  t.toLowerCase(),
1769
1786
  ...o[t] || []
1770
1787
  ];
1771
- for (const i of r) {
1772
- const n = this.config[i];
1788
+ for (const r of i) {
1789
+ const n = this.config[r];
1773
1790
  if (n && typeof n == "object" && !Array.isArray(n))
1774
1791
  return n;
1775
1792
  }
@@ -1793,10 +1810,10 @@ class f extends HTMLElement {
1793
1810
  provider: "localStorage"
1794
1811
  };
1795
1812
  if (t && typeof t == "object") {
1796
- const r = Number((o = (e = t.intervalMs) != null ? e : t.interval) != null ? o : 3e4);
1813
+ const i = Number((o = (e = t.intervalMs) != null ? e : t.interval) != null ? o : 3e4);
1797
1814
  return {
1798
1815
  enabled: !!t.enabled,
1799
- intervalMs: Number.isFinite(r) && r > 0 ? r : 3e4,
1816
+ intervalMs: Number.isFinite(i) && i > 0 ? i : 3e4,
1800
1817
  storageKey: String(t.storageKey || "rte-autosave"),
1801
1818
  provider: t.provider || "localStorage",
1802
1819
  apiUrl: t.apiUrl
@@ -1858,12 +1875,12 @@ class f extends HTMLElement {
1858
1875
  if (e && e.rangeCount > 0) {
1859
1876
  const o = e.getRangeAt(0);
1860
1877
  o.deleteContents();
1861
- const r = document.createElement("div");
1862
- r.innerHTML = t;
1863
- const i = document.createDocumentFragment();
1864
- for (; r.firstChild; )
1865
- i.appendChild(r.firstChild);
1866
- o.insertNode(i), o.collapse(!1), e.removeAllRanges(), e.addRange(o);
1878
+ const i = document.createElement("div");
1879
+ i.innerHTML = t;
1880
+ const r = document.createDocumentFragment();
1881
+ for (; i.firstChild; )
1882
+ r.appendChild(i.firstChild);
1883
+ o.insertNode(r), o.collapse(!1), e.removeAllRanges(), e.addRange(o);
1867
1884
  } else
1868
1885
  this.contentElement.focus(), document.execCommand("insertHTML", !1, t);
1869
1886
  }
@@ -1871,8 +1888,8 @@ class f extends HTMLElement {
1871
1888
  * Create UI elements
1872
1889
  */
1873
1890
  createUI(t, e) {
1874
- const o = this.querySelector('[slot="toolbar"]'), r = this.querySelector('[slot="statusbar"]');
1875
- this.innerHTML = "", this.config.toolbar !== !1 && !o ? (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.appendChild(this.toolbarElement), this.toolbar = new L(
1891
+ const o = this.querySelector('[slot="toolbar"]'), i = this.querySelector('[slot="statusbar"]');
1892
+ this.innerHTML = "", this.config.toolbar !== !1 && !o ? (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.appendChild(this.toolbarElement), this.toolbar = new A(
1876
1893
  {
1877
1894
  items: this.resolveToolbarItems(),
1878
1895
  sticky: this.isToolbarStickyEnabled(),
@@ -1881,7 +1898,7 @@ class f extends HTMLElement {
1881
1898
  t,
1882
1899
  this.pluginLoader
1883
1900
  // Pass plugin loader to get all registered plugins
1884
- ), this.toolbar.setCommandHandler((i, n) => {
1901
+ ), this.toolbar.setCommandHandler((r, n) => {
1885
1902
  var a;
1886
1903
  if (this.contentElement) {
1887
1904
  this.contentElement.focus();
@@ -1891,16 +1908,16 @@ class f extends HTMLElement {
1891
1908
  d.nodeType === Node.TEXT_NODE ? c.setStart(d, ((a = d.textContent) == null ? void 0 : a.length) || 0) : d.nodeType === Node.ELEMENT_NODE ? (c.selectNodeContents(d), c.collapse(!1)) : c.setStart(this.contentElement, 0), c.collapse(!0), l == null || l.removeAllRanges(), l == null || l.addRange(c);
1892
1909
  }
1893
1910
  }
1894
- return this.executeCommand(i, n);
1911
+ return this.executeCommand(r, n);
1895
1912
  }), this.toolbar.render(this.toolbarElement)) : o && this.appendChild(o), this.contentElement = document.createElement("div"), this.contentElement.className = "editora-content rte-content", this.contentElement.contentEditable = this.config.readonly ? "false" : "true", this.applyLanguageSettings(), this.applyAccessibilitySettings(), this.applySpellcheckSettings(), this.config.placeholder && this.contentElement.setAttribute("data-placeholder", this.config.placeholder);
1896
1913
  try {
1897
1914
  document.execCommand("defaultParagraphSeparator", !1, "p");
1898
- } catch (i) {
1899
- console.warn("defaultParagraphSeparator not supported:", i);
1915
+ } catch (r) {
1916
+ console.warn("defaultParagraphSeparator not supported:", r);
1900
1917
  }
1901
1918
  if (e) {
1902
- const i = document.createElement("div");
1903
- i.innerHTML = e.trim(), !Array.from(i.childNodes).some((a) => {
1919
+ const r = document.createElement("div");
1920
+ r.innerHTML = e.trim(), !Array.from(r.childNodes).some((a) => {
1904
1921
  if (a.nodeType === Node.ELEMENT_NODE) {
1905
1922
  const l = a.tagName;
1906
1923
  return ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "UL", "OL", "BLOCKQUOTE", "PRE"].includes(l);
@@ -1909,9 +1926,9 @@ class f extends HTMLElement {
1909
1926
  }) && e.trim() ? this.contentElement.innerHTML = `<p>${e.trim()}</p>` : this.contentElement.innerHTML = e;
1910
1927
  } else
1911
1928
  this.config.placeholder ? this.contentElement.innerHTML = "" : this.contentElement.innerHTML = "<p><br></p>";
1912
- this.appendChild(this.contentElement), this.isToolbarFloatingEnabled() && (this.floatingToolbar = new T({ enabled: !0 }), this.floatingToolbar.create(this)), r ? this.appendChild(r) : this.isStatusbarEnabled() && (this.statusBarElement = document.createElement("div"), this.statusBarElement.className = "editora-statusbar-container", this.appendChild(this.statusBarElement), this.statusBar = new I({ position: this.getStatusbarPosition() }), this.statusBar.create(this.statusBarElement)), this.config.autofocus && setTimeout(() => {
1913
- var i;
1914
- return (i = this.contentElement) == null ? void 0 : i.focus();
1929
+ this.appendChild(this.contentElement), this.isToolbarFloatingEnabled() && (this.floatingToolbar = new T({ enabled: !0 }), this.floatingToolbar.create(this)), i ? this.appendChild(i) : this.isStatusbarEnabled() && (this.statusBarElement = document.createElement("div"), this.statusBarElement.className = "editora-statusbar-container", this.appendChild(this.statusBarElement), this.statusBar = new I({ position: this.getStatusbarPosition() }), this.statusBar.create(this.statusBarElement)), this.config.autofocus && setTimeout(() => {
1930
+ var r;
1931
+ return (r = this.contentElement) == null ? void 0 : r.focus();
1915
1932
  }, 0);
1916
1933
  }
1917
1934
  /**
@@ -1923,9 +1940,9 @@ class f extends HTMLElement {
1923
1940
  this.contentElement.addEventListener("input", () => {
1924
1941
  if (!this.contentElement) return;
1925
1942
  let o = this.contentElement.innerHTML;
1926
- const r = this.getPerformanceConfig(), i = this.getContentSanitizeConfig(), n = this.getSecurityConfig();
1927
- if (n.sanitizeOnInput !== !1 && i.sanitize !== !1) {
1928
- const l = $(o, i, n);
1943
+ const i = this.getPerformanceConfig(), r = this.getContentSanitizeConfig(), n = this.getSecurityConfig();
1944
+ if (n.sanitizeOnInput !== !1 && r.sanitize !== !1) {
1945
+ const l = $(o, r, n);
1929
1946
  if (l !== o) {
1930
1947
  const c = window.getSelection(), d = c && c.rangeCount > 0 ? c.getRangeAt(0) : null;
1931
1948
  if (this.contentElement.innerHTML = l, d && c)
@@ -1943,26 +1960,26 @@ class f extends HTMLElement {
1943
1960
  bubbles: !0
1944
1961
  }));
1945
1962
  };
1946
- r.debounceInputMs > 0 ? this.contentChangeDebounceTimer = setTimeout(a, r.debounceInputMs) : a(), this.updateStatusBar();
1963
+ i.debounceInputMs > 0 ? this.contentChangeDebounceTimer = setTimeout(a, i.debounceInputMs) : a(), this.updateStatusBar();
1947
1964
  }), this.contentElement.addEventListener("contextmenu", (o) => {
1948
- const r = this.config.contextMenu;
1949
- (r === !1 || typeof r == "object" && r !== null && r.enabled === !1) && o.preventDefault();
1965
+ const i = this.config.contextMenu;
1966
+ (i === !1 || typeof i == "object" && i !== null && i.enabled === !1) && o.preventDefault();
1950
1967
  }), this.contentElement.addEventListener("paste", (o) => {
1951
1968
  var d, g;
1952
1969
  o.preventDefault();
1953
- const r = this.config.paste || {};
1954
- let i = ((d = o.clipboardData) == null ? void 0 : d.getData("text/html")) || "";
1955
- const n = ((g = o.clipboardData) == null ? void 0 : g.getData("text/plain")) || "", a = this.getContentSanitizeConfig(), l = this.getSecurityConfig(), c = !!i && /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);
1956
- if ((r.clean || !r.keepFormatting) && n) {
1970
+ const i = this.config.paste || {};
1971
+ let r = ((d = o.clipboardData) == null ? void 0 : d.getData("text/html")) || "";
1972
+ const n = ((g = o.clipboardData) == null ? void 0 : g.getData("text/plain")) || "", a = this.getContentSanitizeConfig(), l = this.getSecurityConfig(), c = !!r && /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);
1973
+ if ((i.clean || !i.keepFormatting) && n) {
1957
1974
  document.execCommand("insertText", !1, n);
1958
1975
  return;
1959
1976
  }
1960
- if (r.convertWord === !1 && c && n) {
1977
+ if (i.convertWord === !1 && c && n) {
1961
1978
  document.execCommand("insertText", !1, n);
1962
1979
  return;
1963
1980
  }
1964
- if (i) {
1965
- l.sanitizeOnPaste !== !1 && a.sanitize !== !1 && (i = F(i, a, l)), this.insertHTMLAtSelection(i);
1981
+ if (r) {
1982
+ l.sanitizeOnPaste !== !1 && a.sanitize !== !1 && (r = F(r, a, l)), this.insertHTMLAtSelection(r);
1966
1983
  return;
1967
1984
  }
1968
1985
  n && document.execCommand("insertText", !1, n);
@@ -1974,13 +1991,13 @@ class f extends HTMLElement {
1974
1991
  bubbles: !0
1975
1992
  })), this.dispatchEvent(new Event("editor-blur", { bubbles: !0 })), this.updateFloatingToolbar(), this.updateStatusBar();
1976
1993
  }), this.contentElement.addEventListener("keydown", (o) => {
1977
- this.getAccessibilityConfig().keyboardNavigation && t.handleKeyDown(o, (i, n) => {
1978
- this.executeCommand(i, n);
1994
+ this.getAccessibilityConfig().keyboardNavigation && t.handleKeyDown(o, (r, n) => {
1995
+ this.executeCommand(r, n);
1979
1996
  });
1980
1997
  });
1981
1998
  const e = () => {
1982
- const o = this.getSelectionRangeInEditor(), r = document.activeElement, i = !!r && !!this.contentElement && (r === this.contentElement || this.contentElement.contains(r));
1983
- this.getPerformanceConfig().viewportOnlyScan && !this.isEditorInViewport() && !i || !o && !i || (this.updateFloatingToolbar(), this.updateStatusBar());
1999
+ const o = this.getSelectionRangeInEditor(), i = document.activeElement, r = !!i && !!this.contentElement && (i === this.contentElement || this.contentElement.contains(i));
2000
+ this.getPerformanceConfig().viewportOnlyScan && !this.isEditorInViewport() && !r || !o && !r || (this.updateFloatingToolbar(), this.updateStatusBar());
1984
2001
  };
1985
2002
  this.selectionChangeHandler = e, document.addEventListener("selectionchange", this.selectionChangeHandler);
1986
2003
  }
@@ -2002,7 +2019,7 @@ class f extends HTMLElement {
2002
2019
  }
2003
2020
  }
2004
2021
  getSelectionAnchorRect(t, e) {
2005
- const o = Array.from(e.getClientRects()).filter((i) => i.width > 0 || i.height > 0);
2022
+ const o = Array.from(e.getClientRects()).filter((r) => r.width > 0 || r.height > 0);
2006
2023
  return o.length === 0 ? e.getBoundingClientRect() : this.isSelectionBackward(t) ? o[0] : o[o.length - 1];
2007
2024
  }
2008
2025
  /**
@@ -2024,17 +2041,17 @@ class f extends HTMLElement {
2024
2041
  this.floatingToolbar.hide();
2025
2042
  return;
2026
2043
  }
2027
- const r = window.getSelection();
2028
- if (!r) {
2044
+ const i = window.getSelection();
2045
+ if (!i) {
2029
2046
  this.floatingToolbar.hide();
2030
2047
  return;
2031
2048
  }
2032
- const i = this.getSelectionAnchorRect(r, o);
2033
- if (!i) {
2049
+ const r = this.getSelectionAnchorRect(i, o);
2050
+ if (!r) {
2034
2051
  this.floatingToolbar.hide();
2035
2052
  return;
2036
2053
  }
2037
- this.floatingToolbar.show(i.left, i.top - 40);
2054
+ this.floatingToolbar.show(r.left, r.top - 40);
2038
2055
  }
2039
2056
  /**
2040
2057
  * Update status bar with selection and cursor information
@@ -2047,12 +2064,12 @@ class f extends HTMLElement {
2047
2064
  const t = this.getPerformanceConfig(), e = document.activeElement === this.contentElement || this.contentElement.contains(document.activeElement);
2048
2065
  if (t.viewportOnlyScan && !this.isEditorInViewport() && !e)
2049
2066
  return;
2050
- const o = this.contentElement.textContent || "", { words: r, chars: i } = z(o), n = N(this.contentElement);
2067
+ const o = this.contentElement.textContent || "", { words: i, chars: r } = z(o), n = N(this.contentElement);
2051
2068
  let a, l;
2052
2069
  const c = this.getSelectionRangeInEditor();
2053
2070
  c && (a = D(this.contentElement, c), c.collapsed || (l = B(c, a), a = void 0)), this.statusBar.update({
2054
- wordCount: r,
2055
- charCount: i,
2071
+ wordCount: i,
2072
+ charCount: r,
2056
2073
  lineCount: n,
2057
2074
  cursorPosition: a,
2058
2075
  selectionInfo: l
@@ -2175,8 +2192,8 @@ class f extends HTMLElement {
2175
2192
  * Destroy the editor
2176
2193
  */
2177
2194
  destroy() {
2178
- var t, e, o, r;
2179
- this.contentChangeDebounceTimer && (clearTimeout(this.contentChangeDebounceTimer), this.contentChangeDebounceTimer = void 0), this.contentElement && this.persistAutosave(this.contentElement.innerHTML || ""), this.stopAutosave(), this.selectionChangeHandler && (document.removeEventListener("selectionchange", this.selectionChangeHandler), this.selectionChangeHandler = void 0), (t = this.engine) == null || t.destroy(), (e = this.toolbar) == null || e.destroy(), (o = this.floatingToolbar) == null || o.destroy(), (r = this.statusBar) == null || r.destroy(), this.innerHTML = "", this.contentElement = void 0, this.toolbarElement = void 0, this.statusBarElement = void 0, this.loadedPlugins = [], this.isInitialized = !1, this.dispatchEvent(new Event("editor-destroy", { bubbles: !0 }));
2195
+ var t, e, o, i;
2196
+ this.contentChangeDebounceTimer && (clearTimeout(this.contentChangeDebounceTimer), this.contentChangeDebounceTimer = void 0), this.contentElement && this.persistAutosave(this.contentElement.innerHTML || ""), this.stopAutosave(), this.selectionChangeHandler && (document.removeEventListener("selectionchange", this.selectionChangeHandler), this.selectionChangeHandler = void 0), (t = this.engine) == null || t.destroy(), (e = this.toolbar) == null || e.destroy(), (o = this.floatingToolbar) == null || o.destroy(), (i = this.statusBar) == null || i.destroy(), this.innerHTML = "", this.contentElement = void 0, this.toolbarElement = void 0, this.statusBarElement = void 0, this.loadedPlugins = [], this.isInitialized = !1, this.dispatchEvent(new Event("editor-destroy", { bubbles: !0 }));
2180
2197
  }
2181
2198
  // Public API methods
2182
2199
  getContent() {
@@ -2200,7 +2217,7 @@ class f extends HTMLElement {
2200
2217
  }
2201
2218
  const v = new x();
2202
2219
  f.__globalPluginLoader = v;
2203
- const _ = {
2220
+ const K = {
2204
2221
  // Core editing plugins (always loaded)
2205
2222
  bold: () => import("./BoldPlugin.native-BAzzoqU5.mjs").then((s) => s.BoldPlugin()),
2206
2223
  italic: () => import("./ItalicPlugin.native-CQjjDyUL.mjs").then((s) => s.ItalicPlugin()),
@@ -2209,12 +2226,12 @@ const _ = {
2209
2226
  clearFormatting: () => import("./ClearFormattingPlugin.native-Bq_XcTh2.mjs").then((s) => s.ClearFormattingPlugin()),
2210
2227
  heading: () => import("./HeadingPlugin.native-DrLYwQnQ.mjs").then((s) => s.HeadingPlugin()),
2211
2228
  blockquote: () => import("./BlockquotePlugin.native-JFmOLsxN.mjs").then((s) => s.BlockquotePlugin()),
2212
- code: () => import("./CodePlugin.native-B263UI8O.mjs").then((s) => s.CodePlugin()),
2229
+ code: () => import("./CodePlugin.native-DlpTPdkd.mjs").then((s) => s.CodePlugin()),
2213
2230
  list: () => import("./ListPlugin.native-V7EZC1lM.mjs").then((s) => s.ListPlugin()),
2214
2231
  history: () => import("./HistoryPlugin.native-TDnVMsEO.mjs").then((s) => s.HistoryPlugin())
2215
2232
  };
2216
2233
  async function q() {
2217
- return Object.entries(_).forEach(([s, t]) => {
2234
+ return Object.entries(K).forEach(([s, t]) => {
2218
2235
  v.register(s, t);
2219
2236
  }), v;
2220
2237
  }
@@ -2222,10 +2239,10 @@ typeof window != "undefined" && q().then((s) => {
2222
2239
  f.__globalPluginLoader = s, customElements.get("editora-editor") || customElements.define("editora-editor", f);
2223
2240
  const t = document.querySelectorAll("editora-editor:not([data-initial-content])"), e = [];
2224
2241
  t.forEach((o) => {
2225
- const r = o.innerHTML.trim();
2226
- r && (e.push(r), o.setAttribute("data-initial-content", r), o.innerHTML = "");
2227
- }), t.forEach((o, r) => {
2228
- o instanceof f && !o.isInitialized && e[r] && o.setAttribute("content", e[r]);
2242
+ const i = o.innerHTML.trim();
2243
+ i && (e.push(i), o.setAttribute("data-initial-content", i), o.innerHTML = "");
2244
+ }), t.forEach((o, i) => {
2245
+ o instanceof f && !o.isInitialized && e[i] && o.setAttribute("content", e[i]);
2229
2246
  });
2230
2247
  });
2231
2248
  export {