ckeditor5-livewire 1.10.0 → 1.12.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/hooks/editable.d.ts +3 -5
- package/dist/hooks/editable.d.ts.map +1 -1
- package/dist/hooks/editor/editor.d.ts +0 -4
- package/dist/hooks/editor/editor.d.ts.map +1 -1
- package/dist/hooks/editor/plugins/livewire-sync.d.ts.map +1 -1
- package/dist/hooks/editor/types/editor-relaxed-constructor.type.d.ts +6 -0
- package/dist/hooks/editor/types/editor-relaxed-constructor.type.d.ts.map +1 -0
- package/dist/hooks/editor/types/index.d.ts +2 -0
- package/dist/hooks/editor/types/index.d.ts.map +1 -0
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +10 -0
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +1 -0
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +12 -0
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +1 -0
- package/dist/hooks/editor/utils/cleanup-orphan-editor-elements.d.ts +8 -0
- package/dist/hooks/editor/utils/cleanup-orphan-editor-elements.d.ts.map +1 -0
- package/dist/hooks/editor/utils/create-editor-in-context.d.ts +7 -4
- package/dist/hooks/editor/utils/create-editor-in-context.d.ts.map +1 -1
- package/dist/hooks/editor/utils/index.d.ts +4 -0
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/hooks/editor/utils/is-multiroot-editor-instance.d.ts +6 -0
- package/dist/hooks/editor/utils/is-multiroot-editor-instance.d.ts.map +1 -0
- package/dist/hooks/editor/utils/wrap-with-watchdog.d.ts +7 -16
- package/dist/hooks/editor/utils/wrap-with-watchdog.d.ts.map +1 -1
- package/dist/hooks/ui-part.d.ts +2 -6
- package/dist/hooks/ui-part.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +349 -232
- package/dist/index.mjs.map +1 -1
- package/dist/shared/are-maps-equal.d.ts +11 -0
- package/dist/shared/are-maps-equal.d.ts.map +1 -0
- package/dist/shared/async-registry.d.ts +43 -10
- package/dist/shared/async-registry.d.ts.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/hooks/context/context.test.ts +3 -1
- package/src/hooks/editable.ts +74 -47
- package/src/hooks/editor/editor.test.ts +44 -9
- package/src/hooks/editor/editor.ts +161 -149
- package/src/hooks/editor/plugins/livewire-sync.ts +17 -8
- package/src/hooks/editor/types/editor-relaxed-constructor.type.ts +6 -0
- package/src/hooks/editor/types/index.ts +1 -0
- package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +48 -0
- package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +61 -0
- package/src/hooks/editor/utils/cleanup-orphan-editor-elements.test.ts +285 -0
- package/src/hooks/editor/utils/cleanup-orphan-editor-elements.ts +60 -0
- package/src/hooks/editor/utils/create-editor-in-context.ts +8 -7
- package/src/hooks/editor/utils/index.ts +4 -0
- package/src/hooks/editor/utils/is-multiroot-editor-instance.ts +8 -0
- package/src/hooks/editor/utils/wrap-with-watchdog.test.ts +34 -14
- package/src/hooks/editor/utils/wrap-with-watchdog.ts +16 -26
- package/src/hooks/ui-part.ts +10 -16
- package/src/shared/are-maps-equal.test.ts +56 -0
- package/src/shared/are-maps-equal.ts +22 -0
- package/src/shared/async-registry.test.ts +212 -31
- package/src/shared/async-registry.ts +178 -61
- package/src/shared/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -42,12 +42,22 @@ function t(e, t) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
45
|
+
//#region src/shared/are-maps-equal.ts
|
|
46
|
+
function n(e, t) {
|
|
47
|
+
if (!e || e.size !== t.size) return !1;
|
|
48
|
+
for (let [n, r] of e) if (!t.has(n) || t.get(n) !== r) return !1;
|
|
49
|
+
return !0;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
45
52
|
//#region src/shared/async-registry.ts
|
|
46
|
-
var
|
|
53
|
+
var r = class {
|
|
47
54
|
items = /* @__PURE__ */ new Map();
|
|
48
55
|
initializationErrors = /* @__PURE__ */ new Map();
|
|
49
56
|
pendingCallbacks = /* @__PURE__ */ new Map();
|
|
50
57
|
watchers = /* @__PURE__ */ new Set();
|
|
58
|
+
batchDepth = 0;
|
|
59
|
+
lastNotifiedItems = null;
|
|
60
|
+
lastNotifiedErrors = null;
|
|
51
61
|
execute(e, t, n) {
|
|
52
62
|
let r = this.items.get(e), i = this.initializationErrors.get(e);
|
|
53
63
|
return i ? (n?.(i), Promise.reject(i)) : r ? Promise.resolve(t(r)) : new Promise((r, i) => {
|
|
@@ -57,28 +67,50 @@ var n = class {
|
|
|
57
67
|
}), n ? a.error.push(n) : a.error.push(i);
|
|
58
68
|
});
|
|
59
69
|
}
|
|
70
|
+
mountEffect(e, t) {
|
|
71
|
+
let n, r, i = !1, a = this.watch((o) => {
|
|
72
|
+
let s = o.get(e);
|
|
73
|
+
if (s !== r && (n?.(), n = void 0, r = s, s)) try {
|
|
74
|
+
let e = t(s);
|
|
75
|
+
i ? (e?.(), a()) : n = e;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
throw console.error(e), e;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return () => {
|
|
81
|
+
i = !0, r && (a(), n?.(), n = void 0);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
60
84
|
register(e, t) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
this.batch(() => {
|
|
86
|
+
if (this.items.has(e)) throw Error(`Item with ID "${e}" is already registered.`);
|
|
87
|
+
this.resetErrors(e), this.items.set(e, t);
|
|
88
|
+
let n = this.pendingCallbacks.get(e);
|
|
89
|
+
n && (n.success.forEach((e) => e(t)), this.pendingCallbacks.delete(e)), this.items.size === 1 && e !== null && this.register(null, t);
|
|
90
|
+
});
|
|
65
91
|
}
|
|
66
92
|
error(e, t) {
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
this.batch(() => {
|
|
94
|
+
this.items.delete(e), this.initializationErrors.set(e, t);
|
|
95
|
+
let n = this.pendingCallbacks.get(e);
|
|
96
|
+
n && (n.error.forEach((e) => e(t)), this.pendingCallbacks.delete(e)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, t);
|
|
97
|
+
});
|
|
70
98
|
}
|
|
71
99
|
resetErrors(e) {
|
|
72
100
|
let { initializationErrors: t } = this;
|
|
73
101
|
t.has(null) && t.get(null) === t.get(e) && t.delete(null), t.delete(e);
|
|
74
102
|
}
|
|
75
|
-
unregister(e) {
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
unregister(e, t = !0) {
|
|
104
|
+
this.batch(() => {
|
|
105
|
+
e && this.items.get(null) === this.items.get(e) && this.unregister(null, !1), this.items.delete(e), t && this.pendingCallbacks.delete(e), this.resetErrors(e);
|
|
106
|
+
});
|
|
78
107
|
}
|
|
79
108
|
getItems() {
|
|
80
109
|
return Array.from(this.items.values());
|
|
81
110
|
}
|
|
111
|
+
getItem(e) {
|
|
112
|
+
return this.items.get(e);
|
|
113
|
+
}
|
|
82
114
|
hasItem(e) {
|
|
83
115
|
return this.items.has(e);
|
|
84
116
|
}
|
|
@@ -89,7 +121,18 @@ var n = class {
|
|
|
89
121
|
}
|
|
90
122
|
async destroyAll() {
|
|
91
123
|
let e = Array.from(new Set(this.items.values())).map((e) => e.destroy());
|
|
92
|
-
this.items.clear(), this.pendingCallbacks.clear(), await Promise.all(e), this.
|
|
124
|
+
this.items.clear(), this.pendingCallbacks.clear(), await Promise.all(e), this.flushWatchers();
|
|
125
|
+
}
|
|
126
|
+
async reset() {
|
|
127
|
+
await this.destroyAll(), this.watchers.clear();
|
|
128
|
+
}
|
|
129
|
+
batch(e) {
|
|
130
|
+
this.batchDepth++;
|
|
131
|
+
try {
|
|
132
|
+
return e();
|
|
133
|
+
} finally {
|
|
134
|
+
this.batchDepth--, this.batchDepth === 0 && this.flushWatchers();
|
|
135
|
+
}
|
|
93
136
|
}
|
|
94
137
|
watch(e) {
|
|
95
138
|
return this.watchers.add(e), e(new Map(this.items), new Map(this.initializationErrors)), this.unwatch.bind(this, e);
|
|
@@ -97,8 +140,8 @@ var n = class {
|
|
|
97
140
|
unwatch(e) {
|
|
98
141
|
this.watchers.delete(e);
|
|
99
142
|
}
|
|
100
|
-
|
|
101
|
-
this.watchers.forEach((e) => e(new Map(this.items), new Map(this.initializationErrors)));
|
|
143
|
+
flushWatchers() {
|
|
144
|
+
n(this.lastNotifiedItems, this.items) && n(this.lastNotifiedErrors, this.initializationErrors) || (this.lastNotifiedItems = new Map(this.items), this.lastNotifiedErrors = new Map(this.initializationErrors), this.watchers.forEach((e) => e(new Map(this.items), new Map(this.initializationErrors))));
|
|
102
145
|
}
|
|
103
146
|
getPendingCallbacks(e) {
|
|
104
147
|
let t = this.pendingCallbacks.get(e);
|
|
@@ -107,13 +150,10 @@ var n = class {
|
|
|
107
150
|
error: []
|
|
108
151
|
}, this.pendingCallbacks.set(e, t)), t;
|
|
109
152
|
}
|
|
110
|
-
registerAsDefault(e, t) {
|
|
111
|
-
this.items.size === 1 && e !== null && this.register(null, t);
|
|
112
|
-
}
|
|
113
153
|
};
|
|
114
154
|
//#endregion
|
|
115
155
|
//#region src/shared/debounce.ts
|
|
116
|
-
function
|
|
156
|
+
function i(e, t) {
|
|
117
157
|
let n = null;
|
|
118
158
|
return (...r) => {
|
|
119
159
|
n && clearTimeout(n), n = setTimeout(() => {
|
|
@@ -123,24 +163,24 @@ function r(e, t) {
|
|
|
123
163
|
}
|
|
124
164
|
//#endregion
|
|
125
165
|
//#region src/shared/filter-object-values.ts
|
|
126
|
-
function
|
|
166
|
+
function a(e, t) {
|
|
127
167
|
let n = Object.entries(e).filter(([e, n]) => t(n, e));
|
|
128
168
|
return Object.fromEntries(n);
|
|
129
169
|
}
|
|
130
170
|
//#endregion
|
|
131
171
|
//#region src/shared/is-empty-object.ts
|
|
132
|
-
function
|
|
172
|
+
function o(e) {
|
|
133
173
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
134
174
|
}
|
|
135
175
|
//#endregion
|
|
136
176
|
//#region src/shared/map-object-values.ts
|
|
137
|
-
function
|
|
177
|
+
function s(e, t) {
|
|
138
178
|
let n = Object.entries(e).map(([e, n]) => [e, t(n, e)]);
|
|
139
179
|
return Object.fromEntries(n);
|
|
140
180
|
}
|
|
141
181
|
//#endregion
|
|
142
182
|
//#region src/shared/shallow-equal.ts
|
|
143
|
-
function
|
|
183
|
+
function c(e, t) {
|
|
144
184
|
if (e === t) return !0;
|
|
145
185
|
let n = Object.keys(e), r = Object.keys(t);
|
|
146
186
|
if (n.length !== r.length) return !1;
|
|
@@ -149,12 +189,12 @@ function s(e, t) {
|
|
|
149
189
|
}
|
|
150
190
|
//#endregion
|
|
151
191
|
//#region src/shared/uid.ts
|
|
152
|
-
function
|
|
192
|
+
function l() {
|
|
153
193
|
return Math.random().toString(36).substring(2);
|
|
154
194
|
}
|
|
155
195
|
//#endregion
|
|
156
196
|
//#region src/shared/wait-for.ts
|
|
157
|
-
function
|
|
197
|
+
function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
158
198
|
return new Promise((r, i) => {
|
|
159
199
|
let a = Date.now(), o = null, s = setTimeout(() => {
|
|
160
200
|
i(o ?? /* @__PURE__ */ Error("Timeout"));
|
|
@@ -170,40 +210,104 @@ function l(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
|
170
210
|
});
|
|
171
211
|
}
|
|
172
212
|
//#endregion
|
|
213
|
+
//#region src/hooks/editor/utils/assign-initial-data-to-editor-config.ts
|
|
214
|
+
function d(e, t) {
|
|
215
|
+
let n = f(e), r = new Set([...Object.keys(n), ...Object.keys(t.roots ?? {})]), i = Array.from(r).reduce((e, r) => ({
|
|
216
|
+
...e,
|
|
217
|
+
[r]: {
|
|
218
|
+
...t.roots?.[r],
|
|
219
|
+
...r === "main" ? t.root : {},
|
|
220
|
+
...r in n ? { initialData: n[r] } : {}
|
|
221
|
+
}
|
|
222
|
+
}), Object.create(t.roots || {})), a = {
|
|
223
|
+
...t,
|
|
224
|
+
roots: i
|
|
225
|
+
};
|
|
226
|
+
return delete a.root, a;
|
|
227
|
+
}
|
|
228
|
+
function f(e) {
|
|
229
|
+
return typeof e == "string" ? { main: e } : { ...e };
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/hooks/editor/utils/assign-source-elements-to-editor-config.ts
|
|
233
|
+
function p(e, t, n) {
|
|
234
|
+
let r = m(t);
|
|
235
|
+
if (!e.editorName || e.editorName === "ClassicEditor") return {
|
|
236
|
+
...n,
|
|
237
|
+
attachTo: r.main
|
|
238
|
+
};
|
|
239
|
+
let i = new Set([...Object.keys(r), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, t) => ({
|
|
240
|
+
...e,
|
|
241
|
+
[t]: {
|
|
242
|
+
...n.roots?.[t],
|
|
243
|
+
...t === "main" ? n.root : {},
|
|
244
|
+
...t in r ? { element: r[t] } : {}
|
|
245
|
+
}
|
|
246
|
+
}), Object.create(n.roots || {})), o = {
|
|
247
|
+
...n,
|
|
248
|
+
roots: a
|
|
249
|
+
};
|
|
250
|
+
return delete o.root, o;
|
|
251
|
+
}
|
|
252
|
+
function m(e) {
|
|
253
|
+
return e instanceof HTMLElement ? { main: e } : { ...e };
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/hooks/editor/utils/cleanup-orphan-editor-elements.ts
|
|
257
|
+
function h(e) {
|
|
258
|
+
let t = [
|
|
259
|
+
e.ui?.element,
|
|
260
|
+
e.ui?.view?.toolbar?.element,
|
|
261
|
+
e.ui?.view?.menuBarView?.element
|
|
262
|
+
].filter(Boolean);
|
|
263
|
+
for (let e of t) i(e);
|
|
264
|
+
let n = e.ui?.view?.body?._bodyCollectionContainer;
|
|
265
|
+
n?.isConnected && i(n);
|
|
266
|
+
let r = e.editing?.view;
|
|
267
|
+
if (r) for (let e of r.domRoots.values()) e instanceof HTMLElement && (e.removeAttribute("contenteditable"), e.removeAttribute("role"), e.removeAttribute("aria-label"), e.removeAttribute("aria-multiline"), e.removeAttribute("spellcheck"), e.classList.remove("ck", "ck-content", "ck-editor__editable", "ck-rounded-corners", "ck-editor__editable_inline", "ck-blurred", "ck-focused"), i(e));
|
|
268
|
+
function i(e) {
|
|
269
|
+
e.hasAttribute("data-cke-controlled") ? e.innerHTML = "" : e.remove();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
173
273
|
//#region src/hooks/editor/utils/create-editor-in-context.ts
|
|
174
|
-
var
|
|
175
|
-
async function
|
|
176
|
-
let
|
|
177
|
-
await
|
|
178
|
-
creator:
|
|
179
|
-
id:
|
|
180
|
-
sourceElementOrData: e,
|
|
274
|
+
var g = Symbol.for("context-editor-watchdog");
|
|
275
|
+
async function _({ context: e, creator: t, config: n }) {
|
|
276
|
+
let r = l();
|
|
277
|
+
await e.add({
|
|
278
|
+
creator: t.create.bind(t),
|
|
279
|
+
id: r,
|
|
181
280
|
type: "editor",
|
|
182
|
-
config:
|
|
281
|
+
config: n
|
|
183
282
|
});
|
|
184
|
-
let
|
|
283
|
+
let i = e.getItem(r), a = {
|
|
185
284
|
state: "available",
|
|
186
|
-
editorContextId:
|
|
187
|
-
context:
|
|
285
|
+
editorContextId: r,
|
|
286
|
+
context: e
|
|
188
287
|
};
|
|
189
|
-
|
|
190
|
-
let
|
|
191
|
-
return
|
|
192
|
-
...
|
|
193
|
-
editor:
|
|
288
|
+
i[g] = a;
|
|
289
|
+
let o = e.destroy.bind(e);
|
|
290
|
+
return e.destroy = async () => (a.state = "unavailable", o()), {
|
|
291
|
+
...a,
|
|
292
|
+
editor: i
|
|
194
293
|
};
|
|
195
294
|
}
|
|
196
|
-
function
|
|
197
|
-
return
|
|
295
|
+
function v(e) {
|
|
296
|
+
return g in e ? e[g] : null;
|
|
198
297
|
}
|
|
199
298
|
//#endregion
|
|
200
299
|
//#region src/hooks/editor/utils/get-editor-roots-values.ts
|
|
201
|
-
function
|
|
300
|
+
function y(e) {
|
|
202
301
|
return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create({}));
|
|
203
302
|
}
|
|
204
303
|
//#endregion
|
|
304
|
+
//#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
|
|
305
|
+
function b(e) {
|
|
306
|
+
return "addEditable" in e.ui;
|
|
307
|
+
}
|
|
308
|
+
//#endregion
|
|
205
309
|
//#region src/hooks/editor/utils/is-single-root-editor.ts
|
|
206
|
-
function
|
|
310
|
+
function x(e) {
|
|
207
311
|
return [
|
|
208
312
|
"inline",
|
|
209
313
|
"classic",
|
|
@@ -213,7 +317,7 @@ function m(e) {
|
|
|
213
317
|
}
|
|
214
318
|
//#endregion
|
|
215
319
|
//#region src/hooks/editor/utils/load-editor-constructor.ts
|
|
216
|
-
async function
|
|
320
|
+
async function S(e) {
|
|
217
321
|
let t = await import("ckeditor5"), n = {
|
|
218
322
|
inline: t.InlineEditor,
|
|
219
323
|
balloon: t.BalloonEditor,
|
|
@@ -226,7 +330,7 @@ async function h(e) {
|
|
|
226
330
|
}
|
|
227
331
|
//#endregion
|
|
228
332
|
//#region src/hooks/editor/custom-editor-plugins.ts
|
|
229
|
-
var
|
|
333
|
+
var C = class e {
|
|
230
334
|
static the = new e();
|
|
231
335
|
plugins = /* @__PURE__ */ new Map();
|
|
232
336
|
constructor() {}
|
|
@@ -250,9 +354,9 @@ var g = class e {
|
|
|
250
354
|
};
|
|
251
355
|
//#endregion
|
|
252
356
|
//#region src/hooks/editor/utils/load-editor-plugins.ts
|
|
253
|
-
async function
|
|
357
|
+
async function w(e) {
|
|
254
358
|
let t = await import("ckeditor5"), n = null, r = e.map(async (e) => {
|
|
255
|
-
let r = await
|
|
359
|
+
let r = await C.the.get(e);
|
|
256
360
|
if (r) return r;
|
|
257
361
|
let { [e]: i } = t;
|
|
258
362
|
if (i) return i;
|
|
@@ -274,19 +378,19 @@ async function _(e) {
|
|
|
274
378
|
}
|
|
275
379
|
//#endregion
|
|
276
380
|
//#region src/hooks/editor/utils/load-editor-translations.ts
|
|
277
|
-
async function
|
|
278
|
-
let n = [e.ui, e.content], r = [
|
|
279
|
-
return t && r.push(
|
|
381
|
+
async function T(e, t) {
|
|
382
|
+
let n = [e.ui, e.content], r = [E("ckeditor5", n)];
|
|
383
|
+
return t && r.push(E("ckeditor5-premium-features", n)), await Promise.all(r).then((e) => e.flat());
|
|
280
384
|
}
|
|
281
|
-
async function
|
|
385
|
+
async function E(e, t) {
|
|
282
386
|
/* v8 ignore next */
|
|
283
387
|
return await Promise.all(t.filter((e) => e !== "en").map(async (t) => {
|
|
284
|
-
let n = await
|
|
388
|
+
let n = await D(e, t);
|
|
285
389
|
/* v8 ignore next -- @preserve */
|
|
286
390
|
return n?.default ?? n;
|
|
287
391
|
}).filter(Boolean));
|
|
288
392
|
}
|
|
289
|
-
async function
|
|
393
|
+
async function D(e, t) {
|
|
290
394
|
try {
|
|
291
395
|
/* v8 ignore next if -- @preserve */
|
|
292
396
|
if (e === "ckeditor5") switch (t) {
|
|
@@ -446,15 +550,15 @@ catch (n) {
|
|
|
446
550
|
}
|
|
447
551
|
//#endregion
|
|
448
552
|
//#region src/hooks/editor/utils/normalize-custom-translations.ts
|
|
449
|
-
function
|
|
450
|
-
return
|
|
553
|
+
function O(e) {
|
|
554
|
+
return s(e, (e) => ({ dictionary: e }));
|
|
451
555
|
}
|
|
452
556
|
//#endregion
|
|
453
557
|
//#region src/hooks/editor/utils/query-editor-editables.ts
|
|
454
|
-
function
|
|
455
|
-
return
|
|
558
|
+
function k(e) {
|
|
559
|
+
return s(A(e), ({ element: e }) => e);
|
|
456
560
|
}
|
|
457
|
-
function
|
|
561
|
+
function A(e) {
|
|
458
562
|
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => ({
|
|
459
563
|
...e,
|
|
460
564
|
[t.rootName]: {
|
|
@@ -476,38 +580,38 @@ function C(e) {
|
|
|
476
580
|
}
|
|
477
581
|
} : t;
|
|
478
582
|
}
|
|
479
|
-
function
|
|
480
|
-
return
|
|
583
|
+
function j(e) {
|
|
584
|
+
return a(s(A(e), ({ content: e }) => e), (e) => typeof e == "string");
|
|
481
585
|
}
|
|
482
586
|
//#endregion
|
|
483
587
|
//#region src/hooks/editor/utils/resolve-editor-config-elements-references.ts
|
|
484
|
-
function
|
|
588
|
+
function M(e) {
|
|
485
589
|
if (!e || typeof e != "object") return e;
|
|
486
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
590
|
+
if (Array.isArray(e)) return e.map((e) => M(e));
|
|
487
591
|
let t = e;
|
|
488
592
|
if (t.$element && typeof t.$element == "string") {
|
|
489
593
|
let e = document.querySelector(t.$element);
|
|
490
594
|
return e || console.warn(`Element not found for selector: ${t.$element}`), e || null;
|
|
491
595
|
}
|
|
492
596
|
let n = Object.create(null);
|
|
493
|
-
for (let [t, r] of Object.entries(e)) n[t] =
|
|
597
|
+
for (let [t, r] of Object.entries(e)) n[t] = M(r);
|
|
494
598
|
return n;
|
|
495
599
|
}
|
|
496
600
|
//#endregion
|
|
497
601
|
//#region src/hooks/editor/utils/resolve-editor-config-translations.ts
|
|
498
|
-
function
|
|
602
|
+
function N(e, t, n) {
|
|
499
603
|
if (!n || typeof n != "object") return n;
|
|
500
|
-
if (Array.isArray(n)) return n.map((n) =>
|
|
604
|
+
if (Array.isArray(n)) return n.map((n) => N(e, t, n));
|
|
501
605
|
let r = n;
|
|
502
606
|
if (r.$translation && typeof r.$translation == "string") {
|
|
503
|
-
let n = r.$translation, i =
|
|
607
|
+
let n = r.$translation, i = P(e, n, t);
|
|
504
608
|
return i === void 0 && console.warn(`Translation not found for key: ${n}`), i === void 0 ? null : i;
|
|
505
609
|
}
|
|
506
610
|
let i = Object.create(null);
|
|
507
|
-
for (let [r, a] of Object.entries(n)) i[r] =
|
|
611
|
+
for (let [r, a] of Object.entries(n)) i[r] = N(e, t, a);
|
|
508
612
|
return i;
|
|
509
613
|
}
|
|
510
|
-
function
|
|
614
|
+
function P(e, t, n) {
|
|
511
615
|
for (let r of e) {
|
|
512
616
|
let e = r[n];
|
|
513
617
|
if (e?.dictionary && t in e.dictionary) return e.dictionary[t];
|
|
@@ -515,7 +619,7 @@ function D(e, t, n) {
|
|
|
515
619
|
}
|
|
516
620
|
//#endregion
|
|
517
621
|
//#region src/hooks/editor/utils/set-editor-editable-height.ts
|
|
518
|
-
function
|
|
622
|
+
function F(e, t) {
|
|
519
623
|
let { editing: n } = e;
|
|
520
624
|
n.view.change((e) => {
|
|
521
625
|
e.setStyle("height", `${t}px`, n.view.document.getRoot());
|
|
@@ -523,34 +627,34 @@ function O(e, t) {
|
|
|
523
627
|
}
|
|
524
628
|
//#endregion
|
|
525
629
|
//#region src/hooks/editor/utils/wrap-with-watchdog.ts
|
|
526
|
-
var
|
|
527
|
-
async function
|
|
528
|
-
let { EditorWatchdog:
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
};
|
|
630
|
+
var I = Symbol.for("livewire-editor-watchdog");
|
|
631
|
+
async function L(e, t) {
|
|
632
|
+
let { EditorWatchdog: n } = await import("ckeditor5"), r = new n(null, t ?? {
|
|
633
|
+
crashNumberLimit: 10,
|
|
634
|
+
minimumNonErrorTimePeriod: 5e3
|
|
635
|
+
});
|
|
636
|
+
return r.setCreator(async () => {
|
|
637
|
+
let t = await e();
|
|
638
|
+
return t[I] = r, t;
|
|
639
|
+
}), r;
|
|
536
640
|
}
|
|
537
|
-
function
|
|
538
|
-
return
|
|
641
|
+
function R(e) {
|
|
642
|
+
return I in e ? e[I] : null;
|
|
539
643
|
}
|
|
540
644
|
//#endregion
|
|
541
645
|
//#region src/hooks/context/contexts-registry.ts
|
|
542
|
-
var
|
|
646
|
+
var z = class e extends r {
|
|
543
647
|
static the = new e();
|
|
544
|
-
},
|
|
648
|
+
}, B = class extends e {
|
|
545
649
|
contextPromise = null;
|
|
546
650
|
async mounted() {
|
|
547
|
-
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins:
|
|
651
|
+
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: a, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await w(a ?? []), u = [...await T(t, l), O(r || {})].filter((e) => !o(e));
|
|
548
652
|
this.contextPromise = (async () => {
|
|
549
653
|
let { ContextWatchdog: e, Context: n } = await import("ckeditor5"), r = new e(n, {
|
|
550
654
|
crashNumberLimit: 10,
|
|
551
655
|
...i
|
|
552
|
-
}), a =
|
|
553
|
-
return a =
|
|
656
|
+
}), a = M(s);
|
|
657
|
+
return a = N([...u].reverse(), t.ui, a), await r.create({
|
|
554
658
|
...a,
|
|
555
659
|
language: t,
|
|
556
660
|
plugins: c,
|
|
@@ -561,7 +665,7 @@ var M = class e extends n {
|
|
|
561
665
|
})();
|
|
562
666
|
let d = await this.contextPromise;
|
|
563
667
|
/* v8 ignore next if -- @preserve */
|
|
564
|
-
this.isBeingDestroyed() ||
|
|
668
|
+
this.isBeingDestroyed() || z.the.register(e, d);
|
|
565
669
|
}
|
|
566
670
|
async destroyed() {
|
|
567
671
|
let { contextId: e } = this.canonical;
|
|
@@ -569,15 +673,15 @@ var M = class e extends n {
|
|
|
569
673
|
try {
|
|
570
674
|
await (await this.contextPromise)?.destroy();
|
|
571
675
|
} finally {
|
|
572
|
-
this.contextPromise = null,
|
|
676
|
+
this.contextPromise = null, z.the.hasItem(e) && z.the.unregister(e);
|
|
573
677
|
}
|
|
574
678
|
}
|
|
575
|
-
},
|
|
679
|
+
}, V = class e extends r {
|
|
576
680
|
static the = new e();
|
|
577
681
|
};
|
|
578
682
|
//#endregion
|
|
579
683
|
//#region src/hooks/utils/is-wire-model-connected.ts
|
|
580
|
-
function
|
|
684
|
+
function H(e) {
|
|
581
685
|
let t = e;
|
|
582
686
|
for (; t;) {
|
|
583
687
|
for (let e of t.attributes) if (e.name.startsWith("wire:model")) return !0;
|
|
@@ -587,7 +691,7 @@ function F(e) {
|
|
|
587
691
|
}
|
|
588
692
|
//#endregion
|
|
589
693
|
//#region src/hooks/utils/root-attributes-updater.ts
|
|
590
|
-
function
|
|
694
|
+
function U(e, t) {
|
|
591
695
|
let n = /* @__PURE__ */ new Set();
|
|
592
696
|
return (r) => {
|
|
593
697
|
e.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
@@ -601,57 +705,67 @@ function I(e, t) {
|
|
|
601
705
|
}
|
|
602
706
|
//#endregion
|
|
603
707
|
//#region src/hooks/editable.ts
|
|
604
|
-
var
|
|
605
|
-
editorPromise = null;
|
|
708
|
+
var W = class extends e {
|
|
606
709
|
rootAttributesUpdater = null;
|
|
607
710
|
pendingContent = null;
|
|
608
711
|
mounted() {
|
|
609
|
-
let { editorId: e, rootName: t, content: n } = this.canonical
|
|
610
|
-
this.editorPromise = P.the.execute(e, (e) => {
|
|
712
|
+
let { editorId: e, rootName: t, content: n } = this.canonical, r = V.the.mountEffect(e, (e) => {
|
|
611
713
|
/* v8 ignore next if -- @preserve */
|
|
612
|
-
if (this.isBeingDestroyed()) return
|
|
613
|
-
let
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
714
|
+
if (this.isBeingDestroyed()) return;
|
|
715
|
+
let r = e.model.document.getRoot(t);
|
|
716
|
+
if (r?.isAttached() && n !== null) {
|
|
717
|
+
let r = e.getData({ rootName: t });
|
|
718
|
+
r && r !== n && e.setData({ [t]: n });
|
|
719
|
+
}
|
|
720
|
+
/* v8 ignore next else -- @preserve */
|
|
721
|
+
if (!r && b(e)) {
|
|
722
|
+
let { ui: r, editing: i } = e;
|
|
620
723
|
e.addRoot(t, {
|
|
621
724
|
isUndoable: !1,
|
|
622
|
-
...n !== null && {
|
|
725
|
+
...n !== null && { initialData: n }
|
|
623
726
|
});
|
|
624
727
|
let a = this.element.querySelector("[data-cke-editable-content]"), o = r.view.createEditable(t, a);
|
|
625
728
|
r.addEditable(o), i.view.forceRender();
|
|
626
729
|
}
|
|
627
|
-
|
|
730
|
+
let i = this.syncTypingContentPush(e), a = this.setupPendingReceivedContentHandlers(e);
|
|
731
|
+
return this.applyRootAttributes(e), () => {
|
|
732
|
+
/* v8 ignore next else -- @preserve */
|
|
733
|
+
if (i(), a(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
|
|
734
|
+
let n = e.model.document.getRoot(t);
|
|
735
|
+
/* v8 ignore next if -- @preserve */
|
|
736
|
+
if (n && b(e)) {
|
|
737
|
+
try {
|
|
738
|
+
/* v8 ignore else -- @preserve */
|
|
739
|
+
e.ui.view.editables[t] && e.detachEditable(n);
|
|
740
|
+
} catch (e) {
|
|
741
|
+
/* v8 ignore next -- @preserve */
|
|
742
|
+
console.error("Unable unmount editable from root:", e);
|
|
743
|
+
}
|
|
744
|
+
n.isAttached() && e.detachRoot(t, !1);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
};
|
|
628
748
|
});
|
|
749
|
+
this.onBeforeDestroy(r);
|
|
629
750
|
}
|
|
630
751
|
async afterCommitSynced() {
|
|
631
|
-
let e = await
|
|
632
|
-
this.applyCanonicalContentToEditor(
|
|
752
|
+
let { editorId: e } = this.canonical, t = await V.the.waitFor(e);
|
|
753
|
+
this.applyCanonicalContentToEditor(t), this.applyRootAttributes(t);
|
|
633
754
|
}
|
|
634
|
-
|
|
635
|
-
let { rootName: e } = this.canonical;
|
|
755
|
+
destroyed() {
|
|
636
756
|
this.element.style.display = "none";
|
|
637
|
-
let t = await this.editorPromise;
|
|
638
|
-
if (this.editorPromise = null, this.rootAttributesUpdater?.(null), t && t.state !== "destroyed") {
|
|
639
|
-
let n = t.model.document.getRoot(e);
|
|
640
|
-
/* v8 ignore next if -- @preserve */
|
|
641
|
-
n && "detachEditable" in t && (t.detachEditable(n), t.detachRoot(e, !1));
|
|
642
|
-
}
|
|
643
757
|
}
|
|
644
758
|
syncTypingContentPush(e) {
|
|
645
|
-
let { rootName: t, saveDebounceMs: n } = this.canonical,
|
|
646
|
-
if (a) return;
|
|
759
|
+
let { rootName: t, saveDebounceMs: n } = this.canonical, r = this.element.querySelector("input"), a = !1, o = () => {
|
|
760
|
+
if (a || !e.model.document.getRoot(t)?.isAttached()) return;
|
|
647
761
|
let n = e.getData({ rootName: t });
|
|
648
|
-
|
|
649
|
-
}, s =
|
|
762
|
+
r && (r.value = n), this.$wire.set("content", n);
|
|
763
|
+
}, s = i(n, o), c = () => {
|
|
650
764
|
e.ui.focusTracker.isFocused ? s() : o();
|
|
651
765
|
};
|
|
652
|
-
e.model.document.on("change:data", c), o(),
|
|
766
|
+
return e.model.document.on("change:data", c), o(), () => {
|
|
653
767
|
a = !0, e.model.document.off("change:data", c);
|
|
654
|
-
}
|
|
768
|
+
};
|
|
655
769
|
}
|
|
656
770
|
setupPendingReceivedContentHandlers(e) {
|
|
657
771
|
let { ui: t, model: n } = e, { focusTracker: r } = t, { rootName: i } = this.canonical, a = () => {
|
|
@@ -659,12 +773,12 @@ var L = class extends e {
|
|
|
659
773
|
}, o = () => {
|
|
660
774
|
!r.isFocused && this.pendingContent !== null && (e.setData({ [i]: this.pendingContent }), this.pendingContent = null);
|
|
661
775
|
};
|
|
662
|
-
n.document.on("change:data", a), r.on("change:isFocused", o),
|
|
776
|
+
return n.document.on("change:data", a), r.on("change:isFocused", o), () => {
|
|
663
777
|
n.document.off("change:data", a), r.off("change:isFocused", o);
|
|
664
|
-
}
|
|
778
|
+
};
|
|
665
779
|
}
|
|
666
780
|
applyCanonicalContentToEditor(e) {
|
|
667
|
-
if (!
|
|
781
|
+
if (!H(this.element)) return;
|
|
668
782
|
let { content: t, rootName: n } = this.canonical, { ui: r } = e;
|
|
669
783
|
if (e.getData({ rootName: n }) !== (t ?? "")) {
|
|
670
784
|
if (r.focusTracker.isFocused) {
|
|
@@ -676,12 +790,12 @@ var L = class extends e {
|
|
|
676
790
|
}
|
|
677
791
|
applyRootAttributes(e) {
|
|
678
792
|
let { rootName: t, rootAttributes: n } = this.canonical;
|
|
679
|
-
this.rootAttributesUpdater ??=
|
|
793
|
+
this.rootAttributesUpdater ??= U(e, t), this.rootAttributesUpdater(n);
|
|
680
794
|
}
|
|
681
795
|
};
|
|
682
796
|
//#endregion
|
|
683
797
|
//#region src/hooks/editor/plugins/livewire-sync.ts
|
|
684
|
-
async function
|
|
798
|
+
async function G({ saveDebounceMs: e, component: t }) {
|
|
685
799
|
let { Plugin: n } = await import("ckeditor5");
|
|
686
800
|
return class extends n {
|
|
687
801
|
static get pluginName() {
|
|
@@ -693,15 +807,15 @@ async function R({ saveDebounceMs: e, component: t }) {
|
|
|
693
807
|
setupAfterCommitHandler() {
|
|
694
808
|
let { editor: e } = this, { model: n, ui: { focusTracker: r } } = e, i = null;
|
|
695
809
|
e.on("afterCommitSynced", () => {
|
|
696
|
-
if (!
|
|
810
|
+
if (!H(t.element)) return;
|
|
697
811
|
let { content: n } = t.canonical, a = this.getEditorRootsValues();
|
|
698
812
|
if (r.isFocused) {
|
|
699
813
|
/* v8 ignore next else -- @preserve */
|
|
700
|
-
|
|
814
|
+
c(n, a) || (i = n);
|
|
701
815
|
return;
|
|
702
816
|
}
|
|
703
817
|
/* v8 ignore next else -- @preserve */
|
|
704
|
-
|
|
818
|
+
c(n, a) || e.setData(n);
|
|
705
819
|
}), n.document.on("change:data", () => {
|
|
706
820
|
i = null;
|
|
707
821
|
}), r.on("change:isFocused", () => {
|
|
@@ -715,41 +829,43 @@ async function R({ saveDebounceMs: e, component: t }) {
|
|
|
715
829
|
});
|
|
716
830
|
}
|
|
717
831
|
setupSetEditorContentHandler() {
|
|
718
|
-
Livewire.on("set-editor-content", ({ editorId:
|
|
719
|
-
|
|
832
|
+
let { editor: e } = this, n = Livewire.on("set-editor-content", ({ editorId: n, content: r }) => {
|
|
833
|
+
n === t.canonical.editorId && (c(this.getEditorRootsValues(), r) || e.setData(r));
|
|
720
834
|
});
|
|
835
|
+
/* v8 ignore next if -- @preserve */
|
|
836
|
+
typeof n == "function" && e.once("destroy", n);
|
|
721
837
|
}
|
|
722
838
|
setupTypingContentPush() {
|
|
723
|
-
let { editor: n } = this, { model:
|
|
839
|
+
let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t, s = !1, l = () => {
|
|
724
840
|
/* v8 ignore next if -- @preserve */
|
|
725
|
-
if (
|
|
841
|
+
if (s) return;
|
|
726
842
|
let e = this.getEditorRootsValues();
|
|
727
|
-
|
|
843
|
+
c(e, t.canonical.content ?? {}) || (o.set("content", e), o.dispatch("editor-content-changed", {
|
|
728
844
|
editorId: t.canonical.editorId,
|
|
729
845
|
content: e
|
|
730
846
|
}));
|
|
731
|
-
}, u =
|
|
847
|
+
}, u = i(e, l);
|
|
848
|
+
r.document.on("change:data", i(10, () => {
|
|
732
849
|
a.focusTracker.isFocused ? u() : l();
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
c = !0, i.document.off("change:data", d);
|
|
850
|
+
})), n.once("ready", l), n.once("destroy", () => {
|
|
851
|
+
s = !0;
|
|
736
852
|
});
|
|
737
853
|
}
|
|
738
854
|
setupFocusableEventPush() {
|
|
739
855
|
let { ui: e } = this.editor, { $wire: n } = t;
|
|
740
856
|
e.focusTracker.on("change:isFocused", () => {
|
|
741
857
|
let r = this.getEditorRootsValues();
|
|
742
|
-
n.set("focused", e.focusTracker.isFocused),
|
|
858
|
+
n.set("focused", e.focusTracker.isFocused), c(r, t.canonical.content ?? {}) || n.set("content", r);
|
|
743
859
|
});
|
|
744
860
|
}
|
|
745
861
|
getEditorRootsValues() {
|
|
746
|
-
return
|
|
862
|
+
return y(this.editor);
|
|
747
863
|
}
|
|
748
864
|
};
|
|
749
865
|
}
|
|
750
866
|
//#endregion
|
|
751
867
|
//#region src/hooks/editor/plugins/sync-editor-with-input.ts
|
|
752
|
-
async function
|
|
868
|
+
async function K(e) {
|
|
753
869
|
let { Plugin: t } = await import("ckeditor5");
|
|
754
870
|
return class extends t {
|
|
755
871
|
input = null;
|
|
@@ -759,7 +875,7 @@ async function z(e) {
|
|
|
759
875
|
}
|
|
760
876
|
afterInit() {
|
|
761
877
|
let { editor: t } = this, n = t.sourceElement.id.replace(/_editor$/, "");
|
|
762
|
-
this.input = document.getElementById(`${n}_input`), this.input && (t.model.document.on("change:data",
|
|
878
|
+
this.input = document.getElementById(`${n}_input`), this.input && (t.model.document.on("change:data", i(e, () => this.sync())), t.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
763
879
|
}
|
|
764
880
|
sync = () => {
|
|
765
881
|
/* v8 ignore next else -- @preserve */
|
|
@@ -775,100 +891,100 @@ async function z(e) {
|
|
|
775
891
|
}
|
|
776
892
|
//#endregion
|
|
777
893
|
//#region src/hooks/editor/editor.ts
|
|
778
|
-
var
|
|
779
|
-
editorPromise = null;
|
|
894
|
+
var q = class extends e {
|
|
780
895
|
rootAttributesUpdater = null;
|
|
781
896
|
async mounted() {
|
|
782
897
|
let { editorId: e } = this.canonical;
|
|
783
|
-
|
|
898
|
+
V.the.resetErrors(e);
|
|
784
899
|
try {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
900
|
+
let t = await this.createEditor(), n = v(t), r = R(t);
|
|
901
|
+
/* v8 ignore next 3 */
|
|
902
|
+
if (this.isBeingDestroyed()) return;
|
|
903
|
+
let i = V.the.mountEffect(e, (t) => {
|
|
904
|
+
t.once("destroy", () => {
|
|
905
|
+
V.the.unregister(e, !1);
|
|
906
|
+
}, { priority: "highest" });
|
|
907
|
+
});
|
|
908
|
+
this.onBeforeDestroy(async () => {
|
|
909
|
+
V.the.unregister(e), i(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : r ? await r.destroy() : await t.destroy();
|
|
910
|
+
}), V.the.register(e, t);
|
|
792
911
|
} catch (t) {
|
|
793
|
-
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t),
|
|
912
|
+
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t), V.the.error(e, t);
|
|
794
913
|
}
|
|
795
914
|
}
|
|
796
915
|
async destroyed() {
|
|
797
916
|
this.element.style.display = "none";
|
|
798
|
-
try {
|
|
799
|
-
let e = await this.editorPromise;
|
|
800
|
-
if (!e) return;
|
|
801
|
-
let t = f(e), n = j(e);
|
|
802
|
-
t ? t.state !== "unavailable" && await t.context.remove(t.editorContextId) : n ? await n.destroy() : await e.destroy();
|
|
803
|
-
} finally {
|
|
804
|
-
this.editorPromise = null;
|
|
805
|
-
}
|
|
806
917
|
}
|
|
807
918
|
async afterCommitSynced() {
|
|
808
|
-
let e = await this.
|
|
919
|
+
let e = await V.the.waitFor(this.canonical.editorId);
|
|
809
920
|
/* v8 ignore if -- @preserve */
|
|
810
921
|
e && (e.fire("afterCommitSynced"), this.applyRootAttributes(e));
|
|
811
922
|
}
|
|
812
923
|
applyRootAttributes(e) {
|
|
813
924
|
let { rootAttributes: t } = this.canonical;
|
|
814
|
-
this.rootAttributesUpdater ??=
|
|
925
|
+
this.rootAttributesUpdater ??= U(e, "main"), this.rootAttributesUpdater(t);
|
|
815
926
|
}
|
|
816
927
|
async createEditor() {
|
|
817
|
-
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language:
|
|
928
|
+
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language: a, watchdog: s, content: c } = this.canonical, { customTranslations: l, editorType: u, licenseKey: f, watchdogConfig: m, config: { plugins: g, ...v } } = e, y = await S(u), b = await (n ? z.the.waitFor(n) : null), C = async () => {
|
|
929
|
+
let { loadedPlugins: e, hasPremium: n } = await w(g);
|
|
930
|
+
e.push(await G({
|
|
931
|
+
saveDebounceMs: i,
|
|
932
|
+
component: this
|
|
933
|
+
})), x(u) && e.push(await K(i));
|
|
934
|
+
let s = [...await T(a, n), O(l || {})].filter((e) => !o(e)), m = {
|
|
935
|
+
...c,
|
|
936
|
+
...j(t)
|
|
937
|
+
};
|
|
938
|
+
x(u) && (m = m.main || "");
|
|
939
|
+
let h = await (async () => {
|
|
940
|
+
let n = k(t);
|
|
941
|
+
if (!(n instanceof HTMLElement) && !("main" in n)) {
|
|
942
|
+
let e = u === "decoupled" ? ["main"] : Object.keys(m);
|
|
943
|
+
J(n, e) || (n = await Y(t, e), m = {
|
|
944
|
+
...c,
|
|
945
|
+
...j(t)
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
x(u) && "main" in n && (n = n.main);
|
|
949
|
+
let r = { ...v };
|
|
950
|
+
r = M(r), r = N([...s].reverse(), a.ui, r), r = p(y, n, r), r = d(m, r);
|
|
951
|
+
let i = {
|
|
952
|
+
...r,
|
|
953
|
+
licenseKey: f,
|
|
954
|
+
plugins: e,
|
|
955
|
+
language: a,
|
|
956
|
+
...s.length && { translations: s }
|
|
957
|
+
};
|
|
958
|
+
return !b || !(n instanceof HTMLElement) ? y.create(i) : (await _({
|
|
959
|
+
context: b,
|
|
960
|
+
creator: y,
|
|
961
|
+
config: i
|
|
962
|
+
})).editor;
|
|
963
|
+
})();
|
|
964
|
+
return x(u) && r && F(h, r), this.applyRootAttributes(h), h;
|
|
965
|
+
};
|
|
818
966
|
if (s && !b) {
|
|
819
|
-
let e = await
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
967
|
+
let e = await L(C, m);
|
|
968
|
+
return e.on("error", (e, { causesRestart: n }) => {
|
|
969
|
+
if (n) {
|
|
970
|
+
let e = V.the.getItem(t);
|
|
971
|
+
/* v8 ignore next 3 */
|
|
972
|
+
e && (h(e), V.the.unregister(t));
|
|
973
|
+
}
|
|
974
|
+
}), e.on("restart", () => {
|
|
975
|
+
V.the.register(t, e.editor);
|
|
976
|
+
}), await e.create({}), e.editor;
|
|
824
977
|
}
|
|
825
|
-
|
|
826
|
-
C.push(await R({
|
|
827
|
-
saveDebounceMs: i,
|
|
828
|
-
component: this
|
|
829
|
-
})), m(u) && C.push(await z(i));
|
|
830
|
-
let k = [...await v(o, D), x(l || {})].filter((e) => !a(e)), j = {
|
|
831
|
-
...c,
|
|
832
|
-
...w(t)
|
|
833
|
-
};
|
|
834
|
-
m(u) && (j = j.main || "");
|
|
835
|
-
let N = await (async () => {
|
|
836
|
-
let e = S(t);
|
|
837
|
-
if (!(e instanceof HTMLElement) && !("main" in e)) {
|
|
838
|
-
let n = u === "decoupled" ? ["main"] : Object.keys(j);
|
|
839
|
-
V(e, n) || (e = await H(t, n), j = {
|
|
840
|
-
...c,
|
|
841
|
-
...w(t)
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
m(u) && "main" in e && (e = e.main);
|
|
845
|
-
let n = T(g);
|
|
846
|
-
n = E([...k].reverse(), o.ui, n);
|
|
847
|
-
let r = {
|
|
848
|
-
...n,
|
|
849
|
-
initialData: j,
|
|
850
|
-
licenseKey: f,
|
|
851
|
-
plugins: C,
|
|
852
|
-
language: o,
|
|
853
|
-
...k.length && { translations: k }
|
|
854
|
-
};
|
|
855
|
-
return !b || !(e instanceof HTMLElement) ? y.create(e, r) : (await d({
|
|
856
|
-
context: b,
|
|
857
|
-
element: e,
|
|
858
|
-
creator: y,
|
|
859
|
-
config: r
|
|
860
|
-
})).editor;
|
|
861
|
-
})();
|
|
862
|
-
return m(u) && r && O(N, r), this.applyRootAttributes(N), N;
|
|
978
|
+
return C();
|
|
863
979
|
}
|
|
864
980
|
};
|
|
865
|
-
function
|
|
981
|
+
function J(e, t) {
|
|
866
982
|
return t.every((t) => e[t]);
|
|
867
983
|
}
|
|
868
|
-
async function
|
|
869
|
-
return
|
|
870
|
-
let n =
|
|
871
|
-
if (!
|
|
984
|
+
async function Y(e, t) {
|
|
985
|
+
return u(() => {
|
|
986
|
+
let n = k(e);
|
|
987
|
+
if (!J(n, t)) throw Error(`It looks like not all required root elements are present yet.
|
|
872
988
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
873
989
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
874
990
|
Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
@@ -880,26 +996,27 @@ Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
|
880
996
|
}
|
|
881
997
|
//#endregion
|
|
882
998
|
//#region src/hooks/ui-part.ts
|
|
883
|
-
var
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
let { editorId: e, name: t } = this.canonical;
|
|
887
|
-
this.mountedPromise = P.the.execute(e, (e) => {
|
|
999
|
+
var X = class extends e {
|
|
1000
|
+
mounted() {
|
|
1001
|
+
let { editorId: e, name: t } = this.canonical, n = V.the.mountEffect(e, (e) => {
|
|
888
1002
|
/* v8 ignore next if -- @preserve */
|
|
889
1003
|
if (this.isBeingDestroyed()) return;
|
|
890
|
-
let { ui: n } = e, r =
|
|
1004
|
+
let { ui: n } = e, r = Z(t), i = n.view[r];
|
|
891
1005
|
if (!i) {
|
|
892
1006
|
console.error(`Unknown UI part name: "${t}". Supported names are "toolbar" and "menubar".`);
|
|
893
1007
|
return;
|
|
894
1008
|
}
|
|
895
|
-
this.element.appendChild(i.element)
|
|
1009
|
+
return this.element.appendChild(i.element), () => {
|
|
1010
|
+
this.element.innerHTML = "";
|
|
1011
|
+
};
|
|
896
1012
|
});
|
|
1013
|
+
this.onBeforeDestroy(n);
|
|
897
1014
|
}
|
|
898
|
-
|
|
899
|
-
this.element.style.display = "none"
|
|
1015
|
+
destroyed() {
|
|
1016
|
+
this.element.style.display = "none";
|
|
900
1017
|
}
|
|
901
1018
|
};
|
|
902
|
-
function
|
|
1019
|
+
function Z(e) {
|
|
903
1020
|
switch (e) {
|
|
904
1021
|
case "toolbar": return "toolbar";
|
|
905
1022
|
case "menubar": return "menuBarView";
|
|
@@ -908,19 +1025,19 @@ function W(e) {
|
|
|
908
1025
|
}
|
|
909
1026
|
//#endregion
|
|
910
1027
|
//#region src/hooks/index.ts
|
|
911
|
-
var
|
|
912
|
-
ckeditor5:
|
|
913
|
-
"ckeditor5-context":
|
|
914
|
-
"ckeditor5-ui-part":
|
|
915
|
-
"ckeditor5-editable":
|
|
1028
|
+
var Q = {
|
|
1029
|
+
ckeditor5: q,
|
|
1030
|
+
"ckeditor5-context": B,
|
|
1031
|
+
"ckeditor5-ui-part": X,
|
|
1032
|
+
"ckeditor5-editable": W
|
|
916
1033
|
};
|
|
917
|
-
function
|
|
918
|
-
for (let [e, n] of Object.entries(
|
|
1034
|
+
function $() {
|
|
1035
|
+
for (let [e, n] of Object.entries(Q)) t(e, n);
|
|
919
1036
|
}
|
|
920
1037
|
//#endregion
|
|
921
1038
|
//#region src/index.ts
|
|
922
|
-
|
|
1039
|
+
$();
|
|
923
1040
|
//#endregion
|
|
924
|
-
export { e as ClassHook,
|
|
1041
|
+
export { e as ClassHook, z as ContextsRegistry, C as CustomEditorPluginsRegistry, W as EditableComponentHook, q as EditorComponentHook, V as EditorsRegistry, X as UIPartComponentHook, t as registerLivewireComponentHook };
|
|
925
1042
|
|
|
926
1043
|
//# sourceMappingURL=index.mjs.map
|