@editora/core 1.0.6 → 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.
- package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
- package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
- package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
- package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
- package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
- package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
- package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
- package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
- package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
- package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
- package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
- package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
- package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
- package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
- package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
- package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
- package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
- package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
- package/dist/editora.min.js +10 -10
- package/dist/editora.umd.js +10 -10
- package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
- package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
- package/dist/index-BslAFzmv.mjs +16544 -0
- package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
- package/dist/index.esm.js +2 -2
- package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
- package/dist/plugin-loader.js +15 -15
- package/dist/webcomponent-core.js +241 -224
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +86 -106
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +205 -188
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +477 -402
- package/package.json +1 -1
- package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
- package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
- package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
- 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
|
|
21
|
-
return e && this.applyPluginConfig(
|
|
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((
|
|
29
|
-
)).filter((
|
|
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 (
|
|
109
|
-
console.error(`Failed to initialize plugin "${t.name}":`,
|
|
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 (
|
|
115
|
-
console.error(`Failed to run init hook for plugin "${t.name}":`,
|
|
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
|
|
151
|
-
if (!
|
|
150
|
+
const i = this.getPlugin(t);
|
|
151
|
+
if (!i)
|
|
152
152
|
throw new Error(`Plugin not found: ${t}`);
|
|
153
|
-
const
|
|
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
|
|
157
|
+
return i.executeLocal ? i.executeLocal(e, ...o) : null;
|
|
158
158
|
case "api":
|
|
159
|
-
if (!
|
|
159
|
+
if (!i.executeAPI)
|
|
160
160
|
throw new Error(`Plugin ${t} does not support API mode`);
|
|
161
|
-
return await
|
|
161
|
+
return await i.executeAPI(e, ...o);
|
|
162
162
|
case "hybrid":
|
|
163
|
-
if (
|
|
164
|
-
return await
|
|
163
|
+
if (i.executeHybrid)
|
|
164
|
+
return await i.executeHybrid(e, ...o);
|
|
165
165
|
try {
|
|
166
|
-
if (
|
|
167
|
-
return await
|
|
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),
|
|
170
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
250
|
-
return e !== void 0 ?
|
|
251
|
-
|
|
252
|
-
}).catch((
|
|
253
|
-
console.error(`Async command failed: ${t}`,
|
|
254
|
-
}), !0) :
|
|
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
|
|
288
|
-
|
|
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((
|
|
297
|
+
o && o.forEach((i) => {
|
|
298
298
|
try {
|
|
299
|
-
|
|
300
|
-
} catch (
|
|
301
|
-
console.error(`Error in ${t} handler:`,
|
|
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
|
|
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()),
|
|
334
|
-
|
|
335
|
-
a.command &&
|
|
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 =
|
|
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 =
|
|
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 =
|
|
431
|
-
p || (p =
|
|
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((
|
|
460
|
+
o.forEach((i, r) => {
|
|
456
461
|
const n = document.createElement("div");
|
|
457
|
-
if (n.className = "editora-toolbar-group",
|
|
462
|
+
if (n.className = "editora-toolbar-group", i.forEach((a) => {
|
|
458
463
|
this.appendToolbarButton(n, a);
|
|
459
|
-
}), t.appendChild(n),
|
|
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((
|
|
503
|
-
this.appendToolbarButton(o,
|
|
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
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}),
|
|
548
|
-
}), o.addEventListener("click", (
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
|
|
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
|
|
554
|
-
e.contains(
|
|
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("
|
|
557
|
-
document.removeEventListener("
|
|
558
|
-
}, e.appendChild(o), e.appendChild(
|
|
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
|
|
570
|
-
|
|
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
|
|
576
|
-
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}),
|
|
581
|
-
}), o.addEventListener("click", (
|
|
582
|
-
var
|
|
583
|
-
|
|
584
|
-
const
|
|
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
|
-
|
|
588
|
-
|
|
589
|
-
}),
|
|
590
|
-
})
|
|
591
|
-
|
|
592
|
-
|
|
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
|
|
692
|
-
|
|
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
|
|
695
|
-
o.push(`Ln ${
|
|
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
|
|
699
|
-
this.statusInfo.wordCount !== void 0 &&
|
|
700
|
-
|
|
701
|
-
}), o.forEach((
|
|
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 =
|
|
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
|
-
}),
|
|
720
|
+
}), i.forEach((r, n) => {
|
|
708
721
|
const a = document.createElement("span");
|
|
709
|
-
if (a.className = "editora-statusbar-item", a.textContent =
|
|
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),
|
|
724
|
-
`), n =
|
|
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
|
|
743
|
+
const i = document.createTreeWalker(
|
|
731
744
|
s,
|
|
732
745
|
NodeFilter.SHOW_TEXT,
|
|
733
746
|
null
|
|
734
747
|
);
|
|
735
|
-
let
|
|
736
|
-
for (;
|
|
737
|
-
if (
|
|
748
|
+
let r = i.firstChild();
|
|
749
|
+
for (; r; ) {
|
|
750
|
+
if (r === t) {
|
|
738
751
|
o += e;
|
|
739
752
|
break;
|
|
740
|
-
} else
|
|
741
|
-
|
|
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,
|
|
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
|
|
752
|
-
(
|
|
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),
|
|
1064
|
-
return
|
|
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((
|
|
1090
|
-
const
|
|
1091
|
-
e.has(
|
|
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((
|
|
1097
|
-
o += `## ${
|
|
1109
|
+
return e.forEach((i, r) => {
|
|
1110
|
+
o += `## ${r}
|
|
1098
1111
|
|
|
1099
|
-
`,
|
|
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,
|
|
1163
|
-
return n.innerHTML = s, C(n, o,
|
|
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
|
|
1168
|
-
if (
|
|
1169
|
-
const
|
|
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 (;
|
|
1172
|
-
s.insertBefore(
|
|
1173
|
-
s.removeChild(
|
|
1184
|
+
for (; r.firstChild; )
|
|
1185
|
+
s.insertBefore(r.firstChild, r);
|
|
1186
|
+
s.removeChild(r);
|
|
1174
1187
|
continue;
|
|
1175
1188
|
}
|
|
1176
|
-
R(
|
|
1177
|
-
} else
|
|
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),
|
|
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
|
|
1265
|
+
const i = { locale: "en", direction: "ltr" };
|
|
1253
1266
|
if (typeof e.language == "string" ? e.language = {
|
|
1254
1267
|
locale: e.language,
|
|
1255
|
-
direction:
|
|
1268
|
+
direction: i.direction
|
|
1256
1269
|
} : typeof e.language == "object" && e.language ? e.language = {
|
|
1257
|
-
...
|
|
1270
|
+
...i,
|
|
1258
1271
|
...e.language
|
|
1259
|
-
} : e.language =
|
|
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
|
|
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
|
-
...
|
|
1283
|
+
...r,
|
|
1271
1284
|
enabled: e.spellcheck
|
|
1272
1285
|
};
|
|
1273
1286
|
else if (typeof e.spellcheck == "object" && e.spellcheck) {
|
|
1274
1287
|
const n = {
|
|
1275
|
-
...
|
|
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 =
|
|
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,
|
|
1341
|
-
const
|
|
1342
|
-
e[
|
|
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 [
|
|
1391
|
-
|
|
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
|
|
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 =
|
|
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((
|
|
1568
|
-
if (
|
|
1580
|
+
this.loadedPlugins = t, t.forEach((i) => {
|
|
1581
|
+
if (i.init && typeof i.init == "function")
|
|
1569
1582
|
try {
|
|
1570
|
-
|
|
1571
|
-
} catch (
|
|
1572
|
-
console.error(`[RichTextEditor] Error initializing plugin ${
|
|
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
|
|
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),
|
|
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
|
|
1603
|
-
|
|
1604
|
-
for (const n of
|
|
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
|
|
1610
|
-
if (typeof
|
|
1611
|
-
const n = await this.pluginLoader.load(
|
|
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(
|
|
1615
|
-
if (
|
|
1616
|
-
const
|
|
1617
|
-
|
|
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
|
|
1622
|
-
for (const n of
|
|
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 =
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
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
|
|
1751
|
-
} catch (
|
|
1752
|
-
return console.error(`[RichTextEditor] Error executing native command ${t}:`,
|
|
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
|
|
1761
|
-
if (
|
|
1762
|
-
return
|
|
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
|
-
},
|
|
1783
|
+
}, i = [
|
|
1767
1784
|
t,
|
|
1768
1785
|
t.toLowerCase(),
|
|
1769
1786
|
...o[t] || []
|
|
1770
1787
|
];
|
|
1771
|
-
for (const
|
|
1772
|
-
const n = this.config[
|
|
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
|
|
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(
|
|
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
|
|
1862
|
-
|
|
1863
|
-
const
|
|
1864
|
-
for (;
|
|
1865
|
-
|
|
1866
|
-
o.insertNode(
|
|
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"]'),
|
|
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
|
|
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((
|
|
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(
|
|
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 (
|
|
1899
|
-
console.warn("defaultParagraphSeparator not supported:",
|
|
1915
|
+
} catch (r) {
|
|
1916
|
+
console.warn("defaultParagraphSeparator not supported:", r);
|
|
1900
1917
|
}
|
|
1901
1918
|
if (e) {
|
|
1902
|
-
const
|
|
1903
|
-
|
|
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)),
|
|
1913
|
-
var
|
|
1914
|
-
return (
|
|
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
|
|
1927
|
-
if (n.sanitizeOnInput !== !1 &&
|
|
1928
|
-
const l = $(o,
|
|
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
|
-
|
|
1963
|
+
i.debounceInputMs > 0 ? this.contentChangeDebounceTimer = setTimeout(a, i.debounceInputMs) : a(), this.updateStatusBar();
|
|
1947
1964
|
}), this.contentElement.addEventListener("contextmenu", (o) => {
|
|
1948
|
-
const
|
|
1949
|
-
(
|
|
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
|
|
1954
|
-
let
|
|
1955
|
-
const n = ((g = o.clipboardData) == null ? void 0 : g.getData("text/plain")) || "", a = this.getContentSanitizeConfig(), l = this.getSecurityConfig(), c = !!
|
|
1956
|
-
if ((
|
|
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 (
|
|
1977
|
+
if (i.convertWord === !1 && c && n) {
|
|
1961
1978
|
document.execCommand("insertText", !1, n);
|
|
1962
1979
|
return;
|
|
1963
1980
|
}
|
|
1964
|
-
if (
|
|
1965
|
-
l.sanitizeOnPaste !== !1 && a.sanitize !== !1 && (
|
|
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, (
|
|
1978
|
-
this.executeCommand(
|
|
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(),
|
|
1983
|
-
this.getPerformanceConfig().viewportOnlyScan && !this.isEditorInViewport() && !
|
|
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((
|
|
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
|
|
2028
|
-
if (!
|
|
2044
|
+
const i = window.getSelection();
|
|
2045
|
+
if (!i) {
|
|
2029
2046
|
this.floatingToolbar.hide();
|
|
2030
2047
|
return;
|
|
2031
2048
|
}
|
|
2032
|
-
const
|
|
2033
|
-
if (!
|
|
2049
|
+
const r = this.getSelectionAnchorRect(i, o);
|
|
2050
|
+
if (!r) {
|
|
2034
2051
|
this.floatingToolbar.hide();
|
|
2035
2052
|
return;
|
|
2036
2053
|
}
|
|
2037
|
-
this.floatingToolbar.show(
|
|
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:
|
|
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:
|
|
2055
|
-
charCount:
|
|
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,
|
|
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(), (
|
|
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-
|
|
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(
|
|
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
|
|
2226
|
-
|
|
2227
|
-
}), t.forEach((o,
|
|
2228
|
-
o instanceof f && !o.isInitialized && e[
|
|
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 {
|