ckeditor5-elements-toolbar 49.0.0-alpha.4 → 49.0.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/README.md +1 -1
- package/dist/augmentation.d.ts +1 -1
- package/dist/augmentation.d.ts.map +1 -1
- package/dist/elementToolbar.d.ts +1 -1
- package/dist/elementToolbar.d.ts.map +1 -1
- package/dist/elementToolbar.js +4 -4
- package/dist/elementToolbar.js.map +1 -1
- package/package.json +6 -2
- package/src/augmentation.ts +1 -1
- package/src/elementToolbar.ts +5 -16
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ import { ElementActions, ElementToolbar } from 'ckeditor5-elements';
|
|
|
18
18
|
|
|
19
19
|
// In the editor config:
|
|
20
20
|
plugins: [..., ElementActions, ElementToolbar],
|
|
21
|
-
|
|
21
|
+
elementToolbar: [
|
|
22
22
|
{ element: 'note', items: ['moveElementUp', 'moveElementDown', '|', 'duplicateElement', 'deleteElement'] },
|
|
23
23
|
{ element: element => element.name.startsWith('heading'), items: ['heading', '|', 'deleteElement'] }
|
|
24
24
|
]
|
package/dist/augmentation.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"augmentation.d.ts","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,QAAQ,WAAW,CAAC;IAC1B,UAAU,UAAU;QACnB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;KAC5C;IAED,UAAU,YAAY;QACrB;;WAEG;QACH,
|
|
1
|
+
{"version":3,"file":"augmentation.d.ts","sourceRoot":"","sources":["../src/augmentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,QAAQ,WAAW,CAAC;IAC1B,UAAU,UAAU;QACnB,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC;KAC5C;IAED,UAAU,YAAY;QACrB;;WAEG;QACH,cAAc,CAAC,EAAE,wBAAwB,EAAE,CAAC;KAC5C;CACD"}
|
package/dist/elementToolbar.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface ElementToolbarDefinition {
|
|
|
24
24
|
ariaLabel?: string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Shows floating toolbars for elements, configured by the `
|
|
27
|
+
* Shows floating toolbars for elements, configured by the `elementToolbar` editor config option (see
|
|
28
28
|
* {@link ElementToolbarDefinition}): the toolbar of the closest element at the selection that matches, next to it,
|
|
29
29
|
* while the editor is focused. When toolbars match nested elements, the toolbar of the innermost one shows.
|
|
30
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elementToolbar.d.ts","sourceRoot":"","sources":["../src/elementToolbar.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"elementToolbar.d.ts","sourceRoot":"","sources":["../src/elementToolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACvG,OAAO,EAMN,KAAK,cAAc,EACnB,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,OAAO,EAAE,cAAc,CAAC;IAExB;;;;;;;OAOG;IACH,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAE3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;IACjD,WAAkB,QAAQ,IAAI,SAAS,CAAC,OAAO,uBAAuB,CAAC,CAEtE;IAED,WAAkB,UAAU,IAAI,gBAAgB,CAE/C;IAED;;OAEG;IACI,SAAS,IAAI,IAAI;IAoBxB;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,GAAG,YAAY,GAAG,IAAI;IAUpF;;;OAGG;IACH,OAAO,CAAC,WAAW;CA0BnB"}
|
package/dist/elementToolbar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin, WidgetToolbarRepository } from 'ckeditor5';
|
|
2
|
-
import { ElementOrPositionButtonView, ElementOrPositionCommand, getElementAtSelection, matchesElement } from 'ckeditor5-elements-core';
|
|
2
|
+
import { ElementOrPositionButtonView, ElementOrPositionCommand, getAncestorElements, getElementAtSelection, matchesElement } from 'ckeditor5-elements-core';
|
|
3
3
|
/**
|
|
4
|
-
* Shows floating toolbars for elements, configured by the `
|
|
4
|
+
* Shows floating toolbars for elements, configured by the `elementToolbar` editor config option (see
|
|
5
5
|
* {@link ElementToolbarDefinition}): the toolbar of the closest element at the selection that matches, next to it,
|
|
6
6
|
* while the editor is focused. When toolbars match nested elements, the toolbar of the innermost one shows.
|
|
7
7
|
*
|
|
@@ -23,7 +23,7 @@ export default class ElementToolbar extends Plugin {
|
|
|
23
23
|
afterInit() {
|
|
24
24
|
const editor = this.editor;
|
|
25
25
|
const repository = editor.plugins.get(WidgetToolbarRepository);
|
|
26
|
-
(editor.config.get('
|
|
26
|
+
(editor.config.get('elementToolbar') ?? []).forEach((definition, index) => {
|
|
27
27
|
const toolbarId = `elementToolbar${String(index)}`;
|
|
28
28
|
const getElement = () => this.getElement(definition.element);
|
|
29
29
|
repository.register(toolbarId, {
|
|
@@ -41,7 +41,7 @@ export default class ElementToolbar extends Plugin {
|
|
|
41
41
|
* selection, or one of their ancestors. Never a root.
|
|
42
42
|
*/
|
|
43
43
|
getElement(element) {
|
|
44
|
-
for (
|
|
44
|
+
for (const node of getAncestorElements(getElementAtSelection(this.editor.model.document.selection))) {
|
|
45
45
|
if (matchesElement(element, node)) {
|
|
46
46
|
return node;
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elementToolbar.js","sourceRoot":"","sources":["../src/elementToolbar.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"elementToolbar.js","sourceRoot":"","sources":["../src/elementToolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAA6C,MAAM,WAAW,CAAC;AACvG,OAAO,EACN,2BAA2B,EAC3B,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EAEd,MAAM,yBAAyB,CAAC;AA4BjC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;IAC1C,MAAM,KAAK,QAAQ;QACzB,OAAO,CAAC,uBAAuB,CAAU,CAAC;IAC3C,CAAC;IAEM,MAAM,KAAK,UAAU;QAC3B,OAAO,gBAAyB,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QAE/D,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;YACzE,MAAM,SAAS,GAAG,iBAAiB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnD,MAAM,UAAU,GAAG,GAAwB,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAElF,UAAU,CAAC,QAAQ,CAAC,SAAS,EAAE;gBAC9B,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC9D,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,IA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YACpD,OAAO,IAAI,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAC7B,IAAI,EACJ,MAAM,CAAC,EAAE,CAAC,IAAI,2BAA2B,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAClF,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ckeditor5-elements-toolbar",
|
|
3
|
-
"version": "49.0.0
|
|
3
|
+
"version": "49.0.0",
|
|
4
4
|
"description": "Element toolbars for CKEditor 5: floating toolbars for the elements that match a name or a filter, with buttons that act on the element.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
],
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"ckeditor5-elements-core": "49.0.0
|
|
40
|
+
"ckeditor5-elements-core": "49.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"ckeditor5-elements-actions": "49.0.0",
|
|
44
|
+
"ckeditor5-elements-menu": "49.0.0"
|
|
41
45
|
},
|
|
42
46
|
"peerDependencies": {
|
|
43
47
|
"ckeditor5": "^49.0.0"
|
package/src/augmentation.ts
CHANGED
package/src/elementToolbar.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Plugin,
|
|
3
|
-
WidgetToolbarRepository,
|
|
4
|
-
type ModelDocumentFragment,
|
|
5
|
-
type ModelElement,
|
|
6
|
-
type ToolbarConfigItem
|
|
7
|
-
} from 'ckeditor5';
|
|
1
|
+
import { Plugin, WidgetToolbarRepository, type ModelElement, type ToolbarConfigItem } from 'ckeditor5';
|
|
8
2
|
import {
|
|
9
3
|
ElementOrPositionButtonView,
|
|
10
4
|
ElementOrPositionCommand,
|
|
5
|
+
getAncestorElements,
|
|
11
6
|
getElementAtSelection,
|
|
12
7
|
matchesElement,
|
|
13
8
|
type ElementMatcher
|
|
@@ -40,7 +35,7 @@ export interface ElementToolbarDefinition {
|
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
/**
|
|
43
|
-
* Shows floating toolbars for elements, configured by the `
|
|
38
|
+
* Shows floating toolbars for elements, configured by the `elementToolbar` editor config option (see
|
|
44
39
|
* {@link ElementToolbarDefinition}): the toolbar of the closest element at the selection that matches, next to it,
|
|
45
40
|
* while the editor is focused. When toolbars match nested elements, the toolbar of the innermost one shows.
|
|
46
41
|
*
|
|
@@ -65,7 +60,7 @@ export default class ElementToolbar extends Plugin {
|
|
|
65
60
|
const editor = this.editor;
|
|
66
61
|
const repository = editor.plugins.get(WidgetToolbarRepository);
|
|
67
62
|
|
|
68
|
-
(editor.config.get('
|
|
63
|
+
(editor.config.get('elementToolbar') ?? []).forEach((definition, index) => {
|
|
69
64
|
const toolbarId = `elementToolbar${String(index)}`;
|
|
70
65
|
const getElement = (): ModelElement | null => this.getElement(definition.element);
|
|
71
66
|
|
|
@@ -86,13 +81,7 @@ export default class ElementToolbar extends Plugin {
|
|
|
86
81
|
* selection, or one of their ancestors. Never a root.
|
|
87
82
|
*/
|
|
88
83
|
public getElement(element: ElementToolbarDefinition['element']): ModelElement | null {
|
|
89
|
-
for (
|
|
90
|
-
let node: ModelElement | ModelDocumentFragment | null = getElementAtSelection(
|
|
91
|
-
this.editor.model.document.selection
|
|
92
|
-
);
|
|
93
|
-
node?.is('element') && !node.is('rootElement');
|
|
94
|
-
node = node.parent
|
|
95
|
-
) {
|
|
84
|
+
for (const node of getAncestorElements(getElementAtSelection(this.editor.model.document.selection))) {
|
|
96
85
|
if (matchesElement(element, node)) {
|
|
97
86
|
return node;
|
|
98
87
|
}
|