ckeditor5-livewire 1.12.2 → 1.13.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
@@ -212,6 +212,7 @@ function u(e, t, n) {
212
212
  ...n.roots?.[i],
213
213
  ...i === "main" ? n.root : {},
214
214
  ...i in t ? {
215
+ modelElement: t[i].modelElement || "$root",
215
216
  ...t[i].content !== null && { initialData: t[i].content },
216
217
  ...!r && t[i].element !== null && { element: t[i].element }
217
218
  } : {}
@@ -269,7 +270,7 @@ function m(e) {
269
270
  //#endregion
270
271
  //#region src/hooks/editor/utils/get-editor-roots-values.ts
271
272
  function h(e) {
272
- return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create({}));
273
+ return e.model.document.getRootNames().reduce((t, n) => (t[n] = e.getData({ rootName: n }), t), Object.create(null));
273
274
  }
274
275
  //#endregion
275
276
  //#region src/hooks/editor/utils/is-multiroot-editor-instance.ts
@@ -528,26 +529,30 @@ function w(e) {
528
529
  //#region src/hooks/editor/utils/query-all-editor-editables.ts
529
530
  function T(e) {
530
531
  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
+ let r = t.rootName, i = t.modelElement || null;
532
533
  return e[r] = {
533
534
  element: n.querySelector("[data-cke-editable-content]"),
534
- content: t.content
535
+ content: t.content,
536
+ modelElement: i
535
537
  }, e;
536
- }, Object.create({})), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e);
538
+ }, Object.create(null)), n = window.Livewire.all().find(({ name: t, canonical: n }) => t === "ckeditor5" && n.editorId === e);
537
539
  /* v8 ignore next -- @preserve */
538
540
  if (!n) return t;
539
541
  // 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 ?? ""
542
+ let r = n.canonical.content ?? {}, i = n.canonical.modelElement || null, a = document.querySelector(`#${e}_editor`);
543
+ "main" in t ? t.main.modelElement ??= i : a && (t.main = {
544
+ element: a,
545
+ content: r.main ?? "",
546
+ modelElement: i
544
547
  });
545
548
  for (let [e, n] of Object.entries(r)) t[e] ? t[e] = {
546
549
  ...t[e],
547
- content: t[e].content ?? n
550
+ content: t[e].content ?? n,
551
+ modelElement: t[e].modelElement ?? i
548
552
  } : t[e] = {
549
553
  element: null,
550
- content: n
554
+ content: n,
555
+ modelElement: i
551
556
  };
552
557
  return t;
553
558
  }
@@ -677,28 +682,29 @@ var R = class extends e {
677
682
  rootAttributesUpdater = null;
678
683
  pendingContent = null;
679
684
  mounted() {
680
- let { editorId: e, rootName: t, content: n } = this.canonical, r = F.the.mountEffect(e, (e) => {
685
+ let { editorId: e, rootName: t, content: n, modelElement: r } = this.canonical, i = F.the.mountEffect(e, (e) => {
681
686
  /* v8 ignore next if -- @preserve */
682
687
  if (this.isBeingDestroyed()) return;
683
- let r = e.model.document.getRoot(t);
684
- if (r?.isAttached() && n !== null) {
688
+ let i = e.model.document.getRoot(t);
689
+ if (i?.isAttached() && n !== null) {
685
690
  let r = e.getData({ rootName: t });
686
691
  r && r !== n && e.setData({ [t]: n });
687
692
  }
688
693
  /* v8 ignore next else -- @preserve */
689
- if (!r && g(e)) {
690
- let { ui: r, editing: i } = e;
694
+ if (!i && g(e)) {
695
+ let { ui: i, editing: a } = e;
691
696
  e.addRoot(t, {
692
697
  isUndoable: !1,
698
+ modelElement: r ?? "$root",
693
699
  ...n !== null && { initialData: n }
694
700
  });
695
- let a = this.element.querySelector("[data-cke-editable-content]"), o = r.view.createEditable(t, a);
696
- r.addEditable(o), i.view.forceRender();
701
+ let o = this.element.querySelector("[data-cke-editable-content]"), s = i.view.createEditable(t, o);
702
+ i.addEditable(s), a.view.forceRender();
697
703
  }
698
- let i = this.syncTypingContentPush(e), a = this.setupPendingReceivedContentHandlers(e);
704
+ let a = this.syncTypingContentPush(e), o = this.setupPendingReceivedContentHandlers(e);
699
705
  return this.applyRootAttributes(e), () => {
700
706
  /* v8 ignore next else -- @preserve */
701
- if (i(), a(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
707
+ if (a(), o(), this.rootAttributesUpdater?.(null), e.state !== "destroyed") {
702
708
  let n = e.model.document.getRoot(t);
703
709
  /* v8 ignore next if -- @preserve */
704
710
  if (n && g(e)) {
@@ -714,7 +720,7 @@ var R = class extends e {
714
720
  }
715
721
  };
716
722
  });
717
- this.onBeforeDestroy(r);
723
+ this.onBeforeDestroy(i);
718
724
  }
719
725
  async afterCommitSynced() {
720
726
  let { editorId: e } = this.canonical, t = await F.the.waitFor(e);