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