@editora/core 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-B1_vtXRz.mjs +3910 -0
  48. package/dist/index-C6BoNR2t.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2039 -473
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2208 -641
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -1,2341 +0,0 @@
1
- class v {
2
- constructor(t, e, o) {
3
- this.doc = t, this.selection = e, this.schema = o;
4
- }
5
- static create(t, e) {
6
- const o = e || t.node("doc", {}, [t.node("paragraph")]);
7
- return new v(o, { anchor: 0, head: 0 }, t);
8
- }
9
- apply(t, e) {
10
- return new v(t, e || this.selection, this.schema);
11
- }
12
- }
13
- class P {
14
- constructor(t, e) {
15
- this.nodes = new Map(Object.entries(t)), this.marks = new Map(Object.entries(e));
16
- }
17
- node(t, e, o) {
18
- return { type: t, attrs: e, content: o };
19
- }
20
- text(t, e) {
21
- return { type: "text", text: t, marks: e };
22
- }
23
- }
24
- class N {
25
- constructor() {
26
- this.plugins = [], this.pluginConfigs = /* @__PURE__ */ new Map();
27
- }
28
- register(t, e) {
29
- this.plugins.push(t), e && this.pluginConfigs.set(t.name, e);
30
- const o = this.pluginConfigs.get(t.name) || t.config;
31
- if (t.initialize)
32
- try {
33
- t.initialize(o);
34
- } catch (n) {
35
- console.error(`Failed to initialize plugin "${t.name}":`, n);
36
- }
37
- if (t.init && t.init !== t.initialize)
38
- try {
39
- t.init(o);
40
- } catch (n) {
41
- console.error(`Failed to run init hook for plugin "${t.name}":`, n);
42
- }
43
- }
44
- unregister(t) {
45
- const e = this.plugins.findIndex((o) => o.name === t);
46
- if (e > -1) {
47
- const o = this.plugins[e];
48
- o.destroy && o.destroy(), this.plugins.splice(e, 1), this.pluginConfigs.delete(t);
49
- }
50
- }
51
- getPlugin(t) {
52
- return this.plugins.find((e) => e.name === t);
53
- }
54
- getPluginConfig(t) {
55
- return this.pluginConfigs.get(t);
56
- }
57
- buildSchema() {
58
- const t = {}, e = {};
59
- return this.plugins.forEach((o) => {
60
- o.nodes && Object.assign(t, o.nodes), o.marks && Object.assign(e, o.marks);
61
- }), new P(t, e);
62
- }
63
- getCommands() {
64
- const t = {};
65
- return this.plugins.forEach((e) => {
66
- e.commands && Object.assign(t, e.commands);
67
- }), t;
68
- }
69
- getToolbarItems() {
70
- return this.plugins.flatMap((t) => t.toolbar || []);
71
- }
72
- /**
73
- * Execute plugin command with mode awareness
74
- */
75
- async executePluginCommand(t, e, ...o) {
76
- const n = this.getPlugin(t);
77
- if (!n)
78
- throw new Error(`Plugin not found: ${t}`);
79
- const i = this.getPluginConfig(t) || n.config || {}, r = i.mode || "local";
80
- try {
81
- switch (r) {
82
- case "local":
83
- return n.executeLocal ? n.executeLocal(e, ...o) : null;
84
- case "api":
85
- if (!n.executeAPI)
86
- throw new Error(`Plugin ${t} does not support API mode`);
87
- return await n.executeAPI(e, ...o);
88
- case "hybrid":
89
- if (n.executeHybrid)
90
- return await n.executeHybrid(e, ...o);
91
- try {
92
- if (n.executeAPI)
93
- return await n.executeAPI(e, ...o);
94
- } catch (a) {
95
- if (console.warn(`API execution failed for ${t}, falling back to local`, a), n.executeLocal && i.fallbackToLocal !== !1)
96
- return n.executeLocal(e, ...o);
97
- throw a;
98
- }
99
- break;
100
- default:
101
- throw new Error(`Unknown plugin mode: ${r}`);
102
- }
103
- } catch (a) {
104
- throw console.error(`Error executing command ${e} on plugin ${t}:`, a), a;
105
- }
106
- }
107
- /**
108
- * Destroy all plugins
109
- */
110
- async destroyAll() {
111
- const t = this.plugins.filter((e) => e.destroy).map((e) => e.destroy());
112
- await Promise.all(t), this.plugins = [], this.pluginConfigs.clear();
113
- }
114
- }
115
- class O {
116
- constructor(t) {
117
- this.shortcuts = /* @__PURE__ */ new Map(), this.enabled = !0, this.isMac = typeof navigator != "undefined" && navigator.platform.toUpperCase().indexOf("MAC") >= 0, (t == null ? void 0 : t.enabled) === !1 && (this.enabled = !1), this.registerDefaultShortcuts(), t != null && t.shortcuts && t.shortcuts.forEach((e) => this.registerShortcut(e)), t != null && t.customShortcuts && Object.values(t.customShortcuts).forEach((e) => {
118
- this.registerShortcut(e);
119
- });
120
- }
121
- registerDefaultShortcuts() {
122
- this.registerShortcut({
123
- key: "b",
124
- ctrl: !this.isMac,
125
- meta: this.isMac,
126
- command: "toggleBold",
127
- description: "Bold",
128
- preventDefault: !0
129
- }), this.registerShortcut({
130
- key: "i",
131
- ctrl: !this.isMac,
132
- meta: this.isMac,
133
- command: "toggleItalic",
134
- description: "Italic",
135
- preventDefault: !0
136
- }), this.registerShortcut({
137
- key: "u",
138
- ctrl: !this.isMac,
139
- meta: this.isMac,
140
- command: "toggleUnderline",
141
- description: "Underline",
142
- preventDefault: !0
143
- }), this.registerShortcut({
144
- key: "d",
145
- ctrl: !this.isMac,
146
- meta: this.isMac,
147
- command: "toggleStrikethrough",
148
- description: "Strikethrough",
149
- preventDefault: !0
150
- }), this.registerShortcut({
151
- key: "z",
152
- ctrl: !this.isMac,
153
- meta: this.isMac,
154
- command: "undo",
155
- description: "Undo",
156
- preventDefault: !0
157
- }), this.registerShortcut({
158
- key: "z",
159
- ctrl: !this.isMac,
160
- meta: this.isMac,
161
- shift: !0,
162
- command: "redo",
163
- description: "Redo",
164
- preventDefault: !0
165
- }), this.registerShortcut({
166
- key: "y",
167
- ctrl: !this.isMac,
168
- meta: this.isMac,
169
- command: "redo",
170
- description: "Redo",
171
- preventDefault: !0
172
- });
173
- for (let t = 1; t <= 6; t++)
174
- this.registerShortcut({
175
- key: String(t),
176
- ctrl: !this.isMac,
177
- meta: this.isMac,
178
- alt: !0,
179
- command: "setBlockType",
180
- params: `h${t}`,
181
- description: `Heading ${t}`,
182
- preventDefault: !0
183
- });
184
- this.registerShortcut({
185
- key: "7",
186
- ctrl: !this.isMac,
187
- meta: this.isMac,
188
- alt: !0,
189
- command: "setBlockType",
190
- params: "p",
191
- description: "Paragraph",
192
- preventDefault: !0
193
- }), this.registerShortcut({
194
- key: "7",
195
- ctrl: !this.isMac,
196
- meta: this.isMac,
197
- shift: !0,
198
- command: "toggleOrderedList",
199
- description: "Numbered List",
200
- preventDefault: !0
201
- }), this.registerShortcut({
202
- key: "8",
203
- ctrl: !this.isMac,
204
- meta: this.isMac,
205
- shift: !0,
206
- command: "toggleBulletList",
207
- description: "Bullet List",
208
- preventDefault: !0
209
- }), this.registerShortcut({
210
- key: "k",
211
- ctrl: !this.isMac,
212
- meta: this.isMac,
213
- command: "openLinkDialog",
214
- description: "Insert/Edit Link",
215
- preventDefault: !0
216
- }), this.registerShortcut({
217
- key: "e",
218
- ctrl: !this.isMac,
219
- meta: this.isMac,
220
- alt: !0,
221
- command: "insertCodeBlock",
222
- description: "Code Block",
223
- preventDefault: !0
224
- }), this.registerShortcut({
225
- key: "q",
226
- ctrl: !this.isMac,
227
- meta: this.isMac,
228
- shift: !0,
229
- command: "toggleBlockquote",
230
- description: "Blockquote",
231
- preventDefault: !0
232
- }), this.registerShortcut({
233
- key: "l",
234
- ctrl: !this.isMac,
235
- meta: this.isMac,
236
- shift: !0,
237
- command: "setTextAlignment",
238
- params: "left",
239
- description: "Align Left",
240
- preventDefault: !0
241
- }), this.registerShortcut({
242
- key: "e",
243
- ctrl: !this.isMac,
244
- meta: this.isMac,
245
- shift: !0,
246
- alt: !0,
247
- command: "setTextAlignment",
248
- params: "center",
249
- description: "Align Center",
250
- preventDefault: !0
251
- }), this.registerShortcut({
252
- key: "r",
253
- ctrl: !this.isMac,
254
- meta: this.isMac,
255
- shift: !0,
256
- command: "setTextAlignment",
257
- params: "right",
258
- description: "Align Right",
259
- preventDefault: !0
260
- }), this.registerShortcut({
261
- key: "j",
262
- ctrl: !this.isMac,
263
- meta: this.isMac,
264
- shift: !0,
265
- command: "setTextAlignment",
266
- params: "justify",
267
- description: "Justify",
268
- preventDefault: !0
269
- }), this.registerShortcut({
270
- key: "\\",
271
- ctrl: !this.isMac,
272
- meta: this.isMac,
273
- command: "clearFormatting",
274
- description: "Clear Formatting",
275
- preventDefault: !0
276
- }), this.registerShortcut({
277
- key: "]",
278
- ctrl: !this.isMac,
279
- meta: this.isMac,
280
- command: "increaseIndent",
281
- description: "Indent",
282
- preventDefault: !0
283
- }), this.registerShortcut({
284
- key: "[",
285
- ctrl: !this.isMac,
286
- meta: this.isMac,
287
- command: "decreaseIndent",
288
- description: "Outdent",
289
- preventDefault: !0
290
- }), this.registerShortcut({
291
- key: "g",
292
- ctrl: !this.isMac,
293
- meta: this.isMac,
294
- shift: !0,
295
- command: "insertImage",
296
- description: "Insert Image",
297
- preventDefault: !0
298
- }), this.registerShortcut({
299
- key: "t",
300
- ctrl: !this.isMac,
301
- meta: this.isMac,
302
- shift: !0,
303
- alt: !0,
304
- command: "insertTable",
305
- description: "Insert Table",
306
- preventDefault: !0
307
- }), this.registerShortcut({
308
- key: "f11",
309
- command: "toggleFullscreen",
310
- description: "Toggle Fullscreen",
311
- preventDefault: !0
312
- }), this.registerShortcut({
313
- key: "p",
314
- ctrl: !this.isMac,
315
- meta: this.isMac,
316
- shift: !0,
317
- command: "togglePreview",
318
- description: "Preview",
319
- preventDefault: !0
320
- }), this.registerShortcut({
321
- key: "p",
322
- ctrl: !this.isMac,
323
- meta: this.isMac,
324
- command: "print",
325
- description: "Print",
326
- preventDefault: !0
327
- }), this.registerShortcut({
328
- key: "s",
329
- ctrl: !this.isMac,
330
- meta: this.isMac,
331
- shift: !0,
332
- alt: !0,
333
- command: "insertSpecialCharacter",
334
- description: "Insert Special Character",
335
- preventDefault: !0
336
- }), this.registerShortcut({
337
- key: "m",
338
- ctrl: !this.isMac,
339
- meta: this.isMac,
340
- shift: !0,
341
- command: "insertEmoji",
342
- description: "Insert Emoji",
343
- preventDefault: !0
344
- }), this.registerShortcut({
345
- key: "9",
346
- ctrl: !this.isMac,
347
- meta: this.isMac,
348
- shift: !0,
349
- command: "toggleChecklist",
350
- description: "Checklist",
351
- preventDefault: !0
352
- }), this.registerShortcut({
353
- key: "a",
354
- ctrl: !this.isMac,
355
- meta: this.isMac,
356
- shift: !0,
357
- alt: !0,
358
- command: "toggleA11yChecker",
359
- description: "Accessibility Checker",
360
- preventDefault: !0
361
- }), this.registerShortcut({
362
- key: "F7",
363
- command: "toggleSpellCheck",
364
- description: "Spell Check",
365
- preventDefault: !0
366
- }), this.registerShortcut({
367
- key: "m",
368
- ctrl: !this.isMac,
369
- meta: this.isMac,
370
- alt: !0,
371
- command: "insertMath",
372
- description: "Insert Math",
373
- preventDefault: !0
374
- }), this.registerShortcut({
375
- key: "f",
376
- ctrl: !this.isMac,
377
- meta: this.isMac,
378
- alt: !0,
379
- command: "insertFootnote",
380
- description: "Insert Footnote",
381
- preventDefault: !0
382
- });
383
- }
384
- registerShortcut(t) {
385
- const e = this.getShortcutKey(t);
386
- this.shortcuts.set(e, t);
387
- }
388
- unregisterShortcut(t) {
389
- const e = this.getShortcutKey(t);
390
- this.shortcuts.delete(e);
391
- }
392
- getShortcutKey(t) {
393
- const e = [];
394
- return t.ctrl && e.push("ctrl"), t.alt && e.push("alt"), t.shift && e.push("shift"), t.meta && e.push("meta"), e.push(t.key.toLowerCase()), e.join("+");
395
- }
396
- getEventKey(t) {
397
- const e = [];
398
- return t.ctrlKey && e.push("ctrl"), t.altKey && e.push("alt"), t.shiftKey && e.push("shift"), t.metaKey && e.push("meta"), e.push(t.key.toLowerCase()), e.join("+");
399
- }
400
- handleKeyDown(t, e) {
401
- if (!this.enabled) return !1;
402
- const o = this.getEventKey(t), n = this.shortcuts.get(o);
403
- return n ? (n.preventDefault !== !1 && (t.preventDefault(), t.stopPropagation()), e(n.command, n.params), !0) : !1;
404
- }
405
- enable() {
406
- this.enabled = !0;
407
- }
408
- disable() {
409
- this.enabled = !1;
410
- }
411
- isEnabled() {
412
- return this.enabled;
413
- }
414
- getAllShortcuts() {
415
- return Array.from(this.shortcuts.values());
416
- }
417
- getShortcutForCommand(t) {
418
- return Array.from(this.shortcuts.values()).find((e) => e.command === t);
419
- }
420
- getShortcutDescription(t) {
421
- const e = [];
422
- this.isMac ? (t.meta && e.push("⌘"), t.ctrl && e.push("⌃"), t.alt && e.push("⌥"), t.shift && e.push("⇧")) : (t.ctrl && e.push("Ctrl"), t.alt && e.push("Alt"), t.shift && e.push("Shift"));
423
- const o = t.key.length === 1 ? t.key.toUpperCase() : t.key;
424
- return e.push(o), e.join("+");
425
- }
426
- getShortcutsHelp() {
427
- const t = this.getAllShortcuts(), e = /* @__PURE__ */ new Map();
428
- t.forEach((n) => {
429
- const i = this.getShortcutCategory(n.command);
430
- e.has(i) || e.set(i, []), e.get(i).push(n);
431
- });
432
- let o = `# Keyboard Shortcuts
433
-
434
- `;
435
- return e.forEach((n, i) => {
436
- o += `## ${i}
437
-
438
- `, n.forEach((r) => {
439
- const a = this.getShortcutDescription(r);
440
- o += `- **${a}**: ${r.description || r.command}
441
- `;
442
- }), o += `
443
- `;
444
- }), o;
445
- }
446
- getShortcutCategory(t) {
447
- return t.includes("toggle") && (t.includes("Bold") || t.includes("Italic") || t.includes("Underline") || t.includes("Strike") || t.includes("Code") || t.includes("Super") || t.includes("Sub")) ? "Text Formatting" : t.includes("Heading") || t.includes("Paragraph") ? "Block Formatting" : t.includes("List") || t.includes("Checklist") ? "Lists" : t.includes("Alignment") || t.includes("Indent") ? "Alignment & Indentation" : t.includes("undo") || t.includes("redo") ? "History" : t.includes("insert") ? "Insert" : t.includes("find") || t.includes("replace") ? "Find & Replace" : t.includes("Accessibility") || t.includes("spell") ? "Tools" : "Other";
448
- }
449
- }
450
- class B {
451
- constructor(t = {}) {
452
- this.commands = /* @__PURE__ */ new Map(), Object.entries(t).forEach(([e, o]) => {
453
- this.register(e, o);
454
- });
455
- }
456
- /**
457
- * Register a command
458
- */
459
- register(t, e) {
460
- this.commands.has(t) && console.warn(`Command ${t} is being overwritten`), this.commands.set(t, e);
461
- }
462
- /**
463
- * Unregister a command
464
- */
465
- unregister(t) {
466
- this.commands.delete(t);
467
- }
468
- /**
469
- * Get a command handler
470
- */
471
- get(t) {
472
- return this.commands.get(t);
473
- }
474
- /**
475
- * Check if command exists
476
- */
477
- has(t) {
478
- return this.commands.has(t);
479
- }
480
- /**
481
- * Get all command names
482
- */
483
- getCommandNames() {
484
- return Array.from(this.commands.keys());
485
- }
486
- /**
487
- * Clear all commands
488
- */
489
- clear() {
490
- this.commands.clear();
491
- }
492
- }
493
- class z {
494
- constructor(t = {}) {
495
- this.listeners = /* @__PURE__ */ new Map(), this.isReadonly = !1, this.isDestroyed = !1, this.isReadonly = t.readonly || !1, this.pluginManager = new N(), t.plugins && Array.isArray(t.plugins) && t.plugins.forEach((o) => this.pluginManager.register(o));
496
- const e = this.pluginManager.buildSchema();
497
- this.state = v.create(e), this.commandRegistry = new B(this.pluginManager.getCommands());
498
- }
499
- /**
500
- * Execute a command
501
- */
502
- execCommand(t, ...e) {
503
- if (this.isReadonly)
504
- return console.warn("Cannot execute commands in readonly mode"), !1;
505
- if (this.isDestroyed)
506
- return console.warn("Cannot execute commands on destroyed editor"), !1;
507
- const o = this.commandRegistry.get(t);
508
- if (!o)
509
- return console.warn(`Command not found: ${t}`), !1;
510
- let n;
511
- return e.length === 0 ? n = o(this.state) : e.length === 1 ? n = o(this.state, e[0]) : n = o(this.state, ...e), n instanceof Promise ? (n.then((i) => {
512
- i && typeof i == "object" && "doc" in i && "selection" in i && (this.setState(i), this.emit("change", this.state));
513
- }).catch((i) => {
514
- console.error(`Async command failed: ${t}`, i);
515
- }), !0) : n && typeof n == "object" && "doc" in n && "selection" in n ? (this.setState(n), this.emit("change", this.state), !0) : n !== !1 && n != null;
516
- }
517
- /**
518
- * Update editor state
519
- */
520
- setState(t) {
521
- this.isDestroyed || (this.state = t, this.emit("stateChange", t));
522
- }
523
- /**
524
- * Get current state
525
- */
526
- getState() {
527
- return this.state;
528
- }
529
- /**
530
- * Set readonly mode
531
- */
532
- setReadonly(t) {
533
- this.isReadonly = t, this.emit("readonlyChange", t);
534
- }
535
- /**
536
- * Check if readonly
537
- */
538
- isReadOnly() {
539
- return this.isReadonly;
540
- }
541
- /**
542
- * Event emitter
543
- */
544
- on(t, e) {
545
- return this.listeners.has(t) || this.listeners.set(t, []), this.listeners.get(t).push(e), () => {
546
- const o = this.listeners.get(t);
547
- if (o) {
548
- const n = o.indexOf(e);
549
- n > -1 && o.splice(n, 1);
550
- }
551
- };
552
- }
553
- /**
554
- * Emit event
555
- */
556
- emit(t, ...e) {
557
- const o = this.listeners.get(t);
558
- o && o.forEach((n) => {
559
- try {
560
- n(...e);
561
- } catch (i) {
562
- console.error(`Error in ${t} handler:`, i);
563
- }
564
- });
565
- }
566
- /**
567
- * Destroy editor instance
568
- */
569
- destroy() {
570
- this.isDestroyed || (this.isDestroyed = !0, this.listeners.clear(), this.emit("destroy"));
571
- }
572
- /**
573
- * Check if destroyed
574
- */
575
- isEditorDestroyed() {
576
- return this.isDestroyed;
577
- }
578
- }
579
- class R {
580
- // PluginLoader instance to get all registered plugins
581
- setLastCommandTrigger(t, e) {
582
- if (typeof window == "undefined" || !t) return;
583
- const o = e || t.getAttribute("data-command") || void 0;
584
- o && (window.__editoraLastCommandButton = t, window.__editoraLastCommand = o);
585
- }
586
- constructor(t, e, o) {
587
- this.config = t, this.plugins = e, this.pluginLoader = o;
588
- }
589
- /**
590
- * Set command handler for toolbar buttons
591
- */
592
- setCommandHandler(t) {
593
- this.commandHandler = t;
594
- }
595
- /**
596
- * Parse toolbar string into button groups
597
- */
598
- parseToolbarString(t) {
599
- const e = [], o = t.split("|").map((a) => a.trim()), n = this.getAvailableToolbarItems(), i = /* @__PURE__ */ new Map();
600
- n.forEach((a) => {
601
- a.command && i.set(a.command, a), a.type === "group" && a.label && i.set(a.label, a);
602
- });
603
- const r = {
604
- bold: "toggleBold",
605
- italic: "toggleItalic",
606
- underline: "toggleUnderline",
607
- strikethrough: "toggleStrikethrough",
608
- bullist: "toggleBulletList",
609
- numlist: "toggleOrderedList",
610
- checklist: "toggleChecklist",
611
- link: "openLinkDialog",
612
- image: "openImageDialog",
613
- table: "insertTable",
614
- trackChanges: "toggleTrackChanges",
615
- acceptTrackChanges: "acceptAllTrackChanges",
616
- rejectTrackChanges: "rejectAllTrackChanges",
617
- anchor: "insertAnchor",
618
- code: "toggleSourceView",
619
- blockquote: "toggleBlockquote",
620
- undo: "undo",
621
- redo: "redo",
622
- textColor: "openTextColorPicker",
623
- backgroundColor: "openBackgroundColorPicker",
624
- fontSize: "fontSize",
625
- fontFamily: "setFontFamily",
626
- lineHeight: "setLineHeight",
627
- heading: "setBlockType",
628
- paragraph: "setParagraph",
629
- textAlignment: "setTextAlignment",
630
- direction: "setDirectionLTR",
631
- indent: "increaseIndent",
632
- outdent: "decreaseIndent",
633
- capitalization: "setCapitalization",
634
- math: "insertMath",
635
- specialCharacters: "insertSpecialCharacter",
636
- emojis: "openEmojiDialog",
637
- embedIframe: "openEmbedIframeDialog",
638
- fullscreen: "toggleFullscreen",
639
- preview: "togglePreview",
640
- print: "print",
641
- a11yChecker: "toggleA11yChecker",
642
- spellCheck: "toggleSpellCheck",
643
- comments: "addComment",
644
- showHideComments: "toggleComments",
645
- toggleComments: "toggleComments",
646
- footnote: "insertFootnote",
647
- mergeTags: "insertMergeTag",
648
- dataBinding: "openDataBindingDialog",
649
- dataBindingPreview: "openDataBindingDialog",
650
- contentRules: "toggleContentRulesPanel",
651
- contentRulesAudit: "runContentRulesAudit",
652
- contentRulesRealtime: "toggleContentRulesRealtime",
653
- mention: "insertMention",
654
- slash: "openSlashCommands",
655
- slashCommands: "openSlashCommands",
656
- pageBreak: "insertPageBreak",
657
- template: "insertTemplate",
658
- importWord: "importWord",
659
- exportWord: "exportWord",
660
- exportPdf: "exportPdf",
661
- insertImage: "insertImage",
662
- insertVideo: "insertVideo",
663
- codeBlock: "insertCodeBlock"
664
- };
665
- return o.forEach((a) => {
666
- const l = [];
667
- a.split(/\s+/).filter(Boolean).forEach((d) => {
668
- if (d === "direction") {
669
- const u = i.get("setDirectionLTR"), f = i.get("setDirectionRTL");
670
- u && l.push({
671
- id: "directionLTR",
672
- label: u.label,
673
- command: u.command,
674
- icon: u.icon,
675
- type: u.type || "button",
676
- options: u.options
677
- }), f && l.push({
678
- id: "directionRTL",
679
- label: f.label,
680
- command: f.command,
681
- icon: f.icon,
682
- type: f.type || "button",
683
- options: f.options
684
- });
685
- return;
686
- }
687
- if (d === "comments") {
688
- const u = i.get("addComment"), f = i.get("toggleComments");
689
- u && l.push({
690
- id: "addComment",
691
- label: u.label,
692
- command: u.command,
693
- icon: u.icon,
694
- type: u.type || "button",
695
- options: u.options
696
- }), f && l.push({
697
- id: "toggleComments",
698
- label: f.label,
699
- command: f.command,
700
- icon: f.icon,
701
- type: f.type || "button",
702
- options: f.options
703
- });
704
- return;
705
- }
706
- const h = r[d] || d;
707
- let p = i.get(h);
708
- p || (p = i.get(d)), p && l.push({
709
- id: d,
710
- label: p.label,
711
- command: p.command,
712
- icon: p.icon,
713
- type: p.type === "separator" ? "separator" : p.type || "button",
714
- options: p.options,
715
- items: p.items
716
- });
717
- }), l.length > 0 && e.push(l);
718
- }), e;
719
- }
720
- /**
721
- * Get all available toolbar items from plugins
722
- */
723
- getAvailableToolbarItems() {
724
- return this.plugins.flatMap((e) => e.toolbar || []);
725
- }
726
- /**
727
- * Render toolbar to DOM element
728
- */
729
- render(t) {
730
- 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}`);
731
- const e = this.config.items || this.getDefaultToolbarString(), o = this.parseToolbarString(e);
732
- o.forEach((n, i) => {
733
- const r = document.createElement("div");
734
- if (r.className = "editora-toolbar-group", n.forEach((a) => {
735
- this.appendToolbarButton(r, a);
736
- }), t.appendChild(r), i < o.length - 1) {
737
- const a = document.createElement("div");
738
- a.className = "editora-toolbar-separator", t.appendChild(a);
739
- }
740
- });
741
- }
742
- /**
743
- * Append a toolbar button or group to a parent element
744
- */
745
- appendToolbarButton(t, e) {
746
- if (e.type === "separator") {
747
- const o = document.createElement("div");
748
- o.className = "editora-toolbar-separator", t.appendChild(o);
749
- } else if (e.type === "dropdown") {
750
- const o = this.createDropdown(e);
751
- t.appendChild(o);
752
- } else if (e.type === "inline-menu") {
753
- const o = this.createInlineMenu(e);
754
- t.appendChild(o);
755
- } else if (e.type === "group" && e.items && e.items.length) {
756
- const o = this.createGroupButton(e);
757
- t.appendChild(o);
758
- } else if (e.type === "input") {
759
- const o = this.createInput(e);
760
- t.appendChild(o);
761
- } else {
762
- const o = this.createButton(e);
763
- t.appendChild(o);
764
- }
765
- }
766
- /**
767
- * Create a toolbar button element
768
- */
769
- createGroupButton(t) {
770
- const e = document.createElement("div"), o = t.label.toLowerCase().replace(/\s+/g, "-");
771
- if (e.className = `editora-toolbar-group-button ${o}`, e.title = t.label, t.icon)
772
- if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
773
- const n = document.createElement("span");
774
- n.className = "editora-toolbar-icon", n.innerHTML = t.icon, e.appendChild(n);
775
- } else
776
- e.innerHTML = t.icon;
777
- if (t.items && t.items.length) {
778
- const n = document.createElement("div");
779
- n.className = `editora-toolbar-group-items ${o}`, t.items.forEach((i) => {
780
- this.appendToolbarButton(n, i);
781
- }), e.appendChild(n);
782
- }
783
- return e;
784
- }
785
- /**
786
- * Create a toolbar button element
787
- */
788
- createInput(t) {
789
- const e = document.createElement("input");
790
- 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) => {
791
- o.preventDefault(), this.setLastCommandTrigger(e, t.command), this.commandHandler && t.command && this.commandHandler(t.command);
792
- }), e;
793
- }
794
- /**
795
- * Create a toolbar button element
796
- */
797
- createButton(t) {
798
- const e = document.createElement("button");
799
- if (e.className = "editora-toolbar-button", e.type = "button", e.title = t.label, t.command && e.setAttribute("data-command", t.command), t.icon)
800
- if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
801
- const o = document.createElement("span");
802
- o.className = "editora-toolbar-icon", o.innerHTML = t.icon, e.appendChild(o);
803
- } else
804
- e.innerHTML = t.icon;
805
- else
806
- e.textContent = t.label;
807
- return t.active && e.classList.add("active"), t.disabled && (e.disabled = !0), e.addEventListener("click", (o) => {
808
- o.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command);
809
- }), e;
810
- }
811
- /**
812
- * Create a dropdown element
813
- */
814
- createDropdown(t) {
815
- const e = document.createElement("div");
816
- e.className = "editora-toolbar-dropdown";
817
- const o = document.createElement("button");
818
- o.className = "editora-toolbar-button editora-toolbar-dropdown-trigger", o.type = "button", o.textContent = t.label;
819
- const n = document.createElement("div");
820
- n.className = "editora-toolbar-dropdown-menu", n.style.display = "none", t.options && t.options.forEach((a) => {
821
- const l = document.createElement("button");
822
- l.className = "editora-toolbar-dropdown-item", l.type = "button", l.textContent = a.label, l.setAttribute("data-value", a.value), l.addEventListener("click", (c) => {
823
- c.preventDefault(), this.setLastCommandTrigger(o, t.command), this.commandHandler && t.command && this.commandHandler(t.command, a.value), n.style.display = "none";
824
- }), n.appendChild(l);
825
- }), o.addEventListener("click", (a) => {
826
- a.preventDefault(), a.stopPropagation(), this.setLastCommandTrigger(o, t.command);
827
- const l = n.style.display === "block";
828
- n.style.display = l ? "none" : "block";
829
- });
830
- const i = (a) => {
831
- e.contains(a.target) || (n.style.display = "none");
832
- }, r = (a) => {
833
- a.key === "Escape" && (n.style.display = "none");
834
- };
835
- return document.addEventListener("mousedown", i, !0), document.addEventListener("keydown", r), e._cleanupDropdown = () => {
836
- document.removeEventListener("mousedown", i, !0), document.removeEventListener("keydown", r);
837
- }, e.appendChild(o), e.appendChild(n), e;
838
- }
839
- /**
840
- * Create an inline menu element (like dropdown but triggered by button click)
841
- */
842
- createInlineMenu(t) {
843
- const e = document.createElement("div");
844
- e.className = "editora-toolbar-dropdown editora-toolbar-inline-menu";
845
- const o = document.createElement("button");
846
- if (o.className = "editora-toolbar-button", o.type = "button", o.title = t.label, t.icon)
847
- if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
848
- const a = document.createElement("span");
849
- a.className = "editora-toolbar-icon", a.innerHTML = t.icon, o.appendChild(a);
850
- } else
851
- o.innerHTML = t.icon;
852
- else
853
- o.textContent = t.label;
854
- const n = document.createElement("div");
855
- n.className = "editora-toolbar-dropdown-menu", n.style.display = "none", t.options && t.options.forEach((a) => {
856
- const l = document.createElement("button");
857
- l.className = "editora-toolbar-dropdown-item", l.type = "button", l.textContent = a.label, l.setAttribute("data-value", a.value), l.addEventListener("click", (c) => {
858
- c.preventDefault(), c.stopPropagation(), this.setLastCommandTrigger(o, t.command), this.commandHandler && t.command && this.commandHandler(t.command, a.value), n.style.display = "none";
859
- }), n.appendChild(l);
860
- }), o.addEventListener("click", (a) => {
861
- var c;
862
- a.preventDefault(), a.stopPropagation(), this.setLastCommandTrigger(o, t.command);
863
- const l = (c = this.container) == null ? void 0 : c.querySelectorAll(
864
- ".editora-toolbar-dropdown-menu"
865
- );
866
- l == null || l.forEach((d) => {
867
- d !== n && (d.style.display = "none");
868
- }), n.style.display = n.style.display === "none" ? "block" : "none";
869
- });
870
- const i = (a) => {
871
- e.contains(a.target) || (n.style.display = "none");
872
- }, r = (a) => {
873
- a.key === "Escape" && (n.style.display = "none");
874
- };
875
- return document.addEventListener("mousedown", i, !0), document.addEventListener("keydown", r), e._cleanupDropdown = () => {
876
- document.removeEventListener("mousedown", i, !0), document.removeEventListener("keydown", r);
877
- }, e.appendChild(o), e.appendChild(n), e;
878
- }
879
- /**
880
- * Get default toolbar string if none provided
881
- */
882
- getDefaultToolbarString() {
883
- return this.getAvailableToolbarItems().map((e) => e.command).join(" ");
884
- }
885
- /**
886
- * Update button state
887
- */
888
- updateButtonState(t, e) {
889
- if (!this.container) return;
890
- const o = this.container.querySelector(
891
- `[data-command="${t}"]`
892
- );
893
- o && (e.active !== void 0 && o.classList.toggle("active", e.active), e.disabled !== void 0 && (o.disabled = e.disabled));
894
- }
895
- /**
896
- * Destroy toolbar
897
- */
898
- destroy() {
899
- this.container && (this.container.querySelectorAll(".editora-toolbar-dropdown").forEach((e) => {
900
- const o = e._cleanupDropdown;
901
- o && o();
902
- }), this.container.innerHTML = ""), this.commandHandler = void 0;
903
- }
904
- }
905
- class H {
906
- constructor(t) {
907
- this.visible = !1, this.config = t;
908
- }
909
- /**
910
- * Create and mount floating toolbar
911
- */
912
- create(t) {
913
- const e = document.createElement("div");
914
- return e.className = "editora-floating-toolbar", e.style.display = "none", e.style.position = "absolute", e.style.zIndex = "1000", this.container = e, t.appendChild(e), e;
915
- }
916
- /**
917
- * Show toolbar at position
918
- */
919
- show(t, e) {
920
- this.container && (this.container.style.display = "block", this.container.style.left = `${t}px`, this.container.style.top = `${e}px`, this.visible = !0);
921
- }
922
- /**
923
- * Hide toolbar
924
- */
925
- hide() {
926
- this.container && (this.container.style.display = "none", this.visible = !1);
927
- }
928
- /**
929
- * Update position
930
- */
931
- updatePosition(t, e) {
932
- !this.container || !this.visible || (this.container.style.left = `${t}px`, this.container.style.top = `${e}px`);
933
- }
934
- /**
935
- * Check if visible
936
- */
937
- isVisible() {
938
- return this.visible;
939
- }
940
- /**
941
- * Destroy floating toolbar
942
- */
943
- destroy() {
944
- this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = void 0, this.visible = !1;
945
- }
946
- }
947
- class j {
948
- constructor(t = {}) {
949
- this.statusInfo = {}, this.config = t;
950
- }
951
- /**
952
- * Create and mount status bar
953
- */
954
- create(t) {
955
- const e = document.createElement("div");
956
- return e.className = "editora-statusbar", this.config.position && e.classList.add(`editora-statusbar-${this.config.position}`), this.container = e, t.appendChild(e), e;
957
- }
958
- /**
959
- * Update status information
960
- */
961
- update(t) {
962
- this.statusInfo = { ...this.statusInfo, ...t }, this.render();
963
- }
964
- /**
965
- * Render status bar content
966
- */
967
- render() {
968
- if (!this.container) return;
969
- this.container.innerHTML = "";
970
- const t = document.createElement("div");
971
- t.className = "editora-statusbar-left";
972
- const e = document.createElement("div");
973
- e.className = "editora-statusbar-right";
974
- const o = [];
975
- if (this.statusInfo.selectionInfo) {
976
- const i = this.statusInfo.selectionInfo;
977
- 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`));
978
- } else if (this.statusInfo.cursorPosition) {
979
- const i = this.statusInfo.cursorPosition;
980
- o.push(`Ln ${i.line}, Col ${i.column}`);
981
- }
982
- this.statusInfo.language && o.push(this.statusInfo.language);
983
- const n = [];
984
- this.statusInfo.wordCount !== void 0 && n.push(`${this.statusInfo.wordCount} words`), this.statusInfo.charCount !== void 0 && n.push(`${this.statusInfo.charCount} chars`), this.statusInfo.lineCount !== void 0 && n.push(`${this.statusInfo.lineCount} lines`), this.statusInfo.custom && Object.entries(this.statusInfo.custom).forEach(([i, r]) => {
985
- n.push(`${i}: ${r}`);
986
- }), o.forEach((i, r) => {
987
- const a = document.createElement("span");
988
- if (a.className = "editora-statusbar-item", a.textContent = i, t.appendChild(a), r < o.length - 1) {
989
- const l = document.createElement("span");
990
- l.className = "editora-statusbar-separator", l.textContent = "|", t.appendChild(l);
991
- }
992
- }), n.forEach((i, r) => {
993
- const a = document.createElement("span");
994
- if (a.className = "editora-statusbar-item", a.textContent = i, e.appendChild(a), r < n.length - 1) {
995
- const l = document.createElement("span");
996
- l.className = "editora-statusbar-separator", l.textContent = "|", e.appendChild(l);
997
- }
998
- }), this.container.appendChild(t), this.container.appendChild(e);
999
- }
1000
- /**
1001
- * Destroy status bar
1002
- */
1003
- destroy() {
1004
- this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = void 0;
1005
- }
1006
- }
1007
- function F(s, t) {
1008
- const e = s.textContent || "", o = $(s, t.startContainer, t.startOffset), i = e.substring(0, o).split(`
1009
- `), r = i.length, a = i[i.length - 1].length + 1;
1010
- return { line: r, column: a };
1011
- }
1012
- function $(s, t, e) {
1013
- var r;
1014
- let o = 0;
1015
- const n = document.createTreeWalker(
1016
- s,
1017
- NodeFilter.SHOW_TEXT,
1018
- null
1019
- );
1020
- let i = n.firstChild();
1021
- for (; i; ) {
1022
- if (i === t) {
1023
- o += e;
1024
- break;
1025
- } else i.nodeType === Node.TEXT_NODE && (o += ((r = i.textContent) == null ? void 0 : r.length) || 0);
1026
- i = n.nextNode();
1027
- }
1028
- return o;
1029
- }
1030
- function _(s) {
1031
- var o, n;
1032
- const t = s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");
1033
- let e = 1;
1034
- if (t.length > 0) {
1035
- e = t.length;
1036
- const i = t[t.length - 1];
1037
- (i.tagName === "BR" || ((o = i.innerHTML) == null ? void 0 : o.trim()) === "" || ((n = i.textContent) == null ? void 0 : n.trim()) === "") && e++;
1038
- } else {
1039
- const r = (s.textContent || "").split(`
1040
- `).length;
1041
- e = Math.max(1, r);
1042
- }
1043
- return e;
1044
- }
1045
- function W(s) {
1046
- const t = s.trim() ? s.trim().split(/\s+/).length : 0, e = s.length;
1047
- return { words: t, chars: e };
1048
- }
1049
- function U(s, t) {
1050
- const e = s.toString();
1051
- return {
1052
- startLine: t.line,
1053
- startColumn: t.column,
1054
- endLine: t.line,
1055
- // For now, assuming single line selections
1056
- endColumn: t.column + e.length,
1057
- selectedChars: e.length,
1058
- selectedWords: e.trim().split(/\s+/).filter(Boolean).length
1059
- };
1060
- }
1061
- const E = class E {
1062
- /**
1063
- * Resolve configuration from multiple sources with priority
1064
- */
1065
- static resolve(t) {
1066
- const e = {};
1067
- if (Object.assign(e, this.EDITOR_DEFAULTS), t.pluginDefaults && Object.assign(e, t.pluginDefaults), t.attributes) {
1068
- const o = this.parseAttributes(t.attributes);
1069
- Object.assign(e, o);
1070
- }
1071
- return t.jsConfig && Object.assign(e, t.jsConfig), this.normalizeConfig(e);
1072
- }
1073
- /**
1074
- * Normalize mixed legacy/new config shapes
1075
- */
1076
- static normalizeConfig(t) {
1077
- const e = { ...t };
1078
- if (e.toolbarFloating !== void 0 || e.toolbarSticky !== void 0) {
1079
- const r = typeof e.toolbar == "object" && e.toolbar ? { ...e.toolbar } : typeof e.toolbar == "string" ? { items: e.toolbar } : {};
1080
- e.toolbarFloating !== void 0 && (r.floating = !!e.toolbarFloating), e.toolbarSticky !== void 0 && (r.sticky = !!e.toolbarSticky), e.toolbar = r;
1081
- }
1082
- if (e.toolbarItems !== void 0 && typeof e.toolbar == "object" && e.toolbar && (e.toolbar.items = e.toolbarItems), e.autosaveEnabled !== void 0 || e.autosaveIntervalMs !== void 0 || e.autosaveStorageKey !== void 0 || e.autosaveProvider !== void 0 || e.autosaveApiUrl !== void 0) {
1083
- const r = typeof e.autosave == "object" && e.autosave ? { ...e.autosave } : {};
1084
- e.autosaveEnabled !== void 0 && (r.enabled = !!e.autosaveEnabled), e.autosaveIntervalMs !== void 0 && (r.intervalMs = Number(e.autosaveIntervalMs)), e.autosaveStorageKey !== void 0 && (r.storageKey = e.autosaveStorageKey), e.autosaveProvider !== void 0 && (r.provider = e.autosaveProvider), e.autosaveApiUrl !== void 0 && (r.apiUrl = e.autosaveApiUrl), e.autosave = r;
1085
- }
1086
- const o = {
1087
- enabled: !1,
1088
- intervalMs: 3e4,
1089
- storageKey: "rte-autosave",
1090
- provider: "localStorage",
1091
- apiUrl: ""
1092
- };
1093
- if (typeof e.autosave == "boolean")
1094
- e.autosave = {
1095
- ...o,
1096
- enabled: e.autosave
1097
- };
1098
- else if (typeof e.autosave == "object" && e.autosave) {
1099
- const r = {
1100
- ...o,
1101
- ...e.autosave
1102
- };
1103
- r.intervalMs === void 0 && r.interval !== void 0 && (r.intervalMs = Number(r.interval)), r.enabled === void 0 && (r.enabled = !0), (!Number.isFinite(r.intervalMs) || r.intervalMs <= 0) && (r.intervalMs = o.intervalMs), e.autosave = r;
1104
- } else
1105
- e.autosave = o;
1106
- if (e.languageLocale !== void 0 || e.languageDirection !== void 0) {
1107
- const r = typeof e.language == "object" && e.language ? { ...e.language } : {};
1108
- e.languageLocale !== void 0 && (r.locale = e.languageLocale), e.languageDirection !== void 0 && (r.direction = e.languageDirection), e.language = r;
1109
- }
1110
- const n = { locale: "en", direction: "ltr" };
1111
- if (typeof e.language == "string" ? e.language = {
1112
- locale: e.language,
1113
- direction: n.direction
1114
- } : typeof e.language == "object" && e.language ? e.language = {
1115
- ...n,
1116
- ...e.language
1117
- } : e.language = n, e.spellcheckEnabled !== void 0 || e.spellcheckProvider !== void 0 || e.spellcheckApiUrl !== void 0) {
1118
- const r = typeof e.spellcheck == "object" && e.spellcheck ? { ...e.spellcheck } : {};
1119
- e.spellcheckEnabled !== void 0 && (r.enabled = !!e.spellcheckEnabled), e.spellcheckProvider !== void 0 && (r.provider = e.spellcheckProvider), e.spellcheckApiUrl !== void 0 && (r.apiUrl = e.spellcheckApiUrl), e.spellcheck = r;
1120
- }
1121
- const i = {
1122
- enabled: !1,
1123
- provider: "browser",
1124
- apiUrl: ""
1125
- };
1126
- if (typeof e.spellcheck == "boolean")
1127
- e.spellcheck = {
1128
- ...i,
1129
- enabled: e.spellcheck
1130
- };
1131
- else if (typeof e.spellcheck == "object" && e.spellcheck) {
1132
- const r = {
1133
- ...i,
1134
- ...e.spellcheck
1135
- };
1136
- !r.provider && r.mode && (r.provider = r.mode === "local" ? "browser" : "api"), r.enabled === void 0 && (r.enabled = !!(r.mode || r.provider || r.apiUrl)), e.spellcheck = r;
1137
- } else
1138
- e.spellcheck = i;
1139
- return e.contextMenuEnabled !== void 0 && (e.contextMenu = {
1140
- enabled: !!e.contextMenuEnabled
1141
- }), typeof e.contextMenu == "boolean" ? e.contextMenu = { enabled: e.contextMenu } : typeof e.contextMenu == "object" && e.contextMenu ? e.contextMenu = {
1142
- enabled: e.contextMenu.enabled !== !1
1143
- } : e.contextMenu = { enabled: !0 }, (e.pasteClean !== void 0 || e.pasteKeepFormatting !== void 0 || e.pasteConvertWord !== void 0) && (e.paste = {
1144
- ...e.paste || {},
1145
- ...e.pasteClean !== void 0 ? { clean: !!e.pasteClean } : {},
1146
- ...e.pasteKeepFormatting !== void 0 ? { keepFormatting: !!e.pasteKeepFormatting } : {},
1147
- ...e.pasteConvertWord !== void 0 ? { convertWord: !!e.pasteConvertWord } : {}
1148
- }), e.paste = {
1149
- clean: !0,
1150
- keepFormatting: !1,
1151
- convertWord: !0,
1152
- ...e.paste || {}
1153
- }, e.contentConfig = {
1154
- allowedTags: [],
1155
- allowedAttributes: {},
1156
- sanitize: !0,
1157
- ...e.contentConfig || {}
1158
- }, (e.securitySanitizeOnPaste !== void 0 || e.securitySanitizeOnInput !== void 0) && (e.security = {
1159
- ...e.security || {},
1160
- ...e.securitySanitizeOnPaste !== void 0 ? { sanitizeOnPaste: !!e.securitySanitizeOnPaste } : {},
1161
- ...e.securitySanitizeOnInput !== void 0 ? { sanitizeOnInput: !!e.securitySanitizeOnInput } : {}
1162
- }), e.security = {
1163
- sanitizeOnPaste: !0,
1164
- sanitizeOnInput: !0,
1165
- ...e.security || {}
1166
- }, (e.accessibilityEnableAria !== void 0 || e.accessibilityKeyboardNavigation !== void 0 || e.accessibilityChecker !== void 0) && (e.accessibility = {
1167
- ...e.accessibility || {},
1168
- ...e.accessibilityEnableAria !== void 0 ? { enableARIA: !!e.accessibilityEnableAria } : {},
1169
- ...e.accessibilityKeyboardNavigation !== void 0 ? { keyboardNavigation: !!e.accessibilityKeyboardNavigation } : {},
1170
- ...e.accessibilityChecker !== void 0 ? { checker: !!e.accessibilityChecker } : {}
1171
- }), typeof e.accessibility == "boolean" && (e.accessibility = {
1172
- enableARIA: e.accessibility,
1173
- keyboardNavigation: e.accessibility,
1174
- checker: !1
1175
- }), e.accessibility = {
1176
- enableARIA: !0,
1177
- keyboardNavigation: !0,
1178
- checker: !1,
1179
- ...e.accessibility || {}
1180
- }, (e.performanceDebounceInputMs !== void 0 || e.performanceViewportOnlyScan !== void 0) && (e.performance = {
1181
- ...e.performance || {},
1182
- ...e.performanceDebounceInputMs !== void 0 ? { debounceInputMs: Number(e.performanceDebounceInputMs) } : {},
1183
- ...e.performanceViewportOnlyScan !== void 0 ? { viewportOnlyScan: !!e.performanceViewportOnlyScan } : {}
1184
- }), typeof e.performance == "boolean" && (e.performance = {
1185
- debounceInputMs: 100,
1186
- viewportOnlyScan: e.performance
1187
- }), e.performance = {
1188
- debounceInputMs: 100,
1189
- viewportOnlyScan: !0,
1190
- ...e.performance || {}
1191
- }, (typeof e.performance.debounceInputMs != "number" || !Number.isFinite(e.performance.debounceInputMs) || e.performance.debounceInputMs < 0) && (e.performance.debounceInputMs = 100), e;
1192
- }
1193
- /**
1194
- * Parse web component attributes
1195
- */
1196
- static parseAttributes(t) {
1197
- const e = {};
1198
- for (const [o, n] of Object.entries(t)) {
1199
- const i = this.kebabToCamel(o);
1200
- e[i] = this.parseAttributeValue(n);
1201
- }
1202
- return e;
1203
- }
1204
- /**
1205
- * Parse attribute value to appropriate type
1206
- */
1207
- static parseAttributeValue(t) {
1208
- if (t === "true") return !0;
1209
- if (t === "false") return !1;
1210
- if (/^\d+$/.test(t)) return parseInt(t, 10);
1211
- if (/^\d+\.\d+$/.test(t)) return parseFloat(t);
1212
- if (t.startsWith("{") || t.startsWith("["))
1213
- try {
1214
- return JSON.parse(t);
1215
- } catch (e) {
1216
- return t;
1217
- }
1218
- return t;
1219
- }
1220
- /**
1221
- * Convert kebab-case to camelCase
1222
- */
1223
- static kebabToCamel(t) {
1224
- return t.replace(/-([a-z])/g, (e, o) => o.toUpperCase());
1225
- }
1226
- /**
1227
- * Validate configuration
1228
- */
1229
- static validate(t) {
1230
- const e = [];
1231
- return t.height !== void 0 && typeof t.height == "number" && t.height < 0 && e.push("height must be a positive number"), t.width !== void 0 && typeof t.width == "number" && t.width < 0 && e.push("width must be a positive number"), t.plugins !== void 0 && !Array.isArray(t.plugins) && typeof t.plugins != "string" && e.push("plugins must be an array or string"), t.theme !== void 0 && typeof t.theme != "string" && e.push("theme must be a string"), {
1232
- valid: e.length === 0,
1233
- errors: e
1234
- };
1235
- }
1236
- /**
1237
- * Get default configuration
1238
- */
1239
- static getDefaults() {
1240
- return { ...this.EDITOR_DEFAULTS };
1241
- }
1242
- /**
1243
- * Merge configurations (deep merge)
1244
- */
1245
- static merge(...t) {
1246
- const e = {};
1247
- for (const o of t)
1248
- for (const [n, i] of Object.entries(o))
1249
- i != null && (typeof i == "object" && !Array.isArray(i) && e[n] ? e[n] = this.merge(e[n], i) : e[n] = i);
1250
- return e;
1251
- }
1252
- };
1253
- E.EDITOR_DEFAULTS = {
1254
- height: 400,
1255
- width: "100%",
1256
- readonly: !1,
1257
- disabled: !1,
1258
- menubar: !0,
1259
- toolbar: !0,
1260
- plugins: [],
1261
- theme: "light",
1262
- content: "",
1263
- placeholder: "Start typing...",
1264
- autofocus: !1,
1265
- autosave: !1,
1266
- accessibility: {
1267
- enableARIA: !0,
1268
- keyboardNavigation: !0,
1269
- checker: !1
1270
- },
1271
- performance: {
1272
- debounceInputMs: 100,
1273
- viewportOnlyScan: !0
1274
- },
1275
- spellcheck: {
1276
- enabled: !1,
1277
- provider: "browser",
1278
- apiUrl: ""
1279
- },
1280
- language: {
1281
- locale: "en",
1282
- direction: "ltr"
1283
- },
1284
- contextMenu: {
1285
- enabled: !0
1286
- },
1287
- contentConfig: {
1288
- allowedTags: [],
1289
- allowedAttributes: {},
1290
- sanitize: !0
1291
- },
1292
- paste: {
1293
- clean: !0,
1294
- keepFormatting: !1,
1295
- convertWord: !0
1296
- },
1297
- security: {
1298
- sanitizeOnPaste: !0,
1299
- sanitizeOnInput: !0
1300
- },
1301
- statusbar: !1
1302
- };
1303
- let x = E;
1304
- class K {
1305
- constructor() {
1306
- this.loadedPlugins = /* @__PURE__ */ new Map(), this.pluginRegistry = /* @__PURE__ */ new Map();
1307
- }
1308
- /**
1309
- * Register a plugin factory (sync or async)
1310
- */
1311
- register(t, e) {
1312
- this.pluginRegistry.set(t, e);
1313
- }
1314
- /**
1315
- * Load a plugin by name (async)
1316
- */
1317
- async load(t, e) {
1318
- if (this.loadedPlugins.has(t))
1319
- return this.loadedPlugins.get(t);
1320
- const o = this.pluginRegistry.get(t);
1321
- if (!o)
1322
- return console.warn(`Plugin not found: ${t}`), null;
1323
- const n = await o();
1324
- return e && this.applyPluginConfig(n, e), this.loadedPlugins.set(t, n), n;
1325
- }
1326
- /**
1327
- * Load multiple plugins
1328
- */
1329
- async loadMultiple(t, e) {
1330
- return (await Promise.all(
1331
- t.map((n) => this.load(n, e))
1332
- )).filter((n) => n !== null);
1333
- }
1334
- /**
1335
- * Parse plugin string "lists link image media"
1336
- */
1337
- async parsePluginString(t, e) {
1338
- const o = t.split(/\s+/).filter(Boolean);
1339
- return this.loadMultiple(o, e);
1340
- }
1341
- /**
1342
- * Apply configuration to plugin
1343
- */
1344
- applyPluginConfig(t, e) {
1345
- t.__pluginConfig = e;
1346
- }
1347
- /**
1348
- * Unload a plugin
1349
- */
1350
- unload(t) {
1351
- this.loadedPlugins.delete(t);
1352
- }
1353
- /**
1354
- * Clear all loaded plugins
1355
- */
1356
- clear() {
1357
- this.loadedPlugins.clear();
1358
- }
1359
- /**
1360
- * Get all loaded plugins
1361
- */
1362
- getLoadedPlugins() {
1363
- return Array.from(this.loadedPlugins.values());
1364
- }
1365
- /**
1366
- * Get all registered plugin names (available for loading)
1367
- */
1368
- getRegisteredPluginNames() {
1369
- return Array.from(this.pluginRegistry.keys());
1370
- }
1371
- /**
1372
- * Check if plugin is loaded
1373
- */
1374
- isLoaded(t) {
1375
- return this.loadedPlugins.has(t);
1376
- }
1377
- }
1378
- const q = [
1379
- "p",
1380
- "br",
1381
- "strong",
1382
- "em",
1383
- "u",
1384
- "s",
1385
- "strike",
1386
- "del",
1387
- "b",
1388
- "i",
1389
- "h1",
1390
- "h2",
1391
- "h3",
1392
- "h4",
1393
- "h5",
1394
- "h6",
1395
- "ul",
1396
- "ol",
1397
- "li",
1398
- "a",
1399
- "img",
1400
- "video",
1401
- "audio",
1402
- "iframe",
1403
- "table",
1404
- "thead",
1405
- "tbody",
1406
- "tr",
1407
- "th",
1408
- "td",
1409
- "blockquote",
1410
- "pre",
1411
- "code",
1412
- "span",
1413
- "div",
1414
- "section",
1415
- "sup",
1416
- "sub",
1417
- "hr"
1418
- ], V = {
1419
- "*": ["class", "style", "id", "data-*", "role", "aria-*", "tabindex", "contenteditable", "spellcheck", "dir", "lang"],
1420
- a: ["href", "target", "rel", "title"],
1421
- img: ["src", "alt", "width", "height", "loading"],
1422
- video: ["src", "controls", "width", "height", "autoplay", "loop", "muted"],
1423
- audio: ["src", "controls", "autoplay", "loop", "muted"],
1424
- iframe: ["src", "width", "height", "name", "title", "longdesc", "allow", "allowfullscreen", "frameborder", "scrolling", "loading", "referrerpolicy"],
1425
- table: ["border", "cellpadding", "cellspacing"],
1426
- td: ["colspan", "rowspan", "align", "valign"],
1427
- th: ["colspan", "rowspan", "align", "valign"]
1428
- };
1429
- function M(s, t, e) {
1430
- if ((t == null ? void 0 : t.sanitize) === !1)
1431
- return s;
1432
- const o = t != null && t.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : q, i = !!(t != null && t.allowedAttributes) && Object.keys(t.allowedAttributes).length > 0 ? t.allowedAttributes : V, r = document.createElement("div");
1433
- return r.innerHTML = s, I(r, o, i), r.innerHTML;
1434
- }
1435
- function I(s, t, e) {
1436
- const o = Array.from(s.childNodes);
1437
- for (const n of o)
1438
- if (n.nodeType === Node.ELEMENT_NODE) {
1439
- const i = n, r = i.tagName.toLowerCase();
1440
- if (!t.includes(r)) {
1441
- for (; i.firstChild; )
1442
- s.insertBefore(i.firstChild, i);
1443
- s.removeChild(i);
1444
- continue;
1445
- }
1446
- G(i, e), I(i, t, e);
1447
- } else n.nodeType !== Node.TEXT_NODE && s.removeChild(n);
1448
- }
1449
- function G(s, t) {
1450
- const e = s.tagName.toLowerCase(), o = Array.from(s.attributes), n = t[e] || [], i = t["*"] || [], r = [...n, ...i];
1451
- for (const a of o) {
1452
- const l = a.name.toLowerCase();
1453
- let c = !1;
1454
- r.includes(l) && (c = !0);
1455
- for (const d of r)
1456
- if (d.endsWith("*")) {
1457
- const h = d.slice(0, -1);
1458
- if (l.startsWith(h)) {
1459
- c = !0;
1460
- break;
1461
- }
1462
- }
1463
- (l.startsWith("on") || l === "javascript:" || l === "href" && a.value.trim().toLowerCase().startsWith("javascript:") || l === "src" && a.value.trim().toLowerCase().startsWith("javascript:")) && (c = !1), l === "dir" && !["ltr", "rtl", "auto"].includes(a.value.trim().toLowerCase()) && (c = !1), c || s.removeAttribute(a.name);
1464
- }
1465
- s.hasAttribute("href") && (s.getAttribute("href") || "").trim().toLowerCase().startsWith("javascript:") && s.removeAttribute("href"), s.hasAttribute("src") && (s.getAttribute("src") || "").trim().toLowerCase().startsWith("javascript:") && s.removeAttribute("src");
1466
- }
1467
- function X(s, t, e) {
1468
- return (e == null ? void 0 : e.sanitizeOnPaste) === !1 ? s : M(s, t);
1469
- }
1470
- function Y(s, t, e) {
1471
- return (e == null ? void 0 : e.sanitizeOnInput) === !1 ? s : M(s, t);
1472
- }
1473
- const J = '.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor;fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';
1474
- let y;
1475
- const Q = "__editoraCommandEditorRoot", Z = "__editoraLastCommandButton", S = "editora-editor, [data-editora-editor], .rte-editor, .editora-editor", T = ".rte-content, .editora-content", C = /* @__PURE__ */ new Set();
1476
- let g = null, A = !1, k = null, w = null;
1477
- function L(s) {
1478
- if (!(s instanceof HTMLElement)) return !1;
1479
- const t = s;
1480
- return typeof t.execCommand == "function" && (t.tagName.toLowerCase() === "editora-editor" || t.classList.contains("editora-editor") || t.hasAttribute("data-editora-editor"));
1481
- }
1482
- function tt(s) {
1483
- return s ? s.nodeType === Node.ELEMENT_NODE ? s : s.parentElement : null;
1484
- }
1485
- function b(s) {
1486
- if (!s) return null;
1487
- if (L(s))
1488
- return s;
1489
- const t = s.matches(S) ? s : s.closest(S);
1490
- return !t || !L(t) ? null : t;
1491
- }
1492
- function et() {
1493
- var n;
1494
- if (typeof window == "undefined") return null;
1495
- const s = window[Q];
1496
- if (s instanceof HTMLElement) {
1497
- const i = b(s);
1498
- if (i) return i;
1499
- const r = s.matches(T) ? s : s.querySelector(T);
1500
- if (r) {
1501
- const a = b(r);
1502
- if (a) return a;
1503
- }
1504
- }
1505
- const t = window[Z];
1506
- if (t instanceof HTMLElement) {
1507
- const i = b(t);
1508
- if (i) return i;
1509
- }
1510
- const e = document.activeElement;
1511
- if (e) {
1512
- const i = b(e);
1513
- if (i) return i;
1514
- }
1515
- const o = (n = window.getSelection) == null ? void 0 : n.call(window);
1516
- if (o && o.rangeCount > 0) {
1517
- const i = b(tt(o.getRangeAt(0).startContainer));
1518
- if (i) return i;
1519
- }
1520
- if (g && g.isConnected)
1521
- return g;
1522
- for (const i of C)
1523
- if (i.isConnected) return i;
1524
- return null;
1525
- }
1526
- function ot() {
1527
- if (typeof window == "undefined" || A) return;
1528
- k = typeof window.executeEditorCommand == "function" ? window.executeEditorCommand.bind(window) : null, w = typeof window.execEditorCommand == "function" ? window.execEditorCommand.bind(window) : null;
1529
- const s = (t, ...e) => {
1530
- const o = et();
1531
- return o ? o.execCommand(t, ...e) : k ? k(t, ...e) : w ? w(t, ...e) : !1;
1532
- };
1533
- window.executeEditorCommand = s, window.execEditorCommand = s, A = !0;
1534
- }
1535
- function it() {
1536
- const s = "editora-webcomponent-styles";
1537
- if (!document.getElementById(s)) {
1538
- const t = document.createElement("style");
1539
- t.id = s, t.textContent = J, document.head.appendChild(t);
1540
- }
1541
- }
1542
- function D() {
1543
- if (!y) {
1544
- const s = m.__globalPluginLoader;
1545
- s ? y = s : y = new K();
1546
- }
1547
- return y;
1548
- }
1549
- function nt(s) {
1550
- const t = D();
1551
- Object.entries(s).forEach(([e, o]) => {
1552
- t.register(e, o);
1553
- });
1554
- }
1555
- class m extends HTMLElement {
1556
- constructor() {
1557
- if (super(), this.pluginLoader = D(), this.config = {}, this.isInitialized = !1, this.keyboardShortcutManager = new O(), this.lastAutosavedContent = "", this.loadedPlugins = [], this.lastBeforeInputType = null, it(), !this.hasAttribute("data-initial-content")) {
1558
- const t = this.innerHTML.trim();
1559
- t && this.setAttribute("data-initial-content", t);
1560
- }
1561
- }
1562
- // Observed attributes for reactive updates
1563
- static get observedAttributes() {
1564
- return [
1565
- "height",
1566
- "width",
1567
- "menubar",
1568
- "plugins",
1569
- "toolbar",
1570
- "toolbar-items",
1571
- "toolbar-floating",
1572
- "toolbar-sticky",
1573
- "readonly",
1574
- "disabled",
1575
- "theme",
1576
- "placeholder",
1577
- "autofocus",
1578
- "autosave",
1579
- "autosave-enabled",
1580
- "autosave-interval-ms",
1581
- "autosave-storage-key",
1582
- "autosave-provider",
1583
- "autosave-api-url",
1584
- "accessibility",
1585
- "accessibility-enable-aria",
1586
- "accessibility-keyboard-navigation",
1587
- "accessibility-checker",
1588
- "performance",
1589
- "performance-debounce-input-ms",
1590
- "performance-viewport-only-scan",
1591
- "language",
1592
- "language-locale",
1593
- "language-direction",
1594
- "spellcheck",
1595
- "spellcheck-enabled",
1596
- "spellcheck-provider",
1597
- "context-menu",
1598
- "context-menu-enabled",
1599
- "paste",
1600
- "paste-clean",
1601
- "paste-keep-formatting",
1602
- "paste-convert-word",
1603
- "security",
1604
- "security-sanitize-on-paste",
1605
- "security-sanitize-on-input",
1606
- "statusbar"
1607
- ];
1608
- }
1609
- /**
1610
- * Called when element is added to DOM
1611
- */
1612
- connectedCallback() {
1613
- this.config = this.resolveConfig(), this.waitForPluginLoader().then(() => {
1614
- setTimeout(async () => {
1615
- await this.initialize();
1616
- }, 0);
1617
- });
1618
- }
1619
- /**
1620
- * Wait for the global plugin loader to be available
1621
- */
1622
- async waitForPluginLoader() {
1623
- if (m.__globalPluginLoader) {
1624
- this.pluginLoader = m.__globalPluginLoader;
1625
- return;
1626
- }
1627
- return new Promise((t) => {
1628
- const e = () => {
1629
- m.__globalPluginLoader ? (this.pluginLoader = m.__globalPluginLoader, t()) : setTimeout(e, 0);
1630
- };
1631
- e();
1632
- });
1633
- }
1634
- /**
1635
- * Called when element is removed from DOM
1636
- */
1637
- disconnectedCallback() {
1638
- this.destroy();
1639
- }
1640
- /**
1641
- * Called when an observed attribute changes
1642
- */
1643
- attributeChangedCallback(t, e, o) {
1644
- e !== o && (this.config = this.resolveConfig(), this.handleAttributeChange(t, o));
1645
- }
1646
- /**
1647
- * Set configuration via JavaScript API
1648
- */
1649
- async setConfig(t) {
1650
- this.jsConfig = t, this.config = this.resolveConfig(), this.isConnected && (this.destroy(), await this.waitForPluginLoader(), await this.initialize());
1651
- }
1652
- /**
1653
- * Initialize the editor
1654
- */
1655
- async initialize() {
1656
- var o;
1657
- if (this.querySelector(".editora-toolbar") || this.isInitialized) return;
1658
- this.setAttribute("data-editora-editor", "true"), C.add(this), g || (g = this), ot(), 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}`);
1659
- const t = await this.loadPlugins();
1660
- this.loadedPlugins = t, t.forEach((n) => {
1661
- if (n.init && typeof n.init == "function")
1662
- try {
1663
- n.init({ editorElement: this });
1664
- } catch (i) {
1665
- console.error(`[RichTextEditor] Error initializing plugin ${n.name}:`, i);
1666
- }
1667
- });
1668
- const e = (o = this.restoreAutosavedContent()) != null ? o : this.getAttribute("data-initial-content") || "";
1669
- this.engine = new z({
1670
- content: e,
1671
- plugins: t,
1672
- readonly: this.config.readonly
1673
- }), this.createUI(t, e), this.setupEventListeners(), this.startAutosave(), this.isInitialized = !0, this.dispatchEvent(new CustomEvent("editor-ready", {
1674
- detail: { api: this.getAPI() },
1675
- bubbles: !0
1676
- }));
1677
- }
1678
- /**
1679
- * Get initial content from slot or attribute
1680
- */
1681
- getInitialContent() {
1682
- if (this.config.content)
1683
- return this.config.content;
1684
- const t = this.querySelector("[slot]");
1685
- return t ? t.innerHTML : this.hasChildNodes() ? Array.from(this.childNodes).map((o) => o.nodeType === Node.TEXT_NODE ? o.textContent : o.nodeType === Node.ELEMENT_NODE ? o.outerHTML : "").join("").trim() : "";
1686
- }
1687
- /**
1688
- * Load plugins based on configuration
1689
- */
1690
- async loadPlugins() {
1691
- this.pluginLoader || await this.waitForPluginLoader();
1692
- 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), n = this.getAccessibilityConfig().checker === !0;
1693
- if (e) {
1694
- if (typeof this.config.plugins == "string") {
1695
- const i = this.config.plugins.split(/\s+/).filter(Boolean);
1696
- n && !i.includes("a11yChecker") && i.push("a11yChecker");
1697
- for (const r of i) {
1698
- const a = await this.pluginLoader.load(r, this.getPluginLoadConfig(r));
1699
- a && t.push(a);
1700
- }
1701
- } else if (Array.isArray(this.config.plugins)) {
1702
- for (const i of this.config.plugins)
1703
- if (typeof i == "string") {
1704
- const r = await this.pluginLoader.load(i, this.getPluginLoadConfig(i));
1705
- r && t.push(r);
1706
- } else
1707
- t.push(i);
1708
- if (n && !t.some((i) => (i == null ? void 0 : i.name) === "a11yChecker")) {
1709
- const i = await this.pluginLoader.load("a11yChecker", this.getPluginLoadConfig("a11yChecker"));
1710
- i && t.push(i);
1711
- }
1712
- }
1713
- } else {
1714
- const i = this.pluginLoader.getRegisteredPluginNames();
1715
- for (const r of i) {
1716
- const a = await this.pluginLoader.load(r, this.getPluginLoadConfig(r));
1717
- a && t.push(a);
1718
- }
1719
- }
1720
- return t;
1721
- }
1722
- resolveToolbarItems() {
1723
- const t = this.config.toolbarItems;
1724
- if (typeof t == "string") return t;
1725
- if (Array.isArray(t)) return t.join(" ");
1726
- const e = this.config.toolbar;
1727
- if (typeof e == "string") return e;
1728
- if (!e || typeof e != "object") return;
1729
- const o = e.items;
1730
- if (typeof o == "string") return o;
1731
- if (Array.isArray(o)) return o.join(" ");
1732
- }
1733
- isToolbarStickyEnabled() {
1734
- const t = this.config.toolbar;
1735
- return !t || typeof t != "object" ? !1 : !!t.sticky;
1736
- }
1737
- isToolbarFloatingEnabled() {
1738
- const t = this.config.toolbar;
1739
- return !t || typeof t != "object" ? !1 : !!t.floating;
1740
- }
1741
- isStatusbarEnabled() {
1742
- const t = this.config.statusbar;
1743
- return typeof t == "boolean" ? t : t && typeof t == "object" ? t.enabled !== !1 : !1;
1744
- }
1745
- getStatusbarPosition() {
1746
- const t = this.config.statusbar;
1747
- return t && typeof t == "object" && t.position === "top" ? "top" : "bottom";
1748
- }
1749
- getLanguageConfig() {
1750
- const t = this.config.language;
1751
- return typeof t == "string" ? { locale: t, direction: "ltr" } : t && typeof t == "object" ? {
1752
- locale: t.locale || "en",
1753
- direction: t.direction === "rtl" ? "rtl" : "ltr"
1754
- } : { locale: "en", direction: "ltr" };
1755
- }
1756
- getAccessibilityConfig() {
1757
- const t = this.config.accessibility;
1758
- return typeof t == "boolean" ? {
1759
- enableARIA: t,
1760
- keyboardNavigation: t,
1761
- checker: !1
1762
- } : t && typeof t == "object" ? {
1763
- enableARIA: t.enableARIA !== !1,
1764
- keyboardNavigation: t.keyboardNavigation !== !1,
1765
- checker: !!t.checker
1766
- } : {
1767
- enableARIA: !0,
1768
- keyboardNavigation: !0,
1769
- checker: !1
1770
- };
1771
- }
1772
- getPerformanceConfig() {
1773
- var e;
1774
- const t = this.config.performance;
1775
- if (typeof t == "boolean")
1776
- return {
1777
- debounceInputMs: 100,
1778
- viewportOnlyScan: t
1779
- };
1780
- if (t && typeof t == "object") {
1781
- const o = Number((e = t.debounceInputMs) != null ? e : 100);
1782
- return {
1783
- debounceInputMs: Number.isFinite(o) && o >= 0 ? o : 100,
1784
- viewportOnlyScan: t.viewportOnlyScan !== !1
1785
- };
1786
- }
1787
- return {
1788
- debounceInputMs: 100,
1789
- viewportOnlyScan: !0
1790
- };
1791
- }
1792
- isEditorInViewport() {
1793
- if (!this.contentElement || typeof window == "undefined") return !0;
1794
- const t = this.contentElement.getBoundingClientRect();
1795
- return t.bottom >= 0 && t.top <= window.innerHeight;
1796
- }
1797
- applyAccessibilitySettings() {
1798
- if (!this.contentElement) return;
1799
- const t = this.getAccessibilityConfig();
1800
- if (t.enableARIA) {
1801
- this.contentElement.setAttribute("role", "textbox"), this.contentElement.setAttribute("aria-multiline", "true"), this.contentElement.setAttribute("aria-disabled", this.config.readonly ? "true" : "false");
1802
- const e = typeof this.config.placeholder == "string" ? this.config.placeholder.trim() : "";
1803
- e ? this.contentElement.setAttribute("aria-label", e) : this.contentElement.removeAttribute("aria-label");
1804
- } else
1805
- this.contentElement.removeAttribute("role"), this.contentElement.removeAttribute("aria-multiline"), this.contentElement.removeAttribute("aria-disabled"), this.contentElement.removeAttribute("aria-label");
1806
- this.contentElement.tabIndex = t.keyboardNavigation ? 0 : -1;
1807
- }
1808
- applyLanguageSettings() {
1809
- if (!this.contentElement) return;
1810
- const t = this.getLanguageConfig();
1811
- this.contentElement.setAttribute("lang", t.locale), this.contentElement.setAttribute("dir", t.direction);
1812
- }
1813
- getSpellcheckConfig() {
1814
- const t = this.config.spellcheck;
1815
- if (typeof t == "boolean")
1816
- return {
1817
- enabled: t,
1818
- provider: "browser"
1819
- };
1820
- if (t && typeof t == "object") {
1821
- const e = t.provider || "browser";
1822
- return {
1823
- enabled: !!t.enabled,
1824
- provider: e,
1825
- mode: t.mode
1826
- };
1827
- }
1828
- return { enabled: !1, provider: "browser" };
1829
- }
1830
- applySpellcheckSettings() {
1831
- if (!this.contentElement) return;
1832
- const t = this.getSpellcheckConfig(), e = t.enabled && t.provider === "browser";
1833
- this.contentElement.spellcheck = e, this.contentElement.setAttribute("spellcheck", e ? "true" : "false");
1834
- }
1835
- executeCommand(t, ...e) {
1836
- var i;
1837
- typeof window != "undefined" && (window.__editoraCommandEditorRoot = this);
1838
- const o = {
1839
- editorElement: this,
1840
- contentElement: this.contentElement,
1841
- toolbarElement: this.toolbarElement
1842
- }, n = this.loadedPlugins.find((r) => r.commands && r.commands[t]);
1843
- if (n && n.commands) {
1844
- const r = n.commands[t];
1845
- if (typeof r == "function")
1846
- try {
1847
- return t === "toggleFullscreen" ? r(this, o) : r(...e, o), !0;
1848
- } catch (a) {
1849
- return console.error(`[RichTextEditor] Error executing native command ${t}:`, a), !1;
1850
- }
1851
- }
1852
- return ((i = this.engine) == null ? void 0 : i.execCommand(t, ...e)) || !1;
1853
- }
1854
- getPluginLoadConfig(t) {
1855
- const e = this.config.pluginConfig;
1856
- if (e && typeof e == "object") {
1857
- const i = e[t];
1858
- if (i && typeof i == "object")
1859
- return i;
1860
- }
1861
- const o = {
1862
- spellCheck: ["spellcheck", "spellCheck"],
1863
- trackChanges: ["trackchanges", "track-changes", "trackChanges"],
1864
- versionDiff: ["versiondiff", "version-diff", "versionDiff"],
1865
- "version-diff": ["versiondiff", "version-diff", "versionDiff"],
1866
- conditionalContent: ["conditionalcontent", "conditional-content", "conditionalContent"],
1867
- "conditional-content": ["conditionalcontent", "conditional-content", "conditionalContent"],
1868
- dataBinding: ["databinding", "data-binding", "dataBinding"],
1869
- "data-binding": ["databinding", "data-binding", "dataBinding"],
1870
- contentRules: ["contentrules", "content-rules", "contentRules"],
1871
- "content-rules": ["contentrules", "content-rules", "contentRules"],
1872
- mentions: ["mention", "mentions"],
1873
- mention: ["mention", "mentions"],
1874
- slashCommands: ["slashcommands", "slash-commands", "slashCommands"],
1875
- "slash-commands": ["slashcommands", "slash-commands", "slashCommands"],
1876
- formatPainter: ["formatpainter", "format-painter", "formatPainter"],
1877
- "format-painter": ["formatpainter", "format-painter", "formatPainter"]
1878
- }, n = [
1879
- t,
1880
- t.toLowerCase(),
1881
- ...o[t] || []
1882
- ];
1883
- for (const i of n) {
1884
- const r = this.config[i];
1885
- if (r && typeof r == "object" && !Array.isArray(r))
1886
- return r;
1887
- }
1888
- }
1889
- getContentSanitizeConfig() {
1890
- const t = this.config.contentConfig;
1891
- return t && typeof t == "object" ? t : { sanitize: !0 };
1892
- }
1893
- getSecurityConfig() {
1894
- const t = this.config.security;
1895
- return t && typeof t == "object" ? t : { sanitizeOnPaste: !0, sanitizeOnInput: !0 };
1896
- }
1897
- getAutosaveConfig() {
1898
- var e, o;
1899
- const t = this.config.autosave;
1900
- if (typeof t == "boolean")
1901
- return {
1902
- enabled: t,
1903
- intervalMs: 3e4,
1904
- storageKey: "rte-autosave",
1905
- provider: "localStorage"
1906
- };
1907
- if (t && typeof t == "object") {
1908
- const n = Number((o = (e = t.intervalMs) != null ? e : t.interval) != null ? o : 3e4);
1909
- return {
1910
- enabled: !!t.enabled,
1911
- intervalMs: Number.isFinite(n) && n > 0 ? n : 3e4,
1912
- storageKey: String(t.storageKey || "rte-autosave"),
1913
- provider: t.provider || "localStorage",
1914
- apiUrl: t.apiUrl
1915
- };
1916
- }
1917
- return {
1918
- enabled: !1,
1919
- intervalMs: 3e4,
1920
- storageKey: "rte-autosave",
1921
- provider: "localStorage"
1922
- };
1923
- }
1924
- persistAutosave(t) {
1925
- const e = this.getAutosaveConfig();
1926
- if (e.enabled && t !== this.lastAutosavedContent) {
1927
- if (this.lastAutosavedContent = t, e.provider === "localStorage") {
1928
- try {
1929
- localStorage.setItem(e.storageKey, t), localStorage.setItem(`${e.storageKey}-timestamp`, Date.now().toString());
1930
- } catch (o) {
1931
- console.error("[RichTextEditor] Failed to save autosave content to localStorage:", o);
1932
- }
1933
- return;
1934
- }
1935
- e.provider === "api" && e.apiUrl && fetch(e.apiUrl, {
1936
- method: "POST",
1937
- headers: { "Content-Type": "application/json" },
1938
- body: JSON.stringify({ content: t, timestamp: Date.now() })
1939
- }).catch((o) => {
1940
- console.error("[RichTextEditor] Failed to save autosave content to API:", o);
1941
- });
1942
- }
1943
- }
1944
- restoreAutosavedContent() {
1945
- const t = this.getAutosaveConfig();
1946
- if (!t.enabled || t.provider !== "localStorage") return null;
1947
- try {
1948
- const e = localStorage.getItem(t.storageKey);
1949
- if (e)
1950
- return this.lastAutosavedContent = e, e;
1951
- } catch (e) {
1952
- console.error("[RichTextEditor] Failed to restore autosaved content:", e);
1953
- }
1954
- return null;
1955
- }
1956
- stopAutosave() {
1957
- this.autosaveTimer && (clearInterval(this.autosaveTimer), this.autosaveTimer = void 0);
1958
- }
1959
- startAutosave() {
1960
- this.stopAutosave();
1961
- const t = this.getAutosaveConfig();
1962
- !t.enabled || !this.contentElement || (this.autosaveTimer = setInterval(() => {
1963
- var e;
1964
- this.persistAutosave(((e = this.contentElement) == null ? void 0 : e.innerHTML) || "");
1965
- }, t.intervalMs));
1966
- }
1967
- insertHTMLAtSelection(t) {
1968
- if (!this.contentElement) return;
1969
- const e = window.getSelection();
1970
- if (e && e.rangeCount > 0) {
1971
- const o = e.getRangeAt(0);
1972
- o.deleteContents();
1973
- const n = document.createElement("div");
1974
- n.innerHTML = t;
1975
- const i = document.createDocumentFragment();
1976
- for (; n.firstChild; )
1977
- i.appendChild(n.firstChild);
1978
- o.insertNode(i), o.collapse(!1), e.removeAllRanges(), e.addRange(o);
1979
- } else
1980
- this.contentElement.focus(), document.execCommand("insertHTML", !1, t);
1981
- }
1982
- /**
1983
- * Create UI elements
1984
- */
1985
- createUI(t, e) {
1986
- const o = this.querySelector('[slot="toolbar"]'), n = this.querySelector('[slot="statusbar"]');
1987
- 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 R(
1988
- {
1989
- items: this.resolveToolbarItems(),
1990
- sticky: this.isToolbarStickyEnabled(),
1991
- position: "top"
1992
- },
1993
- t,
1994
- this.pluginLoader
1995
- // Pass plugin loader to get all registered plugins
1996
- ), this.toolbar.setCommandHandler((i, r) => {
1997
- var a;
1998
- if (this.contentElement) {
1999
- this.contentElement.focus();
2000
- const l = window.getSelection();
2001
- if (!l || l.rangeCount === 0 || !this.contentElement.contains(l.anchorNode)) {
2002
- const c = document.createRange(), d = this.contentElement.lastChild || this.contentElement;
2003
- 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);
2004
- }
2005
- }
2006
- return this.executeCommand(i, r);
2007
- }), 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);
2008
- try {
2009
- document.execCommand("defaultParagraphSeparator", !1, "p");
2010
- } catch (i) {
2011
- console.warn("defaultParagraphSeparator not supported:", i);
2012
- }
2013
- if (e) {
2014
- const i = document.createElement("div");
2015
- i.innerHTML = e.trim(), !Array.from(i.childNodes).some((a) => {
2016
- if (a.nodeType === Node.ELEMENT_NODE) {
2017
- const l = a.tagName;
2018
- return ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "UL", "OL", "BLOCKQUOTE", "PRE"].includes(l);
2019
- }
2020
- return !1;
2021
- }) && e.trim() ? this.contentElement.innerHTML = `<p>${e.trim()}</p>` : this.contentElement.innerHTML = e;
2022
- } else
2023
- this.config.placeholder ? this.contentElement.innerHTML = "" : this.contentElement.innerHTML = "<p><br></p>";
2024
- this.appendChild(this.contentElement), this.isToolbarFloatingEnabled() && (this.floatingToolbar = new H({ enabled: !0 }), this.floatingToolbar.create(this)), n ? this.appendChild(n) : this.isStatusbarEnabled() && (this.statusBarElement = document.createElement("div"), this.statusBarElement.className = "editora-statusbar-container", this.appendChild(this.statusBarElement), this.statusBar = new j({ position: this.getStatusbarPosition() }), this.statusBar.create(this.statusBarElement)), this.config.autofocus && setTimeout(() => {
2025
- var i;
2026
- return (i = this.contentElement) == null ? void 0 : i.focus();
2027
- }, 0);
2028
- }
2029
- /**
2030
- * Setup event listeners
2031
- */
2032
- setupEventListeners() {
2033
- if (!this.contentElement || !this.engine) return;
2034
- const t = this.keyboardShortcutManager;
2035
- this.contentElement.addEventListener("beforeinput", (o) => {
2036
- this.lastBeforeInputType = o.inputType || null;
2037
- }), this.contentElement.addEventListener("input", () => {
2038
- if (!this.contentElement) return;
2039
- let o = this.contentElement.innerHTML;
2040
- const n = this.getPerformanceConfig(), i = this.getContentSanitizeConfig(), r = this.getSecurityConfig(), a = this.lastBeforeInputType;
2041
- if (this.lastBeforeInputType = null, r.sanitizeOnInput !== !1 && i.sanitize !== !1 && !a) {
2042
- const d = Y(o, i, r);
2043
- if (d !== o) {
2044
- const h = window.getSelection(), p = h && h.rangeCount > 0 ? h.getRangeAt(0) : null;
2045
- if (this.contentElement.innerHTML = d, p && h)
2046
- try {
2047
- h.removeAllRanges(), h.addRange(p);
2048
- } catch (u) {
2049
- }
2050
- o = d;
2051
- }
2052
- }
2053
- this.contentChangeDebounceTimer && clearTimeout(this.contentChangeDebounceTimer);
2054
- const c = () => {
2055
- this.dispatchEvent(new CustomEvent("content-change", {
2056
- detail: { html: o },
2057
- bubbles: !0
2058
- }));
2059
- };
2060
- n.debounceInputMs > 0 ? this.contentChangeDebounceTimer = setTimeout(c, n.debounceInputMs) : c(), this.updateStatusBar();
2061
- }), this.contentElement.addEventListener("contextmenu", (o) => {
2062
- const n = this.config.contextMenu;
2063
- (n === !1 || typeof n == "object" && n !== null && n.enabled === !1) && o.preventDefault();
2064
- }), this.contentElement.addEventListener("paste", (o) => {
2065
- var d, h;
2066
- if (o.__editoraSmartPasteHandled === !0 || o.defaultPrevented)
2067
- return;
2068
- o.preventDefault();
2069
- const n = this.config.paste || {};
2070
- let i = ((d = o.clipboardData) == null ? void 0 : d.getData("text/html")) || "";
2071
- const r = ((h = o.clipboardData) == null ? void 0 : h.getData("text/plain")) || "", a = this.getContentSanitizeConfig(), l = this.getSecurityConfig(), c = !!i && /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);
2072
- if ((n.clean || !n.keepFormatting) && r) {
2073
- document.execCommand("insertText", !1, r);
2074
- return;
2075
- }
2076
- if (n.convertWord === !1 && c && r) {
2077
- document.execCommand("insertText", !1, r);
2078
- return;
2079
- }
2080
- if (i) {
2081
- l.sanitizeOnPaste !== !1 && a.sanitize !== !1 && (i = X(i, a, l)), this.insertHTMLAtSelection(i);
2082
- return;
2083
- }
2084
- r && document.execCommand("insertText", !1, r);
2085
- }), this.contentElement.addEventListener("focus", () => {
2086
- g = this, this.dispatchEvent(new Event("editor-focus", { bubbles: !0 })), this.updateStatusBar();
2087
- }), this.contentElement.addEventListener("blur", () => {
2088
- this.contentChangeDebounceTimer && (clearTimeout(this.contentChangeDebounceTimer), this.contentChangeDebounceTimer = void 0), this.contentElement && this.dispatchEvent(new CustomEvent("content-change", {
2089
- detail: { html: this.contentElement.innerHTML },
2090
- bubbles: !0
2091
- })), this.dispatchEvent(new Event("editor-blur", { bubbles: !0 })), this.updateFloatingToolbar(), this.updateStatusBar();
2092
- }), this.contentElement.addEventListener("keydown", (o) => {
2093
- this.getAccessibilityConfig().keyboardNavigation && t.handleKeyDown(o, (i, r) => {
2094
- this.executeCommand(i, r);
2095
- });
2096
- });
2097
- const e = () => {
2098
- const o = this.getSelectionRangeInEditor(), n = document.activeElement, i = !!n && !!this.contentElement && (n === this.contentElement || this.contentElement.contains(n));
2099
- this.getPerformanceConfig().viewportOnlyScan && !this.isEditorInViewport() && !i || !o && !i || (this.updateFloatingToolbar(), this.updateStatusBar());
2100
- };
2101
- this.selectionChangeHandler = e, document.addEventListener("selectionchange", this.selectionChangeHandler);
2102
- }
2103
- getSelectionRangeInEditor() {
2104
- if (!this.contentElement) return null;
2105
- const t = window.getSelection();
2106
- if (!t || t.rangeCount === 0)
2107
- return null;
2108
- const e = t.getRangeAt(0), o = e.commonAncestorContainer;
2109
- return this.contentElement.contains(o) ? e : null;
2110
- }
2111
- isSelectionBackward(t) {
2112
- if (!t.anchorNode || !t.focusNode) return !1;
2113
- try {
2114
- const e = document.createRange();
2115
- return e.setStart(t.anchorNode, t.anchorOffset), e.setEnd(t.focusNode, t.focusOffset), e.collapsed;
2116
- } catch (e) {
2117
- return !1;
2118
- }
2119
- }
2120
- getSelectionAnchorRect(t, e) {
2121
- const o = Array.from(e.getClientRects()).filter((i) => i.width > 0 || i.height > 0);
2122
- return o.length === 0 ? e.getBoundingClientRect() : this.isSelectionBackward(t) ? o[0] : o[o.length - 1];
2123
- }
2124
- /**
2125
- * Update floating toolbar position
2126
- */
2127
- updateFloatingToolbar() {
2128
- if (!this.floatingToolbar || !this.contentElement) return;
2129
- if (this.config.readonly || this.contentElement.contentEditable === "false" || this.contentElement.getAttribute("data-readonly") === "true" || this.getAttribute("readonly") === "true" || this.getAttribute("data-readonly") === "true") {
2130
- this.floatingToolbar.hide();
2131
- return;
2132
- }
2133
- const e = this.getPerformanceConfig(), o = document.activeElement === this.contentElement || !!this.contentElement && this.contentElement.contains(document.activeElement);
2134
- if (e.viewportOnlyScan && !this.isEditorInViewport() && !o) {
2135
- this.floatingToolbar.hide();
2136
- return;
2137
- }
2138
- const n = this.getSelectionRangeInEditor();
2139
- if (!n) {
2140
- this.floatingToolbar.hide();
2141
- return;
2142
- }
2143
- if (n.collapsed) {
2144
- this.floatingToolbar.hide();
2145
- return;
2146
- }
2147
- const i = window.getSelection();
2148
- if (!i) {
2149
- this.floatingToolbar.hide();
2150
- return;
2151
- }
2152
- const r = this.getSelectionAnchorRect(i, n);
2153
- if (!r) {
2154
- this.floatingToolbar.hide();
2155
- return;
2156
- }
2157
- this.floatingToolbar.show(r.left, r.top - 40);
2158
- }
2159
- /**
2160
- * Update status bar with selection and cursor information
2161
- */
2162
- /**
2163
- * Update status bar with current content and cursor information
2164
- */
2165
- updateStatusBar() {
2166
- if (!this.statusBar || !this.contentElement) return;
2167
- const t = this.getPerformanceConfig(), e = document.activeElement === this.contentElement || this.contentElement.contains(document.activeElement);
2168
- if (t.viewportOnlyScan && !this.isEditorInViewport() && !e)
2169
- return;
2170
- const o = this.contentElement.textContent || "", { words: n, chars: i } = W(o), r = _(this.contentElement);
2171
- let a, l;
2172
- const c = this.getSelectionRangeInEditor();
2173
- c && (a = F(this.contentElement, c), c.collapsed || (l = U(c, a), a = void 0)), this.statusBar.update({
2174
- wordCount: n,
2175
- charCount: i,
2176
- lineCount: r,
2177
- cursorPosition: a,
2178
- selectionInfo: l
2179
- });
2180
- }
2181
- /**
2182
- * Handle attribute changes
2183
- */
2184
- handleAttributeChange(t, e) {
2185
- switch (t) {
2186
- case "readonly":
2187
- this.contentElement && (this.contentElement.contentEditable = e === "true" ? "false" : "true", this.applyAccessibilitySettings()), this.engine && this.engine.setReadonly(e === "true");
2188
- break;
2189
- case "theme":
2190
- this.classList.forEach((o) => {
2191
- o.startsWith("editora-theme-") && this.classList.remove(o);
2192
- }), e && this.classList.add(`editora-theme-${e}`);
2193
- break;
2194
- case "placeholder":
2195
- this.contentElement && (this.contentElement.setAttribute("data-placeholder", e), this.applyAccessibilitySettings());
2196
- break;
2197
- case "accessibility":
2198
- case "accessibility-enable-aria":
2199
- case "accessibility-keyboard-navigation":
2200
- case "accessibility-checker":
2201
- this.applyAccessibilitySettings();
2202
- break;
2203
- case "performance":
2204
- case "performance-debounce-input-ms":
2205
- case "performance-viewport-only-scan":
2206
- break;
2207
- case "language":
2208
- case "language-locale":
2209
- case "language-direction":
2210
- this.applyLanguageSettings();
2211
- break;
2212
- case "spellcheck":
2213
- case "spellcheck-enabled":
2214
- case "spellcheck-provider":
2215
- this.applySpellcheckSettings();
2216
- break;
2217
- case "autosave":
2218
- case "autosave-enabled":
2219
- case "autosave-interval-ms":
2220
- case "autosave-storage-key":
2221
- case "autosave-provider":
2222
- case "autosave-api-url":
2223
- this.startAutosave();
2224
- break;
2225
- case "security":
2226
- case "security-sanitize-on-paste":
2227
- case "security-sanitize-on-input":
2228
- case "paste":
2229
- case "paste-clean":
2230
- case "paste-keep-formatting":
2231
- case "paste-convert-word":
2232
- case "context-menu":
2233
- case "context-menu-enabled":
2234
- break;
2235
- case "toolbar":
2236
- case "toolbar-items":
2237
- case "toolbar-floating":
2238
- case "toolbar-sticky":
2239
- case "plugins":
2240
- case "statusbar":
2241
- this.isConnected && (this.destroy(), this.waitForPluginLoader().then(() => {
2242
- this.initialize().catch((o) => {
2243
- console.error("[RichTextEditor] Error during attribute change re-initialization:", o);
2244
- });
2245
- }));
2246
- break;
2247
- }
2248
- }
2249
- /**
2250
- * Resolve configuration from all sources
2251
- */
2252
- resolveConfig() {
2253
- const t = {};
2254
- for (let e = 0; e < this.attributes.length; e++) {
2255
- const o = this.attributes[e];
2256
- t[o.name] = o.value;
2257
- }
2258
- return x.resolve({
2259
- jsConfig: this.jsConfig,
2260
- attributes: t
2261
- });
2262
- }
2263
- /**
2264
- * Get public API
2265
- */
2266
- getAPI() {
2267
- return {
2268
- getContent: () => {
2269
- var t;
2270
- return ((t = this.contentElement) == null ? void 0 : t.innerHTML) || "";
2271
- },
2272
- setContent: (t) => {
2273
- this.contentElement && (this.contentElement.innerHTML = t);
2274
- },
2275
- execCommand: (t, e) => this.executeCommand(t, e),
2276
- focus: () => {
2277
- var t;
2278
- (t = this.contentElement) == null || t.focus();
2279
- },
2280
- blur: () => {
2281
- var t;
2282
- (t = this.contentElement) == null || t.blur();
2283
- },
2284
- destroy: () => {
2285
- this.destroy();
2286
- },
2287
- on: (t, e) => (this.addEventListener(t, e), () => this.removeEventListener(t, e)),
2288
- getConfig: () => ({ ...this.config }),
2289
- setReadonly: (t) => {
2290
- this.setAttribute("readonly", t.toString());
2291
- }
2292
- };
2293
- }
2294
- /**
2295
- * Destroy the editor
2296
- */
2297
- destroy() {
2298
- var t, e, o, n;
2299
- 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(), (n = this.statusBar) == null || n.destroy(), this.innerHTML = "", this.contentElement = void 0, this.toolbarElement = void 0, this.statusBarElement = void 0, this.loadedPlugins = [], this.isInitialized = !1, C.delete(this), g === this && (g = null), this.dispatchEvent(new Event("editor-destroy", { bubbles: !0 }));
2300
- }
2301
- // Public API methods
2302
- getContent() {
2303
- var t;
2304
- return ((t = this.contentElement) == null ? void 0 : t.innerHTML) || "";
2305
- }
2306
- setContent(t) {
2307
- this.contentElement && (this.contentElement.innerHTML = t);
2308
- }
2309
- execCommand(t, ...e) {
2310
- return this.executeCommand(t, ...e);
2311
- }
2312
- focus() {
2313
- var t;
2314
- (t = this.contentElement) == null || t.focus();
2315
- }
2316
- blur() {
2317
- var t;
2318
- (t = this.contentElement) == null || t.blur();
2319
- }
2320
- }
2321
- export {
2322
- B as C,
2323
- v as E,
2324
- H as F,
2325
- O as K,
2326
- N as P,
2327
- m as R,
2328
- P as S,
2329
- R as T,
2330
- z as a,
2331
- x as b,
2332
- K as c,
2333
- j as d,
2334
- W as e,
2335
- _ as f,
2336
- F as g,
2337
- U as h,
2338
- $ as i,
2339
- nt as j
2340
- };
2341
- //# sourceMappingURL=index-Cd9jEuZP.mjs.map