ckeditor5-blazor 1.10.0 → 1.10.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.
- package/dist/elements/editable.d.ts.map +1 -1
- package/dist/elements/editor/editor.d.ts +2 -2
- 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 +204 -207
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/elements/editable.ts +1 -0
- package/src/elements/editor/editor.ts +36 -44
- package/src/interop/create-editor-blazor-interop.ts +3 -3
package/dist/index.mjs
CHANGED
|
@@ -6,8 +6,8 @@ class k extends Error {
|
|
|
6
6
|
function H(r, t) {
|
|
7
7
|
if (!r || r.size !== t.size)
|
|
8
8
|
return !1;
|
|
9
|
-
for (const [e,
|
|
10
|
-
if (!t.has(e) || t.get(e) !==
|
|
9
|
+
for (const [e, a] of r)
|
|
10
|
+
if (!t.has(e) || t.get(e) !== a)
|
|
11
11
|
return !1;
|
|
12
12
|
return !0;
|
|
13
13
|
}
|
|
@@ -46,13 +46,13 @@ class Y {
|
|
|
46
46
|
* @param onError Optional error callback.
|
|
47
47
|
* @returns A promise that resolves with the result of the function.
|
|
48
48
|
*/
|
|
49
|
-
execute(t, e,
|
|
50
|
-
const
|
|
51
|
-
return n ? (
|
|
49
|
+
execute(t, e, a) {
|
|
50
|
+
const i = this.items.get(t), n = this.initializationErrors.get(t);
|
|
51
|
+
return n ? (a?.(n), Promise.reject(n)) : i ? Promise.resolve(e(i)) : new Promise((o, c) => {
|
|
52
52
|
const u = this.getPendingCallbacks(t);
|
|
53
53
|
u.success.push(async (s) => {
|
|
54
54
|
o(await e(s));
|
|
55
|
-
}),
|
|
55
|
+
}), a ? u.error.push(a) : u.error.push(c);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -63,19 +63,19 @@ class Y {
|
|
|
63
63
|
* @returns A function that stops observing and immediately runs any pending cleanup.
|
|
64
64
|
*/
|
|
65
65
|
mountEffect(t, e) {
|
|
66
|
-
let
|
|
66
|
+
let a, i, n = !1;
|
|
67
67
|
const o = this.watch((c) => {
|
|
68
68
|
const u = c.get(t);
|
|
69
|
-
if (u !==
|
|
69
|
+
if (u !== i && (a?.(), a = void 0, i = u, !!u))
|
|
70
70
|
try {
|
|
71
71
|
const s = e(u);
|
|
72
|
-
n ? (s?.(), o()) :
|
|
72
|
+
n ? (s?.(), o()) : a = s;
|
|
73
73
|
} catch (s) {
|
|
74
74
|
throw console.error(s), s;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
return () => {
|
|
78
|
-
n = !0,
|
|
78
|
+
n = !0, i && (o(), a?.(), a = void 0);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -89,8 +89,8 @@ class Y {
|
|
|
89
89
|
if (this.items.has(t))
|
|
90
90
|
throw new Error(`Item with ID "${t}" is already registered.`);
|
|
91
91
|
this.resetErrors(t), this.items.set(t, e);
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const a = this.pendingCallbacks.get(t);
|
|
93
|
+
a && (a.success.forEach((i) => i(e)), this.pendingCallbacks.delete(t)), this.items.size === 1 && t !== null && this.register(null, e);
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -102,8 +102,8 @@ class Y {
|
|
|
102
102
|
error(t, e) {
|
|
103
103
|
this.batch(() => {
|
|
104
104
|
this.items.delete(t), this.initializationErrors.set(t, e);
|
|
105
|
-
const
|
|
106
|
-
|
|
105
|
+
const a = this.pendingCallbacks.get(t);
|
|
106
|
+
a && (a.error.forEach((i) => i(e)), this.pendingCallbacks.delete(t)), this.initializationErrors.size === 1 && !this.items.size && this.error(null, e);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
@@ -159,8 +159,8 @@ class Y {
|
|
|
159
159
|
* @returns A promise that resolves with the item instance.
|
|
160
160
|
*/
|
|
161
161
|
waitFor(t) {
|
|
162
|
-
return new Promise((e,
|
|
163
|
-
this.execute(t, e,
|
|
162
|
+
return new Promise((e, a) => {
|
|
163
|
+
this.execute(t, e, a);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
@@ -238,31 +238,31 @@ class Y {
|
|
|
238
238
|
}
|
|
239
239
|
function $(r, t) {
|
|
240
240
|
let e = null;
|
|
241
|
-
return (...
|
|
241
|
+
return (...a) => {
|
|
242
242
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
243
|
-
t(...
|
|
243
|
+
t(...a);
|
|
244
244
|
}, r);
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
function st(r, t) {
|
|
248
|
-
const e = Object.entries(r).filter(([
|
|
248
|
+
const e = Object.entries(r).filter(([a, i]) => t(i, a));
|
|
249
249
|
return Object.fromEntries(e);
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function P(r) {
|
|
252
252
|
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
253
253
|
}
|
|
254
254
|
function W(r, t) {
|
|
255
|
-
const e = Object.entries(r).map(([
|
|
255
|
+
const e = Object.entries(r).map(([a, i]) => [a, t(i, a)]);
|
|
256
256
|
return Object.fromEntries(e);
|
|
257
257
|
}
|
|
258
258
|
function ct(r, t) {
|
|
259
259
|
if (r === t)
|
|
260
260
|
return !0;
|
|
261
|
-
const e = Object.keys(r),
|
|
262
|
-
if (e.length !==
|
|
261
|
+
const e = Object.keys(r), a = Object.keys(t);
|
|
262
|
+
if (e.length !== a.length)
|
|
263
263
|
return !1;
|
|
264
|
-
for (const
|
|
265
|
-
if (r[
|
|
264
|
+
for (const i of e)
|
|
265
|
+
if (r[i] !== t[i] || !Object.prototype.hasOwnProperty.call(t, i))
|
|
266
266
|
return !1;
|
|
267
267
|
return !0;
|
|
268
268
|
}
|
|
@@ -273,23 +273,23 @@ function lt(r, {
|
|
|
273
273
|
timeOutAfter: t = 500,
|
|
274
274
|
retryAfter: e = 100
|
|
275
275
|
} = {}) {
|
|
276
|
-
return new Promise((
|
|
276
|
+
return new Promise((a, i) => {
|
|
277
277
|
const n = Date.now();
|
|
278
278
|
let o = null;
|
|
279
279
|
const c = setTimeout(() => {
|
|
280
|
-
|
|
280
|
+
i(o ?? new Error("Timeout"));
|
|
281
281
|
}, t), u = async () => {
|
|
282
282
|
try {
|
|
283
283
|
const s = await r();
|
|
284
|
-
clearTimeout(c),
|
|
284
|
+
clearTimeout(c), a(s);
|
|
285
285
|
} catch (s) {
|
|
286
|
-
o = s, Date.now() - n > t ?
|
|
286
|
+
o = s, Date.now() - n > t ? i(s) : setTimeout(u, e);
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
289
|
u();
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function M() {
|
|
293
293
|
return new Promise((r) => {
|
|
294
294
|
switch (document.readyState) {
|
|
295
295
|
case "loading":
|
|
@@ -310,11 +310,11 @@ function L(r) {
|
|
|
310
310
|
} };
|
|
311
311
|
let t;
|
|
312
312
|
return {
|
|
313
|
-
promise: new Promise((
|
|
314
|
-
t = new MutationObserver((
|
|
315
|
-
for (const n of
|
|
313
|
+
promise: new Promise((a) => {
|
|
314
|
+
t = new MutationObserver((i) => {
|
|
315
|
+
for (const n of i)
|
|
316
316
|
if (n.type === "attributes" && n.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
|
|
317
|
-
t.disconnect(),
|
|
317
|
+
t.disconnect(), a();
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
320
|
}), t.observe(r, { attributes: !0 });
|
|
@@ -322,7 +322,7 @@ function L(r) {
|
|
|
322
322
|
disconnect: () => t?.disconnect()
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function x(r) {
|
|
326
326
|
r.setAttribute("data-cke-interactive", "true");
|
|
327
327
|
}
|
|
328
328
|
function dt(r) {
|
|
@@ -332,12 +332,12 @@ function dt(r) {
|
|
|
332
332
|
r.ui?.view?.menuBarView?.element
|
|
333
333
|
].filter(Boolean);
|
|
334
334
|
for (const n of t)
|
|
335
|
-
|
|
335
|
+
i(n);
|
|
336
336
|
const e = r.ui?.view?.body?._bodyCollectionContainer;
|
|
337
|
-
e?.isConnected &&
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
for (const n of
|
|
337
|
+
e?.isConnected && i(e);
|
|
338
|
+
const a = r.editing?.view;
|
|
339
|
+
if (a)
|
|
340
|
+
for (const n of a.domRoots.values())
|
|
341
341
|
n instanceof HTMLElement && (n.removeAttribute("contenteditable"), n.removeAttribute("role"), n.removeAttribute("aria-label"), n.removeAttribute("aria-multiline"), n.removeAttribute("spellcheck"), n.classList.remove(
|
|
342
342
|
"ck",
|
|
343
343
|
"ck-content",
|
|
@@ -346,24 +346,24 @@ function dt(r) {
|
|
|
346
346
|
"ck-editor__editable_inline",
|
|
347
347
|
"ck-blurred",
|
|
348
348
|
"ck-focused"
|
|
349
|
-
),
|
|
350
|
-
function
|
|
349
|
+
), i(n));
|
|
350
|
+
function i(n) {
|
|
351
351
|
n.hasAttribute("data-cke-controlled") ? n.innerHTML = "" : n.remove();
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
const V = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
355
|
-
async function mt({ element: r, context: t, creator: e, config:
|
|
356
|
-
const
|
|
355
|
+
async function mt({ element: r, context: t, creator: e, config: a }) {
|
|
356
|
+
const i = ut();
|
|
357
357
|
await t.add({
|
|
358
358
|
creator: (u, s) => e.create(u, s),
|
|
359
|
-
id:
|
|
359
|
+
id: i,
|
|
360
360
|
sourceElementOrData: r,
|
|
361
361
|
type: "editor",
|
|
362
|
-
config:
|
|
362
|
+
config: a
|
|
363
363
|
});
|
|
364
|
-
const n = t.getItem(
|
|
364
|
+
const n = t.getItem(i), o = {
|
|
365
365
|
state: "available",
|
|
366
|
-
editorContextId:
|
|
366
|
+
editorContextId: i,
|
|
367
367
|
context: t
|
|
368
368
|
};
|
|
369
369
|
n[V] = o;
|
|
@@ -383,19 +383,19 @@ function O(r) {
|
|
|
383
383
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
384
384
|
}
|
|
385
385
|
async function J(r) {
|
|
386
|
-
const t = await import("ckeditor5"),
|
|
386
|
+
const t = await import("ckeditor5"), a = {
|
|
387
387
|
inline: t.InlineEditor,
|
|
388
388
|
balloon: t.BalloonEditor,
|
|
389
389
|
classic: t.ClassicEditor,
|
|
390
390
|
decoupled: t.DecoupledEditor,
|
|
391
391
|
multiroot: t.MultiRootEditor
|
|
392
392
|
}[r];
|
|
393
|
-
if (!
|
|
393
|
+
if (!a)
|
|
394
394
|
throw new k(`Unsupported editor type: ${r}`);
|
|
395
|
-
return
|
|
395
|
+
return a;
|
|
396
396
|
}
|
|
397
|
-
class
|
|
398
|
-
static the = new
|
|
397
|
+
class _ {
|
|
398
|
+
static the = new _();
|
|
399
399
|
/**
|
|
400
400
|
* Map of registered custom plugins.
|
|
401
401
|
*/
|
|
@@ -457,9 +457,9 @@ class F {
|
|
|
457
457
|
async function Q(r) {
|
|
458
458
|
const t = await import("ckeditor5");
|
|
459
459
|
let e = null;
|
|
460
|
-
const
|
|
461
|
-
if (ft(
|
|
462
|
-
const { name: u, path: s } =
|
|
460
|
+
const a = r.map(async (i) => {
|
|
461
|
+
if (ft(i)) {
|
|
462
|
+
const { name: u, path: s } = i.$import, l = await import(
|
|
463
463
|
/* @vite-ignore */
|
|
464
464
|
s
|
|
465
465
|
), p = (Object.prototype.hasOwnProperty.call(l, u) ? l[u] : void 0) ?? (Object.prototype.hasOwnProperty.call(l, "default") ? l.default : void 0);
|
|
@@ -467,25 +467,25 @@ async function Q(r) {
|
|
|
467
467
|
throw new k(`Plugin "${u}" not found in module "${s}".`);
|
|
468
468
|
return p;
|
|
469
469
|
}
|
|
470
|
-
const n = await
|
|
470
|
+
const n = await _.the.get(i);
|
|
471
471
|
if (n)
|
|
472
472
|
return n;
|
|
473
|
-
const { [
|
|
473
|
+
const { [i]: o } = t;
|
|
474
474
|
if (o)
|
|
475
475
|
return o;
|
|
476
476
|
if (!e)
|
|
477
477
|
try {
|
|
478
478
|
e = await import("ckeditor5-premium-features");
|
|
479
479
|
} catch (u) {
|
|
480
|
-
throw console.error(`Failed to load premium package: ${u}`), new k(`Plugin "${
|
|
480
|
+
throw console.error(`Failed to load premium package: ${u}`), new k(`Plugin "${i}" not found in base package and failed to load premium package.`);
|
|
481
481
|
}
|
|
482
|
-
const { [
|
|
482
|
+
const { [i]: c } = e || {};
|
|
483
483
|
if (c)
|
|
484
484
|
return c;
|
|
485
|
-
throw new k(`Plugin "${
|
|
485
|
+
throw new k(`Plugin "${i}" not found in base or premium packages.`);
|
|
486
486
|
});
|
|
487
487
|
return {
|
|
488
|
-
loadedPlugins: await Promise.all(
|
|
488
|
+
loadedPlugins: await Promise.all(a),
|
|
489
489
|
hasPremium: !!e
|
|
490
490
|
};
|
|
491
491
|
}
|
|
@@ -499,14 +499,14 @@ async function Z(r, t) {
|
|
|
499
499
|
K("ckeditor5", e),
|
|
500
500
|
/* v8 ignore next -- @preserve */
|
|
501
501
|
t && K("ckeditor5-premium-features", e)
|
|
502
|
-
].filter((
|
|
503
|
-
).then((
|
|
502
|
+
].filter((i) => !!i)
|
|
503
|
+
).then((i) => i.flat());
|
|
504
504
|
}
|
|
505
505
|
async function K(r, t) {
|
|
506
506
|
return await Promise.all(
|
|
507
507
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
508
|
-
const
|
|
509
|
-
return
|
|
508
|
+
const a = await pt(r, e);
|
|
509
|
+
return a?.default ?? a;
|
|
510
510
|
}).filter(Boolean)
|
|
511
511
|
);
|
|
512
512
|
}
|
|
@@ -815,7 +815,7 @@ function tt(r) {
|
|
|
815
815
|
dictionary: t
|
|
816
816
|
}));
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function q() {
|
|
819
819
|
return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
|
|
820
820
|
}
|
|
821
821
|
function et(r) {
|
|
@@ -823,8 +823,8 @@ function et(r) {
|
|
|
823
823
|
return W(t, ({ element: e }) => e);
|
|
824
824
|
}
|
|
825
825
|
function G(r) {
|
|
826
|
-
const t = rt(r), e = W(t, ({ content:
|
|
827
|
-
return st(e, (
|
|
826
|
+
const t = rt(r), e = W(t, ({ content: a }) => a);
|
|
827
|
+
return st(e, (a) => typeof a == "string");
|
|
828
828
|
}
|
|
829
829
|
function rt(r) {
|
|
830
830
|
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, c) => {
|
|
@@ -836,18 +836,18 @@ function rt(r) {
|
|
|
836
836
|
}, /* @__PURE__ */ Object.create({})), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
|
|
837
837
|
if (!e)
|
|
838
838
|
return t;
|
|
839
|
-
const
|
|
840
|
-
return
|
|
839
|
+
const a = t.main, i = JSON.parse(e.getAttribute("data-cke-content")), n = document.querySelector(`#${r}_editor `);
|
|
840
|
+
return a && i?.main ? {
|
|
841
841
|
...t,
|
|
842
842
|
main: {
|
|
843
|
-
...
|
|
844
|
-
content:
|
|
843
|
+
...a,
|
|
844
|
+
content: a.content || i.main
|
|
845
845
|
}
|
|
846
846
|
} : n ? {
|
|
847
847
|
...t,
|
|
848
848
|
main: {
|
|
849
849
|
element: n,
|
|
850
|
-
content:
|
|
850
|
+
content: i?.main || null
|
|
851
851
|
}
|
|
852
852
|
} : t;
|
|
853
853
|
}
|
|
@@ -855,55 +855,55 @@ function S(r) {
|
|
|
855
855
|
if (!r || typeof r != "object")
|
|
856
856
|
return r;
|
|
857
857
|
if (Array.isArray(r))
|
|
858
|
-
return r.map((
|
|
858
|
+
return r.map((a) => S(a));
|
|
859
859
|
const t = r;
|
|
860
860
|
if (t.$element && typeof t.$element == "string") {
|
|
861
|
-
const
|
|
862
|
-
return
|
|
861
|
+
const a = document.querySelector(t.$element);
|
|
862
|
+
return a || console.warn(`Element not found for selector: ${t.$element}`), a || null;
|
|
863
863
|
}
|
|
864
864
|
const e = /* @__PURE__ */ Object.create(null);
|
|
865
|
-
for (const [
|
|
866
|
-
e[
|
|
865
|
+
for (const [a, i] of Object.entries(r))
|
|
866
|
+
e[a] = S(i);
|
|
867
867
|
return e;
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function D(r, t, e) {
|
|
870
870
|
if (!e || typeof e != "object")
|
|
871
871
|
return e;
|
|
872
872
|
if (Array.isArray(e))
|
|
873
|
-
return e.map((n) =>
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
const n =
|
|
873
|
+
return e.map((n) => D(r, t, n));
|
|
874
|
+
const a = e;
|
|
875
|
+
if (a.$translation && typeof a.$translation == "string") {
|
|
876
|
+
const n = a.$translation, o = wt(r, n, t);
|
|
877
877
|
return o === void 0 && console.warn(`Translation not found for key: ${n}`), o !== void 0 ? o : null;
|
|
878
878
|
}
|
|
879
|
-
const
|
|
879
|
+
const i = /* @__PURE__ */ Object.create(null);
|
|
880
880
|
for (const [n, o] of Object.entries(e))
|
|
881
|
-
|
|
882
|
-
return
|
|
881
|
+
i[n] = D(r, t, o);
|
|
882
|
+
return i;
|
|
883
883
|
}
|
|
884
884
|
function wt(r, t, e) {
|
|
885
|
-
for (const
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
888
|
-
return
|
|
885
|
+
for (const a of r) {
|
|
886
|
+
const i = a[e];
|
|
887
|
+
if (i?.dictionary && t in i.dictionary)
|
|
888
|
+
return i.dictionary[t];
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
function gt(r, t) {
|
|
892
892
|
const { editing: e } = r;
|
|
893
|
-
e.view.change((
|
|
894
|
-
|
|
893
|
+
e.view.change((a) => {
|
|
894
|
+
a.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
895
895
|
});
|
|
896
896
|
}
|
|
897
897
|
const z = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
|
|
898
898
|
async function bt(r, t) {
|
|
899
|
-
const { EditorWatchdog: e } = await import("ckeditor5"),
|
|
899
|
+
const { EditorWatchdog: e } = await import("ckeditor5"), a = new e(null, t ?? {
|
|
900
900
|
crashNumberLimit: 10,
|
|
901
901
|
minimumNonErrorTimePeriod: 5e3
|
|
902
902
|
});
|
|
903
|
-
return
|
|
904
|
-
const
|
|
905
|
-
return
|
|
906
|
-
}),
|
|
903
|
+
return a.setCreator(async () => {
|
|
904
|
+
const i = await r();
|
|
905
|
+
return i[z] = a, i;
|
|
906
|
+
}), a;
|
|
907
907
|
}
|
|
908
908
|
function yt(r) {
|
|
909
909
|
return z in r ? r[z] : null;
|
|
@@ -924,23 +924,23 @@ class Et extends HTMLElement {
|
|
|
924
924
|
* Mounts the context component.
|
|
925
925
|
*/
|
|
926
926
|
async connectedCallback() {
|
|
927
|
-
await
|
|
927
|
+
await M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
|
|
928
928
|
}
|
|
929
929
|
/**
|
|
930
930
|
* Initializes the context component.
|
|
931
931
|
*/
|
|
932
932
|
async initializeContext() {
|
|
933
|
-
const t = this.getAttribute("data-cke-context-id"), e = JSON.parse(this.getAttribute("data-cke-language")),
|
|
933
|
+
const t = this.getAttribute("data-cke-context-id"), e = JSON.parse(this.getAttribute("data-cke-language")), a = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: i, watchdogConfig: n, config: { plugins: o, ...c } } = a, { loadedPlugins: u, hasPremium: s } = await Q(o ?? []), l = [
|
|
934
934
|
...await Z(e, s),
|
|
935
|
-
tt(
|
|
936
|
-
].filter((w) => !
|
|
935
|
+
tt(i || {})
|
|
936
|
+
].filter((w) => !P(w));
|
|
937
937
|
this.contextPromise = (async () => {
|
|
938
938
|
const { ContextWatchdog: w, Context: y } = await import("ckeditor5"), E = new w(y, {
|
|
939
939
|
crashNumberLimit: 10,
|
|
940
940
|
...n
|
|
941
941
|
});
|
|
942
942
|
let h = S(c);
|
|
943
|
-
return h =
|
|
943
|
+
return h = D([...l].reverse(), e.ui, h), await E.create({
|
|
944
944
|
...h,
|
|
945
945
|
language: e,
|
|
946
946
|
plugins: u,
|
|
@@ -984,14 +984,14 @@ class kt extends HTMLElement {
|
|
|
984
984
|
* Mounts the editable component.
|
|
985
985
|
*/
|
|
986
986
|
async connectedCallback() {
|
|
987
|
-
await
|
|
987
|
+
await M(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
990
990
|
* Initializes the editable instance.
|
|
991
991
|
*/
|
|
992
992
|
async initializeEditable() {
|
|
993
|
-
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id",
|
|
994
|
-
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"),
|
|
993
|
+
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", q()[0]);
|
|
994
|
+
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), a = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), i = this.getAttribute("data-cke-content"), n = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
|
|
995
995
|
if (!t || !e)
|
|
996
996
|
throw new k("Editor ID or Root Name is missing.");
|
|
997
997
|
this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (o) => {
|
|
@@ -999,22 +999,22 @@ class kt extends HTMLElement {
|
|
|
999
999
|
return;
|
|
1000
1000
|
const { ui: c, editing: u, model: s } = o, d = this.querySelector("input"), l = s.document.getRoot(e);
|
|
1001
1001
|
if (l?.isAttached()) {
|
|
1002
|
-
if (
|
|
1002
|
+
if (i !== null) {
|
|
1003
1003
|
const h = o.getData({ rootName: e });
|
|
1004
|
-
h && h !==
|
|
1005
|
-
[e]:
|
|
1004
|
+
h && h !== i && o.setData({
|
|
1005
|
+
[e]: i
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
|
-
|
|
1009
|
-
h.setAttributes(
|
|
1008
|
+
P(a) || o.model.change((h) => {
|
|
1009
|
+
h.setAttributes(a, l);
|
|
1010
1010
|
});
|
|
1011
1011
|
return;
|
|
1012
1012
|
}
|
|
1013
1013
|
o.addRoot(e, {
|
|
1014
1014
|
isUndoable: !1,
|
|
1015
|
-
attributes: { ...
|
|
1016
|
-
...
|
|
1017
|
-
data:
|
|
1015
|
+
attributes: { ...a },
|
|
1016
|
+
...i !== null && {
|
|
1017
|
+
data: i
|
|
1018
1018
|
}
|
|
1019
1019
|
});
|
|
1020
1020
|
const p = this.querySelector("[data-cke-editable-content]"), w = c.view.createEditable(e, p);
|
|
@@ -1056,8 +1056,8 @@ async function vt({
|
|
|
1056
1056
|
editorId: t,
|
|
1057
1057
|
targetElement: e
|
|
1058
1058
|
}) {
|
|
1059
|
-
const { Plugin:
|
|
1060
|
-
return class extends
|
|
1059
|
+
const { Plugin: a } = await import("ckeditor5");
|
|
1060
|
+
return class extends a {
|
|
1061
1061
|
/**
|
|
1062
1062
|
* The name of the plugin.
|
|
1063
1063
|
*/
|
|
@@ -1116,16 +1116,16 @@ async function At(r) {
|
|
|
1116
1116
|
* Initializes the plugin.
|
|
1117
1117
|
*/
|
|
1118
1118
|
afterInit() {
|
|
1119
|
-
const { editor:
|
|
1120
|
-
this.input = document.getElementById(`${n}_input`), this.input && (
|
|
1119
|
+
const { editor: a } = this, n = a.sourceElement.id.replace(/_editor$/, "");
|
|
1120
|
+
this.input = document.getElementById(`${n}_input`), this.input && (a.model.document.on("change:data", $(r, () => this.sync())), a.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1121
1121
|
}
|
|
1122
1122
|
/**
|
|
1123
1123
|
* Synchronizes the editor's content with the input field.
|
|
1124
1124
|
*/
|
|
1125
1125
|
sync = () => {
|
|
1126
1126
|
if (this.input) {
|
|
1127
|
-
const
|
|
1128
|
-
this.input.value =
|
|
1127
|
+
const a = this.editor.getData();
|
|
1128
|
+
this.input.value = a, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1129
1129
|
}
|
|
1130
1130
|
};
|
|
1131
1131
|
/**
|
|
@@ -1138,9 +1138,9 @@ async function At(r) {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
class Ct extends HTMLElement {
|
|
1140
1140
|
/**
|
|
1141
|
-
*
|
|
1141
|
+
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
1142
1142
|
*/
|
|
1143
|
-
|
|
1143
|
+
unmountEffect = null;
|
|
1144
1144
|
/**
|
|
1145
1145
|
* Wait result for the interactive attribute.
|
|
1146
1146
|
*/
|
|
@@ -1149,7 +1149,7 @@ class Ct extends HTMLElement {
|
|
|
1149
1149
|
* Mounts the editor component.
|
|
1150
1150
|
*/
|
|
1151
1151
|
async connectedCallback() {
|
|
1152
|
-
await
|
|
1152
|
+
await M(), this.interactiveWait = L(this), J("classic"), await this.interactiveWait.promise, await this.initializeEditor();
|
|
1153
1153
|
}
|
|
1154
1154
|
/**
|
|
1155
1155
|
* Initializes the editor instance.
|
|
@@ -1158,13 +1158,20 @@ class Ct extends HTMLElement {
|
|
|
1158
1158
|
const t = this.getAttribute("data-cke-editor-id");
|
|
1159
1159
|
m.the.resetErrors(t);
|
|
1160
1160
|
try {
|
|
1161
|
-
this.style.display = "block"
|
|
1162
|
-
const e = await this.
|
|
1163
|
-
this.isConnected
|
|
1164
|
-
m.the.
|
|
1165
|
-
|
|
1161
|
+
this.style.display = "block";
|
|
1162
|
+
const e = await this.createEditor(), a = ht(e), i = yt(e);
|
|
1163
|
+
if (this.isConnected) {
|
|
1164
|
+
const n = m.the.mountEffect(t, (o) => {
|
|
1165
|
+
o.once("destroy", () => {
|
|
1166
|
+
m.the.unregister(t, !1);
|
|
1167
|
+
}, { priority: "highest" });
|
|
1168
|
+
});
|
|
1169
|
+
this.unmountEffect = async () => {
|
|
1170
|
+
m.the.unregister(t), n(), a ? a.state !== "unavailable" && await a.context.remove(a.editorContextId) : i ? await i.destroy() : await e.destroy();
|
|
1171
|
+
}, m.the.register(t, e);
|
|
1172
|
+
}
|
|
1166
1173
|
} catch (e) {
|
|
1167
|
-
console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e),
|
|
1174
|
+
console.error(`Error initializing CKEditor5 instance with ID "${t}":`, e), m.the.error(t, e);
|
|
1168
1175
|
}
|
|
1169
1176
|
}
|
|
1170
1177
|
/**
|
|
@@ -1172,28 +1179,19 @@ class Ct extends HTMLElement {
|
|
|
1172
1179
|
* This is important to prevent memory leaks and ensure that the editor is properly cleaned up.
|
|
1173
1180
|
*/
|
|
1174
1181
|
async disconnectedCallback() {
|
|
1175
|
-
this.interactiveWait?.disconnect(), this.style.display = "none";
|
|
1176
|
-
try {
|
|
1177
|
-
const t = await this.editorPromise;
|
|
1178
|
-
if (!t)
|
|
1179
|
-
return;
|
|
1180
|
-
const e = ht(t), i = yt(t);
|
|
1181
|
-
e ? e.state !== "unavailable" && await e.context.remove(e.editorContextId) : i ? await i.destroy() : await t.destroy();
|
|
1182
|
-
} finally {
|
|
1183
|
-
this.editorPromise = null;
|
|
1184
|
-
}
|
|
1182
|
+
this.interactiveWait?.disconnect(), this.style.display = "none", this.unmountEffect?.();
|
|
1185
1183
|
}
|
|
1186
1184
|
/**
|
|
1187
1185
|
* Creates the CKEditor instance.
|
|
1188
1186
|
*/
|
|
1189
1187
|
async createEditor() {
|
|
1190
|
-
const t = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")),
|
|
1188
|
+
const t = this.getAttribute("data-cke-editor-id"), e = JSON.parse(this.getAttribute("data-cke-preset")), a = this.getAttribute("data-cke-context-id"), i = 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), c = JSON.parse(this.getAttribute("data-cke-language")), u = this.hasAttribute("data-cke-watchdog"), s = JSON.parse(this.getAttribute("data-cke-content")), {
|
|
1191
1189
|
customTranslations: d,
|
|
1192
1190
|
editorType: l,
|
|
1193
1191
|
licenseKey: p,
|
|
1194
1192
|
watchdogConfig: w,
|
|
1195
1193
|
config: { plugins: y, ...E }
|
|
1196
|
-
} = e, h = await J(l), v = await (
|
|
1194
|
+
} = e, h = await J(l), v = await (a ? C.the.waitFor(a) : null), F = async () => {
|
|
1197
1195
|
const { loadedPlugins: g, hasPremium: T } = await Q(y);
|
|
1198
1196
|
g.push(
|
|
1199
1197
|
await vt({
|
|
@@ -1207,24 +1205,24 @@ class Ct extends HTMLElement {
|
|
|
1207
1205
|
const A = [
|
|
1208
1206
|
...await Z(c, T),
|
|
1209
1207
|
tt(d || {})
|
|
1210
|
-
].filter((f) => !
|
|
1208
|
+
].filter((f) => !P(f));
|
|
1211
1209
|
let I = {
|
|
1212
1210
|
...s,
|
|
1213
1211
|
...G(t)
|
|
1214
1212
|
};
|
|
1215
1213
|
O(l) && (I = I.main || "");
|
|
1216
|
-
const
|
|
1214
|
+
const N = await (async () => {
|
|
1217
1215
|
let f = et(t);
|
|
1218
1216
|
if (!f.main) {
|
|
1219
1217
|
const B = O(l) ? ["main"] : Object.keys(I);
|
|
1220
|
-
|
|
1218
|
+
at(f, B) || (f = await It(t, B), I = {
|
|
1221
1219
|
...s,
|
|
1222
1220
|
...G(t)
|
|
1223
1221
|
});
|
|
1224
1222
|
}
|
|
1225
1223
|
O(l) && "main" in f && (f = f.main);
|
|
1226
1224
|
let R = S(E);
|
|
1227
|
-
R =
|
|
1225
|
+
R = D([...A].reverse(), c.ui, R);
|
|
1228
1226
|
const j = {
|
|
1229
1227
|
...R,
|
|
1230
1228
|
initialData: I,
|
|
@@ -1242,12 +1240,12 @@ class Ct extends HTMLElement {
|
|
|
1242
1240
|
config: j
|
|
1243
1241
|
})).editor;
|
|
1244
1242
|
})();
|
|
1245
|
-
return
|
|
1246
|
-
f.setAttributes(
|
|
1247
|
-
}), O(l) && n && gt(
|
|
1243
|
+
return P(i) || N.model.change((f) => {
|
|
1244
|
+
f.setAttributes(i, N.model.document.getRoot());
|
|
1245
|
+
}), O(l) && n && gt(N, n), N;
|
|
1248
1246
|
};
|
|
1249
1247
|
if (u && !v) {
|
|
1250
|
-
const g = await bt(
|
|
1248
|
+
const g = await bt(F, w);
|
|
1251
1249
|
return g.on("error", (T, { causesRestart: U }) => {
|
|
1252
1250
|
if (U) {
|
|
1253
1251
|
const A = m.the.getItem(t);
|
|
@@ -1258,22 +1256,22 @@ class Ct extends HTMLElement {
|
|
|
1258
1256
|
m.the.register(t, T);
|
|
1259
1257
|
}), await g.create({}), g.editor;
|
|
1260
1258
|
}
|
|
1261
|
-
return
|
|
1259
|
+
return F();
|
|
1262
1260
|
}
|
|
1263
1261
|
}
|
|
1264
|
-
function
|
|
1262
|
+
function at(r, t) {
|
|
1265
1263
|
return t.every((e) => r[e]);
|
|
1266
1264
|
}
|
|
1267
1265
|
async function It(r, t) {
|
|
1268
1266
|
return lt(
|
|
1269
1267
|
() => {
|
|
1270
1268
|
const e = et(r);
|
|
1271
|
-
if (!
|
|
1269
|
+
if (!at(e, t))
|
|
1272
1270
|
throw new Error(
|
|
1273
1271
|
`It looks like not all required root elements are present yet.
|
|
1274
1272
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
1275
1273
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
1276
|
-
Missing roots: ${t.filter((
|
|
1274
|
+
Missing roots: ${t.filter((a) => !e[a]).join(", ")}.`
|
|
1277
1275
|
);
|
|
1278
1276
|
return e;
|
|
1279
1277
|
},
|
|
@@ -1289,12 +1287,12 @@ class Ot extends HTMLElement {
|
|
|
1289
1287
|
* Mounts the UI part component.
|
|
1290
1288
|
*/
|
|
1291
1289
|
async connectedCallback() {
|
|
1292
|
-
await
|
|
1293
|
-
const t = this.getAttribute("data-cke-editor-id") ||
|
|
1294
|
-
!t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (
|
|
1290
|
+
await M();
|
|
1291
|
+
const t = this.getAttribute("data-cke-editor-id") || q()[0], e = this.getAttribute("data-cke-name");
|
|
1292
|
+
!t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (a) => {
|
|
1295
1293
|
if (!this.isConnected)
|
|
1296
1294
|
return;
|
|
1297
|
-
const { ui:
|
|
1295
|
+
const { ui: i } = a, n = Tt(e), o = i.view[n];
|
|
1298
1296
|
if (!o)
|
|
1299
1297
|
throw new k(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1300
1298
|
return this.appendChild(o.element), () => {
|
|
@@ -1320,43 +1318,43 @@ function Tt(r) {
|
|
|
1320
1318
|
return null;
|
|
1321
1319
|
}
|
|
1322
1320
|
}
|
|
1323
|
-
const
|
|
1321
|
+
const Nt = {
|
|
1324
1322
|
"cke5-editor": Ct,
|
|
1325
1323
|
"cke5-context": Et,
|
|
1326
1324
|
"cke5-ui-part": Ot,
|
|
1327
1325
|
"cke5-editable": kt
|
|
1328
1326
|
};
|
|
1329
|
-
function
|
|
1330
|
-
for (const [r, t] of Object.entries(
|
|
1327
|
+
function Pt() {
|
|
1328
|
+
for (const [r, t] of Object.entries(Nt))
|
|
1331
1329
|
window.customElements.get(r) || window.customElements.define(r, t);
|
|
1332
1330
|
}
|
|
1333
1331
|
function Vt(r) {
|
|
1334
|
-
return
|
|
1332
|
+
return x(r), {
|
|
1335
1333
|
unmount() {
|
|
1336
1334
|
}
|
|
1337
1335
|
};
|
|
1338
1336
|
}
|
|
1339
|
-
function
|
|
1337
|
+
function it(r, t) {
|
|
1340
1338
|
const e = {
|
|
1341
1339
|
/** Value received from Blazor while the editor was focused, pending application on blur. */
|
|
1342
1340
|
pendingValue: null,
|
|
1343
1341
|
/** The last value sent to or received from Blazor to prevent circular updates. */
|
|
1344
1342
|
lastSyncedValue: null
|
|
1345
|
-
},
|
|
1343
|
+
}, a = () => {
|
|
1346
1344
|
e.pendingValue = null;
|
|
1347
|
-
},
|
|
1345
|
+
}, i = (n, o, c) => {
|
|
1348
1346
|
if (c || e.pendingValue === null)
|
|
1349
1347
|
return;
|
|
1350
1348
|
const u = t.getCurrentValue();
|
|
1351
1349
|
t.isEqual(u, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
|
|
1352
1350
|
};
|
|
1353
|
-
return r.model.document.on("change:data",
|
|
1351
|
+
return r.model.document.on("change:data", a), r.ui.focusTracker.on("change:isFocused", i), {
|
|
1354
1352
|
/**
|
|
1355
1353
|
* Removes all editor listeners registered by this sync instance.
|
|
1356
1354
|
* Call this when the Blazor component is disposed.
|
|
1357
1355
|
*/
|
|
1358
1356
|
unmount() {
|
|
1359
|
-
r.model.document.off("change:data",
|
|
1357
|
+
r.model.document.off("change:data", a), r.ui.focusTracker.off("change:isFocused", i);
|
|
1360
1358
|
},
|
|
1361
1359
|
/**
|
|
1362
1360
|
* Checks whether the given value differs from the last synced value and, if so,
|
|
@@ -1395,64 +1393,64 @@ function nt() {
|
|
|
1395
1393
|
}
|
|
1396
1394
|
function ot(r, t) {
|
|
1397
1395
|
const e = /* @__PURE__ */ new Set();
|
|
1398
|
-
return (
|
|
1399
|
-
r.model.enqueueChange({ isUndoable: !1 }, (
|
|
1396
|
+
return (a) => {
|
|
1397
|
+
r.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
1400
1398
|
const n = r.model.document.getRoot(t);
|
|
1401
1399
|
if (n) {
|
|
1402
1400
|
for (const o of e)
|
|
1403
|
-
|
|
1404
|
-
for (const [o, c] of Object.entries(
|
|
1405
|
-
|
|
1401
|
+
a && o in a || (i.removeAttribute(o, n), e.delete(o));
|
|
1402
|
+
for (const [o, c] of Object.entries(a ?? {}))
|
|
1403
|
+
i.setAttribute(o, c, n), e.add(o);
|
|
1406
1404
|
}
|
|
1407
1405
|
});
|
|
1408
1406
|
};
|
|
1409
1407
|
}
|
|
1410
1408
|
function zt(r, t) {
|
|
1411
|
-
const e = r.getAttribute("data-cke-editor-id") ??
|
|
1412
|
-
let
|
|
1409
|
+
const e = r.getAttribute("data-cke-editor-id") ?? q()[0], a = r.getAttribute("data-cke-root-name") ?? "main";
|
|
1410
|
+
let i = !1, n = null, o = null, c = nt(), u = null;
|
|
1413
1411
|
const s = (d) => {
|
|
1414
1412
|
if (!(d instanceof b) || d.detail.editorId !== e)
|
|
1415
1413
|
return;
|
|
1416
|
-
const l = d.detail.roots[
|
|
1414
|
+
const l = d.detail.roots[a];
|
|
1417
1415
|
l !== void 0 && c.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
|
|
1418
1416
|
};
|
|
1419
|
-
return n = m.the.mountEffect(e, (d) => (o = globalThis.DotNet.createJSObjectReference(d), c =
|
|
1420
|
-
getCurrentValue: () => d.getData({ rootName:
|
|
1421
|
-
applyValue: (l) => d.setData({ [
|
|
1417
|
+
return n = m.the.mountEffect(e, (d) => (o = globalThis.DotNet.createJSObjectReference(d), c = it(d, {
|
|
1418
|
+
getCurrentValue: () => d.getData({ rootName: a }) ?? "",
|
|
1419
|
+
applyValue: (l) => d.setData({ [a]: l }),
|
|
1422
1420
|
isEqual: (l, p) => l === p
|
|
1423
|
-
}), u = ot(d,
|
|
1421
|
+
}), u = ot(d, a), () => {
|
|
1424
1422
|
c.unmount(), o && (globalThis.DotNet?.disposeJSObjectReference(o), o = null), u = null;
|
|
1425
|
-
})), document.body.addEventListener(b.EVENT_NAME, s),
|
|
1423
|
+
})), document.body.addEventListener(b.EVENT_NAME, s), x(r), {
|
|
1426
1424
|
/**
|
|
1427
1425
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1428
1426
|
*/
|
|
1429
1427
|
unmount() {
|
|
1430
|
-
|
|
1428
|
+
i || (document.body.removeEventListener(b.EVENT_NAME, s), n?.(), n = null, i = !0);
|
|
1431
1429
|
},
|
|
1432
1430
|
/**
|
|
1433
1431
|
* Updates this editable root's data from Blazor.
|
|
1434
1432
|
* If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1435
1433
|
*/
|
|
1436
1434
|
setValue: async (d) => {
|
|
1437
|
-
|
|
1435
|
+
i || (await m.the.waitFor(e), c.setValue(d));
|
|
1438
1436
|
},
|
|
1439
1437
|
/**
|
|
1440
1438
|
* Updates the root attributes on the editor. This is useful when the Blazor component
|
|
1441
1439
|
* re-renders with new root attributes.
|
|
1442
1440
|
*/
|
|
1443
1441
|
setRootAttributes: async (d) => {
|
|
1444
|
-
|
|
1442
|
+
i || (await m.the.waitFor(e), u?.(d));
|
|
1445
1443
|
}
|
|
1446
1444
|
};
|
|
1447
1445
|
}
|
|
1448
1446
|
function $t(r, t) {
|
|
1449
1447
|
const e = r.getAttribute("data-cke-editor-id");
|
|
1450
|
-
let
|
|
1448
|
+
let a = !1, i = null, n = nt(), o = null, c = null;
|
|
1451
1449
|
const u = (s) => {
|
|
1452
1450
|
!(s instanceof b) || s.detail.editorId !== e || n.shouldNotify(s.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", c, s.detail.roots);
|
|
1453
1451
|
};
|
|
1454
|
-
return
|
|
1455
|
-
c = globalThis.DotNet.createJSObjectReference(s), n =
|
|
1452
|
+
return i = m.the.mountEffect(e, (s) => {
|
|
1453
|
+
c = globalThis.DotNet.createJSObjectReference(s), n = it(s, {
|
|
1456
1454
|
getCurrentValue: () => X(s),
|
|
1457
1455
|
applyValue: (l) => s.setData(l),
|
|
1458
1456
|
isEqual: ct
|
|
@@ -1464,24 +1462,24 @@ function $t(r, t) {
|
|
|
1464
1462
|
return s.ui.focusTracker.on("change:isFocused", d), t.invokeMethodAsync("OnEditorReady", c), () => {
|
|
1465
1463
|
s.ui.focusTracker.off("change:isFocused", d), n.unmount(), c && (globalThis.DotNet?.disposeJSObjectReference(c), c = null), o = null;
|
|
1466
1464
|
};
|
|
1467
|
-
}), document.body.addEventListener(b.EVENT_NAME, u),
|
|
1465
|
+
}), document.body.addEventListener(b.EVENT_NAME, u), Pt(), x(r), {
|
|
1468
1466
|
/**
|
|
1469
1467
|
* Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1470
1468
|
*/
|
|
1471
1469
|
setValue: async (s) => {
|
|
1472
|
-
|
|
1470
|
+
a || (await m.the.waitFor(e), n.setValue(s));
|
|
1473
1471
|
},
|
|
1474
1472
|
/**
|
|
1475
1473
|
* Updates the root attributes on the editor instance.
|
|
1476
1474
|
*/
|
|
1477
1475
|
setRootAttributes: async (s) => {
|
|
1478
|
-
|
|
1476
|
+
a || (await m.the.waitFor(e), o?.(s));
|
|
1479
1477
|
},
|
|
1480
1478
|
/**
|
|
1481
1479
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1482
1480
|
*/
|
|
1483
1481
|
unmount() {
|
|
1484
|
-
|
|
1482
|
+
a || (document.body.removeEventListener(b.EVENT_NAME, u), i?.(), i = null, a = !0);
|
|
1485
1483
|
},
|
|
1486
1484
|
/**
|
|
1487
1485
|
* Installs the custom image upload adapter that delegates uploads to Blazor.
|
|
@@ -1489,10 +1487,9 @@ function $t(r, t) {
|
|
|
1489
1487
|
* to avoid unnecessary overhead for consumers that don't use this feature.
|
|
1490
1488
|
*/
|
|
1491
1489
|
attachImageUploadAdapter: async () => {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
St(s, t);
|
|
1490
|
+
a || m.the.mountEffect(e, (s) => {
|
|
1491
|
+
St(s, t);
|
|
1492
|
+
});
|
|
1496
1493
|
}
|
|
1497
1494
|
};
|
|
1498
1495
|
}
|
|
@@ -1500,14 +1497,14 @@ function St(r, t) {
|
|
|
1500
1497
|
if (!r.plugins.has("FileRepository"))
|
|
1501
1498
|
return;
|
|
1502
1499
|
const e = r.plugins.get("FileRepository");
|
|
1503
|
-
e.createUploadAdapter = (
|
|
1504
|
-
let
|
|
1500
|
+
e.createUploadAdapter = (a) => {
|
|
1501
|
+
let i = !1;
|
|
1505
1502
|
return {
|
|
1506
1503
|
async upload() {
|
|
1507
|
-
const n = await
|
|
1508
|
-
if (
|
|
1504
|
+
const n = await a.file;
|
|
1505
|
+
if (i)
|
|
1509
1506
|
throw new Error("Upload aborted.");
|
|
1510
|
-
const o = await
|
|
1507
|
+
const o = await Dt(n), c = await t.invokeMethodAsync("OnEditorImageUpload", {
|
|
1511
1508
|
fileName: n.name,
|
|
1512
1509
|
mimeType: n.type,
|
|
1513
1510
|
payload: o
|
|
@@ -1519,22 +1516,22 @@ function St(r, t) {
|
|
|
1519
1516
|
return { default: c };
|
|
1520
1517
|
},
|
|
1521
1518
|
abort() {
|
|
1522
|
-
|
|
1519
|
+
i = !0;
|
|
1523
1520
|
}
|
|
1524
1521
|
};
|
|
1525
1522
|
};
|
|
1526
1523
|
}
|
|
1527
|
-
function
|
|
1524
|
+
function Dt(r) {
|
|
1528
1525
|
return new Promise((t, e) => {
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1531
|
-
const
|
|
1526
|
+
const a = new FileReader();
|
|
1527
|
+
a.onload = () => {
|
|
1528
|
+
const i = a.result, n = i.split(",")[1] ?? i;
|
|
1532
1529
|
t(n);
|
|
1533
|
-
},
|
|
1530
|
+
}, a.onerror = () => e(a.error), a.readAsDataURL(r);
|
|
1534
1531
|
});
|
|
1535
1532
|
}
|
|
1536
1533
|
function Wt(r) {
|
|
1537
|
-
return
|
|
1534
|
+
return x(r), {
|
|
1538
1535
|
unmount() {
|
|
1539
1536
|
}
|
|
1540
1537
|
};
|
|
@@ -1543,7 +1540,7 @@ export {
|
|
|
1543
1540
|
k as CKEditor5BlazorError,
|
|
1544
1541
|
b as CKEditor5ChangeDataEvent,
|
|
1545
1542
|
C as ContextsRegistry,
|
|
1546
|
-
|
|
1543
|
+
_ as CustomEditorPluginsRegistry,
|
|
1547
1544
|
kt as EditableComponentElement,
|
|
1548
1545
|
Ct as EditorComponentElement,
|
|
1549
1546
|
m as EditorsRegistry,
|
|
@@ -1552,6 +1549,6 @@ export {
|
|
|
1552
1549
|
zt as createEditableBlazorInterop,
|
|
1553
1550
|
$t as createEditorBlazorInterop,
|
|
1554
1551
|
Wt as createUIPartBlazorInterop,
|
|
1555
|
-
|
|
1552
|
+
Pt as ensureEditorElementsRegistered
|
|
1556
1553
|
};
|
|
1557
1554
|
//# sourceMappingURL=index.mjs.map
|