@ckeditor/ckeditor5-remove-format 36.0.0 → 37.0.0-alpha.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/package.json +25 -20
- package/src/index.d.ts +10 -0
- package/src/index.js +0 -2
- package/src/removeformat.d.ts +31 -0
- package/src/removeformat.js +12 -19
- package/src/removeformatcommand.d.ts +47 -0
- package/src/removeformatcommand.js +79 -99
- package/src/removeformatediting.d.ts +28 -0
- package/src/removeformatediting.js +13 -21
- package/src/removeformatui.d.ts +27 -0
- package/src/removeformatui.js +29 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-remove-format",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Remove format feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,24 +12,25 @@
|
|
|
12
12
|
],
|
|
13
13
|
"main": "src/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"ckeditor5": "^
|
|
15
|
+
"ckeditor5": "^37.0.0-alpha.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
19
|
-
"@ckeditor/ckeditor5-clipboard": "^
|
|
20
|
-
"@ckeditor/ckeditor5-core": "^
|
|
21
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
22
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
23
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
24
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
25
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
26
|
-
"@ckeditor/ckeditor5-image": "^
|
|
27
|
-
"@ckeditor/ckeditor5-link": "^
|
|
28
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
29
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
30
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
31
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
32
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
|
22
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
23
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
|
30
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
31
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
|
|
32
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
|
33
|
+
"typescript": "^4.8.4",
|
|
33
34
|
"webpack": "^5.58.1",
|
|
34
35
|
"webpack-cli": "^4.9.0"
|
|
35
36
|
},
|
|
@@ -48,13 +49,17 @@
|
|
|
48
49
|
},
|
|
49
50
|
"files": [
|
|
50
51
|
"lang",
|
|
51
|
-
"src",
|
|
52
|
+
"src/**/*.js",
|
|
53
|
+
"src/**/*.d.ts",
|
|
52
54
|
"theme",
|
|
53
55
|
"build",
|
|
54
56
|
"ckeditor5-metadata.json",
|
|
55
57
|
"CHANGELOG.md"
|
|
56
58
|
],
|
|
57
59
|
"scripts": {
|
|
58
|
-
"dll:build": "webpack"
|
|
59
|
-
|
|
60
|
+
"dll:build": "webpack",
|
|
61
|
+
"build": "tsc -p ./tsconfig.release.json",
|
|
62
|
+
"postversion": "npm run build"
|
|
63
|
+
},
|
|
64
|
+
"types": "src/index.d.ts"
|
|
60
65
|
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module remove-format
|
|
7
|
+
*/
|
|
8
|
+
export { default as RemoveFormat } from './removeformat';
|
|
9
|
+
export { default as RemoveFormatEditing } from './removeformatediting';
|
|
10
|
+
export { default as RemoveFormatUI } from './removeformatui';
|
package/src/index.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module remove-format
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
export { default as RemoveFormat } from './removeformat';
|
|
11
9
|
export { default as RemoveFormatEditing } from './removeformatediting';
|
|
12
10
|
export { default as RemoveFormatUI } from './removeformatui';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module remove-format/removeformat
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The remove format plugin.
|
|
11
|
+
*
|
|
12
|
+
* This is a "glue" plugin which loads the {@link module:remove-format/removeformatediting~RemoveFormatEditing}
|
|
13
|
+
* and {@link module:remove-format/removeformatui~RemoveFormatUI} plugins.
|
|
14
|
+
*
|
|
15
|
+
* For a detailed overview, check out the {@glink features/remove-format remove format} feature documentation.
|
|
16
|
+
*/
|
|
17
|
+
export default class RemoveFormat extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get requires(): PluginDependencies;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get pluginName(): 'RemoveFormat';
|
|
26
|
+
}
|
|
27
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
28
|
+
interface PluginsMap {
|
|
29
|
+
[RemoveFormat.pluginName]: RemoveFormat;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/removeformat.js
CHANGED
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module remove-format/removeformat
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import RemoveFormatUI from './removeformatui';
|
|
13
10
|
import RemoveFormatEditing from './removeformatediting';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* The remove format plugin.
|
|
17
13
|
*
|
|
@@ -19,21 +15,18 @@ import RemoveFormatEditing from './removeformatediting';
|
|
|
19
15
|
* and {@link module:remove-format/removeformatui~RemoveFormatUI} plugins.
|
|
20
16
|
*
|
|
21
17
|
* For a detailed overview, check out the {@glink features/remove-format remove format} feature documentation.
|
|
22
|
-
*
|
|
23
|
-
* @extends module:core/plugin~Plugin
|
|
24
18
|
*/
|
|
25
19
|
export default class RemoveFormat extends Plugin {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get requires() {
|
|
24
|
+
return [RemoveFormatEditing, RemoveFormatUI];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get pluginName() {
|
|
30
|
+
return 'RemoveFormat';
|
|
31
|
+
}
|
|
39
32
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from 'ckeditor5/src/core';
|
|
6
|
+
/**
|
|
7
|
+
* The remove format command.
|
|
8
|
+
*
|
|
9
|
+
* It is used by the {@link module:remove-format/removeformat~RemoveFormat remove format feature}
|
|
10
|
+
* to clear the formatting in the selection.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* editor.execute( 'removeFormat' );
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export default class RemoveFormatCommand extends Command {
|
|
17
|
+
value: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
refresh(): void;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
execute(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Returns an iterable of items in a selection (including the selection itself) that have formatting model
|
|
28
|
+
* attributes to be removed by the feature.
|
|
29
|
+
*
|
|
30
|
+
* @param schema The schema describing the item.
|
|
31
|
+
*/
|
|
32
|
+
private _getFormattingItems;
|
|
33
|
+
/**
|
|
34
|
+
* Returns an iterable of formatting attributes of a given model item.
|
|
35
|
+
*
|
|
36
|
+
* **Note:** Formatting items have the `isFormatting` property set to `true`.
|
|
37
|
+
*
|
|
38
|
+
* @param schema The schema describing the item.
|
|
39
|
+
* @returns The names of formatting attributes found in a given item.
|
|
40
|
+
*/
|
|
41
|
+
private _getFormattingAttributes;
|
|
42
|
+
}
|
|
43
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
44
|
+
interface CommandsMap {
|
|
45
|
+
removeFormat: RemoveFormatCommand;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -2,113 +2,93 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module remove-format/removeformatcommand
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
5
|
import { Command } from 'ckeditor5/src/core';
|
|
11
6
|
import { first } from 'ckeditor5/src/utils';
|
|
12
|
-
|
|
13
7
|
/**
|
|
14
8
|
* The remove format command.
|
|
15
9
|
*
|
|
16
10
|
* It is used by the {@link module:remove-format/removeformat~RemoveFormat remove format feature}
|
|
17
11
|
* to clear the formatting in the selection.
|
|
18
12
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* editor.execute( 'removeFormat' );
|
|
15
|
+
* ```
|
|
22
16
|
*/
|
|
23
17
|
export default class RemoveFormatCommand extends Command {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* @protected
|
|
101
|
-
* @param {module:engine/model/item~Item|module:engine/model/documentselection~DocumentSelection} item
|
|
102
|
-
* @param {module:engine/model/schema~Schema} schema The schema describing the item.
|
|
103
|
-
* @returns {Iterable.<String>} The names of formatting attributes found in a given item.
|
|
104
|
-
*/
|
|
105
|
-
* _getFormattingAttributes( item, schema ) {
|
|
106
|
-
for ( const [ attributeName ] of item.getAttributes() ) {
|
|
107
|
-
const attributeProperties = schema.getAttributeProperties( attributeName );
|
|
108
|
-
|
|
109
|
-
if ( attributeProperties && attributeProperties.isFormatting ) {
|
|
110
|
-
yield attributeName;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
refresh() {
|
|
22
|
+
const model = this.editor.model;
|
|
23
|
+
this.isEnabled = !!first(this._getFormattingItems(model.document.selection, model.schema));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
execute() {
|
|
29
|
+
const model = this.editor.model;
|
|
30
|
+
const schema = model.schema;
|
|
31
|
+
model.change(writer => {
|
|
32
|
+
for (const item of this._getFormattingItems(model.document.selection, schema)) {
|
|
33
|
+
if (item.is('selection')) {
|
|
34
|
+
for (const attributeName of this._getFormattingAttributes(item, schema)) {
|
|
35
|
+
writer.removeSelectionAttribute(attributeName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Workaround for items with multiple removable attributes. See
|
|
40
|
+
// https://github.com/ckeditor/ckeditor5-remove-format/pull/1#pullrequestreview-220515609
|
|
41
|
+
const itemRange = writer.createRangeOn(item);
|
|
42
|
+
for (const attributeName of this._getFormattingAttributes(item, schema)) {
|
|
43
|
+
writer.removeAttribute(attributeName, itemRange);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns an iterable of items in a selection (including the selection itself) that have formatting model
|
|
51
|
+
* attributes to be removed by the feature.
|
|
52
|
+
*
|
|
53
|
+
* @param schema The schema describing the item.
|
|
54
|
+
*/
|
|
55
|
+
*_getFormattingItems(selection, schema) {
|
|
56
|
+
const itemHasRemovableFormatting = (item) => {
|
|
57
|
+
return !!first(this._getFormattingAttributes(item, schema));
|
|
58
|
+
};
|
|
59
|
+
// Check formatting on selected items that are not blocks.
|
|
60
|
+
for (const curRange of selection.getRanges()) {
|
|
61
|
+
for (const item of curRange.getItems()) {
|
|
62
|
+
if (!schema.isBlock(item) && itemHasRemovableFormatting(item)) {
|
|
63
|
+
yield item;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Check formatting from selected blocks.
|
|
68
|
+
for (const block of selection.getSelectedBlocks()) {
|
|
69
|
+
if (itemHasRemovableFormatting(block)) {
|
|
70
|
+
yield block;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Finally the selection might be formatted as well, so make sure to check it.
|
|
74
|
+
if (itemHasRemovableFormatting(selection)) {
|
|
75
|
+
yield selection;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns an iterable of formatting attributes of a given model item.
|
|
80
|
+
*
|
|
81
|
+
* **Note:** Formatting items have the `isFormatting` property set to `true`.
|
|
82
|
+
*
|
|
83
|
+
* @param schema The schema describing the item.
|
|
84
|
+
* @returns The names of formatting attributes found in a given item.
|
|
85
|
+
*/
|
|
86
|
+
*_getFormattingAttributes(item, schema) {
|
|
87
|
+
for (const [attributeName] of item.getAttributes()) {
|
|
88
|
+
const attributeProperties = schema.getAttributeProperties(attributeName);
|
|
89
|
+
if (attributeProperties && attributeProperties.isFormatting) {
|
|
90
|
+
yield attributeName;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
114
94
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module remove-format/removeformatediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The remove format editing plugin.
|
|
11
|
+
*
|
|
12
|
+
* It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.
|
|
13
|
+
*/
|
|
14
|
+
export default class RemoveFormatEditing extends Plugin {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
static get pluginName(): 'RemoveFormatEditing';
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
init(): void;
|
|
23
|
+
}
|
|
24
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
25
|
+
interface PluginsMap {
|
|
26
|
+
[RemoveFormatEditing.pluginName]: RemoveFormatEditing;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -2,36 +2,28 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module remove-format/removeformatediting
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
|
-
|
|
12
9
|
import RemoveFormatCommand from './removeformatcommand';
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* The remove format editing plugin.
|
|
16
12
|
*
|
|
17
13
|
* It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.
|
|
18
|
-
*
|
|
19
|
-
* @extends module:core/plugin~Plugin
|
|
20
14
|
*/
|
|
21
15
|
export default class RemoveFormatEditing extends Plugin {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
editor.commands.add( 'removeFormat', new RemoveFormatCommand( editor ) );
|
|
36
|
-
}
|
|
16
|
+
/**
|
|
17
|
+
* @inheritDoc
|
|
18
|
+
*/
|
|
19
|
+
static get pluginName() {
|
|
20
|
+
return 'RemoveFormatEditing';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
init() {
|
|
26
|
+
const editor = this.editor;
|
|
27
|
+
editor.commands.add('removeFormat', new RemoveFormatCommand(editor));
|
|
28
|
+
}
|
|
37
29
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module remove-format/removeformatui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
|
9
|
+
/**
|
|
10
|
+
* The remove format UI plugin. It registers the `'removeFormat'` button which can be
|
|
11
|
+
* used in the toolbar.
|
|
12
|
+
*/
|
|
13
|
+
export default class RemoveFormatUI extends Plugin {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
static get pluginName(): 'RemoveFormatUI';
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
init(): void;
|
|
22
|
+
}
|
|
23
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
24
|
+
interface PluginsMap {
|
|
25
|
+
[RemoveFormatUI.pluginName]: RemoveFormatUI;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/removeformatui.js
CHANGED
|
@@ -2,58 +2,45 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module remove-format/removeformatui
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import { ButtonView } from 'ckeditor5/src/ui';
|
|
12
|
-
|
|
13
10
|
import removeFormatIcon from '../theme/icons/remove-format.svg';
|
|
14
|
-
|
|
15
11
|
const REMOVE_FORMAT = 'removeFormat';
|
|
16
|
-
|
|
17
12
|
/**
|
|
18
13
|
* The remove format UI plugin. It registers the `'removeFormat'` button which can be
|
|
19
14
|
* used in the toolbar.
|
|
20
|
-
*
|
|
21
|
-
* @extends module:core/plugin~Plugin
|
|
22
15
|
*/
|
|
23
16
|
export default class RemoveFormatUI extends Plugin {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
editor.editing.view.focus();
|
|
54
|
-
} );
|
|
55
|
-
|
|
56
|
-
return view;
|
|
57
|
-
} );
|
|
58
|
-
}
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName() {
|
|
21
|
+
return 'RemoveFormatUI';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @inheritDoc
|
|
25
|
+
*/
|
|
26
|
+
init() {
|
|
27
|
+
const editor = this.editor;
|
|
28
|
+
const t = editor.t;
|
|
29
|
+
editor.ui.componentFactory.add(REMOVE_FORMAT, locale => {
|
|
30
|
+
const command = editor.commands.get(REMOVE_FORMAT);
|
|
31
|
+
const view = new ButtonView(locale);
|
|
32
|
+
view.set({
|
|
33
|
+
label: t('Remove Format'),
|
|
34
|
+
icon: removeFormatIcon,
|
|
35
|
+
tooltip: true
|
|
36
|
+
});
|
|
37
|
+
view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
|
|
38
|
+
// Execute the command.
|
|
39
|
+
this.listenTo(view, 'execute', () => {
|
|
40
|
+
editor.execute(REMOVE_FORMAT);
|
|
41
|
+
editor.editing.view.focus();
|
|
42
|
+
});
|
|
43
|
+
return view;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
59
46
|
}
|