ckeditor5-blazor 0.1.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.
- package/dist/ckeditor5-blazor-error.d.ts +7 -0
- package/dist/ckeditor5-blazor-error.d.ts.map +1 -0
- package/dist/elements/context/context.d.ts +26 -0
- package/dist/elements/context/context.d.ts.map +1 -0
- package/dist/elements/context/contexts-registry.d.ts +9 -0
- package/dist/elements/context/contexts-registry.d.ts.map +1 -0
- package/dist/elements/context/index.d.ts +4 -0
- package/dist/elements/context/index.d.ts.map +1 -0
- package/dist/elements/context/typings.d.ts +34 -0
- package/dist/elements/context/typings.d.ts.map +1 -0
- package/dist/elements/editable.d.ts +34 -0
- package/dist/elements/editable.d.ts.map +1 -0
- package/dist/elements/editor/custom-editor-plugins.d.ts +54 -0
- package/dist/elements/editor/custom-editor-plugins.d.ts.map +1 -0
- package/dist/elements/editor/editor.d.ts +31 -0
- package/dist/elements/editor/editor.d.ts.map +1 -0
- package/dist/elements/editor/editors-registry.d.ts +9 -0
- package/dist/elements/editor/editors-registry.d.ts.map +1 -0
- package/dist/elements/editor/index.d.ts +3 -0
- package/dist/elements/editor/index.d.ts.map +1 -0
- package/dist/elements/editor/plugins/dispatch-editor-roots-change-event.d.ts +23 -0
- package/dist/elements/editor/plugins/dispatch-editor-roots-change-event.d.ts.map +1 -0
- package/dist/elements/editor/plugins/index.d.ts +3 -0
- package/dist/elements/editor/plugins/index.d.ts.map +1 -0
- package/dist/elements/editor/plugins/sync-editor-with-input.d.ts +6 -0
- package/dist/elements/editor/plugins/sync-editor-with-input.d.ts.map +1 -0
- package/dist/elements/editor/typings.d.ts +99 -0
- package/dist/elements/editor/typings.d.ts.map +1 -0
- package/dist/elements/editor/utils/create-editor-in-context.d.ts +44 -0
- package/dist/elements/editor/utils/create-editor-in-context.d.ts.map +1 -0
- package/dist/elements/editor/utils/get-editor-roots-values.d.ts +9 -0
- package/dist/elements/editor/utils/get-editor-roots-values.d.ts.map +1 -0
- package/dist/elements/editor/utils/index.d.ts +14 -0
- package/dist/elements/editor/utils/index.d.ts.map +1 -0
- package/dist/elements/editor/utils/is-single-root-editor.d.ts +9 -0
- package/dist/elements/editor/utils/is-single-root-editor.d.ts.map +1 -0
- package/dist/elements/editor/utils/load-editor-constructor.d.ts +9 -0
- package/dist/elements/editor/utils/load-editor-constructor.d.ts.map +1 -0
- package/dist/elements/editor/utils/load-editor-plugins.d.ts +20 -0
- package/dist/elements/editor/utils/load-editor-plugins.d.ts.map +1 -0
- package/dist/elements/editor/utils/load-editor-translations.d.ts +14 -0
- package/dist/elements/editor/utils/load-editor-translations.d.ts.map +1 -0
- package/dist/elements/editor/utils/normalize-custom-translations.d.ts +11 -0
- package/dist/elements/editor/utils/normalize-custom-translations.d.ts.map +1 -0
- package/dist/elements/editor/utils/query-all-editor-ids.d.ts +5 -0
- package/dist/elements/editor/utils/query-all-editor-ids.d.ts.map +1 -0
- package/dist/elements/editor/utils/query-editor-editables.d.ts +25 -0
- package/dist/elements/editor/utils/query-editor-editables.d.ts.map +1 -0
- package/dist/elements/editor/utils/resolve-editor-config-elements-references.d.ts +9 -0
- package/dist/elements/editor/utils/resolve-editor-config-elements-references.d.ts.map +1 -0
- package/dist/elements/editor/utils/resolve-editor-config-translations.d.ts +25 -0
- package/dist/elements/editor/utils/resolve-editor-config-translations.d.ts.map +1 -0
- package/dist/elements/editor/utils/set-editor-editable-height.d.ts +9 -0
- package/dist/elements/editor/utils/set-editor-editable-height.d.ts.map +1 -0
- package/dist/elements/editor/utils/wrap-with-watchdog.d.ts +24 -0
- package/dist/elements/editor/utils/wrap-with-watchdog.d.ts.map +1 -0
- package/dist/elements/ensure-editor-elements-registered.d.ts +5 -0
- package/dist/elements/ensure-editor-elements-registered.d.ts.map +1 -0
- package/dist/elements/index.d.ts +6 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/ui-part.d.ts +18 -0
- package/dist/elements/ui-part.d.ts.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1400 -0
- package/dist/index.mjs.map +1 -0
- package/dist/interop/create-context-blazor-interop.d.ts +10 -0
- package/dist/interop/create-context-blazor-interop.d.ts.map +1 -0
- package/dist/interop/create-editable-blazor-interop.d.ts +21 -0
- package/dist/interop/create-editable-blazor-interop.d.ts.map +1 -0
- package/dist/interop/create-editor-blazor-interop.d.ts +19 -0
- package/dist/interop/create-editor-blazor-interop.d.ts.map +1 -0
- package/dist/interop/create-ui-part-blazor-interop.d.ts +10 -0
- package/dist/interop/create-ui-part-blazor-interop.d.ts.map +1 -0
- package/dist/interop/index.d.ts +5 -0
- package/dist/interop/index.d.ts.map +1 -0
- package/dist/interop/utils/create-editor-value-sync.d.ts +63 -0
- package/dist/interop/utils/create-editor-value-sync.d.ts.map +1 -0
- package/dist/interop/utils/index.d.ts +2 -0
- package/dist/interop/utils/index.d.ts.map +1 -0
- package/dist/shared/async-registry.d.ts +136 -0
- package/dist/shared/async-registry.d.ts.map +1 -0
- package/dist/shared/camel-case.d.ts +8 -0
- package/dist/shared/camel-case.d.ts.map +1 -0
- package/dist/shared/debounce.d.ts +2 -0
- package/dist/shared/debounce.d.ts.map +1 -0
- package/dist/shared/deep-camel-case-keys.d.ts +8 -0
- package/dist/shared/deep-camel-case-keys.d.ts.map +1 -0
- package/dist/shared/filter-object-values.d.ts +9 -0
- package/dist/shared/filter-object-values.d.ts.map +1 -0
- package/dist/shared/index.d.ts +16 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/is-empty-object.d.ts +2 -0
- package/dist/shared/is-empty-object.d.ts.map +1 -0
- package/dist/shared/is-plain-object.d.ts +8 -0
- package/dist/shared/is-plain-object.d.ts.map +1 -0
- package/dist/shared/map-object-values.d.ts +11 -0
- package/dist/shared/map-object-values.d.ts.map +1 -0
- package/dist/shared/once.d.ts +2 -0
- package/dist/shared/once.d.ts.map +1 -0
- package/dist/shared/shallow-equal.d.ts +9 -0
- package/dist/shared/shallow-equal.d.ts.map +1 -0
- package/dist/shared/timeout.d.ts +8 -0
- package/dist/shared/timeout.d.ts.map +1 -0
- package/dist/shared/uid.d.ts +7 -0
- package/dist/shared/uid.d.ts.map +1 -0
- package/dist/shared/wait-for-dom-ready.d.ts +5 -0
- package/dist/shared/wait-for-dom-ready.d.ts.map +1 -0
- package/dist/shared/wait-for-interactive-attribute.d.ts +18 -0
- package/dist/shared/wait-for-interactive-attribute.d.ts.map +1 -0
- package/dist/shared/wait-for.d.ts +20 -0
- package/dist/shared/wait-for.d.ts.map +1 -0
- package/dist/types/can-be-promise.type.d.ts +2 -0
- package/dist/types/can-be-promise.type.d.ts.map +1 -0
- package/dist/types/dot-net-interop.type.d.ts +7 -0
- package/dist/types/dot-net-interop.type.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/required-by.type.d.ts +2 -0
- package/dist/types/required-by.type.d.ts.map +1 -0
- package/package.json +49 -0
- package/src/ckeditor5-blazor-error.ts +9 -0
- package/src/elements/context/context.test.ts +323 -0
- package/src/elements/context/context.ts +128 -0
- package/src/elements/context/contexts-registry.test.ts +10 -0
- package/src/elements/context/contexts-registry.ts +10 -0
- package/src/elements/context/index.ts +3 -0
- package/src/elements/context/typings.ts +38 -0
- package/src/elements/editable.test.ts +383 -0
- package/src/elements/editable.ts +183 -0
- package/src/elements/editor/custom-editor-plugins.test.ts +103 -0
- package/src/elements/editor/custom-editor-plugins.ts +85 -0
- package/src/elements/editor/editor.test.ts +562 -0
- package/src/elements/editor/editor.ts +330 -0
- package/src/elements/editor/editors-registry.test.ts +10 -0
- package/src/elements/editor/editors-registry.ts +10 -0
- package/src/elements/editor/index.ts +2 -0
- package/src/elements/editor/plugins/dispatch-editor-roots-change-event.ts +76 -0
- package/src/elements/editor/plugins/index.ts +2 -0
- package/src/elements/editor/plugins/sync-editor-with-input.ts +79 -0
- package/src/elements/editor/typings.ts +114 -0
- package/src/elements/editor/utils/create-editor-in-context.ts +89 -0
- package/src/elements/editor/utils/get-editor-roots-values.test.ts +48 -0
- package/src/elements/editor/utils/get-editor-roots-values.ts +21 -0
- package/src/elements/editor/utils/index.ts +13 -0
- package/src/elements/editor/utils/is-single-root-editor.test.ts +40 -0
- package/src/elements/editor/utils/is-single-root-editor.ts +11 -0
- package/src/elements/editor/utils/load-editor-constructor.test.ts +62 -0
- package/src/elements/editor/utils/load-editor-constructor.ts +29 -0
- package/src/elements/editor/utils/load-editor-plugins.test.ts +100 -0
- package/src/elements/editor/utils/load-editor-plugins.ts +72 -0
- package/src/elements/editor/utils/load-editor-translations.ts +232 -0
- package/src/elements/editor/utils/normalize-custom-translations.test.ts +152 -0
- package/src/elements/editor/utils/normalize-custom-translations.ts +17 -0
- package/src/elements/editor/utils/query-all-editor-ids.ts +9 -0
- package/src/elements/editor/utils/query-editor-editables.ts +101 -0
- package/src/elements/editor/utils/resolve-editor-config-elements-references.test.ts +93 -0
- package/src/elements/editor/utils/resolve-editor-config-elements-references.ts +36 -0
- package/src/elements/editor/utils/resolve-editor-config-translations.test.ts +131 -0
- package/src/elements/editor/utils/resolve-editor-config-translations.ts +77 -0
- package/src/elements/editor/utils/set-editor-editable-height.test.ts +131 -0
- package/src/elements/editor/utils/set-editor-editable-height.ts +15 -0
- package/src/elements/editor/utils/wrap-with-watchdog.test.ts +45 -0
- package/src/elements/editor/utils/wrap-with-watchdog.ts +51 -0
- package/src/elements/ensure-editor-elements-registered.ts +24 -0
- package/src/elements/index.ts +14 -0
- package/src/elements/ui-part.test.ts +156 -0
- package/src/elements/ui-part.ts +84 -0
- package/src/index.ts +15 -0
- package/src/interop/create-context-blazor-interop.test.ts +30 -0
- package/src/interop/create-context-blazor-interop.ts +15 -0
- package/src/interop/create-editable-blazor-interop.test.ts +213 -0
- package/src/interop/create-editable-blazor-interop.ts +98 -0
- package/src/interop/create-editor-blazor-interop.test.ts +183 -0
- package/src/interop/create-editor-blazor-interop.ts +112 -0
- package/src/interop/create-ui-part-blazor-interop.test.ts +30 -0
- package/src/interop/create-ui-part-blazor-interop.ts +15 -0
- package/src/interop/index.ts +4 -0
- package/src/interop/utils/create-editor-value-sync.test.ts +302 -0
- package/src/interop/utils/create-editor-value-sync.ts +160 -0
- package/src/interop/utils/index.ts +1 -0
- package/src/shared/async-registry.test.ts +737 -0
- package/src/shared/async-registry.ts +353 -0
- package/src/shared/camel-case.test.ts +35 -0
- package/src/shared/camel-case.ts +11 -0
- package/src/shared/debounce.test.ts +72 -0
- package/src/shared/debounce.ts +16 -0
- package/src/shared/deep-camel-case-keys.test.ts +34 -0
- package/src/shared/deep-camel-case-keys.ts +26 -0
- package/src/shared/filter-object-values.test.ts +25 -0
- package/src/shared/filter-object-values.ts +17 -0
- package/src/shared/index.ts +15 -0
- package/src/shared/is-empty-object.test.ts +78 -0
- package/src/shared/is-empty-object.ts +3 -0
- package/src/shared/is-plain-object.test.ts +38 -0
- package/src/shared/is-plain-object.ts +15 -0
- package/src/shared/map-object-values.test.ts +29 -0
- package/src/shared/map-object-values.ts +19 -0
- package/src/shared/once.test.ts +116 -0
- package/src/shared/once.ts +12 -0
- package/src/shared/shallow-equal.test.ts +51 -0
- package/src/shared/shallow-equal.ts +30 -0
- package/src/shared/timeout.test.ts +65 -0
- package/src/shared/timeout.ts +13 -0
- package/src/shared/uid.test.ts +25 -0
- package/src/shared/uid.ts +8 -0
- package/src/shared/wait-for-dom-ready.test.ts +87 -0
- package/src/shared/wait-for-dom-ready.ts +21 -0
- package/src/shared/wait-for-interactive-attribute.test.ts +93 -0
- package/src/shared/wait-for-interactive-attribute.ts +50 -0
- package/src/shared/wait-for.test.ts +24 -0
- package/src/shared/wait-for.ts +56 -0
- package/src/types/can-be-promise.type.ts +1 -0
- package/src/types/dot-net-interop.type.ts +6 -0
- package/src/types/dotnet-global.d.ts +14 -0
- package/src/types/index.ts +3 -0
- package/src/types/required-by.type.ts +1 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1400 @@
|
|
|
1
|
+
class b extends Error {
|
|
2
|
+
constructor(t) {
|
|
3
|
+
super(t), this.name = "CKEditor5BlazorError";
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class j {
|
|
7
|
+
/**
|
|
8
|
+
* Map of registered items.
|
|
9
|
+
*/
|
|
10
|
+
items = /* @__PURE__ */ new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Map of initialization errors for items that failed to register.
|
|
13
|
+
*/
|
|
14
|
+
initializationErrors = /* @__PURE__ */ new Map();
|
|
15
|
+
/**
|
|
16
|
+
* Map of pending callbacks waiting for items to be registered or fail.
|
|
17
|
+
*/
|
|
18
|
+
pendingCallbacks = /* @__PURE__ */ new Map();
|
|
19
|
+
/**
|
|
20
|
+
* Set of watchers that observe changes to the registry.
|
|
21
|
+
*/
|
|
22
|
+
watchers = /* @__PURE__ */ new Set();
|
|
23
|
+
/**
|
|
24
|
+
* Executes a function on an item.
|
|
25
|
+
* If the item is not yet registered, it will wait for it to be registered.
|
|
26
|
+
*
|
|
27
|
+
* @param id The ID of the item.
|
|
28
|
+
* @param onSuccess The function to execute.
|
|
29
|
+
* @param onError Optional error callback.
|
|
30
|
+
* @returns A promise that resolves with the result of the function.
|
|
31
|
+
*/
|
|
32
|
+
execute(t, e, i) {
|
|
33
|
+
const a = this.items.get(t), n = this.initializationErrors.get(t);
|
|
34
|
+
return n ? (i?.(n), Promise.reject(n)) : a ? Promise.resolve(e(a)) : new Promise((o, c) => {
|
|
35
|
+
const u = this.getPendingCallbacks(t);
|
|
36
|
+
u.success.push(async (s) => {
|
|
37
|
+
o(await e(s));
|
|
38
|
+
}), i ? u.error.push(i) : u.error.push(c);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Registers an item.
|
|
43
|
+
*
|
|
44
|
+
* @param id The ID of the item.
|
|
45
|
+
* @param item The item instance.
|
|
46
|
+
*/
|
|
47
|
+
register(t, e) {
|
|
48
|
+
if (this.items.has(t))
|
|
49
|
+
throw new Error(`Item with ID "${t}" is already registered.`);
|
|
50
|
+
this.resetErrors(t), this.items.set(t, e);
|
|
51
|
+
const i = this.pendingCallbacks.get(t);
|
|
52
|
+
i && (i.success.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.registerAsDefault(t, e), this.notifyWatchers();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Registers an error for an item.
|
|
56
|
+
*
|
|
57
|
+
* @param id The ID of the item.
|
|
58
|
+
* @param error The error to register.
|
|
59
|
+
*/
|
|
60
|
+
error(t, e) {
|
|
61
|
+
this.items.delete(t), this.initializationErrors.set(t, e);
|
|
62
|
+
const i = this.pendingCallbacks.get(t);
|
|
63
|
+
i && (i.error.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e), this.notifyWatchers();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resets errors for an item.
|
|
67
|
+
*
|
|
68
|
+
* @param id The ID of the item.
|
|
69
|
+
*/
|
|
70
|
+
resetErrors(t) {
|
|
71
|
+
const { initializationErrors: e } = this;
|
|
72
|
+
e.has(null) && e.get(null) === e.get(t) && e.delete(null), e.delete(t);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Un-registers an item.
|
|
76
|
+
*
|
|
77
|
+
* @param id The ID of the item.
|
|
78
|
+
*/
|
|
79
|
+
unregister(t) {
|
|
80
|
+
if (!this.items.has(t))
|
|
81
|
+
throw new Error(`Item with ID "${t}" is not registered.`);
|
|
82
|
+
t && this.items.get(null) === this.items.get(t) && this.unregister(null), this.items.delete(t), this.pendingCallbacks.delete(t), this.notifyWatchers();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gets all registered items.
|
|
86
|
+
*
|
|
87
|
+
* @returns An array of all registered items.
|
|
88
|
+
*/
|
|
89
|
+
getItems() {
|
|
90
|
+
return Array.from(this.items.values());
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Checks if an item with the given ID is registered.
|
|
94
|
+
*
|
|
95
|
+
* @param id The ID of the item.
|
|
96
|
+
* @returns `true` if the item is registered, `false` otherwise.
|
|
97
|
+
*/
|
|
98
|
+
hasItem(t) {
|
|
99
|
+
return this.items.has(t);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Gets a promise that resolves with the item instance for the given ID.
|
|
103
|
+
* If the item is not registered yet, it will wait for it to be registered.
|
|
104
|
+
*
|
|
105
|
+
* @param id The ID of the item.
|
|
106
|
+
* @param timeout Optional timeout in milliseconds.
|
|
107
|
+
* @returns A promise that resolves with the item instance.
|
|
108
|
+
*/
|
|
109
|
+
waitFor(t, e) {
|
|
110
|
+
return new Promise((i, a) => {
|
|
111
|
+
let n = !1, o = null;
|
|
112
|
+
this.execute(
|
|
113
|
+
t,
|
|
114
|
+
(c) => {
|
|
115
|
+
n || (o !== null && clearTimeout(o), i(c));
|
|
116
|
+
},
|
|
117
|
+
(c) => {
|
|
118
|
+
n || (o !== null && clearTimeout(o), a(c));
|
|
119
|
+
}
|
|
120
|
+
), e && (o = setTimeout(() => {
|
|
121
|
+
n = !0, a(new Error(`Timeout waiting for item with ID "${t}" to be registered.`));
|
|
122
|
+
}, e));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Destroys all registered items and clears the registry.
|
|
127
|
+
* This will call the `destroy` method on each item.
|
|
128
|
+
*/
|
|
129
|
+
async destroyAll() {
|
|
130
|
+
const t = Array.from(new Set(this.items.values())).map((e) => e.destroy());
|
|
131
|
+
this.items.clear(), this.pendingCallbacks.clear(), await Promise.all(t), this.notifyWatchers();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Registers a watcher that will be called whenever the registry changes.
|
|
135
|
+
*
|
|
136
|
+
* @param watcher The watcher function to register.
|
|
137
|
+
* @returns A function to unregister the watcher.
|
|
138
|
+
*/
|
|
139
|
+
watch(t) {
|
|
140
|
+
return this.watchers.add(t), t(
|
|
141
|
+
new Map(this.items),
|
|
142
|
+
new Map(this.initializationErrors)
|
|
143
|
+
), this.unwatch.bind(this, t);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Un-registers a watcher.
|
|
147
|
+
*
|
|
148
|
+
* @param watcher The watcher function to unregister.
|
|
149
|
+
*/
|
|
150
|
+
unwatch(t) {
|
|
151
|
+
this.watchers.delete(t);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Resets the registry by clearing all items, errors, and pending callbacks.
|
|
155
|
+
*/
|
|
156
|
+
reset() {
|
|
157
|
+
this.items.clear(), this.initializationErrors.clear(), this.pendingCallbacks.clear(), this.notifyWatchers();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Notifies all watchers about changes to the registry.
|
|
161
|
+
*/
|
|
162
|
+
notifyWatchers() {
|
|
163
|
+
this.watchers.forEach(
|
|
164
|
+
(t) => t(
|
|
165
|
+
new Map(this.items),
|
|
166
|
+
new Map(this.initializationErrors)
|
|
167
|
+
)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets or creates pending callbacks for a specific ID.
|
|
172
|
+
*
|
|
173
|
+
* @param id The ID of the item.
|
|
174
|
+
* @returns The pending callbacks structure.
|
|
175
|
+
*/
|
|
176
|
+
getPendingCallbacks(t) {
|
|
177
|
+
let e = this.pendingCallbacks.get(t);
|
|
178
|
+
return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Registers an item as the default (null ID) item if it's the first one.
|
|
182
|
+
*
|
|
183
|
+
* @param id The ID of the item being registered.
|
|
184
|
+
* @param item The item instance.
|
|
185
|
+
*/
|
|
186
|
+
registerAsDefault(t, e) {
|
|
187
|
+
this.items.size === 1 && t !== null && this.register(null, e);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function z(r, t) {
|
|
191
|
+
let e = null;
|
|
192
|
+
return (...i) => {
|
|
193
|
+
e && clearTimeout(e), e = setTimeout(() => {
|
|
194
|
+
t(...i);
|
|
195
|
+
}, r);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function et(r, t) {
|
|
199
|
+
const e = Object.entries(r).filter(([i, a]) => t(a, i));
|
|
200
|
+
return Object.fromEntries(e);
|
|
201
|
+
}
|
|
202
|
+
function B(r) {
|
|
203
|
+
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
204
|
+
}
|
|
205
|
+
function V(r, t) {
|
|
206
|
+
const e = Object.entries(r).map(([i, a]) => [i, t(a, i)]);
|
|
207
|
+
return Object.fromEntries(e);
|
|
208
|
+
}
|
|
209
|
+
function rt(r, t) {
|
|
210
|
+
if (r === t)
|
|
211
|
+
return !0;
|
|
212
|
+
const e = Object.keys(r), i = Object.keys(t);
|
|
213
|
+
if (e.length !== i.length)
|
|
214
|
+
return !1;
|
|
215
|
+
for (const a of e)
|
|
216
|
+
if (r[a] !== t[a] || !Object.prototype.hasOwnProperty.call(t, a))
|
|
217
|
+
return !1;
|
|
218
|
+
return !0;
|
|
219
|
+
}
|
|
220
|
+
function it() {
|
|
221
|
+
return Math.random().toString(36).substring(2);
|
|
222
|
+
}
|
|
223
|
+
function at(r, {
|
|
224
|
+
timeOutAfter: t = 500,
|
|
225
|
+
retryAfter: e = 100
|
|
226
|
+
} = {}) {
|
|
227
|
+
return new Promise((i, a) => {
|
|
228
|
+
const n = Date.now();
|
|
229
|
+
let o = null;
|
|
230
|
+
const c = setTimeout(() => {
|
|
231
|
+
a(o ?? new Error("Timeout"));
|
|
232
|
+
}, t), u = async () => {
|
|
233
|
+
try {
|
|
234
|
+
const s = await r();
|
|
235
|
+
clearTimeout(c), i(s);
|
|
236
|
+
} catch (s) {
|
|
237
|
+
o = s, Date.now() - n > t ? a(s) : setTimeout(u, e);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
u();
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function I() {
|
|
244
|
+
return new Promise((r) => {
|
|
245
|
+
switch (document.readyState) {
|
|
246
|
+
case "loading":
|
|
247
|
+
document.addEventListener("DOMContentLoaded", () => r(), { once: !0 });
|
|
248
|
+
break;
|
|
249
|
+
case "interactive":
|
|
250
|
+
case "complete":
|
|
251
|
+
setTimeout(r, 0);
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
console.warn("Unexpected document.readyState:", document.readyState), setTimeout(r, 0);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function M(r) {
|
|
259
|
+
if (r.hasAttribute("data-cke-interactive"))
|
|
260
|
+
return { promise: Promise.resolve(), disconnect: () => {
|
|
261
|
+
} };
|
|
262
|
+
let t;
|
|
263
|
+
return {
|
|
264
|
+
promise: new Promise((i) => {
|
|
265
|
+
t = new MutationObserver((a) => {
|
|
266
|
+
for (const n of a)
|
|
267
|
+
if (n.type === "attributes" && n.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
|
|
268
|
+
t.disconnect(), i();
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}), t.observe(r, { attributes: !0 });
|
|
272
|
+
}),
|
|
273
|
+
disconnect: () => t?.disconnect()
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function D(r) {
|
|
277
|
+
r.setAttribute("data-cke-interactive", "true");
|
|
278
|
+
}
|
|
279
|
+
const x = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
280
|
+
async function nt({ element: r, context: t, creator: e, config: i }) {
|
|
281
|
+
const a = it();
|
|
282
|
+
await t.add({
|
|
283
|
+
creator: (u, s) => e.create(u, s),
|
|
284
|
+
id: a,
|
|
285
|
+
sourceElementOrData: r,
|
|
286
|
+
type: "editor",
|
|
287
|
+
config: i
|
|
288
|
+
});
|
|
289
|
+
const n = t.getItem(a), o = {
|
|
290
|
+
state: "available",
|
|
291
|
+
editorContextId: a,
|
|
292
|
+
context: t
|
|
293
|
+
};
|
|
294
|
+
n[x] = o;
|
|
295
|
+
const c = t.destroy.bind(t);
|
|
296
|
+
return t.destroy = async () => (o.state = "unavailable", c()), {
|
|
297
|
+
...o,
|
|
298
|
+
editor: n
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function ot(r) {
|
|
302
|
+
return x in r ? r[x] : null;
|
|
303
|
+
}
|
|
304
|
+
function H(r) {
|
|
305
|
+
return Array.from(r.model.document.getRoots()).reduce((t, e) => (e.rootName === "$graveyard" || (t[e.rootName] = r.getData({ rootName: e.rootName })), t), /* @__PURE__ */ Object.create({}));
|
|
306
|
+
}
|
|
307
|
+
function A(r) {
|
|
308
|
+
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
309
|
+
}
|
|
310
|
+
async function L(r) {
|
|
311
|
+
const t = await import("ckeditor5"), i = {
|
|
312
|
+
inline: t.InlineEditor,
|
|
313
|
+
balloon: t.BalloonEditor,
|
|
314
|
+
classic: t.ClassicEditor,
|
|
315
|
+
decoupled: t.DecoupledEditor,
|
|
316
|
+
multiroot: t.MultiRootEditor
|
|
317
|
+
}[r];
|
|
318
|
+
if (!i)
|
|
319
|
+
throw new b(`Unsupported editor type: ${r}`);
|
|
320
|
+
return i;
|
|
321
|
+
}
|
|
322
|
+
class $ {
|
|
323
|
+
static the = new $();
|
|
324
|
+
/**
|
|
325
|
+
* Map of registered custom plugins.
|
|
326
|
+
*/
|
|
327
|
+
plugins = /* @__PURE__ */ new Map();
|
|
328
|
+
/**
|
|
329
|
+
* Private constructor to enforce singleton pattern.
|
|
330
|
+
*/
|
|
331
|
+
constructor() {
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Registers a custom plugin for the CKEditor.
|
|
335
|
+
*
|
|
336
|
+
* @param name The name of the plugin.
|
|
337
|
+
* @param reader The plugin reader function that returns the plugin constructor.
|
|
338
|
+
* @returns A function to unregister the plugin.
|
|
339
|
+
*/
|
|
340
|
+
register(t, e) {
|
|
341
|
+
if (this.plugins.has(t))
|
|
342
|
+
throw new b(`Plugin with name "${t}" is already registered.`);
|
|
343
|
+
return this.plugins.set(t, e), this.unregister.bind(this, t);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Removes a custom plugin by its name.
|
|
347
|
+
*
|
|
348
|
+
* @param name The name of the plugin to unregister.
|
|
349
|
+
* @throws Will throw an error if the plugin is not registered.
|
|
350
|
+
*/
|
|
351
|
+
unregister(t) {
|
|
352
|
+
if (!this.plugins.has(t))
|
|
353
|
+
throw new b(`Plugin with name "${t}" is not registered.`);
|
|
354
|
+
this.plugins.delete(t);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Removes all custom editor plugins.
|
|
358
|
+
* This is useful for cleanup in tests or when reloading plugins.
|
|
359
|
+
*/
|
|
360
|
+
unregisterAll() {
|
|
361
|
+
this.plugins.clear();
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Retrieves a custom plugin by its name.
|
|
365
|
+
*
|
|
366
|
+
* @param name The name of the plugin.
|
|
367
|
+
* @returns The plugin constructor or undefined if not found.
|
|
368
|
+
*/
|
|
369
|
+
async get(t) {
|
|
370
|
+
return this.plugins.get(t)?.();
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Checks if a plugin with the given name is registered.
|
|
374
|
+
*
|
|
375
|
+
* @param name The name of the plugin.
|
|
376
|
+
* @returns `true` if the plugin is registered, `false` otherwise.
|
|
377
|
+
*/
|
|
378
|
+
has(t) {
|
|
379
|
+
return this.plugins.has(t);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async function J(r) {
|
|
383
|
+
const t = await import("ckeditor5");
|
|
384
|
+
let e = null;
|
|
385
|
+
const i = r.map(async (a) => {
|
|
386
|
+
const n = await $.the.get(a);
|
|
387
|
+
if (n)
|
|
388
|
+
return n;
|
|
389
|
+
const { [a]: o } = t;
|
|
390
|
+
if (o)
|
|
391
|
+
return o;
|
|
392
|
+
if (!e)
|
|
393
|
+
try {
|
|
394
|
+
e = await import("ckeditor5-premium-features");
|
|
395
|
+
} catch (u) {
|
|
396
|
+
throw console.error(`Failed to load premium package: ${u}`), new b(`Plugin "${a}" not found in base package and failed to load premium package.`);
|
|
397
|
+
}
|
|
398
|
+
const { [a]: c } = e || {};
|
|
399
|
+
if (c)
|
|
400
|
+
return c;
|
|
401
|
+
throw new b(`Plugin "${a}" not found in base or premium packages.`);
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
loadedPlugins: await Promise.all(i),
|
|
405
|
+
hasPremium: !!e
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
async function U(r, t) {
|
|
409
|
+
const e = [r.ui, r.content];
|
|
410
|
+
return await Promise.all(
|
|
411
|
+
[
|
|
412
|
+
F("ckeditor5", e),
|
|
413
|
+
/* v8 ignore next -- @preserve */
|
|
414
|
+
t && F("ckeditor5-premium-features", e)
|
|
415
|
+
].filter((a) => !!a)
|
|
416
|
+
).then((a) => a.flat());
|
|
417
|
+
}
|
|
418
|
+
async function F(r, t) {
|
|
419
|
+
return await Promise.all(
|
|
420
|
+
t.filter((e) => e !== "en").map(async (e) => {
|
|
421
|
+
const i = await st(r, e);
|
|
422
|
+
return i?.default ?? i;
|
|
423
|
+
}).filter(Boolean)
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
async function st(r, t) {
|
|
427
|
+
try {
|
|
428
|
+
if (r === "ckeditor5")
|
|
429
|
+
switch (t) {
|
|
430
|
+
case "af":
|
|
431
|
+
return await import("ckeditor5/translations/af.js");
|
|
432
|
+
case "ar":
|
|
433
|
+
return await import("ckeditor5/translations/ar.js");
|
|
434
|
+
case "ast":
|
|
435
|
+
return await import("ckeditor5/translations/ast.js");
|
|
436
|
+
case "az":
|
|
437
|
+
return await import("ckeditor5/translations/az.js");
|
|
438
|
+
case "bg":
|
|
439
|
+
return await import("ckeditor5/translations/bg.js");
|
|
440
|
+
case "bn":
|
|
441
|
+
return await import("ckeditor5/translations/bn.js");
|
|
442
|
+
case "bs":
|
|
443
|
+
return await import("ckeditor5/translations/bs.js");
|
|
444
|
+
case "ca":
|
|
445
|
+
return await import("ckeditor5/translations/ca.js");
|
|
446
|
+
case "cs":
|
|
447
|
+
return await import("ckeditor5/translations/cs.js");
|
|
448
|
+
case "da":
|
|
449
|
+
return await import("ckeditor5/translations/da.js");
|
|
450
|
+
case "de":
|
|
451
|
+
return await import("ckeditor5/translations/de.js");
|
|
452
|
+
case "de-ch":
|
|
453
|
+
return await import("ckeditor5/translations/de-ch.js");
|
|
454
|
+
case "el":
|
|
455
|
+
return await import("ckeditor5/translations/el.js");
|
|
456
|
+
case "en":
|
|
457
|
+
return await import("ckeditor5/translations/en.js");
|
|
458
|
+
case "en-au":
|
|
459
|
+
return await import("ckeditor5/translations/en-au.js");
|
|
460
|
+
case "en-gb":
|
|
461
|
+
return await import("ckeditor5/translations/en-gb.js");
|
|
462
|
+
case "eo":
|
|
463
|
+
return await import("ckeditor5/translations/eo.js");
|
|
464
|
+
case "es":
|
|
465
|
+
return await import("ckeditor5/translations/es.js");
|
|
466
|
+
case "es-co":
|
|
467
|
+
return await import("ckeditor5/translations/es-co.js");
|
|
468
|
+
case "et":
|
|
469
|
+
return await import("ckeditor5/translations/et.js");
|
|
470
|
+
case "eu":
|
|
471
|
+
return await import("ckeditor5/translations/eu.js");
|
|
472
|
+
case "fa":
|
|
473
|
+
return await import("ckeditor5/translations/fa.js");
|
|
474
|
+
case "fi":
|
|
475
|
+
return await import("ckeditor5/translations/fi.js");
|
|
476
|
+
case "fr":
|
|
477
|
+
return await import("ckeditor5/translations/fr.js");
|
|
478
|
+
case "gl":
|
|
479
|
+
return await import("ckeditor5/translations/gl.js");
|
|
480
|
+
case "gu":
|
|
481
|
+
return await import("ckeditor5/translations/gu.js");
|
|
482
|
+
case "he":
|
|
483
|
+
return await import("ckeditor5/translations/he.js");
|
|
484
|
+
case "hi":
|
|
485
|
+
return await import("ckeditor5/translations/hi.js");
|
|
486
|
+
case "hr":
|
|
487
|
+
return await import("ckeditor5/translations/hr.js");
|
|
488
|
+
case "hu":
|
|
489
|
+
return await import("ckeditor5/translations/hu.js");
|
|
490
|
+
case "hy":
|
|
491
|
+
return await import("ckeditor5/translations/hy.js");
|
|
492
|
+
case "id":
|
|
493
|
+
return await import("ckeditor5/translations/id.js");
|
|
494
|
+
case "it":
|
|
495
|
+
return await import("ckeditor5/translations/it.js");
|
|
496
|
+
case "ja":
|
|
497
|
+
return await import("ckeditor5/translations/ja.js");
|
|
498
|
+
case "jv":
|
|
499
|
+
return await import("ckeditor5/translations/jv.js");
|
|
500
|
+
case "kk":
|
|
501
|
+
return await import("ckeditor5/translations/kk.js");
|
|
502
|
+
case "km":
|
|
503
|
+
return await import("ckeditor5/translations/km.js");
|
|
504
|
+
case "kn":
|
|
505
|
+
return await import("ckeditor5/translations/kn.js");
|
|
506
|
+
case "ko":
|
|
507
|
+
return await import("ckeditor5/translations/ko.js");
|
|
508
|
+
case "ku":
|
|
509
|
+
return await import("ckeditor5/translations/ku.js");
|
|
510
|
+
case "lt":
|
|
511
|
+
return await import("ckeditor5/translations/lt.js");
|
|
512
|
+
case "lv":
|
|
513
|
+
return await import("ckeditor5/translations/lv.js");
|
|
514
|
+
case "ms":
|
|
515
|
+
return await import("ckeditor5/translations/ms.js");
|
|
516
|
+
case "nb":
|
|
517
|
+
return await import("ckeditor5/translations/nb.js");
|
|
518
|
+
case "ne":
|
|
519
|
+
return await import("ckeditor5/translations/ne.js");
|
|
520
|
+
case "nl":
|
|
521
|
+
return await import("ckeditor5/translations/nl.js");
|
|
522
|
+
case "no":
|
|
523
|
+
return await import("ckeditor5/translations/no.js");
|
|
524
|
+
case "oc":
|
|
525
|
+
return await import("ckeditor5/translations/oc.js");
|
|
526
|
+
case "pl":
|
|
527
|
+
return await import("ckeditor5/translations/pl.js");
|
|
528
|
+
case "pt":
|
|
529
|
+
return await import("ckeditor5/translations/pt.js");
|
|
530
|
+
case "pt-br":
|
|
531
|
+
return await import("ckeditor5/translations/pt-br.js");
|
|
532
|
+
case "ro":
|
|
533
|
+
return await import("ckeditor5/translations/ro.js");
|
|
534
|
+
case "ru":
|
|
535
|
+
return await import("ckeditor5/translations/ru.js");
|
|
536
|
+
case "si":
|
|
537
|
+
return await import("ckeditor5/translations/si.js");
|
|
538
|
+
case "sk":
|
|
539
|
+
return await import("ckeditor5/translations/sk.js");
|
|
540
|
+
case "sl":
|
|
541
|
+
return await import("ckeditor5/translations/sl.js");
|
|
542
|
+
case "sq":
|
|
543
|
+
return await import("ckeditor5/translations/sq.js");
|
|
544
|
+
case "sr":
|
|
545
|
+
return await import("ckeditor5/translations/sr.js");
|
|
546
|
+
case "sr-latn":
|
|
547
|
+
return await import("ckeditor5/translations/sr-latn.js");
|
|
548
|
+
case "sv":
|
|
549
|
+
return await import("ckeditor5/translations/sv.js");
|
|
550
|
+
case "th":
|
|
551
|
+
return await import("ckeditor5/translations/th.js");
|
|
552
|
+
case "tk":
|
|
553
|
+
return await import("ckeditor5/translations/tk.js");
|
|
554
|
+
case "tr":
|
|
555
|
+
return await import("ckeditor5/translations/tr.js");
|
|
556
|
+
case "tt":
|
|
557
|
+
return await import("ckeditor5/translations/tt.js");
|
|
558
|
+
case "ug":
|
|
559
|
+
return await import("ckeditor5/translations/ug.js");
|
|
560
|
+
case "uk":
|
|
561
|
+
return await import("ckeditor5/translations/uk.js");
|
|
562
|
+
case "ur":
|
|
563
|
+
return await import("ckeditor5/translations/ur.js");
|
|
564
|
+
case "uz":
|
|
565
|
+
return await import("ckeditor5/translations/uz.js");
|
|
566
|
+
case "vi":
|
|
567
|
+
return await import("ckeditor5/translations/vi.js");
|
|
568
|
+
case "zh":
|
|
569
|
+
return await import("ckeditor5/translations/zh.js");
|
|
570
|
+
case "zh-cn":
|
|
571
|
+
return await import("ckeditor5/translations/zh-cn.js");
|
|
572
|
+
default:
|
|
573
|
+
return console.warn(`Language ${t} not found in ckeditor5 translations`), null;
|
|
574
|
+
}
|
|
575
|
+
else
|
|
576
|
+
switch (t) {
|
|
577
|
+
case "af":
|
|
578
|
+
return await import("ckeditor5-premium-features/translations/af.js");
|
|
579
|
+
case "ar":
|
|
580
|
+
return await import("ckeditor5-premium-features/translations/ar.js");
|
|
581
|
+
case "ast":
|
|
582
|
+
return await import("ckeditor5-premium-features/translations/ast.js");
|
|
583
|
+
case "az":
|
|
584
|
+
return await import("ckeditor5-premium-features/translations/az.js");
|
|
585
|
+
case "bg":
|
|
586
|
+
return await import("ckeditor5-premium-features/translations/bg.js");
|
|
587
|
+
case "bn":
|
|
588
|
+
return await import("ckeditor5-premium-features/translations/bn.js");
|
|
589
|
+
case "bs":
|
|
590
|
+
return await import("ckeditor5-premium-features/translations/bs.js");
|
|
591
|
+
case "ca":
|
|
592
|
+
return await import("ckeditor5-premium-features/translations/ca.js");
|
|
593
|
+
case "cs":
|
|
594
|
+
return await import("ckeditor5-premium-features/translations/cs.js");
|
|
595
|
+
case "da":
|
|
596
|
+
return await import("ckeditor5-premium-features/translations/da.js");
|
|
597
|
+
case "de":
|
|
598
|
+
return await import("ckeditor5-premium-features/translations/de.js");
|
|
599
|
+
case "de-ch":
|
|
600
|
+
return await import("ckeditor5-premium-features/translations/de-ch.js");
|
|
601
|
+
case "el":
|
|
602
|
+
return await import("ckeditor5-premium-features/translations/el.js");
|
|
603
|
+
case "en":
|
|
604
|
+
return await import("ckeditor5-premium-features/translations/en.js");
|
|
605
|
+
case "en-au":
|
|
606
|
+
return await import("ckeditor5-premium-features/translations/en-au.js");
|
|
607
|
+
case "en-gb":
|
|
608
|
+
return await import("ckeditor5-premium-features/translations/en-gb.js");
|
|
609
|
+
case "eo":
|
|
610
|
+
return await import("ckeditor5-premium-features/translations/eo.js");
|
|
611
|
+
case "es":
|
|
612
|
+
return await import("ckeditor5-premium-features/translations/es.js");
|
|
613
|
+
case "es-co":
|
|
614
|
+
return await import("ckeditor5-premium-features/translations/es-co.js");
|
|
615
|
+
case "et":
|
|
616
|
+
return await import("ckeditor5-premium-features/translations/et.js");
|
|
617
|
+
case "eu":
|
|
618
|
+
return await import("ckeditor5-premium-features/translations/eu.js");
|
|
619
|
+
case "fa":
|
|
620
|
+
return await import("ckeditor5-premium-features/translations/fa.js");
|
|
621
|
+
case "fi":
|
|
622
|
+
return await import("ckeditor5-premium-features/translations/fi.js");
|
|
623
|
+
case "fr":
|
|
624
|
+
return await import("ckeditor5-premium-features/translations/fr.js");
|
|
625
|
+
case "gl":
|
|
626
|
+
return await import("ckeditor5-premium-features/translations/gl.js");
|
|
627
|
+
case "gu":
|
|
628
|
+
return await import("ckeditor5-premium-features/translations/gu.js");
|
|
629
|
+
case "he":
|
|
630
|
+
return await import("ckeditor5-premium-features/translations/he.js");
|
|
631
|
+
case "hi":
|
|
632
|
+
return await import("ckeditor5-premium-features/translations/hi.js");
|
|
633
|
+
case "hr":
|
|
634
|
+
return await import("ckeditor5-premium-features/translations/hr.js");
|
|
635
|
+
case "hu":
|
|
636
|
+
return await import("ckeditor5-premium-features/translations/hu.js");
|
|
637
|
+
case "hy":
|
|
638
|
+
return await import("ckeditor5-premium-features/translations/hy.js");
|
|
639
|
+
case "id":
|
|
640
|
+
return await import("ckeditor5-premium-features/translations/id.js");
|
|
641
|
+
case "it":
|
|
642
|
+
return await import("ckeditor5-premium-features/translations/it.js");
|
|
643
|
+
case "ja":
|
|
644
|
+
return await import("ckeditor5-premium-features/translations/ja.js");
|
|
645
|
+
case "jv":
|
|
646
|
+
return await import("ckeditor5-premium-features/translations/jv.js");
|
|
647
|
+
case "kk":
|
|
648
|
+
return await import("ckeditor5-premium-features/translations/kk.js");
|
|
649
|
+
case "km":
|
|
650
|
+
return await import("ckeditor5-premium-features/translations/km.js");
|
|
651
|
+
case "kn":
|
|
652
|
+
return await import("ckeditor5-premium-features/translations/kn.js");
|
|
653
|
+
case "ko":
|
|
654
|
+
return await import("ckeditor5-premium-features/translations/ko.js");
|
|
655
|
+
case "ku":
|
|
656
|
+
return await import("ckeditor5-premium-features/translations/ku.js");
|
|
657
|
+
case "lt":
|
|
658
|
+
return await import("ckeditor5-premium-features/translations/lt.js");
|
|
659
|
+
case "lv":
|
|
660
|
+
return await import("ckeditor5-premium-features/translations/lv.js");
|
|
661
|
+
case "ms":
|
|
662
|
+
return await import("ckeditor5-premium-features/translations/ms.js");
|
|
663
|
+
case "nb":
|
|
664
|
+
return await import("ckeditor5-premium-features/translations/nb.js");
|
|
665
|
+
case "ne":
|
|
666
|
+
return await import("ckeditor5-premium-features/translations/ne.js");
|
|
667
|
+
case "nl":
|
|
668
|
+
return await import("ckeditor5-premium-features/translations/nl.js");
|
|
669
|
+
case "no":
|
|
670
|
+
return await import("ckeditor5-premium-features/translations/no.js");
|
|
671
|
+
case "oc":
|
|
672
|
+
return await import("ckeditor5-premium-features/translations/oc.js");
|
|
673
|
+
case "pl":
|
|
674
|
+
return await import("ckeditor5-premium-features/translations/pl.js");
|
|
675
|
+
case "pt":
|
|
676
|
+
return await import("ckeditor5-premium-features/translations/pt.js");
|
|
677
|
+
case "pt-br":
|
|
678
|
+
return await import("ckeditor5-premium-features/translations/pt-br.js");
|
|
679
|
+
case "ro":
|
|
680
|
+
return await import("ckeditor5-premium-features/translations/ro.js");
|
|
681
|
+
case "ru":
|
|
682
|
+
return await import("ckeditor5-premium-features/translations/ru.js");
|
|
683
|
+
case "si":
|
|
684
|
+
return await import("ckeditor5-premium-features/translations/si.js");
|
|
685
|
+
case "sk":
|
|
686
|
+
return await import("ckeditor5-premium-features/translations/sk.js");
|
|
687
|
+
case "sl":
|
|
688
|
+
return await import("ckeditor5-premium-features/translations/sl.js");
|
|
689
|
+
case "sq":
|
|
690
|
+
return await import("ckeditor5-premium-features/translations/sq.js");
|
|
691
|
+
case "sr":
|
|
692
|
+
return await import("ckeditor5-premium-features/translations/sr.js");
|
|
693
|
+
case "sr-latn":
|
|
694
|
+
return await import("ckeditor5-premium-features/translations/sr-latn.js");
|
|
695
|
+
case "sv":
|
|
696
|
+
return await import("ckeditor5-premium-features/translations/sv.js");
|
|
697
|
+
case "th":
|
|
698
|
+
return await import("ckeditor5-premium-features/translations/th.js");
|
|
699
|
+
case "tk":
|
|
700
|
+
return await import("ckeditor5-premium-features/translations/tk.js");
|
|
701
|
+
case "tr":
|
|
702
|
+
return await import("ckeditor5-premium-features/translations/tr.js");
|
|
703
|
+
case "tt":
|
|
704
|
+
return await import("ckeditor5-premium-features/translations/tt.js");
|
|
705
|
+
case "ug":
|
|
706
|
+
return await import("ckeditor5-premium-features/translations/ug.js");
|
|
707
|
+
case "uk":
|
|
708
|
+
return await import("ckeditor5-premium-features/translations/uk.js");
|
|
709
|
+
case "ur":
|
|
710
|
+
return await import("ckeditor5-premium-features/translations/ur.js");
|
|
711
|
+
case "uz":
|
|
712
|
+
return await import("ckeditor5-premium-features/translations/uz.js");
|
|
713
|
+
case "vi":
|
|
714
|
+
return await import("ckeditor5-premium-features/translations/vi.js");
|
|
715
|
+
case "zh":
|
|
716
|
+
return await import("ckeditor5-premium-features/translations/zh.js");
|
|
717
|
+
case "zh-cn":
|
|
718
|
+
return await import("ckeditor5-premium-features/translations/zh-cn.js");
|
|
719
|
+
default:
|
|
720
|
+
return console.warn(`Language ${t} not found in premium translations`), await import("ckeditor5-premium-features/translations/en.js");
|
|
721
|
+
}
|
|
722
|
+
} catch (e) {
|
|
723
|
+
return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function K(r) {
|
|
727
|
+
return V(r, (t) => ({
|
|
728
|
+
dictionary: t
|
|
729
|
+
}));
|
|
730
|
+
}
|
|
731
|
+
function G() {
|
|
732
|
+
return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
|
|
733
|
+
}
|
|
734
|
+
function Y(r) {
|
|
735
|
+
const t = X(r);
|
|
736
|
+
return V(t, ({ element: e }) => e);
|
|
737
|
+
}
|
|
738
|
+
function _(r) {
|
|
739
|
+
const t = X(r), e = V(t, ({ content: i }) => i);
|
|
740
|
+
return et(e, (i) => typeof i == "string");
|
|
741
|
+
}
|
|
742
|
+
function X(r) {
|
|
743
|
+
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, c) => {
|
|
744
|
+
const u = c.getAttribute("data-cke-root-name"), s = c.getAttribute("data-cke-content");
|
|
745
|
+
return o[u] = {
|
|
746
|
+
element: c.querySelector("[data-cke-editable-content]"),
|
|
747
|
+
content: s
|
|
748
|
+
}, o;
|
|
749
|
+
}, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
|
|
750
|
+
if (!e)
|
|
751
|
+
return t;
|
|
752
|
+
const i = t.main, a = JSON.parse(e.getAttribute("data-cke-content")), n = document.querySelector(`#${r}_editor `);
|
|
753
|
+
return i && a?.main ? {
|
|
754
|
+
...t,
|
|
755
|
+
main: {
|
|
756
|
+
...i,
|
|
757
|
+
content: i.content || a.main
|
|
758
|
+
}
|
|
759
|
+
} : n ? {
|
|
760
|
+
...t,
|
|
761
|
+
main: {
|
|
762
|
+
element: n,
|
|
763
|
+
content: a?.main || null
|
|
764
|
+
}
|
|
765
|
+
} : t;
|
|
766
|
+
}
|
|
767
|
+
function P(r) {
|
|
768
|
+
if (!r || typeof r != "object")
|
|
769
|
+
return r;
|
|
770
|
+
if (Array.isArray(r))
|
|
771
|
+
return r.map((i) => P(i));
|
|
772
|
+
const t = r;
|
|
773
|
+
if (t.$element && typeof t.$element == "string") {
|
|
774
|
+
const i = document.querySelector(t.$element);
|
|
775
|
+
return i || console.warn(`Element not found for selector: ${t.$element}`), i || null;
|
|
776
|
+
}
|
|
777
|
+
const e = /* @__PURE__ */ Object.create(null);
|
|
778
|
+
for (const [i, a] of Object.entries(r))
|
|
779
|
+
e[i] = P(a);
|
|
780
|
+
return e;
|
|
781
|
+
}
|
|
782
|
+
function T(r, t, e) {
|
|
783
|
+
if (!e || typeof e != "object")
|
|
784
|
+
return e;
|
|
785
|
+
if (Array.isArray(e))
|
|
786
|
+
return e.map((n) => T(r, t, n));
|
|
787
|
+
const i = e;
|
|
788
|
+
if (i.$translation && typeof i.$translation == "string") {
|
|
789
|
+
const n = i.$translation, o = ct(r, n, t);
|
|
790
|
+
return o === void 0 && console.warn(`Translation not found for key: ${n}`), o !== void 0 ? o : null;
|
|
791
|
+
}
|
|
792
|
+
const a = /* @__PURE__ */ Object.create(null);
|
|
793
|
+
for (const [n, o] of Object.entries(e))
|
|
794
|
+
a[n] = T(r, t, o);
|
|
795
|
+
return a;
|
|
796
|
+
}
|
|
797
|
+
function ct(r, t, e) {
|
|
798
|
+
for (const i of r) {
|
|
799
|
+
const a = i[e];
|
|
800
|
+
if (a?.dictionary && t in a.dictionary)
|
|
801
|
+
return a.dictionary[t];
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function ut(r, t) {
|
|
805
|
+
const { editing: e } = r;
|
|
806
|
+
e.view.change((i) => {
|
|
807
|
+
i.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
const N = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
|
|
811
|
+
async function lt(r) {
|
|
812
|
+
const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(r);
|
|
813
|
+
return e.setCreator(async (...i) => {
|
|
814
|
+
const a = await r.create(...i);
|
|
815
|
+
return a[N] = e, a;
|
|
816
|
+
}), {
|
|
817
|
+
watchdog: e,
|
|
818
|
+
Constructor: {
|
|
819
|
+
create: async (...i) => (await e.create(...i), e.editor)
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
function dt(r) {
|
|
824
|
+
return N in r ? r[N] : null;
|
|
825
|
+
}
|
|
826
|
+
class v extends j {
|
|
827
|
+
static the = new v();
|
|
828
|
+
}
|
|
829
|
+
class mt extends HTMLElement {
|
|
830
|
+
/**
|
|
831
|
+
* The promise that resolves to the context instance.
|
|
832
|
+
*/
|
|
833
|
+
contextPromise = null;
|
|
834
|
+
/**
|
|
835
|
+
* Wait result for the interactive attribute.
|
|
836
|
+
*/
|
|
837
|
+
interactiveWait;
|
|
838
|
+
/**
|
|
839
|
+
* Mounts the context component.
|
|
840
|
+
*/
|
|
841
|
+
async connectedCallback() {
|
|
842
|
+
await I(), this.interactiveWait = M(this), await this.interactiveWait.promise, await this.initializeContext();
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Initializes the context component.
|
|
846
|
+
*/
|
|
847
|
+
async initializeContext() {
|
|
848
|
+
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: o, ...c } } = i, { loadedPlugins: u, hasPremium: s } = await J(o ?? []), p = [
|
|
849
|
+
...await U(e, s),
|
|
850
|
+
K(a || {})
|
|
851
|
+
].filter((f) => !B(f));
|
|
852
|
+
this.contextPromise = (async () => {
|
|
853
|
+
const { ContextWatchdog: f, Context: w } = await import("ckeditor5"), h = new f(w, {
|
|
854
|
+
crashNumberLimit: 10,
|
|
855
|
+
...n
|
|
856
|
+
});
|
|
857
|
+
let y = P(c);
|
|
858
|
+
return y = T([...p].reverse(), e.ui, y), await h.create({
|
|
859
|
+
...y,
|
|
860
|
+
language: e,
|
|
861
|
+
plugins: u,
|
|
862
|
+
...p.length && {
|
|
863
|
+
translations: p
|
|
864
|
+
}
|
|
865
|
+
}), h.on("itemError", (...O) => {
|
|
866
|
+
console.error("Context item error:", ...O);
|
|
867
|
+
}), h;
|
|
868
|
+
})();
|
|
869
|
+
const E = await this.contextPromise;
|
|
870
|
+
this.isConnected && v.the.register(t, E);
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Destroys the context component. Unmounts root from the editor.
|
|
874
|
+
*/
|
|
875
|
+
async disconnectedCallback() {
|
|
876
|
+
this.interactiveWait?.disconnect();
|
|
877
|
+
const t = this.getAttribute("data-cke-context-id");
|
|
878
|
+
this.style.display = "none";
|
|
879
|
+
try {
|
|
880
|
+
await (await this.contextPromise)?.destroy();
|
|
881
|
+
} finally {
|
|
882
|
+
this.contextPromise = null, t && v.the.hasItem(t) && v.the.unregister(t);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
class m extends j {
|
|
887
|
+
static the = new m();
|
|
888
|
+
}
|
|
889
|
+
class ht extends HTMLElement {
|
|
890
|
+
/**
|
|
891
|
+
* The promise that resolves when the editable is mounted.
|
|
892
|
+
*/
|
|
893
|
+
editorPromise = null;
|
|
894
|
+
/**
|
|
895
|
+
* Wait result for the interactive attribute.
|
|
896
|
+
*/
|
|
897
|
+
interactiveWait;
|
|
898
|
+
/**
|
|
899
|
+
* Callbacks to be invoked before the editable is destroyed.
|
|
900
|
+
*/
|
|
901
|
+
beforeDestroyCallbacks = [];
|
|
902
|
+
/**
|
|
903
|
+
* Registers a callback to be called before the editable is destroyed.
|
|
904
|
+
*/
|
|
905
|
+
onBeforeDestroy(t) {
|
|
906
|
+
this.beforeDestroyCallbacks.push(t);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Mounts the editable component.
|
|
910
|
+
*/
|
|
911
|
+
async connectedCallback() {
|
|
912
|
+
await I(), this.interactiveWait = M(this), await this.interactiveWait.promise, await this.initializeEditable();
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Initializes the editable instance.
|
|
916
|
+
*/
|
|
917
|
+
async initializeEditable() {
|
|
918
|
+
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", G()[0]);
|
|
919
|
+
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);
|
|
920
|
+
if (!t || !e)
|
|
921
|
+
throw new b("Editor ID or Root Name is missing.");
|
|
922
|
+
this.style.display = "block", this.editorPromise = m.the.execute(t, async (n) => {
|
|
923
|
+
if (!this.isConnected)
|
|
924
|
+
return null;
|
|
925
|
+
const { ui: o, editing: c, model: u } = n, s = this.querySelector("input");
|
|
926
|
+
if (u.document.getRoot(e)?.isAttached()) {
|
|
927
|
+
if (i !== null) {
|
|
928
|
+
const h = n.getData({ rootName: e });
|
|
929
|
+
h && h !== i && n.setData({
|
|
930
|
+
[e]: i
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
return n;
|
|
934
|
+
}
|
|
935
|
+
n.addRoot(e, {
|
|
936
|
+
isUndoable: !1,
|
|
937
|
+
...i !== null && {
|
|
938
|
+
data: i
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
const p = this.querySelector("[data-cke-editable-content]"), E = o.view.createEditable(e, p);
|
|
942
|
+
o.addEditable(E), c.view.forceRender();
|
|
943
|
+
const f = () => {
|
|
944
|
+
if (!u.document.getRoot(e)?.isAttached())
|
|
945
|
+
return;
|
|
946
|
+
const h = n.getData({ rootName: e });
|
|
947
|
+
s && (s.value = h, s.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
|
|
948
|
+
detail: {
|
|
949
|
+
value: h
|
|
950
|
+
}
|
|
951
|
+
}));
|
|
952
|
+
}, w = z(a, f);
|
|
953
|
+
return n.model.document.on("change:data", w), this.onBeforeDestroy(() => n.model.document.off("change:data", w)), f(), n;
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Destroys the editable component. Unmounts root from the editor.
|
|
958
|
+
*/
|
|
959
|
+
async disconnectedCallback() {
|
|
960
|
+
this.interactiveWait?.disconnect();
|
|
961
|
+
const t = this.getAttribute("data-cke-root-name");
|
|
962
|
+
this.style.display = "none";
|
|
963
|
+
const e = await this.editorPromise;
|
|
964
|
+
this.editorPromise = null;
|
|
965
|
+
for (const i of this.beforeDestroyCallbacks)
|
|
966
|
+
i();
|
|
967
|
+
if (this.beforeDestroyCallbacks = [], e && e.state !== "destroyed" && t) {
|
|
968
|
+
const i = e.model.document.getRoot(t);
|
|
969
|
+
if (i && "detachEditable" in e) {
|
|
970
|
+
try {
|
|
971
|
+
e.ui.view.editables[t] && e.detachEditable(i);
|
|
972
|
+
} catch (a) {
|
|
973
|
+
console.error("Unable unmount editable from root:", a);
|
|
974
|
+
}
|
|
975
|
+
i.isAttached() && e.detachRoot(t, !1);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
async function pt({
|
|
981
|
+
saveDebounceMs: r,
|
|
982
|
+
editorId: t,
|
|
983
|
+
targetElement: e
|
|
984
|
+
}) {
|
|
985
|
+
const { Plugin: i } = await import("ckeditor5");
|
|
986
|
+
return class extends i {
|
|
987
|
+
/**
|
|
988
|
+
* The name of the plugin.
|
|
989
|
+
*/
|
|
990
|
+
static get pluginName() {
|
|
991
|
+
return "DispatchEditorRootsChangeEvent";
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Initializes the plugin.
|
|
995
|
+
*/
|
|
996
|
+
afterInit() {
|
|
997
|
+
const { editor: n } = this, o = z(r, this.dispatch);
|
|
998
|
+
n.model.document.on("change:data", o), n.once("ready", this.dispatch);
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Dispatches a custom event with all roots data.
|
|
1002
|
+
*/
|
|
1003
|
+
dispatch = () => {
|
|
1004
|
+
const { editor: n } = this;
|
|
1005
|
+
e.dispatchEvent(
|
|
1006
|
+
new g({
|
|
1007
|
+
editorId: t,
|
|
1008
|
+
editor: n,
|
|
1009
|
+
roots: H(n)
|
|
1010
|
+
})
|
|
1011
|
+
);
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
class g extends CustomEvent {
|
|
1016
|
+
static EVENT_NAME = "ckeditor5:change:data";
|
|
1017
|
+
constructor(t) {
|
|
1018
|
+
super(g.EVENT_NAME, {
|
|
1019
|
+
detail: t,
|
|
1020
|
+
bubbles: !0
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
async function wt(r) {
|
|
1025
|
+
const { Plugin: t } = await import("ckeditor5");
|
|
1026
|
+
return class extends t {
|
|
1027
|
+
/**
|
|
1028
|
+
* The input element to synchronize with.
|
|
1029
|
+
*/
|
|
1030
|
+
input = null;
|
|
1031
|
+
/**
|
|
1032
|
+
* The form element reference for cleanup.
|
|
1033
|
+
*/
|
|
1034
|
+
form = null;
|
|
1035
|
+
/**
|
|
1036
|
+
* The name of the plugin.
|
|
1037
|
+
*/
|
|
1038
|
+
static get pluginName() {
|
|
1039
|
+
return "SyncEditorWithInput";
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* Initializes the plugin.
|
|
1043
|
+
*/
|
|
1044
|
+
afterInit() {
|
|
1045
|
+
const { editor: i } = this, n = i.sourceElement.id.replace(/_editor$/, "");
|
|
1046
|
+
this.input = document.getElementById(`${n}_input`), this.input && (i.model.document.on("change:data", z(r, () => this.sync())), i.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Synchronizes the editor's content with the input field.
|
|
1050
|
+
*/
|
|
1051
|
+
sync = () => {
|
|
1052
|
+
if (this.input) {
|
|
1053
|
+
const i = this.editor.getData();
|
|
1054
|
+
this.input.value = i, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* Destroys the plugin.
|
|
1059
|
+
*/
|
|
1060
|
+
destroy() {
|
|
1061
|
+
this.form && this.form.removeEventListener("submit", this.sync), this.input = null, this.form = null;
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
class ft extends HTMLElement {
|
|
1066
|
+
/**
|
|
1067
|
+
* The promise that resolves to the editor instance.
|
|
1068
|
+
*/
|
|
1069
|
+
editorPromise = null;
|
|
1070
|
+
/**
|
|
1071
|
+
* Wait result for the interactive attribute.
|
|
1072
|
+
*/
|
|
1073
|
+
interactiveWait;
|
|
1074
|
+
/**
|
|
1075
|
+
* Mounts the editor component.
|
|
1076
|
+
*/
|
|
1077
|
+
async connectedCallback() {
|
|
1078
|
+
await I(), this.interactiveWait = M(this), L("classic"), await this.interactiveWait.promise, await this.initializeEditor();
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Initializes the editor instance.
|
|
1082
|
+
*/
|
|
1083
|
+
async initializeEditor() {
|
|
1084
|
+
const t = this.getAttribute("data-cke-editor-id");
|
|
1085
|
+
m.the.resetErrors(t);
|
|
1086
|
+
try {
|
|
1087
|
+
this.style.display = "block", this.editorPromise = this.createEditor();
|
|
1088
|
+
const e = await this.editorPromise;
|
|
1089
|
+
this.isConnected && (m.the.register(t, e), e.once("destroy", () => {
|
|
1090
|
+
m.the.hasItem(t) && m.the.unregister(t);
|
|
1091
|
+
}));
|
|
1092
|
+
} catch (e) {
|
|
1093
|
+
console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e), this.editorPromise = null, m.the.error(t, e);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Destroys the editor instance when the component is destroyed.
|
|
1098
|
+
* This is important to prevent memory leaks and ensure that the editor is properly cleaned up.
|
|
1099
|
+
*/
|
|
1100
|
+
async disconnectedCallback() {
|
|
1101
|
+
this.interactiveWait?.disconnect(), this.style.display = "none";
|
|
1102
|
+
try {
|
|
1103
|
+
const t = await this.editorPromise;
|
|
1104
|
+
if (!t)
|
|
1105
|
+
return;
|
|
1106
|
+
const e = ot(t), i = dt(t);
|
|
1107
|
+
e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : i ? await i.destroy() : await t.destroy();
|
|
1108
|
+
} finally {
|
|
1109
|
+
this.editorPromise = null;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Creates the CKEditor instance.
|
|
1114
|
+
*/
|
|
1115
|
+
async createEditor() {
|
|
1116
|
+
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), o = JSON.parse(this.getAttribute("data-cke-language")), c = this.hasAttribute("data-cke-watchdog"), u = JSON.parse(this.getAttribute("data-cke-content")), {
|
|
1117
|
+
customTranslations: s,
|
|
1118
|
+
editorType: l,
|
|
1119
|
+
licenseKey: p,
|
|
1120
|
+
config: { plugins: E, ...f }
|
|
1121
|
+
} = e;
|
|
1122
|
+
let w = await L(l);
|
|
1123
|
+
const h = await (i ? v.the.waitFor(i) : null);
|
|
1124
|
+
if (c && !h) {
|
|
1125
|
+
const d = await lt(w);
|
|
1126
|
+
({ Constructor: w } = d), d.watchdog.on("restart", () => {
|
|
1127
|
+
const k = d.watchdog.editor;
|
|
1128
|
+
this.editorPromise = Promise.resolve(k), m.the.register(t, k);
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
const { loadedPlugins: y, hasPremium: O } = await J(E);
|
|
1132
|
+
y.push(
|
|
1133
|
+
await pt({
|
|
1134
|
+
saveDebounceMs: n,
|
|
1135
|
+
editorId: t,
|
|
1136
|
+
targetElement: this
|
|
1137
|
+
})
|
|
1138
|
+
), A(l) && y.push(
|
|
1139
|
+
await wt(n)
|
|
1140
|
+
);
|
|
1141
|
+
const S = [
|
|
1142
|
+
...await U(o, O),
|
|
1143
|
+
K(s || {})
|
|
1144
|
+
].filter((d) => !B(d));
|
|
1145
|
+
let C = {
|
|
1146
|
+
...u,
|
|
1147
|
+
..._(t)
|
|
1148
|
+
};
|
|
1149
|
+
A(l) && (C = C.main || "");
|
|
1150
|
+
const R = await (async () => {
|
|
1151
|
+
let d = Y(t);
|
|
1152
|
+
if (!d.main) {
|
|
1153
|
+
const q = A(l) ? ["main"] : Object.keys(C);
|
|
1154
|
+
Q(d, q) || (d = await gt(t, q), C = {
|
|
1155
|
+
...u,
|
|
1156
|
+
..._(t)
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
A(l) && "main" in d && (d = d.main);
|
|
1160
|
+
let k = P(f);
|
|
1161
|
+
k = T([...S].reverse(), o.ui, k);
|
|
1162
|
+
const W = {
|
|
1163
|
+
...k,
|
|
1164
|
+
initialData: C,
|
|
1165
|
+
licenseKey: p,
|
|
1166
|
+
plugins: y,
|
|
1167
|
+
language: o,
|
|
1168
|
+
...S.length && {
|
|
1169
|
+
translations: S
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
return !h || !(d instanceof HTMLElement) ? w.create(d, W) : (await nt({
|
|
1173
|
+
context: h,
|
|
1174
|
+
element: d,
|
|
1175
|
+
creator: w,
|
|
1176
|
+
config: W
|
|
1177
|
+
})).editor;
|
|
1178
|
+
})();
|
|
1179
|
+
return A(l) && a && ut(R, a), R;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
function Q(r, t) {
|
|
1183
|
+
return t.every((e) => r[e]);
|
|
1184
|
+
}
|
|
1185
|
+
async function gt(r, t) {
|
|
1186
|
+
return at(
|
|
1187
|
+
() => {
|
|
1188
|
+
const e = Y(r);
|
|
1189
|
+
if (!Q(e, t))
|
|
1190
|
+
throw new Error(
|
|
1191
|
+
`It looks like not all required root elements are present yet.
|
|
1192
|
+
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
1193
|
+
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
1194
|
+
Missing roots: ${t.filter((i) => !e[i]).join(", ")}.`
|
|
1195
|
+
);
|
|
1196
|
+
return e;
|
|
1197
|
+
},
|
|
1198
|
+
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
class yt extends HTMLElement {
|
|
1202
|
+
/**
|
|
1203
|
+
* The promise that resolves when the UI part is mounted.
|
|
1204
|
+
*/
|
|
1205
|
+
mountedPromise = null;
|
|
1206
|
+
/**
|
|
1207
|
+
* Mounts the UI part component.
|
|
1208
|
+
*/
|
|
1209
|
+
async connectedCallback() {
|
|
1210
|
+
await I();
|
|
1211
|
+
const t = this.getAttribute("data-cke-editor-id") || G()[0], e = this.getAttribute("data-cke-name");
|
|
1212
|
+
!t || !e || (this.style.display = "block", this.mountedPromise = m.the.execute(t, (i) => {
|
|
1213
|
+
if (!this.isConnected)
|
|
1214
|
+
return;
|
|
1215
|
+
const { ui: a } = i, n = bt(e), o = a.view[n];
|
|
1216
|
+
if (!o)
|
|
1217
|
+
throw new b(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1218
|
+
this.appendChild(o.element);
|
|
1219
|
+
}));
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Destroys the UI part component. Unmounts UI parts from the editor.
|
|
1223
|
+
*/
|
|
1224
|
+
async disconnectedCallback() {
|
|
1225
|
+
this.style.display = "none", await this.mountedPromise, this.mountedPromise = null, this.innerHTML = "";
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
function bt(r) {
|
|
1229
|
+
switch (r) {
|
|
1230
|
+
case "toolbar":
|
|
1231
|
+
return "toolbar";
|
|
1232
|
+
case "menubar":
|
|
1233
|
+
return "menuBarView";
|
|
1234
|
+
/* v8 ignore next -- @preserve */
|
|
1235
|
+
default:
|
|
1236
|
+
return null;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
const Et = {
|
|
1240
|
+
"cke5-editor": ft,
|
|
1241
|
+
"cke5-context": mt,
|
|
1242
|
+
"cke5-ui-part": yt,
|
|
1243
|
+
"cke5-editable": ht
|
|
1244
|
+
};
|
|
1245
|
+
function kt() {
|
|
1246
|
+
for (const [r, t] of Object.entries(Et))
|
|
1247
|
+
window.customElements.get(r) || window.customElements.define(r, t);
|
|
1248
|
+
}
|
|
1249
|
+
function Tt(r) {
|
|
1250
|
+
return D(r), {
|
|
1251
|
+
unmount() {
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
function Z(r, t) {
|
|
1256
|
+
const e = {
|
|
1257
|
+
/** Value received from Blazor while the editor was focused, pending application on blur. */
|
|
1258
|
+
pendingValue: null,
|
|
1259
|
+
/** The last value sent to or received from Blazor to prevent circular updates. */
|
|
1260
|
+
lastSyncedValue: null
|
|
1261
|
+
}, i = () => {
|
|
1262
|
+
e.pendingValue = null;
|
|
1263
|
+
}, a = (n, o, c) => {
|
|
1264
|
+
if (c || e.pendingValue === null)
|
|
1265
|
+
return;
|
|
1266
|
+
const u = t.getCurrentValue();
|
|
1267
|
+
t.isEqual(u, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
|
|
1268
|
+
};
|
|
1269
|
+
return r.model.document.on("change:data", i), r.ui.focusTracker.on("change:isFocused", a), {
|
|
1270
|
+
/**
|
|
1271
|
+
* Removes all editor listeners registered by this sync instance.
|
|
1272
|
+
* Call this when the Blazor component is disposed.
|
|
1273
|
+
*/
|
|
1274
|
+
unmount() {
|
|
1275
|
+
r.model.document.off("change:data", i), r.ui.focusTracker.off("change:isFocused", a);
|
|
1276
|
+
},
|
|
1277
|
+
/**
|
|
1278
|
+
* Checks whether the given value differs from the last synced value and, if so,
|
|
1279
|
+
* updates `lastSyncedValue` and returns `true` to signal that Blazor should be notified.
|
|
1280
|
+
*
|
|
1281
|
+
* Call this from the `CKEditor5ChangeDataEvent` handler to conditionally invoke
|
|
1282
|
+
* the .NET interop method.
|
|
1283
|
+
*/
|
|
1284
|
+
shouldNotify(n) {
|
|
1285
|
+
return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) ? !1 : (e.lastSyncedValue = n, !0);
|
|
1286
|
+
},
|
|
1287
|
+
/**
|
|
1288
|
+
* Pushes a new value from Blazor into the editor.
|
|
1289
|
+
* If the editor is currently focused, the update is deferred until blur.
|
|
1290
|
+
* If the value matches the last synced state, the update is skipped entirely.
|
|
1291
|
+
*/
|
|
1292
|
+
setValue(n) {
|
|
1293
|
+
if (r.ui.focusTracker.isFocused) {
|
|
1294
|
+
e.pendingValue = n;
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, n) || (e.lastSyncedValue = n, t.applyValue(n));
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
function tt() {
|
|
1302
|
+
return {
|
|
1303
|
+
unmount() {
|
|
1304
|
+
},
|
|
1305
|
+
shouldNotify(r) {
|
|
1306
|
+
return !1;
|
|
1307
|
+
},
|
|
1308
|
+
setValue(r) {
|
|
1309
|
+
}
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
function It(r, t) {
|
|
1313
|
+
const e = r.getAttribute("data-cke-editor-id"), i = r.getAttribute("data-cke-root-name") ?? "main";
|
|
1314
|
+
let a = !1, n = tt(), o = null;
|
|
1315
|
+
const c = (s) => {
|
|
1316
|
+
if (!(s instanceof g) || s.detail.editorId !== e)
|
|
1317
|
+
return;
|
|
1318
|
+
const l = s.detail.roots[i];
|
|
1319
|
+
l !== void 0 && n.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
|
|
1320
|
+
};
|
|
1321
|
+
return (async () => {
|
|
1322
|
+
const s = await m.the.waitFor(e);
|
|
1323
|
+
o = DotNet.createJSObjectReference(s), n = Z(s, {
|
|
1324
|
+
getCurrentValue: () => s.getData({ rootName: i }) ?? "",
|
|
1325
|
+
applyValue: (l) => s.setData({ [i]: l }),
|
|
1326
|
+
isEqual: (l, p) => l === p
|
|
1327
|
+
});
|
|
1328
|
+
})(), document.body.addEventListener(g.EVENT_NAME, c), D(r), {
|
|
1329
|
+
/**
|
|
1330
|
+
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1331
|
+
*/
|
|
1332
|
+
unmount() {
|
|
1333
|
+
a || (document.body.removeEventListener(g.EVENT_NAME, c), n.unmount(), o && (DotNet.disposeJSObjectReference(o), o = null), a = !0);
|
|
1334
|
+
},
|
|
1335
|
+
/**
|
|
1336
|
+
* Updates this editable root's data from Blazor.
|
|
1337
|
+
* If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1338
|
+
*/
|
|
1339
|
+
setValue: async (s) => {
|
|
1340
|
+
a || (await m.the.waitFor(e), n.setValue(s));
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
function Dt(r, t) {
|
|
1345
|
+
const e = r.getAttribute("data-cke-editor-id");
|
|
1346
|
+
let i = !1, a = null, n = tt(), o = null;
|
|
1347
|
+
const c = (s) => {
|
|
1348
|
+
!(s instanceof g) || s.detail.editorId !== e || n.shouldNotify(s.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", o, s.detail.roots);
|
|
1349
|
+
};
|
|
1350
|
+
return (async () => {
|
|
1351
|
+
const s = await m.the.waitFor(e);
|
|
1352
|
+
o = globalThis.DotNet.createJSObjectReference(s), n = Z(s, {
|
|
1353
|
+
getCurrentValue: () => H(s),
|
|
1354
|
+
applyValue: (p) => s.setData(p),
|
|
1355
|
+
isEqual: rt
|
|
1356
|
+
});
|
|
1357
|
+
const l = (p, E, f) => {
|
|
1358
|
+
const w = f ? "OnEditorFocus" : "OnEditorBlur";
|
|
1359
|
+
t.invokeMethodAsync(w, o);
|
|
1360
|
+
};
|
|
1361
|
+
s.ui.focusTracker.on("change:isFocused", l), t.invokeMethodAsync("OnEditorReady", o), a = () => {
|
|
1362
|
+
s.ui.focusTracker.off("change:isFocused", l);
|
|
1363
|
+
};
|
|
1364
|
+
})(), document.body.addEventListener(g.EVENT_NAME, c), kt(), D(r), {
|
|
1365
|
+
/**
|
|
1366
|
+
* Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1367
|
+
*/
|
|
1368
|
+
setValue: async (s) => {
|
|
1369
|
+
i || (await m.the.waitFor(e), n.setValue(s));
|
|
1370
|
+
},
|
|
1371
|
+
/**
|
|
1372
|
+
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1373
|
+
*/
|
|
1374
|
+
unmount() {
|
|
1375
|
+
i || (document.body.removeEventListener(g.EVENT_NAME, c), n.unmount(), a?.(), o && (globalThis.DotNet.disposeJSObjectReference(o), o = null), i = !0);
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
function Ot(r) {
|
|
1380
|
+
return D(r), {
|
|
1381
|
+
unmount() {
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
export {
|
|
1386
|
+
b as CKEditor5BlazorError,
|
|
1387
|
+
g as CKEditor5ChangeDataEvent,
|
|
1388
|
+
v as ContextsRegistry,
|
|
1389
|
+
$ as CustomEditorPluginsRegistry,
|
|
1390
|
+
ht as EditableComponentElement,
|
|
1391
|
+
ft as EditorComponentElement,
|
|
1392
|
+
m as EditorsRegistry,
|
|
1393
|
+
yt as UIPartComponentElement,
|
|
1394
|
+
Tt as createContextBlazorInterop,
|
|
1395
|
+
It as createEditableBlazorInterop,
|
|
1396
|
+
Dt as createEditorBlazorInterop,
|
|
1397
|
+
Ot as createUIPartBlazorInterop,
|
|
1398
|
+
kt as ensureEditorElementsRegistered
|
|
1399
|
+
};
|
|
1400
|
+
//# sourceMappingURL=index.mjs.map
|