ckeditor5-livewire 1.2.10 → 1.3.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/hooks/editable.d.ts +17 -0
- package/dist/hooks/editable.d.ts.map +1 -1
- package/dist/hooks/editor/plugins/livewire-sync.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +182 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/editable.test.ts +131 -6
- package/src/hooks/editable.ts +89 -32
- package/src/hooks/editor/plugins/livewire-sync.ts +26 -18
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class P {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
this.livewireComponent = t;
|
|
4
4
|
}
|
|
@@ -31,7 +31,7 @@ class C {
|
|
|
31
31
|
return ["destroyed", "destroying"].includes(this.state);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function _(i, t) {
|
|
35
35
|
const e = /* @__PURE__ */ new Map();
|
|
36
36
|
window.Livewire?.hook("component.init", async ({ component: r, cleanup: n }) => {
|
|
37
37
|
if (r.name !== i)
|
|
@@ -47,7 +47,7 @@ function U(i, t) {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
class
|
|
50
|
+
class L {
|
|
51
51
|
/**
|
|
52
52
|
* Map of registered items.
|
|
53
53
|
*/
|
|
@@ -221,18 +221,18 @@ function D(i, t) {
|
|
|
221
221
|
}, i);
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function K(i, t) {
|
|
225
225
|
const e = Object.entries(i).filter(([r, n]) => t(n, r));
|
|
226
226
|
return Object.fromEntries(e);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function A(i) {
|
|
229
229
|
return Object.keys(i).length === 0 && i.constructor === Object;
|
|
230
230
|
}
|
|
231
231
|
function O(i, t) {
|
|
232
232
|
const e = Object.entries(i).map(([r, n]) => [r, t(n, r)]);
|
|
233
233
|
return Object.fromEntries(e);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function b(i, t) {
|
|
236
236
|
if (i === t)
|
|
237
237
|
return !0;
|
|
238
238
|
const e = Object.keys(i), r = Object.keys(t);
|
|
@@ -243,10 +243,10 @@ function P(i, t) {
|
|
|
243
243
|
return !1;
|
|
244
244
|
return !0;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function G() {
|
|
247
247
|
return Math.random().toString(36).substring(2);
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function Y(i, {
|
|
250
250
|
timeOutAfter: t = 500,
|
|
251
251
|
retryAfter: e = 100
|
|
252
252
|
} = {}) {
|
|
@@ -266,9 +266,9 @@ function G(i, {
|
|
|
266
266
|
c();
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
|
-
const
|
|
270
|
-
async function
|
|
271
|
-
const n =
|
|
269
|
+
const T = Symbol.for("context-editor-watchdog");
|
|
270
|
+
async function X({ element: i, context: t, creator: e, config: r }) {
|
|
271
|
+
const n = G();
|
|
272
272
|
await t.add({
|
|
273
273
|
creator: (c, u) => e.create(c, u),
|
|
274
274
|
id: n,
|
|
@@ -281,23 +281,23 @@ async function Y({ element: i, context: t, creator: e, config: r }) {
|
|
|
281
281
|
editorContextId: n,
|
|
282
282
|
context: t
|
|
283
283
|
};
|
|
284
|
-
a[
|
|
284
|
+
a[T] = s;
|
|
285
285
|
const o = t.destroy.bind(t);
|
|
286
286
|
return t.destroy = async () => (s.state = "unavailable", o()), {
|
|
287
287
|
...s,
|
|
288
288
|
editor: a
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
function X(i) {
|
|
292
|
-
return I in i ? i[I] : null;
|
|
293
|
-
}
|
|
294
291
|
function J(i) {
|
|
292
|
+
return T in i ? i[T] : null;
|
|
293
|
+
}
|
|
294
|
+
function Q(i) {
|
|
295
295
|
return i.model.document.getRootNames().reduce((e, r) => (e[r] = i.getData({ rootName: r }), e), /* @__PURE__ */ Object.create({}));
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function C(i) {
|
|
298
298
|
return ["inline", "classic", "balloon", "decoupled"].includes(i);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function W(i) {
|
|
301
301
|
let t = i;
|
|
302
302
|
for (; t; ) {
|
|
303
303
|
for (const e of t.attributes)
|
|
@@ -379,7 +379,7 @@ class S {
|
|
|
379
379
|
return this.plugins.has(t);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
async function
|
|
382
|
+
async function F(i) {
|
|
383
383
|
const t = await import("ckeditor5");
|
|
384
384
|
let e = null;
|
|
385
385
|
const r = i.map(async (n) => {
|
|
@@ -728,7 +728,7 @@ function j(i) {
|
|
|
728
728
|
dictionary: t
|
|
729
729
|
}));
|
|
730
730
|
}
|
|
731
|
-
function
|
|
731
|
+
function N(i) {
|
|
732
732
|
const t = q(i);
|
|
733
733
|
return O(t, ({ element: e }) => e);
|
|
734
734
|
}
|
|
@@ -754,15 +754,15 @@ function q(i) {
|
|
|
754
754
|
}
|
|
755
755
|
} : t;
|
|
756
756
|
}
|
|
757
|
-
function
|
|
757
|
+
function z(i) {
|
|
758
758
|
const t = q(i), e = O(t, ({ content: r }) => r);
|
|
759
|
-
return
|
|
759
|
+
return K(e, (r) => typeof r == "string");
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function I(i) {
|
|
762
762
|
if (!i || typeof i != "object")
|
|
763
763
|
return i;
|
|
764
764
|
if (Array.isArray(i))
|
|
765
|
-
return i.map((r) =>
|
|
765
|
+
return i.map((r) => I(r));
|
|
766
766
|
const t = i;
|
|
767
767
|
if (t.$element && typeof t.$element == "string") {
|
|
768
768
|
const r = document.querySelector(t.$element);
|
|
@@ -770,7 +770,7 @@ function x(i) {
|
|
|
770
770
|
}
|
|
771
771
|
const e = /* @__PURE__ */ Object.create(null);
|
|
772
772
|
for (const [r, n] of Object.entries(i))
|
|
773
|
-
e[r] =
|
|
773
|
+
e[r] = I(n);
|
|
774
774
|
return e;
|
|
775
775
|
}
|
|
776
776
|
function et(i, t) {
|
|
@@ -779,12 +779,12 @@ function et(i, t) {
|
|
|
779
779
|
r.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
780
780
|
});
|
|
781
781
|
}
|
|
782
|
-
const
|
|
782
|
+
const x = Symbol.for("elixir-editor-watchdog");
|
|
783
783
|
async function rt(i) {
|
|
784
784
|
const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(i);
|
|
785
785
|
return e.setCreator(async (...r) => {
|
|
786
786
|
const n = await i.create(...r);
|
|
787
|
-
return n[
|
|
787
|
+
return n[x] = e, n;
|
|
788
788
|
}), {
|
|
789
789
|
watchdog: e,
|
|
790
790
|
Constructor: {
|
|
@@ -793,12 +793,12 @@ async function rt(i) {
|
|
|
793
793
|
};
|
|
794
794
|
}
|
|
795
795
|
function it(i) {
|
|
796
|
-
return
|
|
796
|
+
return x in i ? i[x] : null;
|
|
797
797
|
}
|
|
798
|
-
class
|
|
799
|
-
static the = new
|
|
798
|
+
class h extends L {
|
|
799
|
+
static the = new h();
|
|
800
800
|
}
|
|
801
|
-
class nt extends
|
|
801
|
+
class nt extends P {
|
|
802
802
|
/**
|
|
803
803
|
* The promise that resolves to the context instance.
|
|
804
804
|
*/
|
|
@@ -807,28 +807,28 @@ class nt extends C {
|
|
|
807
807
|
* Mounts the context component.
|
|
808
808
|
*/
|
|
809
809
|
async mounted() {
|
|
810
|
-
const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: n, watchdogConfig: a, config: { plugins: s, ...o } } = r, { loadedPlugins: c, hasPremium: u } = await
|
|
810
|
+
const { contextId: t, language: e, context: r } = this.canonical, { customTranslations: n, watchdogConfig: a, config: { plugins: s, ...o } } = r, { loadedPlugins: c, hasPremium: u } = await F(s ?? []), k = [
|
|
811
811
|
...await V(e, u),
|
|
812
812
|
j(n || {})
|
|
813
|
-
].filter((
|
|
813
|
+
].filter((f) => !A(f));
|
|
814
814
|
this.contextPromise = (async () => {
|
|
815
|
-
const { ContextWatchdog:
|
|
815
|
+
const { ContextWatchdog: f, Context: p } = await import("ckeditor5"), w = new f(p, {
|
|
816
816
|
crashNumberLimit: 10,
|
|
817
817
|
...a
|
|
818
818
|
});
|
|
819
|
-
return await
|
|
819
|
+
return await w.create({
|
|
820
820
|
...o,
|
|
821
821
|
language: e,
|
|
822
822
|
plugins: c,
|
|
823
|
-
...
|
|
824
|
-
translations:
|
|
823
|
+
...k.length && {
|
|
824
|
+
translations: k
|
|
825
825
|
}
|
|
826
|
-
}),
|
|
827
|
-
console.error("Context item error:", ...
|
|
828
|
-
}),
|
|
826
|
+
}), w.on("itemError", (...g) => {
|
|
827
|
+
console.error("Context item error:", ...g);
|
|
828
|
+
}), w;
|
|
829
829
|
})();
|
|
830
|
-
const
|
|
831
|
-
this.isBeingDestroyed() ||
|
|
830
|
+
const v = await this.contextPromise;
|
|
831
|
+
this.isBeingDestroyed() || h.the.register(t, v);
|
|
832
832
|
}
|
|
833
833
|
/**
|
|
834
834
|
* Destroys the context component. Unmounts root from the editor.
|
|
@@ -839,59 +839,96 @@ class nt extends C {
|
|
|
839
839
|
try {
|
|
840
840
|
await (await this.contextPromise)?.destroy();
|
|
841
841
|
} finally {
|
|
842
|
-
this.contextPromise = null,
|
|
842
|
+
this.contextPromise = null, h.the.hasItem(t) && h.the.unregister(t);
|
|
843
843
|
}
|
|
844
844
|
}
|
|
845
845
|
}
|
|
846
|
-
class
|
|
847
|
-
static the = new
|
|
846
|
+
class m extends L {
|
|
847
|
+
static the = new m();
|
|
848
848
|
}
|
|
849
|
-
class at extends
|
|
849
|
+
class at extends P {
|
|
850
850
|
/**
|
|
851
851
|
* The promise that resolves when the editable is mounted.
|
|
852
852
|
*/
|
|
853
853
|
editorPromise = null;
|
|
854
|
+
/**
|
|
855
|
+
* Pending content to apply when the editor loses focus.
|
|
856
|
+
*/
|
|
857
|
+
pendingContent = null;
|
|
854
858
|
/**
|
|
855
859
|
* Mounts the editable component.
|
|
856
860
|
*/
|
|
857
861
|
mounted() {
|
|
858
|
-
const { editorId: t, rootName: e, content: r
|
|
859
|
-
this.editorPromise =
|
|
862
|
+
const { editorId: t, rootName: e, content: r } = this.canonical;
|
|
863
|
+
this.editorPromise = m.the.execute(t, (n) => {
|
|
860
864
|
if (this.isBeingDestroyed())
|
|
861
865
|
return null;
|
|
862
|
-
const { ui:
|
|
863
|
-
if (
|
|
866
|
+
const { ui: a, editing: s, model: o } = n;
|
|
867
|
+
if (o.document.getRoot(e)) {
|
|
864
868
|
if (r !== null) {
|
|
865
|
-
const
|
|
866
|
-
|
|
869
|
+
const c = n.getData({ rootName: e });
|
|
870
|
+
c && c !== r && n.setData({
|
|
867
871
|
[e]: r
|
|
868
872
|
});
|
|
869
873
|
}
|
|
870
|
-
|
|
874
|
+
} else {
|
|
875
|
+
n.addRoot(e, {
|
|
876
|
+
isUndoable: !1,
|
|
877
|
+
...r !== null && {
|
|
878
|
+
data: r
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
const c = this.element.querySelector("[data-cke-editable-content]"), u = a.view.createEditable(e, c);
|
|
882
|
+
a.addEditable(u), s.view.forceRender();
|
|
871
883
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
884
|
+
return this.syncTypingContentPush(n), this.setupPendingReceivedContentHandlers(n), n;
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Setups the content sync from the editor to Livewire on user input with debounce.
|
|
889
|
+
*/
|
|
890
|
+
syncTypingContentPush(t) {
|
|
891
|
+
const { rootName: e, saveDebounceMs: r } = this.canonical, n = this.element.querySelector("input"), a = () => {
|
|
892
|
+
const s = t.getData({ rootName: e });
|
|
893
|
+
n && (n.value = s), this.$wire.set("content", s);
|
|
894
|
+
};
|
|
895
|
+
t.model.document.on("change:data", D(r, a)), a();
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Sets up handlers that manage pending incoming content (clears pending
|
|
899
|
+
* content on user edits and applies pending content on blur).
|
|
900
|
+
*/
|
|
901
|
+
setupPendingReceivedContentHandlers(t) {
|
|
902
|
+
const { ui: e, model: r } = t, { rootName: n } = this.canonical;
|
|
903
|
+
r.document.on("change:data", () => {
|
|
904
|
+
this.pendingContent = null;
|
|
905
|
+
}), e.focusTracker.on("change:isFocused", () => {
|
|
906
|
+
!e.focusTracker.isFocused && this.pendingContent !== null && (t.setData({
|
|
907
|
+
[n]: this.pendingContent
|
|
908
|
+
}), this.pendingContent = null);
|
|
885
909
|
});
|
|
886
910
|
}
|
|
911
|
+
/**
|
|
912
|
+
* Applies canonical content to the editor while respecting focus/pending state.
|
|
913
|
+
*/
|
|
914
|
+
applyCanonicalContentToEditor(t) {
|
|
915
|
+
if (!W(this.element))
|
|
916
|
+
return;
|
|
917
|
+
const { content: e, rootName: r } = this.canonical, { ui: n } = t;
|
|
918
|
+
if (t.getData({ rootName: r }) !== (e ?? "")) {
|
|
919
|
+
if (n.focusTracker.isFocused) {
|
|
920
|
+
this.pendingContent = e ?? "";
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
t.setData({ [r]: e ?? "" });
|
|
924
|
+
}
|
|
925
|
+
}
|
|
887
926
|
/**
|
|
888
927
|
* Called when the component is updated by Livewire.
|
|
889
928
|
*/
|
|
890
929
|
async afterCommitSynced() {
|
|
891
|
-
const t = await this.editorPromise
|
|
892
|
-
|
|
893
|
-
[r]: e ?? ""
|
|
894
|
-
});
|
|
930
|
+
const t = await this.editorPromise;
|
|
931
|
+
this.applyCanonicalContentToEditor(t);
|
|
895
932
|
}
|
|
896
933
|
/**
|
|
897
934
|
* Destroys the editable component. Unmounts root from the editor.
|
|
@@ -922,41 +959,49 @@ async function st({
|
|
|
922
959
|
* Initializes the plugin.
|
|
923
960
|
*/
|
|
924
961
|
init() {
|
|
925
|
-
this.setupTypingContentPush(), this.setupFocusableEventPush(), this.
|
|
962
|
+
this.setupTypingContentPush(), this.setupFocusableEventPush(), this.setupAfterCommitHandler(), this.setupSetEditorContentHandler();
|
|
926
963
|
}
|
|
927
964
|
/**
|
|
928
|
-
* Setups the content
|
|
965
|
+
* Setups handler that updates the editor content after Livewire changes attributes
|
|
966
|
+
* on the component and commits the changes, but only if the editor is not focused to prevent
|
|
967
|
+
* disrupting the user while editing.
|
|
929
968
|
*/
|
|
930
|
-
|
|
969
|
+
setupAfterCommitHandler() {
|
|
931
970
|
const { editor: n } = this, { model: a, ui: { focusTracker: s } } = n;
|
|
932
971
|
let o = null;
|
|
933
972
|
n.on("afterCommitSynced", () => {
|
|
973
|
+
if (!W(t.element))
|
|
974
|
+
return;
|
|
934
975
|
const { content: c } = t.canonical, u = this.getEditorRootsValues();
|
|
935
|
-
if (
|
|
936
|
-
|
|
937
|
-
P(c, u) || (o = c);
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
P(c, u) || n.setData(c);
|
|
941
|
-
}
|
|
942
|
-
}), Livewire.on("set-editor-content", ({ editorId: c, content: u }) => {
|
|
943
|
-
if (c !== t.canonical.editorId)
|
|
976
|
+
if (s.isFocused) {
|
|
977
|
+
b(c, u) || (o = c);
|
|
944
978
|
return;
|
|
945
|
-
|
|
946
|
-
|
|
979
|
+
}
|
|
980
|
+
b(c, u) || n.setData(c);
|
|
947
981
|
}), a.document.on("change:data", () => {
|
|
948
982
|
o = null;
|
|
949
983
|
}), s.on("change:isFocused", () => {
|
|
950
984
|
!s.isFocused && o !== null && (n.setData(o), o = null);
|
|
951
985
|
});
|
|
952
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* Setups the content sync from Livewire to the editor when Livewire emits an event.
|
|
989
|
+
*/
|
|
990
|
+
setupSetEditorContentHandler() {
|
|
991
|
+
Livewire.on("set-editor-content", ({ editorId: n, content: a }) => {
|
|
992
|
+
if (n !== t.canonical.editorId)
|
|
993
|
+
return;
|
|
994
|
+
const s = this.getEditorRootsValues();
|
|
995
|
+
b(s, a) || this.editor.setData(a);
|
|
996
|
+
});
|
|
997
|
+
}
|
|
953
998
|
/**
|
|
954
999
|
* Setups the content push event for the editor.
|
|
955
1000
|
*/
|
|
956
1001
|
setupTypingContentPush() {
|
|
957
1002
|
const { model: n } = this.editor, { $wire: a } = t, s = () => {
|
|
958
1003
|
const o = this.getEditorRootsValues();
|
|
959
|
-
|
|
1004
|
+
b(o, t.canonical.content ?? {}) || (a.set("content", o), a.dispatch("editor-content-changed", {
|
|
960
1005
|
editorId: t.canonical.editorId,
|
|
961
1006
|
content: o
|
|
962
1007
|
}));
|
|
@@ -969,7 +1014,7 @@ async function st({
|
|
|
969
1014
|
setupFocusableEventPush() {
|
|
970
1015
|
const { ui: n } = this.editor, { $wire: a } = t, s = () => {
|
|
971
1016
|
const o = this.getEditorRootsValues();
|
|
972
|
-
a.set("focused", n.focusTracker.isFocused),
|
|
1017
|
+
a.set("focused", n.focusTracker.isFocused), b(o, t.canonical.content ?? {}) || a.set("content", o);
|
|
973
1018
|
};
|
|
974
1019
|
n.focusTracker.on("change:isFocused", s);
|
|
975
1020
|
}
|
|
@@ -977,7 +1022,7 @@ async function st({
|
|
|
977
1022
|
* Gets the current values of all editor roots.
|
|
978
1023
|
*/
|
|
979
1024
|
getEditorRootsValues() {
|
|
980
|
-
return
|
|
1025
|
+
return Q(this.editor);
|
|
981
1026
|
}
|
|
982
1027
|
};
|
|
983
1028
|
}
|
|
@@ -1022,7 +1067,7 @@ async function ot(i) {
|
|
|
1022
1067
|
}
|
|
1023
1068
|
};
|
|
1024
1069
|
}
|
|
1025
|
-
class ct extends
|
|
1070
|
+
class ct extends P {
|
|
1026
1071
|
/**
|
|
1027
1072
|
* The promise that resolves to the editor instance.
|
|
1028
1073
|
*/
|
|
@@ -1032,15 +1077,15 @@ class ct extends C {
|
|
|
1032
1077
|
*/
|
|
1033
1078
|
async mounted() {
|
|
1034
1079
|
const { editorId: t } = this.canonical;
|
|
1035
|
-
|
|
1080
|
+
m.the.resetErrors(t);
|
|
1036
1081
|
try {
|
|
1037
1082
|
this.editorPromise = this.createEditor();
|
|
1038
1083
|
const e = await this.editorPromise;
|
|
1039
|
-
this.isBeingDestroyed() || (
|
|
1040
|
-
|
|
1084
|
+
this.isBeingDestroyed() || (m.the.register(t, e), e.once("destroy", () => {
|
|
1085
|
+
m.the.hasItem(t) && m.the.unregister(t);
|
|
1041
1086
|
}));
|
|
1042
1087
|
} catch (e) {
|
|
1043
|
-
console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e), this.editorPromise = null,
|
|
1088
|
+
console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e), this.editorPromise = null, m.the.error(t, e);
|
|
1044
1089
|
}
|
|
1045
1090
|
}
|
|
1046
1091
|
/**
|
|
@@ -1053,7 +1098,7 @@ class ct extends C {
|
|
|
1053
1098
|
const t = await this.editorPromise;
|
|
1054
1099
|
if (!t)
|
|
1055
1100
|
return;
|
|
1056
|
-
const e =
|
|
1101
|
+
const e = J(t), r = it(t);
|
|
1057
1102
|
e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : r ? await r.destroy() : await t.destroy();
|
|
1058
1103
|
} finally {
|
|
1059
1104
|
this.editorPromise = null;
|
|
@@ -1080,77 +1125,77 @@ class ct extends C {
|
|
|
1080
1125
|
content: c
|
|
1081
1126
|
} = this.canonical, {
|
|
1082
1127
|
customTranslations: u,
|
|
1083
|
-
editorType:
|
|
1084
|
-
licenseKey:
|
|
1085
|
-
config: { plugins:
|
|
1128
|
+
editorType: d,
|
|
1129
|
+
licenseKey: k,
|
|
1130
|
+
config: { plugins: v, ...f }
|
|
1086
1131
|
} = t;
|
|
1087
|
-
let
|
|
1088
|
-
const
|
|
1089
|
-
if (o && !
|
|
1090
|
-
const l = await rt(
|
|
1091
|
-
({ Constructor:
|
|
1092
|
-
const
|
|
1093
|
-
this.editorPromise = Promise.resolve(
|
|
1132
|
+
let p = await Z(d);
|
|
1133
|
+
const w = await (r ? h.the.waitFor(r) : null);
|
|
1134
|
+
if (o && !w) {
|
|
1135
|
+
const l = await rt(p);
|
|
1136
|
+
({ Constructor: p } = l), l.watchdog.on("restart", () => {
|
|
1137
|
+
const E = l.watchdog.editor;
|
|
1138
|
+
this.editorPromise = Promise.resolve(E), m.the.register(e, E);
|
|
1094
1139
|
});
|
|
1095
1140
|
}
|
|
1096
|
-
const { loadedPlugins:
|
|
1097
|
-
|
|
1141
|
+
const { loadedPlugins: g, hasPremium: U } = await F(v);
|
|
1142
|
+
g.push(
|
|
1098
1143
|
await st(
|
|
1099
1144
|
{
|
|
1100
1145
|
saveDebounceMs: a,
|
|
1101
1146
|
component: this
|
|
1102
1147
|
}
|
|
1103
1148
|
)
|
|
1104
|
-
),
|
|
1149
|
+
), C(d) && g.push(
|
|
1105
1150
|
await ot(a)
|
|
1106
1151
|
);
|
|
1107
1152
|
const $ = [
|
|
1108
|
-
...await V(s,
|
|
1153
|
+
...await V(s, U),
|
|
1109
1154
|
j(u || {})
|
|
1110
|
-
].filter((l) => !
|
|
1111
|
-
let
|
|
1155
|
+
].filter((l) => !A(l));
|
|
1156
|
+
let y = {
|
|
1112
1157
|
...c,
|
|
1113
|
-
...
|
|
1158
|
+
...z(e)
|
|
1114
1159
|
};
|
|
1115
|
-
|
|
1116
|
-
const
|
|
1117
|
-
let l =
|
|
1160
|
+
C(d) && (y = y.main || "");
|
|
1161
|
+
const H = await (async () => {
|
|
1162
|
+
let l = N(e);
|
|
1118
1163
|
if (!(l instanceof HTMLElement) && !("main" in l)) {
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1164
|
+
const M = d === "decoupled" ? ["main"] : Object.keys(y);
|
|
1165
|
+
B(l, M) || (l = await ut(e, M), y = {
|
|
1121
1166
|
...c,
|
|
1122
|
-
...
|
|
1167
|
+
...z(e)
|
|
1123
1168
|
});
|
|
1124
1169
|
}
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
...
|
|
1128
|
-
initialData:
|
|
1129
|
-
licenseKey:
|
|
1130
|
-
plugins:
|
|
1170
|
+
C(d) && "main" in l && (l = l.main);
|
|
1171
|
+
const E = {
|
|
1172
|
+
...I(f),
|
|
1173
|
+
initialData: y,
|
|
1174
|
+
licenseKey: k,
|
|
1175
|
+
plugins: g,
|
|
1131
1176
|
language: s,
|
|
1132
1177
|
...$.length && {
|
|
1133
1178
|
translations: $
|
|
1134
1179
|
}
|
|
1135
1180
|
};
|
|
1136
|
-
return !
|
|
1137
|
-
context:
|
|
1181
|
+
return !w || !(l instanceof HTMLElement) ? p.create(l, E) : (await X({
|
|
1182
|
+
context: w,
|
|
1138
1183
|
element: l,
|
|
1139
|
-
creator:
|
|
1140
|
-
config:
|
|
1184
|
+
creator: p,
|
|
1185
|
+
config: E
|
|
1141
1186
|
})).editor;
|
|
1142
1187
|
})();
|
|
1143
|
-
return
|
|
1188
|
+
return C(d) && n && et(H, n), H;
|
|
1144
1189
|
}
|
|
1145
1190
|
}
|
|
1146
|
-
function
|
|
1191
|
+
function B(i, t) {
|
|
1147
1192
|
return t.every((e) => i[e]);
|
|
1148
1193
|
}
|
|
1149
1194
|
async function ut(i, t) {
|
|
1150
|
-
return
|
|
1195
|
+
return Y(
|
|
1151
1196
|
() => {
|
|
1152
|
-
const e =
|
|
1153
|
-
if (!
|
|
1197
|
+
const e = N(i);
|
|
1198
|
+
if (!B(e, t))
|
|
1154
1199
|
throw new Error(
|
|
1155
1200
|
`It looks like not all required root elements are present yet.
|
|
1156
1201
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
@@ -1162,7 +1207,7 @@ Missing roots: ${t.filter((r) => !e[r]).join(", ")}.`
|
|
|
1162
1207
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1163
1208
|
);
|
|
1164
1209
|
}
|
|
1165
|
-
class lt extends
|
|
1210
|
+
class lt extends P {
|
|
1166
1211
|
/**
|
|
1167
1212
|
* The promise that resolves when the UI part is mounted.
|
|
1168
1213
|
*/
|
|
@@ -1172,7 +1217,7 @@ class lt extends C {
|
|
|
1172
1217
|
*/
|
|
1173
1218
|
async mounted() {
|
|
1174
1219
|
const { editorId: t, name: e } = this.canonical;
|
|
1175
|
-
this.mountedPromise =
|
|
1220
|
+
this.mountedPromise = m.the.execute(t, (r) => {
|
|
1176
1221
|
if (this.isBeingDestroyed())
|
|
1177
1222
|
return;
|
|
1178
1223
|
const { ui: n } = r, a = mt(e), s = n.view[a];
|
|
@@ -1208,17 +1253,17 @@ const dt = {
|
|
|
1208
1253
|
};
|
|
1209
1254
|
function wt() {
|
|
1210
1255
|
for (const [i, t] of Object.entries(dt))
|
|
1211
|
-
|
|
1256
|
+
_(i, t);
|
|
1212
1257
|
}
|
|
1213
1258
|
wt();
|
|
1214
1259
|
export {
|
|
1215
|
-
|
|
1216
|
-
|
|
1260
|
+
P as ClassHook,
|
|
1261
|
+
h as ContextsRegistry,
|
|
1217
1262
|
S as CustomEditorPluginsRegistry,
|
|
1218
1263
|
at as EditableComponentHook,
|
|
1219
1264
|
ct as EditorComponentHook,
|
|
1220
|
-
|
|
1265
|
+
m as EditorsRegistry,
|
|
1221
1266
|
lt as UIPartComponentHook,
|
|
1222
|
-
|
|
1267
|
+
_ as registerLivewireComponentHook
|
|
1223
1268
|
};
|
|
1224
1269
|
//# sourceMappingURL=index.mjs.map
|