ckeditor5-phoenix 1.25.0 → 1.26.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,8 +1,8 @@
1
- function q(a, t) {
2
- if (!a || a.size !== t.size)
1
+ function q(r, t) {
2
+ if (!r || r.size !== t.size)
3
3
  return !1;
4
- for (const [e, r] of a)
5
- if (!t.has(e) || t.get(e) !== r)
4
+ for (const [e, a] of r)
5
+ if (!t.has(e) || t.get(e) !== a)
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, r) {
44
+ execute(t, e, a) {
45
45
  const n = this.items.get(t), i = this.initializationErrors.get(t);
46
- return i ? (r?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : new Promise((s, c) => {
46
+ return i ? (a?.(i), Promise.reject(i)) : n ? Promise.resolve(e(n)) : 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
- }), r ? o.error.push(r) : o.error.push(c);
50
+ }), a ? o.error.push(a) : 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 r, n, i = !1;
61
+ let a, n, i = !1;
62
62
  const s = this.watch((c) => {
63
63
  const o = c.get(t);
64
- if (o !== n && (r?.(), r = void 0, n = o, !!o))
64
+ if (o !== n && (a?.(), a = void 0, n = o, !!o))
65
65
  try {
66
66
  const u = e(o);
67
- i ? (u?.(), s()) : r = u;
67
+ i ? (u?.(), s()) : a = u;
68
68
  } catch (u) {
69
69
  throw console.error(u), u;
70
70
  }
71
71
  });
72
72
  return () => {
73
- i = !0, n && (s(), r?.(), r = void 0);
73
+ i = !0, n && (s(), a?.(), a = 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 r = this.pendingCallbacks.get(t);
88
- r && (r.success.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, 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);
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 r = this.pendingCallbacks.get(t);
101
- r && (r.error.forEach((n) => n(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, 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);
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, r) => {
158
- this.execute(t, e, r);
157
+ return new Promise((e, a) => {
158
+ this.execute(t, e, a);
159
159
  });
160
160
  }
161
161
  /**
@@ -231,42 +231,42 @@ class Y {
231
231
  return e || (e = { success: [], error: [] }, this.pendingCallbacks.set(t, e)), e;
232
232
  }
233
233
  }
234
- function at(a) {
235
- return a.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
234
+ function at(r) {
235
+ return r.replace(/[-_\s]+(.)?/g, (t, e) => e ? e.toUpperCase() : "").replace(/^./, (t) => t.toLowerCase());
236
236
  }
237
- function T(a, t) {
237
+ function T(r, t) {
238
238
  let e = null;
239
- return (...r) => {
239
+ return (...a) => {
240
240
  e && clearTimeout(e), e = setTimeout(() => {
241
- t(...r);
242
- }, a);
241
+ t(...a);
242
+ }, r);
243
243
  };
244
244
  }
245
- function nt(a) {
246
- if (Object.prototype.toString.call(a) !== "[object Object]")
245
+ function nt(r) {
246
+ if (Object.prototype.toString.call(r) !== "[object Object]")
247
247
  return !1;
248
- const t = Object.getPrototypeOf(a);
248
+ const t = Object.getPrototypeOf(r);
249
249
  return t === Object.prototype || t === null;
250
250
  }
251
- function I(a) {
252
- if (Array.isArray(a))
253
- return a.map(I);
254
- if (nt(a)) {
251
+ function I(r) {
252
+ if (Array.isArray(r))
253
+ return r.map(I);
254
+ if (nt(r)) {
255
255
  const t = /* @__PURE__ */ Object.create(null);
256
- for (const [e, r] of Object.entries(a))
257
- t[at(e)] = I(r);
256
+ for (const [e, a] of Object.entries(r))
257
+ t[at(e)] = I(a);
258
258
  return t;
259
259
  }
260
- return a;
260
+ return r;
261
261
  }
262
- function it(a, t) {
263
- const e = Object.entries(a).filter(([r, n]) => t(n, r));
262
+ function it(r, t) {
263
+ const e = Object.entries(r).filter(([a, n]) => t(n, a));
264
264
  return Object.fromEntries(e);
265
265
  }
266
266
  function st() {
267
- const a = document.querySelector('meta[name="csrf-token"]');
268
- if (a)
269
- return a.getAttribute("content");
267
+ const r = document.querySelector('meta[name="csrf-token"]');
268
+ if (r)
269
+ return r.getAttribute("content");
270
270
  const t = document.cookie.match(/(?:^|; )_csrf_token=([^;]*)/);
271
271
  return t ? decodeURIComponent(t[1]) : null;
272
272
  }
@@ -345,15 +345,15 @@ class D {
345
345
  this._beforeDestroyCallbacks = [];
346
346
  }
347
347
  }
348
- function S(a) {
348
+ function S(r) {
349
349
  return {
350
350
  /**
351
351
  * The mounted lifecycle callback for the LiveView hook object.
352
352
  * It creates an instance of the user-defined hook class and sets up the necessary properties and methods.
353
353
  */
354
354
  async mounted() {
355
- const t = new a();
356
- this.el.instance = t, t.el = this.el, t.pushEvent = (r, n, i) => this.pushEvent?.(r, n, i), t.pushEventTo = (r, n, i, s) => this.pushEventTo?.(r, n, i, s), t.handleEvent = (r, n) => this.handleEvent?.(r, n), t.state = "mounting";
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";
357
357
  const e = await t.mounted?.();
358
358
  return t.state = "mounted", e;
359
359
  },
@@ -390,52 +390,52 @@ function S(a) {
390
390
  }
391
391
  };
392
392
  }
393
- function J(a) {
394
- return Object.keys(a).length === 0 && a.constructor === Object;
393
+ function J(r) {
394
+ return Object.keys(r).length === 0 && r.constructor === Object;
395
395
  }
396
- function ot(a) {
397
- return a == null;
396
+ function ot(r) {
397
+ return r == null;
398
398
  }
399
- function $(a, t) {
400
- const e = Object.entries(a).map(([r, n]) => [r, t(n, r)]);
399
+ function $(r, t) {
400
+ const e = Object.entries(r).map(([a, n]) => [a, t(n, a)]);
401
401
  return Object.fromEntries(e);
402
402
  }
403
- function F(a) {
404
- if (a === null)
403
+ function B(r) {
404
+ if (r === null)
405
405
  return null;
406
- const t = Number.parseInt(a, 10);
406
+ const t = Number.parseInt(r, 10);
407
407
  return Number.isNaN(t) ? null : t;
408
408
  }
409
- function ct(a) {
410
- return a == null || a.trim() === "" ? null : JSON.parse(a);
409
+ function ct(r) {
410
+ return r == null || r.trim() === "" ? null : JSON.parse(r);
411
411
  }
412
- function ut(a, t) {
413
- if (a === t)
412
+ function ut(r, t) {
413
+ if (r === t)
414
414
  return !0;
415
- const e = Object.keys(a), r = Object.keys(t);
416
- if (e.length !== r.length)
415
+ const e = Object.keys(r), a = Object.keys(t);
416
+ if (e.length !== a.length)
417
417
  return !1;
418
418
  for (const n of e)
419
- if (a[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
419
+ if (r[n] !== t[n] || !Object.prototype.hasOwnProperty.call(t, n))
420
420
  return !1;
421
421
  return !0;
422
422
  }
423
423
  function lt() {
424
424
  return Math.random().toString(36).substring(2);
425
425
  }
426
- function dt(a, {
426
+ function dt(r, {
427
427
  timeOutAfter: t = 500,
428
428
  retryAfter: e = 100
429
429
  } = {}) {
430
- return new Promise((r, n) => {
430
+ return new Promise((a, n) => {
431
431
  const i = Date.now();
432
432
  let s = null;
433
433
  const c = setTimeout(() => {
434
434
  n(s ?? new Error("Timeout"));
435
435
  }, t), o = async () => {
436
436
  try {
437
- const u = await a();
438
- clearTimeout(c), r(u);
437
+ const u = await r();
438
+ clearTimeout(c), a(u);
439
439
  } catch (u) {
440
440
  s = u, Date.now() - i > t ? n(u) : setTimeout(o, e);
441
441
  }
@@ -443,19 +443,19 @@ function dt(a, {
443
443
  o();
444
444
  });
445
445
  }
446
- function ht(a) {
446
+ function ht(r) {
447
447
  const t = [
448
- a.ui?.element,
449
- a.ui?.view?.toolbar?.element,
450
- a.ui?.view?.menuBarView?.element
448
+ r.ui?.element,
449
+ r.ui?.view?.toolbar?.element,
450
+ r.ui?.view?.menuBarView?.element
451
451
  ].filter(Boolean);
452
452
  for (const i of t)
453
453
  n(i);
454
- const e = a.ui?.view?.body?._bodyCollectionContainer;
454
+ const e = r.ui?.view?.body?._bodyCollectionContainer;
455
455
  e?.isConnected && n(e);
456
- const r = a.editing?.view;
457
- if (r)
458
- for (const i of r.domRoots.values())
456
+ const a = r.editing?.view;
457
+ if (a)
458
+ for (const i of a.domRoots.values())
459
459
  i instanceof HTMLElement && (i.removeAttribute("contenteditable"), i.removeAttribute("role"), i.removeAttribute("aria-label"), i.removeAttribute("aria-multiline"), i.removeAttribute("spellcheck"), i.classList.remove(
460
460
  "ck",
461
461
  "ck-content",
@@ -470,14 +470,14 @@ function ht(a) {
470
470
  }
471
471
  }
472
472
  const R = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
473
- async function mt({ element: a, context: t, creator: e, config: r }) {
473
+ async function mt({ element: r, context: t, creator: e, config: a }) {
474
474
  const n = lt();
475
475
  await t.add({
476
476
  creator: (o, u) => e.create(o, u),
477
477
  id: n,
478
- sourceElementOrData: a,
478
+ sourceElementOrData: r,
479
479
  type: "editor",
480
- config: r
480
+ config: a
481
481
  });
482
482
  const i = t.getItem(n), s = {
483
483
  state: "available",
@@ -491,26 +491,26 @@ async function mt({ element: a, context: t, creator: e, config: r }) {
491
491
  editor: i
492
492
  };
493
493
  }
494
- function pt(a) {
495
- return R in a ? a[R] : null;
494
+ function pt(r) {
495
+ return R in r ? r[R] : null;
496
496
  }
497
- function B(a) {
498
- return "addEditable" in a.ui;
497
+ function F(r) {
498
+ return "addEditable" in r.ui;
499
499
  }
500
- function A(a) {
501
- return ["inline", "classic", "balloon", "decoupled"].includes(a);
500
+ function A(r) {
501
+ return ["inline", "classic", "balloon", "decoupled"].includes(r);
502
502
  }
503
- async function ft(a) {
504
- const t = await import("ckeditor5"), r = {
503
+ async function ft(r) {
504
+ const t = await import("ckeditor5"), a = {
505
505
  inline: t.InlineEditor,
506
506
  balloon: t.BalloonEditor,
507
507
  classic: t.ClassicEditor,
508
508
  decoupled: t.DecoupledEditor,
509
509
  multiroot: t.MultiRootEditor
510
- }[a];
511
- if (!r)
512
- throw new Error(`Unsupported editor type: ${a}`);
513
- return r;
510
+ }[r];
511
+ if (!a)
512
+ throw new Error(`Unsupported editor type: ${r}`);
513
+ return a;
514
514
  }
515
515
  class _ {
516
516
  static the = new _();
@@ -572,10 +572,10 @@ class _ {
572
572
  return this.plugins.has(t);
573
573
  }
574
574
  }
575
- async function G(a) {
575
+ async function G(r) {
576
576
  const t = await import("ckeditor5");
577
577
  let e = null;
578
- const r = a.map(async (n) => {
578
+ const a = r.map(async (n) => {
579
579
  const i = await _.the.get(n);
580
580
  if (i)
581
581
  return i;
@@ -594,12 +594,12 @@ async function G(a) {
594
594
  throw new Error(`Plugin "${n}" not found in base or premium packages.`);
595
595
  });
596
596
  return {
597
- loadedPlugins: await Promise.all(r),
597
+ loadedPlugins: await Promise.all(a),
598
598
  hasPremium: !!e
599
599
  };
600
600
  }
601
- async function X(a, t) {
602
- const e = [a.ui, a.content];
601
+ async function X(r, t) {
602
+ const e = [r.ui, r.content];
603
603
  return await Promise.all(
604
604
  [
605
605
  L("ckeditor5", e),
@@ -608,17 +608,17 @@ async function X(a, t) {
608
608
  ].filter((n) => !!n)
609
609
  ).then((n) => n.flat());
610
610
  }
611
- async function L(a, t) {
611
+ async function L(r, t) {
612
612
  return await Promise.all(
613
613
  t.filter((e) => e !== "en").map(async (e) => {
614
- const r = await wt(a, e);
615
- return r?.default ?? r;
614
+ const a = await wt(r, e);
615
+ return a?.default ?? a;
616
616
  }).filter(Boolean)
617
617
  );
618
618
  }
619
- async function wt(a, t) {
619
+ async function wt(r, t) {
620
620
  try {
621
- if (a === "ckeditor5")
621
+ if (r === "ckeditor5")
622
622
  switch (t) {
623
623
  case "af":
624
624
  return await import("ckeditor5/translations/af.js");
@@ -913,26 +913,26 @@ async function wt(a, t) {
913
913
  return console.warn(`Language ${t} not found in premium translations`), await import("ckeditor5-premium-features/translations/en.js");
914
914
  }
915
915
  } catch (e) {
916
- return console.error(`Failed to load translation for ${a}/${t}:`, e), null;
916
+ return console.error(`Failed to load translation for ${r}/${t}:`, e), null;
917
917
  }
918
918
  }
919
- function Q(a) {
920
- return $(a, (t) => ({
919
+ function Q(r) {
920
+ return $(r, (t) => ({
921
921
  dictionary: t
922
922
  }));
923
923
  }
924
- function Z(a) {
925
- const t = tt(a);
924
+ function Z(r) {
925
+ const t = tt(r);
926
926
  return $(t, ({ content: e }) => e);
927
927
  }
928
- function W(a) {
929
- const t = tt(a), e = $(t, ({ initialValue: r }) => r);
930
- return it(e, (r) => typeof r == "string");
928
+ function W(r) {
929
+ const t = tt(r), e = $(t, ({ initialValue: a }) => a);
930
+ return it(e, (a) => typeof a == "string");
931
931
  }
932
- function tt(a) {
932
+ function tt(r) {
933
933
  const t = document.querySelectorAll(
934
934
  [
935
- `[data-cke-editor-id="${a}"][data-cke-editable-root-name]`,
935
+ `[data-cke-editor-id="${r}"][data-cke-editable-root-name]`,
936
936
  "[data-cke-editable-root-name]:not([data-cke-editor-id])"
937
937
  ].join(", ")
938
938
  ), e = Array.from(t).reduce((c, o) => {
@@ -944,10 +944,10 @@ function tt(a) {
944
944
  initialValue: l
945
945
  }
946
946
  };
947
- }, /* @__PURE__ */ Object.create({})), r = document.querySelector(`[phx-hook="CKEditor5"][id="${a}"]`);
948
- if (!r)
947
+ }, /* @__PURE__ */ Object.create({})), a = document.querySelector(`[phx-hook="CKEditor5"][id="${r}"]`);
948
+ if (!a)
949
949
  return e;
950
- const n = r.getAttribute("data-cke-initial-value") || "", i = r.querySelector(`#${a}_editor `), s = e.main;
950
+ const n = a.getAttribute("data-cke-initial-value") || "", i = a.querySelector(`#${r}_editor `), s = e.main;
951
951
  return s ? {
952
952
  ...e,
953
953
  main: {
@@ -963,12 +963,12 @@ function tt(a) {
963
963
  } : e;
964
964
  }
965
965
  const K = ["inline", "classic", "balloon", "decoupled", "multiroot"];
966
- function gt(a) {
967
- const t = a.getAttribute("data-cke-preset");
966
+ function gt(r) {
967
+ const t = r.getAttribute("data-cke-preset");
968
968
  if (!t)
969
969
  throw new Error('CKEditor5 hook requires a "cke-preset" attribute on the element.');
970
- const { type: e, config: r, license: n, watchdog: i, ...s } = JSON.parse(t);
971
- if (!e || !r || !n)
970
+ const { type: e, config: a, license: n, watchdog: i, ...s } = JSON.parse(t);
971
+ if (!e || !a || !n)
972
972
  throw new Error('CKEditor5 hook configuration must include "editor", "config", and "license" properties.');
973
973
  if (!K.includes(e))
974
974
  throw new Error(`Invalid editor type: ${e}. Must be one of: ${K.join(", ")}.`);
@@ -976,79 +976,79 @@ function gt(a) {
976
976
  type: e,
977
977
  license: n,
978
978
  watchdog: i,
979
- config: I(r),
979
+ config: I(a),
980
980
  customTranslations: s.customTranslations || s.custom_translations
981
981
  };
982
982
  }
983
- function x(a) {
984
- if (!a || typeof a != "object")
985
- return a;
986
- if (Array.isArray(a))
987
- return a.map((r) => x(r));
988
- const t = a;
983
+ function x(r) {
984
+ if (!r || typeof r != "object")
985
+ return r;
986
+ if (Array.isArray(r))
987
+ return r.map((a) => x(a));
988
+ const t = r;
989
989
  if (t.$element && typeof t.$element == "string") {
990
- const r = document.querySelector(t.$element);
991
- return r || console.warn(`Element not found for selector: ${t.$element}`), r || null;
990
+ const a = document.querySelector(t.$element);
991
+ return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
992
992
  }
993
993
  const e = /* @__PURE__ */ Object.create(null);
994
- for (const [r, n] of Object.entries(a))
995
- e[r] = x(n);
994
+ for (const [a, n] of Object.entries(r))
995
+ e[a] = x(n);
996
996
  return e;
997
997
  }
998
- function O(a, t, e) {
998
+ function O(r, t, e) {
999
999
  if (!e || typeof e != "object")
1000
1000
  return e;
1001
1001
  if (Array.isArray(e))
1002
- return e.map((i) => O(a, t, i));
1003
- const r = e;
1004
- if (r.$translation && typeof r.$translation == "string") {
1005
- const i = r.$translation, s = yt(a, i, t);
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);
1006
1006
  return s === void 0 && console.warn(`Translation not found for key: ${i}`), s !== void 0 ? s : null;
1007
1007
  }
1008
1008
  const n = /* @__PURE__ */ Object.create(null);
1009
1009
  for (const [i, s] of Object.entries(e))
1010
- n[i] = O(a, t, s);
1010
+ n[i] = O(r, t, s);
1011
1011
  return n;
1012
1012
  }
1013
- function yt(a, t, e) {
1014
- for (const r of a) {
1015
- const n = r[e];
1013
+ function yt(r, t, e) {
1014
+ for (const a of r) {
1015
+ const n = a[e];
1016
1016
  if (n?.dictionary && t in n.dictionary)
1017
1017
  return n.dictionary[t];
1018
1018
  }
1019
1019
  }
1020
- function bt(a, t) {
1021
- const { editing: e } = a;
1022
- e.view.change((r) => {
1023
- r.setStyle("height", `${t}px`, e.view.document.getRoot());
1020
+ function bt(r, t) {
1021
+ const { editing: e } = r;
1022
+ e.view.change((a) => {
1023
+ a.setStyle("height", `${t}px`, e.view.document.getRoot());
1024
1024
  });
1025
1025
  }
1026
1026
  const U = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
1027
- async function kt(a, t) {
1028
- const { EditorWatchdog: e } = await import("ckeditor5"), r = new e(null, t ?? {
1027
+ async function kt(r, t) {
1028
+ const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
1029
1029
  crashNumberLimit: 10,
1030
1030
  minimumNonErrorTimePeriod: 5e3
1031
1031
  });
1032
- return r.setCreator(async () => {
1033
- const n = await a();
1034
- return n[U] = r, n;
1035
- }), r;
1032
+ return a.setCreator(async () => {
1033
+ const n = await r();
1034
+ return n[U] = a, n;
1035
+ }), a;
1036
1036
  }
1037
- function Et(a) {
1038
- return U in a ? a[U] : null;
1037
+ function Et(r) {
1038
+ return U in r ? r[U] : null;
1039
1039
  }
1040
1040
  class y extends Y {
1041
1041
  static the = new y();
1042
1042
  }
1043
- function vt(a) {
1044
- const t = a.getAttribute("data-cke-context");
1043
+ function vt(r) {
1044
+ const t = r.getAttribute("data-cke-context");
1045
1045
  if (!t)
1046
1046
  throw new Error('CKEditor5 hook requires a "data-cke-context" attribute on the element.');
1047
- const { config: e, ...r } = JSON.parse(t);
1047
+ const { config: e, ...a } = JSON.parse(t);
1048
1048
  return {
1049
1049
  config: I(e),
1050
- customTranslations: r.customTranslations || r.custom_translations,
1051
- watchdogConfig: r.watchdogConfig || r.watchdog_config
1050
+ customTranslations: a.customTranslations || a.custom_translations,
1051
+ watchdogConfig: a.watchdogConfig || a.watchdog_config
1052
1052
  };
1053
1053
  }
1054
1054
  class Ct extends D {
@@ -1060,7 +1060,7 @@ class Ct extends D {
1060
1060
  * Attributes for the context instance.
1061
1061
  */
1062
1062
  get attrs() {
1063
- const t = (r) => this.el.getAttribute(r) || null, e = {
1063
+ const t = (a) => this.el.getAttribute(a) || null, e = {
1064
1064
  id: this.el.id,
1065
1065
  config: vt(this.el),
1066
1066
  language: {
@@ -1079,9 +1079,9 @@ class Ct extends D {
1079
1079
  * Mounts the context component.
1080
1080
  */
1081
1081
  async mounted() {
1082
- const { id: t, language: e } = this.attrs, { customTranslations: r, watchdogConfig: n, config: { plugins: i, ...s } } = this.attrs.config, { loadedPlugins: c, hasPremium: o } = await G(i ?? []), l = [
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 = [
1083
1083
  ...await X(e, o),
1084
- Q(r?.dictionary || {})
1084
+ Q(a?.dictionary || {})
1085
1085
  ].filter((m) => !J(m));
1086
1086
  let d = x(s);
1087
1087
  d = O([...l].reverse(), e.ui, d), this.contextPromise = (async () => {
@@ -1116,11 +1116,11 @@ class Ct extends D {
1116
1116
  }
1117
1117
  }
1118
1118
  }
1119
- function Pt(a) {
1120
- return a.hasAttribute("data-cke-context");
1119
+ function Pt(r) {
1120
+ return r.hasAttribute("data-cke-context");
1121
1121
  }
1122
- function At(a) {
1123
- let t = a;
1122
+ function At(r) {
1123
+ let t = r;
1124
1124
  for (; t; ) {
1125
1125
  if (Pt(t))
1126
1126
  return t;
@@ -1128,29 +1128,29 @@ function At(a) {
1128
1128
  }
1129
1129
  return null;
1130
1130
  }
1131
- async function Tt(a) {
1132
- const t = At(a);
1131
+ async function Tt(r) {
1132
+ const t = At(r);
1133
1133
  return t ? y.the.waitFor(t.id) : null;
1134
1134
  }
1135
1135
  const It = S(Ct);
1136
- function xt(a, t) {
1136
+ function xt(r, t) {
1137
1137
  const e = /* @__PURE__ */ new Set();
1138
- return (r) => {
1138
+ return (a) => {
1139
1139
  let n = !1;
1140
- return a.model.enqueueChange({ isUndoable: !1 }, (i) => {
1141
- const s = a.model.document.getRoot(t);
1140
+ return r.model.enqueueChange({ isUndoable: !1 }, (i) => {
1141
+ const s = r.model.document.getRoot(t);
1142
1142
  if (s) {
1143
1143
  for (const c of e)
1144
- r && c in r || (i.removeAttribute(c, s), e.delete(c), n = !0);
1145
- for (const [c, o] of Object.entries(r ?? {}))
1144
+ a && c in a || (i.removeAttribute(c, s), e.delete(c), n = !0);
1145
+ for (const [c, o] of Object.entries(a ?? {}))
1146
1146
  i.setAttribute(c, o, s), e.add(c), n = !0;
1147
1147
  }
1148
1148
  }), n;
1149
1149
  };
1150
1150
  }
1151
1151
  async function Ot() {
1152
- const { Plugin: a, FileRepository: t } = await import("ckeditor5");
1153
- return class extends a {
1152
+ const { Plugin: r, FileRepository: t } = await import("ckeditor5");
1153
+ return class extends r {
1154
1154
  /**
1155
1155
  * The name of the plugin.
1156
1156
  */
@@ -1164,7 +1164,7 @@ async function Ot() {
1164
1164
  * Initializes the plugin.
1165
1165
  */
1166
1166
  init() {
1167
- const { editor: r } = this, { plugins: n, config: i } = r, s = i.get("phoenixUpload.url");
1167
+ const { editor: a } = this, { plugins: n, config: i } = a, s = i.get("phoenixUpload.url");
1168
1168
  if (!s || n.has("SimpleUploadAdapter") || n.has("Base64UploadAdapter") || n.has("CKFinderUploadAdapter"))
1169
1169
  return;
1170
1170
  const c = n.get(t);
@@ -1187,12 +1187,12 @@ class Dt {
1187
1187
  this.abortController = new AbortController();
1188
1188
  const e = new FormData();
1189
1189
  e.append("file", t), t.size && (this.loader.uploadTotal = t.size, this.loader.uploaded = 0);
1190
- const r = {}, n = st();
1191
- n && (r["X-CSRF-Token"] = n);
1190
+ const a = {}, n = st();
1191
+ n && (a["X-CSRF-Token"] = n);
1192
1192
  try {
1193
1193
  const i = await fetch(this.uploadUrl, {
1194
1194
  method: "POST",
1195
- headers: r,
1195
+ headers: a,
1196
1196
  body: e,
1197
1197
  signal: this.abortController.signal
1198
1198
  });
@@ -1221,7 +1221,7 @@ class Dt {
1221
1221
  }
1222
1222
  }
1223
1223
  async function St({
1224
- editorId: a,
1224
+ editorId: r,
1225
1225
  saveDebounceMs: t
1226
1226
  }) {
1227
1227
  const { Plugin: e } = await import("ckeditor5");
@@ -1245,7 +1245,7 @@ async function St({
1245
1245
  */
1246
1246
  afterInit() {
1247
1247
  const { editor: n } = this;
1248
- this.input = document.getElementById(`${a}_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));
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));
1249
1249
  }
1250
1250
  /**
1251
1251
  * Synchronizes the editor's content with the input field.
@@ -1263,8 +1263,8 @@ async function St({
1263
1263
  };
1264
1264
  }
1265
1265
  const M = /* @__PURE__ */ Symbol("suppress-phoenix-sync");
1266
- async function Nt(a) {
1267
- const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: r, events: n, pushEvent: i, handleEvent: s } = a;
1266
+ async function Nt(r) {
1267
+ const { Plugin: t } = await import("ckeditor5"), { editorId: e, saveDebounceMs: a, events: n, pushEvent: i, handleEvent: s } = r;
1268
1268
  return class extends t {
1269
1269
  /**
1270
1270
  * The name of the plugin.
@@ -1303,7 +1303,7 @@ async function Nt(a) {
1303
1303
  data: m
1304
1304
  }
1305
1305
  ), u = m);
1306
- }, w = T(r, d);
1306
+ }, w = T(a, d);
1307
1307
  o.model.document.on("change:data", T(10, (m) => {
1308
1308
  if (Vt(m)) {
1309
1309
  u = null;
@@ -1332,20 +1332,20 @@ async function Nt(a) {
1332
1332
  }
1333
1333
  };
1334
1334
  }
1335
- function V(a) {
1336
- return a.model.document.getRootNames().reduce((e, r) => (e[r] = a.getData({ rootName: r }), e), /* @__PURE__ */ Object.create({}));
1335
+ function V(r) {
1336
+ return r.model.document.getRootNames().reduce((e, a) => (e[a] = r.getData({ rootName: a }), e), /* @__PURE__ */ Object.create({}));
1337
1337
  }
1338
- function Vt(a) {
1339
- const t = a[M];
1340
- return delete a[M], !!t;
1338
+ function Vt(r) {
1339
+ const t = r[M];
1340
+ return delete r[M], !!t;
1341
1341
  }
1342
- function Rt(a) {
1342
+ function Rt(r) {
1343
1343
  let t = !1;
1344
- const e = (r) => {
1345
- t || (r[M] = !0);
1344
+ const e = (a) => {
1345
+ t || (a[M] = !0);
1346
1346
  };
1347
- return a.model.document.once("change:data", e, { priority: "highest" }), () => {
1348
- t = !0, a.model.document.off("change:data", e);
1347
+ return r.model.document.once("change:data", e, { priority: "highest" }), () => {
1348
+ t = !0, r.model.document.off("change:data", e);
1349
1349
  };
1350
1350
  }
1351
1351
  class et {
@@ -1403,11 +1403,11 @@ class et {
1403
1403
  constructor({
1404
1404
  el: t,
1405
1405
  editor: e,
1406
- rootName: r,
1406
+ rootName: a,
1407
1407
  valueAttrName: n = "data-cke-value",
1408
1408
  rootAttrsAttrName: i = "data-cke-root-attrs"
1409
1409
  }) {
1410
- this.el = t, this.editor = e, this.rootName = r, this.valueAttrName = n, this.rootAttrsAttrName = i;
1410
+ this.el = t, this.editor = e, this.rootName = a, this.valueAttrName = n, this.rootAttrsAttrName = i;
1411
1411
  const { value: s } = this.attrs;
1412
1412
  this.previousValue = s, this.setupSyncHandlers(e, this.rootName);
1413
1413
  }
@@ -1426,13 +1426,13 @@ class et {
1426
1426
  * However, if the editor is focused, we want to wait until it blurs to avoid disrupting the user while typing.
1427
1427
  */
1428
1428
  async updated() {
1429
- const { editor: t } = this, { value: e, rootAttributes: r } = this.attrs;
1429
+ const { editor: t } = this, { value: e, rootAttributes: a } = this.attrs;
1430
1430
  if (!t || t.state === "destroyed" || this.isDestroyed)
1431
1431
  return;
1432
1432
  let n = () => {
1433
1433
  };
1434
1434
  t.model.enqueueChange({ isUndoable: !1 }, () => {
1435
- let i = this.attrsUpdater?.(r);
1435
+ let i = this.attrsUpdater?.(a);
1436
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
1437
  }), n();
1438
1438
  }
@@ -1442,20 +1442,20 @@ class et {
1442
1442
  */
1443
1443
  setupSyncHandlers(t, e) {
1444
1444
  this.attrsUpdater = xt(t, e), this.attrsUpdater(this.attrs.rootAttributes);
1445
- const r = () => {
1445
+ const a = () => {
1446
1446
  this.pendingValue = null;
1447
1447
  }, n = () => {
1448
1448
  !t.ui.focusTracker.isFocused && this.pendingValue !== null && (this.setRootValue(t, e, this.pendingValue), this.pendingValue = null);
1449
1449
  };
1450
- t.model.document.on("change:data", r), t.ui.focusTracker.on("change:isFocused", n), this.cleanupCallbacks.push(() => {
1451
- t.model.document.off("change:data", r), t.ui.focusTracker.off("change:isFocused", n);
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);
1452
1452
  });
1453
1453
  }
1454
1454
  /**
1455
1455
  * Sets the value of a specific root in the editor.
1456
1456
  */
1457
- setRootValue(t, e, r) {
1458
- t.getData({ rootName: e }) !== r && t.setData({ [e]: r });
1457
+ setRootValue(t, e, a) {
1458
+ t.getData({ rootName: e }) !== a && t.setData({ [e]: a });
1459
1459
  }
1460
1460
  /**
1461
1461
  * Disconnects the observer and cleans up editor event listeners.
@@ -1478,19 +1478,19 @@ class Ut extends D {
1478
1478
  * Attributes for the editor instance.
1479
1479
  */
1480
1480
  get attrs() {
1481
- const { el: t } = this, e = t.getAttribute.bind(t), r = t.hasAttribute.bind(t), n = {
1481
+ const { el: t } = this, e = t.getAttribute.bind(t), a = t.hasAttribute.bind(t), n = {
1482
1482
  editorId: e("id"),
1483
1483
  contextId: e("data-cke-context-id"),
1484
1484
  preset: gt(t),
1485
- editableHeight: F(e("data-cke-editable-height")),
1486
- watchdog: r("data-cke-watchdog"),
1485
+ editableHeight: B(e("data-cke-editable-height")),
1486
+ watchdog: a("data-cke-watchdog"),
1487
1487
  events: {
1488
- change: r("data-cke-change-event"),
1489
- blur: r("data-cke-blur-event"),
1490
- focus: r("data-cke-focus-event"),
1491
- ready: r("data-cke-ready-event")
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")
1492
1492
  },
1493
- saveDebounceMs: F(e("data-cke-save-debounce-ms")) ?? 400,
1493
+ saveDebounceMs: B(e("data-cke-save-debounce-ms")) ?? 400,
1494
1494
  language: {
1495
1495
  ui: e("data-cke-language") || "en",
1496
1496
  content: e("data-cke-content-language") || "en"
@@ -1513,7 +1513,7 @@ class Ut extends D {
1513
1513
  const e = await this.createEditor();
1514
1514
  if (this.isBeingDestroyed())
1515
1515
  return;
1516
- const r = h.the.mountEffect(t, (n) => (n.once("destroy", () => {
1516
+ const a = h.the.mountEffect(t, (n) => (n.once("destroy", () => {
1517
1517
  h.the.unregister(t, !1);
1518
1518
  }, { priority: "highest" }), this.sentinel = new et({
1519
1519
  editor: n,
@@ -1524,7 +1524,11 @@ class Ut extends D {
1524
1524
  }), () => {
1525
1525
  this.sentinel?.destroy(), this.sentinel = null;
1526
1526
  }));
1527
- this.onBeforeDestroy(r), h.the.register(t, e);
1527
+ 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();
1531
+ }), h.the.register(t, e);
1528
1532
  } catch (e) {
1529
1533
  console.error(e), h.the.error(t, e);
1530
1534
  }
@@ -1537,18 +1541,10 @@ class Ut extends D {
1537
1541
  this.sentinel?.updated();
1538
1542
  }
1539
1543
  /**
1540
- * Destroys the editor instance when the component is destroyed.
1541
- * This is important to prevent memory leaks and ensure that the editor is properly cleaned up.
1544
+ * Destroys editor component.
1542
1545
  */
1543
1546
  async destroyed() {
1544
- const { editorId: t } = this.attrs;
1545
1547
  this.el.style.display = "none";
1546
- const e = await h.the.waitFor(t);
1547
- if (!e)
1548
- return;
1549
- h.the.unregister(t);
1550
- const r = pt(e), n = Et(e);
1551
- r ? r.state !== "unavailable" && await r.context.remove(r.editorContextId) : n ? await n.destroy() : await e.destroy();
1552
1548
  }
1553
1549
  /**
1554
1550
  * Creates the CKEditor instance.
@@ -1557,13 +1553,13 @@ class Ut extends D {
1557
1553
  const {
1558
1554
  preset: t,
1559
1555
  editorId: e,
1560
- contextId: r,
1556
+ contextId: a,
1561
1557
  editableHeight: n,
1562
1558
  events: i,
1563
1559
  saveDebounceMs: s,
1564
1560
  language: c,
1565
1561
  watchdog: o
1566
- } = this.attrs, { customTranslations: u, type: l, license: d, config: { plugins: w, ...m } } = t, v = await ft(l), g = await (r ? y.the.waitFor(r) : Tt(this.el)), C = async () => {
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 () => {
1567
1563
  const { loadedPlugins: f, hasPremium: P } = await G(w);
1568
1564
  A(l) && f.push(
1569
1565
  await St({
@@ -1630,19 +1626,19 @@ class Ut extends D {
1630
1626
  return C();
1631
1627
  }
1632
1628
  }
1633
- function rt(a, t) {
1634
- return t.every((e) => a[e]);
1629
+ function rt(r, t) {
1630
+ return t.every((e) => r[e]);
1635
1631
  }
1636
- async function Mt(a, t) {
1632
+ async function Mt(r, t) {
1637
1633
  return dt(
1638
1634
  () => {
1639
- const e = Z(a);
1635
+ const e = Z(r);
1640
1636
  if (!rt(e, t))
1641
1637
  throw new Error(
1642
1638
  `It looks like not all required root elements are present yet.
1643
1639
  * If you want to wait for them, ensure they are registered before editor initialization.
1644
1640
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
1645
- Missing roots: ${t.filter((r) => !e[r]).join(", ")}.`
1641
+ Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
1646
1642
  );
1647
1643
  return e;
1648
1644
  },
@@ -1676,32 +1672,32 @@ class _t extends D {
1676
1672
  * Mounts the editable component.
1677
1673
  */
1678
1674
  mounted() {
1679
- const { editableId: t, editorId: e, rootName: r, initialValue: n } = this.attrs, i = h.the.mountEffect(e, (s) => {
1675
+ const { editableId: t, editorId: e, rootName: a, initialValue: n } = this.attrs, i = h.the.mountEffect(e, (s) => {
1680
1676
  const c = this.el.querySelector("[data-cke-editable-content]");
1681
1677
  if (this.isBeingDestroyed())
1682
1678
  return;
1683
1679
  const o = this.el.querySelector(`#${t}_input`);
1684
- if (B(s) && !s.model.document.getRoot(r)) {
1680
+ if (F(s) && !s.model.document.getRoot(a)) {
1685
1681
  const { ui: l, editing: d } = s;
1686
- s.addRoot(r, {
1682
+ s.addRoot(a, {
1687
1683
  isUndoable: !1,
1688
1684
  data: n
1689
1685
  });
1690
- const w = l.view.createEditable(r, c);
1686
+ const w = l.view.createEditable(a, c);
1691
1687
  l.addEditable(w), d.view.forceRender();
1692
1688
  }
1693
1689
  this.sentinel = new et({
1694
1690
  el: this.el,
1695
1691
  editor: s,
1696
- rootName: r,
1692
+ rootName: a,
1697
1693
  valueAttrName: "data-cke-editable-initial-value",
1698
1694
  rootAttrsAttrName: "data-cke-editable-root-attrs"
1699
1695
  });
1700
- const u = o ? Ht(o, s, r) : null;
1696
+ const u = o ? Ht(o, s, a) : null;
1701
1697
  return () => {
1702
1698
  if (u?.(), this.sentinel?.destroy(), this.sentinel = null, s.state !== "destroyed") {
1703
- const l = s.model.document.getRoot(r);
1704
- l && B(s) && (s.ui.view.editables[r] && s.detachEditable(l), l.isAttached() && s.detachRoot(r, !1));
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));
1705
1701
  }
1706
1702
  };
1707
1703
  });
@@ -1717,11 +1713,11 @@ class _t extends D {
1717
1713
  }
1718
1714
  }
1719
1715
  const zt = S(_t);
1720
- function Ht(a, t, e) {
1721
- const r = () => {
1722
- a.value = t.getData({ rootName: e });
1723
- }, n = T(200, r);
1724
- return t.model.document.on("change:data", n), r(), () => {
1716
+ function Ht(r, t, e) {
1717
+ const a = () => {
1718
+ r.value = t.getData({ rootName: e });
1719
+ }, n = T(200, a);
1720
+ return t.model.document.on("change:data", n), a(), () => {
1725
1721
  t.model.document.off("change:data", n);
1726
1722
  };
1727
1723
  }
@@ -1745,7 +1741,7 @@ class jt extends D {
1745
1741
  * Mounts the UI part component.
1746
1742
  */
1747
1743
  mounted() {
1748
- const { editorId: t, name: e } = this.attrs, r = h.the.mountEffect(t, (n) => {
1744
+ const { editorId: t, name: e } = this.attrs, a = h.the.mountEffect(t, (n) => {
1749
1745
  if (this.isBeingDestroyed())
1750
1746
  return;
1751
1747
  const { ui: i } = n, s = qt(e), c = i.view[s];
@@ -1758,12 +1754,12 @@ class jt extends D {
1758
1754
  };
1759
1755
  });
1760
1756
  this.onBeforeDestroy(() => {
1761
- this.el.style.display = "none", r();
1757
+ this.el.style.display = "none", a();
1762
1758
  });
1763
1759
  }
1764
1760
  }
1765
- function qt(a) {
1766
- switch (a) {
1761
+ function qt(r) {
1762
+ switch (r) {
1767
1763
  case "toolbar":
1768
1764
  return "toolbar";
1769
1765
  case "menubar":
@@ -1772,10 +1768,10 @@ function qt(a) {
1772
1768
  return null;
1773
1769
  }
1774
1770
  }
1775
- const Ft = S(jt), Kt = {
1771
+ const Bt = S(jt), Kt = {
1776
1772
  CKEditor5: $t,
1777
1773
  CKEditable: zt,
1778
- CKUIPart: Ft,
1774
+ CKUIPart: Bt,
1779
1775
  CKContext: It
1780
1776
  };
1781
1777
  export {