ckeditor5-blazor 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +38 -38
- package/dist/index.mjs.map +1 -1
- package/dist/interop/create-editable-blazor-interop.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/interop/create-editable-blazor-interop.test.ts +21 -0
- package/src/interop/create-editable-blazor-interop.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-editable-blazor-interop.d.ts","sourceRoot":"","sources":["../../../src/interop/create-editable-blazor-interop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"create-editable-blazor-interop.d.ts","sourceRoot":"","sources":["../../../src/interop/create-editable-blazor-interop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAQ9C;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa;IAgDpF;;OAEG;;IAiBH;;;OAGG;sBACqB,MAAM;EAWjC"}
|
package/package.json
CHANGED
|
@@ -78,6 +78,27 @@ describe('createEditableBlazorInterop', () => {
|
|
|
78
78
|
);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
+
it('falls back to the first available editor id when data-cke-editor-id attribute is missing', async () => {
|
|
82
|
+
element.removeAttribute('data-cke-editor-id');
|
|
83
|
+
|
|
84
|
+
createEditableBlazorInterop(element, dotnetInterop);
|
|
85
|
+
|
|
86
|
+
const editor = await waitForTestEditor();
|
|
87
|
+
const changeEvent = new CKEditor5ChangeDataEvent({
|
|
88
|
+
editorId: DEFAULT_TEST_EDITOR_ID,
|
|
89
|
+
editor,
|
|
90
|
+
roots: { main: 'fallback changed' },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
document.body.dispatchEvent(changeEvent);
|
|
94
|
+
|
|
95
|
+
expect(dotnetInterop.invokeMethodAsync).toHaveBeenCalledWith(
|
|
96
|
+
'OnChangeEditableData',
|
|
97
|
+
expect.anything(),
|
|
98
|
+
'fallback changed',
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
81
102
|
it('should ignore ckeditor5 change events from other editors', async () => {
|
|
82
103
|
createEditableBlazorInterop(element, dotnetInterop);
|
|
83
104
|
|
|
@@ -2,6 +2,7 @@ import type { DotNetInterop } from '../types';
|
|
|
2
2
|
|
|
3
3
|
import { EditorsRegistry } from '../elements/editor/editors-registry';
|
|
4
4
|
import { CKEditor5ChangeDataEvent } from '../elements/editor/plugins/dispatch-editor-roots-change-event';
|
|
5
|
+
import { queryAllEditorIds } from '../elements/editor/utils';
|
|
5
6
|
import { markElementAsInteractive } from '../shared';
|
|
6
7
|
import { createEditorValueSync, createNoopSync } from './utils/create-editor-value-sync';
|
|
7
8
|
|
|
@@ -14,7 +15,7 @@ import { createEditorValueSync, createNoopSync } from './utils/create-editor-val
|
|
|
14
15
|
* @returns An object containing lifecycle and synchronization methods.
|
|
15
16
|
*/
|
|
16
17
|
export function createEditableBlazorInterop(element: HTMLElement, interop: DotNetInterop) {
|
|
17
|
-
const editorId = element.getAttribute('data-cke-editor-id')
|
|
18
|
+
const editorId = element.getAttribute('data-cke-editor-id') ?? queryAllEditorIds()[0]!;
|
|
18
19
|
const rootName = element.getAttribute('data-cke-root-name') ?? 'main';
|
|
19
20
|
|
|
20
21
|
let unmounted = false;
|