@ckeditor/ckeditor5-autoformat 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 +19 -18
- package/src/autoformat.d.ts +85 -0
- package/src/autoformat.js +9 -9
- package/src/blockautoformatediting.d.ts +57 -0
- package/src/blockautoformatediting.js +7 -6
- package/src/index.d.ts +8 -0
- package/src/inlineautoformatediting.d.ts +83 -0
- package/src/inlineautoformatediting.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-autoformat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.0-alpha.0",
|
|
4
4
|
"description": "Autoformatting feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -12,24 +12,24 @@
|
|
|
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-block-quote": "^
|
|
20
|
-
"@ckeditor/ckeditor5-code-block": "^
|
|
21
|
-
"@ckeditor/ckeditor5-core": "^
|
|
22
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
23
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
24
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
25
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
26
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
27
|
-
"@ckeditor/ckeditor5-horizontal-line": "^
|
|
28
|
-
"@ckeditor/ckeditor5-list": "^
|
|
29
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
30
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
31
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
32
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
|
19
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
|
|
20
|
+
"@ckeditor/ckeditor5-code-block": "^37.0.0-alpha.0",
|
|
21
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
|
22
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
|
23
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
|
|
24
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
|
25
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
|
26
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
|
27
|
+
"@ckeditor/ckeditor5-horizontal-line": "^37.0.0-alpha.0",
|
|
28
|
+
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
|
|
29
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
|
30
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
|
31
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
|
32
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
|
|
33
33
|
"typescript": "^4.8.4",
|
|
34
34
|
"webpack": "^5.58.1",
|
|
35
35
|
"webpack-cli": "^4.9.0"
|
|
@@ -63,5 +63,6 @@
|
|
|
63
63
|
"dll:build": "webpack",
|
|
64
64
|
"build": "tsc -p ./tsconfig.release.json",
|
|
65
65
|
"postversion": "npm run build"
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"types": "src/index.d.ts"
|
|
67
68
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
6
|
+
/**
|
|
7
|
+
* Enables a set of predefined autoformatting actions.
|
|
8
|
+
*
|
|
9
|
+
* For a detailed overview, check the {@glink features/autoformat Autoformatting} feature guide
|
|
10
|
+
* and the {@glink api/autoformat package page}.
|
|
11
|
+
*/
|
|
12
|
+
export default class Autoformat extends Plugin {
|
|
13
|
+
/**
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
static get requires(): PluginDependencies;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static get pluginName(): 'Autoformat';
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
afterInit(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Adds autoformatting related to the {@link module:list/list~List}.
|
|
27
|
+
*
|
|
28
|
+
* When typed:
|
|
29
|
+
* - `* ` or `- ` – A paragraph will be changed into a bulleted list.
|
|
30
|
+
* - `1. ` or `1) ` – A paragraph will be changed into a numbered list ("1" can be any digit or a list of digits).
|
|
31
|
+
* - `[] ` or `[ ] ` – A paragraph will be changed into a to-do list.
|
|
32
|
+
* - `[x] ` or `[ x ] ` – A paragraph will be changed into a checked to-do list.
|
|
33
|
+
*/
|
|
34
|
+
private _addListAutoformats;
|
|
35
|
+
/**
|
|
36
|
+
* Adds autoformatting related to the {@link module:basic-styles/bold~Bold},
|
|
37
|
+
* {@link module:basic-styles/italic~Italic}, {@link module:basic-styles/code~Code}
|
|
38
|
+
* and {@link module:basic-styles/strikethrough~Strikethrough}
|
|
39
|
+
*
|
|
40
|
+
* When typed:
|
|
41
|
+
* - `**foobar**` – `**` characters are removed and `foobar` is set to bold,
|
|
42
|
+
* - `__foobar__` – `__` characters are removed and `foobar` is set to bold,
|
|
43
|
+
* - `*foobar*` – `*` characters are removed and `foobar` is set to italic,
|
|
44
|
+
* - `_foobar_` – `_` characters are removed and `foobar` is set to italic,
|
|
45
|
+
* - ``` `foobar` – ``` ` ``` characters are removed and `foobar` is set to code,
|
|
46
|
+
* - `~~foobar~~` – `~~` characters are removed and `foobar` is set to strikethrough.
|
|
47
|
+
*/
|
|
48
|
+
private _addBasicStylesAutoformats;
|
|
49
|
+
/**
|
|
50
|
+
* Adds autoformatting related to {@link module:heading/heading~Heading}.
|
|
51
|
+
*
|
|
52
|
+
* It is using a number at the end of the command name to associate it with the proper trigger:
|
|
53
|
+
*
|
|
54
|
+
* * `heading` with a `heading1` value will be executed when typing `#`,
|
|
55
|
+
* * `heading` with a `heading2` value will be executed when typing `##`,
|
|
56
|
+
* * ... up to `heading6` for `######`.
|
|
57
|
+
*/
|
|
58
|
+
private _addHeadingAutoformats;
|
|
59
|
+
/**
|
|
60
|
+
* Adds autoformatting related to {@link module:block-quote/blockquote~BlockQuote}.
|
|
61
|
+
*
|
|
62
|
+
* When typed:
|
|
63
|
+
* * `> ` – A paragraph will be changed to a block quote.
|
|
64
|
+
*/
|
|
65
|
+
private _addBlockQuoteAutoformats;
|
|
66
|
+
/**
|
|
67
|
+
* Adds autoformatting related to {@link module:code-block/codeblock~CodeBlock}.
|
|
68
|
+
*
|
|
69
|
+
* When typed:
|
|
70
|
+
* - `` ``` `` – A paragraph will be changed to a code block.
|
|
71
|
+
*/
|
|
72
|
+
private _addCodeBlockAutoformats;
|
|
73
|
+
/**
|
|
74
|
+
* Adds autoformatting related to {@link module:horizontal-line/horizontalline~HorizontalLine}.
|
|
75
|
+
*
|
|
76
|
+
* When typed:
|
|
77
|
+
* - `` --- `` – Will be replaced with a horizontal line.
|
|
78
|
+
*/
|
|
79
|
+
private _addHorizontalLineAutoformats;
|
|
80
|
+
}
|
|
81
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
82
|
+
interface PluginsMap {
|
|
83
|
+
[Autoformat.pluginName]: Autoformat;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/autoformat.js
CHANGED
|
@@ -9,12 +9,12 @@ import inlineAutoformatEditing from './inlineautoformatediting';
|
|
|
9
9
|
/**
|
|
10
10
|
* Enables a set of predefined autoformatting actions.
|
|
11
11
|
*
|
|
12
|
-
* For a detailed overview, check the {@glink features/autoformat Autoformatting feature
|
|
12
|
+
* For a detailed overview, check the {@glink features/autoformat Autoformatting} feature guide
|
|
13
13
|
* and the {@glink api/autoformat package page}.
|
|
14
14
|
*/
|
|
15
15
|
export default class Autoformat extends Plugin {
|
|
16
16
|
/**
|
|
17
|
-
* @
|
|
17
|
+
* @inheritDoc
|
|
18
18
|
*/
|
|
19
19
|
static get requires() {
|
|
20
20
|
return [Delete];
|
|
@@ -40,10 +40,10 @@ export default class Autoformat extends Plugin {
|
|
|
40
40
|
* Adds autoformatting related to the {@link module:list/list~List}.
|
|
41
41
|
*
|
|
42
42
|
* When typed:
|
|
43
|
-
* - `* ` or `- ` – A paragraph will be changed
|
|
44
|
-
* - `1. ` or `1) ` – A paragraph will be changed
|
|
45
|
-
* - `[] ` or `[ ] ` – A paragraph will be changed
|
|
46
|
-
* - `[x] ` or `[ x ] ` – A paragraph will be changed
|
|
43
|
+
* - `* ` or `- ` – A paragraph will be changed into a bulleted list.
|
|
44
|
+
* - `1. ` or `1) ` – A paragraph will be changed into a numbered list ("1" can be any digit or a list of digits).
|
|
45
|
+
* - `[] ` or `[ ] ` – A paragraph will be changed into a to-do list.
|
|
46
|
+
* - `[x] ` or `[ x ] ` – A paragraph will be changed into a checked to-do list.
|
|
47
47
|
*/
|
|
48
48
|
_addListAutoformats() {
|
|
49
49
|
const commands = this.editor.commands;
|
|
@@ -104,9 +104,9 @@ export default class Autoformat extends Plugin {
|
|
|
104
104
|
*
|
|
105
105
|
* It is using a number at the end of the command name to associate it with the proper trigger:
|
|
106
106
|
*
|
|
107
|
-
* * `heading` with
|
|
108
|
-
* * `heading` with
|
|
109
|
-
* * ... up to `heading6`
|
|
107
|
+
* * `heading` with a `heading1` value will be executed when typing `#`,
|
|
108
|
+
* * `heading` with a `heading2` value will be executed when typing `##`,
|
|
109
|
+
* * ... up to `heading6` for `######`.
|
|
110
110
|
*/
|
|
111
111
|
_addHeadingAutoformats() {
|
|
112
112
|
const command = this.editor.commands.get('heading');
|
|
@@ -0,0 +1,57 @@
|
|
|
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 type { Editor } from 'ckeditor5/src/core';
|
|
6
|
+
import type Autoformat from './autoformat';
|
|
7
|
+
/**
|
|
8
|
+
* The block autoformatting engine. It allows to format various block patterns. For example,
|
|
9
|
+
* it can be configured to turn a paragraph starting with `*` and followed by a space into a list item.
|
|
10
|
+
*
|
|
11
|
+
* The autoformatting operation is integrated with the undo manager,
|
|
12
|
+
* so the autoformatting step can be undone if the user's intention was not to format the text.
|
|
13
|
+
*
|
|
14
|
+
* See the {@link module:autoformat/blockautoformatediting~blockAutoformatEditing `blockAutoformatEditing`} documentation
|
|
15
|
+
* to learn how to create custom block autoformatters. You can also use
|
|
16
|
+
* the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters
|
|
17
|
+
* (lists, headings, bold and italic).
|
|
18
|
+
*
|
|
19
|
+
* @module autoformat/blockautoformatediting
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Creates a listener triggered on {@link module:engine/model/document~Document#event:change:data `change:data`} event in the document.
|
|
23
|
+
* Calls the callback when inserted text matches the regular expression or the command name
|
|
24
|
+
* if provided instead of the callback.
|
|
25
|
+
*
|
|
26
|
+
* Examples of usage:
|
|
27
|
+
*
|
|
28
|
+
* To convert a paragraph into heading 1 when `- ` is typed, using just the command name:
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* blockAutoformatEditing( editor, plugin, /^\- $/, 'heading1' );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* To convert a paragraph into heading 1 when `- ` is typed, using just the callback:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* blockAutoformatEditing( editor, plugin, /^\- $/, ( context ) => {
|
|
38
|
+
* const { match } = context;
|
|
39
|
+
* const headingLevel = match[ 1 ].length;
|
|
40
|
+
*
|
|
41
|
+
* editor.execute( 'heading', {
|
|
42
|
+
* formatId: `heading${ headingLevel }`
|
|
43
|
+
* } );
|
|
44
|
+
* } );
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @param editor The editor instance.
|
|
48
|
+
* @param plugin The autoformat plugin instance.
|
|
49
|
+
* @param pattern The regular expression to execute on just inserted text. The regular expression is tested against the text
|
|
50
|
+
* from the beginning until the caret position.
|
|
51
|
+
* @param callbackOrCommand The callback to execute or the command to run when the text is matched.
|
|
52
|
+
* In case of providing the callback, it receives the following parameter:
|
|
53
|
+
* * match RegExp.exec() result of matching the pattern to inserted text.
|
|
54
|
+
*/
|
|
55
|
+
export default function blockAutoformatEditing(editor: Editor, plugin: Autoformat, pattern: RegExp, callbackOrCommand: string | ((context: {
|
|
56
|
+
match: RegExpExecArray;
|
|
57
|
+
}) => unknown)): void;
|
|
@@ -25,13 +25,13 @@ import { first } from 'ckeditor5/src/utils';
|
|
|
25
25
|
*
|
|
26
26
|
* Examples of usage:
|
|
27
27
|
*
|
|
28
|
-
* To convert a paragraph
|
|
28
|
+
* To convert a paragraph into heading 1 when `- ` is typed, using just the command name:
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
31
|
* blockAutoformatEditing( editor, plugin, /^\- $/, 'heading1' );
|
|
32
32
|
* ```
|
|
33
33
|
*
|
|
34
|
-
* To convert a paragraph
|
|
34
|
+
* To convert a paragraph into heading 1 when `- ` is typed, using just the callback:
|
|
35
35
|
*
|
|
36
36
|
* ```ts
|
|
37
37
|
* blockAutoformatEditing( editor, plugin, /^\- $/, ( context ) => {
|
|
@@ -50,7 +50,7 @@ import { first } from 'ckeditor5/src/utils';
|
|
|
50
50
|
* from the beginning until the caret position.
|
|
51
51
|
* @param callbackOrCommand The callback to execute or the command to run when the text is matched.
|
|
52
52
|
* In case of providing the callback, it receives the following parameter:
|
|
53
|
-
* *
|
|
53
|
+
* * match RegExp.exec() result of matching the pattern to inserted text.
|
|
54
54
|
*/
|
|
55
55
|
export default function blockAutoformatEditing(editor, plugin, pattern, callbackOrCommand) {
|
|
56
56
|
let callback;
|
|
@@ -93,8 +93,8 @@ export default function blockAutoformatEditing(editor, plugin, pattern, callback
|
|
|
93
93
|
!['numberedList', 'bulletedList', 'todoList'].includes(callbackOrCommand)) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
// In case a command is bound, do not re-execute it over an existing block style which would result
|
|
97
|
-
// Instead just drop processing so that autoformat trigger text is not lost. E.g. writing "# " in a level 1 heading.
|
|
96
|
+
// In case a command is bound, do not re-execute it over an existing block style which would result in a style removal.
|
|
97
|
+
// Instead, just drop processing so that autoformat trigger text is not lost. E.g. writing "# " in a level 1 heading.
|
|
98
98
|
if (command && command.value === true) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -129,7 +129,8 @@ export default function blockAutoformatEditing(editor, plugin, pattern, callback
|
|
|
129
129
|
}
|
|
130
130
|
range.detach();
|
|
131
131
|
editor.model.enqueueChange(() => {
|
|
132
|
-
editor.plugins.get('Delete')
|
|
132
|
+
const deletePlugin = editor.plugins.get('Delete');
|
|
133
|
+
deletePlugin.requestUndoOnBackspace();
|
|
133
134
|
});
|
|
134
135
|
});
|
|
135
136
|
});
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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 autoformat
|
|
7
|
+
*/
|
|
8
|
+
export { default as Autoformat } from './autoformat';
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
* The inline autoformatting engine. It allows to format various inline patterns. For example,
|
|
7
|
+
* it can be configured to make "foo" bold when typed `**foo**` (the `**` markers will be removed).
|
|
8
|
+
*
|
|
9
|
+
* The autoformatting operation is integrated with the undo manager,
|
|
10
|
+
* so the autoformatting step can be undone if the user's intention was not to format the text.
|
|
11
|
+
*
|
|
12
|
+
* See the {@link module:autoformat/inlineautoformatediting~inlineAutoformatEditing `inlineAutoformatEditing`} documentation
|
|
13
|
+
* to learn how to create custom inline autoformatters. You can also use
|
|
14
|
+
* the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters
|
|
15
|
+
* (lists, headings, bold and italic).
|
|
16
|
+
*
|
|
17
|
+
* @module autoformat/inlineautoformatediting
|
|
18
|
+
*/
|
|
19
|
+
import type { Editor } from 'ckeditor5/src/core';
|
|
20
|
+
import type { Range, Writer } from 'ckeditor5/src/engine';
|
|
21
|
+
import type Autoformat from './autoformat';
|
|
22
|
+
export type TestCallback = (text: string) => {
|
|
23
|
+
remove: Array<Array<number>>;
|
|
24
|
+
format: Array<Array<number>>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Enables autoformatting mechanism for a given {@link module:core/editor/editor~Editor}.
|
|
28
|
+
*
|
|
29
|
+
* It formats the matched text by applying the given model attribute or by running the provided formatting callback.
|
|
30
|
+
* On every {@link module:engine/model/document~Document#event:change:data data change} in the model document
|
|
31
|
+
* the autoformatting engine checks the text on the left of the selection
|
|
32
|
+
* and executes the provided action if the text matches given criteria (regular expression or callback).
|
|
33
|
+
*
|
|
34
|
+
* @param editor The editor instance.
|
|
35
|
+
* @param plugin The autoformat plugin instance.
|
|
36
|
+
* @param testRegexpOrCallback The regular expression or callback to execute on text.
|
|
37
|
+
* Provided regular expression *must* have three capture groups. The first and the third capture group
|
|
38
|
+
* should match opening and closing delimiters. The second capture group should match the text to format.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Matches the `**bold text**` pattern.
|
|
42
|
+
* // There are three capturing groups:
|
|
43
|
+
* // - The first to match the starting `**` delimiter.
|
|
44
|
+
* // - The second to match the text to format.
|
|
45
|
+
* // - The third to match the ending `**` delimiter.
|
|
46
|
+
* inlineAutoformatEditing( editor, plugin, /(\*\*)([^\*]+?)(\*\*)$/g, formatCallback );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* When a function is provided instead of the regular expression, it will be executed with the text to match as a parameter.
|
|
50
|
+
* The function should return proper "ranges" to delete and format.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* {
|
|
54
|
+
* remove: [
|
|
55
|
+
* [ 0, 1 ], // Remove the first letter from the given text.
|
|
56
|
+
* [ 5, 6 ] // Remove the 6th letter from the given text.
|
|
57
|
+
* ],
|
|
58
|
+
* format: [
|
|
59
|
+
* [ 1, 5 ] // Format all letters from 2nd to 5th.
|
|
60
|
+
* ]
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param formatCallback A callback to apply actual formatting.
|
|
65
|
+
* It should return `false` if changes should not be applied (e.g. if a command is disabled).
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* inlineAutoformatEditing( editor, plugin, /(\*\*)([^\*]+?)(\*\*)$/g, ( writer, rangesToFormat ) => {
|
|
69
|
+
* const command = editor.commands.get( 'bold' );
|
|
70
|
+
*
|
|
71
|
+
* if ( !command.isEnabled ) {
|
|
72
|
+
* return false;
|
|
73
|
+
* }
|
|
74
|
+
*
|
|
75
|
+
* const validRanges = editor.model.schema.getValidRanges( rangesToFormat, 'bold' );
|
|
76
|
+
*
|
|
77
|
+
* for ( let range of validRanges ) {
|
|
78
|
+
* writer.setAttribute( 'bold', true, range );
|
|
79
|
+
* }
|
|
80
|
+
* } );
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export default function inlineAutoformatEditing(editor: Editor, plugin: Autoformat, testRegexpOrCallback: RegExp | TestCallback, formatCallback: (writer: Writer, rangesToFormat: Array<Range>) => boolean | undefined): void;
|
|
@@ -138,7 +138,8 @@ export default function inlineAutoformatEditing(editor, plugin, testRegexpOrCall
|
|
|
138
138
|
writer.remove(range);
|
|
139
139
|
}
|
|
140
140
|
model.enqueueChange(() => {
|
|
141
|
-
editor.plugins.get('Delete')
|
|
141
|
+
const deletePlugin = editor.plugins.get('Delete');
|
|
142
|
+
deletePlugin.requestUndoOnBackspace();
|
|
142
143
|
});
|
|
143
144
|
});
|
|
144
145
|
});
|