ckeditor5-blazor 1.8.0 → 1.9.1
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/elements/editable.d.ts.map +1 -1
- package/dist/elements/editor/editor.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +285 -253
- package/dist/index.mjs.map +1 -1
- package/dist/interop/create-editable-blazor-interop.d.ts +5 -0
- package/dist/interop/create-editable-blazor-interop.d.ts.map +1 -1
- package/dist/interop/create-editor-blazor-interop.d.ts +4 -0
- package/dist/interop/create-editor-blazor-interop.d.ts.map +1 -1
- package/dist/interop/utils/index.d.ts +1 -0
- package/dist/interop/utils/index.d.ts.map +1 -1
- package/dist/interop/utils/sync-root-attributes.d.ts +16 -0
- package/dist/interop/utils/sync-root-attributes.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/elements/editable.test.ts +57 -0
- package/src/elements/editable.ts +11 -1
- package/src/elements/editor/editor.test.ts +15 -0
- package/src/elements/editor/editor.ts +8 -0
- package/src/interop/create-editable-blazor-interop.test.ts +55 -0
- package/src/interop/create-editable-blazor-interop.ts +22 -2
- package/src/interop/create-editor-blazor-interop.test.ts +48 -0
- package/src/interop/create-editor-blazor-interop.ts +20 -1
- package/src/interop/utils/index.ts +1 -0
- package/src/interop/utils/sync-root-attributes.ts +46 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
class
|
|
1
|
+
class E extends Error {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
super(t), this.name = "CKEditor5BlazorError";
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
class
|
|
6
|
+
class B {
|
|
7
7
|
/**
|
|
8
8
|
* Map of registered items.
|
|
9
9
|
*/
|
|
@@ -31,11 +31,11 @@ class _ {
|
|
|
31
31
|
*/
|
|
32
32
|
execute(t, e, i) {
|
|
33
33
|
const a = this.items.get(t), n = this.initializationErrors.get(t);
|
|
34
|
-
return n ? (i?.(n), Promise.reject(n)) : a ? Promise.resolve(e(a)) : new Promise((o,
|
|
34
|
+
return n ? (i?.(n), Promise.reject(n)) : a ? Promise.resolve(e(a)) : new Promise((o, s) => {
|
|
35
35
|
const u = this.getPendingCallbacks(t);
|
|
36
|
-
u.success.push(async (
|
|
37
|
-
o(await e(
|
|
38
|
-
}), i ? u.error.push(i) : u.error.push(
|
|
36
|
+
u.success.push(async (d) => {
|
|
37
|
+
o(await e(d));
|
|
38
|
+
}), i ? u.error.push(i) : u.error.push(s);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
@@ -111,11 +111,11 @@ class _ {
|
|
|
111
111
|
let n = !1, o = null;
|
|
112
112
|
this.execute(
|
|
113
113
|
t,
|
|
114
|
-
(
|
|
115
|
-
n || (o !== null && clearTimeout(o), i(
|
|
114
|
+
(s) => {
|
|
115
|
+
n || (o !== null && clearTimeout(o), i(s));
|
|
116
116
|
},
|
|
117
|
-
(
|
|
118
|
-
n || (o !== null && clearTimeout(o), a(
|
|
117
|
+
(s) => {
|
|
118
|
+
n || (o !== null && clearTimeout(o), a(s));
|
|
119
119
|
}
|
|
120
120
|
), e && (o = setTimeout(() => {
|
|
121
121
|
n = !0, a(new Error(`Timeout waiting for item with ID "${t}" to be registered.`));
|
|
@@ -187,7 +187,7 @@ class _ {
|
|
|
187
187
|
this.items.size === 1 && t !== null && this.register(null, e);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function R(r, t) {
|
|
191
191
|
let e = null;
|
|
192
192
|
return (...i) => {
|
|
193
193
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
@@ -195,18 +195,18 @@ function z(r, t) {
|
|
|
195
195
|
}, r);
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function it(r, t) {
|
|
199
199
|
const e = Object.entries(r).filter(([i, a]) => t(a, i));
|
|
200
200
|
return Object.fromEntries(e);
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function T(r) {
|
|
203
203
|
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function M(r, t) {
|
|
206
206
|
const e = Object.entries(r).map(([i, a]) => [i, t(a, i)]);
|
|
207
207
|
return Object.fromEntries(e);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function at(r, t) {
|
|
210
210
|
if (r === t)
|
|
211
211
|
return !0;
|
|
212
212
|
const e = Object.keys(r), i = Object.keys(t);
|
|
@@ -217,30 +217,30 @@ function rt(r, t) {
|
|
|
217
217
|
return !1;
|
|
218
218
|
return !0;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function nt() {
|
|
221
221
|
return Math.random().toString(36).substring(2);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ot(r, {
|
|
224
224
|
timeOutAfter: t = 500,
|
|
225
225
|
retryAfter: e = 100
|
|
226
226
|
} = {}) {
|
|
227
227
|
return new Promise((i, a) => {
|
|
228
228
|
const n = Date.now();
|
|
229
229
|
let o = null;
|
|
230
|
-
const
|
|
230
|
+
const s = setTimeout(() => {
|
|
231
231
|
a(o ?? new Error("Timeout"));
|
|
232
232
|
}, t), u = async () => {
|
|
233
233
|
try {
|
|
234
|
-
const
|
|
235
|
-
clearTimeout(
|
|
236
|
-
} catch (
|
|
237
|
-
o =
|
|
234
|
+
const d = await r();
|
|
235
|
+
clearTimeout(s), i(d);
|
|
236
|
+
} catch (d) {
|
|
237
|
+
o = d, Date.now() - n > t ? a(d) : setTimeout(u, e);
|
|
238
238
|
}
|
|
239
239
|
};
|
|
240
240
|
u();
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function D() {
|
|
244
244
|
return new Promise((r) => {
|
|
245
245
|
switch (document.readyState) {
|
|
246
246
|
case "loading":
|
|
@@ -255,7 +255,7 @@ function T() {
|
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function $(r) {
|
|
259
259
|
if (r.hasAttribute("data-cke-interactive"))
|
|
260
260
|
return { promise: Promise.resolve(), disconnect: () => {
|
|
261
261
|
} };
|
|
@@ -273,14 +273,14 @@ function M(r) {
|
|
|
273
273
|
disconnect: () => t?.disconnect()
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function x(r) {
|
|
277
277
|
r.setAttribute("data-cke-interactive", "true");
|
|
278
278
|
}
|
|
279
|
-
const
|
|
280
|
-
async function
|
|
281
|
-
const a =
|
|
279
|
+
const z = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
280
|
+
async function st({ element: r, context: t, creator: e, config: i }) {
|
|
281
|
+
const a = nt();
|
|
282
282
|
await t.add({
|
|
283
|
-
creator: (u,
|
|
283
|
+
creator: (u, d) => e.create(u, d),
|
|
284
284
|
id: a,
|
|
285
285
|
sourceElementOrData: r,
|
|
286
286
|
type: "editor",
|
|
@@ -291,23 +291,23 @@ async function nt({ element: r, context: t, creator: e, config: i }) {
|
|
|
291
291
|
editorContextId: a,
|
|
292
292
|
context: t
|
|
293
293
|
};
|
|
294
|
-
n[
|
|
295
|
-
const
|
|
296
|
-
return t.destroy = async () => (o.state = "unavailable",
|
|
294
|
+
n[z] = o;
|
|
295
|
+
const s = t.destroy.bind(t);
|
|
296
|
+
return t.destroy = async () => (o.state = "unavailable", s()), {
|
|
297
297
|
...o,
|
|
298
298
|
editor: n
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
return
|
|
301
|
+
function ct(r) {
|
|
302
|
+
return z in r ? r[z] : null;
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function J(r) {
|
|
305
305
|
return Array.from(r.model.document.getRoots()).reduce((t, e) => (e.rootName === "$graveyard" || (t[e.rootName] = r.getData({ rootName: e.rootName })), t), /* @__PURE__ */ Object.create({}));
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function P(r) {
|
|
308
308
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
309
309
|
}
|
|
310
|
-
async function
|
|
310
|
+
async function U(r) {
|
|
311
311
|
const t = await import("ckeditor5"), i = {
|
|
312
312
|
inline: t.InlineEditor,
|
|
313
313
|
balloon: t.BalloonEditor,
|
|
@@ -316,11 +316,11 @@ async function q(r) {
|
|
|
316
316
|
multiroot: t.MultiRootEditor
|
|
317
317
|
}[r];
|
|
318
318
|
if (!i)
|
|
319
|
-
throw new
|
|
319
|
+
throw new E(`Unsupported editor type: ${r}`);
|
|
320
320
|
return i;
|
|
321
321
|
}
|
|
322
|
-
class
|
|
323
|
-
static the = new
|
|
322
|
+
class W {
|
|
323
|
+
static the = new W();
|
|
324
324
|
/**
|
|
325
325
|
* Map of registered custom plugins.
|
|
326
326
|
*/
|
|
@@ -339,7 +339,7 @@ class R {
|
|
|
339
339
|
*/
|
|
340
340
|
register(t, e) {
|
|
341
341
|
if (this.plugins.has(t))
|
|
342
|
-
throw new
|
|
342
|
+
throw new E(`Plugin with name "${t}" is already registered.`);
|
|
343
343
|
return this.plugins.set(t, e), this.unregister.bind(this, t);
|
|
344
344
|
}
|
|
345
345
|
/**
|
|
@@ -350,7 +350,7 @@ class R {
|
|
|
350
350
|
*/
|
|
351
351
|
unregister(t) {
|
|
352
352
|
if (!this.plugins.has(t))
|
|
353
|
-
throw new
|
|
353
|
+
throw new E(`Plugin with name "${t}" is not registered.`);
|
|
354
354
|
this.plugins.delete(t);
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
@@ -379,20 +379,20 @@ class R {
|
|
|
379
379
|
return this.plugins.has(t);
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
async function
|
|
382
|
+
async function H(r) {
|
|
383
383
|
const t = await import("ckeditor5");
|
|
384
384
|
let e = null;
|
|
385
385
|
const i = r.map(async (a) => {
|
|
386
|
-
if (
|
|
387
|
-
const { name: u, path:
|
|
386
|
+
if (ut(a)) {
|
|
387
|
+
const { name: u, path: d } = a.$import, l = await import(
|
|
388
388
|
/* @vite-ignore */
|
|
389
|
-
|
|
390
|
-
),
|
|
391
|
-
if (!
|
|
392
|
-
throw new
|
|
393
|
-
return
|
|
389
|
+
d
|
|
390
|
+
), w = (Object.prototype.hasOwnProperty.call(l, u) ? l[u] : void 0) ?? (Object.prototype.hasOwnProperty.call(l, "default") ? l.default : void 0);
|
|
391
|
+
if (!w)
|
|
392
|
+
throw new E(`Plugin "${u}" not found in module "${d}".`);
|
|
393
|
+
return w;
|
|
394
394
|
}
|
|
395
|
-
const n = await
|
|
395
|
+
const n = await W.the.get(a);
|
|
396
396
|
if (n)
|
|
397
397
|
return n;
|
|
398
398
|
const { [a]: o } = t;
|
|
@@ -402,40 +402,40 @@ async function J(r) {
|
|
|
402
402
|
try {
|
|
403
403
|
e = await import("ckeditor5-premium-features");
|
|
404
404
|
} catch (u) {
|
|
405
|
-
throw console.error(`Failed to load premium package: ${u}`), new
|
|
405
|
+
throw console.error(`Failed to load premium package: ${u}`), new E(`Plugin "${a}" not found in base package and failed to load premium package.`);
|
|
406
406
|
}
|
|
407
|
-
const { [a]:
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
throw new
|
|
407
|
+
const { [a]: s } = e || {};
|
|
408
|
+
if (s)
|
|
409
|
+
return s;
|
|
410
|
+
throw new E(`Plugin "${a}" not found in base or premium packages.`);
|
|
411
411
|
});
|
|
412
412
|
return {
|
|
413
413
|
loadedPlugins: await Promise.all(i),
|
|
414
414
|
hasPremium: !!e
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function ut(r) {
|
|
418
418
|
return typeof r == "object" && r !== null && "$import" in r;
|
|
419
419
|
}
|
|
420
420
|
async function K(r, t) {
|
|
421
421
|
const e = [r.ui, r.content];
|
|
422
422
|
return await Promise.all(
|
|
423
423
|
[
|
|
424
|
-
|
|
424
|
+
j("ckeditor5", e),
|
|
425
425
|
/* v8 ignore next -- @preserve */
|
|
426
|
-
t &&
|
|
426
|
+
t && j("ckeditor5-premium-features", e)
|
|
427
427
|
].filter((a) => !!a)
|
|
428
428
|
).then((a) => a.flat());
|
|
429
429
|
}
|
|
430
|
-
async function
|
|
430
|
+
async function j(r, t) {
|
|
431
431
|
return await Promise.all(
|
|
432
432
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
433
|
-
const i = await
|
|
433
|
+
const i = await lt(r, e);
|
|
434
434
|
return i?.default ?? i;
|
|
435
435
|
}).filter(Boolean)
|
|
436
436
|
);
|
|
437
437
|
}
|
|
438
|
-
async function
|
|
438
|
+
async function lt(r, t) {
|
|
439
439
|
try {
|
|
440
440
|
if (r === "ckeditor5")
|
|
441
441
|
switch (t) {
|
|
@@ -736,27 +736,27 @@ async function ct(r, t) {
|
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
function G(r) {
|
|
739
|
-
return
|
|
739
|
+
return M(r, (t) => ({
|
|
740
740
|
dictionary: t
|
|
741
741
|
}));
|
|
742
742
|
}
|
|
743
|
-
function
|
|
743
|
+
function F() {
|
|
744
744
|
return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
|
|
745
745
|
}
|
|
746
746
|
function Y(r) {
|
|
747
747
|
const t = X(r);
|
|
748
|
-
return
|
|
748
|
+
return M(t, ({ element: e }) => e);
|
|
749
749
|
}
|
|
750
|
-
function
|
|
751
|
-
const t = X(r), e =
|
|
752
|
-
return
|
|
750
|
+
function _(r) {
|
|
751
|
+
const t = X(r), e = M(t, ({ content: i }) => i);
|
|
752
|
+
return it(e, (i) => typeof i == "string");
|
|
753
753
|
}
|
|
754
754
|
function X(r) {
|
|
755
|
-
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o,
|
|
756
|
-
const u =
|
|
755
|
+
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, s) => {
|
|
756
|
+
const u = s.getAttribute("data-cke-root-name"), d = s.getAttribute("data-cke-content");
|
|
757
757
|
return o[u] = {
|
|
758
|
-
element:
|
|
759
|
-
content:
|
|
758
|
+
element: s.querySelector("[data-cke-editable-content]"),
|
|
759
|
+
content: d
|
|
760
760
|
}, o;
|
|
761
761
|
}, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
|
|
762
762
|
if (!e)
|
|
@@ -776,11 +776,11 @@ function X(r) {
|
|
|
776
776
|
}
|
|
777
777
|
} : t;
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function O(r) {
|
|
780
780
|
if (!r || typeof r != "object")
|
|
781
781
|
return r;
|
|
782
782
|
if (Array.isArray(r))
|
|
783
|
-
return r.map((i) =>
|
|
783
|
+
return r.map((i) => O(i));
|
|
784
784
|
const t = r;
|
|
785
785
|
if (t.$element && typeof t.$element == "string") {
|
|
786
786
|
const i = document.querySelector(t.$element);
|
|
@@ -788,43 +788,43 @@ function P(r) {
|
|
|
788
788
|
}
|
|
789
789
|
const e = /* @__PURE__ */ Object.create(null);
|
|
790
790
|
for (const [i, a] of Object.entries(r))
|
|
791
|
-
e[i] =
|
|
791
|
+
e[i] = O(a);
|
|
792
792
|
return e;
|
|
793
793
|
}
|
|
794
|
-
function
|
|
794
|
+
function S(r, t, e) {
|
|
795
795
|
if (!e || typeof e != "object")
|
|
796
796
|
return e;
|
|
797
797
|
if (Array.isArray(e))
|
|
798
|
-
return e.map((n) =>
|
|
798
|
+
return e.map((n) => S(r, t, n));
|
|
799
799
|
const i = e;
|
|
800
800
|
if (i.$translation && typeof i.$translation == "string") {
|
|
801
|
-
const n = i.$translation, o =
|
|
801
|
+
const n = i.$translation, o = dt(r, n, t);
|
|
802
802
|
return o === void 0 && console.warn(`Translation not found for key: ${n}`), o !== void 0 ? o : null;
|
|
803
803
|
}
|
|
804
804
|
const a = /* @__PURE__ */ Object.create(null);
|
|
805
805
|
for (const [n, o] of Object.entries(e))
|
|
806
|
-
a[n] =
|
|
806
|
+
a[n] = S(r, t, o);
|
|
807
807
|
return a;
|
|
808
808
|
}
|
|
809
|
-
function
|
|
809
|
+
function dt(r, t, e) {
|
|
810
810
|
for (const i of r) {
|
|
811
811
|
const a = i[e];
|
|
812
812
|
if (a?.dictionary && t in a.dictionary)
|
|
813
813
|
return a.dictionary[t];
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function mt(r, t) {
|
|
817
817
|
const { editing: e } = r;
|
|
818
818
|
e.view.change((i) => {
|
|
819
819
|
i.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
820
820
|
});
|
|
821
821
|
}
|
|
822
|
-
const
|
|
823
|
-
async function
|
|
822
|
+
const V = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
|
|
823
|
+
async function ht(r) {
|
|
824
824
|
const { EditorWatchdog: t } = await import("ckeditor5"), e = new t(r);
|
|
825
825
|
return e.setCreator(async (...i) => {
|
|
826
826
|
const a = await r.create(...i);
|
|
827
|
-
return a[
|
|
827
|
+
return a[V] = e, a;
|
|
828
828
|
}), {
|
|
829
829
|
watchdog: e,
|
|
830
830
|
Constructor: {
|
|
@@ -832,13 +832,13 @@ async function dt(r) {
|
|
|
832
832
|
}
|
|
833
833
|
};
|
|
834
834
|
}
|
|
835
|
-
function
|
|
836
|
-
return
|
|
835
|
+
function pt(r) {
|
|
836
|
+
return V in r ? r[V] : null;
|
|
837
837
|
}
|
|
838
|
-
class v extends
|
|
838
|
+
class v extends B {
|
|
839
839
|
static the = new v();
|
|
840
840
|
}
|
|
841
|
-
class
|
|
841
|
+
class wt extends HTMLElement {
|
|
842
842
|
/**
|
|
843
843
|
* The promise that resolves to the context instance.
|
|
844
844
|
*/
|
|
@@ -851,35 +851,35 @@ class ht extends HTMLElement {
|
|
|
851
851
|
* Mounts the context component.
|
|
852
852
|
*/
|
|
853
853
|
async connectedCallback() {
|
|
854
|
-
await
|
|
854
|
+
await D(), this.interactiveWait = $(this), await this.interactiveWait.promise, await this.initializeContext();
|
|
855
855
|
}
|
|
856
856
|
/**
|
|
857
857
|
* Initializes the context component.
|
|
858
858
|
*/
|
|
859
859
|
async initializeContext() {
|
|
860
|
-
const t = this.getAttribute("data-cke-context-id"), e = JSON.parse(this.getAttribute("data-cke-language")), i = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: a, watchdogConfig: n, config: { plugins: o, ...
|
|
861
|
-
...await K(e,
|
|
860
|
+
const t = this.getAttribute("data-cke-context-id"), e = JSON.parse(this.getAttribute("data-cke-language")), i = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: a, watchdogConfig: n, config: { plugins: o, ...s } } = i, { loadedPlugins: u, hasPremium: d } = await H(o ?? []), l = [
|
|
861
|
+
...await K(e, d),
|
|
862
862
|
G(a || {})
|
|
863
|
-
].filter((
|
|
863
|
+
].filter((y) => !T(y));
|
|
864
864
|
this.contextPromise = (async () => {
|
|
865
|
-
const { ContextWatchdog:
|
|
865
|
+
const { ContextWatchdog: y, Context: b } = await import("ckeditor5"), f = new y(b, {
|
|
866
866
|
crashNumberLimit: 10,
|
|
867
867
|
...n
|
|
868
868
|
});
|
|
869
|
-
let
|
|
870
|
-
return
|
|
871
|
-
...
|
|
869
|
+
let p = O(s);
|
|
870
|
+
return p = S([...l].reverse(), e.ui, p), await f.create({
|
|
871
|
+
...p,
|
|
872
872
|
language: e,
|
|
873
873
|
plugins: u,
|
|
874
|
-
...
|
|
875
|
-
translations:
|
|
874
|
+
...l.length && {
|
|
875
|
+
translations: l
|
|
876
876
|
}
|
|
877
|
-
}),
|
|
878
|
-
console.error("Context item error:", ...
|
|
879
|
-
}),
|
|
877
|
+
}), f.on("itemError", (...A) => {
|
|
878
|
+
console.error("Context item error:", ...A);
|
|
879
|
+
}), f;
|
|
880
880
|
})();
|
|
881
|
-
const
|
|
882
|
-
this.isConnected && v.the.register(t,
|
|
881
|
+
const w = await this.contextPromise;
|
|
882
|
+
this.isConnected && v.the.register(t, w);
|
|
883
883
|
}
|
|
884
884
|
/**
|
|
885
885
|
* Destroys the context component. Unmounts root from the editor.
|
|
@@ -895,10 +895,10 @@ class ht extends HTMLElement {
|
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
class h extends
|
|
898
|
+
class h extends B {
|
|
899
899
|
static the = new h();
|
|
900
900
|
}
|
|
901
|
-
class
|
|
901
|
+
class ft extends HTMLElement {
|
|
902
902
|
/**
|
|
903
903
|
* The promise that resolves when the editable is mounted.
|
|
904
904
|
*/
|
|
@@ -921,48 +921,51 @@ class pt extends HTMLElement {
|
|
|
921
921
|
* Mounts the editable component.
|
|
922
922
|
*/
|
|
923
923
|
async connectedCallback() {
|
|
924
|
-
await
|
|
924
|
+
await D(), this.interactiveWait = $(this), await this.interactiveWait.promise, await this.initializeEditable();
|
|
925
925
|
}
|
|
926
926
|
/**
|
|
927
927
|
* Initializes the editable instance.
|
|
928
928
|
*/
|
|
929
929
|
async initializeEditable() {
|
|
930
|
-
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id",
|
|
931
|
-
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), i = this.getAttribute("data-cke-
|
|
930
|
+
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", F()[0]);
|
|
931
|
+
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), i = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), a = this.getAttribute("data-cke-content"), n = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
|
|
932
932
|
if (!t || !e)
|
|
933
|
-
throw new
|
|
934
|
-
this.style.display = "block", this.editorPromise = h.the.execute(t, async (
|
|
933
|
+
throw new E("Editor ID or Root Name is missing.");
|
|
934
|
+
this.style.display = "block", this.editorPromise = h.the.execute(t, async (o) => {
|
|
935
935
|
if (!this.isConnected)
|
|
936
936
|
return null;
|
|
937
|
-
const { ui:
|
|
938
|
-
if (
|
|
939
|
-
if (
|
|
940
|
-
const p =
|
|
941
|
-
p && p !==
|
|
942
|
-
[e]:
|
|
937
|
+
const { ui: s, editing: u, model: d } = o, c = this.querySelector("input"), l = d.document.getRoot(e);
|
|
938
|
+
if (l?.isAttached()) {
|
|
939
|
+
if (a !== null) {
|
|
940
|
+
const p = o.getData({ rootName: e });
|
|
941
|
+
p && p !== a && o.setData({
|
|
942
|
+
[e]: a
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
|
-
return
|
|
945
|
+
return T(i) || o.model.change((p) => {
|
|
946
|
+
p.setAttributes(i, l);
|
|
947
|
+
}), o;
|
|
946
948
|
}
|
|
947
|
-
|
|
949
|
+
o.addRoot(e, {
|
|
948
950
|
isUndoable: !1,
|
|
949
|
-
...i
|
|
950
|
-
|
|
951
|
+
attributes: { ...i },
|
|
952
|
+
...a !== null && {
|
|
953
|
+
data: a
|
|
951
954
|
}
|
|
952
955
|
});
|
|
953
|
-
const
|
|
954
|
-
|
|
955
|
-
const
|
|
956
|
-
if (!
|
|
956
|
+
const w = this.querySelector("[data-cke-editable-content]"), y = s.view.createEditable(e, w);
|
|
957
|
+
s.addEditable(y), u.view.forceRender();
|
|
958
|
+
const b = () => {
|
|
959
|
+
if (!d.document.getRoot(e)?.isAttached())
|
|
957
960
|
return;
|
|
958
|
-
const p =
|
|
959
|
-
|
|
961
|
+
const p = o.getData({ rootName: e });
|
|
962
|
+
c && (c.value = p, c.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
|
|
960
963
|
detail: {
|
|
961
964
|
value: p
|
|
962
965
|
}
|
|
963
966
|
}));
|
|
964
|
-
},
|
|
965
|
-
return
|
|
967
|
+
}, f = R(n, b);
|
|
968
|
+
return o.model.document.on("change:data", f), this.onBeforeDestroy(() => o.model.document.off("change:data", f)), b(), o;
|
|
966
969
|
});
|
|
967
970
|
}
|
|
968
971
|
/**
|
|
@@ -989,7 +992,7 @@ class pt extends HTMLElement {
|
|
|
989
992
|
}
|
|
990
993
|
}
|
|
991
994
|
}
|
|
992
|
-
async function
|
|
995
|
+
async function gt({
|
|
993
996
|
saveDebounceMs: r,
|
|
994
997
|
editorId: t,
|
|
995
998
|
targetElement: e
|
|
@@ -1006,7 +1009,7 @@ async function wt({
|
|
|
1006
1009
|
* Initializes the plugin.
|
|
1007
1010
|
*/
|
|
1008
1011
|
afterInit() {
|
|
1009
|
-
const { editor: n } = this, o =
|
|
1012
|
+
const { editor: n } = this, o = R(r, this.dispatch);
|
|
1010
1013
|
n.model.document.on("change:data", o), n.once("ready", this.dispatch);
|
|
1011
1014
|
}
|
|
1012
1015
|
/**
|
|
@@ -1015,25 +1018,25 @@ async function wt({
|
|
|
1015
1018
|
dispatch = () => {
|
|
1016
1019
|
const { editor: n } = this;
|
|
1017
1020
|
e.dispatchEvent(
|
|
1018
|
-
new
|
|
1021
|
+
new g({
|
|
1019
1022
|
editorId: t,
|
|
1020
1023
|
editor: n,
|
|
1021
|
-
roots:
|
|
1024
|
+
roots: J(n)
|
|
1022
1025
|
})
|
|
1023
1026
|
);
|
|
1024
1027
|
};
|
|
1025
1028
|
};
|
|
1026
1029
|
}
|
|
1027
|
-
class
|
|
1030
|
+
class g extends CustomEvent {
|
|
1028
1031
|
static EVENT_NAME = "ckeditor5:change:data";
|
|
1029
1032
|
constructor(t) {
|
|
1030
|
-
super(
|
|
1033
|
+
super(g.EVENT_NAME, {
|
|
1031
1034
|
detail: t,
|
|
1032
1035
|
bubbles: !0
|
|
1033
1036
|
});
|
|
1034
1037
|
}
|
|
1035
1038
|
}
|
|
1036
|
-
async function
|
|
1039
|
+
async function yt(r) {
|
|
1037
1040
|
const { Plugin: t } = await import("ckeditor5");
|
|
1038
1041
|
return class extends t {
|
|
1039
1042
|
/**
|
|
@@ -1055,7 +1058,7 @@ async function ft(r) {
|
|
|
1055
1058
|
*/
|
|
1056
1059
|
afterInit() {
|
|
1057
1060
|
const { editor: i } = this, n = i.sourceElement.id.replace(/_editor$/, "");
|
|
1058
|
-
this.input = document.getElementById(`${n}_input`), this.input && (i.model.document.on("change:data",
|
|
1061
|
+
this.input = document.getElementById(`${n}_input`), this.input && (i.model.document.on("change:data", R(r, () => this.sync())), i.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1059
1062
|
}
|
|
1060
1063
|
/**
|
|
1061
1064
|
* Synchronizes the editor's content with the input field.
|
|
@@ -1074,7 +1077,7 @@ async function ft(r) {
|
|
|
1074
1077
|
}
|
|
1075
1078
|
};
|
|
1076
1079
|
}
|
|
1077
|
-
class
|
|
1080
|
+
class bt extends HTMLElement {
|
|
1078
1081
|
/**
|
|
1079
1082
|
* The promise that resolves to the editor instance.
|
|
1080
1083
|
*/
|
|
@@ -1087,7 +1090,7 @@ class gt extends HTMLElement {
|
|
|
1087
1090
|
* Mounts the editor component.
|
|
1088
1091
|
*/
|
|
1089
1092
|
async connectedCallback() {
|
|
1090
|
-
await
|
|
1093
|
+
await D(), this.interactiveWait = $(this), U("classic"), await this.interactiveWait.promise, await this.initializeEditor();
|
|
1091
1094
|
}
|
|
1092
1095
|
/**
|
|
1093
1096
|
* Initializes the editor instance.
|
|
@@ -1115,7 +1118,7 @@ class gt extends HTMLElement {
|
|
|
1115
1118
|
const t = await this.editorPromise;
|
|
1116
1119
|
if (!t)
|
|
1117
1120
|
return;
|
|
1118
|
-
const e =
|
|
1121
|
+
const e = ct(t), i = pt(t);
|
|
1119
1122
|
e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : i ? await i.destroy() : await t.destroy();
|
|
1120
1123
|
} finally {
|
|
1121
1124
|
this.editorPromise = null;
|
|
@@ -1125,77 +1128,79 @@ class gt extends HTMLElement {
|
|
|
1125
1128
|
* Creates the CKEditor instance.
|
|
1126
1129
|
*/
|
|
1127
1130
|
async createEditor() {
|
|
1128
|
-
const t = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")), i = this.getAttribute("data-cke-context-id"), a = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null,
|
|
1129
|
-
customTranslations:
|
|
1131
|
+
const t = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")), i = this.getAttribute("data-cke-context-id"), a = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), n = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null, o = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10), s = JSON.parse(this.getAttribute("data-cke-language")), u = this.hasAttribute("data-cke-watchdog"), d = JSON.parse(this.getAttribute("data-cke-content")), {
|
|
1132
|
+
customTranslations: c,
|
|
1130
1133
|
editorType: l,
|
|
1131
|
-
licenseKey:
|
|
1132
|
-
config: { plugins:
|
|
1134
|
+
licenseKey: w,
|
|
1135
|
+
config: { plugins: y, ...b }
|
|
1133
1136
|
} = e;
|
|
1134
|
-
let
|
|
1137
|
+
let f = await U(l);
|
|
1135
1138
|
const p = await (i ? v.the.waitFor(i) : null);
|
|
1136
|
-
if (
|
|
1137
|
-
const m = await
|
|
1138
|
-
({ Constructor:
|
|
1139
|
+
if (u && !p) {
|
|
1140
|
+
const m = await ht(f);
|
|
1141
|
+
({ Constructor: f } = m), m.watchdog.on("restart", () => {
|
|
1139
1142
|
const k = m.watchdog.editor;
|
|
1140
1143
|
this.editorPromise = Promise.resolve(k), h.the.register(t, k);
|
|
1141
1144
|
});
|
|
1142
1145
|
}
|
|
1143
|
-
const { loadedPlugins:
|
|
1144
|
-
|
|
1145
|
-
await
|
|
1146
|
-
saveDebounceMs:
|
|
1146
|
+
const { loadedPlugins: A, hasPremium: rt } = await H(y);
|
|
1147
|
+
A.push(
|
|
1148
|
+
await gt({
|
|
1149
|
+
saveDebounceMs: o,
|
|
1147
1150
|
editorId: t,
|
|
1148
1151
|
targetElement: this
|
|
1149
1152
|
})
|
|
1150
|
-
),
|
|
1151
|
-
await
|
|
1153
|
+
), P(l) && A.push(
|
|
1154
|
+
await yt(o)
|
|
1152
1155
|
);
|
|
1153
|
-
const
|
|
1154
|
-
...await K(
|
|
1155
|
-
G(
|
|
1156
|
-
].filter((m) => !
|
|
1156
|
+
const N = [
|
|
1157
|
+
...await K(s, rt),
|
|
1158
|
+
G(c || {})
|
|
1159
|
+
].filter((m) => !T(m));
|
|
1157
1160
|
let C = {
|
|
1158
|
-
...
|
|
1159
|
-
...
|
|
1161
|
+
...d,
|
|
1162
|
+
..._(t)
|
|
1160
1163
|
};
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1164
|
+
P(l) && (C = C.main || "");
|
|
1165
|
+
const I = await (async () => {
|
|
1163
1166
|
let m = Y(t);
|
|
1164
1167
|
if (!m.main) {
|
|
1165
|
-
const L =
|
|
1166
|
-
Q(m, L) || (m = await
|
|
1167
|
-
...
|
|
1168
|
-
...
|
|
1168
|
+
const L = P(l) ? ["main"] : Object.keys(C);
|
|
1169
|
+
Q(m, L) || (m = await Et(t, L), C = {
|
|
1170
|
+
...d,
|
|
1171
|
+
..._(t)
|
|
1169
1172
|
});
|
|
1170
1173
|
}
|
|
1171
|
-
|
|
1172
|
-
let k =
|
|
1173
|
-
k =
|
|
1174
|
-
const
|
|
1174
|
+
P(l) && "main" in m && (m = m.main);
|
|
1175
|
+
let k = O(b);
|
|
1176
|
+
k = S([...N].reverse(), s.ui, k);
|
|
1177
|
+
const q = {
|
|
1175
1178
|
...k,
|
|
1176
1179
|
initialData: C,
|
|
1177
|
-
licenseKey:
|
|
1178
|
-
plugins:
|
|
1179
|
-
language:
|
|
1180
|
-
...
|
|
1181
|
-
translations:
|
|
1180
|
+
licenseKey: w,
|
|
1181
|
+
plugins: A,
|
|
1182
|
+
language: s,
|
|
1183
|
+
...N.length && {
|
|
1184
|
+
translations: N
|
|
1182
1185
|
}
|
|
1183
1186
|
};
|
|
1184
|
-
return !p || !(m instanceof HTMLElement) ?
|
|
1187
|
+
return !p || !(m instanceof HTMLElement) ? f.create(m, q) : (await st({
|
|
1185
1188
|
context: p,
|
|
1186
1189
|
element: m,
|
|
1187
|
-
creator:
|
|
1188
|
-
config:
|
|
1190
|
+
creator: f,
|
|
1191
|
+
config: q
|
|
1189
1192
|
})).editor;
|
|
1190
1193
|
})();
|
|
1191
|
-
return
|
|
1194
|
+
return T(a) || I.model.change((m) => {
|
|
1195
|
+
m.setAttributes(a, I.model.document.getRoot());
|
|
1196
|
+
}), P(l) && n && mt(I, n), I;
|
|
1192
1197
|
}
|
|
1193
1198
|
}
|
|
1194
1199
|
function Q(r, t) {
|
|
1195
1200
|
return t.every((e) => r[e]);
|
|
1196
1201
|
}
|
|
1197
|
-
async function
|
|
1198
|
-
return
|
|
1202
|
+
async function Et(r, t) {
|
|
1203
|
+
return ot(
|
|
1199
1204
|
() => {
|
|
1200
1205
|
const e = Y(r);
|
|
1201
1206
|
if (!Q(e, t))
|
|
@@ -1210,7 +1215,7 @@ Missing roots: ${t.filter((i) => !e[i]).join(", ")}.`
|
|
|
1210
1215
|
{ timeOutAfter: 2e3, retryAfter: 100 }
|
|
1211
1216
|
);
|
|
1212
1217
|
}
|
|
1213
|
-
class
|
|
1218
|
+
class kt extends HTMLElement {
|
|
1214
1219
|
/**
|
|
1215
1220
|
* The promise that resolves when the UI part is mounted.
|
|
1216
1221
|
*/
|
|
@@ -1219,14 +1224,14 @@ class bt extends HTMLElement {
|
|
|
1219
1224
|
* Mounts the UI part component.
|
|
1220
1225
|
*/
|
|
1221
1226
|
async connectedCallback() {
|
|
1222
|
-
await
|
|
1223
|
-
const t = this.getAttribute("data-cke-editor-id") ||
|
|
1227
|
+
await D();
|
|
1228
|
+
const t = this.getAttribute("data-cke-editor-id") || F()[0], e = this.getAttribute("data-cke-name");
|
|
1224
1229
|
!t || !e || (this.style.display = "block", this.mountedPromise = h.the.execute(t, (i) => {
|
|
1225
1230
|
if (!this.isConnected)
|
|
1226
1231
|
return;
|
|
1227
|
-
const { ui: a } = i, n =
|
|
1232
|
+
const { ui: a } = i, n = vt(e), o = a.view[n];
|
|
1228
1233
|
if (!o)
|
|
1229
|
-
throw new
|
|
1234
|
+
throw new E(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1230
1235
|
this.appendChild(o.element);
|
|
1231
1236
|
}));
|
|
1232
1237
|
}
|
|
@@ -1237,7 +1242,7 @@ class bt extends HTMLElement {
|
|
|
1237
1242
|
this.style.display = "none", await this.mountedPromise, this.mountedPromise = null, this.innerHTML = "";
|
|
1238
1243
|
}
|
|
1239
1244
|
}
|
|
1240
|
-
function
|
|
1245
|
+
function vt(r) {
|
|
1241
1246
|
switch (r) {
|
|
1242
1247
|
case "toolbar":
|
|
1243
1248
|
return "toolbar";
|
|
@@ -1248,18 +1253,18 @@ function Et(r) {
|
|
|
1248
1253
|
return null;
|
|
1249
1254
|
}
|
|
1250
1255
|
}
|
|
1251
|
-
const
|
|
1252
|
-
"cke5-editor":
|
|
1253
|
-
"cke5-context":
|
|
1254
|
-
"cke5-ui-part":
|
|
1255
|
-
"cke5-editable":
|
|
1256
|
+
const At = {
|
|
1257
|
+
"cke5-editor": bt,
|
|
1258
|
+
"cke5-context": wt,
|
|
1259
|
+
"cke5-ui-part": kt,
|
|
1260
|
+
"cke5-editable": ft
|
|
1256
1261
|
};
|
|
1257
|
-
function
|
|
1258
|
-
for (const [r, t] of Object.entries(
|
|
1262
|
+
function Ct() {
|
|
1263
|
+
for (const [r, t] of Object.entries(At))
|
|
1259
1264
|
window.customElements.get(r) || window.customElements.define(r, t);
|
|
1260
1265
|
}
|
|
1261
|
-
function
|
|
1262
|
-
return
|
|
1266
|
+
function xt(r) {
|
|
1267
|
+
return x(r), {
|
|
1263
1268
|
unmount() {
|
|
1264
1269
|
}
|
|
1265
1270
|
};
|
|
@@ -1272,8 +1277,8 @@ function Z(r, t) {
|
|
|
1272
1277
|
lastSyncedValue: null
|
|
1273
1278
|
}, i = () => {
|
|
1274
1279
|
e.pendingValue = null;
|
|
1275
|
-
}, a = (n, o,
|
|
1276
|
-
if (
|
|
1280
|
+
}, a = (n, o, s) => {
|
|
1281
|
+
if (s || e.pendingValue === null)
|
|
1277
1282
|
return;
|
|
1278
1283
|
const u = t.getCurrentValue();
|
|
1279
1284
|
t.isEqual(u, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
|
|
@@ -1321,70 +1326,97 @@ function tt() {
|
|
|
1321
1326
|
}
|
|
1322
1327
|
};
|
|
1323
1328
|
}
|
|
1324
|
-
function
|
|
1325
|
-
const e =
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
+
function et(r, t) {
|
|
1330
|
+
const e = /* @__PURE__ */ new Set();
|
|
1331
|
+
return (i) => {
|
|
1332
|
+
r.model.enqueueChange({ isUndoable: !1 }, (a) => {
|
|
1333
|
+
const n = r.model.document.getRoot(t);
|
|
1334
|
+
if (n) {
|
|
1335
|
+
for (const o of e)
|
|
1336
|
+
i && o in i || (a.removeAttribute(o, n), e.delete(o));
|
|
1337
|
+
for (const [o, s] of Object.entries(i ?? {}))
|
|
1338
|
+
a.setAttribute(o, s, n), e.add(o);
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
function Nt(r, t) {
|
|
1344
|
+
const e = r.getAttribute("data-cke-editor-id") ?? F()[0], i = r.getAttribute("data-cke-root-name") ?? "main";
|
|
1345
|
+
let a = !1, n = null, o = tt(), s = null;
|
|
1346
|
+
const u = (c) => {
|
|
1347
|
+
if (!(c instanceof g) || c.detail.editorId !== e)
|
|
1329
1348
|
return;
|
|
1330
|
-
const l =
|
|
1331
|
-
l !== void 0 &&
|
|
1349
|
+
const l = c.detail.roots[i];
|
|
1350
|
+
l !== void 0 && o.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", n, l);
|
|
1332
1351
|
};
|
|
1333
1352
|
return (async () => {
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1336
|
-
getCurrentValue: () =>
|
|
1337
|
-
applyValue: (l) =>
|
|
1338
|
-
isEqual: (l,
|
|
1339
|
-
});
|
|
1340
|
-
})(), document.body.addEventListener(
|
|
1353
|
+
const c = await h.the.waitFor(e);
|
|
1354
|
+
n = DotNet.createJSObjectReference(c), o = Z(c, {
|
|
1355
|
+
getCurrentValue: () => c.getData({ rootName: i }) ?? "",
|
|
1356
|
+
applyValue: (l) => c.setData({ [i]: l }),
|
|
1357
|
+
isEqual: (l, w) => l === w
|
|
1358
|
+
}), s = et(c, i);
|
|
1359
|
+
})(), document.body.addEventListener(g.EVENT_NAME, u), x(r), {
|
|
1341
1360
|
/**
|
|
1342
1361
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1343
1362
|
*/
|
|
1344
1363
|
unmount() {
|
|
1345
|
-
a || (document.body.removeEventListener(
|
|
1364
|
+
a || (document.body.removeEventListener(g.EVENT_NAME, u), o.unmount(), n && (DotNet.disposeJSObjectReference(n), n = null), s = null, a = !0);
|
|
1346
1365
|
},
|
|
1347
1366
|
/**
|
|
1348
1367
|
* Updates this editable root's data from Blazor.
|
|
1349
1368
|
* If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1350
1369
|
*/
|
|
1351
|
-
setValue: async (
|
|
1352
|
-
a || (await h.the.waitFor(e),
|
|
1370
|
+
setValue: async (c) => {
|
|
1371
|
+
a || (await h.the.waitFor(e), o.setValue(c));
|
|
1372
|
+
},
|
|
1373
|
+
/**
|
|
1374
|
+
* Updates the root attributes on the editor. This is useful when the Blazor component
|
|
1375
|
+
* re-renders with new root attributes.
|
|
1376
|
+
*/
|
|
1377
|
+
setRootAttributes: async (c) => {
|
|
1378
|
+
a || (await h.the.waitFor(e), s?.(c));
|
|
1353
1379
|
}
|
|
1354
1380
|
};
|
|
1355
1381
|
}
|
|
1356
|
-
function
|
|
1382
|
+
function zt(r, t) {
|
|
1357
1383
|
const e = r.getAttribute("data-cke-editor-id");
|
|
1358
|
-
let i = !1, a = null, n = tt(), o = null;
|
|
1359
|
-
const
|
|
1360
|
-
!(
|
|
1384
|
+
let i = !1, a = null, n = tt(), o = null, s = null;
|
|
1385
|
+
const u = (c) => {
|
|
1386
|
+
!(c instanceof g) || c.detail.editorId !== e || n.shouldNotify(c.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", s, c.detail.roots);
|
|
1361
1387
|
};
|
|
1362
1388
|
return (async () => {
|
|
1363
|
-
const
|
|
1364
|
-
|
|
1365
|
-
getCurrentValue: () =>
|
|
1366
|
-
applyValue: (
|
|
1367
|
-
isEqual:
|
|
1368
|
-
});
|
|
1369
|
-
const l = (
|
|
1370
|
-
const
|
|
1371
|
-
t.invokeMethodAsync(
|
|
1389
|
+
const c = await h.the.waitFor(e);
|
|
1390
|
+
s = globalThis.DotNet.createJSObjectReference(c), n = Z(c, {
|
|
1391
|
+
getCurrentValue: () => J(c),
|
|
1392
|
+
applyValue: (w) => c.setData(w),
|
|
1393
|
+
isEqual: at
|
|
1394
|
+
}), o = et(c, "main");
|
|
1395
|
+
const l = (w, y, b) => {
|
|
1396
|
+
const f = b ? "OnEditorFocus" : "OnEditorBlur";
|
|
1397
|
+
t.invokeMethodAsync(f, s);
|
|
1372
1398
|
};
|
|
1373
|
-
|
|
1374
|
-
|
|
1399
|
+
c.ui.focusTracker.on("change:isFocused", l), t.invokeMethodAsync("OnEditorReady", s), a = () => {
|
|
1400
|
+
c.ui.focusTracker.off("change:isFocused", l);
|
|
1375
1401
|
};
|
|
1376
|
-
})(), document.body.addEventListener(
|
|
1402
|
+
})(), document.body.addEventListener(g.EVENT_NAME, u), Ct(), x(r), {
|
|
1377
1403
|
/**
|
|
1378
1404
|
* Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1379
1405
|
*/
|
|
1380
|
-
setValue: async (
|
|
1381
|
-
i || (await h.the.waitFor(e), n.setValue(
|
|
1406
|
+
setValue: async (c) => {
|
|
1407
|
+
i || (await h.the.waitFor(e), n.setValue(c));
|
|
1408
|
+
},
|
|
1409
|
+
/**
|
|
1410
|
+
* Updates the root attributes on the editor instance.
|
|
1411
|
+
*/
|
|
1412
|
+
setRootAttributes: async (c) => {
|
|
1413
|
+
i || (await h.the.waitFor(e), o?.(c));
|
|
1382
1414
|
},
|
|
1383
1415
|
/**
|
|
1384
1416
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1385
1417
|
*/
|
|
1386
1418
|
unmount() {
|
|
1387
|
-
i || (document.body.removeEventListener(
|
|
1419
|
+
i || (document.body.removeEventListener(g.EVENT_NAME, u), n.unmount(), a?.(), s && (globalThis.DotNet.disposeJSObjectReference(s), s = null), o = null, i = !0);
|
|
1388
1420
|
},
|
|
1389
1421
|
/**
|
|
1390
1422
|
* Installs the custom image upload adapter that delegates uploads to Blazor.
|
|
@@ -1394,12 +1426,12 @@ function xt(r, t) {
|
|
|
1394
1426
|
attachImageUploadAdapter: async () => {
|
|
1395
1427
|
if (i)
|
|
1396
1428
|
return;
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1429
|
+
const c = await h.the.waitFor(e);
|
|
1430
|
+
Pt(c, t);
|
|
1399
1431
|
}
|
|
1400
1432
|
};
|
|
1401
1433
|
}
|
|
1402
|
-
function
|
|
1434
|
+
function Pt(r, t) {
|
|
1403
1435
|
if (!r.plugins.has("FileRepository"))
|
|
1404
1436
|
return;
|
|
1405
1437
|
const e = r.plugins.get("FileRepository");
|
|
@@ -1410,16 +1442,16 @@ function Ct(r, t) {
|
|
|
1410
1442
|
const n = await i.file;
|
|
1411
1443
|
if (a)
|
|
1412
1444
|
throw new Error("Upload aborted.");
|
|
1413
|
-
const o = await
|
|
1445
|
+
const o = await It(n), s = await t.invokeMethodAsync("OnEditorImageUpload", {
|
|
1414
1446
|
fileName: n.name,
|
|
1415
1447
|
mimeType: n.type,
|
|
1416
1448
|
payload: o
|
|
1417
1449
|
});
|
|
1418
|
-
if (!
|
|
1450
|
+
if (!s)
|
|
1419
1451
|
throw new Error(
|
|
1420
1452
|
"OnImageUpload handler returned null. Make sure the OnImageUpload parameter is set on the <CKE5Editor> component."
|
|
1421
1453
|
);
|
|
1422
|
-
return { default:
|
|
1454
|
+
return { default: s };
|
|
1423
1455
|
},
|
|
1424
1456
|
abort() {
|
|
1425
1457
|
a = !0;
|
|
@@ -1427,7 +1459,7 @@ function Ct(r, t) {
|
|
|
1427
1459
|
};
|
|
1428
1460
|
};
|
|
1429
1461
|
}
|
|
1430
|
-
function
|
|
1462
|
+
function It(r) {
|
|
1431
1463
|
return new Promise((t, e) => {
|
|
1432
1464
|
const i = new FileReader();
|
|
1433
1465
|
i.onload = () => {
|
|
@@ -1436,25 +1468,25 @@ function At(r) {
|
|
|
1436
1468
|
}, i.onerror = () => e(i.error), i.readAsDataURL(r);
|
|
1437
1469
|
});
|
|
1438
1470
|
}
|
|
1439
|
-
function
|
|
1440
|
-
return
|
|
1471
|
+
function Vt(r) {
|
|
1472
|
+
return x(r), {
|
|
1441
1473
|
unmount() {
|
|
1442
1474
|
}
|
|
1443
1475
|
};
|
|
1444
1476
|
}
|
|
1445
1477
|
export {
|
|
1446
|
-
|
|
1447
|
-
|
|
1478
|
+
E as CKEditor5BlazorError,
|
|
1479
|
+
g as CKEditor5ChangeDataEvent,
|
|
1448
1480
|
v as ContextsRegistry,
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1481
|
+
W as CustomEditorPluginsRegistry,
|
|
1482
|
+
ft as EditableComponentElement,
|
|
1483
|
+
bt as EditorComponentElement,
|
|
1452
1484
|
h as EditorsRegistry,
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1485
|
+
kt as UIPartComponentElement,
|
|
1486
|
+
xt as createContextBlazorInterop,
|
|
1487
|
+
Nt as createEditableBlazorInterop,
|
|
1488
|
+
zt as createEditorBlazorInterop,
|
|
1489
|
+
Vt as createUIPartBlazorInterop,
|
|
1490
|
+
Ct as ensureEditorElementsRegistered
|
|
1459
1491
|
};
|
|
1460
1492
|
//# sourceMappingURL=index.mjs.map
|