ckeditor5-livewire 1.5.0 → 1.6.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/context/context.d.ts.map +1 -1
- package/dist/hooks/editor/editor.d.ts.map +1 -1
- package/dist/hooks/editor/utils/index.d.ts +1 -0
- package/dist/hooks/editor/utils/index.d.ts.map +1 -1
- package/dist/hooks/editor/utils/load-editor-translations.d.ts +2 -1
- package/dist/hooks/editor/utils/load-editor-translations.d.ts.map +1 -1
- package/dist/hooks/editor/utils/resolve-editor-config-translations.d.ts +25 -0
- package/dist/hooks/editor/utils/resolve-editor-config-translations.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +216 -191
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/context/context.test.ts +77 -52
- package/src/hooks/context/context.ts +9 -1
- package/src/hooks/editor/editor.test.ts +33 -0
- package/src/hooks/editor/editor.ts +8 -1
- package/src/hooks/editor/utils/index.ts +1 -0
- package/src/hooks/editor/utils/load-editor-translations.ts +3 -1
- package/src/hooks/editor/utils/resolve-editor-config-translations.test.ts +131 -0
- package/src/hooks/editor/utils/resolve-editor-config-translations.ts +77 -0
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class D {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
this.livewireComponent = t;
|
|
4
4
|
}
|
|
@@ -51,7 +51,7 @@ class P {
|
|
|
51
51
|
this._beforeDestroyCallbacks = [];
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function G(i, t) {
|
|
55
55
|
const e = /* @__PURE__ */ new Map();
|
|
56
56
|
window.Livewire?.hook("component.init", async ({ component: r, cleanup: n }) => {
|
|
57
57
|
if (r.name !== i)
|
|
@@ -67,7 +67,7 @@ function U(i, t) {
|
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
class
|
|
70
|
+
class V {
|
|
71
71
|
/**
|
|
72
72
|
* Map of registered items.
|
|
73
73
|
*/
|
|
@@ -95,11 +95,11 @@ class L {
|
|
|
95
95
|
*/
|
|
96
96
|
execute(t, e, r) {
|
|
97
97
|
const n = this.items.get(t), a = this.initializationErrors.get(t);
|
|
98
|
-
return a ? (r?.(a), Promise.reject(a)) : n ? Promise.resolve(e(n)) : new Promise((
|
|
98
|
+
return a ? (r?.(a), Promise.reject(a)) : n ? Promise.resolve(e(n)) : new Promise((o, s) => {
|
|
99
99
|
const c = this.getPendingCallbacks(t);
|
|
100
100
|
c.success.push(async (u) => {
|
|
101
|
-
|
|
102
|
-
}), r ? c.error.push(r) : c.error.push(
|
|
101
|
+
o(await e(u));
|
|
102
|
+
}), r ? c.error.push(r) : c.error.push(s);
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
@@ -233,7 +233,7 @@ class L {
|
|
|
233
233
|
this.items.size === 1 && t !== null && this.register(null, e);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function S(i, t) {
|
|
237
237
|
let e = null;
|
|
238
238
|
return (...r) => {
|
|
239
239
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
@@ -241,18 +241,18 @@ function x(i, t) {
|
|
|
241
241
|
}, i);
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function Y(i, t) {
|
|
245
245
|
const e = Object.entries(i).filter(([r, n]) => t(n, r));
|
|
246
246
|
return Object.fromEntries(e);
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function W(i) {
|
|
249
249
|
return Object.keys(i).length === 0 && i.constructor === Object;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function R(i, t) {
|
|
252
252
|
const e = Object.entries(i).map(([r, n]) => [r, t(n, r)]);
|
|
253
253
|
return Object.fromEntries(e);
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function C(i, t) {
|
|
256
256
|
if (i === t)
|
|
257
257
|
return !0;
|
|
258
258
|
const e = Object.keys(i), r = Object.keys(t);
|
|
@@ -263,32 +263,32 @@ function b(i, t) {
|
|
|
263
263
|
return !1;
|
|
264
264
|
return !0;
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function X() {
|
|
267
267
|
return Math.random().toString(36).substring(2);
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function J(i, {
|
|
270
270
|
timeOutAfter: t = 500,
|
|
271
271
|
retryAfter: e = 100
|
|
272
272
|
} = {}) {
|
|
273
273
|
return new Promise((r, n) => {
|
|
274
274
|
const a = Date.now();
|
|
275
|
-
let
|
|
276
|
-
const
|
|
277
|
-
n(
|
|
275
|
+
let o = null;
|
|
276
|
+
const s = setTimeout(() => {
|
|
277
|
+
n(o ?? new Error("Timeout"));
|
|
278
278
|
}, t), c = async () => {
|
|
279
279
|
try {
|
|
280
280
|
const u = await i();
|
|
281
|
-
clearTimeout(
|
|
281
|
+
clearTimeout(s), r(u);
|
|
282
282
|
} catch (u) {
|
|
283
|
-
|
|
283
|
+
o = u, Date.now() - a > t ? n(u) : setTimeout(c, e);
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
286
|
c();
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
const
|
|
290
|
-
async function
|
|
291
|
-
const n =
|
|
289
|
+
const O = Symbol.for("context-editor-watchdog");
|
|
290
|
+
async function Q({ element: i, context: t, creator: e, config: r }) {
|
|
291
|
+
const n = X();
|
|
292
292
|
await t.add({
|
|
293
293
|
creator: (c, u) => e.create(c, u),
|
|
294
294
|
id: n,
|
|
@@ -296,28 +296,28 @@ async function X({ element: i, context: t, creator: e, config: r }) {
|
|
|
296
296
|
type: "editor",
|
|
297
297
|
config: r
|
|
298
298
|
});
|
|
299
|
-
const a = t.getItem(n),
|
|
299
|
+
const a = t.getItem(n), o = {
|
|
300
300
|
state: "available",
|
|
301
301
|
editorContextId: n,
|
|
302
302
|
context: t
|
|
303
303
|
};
|
|
304
|
-
a[
|
|
305
|
-
const
|
|
306
|
-
return t.destroy = async () => (
|
|
307
|
-
...
|
|
304
|
+
a[O] = o;
|
|
305
|
+
const s = t.destroy.bind(t);
|
|
306
|
+
return t.destroy = async () => (o.state = "unavailable", s()), {
|
|
307
|
+
...o,
|
|
308
308
|
editor: a
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
return
|
|
311
|
+
function Z(i) {
|
|
312
|
+
return O in i ? i[O] : null;
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function tt(i) {
|
|
315
315
|
return i.model.document.getRootNames().reduce((e, r) => (e[r] = i.getData({ rootName: r }), e), /* @__PURE__ */ Object.create({}));
|
|
316
316
|
}
|
|
317
317
|
function k(i) {
|
|
318
318
|
return ["inline", "classic", "balloon", "decoupled"].includes(i);
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function B(i) {
|
|
321
321
|
let t = i;
|
|
322
322
|
for (; t; ) {
|
|
323
323
|
for (const e of t.attributes)
|
|
@@ -327,7 +327,7 @@ function F(i) {
|
|
|
327
327
|
}
|
|
328
328
|
return !1;
|
|
329
329
|
}
|
|
330
|
-
async function
|
|
330
|
+
async function et(i) {
|
|
331
331
|
const t = await import("ckeditor5"), r = {
|
|
332
332
|
inline: t.InlineEditor,
|
|
333
333
|
balloon: t.BalloonEditor,
|
|
@@ -339,8 +339,8 @@ async function Z(i) {
|
|
|
339
339
|
throw new Error(`Unsupported editor type: ${i}`);
|
|
340
340
|
return r;
|
|
341
341
|
}
|
|
342
|
-
class
|
|
343
|
-
static the = new
|
|
342
|
+
class H {
|
|
343
|
+
static the = new H();
|
|
344
344
|
/**
|
|
345
345
|
* Map of registered custom plugins.
|
|
346
346
|
*/
|
|
@@ -399,25 +399,25 @@ class S {
|
|
|
399
399
|
return this.plugins.has(t);
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
async function
|
|
402
|
+
async function N(i) {
|
|
403
403
|
const t = await import("ckeditor5");
|
|
404
404
|
let e = null;
|
|
405
405
|
const r = i.map(async (n) => {
|
|
406
|
-
const a = await
|
|
406
|
+
const a = await H.the.get(n);
|
|
407
407
|
if (a)
|
|
408
408
|
return a;
|
|
409
|
-
const { [n]:
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
409
|
+
const { [n]: o } = t;
|
|
410
|
+
if (o)
|
|
411
|
+
return o;
|
|
412
412
|
if (!e)
|
|
413
413
|
try {
|
|
414
414
|
e = await import("ckeditor5-premium-features");
|
|
415
415
|
} catch (c) {
|
|
416
416
|
console.error(`Failed to load premium package: ${c}`);
|
|
417
417
|
}
|
|
418
|
-
const { [n]:
|
|
419
|
-
if (
|
|
420
|
-
return
|
|
418
|
+
const { [n]: s } = e || {};
|
|
419
|
+
if (s)
|
|
420
|
+
return s;
|
|
421
421
|
throw new Error(`Plugin "${n}" not found in base or premium packages.`);
|
|
422
422
|
});
|
|
423
423
|
return {
|
|
@@ -425,25 +425,25 @@ async function W(i) {
|
|
|
425
425
|
hasPremium: !!e
|
|
426
426
|
};
|
|
427
427
|
}
|
|
428
|
-
async function
|
|
428
|
+
async function q(i, t) {
|
|
429
429
|
const e = [i.ui, i.content];
|
|
430
430
|
return await Promise.all(
|
|
431
431
|
[
|
|
432
|
-
|
|
432
|
+
L("ckeditor5", e),
|
|
433
433
|
/* v8 ignore next */
|
|
434
|
-
t &&
|
|
434
|
+
t && L("ckeditor5-premium-features", e)
|
|
435
435
|
].filter((n) => !!n)
|
|
436
436
|
).then((n) => n.flat());
|
|
437
437
|
}
|
|
438
|
-
async function
|
|
438
|
+
async function L(i, t) {
|
|
439
439
|
return await Promise.all(
|
|
440
440
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
441
|
-
const r = await
|
|
441
|
+
const r = await rt(i, e);
|
|
442
442
|
return r?.default ?? r;
|
|
443
443
|
}).filter(Boolean)
|
|
444
444
|
);
|
|
445
445
|
}
|
|
446
|
-
async function
|
|
446
|
+
async function rt(i, t) {
|
|
447
447
|
try {
|
|
448
448
|
if (i === "ckeditor5")
|
|
449
449
|
switch (t) {
|
|
@@ -743,23 +743,23 @@ async function tt(i, t) {
|
|
|
743
743
|
return console.error(`Failed to load translation for ${i}/${t}:`, e), null;
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
-
function
|
|
747
|
-
return
|
|
746
|
+
function _(i) {
|
|
747
|
+
return R(i, (t) => ({
|
|
748
748
|
dictionary: t
|
|
749
749
|
}));
|
|
750
750
|
}
|
|
751
751
|
function j(i) {
|
|
752
|
-
const t =
|
|
753
|
-
return
|
|
752
|
+
const t = U(i);
|
|
753
|
+
return R(t, ({ element: e }) => e);
|
|
754
754
|
}
|
|
755
|
-
function
|
|
756
|
-
const t = window.Livewire.all().filter(({ name:
|
|
757
|
-
...
|
|
758
|
-
[
|
|
755
|
+
function U(i) {
|
|
756
|
+
const t = window.Livewire.all().filter(({ name: o, canonical: s }) => o === "ckeditor5-editable" && s.editorId === i).reduce((o, { canonical: s, el: c }) => ({
|
|
757
|
+
...o,
|
|
758
|
+
[s.rootName]: {
|
|
759
759
|
element: c.querySelector("[data-cke-editable-content]"),
|
|
760
|
-
content:
|
|
760
|
+
content: s.content
|
|
761
761
|
}
|
|
762
|
-
}), /* @__PURE__ */ Object.create({})), r = window.Livewire.all().find(({ name:
|
|
762
|
+
}), /* @__PURE__ */ Object.create({})), r = window.Livewire.all().find(({ name: o, canonical: s }) => o === "ckeditor5" && s.editorId === i)?.canonical.content, n = document.querySelector(`#${i}_editor `), a = t.main;
|
|
763
763
|
return a && r?.main ? {
|
|
764
764
|
...t,
|
|
765
765
|
main: {
|
|
@@ -774,15 +774,15 @@ function N(i) {
|
|
|
774
774
|
}
|
|
775
775
|
} : t;
|
|
776
776
|
}
|
|
777
|
-
function
|
|
778
|
-
const t =
|
|
779
|
-
return
|
|
777
|
+
function F(i) {
|
|
778
|
+
const t = U(i), e = R(t, ({ content: r }) => r);
|
|
779
|
+
return Y(e, (r) => typeof r == "string");
|
|
780
780
|
}
|
|
781
|
-
function
|
|
781
|
+
function v(i) {
|
|
782
782
|
if (!i || typeof i != "object")
|
|
783
783
|
return i;
|
|
784
784
|
if (Array.isArray(i))
|
|
785
|
-
return i.map((r) =>
|
|
785
|
+
return i.map((r) => v(r));
|
|
786
786
|
const t = i;
|
|
787
787
|
if (t.$element && typeof t.$element == "string") {
|
|
788
788
|
const r = document.querySelector(t.$element);
|
|
@@ -790,21 +790,43 @@ function I(i) {
|
|
|
790
790
|
}
|
|
791
791
|
const e = /* @__PURE__ */ Object.create(null);
|
|
792
792
|
for (const [r, n] of Object.entries(i))
|
|
793
|
-
e[r] =
|
|
793
|
+
e[r] = v(n);
|
|
794
794
|
return e;
|
|
795
795
|
}
|
|
796
|
-
function
|
|
796
|
+
function P(i, t, e) {
|
|
797
|
+
if (!e || typeof e != "object")
|
|
798
|
+
return e;
|
|
799
|
+
if (Array.isArray(e))
|
|
800
|
+
return e.map((a) => P(i, t, a));
|
|
801
|
+
const r = e;
|
|
802
|
+
if (r.$translation && typeof r.$translation == "string") {
|
|
803
|
+
const a = r.$translation, o = it(i, a, t);
|
|
804
|
+
return o === void 0 && console.warn(`Translation not found for key: ${a}`), o !== void 0 ? o : null;
|
|
805
|
+
}
|
|
806
|
+
const n = /* @__PURE__ */ Object.create(null);
|
|
807
|
+
for (const [a, o] of Object.entries(e))
|
|
808
|
+
n[a] = P(i, t, o);
|
|
809
|
+
return n;
|
|
810
|
+
}
|
|
811
|
+
function it(i, t, e) {
|
|
812
|
+
for (const r of i) {
|
|
813
|
+
const n = r[e];
|
|
814
|
+
if (n?.dictionary && t in n.dictionary)
|
|
815
|
+
return n.dictionary[t];
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function nt(i, t) {
|
|
797
819
|
const { editing: e } = i;
|
|
798
820
|
e.view.change((r) => {
|
|
799
821
|
r.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
800
822
|
});
|
|
801
823
|
}
|
|
802
|
-
const
|
|
803
|
-
async function
|
|
824
|
+
const $ = Symbol.for("elixir-editor-watchdog");
|
|
825
|
+
async function at(i) {
|
|
804
826
|
const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(i);
|
|
805
827
|
return e.setCreator(async (...r) => {
|
|
806
828
|
const n = await i.create(...r);
|
|
807
|
-
return n[
|
|
829
|
+
return n[$] = e, n;
|
|
808
830
|
}), {
|
|
809
831
|
watchdog: e,
|
|
810
832
|
Constructor: {
|
|
@@ -812,13 +834,13 @@ async function rt(i) {
|
|
|
812
834
|
}
|
|
813
835
|
};
|
|
814
836
|
}
|
|
815
|
-
function
|
|
816
|
-
return
|
|
837
|
+
function ot(i) {
|
|
838
|
+
return $ in i ? i[$] : null;
|
|
817
839
|
}
|
|
818
|
-
class
|
|
819
|
-
static the = new
|
|
840
|
+
class g extends V {
|
|
841
|
+
static the = new g();
|
|
820
842
|
}
|
|
821
|
-
class
|
|
843
|
+
class st extends D {
|
|
822
844
|
/**
|
|
823
845
|
* The promise that resolves to the context instance.
|
|
824
846
|
*/
|
|
@@ -827,28 +849,29 @@ class nt extends P {
|
|
|
827
849
|
* Mounts the context component.
|
|
828
850
|
*/
|
|
829
851
|
async mounted() {
|
|
830
|
-
const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: n, watchdogConfig: a, config: { plugins:
|
|
831
|
-
...await
|
|
832
|
-
|
|
833
|
-
].filter((
|
|
852
|
+
const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: n, watchdogConfig: a, config: { plugins: o, ...s } } = r, { loadedPlugins: c, hasPremium: u } = await N(o ?? []), y = [
|
|
853
|
+
...await q(e, u),
|
|
854
|
+
_(n || {})
|
|
855
|
+
].filter((E) => !W(E));
|
|
834
856
|
this.contextPromise = (async () => {
|
|
835
|
-
const { ContextWatchdog:
|
|
857
|
+
const { ContextWatchdog: E, Context: w } = await import("ckeditor5"), h = new E(w, {
|
|
836
858
|
crashNumberLimit: 10,
|
|
837
859
|
...a
|
|
838
860
|
});
|
|
839
|
-
|
|
840
|
-
|
|
861
|
+
let p = v(s);
|
|
862
|
+
return p = P([...y].reverse(), e.ui, p), await h.create({
|
|
863
|
+
...p,
|
|
841
864
|
language: e,
|
|
842
865
|
plugins: c,
|
|
843
|
-
...
|
|
844
|
-
translations:
|
|
866
|
+
...y.length && {
|
|
867
|
+
translations: y
|
|
845
868
|
}
|
|
846
|
-
}), h.on("itemError", (...
|
|
847
|
-
console.error("Context item error:", ...
|
|
869
|
+
}), h.on("itemError", (...I) => {
|
|
870
|
+
console.error("Context item error:", ...I);
|
|
848
871
|
}), h;
|
|
849
872
|
})();
|
|
850
|
-
const
|
|
851
|
-
this.isBeingDestroyed() ||
|
|
873
|
+
const T = await this.contextPromise;
|
|
874
|
+
this.isBeingDestroyed() || g.the.register(t, T);
|
|
852
875
|
}
|
|
853
876
|
/**
|
|
854
877
|
* Destroys the context component. Unmounts root from the editor.
|
|
@@ -859,14 +882,14 @@ class nt extends P {
|
|
|
859
882
|
try {
|
|
860
883
|
await (await this.contextPromise)?.destroy();
|
|
861
884
|
} finally {
|
|
862
|
-
this.contextPromise = null,
|
|
885
|
+
this.contextPromise = null, g.the.hasItem(t) && g.the.unregister(t);
|
|
863
886
|
}
|
|
864
887
|
}
|
|
865
888
|
}
|
|
866
|
-
class d extends
|
|
889
|
+
class d extends V {
|
|
867
890
|
static the = new d();
|
|
868
891
|
}
|
|
869
|
-
class
|
|
892
|
+
class ct extends D {
|
|
870
893
|
/**
|
|
871
894
|
* The promise that resolves when the editable is mounted.
|
|
872
895
|
*/
|
|
@@ -883,8 +906,8 @@ class at extends P {
|
|
|
883
906
|
this.editorPromise = d.the.execute(t, (n) => {
|
|
884
907
|
if (this.isBeingDestroyed())
|
|
885
908
|
return null;
|
|
886
|
-
const { ui: a, editing:
|
|
887
|
-
if (
|
|
909
|
+
const { ui: a, editing: o, model: s } = n;
|
|
910
|
+
if (s.document.getRoot(e)) {
|
|
888
911
|
if (r !== null) {
|
|
889
912
|
const c = n.getData({ rootName: e });
|
|
890
913
|
c && c !== r && n.setData({
|
|
@@ -899,7 +922,7 @@ class at extends P {
|
|
|
899
922
|
}
|
|
900
923
|
});
|
|
901
924
|
const c = this.element.querySelector("[data-cke-editable-content]"), u = a.view.createEditable(e, c);
|
|
902
|
-
a.addEditable(u),
|
|
925
|
+
a.addEditable(u), o.view.forceRender();
|
|
903
926
|
}
|
|
904
927
|
return this.syncTypingContentPush(n), this.setupPendingReceivedContentHandlers(n), n;
|
|
905
928
|
});
|
|
@@ -909,11 +932,11 @@ class at extends P {
|
|
|
909
932
|
*/
|
|
910
933
|
syncTypingContentPush(t) {
|
|
911
934
|
const { rootName: e, saveDebounceMs: r } = this.canonical, n = this.element.querySelector("input"), a = () => {
|
|
912
|
-
const
|
|
913
|
-
n && (n.value =
|
|
914
|
-
},
|
|
915
|
-
t.model.document.on("change:data",
|
|
916
|
-
t.model.document.off("change:data",
|
|
935
|
+
const s = t.getData({ rootName: e });
|
|
936
|
+
n && (n.value = s), this.$wire.set("content", s);
|
|
937
|
+
}, o = S(r, a);
|
|
938
|
+
t.model.document.on("change:data", o), a(), this.onBeforeDestroy(() => {
|
|
939
|
+
t.model.document.off("change:data", o);
|
|
917
940
|
});
|
|
918
941
|
}
|
|
919
942
|
/**
|
|
@@ -921,22 +944,22 @@ class at extends P {
|
|
|
921
944
|
* content on user edits and applies pending content on blur).
|
|
922
945
|
*/
|
|
923
946
|
setupPendingReceivedContentHandlers(t) {
|
|
924
|
-
const { ui: e, model: r } = t, { focusTracker: n } = e, { rootName: a } = this.canonical,
|
|
947
|
+
const { ui: e, model: r } = t, { focusTracker: n } = e, { rootName: a } = this.canonical, o = () => {
|
|
925
948
|
this.pendingContent = null;
|
|
926
|
-
},
|
|
949
|
+
}, s = () => {
|
|
927
950
|
!n.isFocused && this.pendingContent !== null && (t.setData({
|
|
928
951
|
[a]: this.pendingContent
|
|
929
952
|
}), this.pendingContent = null);
|
|
930
953
|
};
|
|
931
|
-
r.document.on("change:data",
|
|
932
|
-
r.document.off("change:data",
|
|
954
|
+
r.document.on("change:data", o), n.on("change:isFocused", s), this.onBeforeDestroy(() => {
|
|
955
|
+
r.document.off("change:data", o), n.off("change:isFocused", s);
|
|
933
956
|
});
|
|
934
957
|
}
|
|
935
958
|
/**
|
|
936
959
|
* Applies canonical content to the editor while respecting focus/pending state.
|
|
937
960
|
*/
|
|
938
961
|
applyCanonicalContentToEditor(t) {
|
|
939
|
-
if (!
|
|
962
|
+
if (!B(this.element))
|
|
940
963
|
return;
|
|
941
964
|
const { content: e, rootName: r } = this.canonical, { ui: n } = t;
|
|
942
965
|
if (t.getData({ rootName: r }) !== (e ?? "")) {
|
|
@@ -967,7 +990,7 @@ class at extends P {
|
|
|
967
990
|
}
|
|
968
991
|
}
|
|
969
992
|
}
|
|
970
|
-
async function
|
|
993
|
+
async function ut({
|
|
971
994
|
saveDebounceMs: i,
|
|
972
995
|
component: t
|
|
973
996
|
}) {
|
|
@@ -991,21 +1014,21 @@ async function st({
|
|
|
991
1014
|
* disrupting the user while editing.
|
|
992
1015
|
*/
|
|
993
1016
|
setupAfterCommitHandler() {
|
|
994
|
-
const { editor: n } = this, { model: a, ui: { focusTracker:
|
|
995
|
-
let
|
|
1017
|
+
const { editor: n } = this, { model: a, ui: { focusTracker: o } } = n;
|
|
1018
|
+
let s = null;
|
|
996
1019
|
n.on("afterCommitSynced", () => {
|
|
997
|
-
if (!
|
|
1020
|
+
if (!B(t.element))
|
|
998
1021
|
return;
|
|
999
1022
|
const { content: c } = t.canonical, u = this.getEditorRootsValues();
|
|
1000
|
-
if (
|
|
1001
|
-
|
|
1023
|
+
if (o.isFocused) {
|
|
1024
|
+
C(c, u) || (s = c);
|
|
1002
1025
|
return;
|
|
1003
1026
|
}
|
|
1004
|
-
|
|
1027
|
+
C(c, u) || n.setData(c);
|
|
1005
1028
|
}), a.document.on("change:data", () => {
|
|
1006
|
-
|
|
1007
|
-
}),
|
|
1008
|
-
!
|
|
1029
|
+
s = null;
|
|
1030
|
+
}), o.on("change:isFocused", () => {
|
|
1031
|
+
!o.isFocused && s !== null && (n.setData(s), s = null);
|
|
1009
1032
|
});
|
|
1010
1033
|
}
|
|
1011
1034
|
/**
|
|
@@ -1030,42 +1053,42 @@ async function st({
|
|
|
1030
1053
|
Livewire.on("set-editor-content", ({ editorId: n, content: a }) => {
|
|
1031
1054
|
if (n !== t.canonical.editorId)
|
|
1032
1055
|
return;
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1056
|
+
const o = this.getEditorRootsValues();
|
|
1057
|
+
C(o, a) || this.editor.setData(a);
|
|
1035
1058
|
});
|
|
1036
1059
|
}
|
|
1037
1060
|
/**
|
|
1038
1061
|
* Setups the content push event for the editor.
|
|
1039
1062
|
*/
|
|
1040
1063
|
setupTypingContentPush() {
|
|
1041
|
-
const { model: n } = this.editor, { $wire: a } = t,
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1064
|
+
const { model: n } = this.editor, { $wire: a } = t, o = () => {
|
|
1065
|
+
const s = this.getEditorRootsValues();
|
|
1066
|
+
C(s, t.canonical.content ?? {}) || (a.set("content", s), a.dispatch("editor-content-changed", {
|
|
1044
1067
|
editorId: t.canonical.editorId,
|
|
1045
|
-
content:
|
|
1068
|
+
content: s
|
|
1046
1069
|
}));
|
|
1047
1070
|
};
|
|
1048
|
-
n.document.on("change:data",
|
|
1071
|
+
n.document.on("change:data", S(i, o)), this.editor.once("ready", o);
|
|
1049
1072
|
}
|
|
1050
1073
|
/**
|
|
1051
1074
|
* Setups the event push for the editor.
|
|
1052
1075
|
*/
|
|
1053
1076
|
setupFocusableEventPush() {
|
|
1054
|
-
const { ui: n } = this.editor, { $wire: a } = t,
|
|
1055
|
-
const
|
|
1056
|
-
a.set("focused", n.focusTracker.isFocused),
|
|
1077
|
+
const { ui: n } = this.editor, { $wire: a } = t, o = () => {
|
|
1078
|
+
const s = this.getEditorRootsValues();
|
|
1079
|
+
a.set("focused", n.focusTracker.isFocused), C(s, t.canonical.content ?? {}) || a.set("content", s);
|
|
1057
1080
|
};
|
|
1058
|
-
n.focusTracker.on("change:isFocused",
|
|
1081
|
+
n.focusTracker.on("change:isFocused", o);
|
|
1059
1082
|
}
|
|
1060
1083
|
/**
|
|
1061
1084
|
* Gets the current values of all editor roots.
|
|
1062
1085
|
*/
|
|
1063
1086
|
getEditorRootsValues() {
|
|
1064
|
-
return
|
|
1087
|
+
return tt(this.editor);
|
|
1065
1088
|
}
|
|
1066
1089
|
};
|
|
1067
1090
|
}
|
|
1068
|
-
async function
|
|
1091
|
+
async function lt(i) {
|
|
1069
1092
|
const { Plugin: t } = await import("ckeditor5");
|
|
1070
1093
|
return class extends t {
|
|
1071
1094
|
/**
|
|
@@ -1087,7 +1110,7 @@ async function ot(i) {
|
|
|
1087
1110
|
*/
|
|
1088
1111
|
afterInit() {
|
|
1089
1112
|
const { editor: r } = this, a = r.sourceElement.id.replace(/_editor$/, "");
|
|
1090
|
-
this.input = document.getElementById(`${a}_input`), this.input && (r.model.document.on("change:data",
|
|
1113
|
+
this.input = document.getElementById(`${a}_input`), this.input && (r.model.document.on("change:data", S(i, () => this.sync())), r.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1091
1114
|
}
|
|
1092
1115
|
/**
|
|
1093
1116
|
* Synchronizes the editor's content with the input field.
|
|
@@ -1106,7 +1129,7 @@ async function ot(i) {
|
|
|
1106
1129
|
}
|
|
1107
1130
|
};
|
|
1108
1131
|
}
|
|
1109
|
-
class
|
|
1132
|
+
class dt extends D {
|
|
1110
1133
|
/**
|
|
1111
1134
|
* The promise that resolves to the editor instance.
|
|
1112
1135
|
*/
|
|
@@ -1137,7 +1160,7 @@ class ct extends P {
|
|
|
1137
1160
|
const t = await this.editorPromise;
|
|
1138
1161
|
if (!t)
|
|
1139
1162
|
return;
|
|
1140
|
-
const e =
|
|
1163
|
+
const e = Z(t), r = ot(t);
|
|
1141
1164
|
e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : r ? await r.destroy() : await t.destroy();
|
|
1142
1165
|
} finally {
|
|
1143
1166
|
this.editorPromise = null;
|
|
@@ -1159,82 +1182,84 @@ class ct extends P {
|
|
|
1159
1182
|
contextId: r,
|
|
1160
1183
|
editableHeight: n,
|
|
1161
1184
|
saveDebounceMs: a,
|
|
1162
|
-
language:
|
|
1163
|
-
watchdog:
|
|
1185
|
+
language: o,
|
|
1186
|
+
watchdog: s,
|
|
1164
1187
|
content: c
|
|
1165
1188
|
} = this.canonical, {
|
|
1166
1189
|
customTranslations: u,
|
|
1167
1190
|
editorType: m,
|
|
1168
|
-
licenseKey:
|
|
1169
|
-
config: { plugins:
|
|
1191
|
+
licenseKey: y,
|
|
1192
|
+
config: { plugins: T, ...E }
|
|
1170
1193
|
} = t;
|
|
1171
|
-
let
|
|
1172
|
-
const h = await (r ?
|
|
1173
|
-
if (
|
|
1174
|
-
const l = await
|
|
1175
|
-
({ Constructor:
|
|
1176
|
-
const
|
|
1177
|
-
this.editorPromise = Promise.resolve(
|
|
1194
|
+
let w = await et(m);
|
|
1195
|
+
const h = await (r ? g.the.waitFor(r) : null);
|
|
1196
|
+
if (s && !h) {
|
|
1197
|
+
const l = await at(w);
|
|
1198
|
+
({ Constructor: w } = l), l.watchdog.on("restart", () => {
|
|
1199
|
+
const f = l.watchdog.editor;
|
|
1200
|
+
this.editorPromise = Promise.resolve(f), d.the.register(e, f);
|
|
1178
1201
|
});
|
|
1179
1202
|
}
|
|
1180
|
-
const { loadedPlugins:
|
|
1181
|
-
|
|
1182
|
-
await
|
|
1203
|
+
const { loadedPlugins: p, hasPremium: I } = await N(T);
|
|
1204
|
+
p.push(
|
|
1205
|
+
await ut(
|
|
1183
1206
|
{
|
|
1184
1207
|
saveDebounceMs: a,
|
|
1185
1208
|
component: this
|
|
1186
1209
|
}
|
|
1187
1210
|
)
|
|
1188
|
-
), k(m) &&
|
|
1189
|
-
await
|
|
1211
|
+
), k(m) && p.push(
|
|
1212
|
+
await lt(a)
|
|
1190
1213
|
);
|
|
1191
|
-
const
|
|
1192
|
-
...await
|
|
1193
|
-
|
|
1194
|
-
].filter((l) => !
|
|
1195
|
-
let
|
|
1214
|
+
const x = [
|
|
1215
|
+
...await q(o, I),
|
|
1216
|
+
_(u || {})
|
|
1217
|
+
].filter((l) => !W(l));
|
|
1218
|
+
let b = {
|
|
1196
1219
|
...c,
|
|
1197
|
-
...
|
|
1220
|
+
...F(e)
|
|
1198
1221
|
};
|
|
1199
|
-
k(m) && (
|
|
1200
|
-
const
|
|
1222
|
+
k(m) && (b = b.main || "");
|
|
1223
|
+
const M = await (async () => {
|
|
1201
1224
|
let l = j(e);
|
|
1202
1225
|
if (!(l instanceof HTMLElement) && !("main" in l)) {
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1226
|
+
const A = m === "decoupled" ? ["main"] : Object.keys(b);
|
|
1227
|
+
K(l, A) || (l = await mt(e, A), b = {
|
|
1205
1228
|
...c,
|
|
1206
|
-
...
|
|
1229
|
+
...F(e)
|
|
1207
1230
|
});
|
|
1208
1231
|
}
|
|
1209
1232
|
k(m) && "main" in l && (l = l.main);
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1233
|
+
let f = v(E);
|
|
1234
|
+
f = P([...x].reverse(), o.ui, f);
|
|
1235
|
+
const z = {
|
|
1236
|
+
...f,
|
|
1237
|
+
initialData: b,
|
|
1238
|
+
licenseKey: y,
|
|
1239
|
+
plugins: p,
|
|
1240
|
+
language: o,
|
|
1241
|
+
...x.length && {
|
|
1242
|
+
translations: x
|
|
1218
1243
|
}
|
|
1219
1244
|
};
|
|
1220
|
-
return !h || !(l instanceof HTMLElement) ?
|
|
1245
|
+
return !h || !(l instanceof HTMLElement) ? w.create(l, z) : (await Q({
|
|
1221
1246
|
context: h,
|
|
1222
1247
|
element: l,
|
|
1223
|
-
creator:
|
|
1224
|
-
config:
|
|
1248
|
+
creator: w,
|
|
1249
|
+
config: z
|
|
1225
1250
|
})).editor;
|
|
1226
1251
|
})();
|
|
1227
|
-
return k(m) && n &&
|
|
1252
|
+
return k(m) && n && nt(M, n), M;
|
|
1228
1253
|
}
|
|
1229
1254
|
}
|
|
1230
|
-
function
|
|
1255
|
+
function K(i, t) {
|
|
1231
1256
|
return t.every((e) => i[e]);
|
|
1232
1257
|
}
|
|
1233
|
-
async function
|
|
1234
|
-
return
|
|
1258
|
+
async function mt(i, t) {
|
|
1259
|
+
return J(
|
|
1235
1260
|
() => {
|
|
1236
1261
|
const e = j(i);
|
|
1237
|
-
if (!
|
|
1262
|
+
if (!K(e, t))
|
|
1238
1263
|
throw new Error(
|
|
1239
1264
|
`It looks like not all required root elements are present yet.
|
|
1240
1265
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
@@ -1246,7 +1271,7 @@ Missing roots: ${t.filter((r) => !e[r]).join(", ")}.`
|
|
|
1246
1271
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1247
1272
|
);
|
|
1248
1273
|
}
|
|
1249
|
-
class
|
|
1274
|
+
class ht extends D {
|
|
1250
1275
|
/**
|
|
1251
1276
|
* The promise that resolves when the UI part is mounted.
|
|
1252
1277
|
*/
|
|
@@ -1259,12 +1284,12 @@ class lt extends P {
|
|
|
1259
1284
|
this.mountedPromise = d.the.execute(t, (r) => {
|
|
1260
1285
|
if (this.isBeingDestroyed())
|
|
1261
1286
|
return;
|
|
1262
|
-
const { ui: n } = r, a =
|
|
1263
|
-
if (!
|
|
1287
|
+
const { ui: n } = r, a = pt(e), o = n.view[a];
|
|
1288
|
+
if (!o) {
|
|
1264
1289
|
console.error(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1265
1290
|
return;
|
|
1266
1291
|
}
|
|
1267
|
-
this.element.appendChild(
|
|
1292
|
+
this.element.appendChild(o.element);
|
|
1268
1293
|
});
|
|
1269
1294
|
}
|
|
1270
1295
|
/**
|
|
@@ -1274,7 +1299,7 @@ class lt extends P {
|
|
|
1274
1299
|
this.element.style.display = "none", await this.mountedPromise, this.mountedPromise = null, this.element.innerHTML = "";
|
|
1275
1300
|
}
|
|
1276
1301
|
}
|
|
1277
|
-
function
|
|
1302
|
+
function pt(i) {
|
|
1278
1303
|
switch (i) {
|
|
1279
1304
|
case "toolbar":
|
|
1280
1305
|
return "toolbar";
|
|
@@ -1284,25 +1309,25 @@ function dt(i) {
|
|
|
1284
1309
|
return null;
|
|
1285
1310
|
}
|
|
1286
1311
|
}
|
|
1287
|
-
const
|
|
1288
|
-
ckeditor5:
|
|
1289
|
-
"ckeditor5-context":
|
|
1290
|
-
"ckeditor5-ui-part":
|
|
1291
|
-
"ckeditor5-editable":
|
|
1312
|
+
const wt = {
|
|
1313
|
+
ckeditor5: dt,
|
|
1314
|
+
"ckeditor5-context": st,
|
|
1315
|
+
"ckeditor5-ui-part": ht,
|
|
1316
|
+
"ckeditor5-editable": ct
|
|
1292
1317
|
};
|
|
1293
|
-
function
|
|
1294
|
-
for (const [i, t] of Object.entries(
|
|
1295
|
-
|
|
1318
|
+
function ft() {
|
|
1319
|
+
for (const [i, t] of Object.entries(wt))
|
|
1320
|
+
G(i, t);
|
|
1296
1321
|
}
|
|
1297
|
-
|
|
1322
|
+
ft();
|
|
1298
1323
|
export {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1324
|
+
D as ClassHook,
|
|
1325
|
+
g as ContextsRegistry,
|
|
1326
|
+
H as CustomEditorPluginsRegistry,
|
|
1327
|
+
ct as EditableComponentHook,
|
|
1328
|
+
dt as EditorComponentHook,
|
|
1304
1329
|
d as EditorsRegistry,
|
|
1305
|
-
|
|
1306
|
-
|
|
1330
|
+
ht as UIPartComponentHook,
|
|
1331
|
+
G as registerLivewireComponentHook
|
|
1307
1332
|
};
|
|
1308
1333
|
//# sourceMappingURL=index.mjs.map
|