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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- class P {
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 U(i, t) {
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 L {
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((s, o) => {
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
- s(await e(u));
102
- }), r ? c.error.push(r) : c.error.push(o);
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 x(i, t) {
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 K(i, t) {
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 A(i) {
248
+ function W(i) {
249
249
  return Object.keys(i).length === 0 && i.constructor === Object;
250
250
  }
251
- function O(i, t) {
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 b(i, t) {
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 G() {
266
+ function X() {
267
267
  return Math.random().toString(36).substring(2);
268
268
  }
269
- function Y(i, {
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 s = null;
276
- const o = setTimeout(() => {
277
- n(s ?? new Error("Timeout"));
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(o), r(u);
281
+ clearTimeout(s), r(u);
282
282
  } catch (u) {
283
- s = u, Date.now() - a > t ? n(u) : setTimeout(c, e);
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 D = Symbol.for("context-editor-watchdog");
290
- async function X({ element: i, context: t, creator: e, config: r }) {
291
- const n = G();
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), s = {
299
+ const a = t.getItem(n), o = {
300
300
  state: "available",
301
301
  editorContextId: n,
302
302
  context: t
303
303
  };
304
- a[D] = s;
305
- const o = t.destroy.bind(t);
306
- return t.destroy = async () => (s.state = "unavailable", o()), {
307
- ...s,
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 J(i) {
312
- return D in i ? i[D] : null;
311
+ function Z(i) {
312
+ return O in i ? i[O] : null;
313
313
  }
314
- function Q(i) {
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 F(i) {
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 Z(i) {
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 S {
343
- static the = new S();
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 W(i) {
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 S.the.get(n);
406
+ const a = await H.the.get(n);
407
407
  if (a)
408
408
  return a;
409
- const { [n]: s } = t;
410
- if (s)
411
- return s;
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]: o } = e || {};
419
- if (o)
420
- return o;
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 V(i, t) {
428
+ async function q(i, t) {
429
429
  const e = [i.ui, i.content];
430
430
  return await Promise.all(
431
431
  [
432
- M("ckeditor5", e),
432
+ L("ckeditor5", e),
433
433
  /* v8 ignore next */
434
- t && M("ckeditor5-premium-features", e)
434
+ t && L("ckeditor5-premium-features", e)
435
435
  ].filter((n) => !!n)
436
436
  ).then((n) => n.flat());
437
437
  }
438
- async function M(i, t) {
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 tt(i, e);
441
+ const r = await rt(i, e);
442
442
  return r?.default ?? r;
443
443
  }).filter(Boolean)
444
444
  );
445
445
  }
446
- async function tt(i, t) {
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 B(i) {
747
- return O(i, (t) => ({
746
+ function _(i) {
747
+ return R(i, (t) => ({
748
748
  dictionary: t
749
749
  }));
750
750
  }
751
751
  function j(i) {
752
- const t = N(i);
753
- return O(t, ({ element: e }) => e);
752
+ const t = U(i);
753
+ return R(t, ({ element: e }) => e);
754
754
  }
755
- function N(i) {
756
- const t = window.Livewire.all().filter(({ name: s, canonical: o }) => s === "ckeditor5-editable" && o.editorId === i).reduce((s, { canonical: o, el: c }) => ({
757
- ...s,
758
- [o.rootName]: {
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: o.content
760
+ content: s.content
761
761
  }
762
- }), /* @__PURE__ */ Object.create({})), r = window.Livewire.all().find(({ name: s, canonical: o }) => s === "ckeditor5" && o.editorId === i)?.canonical.content, n = document.querySelector(`#${i}_editor `), a = t.main;
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 z(i) {
778
- const t = N(i), e = O(t, ({ content: r }) => r);
779
- return K(e, (r) => typeof r == "string");
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 I(i) {
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) => I(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] = I(n);
793
+ e[r] = v(n);
794
794
  return e;
795
795
  }
796
- function et(i, t) {
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 T = Symbol.for("elixir-editor-watchdog");
803
- async function rt(i) {
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[T] = e, 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 it(i) {
816
- return T in i ? i[T] : null;
837
+ function ot(i) {
838
+ return $ in i ? i[$] : null;
817
839
  }
818
- class w extends L {
819
- static the = new w();
840
+ class g extends V {
841
+ static the = new g();
820
842
  }
821
- class nt extends P {
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: s, ...o } } = r, { loadedPlugins: c, hasPremium: u } = await W(s ?? []), C = [
831
- ...await V(e, u),
832
- B(n || {})
833
- ].filter((f) => !A(f));
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: f, Context: p } = await import("ckeditor5"), h = new f(p, {
857
+ const { ContextWatchdog: E, Context: w } = await import("ckeditor5"), h = new E(w, {
836
858
  crashNumberLimit: 10,
837
859
  ...a
838
860
  });
839
- return await h.create({
840
- ...o,
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
- ...C.length && {
844
- translations: C
866
+ ...y.length && {
867
+ translations: y
845
868
  }
846
- }), h.on("itemError", (...g) => {
847
- console.error("Context item error:", ...g);
869
+ }), h.on("itemError", (...I) => {
870
+ console.error("Context item error:", ...I);
848
871
  }), h;
849
872
  })();
850
- const v = await this.contextPromise;
851
- this.isBeingDestroyed() || w.the.register(t, v);
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, w.the.hasItem(t) && w.the.unregister(t);
885
+ this.contextPromise = null, g.the.hasItem(t) && g.the.unregister(t);
863
886
  }
864
887
  }
865
888
  }
866
- class d extends L {
889
+ class d extends V {
867
890
  static the = new d();
868
891
  }
869
- class at extends P {
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: s, model: o } = n;
887
- if (o.document.getRoot(e)) {
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), s.view.forceRender();
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 o = t.getData({ rootName: e });
913
- n && (n.value = o), this.$wire.set("content", o);
914
- }, s = x(r, a);
915
- t.model.document.on("change:data", s), a(), this.onBeforeDestroy(() => {
916
- t.model.document.off("change:data", s);
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, s = () => {
947
+ const { ui: e, model: r } = t, { focusTracker: n } = e, { rootName: a } = this.canonical, o = () => {
925
948
  this.pendingContent = null;
926
- }, o = () => {
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", s), n.on("change:isFocused", o), this.onBeforeDestroy(() => {
932
- r.document.off("change:data", s), n.off("change:isFocused", o);
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 (!F(this.element))
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 st({
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: s } } = n;
995
- let o = null;
1017
+ const { editor: n } = this, { model: a, ui: { focusTracker: o } } = n;
1018
+ let s = null;
996
1019
  n.on("afterCommitSynced", () => {
997
- if (!F(t.element))
1020
+ if (!B(t.element))
998
1021
  return;
999
1022
  const { content: c } = t.canonical, u = this.getEditorRootsValues();
1000
- if (s.isFocused) {
1001
- b(c, u) || (o = c);
1023
+ if (o.isFocused) {
1024
+ C(c, u) || (s = c);
1002
1025
  return;
1003
1026
  }
1004
- b(c, u) || n.setData(c);
1027
+ C(c, u) || n.setData(c);
1005
1028
  }), a.document.on("change:data", () => {
1006
- o = null;
1007
- }), s.on("change:isFocused", () => {
1008
- !s.isFocused && o !== null && (n.setData(o), o = null);
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 s = this.getEditorRootsValues();
1034
- b(s, a) || this.editor.setData(a);
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, s = () => {
1042
- const o = this.getEditorRootsValues();
1043
- b(o, t.canonical.content ?? {}) || (a.set("content", o), a.dispatch("editor-content-changed", {
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: o
1068
+ content: s
1046
1069
  }));
1047
1070
  };
1048
- n.document.on("change:data", x(i, s)), this.editor.once("ready", s);
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, s = () => {
1055
- const o = this.getEditorRootsValues();
1056
- a.set("focused", n.focusTracker.isFocused), b(o, t.canonical.content ?? {}) || a.set("content", o);
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", s);
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 Q(this.editor);
1087
+ return tt(this.editor);
1065
1088
  }
1066
1089
  };
1067
1090
  }
1068
- async function ot(i) {
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", x(i, () => this.sync())), r.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
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 ct extends P {
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 = J(t), r = it(t);
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: s,
1163
- watchdog: o,
1185
+ language: o,
1186
+ watchdog: s,
1164
1187
  content: c
1165
1188
  } = this.canonical, {
1166
1189
  customTranslations: u,
1167
1190
  editorType: m,
1168
- licenseKey: C,
1169
- config: { plugins: v, ...f }
1191
+ licenseKey: y,
1192
+ config: { plugins: T, ...E }
1170
1193
  } = t;
1171
- let p = await Z(m);
1172
- const h = await (r ? w.the.waitFor(r) : null);
1173
- if (o && !h) {
1174
- const l = await rt(p);
1175
- ({ Constructor: p } = l), l.watchdog.on("restart", () => {
1176
- const E = l.watchdog.editor;
1177
- this.editorPromise = Promise.resolve(E), d.the.register(e, E);
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: g, hasPremium: _ } = await W(v);
1181
- g.push(
1182
- await st(
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) && g.push(
1189
- await ot(a)
1211
+ ), k(m) && p.push(
1212
+ await lt(a)
1190
1213
  );
1191
- const $ = [
1192
- ...await V(s, _),
1193
- B(u || {})
1194
- ].filter((l) => !A(l));
1195
- let y = {
1214
+ const x = [
1215
+ ...await q(o, I),
1216
+ _(u || {})
1217
+ ].filter((l) => !W(l));
1218
+ let b = {
1196
1219
  ...c,
1197
- ...z(e)
1220
+ ...F(e)
1198
1221
  };
1199
- k(m) && (y = y.main || "");
1200
- const R = await (async () => {
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 H = m === "decoupled" ? ["main"] : Object.keys(y);
1204
- q(l, H) || (l = await ut(e, H), y = {
1226
+ const A = m === "decoupled" ? ["main"] : Object.keys(b);
1227
+ K(l, A) || (l = await mt(e, A), b = {
1205
1228
  ...c,
1206
- ...z(e)
1229
+ ...F(e)
1207
1230
  });
1208
1231
  }
1209
1232
  k(m) && "main" in l && (l = l.main);
1210
- const E = {
1211
- ...I(f),
1212
- initialData: y,
1213
- licenseKey: C,
1214
- plugins: g,
1215
- language: s,
1216
- ...$.length && {
1217
- translations: $
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) ? p.create(l, E) : (await X({
1245
+ return !h || !(l instanceof HTMLElement) ? w.create(l, z) : (await Q({
1221
1246
  context: h,
1222
1247
  element: l,
1223
- creator: p,
1224
- config: E
1248
+ creator: w,
1249
+ config: z
1225
1250
  })).editor;
1226
1251
  })();
1227
- return k(m) && n && et(R, n), R;
1252
+ return k(m) && n && nt(M, n), M;
1228
1253
  }
1229
1254
  }
1230
- function q(i, t) {
1255
+ function K(i, t) {
1231
1256
  return t.every((e) => i[e]);
1232
1257
  }
1233
- async function ut(i, t) {
1234
- return Y(
1258
+ async function mt(i, t) {
1259
+ return J(
1235
1260
  () => {
1236
1261
  const e = j(i);
1237
- if (!q(e, t))
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 lt extends P {
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 = dt(e), s = n.view[a];
1263
- if (!s) {
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(s.element);
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 dt(i) {
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 mt = {
1288
- ckeditor5: ct,
1289
- "ckeditor5-context": nt,
1290
- "ckeditor5-ui-part": lt,
1291
- "ckeditor5-editable": at
1312
+ const wt = {
1313
+ ckeditor5: dt,
1314
+ "ckeditor5-context": st,
1315
+ "ckeditor5-ui-part": ht,
1316
+ "ckeditor5-editable": ct
1292
1317
  };
1293
- function ht() {
1294
- for (const [i, t] of Object.entries(mt))
1295
- U(i, t);
1318
+ function ft() {
1319
+ for (const [i, t] of Object.entries(wt))
1320
+ G(i, t);
1296
1321
  }
1297
- ht();
1322
+ ft();
1298
1323
  export {
1299
- P as ClassHook,
1300
- w as ContextsRegistry,
1301
- S as CustomEditorPluginsRegistry,
1302
- at as EditableComponentHook,
1303
- ct as EditorComponentHook,
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
- lt as UIPartComponentHook,
1306
- U as registerLivewireComponentHook
1330
+ ht as UIPartComponentHook,
1331
+ G as registerLivewireComponentHook
1307
1332
  };
1308
1333
  //# sourceMappingURL=index.mjs.map