ckeditor5-livewire 1.2.3 → 1.2.5

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
@@ -31,23 +31,23 @@ class v {
31
31
  return ["destroyed", "destroying"].includes(this.state);
32
32
  }
33
33
  }
34
- function _(i, t) {
34
+ function U(i, t) {
35
35
  const e = /* @__PURE__ */ new Map();
36
- window.Livewire?.hook("component.init", async ({ component: r, cleanup: n }) => {
36
+ window.Livewire?.hook("component.init", async ({ component: r, cleanup: a }) => {
37
37
  if (r.name !== i)
38
38
  return;
39
- const a = new t(r);
40
- e.set(r.id, a), n(async () => {
41
- a.state = "destroying", await a.destroyed(), a.state = "destroyed", e.delete(r.id);
42
- }), await a.mounted(), a.state = "mounted";
43
- }), window.Livewire?.hook("commit", async ({ component: r, succeed: n }) => {
44
- r.name === i && n(() => {
45
- const a = e.get(r.id);
46
- a?.state === "mounted" && a?.afterCommitSynced?.();
39
+ const n = new t(r);
40
+ e.set(r.id, n), a(async () => {
41
+ n.state = "destroying", await n.destroyed(), n.state = "destroyed", e.delete(r.id);
42
+ }), await n.mounted(), n.state = "mounted";
43
+ }), window.Livewire?.hook("commit", async ({ component: r, succeed: a }) => {
44
+ r.name === i && a(() => {
45
+ const n = e.get(r.id);
46
+ n?.state === "mounted" && n?.afterCommitSynced?.();
47
47
  });
48
48
  });
49
49
  }
50
- class H {
50
+ class A {
51
51
  /**
52
52
  * Map of registered items.
53
53
  */
@@ -74,8 +74,8 @@ class H {
74
74
  * @returns A promise that resolves with the result of the function.
75
75
  */
76
76
  execute(t, e, r) {
77
- const n = this.items.get(t), a = this.initializationErrors.get(t);
78
- return a ? (r?.(a), Promise.reject(a)) : n ? Promise.resolve(e(n)) : new Promise((s, o) => {
77
+ const a = this.items.get(t), n = this.initializationErrors.get(t);
78
+ return n ? (r?.(n), Promise.reject(n)) : a ? Promise.resolve(e(a)) : new Promise((s, o) => {
79
79
  const c = this.getPendingCallbacks(t);
80
80
  c.success.push(async (u) => {
81
81
  s(await e(u));
@@ -93,7 +93,7 @@ class H {
93
93
  throw new Error(`Item with ID "${t}" is already registered.`);
94
94
  this.resetErrors(t), this.items.set(t, e);
95
95
  const r = this.pendingCallbacks.get(t);
96
- r && (r.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.registerAsDefault(t, e), this.notifyWatchers();
96
+ r && (r.success.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.registerAsDefault(t, e), this.notifyWatchers();
97
97
  }
98
98
  /**
99
99
  * Registers an error for an item.
@@ -104,7 +104,7 @@ class H {
104
104
  error(t, e) {
105
105
  this.items.delete(t), this.initializationErrors.set(t, e);
106
106
  const r = this.pendingCallbacks.get(t);
107
- r && (r.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e), this.notifyWatchers();
107
+ r && (r.error.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e), this.notifyWatchers();
108
108
  }
109
109
  /**
110
110
  * Resets errors for an item.
@@ -221,15 +221,15 @@ function O(i, t) {
221
221
  }, i);
222
222
  };
223
223
  }
224
- function K(i, t) {
225
- const e = Object.entries(i).filter(([r, n]) => t(n, r));
224
+ function _(i, t) {
225
+ const e = Object.entries(i).filter(([r, a]) => t(a, r));
226
226
  return Object.fromEntries(e);
227
227
  }
228
- function j(i) {
228
+ function H(i) {
229
229
  return Object.keys(i).length === 0 && i.constructor === Object;
230
230
  }
231
231
  function S(i, t) {
232
- const e = Object.entries(i).map(([r, n]) => [r, t(n, r)]);
232
+ const e = Object.entries(i).map(([r, a]) => [r, t(a, r)]);
233
233
  return Object.fromEntries(e);
234
234
  }
235
235
  function P(i, t) {
@@ -238,66 +238,66 @@ function P(i, t) {
238
238
  const e = Object.keys(i), r = Object.keys(t);
239
239
  if (e.length !== r.length)
240
240
  return !1;
241
- for (const n of e)
242
- if (i[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
241
+ for (const a of e)
242
+ if (i[a] !== t[a] || !Object.prototype.hasOwnProperty.call(t, a))
243
243
  return !1;
244
244
  return !0;
245
245
  }
246
- function G() {
246
+ function K() {
247
247
  return Math.random().toString(36).substring(2);
248
248
  }
249
- function Y(i, {
249
+ function G(i, {
250
250
  timeOutAfter: t = 500,
251
251
  retryAfter: e = 100
252
252
  } = {}) {
253
- return new Promise((r, n) => {
254
- const a = Date.now();
253
+ return new Promise((r, a) => {
254
+ const n = Date.now();
255
255
  let s = null;
256
256
  const o = setTimeout(() => {
257
- n(s ?? new Error("Timeout"));
257
+ a(s ?? new Error("Timeout"));
258
258
  }, t), c = async () => {
259
259
  try {
260
260
  const u = await i();
261
261
  clearTimeout(o), r(u);
262
262
  } catch (u) {
263
- s = u, Date.now() - a > t ? n(u) : setTimeout(c, e);
263
+ s = u, Date.now() - n > t ? a(u) : setTimeout(c, e);
264
264
  }
265
265
  };
266
266
  c();
267
267
  });
268
268
  }
269
269
  const I = Symbol.for("context-editor-watchdog");
270
- async function X({ element: i, context: t, creator: e, config: r }) {
271
- const n = G();
270
+ async function Y({ element: i, context: t, creator: e, config: r }) {
271
+ const a = K();
272
272
  await t.add({
273
273
  creator: (c, u) => e.create(c, u),
274
- id: n,
274
+ id: a,
275
275
  sourceElementOrData: i,
276
276
  type: "editor",
277
277
  config: r
278
278
  });
279
- const a = t.getItem(n), s = {
279
+ const n = t.getItem(a), s = {
280
280
  state: "available",
281
- editorContextId: n,
281
+ editorContextId: a,
282
282
  context: t
283
283
  };
284
- a[I] = s;
284
+ n[I] = s;
285
285
  const o = t.destroy.bind(t);
286
286
  return t.destroy = async () => (s.state = "unavailable", o()), {
287
287
  ...s,
288
- editor: a
288
+ editor: n
289
289
  };
290
290
  }
291
- function J(i) {
291
+ function X(i) {
292
292
  return I in i ? i[I] : null;
293
293
  }
294
- function Q(i) {
294
+ function J(i) {
295
295
  return i.model.document.getRootNames().reduce((e, r) => (e[r] = i.getData({ rootName: r }), e), /* @__PURE__ */ Object.create({}));
296
296
  }
297
297
  function C(i) {
298
298
  return ["inline", "classic", "balloon", "decoupled"].includes(i);
299
299
  }
300
- function Z(i) {
300
+ function Q(i) {
301
301
  let t = i;
302
302
  for (; t; ) {
303
303
  for (const e of t.attributes)
@@ -307,7 +307,7 @@ function Z(i) {
307
307
  }
308
308
  return !1;
309
309
  }
310
- async function tt(i) {
310
+ async function Z(i) {
311
311
  const t = await import("ckeditor5"), r = {
312
312
  inline: t.InlineEditor,
313
313
  balloon: t.BalloonEditor,
@@ -379,14 +379,14 @@ class $ {
379
379
  return this.plugins.has(t);
380
380
  }
381
381
  }
382
- async function F(i) {
382
+ async function j(i) {
383
383
  const t = await import("ckeditor5");
384
384
  let e = null;
385
- const r = i.map(async (n) => {
386
- const a = await $.the.get(n);
387
- if (a)
388
- return a;
389
- const { [n]: s } = t;
385
+ const r = i.map(async (a) => {
386
+ const n = await $.the.get(a);
387
+ if (n)
388
+ return n;
389
+ const { [a]: s } = t;
390
390
  if (s)
391
391
  return s;
392
392
  if (!e)
@@ -395,35 +395,35 @@ async function F(i) {
395
395
  } catch (c) {
396
396
  console.error(`Failed to load premium package: ${c}`);
397
397
  }
398
- const { [n]: o } = e || {};
398
+ const { [a]: o } = e || {};
399
399
  if (o)
400
400
  return o;
401
- throw new Error(`Plugin "${n}" not found in base or premium packages.`);
401
+ throw new Error(`Plugin "${a}" not found in base or premium packages.`);
402
402
  });
403
403
  return {
404
404
  loadedPlugins: await Promise.all(r),
405
405
  hasPremium: !!e
406
406
  };
407
407
  }
408
- async function V(i, t) {
408
+ async function F(i, t) {
409
409
  const e = [i.ui, i.content];
410
410
  return await Promise.all(
411
411
  [
412
- W("ckeditor5", e),
412
+ L("ckeditor5", e),
413
413
  /* v8 ignore next */
414
- t && W("ckeditor5-premium-features", e)
415
- ].filter((n) => !!n)
416
- ).then((n) => n.flat());
414
+ t && L("ckeditor5-premium-features", e)
415
+ ].filter((a) => !!a)
416
+ ).then((a) => a.flat());
417
417
  }
418
- async function W(i, t) {
418
+ async function L(i, t) {
419
419
  return await Promise.all(
420
420
  t.filter((e) => e !== "en").map(async (e) => {
421
- const r = await et(i, e);
421
+ const r = await tt(i, e);
422
422
  return r?.default ?? r;
423
423
  }).filter(Boolean)
424
424
  );
425
425
  }
426
- async function et(i, t) {
426
+ async function tt(i, t) {
427
427
  try {
428
428
  if (i === "ckeditor5")
429
429
  switch (t) {
@@ -723,12 +723,18 @@ async function et(i, t) {
723
723
  return console.error(`Failed to load translation for ${i}/${t}:`, e), null;
724
724
  }
725
725
  }
726
- function q(i) {
726
+ function V(i) {
727
727
  return S(i, (t) => ({
728
728
  dictionary: t
729
729
  }));
730
730
  }
731
- function M(i) {
731
+ function x(i, t) {
732
+ if (C(t) && t !== "decoupled")
733
+ return document.getElementById(`${i}_editor`);
734
+ const e = q(i);
735
+ return S(e, ({ element: r }) => r);
736
+ }
737
+ function q(i) {
732
738
  return window.Livewire.all().filter(({ name: t, canonical: e }) => t === "ckeditor5-editable" && e.editorId === i).reduce((t, { canonical: e, el: r }) => ({
733
739
  ...t,
734
740
  [e.rootName]: {
@@ -737,60 +743,37 @@ function M(i) {
737
743
  }
738
744
  }), /* @__PURE__ */ Object.create({}));
739
745
  }
740
- function T(i, t) {
741
- if (t === "decoupled") {
742
- const { element: r } = N(i);
743
- return r;
744
- }
745
- if (C(t))
746
- return document.getElementById(`${i}_editor`);
747
- const e = M(i);
748
- return S(e, ({ element: r }) => r);
746
+ function W(i) {
747
+ const t = q(i), e = S(t, ({ content: r }) => r);
748
+ return _(e, (r) => typeof r == "string");
749
749
  }
750
- function A(i, t) {
751
- if (t === "decoupled") {
752
- const { content: n } = N(i);
753
- if (typeof n == "string")
754
- return {
755
- main: n
756
- };
757
- }
758
- const e = M(i), r = S(e, ({ content: n }) => n);
759
- return K(r, (n) => typeof n == "string");
760
- }
761
- function N(i) {
762
- const t = M(i).main;
763
- if (!t)
764
- throw new Error(`No "main" editable found for editor with ID "${i}".`);
765
- return t;
766
- }
767
- function x(i) {
750
+ function T(i) {
768
751
  if (!i || typeof i != "object")
769
752
  return i;
770
753
  if (Array.isArray(i))
771
- return i.map((r) => x(r));
754
+ return i.map((r) => T(r));
772
755
  const t = i;
773
756
  if (t.$element && typeof t.$element == "string") {
774
757
  const r = document.querySelector(t.$element);
775
758
  return r || console.warn(`Element not found for selector: ${t.$element}`), r || null;
776
759
  }
777
760
  const e = /* @__PURE__ */ Object.create(null);
778
- for (const [r, n] of Object.entries(i))
779
- e[r] = x(n);
761
+ for (const [r, a] of Object.entries(i))
762
+ e[r] = T(a);
780
763
  return e;
781
764
  }
782
- function rt(i, t) {
765
+ function et(i, t) {
783
766
  const { editing: e } = i;
784
767
  e.view.change((r) => {
785
768
  r.setStyle("height", `${t}px`, e.view.document.getRoot());
786
769
  });
787
770
  }
788
771
  const D = Symbol.for("elixir-editor-watchdog");
789
- async function it(i) {
772
+ async function rt(i) {
790
773
  const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(i);
791
774
  return e.setCreator(async (...r) => {
792
- const n = await i.create(...r);
793
- return n[D] = e, n;
775
+ const a = await i.create(...r);
776
+ return a[D] = e, a;
794
777
  }), {
795
778
  watchdog: e,
796
779
  Constructor: {
@@ -798,10 +781,10 @@ async function it(i) {
798
781
  }
799
782
  };
800
783
  }
801
- function nt(i) {
784
+ function it(i) {
802
785
  return D in i ? i[D] : null;
803
786
  }
804
- class y extends H {
787
+ class y extends A {
805
788
  static the = new y();
806
789
  }
807
790
  class at extends v {
@@ -813,14 +796,14 @@ class at extends v {
813
796
  * Mounts the context component.
814
797
  */
815
798
  async mounted() {
816
- const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: n, watchdogConfig: a, config: { plugins: s, ...o } } = r, { loadedPlugins: c, hasPremium: u } = await F(s ?? []), h = [
817
- ...await V(e, u),
818
- q(n || {})
819
- ].filter((d) => !j(d));
799
+ const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: a, watchdogConfig: n, config: { plugins: s, ...o } } = r, { loadedPlugins: c, hasPremium: u } = await j(s ?? []), h = [
800
+ ...await F(e, u),
801
+ V(a || {})
802
+ ].filter((d) => !H(d));
820
803
  this.contextPromise = (async () => {
821
804
  const { ContextWatchdog: d, Context: g } = await import("ckeditor5"), p = new d(g, {
822
805
  crashNumberLimit: 10,
823
- ...a
806
+ ...n
824
807
  });
825
808
  return await p.create({
826
809
  ...o,
@@ -849,10 +832,10 @@ class at extends v {
849
832
  }
850
833
  }
851
834
  }
852
- class w extends H {
835
+ class w extends A {
853
836
  static the = new w();
854
837
  }
855
- class st extends v {
838
+ class nt extends v {
856
839
  /**
857
840
  * The promise that resolves when the editable is mounted.
858
841
  */
@@ -861,7 +844,7 @@ class st extends v {
861
844
  * Mounts the editable component.
862
845
  */
863
846
  mounted() {
864
- const { editorId: t, rootName: e, content: r, saveDebounceMs: n } = this.canonical, a = this.element.querySelector("input");
847
+ const { editorId: t, rootName: e, content: r, saveDebounceMs: a } = this.canonical, n = this.element.querySelector("input");
865
848
  this.editorPromise = w.the.execute(t, (s) => {
866
849
  const { ui: o, editing: c, model: u } = s;
867
850
  if (u.document.getRoot(e)) {
@@ -879,13 +862,13 @@ class st extends v {
879
862
  data: r
880
863
  }
881
864
  });
882
- const l = this.element.querySelector("[data-cke-editable-content]"), h = o.view.createEditable(e, l);
865
+ const m = this.element.querySelector("[data-cke-editable-content]"), h = o.view.createEditable(e, m);
883
866
  o.addEditable(h), c.view.forceRender();
884
867
  const f = () => {
885
868
  const d = s.getData({ rootName: e });
886
- a && (a.value = d), this.$wire.set("content", d);
869
+ n && (n.value = d), this.$wire.set("content", d);
887
870
  };
888
- return s.model.document.on("change:data", O(n, f)), f(), s;
871
+ return s.model.document.on("change:data", O(a, f)), f(), s;
889
872
  });
890
873
  }
891
874
  /**
@@ -910,7 +893,7 @@ class st extends v {
910
893
  }
911
894
  }
912
895
  }
913
- async function ot({
896
+ async function st({
914
897
  saveDebounceMs: i,
915
898
  component: t
916
899
  }) {
@@ -932,60 +915,60 @@ async function ot({
932
915
  * Setups the content sync from Livewire to the editor.
933
916
  */
934
917
  setupContentServerSync() {
935
- const { editor: n } = this, { model: a, ui: { focusTracker: s } } = n;
918
+ const { editor: a } = this, { model: n, ui: { focusTracker: s } } = a;
936
919
  let o = null;
937
- n.on("afterCommitSynced", () => {
920
+ a.on("afterCommitSynced", () => {
938
921
  const { content: c } = t.canonical, u = this.getEditorRootsValues();
939
- if (Z(t.element)) {
922
+ if (Q(t.element)) {
940
923
  if (s.isFocused) {
941
924
  P(c, u) || (o = c);
942
925
  return;
943
926
  }
944
- P(c, u) || n.setData(c);
927
+ P(c, u) || a.setData(c);
945
928
  }
946
929
  }), Livewire.on("set-editor-content", ({ editorId: c, content: u }) => {
947
930
  if (c !== t.canonical.editorId)
948
931
  return;
949
- const l = this.getEditorRootsValues();
950
- P(l, u) || n.setData(u);
951
- }), a.document.on("change:data", () => {
932
+ const m = this.getEditorRootsValues();
933
+ P(m, u) || a.setData(u);
934
+ }), n.document.on("change:data", () => {
952
935
  o = null;
953
936
  }), s.on("change:isFocused", () => {
954
- !s.isFocused && o !== null && (n.setData(o), o = null);
937
+ !s.isFocused && o !== null && (a.setData(o), o = null);
955
938
  });
956
939
  }
957
940
  /**
958
941
  * Setups the content push event for the editor.
959
942
  */
960
943
  setupTypingContentPush() {
961
- const { model: n } = this.editor, { $wire: a } = t, s = () => {
944
+ const { model: a } = this.editor, { $wire: n } = t, s = () => {
962
945
  const o = this.getEditorRootsValues();
963
- P(o, t.canonical.content) || (a.set("content", o), a.dispatch("editor-content-changed", {
946
+ P(o, t.canonical.content ?? {}) || (n.set("content", o), n.dispatch("editor-content-changed", {
964
947
  editorId: t.canonical.editorId,
965
948
  content: o
966
949
  }));
967
950
  };
968
- n.document.on("change:data", O(i, s)), this.editor.once("ready", s);
951
+ a.document.on("change:data", O(i, s)), this.editor.once("ready", s);
969
952
  }
970
953
  /**
971
954
  * Setups the event push for the editor.
972
955
  */
973
956
  setupFocusableEventPush() {
974
- const { ui: n } = this.editor, { $wire: a } = t, s = () => {
957
+ const { ui: a } = this.editor, { $wire: n } = t, s = () => {
975
958
  const o = this.getEditorRootsValues();
976
- a.set("focused", n.focusTracker.isFocused), P(o, t.canonical.content) || a.set("content", o);
959
+ n.set("focused", a.focusTracker.isFocused), P(o, t.canonical.content ?? {}) || n.set("content", o);
977
960
  };
978
- n.focusTracker.on("change:isFocused", s);
961
+ a.focusTracker.on("change:isFocused", s);
979
962
  }
980
963
  /**
981
964
  * Gets the current values of all editor roots.
982
965
  */
983
966
  getEditorRootsValues() {
984
- return Q(this.editor);
967
+ return J(this.editor);
985
968
  }
986
969
  };
987
970
  }
988
- async function ct(i) {
971
+ async function ot(i) {
989
972
  const { Plugin: t } = await import("ckeditor5");
990
973
  return class extends t {
991
974
  /**
@@ -1006,8 +989,8 @@ async function ct(i) {
1006
989
  * Initializes the plugin.
1007
990
  */
1008
991
  afterInit() {
1009
- const { editor: r } = this, a = r.sourceElement.id.replace(/_editor$/, "");
1010
- this.input = document.getElementById(`${a}_input`), this.input && (r.model.document.on("change:data", O(i, () => this.sync())), r.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
992
+ const { editor: r } = this, n = r.sourceElement.id.replace(/_editor$/, "");
993
+ this.input = document.getElementById(`${n}_input`), this.input && (r.model.document.on("change:data", O(i, () => this.sync())), r.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1011
994
  }
1012
995
  /**
1013
996
  * Synchronizes the editor's content with the input field.
@@ -1026,7 +1009,7 @@ async function ct(i) {
1026
1009
  }
1027
1010
  };
1028
1011
  }
1029
- class ut extends v {
1012
+ class ct extends v {
1030
1013
  /**
1031
1014
  * The promise that resolves to the editor instance.
1032
1015
  */
@@ -1057,7 +1040,7 @@ class ut extends v {
1057
1040
  const t = await this.editorPromise;
1058
1041
  if (!t)
1059
1042
  return;
1060
- const e = J(t), r = nt(t);
1043
+ const e = X(t), r = it(t);
1061
1044
  e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : r ? await r.destroy() : await t.destroy();
1062
1045
  } finally {
1063
1046
  this.editorPromise = null;
@@ -1077,57 +1060,58 @@ class ut extends v {
1077
1060
  preset: t,
1078
1061
  editorId: e,
1079
1062
  contextId: r,
1080
- editableHeight: n,
1081
- saveDebounceMs: a,
1063
+ editableHeight: a,
1064
+ saveDebounceMs: n,
1082
1065
  language: s,
1083
1066
  watchdog: o,
1084
1067
  content: c
1085
1068
  } = this.canonical, {
1086
1069
  customTranslations: u,
1087
- editorType: l,
1070
+ editorType: m,
1088
1071
  licenseKey: h,
1089
1072
  config: { plugins: f, ...d }
1090
1073
  } = t;
1091
- let g = await tt(l);
1074
+ let g = await Z(m);
1092
1075
  const p = await (r ? y.the.waitFor(r) : null);
1093
1076
  if (o && !p) {
1094
- const m = await it(g);
1095
- ({ Constructor: g } = m), m.watchdog.on("restart", () => {
1096
- const k = m.watchdog.editor;
1077
+ const l = await rt(g);
1078
+ ({ Constructor: g } = l), l.watchdog.on("restart", () => {
1079
+ const k = l.watchdog.editor;
1097
1080
  this.editorPromise = Promise.resolve(k), w.the.register(e, k);
1098
1081
  });
1099
1082
  }
1100
- const { loadedPlugins: E, hasPremium: U } = await F(f);
1083
+ const { loadedPlugins: E, hasPremium: B } = await j(f);
1101
1084
  E.push(
1102
- await ot(
1085
+ await st(
1103
1086
  {
1104
- saveDebounceMs: a,
1087
+ saveDebounceMs: n,
1105
1088
  component: this
1106
1089
  }
1107
1090
  )
1108
- ), C(l) && E.push(
1109
- await ct(a)
1091
+ ), C(m) && E.push(
1092
+ await ot(n)
1110
1093
  );
1111
1094
  const z = [
1112
- ...await V(s, U),
1113
- q(u || {})
1114
- ].filter((m) => !j(m));
1095
+ ...await F(s, B),
1096
+ V(u || {})
1097
+ ].filter((l) => !H(l));
1115
1098
  let b = {
1116
1099
  ...c,
1117
- ...A(e, l)
1100
+ ...W(e)
1118
1101
  };
1119
- C(l) && (b = b.main || "");
1120
- const R = await (async () => {
1121
- let m = T(e, l);
1122
- if (mt(m, l)) {
1123
- const L = Object.keys(b);
1124
- B(m, L) || (m = await lt(e, l, L), b = {
1102
+ C(m) && (b = b.main || "");
1103
+ const M = await (async () => {
1104
+ let l = x(e, m);
1105
+ if (!(l instanceof HTMLElement) && !("main" in l)) {
1106
+ const R = m === "decoupled" ? ["main"] : Object.keys(b);
1107
+ N(l, R) || (l = await ut(e, m, R), b = {
1125
1108
  ...c,
1126
- ...A(e, l)
1109
+ ...W(e)
1127
1110
  });
1128
1111
  }
1112
+ C(m) && "main" in l && (l = l.main);
1129
1113
  const k = {
1130
- ...x(d),
1114
+ ...T(d),
1131
1115
  initialData: b,
1132
1116
  licenseKey: h,
1133
1117
  plugins: E,
@@ -1136,39 +1120,36 @@ class ut extends v {
1136
1120
  translations: z
1137
1121
  }
1138
1122
  };
1139
- return !p || !(m instanceof HTMLElement) ? g.create(m, k) : (await X({
1123
+ return !p || !(l instanceof HTMLElement) ? g.create(l, k) : (await Y({
1140
1124
  context: p,
1141
- element: m,
1125
+ element: l,
1142
1126
  creator: g,
1143
1127
  config: k
1144
1128
  })).editor;
1145
1129
  })();
1146
- return C(l) && n && rt(R, n), R;
1130
+ return C(m) && a && et(M, a), M;
1147
1131
  }
1148
1132
  }
1149
- function B(i, t) {
1133
+ function N(i, t) {
1150
1134
  return t.every((e) => i[e]);
1151
1135
  }
1152
- async function lt(i, t, e) {
1153
- return await Y(
1136
+ async function ut(i, t, e) {
1137
+ return await G(
1154
1138
  () => {
1155
- const r = T(i, t);
1156
- if (!B(r, e))
1139
+ const r = x(i, t);
1140
+ if (!N(r, e))
1157
1141
  throw new Error(
1158
1142
  `It looks like not all required root elements are present yet.
1159
1143
  * If you want to wait for them, ensure they are registered before editor initialization.
1160
1144
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
1161
- Missing roots: ${e.filter((n) => !r[n]).join(", ")}.`
1145
+ Missing roots: ${e.filter((a) => !r[a]).join(", ")}.`
1162
1146
  );
1163
1147
  return !0;
1164
1148
  },
1165
1149
  { timeOutAfter: 2e3, retryAfter: 100 }
1166
- ), T(i, t);
1167
- }
1168
- function mt(i, t) {
1169
- return !C(t) && typeof i == "object" && !(i instanceof HTMLElement);
1150
+ ), x(i, t);
1170
1151
  }
1171
- class dt extends v {
1152
+ class lt extends v {
1172
1153
  /**
1173
1154
  * The promise that resolves when the UI part is mounted.
1174
1155
  */
@@ -1179,7 +1160,7 @@ class dt extends v {
1179
1160
  async mounted() {
1180
1161
  const { editorId: t, name: e } = this.canonical;
1181
1162
  this.mountedPromise = w.the.execute(t, (r) => {
1182
- const { ui: n } = r, a = wt(e), s = n.view[a];
1163
+ const { ui: a } = r, n = mt(e), s = a.view[n];
1183
1164
  if (!s) {
1184
1165
  console.error(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1185
1166
  return;
@@ -1194,7 +1175,7 @@ class dt extends v {
1194
1175
  this.element.style.display = "none", await this.mountedPromise, this.mountedPromise = null, this.element.innerHTML = "";
1195
1176
  }
1196
1177
  }
1197
- function wt(i) {
1178
+ function mt(i) {
1198
1179
  switch (i) {
1199
1180
  case "toolbar":
1200
1181
  return "toolbar";
@@ -1204,15 +1185,15 @@ function wt(i) {
1204
1185
  return null;
1205
1186
  }
1206
1187
  }
1207
- const pt = {
1208
- ckeditor5: ut,
1188
+ const dt = {
1189
+ ckeditor5: ct,
1209
1190
  "ckeditor5-context": at,
1210
- "ckeditor5-ui-part": dt,
1211
- "ckeditor5-editable": st
1191
+ "ckeditor5-ui-part": lt,
1192
+ "ckeditor5-editable": nt
1212
1193
  };
1213
- function ht() {
1214
- for (const [i, t] of Object.entries(pt))
1215
- _(i, t);
1194
+ function wt() {
1195
+ for (const [i, t] of Object.entries(dt))
1196
+ U(i, t);
1216
1197
  }
1217
- ht();
1198
+ wt();
1218
1199
  //# sourceMappingURL=index.mjs.map