ckeditor5-blazor 1.11.1 → 1.12.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/utils/assign-editor-roots-to-config.d.ts.map +1 -1
- package/dist/elements/editor/utils/query-all-editor-editables.d.ts +1 -0
- package/dist/elements/editor/utils/query-all-editor-editables.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +365 -359
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/elements/editable.test.ts +42 -3
- package/src/elements/editable.ts +2 -0
- package/src/elements/editor/editor.test.ts +97 -13
- package/src/elements/editor/utils/assign-editor-roots-to-config.ts +3 -2
- package/src/elements/editor/utils/get-editor-roots-values.ts +1 -1
- package/src/elements/editor/utils/query-all-editor-editables.ts +12 -2
- package/src/elements/ui-part.test.ts +8 -9
- package/src/interop/create-editable-blazor-interop.test.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
class
|
|
1
|
+
class v extends Error {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
super(t), this.name = "CKEditor5BlazorError";
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function U(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, n] of r)
|
|
10
|
+
if (!t.has(e) || t.get(e) !== n)
|
|
11
11
|
return !1;
|
|
12
12
|
return !0;
|
|
13
13
|
}
|
|
@@ -46,13 +46,13 @@ class H {
|
|
|
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
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
o(await e(
|
|
55
|
-
}),
|
|
49
|
+
execute(t, e, n) {
|
|
50
|
+
const i = this.items.get(t), a = this.initializationErrors.get(t);
|
|
51
|
+
return a ? (n?.(a), Promise.reject(a)) : i ? Promise.resolve(e(i)) : new Promise((o, s) => {
|
|
52
|
+
const c = this.getPendingCallbacks(t);
|
|
53
|
+
c.success.push(async (u) => {
|
|
54
|
+
o(await e(u));
|
|
55
|
+
}), n ? c.error.push(n) : c.error.push(s);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -63,19 +63,19 @@ class H {
|
|
|
63
63
|
* @returns A function that stops observing and immediately runs any pending cleanup.
|
|
64
64
|
*/
|
|
65
65
|
mountEffect(t, e) {
|
|
66
|
-
let
|
|
67
|
-
const o = this.watch((
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
66
|
+
let n, i, a = !1;
|
|
67
|
+
const o = this.watch((s) => {
|
|
68
|
+
const c = s.get(t);
|
|
69
|
+
if (c !== i && (n?.(), n = void 0, i = c, !!c))
|
|
70
70
|
try {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
} catch (
|
|
74
|
-
throw console.error(
|
|
71
|
+
const u = e(c);
|
|
72
|
+
a ? (u?.(), o()) : n = u;
|
|
73
|
+
} catch (u) {
|
|
74
|
+
throw console.error(u), u;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
return () => {
|
|
78
|
-
|
|
78
|
+
a = !0, i && (o(), n?.(), n = void 0);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -89,8 +89,8 @@ class H {
|
|
|
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 n = this.pendingCallbacks.get(t);
|
|
93
|
+
n && (n.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 H {
|
|
|
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 n = this.pendingCallbacks.get(t);
|
|
106
|
+
n && (n.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 H {
|
|
|
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, n) => {
|
|
163
|
+
this.execute(t, e, n);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
@@ -220,7 +220,7 @@ class H {
|
|
|
220
220
|
* Immediately dispatches the current state to all watchers if it changed.
|
|
221
221
|
*/
|
|
222
222
|
flushWatchers() {
|
|
223
|
-
|
|
223
|
+
U(this.lastNotifiedItems, this.items) && U(this.lastNotifiedErrors, this.initializationErrors) || (this.lastNotifiedItems = new Map(this.items), this.lastNotifiedErrors = new Map(this.initializationErrors), this.watchers.forEach((t) => t(
|
|
224
224
|
new Map(this.items),
|
|
225
225
|
new Map(this.initializationErrors)
|
|
226
226
|
)));
|
|
@@ -238,54 +238,54 @@ class H {
|
|
|
238
238
|
}
|
|
239
239
|
function W(r, t) {
|
|
240
240
|
let e = null;
|
|
241
|
-
return (...
|
|
241
|
+
return (...n) => {
|
|
242
242
|
e && clearTimeout(e), e = setTimeout(() => {
|
|
243
|
-
t(...
|
|
243
|
+
t(...n);
|
|
244
244
|
}, r);
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
function P(r) {
|
|
248
248
|
return Object.keys(r).length === 0 && r.constructor === Object;
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
const e = Object.entries(r).map(([
|
|
250
|
+
function nt(r, t) {
|
|
251
|
+
const e = Object.entries(r).map(([n, i]) => [n, t(i, n)]);
|
|
252
252
|
return Object.fromEntries(e);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function at(r, t) {
|
|
255
255
|
if (r === t)
|
|
256
256
|
return !0;
|
|
257
|
-
const e = Object.keys(r),
|
|
258
|
-
if (e.length !==
|
|
257
|
+
const e = Object.keys(r), n = Object.keys(t);
|
|
258
|
+
if (e.length !== n.length)
|
|
259
259
|
return !1;
|
|
260
|
-
for (const
|
|
261
|
-
if (r[
|
|
260
|
+
for (const i of e)
|
|
261
|
+
if (r[i] !== t[i] || !Object.prototype.hasOwnProperty.call(t, i))
|
|
262
262
|
return !1;
|
|
263
263
|
return !0;
|
|
264
264
|
}
|
|
265
|
-
function
|
|
265
|
+
function it() {
|
|
266
266
|
return Math.random().toString(36).substring(2);
|
|
267
267
|
}
|
|
268
268
|
function ot(r, {
|
|
269
269
|
timeOutAfter: t = 500,
|
|
270
270
|
retryAfter: e = 100
|
|
271
271
|
} = {}) {
|
|
272
|
-
return new Promise((
|
|
273
|
-
const
|
|
272
|
+
return new Promise((n, i) => {
|
|
273
|
+
const a = Date.now();
|
|
274
274
|
let o = null;
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
}, t),
|
|
275
|
+
const s = setTimeout(() => {
|
|
276
|
+
i(o ?? new Error("Timeout"));
|
|
277
|
+
}, t), c = async () => {
|
|
278
278
|
try {
|
|
279
|
-
const
|
|
280
|
-
clearTimeout(
|
|
281
|
-
} catch (
|
|
282
|
-
o =
|
|
279
|
+
const u = await r();
|
|
280
|
+
clearTimeout(s), n(u);
|
|
281
|
+
} catch (u) {
|
|
282
|
+
o = u, Date.now() - a > t ? i(u) : setTimeout(c, e);
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
285
|
+
c();
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function R() {
|
|
289
289
|
return new Promise((r) => {
|
|
290
290
|
switch (document.readyState) {
|
|
291
291
|
case "loading":
|
|
@@ -306,11 +306,11 @@ function L(r) {
|
|
|
306
306
|
} };
|
|
307
307
|
let t;
|
|
308
308
|
return {
|
|
309
|
-
promise: new Promise((
|
|
310
|
-
t = new MutationObserver((
|
|
311
|
-
for (const
|
|
312
|
-
if (
|
|
313
|
-
t.disconnect(),
|
|
309
|
+
promise: new Promise((n) => {
|
|
310
|
+
t = new MutationObserver((i) => {
|
|
311
|
+
for (const a of i)
|
|
312
|
+
if (a.type === "attributes" && a.attributeName === "data-cke-interactive" && r.hasAttribute("data-cke-interactive")) {
|
|
313
|
+
t.disconnect(), n();
|
|
314
314
|
break;
|
|
315
315
|
}
|
|
316
316
|
}), t.observe(r, { attributes: !0 });
|
|
@@ -318,33 +318,34 @@ function L(r) {
|
|
|
318
318
|
disconnect: () => t?.disconnect()
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function x(r) {
|
|
322
322
|
r.setAttribute("data-cke-interactive", "true");
|
|
323
323
|
}
|
|
324
324
|
function st(r, t, e) {
|
|
325
|
-
const
|
|
325
|
+
const n = !r.editorName || r.editorName === "ClassicEditor", i = /* @__PURE__ */ new Set([
|
|
326
326
|
...Object.keys(t),
|
|
327
327
|
...Object.keys(e.roots ?? {})
|
|
328
|
-
]),
|
|
329
|
-
...
|
|
330
|
-
[
|
|
328
|
+
]), a = Array.from(i).reduce((s, c) => ({
|
|
329
|
+
...s,
|
|
330
|
+
[c]: {
|
|
331
331
|
/* v8 ignore next 1 */
|
|
332
|
-
...e.roots?.[
|
|
333
|
-
...
|
|
334
|
-
/* v8 ignore next
|
|
335
|
-
...
|
|
336
|
-
...t[
|
|
337
|
-
initialData: t[
|
|
332
|
+
...e.roots?.[c],
|
|
333
|
+
...c === "main" ? e.root : {},
|
|
334
|
+
/* v8 ignore next 12 */
|
|
335
|
+
...c in t ? {
|
|
336
|
+
...t[c].content !== null && {
|
|
337
|
+
initialData: t[c].content
|
|
338
338
|
},
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
modelElement: t[c].modelElement || "$root",
|
|
340
|
+
...!n && t[c].element !== null && {
|
|
341
|
+
element: t[c].element
|
|
341
342
|
}
|
|
342
343
|
} : {}
|
|
343
344
|
}
|
|
344
|
-
}),
|
|
345
|
+
}), { ...e.roots || {} }), o = {
|
|
345
346
|
...e,
|
|
346
|
-
roots:
|
|
347
|
-
...
|
|
347
|
+
roots: a,
|
|
348
|
+
...n && t.main?.element && {
|
|
348
349
|
attachTo: t.main.element
|
|
349
350
|
}
|
|
350
351
|
};
|
|
@@ -356,14 +357,14 @@ function ct(r) {
|
|
|
356
357
|
r.ui?.view?.toolbar?.element,
|
|
357
358
|
r.ui?.view?.menuBarView?.element
|
|
358
359
|
].filter(Boolean);
|
|
359
|
-
for (const
|
|
360
|
-
|
|
360
|
+
for (const a of t)
|
|
361
|
+
i(a);
|
|
361
362
|
const e = r.ui?.view?.body?._bodyCollectionContainer;
|
|
362
|
-
e?.isConnected &&
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
for (const
|
|
366
|
-
|
|
363
|
+
e?.isConnected && i(e);
|
|
364
|
+
const n = r.editing?.view;
|
|
365
|
+
if (n)
|
|
366
|
+
for (const a of n.domRoots.values())
|
|
367
|
+
a instanceof HTMLElement && (a.removeAttribute("contenteditable"), a.removeAttribute("role"), a.removeAttribute("aria-label"), a.removeAttribute("aria-multiline"), a.removeAttribute("spellcheck"), a.classList.remove(
|
|
367
368
|
"ck",
|
|
368
369
|
"ck-content",
|
|
369
370
|
"ck-editor__editable",
|
|
@@ -371,52 +372,52 @@ function ct(r) {
|
|
|
371
372
|
"ck-editor__editable_inline",
|
|
372
373
|
"ck-blurred",
|
|
373
374
|
"ck-focused"
|
|
374
|
-
),
|
|
375
|
-
function
|
|
376
|
-
|
|
375
|
+
), i(a));
|
|
376
|
+
function i(a) {
|
|
377
|
+
a.hasAttribute("data-cke-controlled") ? a.innerHTML = "" : a.remove();
|
|
377
378
|
}
|
|
378
379
|
}
|
|
379
380
|
const z = /* @__PURE__ */ Symbol.for("context-editor-watchdog");
|
|
380
381
|
async function ut({ context: r, creator: t, config: e }) {
|
|
381
|
-
const
|
|
382
|
+
const n = it();
|
|
382
383
|
await r.add({
|
|
383
384
|
creator: t.create.bind(t),
|
|
384
|
-
id:
|
|
385
|
+
id: n,
|
|
385
386
|
type: "editor",
|
|
386
387
|
config: e
|
|
387
388
|
});
|
|
388
|
-
const
|
|
389
|
+
const i = r.getItem(n), a = {
|
|
389
390
|
state: "available",
|
|
390
|
-
editorContextId:
|
|
391
|
+
editorContextId: n,
|
|
391
392
|
context: r
|
|
392
393
|
};
|
|
393
|
-
|
|
394
|
+
i[z] = a;
|
|
394
395
|
const o = r.destroy.bind(r);
|
|
395
|
-
return r.destroy = async () => (
|
|
396
|
-
...
|
|
397
|
-
editor:
|
|
396
|
+
return r.destroy = async () => (a.state = "unavailable", o()), {
|
|
397
|
+
...a,
|
|
398
|
+
editor: i
|
|
398
399
|
};
|
|
399
400
|
}
|
|
400
401
|
function lt(r) {
|
|
401
402
|
return z in r ? r[z] : null;
|
|
402
403
|
}
|
|
403
404
|
function J(r) {
|
|
404
|
-
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(
|
|
405
|
+
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(null));
|
|
405
406
|
}
|
|
406
407
|
function V(r) {
|
|
407
408
|
return ["inline", "classic", "balloon", "decoupled"].includes(r);
|
|
408
409
|
}
|
|
409
|
-
async function
|
|
410
|
-
const t = await import("ckeditor5"),
|
|
410
|
+
async function j(r) {
|
|
411
|
+
const t = await import("ckeditor5"), n = {
|
|
411
412
|
inline: t.InlineEditor,
|
|
412
413
|
balloon: t.BalloonEditor,
|
|
413
414
|
classic: t.ClassicEditor,
|
|
414
415
|
decoupled: t.DecoupledEditor,
|
|
415
416
|
multiroot: t.MultiRootEditor
|
|
416
417
|
}[r];
|
|
417
|
-
if (!
|
|
418
|
-
throw new
|
|
419
|
-
return
|
|
418
|
+
if (!n)
|
|
419
|
+
throw new v(`Unsupported editor type: ${r}`);
|
|
420
|
+
return n;
|
|
420
421
|
}
|
|
421
422
|
class _ {
|
|
422
423
|
static the = new _();
|
|
@@ -438,7 +439,7 @@ class _ {
|
|
|
438
439
|
*/
|
|
439
440
|
register(t, e) {
|
|
440
441
|
if (this.plugins.has(t))
|
|
441
|
-
throw new
|
|
442
|
+
throw new v(`Plugin with name "${t}" is already registered.`);
|
|
442
443
|
return this.plugins.set(t, e), this.unregister.bind(this, t);
|
|
443
444
|
}
|
|
444
445
|
/**
|
|
@@ -449,7 +450,7 @@ class _ {
|
|
|
449
450
|
*/
|
|
450
451
|
unregister(t) {
|
|
451
452
|
if (!this.plugins.has(t))
|
|
452
|
-
throw new
|
|
453
|
+
throw new v(`Plugin with name "${t}" is not registered.`);
|
|
453
454
|
this.plugins.delete(t);
|
|
454
455
|
}
|
|
455
456
|
/**
|
|
@@ -481,35 +482,35 @@ class _ {
|
|
|
481
482
|
async function G(r) {
|
|
482
483
|
const t = await import("ckeditor5");
|
|
483
484
|
let e = null;
|
|
484
|
-
const
|
|
485
|
-
if (dt(
|
|
486
|
-
const { name:
|
|
485
|
+
const n = r.map(async (i) => {
|
|
486
|
+
if (dt(i)) {
|
|
487
|
+
const { name: c, path: u } = i.$import, l = await import(
|
|
487
488
|
/* @vite-ignore */
|
|
488
|
-
|
|
489
|
-
), f = (Object.prototype.hasOwnProperty.call(
|
|
489
|
+
u
|
|
490
|
+
), f = (Object.prototype.hasOwnProperty.call(l, c) ? l[c] : void 0) ?? (Object.prototype.hasOwnProperty.call(l, "default") ? l.default : void 0);
|
|
490
491
|
if (!f)
|
|
491
|
-
throw new
|
|
492
|
+
throw new v(`Plugin "${c}" not found in module "${u}".`);
|
|
492
493
|
return f;
|
|
493
494
|
}
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
return
|
|
497
|
-
const { [
|
|
495
|
+
const a = await _.the.get(i);
|
|
496
|
+
if (a)
|
|
497
|
+
return a;
|
|
498
|
+
const { [i]: o } = t;
|
|
498
499
|
if (o)
|
|
499
500
|
return o;
|
|
500
501
|
if (!e)
|
|
501
502
|
try {
|
|
502
503
|
e = await import("ckeditor5-premium-features");
|
|
503
|
-
} catch (
|
|
504
|
-
throw console.error(`Failed to load premium package: ${
|
|
504
|
+
} catch (c) {
|
|
505
|
+
throw console.error(`Failed to load premium package: ${c}`), new v(`Plugin "${i}" not found in base package and failed to load premium package.`);
|
|
505
506
|
}
|
|
506
|
-
const { [
|
|
507
|
-
if (
|
|
508
|
-
return
|
|
509
|
-
throw new
|
|
507
|
+
const { [i]: s } = e || {};
|
|
508
|
+
if (s)
|
|
509
|
+
return s;
|
|
510
|
+
throw new v(`Plugin "${i}" not found in base or premium packages.`);
|
|
510
511
|
});
|
|
511
512
|
return {
|
|
512
|
-
loadedPlugins: await Promise.all(
|
|
513
|
+
loadedPlugins: await Promise.all(n),
|
|
513
514
|
hasPremium: !!e
|
|
514
515
|
};
|
|
515
516
|
}
|
|
@@ -523,14 +524,14 @@ async function Y(r, t) {
|
|
|
523
524
|
B("ckeditor5", e),
|
|
524
525
|
/* v8 ignore next -- @preserve */
|
|
525
526
|
t && B("ckeditor5-premium-features", e)
|
|
526
|
-
].filter((
|
|
527
|
-
).then((
|
|
527
|
+
].filter((i) => !!i)
|
|
528
|
+
).then((i) => i.flat());
|
|
528
529
|
}
|
|
529
530
|
async function B(r, t) {
|
|
530
531
|
return await Promise.all(
|
|
531
532
|
t.filter((e) => e !== "en").map(async (e) => {
|
|
532
|
-
const
|
|
533
|
-
return
|
|
533
|
+
const n = await mt(r, e);
|
|
534
|
+
return n?.default ?? n;
|
|
534
535
|
}).filter(Boolean)
|
|
535
536
|
);
|
|
536
537
|
}
|
|
@@ -835,11 +836,11 @@ async function mt(r, t) {
|
|
|
835
836
|
}
|
|
836
837
|
}
|
|
837
838
|
function X(r) {
|
|
838
|
-
return
|
|
839
|
+
return nt(r, (t) => ({
|
|
839
840
|
dictionary: t
|
|
840
841
|
}));
|
|
841
842
|
}
|
|
842
|
-
function
|
|
843
|
+
function Q(r) {
|
|
843
844
|
return r ? typeof r == "string" ? {
|
|
844
845
|
ui: r,
|
|
845
846
|
content: r
|
|
@@ -848,87 +849,91 @@ function K(r) {
|
|
|
848
849
|
content: "en"
|
|
849
850
|
};
|
|
850
851
|
}
|
|
851
|
-
function
|
|
852
|
-
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((
|
|
853
|
-
const u =
|
|
854
|
-
return
|
|
855
|
-
element:
|
|
856
|
-
content:
|
|
857
|
-
|
|
858
|
-
|
|
852
|
+
function Z(r) {
|
|
853
|
+
const t = Array.from(document.querySelectorAll(`cke5-editable[data-cke-editor-id="${r}"]`)).reduce((o, s) => {
|
|
854
|
+
const c = s.getAttribute("data-cke-root-name"), u = s.getAttribute("data-cke-root-model-element-name") || null;
|
|
855
|
+
return o[c] = {
|
|
856
|
+
element: s.querySelector("[data-cke-editable-content]"),
|
|
857
|
+
content: s.getAttribute("data-cke-content"),
|
|
858
|
+
modelElement: u
|
|
859
|
+
}, o;
|
|
860
|
+
}, /* @__PURE__ */ Object.create(null)), e = document.querySelector(`cke5-editor[data-cke-editor-id="${r}"]`);
|
|
859
861
|
if (!e)
|
|
860
862
|
return t;
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
element:
|
|
864
|
-
content:
|
|
863
|
+
const n = JSON.parse(e.getAttribute("data-cke-content")) ?? {}, i = document.querySelector(`#${r}_editor`), a = e.getAttribute("data-cke-root-model-element-name");
|
|
864
|
+
"main" in t ? t.main.modelElement ??= a : i && (t.main = {
|
|
865
|
+
element: i,
|
|
866
|
+
content: n.main || "",
|
|
867
|
+
modelElement: a
|
|
865
868
|
});
|
|
866
|
-
for (const [
|
|
867
|
-
t[
|
|
868
|
-
...t[
|
|
869
|
-
content: t[
|
|
870
|
-
|
|
869
|
+
for (const [o, s] of Object.entries(n))
|
|
870
|
+
t[o] ? t[o] = {
|
|
871
|
+
...t[o],
|
|
872
|
+
content: t[o].content ?? s,
|
|
873
|
+
modelElement: t[o].modelElement ?? a
|
|
874
|
+
} : t[o] = {
|
|
871
875
|
element: null,
|
|
872
|
-
content:
|
|
876
|
+
content: s,
|
|
877
|
+
modelElement: a
|
|
873
878
|
};
|
|
874
879
|
return t;
|
|
875
880
|
}
|
|
876
881
|
function F() {
|
|
877
882
|
return Array.from(document.querySelectorAll("cke5-editor")).map((r) => r.getAttribute("data-cke-editor-id")).filter((r) => r !== null);
|
|
878
883
|
}
|
|
879
|
-
function
|
|
884
|
+
function M(r) {
|
|
880
885
|
if (!r || typeof r != "object")
|
|
881
886
|
return r;
|
|
882
887
|
if (Array.isArray(r))
|
|
883
|
-
return r.map((
|
|
888
|
+
return r.map((n) => M(n));
|
|
884
889
|
const t = r;
|
|
885
890
|
if (t.$element && typeof t.$element == "string") {
|
|
886
|
-
const
|
|
887
|
-
return
|
|
891
|
+
const n = document.querySelector(t.$element);
|
|
892
|
+
return n || console.warn(`Element not found for selector: ${t.$element}`), n || null;
|
|
888
893
|
}
|
|
889
894
|
const e = /* @__PURE__ */ Object.create(null);
|
|
890
|
-
for (const [
|
|
891
|
-
e[
|
|
895
|
+
for (const [n, i] of Object.entries(r))
|
|
896
|
+
e[n] = M(i);
|
|
892
897
|
return e;
|
|
893
898
|
}
|
|
894
|
-
function
|
|
899
|
+
function S(r, t, e) {
|
|
895
900
|
if (!e || typeof e != "object")
|
|
896
901
|
return e;
|
|
897
902
|
if (Array.isArray(e))
|
|
898
|
-
return e.map((
|
|
899
|
-
const
|
|
900
|
-
if (
|
|
901
|
-
const
|
|
902
|
-
return o === void 0 && console.warn(`Translation not found for key: ${
|
|
903
|
+
return e.map((a) => S(r, t, a));
|
|
904
|
+
const n = e;
|
|
905
|
+
if (n.$translation && typeof n.$translation == "string") {
|
|
906
|
+
const a = n.$translation, o = ht(r, a, t);
|
|
907
|
+
return o === void 0 && console.warn(`Translation not found for key: ${a}`), o !== void 0 ? o : null;
|
|
903
908
|
}
|
|
904
|
-
const
|
|
905
|
-
for (const [
|
|
906
|
-
|
|
907
|
-
return
|
|
909
|
+
const i = /* @__PURE__ */ Object.create(null);
|
|
910
|
+
for (const [a, o] of Object.entries(e))
|
|
911
|
+
i[a] = S(r, t, o);
|
|
912
|
+
return i;
|
|
908
913
|
}
|
|
909
914
|
function ht(r, t, e) {
|
|
910
|
-
for (const
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
return
|
|
915
|
+
for (const n of r) {
|
|
916
|
+
const i = n[e];
|
|
917
|
+
if (i?.dictionary && t in i.dictionary)
|
|
918
|
+
return i.dictionary[t];
|
|
914
919
|
}
|
|
915
920
|
}
|
|
916
921
|
function ft(r, t) {
|
|
917
922
|
const { editing: e } = r;
|
|
918
|
-
e.view.change((
|
|
919
|
-
|
|
923
|
+
e.view.change((n) => {
|
|
924
|
+
n.setStyle("height", `${t}px`, e.view.document.getRoot());
|
|
920
925
|
});
|
|
921
926
|
}
|
|
922
927
|
const $ = /* @__PURE__ */ Symbol.for("elixir-editor-watchdog");
|
|
923
928
|
async function pt(r, t) {
|
|
924
|
-
const { EditorWatchdog: e } = await import("ckeditor5"),
|
|
929
|
+
const { EditorWatchdog: e } = await import("ckeditor5"), n = new e(null, t ?? {
|
|
925
930
|
crashNumberLimit: 10,
|
|
926
931
|
minimumNonErrorTimePeriod: 5e3
|
|
927
932
|
});
|
|
928
|
-
return
|
|
929
|
-
const
|
|
930
|
-
return
|
|
931
|
-
}),
|
|
933
|
+
return n.setCreator(async () => {
|
|
934
|
+
const i = await r();
|
|
935
|
+
return i[$] = n, i;
|
|
936
|
+
}), n;
|
|
932
937
|
}
|
|
933
938
|
function wt(r) {
|
|
934
939
|
return $ in r ? r[$] : null;
|
|
@@ -949,31 +954,31 @@ class gt extends HTMLElement {
|
|
|
949
954
|
* Mounts the context component.
|
|
950
955
|
*/
|
|
951
956
|
async connectedCallback() {
|
|
952
|
-
await
|
|
957
|
+
await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeContext();
|
|
953
958
|
}
|
|
954
959
|
/**
|
|
955
960
|
* Initializes the context component.
|
|
956
961
|
*/
|
|
957
962
|
async initializeContext() {
|
|
958
|
-
const t = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: e, watchdogConfig:
|
|
959
|
-
...await Y(
|
|
963
|
+
const t = JSON.parse(this.getAttribute("data-cke-context")), { customTranslations: e, watchdogConfig: n, config: { plugins: i, ...a } } = t, o = this.getAttribute("data-cke-context-id"), s = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : Q(a.language), { loadedPlugins: c, hasPremium: u } = await G(i ?? []), l = [
|
|
964
|
+
...await Y(s, u),
|
|
960
965
|
X(e || {})
|
|
961
|
-
].filter((
|
|
966
|
+
].filter((E) => !P(E));
|
|
962
967
|
this.contextPromise = (async () => {
|
|
963
|
-
const { ContextWatchdog:
|
|
968
|
+
const { ContextWatchdog: E, Context: b } = await import("ckeditor5"), w = new E(b, {
|
|
964
969
|
crashNumberLimit: 10,
|
|
965
|
-
...
|
|
970
|
+
...n
|
|
966
971
|
});
|
|
967
|
-
let
|
|
968
|
-
return
|
|
969
|
-
...
|
|
970
|
-
language:
|
|
971
|
-
plugins:
|
|
972
|
-
...
|
|
973
|
-
translations:
|
|
972
|
+
let g = M(a);
|
|
973
|
+
return g = S([...l].reverse(), s.ui, g), await w.create({
|
|
974
|
+
...g,
|
|
975
|
+
language: s,
|
|
976
|
+
plugins: c,
|
|
977
|
+
...l.length && {
|
|
978
|
+
translations: l
|
|
974
979
|
}
|
|
975
|
-
}), w.on("itemError", (...
|
|
976
|
-
console.error("Context item error:", ...
|
|
980
|
+
}), w.on("itemError", (...h) => {
|
|
981
|
+
console.error("Context item error:", ...h);
|
|
977
982
|
}), w;
|
|
978
983
|
})();
|
|
979
984
|
const f = await this.contextPromise;
|
|
@@ -996,7 +1001,7 @@ class gt extends HTMLElement {
|
|
|
996
1001
|
class m extends H {
|
|
997
1002
|
static the = new m();
|
|
998
1003
|
}
|
|
999
|
-
class
|
|
1004
|
+
class Et extends HTMLElement {
|
|
1000
1005
|
/**
|
|
1001
1006
|
* Stops observing the editor registry and immediately runs any pending cleanup.
|
|
1002
1007
|
*/
|
|
@@ -1009,61 +1014,62 @@ class bt extends HTMLElement {
|
|
|
1009
1014
|
* Mounts the editable component.
|
|
1010
1015
|
*/
|
|
1011
1016
|
async connectedCallback() {
|
|
1012
|
-
await
|
|
1017
|
+
await R(), this.interactiveWait = L(this), await this.interactiveWait.promise, await this.initializeEditable();
|
|
1013
1018
|
}
|
|
1014
1019
|
/**
|
|
1015
1020
|
* Initializes the editable instance.
|
|
1016
1021
|
*/
|
|
1017
1022
|
async initializeEditable() {
|
|
1018
1023
|
this.hasAttribute("data-cke-editor-id") || this.setAttribute("data-cke-editor-id", F()[0]);
|
|
1019
|
-
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"),
|
|
1024
|
+
const t = this.getAttribute("data-cke-editor-id"), e = this.getAttribute("data-cke-root-name"), n = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), i = this.getAttribute("data-cke-root-model-element-name") || "$root", a = this.getAttribute("data-cke-content"), o = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10);
|
|
1020
1025
|
if (!t || !e)
|
|
1021
|
-
throw new
|
|
1022
|
-
this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (
|
|
1026
|
+
throw new v("Editor ID or Root Name is missing.");
|
|
1027
|
+
this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (s) => {
|
|
1023
1028
|
if (!this.isConnected)
|
|
1024
1029
|
return;
|
|
1025
|
-
const { ui:
|
|
1026
|
-
if (
|
|
1027
|
-
if (
|
|
1028
|
-
const h =
|
|
1029
|
-
h && h !==
|
|
1030
|
-
[e]:
|
|
1030
|
+
const { ui: c, editing: u, model: d } = s, l = this.querySelector("input"), f = d.document.getRoot(e);
|
|
1031
|
+
if (f?.isAttached()) {
|
|
1032
|
+
if (a !== null) {
|
|
1033
|
+
const h = s.getData({ rootName: e });
|
|
1034
|
+
h && h !== a && s.setData({
|
|
1035
|
+
[e]: a
|
|
1031
1036
|
});
|
|
1032
1037
|
}
|
|
1033
|
-
P(
|
|
1034
|
-
h.setAttributes(
|
|
1038
|
+
P(n) || s.model.change((h) => {
|
|
1039
|
+
h.setAttributes(n, f);
|
|
1035
1040
|
});
|
|
1036
1041
|
return;
|
|
1037
1042
|
}
|
|
1038
|
-
|
|
1043
|
+
s.addRoot(e, {
|
|
1039
1044
|
isUndoable: !1,
|
|
1040
|
-
modelAttributes: { ...
|
|
1041
|
-
|
|
1042
|
-
|
|
1045
|
+
modelAttributes: { ...n },
|
|
1046
|
+
modelElement: i,
|
|
1047
|
+
...a !== null && {
|
|
1048
|
+
initialData: a
|
|
1043
1049
|
}
|
|
1044
1050
|
});
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
const
|
|
1048
|
-
if (!
|
|
1051
|
+
const E = this.querySelector("[data-cke-editable-content]"), b = c.view.createEditable(e, E);
|
|
1052
|
+
c.addEditable(b), u.view.forceRender();
|
|
1053
|
+
const w = () => {
|
|
1054
|
+
if (!d.document.getRoot(e)?.isAttached())
|
|
1049
1055
|
return;
|
|
1050
|
-
const h =
|
|
1056
|
+
const h = s.getData({ rootName: e });
|
|
1051
1057
|
l && (l.value = h, l.dispatchEvent(new Event("input"))), this.dispatchEvent(new CustomEvent("change", {
|
|
1052
1058
|
detail: {
|
|
1053
1059
|
value: h
|
|
1054
1060
|
}
|
|
1055
1061
|
}));
|
|
1056
|
-
},
|
|
1057
|
-
return
|
|
1058
|
-
if (
|
|
1059
|
-
const h =
|
|
1060
|
-
if (h && "detachEditable" in
|
|
1062
|
+
}, g = W(o, w);
|
|
1063
|
+
return s.model.document.on("change:data", g), w(), () => {
|
|
1064
|
+
if (s.model.document.off("change:data", g), s.state !== "destroyed" && e) {
|
|
1065
|
+
const h = s.model.document.getRoot(e);
|
|
1066
|
+
if (h && "detachEditable" in s) {
|
|
1061
1067
|
try {
|
|
1062
|
-
|
|
1063
|
-
} catch (
|
|
1064
|
-
console.error("Unable unmount editable from root:",
|
|
1068
|
+
s.ui.view.editables[e] && s.detachEditable(h);
|
|
1069
|
+
} catch (p) {
|
|
1070
|
+
console.error("Unable unmount editable from root:", p);
|
|
1065
1071
|
}
|
|
1066
|
-
h.isAttached() &&
|
|
1072
|
+
h.isAttached() && s.detachRoot(e, !1);
|
|
1067
1073
|
}
|
|
1068
1074
|
}
|
|
1069
1075
|
};
|
|
@@ -1076,13 +1082,13 @@ class bt extends HTMLElement {
|
|
|
1076
1082
|
this.interactiveWait?.disconnect(), this.style.display = "none", this.unmountEffect?.(), this.unmountEffect = null;
|
|
1077
1083
|
}
|
|
1078
1084
|
}
|
|
1079
|
-
async function
|
|
1085
|
+
async function bt({
|
|
1080
1086
|
saveDebounceMs: r,
|
|
1081
1087
|
editorId: t,
|
|
1082
1088
|
targetElement: e
|
|
1083
1089
|
}) {
|
|
1084
|
-
const { Plugin:
|
|
1085
|
-
return class extends
|
|
1090
|
+
const { Plugin: n } = await import("ckeditor5");
|
|
1091
|
+
return class extends n {
|
|
1086
1092
|
/**
|
|
1087
1093
|
* The name of the plugin.
|
|
1088
1094
|
*/
|
|
@@ -1093,19 +1099,19 @@ async function yt({
|
|
|
1093
1099
|
* Initializes the plugin.
|
|
1094
1100
|
*/
|
|
1095
1101
|
afterInit() {
|
|
1096
|
-
const { editor:
|
|
1097
|
-
|
|
1102
|
+
const { editor: a } = this, o = W(r, this.dispatch);
|
|
1103
|
+
a.model.document.on("change:data", o), a.once("ready", this.dispatch);
|
|
1098
1104
|
}
|
|
1099
1105
|
/**
|
|
1100
1106
|
* Dispatches a custom event with all roots data.
|
|
1101
1107
|
*/
|
|
1102
1108
|
dispatch = () => {
|
|
1103
|
-
const { editor:
|
|
1109
|
+
const { editor: a } = this;
|
|
1104
1110
|
e.dispatchEvent(
|
|
1105
1111
|
new y({
|
|
1106
1112
|
editorId: t,
|
|
1107
|
-
editor:
|
|
1108
|
-
roots: J(
|
|
1113
|
+
editor: a,
|
|
1114
|
+
roots: J(a)
|
|
1109
1115
|
})
|
|
1110
1116
|
);
|
|
1111
1117
|
};
|
|
@@ -1120,7 +1126,7 @@ class y extends CustomEvent {
|
|
|
1120
1126
|
});
|
|
1121
1127
|
}
|
|
1122
1128
|
}
|
|
1123
|
-
async function
|
|
1129
|
+
async function yt(r) {
|
|
1124
1130
|
const { Plugin: t } = await import("ckeditor5");
|
|
1125
1131
|
return class extends t {
|
|
1126
1132
|
/**
|
|
@@ -1141,16 +1147,16 @@ async function Et(r) {
|
|
|
1141
1147
|
* Initializes the plugin.
|
|
1142
1148
|
*/
|
|
1143
1149
|
afterInit() {
|
|
1144
|
-
const { editor:
|
|
1145
|
-
this.input = document.getElementById(`${
|
|
1150
|
+
const { editor: n } = this, a = n.sourceElement.id.replace(/_editor$/, "");
|
|
1151
|
+
this.input = document.getElementById(`${a}_input`), this.input && (n.model.document.on("change:data", W(r, () => this.sync())), n.once("ready", this.sync), this.form = this.input.closest("form"), this.form?.addEventListener("submit", this.sync));
|
|
1146
1152
|
}
|
|
1147
1153
|
/**
|
|
1148
1154
|
* Synchronizes the editor's content with the input field.
|
|
1149
1155
|
*/
|
|
1150
1156
|
sync = () => {
|
|
1151
1157
|
if (this.input) {
|
|
1152
|
-
const
|
|
1153
|
-
this.input.value =
|
|
1158
|
+
const n = this.editor.getData();
|
|
1159
|
+
this.input.value = n, this.input.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1154
1160
|
}
|
|
1155
1161
|
};
|
|
1156
1162
|
/**
|
|
@@ -1174,7 +1180,7 @@ class kt extends HTMLElement {
|
|
|
1174
1180
|
* Mounts the editor component.
|
|
1175
1181
|
*/
|
|
1176
1182
|
async connectedCallback() {
|
|
1177
|
-
await
|
|
1183
|
+
await R(), this.interactiveWait = L(this), j("classic"), await this.interactiveWait.promise, await this.initializeEditor();
|
|
1178
1184
|
}
|
|
1179
1185
|
/**
|
|
1180
1186
|
* Initializes the editor instance.
|
|
@@ -1184,15 +1190,15 @@ class kt extends HTMLElement {
|
|
|
1184
1190
|
m.the.resetErrors(t);
|
|
1185
1191
|
try {
|
|
1186
1192
|
this.style.display = "block";
|
|
1187
|
-
const e = await this.createEditor(),
|
|
1193
|
+
const e = await this.createEditor(), n = lt(e), i = wt(e);
|
|
1188
1194
|
if (this.isConnected) {
|
|
1189
|
-
const
|
|
1195
|
+
const a = m.the.mountEffect(t, (o) => {
|
|
1190
1196
|
o.once("destroy", () => {
|
|
1191
1197
|
m.the.unregister(t, !1);
|
|
1192
1198
|
}, { priority: "highest" });
|
|
1193
1199
|
});
|
|
1194
1200
|
this.unmountEffect = async () => {
|
|
1195
|
-
m.the.unregister(t),
|
|
1201
|
+
m.the.unregister(t), a(), n ? n.state !== "unavailable" && await n.context.remove(n.editorContextId) : i ? await i.destroy() : await e.destroy();
|
|
1196
1202
|
}, m.the.register(t, e);
|
|
1197
1203
|
}
|
|
1198
1204
|
} catch (e) {
|
|
@@ -1212,75 +1218,75 @@ class kt extends HTMLElement {
|
|
|
1212
1218
|
async createEditor() {
|
|
1213
1219
|
const t = JSON.parse(this.getAttribute("data-cke-preset")), {
|
|
1214
1220
|
customTranslations: e,
|
|
1215
|
-
editorType:
|
|
1216
|
-
licenseKey:
|
|
1217
|
-
watchdogConfig:
|
|
1218
|
-
config: { plugins: o, ...
|
|
1219
|
-
} = t,
|
|
1220
|
-
const { loadedPlugins:
|
|
1221
|
-
|
|
1222
|
-
await
|
|
1221
|
+
editorType: n,
|
|
1222
|
+
licenseKey: i,
|
|
1223
|
+
watchdogConfig: a,
|
|
1224
|
+
config: { plugins: o, ...s }
|
|
1225
|
+
} = t, c = this.getAttribute("data-cke-editor-id"), u = this.getAttribute("data-cke-context-id"), d = JSON.parse(this.getAttribute("data-cke-root-attributes") || "{}"), l = this.getAttribute("data-cke-editable-height") ? Number.parseInt(this.getAttribute("data-cke-editable-height"), 10) : null, f = Number.parseInt(this.getAttribute("data-cke-save-debounce-ms"), 10), E = this.hasAttribute("data-cke-watchdog"), b = this.getAttribute("data-cke-language") ? JSON.parse(this.getAttribute("data-cke-language")) : Q(t.config.language), w = await j(n), g = await (u ? C.the.waitFor(u) : null), h = async () => {
|
|
1226
|
+
const { loadedPlugins: p, hasPremium: I } = await G(o);
|
|
1227
|
+
p.push(
|
|
1228
|
+
await bt({
|
|
1223
1229
|
saveDebounceMs: f,
|
|
1224
|
-
editorId:
|
|
1230
|
+
editorId: c,
|
|
1225
1231
|
targetElement: this
|
|
1226
1232
|
})
|
|
1227
|
-
), V(
|
|
1228
|
-
await
|
|
1233
|
+
), V(n) && p.push(
|
|
1234
|
+
await yt(f)
|
|
1229
1235
|
);
|
|
1230
1236
|
const A = [
|
|
1231
|
-
...await Y(
|
|
1237
|
+
...await Y(b, I),
|
|
1232
1238
|
X(e || {})
|
|
1233
1239
|
].filter((N) => !P(N));
|
|
1234
|
-
let T =
|
|
1235
|
-
const
|
|
1236
|
-
V(
|
|
1237
|
-
let
|
|
1238
|
-
...
|
|
1239
|
-
licenseKey:
|
|
1240
|
-
plugins:
|
|
1241
|
-
language:
|
|
1240
|
+
let T = Z(c);
|
|
1241
|
+
const D = Object.keys(T);
|
|
1242
|
+
V(n) && D.push("main"), K(T, D) || (T = await vt(c, D));
|
|
1243
|
+
let k = {
|
|
1244
|
+
...s,
|
|
1245
|
+
licenseKey: i,
|
|
1246
|
+
plugins: p,
|
|
1247
|
+
language: b,
|
|
1242
1248
|
...A.length && {
|
|
1243
1249
|
translations: A
|
|
1244
1250
|
}
|
|
1245
1251
|
};
|
|
1246
|
-
|
|
1247
|
-
const O = await (async () =>
|
|
1248
|
-
context:
|
|
1252
|
+
k = M(k), k = S([...A].reverse(), b.ui, k), k = st(w, T, k);
|
|
1253
|
+
const O = await (async () => g ? (await ut({
|
|
1254
|
+
context: g,
|
|
1249
1255
|
creator: w,
|
|
1250
|
-
config:
|
|
1251
|
-
})).editor : w.create(
|
|
1252
|
-
return P(
|
|
1253
|
-
N.setAttributes(
|
|
1254
|
-
}), V(
|
|
1256
|
+
config: k
|
|
1257
|
+
})).editor : w.create(k))();
|
|
1258
|
+
return P(d) || O.model.change((N) => {
|
|
1259
|
+
N.setAttributes(d, O.model.document.getRoot());
|
|
1260
|
+
}), V(n) && l && ft(O, l), O;
|
|
1255
1261
|
};
|
|
1256
|
-
if (
|
|
1257
|
-
const
|
|
1258
|
-
return
|
|
1262
|
+
if (E && !g) {
|
|
1263
|
+
const p = await pt(h, a);
|
|
1264
|
+
return p.on("error", (I, { causesRestart: q }) => {
|
|
1259
1265
|
if (q) {
|
|
1260
|
-
const A = m.the.getItem(
|
|
1261
|
-
A && (ct(A), m.the.unregister(
|
|
1266
|
+
const A = m.the.getItem(c);
|
|
1267
|
+
A && (ct(A), m.the.unregister(c));
|
|
1262
1268
|
}
|
|
1263
|
-
}),
|
|
1264
|
-
const I =
|
|
1265
|
-
m.the.register(
|
|
1266
|
-
}), await
|
|
1269
|
+
}), p.on("restart", () => {
|
|
1270
|
+
const I = p.editor;
|
|
1271
|
+
m.the.register(c, I);
|
|
1272
|
+
}), await p.create({}), p.editor;
|
|
1267
1273
|
}
|
|
1268
|
-
return
|
|
1274
|
+
return h();
|
|
1269
1275
|
}
|
|
1270
1276
|
}
|
|
1271
|
-
function
|
|
1277
|
+
function K(r, t) {
|
|
1272
1278
|
return t.every((e) => r[e]?.element);
|
|
1273
1279
|
}
|
|
1274
1280
|
async function vt(r, t) {
|
|
1275
1281
|
return ot(
|
|
1276
1282
|
() => {
|
|
1277
|
-
const e =
|
|
1278
|
-
if (!
|
|
1283
|
+
const e = Z(r);
|
|
1284
|
+
if (!K(e, t))
|
|
1279
1285
|
throw new Error(
|
|
1280
1286
|
`It looks like not all required root elements are present yet.
|
|
1281
1287
|
* If you want to wait for them, ensure they are registered before editor initialization.
|
|
1282
1288
|
* If you want lazy initialize roots, consider removing root values from the \`initialData\` config and assign initial data in editable components.
|
|
1283
|
-
Missing roots: ${t.filter((
|
|
1289
|
+
Missing roots: ${t.filter((n) => !e[n]?.element).join(", ")}.`
|
|
1284
1290
|
);
|
|
1285
1291
|
return e;
|
|
1286
1292
|
},
|
|
@@ -1296,14 +1302,14 @@ class At extends HTMLElement {
|
|
|
1296
1302
|
* Mounts the UI part component.
|
|
1297
1303
|
*/
|
|
1298
1304
|
async connectedCallback() {
|
|
1299
|
-
await
|
|
1305
|
+
await R();
|
|
1300
1306
|
const t = this.getAttribute("data-cke-editor-id") || F()[0], e = this.getAttribute("data-cke-name");
|
|
1301
|
-
!t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (
|
|
1307
|
+
!t || !e || (this.style.display = "block", this.unmountEffect = m.the.mountEffect(t, (n) => {
|
|
1302
1308
|
if (!this.isConnected)
|
|
1303
1309
|
return;
|
|
1304
|
-
const { ui:
|
|
1310
|
+
const { ui: i } = n, a = Ct(e), o = i.view[a];
|
|
1305
1311
|
if (!o)
|
|
1306
|
-
throw new
|
|
1312
|
+
throw new v(`Unknown UI part name: "${e}". Supported names are "toolbar" and "menubar".`);
|
|
1307
1313
|
return this.appendChild(o.element), () => {
|
|
1308
1314
|
this.innerHTML = "";
|
|
1309
1315
|
};
|
|
@@ -1331,14 +1337,14 @@ const It = {
|
|
|
1331
1337
|
"cke5-editor": kt,
|
|
1332
1338
|
"cke5-context": gt,
|
|
1333
1339
|
"cke5-ui-part": At,
|
|
1334
|
-
"cke5-editable":
|
|
1340
|
+
"cke5-editable": Et
|
|
1335
1341
|
};
|
|
1336
1342
|
function Tt() {
|
|
1337
1343
|
for (const [r, t] of Object.entries(It))
|
|
1338
1344
|
window.customElements.get(r) || window.customElements.define(r, t);
|
|
1339
1345
|
}
|
|
1340
|
-
function
|
|
1341
|
-
return
|
|
1346
|
+
function St(r) {
|
|
1347
|
+
return x(r), {
|
|
1342
1348
|
unmount() {
|
|
1343
1349
|
}
|
|
1344
1350
|
};
|
|
@@ -1349,21 +1355,21 @@ function tt(r, t) {
|
|
|
1349
1355
|
pendingValue: null,
|
|
1350
1356
|
/** The last value sent to or received from Blazor to prevent circular updates. */
|
|
1351
1357
|
lastSyncedValue: null
|
|
1352
|
-
},
|
|
1358
|
+
}, n = () => {
|
|
1353
1359
|
e.pendingValue = null;
|
|
1354
|
-
},
|
|
1355
|
-
if (
|
|
1360
|
+
}, i = (a, o, s) => {
|
|
1361
|
+
if (s || e.pendingValue === null)
|
|
1356
1362
|
return;
|
|
1357
|
-
const
|
|
1358
|
-
t.isEqual(
|
|
1363
|
+
const c = t.getCurrentValue();
|
|
1364
|
+
t.isEqual(c, e.pendingValue) || t.applyValue(e.pendingValue), e.pendingValue = null;
|
|
1359
1365
|
};
|
|
1360
|
-
return r.model.document.on("change:data",
|
|
1366
|
+
return r.model.document.on("change:data", n), r.ui.focusTracker.on("change:isFocused", i), {
|
|
1361
1367
|
/**
|
|
1362
1368
|
* Removes all editor listeners registered by this sync instance.
|
|
1363
1369
|
* Call this when the Blazor component is disposed.
|
|
1364
1370
|
*/
|
|
1365
1371
|
unmount() {
|
|
1366
|
-
r.model.document.off("change:data",
|
|
1372
|
+
r.model.document.off("change:data", n), r.ui.focusTracker.off("change:isFocused", i);
|
|
1367
1373
|
},
|
|
1368
1374
|
/**
|
|
1369
1375
|
* Checks whether the given value differs from the last synced value and, if so,
|
|
@@ -1372,20 +1378,20 @@ function tt(r, t) {
|
|
|
1372
1378
|
* Call this from the `CKEditor5ChangeDataEvent` handler to conditionally invoke
|
|
1373
1379
|
* the .NET interop method.
|
|
1374
1380
|
*/
|
|
1375
|
-
shouldNotify(
|
|
1376
|
-
return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue,
|
|
1381
|
+
shouldNotify(a) {
|
|
1382
|
+
return e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, a) ? !1 : (e.lastSyncedValue = a, !0);
|
|
1377
1383
|
},
|
|
1378
1384
|
/**
|
|
1379
1385
|
* Pushes a new value from Blazor into the editor.
|
|
1380
1386
|
* If the editor is currently focused, the update is deferred until blur.
|
|
1381
1387
|
* If the value matches the last synced state, the update is skipped entirely.
|
|
1382
1388
|
*/
|
|
1383
|
-
setValue(
|
|
1389
|
+
setValue(a) {
|
|
1384
1390
|
if (r.ui.focusTracker.isFocused) {
|
|
1385
|
-
e.pendingValue =
|
|
1391
|
+
e.pendingValue = a;
|
|
1386
1392
|
return;
|
|
1387
1393
|
}
|
|
1388
|
-
e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue,
|
|
1394
|
+
e.lastSyncedValue !== null && t.isEqual(e.lastSyncedValue, a) || (e.lastSyncedValue = a, t.applyValue(a));
|
|
1389
1395
|
}
|
|
1390
1396
|
};
|
|
1391
1397
|
}
|
|
@@ -1402,93 +1408,93 @@ function et() {
|
|
|
1402
1408
|
}
|
|
1403
1409
|
function rt(r, t) {
|
|
1404
1410
|
const e = /* @__PURE__ */ new Set();
|
|
1405
|
-
return (
|
|
1406
|
-
r.model.enqueueChange({ isUndoable: !1 }, (
|
|
1407
|
-
const
|
|
1408
|
-
if (
|
|
1411
|
+
return (n) => {
|
|
1412
|
+
r.model.enqueueChange({ isUndoable: !1 }, (i) => {
|
|
1413
|
+
const a = r.model.document.getRoot(t);
|
|
1414
|
+
if (a) {
|
|
1409
1415
|
for (const o of e)
|
|
1410
|
-
|
|
1411
|
-
for (const [o,
|
|
1412
|
-
|
|
1416
|
+
n && o in n || (i.removeAttribute(o, a), e.delete(o));
|
|
1417
|
+
for (const [o, s] of Object.entries(n ?? {}))
|
|
1418
|
+
i.setAttribute(o, s, a), e.add(o);
|
|
1413
1419
|
}
|
|
1414
1420
|
});
|
|
1415
1421
|
};
|
|
1416
1422
|
}
|
|
1417
|
-
function
|
|
1418
|
-
const e = r.getAttribute("data-cke-editor-id") ?? F()[0],
|
|
1419
|
-
let
|
|
1420
|
-
const
|
|
1421
|
-
if (!(
|
|
1423
|
+
function Rt(r, t) {
|
|
1424
|
+
const e = r.getAttribute("data-cke-editor-id") ?? F()[0], n = r.getAttribute("data-cke-root-name") ?? "main";
|
|
1425
|
+
let i = !1, a = null, o = null, s = et(), c = null;
|
|
1426
|
+
const u = (d) => {
|
|
1427
|
+
if (!(d instanceof y) || d.detail.editorId !== e)
|
|
1422
1428
|
return;
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1429
|
+
const l = d.detail.roots[n];
|
|
1430
|
+
l !== void 0 && s.shouldNotify(l) && t.invokeMethodAsync("OnChangeEditableData", o, l);
|
|
1425
1431
|
};
|
|
1426
|
-
return
|
|
1427
|
-
getCurrentValue: () =>
|
|
1428
|
-
applyValue: (
|
|
1429
|
-
isEqual: (
|
|
1430
|
-
}),
|
|
1431
|
-
|
|
1432
|
-
})), document.body.addEventListener(y.EVENT_NAME,
|
|
1432
|
+
return a = m.the.mountEffect(e, (d) => (o = globalThis.DotNet.createJSObjectReference(d), s = tt(d, {
|
|
1433
|
+
getCurrentValue: () => d.getData({ rootName: n }) ?? "",
|
|
1434
|
+
applyValue: (l) => d.setData({ [n]: l }),
|
|
1435
|
+
isEqual: (l, f) => l === f
|
|
1436
|
+
}), c = rt(d, n), () => {
|
|
1437
|
+
s.unmount(), o && (globalThis.DotNet?.disposeJSObjectReference(o), o = null), c = null;
|
|
1438
|
+
})), document.body.addEventListener(y.EVENT_NAME, u), x(r), {
|
|
1433
1439
|
/**
|
|
1434
1440
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1435
1441
|
*/
|
|
1436
1442
|
unmount() {
|
|
1437
|
-
|
|
1443
|
+
i || (document.body.removeEventListener(y.EVENT_NAME, u), a?.(), a = null, i = !0);
|
|
1438
1444
|
},
|
|
1439
1445
|
/**
|
|
1440
1446
|
* Updates this editable root's data from Blazor.
|
|
1441
1447
|
* If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1442
1448
|
*/
|
|
1443
|
-
setValue: async (
|
|
1444
|
-
|
|
1449
|
+
setValue: async (d) => {
|
|
1450
|
+
i || (await m.the.waitFor(e), s.setValue(d));
|
|
1445
1451
|
},
|
|
1446
1452
|
/**
|
|
1447
1453
|
* Updates the root attributes on the editor. This is useful when the Blazor component
|
|
1448
1454
|
* re-renders with new root attributes.
|
|
1449
1455
|
*/
|
|
1450
|
-
setRootAttributes: async (
|
|
1451
|
-
|
|
1456
|
+
setRootAttributes: async (d) => {
|
|
1457
|
+
i || (await m.the.waitFor(e), c?.(d));
|
|
1452
1458
|
}
|
|
1453
1459
|
};
|
|
1454
1460
|
}
|
|
1455
|
-
function
|
|
1461
|
+
function xt(r, t) {
|
|
1456
1462
|
const e = r.getAttribute("data-cke-editor-id");
|
|
1457
|
-
let
|
|
1458
|
-
const
|
|
1459
|
-
!(
|
|
1463
|
+
let n = !1, i = null, a = et(), o = null, s = null;
|
|
1464
|
+
const c = (u) => {
|
|
1465
|
+
!(u instanceof y) || u.detail.editorId !== e || a.shouldNotify(u.detail.roots) && t.invokeMethodAsync("OnChangeEditorData", s, u.detail.roots);
|
|
1460
1466
|
};
|
|
1461
|
-
return
|
|
1462
|
-
|
|
1463
|
-
getCurrentValue: () => J(
|
|
1464
|
-
applyValue: (
|
|
1465
|
-
isEqual:
|
|
1466
|
-
}), o = rt(
|
|
1467
|
-
const
|
|
1468
|
-
const
|
|
1469
|
-
t.invokeMethodAsync(
|
|
1467
|
+
return i = m.the.mountEffect(e, (u) => {
|
|
1468
|
+
s = globalThis.DotNet.createJSObjectReference(u), a = tt(u, {
|
|
1469
|
+
getCurrentValue: () => J(u),
|
|
1470
|
+
applyValue: (l) => u.setData(l),
|
|
1471
|
+
isEqual: at
|
|
1472
|
+
}), o = rt(u, "main");
|
|
1473
|
+
const d = (l, f, E) => {
|
|
1474
|
+
const b = E ? "OnEditorFocus" : "OnEditorBlur";
|
|
1475
|
+
t.invokeMethodAsync(b, s);
|
|
1470
1476
|
};
|
|
1471
|
-
return
|
|
1472
|
-
|
|
1477
|
+
return u.ui.focusTracker.on("change:isFocused", d), t.invokeMethodAsync("OnEditorReady", s), () => {
|
|
1478
|
+
u.ui.focusTracker.off("change:isFocused", d), a.unmount(), s && (globalThis.DotNet?.disposeJSObjectReference(s), s = null), o = null;
|
|
1473
1479
|
};
|
|
1474
|
-
}), document.body.addEventListener(y.EVENT_NAME,
|
|
1480
|
+
}), document.body.addEventListener(y.EVENT_NAME, c), Tt(), x(r), {
|
|
1475
1481
|
/**
|
|
1476
1482
|
* Updates the editor data from Blazor. If the editor is focused, the update is deferred until blur to avoid interrupting the user.
|
|
1477
1483
|
*/
|
|
1478
|
-
setValue: async (
|
|
1479
|
-
|
|
1484
|
+
setValue: async (u) => {
|
|
1485
|
+
n || (await m.the.waitFor(e), a.setValue(u));
|
|
1480
1486
|
},
|
|
1481
1487
|
/**
|
|
1482
1488
|
* Updates the root attributes on the editor instance.
|
|
1483
1489
|
*/
|
|
1484
|
-
setRootAttributes: async (
|
|
1485
|
-
|
|
1490
|
+
setRootAttributes: async (u) => {
|
|
1491
|
+
n || (await m.the.waitFor(e), o?.(u));
|
|
1486
1492
|
},
|
|
1487
1493
|
/**
|
|
1488
1494
|
* Cleans up all event listeners when the Blazor component is disposed.
|
|
1489
1495
|
*/
|
|
1490
1496
|
unmount() {
|
|
1491
|
-
|
|
1497
|
+
n || (document.body.removeEventListener(y.EVENT_NAME, c), i?.(), i = null, n = !0);
|
|
1492
1498
|
},
|
|
1493
1499
|
/**
|
|
1494
1500
|
* Installs the custom image upload adapter that delegates uploads to Blazor.
|
|
@@ -1496,8 +1502,8 @@ function Dt(r, t) {
|
|
|
1496
1502
|
* to avoid unnecessary overhead for consumers that don't use this feature.
|
|
1497
1503
|
*/
|
|
1498
1504
|
attachImageUploadAdapter: async () => {
|
|
1499
|
-
|
|
1500
|
-
Ot(
|
|
1505
|
+
n || m.the.mountEffect(e, (u) => {
|
|
1506
|
+
Ot(u, t);
|
|
1501
1507
|
});
|
|
1502
1508
|
}
|
|
1503
1509
|
};
|
|
@@ -1506,58 +1512,58 @@ function Ot(r, t) {
|
|
|
1506
1512
|
if (!r.plugins.has("FileRepository"))
|
|
1507
1513
|
return;
|
|
1508
1514
|
const e = r.plugins.get("FileRepository");
|
|
1509
|
-
e.createUploadAdapter = (
|
|
1510
|
-
let
|
|
1515
|
+
e.createUploadAdapter = (n) => {
|
|
1516
|
+
let i = !1;
|
|
1511
1517
|
return {
|
|
1512
1518
|
async upload() {
|
|
1513
|
-
const
|
|
1514
|
-
if (
|
|
1519
|
+
const a = await n.file;
|
|
1520
|
+
if (i)
|
|
1515
1521
|
throw new Error("Upload aborted.");
|
|
1516
|
-
const o = await Nt(
|
|
1517
|
-
fileName:
|
|
1518
|
-
mimeType:
|
|
1522
|
+
const o = await Nt(a), s = await t.invokeMethodAsync("OnEditorImageUpload", {
|
|
1523
|
+
fileName: a.name,
|
|
1524
|
+
mimeType: a.type,
|
|
1519
1525
|
payload: o
|
|
1520
1526
|
});
|
|
1521
|
-
if (!
|
|
1527
|
+
if (!s)
|
|
1522
1528
|
throw new Error(
|
|
1523
1529
|
"OnImageUpload handler returned null. Make sure the OnImageUpload parameter is set on the <CKE5Editor> component."
|
|
1524
1530
|
);
|
|
1525
|
-
return { default:
|
|
1531
|
+
return { default: s };
|
|
1526
1532
|
},
|
|
1527
1533
|
abort() {
|
|
1528
|
-
|
|
1534
|
+
i = !0;
|
|
1529
1535
|
}
|
|
1530
1536
|
};
|
|
1531
1537
|
};
|
|
1532
1538
|
}
|
|
1533
1539
|
function Nt(r) {
|
|
1534
1540
|
return new Promise((t, e) => {
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
const
|
|
1538
|
-
t(
|
|
1539
|
-
},
|
|
1541
|
+
const n = new FileReader();
|
|
1542
|
+
n.onload = () => {
|
|
1543
|
+
const i = n.result, a = i.split(",")[1] ?? i;
|
|
1544
|
+
t(a);
|
|
1545
|
+
}, n.onerror = () => e(n.error), n.readAsDataURL(r);
|
|
1540
1546
|
});
|
|
1541
1547
|
}
|
|
1542
|
-
function
|
|
1543
|
-
return
|
|
1548
|
+
function Dt(r) {
|
|
1549
|
+
return x(r), {
|
|
1544
1550
|
unmount() {
|
|
1545
1551
|
}
|
|
1546
1552
|
};
|
|
1547
1553
|
}
|
|
1548
1554
|
export {
|
|
1549
|
-
|
|
1555
|
+
v as CKEditor5BlazorError,
|
|
1550
1556
|
y as CKEditor5ChangeDataEvent,
|
|
1551
1557
|
C as ContextsRegistry,
|
|
1552
1558
|
_ as CustomEditorPluginsRegistry,
|
|
1553
|
-
|
|
1559
|
+
Et as EditableComponentElement,
|
|
1554
1560
|
kt as EditorComponentElement,
|
|
1555
1561
|
m as EditorsRegistry,
|
|
1556
1562
|
At as UIPartComponentElement,
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1563
|
+
St as createContextBlazorInterop,
|
|
1564
|
+
Rt as createEditableBlazorInterop,
|
|
1565
|
+
xt as createEditorBlazorInterop,
|
|
1566
|
+
Dt as createUIPartBlazorInterop,
|
|
1561
1567
|
Tt as ensureEditorElementsRegistered
|
|
1562
1568
|
};
|
|
1563
1569
|
//# sourceMappingURL=index.mjs.map
|