ckeditor5-livewire 1.12.1 → 1.13.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 +4 -0
- package/dist/hooks/editable.d.ts.map +1 -1
- package/dist/hooks/editor/editor.d.ts +4 -0
- package/dist/hooks/editor/editor.d.ts.map +1 -1
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts +17 -0
- package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
- package/dist/hooks/editor/utils/index.d.ts +2 -3
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +24 -0
- package/dist/hooks/editor/utils/query-all-editor-editables.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +175 -214
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/editable.test.ts +34 -0
- package/src/hooks/editable.ts +7 -1
- package/src/hooks/editor/editor.test.ts +165 -1
- package/src/hooks/editor/editor.ts +45 -64
- package/src/hooks/editor/utils/assign-editor-roots-to-config.ts +61 -0
- package/src/hooks/editor/utils/get-editor-roots-values.ts +1 -1
- package/src/hooks/editor/utils/index.ts +2 -3
- package/src/hooks/editor/utils/query-all-editor-editables.ts +87 -0
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +0 -10
- package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +0 -1
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +0 -12
- package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +0 -1
- package/dist/hooks/editor/utils/query-editor-editables.d.ts +0 -32
- package/dist/hooks/editor/utils/query-editor-editables.d.ts.map +0 -1
- package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +0 -48
- package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +0 -61
- package/src/hooks/editor/utils/query-editor-editables.ts +0 -93
package/dist/index.mjs
CHANGED
|
@@ -162,25 +162,19 @@ function i(e, t) {
|
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
//#endregion
|
|
165
|
-
//#region src/shared/filter-object-values.ts
|
|
166
|
-
function a(e, t) {
|
|
167
|
-
let n = Object.entries(e).filter(([e, n]) => t(n, e));
|
|
168
|
-
return Object.fromEntries(n);
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
165
|
//#region src/shared/is-empty-object.ts
|
|
172
|
-
function
|
|
166
|
+
function a(e) {
|
|
173
167
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
174
168
|
}
|
|
175
169
|
//#endregion
|
|
176
170
|
//#region src/shared/map-object-values.ts
|
|
177
|
-
function
|
|
171
|
+
function o(e, t) {
|
|
178
172
|
let n = Object.entries(e).map(([e, n]) => [e, t(n, e)]);
|
|
179
173
|
return Object.fromEntries(n);
|
|
180
174
|
}
|
|
181
175
|
//#endregion
|
|
182
176
|
//#region src/shared/shallow-equal.ts
|
|
183
|
-
function
|
|
177
|
+
function s(e, t) {
|
|
184
178
|
if (e === t) return !0;
|
|
185
179
|
let n = Object.keys(e), r = Object.keys(t);
|
|
186
180
|
if (n.length !== r.length) return !1;
|
|
@@ -189,12 +183,12 @@ function c(e, t) {
|
|
|
189
183
|
}
|
|
190
184
|
//#endregion
|
|
191
185
|
//#region src/shared/uid.ts
|
|
192
|
-
function
|
|
186
|
+
function c() {
|
|
193
187
|
return Math.random().toString(36).substring(2);
|
|
194
188
|
}
|
|
195
189
|
//#endregion
|
|
196
190
|
//#region src/shared/wait-for.ts
|
|
197
|
-
function
|
|
191
|
+
function l(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
198
192
|
return new Promise((r, i) => {
|
|
199
193
|
let a = Date.now(), o = null, s = setTimeout(() => {
|
|
200
194
|
i(o ?? /* @__PURE__ */ Error("Timeout"));
|
|
@@ -210,51 +204,29 @@ function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
|
210
204
|
});
|
|
211
205
|
}
|
|
212
206
|
//#endregion
|
|
213
|
-
//#region src/hooks/editor/utils/assign-
|
|
214
|
-
function
|
|
215
|
-
let
|
|
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) => ({
|
|
207
|
+
//#region src/hooks/editor/utils/assign-editor-roots-to-config.ts
|
|
208
|
+
function u(e, t, n) {
|
|
209
|
+
let r = !e.editorName || e.editorName === "ClassicEditor", i = new Set([...Object.keys(t), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, i) => ({
|
|
240
210
|
...e,
|
|
241
|
-
[
|
|
242
|
-
...n.roots?.[
|
|
243
|
-
...
|
|
244
|
-
...
|
|
211
|
+
[i]: {
|
|
212
|
+
...n.roots?.[i],
|
|
213
|
+
...i === "main" ? n.root : {},
|
|
214
|
+
...i in t ? {
|
|
215
|
+
modelElement: t[i].modelElement || "$root",
|
|
216
|
+
...t[i].content !== null && { initialData: t[i].content },
|
|
217
|
+
...!r && t[i].element !== null && { element: t[i].element }
|
|
218
|
+
} : {}
|
|
245
219
|
}
|
|
246
220
|
}), Object.create(n.roots || {})), o = {
|
|
247
221
|
...n,
|
|
248
|
-
roots: a
|
|
222
|
+
roots: a,
|
|
223
|
+
...r && t.main?.element && { attachTo: t.main.element }
|
|
249
224
|
};
|
|
250
225
|
return delete o.root, o;
|
|
251
226
|
}
|
|
252
|
-
function m(e) {
|
|
253
|
-
return e instanceof HTMLElement ? { main: e } : { ...e };
|
|
254
|
-
}
|
|
255
227
|
//#endregion
|
|
256
228
|
//#region src/hooks/editor/utils/cleanup-orphan-editor-elements.ts
|
|
257
|
-
function
|
|
229
|
+
function d(e) {
|
|
258
230
|
let t = [
|
|
259
231
|
e.ui?.element,
|
|
260
232
|
e.ui?.view?.toolbar?.element,
|
|
@@ -271,9 +243,9 @@ function h(e) {
|
|
|
271
243
|
}
|
|
272
244
|
//#endregion
|
|
273
245
|
//#region src/hooks/editor/utils/create-editor-in-context.ts
|
|
274
|
-
var
|
|
275
|
-
async function
|
|
276
|
-
let r =
|
|
246
|
+
var f = Symbol.for("context-editor-watchdog");
|
|
247
|
+
async function p({ context: e, creator: t, config: n }) {
|
|
248
|
+
let r = c();
|
|
277
249
|
await e.add({
|
|
278
250
|
creator: t.create.bind(t),
|
|
279
251
|
id: r,
|
|
@@ -285,29 +257,29 @@ async function _({ context: e, creator: t, config: n }) {
|
|
|
285
257
|
editorContextId: r,
|
|
286
258
|
context: e
|
|
287
259
|
};
|
|
288
|
-
i[
|
|
260
|
+
i[f] = a;
|
|
289
261
|
let o = e.destroy.bind(e);
|
|
290
262
|
return e.destroy = async () => (a.state = "unavailable", o()), {
|
|
291
263
|
...a,
|
|
292
264
|
editor: i
|
|
293
265
|
};
|
|
294
266
|
}
|
|
295
|
-
function
|
|
296
|
-
return
|
|
267
|
+
function m(e) {
|
|
268
|
+
return f in e ? e[f] : null;
|
|
297
269
|
}
|
|
298
270
|
//#endregion
|
|
299
271
|
//#region src/hooks/editor/utils/get-editor-roots-values.ts
|
|
300
|
-
function
|
|
301
|
-
return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create(
|
|
272
|
+
function h(e) {
|
|
273
|
+
return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create(null));
|
|
302
274
|
}
|
|
303
275
|
//#endregion
|
|
304
276
|
//#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
|
|
305
|
-
function
|
|
277
|
+
function g(e) {
|
|
306
278
|
return "addEditable" in e.ui;
|
|
307
279
|
}
|
|
308
280
|
//#endregion
|
|
309
281
|
//#region src/hooks/editor/utils/is-single-root-editor.ts
|
|
310
|
-
function
|
|
282
|
+
function _(e) {
|
|
311
283
|
return [
|
|
312
284
|
"inline",
|
|
313
285
|
"classic",
|
|
@@ -317,7 +289,7 @@ function x(e) {
|
|
|
317
289
|
}
|
|
318
290
|
//#endregion
|
|
319
291
|
//#region src/hooks/editor/utils/load-editor-constructor.ts
|
|
320
|
-
async function
|
|
292
|
+
async function v(e) {
|
|
321
293
|
let t = await import("ckeditor5"), n = {
|
|
322
294
|
inline: t.InlineEditor,
|
|
323
295
|
balloon: t.BalloonEditor,
|
|
@@ -330,7 +302,7 @@ async function S(e) {
|
|
|
330
302
|
}
|
|
331
303
|
//#endregion
|
|
332
304
|
//#region src/hooks/editor/custom-editor-plugins.ts
|
|
333
|
-
var
|
|
305
|
+
var y = class e {
|
|
334
306
|
static the = new e();
|
|
335
307
|
plugins = /* @__PURE__ */ new Map();
|
|
336
308
|
constructor() {}
|
|
@@ -354,9 +326,9 @@ var C = class e {
|
|
|
354
326
|
};
|
|
355
327
|
//#endregion
|
|
356
328
|
//#region src/hooks/editor/utils/load-editor-plugins.ts
|
|
357
|
-
async function
|
|
329
|
+
async function b(e) {
|
|
358
330
|
let t = await import("ckeditor5"), n = null, r = e.map(async (e) => {
|
|
359
|
-
let r = await
|
|
331
|
+
let r = await y.the.get(e);
|
|
360
332
|
if (r) return r;
|
|
361
333
|
let { [e]: i } = t;
|
|
362
334
|
if (i) return i;
|
|
@@ -378,19 +350,19 @@ async function w(e) {
|
|
|
378
350
|
}
|
|
379
351
|
//#endregion
|
|
380
352
|
//#region src/hooks/editor/utils/load-editor-translations.ts
|
|
381
|
-
async function
|
|
382
|
-
let n = [e.ui, e.content], r = [
|
|
383
|
-
return t && r.push(
|
|
353
|
+
async function x(e, t) {
|
|
354
|
+
let n = [e.ui, e.content], r = [S("ckeditor5", n)];
|
|
355
|
+
return t && r.push(S("ckeditor5-premium-features", n)), await Promise.all(r).then((e) => e.flat());
|
|
384
356
|
}
|
|
385
|
-
async function
|
|
357
|
+
async function S(e, t) {
|
|
386
358
|
/* v8 ignore next */
|
|
387
359
|
return await Promise.all(t.filter((e) => e !== "en").map(async (t) => {
|
|
388
|
-
let n = await
|
|
360
|
+
let n = await C(e, t);
|
|
389
361
|
/* v8 ignore next -- @preserve */
|
|
390
362
|
return n?.default ?? n;
|
|
391
363
|
}).filter(Boolean));
|
|
392
364
|
}
|
|
393
|
-
async function
|
|
365
|
+
async function C(e, t) {
|
|
394
366
|
try {
|
|
395
367
|
/* v8 ignore next if -- @preserve */
|
|
396
368
|
if (e === "ckeditor5") switch (t) {
|
|
@@ -550,68 +522,69 @@ catch (n) {
|
|
|
550
522
|
}
|
|
551
523
|
//#endregion
|
|
552
524
|
//#region src/hooks/editor/utils/normalize-custom-translations.ts
|
|
553
|
-
function
|
|
554
|
-
return
|
|
525
|
+
function w(e) {
|
|
526
|
+
return o(e, (e) => ({ dictionary: e }));
|
|
555
527
|
}
|
|
556
528
|
//#endregion
|
|
557
|
-
//#region src/hooks/editor/utils/query-editor-editables.ts
|
|
558
|
-
function
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => ({
|
|
563
|
-
...e,
|
|
564
|
-
[t.rootName]: {
|
|
529
|
+
//#region src/hooks/editor/utils/query-all-editor-editables.ts
|
|
530
|
+
function T(e) {
|
|
531
|
+
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => {
|
|
532
|
+
let r = t.rootName, i = t.modelElement || null;
|
|
533
|
+
return e[r] = {
|
|
565
534
|
element: n.querySelector("[data-cke-editable-content]"),
|
|
566
|
-
content: t.content
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
535
|
+
content: t.content,
|
|
536
|
+
modelElement: i
|
|
537
|
+
}, e;
|
|
538
|
+
}, Object.create(null)), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e);
|
|
539
|
+
/* v8 ignore next -- @preserve */
|
|
540
|
+
if (!n) return t;
|
|
541
|
+
// v8 ignore next -- @preserve
|
|
542
|
+
let r = n.canonical.content ?? {}, i = n.canonical.modelElement || null, a = document.querySelector(`#${e}_editor`);
|
|
543
|
+
"main" in t ? t.main.modelElement ??= i : a && (t.main = {
|
|
544
|
+
element: a,
|
|
545
|
+
content: r.main ?? "",
|
|
546
|
+
modelElement: i
|
|
547
|
+
});
|
|
548
|
+
for (let [e, n] of Object.entries(r)) t[e] ? t[e] = {
|
|
549
|
+
...t[e],
|
|
550
|
+
content: t[e].content ?? n,
|
|
551
|
+
modelElement: t[e].modelElement ?? i
|
|
552
|
+
} : t[e] = {
|
|
553
|
+
element: null,
|
|
554
|
+
content: n,
|
|
555
|
+
modelElement: i
|
|
556
|
+
};
|
|
557
|
+
return t;
|
|
585
558
|
}
|
|
586
559
|
//#endregion
|
|
587
560
|
//#region src/hooks/editor/utils/resolve-editor-config-elements-references.ts
|
|
588
|
-
function
|
|
561
|
+
function E(e) {
|
|
589
562
|
if (!e || typeof e != "object") return e;
|
|
590
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
563
|
+
if (Array.isArray(e)) return e.map((e) => E(e));
|
|
591
564
|
let t = e;
|
|
592
565
|
if (t.$element && typeof t.$element == "string") {
|
|
593
566
|
let e = document.querySelector(t.$element);
|
|
594
567
|
return e || console.warn(`Element not found for selector: ${t.$element}`), e || null;
|
|
595
568
|
}
|
|
596
569
|
let n = Object.create(null);
|
|
597
|
-
for (let [t, r] of Object.entries(e)) n[t] =
|
|
570
|
+
for (let [t, r] of Object.entries(e)) n[t] = E(r);
|
|
598
571
|
return n;
|
|
599
572
|
}
|
|
600
573
|
//#endregion
|
|
601
574
|
//#region src/hooks/editor/utils/resolve-editor-config-translations.ts
|
|
602
|
-
function
|
|
575
|
+
function D(e, t, n) {
|
|
603
576
|
if (!n || typeof n != "object") return n;
|
|
604
|
-
if (Array.isArray(n)) return n.map((n) =>
|
|
577
|
+
if (Array.isArray(n)) return n.map((n) => D(e, t, n));
|
|
605
578
|
let r = n;
|
|
606
579
|
if (r.$translation && typeof r.$translation == "string") {
|
|
607
|
-
let n = r.$translation, i =
|
|
580
|
+
let n = r.$translation, i = O(e, n, t);
|
|
608
581
|
return i === void 0 && console.warn(`Translation not found for key: ${n}`), i === void 0 ? null : i;
|
|
609
582
|
}
|
|
610
583
|
let i = Object.create(null);
|
|
611
|
-
for (let [r, a] of Object.entries(n)) i[r] =
|
|
584
|
+
for (let [r, a] of Object.entries(n)) i[r] = D(e, t, a);
|
|
612
585
|
return i;
|
|
613
586
|
}
|
|
614
|
-
function
|
|
587
|
+
function O(e, t, n) {
|
|
615
588
|
for (let r of e) {
|
|
616
589
|
let e = r[n];
|
|
617
590
|
if (e?.dictionary && t in e.dictionary) return e.dictionary[t];
|
|
@@ -619,7 +592,7 @@ function P(e, t, n) {
|
|
|
619
592
|
}
|
|
620
593
|
//#endregion
|
|
621
594
|
//#region src/hooks/editor/utils/set-editor-editable-height.ts
|
|
622
|
-
function
|
|
595
|
+
function k(e, t) {
|
|
623
596
|
let { editing: n } = e;
|
|
624
597
|
n.view.change((e) => {
|
|
625
598
|
e.setStyle("height", `${t}px`, n.view.document.getRoot());
|
|
@@ -627,34 +600,34 @@ function F(e, t) {
|
|
|
627
600
|
}
|
|
628
601
|
//#endregion
|
|
629
602
|
//#region src/hooks/editor/utils/wrap-with-watchdog.ts
|
|
630
|
-
var
|
|
631
|
-
async function
|
|
603
|
+
var A = Symbol.for("livewire-editor-watchdog");
|
|
604
|
+
async function j(e, t) {
|
|
632
605
|
let { EditorWatchdog: n } = await import("ckeditor5"), r = new n(null, t ?? {
|
|
633
606
|
crashNumberLimit: 10,
|
|
634
607
|
minimumNonErrorTimePeriod: 5e3
|
|
635
608
|
});
|
|
636
609
|
return r.setCreator(async () => {
|
|
637
610
|
let t = await e();
|
|
638
|
-
return t[
|
|
611
|
+
return t[A] = r, t;
|
|
639
612
|
}), r;
|
|
640
613
|
}
|
|
641
|
-
function
|
|
642
|
-
return
|
|
614
|
+
function M(e) {
|
|
615
|
+
return A in e ? e[A] : null;
|
|
643
616
|
}
|
|
644
617
|
//#endregion
|
|
645
618
|
//#region src/hooks/context/contexts-registry.ts
|
|
646
|
-
var
|
|
619
|
+
var N = class e extends r {
|
|
647
620
|
static the = new e();
|
|
648
|
-
},
|
|
621
|
+
}, P = class extends e {
|
|
649
622
|
contextPromise = null;
|
|
650
623
|
async mounted() {
|
|
651
|
-
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins:
|
|
624
|
+
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: o, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await b(o ?? []), u = [...await x(t, l), w(r || {})].filter((e) => !a(e));
|
|
652
625
|
this.contextPromise = (async () => {
|
|
653
626
|
let { ContextWatchdog: e, Context: n } = await import("ckeditor5"), r = new e(n, {
|
|
654
627
|
crashNumberLimit: 10,
|
|
655
628
|
...i
|
|
656
|
-
}), a =
|
|
657
|
-
return a =
|
|
629
|
+
}), a = E(s);
|
|
630
|
+
return a = D([...u].reverse(), t.ui, a), await r.create({
|
|
658
631
|
...a,
|
|
659
632
|
language: t,
|
|
660
633
|
plugins: c,
|
|
@@ -665,7 +638,7 @@ var z = class e extends r {
|
|
|
665
638
|
})();
|
|
666
639
|
let d = await this.contextPromise;
|
|
667
640
|
/* v8 ignore next if -- @preserve */
|
|
668
|
-
this.isBeingDestroyed() ||
|
|
641
|
+
this.isBeingDestroyed() || N.the.register(e, d);
|
|
669
642
|
}
|
|
670
643
|
async destroyed() {
|
|
671
644
|
let { contextId: e } = this.canonical;
|
|
@@ -673,15 +646,15 @@ var z = class e extends r {
|
|
|
673
646
|
try {
|
|
674
647
|
await (await this.contextPromise)?.destroy();
|
|
675
648
|
} finally {
|
|
676
|
-
this.contextPromise = null,
|
|
649
|
+
this.contextPromise = null, N.the.hasItem(e) && N.the.unregister(e);
|
|
677
650
|
}
|
|
678
651
|
}
|
|
679
|
-
},
|
|
652
|
+
}, F = class e extends r {
|
|
680
653
|
static the = new e();
|
|
681
654
|
};
|
|
682
655
|
//#endregion
|
|
683
656
|
//#region src/hooks/utils/is-wire-model-connected.ts
|
|
684
|
-
function
|
|
657
|
+
function I(e) {
|
|
685
658
|
let t = e;
|
|
686
659
|
for (; t;) {
|
|
687
660
|
for (let e of t.attributes) if (e.name.startsWith("wire:model")) return !0;
|
|
@@ -691,7 +664,7 @@ function H(e) {
|
|
|
691
664
|
}
|
|
692
665
|
//#endregion
|
|
693
666
|
//#region src/hooks/utils/root-attributes-updater.ts
|
|
694
|
-
function
|
|
667
|
+
function L(e, t) {
|
|
695
668
|
let n = /* @__PURE__ */ new Set();
|
|
696
669
|
return (r) => {
|
|
697
670
|
e.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
@@ -705,35 +678,36 @@ function U(e, t) {
|
|
|
705
678
|
}
|
|
706
679
|
//#endregion
|
|
707
680
|
//#region src/hooks/editable.ts
|
|
708
|
-
var
|
|
681
|
+
var R = class extends e {
|
|
709
682
|
rootAttributesUpdater = null;
|
|
710
683
|
pendingContent = null;
|
|
711
684
|
mounted() {
|
|
712
|
-
let { editorId: e, rootName: t, content: n } = this.canonical,
|
|
685
|
+
let { editorId: e, rootName: t, content: n, modelElement: r } = this.canonical, i = F.the.mountEffect(e, (e) => {
|
|
713
686
|
/* v8 ignore next if -- @preserve */
|
|
714
687
|
if (this.isBeingDestroyed()) return;
|
|
715
|
-
let
|
|
716
|
-
if (
|
|
688
|
+
let i = e.model.document.getRoot(t);
|
|
689
|
+
if (i?.isAttached() && n !== null) {
|
|
717
690
|
let r = e.getData({ rootName: t });
|
|
718
691
|
r && r !== n && e.setData({ [t]: n });
|
|
719
692
|
}
|
|
720
693
|
/* v8 ignore next else -- @preserve */
|
|
721
|
-
if (!
|
|
722
|
-
let { ui:
|
|
694
|
+
if (!i && g(e)) {
|
|
695
|
+
let { ui: i, editing: a } = e;
|
|
723
696
|
e.addRoot(t, {
|
|
724
697
|
isUndoable: !1,
|
|
698
|
+
modelElement: r ?? "$root",
|
|
725
699
|
...n !== null && { initialData: n }
|
|
726
700
|
});
|
|
727
|
-
let
|
|
728
|
-
|
|
701
|
+
let o = this.element.querySelector("[data-cke-editable-content]"), s = i.view.createEditable(t, o);
|
|
702
|
+
i.addEditable(s), a.view.forceRender();
|
|
729
703
|
}
|
|
730
|
-
let
|
|
704
|
+
let a = this.syncTypingContentPush(e), o = this.setupPendingReceivedContentHandlers(e);
|
|
731
705
|
return this.applyRootAttributes(e), () => {
|
|
732
706
|
/* v8 ignore next else -- @preserve */
|
|
733
|
-
if (
|
|
707
|
+
if (a(), o(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
|
|
734
708
|
let n = e.model.document.getRoot(t);
|
|
735
709
|
/* v8 ignore next if -- @preserve */
|
|
736
|
-
if (n &&
|
|
710
|
+
if (n && g(e)) {
|
|
737
711
|
try {
|
|
738
712
|
/* v8 ignore else -- @preserve */
|
|
739
713
|
e.ui.view.editables[t] && e.detachEditable(n);
|
|
@@ -746,10 +720,10 @@ var W = class extends e {
|
|
|
746
720
|
}
|
|
747
721
|
};
|
|
748
722
|
});
|
|
749
|
-
this.onBeforeDestroy(
|
|
723
|
+
this.onBeforeDestroy(i);
|
|
750
724
|
}
|
|
751
725
|
async afterCommitSynced() {
|
|
752
|
-
let { editorId: e } = this.canonical, t = await
|
|
726
|
+
let { editorId: e } = this.canonical, t = await F.the.waitFor(e);
|
|
753
727
|
this.applyCanonicalContentToEditor(t), this.applyRootAttributes(t);
|
|
754
728
|
}
|
|
755
729
|
destroyed() {
|
|
@@ -778,7 +752,7 @@ var W = class extends e {
|
|
|
778
752
|
};
|
|
779
753
|
}
|
|
780
754
|
applyCanonicalContentToEditor(e) {
|
|
781
|
-
if (!
|
|
755
|
+
if (!I(this.element)) return;
|
|
782
756
|
let { content: t, rootName: n } = this.canonical, { ui: r } = e;
|
|
783
757
|
if (e.getData({ rootName: n }) !== (t ?? "")) {
|
|
784
758
|
if (r.focusTracker.isFocused) {
|
|
@@ -790,12 +764,12 @@ var W = class extends e {
|
|
|
790
764
|
}
|
|
791
765
|
applyRootAttributes(e) {
|
|
792
766
|
let { rootName: t, rootAttributes: n } = this.canonical;
|
|
793
|
-
this.rootAttributesUpdater ??=
|
|
767
|
+
this.rootAttributesUpdater ??= L(e, t), this.rootAttributesUpdater(n);
|
|
794
768
|
}
|
|
795
769
|
};
|
|
796
770
|
//#endregion
|
|
797
771
|
//#region src/hooks/editor/plugins/livewire-sync.ts
|
|
798
|
-
async function
|
|
772
|
+
async function z({ saveDebounceMs: e, component: t }) {
|
|
799
773
|
let { Plugin: n } = await import("ckeditor5");
|
|
800
774
|
return class extends n {
|
|
801
775
|
static get pluginName() {
|
|
@@ -807,15 +781,15 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
807
781
|
setupAfterCommitHandler() {
|
|
808
782
|
let { editor: e } = this, { model: n, ui: { focusTracker: r } } = e, i = null;
|
|
809
783
|
e.on("afterCommitSynced", () => {
|
|
810
|
-
if (!
|
|
784
|
+
if (!I(t.element)) return;
|
|
811
785
|
let { content: n } = t.canonical, a = this.getEditorRootsValues();
|
|
812
786
|
if (r.isFocused) {
|
|
813
787
|
/* v8 ignore next else -- @preserve */
|
|
814
|
-
|
|
788
|
+
s(n, a) || (i = n);
|
|
815
789
|
return;
|
|
816
790
|
}
|
|
817
791
|
/* v8 ignore next else -- @preserve */
|
|
818
|
-
|
|
792
|
+
s(n, a) || e.setData(n);
|
|
819
793
|
}), n.document.on("change:data", () => {
|
|
820
794
|
i = null;
|
|
821
795
|
}), r.on("change:isFocused", () => {
|
|
@@ -830,17 +804,17 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
830
804
|
}
|
|
831
805
|
setupSetEditorContentHandler() {
|
|
832
806
|
let { editor: e } = this, n = Livewire.on("set-editor-content", ({ editorId: n, content: r }) => {
|
|
833
|
-
n === t.canonical.editorId && (
|
|
807
|
+
n === t.canonical.editorId && (s(this.getEditorRootsValues(), r) || e.setData(r));
|
|
834
808
|
});
|
|
835
809
|
/* v8 ignore next if -- @preserve */
|
|
836
810
|
typeof n == "function" && e.once("destroy", n);
|
|
837
811
|
}
|
|
838
812
|
setupTypingContentPush() {
|
|
839
|
-
let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t,
|
|
813
|
+
let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t, c = !1, l = () => {
|
|
840
814
|
/* v8 ignore next if -- @preserve */
|
|
841
|
-
if (
|
|
815
|
+
if (c) return;
|
|
842
816
|
let e = this.getEditorRootsValues();
|
|
843
|
-
|
|
817
|
+
s(e, t.canonical.content ?? {}) || (o.set("content", e), o.dispatch("editor-content-changed", {
|
|
844
818
|
editorId: t.canonical.editorId,
|
|
845
819
|
content: e
|
|
846
820
|
}));
|
|
@@ -848,24 +822,24 @@ async function G({ saveDebounceMs: e, component: t }) {
|
|
|
848
822
|
r.document.on("change:data", i(10, () => {
|
|
849
823
|
a.focusTracker.isFocused ? u() : l();
|
|
850
824
|
})), n.once("ready", l), n.once("destroy", () => {
|
|
851
|
-
|
|
825
|
+
c = !0;
|
|
852
826
|
});
|
|
853
827
|
}
|
|
854
828
|
setupFocusableEventPush() {
|
|
855
829
|
let { ui: e } = this.editor, { $wire: n } = t;
|
|
856
830
|
e.focusTracker.on("change:isFocused", () => {
|
|
857
831
|
let r = this.getEditorRootsValues();
|
|
858
|
-
n.set("focused", e.focusTracker.isFocused),
|
|
832
|
+
n.set("focused", e.focusTracker.isFocused), s(r, t.canonical.content ?? {}) || n.set("content", r);
|
|
859
833
|
});
|
|
860
834
|
}
|
|
861
835
|
getEditorRootsValues() {
|
|
862
|
-
return
|
|
836
|
+
return h(this.editor);
|
|
863
837
|
}
|
|
864
838
|
};
|
|
865
839
|
}
|
|
866
840
|
//#endregion
|
|
867
841
|
//#region src/hooks/editor/plugins/sync-editor-with-input.ts
|
|
868
|
-
async function
|
|
842
|
+
async function B(e) {
|
|
869
843
|
let { Plugin: t } = await import("ckeditor5");
|
|
870
844
|
return class extends t {
|
|
871
845
|
input = null;
|
|
@@ -891,101 +865,88 @@ async function K(e) {
|
|
|
891
865
|
}
|
|
892
866
|
//#endregion
|
|
893
867
|
//#region src/hooks/editor/editor.ts
|
|
894
|
-
var
|
|
868
|
+
var V = class extends e {
|
|
895
869
|
rootAttributesUpdater = null;
|
|
896
870
|
async mounted() {
|
|
897
871
|
let { editorId: e } = this.canonical;
|
|
898
|
-
|
|
872
|
+
F.the.resetErrors(e);
|
|
899
873
|
try {
|
|
900
|
-
let t = await this.createEditor(), n =
|
|
874
|
+
let t = await this.createEditor(), n = m(t), r = M(t);
|
|
901
875
|
/* v8 ignore next 3 */
|
|
902
876
|
if (this.isBeingDestroyed()) return;
|
|
903
|
-
let i =
|
|
877
|
+
let i = F.the.mountEffect(e, (t) => {
|
|
904
878
|
t.once("destroy", () => {
|
|
905
|
-
|
|
879
|
+
F.the.unregister(e, !1);
|
|
906
880
|
}, { priority: "highest" });
|
|
907
881
|
});
|
|
908
882
|
this.onBeforeDestroy(async () => {
|
|
909
|
-
|
|
910
|
-
}),
|
|
883
|
+
F.the.unregister(e), i(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : r ? await r.destroy() : await t.destroy();
|
|
884
|
+
}), F.the.register(e, t);
|
|
911
885
|
} catch (t) {
|
|
912
|
-
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t),
|
|
886
|
+
console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t), F.the.error(e, t);
|
|
913
887
|
}
|
|
914
888
|
}
|
|
915
889
|
async destroyed() {
|
|
916
890
|
this.element.style.display = "none";
|
|
917
891
|
}
|
|
918
892
|
async afterCommitSynced() {
|
|
919
|
-
let e = await
|
|
893
|
+
let e = await F.the.waitFor(this.canonical.editorId);
|
|
920
894
|
/* v8 ignore if -- @preserve */
|
|
921
895
|
e && (e.fire("afterCommitSynced"), this.applyRootAttributes(e));
|
|
922
896
|
}
|
|
923
897
|
applyRootAttributes(e) {
|
|
924
898
|
let { rootAttributes: t } = this.canonical;
|
|
925
|
-
this.rootAttributesUpdater ??=
|
|
899
|
+
this.rootAttributesUpdater ??= L(e, "main"), this.rootAttributesUpdater(t);
|
|
926
900
|
}
|
|
927
901
|
async createEditor() {
|
|
928
|
-
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language:
|
|
929
|
-
let { loadedPlugins: e, hasPremium: n } = await
|
|
930
|
-
e.push(await
|
|
902
|
+
let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language: o, watchdog: s } = this.canonical, { customTranslations: c, editorType: l, licenseKey: f, watchdogConfig: m, config: { plugins: h, ...g } } = e, y = await v(l), S = await (n ? N.the.waitFor(n) : null), C = async () => {
|
|
903
|
+
let { loadedPlugins: e, hasPremium: n } = await b(h);
|
|
904
|
+
e.push(await z({
|
|
931
905
|
saveDebounceMs: i,
|
|
932
906
|
component: this
|
|
933
|
-
})),
|
|
934
|
-
let s = [...await
|
|
935
|
-
|
|
936
|
-
|
|
907
|
+
})), _(l) && e.push(await B(i));
|
|
908
|
+
let s = [...await x(o, n), w(c || {})].filter((e) => !a(e)), d = T(t), m = Object.keys(d);
|
|
909
|
+
_(l) && m.push("main"), H(d, m) || (d = await U(t, m));
|
|
910
|
+
let v = {
|
|
911
|
+
...g,
|
|
912
|
+
licenseKey: f,
|
|
913
|
+
plugins: e,
|
|
914
|
+
language: o,
|
|
915
|
+
...s.length && { translations: s }
|
|
937
916
|
};
|
|
938
|
-
|
|
939
|
-
let
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
...j(t)
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
x(u) && "main" in n && (n = n.main);
|
|
949
|
-
let r = {
|
|
950
|
-
...v,
|
|
951
|
-
licenseKey: f,
|
|
952
|
-
plugins: e,
|
|
953
|
-
language: a,
|
|
954
|
-
...s.length && { translations: s }
|
|
955
|
-
};
|
|
956
|
-
return r = M(r), r = N([...s].reverse(), a.ui, r), r = p(y, n, r), r = d(m, r), b ? (await _({
|
|
957
|
-
context: b,
|
|
958
|
-
creator: y,
|
|
959
|
-
config: r
|
|
960
|
-
})).editor : y.create(r);
|
|
961
|
-
})();
|
|
962
|
-
return x(u) && r && F(h, r), this.applyRootAttributes(h), h;
|
|
917
|
+
v = E(v), v = D([...s].reverse(), o.ui, v), v = u(y, d, v);
|
|
918
|
+
let C = await (async () => S ? (await p({
|
|
919
|
+
context: S,
|
|
920
|
+
creator: y,
|
|
921
|
+
config: v
|
|
922
|
+
})).editor : y.create(v))();
|
|
923
|
+
return _(l) && r && k(C, r), this.applyRootAttributes(C), C;
|
|
963
924
|
};
|
|
964
|
-
if (s && !
|
|
965
|
-
let e = await
|
|
925
|
+
if (s && !S) {
|
|
926
|
+
let e = await j(C, m);
|
|
966
927
|
return e.on("error", (e, { causesRestart: n }) => {
|
|
967
928
|
if (n) {
|
|
968
|
-
let e =
|
|
929
|
+
let e = F.the.getItem(t);
|
|
969
930
|
/* v8 ignore next 3 */
|
|
970
|
-
e && (
|
|
931
|
+
e && (d(e), F.the.unregister(t));
|
|
971
932
|
}
|
|
972
933
|
}), e.on("restart", () => {
|
|
973
|
-
|
|
934
|
+
F.the.register(t, e.editor);
|
|
974
935
|
}), await e.create({}), e.editor;
|
|
975
936
|
}
|
|
976
937
|
return C();
|
|
977
938
|
}
|
|
978
939
|
};
|
|
979
|
-
function
|
|
980
|
-
return t.every((t) => e[t]);
|
|
940
|
+
function H(e, t) {
|
|
941
|
+
return t.every((t) => e[t]?.element);
|
|
981
942
|
}
|
|
982
|
-
async function
|
|
983
|
-
return
|
|
984
|
-
let n =
|
|
985
|
-
if (!
|
|
943
|
+
async function U(e, t) {
|
|
944
|
+
return l(() => {
|
|
945
|
+
let n = T(e);
|
|
946
|
+
if (!H(n, t)) throw Error(`It looks like not all required root elements are present yet.
|
|
986
947
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
987
948
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
988
|
-
Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
949
|
+
Missing roots: ${t.filter((e) => !n[e]?.element).join(", ")}.`);
|
|
989
950
|
return n;
|
|
990
951
|
}, {
|
|
991
952
|
timeOutAfter: 2e3,
|
|
@@ -994,12 +955,12 @@ Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
|
994
955
|
}
|
|
995
956
|
//#endregion
|
|
996
957
|
//#region src/hooks/ui-part.ts
|
|
997
|
-
var
|
|
958
|
+
var W = class extends e {
|
|
998
959
|
mounted() {
|
|
999
|
-
let { editorId: e, name: t } = this.canonical, n =
|
|
960
|
+
let { editorId: e, name: t } = this.canonical, n = F.the.mountEffect(e, (e) => {
|
|
1000
961
|
/* v8 ignore next if -- @preserve */
|
|
1001
962
|
if (this.isBeingDestroyed()) return;
|
|
1002
|
-
let { ui: n } = e, r =
|
|
963
|
+
let { ui: n } = e, r = G(t), i = n.view[r];
|
|
1003
964
|
if (!i) {
|
|
1004
965
|
console.error(`Unknown UI part name: "${t}". Supported names are "toolbar" and "menubar".`);
|
|
1005
966
|
return;
|
|
@@ -1014,7 +975,7 @@ var X = class extends e {
|
|
|
1014
975
|
this.element.style.display = "none";
|
|
1015
976
|
}
|
|
1016
977
|
};
|
|
1017
|
-
function
|
|
978
|
+
function G(e) {
|
|
1018
979
|
switch (e) {
|
|
1019
980
|
case "toolbar": return "toolbar";
|
|
1020
981
|
case "menubar": return "menuBarView";
|
|
@@ -1023,19 +984,19 @@ function Z(e) {
|
|
|
1023
984
|
}
|
|
1024
985
|
//#endregion
|
|
1025
986
|
//#region src/hooks/index.ts
|
|
1026
|
-
var
|
|
1027
|
-
ckeditor5:
|
|
1028
|
-
"ckeditor5-context":
|
|
1029
|
-
"ckeditor5-ui-part":
|
|
1030
|
-
"ckeditor5-editable":
|
|
987
|
+
var K = {
|
|
988
|
+
ckeditor5: V,
|
|
989
|
+
"ckeditor5-context": P,
|
|
990
|
+
"ckeditor5-ui-part": W,
|
|
991
|
+
"ckeditor5-editable": R
|
|
1031
992
|
};
|
|
1032
|
-
function
|
|
1033
|
-
for (let [e, n] of Object.entries(
|
|
993
|
+
function q() {
|
|
994
|
+
for (let [e, n] of Object.entries(K)) t(e, n);
|
|
1034
995
|
}
|
|
1035
996
|
//#endregion
|
|
1036
997
|
//#region src/index.ts
|
|
1037
|
-
|
|
998
|
+
q();
|
|
1038
999
|
//#endregion
|
|
1039
|
-
export { e as ClassHook,
|
|
1000
|
+
export { e as ClassHook, N as ContextsRegistry, y as CustomEditorPluginsRegistry, R as EditableComponentHook, V as EditorComponentHook, F as EditorsRegistry, W as UIPartComponentHook, t as registerLivewireComponentHook };
|
|
1040
1001
|
|
|
1041
1002
|
//# sourceMappingURL=index.mjs.map
|