ckeditor5-livewire 1.11.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/editor/editor.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/create-editor-in-context.d.ts +1 -3
- package/dist/hooks/editor/utils/create-editor-in-context.d.ts.map +1 -1
- package/dist/hooks/editor/utils/index.d.ts +2 -0
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +166 -126
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/hooks/editable.ts +1 -1
- package/src/hooks/editor/editor.ts +8 -6
- 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/create-editor-in-context.ts +2 -5
- package/src/hooks/editor/utils/index.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -210,8 +210,51 @@ function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
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
|
|
213
256
|
//#region src/hooks/editor/utils/cleanup-orphan-editor-elements.ts
|
|
214
|
-
function
|
|
257
|
+
function h(e) {
|
|
215
258
|
let t = [
|
|
216
259
|
e.ui?.element,
|
|
217
260
|
e.ui?.view?.toolbar?.element,
|
|
@@ -228,44 +271,43 @@ function d(e) {
|
|
|
228
271
|
}
|
|
229
272
|
//#endregion
|
|
230
273
|
//#region src/hooks/editor/utils/create-editor-in-context.ts
|
|
231
|
-
var
|
|
232
|
-
async function
|
|
233
|
-
let
|
|
234
|
-
await
|
|
235
|
-
creator:
|
|
236
|
-
id:
|
|
237
|
-
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,
|
|
238
280
|
type: "editor",
|
|
239
|
-
config:
|
|
281
|
+
config: n
|
|
240
282
|
});
|
|
241
|
-
let
|
|
283
|
+
let i = e.getItem(r), a = {
|
|
242
284
|
state: "available",
|
|
243
|
-
editorContextId:
|
|
244
|
-
context:
|
|
285
|
+
editorContextId: r,
|
|
286
|
+
context: e
|
|
245
287
|
};
|
|
246
|
-
|
|
247
|
-
let
|
|
248
|
-
return
|
|
249
|
-
...
|
|
250
|
-
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
|
|
251
293
|
};
|
|
252
294
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
295
|
+
function v(e) {
|
|
296
|
+
return g in e ? e[g] : null;
|
|
255
297
|
}
|
|
256
298
|
//#endregion
|
|
257
299
|
//#region src/hooks/editor/utils/get-editor-roots-values.ts
|
|
258
|
-
function
|
|
300
|
+
function y(e) {
|
|
259
301
|
return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create({}));
|
|
260
302
|
}
|
|
261
303
|
//#endregion
|
|
262
304
|
//#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
|
|
263
|
-
function
|
|
305
|
+
function b(e) {
|
|
264
306
|
return "addEditable" in e.ui;
|
|
265
307
|
}
|
|
266
308
|
//#endregion
|
|
267
309
|
//#region src/hooks/editor/utils/is-single-root-editor.ts
|
|
268
|
-
function
|
|
310
|
+
function x(e) {
|
|
269
311
|
return [
|
|
270
312
|
"inline",
|
|
271
313
|
"classic",
|
|
@@ -275,7 +317,7 @@ function _(e) {
|
|
|
275
317
|
}
|
|
276
318
|
//#endregion
|
|
277
319
|
//#region src/hooks/editor/utils/load-editor-constructor.ts
|
|
278
|
-
async function
|
|
320
|
+
async function S(e) {
|
|
279
321
|
let t = await import("ckeditor5"), n = {
|
|
280
322
|
inline: t.InlineEditor,
|
|
281
323
|
balloon: t.BalloonEditor,
|
|
@@ -288,7 +330,7 @@ async function v(e) {
|
|
|
288
330
|
}
|
|
289
331
|
//#endregion
|
|
290
332
|
//#region src/hooks/editor/custom-editor-plugins.ts
|
|
291
|
-
var
|
|
333
|
+
var C = class e {
|
|
292
334
|
static the = new e();
|
|
293
335
|
plugins = /* @__PURE__ */ new Map();
|
|
294
336
|
constructor() {}
|
|
@@ -312,9 +354,9 @@ var y = class e {
|
|
|
312
354
|
};
|
|
313
355
|
//#endregion
|
|
314
356
|
//#region src/hooks/editor/utils/load-editor-plugins.ts
|
|
315
|
-
async function
|
|
357
|
+
async function w(e) {
|
|
316
358
|
let t = await import("ckeditor5"), n = null, r = e.map(async (e) => {
|
|
317
|
-
let r = await
|
|
359
|
+
let r = await C.the.get(e);
|
|
318
360
|
if (r) return r;
|
|
319
361
|
let { [e]: i } = t;
|
|
320
362
|
if (i) return i;
|
|
@@ -336,19 +378,19 @@ async function b(e) {
|
|
|
336
378
|
}
|
|
337
379
|
//#endregion
|
|
338
380
|
//#region src/hooks/editor/utils/load-editor-translations.ts
|
|
339
|
-
async function
|
|
340
|
-
let n = [e.ui, e.content], r = [
|
|
341
|
-
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());
|
|
342
384
|
}
|
|
343
|
-
async function
|
|
385
|
+
async function E(e, t) {
|
|
344
386
|
/* v8 ignore next */
|
|
345
387
|
return await Promise.all(t.filter((e) => e !== "en").map(async (t) => {
|
|
346
|
-
let n = await
|
|
388
|
+
let n = await D(e, t);
|
|
347
389
|
/* v8 ignore next -- @preserve */
|
|
348
390
|
return n?.default ?? n;
|
|
349
391
|
}).filter(Boolean));
|
|
350
392
|
}
|
|
351
|
-
async function
|
|
393
|
+
async function D(e, t) {
|
|
352
394
|
try {
|
|
353
395
|
/* v8 ignore next if -- @preserve */
|
|
354
396
|
if (e === "ckeditor5") switch (t) {
|
|
@@ -508,15 +550,15 @@ catch (n) {
|
|
|
508
550
|
}
|
|
509
551
|
//#endregion
|
|
510
552
|
//#region src/hooks/editor/utils/normalize-custom-translations.ts
|
|
511
|
-
function
|
|
553
|
+
function O(e) {
|
|
512
554
|
return s(e, (e) => ({ dictionary: e }));
|
|
513
555
|
}
|
|
514
556
|
//#endregion
|
|
515
557
|
//#region src/hooks/editor/utils/query-editor-editables.ts
|
|
516
|
-
function
|
|
517
|
-
return s(
|
|
558
|
+
function k(e) {
|
|
559
|
+
return s(A(e), ({ element: e }) => e);
|
|
518
560
|
}
|
|
519
|
-
function
|
|
561
|
+
function A(e) {
|
|
520
562
|
let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => ({
|
|
521
563
|
...e,
|
|
522
564
|
[t.rootName]: {
|
|
@@ -538,38 +580,38 @@ function E(e) {
|
|
|
538
580
|
}
|
|
539
581
|
} : t;
|
|
540
582
|
}
|
|
541
|
-
function
|
|
542
|
-
return a(s(
|
|
583
|
+
function j(e) {
|
|
584
|
+
return a(s(A(e), ({ content: e }) => e), (e) => typeof e == "string");
|
|
543
585
|
}
|
|
544
586
|
//#endregion
|
|
545
587
|
//#region src/hooks/editor/utils/resolve-editor-config-elements-references.ts
|
|
546
|
-
function
|
|
588
|
+
function M(e) {
|
|
547
589
|
if (!e || typeof e != "object") return e;
|
|
548
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
590
|
+
if (Array.isArray(e)) return e.map((e) => M(e));
|
|
549
591
|
let t = e;
|
|
550
592
|
if (t.$element && typeof t.$element == "string") {
|
|
551
593
|
let e = document.querySelector(t.$element);
|
|
552
594
|
return e || console.warn(`Element not found for selector: ${t.$element}`), e || null;
|
|
553
595
|
}
|
|
554
596
|
let n = Object.create(null);
|
|
555
|
-
for (let [t, r] of Object.entries(e)) n[t] =
|
|
597
|
+
for (let [t, r] of Object.entries(e)) n[t] = M(r);
|
|
556
598
|
return n;
|
|
557
599
|
}
|
|
558
600
|
//#endregion
|
|
559
601
|
//#region src/hooks/editor/utils/resolve-editor-config-translations.ts
|
|
560
|
-
function
|
|
602
|
+
function N(e, t, n) {
|
|
561
603
|
if (!n || typeof n != "object") return n;
|
|
562
|
-
if (Array.isArray(n)) return n.map((n) =>
|
|
604
|
+
if (Array.isArray(n)) return n.map((n) => N(e, t, n));
|
|
563
605
|
let r = n;
|
|
564
606
|
if (r.$translation && typeof r.$translation == "string") {
|
|
565
|
-
let n = r.$translation, i =
|
|
607
|
+
let n = r.$translation, i = P(e, n, t);
|
|
566
608
|
return i === void 0 && console.warn(`Translation not found for key: ${n}`), i === void 0 ? null : i;
|
|
567
609
|
}
|
|
568
610
|
let i = Object.create(null);
|
|
569
|
-
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);
|
|
570
612
|
return i;
|
|
571
613
|
}
|
|
572
|
-
function
|
|
614
|
+
function P(e, t, n) {
|
|
573
615
|
for (let r of e) {
|
|
574
616
|
let e = r[n];
|
|
575
617
|
if (e?.dictionary && t in e.dictionary) return e.dictionary[t];
|
|
@@ -577,7 +619,7 @@ function A(e, t, n) {
|
|
|
577
619
|
}
|
|
578
620
|
//#endregion
|
|
579
621
|
//#region src/hooks/editor/utils/set-editor-editable-height.ts
|
|
580
|
-
function
|
|
622
|
+
function F(e, t) {
|
|
581
623
|
let { editing: n } = e;
|
|
582
624
|
n.view.change((e) => {
|
|
583
625
|
e.setStyle("height", `${t}px`, n.view.document.getRoot());
|
|
@@ -585,34 +627,34 @@ function j(e, t) {
|
|
|
585
627
|
}
|
|
586
628
|
//#endregion
|
|
587
629
|
//#region src/hooks/editor/utils/wrap-with-watchdog.ts
|
|
588
|
-
var
|
|
589
|
-
async function
|
|
630
|
+
var I = Symbol.for("livewire-editor-watchdog");
|
|
631
|
+
async function L(e, t) {
|
|
590
632
|
let { EditorWatchdog: n } = await import("ckeditor5"), r = new n(null, t ?? {
|
|
591
633
|
crashNumberLimit: 10,
|
|
592
634
|
minimumNonErrorTimePeriod: 5e3
|
|
593
635
|
});
|
|
594
636
|
return r.setCreator(async () => {
|
|
595
637
|
let t = await e();
|
|
596
|
-
return t[
|
|
638
|
+
return t[I] = r, t;
|
|
597
639
|
}), r;
|
|
598
640
|
}
|
|
599
|
-
function
|
|
600
|
-
return
|
|
641
|
+
function R(e) {
|
|
642
|
+
return I in e ? e[I] : null;
|
|
601
643
|
}
|
|
602
644
|
//#endregion
|
|
603
645
|
//#region src/hooks/context/contexts-registry.ts
|
|
604
|
-
var
|
|
646
|
+
var z = class e extends r {
|
|
605
647
|
static the = new e();
|
|
606
|
-
},
|
|
648
|
+
}, B = class extends e {
|
|
607
649
|
contextPromise = null;
|
|
608
650
|
async mounted() {
|
|
609
|
-
let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: a, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await
|
|
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));
|
|
610
652
|
this.contextPromise = (async () => {
|
|
611
653
|
let { ContextWatchdog: e, Context: n } = await import("ckeditor5"), r = new e(n, {
|
|
612
654
|
crashNumberLimit: 10,
|
|
613
655
|
...i
|
|
614
|
-
}), a =
|
|
615
|
-
return a =
|
|
656
|
+
}), a = M(s);
|
|
657
|
+
return a = N([...u].reverse(), t.ui, a), await r.create({
|
|
616
658
|
...a,
|
|
617
659
|
language: t,
|
|
618
660
|
plugins: c,
|
|
@@ -623,7 +665,7 @@ var F = class e extends r {
|
|
|
623
665
|
})();
|
|
624
666
|
let d = await this.contextPromise;
|
|
625
667
|
/* v8 ignore next if -- @preserve */
|
|
626
|
-
this.isBeingDestroyed() ||
|
|
668
|
+
this.isBeingDestroyed() || z.the.register(e, d);
|
|
627
669
|
}
|
|
628
670
|
async destroyed() {
|
|
629
671
|
let { contextId: e } = this.canonical;
|
|
@@ -631,15 +673,15 @@ var F = class e extends r {
|
|
|
631
673
|
try {
|
|
632
674
|
await (await this.contextPromise)?.destroy();
|
|
633
675
|
} finally {
|
|
634
|
-
this.contextPromise = null,
|
|
676
|
+
this.contextPromise = null, z.the.hasItem(e) && z.the.unregister(e);
|
|
635
677
|
}
|
|
636
678
|
}
|
|
637
|
-
},
|
|
679
|
+
}, V = class e extends r {
|
|
638
680
|
static the = new e();
|
|
639
681
|
};
|
|
640
682
|
//#endregion
|
|
641
683
|
//#region src/hooks/utils/is-wire-model-connected.ts
|
|
642
|
-
function
|
|
684
|
+
function H(e) {
|
|
643
685
|
let t = e;
|
|
644
686
|
for (; t;) {
|
|
645
687
|
for (let e of t.attributes) if (e.name.startsWith("wire:model")) return !0;
|
|
@@ -649,7 +691,7 @@ function R(e) {
|
|
|
649
691
|
}
|
|
650
692
|
//#endregion
|
|
651
693
|
//#region src/hooks/utils/root-attributes-updater.ts
|
|
652
|
-
function
|
|
694
|
+
function U(e, t) {
|
|
653
695
|
let n = /* @__PURE__ */ new Set();
|
|
654
696
|
return (r) => {
|
|
655
697
|
e.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
@@ -663,11 +705,11 @@ function z(e, t) {
|
|
|
663
705
|
}
|
|
664
706
|
//#endregion
|
|
665
707
|
//#region src/hooks/editable.ts
|
|
666
|
-
var
|
|
708
|
+
var W = class extends e {
|
|
667
709
|
rootAttributesUpdater = null;
|
|
668
710
|
pendingContent = null;
|
|
669
711
|
mounted() {
|
|
670
|
-
let { editorId: e, rootName: t, content: n } = this.canonical, r =
|
|
712
|
+
let { editorId: e, rootName: t, content: n } = this.canonical, r = V.the.mountEffect(e, (e) => {
|
|
671
713
|
/* v8 ignore next if -- @preserve */
|
|
672
714
|
if (this.isBeingDestroyed()) return;
|
|
673
715
|
let r = e.model.document.getRoot(t);
|
|
@@ -676,11 +718,11 @@ var B = class extends e {
|
|
|
676
718
|
r && r !== n && e.setData({ [t]: n });
|
|
677
719
|
}
|
|
678
720
|
/* v8 ignore next else -- @preserve */
|
|
679
|
-
if (!r &&
|
|
721
|
+
if (!r && b(e)) {
|
|
680
722
|
let { ui: r, editing: i } = e;
|
|
681
723
|
e.addRoot(t, {
|
|
682
724
|
isUndoable: !1,
|
|
683
|
-
...n !== null && {
|
|
725
|
+
...n !== null && { initialData: n }
|
|
684
726
|
});
|
|
685
727
|
let a = this.element.querySelector("[data-cke-editable-content]"), o = r.view.createEditable(t, a);
|
|
686
728
|
r.addEditable(o), i.view.forceRender();
|
|
@@ -691,7 +733,7 @@ var B = class extends e {
|
|
|
691
733
|
if (i(), a(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
|
|
692
734
|
let n = e.model.document.getRoot(t);
|
|
693
735
|
/* v8 ignore next if -- @preserve */
|
|
694
|
-
if (n &&
|
|
736
|
+
if (n && b(e)) {
|
|
695
737
|
try {
|
|
696
738
|
/* v8 ignore else -- @preserve */
|
|
697
739
|
e.ui.view.editables[t] && e.detachEditable(n);
|
|
@@ -707,7 +749,7 @@ var B = class extends e {
|
|
|
707
749
|
this.onBeforeDestroy(r);
|
|
708
750
|
}
|
|
709
751
|
async afterCommitSynced() {
|
|
710
|
-
let { editorId: e } = this.canonical, t = await
|
|
752
|
+
let { editorId: e } = this.canonical, t = await V.the.waitFor(e);
|
|
711
753
|
this.applyCanonicalContentToEditor(t), this.applyRootAttributes(t);
|
|
712
754
|
}
|
|
713
755
|
destroyed() {
|
|
@@ -736,7 +778,7 @@ var B = class extends e {
|
|
|
736
778
|
};
|
|
737
779
|
}
|
|
738
780
|
applyCanonicalContentToEditor(e) {
|
|
739
|
-
if (!
|
|
781
|
+
if (!H(this.element)) return;
|
|
740
782
|
let { content: t, rootName: n } = this.canonical, { ui: r } = e;
|
|
741
783
|
if (e.getData({ rootName: n }) !== (t ?? "")) {
|
|
742
784
|
if (r.focusTracker.isFocused) {
|
|
@@ -748,12 +790,12 @@ var B = class extends e {
|
|
|
748
790
|
}
|
|
749
791
|
applyRootAttributes(e) {
|
|
750
792
|
let { rootName: t, rootAttributes: n } = this.canonical;
|
|
751
|
-
this.rootAttributesUpdater ??=
|
|
793
|
+
this.rootAttributesUpdater ??= U(e, t), this.rootAttributesUpdater(n);
|
|
752
794
|
}
|
|
753
795
|
};
|
|
754
796
|
//#endregion
|
|
755
797
|
//#region src/hooks/editor/plugins/livewire-sync.ts
|
|
756
|
-
async function
|
|
798
|
+
async function G({ saveDebounceMs: e, component: t }) {
|
|
757
799
|
let { Plugin: n } = await import("ckeditor5");
|
|
758
800
|
return class extends n {
|
|
759
801
|
static get pluginName() {
|
|
@@ -765,7 +807,7 @@ async function V({ saveDebounceMs: e, component: t }) {
|
|
|
765
807
|
setupAfterCommitHandler() {
|
|
766
808
|
let { editor: e } = this, { model: n, ui: { focusTracker: r } } = e, i = null;
|
|
767
809
|
e.on("afterCommitSynced", () => {
|
|
768
|
-
if (!
|
|
810
|
+
if (!H(t.element)) return;
|
|
769
811
|
let { content: n } = t.canonical, a = this.getEditorRootsValues();
|
|
770
812
|
if (r.isFocused) {
|
|
771
813
|
/* v8 ignore next else -- @preserve */
|
|
@@ -817,13 +859,13 @@ async function V({ saveDebounceMs: e, component: t }) {
|
|
|
817
859
|
});
|
|
818
860
|
}
|
|
819
861
|
getEditorRootsValues() {
|
|
820
|
-
return
|
|
862
|
+
return y(this.editor);
|
|
821
863
|
}
|
|
822
864
|
};
|
|
823
865
|
}
|
|
824
866
|
//#endregion
|
|
825
867
|
//#region src/hooks/editor/plugins/sync-editor-with-input.ts
|
|
826
|
-
async function
|
|
868
|
+
async function K(e) {
|
|
827
869
|
let { Plugin: t } = await import("ckeditor5");
|
|
828
870
|
return class extends t {
|
|
829
871
|
input = null;
|
|
@@ -849,102 +891,100 @@ async function H(e) {
|
|
|
849
891
|
}
|
|
850
892
|
//#endregion
|
|
851
893
|
//#region src/hooks/editor/editor.ts
|
|
852
|
-
var
|
|
894
|
+
var q = class extends e {
|
|
853
895
|
rootAttributesUpdater = null;
|
|
854
896
|
async mounted() {
|
|
855
897
|
let { editorId: e } = this.canonical;
|
|
856
|
-
|
|
898
|
+
V.the.resetErrors(e);
|
|
857
899
|
try {
|
|
858
|
-
let t = await this.createEditor(), n =
|
|
900
|
+
let t = await this.createEditor(), n = v(t), r = R(t);
|
|
859
901
|
/* v8 ignore next 3 */
|
|
860
902
|
if (this.isBeingDestroyed()) return;
|
|
861
|
-
let i =
|
|
903
|
+
let i = V.the.mountEffect(e, (t) => {
|
|
862
904
|
t.once("destroy", () => {
|
|
863
|
-
|
|
905
|
+
V.the.unregister(e, !1);
|
|
864
906
|
}, { priority: "highest" });
|
|
865
907
|
});
|
|
866
908
|
this.onBeforeDestroy(async () => {
|
|
867
|
-
|
|
868
|
-
}),
|
|
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);
|
|
869
911
|
} catch (t) {
|
|
870
|
-
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);
|
|
871
913
|
}
|
|
872
914
|
}
|
|
873
915
|
async destroyed() {
|
|
874
916
|
this.element.style.display = "none";
|
|
875
917
|
}
|
|
876
918
|
async afterCommitSynced() {
|
|
877
|
-
let e = await
|
|
919
|
+
let e = await V.the.waitFor(this.canonical.editorId);
|
|
878
920
|
/* v8 ignore if -- @preserve */
|
|
879
921
|
e && (e.fire("afterCommitSynced"), this.applyRootAttributes(e));
|
|
880
922
|
}
|
|
881
923
|
applyRootAttributes(e) {
|
|
882
924
|
let { rootAttributes: t } = this.canonical;
|
|
883
|
-
this.rootAttributesUpdater ??=
|
|
925
|
+
this.rootAttributesUpdater ??= U(e, "main"), this.rootAttributesUpdater(t);
|
|
884
926
|
}
|
|
885
927
|
async createEditor() {
|
|
886
|
-
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:
|
|
887
|
-
let { loadedPlugins: e, hasPremium: n } = await
|
|
888
|
-
e.push(await
|
|
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({
|
|
889
931
|
saveDebounceMs: i,
|
|
890
932
|
component: this
|
|
891
|
-
})),
|
|
892
|
-
let s = [...await
|
|
933
|
+
})), x(u) && e.push(await K(i));
|
|
934
|
+
let s = [...await T(a, n), O(l || {})].filter((e) => !o(e)), m = {
|
|
893
935
|
...c,
|
|
894
|
-
...
|
|
936
|
+
...j(t)
|
|
895
937
|
};
|
|
896
|
-
|
|
897
|
-
let
|
|
898
|
-
let n =
|
|
938
|
+
x(u) && (m = m.main || "");
|
|
939
|
+
let h = await (async () => {
|
|
940
|
+
let n = k(t);
|
|
899
941
|
if (!(n instanceof HTMLElement) && !("main" in n)) {
|
|
900
|
-
let e = u === "decoupled" ? ["main"] : Object.keys(
|
|
901
|
-
|
|
942
|
+
let e = u === "decoupled" ? ["main"] : Object.keys(m);
|
|
943
|
+
J(n, e) || (n = await Y(t, e), m = {
|
|
902
944
|
...c,
|
|
903
|
-
...
|
|
945
|
+
...j(t)
|
|
904
946
|
});
|
|
905
947
|
}
|
|
906
|
-
|
|
907
|
-
let r =
|
|
908
|
-
r =
|
|
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);
|
|
909
951
|
let i = {
|
|
910
952
|
...r,
|
|
911
|
-
initialData: d,
|
|
912
953
|
licenseKey: f,
|
|
913
954
|
plugins: e,
|
|
914
955
|
language: a,
|
|
915
956
|
...s.length && { translations: s }
|
|
916
957
|
};
|
|
917
|
-
return !
|
|
918
|
-
context:
|
|
919
|
-
element: n,
|
|
958
|
+
return !b || !(n instanceof HTMLElement) ? y.create(i) : (await _({
|
|
959
|
+
context: b,
|
|
920
960
|
creator: y,
|
|
921
961
|
config: i
|
|
922
962
|
})).editor;
|
|
923
963
|
})();
|
|
924
|
-
return
|
|
964
|
+
return x(u) && r && F(h, r), this.applyRootAttributes(h), h;
|
|
925
965
|
};
|
|
926
|
-
if (s && !
|
|
927
|
-
let e = await
|
|
966
|
+
if (s && !b) {
|
|
967
|
+
let e = await L(C, m);
|
|
928
968
|
return e.on("error", (e, { causesRestart: n }) => {
|
|
929
969
|
if (n) {
|
|
930
|
-
let e =
|
|
970
|
+
let e = V.the.getItem(t);
|
|
931
971
|
/* v8 ignore next 3 */
|
|
932
|
-
e && (
|
|
972
|
+
e && (h(e), V.the.unregister(t));
|
|
933
973
|
}
|
|
934
974
|
}), e.on("restart", () => {
|
|
935
|
-
|
|
975
|
+
V.the.register(t, e.editor);
|
|
936
976
|
}), await e.create({}), e.editor;
|
|
937
977
|
}
|
|
938
978
|
return C();
|
|
939
979
|
}
|
|
940
980
|
};
|
|
941
|
-
function
|
|
981
|
+
function J(e, t) {
|
|
942
982
|
return t.every((t) => e[t]);
|
|
943
983
|
}
|
|
944
|
-
async function
|
|
984
|
+
async function Y(e, t) {
|
|
945
985
|
return u(() => {
|
|
946
|
-
let n =
|
|
947
|
-
if (!
|
|
986
|
+
let n = k(e);
|
|
987
|
+
if (!J(n, t)) throw Error(`It looks like not all required root elements are present yet.
|
|
948
988
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
949
989
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
950
990
|
Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
@@ -956,12 +996,12 @@ Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
|
|
|
956
996
|
}
|
|
957
997
|
//#endregion
|
|
958
998
|
//#region src/hooks/ui-part.ts
|
|
959
|
-
var
|
|
999
|
+
var X = class extends e {
|
|
960
1000
|
mounted() {
|
|
961
|
-
let { editorId: e, name: t } = this.canonical, n =
|
|
1001
|
+
let { editorId: e, name: t } = this.canonical, n = V.the.mountEffect(e, (e) => {
|
|
962
1002
|
/* v8 ignore next if -- @preserve */
|
|
963
1003
|
if (this.isBeingDestroyed()) return;
|
|
964
|
-
let { ui: n } = e, r =
|
|
1004
|
+
let { ui: n } = e, r = Z(t), i = n.view[r];
|
|
965
1005
|
if (!i) {
|
|
966
1006
|
console.error(`Unknown UI part name: "${t}". Supported names are "toolbar" and "menubar".`);
|
|
967
1007
|
return;
|
|
@@ -976,7 +1016,7 @@ var K = class extends e {
|
|
|
976
1016
|
this.element.style.display = "none";
|
|
977
1017
|
}
|
|
978
1018
|
};
|
|
979
|
-
function
|
|
1019
|
+
function Z(e) {
|
|
980
1020
|
switch (e) {
|
|
981
1021
|
case "toolbar": return "toolbar";
|
|
982
1022
|
case "menubar": return "menuBarView";
|
|
@@ -985,19 +1025,19 @@ function q(e) {
|
|
|
985
1025
|
}
|
|
986
1026
|
//#endregion
|
|
987
1027
|
//#region src/hooks/index.ts
|
|
988
|
-
var
|
|
989
|
-
ckeditor5:
|
|
990
|
-
"ckeditor5-context":
|
|
991
|
-
"ckeditor5-ui-part":
|
|
992
|
-
"ckeditor5-editable":
|
|
1028
|
+
var Q = {
|
|
1029
|
+
ckeditor5: q,
|
|
1030
|
+
"ckeditor5-context": B,
|
|
1031
|
+
"ckeditor5-ui-part": X,
|
|
1032
|
+
"ckeditor5-editable": W
|
|
993
1033
|
};
|
|
994
|
-
function
|
|
995
|
-
for (let [e, n] of Object.entries(
|
|
1034
|
+
function $() {
|
|
1035
|
+
for (let [e, n] of Object.entries(Q)) t(e, n);
|
|
996
1036
|
}
|
|
997
1037
|
//#endregion
|
|
998
1038
|
//#region src/index.ts
|
|
999
|
-
|
|
1039
|
+
$();
|
|
1000
1040
|
//#endregion
|
|
1001
|
-
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 };
|
|
1002
1042
|
|
|
1003
1043
|
//# sourceMappingURL=index.mjs.map
|