@editora/core 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +34 -0
  2. package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
  3. package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
  4. package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
  5. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
  6. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
  7. package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-0Zari_zp.mjs} +329 -310
  8. package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
  9. package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
  10. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
  11. package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
  12. package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
  13. package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
  14. package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
  15. package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
  16. package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
  17. package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
  18. package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
  19. package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
  20. package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
  21. package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
  22. package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
  23. package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
  24. package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
  25. package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
  26. package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
  27. package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
  28. package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
  29. package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
  30. package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
  31. package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
  32. package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
  33. package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
  34. package/dist/core.css +1 -1
  35. package/dist/editora.min.js +31 -29
  36. package/dist/editora.umd.js +31 -29
  37. package/dist/index-CqWQFb3D.js +10 -0
  38. package/dist/index-OwnkG39N.mjs +2227 -0
  39. package/dist/index.cjs.js +14 -18
  40. package/dist/index.esm.js +204 -521
  41. package/dist/plugin-loader.js +26 -26
  42. package/dist/webcomponent-core.js +1286 -295
  43. package/dist/webcomponent-core.min.css +1 -1
  44. package/dist/webcomponent-core.min.js +100 -75
  45. package/dist/webcomponent.cjs.js +1 -1
  46. package/dist/webcomponent.esm.js +1 -1
  47. package/dist/webcomponent.js +1252 -261
  48. package/dist/webcomponent.min.css +1 -1
  49. package/dist/webcomponent.min.js +3616 -2109
  50. package/index.d.ts +355 -0
  51. package/package.json +19 -17
  52. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
  53. package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
  54. package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
  55. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
  56. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
  57. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
  58. package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
  59. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
  60. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
  61. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
  62. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
  63. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
  64. package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
  65. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
  66. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
  67. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
  68. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
  69. package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
  70. package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
  71. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
  72. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
  73. package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
  74. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
  75. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
  76. package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
  77. package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
  78. package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
  79. package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
  80. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
  81. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
  82. package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
  83. package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
  84. package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
  85. package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
  86. package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
  87. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
  88. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
  89. package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
  90. package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
  91. package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
  92. package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
  93. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
  94. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
  95. package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
  96. package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
  97. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
  98. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
  99. package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
  100. package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
  101. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
  102. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
  103. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
  104. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
  105. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
  106. package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
  107. package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
  108. package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
  109. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
  110. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
  111. package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
  112. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
  113. package/dist/documentManager-irzj9n3V.mjs.map +0 -1
  114. package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
  115. package/dist/editora.min.js.map +0 -1
  116. package/dist/editora.umd.js.map +0 -1
  117. package/dist/index-BF5RBhL9.js +0 -4
  118. package/dist/index-BF5RBhL9.js.map +0 -1
  119. package/dist/index-BPsf460l.mjs +0 -1243
  120. package/dist/index-BPsf460l.mjs.map +0 -1
  121. package/dist/index.cjs.js.map +0 -1
  122. package/dist/index.es-CuicffkQ.mjs.map +0 -1
  123. package/dist/index.esm.js.map +0 -1
  124. package/dist/plugin-loader.js.map +0 -1
  125. package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
  126. package/dist/webcomponent-core.js.map +0 -1
  127. package/dist/webcomponent-core.min.js.map +0 -1
  128. package/dist/webcomponent.cjs.js.map +0 -1
  129. package/dist/webcomponent.esm.js.map +0 -1
  130. package/dist/webcomponent.js.map +0 -1
  131. package/dist/webcomponent.min.js.map +0 -1
@@ -0,0 +1,2227 @@
1
+ class b {
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 b(o, { anchor: 0, head: 0 }, t);
8
+ }
9
+ apply(t, e) {
10
+ return new b(t, e || this.selection, this.schema);
11
+ }
12
+ }
13
+ class C {
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 E {
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 (r) {
35
+ console.error(`Failed to initialize plugin "${t.name}":`, r);
36
+ }
37
+ if (t.init && t.init !== t.initialize)
38
+ try {
39
+ t.init(o);
40
+ } catch (r) {
41
+ console.error(`Failed to run init hook for plugin "${t.name}":`, r);
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 C(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 r = this.getPlugin(t);
77
+ if (!r)
78
+ throw new Error(`Plugin not found: ${t}`);
79
+ const i = this.getPluginConfig(t) || r.config || {}, a = i.mode || "local";
80
+ try {
81
+ switch (a) {
82
+ case "local":
83
+ return r.executeLocal ? r.executeLocal(e, ...o) : null;
84
+ case "api":
85
+ if (!r.executeAPI)
86
+ throw new Error(`Plugin ${t} does not support API mode`);
87
+ return await r.executeAPI(e, ...o);
88
+ case "hybrid":
89
+ if (r.executeHybrid)
90
+ return await r.executeHybrid(e, ...o);
91
+ try {
92
+ if (r.executeAPI)
93
+ return await r.executeAPI(e, ...o);
94
+ } catch (n) {
95
+ if (console.warn(`API execution failed for ${t}, falling back to local`, n), r.executeLocal && i.fallbackToLocal !== !1)
96
+ return r.executeLocal(e, ...o);
97
+ throw n;
98
+ }
99
+ break;
100
+ default:
101
+ throw new Error(`Unknown plugin mode: ${a}`);
102
+ }
103
+ } catch (n) {
104
+ throw console.error(`Error executing command ${e} on plugin ${t}:`, n), n;
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 S {
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), r = this.shortcuts.get(o);
403
+ return r ? (r.preventDefault !== !1 && (t.preventDefault(), t.stopPropagation()), e(r.command, r.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((r) => {
429
+ const i = this.getShortcutCategory(r.command);
430
+ e.has(i) || e.set(i, []), e.get(i).push(r);
431
+ });
432
+ let o = `# Keyboard Shortcuts
433
+
434
+ `;
435
+ return e.forEach((r, i) => {
436
+ o += `## ${i}
437
+
438
+ `, r.forEach((a) => {
439
+ const n = this.getShortcutDescription(a);
440
+ o += `- **${n}**: ${a.description || a.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 M {
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 A {
494
+ constructor(t = {}) {
495
+ this.listeners = /* @__PURE__ */ new Map(), this.isReadonly = !1, this.isDestroyed = !1, this.isReadonly = t.readonly || !1, this.pluginManager = new E(), t.plugins && Array.isArray(t.plugins) && t.plugins.forEach((o) => this.pluginManager.register(o));
496
+ const e = this.pluginManager.buildSchema();
497
+ this.state = b.create(e), this.commandRegistry = new M(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 r;
511
+ return e !== void 0 ? r = o(this.state, e) : r = o(this.state), r instanceof Promise ? (r.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) : r && typeof r == "object" && "doc" in r && "selection" in r ? (this.setState(r), this.emit("change", this.state), !0) : r !== !1 && r != 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 r = o.indexOf(e);
549
+ r > -1 && o.splice(r, 1);
550
+ }
551
+ };
552
+ }
553
+ /**
554
+ * Emit event
555
+ */
556
+ emit(t, ...e) {
557
+ const o = this.listeners.get(t);
558
+ o && o.forEach((r) => {
559
+ try {
560
+ r(...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 L {
580
+ // PluginLoader instance to get all registered plugins
581
+ constructor(t, e, o) {
582
+ this.config = t, this.plugins = e, this.pluginLoader = o;
583
+ }
584
+ /**
585
+ * Set command handler for toolbar buttons
586
+ */
587
+ setCommandHandler(t) {
588
+ this.commandHandler = t;
589
+ }
590
+ /**
591
+ * Parse toolbar string into button groups
592
+ */
593
+ parseToolbarString(t) {
594
+ const e = [], o = t.split("|").map((n) => n.trim()), r = this.getAvailableToolbarItems(), i = /* @__PURE__ */ new Map();
595
+ r.forEach((n) => {
596
+ n.command && i.set(n.command, n), n.type === "group" && n.label && i.set(n.label, n);
597
+ });
598
+ const a = {
599
+ bold: "toggleBold",
600
+ italic: "toggleItalic",
601
+ underline: "toggleUnderline",
602
+ strikethrough: "toggleStrikethrough",
603
+ bullist: "toggleBulletList",
604
+ numlist: "toggleOrderedList",
605
+ checklist: "toggleChecklist",
606
+ link: "openLinkDialog",
607
+ image: "openImageDialog",
608
+ table: "insertTable",
609
+ anchor: "insertAnchor",
610
+ code: "toggleSourceView",
611
+ blockquote: "toggleBlockquote",
612
+ undo: "undo",
613
+ redo: "redo",
614
+ textColor: "openTextColorPicker",
615
+ backgroundColor: "openBackgroundColorPicker",
616
+ fontSize: "fontSize",
617
+ fontFamily: "setFontFamily",
618
+ lineHeight: "setLineHeight",
619
+ heading: "setBlockType",
620
+ paragraph: "setParagraph",
621
+ textAlignment: "setTextAlignment",
622
+ direction: "setDirectionLTR",
623
+ indent: "increaseIndent",
624
+ outdent: "decreaseIndent",
625
+ capitalization: "setCapitalization",
626
+ math: "insertMath",
627
+ specialCharacters: "insertSpecialCharacter",
628
+ emojis: "openEmojiDialog",
629
+ embedIframe: "openEmbedIframeDialog",
630
+ fullscreen: "toggleFullscreen",
631
+ preview: "togglePreview",
632
+ print: "print",
633
+ a11yChecker: "toggleA11yChecker",
634
+ spellCheck: "toggleSpellCheck",
635
+ comments: "addComment",
636
+ showHideComments: "toggleComments",
637
+ toggleComments: "toggleComments",
638
+ footnote: "insertFootnote",
639
+ mergeTags: "insertMergeTag",
640
+ pageBreak: "insertPageBreak",
641
+ template: "insertTemplate",
642
+ importWord: "importWord",
643
+ exportWord: "exportWord",
644
+ exportPdf: "exportPdf",
645
+ insertImage: "insertImage",
646
+ insertVideo: "insertVideo",
647
+ codeBlock: "insertCodeBlock"
648
+ };
649
+ return o.forEach((n) => {
650
+ const l = [];
651
+ n.split(/\s+/).filter(Boolean).forEach((d) => {
652
+ if (d === "direction") {
653
+ const u = i.get("setDirectionLTR"), h = i.get("setDirectionRTL");
654
+ u && l.push({
655
+ id: "directionLTR",
656
+ label: u.label,
657
+ command: u.command,
658
+ icon: u.icon,
659
+ type: u.type || "button",
660
+ options: u.options
661
+ }), h && l.push({
662
+ id: "directionRTL",
663
+ label: h.label,
664
+ command: h.command,
665
+ icon: h.icon,
666
+ type: h.type || "button",
667
+ options: h.options
668
+ });
669
+ return;
670
+ }
671
+ if (d === "comments") {
672
+ const u = i.get("addComment"), h = i.get("toggleComments");
673
+ u && l.push({
674
+ id: "addComment",
675
+ label: u.label,
676
+ command: u.command,
677
+ icon: u.icon,
678
+ type: u.type || "button",
679
+ options: u.options
680
+ }), h && l.push({
681
+ id: "toggleComments",
682
+ label: h.label,
683
+ command: h.command,
684
+ icon: h.icon,
685
+ type: h.type || "button",
686
+ options: h.options
687
+ });
688
+ return;
689
+ }
690
+ const f = a[d] || d;
691
+ let p = i.get(f);
692
+ p || (p = i.get(d)), p && l.push({
693
+ id: d,
694
+ label: p.label,
695
+ command: p.command,
696
+ icon: p.icon,
697
+ type: p.type === "separator" ? "separator" : p.type || "button",
698
+ options: p.options,
699
+ items: p.items
700
+ });
701
+ }), l.length > 0 && e.push(l);
702
+ }), e;
703
+ }
704
+ /**
705
+ * Get all available toolbar items from plugins
706
+ */
707
+ getAvailableToolbarItems() {
708
+ return this.plugins.flatMap((e) => e.toolbar || []);
709
+ }
710
+ /**
711
+ * Render toolbar to DOM element
712
+ */
713
+ render(t) {
714
+ 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}`);
715
+ const e = this.config.items || this.getDefaultToolbarString(), o = this.parseToolbarString(e);
716
+ o.forEach((r, i) => {
717
+ const a = document.createElement("div");
718
+ if (a.className = "editora-toolbar-group", r.forEach((n) => {
719
+ this.appendToolbarButton(a, n);
720
+ }), t.appendChild(a), i < o.length - 1) {
721
+ const n = document.createElement("div");
722
+ n.className = "editora-toolbar-separator", t.appendChild(n);
723
+ }
724
+ });
725
+ }
726
+ /**
727
+ * Append a toolbar button or group to a parent element
728
+ */
729
+ appendToolbarButton(t, e) {
730
+ if (e.type === "separator") {
731
+ const o = document.createElement("div");
732
+ o.className = "editora-toolbar-separator", t.appendChild(o);
733
+ } else if (e.type === "dropdown") {
734
+ const o = this.createDropdown(e);
735
+ t.appendChild(o);
736
+ } else if (e.type === "inline-menu") {
737
+ const o = this.createInlineMenu(e);
738
+ t.appendChild(o);
739
+ } else if (e.type === "group" && e.items && e.items.length) {
740
+ const o = this.createGroupButton(e);
741
+ t.appendChild(o);
742
+ } else if (e.type === "input") {
743
+ const o = this.createInput(e);
744
+ t.appendChild(o);
745
+ } else {
746
+ const o = this.createButton(e);
747
+ t.appendChild(o);
748
+ }
749
+ }
750
+ /**
751
+ * Create a toolbar button element
752
+ */
753
+ createGroupButton(t) {
754
+ const e = document.createElement("div");
755
+ if (e.className = "editora-toolbar-group-button", e.title = t.label, t.icon)
756
+ if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
757
+ const o = document.createElement("span");
758
+ o.className = "editora-toolbar-icon", o.innerHTML = t.icon, e.appendChild(o);
759
+ } else
760
+ e.innerHTML = t.icon;
761
+ if (t.items && t.items.length) {
762
+ const o = document.createElement("div");
763
+ o.className = "editora-toolbar-group-items", t.items.forEach((r) => {
764
+ this.appendToolbarButton(o, r);
765
+ }), e.appendChild(o);
766
+ }
767
+ return e;
768
+ }
769
+ /**
770
+ * Create a toolbar button element
771
+ */
772
+ createInput(t) {
773
+ const e = document.createElement("input");
774
+ 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) => {
775
+ o.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command);
776
+ }), e;
777
+ }
778
+ /**
779
+ * Create a toolbar button element
780
+ */
781
+ createButton(t) {
782
+ const e = document.createElement("button");
783
+ if (e.className = "editora-toolbar-button", e.type = "button", e.title = t.label, t.command && e.setAttribute("data-command", t.command), t.icon)
784
+ if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
785
+ const o = document.createElement("span");
786
+ o.className = "editora-toolbar-icon", o.innerHTML = t.icon, e.appendChild(o);
787
+ } else
788
+ e.innerHTML = t.icon;
789
+ else
790
+ e.textContent = t.label;
791
+ return t.active && e.classList.add("active"), t.disabled && (e.disabled = !0), e.addEventListener("click", (o) => {
792
+ o.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command);
793
+ }), e;
794
+ }
795
+ /**
796
+ * Create a dropdown element
797
+ */
798
+ createDropdown(t) {
799
+ const e = document.createElement("div");
800
+ e.className = "editora-toolbar-dropdown";
801
+ const o = document.createElement("button");
802
+ o.className = "editora-toolbar-button editora-toolbar-dropdown-trigger", o.type = "button", o.textContent = t.label;
803
+ const r = document.createElement("div");
804
+ r.className = "editora-toolbar-dropdown-menu", r.style.display = "none", t.options && t.options.forEach((a) => {
805
+ const n = document.createElement("button");
806
+ n.className = "editora-toolbar-dropdown-item", n.type = "button", n.textContent = a.label, n.setAttribute("data-value", a.value), n.addEventListener("click", (l) => {
807
+ l.preventDefault(), this.commandHandler && t.command && this.commandHandler(t.command, a.value), r.style.display = "none";
808
+ }), r.appendChild(n);
809
+ }), o.addEventListener("click", (a) => {
810
+ a.preventDefault(), a.stopPropagation();
811
+ const n = r.style.display === "block";
812
+ r.style.display = n ? "none" : "block";
813
+ });
814
+ const i = (a) => {
815
+ e.contains(a.target) || (r.style.display = "none");
816
+ };
817
+ return document.addEventListener("click", i), e._cleanupDropdown = () => {
818
+ document.removeEventListener("click", i);
819
+ }, e.appendChild(o), e.appendChild(r), e;
820
+ }
821
+ /**
822
+ * Create an inline menu element (like dropdown but triggered by button click)
823
+ */
824
+ createInlineMenu(t) {
825
+ const e = document.createElement("div");
826
+ e.className = "editora-toolbar-dropdown editora-toolbar-inline-menu";
827
+ const o = document.createElement("button");
828
+ if (o.className = "editora-toolbar-button", o.type = "button", o.title = t.label, t.icon)
829
+ if (t.icon.startsWith("<svg") && t.icon.endsWith("</svg>")) {
830
+ const i = document.createElement("span");
831
+ i.className = "editora-toolbar-icon", i.innerHTML = t.icon, o.appendChild(i);
832
+ } else
833
+ o.innerHTML = t.icon;
834
+ else
835
+ o.textContent = t.label;
836
+ const r = document.createElement("div");
837
+ return r.className = "editora-toolbar-dropdown-menu", r.style.display = "none", t.options && t.options.forEach((i) => {
838
+ const a = document.createElement("button");
839
+ a.className = "editora-toolbar-dropdown-item", a.type = "button", a.textContent = i.label, a.setAttribute("data-value", i.value), a.addEventListener("click", (n) => {
840
+ n.preventDefault(), n.stopPropagation(), this.commandHandler && t.command && this.commandHandler(t.command, i.value), r.style.display = "none";
841
+ }), r.appendChild(a);
842
+ }), o.addEventListener("click", (i) => {
843
+ var n;
844
+ i.preventDefault(), i.stopPropagation();
845
+ const a = (n = this.container) == null ? void 0 : n.querySelectorAll(
846
+ ".editora-toolbar-dropdown-menu"
847
+ );
848
+ a == null || a.forEach((l) => {
849
+ l !== r && (l.style.display = "none");
850
+ }), r.style.display = r.style.display === "none" ? "block" : "none";
851
+ }), document.addEventListener("click", (i) => {
852
+ e.contains(i.target) || (r.style.display = "none");
853
+ }), e.appendChild(o), e.appendChild(r), e;
854
+ }
855
+ /**
856
+ * Get default toolbar string if none provided
857
+ */
858
+ getDefaultToolbarString() {
859
+ return this.getAvailableToolbarItems().map((e) => e.command).join(" ");
860
+ }
861
+ /**
862
+ * Update button state
863
+ */
864
+ updateButtonState(t, e) {
865
+ if (!this.container) return;
866
+ const o = this.container.querySelector(
867
+ `[data-command="${t}"]`
868
+ );
869
+ o && (e.active !== void 0 && o.classList.toggle("active", e.active), e.disabled !== void 0 && (o.disabled = e.disabled));
870
+ }
871
+ /**
872
+ * Destroy toolbar
873
+ */
874
+ destroy() {
875
+ this.container && (this.container.querySelectorAll(".editora-toolbar-dropdown").forEach((e) => {
876
+ const o = e._cleanupDropdown;
877
+ o && o();
878
+ }), this.container.innerHTML = ""), this.commandHandler = void 0;
879
+ }
880
+ }
881
+ class T {
882
+ constructor(t) {
883
+ this.visible = !1, this.config = t;
884
+ }
885
+ /**
886
+ * Create and mount floating toolbar
887
+ */
888
+ create(t) {
889
+ const e = document.createElement("div");
890
+ 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;
891
+ }
892
+ /**
893
+ * Show toolbar at position
894
+ */
895
+ show(t, e) {
896
+ this.container && (this.container.style.display = "block", this.container.style.left = `${t}px`, this.container.style.top = `${e}px`, this.visible = !0);
897
+ }
898
+ /**
899
+ * Hide toolbar
900
+ */
901
+ hide() {
902
+ this.container && (this.container.style.display = "none", this.visible = !1);
903
+ }
904
+ /**
905
+ * Update position
906
+ */
907
+ updatePosition(t, e) {
908
+ !this.container || !this.visible || (this.container.style.left = `${t}px`, this.container.style.top = `${e}px`);
909
+ }
910
+ /**
911
+ * Check if visible
912
+ */
913
+ isVisible() {
914
+ return this.visible;
915
+ }
916
+ /**
917
+ * Destroy floating toolbar
918
+ */
919
+ destroy() {
920
+ this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = void 0, this.visible = !1;
921
+ }
922
+ }
923
+ class I {
924
+ constructor(t = {}) {
925
+ this.statusInfo = {}, this.config = t;
926
+ }
927
+ /**
928
+ * Create and mount status bar
929
+ */
930
+ create(t) {
931
+ const e = document.createElement("div");
932
+ return e.className = "editora-statusbar", this.config.position && e.classList.add(`editora-statusbar-${this.config.position}`), this.container = e, t.appendChild(e), e;
933
+ }
934
+ /**
935
+ * Update status information
936
+ */
937
+ update(t) {
938
+ this.statusInfo = { ...this.statusInfo, ...t }, this.render();
939
+ }
940
+ /**
941
+ * Render status bar content
942
+ */
943
+ render() {
944
+ if (!this.container) return;
945
+ this.container.innerHTML = "";
946
+ const t = document.createElement("div");
947
+ t.className = "editora-statusbar-left";
948
+ const e = document.createElement("div");
949
+ e.className = "editora-statusbar-right";
950
+ const o = [];
951
+ if (this.statusInfo.selectionInfo) {
952
+ const i = this.statusInfo.selectionInfo;
953
+ 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`));
954
+ } else if (this.statusInfo.cursorPosition) {
955
+ const i = this.statusInfo.cursorPosition;
956
+ o.push(`Ln ${i.line}, Col ${i.column}`);
957
+ }
958
+ this.statusInfo.language && o.push(this.statusInfo.language);
959
+ const r = [];
960
+ this.statusInfo.wordCount !== void 0 && r.push(`${this.statusInfo.wordCount} words`), this.statusInfo.charCount !== void 0 && r.push(`${this.statusInfo.charCount} chars`), this.statusInfo.lineCount !== void 0 && r.push(`${this.statusInfo.lineCount} lines`), this.statusInfo.custom && Object.entries(this.statusInfo.custom).forEach(([i, a]) => {
961
+ r.push(`${i}: ${a}`);
962
+ }), o.forEach((i, a) => {
963
+ const n = document.createElement("span");
964
+ if (n.className = "editora-statusbar-item", n.textContent = i, t.appendChild(n), a < o.length - 1) {
965
+ const l = document.createElement("span");
966
+ l.className = "editora-statusbar-separator", l.textContent = "|", t.appendChild(l);
967
+ }
968
+ }), r.forEach((i, a) => {
969
+ const n = document.createElement("span");
970
+ if (n.className = "editora-statusbar-item", n.textContent = i, e.appendChild(n), a < r.length - 1) {
971
+ const l = document.createElement("span");
972
+ l.className = "editora-statusbar-separator", l.textContent = "|", e.appendChild(l);
973
+ }
974
+ }), this.container.appendChild(t), this.container.appendChild(e);
975
+ }
976
+ /**
977
+ * Destroy status bar
978
+ */
979
+ destroy() {
980
+ this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = void 0;
981
+ }
982
+ }
983
+ function D(s, t) {
984
+ const e = s.textContent || "", o = P(s, t.startContainer, t.startOffset), i = e.substring(0, o).split(`
985
+ `), a = i.length, n = i[i.length - 1].length + 1;
986
+ return { line: a, column: n };
987
+ }
988
+ function P(s, t, e) {
989
+ var a;
990
+ let o = 0;
991
+ const r = document.createTreeWalker(
992
+ s,
993
+ NodeFilter.SHOW_TEXT,
994
+ null
995
+ );
996
+ let i = r.firstChild();
997
+ for (; i; ) {
998
+ if (i === t) {
999
+ o += e;
1000
+ break;
1001
+ } else i.nodeType === Node.TEXT_NODE && (o += ((a = i.textContent) == null ? void 0 : a.length) || 0);
1002
+ i = r.nextNode();
1003
+ }
1004
+ return o;
1005
+ }
1006
+ function N(s) {
1007
+ var o, r;
1008
+ const t = s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");
1009
+ let e = 1;
1010
+ if (t.length > 0) {
1011
+ e = t.length;
1012
+ const i = t[t.length - 1];
1013
+ (i.tagName === "BR" || ((o = i.innerHTML) == null ? void 0 : o.trim()) === "" || ((r = i.textContent) == null ? void 0 : r.trim()) === "") && e++;
1014
+ } else {
1015
+ const a = (s.textContent || "").split(`
1016
+ `).length;
1017
+ e = Math.max(1, a);
1018
+ }
1019
+ return e;
1020
+ }
1021
+ function z(s) {
1022
+ const t = s.trim() ? s.trim().split(/\s+/).length : 0, e = s.length;
1023
+ return { words: t, chars: e };
1024
+ }
1025
+ function B(s, t) {
1026
+ const e = s.toString();
1027
+ return {
1028
+ startLine: t.line,
1029
+ startColumn: t.column,
1030
+ endLine: t.line,
1031
+ // For now, assuming single line selections
1032
+ endColumn: t.column + e.length,
1033
+ selectedChars: e.length,
1034
+ selectedWords: e.trim().split(/\s+/).filter(Boolean).length
1035
+ };
1036
+ }
1037
+ const v = class v {
1038
+ /**
1039
+ * Resolve configuration from multiple sources with priority
1040
+ */
1041
+ static resolve(t) {
1042
+ const e = {};
1043
+ if (Object.assign(e, this.EDITOR_DEFAULTS), t.pluginDefaults && Object.assign(e, t.pluginDefaults), t.attributes) {
1044
+ const o = this.parseAttributes(t.attributes);
1045
+ Object.assign(e, o);
1046
+ }
1047
+ return t.jsConfig && Object.assign(e, t.jsConfig), this.normalizeConfig(e);
1048
+ }
1049
+ /**
1050
+ * Normalize mixed legacy/new config shapes
1051
+ */
1052
+ static normalizeConfig(t) {
1053
+ const e = { ...t };
1054
+ if (e.toolbarFloating !== void 0 || e.toolbarSticky !== void 0) {
1055
+ const a = typeof e.toolbar == "object" && e.toolbar ? { ...e.toolbar } : typeof e.toolbar == "string" ? { items: e.toolbar } : {};
1056
+ e.toolbarFloating !== void 0 && (a.floating = !!e.toolbarFloating), e.toolbarSticky !== void 0 && (a.sticky = !!e.toolbarSticky), e.toolbar = a;
1057
+ }
1058
+ 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) {
1059
+ const a = typeof e.autosave == "object" && e.autosave ? { ...e.autosave } : {};
1060
+ e.autosaveEnabled !== void 0 && (a.enabled = !!e.autosaveEnabled), e.autosaveIntervalMs !== void 0 && (a.intervalMs = Number(e.autosaveIntervalMs)), e.autosaveStorageKey !== void 0 && (a.storageKey = e.autosaveStorageKey), e.autosaveProvider !== void 0 && (a.provider = e.autosaveProvider), e.autosaveApiUrl !== void 0 && (a.apiUrl = e.autosaveApiUrl), e.autosave = a;
1061
+ }
1062
+ const o = {
1063
+ enabled: !1,
1064
+ intervalMs: 3e4,
1065
+ storageKey: "rte-autosave",
1066
+ provider: "localStorage",
1067
+ apiUrl: ""
1068
+ };
1069
+ if (typeof e.autosave == "boolean")
1070
+ e.autosave = {
1071
+ ...o,
1072
+ enabled: e.autosave
1073
+ };
1074
+ else if (typeof e.autosave == "object" && e.autosave) {
1075
+ const a = {
1076
+ ...o,
1077
+ ...e.autosave
1078
+ };
1079
+ a.intervalMs === void 0 && a.interval !== void 0 && (a.intervalMs = Number(a.interval)), a.enabled === void 0 && (a.enabled = !0), (!Number.isFinite(a.intervalMs) || a.intervalMs <= 0) && (a.intervalMs = o.intervalMs), e.autosave = a;
1080
+ } else
1081
+ e.autosave = o;
1082
+ if (e.languageLocale !== void 0 || e.languageDirection !== void 0) {
1083
+ const a = typeof e.language == "object" && e.language ? { ...e.language } : {};
1084
+ e.languageLocale !== void 0 && (a.locale = e.languageLocale), e.languageDirection !== void 0 && (a.direction = e.languageDirection), e.language = a;
1085
+ }
1086
+ const r = { locale: "en", direction: "ltr" };
1087
+ if (typeof e.language == "string" ? e.language = {
1088
+ locale: e.language,
1089
+ direction: r.direction
1090
+ } : typeof e.language == "object" && e.language ? e.language = {
1091
+ ...r,
1092
+ ...e.language
1093
+ } : e.language = r, e.spellcheckEnabled !== void 0 || e.spellcheckProvider !== void 0 || e.spellcheckApiUrl !== void 0) {
1094
+ const a = typeof e.spellcheck == "object" && e.spellcheck ? { ...e.spellcheck } : {};
1095
+ e.spellcheckEnabled !== void 0 && (a.enabled = !!e.spellcheckEnabled), e.spellcheckProvider !== void 0 && (a.provider = e.spellcheckProvider), e.spellcheckApiUrl !== void 0 && (a.apiUrl = e.spellcheckApiUrl), e.spellcheck = a;
1096
+ }
1097
+ const i = {
1098
+ enabled: !1,
1099
+ provider: "browser",
1100
+ apiUrl: ""
1101
+ };
1102
+ if (typeof e.spellcheck == "boolean")
1103
+ e.spellcheck = {
1104
+ ...i,
1105
+ enabled: e.spellcheck
1106
+ };
1107
+ else if (typeof e.spellcheck == "object" && e.spellcheck) {
1108
+ const a = {
1109
+ ...i,
1110
+ ...e.spellcheck
1111
+ };
1112
+ !a.provider && a.mode && (a.provider = a.mode === "local" ? "browser" : "api"), a.enabled === void 0 && (a.enabled = !!(a.mode || a.provider || a.apiUrl)), e.spellcheck = a;
1113
+ } else
1114
+ e.spellcheck = i;
1115
+ return e.contextMenuEnabled !== void 0 && (e.contextMenu = {
1116
+ enabled: !!e.contextMenuEnabled
1117
+ }), typeof e.contextMenu == "boolean" ? e.contextMenu = { enabled: e.contextMenu } : typeof e.contextMenu == "object" && e.contextMenu ? e.contextMenu = {
1118
+ enabled: e.contextMenu.enabled !== !1
1119
+ } : e.contextMenu = { enabled: !0 }, (e.pasteClean !== void 0 || e.pasteKeepFormatting !== void 0 || e.pasteConvertWord !== void 0) && (e.paste = {
1120
+ ...e.paste || {},
1121
+ ...e.pasteClean !== void 0 ? { clean: !!e.pasteClean } : {},
1122
+ ...e.pasteKeepFormatting !== void 0 ? { keepFormatting: !!e.pasteKeepFormatting } : {},
1123
+ ...e.pasteConvertWord !== void 0 ? { convertWord: !!e.pasteConvertWord } : {}
1124
+ }), e.paste = {
1125
+ clean: !0,
1126
+ keepFormatting: !1,
1127
+ convertWord: !0,
1128
+ ...e.paste || {}
1129
+ }, e.contentConfig = {
1130
+ allowedTags: [],
1131
+ allowedAttributes: {},
1132
+ sanitize: !0,
1133
+ ...e.contentConfig || {}
1134
+ }, (e.securitySanitizeOnPaste !== void 0 || e.securitySanitizeOnInput !== void 0) && (e.security = {
1135
+ ...e.security || {},
1136
+ ...e.securitySanitizeOnPaste !== void 0 ? { sanitizeOnPaste: !!e.securitySanitizeOnPaste } : {},
1137
+ ...e.securitySanitizeOnInput !== void 0 ? { sanitizeOnInput: !!e.securitySanitizeOnInput } : {}
1138
+ }), e.security = {
1139
+ sanitizeOnPaste: !0,
1140
+ sanitizeOnInput: !0,
1141
+ ...e.security || {}
1142
+ }, (e.accessibilityEnableAria !== void 0 || e.accessibilityKeyboardNavigation !== void 0 || e.accessibilityChecker !== void 0) && (e.accessibility = {
1143
+ ...e.accessibility || {},
1144
+ ...e.accessibilityEnableAria !== void 0 ? { enableARIA: !!e.accessibilityEnableAria } : {},
1145
+ ...e.accessibilityKeyboardNavigation !== void 0 ? { keyboardNavigation: !!e.accessibilityKeyboardNavigation } : {},
1146
+ ...e.accessibilityChecker !== void 0 ? { checker: !!e.accessibilityChecker } : {}
1147
+ }), typeof e.accessibility == "boolean" && (e.accessibility = {
1148
+ enableARIA: e.accessibility,
1149
+ keyboardNavigation: e.accessibility,
1150
+ checker: !1
1151
+ }), e.accessibility = {
1152
+ enableARIA: !0,
1153
+ keyboardNavigation: !0,
1154
+ checker: !1,
1155
+ ...e.accessibility || {}
1156
+ }, (e.performanceDebounceInputMs !== void 0 || e.performanceViewportOnlyScan !== void 0) && (e.performance = {
1157
+ ...e.performance || {},
1158
+ ...e.performanceDebounceInputMs !== void 0 ? { debounceInputMs: Number(e.performanceDebounceInputMs) } : {},
1159
+ ...e.performanceViewportOnlyScan !== void 0 ? { viewportOnlyScan: !!e.performanceViewportOnlyScan } : {}
1160
+ }), typeof e.performance == "boolean" && (e.performance = {
1161
+ debounceInputMs: 100,
1162
+ viewportOnlyScan: e.performance
1163
+ }), e.performance = {
1164
+ debounceInputMs: 100,
1165
+ viewportOnlyScan: !0,
1166
+ ...e.performance || {}
1167
+ }, (typeof e.performance.debounceInputMs != "number" || !Number.isFinite(e.performance.debounceInputMs) || e.performance.debounceInputMs < 0) && (e.performance.debounceInputMs = 100), e;
1168
+ }
1169
+ /**
1170
+ * Parse web component attributes
1171
+ */
1172
+ static parseAttributes(t) {
1173
+ const e = {};
1174
+ for (const [o, r] of Object.entries(t)) {
1175
+ const i = this.kebabToCamel(o);
1176
+ e[i] = this.parseAttributeValue(r);
1177
+ }
1178
+ return e;
1179
+ }
1180
+ /**
1181
+ * Parse attribute value to appropriate type
1182
+ */
1183
+ static parseAttributeValue(t) {
1184
+ if (t === "true") return !0;
1185
+ if (t === "false") return !1;
1186
+ if (/^\d+$/.test(t)) return parseInt(t, 10);
1187
+ if (/^\d+\.\d+$/.test(t)) return parseFloat(t);
1188
+ if (t.startsWith("{") || t.startsWith("["))
1189
+ try {
1190
+ return JSON.parse(t);
1191
+ } catch (e) {
1192
+ return t;
1193
+ }
1194
+ return t;
1195
+ }
1196
+ /**
1197
+ * Convert kebab-case to camelCase
1198
+ */
1199
+ static kebabToCamel(t) {
1200
+ return t.replace(/-([a-z])/g, (e, o) => o.toUpperCase());
1201
+ }
1202
+ /**
1203
+ * Validate configuration
1204
+ */
1205
+ static validate(t) {
1206
+ const e = [];
1207
+ 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"), {
1208
+ valid: e.length === 0,
1209
+ errors: e
1210
+ };
1211
+ }
1212
+ /**
1213
+ * Get default configuration
1214
+ */
1215
+ static getDefaults() {
1216
+ return { ...this.EDITOR_DEFAULTS };
1217
+ }
1218
+ /**
1219
+ * Merge configurations (deep merge)
1220
+ */
1221
+ static merge(...t) {
1222
+ const e = {};
1223
+ for (const o of t)
1224
+ for (const [r, i] of Object.entries(o))
1225
+ i != null && (typeof i == "object" && !Array.isArray(i) && e[r] ? e[r] = this.merge(e[r], i) : e[r] = i);
1226
+ return e;
1227
+ }
1228
+ };
1229
+ v.EDITOR_DEFAULTS = {
1230
+ height: 400,
1231
+ width: "100%",
1232
+ readonly: !1,
1233
+ disabled: !1,
1234
+ menubar: !0,
1235
+ toolbar: !0,
1236
+ plugins: [],
1237
+ theme: "light",
1238
+ content: "",
1239
+ placeholder: "Start typing...",
1240
+ autofocus: !1,
1241
+ autosave: !1,
1242
+ accessibility: {
1243
+ enableARIA: !0,
1244
+ keyboardNavigation: !0,
1245
+ checker: !1
1246
+ },
1247
+ performance: {
1248
+ debounceInputMs: 100,
1249
+ viewportOnlyScan: !0
1250
+ },
1251
+ spellcheck: {
1252
+ enabled: !1,
1253
+ provider: "browser",
1254
+ apiUrl: ""
1255
+ },
1256
+ language: {
1257
+ locale: "en",
1258
+ direction: "ltr"
1259
+ },
1260
+ contextMenu: {
1261
+ enabled: !0
1262
+ },
1263
+ contentConfig: {
1264
+ allowedTags: [],
1265
+ allowedAttributes: {},
1266
+ sanitize: !0
1267
+ },
1268
+ paste: {
1269
+ clean: !0,
1270
+ keepFormatting: !1,
1271
+ convertWord: !0
1272
+ },
1273
+ security: {
1274
+ sanitizeOnPaste: !0,
1275
+ sanitizeOnInput: !0
1276
+ },
1277
+ statusbar: !1
1278
+ };
1279
+ let y = v;
1280
+ class O {
1281
+ constructor() {
1282
+ this.loadedPlugins = /* @__PURE__ */ new Map(), this.pluginRegistry = /* @__PURE__ */ new Map();
1283
+ }
1284
+ /**
1285
+ * Register a plugin factory (sync or async)
1286
+ */
1287
+ register(t, e) {
1288
+ this.pluginRegistry.set(t, e);
1289
+ }
1290
+ /**
1291
+ * Load a plugin by name (async)
1292
+ */
1293
+ async load(t, e) {
1294
+ if (this.loadedPlugins.has(t))
1295
+ return this.loadedPlugins.get(t);
1296
+ const o = this.pluginRegistry.get(t);
1297
+ if (!o)
1298
+ return console.warn(`Plugin not found: ${t}`), null;
1299
+ const r = await o();
1300
+ return e && this.applyPluginConfig(r, e), this.loadedPlugins.set(t, r), r;
1301
+ }
1302
+ /**
1303
+ * Load multiple plugins
1304
+ */
1305
+ async loadMultiple(t, e) {
1306
+ return (await Promise.all(
1307
+ t.map((r) => this.load(r, e))
1308
+ )).filter((r) => r !== null);
1309
+ }
1310
+ /**
1311
+ * Parse plugin string "lists link image media"
1312
+ */
1313
+ async parsePluginString(t, e) {
1314
+ const o = t.split(/\s+/).filter(Boolean);
1315
+ return this.loadMultiple(o, e);
1316
+ }
1317
+ /**
1318
+ * Apply configuration to plugin
1319
+ */
1320
+ applyPluginConfig(t, e) {
1321
+ t.__pluginConfig = e;
1322
+ }
1323
+ /**
1324
+ * Unload a plugin
1325
+ */
1326
+ unload(t) {
1327
+ this.loadedPlugins.delete(t);
1328
+ }
1329
+ /**
1330
+ * Clear all loaded plugins
1331
+ */
1332
+ clear() {
1333
+ this.loadedPlugins.clear();
1334
+ }
1335
+ /**
1336
+ * Get all loaded plugins
1337
+ */
1338
+ getLoadedPlugins() {
1339
+ return Array.from(this.loadedPlugins.values());
1340
+ }
1341
+ /**
1342
+ * Get all registered plugin names (available for loading)
1343
+ */
1344
+ getRegisteredPluginNames() {
1345
+ return Array.from(this.pluginRegistry.keys());
1346
+ }
1347
+ /**
1348
+ * Check if plugin is loaded
1349
+ */
1350
+ isLoaded(t) {
1351
+ return this.loadedPlugins.has(t);
1352
+ }
1353
+ }
1354
+ const j = [
1355
+ "p",
1356
+ "br",
1357
+ "strong",
1358
+ "em",
1359
+ "u",
1360
+ "s",
1361
+ "strike",
1362
+ "del",
1363
+ "b",
1364
+ "i",
1365
+ "h1",
1366
+ "h2",
1367
+ "h3",
1368
+ "h4",
1369
+ "h5",
1370
+ "h6",
1371
+ "ul",
1372
+ "ol",
1373
+ "li",
1374
+ "a",
1375
+ "img",
1376
+ "video",
1377
+ "audio",
1378
+ "table",
1379
+ "thead",
1380
+ "tbody",
1381
+ "tr",
1382
+ "th",
1383
+ "td",
1384
+ "blockquote",
1385
+ "pre",
1386
+ "code",
1387
+ "span",
1388
+ "div",
1389
+ "sup",
1390
+ "sub",
1391
+ "hr"
1392
+ ], H = {
1393
+ "*": ["class", "style", "id", "data-*"],
1394
+ a: ["href", "target", "rel", "title"],
1395
+ img: ["src", "alt", "width", "height", "loading"],
1396
+ video: ["src", "controls", "width", "height", "autoplay", "loop", "muted"],
1397
+ audio: ["src", "controls", "autoplay", "loop", "muted"],
1398
+ table: ["border", "cellpadding", "cellspacing"],
1399
+ td: ["colspan", "rowspan", "align", "valign"],
1400
+ th: ["colspan", "rowspan", "align", "valign"]
1401
+ };
1402
+ function k(s, t, e) {
1403
+ if ((t == null ? void 0 : t.sanitize) === !1)
1404
+ return s;
1405
+ const o = t != null && t.allowedTags && t.allowedTags.length > 0 ? t.allowedTags : j, i = !!(t != null && t.allowedAttributes) && Object.keys(t.allowedAttributes).length > 0 ? t.allowedAttributes : H, a = document.createElement("div");
1406
+ return a.innerHTML = s, x(a, o, i), a.innerHTML;
1407
+ }
1408
+ function x(s, t, e) {
1409
+ const o = Array.from(s.childNodes);
1410
+ for (const r of o)
1411
+ if (r.nodeType === Node.ELEMENT_NODE) {
1412
+ const i = r, a = i.tagName.toLowerCase();
1413
+ if (!t.includes(a)) {
1414
+ for (; i.firstChild; )
1415
+ s.insertBefore(i.firstChild, i);
1416
+ s.removeChild(i);
1417
+ continue;
1418
+ }
1419
+ R(i, e), x(i, t, e);
1420
+ } else r.nodeType !== Node.TEXT_NODE && s.removeChild(r);
1421
+ }
1422
+ function R(s, t) {
1423
+ const e = s.tagName.toLowerCase(), o = Array.from(s.attributes), r = t[e] || [], i = t["*"] || [], a = [...r, ...i];
1424
+ for (const n of o) {
1425
+ const l = n.name.toLowerCase();
1426
+ let c = !1;
1427
+ a.includes(l) && (c = !0);
1428
+ for (const d of a)
1429
+ if (d.endsWith("*")) {
1430
+ const f = d.slice(0, -1);
1431
+ if (l.startsWith(f)) {
1432
+ c = !0;
1433
+ break;
1434
+ }
1435
+ }
1436
+ (l.startsWith("on") || l === "javascript:" || l === "href" && n.value.trim().toLowerCase().startsWith("javascript:") || l === "src" && n.value.trim().toLowerCase().startsWith("javascript:")) && (c = !1), c || s.removeAttribute(n.name);
1437
+ }
1438
+ 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");
1439
+ }
1440
+ function F(s, t, e) {
1441
+ return (e == null ? void 0 : e.sanitizeOnPaste) === !1 ? s : k(s, t);
1442
+ }
1443
+ function $(s, t, e) {
1444
+ return (e == null ? void 0 : e.sanitizeOnInput) === !1 ? s : k(s, t);
1445
+ }
1446
+ const U = '.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-left:1px solid #ccc;border-top-right-radius:3px;border-bottom-right-radius:3px}}}.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-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:#4db8ff}.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:#9a9a9a}.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}}';
1447
+ let m;
1448
+ function W() {
1449
+ const s = "editora-webcomponent-styles";
1450
+ if (!document.getElementById(s)) {
1451
+ const t = document.createElement("style");
1452
+ t.id = s, t.textContent = U, document.head.appendChild(t);
1453
+ }
1454
+ }
1455
+ function w() {
1456
+ if (!m) {
1457
+ const s = g.__globalPluginLoader;
1458
+ s ? m = s : m = new O();
1459
+ }
1460
+ return m;
1461
+ }
1462
+ function K(s) {
1463
+ const t = w();
1464
+ Object.entries(s).forEach(([e, o]) => {
1465
+ t.register(e, o);
1466
+ });
1467
+ }
1468
+ class g extends HTMLElement {
1469
+ constructor() {
1470
+ if (super(), this.pluginLoader = w(), this.config = {}, this.isInitialized = !1, this.keyboardShortcutManager = new S(), this.lastAutosavedContent = "", this.loadedPlugins = [], W(), !this.hasAttribute("data-initial-content")) {
1471
+ const t = this.innerHTML.trim();
1472
+ t && this.setAttribute("data-initial-content", t);
1473
+ }
1474
+ }
1475
+ // Observed attributes for reactive updates
1476
+ static get observedAttributes() {
1477
+ return [
1478
+ "height",
1479
+ "width",
1480
+ "menubar",
1481
+ "plugins",
1482
+ "toolbar",
1483
+ "toolbar-items",
1484
+ "toolbar-floating",
1485
+ "toolbar-sticky",
1486
+ "readonly",
1487
+ "disabled",
1488
+ "theme",
1489
+ "placeholder",
1490
+ "autofocus",
1491
+ "autosave",
1492
+ "autosave-enabled",
1493
+ "autosave-interval-ms",
1494
+ "autosave-storage-key",
1495
+ "autosave-provider",
1496
+ "autosave-api-url",
1497
+ "accessibility",
1498
+ "accessibility-enable-aria",
1499
+ "accessibility-keyboard-navigation",
1500
+ "accessibility-checker",
1501
+ "performance",
1502
+ "performance-debounce-input-ms",
1503
+ "performance-viewport-only-scan",
1504
+ "language",
1505
+ "language-locale",
1506
+ "language-direction",
1507
+ "spellcheck",
1508
+ "spellcheck-enabled",
1509
+ "spellcheck-provider",
1510
+ "context-menu",
1511
+ "context-menu-enabled",
1512
+ "paste",
1513
+ "paste-clean",
1514
+ "paste-keep-formatting",
1515
+ "paste-convert-word",
1516
+ "security",
1517
+ "security-sanitize-on-paste",
1518
+ "security-sanitize-on-input",
1519
+ "statusbar"
1520
+ ];
1521
+ }
1522
+ /**
1523
+ * Called when element is added to DOM
1524
+ */
1525
+ connectedCallback() {
1526
+ this.config = this.resolveConfig(), this.waitForPluginLoader().then(() => {
1527
+ setTimeout(async () => {
1528
+ await this.initialize();
1529
+ }, 0);
1530
+ });
1531
+ }
1532
+ /**
1533
+ * Wait for the global plugin loader to be available
1534
+ */
1535
+ async waitForPluginLoader() {
1536
+ if (g.__globalPluginLoader) {
1537
+ this.pluginLoader = g.__globalPluginLoader;
1538
+ return;
1539
+ }
1540
+ return new Promise((t) => {
1541
+ const e = () => {
1542
+ g.__globalPluginLoader ? (this.pluginLoader = g.__globalPluginLoader, t()) : setTimeout(e, 0);
1543
+ };
1544
+ e();
1545
+ });
1546
+ }
1547
+ /**
1548
+ * Called when element is removed from DOM
1549
+ */
1550
+ disconnectedCallback() {
1551
+ this.destroy();
1552
+ }
1553
+ /**
1554
+ * Called when an observed attribute changes
1555
+ */
1556
+ attributeChangedCallback(t, e, o) {
1557
+ e !== o && (this.config = this.resolveConfig(), this.handleAttributeChange(t, o));
1558
+ }
1559
+ /**
1560
+ * Set configuration via JavaScript API
1561
+ */
1562
+ async setConfig(t) {
1563
+ this.jsConfig = t, this.config = this.resolveConfig(), this.isConnected && (this.destroy(), await this.waitForPluginLoader(), await this.initialize());
1564
+ }
1565
+ /**
1566
+ * Initialize the editor
1567
+ */
1568
+ async initialize() {
1569
+ var o;
1570
+ if (this.querySelector(".editora-toolbar") || this.isInitialized) return;
1571
+ this.setAttribute("data-editora-editor", "true"), this.config.height && (this.style.height = typeof this.config.height == "number" ? `${this.config.height}px` : this.config.height), this.config.width && (this.style.width = typeof this.config.width == "number" ? `${this.config.width}px` : this.config.width), this.classList.add("editora-editor"), this.config.theme && this.classList.add(`editora-theme-${this.config.theme}`);
1572
+ const t = await this.loadPlugins();
1573
+ this.loadedPlugins = t, t.forEach((r) => {
1574
+ if (r.init && typeof r.init == "function")
1575
+ try {
1576
+ r.init({ editorElement: this });
1577
+ } catch (i) {
1578
+ console.error(`[RichTextEditor] Error initializing plugin ${r.name}:`, i);
1579
+ }
1580
+ });
1581
+ const e = (o = this.restoreAutosavedContent()) != null ? o : this.getAttribute("data-initial-content") || "";
1582
+ this.engine = new A({
1583
+ content: e,
1584
+ plugins: t,
1585
+ readonly: this.config.readonly
1586
+ }), this.createUI(t, e), this.setupEventListeners(), this.startAutosave(), this.isInitialized = !0, this.dispatchEvent(new CustomEvent("editor-ready", {
1587
+ detail: { api: this.getAPI() },
1588
+ bubbles: !0
1589
+ }));
1590
+ }
1591
+ /**
1592
+ * Get initial content from slot or attribute
1593
+ */
1594
+ getInitialContent() {
1595
+ if (this.config.content)
1596
+ return this.config.content;
1597
+ const t = this.querySelector("[slot]");
1598
+ 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() : "";
1599
+ }
1600
+ /**
1601
+ * Load plugins based on configuration
1602
+ */
1603
+ async loadPlugins() {
1604
+ this.pluginLoader || await this.waitForPluginLoader();
1605
+ const t = [], e = this.config.plugins && (typeof this.config.plugins == "string" && this.config.plugins.length > 0 || Array.isArray(this.config.plugins) && this.config.plugins.length > 0), r = this.getAccessibilityConfig().checker === !0;
1606
+ if (e) {
1607
+ if (typeof this.config.plugins == "string") {
1608
+ const i = this.config.plugins.split(/\s+/).filter(Boolean);
1609
+ r && !i.includes("a11yChecker") && i.push("a11yChecker");
1610
+ for (const a of i) {
1611
+ const n = await this.pluginLoader.load(a, this.getPluginLoadConfig(a));
1612
+ n && t.push(n);
1613
+ }
1614
+ } else if (Array.isArray(this.config.plugins)) {
1615
+ for (const i of this.config.plugins)
1616
+ if (typeof i == "string") {
1617
+ const a = await this.pluginLoader.load(i, this.getPluginLoadConfig(i));
1618
+ a && t.push(a);
1619
+ } else
1620
+ t.push(i);
1621
+ if (r && !t.some((i) => (i == null ? void 0 : i.name) === "a11yChecker")) {
1622
+ const i = await this.pluginLoader.load("a11yChecker", this.getPluginLoadConfig("a11yChecker"));
1623
+ i && t.push(i);
1624
+ }
1625
+ }
1626
+ } else {
1627
+ const i = this.pluginLoader.getRegisteredPluginNames();
1628
+ for (const a of i) {
1629
+ const n = await this.pluginLoader.load(a, this.getPluginLoadConfig(a));
1630
+ n && t.push(n);
1631
+ }
1632
+ }
1633
+ return t;
1634
+ }
1635
+ resolveToolbarItems() {
1636
+ const t = this.config.toolbarItems;
1637
+ if (typeof t == "string") return t;
1638
+ if (Array.isArray(t)) return t.join(" ");
1639
+ const e = this.config.toolbar;
1640
+ if (typeof e == "string") return e;
1641
+ if (!e || typeof e != "object") return;
1642
+ const o = e.items;
1643
+ if (typeof o == "string") return o;
1644
+ if (Array.isArray(o)) return o.join(" ");
1645
+ }
1646
+ isToolbarStickyEnabled() {
1647
+ const t = this.config.toolbar;
1648
+ return !t || typeof t != "object" ? !1 : !!t.sticky;
1649
+ }
1650
+ isToolbarFloatingEnabled() {
1651
+ const t = this.config.toolbar;
1652
+ return !t || typeof t != "object" ? !1 : !!t.floating;
1653
+ }
1654
+ isStatusbarEnabled() {
1655
+ const t = this.config.statusbar;
1656
+ return typeof t == "boolean" ? t : t && typeof t == "object" ? t.enabled !== !1 : !1;
1657
+ }
1658
+ getStatusbarPosition() {
1659
+ const t = this.config.statusbar;
1660
+ return t && typeof t == "object" && t.position === "top" ? "top" : "bottom";
1661
+ }
1662
+ getLanguageConfig() {
1663
+ const t = this.config.language;
1664
+ return typeof t == "string" ? { locale: t, direction: "ltr" } : t && typeof t == "object" ? {
1665
+ locale: t.locale || "en",
1666
+ direction: t.direction === "rtl" ? "rtl" : "ltr"
1667
+ } : { locale: "en", direction: "ltr" };
1668
+ }
1669
+ getAccessibilityConfig() {
1670
+ const t = this.config.accessibility;
1671
+ return typeof t == "boolean" ? {
1672
+ enableARIA: t,
1673
+ keyboardNavigation: t,
1674
+ checker: !1
1675
+ } : t && typeof t == "object" ? {
1676
+ enableARIA: t.enableARIA !== !1,
1677
+ keyboardNavigation: t.keyboardNavigation !== !1,
1678
+ checker: !!t.checker
1679
+ } : {
1680
+ enableARIA: !0,
1681
+ keyboardNavigation: !0,
1682
+ checker: !1
1683
+ };
1684
+ }
1685
+ getPerformanceConfig() {
1686
+ var e;
1687
+ const t = this.config.performance;
1688
+ if (typeof t == "boolean")
1689
+ return {
1690
+ debounceInputMs: 100,
1691
+ viewportOnlyScan: t
1692
+ };
1693
+ if (t && typeof t == "object") {
1694
+ const o = Number((e = t.debounceInputMs) != null ? e : 100);
1695
+ return {
1696
+ debounceInputMs: Number.isFinite(o) && o >= 0 ? o : 100,
1697
+ viewportOnlyScan: t.viewportOnlyScan !== !1
1698
+ };
1699
+ }
1700
+ return {
1701
+ debounceInputMs: 100,
1702
+ viewportOnlyScan: !0
1703
+ };
1704
+ }
1705
+ isEditorInViewport() {
1706
+ if (!this.contentElement || typeof window == "undefined") return !0;
1707
+ const t = this.contentElement.getBoundingClientRect();
1708
+ return t.bottom >= 0 && t.top <= window.innerHeight;
1709
+ }
1710
+ applyAccessibilitySettings() {
1711
+ if (!this.contentElement) return;
1712
+ const t = this.getAccessibilityConfig();
1713
+ if (t.enableARIA) {
1714
+ this.contentElement.setAttribute("role", "textbox"), this.contentElement.setAttribute("aria-multiline", "true"), this.contentElement.setAttribute("aria-disabled", this.config.readonly ? "true" : "false");
1715
+ const e = typeof this.config.placeholder == "string" ? this.config.placeholder.trim() : "";
1716
+ e ? this.contentElement.setAttribute("aria-label", e) : this.contentElement.removeAttribute("aria-label");
1717
+ } else
1718
+ this.contentElement.removeAttribute("role"), this.contentElement.removeAttribute("aria-multiline"), this.contentElement.removeAttribute("aria-disabled"), this.contentElement.removeAttribute("aria-label");
1719
+ this.contentElement.tabIndex = t.keyboardNavigation ? 0 : -1;
1720
+ }
1721
+ applyLanguageSettings() {
1722
+ if (!this.contentElement) return;
1723
+ const t = this.getLanguageConfig();
1724
+ this.contentElement.setAttribute("lang", t.locale), this.contentElement.setAttribute("dir", t.direction);
1725
+ }
1726
+ getSpellcheckConfig() {
1727
+ const t = this.config.spellcheck;
1728
+ if (typeof t == "boolean")
1729
+ return {
1730
+ enabled: t,
1731
+ provider: "browser"
1732
+ };
1733
+ if (t && typeof t == "object") {
1734
+ const e = t.provider || "browser";
1735
+ return {
1736
+ enabled: !!t.enabled,
1737
+ provider: e,
1738
+ mode: t.mode
1739
+ };
1740
+ }
1741
+ return { enabled: !1, provider: "browser" };
1742
+ }
1743
+ applySpellcheckSettings() {
1744
+ if (!this.contentElement) return;
1745
+ const t = this.getSpellcheckConfig(), e = t.enabled && t.provider === "browser";
1746
+ this.contentElement.spellcheck = e, this.contentElement.setAttribute("spellcheck", e ? "true" : "false");
1747
+ }
1748
+ executeCommand(t, e) {
1749
+ var r;
1750
+ typeof window != "undefined" && (window.__editoraCommandEditorRoot = this);
1751
+ const o = this.loadedPlugins.find((i) => i.commands && i.commands[t]);
1752
+ if (o && o.commands) {
1753
+ const i = o.commands[t];
1754
+ if (typeof i == "function")
1755
+ try {
1756
+ return i(t === "toggleFullscreen" ? this : e), !0;
1757
+ } catch (a) {
1758
+ return console.error(`[RichTextEditor] Error executing native command ${t}:`, a), !1;
1759
+ }
1760
+ }
1761
+ return ((r = this.engine) == null ? void 0 : r.execCommand(t, e)) || !1;
1762
+ }
1763
+ getPluginLoadConfig(t) {
1764
+ const e = this.config.pluginConfig;
1765
+ if (e && typeof e == "object") {
1766
+ const i = e[t];
1767
+ if (i && typeof i == "object")
1768
+ return i;
1769
+ }
1770
+ const o = {
1771
+ spellCheck: ["spellcheck", "spellCheck"]
1772
+ }, r = [
1773
+ t,
1774
+ t.toLowerCase(),
1775
+ ...o[t] || []
1776
+ ];
1777
+ for (const i of r) {
1778
+ const a = this.config[i];
1779
+ if (a && typeof a == "object" && !Array.isArray(a))
1780
+ return a;
1781
+ }
1782
+ }
1783
+ getContentSanitizeConfig() {
1784
+ const t = this.config.contentConfig;
1785
+ return t && typeof t == "object" ? t : { sanitize: !0 };
1786
+ }
1787
+ getSecurityConfig() {
1788
+ const t = this.config.security;
1789
+ return t && typeof t == "object" ? t : { sanitizeOnPaste: !0, sanitizeOnInput: !0 };
1790
+ }
1791
+ getAutosaveConfig() {
1792
+ var e, o;
1793
+ const t = this.config.autosave;
1794
+ if (typeof t == "boolean")
1795
+ return {
1796
+ enabled: t,
1797
+ intervalMs: 3e4,
1798
+ storageKey: "rte-autosave",
1799
+ provider: "localStorage"
1800
+ };
1801
+ if (t && typeof t == "object") {
1802
+ const r = Number((o = (e = t.intervalMs) != null ? e : t.interval) != null ? o : 3e4);
1803
+ return {
1804
+ enabled: !!t.enabled,
1805
+ intervalMs: Number.isFinite(r) && r > 0 ? r : 3e4,
1806
+ storageKey: String(t.storageKey || "rte-autosave"),
1807
+ provider: t.provider || "localStorage",
1808
+ apiUrl: t.apiUrl
1809
+ };
1810
+ }
1811
+ return {
1812
+ enabled: !1,
1813
+ intervalMs: 3e4,
1814
+ storageKey: "rte-autosave",
1815
+ provider: "localStorage"
1816
+ };
1817
+ }
1818
+ persistAutosave(t) {
1819
+ const e = this.getAutosaveConfig();
1820
+ if (e.enabled && t !== this.lastAutosavedContent) {
1821
+ if (this.lastAutosavedContent = t, e.provider === "localStorage") {
1822
+ try {
1823
+ localStorage.setItem(e.storageKey, t), localStorage.setItem(`${e.storageKey}-timestamp`, Date.now().toString());
1824
+ } catch (o) {
1825
+ console.error("[RichTextEditor] Failed to save autosave content to localStorage:", o);
1826
+ }
1827
+ return;
1828
+ }
1829
+ e.provider === "api" && e.apiUrl && fetch(e.apiUrl, {
1830
+ method: "POST",
1831
+ headers: { "Content-Type": "application/json" },
1832
+ body: JSON.stringify({ content: t, timestamp: Date.now() })
1833
+ }).catch((o) => {
1834
+ console.error("[RichTextEditor] Failed to save autosave content to API:", o);
1835
+ });
1836
+ }
1837
+ }
1838
+ restoreAutosavedContent() {
1839
+ const t = this.getAutosaveConfig();
1840
+ if (!t.enabled || t.provider !== "localStorage") return null;
1841
+ try {
1842
+ const e = localStorage.getItem(t.storageKey);
1843
+ if (e)
1844
+ return this.lastAutosavedContent = e, e;
1845
+ } catch (e) {
1846
+ console.error("[RichTextEditor] Failed to restore autosaved content:", e);
1847
+ }
1848
+ return null;
1849
+ }
1850
+ stopAutosave() {
1851
+ this.autosaveTimer && (clearInterval(this.autosaveTimer), this.autosaveTimer = void 0);
1852
+ }
1853
+ startAutosave() {
1854
+ this.stopAutosave();
1855
+ const t = this.getAutosaveConfig();
1856
+ !t.enabled || !this.contentElement || (this.autosaveTimer = setInterval(() => {
1857
+ var e;
1858
+ this.persistAutosave(((e = this.contentElement) == null ? void 0 : e.innerHTML) || "");
1859
+ }, t.intervalMs));
1860
+ }
1861
+ insertHTMLAtSelection(t) {
1862
+ if (!this.contentElement) return;
1863
+ const e = window.getSelection();
1864
+ if (e && e.rangeCount > 0) {
1865
+ const o = e.getRangeAt(0);
1866
+ o.deleteContents();
1867
+ const r = document.createElement("div");
1868
+ r.innerHTML = t;
1869
+ const i = document.createDocumentFragment();
1870
+ for (; r.firstChild; )
1871
+ i.appendChild(r.firstChild);
1872
+ o.insertNode(i), o.collapse(!1), e.removeAllRanges(), e.addRange(o);
1873
+ } else
1874
+ this.contentElement.focus(), document.execCommand("insertHTML", !1, t);
1875
+ }
1876
+ /**
1877
+ * Create UI elements
1878
+ */
1879
+ createUI(t, e) {
1880
+ const o = this.querySelector('[slot="toolbar"]'), r = this.querySelector('[slot="statusbar"]');
1881
+ this.innerHTML = "", this.config.toolbar !== !1 && !o ? (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.appendChild(this.toolbarElement), this.toolbar = new L(
1882
+ {
1883
+ items: this.resolveToolbarItems(),
1884
+ sticky: this.isToolbarStickyEnabled(),
1885
+ position: "top"
1886
+ },
1887
+ t,
1888
+ this.pluginLoader
1889
+ // Pass plugin loader to get all registered plugins
1890
+ ), this.toolbar.setCommandHandler((i, a) => {
1891
+ var n;
1892
+ if (this.contentElement) {
1893
+ this.contentElement.focus();
1894
+ const l = window.getSelection();
1895
+ if (!l || l.rangeCount === 0 || !this.contentElement.contains(l.anchorNode)) {
1896
+ const c = document.createRange(), d = this.contentElement.lastChild || this.contentElement;
1897
+ d.nodeType === Node.TEXT_NODE ? c.setStart(d, ((n = d.textContent) == null ? void 0 : n.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);
1898
+ }
1899
+ }
1900
+ return this.executeCommand(i, a);
1901
+ }), 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);
1902
+ try {
1903
+ document.execCommand("defaultParagraphSeparator", !1, "p");
1904
+ } catch (i) {
1905
+ console.warn("defaultParagraphSeparator not supported:", i);
1906
+ }
1907
+ if (e) {
1908
+ const i = document.createElement("div");
1909
+ i.innerHTML = e.trim(), !Array.from(i.childNodes).some((n) => {
1910
+ if (n.nodeType === Node.ELEMENT_NODE) {
1911
+ const l = n.tagName;
1912
+ return ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "UL", "OL", "BLOCKQUOTE", "PRE"].includes(l);
1913
+ }
1914
+ return !1;
1915
+ }) && e.trim() ? this.contentElement.innerHTML = `<p>${e.trim()}</p>` : this.contentElement.innerHTML = e;
1916
+ } else
1917
+ this.config.placeholder ? this.contentElement.innerHTML = "" : this.contentElement.innerHTML = "<p><br></p>";
1918
+ this.appendChild(this.contentElement), this.isToolbarFloatingEnabled() && (this.floatingToolbar = new T({ enabled: !0 }), this.floatingToolbar.create(this)), r ? this.appendChild(r) : this.isStatusbarEnabled() && (this.statusBarElement = document.createElement("div"), this.statusBarElement.className = "editora-statusbar-container", this.appendChild(this.statusBarElement), this.statusBar = new I({ position: this.getStatusbarPosition() }), this.statusBar.create(this.statusBarElement)), this.config.autofocus && setTimeout(() => {
1919
+ var i;
1920
+ return (i = this.contentElement) == null ? void 0 : i.focus();
1921
+ }, 0);
1922
+ }
1923
+ /**
1924
+ * Setup event listeners
1925
+ */
1926
+ setupEventListeners() {
1927
+ if (!this.contentElement || !this.engine) return;
1928
+ const t = this.keyboardShortcutManager;
1929
+ this.contentElement.addEventListener("input", () => {
1930
+ if (!this.contentElement) return;
1931
+ let o = this.contentElement.innerHTML;
1932
+ const r = this.getPerformanceConfig(), i = this.getContentSanitizeConfig(), a = this.getSecurityConfig();
1933
+ if (a.sanitizeOnInput !== !1 && i.sanitize !== !1) {
1934
+ const l = $(o, i, a);
1935
+ if (l !== o) {
1936
+ const c = window.getSelection(), d = c && c.rangeCount > 0 ? c.getRangeAt(0) : null;
1937
+ if (this.contentElement.innerHTML = l, d && c)
1938
+ try {
1939
+ c.removeAllRanges(), c.addRange(d);
1940
+ } catch (f) {
1941
+ }
1942
+ o = l;
1943
+ }
1944
+ }
1945
+ this.contentChangeDebounceTimer && clearTimeout(this.contentChangeDebounceTimer);
1946
+ const n = () => {
1947
+ this.dispatchEvent(new CustomEvent("content-change", {
1948
+ detail: { html: o },
1949
+ bubbles: !0
1950
+ }));
1951
+ };
1952
+ r.debounceInputMs > 0 ? this.contentChangeDebounceTimer = setTimeout(n, r.debounceInputMs) : n(), this.updateStatusBar();
1953
+ }), this.contentElement.addEventListener("contextmenu", (o) => {
1954
+ const r = this.config.contextMenu;
1955
+ (r === !1 || typeof r == "object" && r !== null && r.enabled === !1) && o.preventDefault();
1956
+ }), this.contentElement.addEventListener("paste", (o) => {
1957
+ var d, f;
1958
+ o.preventDefault();
1959
+ const r = this.config.paste || {};
1960
+ let i = ((d = o.clipboardData) == null ? void 0 : d.getData("text/html")) || "";
1961
+ const a = ((f = o.clipboardData) == null ? void 0 : f.getData("text/plain")) || "", n = this.getContentSanitizeConfig(), l = this.getSecurityConfig(), c = !!i && /class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);
1962
+ if ((r.clean || !r.keepFormatting) && a) {
1963
+ document.execCommand("insertText", !1, a);
1964
+ return;
1965
+ }
1966
+ if (r.convertWord === !1 && c && a) {
1967
+ document.execCommand("insertText", !1, a);
1968
+ return;
1969
+ }
1970
+ if (i) {
1971
+ l.sanitizeOnPaste !== !1 && n.sanitize !== !1 && (i = F(i, n, l)), this.insertHTMLAtSelection(i);
1972
+ return;
1973
+ }
1974
+ a && document.execCommand("insertText", !1, a);
1975
+ }), this.contentElement.addEventListener("focus", () => {
1976
+ this.dispatchEvent(new Event("editor-focus", { bubbles: !0 })), this.updateStatusBar();
1977
+ }), this.contentElement.addEventListener("blur", () => {
1978
+ this.contentChangeDebounceTimer && (clearTimeout(this.contentChangeDebounceTimer), this.contentChangeDebounceTimer = void 0), this.contentElement && this.dispatchEvent(new CustomEvent("content-change", {
1979
+ detail: { html: this.contentElement.innerHTML },
1980
+ bubbles: !0
1981
+ })), this.dispatchEvent(new Event("editor-blur", { bubbles: !0 })), this.updateFloatingToolbar(), this.updateStatusBar();
1982
+ }), this.contentElement.addEventListener("keydown", (o) => {
1983
+ this.getAccessibilityConfig().keyboardNavigation && t.handleKeyDown(o, (i, a) => {
1984
+ this.executeCommand(i, a);
1985
+ });
1986
+ });
1987
+ const e = () => {
1988
+ const o = this.getSelectionRangeInEditor(), r = document.activeElement, i = !!r && !!this.contentElement && (r === this.contentElement || this.contentElement.contains(r));
1989
+ this.getPerformanceConfig().viewportOnlyScan && !this.isEditorInViewport() && !i || !o && !i || (this.updateFloatingToolbar(), this.updateStatusBar());
1990
+ };
1991
+ this.selectionChangeHandler = e, document.addEventListener("selectionchange", this.selectionChangeHandler);
1992
+ }
1993
+ getSelectionRangeInEditor() {
1994
+ if (!this.contentElement) return null;
1995
+ const t = window.getSelection();
1996
+ if (!t || t.rangeCount === 0)
1997
+ return null;
1998
+ const e = t.getRangeAt(0), o = e.commonAncestorContainer;
1999
+ return this.contentElement.contains(o) ? e : null;
2000
+ }
2001
+ isSelectionBackward(t) {
2002
+ if (!t.anchorNode || !t.focusNode) return !1;
2003
+ try {
2004
+ const e = document.createRange();
2005
+ return e.setStart(t.anchorNode, t.anchorOffset), e.setEnd(t.focusNode, t.focusOffset), e.collapsed;
2006
+ } catch (e) {
2007
+ return !1;
2008
+ }
2009
+ }
2010
+ getSelectionAnchorRect(t, e) {
2011
+ const o = Array.from(e.getClientRects()).filter((i) => i.width > 0 || i.height > 0);
2012
+ return o.length === 0 ? e.getBoundingClientRect() : this.isSelectionBackward(t) ? o[0] : o[o.length - 1];
2013
+ }
2014
+ /**
2015
+ * Update floating toolbar position
2016
+ */
2017
+ updateFloatingToolbar() {
2018
+ if (!this.floatingToolbar) return;
2019
+ const t = this.getPerformanceConfig(), e = document.activeElement === this.contentElement || !!this.contentElement && this.contentElement.contains(document.activeElement);
2020
+ if (t.viewportOnlyScan && !this.isEditorInViewport() && !e) {
2021
+ this.floatingToolbar.hide();
2022
+ return;
2023
+ }
2024
+ const o = this.getSelectionRangeInEditor();
2025
+ if (!o) {
2026
+ this.floatingToolbar.hide();
2027
+ return;
2028
+ }
2029
+ if (o.collapsed) {
2030
+ this.floatingToolbar.hide();
2031
+ return;
2032
+ }
2033
+ const r = window.getSelection();
2034
+ if (!r) {
2035
+ this.floatingToolbar.hide();
2036
+ return;
2037
+ }
2038
+ const i = this.getSelectionAnchorRect(r, o);
2039
+ if (!i) {
2040
+ this.floatingToolbar.hide();
2041
+ return;
2042
+ }
2043
+ this.floatingToolbar.show(i.left, i.top - 40);
2044
+ }
2045
+ /**
2046
+ * Update status bar with selection and cursor information
2047
+ */
2048
+ /**
2049
+ * Update status bar with current content and cursor information
2050
+ */
2051
+ updateStatusBar() {
2052
+ if (!this.statusBar || !this.contentElement) return;
2053
+ const t = this.getPerformanceConfig(), e = document.activeElement === this.contentElement || this.contentElement.contains(document.activeElement);
2054
+ if (t.viewportOnlyScan && !this.isEditorInViewport() && !e)
2055
+ return;
2056
+ const o = this.contentElement.textContent || "", { words: r, chars: i } = z(o), a = N(this.contentElement);
2057
+ let n, l;
2058
+ const c = this.getSelectionRangeInEditor();
2059
+ c && (n = D(this.contentElement, c), c.collapsed || (l = B(c, n), n = void 0)), this.statusBar.update({
2060
+ wordCount: r,
2061
+ charCount: i,
2062
+ lineCount: a,
2063
+ cursorPosition: n,
2064
+ selectionInfo: l
2065
+ });
2066
+ }
2067
+ /**
2068
+ * Handle attribute changes
2069
+ */
2070
+ handleAttributeChange(t, e) {
2071
+ switch (t) {
2072
+ case "readonly":
2073
+ this.contentElement && (this.contentElement.contentEditable = e === "true" ? "false" : "true", this.applyAccessibilitySettings()), this.engine && this.engine.setReadonly(e === "true");
2074
+ break;
2075
+ case "theme":
2076
+ this.classList.forEach((o) => {
2077
+ o.startsWith("editora-theme-") && this.classList.remove(o);
2078
+ }), e && this.classList.add(`editora-theme-${e}`);
2079
+ break;
2080
+ case "placeholder":
2081
+ this.contentElement && (this.contentElement.setAttribute("data-placeholder", e), this.applyAccessibilitySettings());
2082
+ break;
2083
+ case "accessibility":
2084
+ case "accessibility-enable-aria":
2085
+ case "accessibility-keyboard-navigation":
2086
+ case "accessibility-checker":
2087
+ this.applyAccessibilitySettings();
2088
+ break;
2089
+ case "performance":
2090
+ case "performance-debounce-input-ms":
2091
+ case "performance-viewport-only-scan":
2092
+ break;
2093
+ case "language":
2094
+ case "language-locale":
2095
+ case "language-direction":
2096
+ this.applyLanguageSettings();
2097
+ break;
2098
+ case "spellcheck":
2099
+ case "spellcheck-enabled":
2100
+ case "spellcheck-provider":
2101
+ this.applySpellcheckSettings();
2102
+ break;
2103
+ case "autosave":
2104
+ case "autosave-enabled":
2105
+ case "autosave-interval-ms":
2106
+ case "autosave-storage-key":
2107
+ case "autosave-provider":
2108
+ case "autosave-api-url":
2109
+ this.startAutosave();
2110
+ break;
2111
+ case "security":
2112
+ case "security-sanitize-on-paste":
2113
+ case "security-sanitize-on-input":
2114
+ case "paste":
2115
+ case "paste-clean":
2116
+ case "paste-keep-formatting":
2117
+ case "paste-convert-word":
2118
+ case "context-menu":
2119
+ case "context-menu-enabled":
2120
+ break;
2121
+ case "toolbar":
2122
+ case "toolbar-items":
2123
+ case "toolbar-floating":
2124
+ case "toolbar-sticky":
2125
+ case "plugins":
2126
+ case "statusbar":
2127
+ this.isConnected && (this.destroy(), this.waitForPluginLoader().then(() => {
2128
+ this.initialize().catch((o) => {
2129
+ console.error("[RichTextEditor] Error during attribute change re-initialization:", o);
2130
+ });
2131
+ }));
2132
+ break;
2133
+ }
2134
+ }
2135
+ /**
2136
+ * Resolve configuration from all sources
2137
+ */
2138
+ resolveConfig() {
2139
+ const t = {};
2140
+ for (let e = 0; e < this.attributes.length; e++) {
2141
+ const o = this.attributes[e];
2142
+ t[o.name] = o.value;
2143
+ }
2144
+ return y.resolve({
2145
+ jsConfig: this.jsConfig,
2146
+ attributes: t
2147
+ });
2148
+ }
2149
+ /**
2150
+ * Get public API
2151
+ */
2152
+ getAPI() {
2153
+ return {
2154
+ getContent: () => {
2155
+ var t;
2156
+ return ((t = this.contentElement) == null ? void 0 : t.innerHTML) || "";
2157
+ },
2158
+ setContent: (t) => {
2159
+ this.contentElement && (this.contentElement.innerHTML = t);
2160
+ },
2161
+ execCommand: (t, e) => this.executeCommand(t, e),
2162
+ focus: () => {
2163
+ var t;
2164
+ (t = this.contentElement) == null || t.focus();
2165
+ },
2166
+ blur: () => {
2167
+ var t;
2168
+ (t = this.contentElement) == null || t.blur();
2169
+ },
2170
+ destroy: () => {
2171
+ this.destroy();
2172
+ },
2173
+ on: (t, e) => (this.addEventListener(t, e), () => this.removeEventListener(t, e)),
2174
+ getConfig: () => ({ ...this.config }),
2175
+ setReadonly: (t) => {
2176
+ this.setAttribute("readonly", t.toString());
2177
+ }
2178
+ };
2179
+ }
2180
+ /**
2181
+ * Destroy the editor
2182
+ */
2183
+ destroy() {
2184
+ var t, e, o, r;
2185
+ this.contentChangeDebounceTimer && (clearTimeout(this.contentChangeDebounceTimer), this.contentChangeDebounceTimer = void 0), this.contentElement && this.persistAutosave(this.contentElement.innerHTML || ""), this.stopAutosave(), this.selectionChangeHandler && (document.removeEventListener("selectionchange", this.selectionChangeHandler), this.selectionChangeHandler = void 0), (t = this.engine) == null || t.destroy(), (e = this.toolbar) == null || e.destroy(), (o = this.floatingToolbar) == null || o.destroy(), (r = this.statusBar) == null || r.destroy(), this.innerHTML = "", this.contentElement = void 0, this.toolbarElement = void 0, this.statusBarElement = void 0, this.loadedPlugins = [], this.isInitialized = !1, this.dispatchEvent(new Event("editor-destroy", { bubbles: !0 }));
2186
+ }
2187
+ // Public API methods
2188
+ getContent() {
2189
+ var t;
2190
+ return ((t = this.contentElement) == null ? void 0 : t.innerHTML) || "";
2191
+ }
2192
+ setContent(t) {
2193
+ this.contentElement && (this.contentElement.innerHTML = t);
2194
+ }
2195
+ execCommand(t, e) {
2196
+ return this.executeCommand(t, e);
2197
+ }
2198
+ focus() {
2199
+ var t;
2200
+ (t = this.contentElement) == null || t.focus();
2201
+ }
2202
+ blur() {
2203
+ var t;
2204
+ (t = this.contentElement) == null || t.blur();
2205
+ }
2206
+ }
2207
+ export {
2208
+ M as C,
2209
+ b as E,
2210
+ T as F,
2211
+ S as K,
2212
+ E as P,
2213
+ g as R,
2214
+ C as S,
2215
+ L as T,
2216
+ A as a,
2217
+ I as b,
2218
+ P as c,
2219
+ N as d,
2220
+ z as e,
2221
+ B as f,
2222
+ D as g,
2223
+ y as h,
2224
+ O as i,
2225
+ K as j
2226
+ };
2227
+ //# sourceMappingURL=index-OwnkG39N.mjs.map