ckeditor5-symfony 1.0.0

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 (174) hide show
  1. package/dist/ckeditor5-symfony-error.d.ts +7 -0
  2. package/dist/ckeditor5-symfony-error.d.ts.map +1 -0
  3. package/dist/elements/context/context.d.ts +18 -0
  4. package/dist/elements/context/context.d.ts.map +1 -0
  5. package/dist/elements/context/contexts-registry.d.ts +9 -0
  6. package/dist/elements/context/contexts-registry.d.ts.map +1 -0
  7. package/dist/elements/context/index.d.ts +4 -0
  8. package/dist/elements/context/index.d.ts.map +1 -0
  9. package/dist/elements/context/typings.d.ts +34 -0
  10. package/dist/elements/context/typings.d.ts.map +1 -0
  11. package/dist/elements/editable.d.ts +18 -0
  12. package/dist/elements/editable.d.ts.map +1 -0
  13. package/dist/elements/editor/custom-editor-plugins.d.ts +54 -0
  14. package/dist/elements/editor/custom-editor-plugins.d.ts.map +1 -0
  15. package/dist/elements/editor/editor.d.ts +23 -0
  16. package/dist/elements/editor/editor.d.ts.map +1 -0
  17. package/dist/elements/editor/editors-registry.d.ts +9 -0
  18. package/dist/elements/editor/editors-registry.d.ts.map +1 -0
  19. package/dist/elements/editor/index.d.ts +3 -0
  20. package/dist/elements/editor/index.d.ts.map +1 -0
  21. package/dist/elements/editor/plugins/index.d.ts +2 -0
  22. package/dist/elements/editor/plugins/index.d.ts.map +1 -0
  23. package/dist/elements/editor/plugins/sync-editor-with-input.d.ts +6 -0
  24. package/dist/elements/editor/plugins/sync-editor-with-input.d.ts.map +1 -0
  25. package/dist/elements/editor/typings.d.ts +99 -0
  26. package/dist/elements/editor/typings.d.ts.map +1 -0
  27. package/dist/elements/editor/utils/create-editor-in-context.d.ts +44 -0
  28. package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -0
  29. package/dist/elements/editor/utils/index.d.ts +12 -0
  30. package/dist/elements/editor/utils/index.d.ts.map +1 -0
  31. package/dist/elements/editor/utils/is-single-root-editor.d.ts +9 -0
  32. package/dist/elements/editor/utils/is-single-root-editor.d.ts.map +1 -0
  33. package/dist/elements/editor/utils/load-editor-constructor.d.ts +9 -0
  34. package/dist/elements/editor/utils/load-editor-constructor.d.ts.map +1 -0
  35. package/dist/elements/editor/utils/load-editor-plugins.d.ts +20 -0
  36. package/dist/elements/editor/utils/load-editor-plugins.d.ts.map +1 -0
  37. package/dist/elements/editor/utils/load-editor-translations.d.ts +14 -0
  38. package/dist/elements/editor/utils/load-editor-translations.d.ts.map +1 -0
  39. package/dist/elements/editor/utils/normalize-custom-translations.d.ts +11 -0
  40. package/dist/elements/editor/utils/normalize-custom-translations.d.ts.map +1 -0
  41. package/dist/elements/editor/utils/query-all-editor-ids.d.ts +5 -0
  42. package/dist/elements/editor/utils/query-all-editor-ids.d.ts.map +1 -0
  43. package/dist/elements/editor/utils/query-editor-editables.d.ts +25 -0
  44. package/dist/elements/editor/utils/query-editor-editables.d.ts.map +1 -0
  45. package/dist/elements/editor/utils/resolve-editor-config-elements-references.d.ts +9 -0
  46. package/dist/elements/editor/utils/resolve-editor-config-elements-references.d.ts.map +1 -0
  47. package/dist/elements/editor/utils/set-editor-editable-height.d.ts +9 -0
  48. package/dist/elements/editor/utils/set-editor-editable-height.d.ts.map +1 -0
  49. package/dist/elements/editor/utils/wrap-with-watchdog.d.ts +24 -0
  50. package/dist/elements/editor/utils/wrap-with-watchdog.d.ts.map +1 -0
  51. package/dist/elements/index.d.ts +6 -0
  52. package/dist/elements/index.d.ts.map +1 -0
  53. package/dist/elements/register-custom-elements.d.ts +5 -0
  54. package/dist/elements/register-custom-elements.d.ts.map +1 -0
  55. package/dist/elements/ui-part.d.ts +18 -0
  56. package/dist/elements/ui-part.d.ts.map +1 -0
  57. package/dist/index.cjs +5 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/index.d.ts +3 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.mjs +1089 -0
  62. package/dist/index.mjs.map +1 -0
  63. package/dist/shared/async-registry.d.ts +136 -0
  64. package/dist/shared/async-registry.d.ts.map +1 -0
  65. package/dist/shared/camel-case.d.ts +8 -0
  66. package/dist/shared/camel-case.d.ts.map +1 -0
  67. package/dist/shared/debounce.d.ts +2 -0
  68. package/dist/shared/debounce.d.ts.map +1 -0
  69. package/dist/shared/deep-camel-case-keys.d.ts +8 -0
  70. package/dist/shared/deep-camel-case-keys.d.ts.map +1 -0
  71. package/dist/shared/filter-object-values.d.ts +9 -0
  72. package/dist/shared/filter-object-values.d.ts.map +1 -0
  73. package/dist/shared/index.d.ts +15 -0
  74. package/dist/shared/index.d.ts.map +1 -0
  75. package/dist/shared/is-empty-object.d.ts +2 -0
  76. package/dist/shared/is-empty-object.d.ts.map +1 -0
  77. package/dist/shared/is-plain-object.d.ts +8 -0
  78. package/dist/shared/is-plain-object.d.ts.map +1 -0
  79. package/dist/shared/map-object-values.d.ts +11 -0
  80. package/dist/shared/map-object-values.d.ts.map +1 -0
  81. package/dist/shared/once.d.ts +2 -0
  82. package/dist/shared/once.d.ts.map +1 -0
  83. package/dist/shared/shallow-equal.d.ts +9 -0
  84. package/dist/shared/shallow-equal.d.ts.map +1 -0
  85. package/dist/shared/timeout.d.ts +8 -0
  86. package/dist/shared/timeout.d.ts.map +1 -0
  87. package/dist/shared/uid.d.ts +7 -0
  88. package/dist/shared/uid.d.ts.map +1 -0
  89. package/dist/shared/wait-for-dom-ready.d.ts +5 -0
  90. package/dist/shared/wait-for-dom-ready.d.ts.map +1 -0
  91. package/dist/shared/wait-for.d.ts +20 -0
  92. package/dist/shared/wait-for.d.ts.map +1 -0
  93. package/dist/types/can-be-promise.type.d.ts +2 -0
  94. package/dist/types/can-be-promise.type.d.ts.map +1 -0
  95. package/dist/types/index.d.ts +3 -0
  96. package/dist/types/index.d.ts.map +1 -0
  97. package/dist/types/required-by.type.d.ts +2 -0
  98. package/dist/types/required-by.type.d.ts.map +1 -0
  99. package/package.json +40 -0
  100. package/src/ckeditor5-symfony-error.ts +9 -0
  101. package/src/elements/context/context.test.ts +291 -0
  102. package/src/elements/context/context.ts +99 -0
  103. package/src/elements/context/contexts-registry.test.ts +10 -0
  104. package/src/elements/context/contexts-registry.ts +10 -0
  105. package/src/elements/context/index.ts +3 -0
  106. package/src/elements/context/typings.ts +39 -0
  107. package/src/elements/editable.test.ts +334 -0
  108. package/src/elements/editable.ts +114 -0
  109. package/src/elements/editor/custom-editor-plugins.test.ts +103 -0
  110. package/src/elements/editor/custom-editor-plugins.ts +86 -0
  111. package/src/elements/editor/editor.test.ts +438 -0
  112. package/src/elements/editor/editor.ts +279 -0
  113. package/src/elements/editor/editors-registry.test.ts +10 -0
  114. package/src/elements/editor/editors-registry.ts +10 -0
  115. package/src/elements/editor/index.ts +2 -0
  116. package/src/elements/editor/plugins/index.ts +1 -0
  117. package/src/elements/editor/plugins/sync-editor-with-input.ts +78 -0
  118. package/src/elements/editor/typings.ts +114 -0
  119. package/src/elements/editor/utils/create-editor-in-context.ts +90 -0
  120. package/src/elements/editor/utils/index.ts +11 -0
  121. package/src/elements/editor/utils/is-single-root-editor.test.ts +40 -0
  122. package/src/elements/editor/utils/is-single-root-editor.ts +11 -0
  123. package/src/elements/editor/utils/load-editor-constructor.test.ts +62 -0
  124. package/src/elements/editor/utils/load-editor-constructor.ts +29 -0
  125. package/src/elements/editor/utils/load-editor-plugins.test.ts +100 -0
  126. package/src/elements/editor/utils/load-editor-plugins.ts +73 -0
  127. package/src/elements/editor/utils/load-editor-translations.ts +233 -0
  128. package/src/elements/editor/utils/normalize-custom-translations.test.ts +152 -0
  129. package/src/elements/editor/utils/normalize-custom-translations.ts +18 -0
  130. package/src/elements/editor/utils/query-all-editor-ids.ts +9 -0
  131. package/src/elements/editor/utils/query-editor-editables.ts +101 -0
  132. package/src/elements/editor/utils/resolve-editor-config-elements-references.test.ts +93 -0
  133. package/src/elements/editor/utils/resolve-editor-config-elements-references.ts +36 -0
  134. package/src/elements/editor/utils/set-editor-editable-height.test.ts +131 -0
  135. package/src/elements/editor/utils/set-editor-editable-height.ts +15 -0
  136. package/src/elements/editor/utils/wrap-with-watchdog.test.ts +45 -0
  137. package/src/elements/editor/utils/wrap-with-watchdog.ts +51 -0
  138. package/src/elements/index.ts +14 -0
  139. package/src/elements/register-custom-elements.ts +24 -0
  140. package/src/elements/ui-part.test.ts +142 -0
  141. package/src/elements/ui-part.ts +80 -0
  142. package/src/index.ts +6 -0
  143. package/src/shared/async-registry.test.ts +737 -0
  144. package/src/shared/async-registry.ts +353 -0
  145. package/src/shared/camel-case.test.ts +35 -0
  146. package/src/shared/camel-case.ts +11 -0
  147. package/src/shared/debounce.test.ts +72 -0
  148. package/src/shared/debounce.ts +16 -0
  149. package/src/shared/deep-camel-case-keys.test.ts +34 -0
  150. package/src/shared/deep-camel-case-keys.ts +26 -0
  151. package/src/shared/filter-object-values.test.ts +25 -0
  152. package/src/shared/filter-object-values.ts +17 -0
  153. package/src/shared/index.ts +14 -0
  154. package/src/shared/is-empty-object.test.ts +78 -0
  155. package/src/shared/is-empty-object.ts +3 -0
  156. package/src/shared/is-plain-object.test.ts +38 -0
  157. package/src/shared/is-plain-object.ts +15 -0
  158. package/src/shared/map-object-values.test.ts +29 -0
  159. package/src/shared/map-object-values.ts +19 -0
  160. package/src/shared/once.test.ts +116 -0
  161. package/src/shared/once.ts +12 -0
  162. package/src/shared/shallow-equal.test.ts +51 -0
  163. package/src/shared/shallow-equal.ts +30 -0
  164. package/src/shared/timeout.test.ts +65 -0
  165. package/src/shared/timeout.ts +13 -0
  166. package/src/shared/uid.test.ts +25 -0
  167. package/src/shared/uid.ts +8 -0
  168. package/src/shared/wait-for-dom-ready.test.ts +87 -0
  169. package/src/shared/wait-for-dom-ready.ts +21 -0
  170. package/src/shared/wait-for.test.ts +24 -0
  171. package/src/shared/wait-for.ts +56 -0
  172. package/src/types/can-be-promise.type.ts +1 -0
  173. package/src/types/index.ts +2 -0
  174. package/src/types/required-by.type.ts +1 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,1089 @@
1
+ class N {
2
+ /**
3
+ * Map of registered items.
4
+ */
5
+ items = /* @__PURE__ */ new Map();
6
+ /**
7
+ * Map of initialization errors for items that failed to register.
8
+ */
9
+ initializationErrors = /* @__PURE__ */ new Map();
10
+ /**
11
+ * Map of pending callbacks waiting for items to be registered or fail.
12
+ */
13
+ pendingCallbacks = /* @__PURE__ */ new Map();
14
+ /**
15
+ * Set of watchers that observe changes to the registry.
16
+ */
17
+ watchers = /* @__PURE__ */ new Set();
18
+ /**
19
+ * Executes a function on an item.
20
+ * If the item is not yet registered, it will wait for it to be registered.
21
+ *
22
+ * @param id The ID of the item.
23
+ * @param onSuccess The function to execute.
24
+ * @param onError Optional error callback.
25
+ * @returns A promise that resolves with the result of the function.
26
+ */
27
+ execute(t, e, i) {
28
+ const a = this.items.get(t), n = this.initializationErrors.get(t);
29
+ return n ? (i?.(n), Promise.reject(n)) : a ? Promise.resolve(e(a)) : new Promise((s, o) => {
30
+ const c = this.getPendingCallbacks(t);
31
+ c.success.push(async (u) => {
32
+ s(await e(u));
33
+ }), i ? c.error.push(i) : c.error.push(o);
34
+ });
35
+ }
36
+ /**
37
+ * Registers an item.
38
+ *
39
+ * @param id The ID of the item.
40
+ * @param item The item instance.
41
+ */
42
+ register(t, e) {
43
+ if (this.items.has(t))
44
+ throw new Error(`Item with ID "${t}" is already registered.`);
45
+ this.resetErrors(t), this.items.set(t, e);
46
+ const i = this.pendingCallbacks.get(t);
47
+ i && (i.success.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.registerAsDefault(t, e), this.notifyWatchers();
48
+ }
49
+ /**
50
+ * Registers an error for an item.
51
+ *
52
+ * @param id The ID of the item.
53
+ * @param error The error to register.
54
+ */
55
+ error(t, e) {
56
+ this.items.delete(t), this.initializationErrors.set(t, e);
57
+ const i = this.pendingCallbacks.get(t);
58
+ i && (i.error.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e), this.notifyWatchers();
59
+ }
60
+ /**
61
+ * Resets errors for an item.
62
+ *
63
+ * @param id The ID of the item.
64
+ */
65
+ resetErrors(t) {
66
+ const { initializationErrors: e } = this;
67
+ e.has(null) && e.get(null) === e.get(t) && e.delete(null), e.delete(t);
68
+ }
69
+ /**
70
+ * Un-registers an item.
71
+ *
72
+ * @param id The ID of the item.
73
+ */
74
+ unregister(t) {
75
+ if (!this.items.has(t))
76
+ throw new Error(`Item with ID "${t}" is not registered.`);
77
+ t && this.items.get(null) === this.items.get(t) && this.unregister(null), this.items.delete(t), this.pendingCallbacks.delete(t), this.notifyWatchers();
78
+ }
79
+ /**
80
+ * Gets all registered items.
81
+ *
82
+ * @returns An array of all registered items.
83
+ */
84
+ getItems() {
85
+ return Array.from(this.items.values());
86
+ }
87
+ /**
88
+ * Checks if an item with the given ID is registered.
89
+ *
90
+ * @param id The ID of the item.
91
+ * @returns `true` if the item is registered, `false` otherwise.
92
+ */
93
+ hasItem(t) {
94
+ return this.items.has(t);
95
+ }
96
+ /**
97
+ * Gets a promise that resolves with the item instance for the given ID.
98
+ * If the item is not registered yet, it will wait for it to be registered.
99
+ *
100
+ * @param id The ID of the item.
101
+ * @param timeout Optional timeout in milliseconds.
102
+ * @returns A promise that resolves with the item instance.
103
+ */
104
+ waitFor(t, e) {
105
+ return new Promise((i, a) => {
106
+ let n = !1, s = null;
107
+ this.execute(
108
+ t,
109
+ (o) => {
110
+ n || (s !== null && clearTimeout(s), i(o));
111
+ },
112
+ (o) => {
113
+ n || (s !== null && clearTimeout(s), a(o));
114
+ }
115
+ ), e && (s = setTimeout(() => {
116
+ n = !0, a(new Error(`Timeout waiting for item with ID "${t}" to be registered.`));
117
+ }, e));
118
+ });
119
+ }
120
+ /**
121
+ * Destroys all registered items and clears the registry.
122
+ * This will call the `destroy` method on each item.
123
+ */
124
+ async destroyAll() {
125
+ const t = Array.from(new Set(this.items.values())).map((e) => e.destroy());
126
+ this.items.clear(), this.pendingCallbacks.clear(), await Promise.all(t), this.notifyWatchers();
127
+ }
128
+ /**
129
+ * Registers a watcher that will be called whenever the registry changes.
130
+ *
131
+ * @param watcher The watcher function to register.
132
+ * @returns A function to unregister the watcher.
133
+ */
134
+ watch(t) {
135
+ return this.watchers.add(t), t(
136
+ new Map(this.items),
137
+ new Map(this.initializationErrors)
138
+ ), this.unwatch.bind(this, t);
139
+ }
140
+ /**
141
+ * Un-registers a watcher.
142
+ *
143
+ * @param watcher The watcher function to unregister.
144
+ */
145
+ unwatch(t) {
146
+ this.watchers.delete(t);
147
+ }
148
+ /**
149
+ * Resets the registry by clearing all items, errors, and pending callbacks.
150
+ */
151
+ reset() {
152
+ this.items.clear(), this.initializationErrors.clear(), this.pendingCallbacks.clear(), this.notifyWatchers();
153
+ }
154
+ /**
155
+ * Notifies all watchers about changes to the registry.
156
+ */
157
+ notifyWatchers() {
158
+ this.watchers.forEach(
159
+ (t) => t(
160
+ new Map(this.items),
161
+ new Map(this.initializationErrors)
162
+ )
163
+ );
164
+ }
165
+ /**
166
+ * Gets or creates pending callbacks for a specific ID.
167
+ *
168
+ * @param id The ID of the item.
169
+ * @returns The pending callbacks structure.
170
+ */
171
+ getPendingCallbacks(t) {
172
+ let e = this.pendingCallbacks.get(t);
173
+ return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
174
+ }
175
+ /**
176
+ * Registers an item as the default (null ID) item if it's the first one.
177
+ *
178
+ * @param id The ID of the item being registered.
179
+ * @param item The item instance.
180
+ */
181
+ registerAsDefault(t, e) {
182
+ this.items.size === 1 && t !== null && this.register(null, e);
183
+ }
184
+ }
185
+ function R(r, t) {
186
+ let e = null;
187
+ return (...i) => {
188
+ e && clearTimeout(e), e = setTimeout(() => {
189
+ t(...i);
190
+ }, r);
191
+ };
192
+ }
193
+ function J(r, t) {
194
+ const e = Object.entries(r).filter(([i, a]) => t(a, i));
195
+ return Object.fromEntries(e);
196
+ }
197
+ function L(r) {
198
+ return Object.keys(r).length === 0 && r.constructor === Object;
199
+ }
200
+ function x(r, t) {
201
+ const e = Object.entries(r).map(([i, a]) => [i, t(a, i)]);
202
+ return Object.fromEntries(e);
203
+ }
204
+ function _() {
205
+ return Math.random().toString(36).substring(2);
206
+ }
207
+ function K(r, {
208
+ timeOutAfter: t = 500,
209
+ retryAfter: e = 100
210
+ } = {}) {
211
+ return new Promise((i, a) => {
212
+ const n = Date.now();
213
+ let s = null;
214
+ const o = setTimeout(() => {
215
+ a(s ?? new Error("Timeout"));
216
+ }, t), c = async () => {
217
+ try {
218
+ const u = await r();
219
+ clearTimeout(o), i(u);
220
+ } catch (u) {
221
+ s = u, Date.now() - n > t ? a(u) : setTimeout(c, e);
222
+ }
223
+ };
224
+ c();
225
+ });
226
+ }
227
+ function A() {
228
+ return new Promise((r) => {
229
+ switch (document.readyState) {
230
+ case "loading":
231
+ document.addEventListener("DOMContentLoaded", () => r(), { once: !0 });
232
+ break;
233
+ case "interactive":
234
+ case "complete":
235
+ setTimeout(r, 0);
236
+ break;
237
+ default:
238
+ console.warn("Unexpected document.readyState:", document.readyState), setTimeout(r, 0);
239
+ }
240
+ });
241
+ }
242
+ const v = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
243
+ async function G({ element: r, context: t, creator: e, config: i }) {
244
+ const a = _();
245
+ await t.add({
246
+ creator: (c, u) => e.create(c, u),
247
+ id: a,
248
+ sourceElementOrData: r,
249
+ type: "editor",
250
+ config: i
251
+ });
252
+ const n = t.getItem(a), s = {
253
+ state: "available",
254
+ editorContextId: a,
255
+ context: t
256
+ };
257
+ n[v] = s;
258
+ const o = t.destroy.bind(t);
259
+ return t.destroy = async () => (s.state = "unavailable", o()), {
260
+ ...s,
261
+ editor: n
262
+ };
263
+ }
264
+ function Y(r) {
265
+ return v in r ? r[v] : null;
266
+ }
267
+ function C(r) {
268
+ return ["inline", "classic", "balloon", "decoupled"].includes(r);
269
+ }
270
+ class h extends Error {
271
+ constructor(t) {
272
+ super(t), this.name = "CKEditor5SymfonyError";
273
+ }
274
+ }
275
+ async function X(r) {
276
+ const t = await import("ckeditor5"), i = {
277
+ inline: t.InlineEditor,
278
+ balloon: t.BalloonEditor,
279
+ classic: t.ClassicEditor,
280
+ decoupled: t.DecoupledEditor,
281
+ multiroot: t.MultiRootEditor
282
+ }[r];
283
+ if (!i)
284
+ throw new h(`Unsupported editor type: ${r}`);
285
+ return i;
286
+ }
287
+ class S {
288
+ static the = new S();
289
+ /**
290
+ * Map of registered custom plugins.
291
+ */
292
+ plugins = /* @__PURE__ */ new Map();
293
+ /**
294
+ * Private constructor to enforce singleton pattern.
295
+ */
296
+ constructor() {
297
+ }
298
+ /**
299
+ * Registers a custom plugin for the CKEditor.
300
+ *
301
+ * @param name The name of the plugin.
302
+ * @param reader The plugin reader function that returns the plugin constructor.
303
+ * @returns A function to unregister the plugin.
304
+ */
305
+ register(t, e) {
306
+ if (this.plugins.has(t))
307
+ throw new h(`Plugin with name "${t}" is already registered.`);
308
+ return this.plugins.set(t, e), this.unregister.bind(this, t);
309
+ }
310
+ /**
311
+ * Removes a custom plugin by its name.
312
+ *
313
+ * @param name The name of the plugin to unregister.
314
+ * @throws Will throw an error if the plugin is not registered.
315
+ */
316
+ unregister(t) {
317
+ if (!this.plugins.has(t))
318
+ throw new h(`Plugin with name "${t}" is not registered.`);
319
+ this.plugins.delete(t);
320
+ }
321
+ /**
322
+ * Removes all custom editor plugins.
323
+ * This is useful for cleanup in tests or when reloading plugins.
324
+ */
325
+ unregisterAll() {
326
+ this.plugins.clear();
327
+ }
328
+ /**
329
+ * Retrieves a custom plugin by its name.
330
+ *
331
+ * @param name The name of the plugin.
332
+ * @returns The plugin constructor or undefined if not found.
333
+ */
334
+ async get(t) {
335
+ return this.plugins.get(t)?.();
336
+ }
337
+ /**
338
+ * Checks if a plugin with the given name is registered.
339
+ *
340
+ * @param name The name of the plugin.
341
+ * @returns `true` if the plugin is registered, `false` otherwise.
342
+ */
343
+ has(t) {
344
+ return this.plugins.has(t);
345
+ }
346
+ }
347
+ async function W(r) {
348
+ const t = await import("ckeditor5");
349
+ let e = null;
350
+ const i = r.map(async (a) => {
351
+ const n = await S.the.get(a);
352
+ if (n)
353
+ return n;
354
+ const { [a]: s } = t;
355
+ if (s)
356
+ return s;
357
+ if (!e)
358
+ try {
359
+ e = await import("ckeditor5-premium-features");
360
+ } catch (c) {
361
+ throw console.error(`Failed to load premium package: ${c}`), new h(`Plugin "${a}" not found in base package and failed to load premium package.`);
362
+ }
363
+ const { [a]: o } = e || {};
364
+ if (o)
365
+ return o;
366
+ throw new h(`Plugin "${a}" not found in base or premium packages.`);
367
+ });
368
+ return {
369
+ loadedPlugins: await Promise.all(i),
370
+ hasPremium: !!e
371
+ };
372
+ }
373
+ async function q(r, t) {
374
+ const e = [r.ui, r.content];
375
+ return await Promise.all(
376
+ [
377
+ $("ckeditor5", e),
378
+ /* v8 ignore next */
379
+ t && $("ckeditor5-premium-features", e)
380
+ ].filter((a) => !!a)
381
+ ).then((a) => a.flat());
382
+ }
383
+ async function $(r, t) {
384
+ return await Promise.all(
385
+ t.filter((e) => e !== "en").map(async (e) => {
386
+ const i = await Q(r, e);
387
+ return i?.default ?? i;
388
+ }).filter(Boolean)
389
+ );
390
+ }
391
+ async function Q(r, t) {
392
+ try {
393
+ if (r === "ckeditor5")
394
+ switch (t) {
395
+ case "af":
396
+ return await import("ckeditor5/translations/af.js");
397
+ case "ar":
398
+ return await import("ckeditor5/translations/ar.js");
399
+ case "ast":
400
+ return await import("ckeditor5/translations/ast.js");
401
+ case "az":
402
+ return await import("ckeditor5/translations/az.js");
403
+ case "bg":
404
+ return await import("ckeditor5/translations/bg.js");
405
+ case "bn":
406
+ return await import("ckeditor5/translations/bn.js");
407
+ case "bs":
408
+ return await import("ckeditor5/translations/bs.js");
409
+ case "ca":
410
+ return await import("ckeditor5/translations/ca.js");
411
+ case "cs":
412
+ return await import("ckeditor5/translations/cs.js");
413
+ case "da":
414
+ return await import("ckeditor5/translations/da.js");
415
+ case "de":
416
+ return await import("ckeditor5/translations/de.js");
417
+ case "de-ch":
418
+ return await import("ckeditor5/translations/de-ch.js");
419
+ case "el":
420
+ return await import("ckeditor5/translations/el.js");
421
+ case "en":
422
+ return await import("ckeditor5/translations/en.js");
423
+ case "en-au":
424
+ return await import("ckeditor5/translations/en-au.js");
425
+ case "en-gb":
426
+ return await import("ckeditor5/translations/en-gb.js");
427
+ case "eo":
428
+ return await import("ckeditor5/translations/eo.js");
429
+ case "es":
430
+ return await import("ckeditor5/translations/es.js");
431
+ case "es-co":
432
+ return await import("ckeditor5/translations/es-co.js");
433
+ case "et":
434
+ return await import("ckeditor5/translations/et.js");
435
+ case "eu":
436
+ return await import("ckeditor5/translations/eu.js");
437
+ case "fa":
438
+ return await import("ckeditor5/translations/fa.js");
439
+ case "fi":
440
+ return await import("ckeditor5/translations/fi.js");
441
+ case "fr":
442
+ return await import("ckeditor5/translations/fr.js");
443
+ case "gl":
444
+ return await import("ckeditor5/translations/gl.js");
445
+ case "gu":
446
+ return await import("ckeditor5/translations/gu.js");
447
+ case "he":
448
+ return await import("ckeditor5/translations/he.js");
449
+ case "hi":
450
+ return await import("ckeditor5/translations/hi.js");
451
+ case "hr":
452
+ return await import("ckeditor5/translations/hr.js");
453
+ case "hu":
454
+ return await import("ckeditor5/translations/hu.js");
455
+ case "hy":
456
+ return await import("ckeditor5/translations/hy.js");
457
+ case "id":
458
+ return await import("ckeditor5/translations/id.js");
459
+ case "it":
460
+ return await import("ckeditor5/translations/it.js");
461
+ case "ja":
462
+ return await import("ckeditor5/translations/ja.js");
463
+ case "jv":
464
+ return await import("ckeditor5/translations/jv.js");
465
+ case "kk":
466
+ return await import("ckeditor5/translations/kk.js");
467
+ case "km":
468
+ return await import("ckeditor5/translations/km.js");
469
+ case "kn":
470
+ return await import("ckeditor5/translations/kn.js");
471
+ case "ko":
472
+ return await import("ckeditor5/translations/ko.js");
473
+ case "ku":
474
+ return await import("ckeditor5/translations/ku.js");
475
+ case "lt":
476
+ return await import("ckeditor5/translations/lt.js");
477
+ case "lv":
478
+ return await import("ckeditor5/translations/lv.js");
479
+ case "ms":
480
+ return await import("ckeditor5/translations/ms.js");
481
+ case "nb":
482
+ return await import("ckeditor5/translations/nb.js");
483
+ case "ne":
484
+ return await import("ckeditor5/translations/ne.js");
485
+ case "nl":
486
+ return await import("ckeditor5/translations/nl.js");
487
+ case "no":
488
+ return await import("ckeditor5/translations/no.js");
489
+ case "oc":
490
+ return await import("ckeditor5/translations/oc.js");
491
+ case "pl":
492
+ return await import("ckeditor5/translations/pl.js");
493
+ case "pt":
494
+ return await import("ckeditor5/translations/pt.js");
495
+ case "pt-br":
496
+ return await import("ckeditor5/translations/pt-br.js");
497
+ case "ro":
498
+ return await import("ckeditor5/translations/ro.js");
499
+ case "ru":
500
+ return await import("ckeditor5/translations/ru.js");
501
+ case "si":
502
+ return await import("ckeditor5/translations/si.js");
503
+ case "sk":
504
+ return await import("ckeditor5/translations/sk.js");
505
+ case "sl":
506
+ return await import("ckeditor5/translations/sl.js");
507
+ case "sq":
508
+ return await import("ckeditor5/translations/sq.js");
509
+ case "sr":
510
+ return await import("ckeditor5/translations/sr.js");
511
+ case "sr-latn":
512
+ return await import("ckeditor5/translations/sr-latn.js");
513
+ case "sv":
514
+ return await import("ckeditor5/translations/sv.js");
515
+ case "th":
516
+ return await import("ckeditor5/translations/th.js");
517
+ case "tk":
518
+ return await import("ckeditor5/translations/tk.js");
519
+ case "tr":
520
+ return await import("ckeditor5/translations/tr.js");
521
+ case "tt":
522
+ return await import("ckeditor5/translations/tt.js");
523
+ case "ug":
524
+ return await import("ckeditor5/translations/ug.js");
525
+ case "uk":
526
+ return await import("ckeditor5/translations/uk.js");
527
+ case "ur":
528
+ return await import("ckeditor5/translations/ur.js");
529
+ case "uz":
530
+ return await import("ckeditor5/translations/uz.js");
531
+ case "vi":
532
+ return await import("ckeditor5/translations/vi.js");
533
+ case "zh":
534
+ return await import("ckeditor5/translations/zh.js");
535
+ case "zh-cn":
536
+ return await import("ckeditor5/translations/zh-cn.js");
537
+ default:
538
+ return console.warn(`Language ${t} not found in ckeditor5 translations`), null;
539
+ }
540
+ else
541
+ switch (t) {
542
+ case "af":
543
+ return await import("ckeditor5-premium-features/translations/af.js");
544
+ case "ar":
545
+ return await import("ckeditor5-premium-features/translations/ar.js");
546
+ case "ast":
547
+ return await import("ckeditor5-premium-features/translations/ast.js");
548
+ case "az":
549
+ return await import("ckeditor5-premium-features/translations/az.js");
550
+ case "bg":
551
+ return await import("ckeditor5-premium-features/translations/bg.js");
552
+ case "bn":
553
+ return await import("ckeditor5-premium-features/translations/bn.js");
554
+ case "bs":
555
+ return await import("ckeditor5-premium-features/translations/bs.js");
556
+ case "ca":
557
+ return await import("ckeditor5-premium-features/translations/ca.js");
558
+ case "cs":
559
+ return await import("ckeditor5-premium-features/translations/cs.js");
560
+ case "da":
561
+ return await import("ckeditor5-premium-features/translations/da.js");
562
+ case "de":
563
+ return await import("ckeditor5-premium-features/translations/de.js");
564
+ case "de-ch":
565
+ return await import("ckeditor5-premium-features/translations/de-ch.js");
566
+ case "el":
567
+ return await import("ckeditor5-premium-features/translations/el.js");
568
+ case "en":
569
+ return await import("ckeditor5-premium-features/translations/en.js");
570
+ case "en-au":
571
+ return await import("ckeditor5-premium-features/translations/en-au.js");
572
+ case "en-gb":
573
+ return await import("ckeditor5-premium-features/translations/en-gb.js");
574
+ case "eo":
575
+ return await import("ckeditor5-premium-features/translations/eo.js");
576
+ case "es":
577
+ return await import("ckeditor5-premium-features/translations/es.js");
578
+ case "es-co":
579
+ return await import("ckeditor5-premium-features/translations/es-co.js");
580
+ case "et":
581
+ return await import("ckeditor5-premium-features/translations/et.js");
582
+ case "eu":
583
+ return await import("ckeditor5-premium-features/translations/eu.js");
584
+ case "fa":
585
+ return await import("ckeditor5-premium-features/translations/fa.js");
586
+ case "fi":
587
+ return await import("ckeditor5-premium-features/translations/fi.js");
588
+ case "fr":
589
+ return await import("ckeditor5-premium-features/translations/fr.js");
590
+ case "gl":
591
+ return await import("ckeditor5-premium-features/translations/gl.js");
592
+ case "gu":
593
+ return await import("ckeditor5-premium-features/translations/gu.js");
594
+ case "he":
595
+ return await import("ckeditor5-premium-features/translations/he.js");
596
+ case "hi":
597
+ return await import("ckeditor5-premium-features/translations/hi.js");
598
+ case "hr":
599
+ return await import("ckeditor5-premium-features/translations/hr.js");
600
+ case "hu":
601
+ return await import("ckeditor5-premium-features/translations/hu.js");
602
+ case "hy":
603
+ return await import("ckeditor5-premium-features/translations/hy.js");
604
+ case "id":
605
+ return await import("ckeditor5-premium-features/translations/id.js");
606
+ case "it":
607
+ return await import("ckeditor5-premium-features/translations/it.js");
608
+ case "ja":
609
+ return await import("ckeditor5-premium-features/translations/ja.js");
610
+ case "jv":
611
+ return await import("ckeditor5-premium-features/translations/jv.js");
612
+ case "kk":
613
+ return await import("ckeditor5-premium-features/translations/kk.js");
614
+ case "km":
615
+ return await import("ckeditor5-premium-features/translations/km.js");
616
+ case "kn":
617
+ return await import("ckeditor5-premium-features/translations/kn.js");
618
+ case "ko":
619
+ return await import("ckeditor5-premium-features/translations/ko.js");
620
+ case "ku":
621
+ return await import("ckeditor5-premium-features/translations/ku.js");
622
+ case "lt":
623
+ return await import("ckeditor5-premium-features/translations/lt.js");
624
+ case "lv":
625
+ return await import("ckeditor5-premium-features/translations/lv.js");
626
+ case "ms":
627
+ return await import("ckeditor5-premium-features/translations/ms.js");
628
+ case "nb":
629
+ return await import("ckeditor5-premium-features/translations/nb.js");
630
+ case "ne":
631
+ return await import("ckeditor5-premium-features/translations/ne.js");
632
+ case "nl":
633
+ return await import("ckeditor5-premium-features/translations/nl.js");
634
+ case "no":
635
+ return await import("ckeditor5-premium-features/translations/no.js");
636
+ case "oc":
637
+ return await import("ckeditor5-premium-features/translations/oc.js");
638
+ case "pl":
639
+ return await import("ckeditor5-premium-features/translations/pl.js");
640
+ case "pt":
641
+ return await import("ckeditor5-premium-features/translations/pt.js");
642
+ case "pt-br":
643
+ return await import("ckeditor5-premium-features/translations/pt-br.js");
644
+ case "ro":
645
+ return await import("ckeditor5-premium-features/translations/ro.js");
646
+ case "ru":
647
+ return await import("ckeditor5-premium-features/translations/ru.js");
648
+ case "si":
649
+ return await import("ckeditor5-premium-features/translations/si.js");
650
+ case "sk":
651
+ return await import("ckeditor5-premium-features/translations/sk.js");
652
+ case "sl":
653
+ return await import("ckeditor5-premium-features/translations/sl.js");
654
+ case "sq":
655
+ return await import("ckeditor5-premium-features/translations/sq.js");
656
+ case "sr":
657
+ return await import("ckeditor5-premium-features/translations/sr.js");
658
+ case "sr-latn":
659
+ return await import("ckeditor5-premium-features/translations/sr-latn.js");
660
+ case "sv":
661
+ return await import("ckeditor5-premium-features/translations/sv.js");
662
+ case "th":
663
+ return await import("ckeditor5-premium-features/translations/th.js");
664
+ case "tk":
665
+ return await import("ckeditor5-premium-features/translations/tk.js");
666
+ case "tr":
667
+ return await import("ckeditor5-premium-features/translations/tr.js");
668
+ case "tt":
669
+ return await import("ckeditor5-premium-features/translations/tt.js");
670
+ case "ug":
671
+ return await import("ckeditor5-premium-features/translations/ug.js");
672
+ case "uk":
673
+ return await import("ckeditor5-premium-features/translations/uk.js");
674
+ case "ur":
675
+ return await import("ckeditor5-premium-features/translations/ur.js");
676
+ case "uz":
677
+ return await import("ckeditor5-premium-features/translations/uz.js");
678
+ case "vi":
679
+ return await import("ckeditor5-premium-features/translations/vi.js");
680
+ case "zh":
681
+ return await import("ckeditor5-premium-features/translations/zh.js");
682
+ case "zh-cn":
683
+ return await import("ckeditor5-premium-features/translations/zh-cn.js");
684
+ default:
685
+ return console.warn(`Language ${t} not found in premium translations`), await import("ckeditor5-premium-features/translations/en.js");
686
+ }
687
+ } catch (e) {
688
+ return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
689
+ }
690
+ }
691
+ function j(r) {
692
+ return x(r, (t) => ({
693
+ dictionary: t
694
+ }));
695
+ }
696
+ function H() {
697
+ return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
698
+ }
699
+ function U(r) {
700
+ const t = B(r);
701
+ return x(t, ({ element: e }) => e);
702
+ }
703
+ function z(r) {
704
+ const t = B(r), e = x(t, ({ content: i }) => i);
705
+ return J(e, (i) => typeof i == "string");
706
+ }
707
+ function B(r) {
708
+ const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((s, o) => {
709
+ const c = o.getAttribute("data-cke-root-name"), u = o.getAttribute("data-cke-content");
710
+ return s[c] = {
711
+ element: o.querySelector("[data-cke-editable-content]"),
712
+ content: u
713
+ }, s;
714
+ }, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
715
+ if (!e)
716
+ return t;
717
+ const i = t.main, a = JSON.parse(e.getAttribute("data-cke-content")), n = document.querySelector(`#${r}_editor `);
718
+ return i && a?.main ? {
719
+ ...t,
720
+ main: {
721
+ ...i,
722
+ content: i.content || a.main
723
+ }
724
+ } : n ? {
725
+ ...t,
726
+ main: {
727
+ element: n,
728
+ content: a?.main || null
729
+ }
730
+ } : t;
731
+ }
732
+ function I(r) {
733
+ if (!r || typeof r != "object")
734
+ return r;
735
+ if (Array.isArray(r))
736
+ return r.map((i) => I(i));
737
+ const t = r;
738
+ if (t.$element && typeof t.$element == "string") {
739
+ const i = document.querySelector(t.$element);
740
+ return i || console.warn(`Element not found for selector: ${t.$element}`), i || null;
741
+ }
742
+ const e = /* @__PURE__ */ Object.create(null);
743
+ for (const [i, a] of Object.entries(r))
744
+ e[i] = I(a);
745
+ return e;
746
+ }
747
+ function Z(r, t) {
748
+ const { editing: e } = r;
749
+ e.view.change((i) => {
750
+ i.setStyle("height", `${t}px`, e.view.document.getRoot());
751
+ });
752
+ }
753
+ const T = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
754
+ async function tt(r) {
755
+ const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(r);
756
+ return e.setCreator(async (...i) => {
757
+ const a = await r.create(...i);
758
+ return a[T] = e, a;
759
+ }), {
760
+ watchdog: e,
761
+ Constructor: {
762
+ create: async (...i) => (await e.create(...i), e.editor)
763
+ }
764
+ };
765
+ }
766
+ function et(r) {
767
+ return T in r ? r[T] : null;
768
+ }
769
+ class b extends N {
770
+ static the = new b();
771
+ }
772
+ class rt extends HTMLElement {
773
+ /**
774
+ * The promise that resolves to the context instance.
775
+ */
776
+ contextPromise = null;
777
+ /**
778
+ * Mounts the context component.
779
+ */
780
+ async connectedCallback() {
781
+ await A();
782
+ const t = this.getAttribute("data-cke-context-id"), e = JSON.parse(this.getAttribute("data-cke-language")), i = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: a, watchdogConfig: n, config: { plugins: s, ...o } } = i, { loadedPlugins: c, hasPremium: u } = await W(s ?? []), f = [
783
+ ...await q(e, u),
784
+ j(a || {})
785
+ ].filter((m) => !L(m));
786
+ this.contextPromise = (async () => {
787
+ const { ContextWatchdog: m, Context: y } = await import("ckeditor5"), w = new m(y, {
788
+ crashNumberLimit: 10,
789
+ ...n
790
+ });
791
+ return await w.create({
792
+ ...o,
793
+ language: e,
794
+ plugins: c,
795
+ ...f.length && {
796
+ translations: f
797
+ }
798
+ }), w.on("itemError", (...P) => {
799
+ console.error("Context item error:", ...P);
800
+ }), w;
801
+ })();
802
+ const g = await this.contextPromise;
803
+ this.isConnected && b.the.register(t, g);
804
+ }
805
+ /**
806
+ * Destroys the context component. Unmounts root from the editor.
807
+ */
808
+ async disconnectedCallback() {
809
+ const t = this.getAttribute("data-cke-context-id");
810
+ this.style.display = "none";
811
+ try {
812
+ await (await this.contextPromise)?.destroy();
813
+ } finally {
814
+ this.contextPromise = null, t && b.the.hasItem(t) && b.the.unregister(t);
815
+ }
816
+ }
817
+ }
818
+ class d extends N {
819
+ static the = new d();
820
+ }
821
+ class it extends HTMLElement {
822
+ /**
823
+ * The promise that resolves when the editable is mounted.
824
+ */
825
+ editorPromise = null;
826
+ /**
827
+ * Mounts the editable component.
828
+ */
829
+ async connectedCallback() {
830
+ await A(), this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", H()[0]);
831
+ const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), i = this.getAttribute("data-cke-content"), a = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
832
+ if (!t || !e)
833
+ throw new h("Editor ID or Root Name is missing.");
834
+ this.style.display = "block", this.editorPromise = d.the.execute(t, async (n) => {
835
+ const s = this.querySelector("input"), { ui: o, editing: c, model: u } = n;
836
+ if (u.document.getRoot(e)) {
837
+ if (i !== null) {
838
+ const m = n.getData({ rootName: e });
839
+ m && m !== i && n.setData({
840
+ [e]: i
841
+ });
842
+ }
843
+ return n;
844
+ }
845
+ n.addRoot(e, {
846
+ isUndoable: !1,
847
+ ...i !== null && {
848
+ data: i
849
+ }
850
+ });
851
+ const p = this.querySelector("[data-cke-editable-content]"), f = o.view.createEditable(e, p);
852
+ o.addEditable(f), c.view.forceRender();
853
+ const g = () => {
854
+ const m = n.getData({ rootName: e });
855
+ s && (s.value = m, s.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", { detail: { value: m } }));
856
+ };
857
+ return n.model.document.on("change:data", R(a, g)), g(), n;
858
+ });
859
+ }
860
+ /**
861
+ * Destroys the editable component. Unmounts root from the editor.
862
+ */
863
+ async disconnectedCallback() {
864
+ const t = this.getAttribute("data-cke-root-name");
865
+ this.style.display = "none";
866
+ const e = await this.editorPromise;
867
+ if (this.editorPromise = null, e && e.state !== "destroyed" && t) {
868
+ const i = e.model.document.getRoot(t);
869
+ i && "detachEditable" in e && (e.detachEditable(i), e.detachRoot(t, !1));
870
+ }
871
+ }
872
+ }
873
+ async function at(r) {
874
+ const { Plugin: t } = await import("ckeditor5");
875
+ return class extends t {
876
+ /**
877
+ * The input element to synchronize with.
878
+ */
879
+ input = null;
880
+ /**
881
+ * The form element reference for cleanup.
882
+ */
883
+ form = null;
884
+ /**
885
+ * The name of the plugin.
886
+ */
887
+ static get pluginName() {
888
+ return "SyncEditorWithInput";
889
+ }
890
+ /**
891
+ * Initializes the plugin.
892
+ */
893
+ afterInit() {
894
+ const { editor: i } = this, n = i.sourceElement.id.replace(/_editor$/, "");
895
+ this.input = document.getElementById(`${n}_input`), this.input && (i.model.document.on("change:data", R(r, () => this.sync())), i.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
896
+ }
897
+ /**
898
+ * Synchronizes the editor's content with the input field.
899
+ */
900
+ sync = () => {
901
+ if (this.input) {
902
+ const i = this.editor.getData();
903
+ this.input.value = i, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
904
+ }
905
+ };
906
+ /**
907
+ * Destroys the plugin.
908
+ */
909
+ destroy() {
910
+ this.form && this.form.removeEventListener("submit", this.sync), this.input = null, this.form = null;
911
+ }
912
+ };
913
+ }
914
+ class nt extends HTMLElement {
915
+ /**
916
+ * The promise that resolves to the editor instance.
917
+ */
918
+ editorPromise = null;
919
+ /**
920
+ * Mounts the editor component.
921
+ */
922
+ async connectedCallback() {
923
+ await A();
924
+ const t = this.getAttribute("data-cke-editor-id");
925
+ d.the.resetErrors(t);
926
+ try {
927
+ this.style.display = "block", this.editorPromise = this.createEditor();
928
+ const e = await this.editorPromise;
929
+ this.isConnected && (d.the.register(t, e), e.once("destroy", () => {
930
+ d.the.hasItem(t) && d.the.unregister(t);
931
+ }));
932
+ } catch (e) {
933
+ console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e), this.editorPromise = null, d.the.error(t, e);
934
+ }
935
+ }
936
+ /**
937
+ * Destroys the editor instance when the component is destroyed.
938
+ * This is important to prevent memory leaks and ensure that the editor is properly cleaned up.
939
+ */
940
+ async disconnectedCallback() {
941
+ this.style.display = "none";
942
+ try {
943
+ const t = await this.editorPromise;
944
+ if (!t)
945
+ return;
946
+ const e = Y(t), i = et(t);
947
+ e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : i ? await i.destroy() : await t.destroy();
948
+ } finally {
949
+ this.editorPromise = null;
950
+ }
951
+ }
952
+ /**
953
+ * Creates the CKEditor instance.
954
+ */
955
+ async createEditor() {
956
+ const t = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")), i = this.getAttribute("data-cke-context-id"), a = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null, n = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10), s = JSON.parse(this.getAttribute("data-cke-language")), o = this.hasAttribute("data-cke-watchdog"), c = JSON.parse(this.getAttribute("data-cke-content")), {
957
+ customTranslations: u,
958
+ editorType: p,
959
+ licenseKey: f,
960
+ config: { plugins: g, ...m }
961
+ } = e;
962
+ let y = await X(p);
963
+ const w = await (i ? b.the.waitFor(i) : null);
964
+ if (o && !w) {
965
+ const l = await tt(y);
966
+ ({ Constructor: y } = l), l.watchdog.on("restart", () => {
967
+ const k = l.watchdog.editor;
968
+ this.editorPromise = Promise.resolve(k), d.the.register(t, k);
969
+ });
970
+ }
971
+ const { loadedPlugins: P, hasPremium: V } = await W(g);
972
+ C(p) && P.push(
973
+ await at(n)
974
+ );
975
+ const O = [
976
+ ...await q(s, V),
977
+ j(u || {})
978
+ ].filter((l) => !L(l));
979
+ let E = {
980
+ ...c,
981
+ ...z(t)
982
+ };
983
+ C(p) && (E = E.main || "");
984
+ const D = await (async () => {
985
+ let l = U(t);
986
+ if (!l.main) {
987
+ const M = C(p) ? ["main"] : Object.keys(E);
988
+ F(l, M) || (l = await st(t, M), E = {
989
+ ...c,
990
+ ...z(t)
991
+ });
992
+ }
993
+ C(p) && "main" in l && (l = l.main);
994
+ const k = {
995
+ ...I(m),
996
+ initialData: E,
997
+ licenseKey: f,
998
+ plugins: P,
999
+ language: s,
1000
+ ...O.length && {
1001
+ translations: O
1002
+ }
1003
+ };
1004
+ return !w || !(l instanceof HTMLElement) ? y.create(l, k) : (await G({
1005
+ context: w,
1006
+ element: l,
1007
+ creator: y,
1008
+ config: k
1009
+ })).editor;
1010
+ })();
1011
+ return C(p) && a && Z(D, a), D;
1012
+ }
1013
+ }
1014
+ function F(r, t) {
1015
+ return t.every((e) => r[e]);
1016
+ }
1017
+ async function st(r, t) {
1018
+ return K(
1019
+ () => {
1020
+ const e = U(r);
1021
+ if (!F(e, t))
1022
+ throw new Error(
1023
+ `It looks like not all required root elements are present yet.
1024
+ * If you want to wait for them, ensure they are registered before editor initialization.
1025
+ * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
1026
+ Missing roots: ${t.filter((i) => !e[i]).join(", ")}.`
1027
+ );
1028
+ return e;
1029
+ },
1030
+ { timeOutAfter: 2e3, retryAfter: 100 }
1031
+ );
1032
+ }
1033
+ class ot extends HTMLElement {
1034
+ /**
1035
+ * The promise that resolves when the UI part is mounted.
1036
+ */
1037
+ mountedPromise = null;
1038
+ /**
1039
+ * Mounts the UI part component.
1040
+ */
1041
+ async connectedCallback() {
1042
+ await A();
1043
+ const t = this.getAttribute("data-cke-editor-id") || H()[0], e = this.getAttribute("data-cke-name");
1044
+ !t || !e || (this.style.display = "block", this.mountedPromise = d.the.execute(t, (i) => {
1045
+ const { ui: a } = i, n = ct(e), s = a.view[n];
1046
+ if (!s)
1047
+ throw new h(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1048
+ this.appendChild(s.element);
1049
+ }));
1050
+ }
1051
+ /**
1052
+ * Destroys the UI part component. Unmounts UI parts from the editor.
1053
+ */
1054
+ async disconnectedCallback() {
1055
+ this.style.display = "none", await this.mountedPromise, this.mountedPromise = null, this.innerHTML = "";
1056
+ }
1057
+ }
1058
+ function ct(r) {
1059
+ switch (r) {
1060
+ case "toolbar":
1061
+ return "toolbar";
1062
+ case "menubar":
1063
+ return "menuBarView";
1064
+ /* v8 ignore next 3 */
1065
+ default:
1066
+ return null;
1067
+ }
1068
+ }
1069
+ const ut = {
1070
+ "cke5-editor": nt,
1071
+ "cke5-context": rt,
1072
+ "cke5-ui-part": ot,
1073
+ "cke5-editable": it
1074
+ };
1075
+ function lt() {
1076
+ for (const [r, t] of Object.entries(ut))
1077
+ window.customElements.get(r) || window.customElements.define(r, t);
1078
+ }
1079
+ lt();
1080
+ export {
1081
+ h as CKEditor5SymfonyError,
1082
+ rt as ContextComponentElement,
1083
+ b as ContextsRegistry,
1084
+ it as EditableComponentElement,
1085
+ nt as EditorComponentElement,
1086
+ ot as UIPartComponentElement,
1087
+ lt as registerCustomElements
1088
+ };
1089
+ //# sourceMappingURL=index.mjs.map