ckeditor5-livewire 1.12.1 → 1.12.2

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 (25) hide show
  1. package/dist/hooks/editor/editor.d.ts.map +1 -1
  2. package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts +17 -0
  3. package/dist/hooks/editor/utils/assign-editor-roots-to-config.d.ts.map +1 -0
  4. package/dist/hooks/editor/utils/index.d.ts +2 -3
  5. package/dist/hooks/editor/utils/index.d.ts.map +1 -1
  6. package/dist/hooks/editor/utils/query-all-editor-editables.d.ts +23 -0
  7. package/dist/hooks/editor/utils/query-all-editor-editables.d.ts.map +1 -0
  8. package/dist/index.cjs +2 -2
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.mjs +159 -204
  11. package/dist/index.mjs.map +1 -1
  12. package/package.json +1 -1
  13. package/src/hooks/editor/editor.ts +40 -64
  14. package/src/hooks/editor/utils/assign-editor-roots-to-config.ts +60 -0
  15. package/src/hooks/editor/utils/index.ts +2 -3
  16. package/src/hooks/editor/utils/query-all-editor-editables.ts +77 -0
  17. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts +0 -10
  18. package/dist/hooks/editor/utils/assign-initial-data-to-editor-config.d.ts.map +0 -1
  19. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts +0 -12
  20. package/dist/hooks/editor/utils/assign-source-elements-to-editor-config.d.ts.map +0 -1
  21. package/dist/hooks/editor/utils/query-editor-editables.d.ts +0 -32
  22. package/dist/hooks/editor/utils/query-editor-editables.d.ts.map +0 -1
  23. package/src/hooks/editor/utils/assign-initial-data-to-editor-config.ts +0 -48
  24. package/src/hooks/editor/utils/assign-source-elements-to-editor-config.ts +0 -61
  25. package/src/hooks/editor/utils/query-editor-editables.ts +0 -93
package/dist/index.mjs CHANGED
@@ -162,25 +162,19 @@ function i(e, t) {
162
162
  };
163
163
  }
164
164
  //#endregion
165
- //#region src/shared/filter-object-values.ts
166
- function a(e, t) {
167
- let n = Object.entries(e).filter(([e, n]) => t(n, e));
168
- return Object.fromEntries(n);
169
- }
170
- //#endregion
171
165
  //#region src/shared/is-empty-object.ts
172
- function o(e) {
166
+ function a(e) {
173
167
  return Object.keys(e).length === 0 && e.constructor === Object;
174
168
  }
175
169
  //#endregion
176
170
  //#region src/shared/map-object-values.ts
177
- function s(e, t) {
171
+ function o(e, t) {
178
172
  let n = Object.entries(e).map(([e, n]) => [e, t(n, e)]);
179
173
  return Object.fromEntries(n);
180
174
  }
181
175
  //#endregion
182
176
  //#region src/shared/shallow-equal.ts
183
- function c(e, t) {
177
+ function s(e, t) {
184
178
  if (e === t) return !0;
185
179
  let n = Object.keys(e), r = Object.keys(t);
186
180
  if (n.length !== r.length) return !1;
@@ -189,12 +183,12 @@ function c(e, t) {
189
183
  }
190
184
  //#endregion
191
185
  //#region src/shared/uid.ts
192
- function l() {
186
+ function c() {
193
187
  return Math.random().toString(36).substring(2);
194
188
  }
195
189
  //#endregion
196
190
  //#region src/shared/wait-for.ts
197
- function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
191
+ function l(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
198
192
  return new Promise((r, i) => {
199
193
  let a = Date.now(), o = null, s = setTimeout(() => {
200
194
  i(o ?? /* @__PURE__ */ Error("Timeout"));
@@ -210,51 +204,28 @@ function u(e, { timeOutAfter: t = 500, retryAfter: n = 100 } = {}) {
210
204
  });
211
205
  }
212
206
  //#endregion
213
- //#region src/hooks/editor/utils/assign-initial-data-to-editor-config.ts
214
- function d(e, t) {
215
- let n = f(e), r = new Set([...Object.keys(n), ...Object.keys(t.roots ?? {})]), i = Array.from(r).reduce((e, r) => ({
216
- ...e,
217
- [r]: {
218
- ...t.roots?.[r],
219
- ...r === "main" ? t.root : {},
220
- ...r in n ? { initialData: n[r] } : {}
221
- }
222
- }), Object.create(t.roots || {})), a = {
223
- ...t,
224
- roots: i
225
- };
226
- return delete a.root, a;
227
- }
228
- function f(e) {
229
- return typeof e == "string" ? { main: e } : { ...e };
230
- }
231
- //#endregion
232
- //#region src/hooks/editor/utils/assign-source-elements-to-editor-config.ts
233
- function p(e, t, n) {
234
- let r = m(t);
235
- if (!e.editorName || e.editorName === "ClassicEditor") return {
236
- ...n,
237
- attachTo: r.main
238
- };
239
- let i = new Set([...Object.keys(r), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, t) => ({
207
+ //#region src/hooks/editor/utils/assign-editor-roots-to-config.ts
208
+ function u(e, t, n) {
209
+ let r = !e.editorName || e.editorName === "ClassicEditor", i = new Set([...Object.keys(t), ...Object.keys(n.roots ?? {})]), a = Array.from(i).reduce((e, i) => ({
240
210
  ...e,
241
- [t]: {
242
- ...n.roots?.[t],
243
- ...t === "main" ? n.root : {},
244
- ...t in r ? { element: r[t] } : {}
211
+ [i]: {
212
+ ...n.roots?.[i],
213
+ ...i === "main" ? n.root : {},
214
+ ...i in t ? {
215
+ ...t[i].content !== null && { initialData: t[i].content },
216
+ ...!r && t[i].element !== null && { element: t[i].element }
217
+ } : {}
245
218
  }
246
219
  }), Object.create(n.roots || {})), o = {
247
220
  ...n,
248
- roots: a
221
+ roots: a,
222
+ ...r && t.main?.element && { attachTo: t.main.element }
249
223
  };
250
224
  return delete o.root, o;
251
225
  }
252
- function m(e) {
253
- return e instanceof HTMLElement ? { main: e } : { ...e };
254
- }
255
226
  //#endregion
256
227
  //#region src/hooks/editor/utils/cleanup-orphan-editor-elements.ts
257
- function h(e) {
228
+ function d(e) {
258
229
  let t = [
259
230
  e.ui?.element,
260
231
  e.ui?.view?.toolbar?.element,
@@ -271,9 +242,9 @@ function h(e) {
271
242
  }
272
243
  //#endregion
273
244
  //#region src/hooks/editor/utils/create-editor-in-context.ts
274
- var g = Symbol.for("context-editor-watchdog");
275
- async function _({ context: e, creator: t, config: n }) {
276
- let r = l();
245
+ var f = Symbol.for("context-editor-watchdog");
246
+ async function p({ context: e, creator: t, config: n }) {
247
+ let r = c();
277
248
  await e.add({
278
249
  creator: t.create.bind(t),
279
250
  id: r,
@@ -285,29 +256,29 @@ async function _({ context: e, creator: t, config: n }) {
285
256
  editorContextId: r,
286
257
  context: e
287
258
  };
288
- i[g] = a;
259
+ i[f] = a;
289
260
  let o = e.destroy.bind(e);
290
261
  return e.destroy = async () => (a.state = "unavailable", o()), {
291
262
  ...a,
292
263
  editor: i
293
264
  };
294
265
  }
295
- function v(e) {
296
- return g in e ? e[g] : null;
266
+ function m(e) {
267
+ return f in e ? e[f] : null;
297
268
  }
298
269
  //#endregion
299
270
  //#region src/hooks/editor/utils/get-editor-roots-values.ts
300
- function y(e) {
271
+ function h(e) {
301
272
  return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create({}));
302
273
  }
303
274
  //#endregion
304
275
  //#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
305
- function b(e) {
276
+ function g(e) {
306
277
  return "addEditable" in e.ui;
307
278
  }
308
279
  //#endregion
309
280
  //#region src/hooks/editor/utils/is-single-root-editor.ts
310
- function x(e) {
281
+ function _(e) {
311
282
  return [
312
283
  "inline",
313
284
  "classic",
@@ -317,7 +288,7 @@ function x(e) {
317
288
  }
318
289
  //#endregion
319
290
  //#region src/hooks/editor/utils/load-editor-constructor.ts
320
- async function S(e) {
291
+ async function v(e) {
321
292
  let t = await import("ckeditor5"), n = {
322
293
  inline: t.InlineEditor,
323
294
  balloon: t.BalloonEditor,
@@ -330,7 +301,7 @@ async function S(e) {
330
301
  }
331
302
  //#endregion
332
303
  //#region src/hooks/editor/custom-editor-plugins.ts
333
- var C = class e {
304
+ var y = class e {
334
305
  static the = new e();
335
306
  plugins = /* @__PURE__ */ new Map();
336
307
  constructor() {}
@@ -354,9 +325,9 @@ var C = class e {
354
325
  };
355
326
  //#endregion
356
327
  //#region src/hooks/editor/utils/load-editor-plugins.ts
357
- async function w(e) {
328
+ async function b(e) {
358
329
  let t = await import("ckeditor5"), n = null, r = e.map(async (e) => {
359
- let r = await C.the.get(e);
330
+ let r = await y.the.get(e);
360
331
  if (r) return r;
361
332
  let { [e]: i } = t;
362
333
  if (i) return i;
@@ -378,19 +349,19 @@ async function w(e) {
378
349
  }
379
350
  //#endregion
380
351
  //#region src/hooks/editor/utils/load-editor-translations.ts
381
- async function T(e, t) {
382
- let n = [e.ui, e.content], r = [E("ckeditor5", n)];
383
- return t && r.push(E("ckeditor5-premium-features", n)), await Promise.all(r).then((e) => e.flat());
352
+ async function x(e, t) {
353
+ let n = [e.ui, e.content], r = [S("ckeditor5", n)];
354
+ return t && r.push(S("ckeditor5-premium-features", n)), await Promise.all(r).then((e) => e.flat());
384
355
  }
385
- async function E(e, t) {
356
+ async function S(e, t) {
386
357
  /* v8 ignore next */
387
358
  return await Promise.all(t.filter((e) => e !== "en").map(async (t) => {
388
- let n = await D(e, t);
359
+ let n = await C(e, t);
389
360
  /* v8 ignore next -- @preserve */
390
361
  return n?.default ?? n;
391
362
  }).filter(Boolean));
392
363
  }
393
- async function D(e, t) {
364
+ async function C(e, t) {
394
365
  try {
395
366
  /* v8 ignore next if -- @preserve */
396
367
  if (e === "ckeditor5") switch (t) {
@@ -550,68 +521,65 @@ catch (n) {
550
521
  }
551
522
  //#endregion
552
523
  //#region src/hooks/editor/utils/normalize-custom-translations.ts
553
- function O(e) {
554
- return s(e, (e) => ({ dictionary: e }));
524
+ function w(e) {
525
+ return o(e, (e) => ({ dictionary: e }));
555
526
  }
556
527
  //#endregion
557
- //#region src/hooks/editor/utils/query-editor-editables.ts
558
- function k(e) {
559
- return s(A(e), ({ element: e }) => e);
560
- }
561
- function A(e) {
562
- let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => ({
563
- ...e,
564
- [t.rootName]: {
528
+ //#region src/hooks/editor/utils/query-all-editor-editables.ts
529
+ function T(e) {
530
+ let t = window.Livewire.all().filter(({ name: t, canonical: n }) => t === "ckeditor5-editable" && n.editorId === e).reduce((e, { canonical: t, el: n }) => {
531
+ let r = t.rootName;
532
+ return e[r] = {
565
533
  element: n.querySelector("[data-cke-editable-content]"),
566
534
  content: t.content
567
- }
568
- }), Object.create({})), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e)?.canonical.content, r = document.querySelector(`#${e}_editor `), i = t.main;
569
- return i && n?.main ? {
570
- ...t,
571
- main: {
572
- ...i,
573
- content: i.content || n.main
574
- }
575
- } : r ? {
576
- ...t,
577
- main: {
578
- element: r,
579
- content: n?.main || null
580
- }
581
- } : t;
582
- }
583
- function j(e) {
584
- return a(s(A(e), ({ content: e }) => e), (e) => typeof e == "string");
535
+ }, e;
536
+ }, Object.create({})), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e);
537
+ /* v8 ignore next -- @preserve */
538
+ if (!n) return t;
539
+ // v8 ignore next -- @preserve
540
+ let r = n.canonical.content ?? {}, i = document.querySelector(`#${e}_editor`);
541
+ i && !t.main && (t.main = {
542
+ element: i,
543
+ content: r.main ?? ""
544
+ });
545
+ for (let [e, n] of Object.entries(r)) t[e] ? t[e] = {
546
+ ...t[e],
547
+ content: t[e].content ?? n
548
+ } : t[e] = {
549
+ element: null,
550
+ content: n
551
+ };
552
+ return t;
585
553
  }
586
554
  //#endregion
587
555
  //#region src/hooks/editor/utils/resolve-editor-config-elements-references.ts
588
- function M(e) {
556
+ function E(e) {
589
557
  if (!e || typeof e != "object") return e;
590
- if (Array.isArray(e)) return e.map((e) => M(e));
558
+ if (Array.isArray(e)) return e.map((e) => E(e));
591
559
  let t = e;
592
560
  if (t.$element && typeof t.$element == "string") {
593
561
  let e = document.querySelector(t.$element);
594
562
  return e || console.warn(`Element not found for selector: ${t.$element}`), e || null;
595
563
  }
596
564
  let n = Object.create(null);
597
- for (let [t, r] of Object.entries(e)) n[t] = M(r);
565
+ for (let [t, r] of Object.entries(e)) n[t] = E(r);
598
566
  return n;
599
567
  }
600
568
  //#endregion
601
569
  //#region src/hooks/editor/utils/resolve-editor-config-translations.ts
602
- function N(e, t, n) {
570
+ function D(e, t, n) {
603
571
  if (!n || typeof n != "object") return n;
604
- if (Array.isArray(n)) return n.map((n) => N(e, t, n));
572
+ if (Array.isArray(n)) return n.map((n) => D(e, t, n));
605
573
  let r = n;
606
574
  if (r.$translation && typeof r.$translation == "string") {
607
- let n = r.$translation, i = P(e, n, t);
575
+ let n = r.$translation, i = O(e, n, t);
608
576
  return i === void 0 && console.warn(`Translation not found for key: ${n}`), i === void 0 ? null : i;
609
577
  }
610
578
  let i = Object.create(null);
611
- for (let [r, a] of Object.entries(n)) i[r] = N(e, t, a);
579
+ for (let [r, a] of Object.entries(n)) i[r] = D(e, t, a);
612
580
  return i;
613
581
  }
614
- function P(e, t, n) {
582
+ function O(e, t, n) {
615
583
  for (let r of e) {
616
584
  let e = r[n];
617
585
  if (e?.dictionary && t in e.dictionary) return e.dictionary[t];
@@ -619,7 +587,7 @@ function P(e, t, n) {
619
587
  }
620
588
  //#endregion
621
589
  //#region src/hooks/editor/utils/set-editor-editable-height.ts
622
- function F(e, t) {
590
+ function k(e, t) {
623
591
  let { editing: n } = e;
624
592
  n.view.change((e) => {
625
593
  e.setStyle("height", `${t}px`, n.view.document.getRoot());
@@ -627,34 +595,34 @@ function F(e, t) {
627
595
  }
628
596
  //#endregion
629
597
  //#region src/hooks/editor/utils/wrap-with-watchdog.ts
630
- var I = Symbol.for("livewire-editor-watchdog");
631
- async function L(e, t) {
598
+ var A = Symbol.for("livewire-editor-watchdog");
599
+ async function j(e, t) {
632
600
  let { EditorWatchdog: n } = await import("ckeditor5"), r = new n(null, t ?? {
633
601
  crashNumberLimit: 10,
634
602
  minimumNonErrorTimePeriod: 5e3
635
603
  });
636
604
  return r.setCreator(async () => {
637
605
  let t = await e();
638
- return t[I] = r, t;
606
+ return t[A] = r, t;
639
607
  }), r;
640
608
  }
641
- function R(e) {
642
- return I in e ? e[I] : null;
609
+ function M(e) {
610
+ return A in e ? e[A] : null;
643
611
  }
644
612
  //#endregion
645
613
  //#region src/hooks/context/contexts-registry.ts
646
- var z = class e extends r {
614
+ var N = class e extends r {
647
615
  static the = new e();
648
- }, B = class extends e {
616
+ }, P = class extends e {
649
617
  contextPromise = null;
650
618
  async mounted() {
651
- let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: a, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await w(a ?? []), u = [...await T(t, l), O(r || {})].filter((e) => !o(e));
619
+ let { contextId: e, language: t, context: n } = this.canonical, { customTranslations: r, watchdogConfig: i, config: { plugins: o, ...s } } = n, { loadedPlugins: c, hasPremium: l } = await b(o ?? []), u = [...await x(t, l), w(r || {})].filter((e) => !a(e));
652
620
  this.contextPromise = (async () => {
653
621
  let { ContextWatchdog: e, Context: n } = await import("ckeditor5"), r = new e(n, {
654
622
  crashNumberLimit: 10,
655
623
  ...i
656
- }), a = M(s);
657
- return a = N([...u].reverse(), t.ui, a), await r.create({
624
+ }), a = E(s);
625
+ return a = D([...u].reverse(), t.ui, a), await r.create({
658
626
  ...a,
659
627
  language: t,
660
628
  plugins: c,
@@ -665,7 +633,7 @@ var z = class e extends r {
665
633
  })();
666
634
  let d = await this.contextPromise;
667
635
  /* v8 ignore next if -- @preserve */
668
- this.isBeingDestroyed() || z.the.register(e, d);
636
+ this.isBeingDestroyed() || N.the.register(e, d);
669
637
  }
670
638
  async destroyed() {
671
639
  let { contextId: e } = this.canonical;
@@ -673,15 +641,15 @@ var z = class e extends r {
673
641
  try {
674
642
  await (await this.contextPromise)?.destroy();
675
643
  } finally {
676
- this.contextPromise = null, z.the.hasItem(e) && z.the.unregister(e);
644
+ this.contextPromise = null, N.the.hasItem(e) && N.the.unregister(e);
677
645
  }
678
646
  }
679
- }, V = class e extends r {
647
+ }, F = class e extends r {
680
648
  static the = new e();
681
649
  };
682
650
  //#endregion
683
651
  //#region src/hooks/utils/is-wire-model-connected.ts
684
- function H(e) {
652
+ function I(e) {
685
653
  let t = e;
686
654
  for (; t;) {
687
655
  for (let e of t.attributes) if (e.name.startsWith("wire:model")) return !0;
@@ -691,7 +659,7 @@ function H(e) {
691
659
  }
692
660
  //#endregion
693
661
  //#region src/hooks/utils/root-attributes-updater.ts
694
- function U(e, t) {
662
+ function L(e, t) {
695
663
  let n = /* @__PURE__ */ new Set();
696
664
  return (r) => {
697
665
  e.model.enqueueChange({ isUndoable: !1 }, (i) => {
@@ -705,11 +673,11 @@ function U(e, t) {
705
673
  }
706
674
  //#endregion
707
675
  //#region src/hooks/editable.ts
708
- var W = class extends e {
676
+ var R = class extends e {
709
677
  rootAttributesUpdater = null;
710
678
  pendingContent = null;
711
679
  mounted() {
712
- let { editorId: e, rootName: t, content: n } = this.canonical, r = V.the.mountEffect(e, (e) => {
680
+ let { editorId: e, rootName: t, content: n } = this.canonical, r = F.the.mountEffect(e, (e) => {
713
681
  /* v8 ignore next if -- @preserve */
714
682
  if (this.isBeingDestroyed()) return;
715
683
  let r = e.model.document.getRoot(t);
@@ -718,7 +686,7 @@ var W = class extends e {
718
686
  r && r !== n && e.setData({ [t]: n });
719
687
  }
720
688
  /* v8 ignore next else -- @preserve */
721
- if (!r && b(e)) {
689
+ if (!r && g(e)) {
722
690
  let { ui: r, editing: i } = e;
723
691
  e.addRoot(t, {
724
692
  isUndoable: !1,
@@ -733,7 +701,7 @@ var W = class extends e {
733
701
  if (i(), a(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
734
702
  let n = e.model.document.getRoot(t);
735
703
  /* v8 ignore next if -- @preserve */
736
- if (n && b(e)) {
704
+ if (n && g(e)) {
737
705
  try {
738
706
  /* v8 ignore else -- @preserve */
739
707
  e.ui.view.editables[t] && e.detachEditable(n);
@@ -749,7 +717,7 @@ var W = class extends e {
749
717
  this.onBeforeDestroy(r);
750
718
  }
751
719
  async afterCommitSynced() {
752
- let { editorId: e } = this.canonical, t = await V.the.waitFor(e);
720
+ let { editorId: e } = this.canonical, t = await F.the.waitFor(e);
753
721
  this.applyCanonicalContentToEditor(t), this.applyRootAttributes(t);
754
722
  }
755
723
  destroyed() {
@@ -778,7 +746,7 @@ var W = class extends e {
778
746
  };
779
747
  }
780
748
  applyCanonicalContentToEditor(e) {
781
- if (!H(this.element)) return;
749
+ if (!I(this.element)) return;
782
750
  let { content: t, rootName: n } = this.canonical, { ui: r } = e;
783
751
  if (e.getData({ rootName: n }) !== (t ?? "")) {
784
752
  if (r.focusTracker.isFocused) {
@@ -790,12 +758,12 @@ var W = class extends e {
790
758
  }
791
759
  applyRootAttributes(e) {
792
760
  let { rootName: t, rootAttributes: n } = this.canonical;
793
- this.rootAttributesUpdater ??= U(e, t), this.rootAttributesUpdater(n);
761
+ this.rootAttributesUpdater ??= L(e, t), this.rootAttributesUpdater(n);
794
762
  }
795
763
  };
796
764
  //#endregion
797
765
  //#region src/hooks/editor/plugins/livewire-sync.ts
798
- async function G({ saveDebounceMs: e, component: t }) {
766
+ async function z({ saveDebounceMs: e, component: t }) {
799
767
  let { Plugin: n } = await import("ckeditor5");
800
768
  return class extends n {
801
769
  static get pluginName() {
@@ -807,15 +775,15 @@ async function G({ saveDebounceMs: e, component: t }) {
807
775
  setupAfterCommitHandler() {
808
776
  let { editor: e } = this, { model: n, ui: { focusTracker: r } } = e, i = null;
809
777
  e.on("afterCommitSynced", () => {
810
- if (!H(t.element)) return;
778
+ if (!I(t.element)) return;
811
779
  let { content: n } = t.canonical, a = this.getEditorRootsValues();
812
780
  if (r.isFocused) {
813
781
  /* v8 ignore next else -- @preserve */
814
- c(n, a) || (i = n);
782
+ s(n, a) || (i = n);
815
783
  return;
816
784
  }
817
785
  /* v8 ignore next else -- @preserve */
818
- c(n, a) || e.setData(n);
786
+ s(n, a) || e.setData(n);
819
787
  }), n.document.on("change:data", () => {
820
788
  i = null;
821
789
  }), r.on("change:isFocused", () => {
@@ -830,17 +798,17 @@ async function G({ saveDebounceMs: e, component: t }) {
830
798
  }
831
799
  setupSetEditorContentHandler() {
832
800
  let { editor: e } = this, n = Livewire.on("set-editor-content", ({ editorId: n, content: r }) => {
833
- n === t.canonical.editorId && (c(this.getEditorRootsValues(), r) || e.setData(r));
801
+ n === t.canonical.editorId && (s(this.getEditorRootsValues(), r) || e.setData(r));
834
802
  });
835
803
  /* v8 ignore next if -- @preserve */
836
804
  typeof n == "function" && e.once("destroy", n);
837
805
  }
838
806
  setupTypingContentPush() {
839
- let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t, s = !1, l = () => {
807
+ let { editor: n } = this, { model: r, ui: a } = n, { $wire: o } = t, c = !1, l = () => {
840
808
  /* v8 ignore next if -- @preserve */
841
- if (s) return;
809
+ if (c) return;
842
810
  let e = this.getEditorRootsValues();
843
- c(e, t.canonical.content ?? {}) || (o.set("content", e), o.dispatch("editor-content-changed", {
811
+ s(e, t.canonical.content ?? {}) || (o.set("content", e), o.dispatch("editor-content-changed", {
844
812
  editorId: t.canonical.editorId,
845
813
  content: e
846
814
  }));
@@ -848,24 +816,24 @@ async function G({ saveDebounceMs: e, component: t }) {
848
816
  r.document.on("change:data", i(10, () => {
849
817
  a.focusTracker.isFocused ? u() : l();
850
818
  })), n.once("ready", l), n.once("destroy", () => {
851
- s = !0;
819
+ c = !0;
852
820
  });
853
821
  }
854
822
  setupFocusableEventPush() {
855
823
  let { ui: e } = this.editor, { $wire: n } = t;
856
824
  e.focusTracker.on("change:isFocused", () => {
857
825
  let r = this.getEditorRootsValues();
858
- n.set("focused", e.focusTracker.isFocused), c(r, t.canonical.content ?? {}) || n.set("content", r);
826
+ n.set("focused", e.focusTracker.isFocused), s(r, t.canonical.content ?? {}) || n.set("content", r);
859
827
  });
860
828
  }
861
829
  getEditorRootsValues() {
862
- return y(this.editor);
830
+ return h(this.editor);
863
831
  }
864
832
  };
865
833
  }
866
834
  //#endregion
867
835
  //#region src/hooks/editor/plugins/sync-editor-with-input.ts
868
- async function K(e) {
836
+ async function B(e) {
869
837
  let { Plugin: t } = await import("ckeditor5");
870
838
  return class extends t {
871
839
  input = null;
@@ -891,101 +859,88 @@ async function K(e) {
891
859
  }
892
860
  //#endregion
893
861
  //#region src/hooks/editor/editor.ts
894
- var q = class extends e {
862
+ var V = class extends e {
895
863
  rootAttributesUpdater = null;
896
864
  async mounted() {
897
865
  let { editorId: e } = this.canonical;
898
- V.the.resetErrors(e);
866
+ F.the.resetErrors(e);
899
867
  try {
900
- let t = await this.createEditor(), n = v(t), r = R(t);
868
+ let t = await this.createEditor(), n = m(t), r = M(t);
901
869
  /* v8 ignore next 3 */
902
870
  if (this.isBeingDestroyed()) return;
903
- let i = V.the.mountEffect(e, (t) => {
871
+ let i = F.the.mountEffect(e, (t) => {
904
872
  t.once("destroy", () => {
905
- V.the.unregister(e, !1);
873
+ F.the.unregister(e, !1);
906
874
  }, { priority: "highest" });
907
875
  });
908
876
  this.onBeforeDestroy(async () => {
909
- V.the.unregister(e), i(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : r ? await r.destroy() : await t.destroy();
910
- }), V.the.register(e, t);
877
+ F.the.unregister(e), i(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : r ? await r.destroy() : await t.destroy();
878
+ }), F.the.register(e, t);
911
879
  } catch (t) {
912
- console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t), V.the.error(e, t);
880
+ console.error(`Error initializing CKEditor5 instance with ID "${e}":`, t), F.the.error(e, t);
913
881
  }
914
882
  }
915
883
  async destroyed() {
916
884
  this.element.style.display = "none";
917
885
  }
918
886
  async afterCommitSynced() {
919
- let e = await V.the.waitFor(this.canonical.editorId);
887
+ let e = await F.the.waitFor(this.canonical.editorId);
920
888
  /* v8 ignore if -- @preserve */
921
889
  e && (e.fire("afterCommitSynced"), this.applyRootAttributes(e));
922
890
  }
923
891
  applyRootAttributes(e) {
924
892
  let { rootAttributes: t } = this.canonical;
925
- this.rootAttributesUpdater ??= U(e, "main"), this.rootAttributesUpdater(t);
893
+ this.rootAttributesUpdater ??= L(e, "main"), this.rootAttributesUpdater(t);
926
894
  }
927
895
  async createEditor() {
928
- let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language: a, watchdog: s, content: c } = this.canonical, { customTranslations: l, editorType: u, licenseKey: f, watchdogConfig: m, config: { plugins: g, ...v } } = e, y = await S(u), b = await (n ? z.the.waitFor(n) : null), C = async () => {
929
- let { loadedPlugins: e, hasPremium: n } = await w(g);
930
- e.push(await G({
896
+ let { preset: e, editorId: t, contextId: n, editableHeight: r, saveDebounceMs: i, language: o, watchdog: s } = this.canonical, { customTranslations: c, editorType: l, licenseKey: f, watchdogConfig: m, config: { plugins: h, ...g } } = e, y = await v(l), S = await (n ? N.the.waitFor(n) : null), C = async () => {
897
+ let { loadedPlugins: e, hasPremium: n } = await b(h);
898
+ e.push(await z({
931
899
  saveDebounceMs: i,
932
900
  component: this
933
- })), x(u) && e.push(await K(i));
934
- let s = [...await T(a, n), O(l || {})].filter((e) => !o(e)), m = {
935
- ...c,
936
- ...j(t)
901
+ })), _(l) && e.push(await B(i));
902
+ let s = [...await x(o, n), w(c || {})].filter((e) => !a(e)), d = T(t), m = Object.keys(d);
903
+ _(l) && m.push("main"), H(d, m) || (d = await U(t, m));
904
+ let v = {
905
+ ...g,
906
+ licenseKey: f,
907
+ plugins: e,
908
+ language: o,
909
+ ...s.length && { translations: s }
937
910
  };
938
- x(u) && (m = m.main || "");
939
- let h = await (async () => {
940
- let n = k(t);
941
- if (!(n instanceof HTMLElement) && !("main" in n)) {
942
- let e = u === "decoupled" ? ["main"] : Object.keys(m);
943
- J(n, e) || (n = await Y(t, e), m = {
944
- ...c,
945
- ...j(t)
946
- });
947
- }
948
- x(u) && "main" in n && (n = n.main);
949
- let r = {
950
- ...v,
951
- licenseKey: f,
952
- plugins: e,
953
- language: a,
954
- ...s.length && { translations: s }
955
- };
956
- return r = M(r), r = N([...s].reverse(), a.ui, r), r = p(y, n, r), r = d(m, r), b ? (await _({
957
- context: b,
958
- creator: y,
959
- config: r
960
- })).editor : y.create(r);
961
- })();
962
- return x(u) && r && F(h, r), this.applyRootAttributes(h), h;
911
+ v = E(v), v = D([...s].reverse(), o.ui, v), v = u(y, d, v);
912
+ let C = await (async () => S ? (await p({
913
+ context: S,
914
+ creator: y,
915
+ config: v
916
+ })).editor : y.create(v))();
917
+ return _(l) && r && k(C, r), this.applyRootAttributes(C), C;
963
918
  };
964
- if (s && !b) {
965
- let e = await L(C, m);
919
+ if (s && !S) {
920
+ let e = await j(C, m);
966
921
  return e.on("error", (e, { causesRestart: n }) => {
967
922
  if (n) {
968
- let e = V.the.getItem(t);
923
+ let e = F.the.getItem(t);
969
924
  /* v8 ignore next 3 */
970
- e && (h(e), V.the.unregister(t));
925
+ e && (d(e), F.the.unregister(t));
971
926
  }
972
927
  }), e.on("restart", () => {
973
- V.the.register(t, e.editor);
928
+ F.the.register(t, e.editor);
974
929
  }), await e.create({}), e.editor;
975
930
  }
976
931
  return C();
977
932
  }
978
933
  };
979
- function J(e, t) {
980
- return t.every((t) => e[t]);
934
+ function H(e, t) {
935
+ return t.every((t) => e[t]?.element);
981
936
  }
982
- async function Y(e, t) {
983
- return u(() => {
984
- let n = k(e);
985
- if (!J(n, t)) throw Error(`It looks like not all required root elements are present yet.
937
+ async function U(e, t) {
938
+ return l(() => {
939
+ let n = T(e);
940
+ if (!H(n, t)) throw Error(`It looks like not all required root elements are present yet.
986
941
  * If you want to wait for them, ensure they are registered before editor initialization.
987
942
  * If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
988
- Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
943
+ Missing roots: ${t.filter((e) => !n[e]?.element).join(", ")}.`);
989
944
  return n;
990
945
  }, {
991
946
  timeOutAfter: 2e3,
@@ -994,12 +949,12 @@ Missing roots: ${t.filter((e) => !n[e]).join(", ")}.`);
994
949
  }
995
950
  //#endregion
996
951
  //#region src/hooks/ui-part.ts
997
- var X = class extends e {
952
+ var W = class extends e {
998
953
  mounted() {
999
- let { editorId: e, name: t } = this.canonical, n = V.the.mountEffect(e, (e) => {
954
+ let { editorId: e, name: t } = this.canonical, n = F.the.mountEffect(e, (e) => {
1000
955
  /* v8 ignore next if -- @preserve */
1001
956
  if (this.isBeingDestroyed()) return;
1002
- let { ui: n } = e, r = Z(t), i = n.view[r];
957
+ let { ui: n } = e, r = G(t), i = n.view[r];
1003
958
  if (!i) {
1004
959
  console.error(`Unknown UI part name: "${t}". Supported names are "toolbar" and "menubar".`);
1005
960
  return;
@@ -1014,7 +969,7 @@ var X = class extends e {
1014
969
  this.element.style.display = "none";
1015
970
  }
1016
971
  };
1017
- function Z(e) {
972
+ function G(e) {
1018
973
  switch (e) {
1019
974
  case "toolbar": return "toolbar";
1020
975
  case "menubar": return "menuBarView";
@@ -1023,19 +978,19 @@ function Z(e) {
1023
978
  }
1024
979
  //#endregion
1025
980
  //#region src/hooks/index.ts
1026
- var Q = {
1027
- ckeditor5: q,
1028
- "ckeditor5-context": B,
1029
- "ckeditor5-ui-part": X,
1030
- "ckeditor5-editable": W
981
+ var K = {
982
+ ckeditor5: V,
983
+ "ckeditor5-context": P,
984
+ "ckeditor5-ui-part": W,
985
+ "ckeditor5-editable": R
1031
986
  };
1032
- function $() {
1033
- for (let [e, n] of Object.entries(Q)) t(e, n);
987
+ function q() {
988
+ for (let [e, n] of Object.entries(K)) t(e, n);
1034
989
  }
1035
990
  //#endregion
1036
991
  //#region src/index.ts
1037
- $();
992
+ q();
1038
993
  //#endregion
1039
- export { e as ClassHook, z as ContextsRegistry, C as CustomEditorPluginsRegistry, W as EditableComponentHook, q as EditorComponentHook, V as EditorsRegistry, X as UIPartComponentHook, t as registerLivewireComponentHook };
994
+ export { e as ClassHook, N as ContextsRegistry, y as CustomEditorPluginsRegistry, R as EditableComponentHook, V as EditorComponentHook, F as EditorsRegistry, W as UIPartComponentHook, t as registerLivewireComponentHook };
1040
995
 
1041
996
  //# sourceMappingURL=index.mjs.map