ckeditor5-phoenix 1.26.0 → 1.27.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.
Files changed (26) hide show
  1. package/dist/hooks/editor/editor.d.ts.map +1 -1
  2. package/dist/hooks/editor/types/editor-relaxed-constructor.type.d.ts +6 -0
  3. package/dist/hooks/editor/types/editor-relaxed-constructor.type.d.ts.map +1 -0
  4. package/dist/hooks/editor/types/index.d.ts +2 -0
  5. package/dist/hooks/editor/types/index.d.ts.map +1 -0
  6. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +10 -0
  7. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +1 -0
  8. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +12 -0
  9. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +1 -0
  10. package/dist/hooks/editor/utils/create-editor-in-context.d.ts +1 -3
  11. package/dist/hooks/editor/utils/create-editor-in-context.d.ts.map +1 -1
  12. package/dist/hooks/editor/utils/index.d.ts +2 -0
  13. package/dist/hooks/editor/utils/index.d.ts.map +1 -1
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.mjs +346 -296
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/src/hooks/editable.ts +1 -1
  20. package/src/hooks/editor/editor.ts +9 -6
  21. package/src/hooks/editor/types/editor-relaxed-constructor.type.ts +6 -0
  22. package/src/hooks/editor/types/index.ts +1 -0
  23. package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +47 -0
  24. package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +60 -0
  25. package/src/hooks/editor/utils/create-editor-in-context.ts +2 -5
  26. package/src/hooks/editor/utils/index.ts +2 -0
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  function q(r, t) {
2
2
  if (!r || r.size !== t.size)
3
3
  return !1;
4
- for (const [e, a] of r)
5
- if (!t.has(e) || t.get(e) !== a)
4
+ for (const [e, n] of r)
5
+ if (!t.has(e) || t.get(e) !== n)
6
6
  return !1;
7
7
  return !0;
8
8
  }
@@ -41,13 +41,13 @@ class Y {
41
41
  * @param onError Optional error callback.
42
42
  * @returns A promise that resolves with the result of the function.
43
43
  */
44
- execute(t, e, a) {
45
- const n = this.items.get(t), i = this.initializationErrors.get(t);
46
- return i ? (a?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : new Promise((s, c) => {
44
+ execute(t, e, n) {
45
+ const a = this.items.get(t), i = this.initializationErrors.get(t);
46
+ return i ? (n?.(i), Promise.reject(i)) : a ? Promise.resolve(e(a)) : new Promise((s, c) => {
47
47
  const o = this.getPendingCallbacks(t);
48
48
  o.success.push(async (u) => {
49
49
  s(await e(u));
50
- }), a ? o.error.push(a) : o.error.push(c);
50
+ }), n ? o.error.push(n) : o.error.push(c);
51
51
  });
52
52
  }
53
53
  /**
@@ -58,19 +58,19 @@ class Y {
58
58
  * @returns A function that stops observing and immediately runs any pending cleanup.
59
59
  */
60
60
  mountEffect(t, e) {
61
- let a, n, i = !1;
61
+ let n, a, i = !1;
62
62
  const s = this.watch((c) => {
63
63
  const o = c.get(t);
64
- if (o !== n && (a?.(), a = void 0, n = o, !!o))
64
+ if (o !== a && (n?.(), n = void 0, a = o, !!o))
65
65
  try {
66
66
  const u = e(o);
67
- i ? (u?.(), s()) : a = u;
67
+ i ? (u?.(), s()) : n = u;
68
68
  } catch (u) {
69
69
  throw console.error(u), u;
70
70
  }
71
71
  });
72
72
  return () => {
73
- i = !0, n && (s(), a?.(), a = void 0);
73
+ i = !0, a && (s(), n?.(), n = void 0);
74
74
  };
75
75
  }
76
76
  /**
@@ -84,8 +84,8 @@ class Y {
84
84
  if (this.items.has(t))
85
85
  throw new Error(`Item with ID "${t}" is already registered.`);
86
86
  this.resetErrors(t), this.items.set(t, e);
87
- const a = this.pendingCallbacks.get(t);
88
- a && (a.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
87
+ const n = this.pendingCallbacks.get(t);
88
+ n && (n.success.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
89
89
  });
90
90
  }
91
91
  /**
@@ -97,8 +97,8 @@ class Y {
97
97
  error(t, e) {
98
98
  this.batch(() => {
99
99
  this.items.delete(t), this.initializationErrors.set(t, e);
100
- const a = this.pendingCallbacks.get(t);
101
- a && (a.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
100
+ const n = this.pendingCallbacks.get(t);
101
+ n && (n.error.forEach((a) => a(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
102
102
  });
103
103
  }
104
104
  /**
@@ -154,8 +154,8 @@ class Y {
154
154
  * @returns A promise that resolves with the item instance.
155
155
  */
156
156
  waitFor(t) {
157
- return new Promise((e, a) => {
158
- this.execute(t, e, a);
157
+ return new Promise((e, n) => {
158
+ this.execute(t, e, n);
159
159
  });
160
160
  }
161
161
  /**
@@ -231,36 +231,36 @@ class Y {
231
231
  return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
232
232
  }
233
233
  }
234
- function at(r) {
234
+ function nt(r) {
235
235
  return r.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
236
236
  }
237
- function T(r, t) {
237
+ function I(r, t) {
238
238
  let e = null;
239
- return (...a) => {
239
+ return (...n) => {
240
240
  e && clearTimeout(e), e = setTimeout(() => {
241
- t(...a);
241
+ t(...n);
242
242
  }, r);
243
243
  };
244
244
  }
245
- function nt(r) {
245
+ function at(r) {
246
246
  if (Object.prototype.toString.call(r) !== "[object Object]")
247
247
  return !1;
248
248
  const t = Object.getPrototypeOf(r);
249
249
  return t === Object.prototype || t === null;
250
250
  }
251
- function I(r) {
251
+ function O(r) {
252
252
  if (Array.isArray(r))
253
- return r.map(I);
254
- if (nt(r)) {
253
+ return r.map(O);
254
+ if (at(r)) {
255
255
  const t = /* @__PURE__ */ Object.create(null);
256
- for (const [e, a] of Object.entries(r))
257
- t[at(e)] = I(a);
256
+ for (const [e, n] of Object.entries(r))
257
+ t[nt(e)] = O(n);
258
258
  return t;
259
259
  }
260
260
  return r;
261
261
  }
262
262
  function it(r, t) {
263
- const e = Object.entries(r).filter(([a, n]) => t(n, a));
263
+ const e = Object.entries(r).filter(([n, a]) => t(a, n));
264
264
  return Object.fromEntries(e);
265
265
  }
266
266
  function st() {
@@ -270,7 +270,7 @@ function st() {
270
270
  const t = document.cookie.match(/(?:^|; )_csrf_token=([^;]*)/);
271
271
  return t ? decodeURIComponent(t[1]) : null;
272
272
  }
273
- class D {
273
+ class S {
274
274
  /**
275
275
  * The current state of the hook.
276
276
  */
@@ -345,7 +345,7 @@ class D {
345
345
  this._beforeDestroyCallbacks = [];
346
346
  }
347
347
  }
348
- function S(r) {
348
+ function N(r) {
349
349
  return {
350
350
  /**
351
351
  * The mounted lifecycle callback for the LiveView hook object.
@@ -353,7 +353,7 @@ function S(r) {
353
353
  */
354
354
  async mounted() {
355
355
  const t = new r();
356
- this.el.instance = t, t.el = this.el, t.pushEvent = (a, n, i) => this.pushEvent?.(a, n, i), t.pushEventTo = (a, n, i, s) => this.pushEventTo?.(a, n, i, s), t.handleEvent = (a, n) => this.handleEvent?.(a, n), t.state = "mounting";
356
+ this.el.instance = t, t.el = this.el, t.pushEvent = (n, a, i) => this.pushEvent?.(n, a, i), t.pushEventTo = (n, a, i, s) => this.pushEventTo?.(n, a, i, s), t.handleEvent = (n, a) => this.handleEvent?.(n, a), t.state = "mounting";
357
357
  const e = await t.mounted?.();
358
358
  return t.state = "mounted", e;
359
359
  },
@@ -396,8 +396,8 @@ function J(r) {
396
396
  function ot(r) {
397
397
  return r == null;
398
398
  }
399
- function $(r, t) {
400
- const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
399
+ function j(r, t) {
400
+ const e = Object.entries(r).map(([n, a]) => [n, t(a, n)]);
401
401
  return Object.fromEntries(e);
402
402
  }
403
403
  function B(r) {
@@ -412,11 +412,11 @@ function ct(r) {
412
412
  function ut(r, t) {
413
413
  if (r === t)
414
414
  return !0;
415
- const e = Object.keys(r), a = Object.keys(t);
416
- if (e.length !== a.length)
415
+ const e = Object.keys(r), n = Object.keys(t);
416
+ if (e.length !== n.length)
417
417
  return !1;
418
- for (const n of e)
419
- if (r[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
418
+ for (const a of e)
419
+ if (r[a] !== t[a] || !Object.prototype.hasOwnProperty.call(t, a))
420
420
  return !1;
421
421
  return !0;
422
422
  }
@@ -427,35 +427,88 @@ function dt(r, {
427
427
  timeOutAfter: t = 500,
428
428
  retryAfter: e = 100
429
429
  } = {}) {
430
- return new Promise((a, n) => {
430
+ return new Promise((n, a) => {
431
431
  const i = Date.now();
432
432
  let s = null;
433
433
  const c = setTimeout(() => {
434
- n(s ?? new Error("Timeout"));
434
+ a(s ?? new Error("Timeout"));
435
435
  }, t), o = async () => {
436
436
  try {
437
437
  const u = await r();
438
- clearTimeout(c), a(u);
438
+ clearTimeout(c), n(u);
439
439
  } catch (u) {
440
- s = u, Date.now() - i > t ? n(u) : setTimeout(o, e);
440
+ s = u, Date.now() - i > t ? a(u) : setTimeout(o, e);
441
441
  }
442
442
  };
443
443
  o();
444
444
  });
445
445
  }
446
- function ht(r) {
446
+ function ht(r, t) {
447
+ const e = mt(r), n = /* @__PURE__ */ new Set([
448
+ ...Object.keys(e),
449
+ ...Object.keys(t.roots ?? {})
450
+ ]), a = Array.from(n).reduce((s, c) => ({
451
+ ...s,
452
+ [c]: {
453
+ ...t.roots?.[c],
454
+ ...c === "main" ? t.root : {},
455
+ /* v8 ignore next 5 */
456
+ ...c in e ? {
457
+ initialData: e[c]
458
+ } : {}
459
+ }
460
+ }), Object.create(t.roots || {})), i = {
461
+ ...t,
462
+ roots: a
463
+ };
464
+ return delete i.root, i;
465
+ }
466
+ function mt(r) {
467
+ return typeof r == "string" ? { main: r } : { ...r };
468
+ }
469
+ function pt(r, t, e) {
470
+ const n = ft(t);
471
+ if (!r.editorName || r.editorName === "ClassicEditor")
472
+ return {
473
+ ...e,
474
+ attachTo: n.main
475
+ };
476
+ const a = /* @__PURE__ */ new Set([
477
+ ...Object.keys(n),
478
+ ...Object.keys(e.roots ?? {})
479
+ ]), i = Array.from(a).reduce((c, o) => ({
480
+ ...c,
481
+ [o]: {
482
+ /* v8 ignore next */
483
+ ...e.roots?.[o],
484
+ ...o === "main" ? e.root : {},
485
+ /* v8 ignore next 5 */
486
+ ...o in n ? {
487
+ element: n[o]
488
+ } : {}
489
+ }
490
+ }), Object.create(e.roots || {})), s = {
491
+ ...e,
492
+ roots: i
493
+ };
494
+ return delete s.root, s;
495
+ }
496
+ function ft(r) {
497
+ return r instanceof HTMLElement ? { main: r } : { ...r };
498
+ }
499
+ function wt(r) {
447
500
  const t = [
448
501
  r.ui?.element,
449
502
  r.ui?.view?.toolbar?.element,
450
503
  r.ui?.view?.menuBarView?.element
451
504
  ].filter(Boolean);
452
505
  for (const i of t)
453
- n(i);
506
+ a(i);
454
507
  const e = r.ui?.view?.body?._bodyCollectionContainer;
455
- e?.isConnected && n(e);
456
- const a = r.editing?.view;
457
- if (a)
458
- for (const i of a.domRoots.values())
508
+ e?.isConnected && a(e);
509
+ const n = r.editing?.view;
510
+ if (n)
511
+ for (const i of n.domRoots.values())
459
512
  i instanceof HTMLElement && (i.removeAttribute("contenteditable"), i.removeAttribute("role"), i.removeAttribute("aria-label"), i.removeAttribute("aria-multiline"), i.removeAttribute("spellcheck"), i.classList.remove(
460
513
  "ck",
461
514
  "ck-content",
@@ -464,56 +517,55 @@ function ht(r) {
464
517
  "ck-editor__editable_inline",
465
518
  "ck-blurred",
466
519
  "ck-focused"
467
- ), n(i));
468
- function n(i) {
520
+ ), a(i));
521
+ function a(i) {
469
522
  i.hasAttribute("data-cke-controlled") ? i.innerHTML = "" : i.remove();
470
523
  }
471
524
  }
472
525
  const R = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
473
- async function mt({ element: r, context: t, creator: e, config: a }) {
526
+ async function gt({ context: r, creator: t, config: e }) {
474
527
  const n = lt();
475
- await t.add({
476
- creator: (o, u) => e.create(o, u),
528
+ await r.add({
529
+ creator: t.create.bind(t),
477
530
  id: n,
478
- sourceElementOrData: r,
479
531
  type: "editor",
480
- config: a
532
+ config: e
481
533
  });
482
- const i = t.getItem(n), s = {
534
+ const a = r.getItem(n), i = {
483
535
  state: "available",
484
536
  editorContextId: n,
485
- context: t
537
+ context: r
486
538
  };
487
- i[R] = s;
488
- const c = t.destroy.bind(t);
489
- return t.destroy = async () => (s.state = "unavailable", c()), {
490
- ...s,
491
- editor: i
539
+ a[R] = i;
540
+ const s = r.destroy.bind(r);
541
+ return r.destroy = async () => (i.state = "unavailable", s()), {
542
+ ...i,
543
+ editor: a
492
544
  };
493
545
  }
494
- function pt(r) {
546
+ function bt(r) {
495
547
  return R in r ? r[R] : null;
496
548
  }
497
549
  function F(r) {
498
550
  return "addEditable" in r.ui;
499
551
  }
500
- function A(r) {
552
+ function T(r) {
501
553
  return ["inline", "classic", "balloon", "decoupled"].includes(r);
502
554
  }
503
- async function ft(r) {
504
- const t = await import("ckeditor5"), a = {
555
+ async function yt(r) {
556
+ const t = await import("ckeditor5"), n = {
505
557
  inline: t.InlineEditor,
506
558
  balloon: t.BalloonEditor,
507
559
  classic: t.ClassicEditor,
508
560
  decoupled: t.DecoupledEditor,
509
561
  multiroot: t.MultiRootEditor
510
562
  }[r];
511
- if (!a)
563
+ if (!n)
512
564
  throw new Error(`Unsupported editor type: ${r}`);
513
- return a;
565
+ return n;
514
566
  }
515
- class _ {
516
- static the = new _();
567
+ class $ {
568
+ static the = new $();
517
569
  /**
518
570
  * Map of registered custom plugins.
519
571
  */
@@ -575,11 +627,11 @@ class _ {
575
627
  async function G(r) {
576
628
  const t = await import("ckeditor5");
577
629
  let e = null;
578
- const a = r.map(async (n) => {
579
- const i = await _.the.get(n);
630
+ const n = r.map(async (a) => {
631
+ const i = await $.the.get(a);
580
632
  if (i)
581
633
  return i;
582
- const { [n]: s } = t;
634
+ const { [a]: s } = t;
583
635
  if (s)
584
636
  return s;
585
637
  if (!e)
@@ -588,13 +640,13 @@ async function G(r) {
588
640
  } catch (o) {
589
641
  console.error(`Failed to load premium package: ${o}`);
590
642
  }
591
- const { [n]: c } = e || {};
643
+ const { [a]: c } = e || {};
592
644
  if (c)
593
645
  return c;
594
- throw new Error(`Plugin "${n}" not found in base or premium packages.`);
646
+ throw new Error(`Plugin "${a}" not found in base or premium packages.`);
595
647
  });
596
648
  return {
597
- loadedPlugins: await Promise.all(a),
649
+ loadedPlugins: await Promise.all(n),
598
650
  hasPremium: !!e
599
651
  };
600
652
  }
@@ -605,18 +657,18 @@ async function X(r, t) {
605
657
  L("ckeditor5", e),
606
658
  /* v8 ignore next */
607
659
  t && L("ckeditor5-premium-features", e)
608
- ].filter((n) => !!n)
609
- ).then((n) => n.flat());
660
+ ].filter((a) => !!a)
661
+ ).then((a) => a.flat());
610
662
  }
611
663
  async function L(r, t) {
612
664
  return await Promise.all(
613
665
  t.filter((e) => e !== "en").map(async (e) => {
614
- const a = await wt(r, e);
615
- return a?.default ?? a;
666
+ const n = await kt(r, e);
667
+ return n?.default ?? n;
616
668
  }).filter(Boolean)
617
669
  );
618
670
  }
619
- async function wt(r, t) {
671
+ async function kt(r, t) {
620
672
  try {
621
673
  if (r === "ckeditor5")
622
674
  switch (t) {
@@ -917,17 +969,17 @@ async function wt(r, t) {
917
969
  }
918
970
  }
919
971
  function Q(r) {
920
- return $(r, (t) => ({
972
+ return j(r, (t) => ({
921
973
  dictionary: t
922
974
  }));
923
975
  }
924
976
  function Z(r) {
925
977
  const t = tt(r);
926
- return $(t, ({ content: e }) => e);
978
+ return j(t, ({ content: e }) => e);
927
979
  }
928
980
  function W(r) {
929
- const t = tt(r), e = $(t, ({ initialValue: a }) => a);
930
- return it(e, (a) => typeof a == "string");
981
+ const t = tt(r), e = j(t, ({ initialValue: n }) => n);
982
+ return it(e, (n) => typeof n == "string");
931
983
  }
932
984
  function tt(r) {
933
985
  const t = document.querySelectorAll(
@@ -944,39 +996,39 @@ function tt(r) {
944
996
  initialValue: l
945
997
  }
946
998
  };
947
- }, /* @__PURE__ */ Object.create({})), a = document.querySelector(`[phx-hook="CKEditor5"][id="${r}"]`);
948
- if (!a)
999
+ }, /* @__PURE__ */ Object.create({})), n = document.querySelector(`[phx-hook="CKEditor5"][id="${r}"]`);
1000
+ if (!n)
949
1001
  return e;
950
- const n = a.getAttribute("data-cke-initial-value") || "", i = a.querySelector(`#${r}_editor `), s = e.main;
1002
+ const a = n.getAttribute("data-cke-initial-value") || "", i = n.querySelector(`#${r}_editor `), s = e.main;
951
1003
  return s ? {
952
1004
  ...e,
953
1005
  main: {
954
1006
  ...s,
955
- initialValue: s.initialValue || n
1007
+ initialValue: s.initialValue || a
956
1008
  }
957
1009
  } : i ? {
958
1010
  ...e,
959
1011
  main: {
960
1012
  content: i,
961
- initialValue: n
1013
+ initialValue: a
962
1014
  }
963
1015
  } : e;
964
1016
  }
965
1017
  const K = ["inline", "classic", "balloon", "decoupled", "multiroot"];
966
- function gt(r) {
1018
+ function Et(r) {
967
1019
  const t = r.getAttribute("data-cke-preset");
968
1020
  if (!t)
969
1021
  throw new Error('CKEditor5 hook requires a "cke-preset" attribute on the element.');
970
- const { type: e, config: a, license: n, watchdog: i, ...s } = JSON.parse(t);
971
- if (!e || !a || !n)
1022
+ const { type: e, config: n, license: a, watchdog: i, ...s } = JSON.parse(t);
1023
+ if (!e || !n || !a)
972
1024
  throw new Error('CKEditor5 hook configuration must include "editor", "config", and "license" properties.');
973
1025
  if (!K.includes(e))
974
1026
  throw new Error(`Invalid editor type: ${e}. Must be one of: ${K.join(", ")}.`);
975
1027
  return {
976
1028
  type: e,
977
- license: n,
1029
+ license: a,
978
1030
  watchdog: i,
979
- config: I(a),
1031
+ config: O(n),
980
1032
  customTranslations: s.customTranslations || s.custom_translations
981
1033
  };
982
1034
  }
@@ -984,74 +1036,74 @@ function x(r) {
984
1036
  if (!r || typeof r != "object")
985
1037
  return r;
986
1038
  if (Array.isArray(r))
987
- return r.map((a) => x(a));
1039
+ return r.map((n) => x(n));
988
1040
  const t = r;
989
1041
  if (t.$element && typeof t.$element == "string") {
990
- const a = document.querySelector(t.$element);
991
- return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
1042
+ const n = document.querySelector(t.$element);
1043
+ return n || console.warn(`Element not found for selector: ${t.$element}`), n || null;
992
1044
  }
993
1045
  const e = /* @__PURE__ */ Object.create(null);
994
- for (const [a, n] of Object.entries(r))
995
- e[a] = x(n);
1046
+ for (const [n, a] of Object.entries(r))
1047
+ e[n] = x(a);
996
1048
  return e;
997
1049
  }
998
- function O(r, t, e) {
1050
+ function D(r, t, e) {
999
1051
  if (!e || typeof e != "object")
1000
1052
  return e;
1001
1053
  if (Array.isArray(e))
1002
- return e.map((i) => O(r, t, i));
1003
- const a = e;
1004
- if (a.$translation && typeof a.$translation == "string") {
1005
- const i = a.$translation, s = yt(r, i, t);
1054
+ return e.map((i) => D(r, t, i));
1055
+ const n = e;
1056
+ if (n.$translation && typeof n.$translation == "string") {
1057
+ const i = n.$translation, s = vt(r, i, t);
1006
1058
  return s === void 0 && console.warn(`Translation not found for key: ${i}`), s !== void 0 ? s : null;
1007
1059
  }
1008
- const n = /* @__PURE__ */ Object.create(null);
1060
+ const a = /* @__PURE__ */ Object.create(null);
1009
1061
  for (const [i, s] of Object.entries(e))
1010
- n[i] = O(r, t, s);
1011
- return n;
1062
+ a[i] = D(r, t, s);
1063
+ return a;
1012
1064
  }
1013
- function yt(r, t, e) {
1014
- for (const a of r) {
1015
- const n = a[e];
1016
- if (n?.dictionary && t in n.dictionary)
1017
- return n.dictionary[t];
1065
+ function vt(r, t, e) {
1066
+ for (const n of r) {
1067
+ const a = n[e];
1068
+ if (a?.dictionary && t in a.dictionary)
1069
+ return a.dictionary[t];
1018
1070
  }
1019
1071
  }
1020
- function bt(r, t) {
1072
+ function Ct(r, t) {
1021
1073
  const { editing: e } = r;
1022
- e.view.change((a) => {
1023
- a.setStyle("height", `${t}px`, e.view.document.getRoot());
1074
+ e.view.change((n) => {
1075
+ n.setStyle("height", `${t}px`, e.view.document.getRoot());
1024
1076
  });
1025
1077
  }
1026
- const U = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
1027
- async function kt(r, t) {
1028
- const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
1078
+ const V = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
1079
+ async function Pt(r, t) {
1080
+ const { EditorWatchdog: e } = await import("ckeditor5"), n = new e(null, t ?? {
1029
1081
  crashNumberLimit: 10,
1030
1082
  minimumNonErrorTimePeriod: 5e3
1031
1083
  });
1032
- return a.setCreator(async () => {
1033
- const n = await r();
1034
- return n[U] = a, n;
1035
- }), a;
1084
+ return n.setCreator(async () => {
1085
+ const a = await r();
1086
+ return a[V] = n, a;
1087
+ }), n;
1036
1088
  }
1037
- function Et(r) {
1038
- return U in r ? r[U] : null;
1089
+ function At(r) {
1090
+ return V in r ? r[V] : null;
1039
1091
  }
1040
1092
  class y extends Y {
1041
1093
  static the = new y();
1042
1094
  }
1043
- function vt(r) {
1095
+ function Tt(r) {
1044
1096
  const t = r.getAttribute("data-cke-context");
1045
1097
  if (!t)
1046
1098
  throw new Error('CKEditor5 hook requires a "data-cke-context" attribute on the element.');
1047
- const { config: e, ...a } = JSON.parse(t);
1099
+ const { config: e, ...n } = JSON.parse(t);
1048
1100
  return {
1049
- config: I(e),
1050
- customTranslations: a.customTranslations || a.custom_translations,
1051
- watchdogConfig: a.watchdogConfig || a.watchdog_config
1101
+ config: O(e),
1102
+ customTranslations: n.customTranslations || n.custom_translations,
1103
+ watchdogConfig: n.watchdogConfig || n.watchdog_config
1052
1104
  };
1053
1105
  }
1054
- class Ct extends D {
1106
+ class It extends S {
1055
1107
  /**
1056
1108
  * The promise that resolves to the context instance.
1057
1109
  */
@@ -1060,9 +1112,9 @@ class Ct extends D {
1060
1112
  * Attributes for the context instance.
1061
1113
  */
1062
1114
  get attrs() {
1063
- const t = (a) => this.el.getAttribute(a) || null, e = {
1115
+ const t = (n) => this.el.getAttribute(n) || null, e = {
1064
1116
  id: this.el.id,
1065
- config: vt(this.el),
1117
+ config: Tt(this.el),
1066
1118
  language: {
1067
1119
  ui: t("data-cke-language") || "en",
1068
1120
  content: t("data-cke-content-language") || "en"
@@ -1079,29 +1131,29 @@ class Ct extends D {
1079
1131
  * Mounts the context component.
1080
1132
  */
1081
1133
  async mounted() {
1082
- const { id: t, language: e } = this.attrs, { customTranslations: a, watchdogConfig: n, config: { plugins: i, ...s } } = this.attrs.config, { loadedPlugins: c, hasPremium: o } = await G(i ?? []), l = [
1134
+ const { id: t, language: e } = this.attrs, { customTranslations: n, watchdogConfig: a, config: { plugins: i, ...s } } = this.attrs.config, { loadedPlugins: c, hasPremium: o } = await G(i ?? []), l = [
1083
1135
  ...await X(e, o),
1084
- Q(a?.dictionary || {})
1136
+ Q(n?.dictionary || {})
1085
1137
  ].filter((m) => !J(m));
1086
1138
  let d = x(s);
1087
- d = O([...l].reverse(), e.ui, d), this.contextPromise = (async () => {
1088
- const { ContextWatchdog: m, Context: v } = await import("ckeditor5"), g = new m(v, {
1139
+ d = D([...l].reverse(), e.ui, d), this.contextPromise = (async () => {
1140
+ const { ContextWatchdog: m, Context: E } = await import("ckeditor5"), b = new m(E, {
1089
1141
  crashNumberLimit: 10,
1090
- ...n
1142
+ ...a
1091
1143
  });
1092
- return await g.create({
1144
+ return await b.create({
1093
1145
  ...d,
1094
1146
  language: e,
1095
1147
  plugins: c,
1096
1148
  ...l.length && {
1097
1149
  translations: l
1098
1150
  }
1099
- }), g.on("itemError", (...C) => {
1100
- console.error("Context item error:", ...C);
1101
- }), g;
1151
+ }), b.on("itemError", (...P) => {
1152
+ console.error("Context item error:", ...P);
1153
+ }), b;
1102
1154
  })();
1103
- const w = await this.contextPromise;
1104
- this.isBeingDestroyed() || y.the.register(t, w);
1155
+ const g = await this.contextPromise;
1156
+ this.isBeingDestroyed() || y.the.register(t, g);
1105
1157
  }
1106
1158
  /**
1107
1159
  * Destroys the context component. Unmounts root from the editor.
@@ -1116,39 +1168,39 @@ class Ct extends D {
1116
1168
  }
1117
1169
  }
1118
1170
  }
1119
- function Pt(r) {
1171
+ function Ot(r) {
1120
1172
  return r.hasAttribute("data-cke-context");
1121
1173
  }
1122
- function At(r) {
1174
+ function xt(r) {
1123
1175
  let t = r;
1124
1176
  for (; t; ) {
1125
- if (Pt(t))
1177
+ if (Ot(t))
1126
1178
  return t;
1127
1179
  t = t.parentElement;
1128
1180
  }
1129
1181
  return null;
1130
1182
  }
1131
- async function Tt(r) {
1132
- const t = At(r);
1183
+ async function Dt(r) {
1184
+ const t = xt(r);
1133
1185
  return t ? y.the.waitFor(t.id) : null;
1134
1186
  }
1135
- const It = S(Ct);
1136
- function xt(r, t) {
1187
+ const St = N(It);
1188
+ function Nt(r, t) {
1137
1189
  const e = /* @__PURE__ */ new Set();
1138
- return (a) => {
1139
- let n = !1;
1190
+ return (n) => {
1191
+ let a = !1;
1140
1192
  return r.model.enqueueChange({ isUndoable: !1 }, (i) => {
1141
1193
  const s = r.model.document.getRoot(t);
1142
1194
  if (s) {
1143
1195
  for (const c of e)
1144
- a && c in a || (i.removeAttribute(c, s), e.delete(c), n = !0);
1145
- for (const [c, o] of Object.entries(a ?? {}))
1146
- i.setAttribute(c, o, s), e.add(c), n = !0;
1196
+ n && c in n || (i.removeAttribute(c, s), e.delete(c), a = !0);
1197
+ for (const [c, o] of Object.entries(n ?? {}))
1198
+ i.setAttribute(c, o, s), e.add(c), a = !0;
1147
1199
  }
1148
- }), n;
1200
+ }), a;
1149
1201
  };
1150
1202
  }
1151
- async function Ot() {
1203
+ async function Mt() {
1152
1204
  const { Plugin: r, FileRepository: t } = await import("ckeditor5");
1153
1205
  return class extends r {
1154
1206
  /**
@@ -1164,15 +1216,15 @@ async function Ot() {
1164
1216
  * Initializes the plugin.
1165
1217
  */
1166
1218
  init() {
1167
- const { editor: a } = this, { plugins: n, config: i } = a, s = i.get("phoenixUpload.url");
1168
- if (!s || n.has("SimpleUploadAdapter") || n.has("Base64UploadAdapter") || n.has("CKFinderUploadAdapter"))
1219
+ const { editor: n } = this, { plugins: a, config: i } = n, s = i.get("phoenixUpload.url");
1220
+ if (!s || a.has("SimpleUploadAdapter") || a.has("Base64UploadAdapter") || a.has("CKFinderUploadAdapter"))
1169
1221
  return;
1170
- const c = n.get(t);
1171
- c.createUploadAdapter = (o) => new Dt(o, s);
1222
+ const c = a.get(t);
1223
+ c.createUploadAdapter = (o) => new Rt(o, s);
1172
1224
  }
1173
1225
  };
1174
1226
  }
1175
- class Dt {
1227
+ class Rt {
1176
1228
  loader;
1177
1229
  uploadUrl;
1178
1230
  abortController = null;
@@ -1187,12 +1239,12 @@ class Dt {
1187
1239
  this.abortController = new AbortController();
1188
1240
  const e = new FormData();
1189
1241
  e.append("file", t), t.size && (this.loader.uploadTotal = t.size, this.loader.uploaded = 0);
1190
- const a = {}, n = st();
1191
- n && (a["X-CSRF-Token"] = n);
1242
+ const n = {}, a = st();
1243
+ a && (n["X-CSRF-Token"] = a);
1192
1244
  try {
1193
1245
  const i = await fetch(this.uploadUrl, {
1194
1246
  method: "POST",
1195
- headers: a,
1247
+ headers: n,
1196
1248
  body: e,
1197
1249
  signal: this.abortController.signal
1198
1250
  });
@@ -1220,7 +1272,7 @@ class Dt {
1220
1272
  this.abortController?.abort(), this.abortController = null;
1221
1273
  }
1222
1274
  }
1223
- async function St({
1275
+ async function Vt({
1224
1276
  editorId: r,
1225
1277
  saveDebounceMs: t
1226
1278
  }) {
@@ -1244,15 +1296,15 @@ async function St({
1244
1296
  * Initializes the plugin.
1245
1297
  */
1246
1298
  afterInit() {
1247
- const { editor: n } = this;
1248
- this.input = document.getElementById(`${r}_input`), this.input && (n.model.document.on("change:data", T(t, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1299
+ const { editor: a } = this;
1300
+ this.input = document.getElementById(`${r}_input`), this.input && (a.model.document.on("change:data", I(t, () => this.sync())), a.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
1249
1301
  }
1250
1302
  /**
1251
1303
  * Synchronizes the editor's content with the input field.
1252
1304
  */
1253
1305
  sync = () => {
1254
- const n = this.editor.getData();
1255
- this.input.value = n, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
1306
+ const a = this.editor.getData();
1307
+ this.input.value = a, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
1256
1308
  };
1257
1309
  /**
1258
1310
  * Destroys the plugin.
@@ -1262,9 +1314,9 @@ async function St({
1262
1314
  }
1263
1315
  };
1264
1316
  }
1265
- const M = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
1266
- async function Nt(r) {
1267
- const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: a, events: n, pushEvent: i, handleEvent: s } = r;
1317
+ const U = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
1318
+ async function Ut(r) {
1319
+ const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: n, events: a, pushEvent: i, handleEvent: s } = r;
1268
1320
  return class extends t {
1269
1321
  /**
1270
1322
  * The name of the plugin.
@@ -1277,10 +1329,10 @@ async function Nt(r) {
1277
1329
  */
1278
1330
  init() {
1279
1331
  const { editor: o } = this;
1280
- n.change && this.setupTypingContentPush(), n.blur && this.setupEventPush("blur"), n.focus && this.setupEventPush("focus"), n.ready && this.editor.once("ready", () => {
1332
+ a.change && this.setupTypingContentPush(), a.blur && this.setupEventPush("blur"), a.focus && this.setupEventPush("focus"), a.ready && this.editor.once("ready", () => {
1281
1333
  i("ckeditor5:ready", {
1282
1334
  editorId: e,
1283
- data: V(o)
1335
+ data: M(o)
1284
1336
  });
1285
1337
  }), s("ckeditor5:set-data", ({ editorId: u, data: l }) => {
1286
1338
  (ot(u) || u === e) && o.setData(l);
@@ -1295,7 +1347,7 @@ async function Nt(r) {
1295
1347
  const d = () => {
1296
1348
  if (l)
1297
1349
  return;
1298
- const m = V(o);
1350
+ const m = M(o);
1299
1351
  (!u || !ut(u, m)) && (i(
1300
1352
  "ckeditor5:change",
1301
1353
  {
@@ -1303,13 +1355,13 @@ async function Nt(r) {
1303
1355
  data: m
1304
1356
  }
1305
1357
  ), u = m);
1306
- }, w = T(a, d);
1307
- o.model.document.on("change:data", T(10, (m) => {
1308
- if (Vt(m)) {
1358
+ }, g = I(n, d);
1359
+ o.model.document.on("change:data", I(10, (m) => {
1360
+ if (jt(m)) {
1309
1361
  u = null;
1310
1362
  return;
1311
1363
  }
1312
- o.ui.focusTracker.isFocused ? w() : d();
1364
+ o.ui.focusTracker.isFocused ? g() : d();
1313
1365
  })), o.once("ready", d), o.once("destroy", () => {
1314
1366
  l = !0;
1315
1367
  });
@@ -1324,7 +1376,7 @@ async function Nt(r) {
1324
1376
  `ckeditor5:${o}`,
1325
1377
  {
1326
1378
  editorId: e,
1327
- data: V(u)
1379
+ data: M(u)
1328
1380
  }
1329
1381
  );
1330
1382
  };
@@ -1332,17 +1384,17 @@ async function Nt(r) {
1332
1384
  }
1333
1385
  };
1334
1386
  }
1335
- function V(r) {
1336
- return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create({}));
1387
+ function M(r) {
1388
+ return r.model.document.getRootNames().reduce((e, n) => (e[n] = r.getData({ rootName: n }), e), /* @__PURE__ */ Object.create({}));
1337
1389
  }
1338
- function Vt(r) {
1339
- const t = r[M];
1340
- return delete r[M], !!t;
1390
+ function jt(r) {
1391
+ const t = r[U];
1392
+ return delete r[U], !!t;
1341
1393
  }
1342
- function Rt(r) {
1394
+ function $t(r) {
1343
1395
  let t = !1;
1344
- const e = (a) => {
1345
- t || (a[M] = !0);
1396
+ const e = (n) => {
1397
+ t || (n[U] = !0);
1346
1398
  };
1347
1399
  return r.model.document.once("change:data", e, { priority: "highest" }), () => {
1348
1400
  t = !0, r.model.document.off("change:data", e);
@@ -1403,11 +1455,11 @@ class et {
1403
1455
  constructor({
1404
1456
  el: t,
1405
1457
  editor: e,
1406
- rootName: a,
1407
- valueAttrName: n = "data-cke-value",
1458
+ rootName: n,
1459
+ valueAttrName: a = "data-cke-value",
1408
1460
  rootAttrsAttrName: i = "data-cke-root-attrs"
1409
1461
  }) {
1410
- this.el = t, this.editor = e, this.rootName = a, this.valueAttrName = n, this.rootAttrsAttrName = i;
1462
+ this.el = t, this.editor = e, this.rootName = n, this.valueAttrName = a, this.rootAttrsAttrName = i;
1411
1463
  const { value: s } = this.attrs;
1412
1464
  this.previousValue = s, this.setupSyncHandlers(e, this.rootName);
1413
1465
  }
@@ -1426,36 +1478,36 @@ class et {
1426
1478
  * However, if the editor is focused, we want to wait until it blurs to avoid disrupting the user while typing.
1427
1479
  */
1428
1480
  async updated() {
1429
- const { editor: t } = this, { value: e, rootAttributes: a } = this.attrs;
1481
+ const { editor: t } = this, { value: e, rootAttributes: n } = this.attrs;
1430
1482
  if (!t || t.state === "destroyed" || this.isDestroyed)
1431
1483
  return;
1432
- let n = () => {
1484
+ let a = () => {
1433
1485
  };
1434
1486
  t.model.enqueueChange({ isUndoable: !1 }, () => {
1435
- let i = this.attrsUpdater?.(a);
1436
- e !== this.previousValue && (this.previousValue = e, t.ui.focusTracker.isFocused ? this.pendingValue = e : (this.setRootValue(t, this.rootName, e), i = !0)), i && (n = Rt(t));
1437
- }), n();
1487
+ let i = this.attrsUpdater?.(n);
1488
+ e !== this.previousValue && (this.previousValue = e, t.ui.focusTracker.isFocused ? this.pendingValue = e : (this.setRootValue(t, this.rootName, e), i = !0)), i && (a = $t(t));
1489
+ }), a();
1438
1490
  }
1439
1491
  /**
1440
1492
  * Sets up focus-aware sync handlers on the editor.
1441
1493
  * Registers cleanup via onBeforeDestroy.
1442
1494
  */
1443
1495
  setupSyncHandlers(t, e) {
1444
- this.attrsUpdater = xt(t, e), this.attrsUpdater(this.attrs.rootAttributes);
1445
- const a = () => {
1496
+ this.attrsUpdater = Nt(t, e), this.attrsUpdater(this.attrs.rootAttributes);
1497
+ const n = () => {
1446
1498
  this.pendingValue = null;
1447
- }, n = () => {
1499
+ }, a = () => {
1448
1500
  !t.ui.focusTracker.isFocused && this.pendingValue !== null && (this.setRootValue(t, e, this.pendingValue), this.pendingValue = null);
1449
1501
  };
1450
- t.model.document.on("change:data", a), t.ui.focusTracker.on("change:isFocused", n), this.cleanupCallbacks.push(() => {
1451
- t.model.document.off("change:data", a), t.ui.focusTracker.off("change:isFocused", n);
1502
+ t.model.document.on("change:data", n), t.ui.focusTracker.on("change:isFocused", a), this.cleanupCallbacks.push(() => {
1503
+ t.model.document.off("change:data", n), t.ui.focusTracker.off("change:isFocused", a);
1452
1504
  });
1453
1505
  }
1454
1506
  /**
1455
1507
  * Sets the value of a specific root in the editor.
1456
1508
  */
1457
- setRootValue(t, e, a) {
1458
- t.getData({ rootName: e }) !== a && t.setData({ [e]: a });
1509
+ setRootValue(t, e, n) {
1510
+ t.getData({ rootName: e }) !== n && t.setData({ [e]: n });
1459
1511
  }
1460
1512
  /**
1461
1513
  * Disconnects the observer and cleans up editor event listeners.
@@ -1468,7 +1520,7 @@ class et {
1468
1520
  class h extends Y {
1469
1521
  static the = new h();
1470
1522
  }
1471
- class Ut extends D {
1523
+ class _t extends S {
1472
1524
  /**
1473
1525
  * The sentinel instance responsible for tracking and updating root values and attributes
1474
1526
  * for single-root editors.
@@ -1478,17 +1530,17 @@ class Ut extends D {
1478
1530
  * Attributes for the editor instance.
1479
1531
  */
1480
1532
  get attrs() {
1481
- const { el: t } = this, e = t.getAttribute.bind(t), a = t.hasAttribute.bind(t), n = {
1533
+ const { el: t } = this, e = t.getAttribute.bind(t), n = t.hasAttribute.bind(t), a = {
1482
1534
  editorId: e("id"),
1483
1535
  contextId: e("data-cke-context-id"),
1484
- preset: gt(t),
1536
+ preset: Et(t),
1485
1537
  editableHeight: B(e("data-cke-editable-height")),
1486
- watchdog: a("data-cke-watchdog"),
1538
+ watchdog: n("data-cke-watchdog"),
1487
1539
  events: {
1488
- change: a("data-cke-change-event"),
1489
- blur: a("data-cke-blur-event"),
1490
- focus: a("data-cke-focus-event"),
1491
- ready: a("data-cke-ready-event")
1540
+ change: n("data-cke-change-event"),
1541
+ blur: n("data-cke-blur-event"),
1542
+ focus: n("data-cke-focus-event"),
1543
+ ready: n("data-cke-ready-event")
1492
1544
  },
1493
1545
  saveDebounceMs: B(e("data-cke-save-debounce-ms")) ?? 400,
1494
1546
  language: {
@@ -1497,11 +1549,11 @@ class Ut extends D {
1497
1549
  }
1498
1550
  };
1499
1551
  return Object.defineProperty(this, "attrs", {
1500
- value: n,
1552
+ value: a,
1501
1553
  writable: !1,
1502
1554
  configurable: !1,
1503
1555
  enumerable: !0
1504
- }), n;
1556
+ }), a;
1505
1557
  }
1506
1558
  /**
1507
1559
  * Mounts the editor component.
@@ -1513,10 +1565,10 @@ class Ut extends D {
1513
1565
  const e = await this.createEditor();
1514
1566
  if (this.isBeingDestroyed())
1515
1567
  return;
1516
- const a = h.the.mountEffect(t, (n) => (n.once("destroy", () => {
1568
+ const n = h.the.mountEffect(t, (a) => (a.once("destroy", () => {
1517
1569
  h.the.unregister(t, !1);
1518
1570
  }, { priority: "highest" }), this.sentinel = new et({
1519
- editor: n,
1571
+ editor: a,
1520
1572
  el: this.el,
1521
1573
  rootName: "main",
1522
1574
  valueAttrName: "data-cke-initial-value",
@@ -1525,9 +1577,9 @@ class Ut extends D {
1525
1577
  this.sentinel?.destroy(), this.sentinel = null;
1526
1578
  }));
1527
1579
  this.onBeforeDestroy(async () => {
1528
- h.the.unregister(t), a();
1529
- const n = pt(e), i = Et(e);
1530
- n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : i ? await i.destroy() : await e.destroy();
1580
+ h.the.unregister(t), n();
1581
+ const a = bt(e), i = At(e);
1582
+ a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : i ? await i.destroy() : await e.destroy();
1531
1583
  }), h.the.register(t, e);
1532
1584
  } catch (e) {
1533
1585
  console.error(e), h.the.error(t, e);
@@ -1553,22 +1605,22 @@ class Ut extends D {
1553
1605
  const {
1554
1606
  preset: t,
1555
1607
  editorId: e,
1556
- contextId: a,
1557
- editableHeight: n,
1608
+ contextId: n,
1609
+ editableHeight: a,
1558
1610
  events: i,
1559
1611
  saveDebounceMs: s,
1560
1612
  language: c,
1561
1613
  watchdog: o
1562
- } = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins: w, ...m } } = t, v = await ft(l), g = await (a ? y.the.waitFor(a) : Tt(this.el)), C = async () => {
1563
- const { loadedPlugins: f, hasPremium: P } = await G(w);
1564
- A(l) && f.push(
1565
- await St({
1614
+ } = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins: g, ...m } } = t, E = await yt(l), b = await (n ? y.the.waitFor(n) : Dt(this.el)), P = async () => {
1615
+ const { loadedPlugins: p, hasPremium: A } = await G(g);
1616
+ T(l) && p.push(
1617
+ await Vt({
1566
1618
  editorId: e,
1567
1619
  saveDebounceMs: s
1568
1620
  })
1569
- ), f.push(
1621
+ ), p.push(
1570
1622
  ...await Promise.all([
1571
- Nt(
1623
+ Ut(
1572
1624
  {
1573
1625
  editorId: e,
1574
1626
  saveDebounceMs: s,
@@ -1577,59 +1629,57 @@ class Ut extends D {
1577
1629
  handleEvent: this.handleEvent.bind(this)
1578
1630
  }
1579
1631
  ),
1580
- Ot()
1632
+ Mt()
1581
1633
  ])
1582
1634
  );
1583
- const b = [
1584
- ...await X(c, P),
1635
+ const k = [
1636
+ ...await X(c, A),
1585
1637
  Q(u?.dictionary || {})
1586
- ].filter((E) => !J(E));
1587
- let k = W(e);
1588
- A(l) && (k = k.main || "");
1589
- let p = Z(e);
1590
- if (!(p instanceof HTMLElement) && !("main" in p)) {
1591
- const E = l === "decoupled" ? ["main"] : Object.keys(k);
1592
- rt(p, E) || (p = await Mt(e, E), k = W(e));
1638
+ ].filter((C) => !J(C));
1639
+ let v = W(e);
1640
+ T(l) && (v = v.main || "");
1641
+ let f = Z(e);
1642
+ if (!(f instanceof HTMLElement) && !("main" in f)) {
1643
+ const C = l === "decoupled" ? ["main"] : Object.keys(v);
1644
+ rt(f, C) || (f = await zt(e, C), v = W(e));
1593
1645
  }
1594
- A(l) && "main" in p && (p = p.main);
1595
- let N = x(m);
1596
- N = O([...b].reverse(), c.ui, N);
1597
- const H = {
1598
- ...N,
1599
- initialData: k,
1646
+ T(l) && "main" in f && (f = f.main);
1647
+ let w = { ...m };
1648
+ w = x(w), w = D([...k].reverse(), c.ui, w), w = pt(E, f, w), w = ht(v, w);
1649
+ const z = {
1650
+ ...w,
1600
1651
  licenseKey: d.key,
1601
- plugins: f,
1652
+ plugins: p,
1602
1653
  language: c,
1603
- ...b.length && {
1604
- translations: b
1654
+ ...k.length && {
1655
+ translations: k
1605
1656
  }
1606
- }, j = await (async () => !g || !(p instanceof HTMLElement) ? v.create(p, H) : (await mt({
1607
- context: g,
1608
- element: p,
1609
- creator: v,
1610
- config: H
1657
+ }, H = await (async () => !b || !(f instanceof HTMLElement) ? E.create(z) : (await gt({
1658
+ context: b,
1659
+ creator: E,
1660
+ config: z
1611
1661
  })).editor)();
1612
- return A(l) && n && bt(j, n), j;
1662
+ return T(l) && a && Ct(H, a), H;
1613
1663
  };
1614
- if (o && !g) {
1615
- const f = await kt(C, t.watchdog);
1616
- return f.on("error", (P, { causesRestart: z }) => {
1617
- if (z) {
1618
- const b = h.the.getItem(e);
1619
- b && (ht(b), h.the.unregister(e));
1664
+ if (o && !b) {
1665
+ const p = await Pt(P, t.watchdog);
1666
+ return p.on("error", (A, { causesRestart: _ }) => {
1667
+ if (_) {
1668
+ const k = h.the.getItem(e);
1669
+ k && (wt(k), h.the.unregister(e));
1620
1670
  }
1621
- }), f.on("restart", () => {
1622
- const P = f.editor;
1623
- h.the.register(e, P);
1624
- }), await f.create({}), f.editor;
1671
+ }), p.on("restart", () => {
1672
+ const A = p.editor;
1673
+ h.the.register(e, A);
1674
+ }), await p.create({}), p.editor;
1625
1675
  }
1626
- return C();
1676
+ return P();
1627
1677
  }
1628
1678
  }
1629
1679
  function rt(r, t) {
1630
1680
  return t.every((e) => r[e]);
1631
1681
  }
1632
- async function Mt(r, t) {
1682
+ async function zt(r, t) {
1633
1683
  return dt(
1634
1684
  () => {
1635
1685
  const e = Z(r);
@@ -1638,15 +1688,15 @@ async function Mt(r, t) {
1638
1688
  `It looks like not all required root elements are present yet.
1639
1689
  * If you want to wait for them, ensure they are registered before editor initialization.
1640
1690
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
1641
- Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
1691
+ Missing roots: ${t.filter((n) => !e[n]).join(", ")}.`
1642
1692
  );
1643
1693
  return e;
1644
1694
  },
1645
1695
  { timeOutAfter: 2e3, retryAfter: 100 }
1646
1696
  );
1647
1697
  }
1648
- const $t = S(Ut);
1649
- class _t extends D {
1698
+ const Ht = N(_t);
1699
+ class qt extends S {
1650
1700
  /**
1651
1701
  * The sentinel instance responsible for tracking and updating root values and attributes.
1652
1702
  */
@@ -1672,32 +1722,32 @@ class _t extends D {
1672
1722
  * Mounts the editable component.
1673
1723
  */
1674
1724
  mounted() {
1675
- const { editableId: t, editorId: e, rootName: a, initialValue: n } = this.attrs, i = h.the.mountEffect(e, (s) => {
1725
+ const { editableId: t, editorId: e, rootName: n, initialValue: a } = this.attrs, i = h.the.mountEffect(e, (s) => {
1676
1726
  const c = this.el.querySelector("[data-cke-editable-content]");
1677
1727
  if (this.isBeingDestroyed())
1678
1728
  return;
1679
1729
  const o = this.el.querySelector(`#${t}_input`);
1680
- if (F(s) && !s.model.document.getRoot(a)) {
1730
+ if (F(s) && !s.model.document.getRoot(n)) {
1681
1731
  const { ui: l, editing: d } = s;
1682
- s.addRoot(a, {
1732
+ s.addRoot(n, {
1683
1733
  isUndoable: !1,
1684
- data: n
1734
+ initialData: a
1685
1735
  });
1686
- const w = l.view.createEditable(a, c);
1687
- l.addEditable(w), d.view.forceRender();
1736
+ const g = l.view.createEditable(n, c);
1737
+ l.addEditable(g), d.view.forceRender();
1688
1738
  }
1689
1739
  this.sentinel = new et({
1690
1740
  el: this.el,
1691
1741
  editor: s,
1692
- rootName: a,
1742
+ rootName: n,
1693
1743
  valueAttrName: "data-cke-editable-initial-value",
1694
1744
  rootAttrsAttrName: "data-cke-editable-root-attrs"
1695
1745
  });
1696
- const u = o ? Ht(o, s, a) : null;
1746
+ const u = o ? Ft(o, s, n) : null;
1697
1747
  return () => {
1698
1748
  if (u?.(), this.sentinel?.destroy(), this.sentinel = null, s.state !== "destroyed") {
1699
- const l = s.model.document.getRoot(a);
1700
- l && F(s) && (s.ui.view.editables[a] && s.detachEditable(l), l.isAttached() && s.detachRoot(a, !1));
1749
+ const l = s.model.document.getRoot(n);
1750
+ l && F(s) && (s.ui.view.editables[n] && s.detachEditable(l), l.isAttached() && s.detachRoot(n, !1));
1701
1751
  }
1702
1752
  };
1703
1753
  });
@@ -1712,16 +1762,16 @@ class _t extends D {
1712
1762
  this.sentinel?.updated();
1713
1763
  }
1714
1764
  }
1715
- const zt = S(_t);
1716
- function Ht(r, t, e) {
1717
- const a = () => {
1765
+ const Bt = N(qt);
1766
+ function Ft(r, t, e) {
1767
+ const n = () => {
1718
1768
  r.value = t.getData({ rootName: e });
1719
- }, n = T(200, a);
1720
- return t.model.document.on("change:data", n), a(), () => {
1721
- t.model.document.off("change:data", n);
1769
+ }, a = I(200, n);
1770
+ return t.model.document.on("change:data", a), n(), () => {
1771
+ t.model.document.off("change:data", a);
1722
1772
  };
1723
1773
  }
1724
- class jt extends D {
1774
+ class Lt extends S {
1725
1775
  /**
1726
1776
  * Attributes for the editable instance.
1727
1777
  */
@@ -1741,10 +1791,10 @@ class jt extends D {
1741
1791
  * Mounts the UI part component.
1742
1792
  */
1743
1793
  mounted() {
1744
- const { editorId: t, name: e } = this.attrs, a = h.the.mountEffect(t, (n) => {
1794
+ const { editorId: t, name: e } = this.attrs, n = h.the.mountEffect(t, (a) => {
1745
1795
  if (this.isBeingDestroyed())
1746
1796
  return;
1747
- const { ui: i } = n, s = qt(e), c = i.view[s];
1797
+ const { ui: i } = a, s = Wt(e), c = i.view[s];
1748
1798
  if (!c) {
1749
1799
  console.error(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
1750
1800
  return;
@@ -1754,11 +1804,11 @@ class jt extends D {
1754
1804
  };
1755
1805
  });
1756
1806
  this.onBeforeDestroy(() => {
1757
- this.el.style.display = "none", a();
1807
+ this.el.style.display = "none", n();
1758
1808
  });
1759
1809
  }
1760
1810
  }
1761
- function qt(r) {
1811
+ function Wt(r) {
1762
1812
  switch (r) {
1763
1813
  case "toolbar":
1764
1814
  return "toolbar";
@@ -1768,18 +1818,18 @@ function qt(r) {
1768
1818
  return null;
1769
1819
  }
1770
1820
  }
1771
- const Bt = S(jt), Kt = {
1772
- CKEditor5: $t,
1773
- CKEditable: zt,
1774
- CKUIPart: Bt,
1775
- CKContext: It
1821
+ const Kt = N(Lt), Xt = {
1822
+ CKEditor5: Ht,
1823
+ CKEditable: Bt,
1824
+ CKUIPart: Kt,
1825
+ CKContext: St
1776
1826
  };
1777
1827
  export {
1778
1828
  y as ContextsRegistry,
1779
- _ as CustomEditorPluginsRegistry,
1829
+ $ as CustomEditorPluginsRegistry,
1780
1830
  h as EditorsRegistry,
1781
- Kt as Hooks,
1782
- pt as unwrapEditorContext,
1783
- Et as unwrapEditorWatchdog
1831
+ Xt as Hooks,
1832
+ bt as unwrapEditorContext,
1833
+ At as unwrapEditorWatchdog
1784
1834
  };
1785
1835
  //# sourceMappingURL=index.mjs.map