@ckeditor/ckeditor5-typing 40.0.0 → 40.2.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/CHANGELOG.md +27 -27
- package/LICENSE.md +3 -3
- package/package.json +4 -4
- package/src/augmentation.d.ts +27 -27
- package/src/augmentation.js +5 -5
- package/src/delete.d.ts +32 -32
- package/src/delete.js +82 -82
- package/src/deletecommand.d.ts +83 -83
- package/src/deletecommand.js +201 -201
- package/src/deleteobserver.d.ts +55 -55
- package/src/deleteobserver.js +261 -261
- package/src/index.d.ts +24 -24
- package/src/index.js +18 -18
- package/src/input.d.ts +21 -21
- package/src/input.js +141 -141
- package/src/inserttextcommand.d.ts +76 -76
- package/src/inserttextcommand.js +83 -80
- package/src/inserttextobserver.d.ts +59 -59
- package/src/inserttextobserver.js +108 -108
- package/src/texttransformation.d.ts +33 -33
- package/src/texttransformation.js +228 -228
- package/src/textwatcher.d.ts +138 -138
- package/src/textwatcher.js +105 -105
- package/src/twostepcaretmovement.d.ts +232 -199
- package/src/twostepcaretmovement.js +622 -435
- package/src/typing.d.ts +23 -23
- package/src/typing.js +27 -27
- package/src/typingconfig.d.ts +204 -204
- package/src/typingconfig.js +5 -5
- package/src/utils/changebuffer.d.ts +103 -103
- package/src/utils/changebuffer.js +123 -123
- package/src/utils/findattributerange.d.ts +33 -33
- package/src/utils/findattributerange.js +41 -41
- package/src/utils/getlasttextline.d.ts +49 -49
- package/src/utils/getlasttextline.js +43 -43
- package/src/utils/inlinehighlight.d.ts +33 -33
- package/src/utils/inlinehighlight.js +74 -74
|
@@ -1,49 +1,49 @@
|
|
|
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 typing/utils/getlasttextline
|
|
7
|
-
*/
|
|
8
|
-
import type { Model, Range } from '@ckeditor/ckeditor5-engine';
|
|
9
|
-
/**
|
|
10
|
-
* Returns the last text line from the given range.
|
|
11
|
-
*
|
|
12
|
-
* "The last text line" is understood as text (from one or more text nodes) which is limited either by a parent block
|
|
13
|
-
* or by inline elements (e.g. `<softBreak>`).
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const rangeToCheck = model.createRange(
|
|
17
|
-
* model.createPositionAt( paragraph, 0 ),
|
|
18
|
-
* model.createPositionAt( paragraph, 'end' )
|
|
19
|
-
* );
|
|
20
|
-
*
|
|
21
|
-
* const { text, range } = getLastTextLine( rangeToCheck, model );
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* For model below, the returned `text` will be "Foo bar baz" and `range` will be set on whole `<paragraph>` content:
|
|
25
|
-
*
|
|
26
|
-
* ```xml
|
|
27
|
-
* <paragraph>Foo bar baz<paragraph>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* However, in below case, `text` will be set to "baz" and `range` will be set only on "baz".
|
|
31
|
-
*
|
|
32
|
-
* ```xml
|
|
33
|
-
* <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export default function getLastTextLine(range: Range, model: Model): LastTextLineData;
|
|
37
|
-
/**
|
|
38
|
-
* The value returned by {@link module:typing/utils/getlasttextline~getLastTextLine}.
|
|
39
|
-
*/
|
|
40
|
-
export type LastTextLineData = {
|
|
41
|
-
/**
|
|
42
|
-
* The text from the text nodes in the last text line.
|
|
43
|
-
*/
|
|
44
|
-
text: string;
|
|
45
|
-
/**
|
|
46
|
-
* The range set on the text nodes in the last text line.
|
|
47
|
-
*/
|
|
48
|
-
range: Range;
|
|
49
|
-
};
|
|
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 typing/utils/getlasttextline
|
|
7
|
+
*/
|
|
8
|
+
import type { Model, Range } from '@ckeditor/ckeditor5-engine';
|
|
9
|
+
/**
|
|
10
|
+
* Returns the last text line from the given range.
|
|
11
|
+
*
|
|
12
|
+
* "The last text line" is understood as text (from one or more text nodes) which is limited either by a parent block
|
|
13
|
+
* or by inline elements (e.g. `<softBreak>`).
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* const rangeToCheck = model.createRange(
|
|
17
|
+
* model.createPositionAt( paragraph, 0 ),
|
|
18
|
+
* model.createPositionAt( paragraph, 'end' )
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* const { text, range } = getLastTextLine( rangeToCheck, model );
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* For model below, the returned `text` will be "Foo bar baz" and `range` will be set on whole `<paragraph>` content:
|
|
25
|
+
*
|
|
26
|
+
* ```xml
|
|
27
|
+
* <paragraph>Foo bar baz<paragraph>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* However, in below case, `text` will be set to "baz" and `range` will be set only on "baz".
|
|
31
|
+
*
|
|
32
|
+
* ```xml
|
|
33
|
+
* <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export default function getLastTextLine(range: Range, model: Model): LastTextLineData;
|
|
37
|
+
/**
|
|
38
|
+
* The value returned by {@link module:typing/utils/getlasttextline~getLastTextLine}.
|
|
39
|
+
*/
|
|
40
|
+
export type LastTextLineData = {
|
|
41
|
+
/**
|
|
42
|
+
* The text from the text nodes in the last text line.
|
|
43
|
+
*/
|
|
44
|
+
text: string;
|
|
45
|
+
/**
|
|
46
|
+
* The range set on the text nodes in the last text line.
|
|
47
|
+
*/
|
|
48
|
+
range: Range;
|
|
49
|
+
};
|
|
@@ -1,43 +1,43 @@
|
|
|
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
|
-
* Returns the last text line from the given range.
|
|
7
|
-
*
|
|
8
|
-
* "The last text line" is understood as text (from one or more text nodes) which is limited either by a parent block
|
|
9
|
-
* or by inline elements (e.g. `<softBreak>`).
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* const rangeToCheck = model.createRange(
|
|
13
|
-
* model.createPositionAt( paragraph, 0 ),
|
|
14
|
-
* model.createPositionAt( paragraph, 'end' )
|
|
15
|
-
* );
|
|
16
|
-
*
|
|
17
|
-
* const { text, range } = getLastTextLine( rangeToCheck, model );
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* For model below, the returned `text` will be "Foo bar baz" and `range` will be set on whole `<paragraph>` content:
|
|
21
|
-
*
|
|
22
|
-
* ```xml
|
|
23
|
-
* <paragraph>Foo bar baz<paragraph>
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* However, in below case, `text` will be set to "baz" and `range` will be set only on "baz".
|
|
27
|
-
*
|
|
28
|
-
* ```xml
|
|
29
|
-
* <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export default function getLastTextLine(range, model) {
|
|
33
|
-
let start = range.start;
|
|
34
|
-
const text = Array.from(range.getWalker({ ignoreElementEnd: false })).reduce((rangeText, { item }) => {
|
|
35
|
-
// Trim text to a last occurrence of an inline element and update range start.
|
|
36
|
-
if (!(item.is('$text') || item.is('$textProxy'))) {
|
|
37
|
-
start = model.createPositionAfter(item);
|
|
38
|
-
return '';
|
|
39
|
-
}
|
|
40
|
-
return rangeText + item.data;
|
|
41
|
-
}, '');
|
|
42
|
-
return { text, range: model.createRange(start, range.end) };
|
|
43
|
-
}
|
|
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
|
+
* Returns the last text line from the given range.
|
|
7
|
+
*
|
|
8
|
+
* "The last text line" is understood as text (from one or more text nodes) which is limited either by a parent block
|
|
9
|
+
* or by inline elements (e.g. `<softBreak>`).
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const rangeToCheck = model.createRange(
|
|
13
|
+
* model.createPositionAt( paragraph, 0 ),
|
|
14
|
+
* model.createPositionAt( paragraph, 'end' )
|
|
15
|
+
* );
|
|
16
|
+
*
|
|
17
|
+
* const { text, range } = getLastTextLine( rangeToCheck, model );
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* For model below, the returned `text` will be "Foo bar baz" and `range` will be set on whole `<paragraph>` content:
|
|
21
|
+
*
|
|
22
|
+
* ```xml
|
|
23
|
+
* <paragraph>Foo bar baz<paragraph>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* However, in below case, `text` will be set to "baz" and `range` will be set only on "baz".
|
|
27
|
+
*
|
|
28
|
+
* ```xml
|
|
29
|
+
* <paragraph>Foo<softBreak></softBreak>bar<softBreak></softBreak>baz<paragraph>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export default function getLastTextLine(range, model) {
|
|
33
|
+
let start = range.start;
|
|
34
|
+
const text = Array.from(range.getWalker({ ignoreElementEnd: false })).reduce((rangeText, { item }) => {
|
|
35
|
+
// Trim text to a last occurrence of an inline element and update range start.
|
|
36
|
+
if (!(item.is('$text') || item.is('$textProxy'))) {
|
|
37
|
+
start = model.createPositionAfter(item);
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
return rangeText + item.data;
|
|
41
|
+
}, '');
|
|
42
|
+
return { text, range: model.createRange(start, range.end) };
|
|
43
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
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 '@ckeditor/ckeditor5-core';
|
|
6
|
-
/**
|
|
7
|
-
* Adds a visual highlight style to an attribute element in which the selection is anchored.
|
|
8
|
-
* Together with two-step caret movement, they indicate that the user is typing inside the element.
|
|
9
|
-
*
|
|
10
|
-
* Highlight is turned on by adding the given class to the attribute element in the view:
|
|
11
|
-
*
|
|
12
|
-
* * The class is removed before the conversion has started, as callbacks added with the `'highest'` priority
|
|
13
|
-
* to {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} events.
|
|
14
|
-
* * The class is added in the view post fixer, after other changes in the model tree were converted to the view.
|
|
15
|
-
*
|
|
16
|
-
* This way, adding and removing the highlight does not interfere with conversion.
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
22
|
-
*
|
|
23
|
-
* // Make `ck-link_selected` class be applied on an `a` element
|
|
24
|
-
* // whenever the corresponding `linkHref` attribute element is selected.
|
|
25
|
-
* inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @param editor The editor instance.
|
|
29
|
-
* @param attributeName The attribute name to check.
|
|
30
|
-
* @param tagName The tagName of a view item.
|
|
31
|
-
* @param className The class name to apply in the view.
|
|
32
|
-
*/
|
|
33
|
-
export default function inlineHighlight(editor: Editor, attributeName: string, tagName: string, className: string): void;
|
|
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 '@ckeditor/ckeditor5-core';
|
|
6
|
+
/**
|
|
7
|
+
* Adds a visual highlight style to an attribute element in which the selection is anchored.
|
|
8
|
+
* Together with two-step caret movement, they indicate that the user is typing inside the element.
|
|
9
|
+
*
|
|
10
|
+
* Highlight is turned on by adding the given class to the attribute element in the view:
|
|
11
|
+
*
|
|
12
|
+
* * The class is removed before the conversion has started, as callbacks added with the `'highest'` priority
|
|
13
|
+
* to {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} events.
|
|
14
|
+
* * The class is added in the view post fixer, after other changes in the model tree were converted to the view.
|
|
15
|
+
*
|
|
16
|
+
* This way, adding and removing the highlight does not interfere with conversion.
|
|
17
|
+
*
|
|
18
|
+
* Usage:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
22
|
+
*
|
|
23
|
+
* // Make `ck-link_selected` class be applied on an `a` element
|
|
24
|
+
* // whenever the corresponding `linkHref` attribute element is selected.
|
|
25
|
+
* inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param editor The editor instance.
|
|
29
|
+
* @param attributeName The attribute name to check.
|
|
30
|
+
* @param tagName The tagName of a view item.
|
|
31
|
+
* @param className The class name to apply in the view.
|
|
32
|
+
*/
|
|
33
|
+
export default function inlineHighlight(editor: Editor, attributeName: string, tagName: string, className: string): void;
|
|
@@ -1,74 +1,74 @@
|
|
|
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 typing/utils/inlinehighlight
|
|
7
|
-
*/
|
|
8
|
-
import findAttributeRange from './findattributerange';
|
|
9
|
-
/**
|
|
10
|
-
* Adds a visual highlight style to an attribute element in which the selection is anchored.
|
|
11
|
-
* Together with two-step caret movement, they indicate that the user is typing inside the element.
|
|
12
|
-
*
|
|
13
|
-
* Highlight is turned on by adding the given class to the attribute element in the view:
|
|
14
|
-
*
|
|
15
|
-
* * The class is removed before the conversion has started, as callbacks added with the `'highest'` priority
|
|
16
|
-
* to {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} events.
|
|
17
|
-
* * The class is added in the view post fixer, after other changes in the model tree were converted to the view.
|
|
18
|
-
*
|
|
19
|
-
* This way, adding and removing the highlight does not interfere with conversion.
|
|
20
|
-
*
|
|
21
|
-
* Usage:
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
25
|
-
*
|
|
26
|
-
* // Make `ck-link_selected` class be applied on an `a` element
|
|
27
|
-
* // whenever the corresponding `linkHref` attribute element is selected.
|
|
28
|
-
* inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param editor The editor instance.
|
|
32
|
-
* @param attributeName The attribute name to check.
|
|
33
|
-
* @param tagName The tagName of a view item.
|
|
34
|
-
* @param className The class name to apply in the view.
|
|
35
|
-
*/
|
|
36
|
-
export default function inlineHighlight(editor, attributeName, tagName, className) {
|
|
37
|
-
const view = editor.editing.view;
|
|
38
|
-
const highlightedElements = new Set();
|
|
39
|
-
// Adding the class.
|
|
40
|
-
view.document.registerPostFixer(writer => {
|
|
41
|
-
const selection = editor.model.document.selection;
|
|
42
|
-
let changed = false;
|
|
43
|
-
if (selection.hasAttribute(attributeName)) {
|
|
44
|
-
const modelRange = findAttributeRange(selection.getFirstPosition(), attributeName, selection.getAttribute(attributeName), editor.model);
|
|
45
|
-
const viewRange = editor.editing.mapper.toViewRange(modelRange);
|
|
46
|
-
// There might be multiple view elements in the `viewRange`, for example, when the `a` element is
|
|
47
|
-
// broken by a UIElement.
|
|
48
|
-
for (const item of viewRange.getItems()) {
|
|
49
|
-
if (item.is('element', tagName) && !item.hasClass(className)) {
|
|
50
|
-
writer.addClass(className, item);
|
|
51
|
-
highlightedElements.add(item);
|
|
52
|
-
changed = true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return changed;
|
|
57
|
-
});
|
|
58
|
-
// Removing the class.
|
|
59
|
-
editor.conversion.for('editingDowncast').add(dispatcher => {
|
|
60
|
-
// Make sure the highlight is removed on every possible event, before conversion is started.
|
|
61
|
-
dispatcher.on('insert', removeHighlight, { priority: 'highest' });
|
|
62
|
-
dispatcher.on('remove', removeHighlight, { priority: 'highest' });
|
|
63
|
-
dispatcher.on('attribute', removeHighlight, { priority: 'highest' });
|
|
64
|
-
dispatcher.on('selection', removeHighlight, { priority: 'highest' });
|
|
65
|
-
function removeHighlight() {
|
|
66
|
-
view.change(writer => {
|
|
67
|
-
for (const item of highlightedElements.values()) {
|
|
68
|
-
writer.removeClass(className, item);
|
|
69
|
-
highlightedElements.delete(item);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
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 typing/utils/inlinehighlight
|
|
7
|
+
*/
|
|
8
|
+
import findAttributeRange from './findattributerange';
|
|
9
|
+
/**
|
|
10
|
+
* Adds a visual highlight style to an attribute element in which the selection is anchored.
|
|
11
|
+
* Together with two-step caret movement, they indicate that the user is typing inside the element.
|
|
12
|
+
*
|
|
13
|
+
* Highlight is turned on by adding the given class to the attribute element in the view:
|
|
14
|
+
*
|
|
15
|
+
* * The class is removed before the conversion has started, as callbacks added with the `'highest'` priority
|
|
16
|
+
* to {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} events.
|
|
17
|
+
* * The class is added in the view post fixer, after other changes in the model tree were converted to the view.
|
|
18
|
+
*
|
|
19
|
+
* This way, adding and removing the highlight does not interfere with conversion.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import inlineHighlight from '@ckeditor/ckeditor5-typing/src/utils/inlinehighlight';
|
|
25
|
+
*
|
|
26
|
+
* // Make `ck-link_selected` class be applied on an `a` element
|
|
27
|
+
* // whenever the corresponding `linkHref` attribute element is selected.
|
|
28
|
+
* inlineHighlight( editor, 'linkHref', 'a', 'ck-link_selected' );
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param editor The editor instance.
|
|
32
|
+
* @param attributeName The attribute name to check.
|
|
33
|
+
* @param tagName The tagName of a view item.
|
|
34
|
+
* @param className The class name to apply in the view.
|
|
35
|
+
*/
|
|
36
|
+
export default function inlineHighlight(editor, attributeName, tagName, className) {
|
|
37
|
+
const view = editor.editing.view;
|
|
38
|
+
const highlightedElements = new Set();
|
|
39
|
+
// Adding the class.
|
|
40
|
+
view.document.registerPostFixer(writer => {
|
|
41
|
+
const selection = editor.model.document.selection;
|
|
42
|
+
let changed = false;
|
|
43
|
+
if (selection.hasAttribute(attributeName)) {
|
|
44
|
+
const modelRange = findAttributeRange(selection.getFirstPosition(), attributeName, selection.getAttribute(attributeName), editor.model);
|
|
45
|
+
const viewRange = editor.editing.mapper.toViewRange(modelRange);
|
|
46
|
+
// There might be multiple view elements in the `viewRange`, for example, when the `a` element is
|
|
47
|
+
// broken by a UIElement.
|
|
48
|
+
for (const item of viewRange.getItems()) {
|
|
49
|
+
if (item.is('element', tagName) && !item.hasClass(className)) {
|
|
50
|
+
writer.addClass(className, item);
|
|
51
|
+
highlightedElements.add(item);
|
|
52
|
+
changed = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return changed;
|
|
57
|
+
});
|
|
58
|
+
// Removing the class.
|
|
59
|
+
editor.conversion.for('editingDowncast').add(dispatcher => {
|
|
60
|
+
// Make sure the highlight is removed on every possible event, before conversion is started.
|
|
61
|
+
dispatcher.on('insert', removeHighlight, { priority: 'highest' });
|
|
62
|
+
dispatcher.on('remove', removeHighlight, { priority: 'highest' });
|
|
63
|
+
dispatcher.on('attribute', removeHighlight, { priority: 'highest' });
|
|
64
|
+
dispatcher.on('selection', removeHighlight, { priority: 'highest' });
|
|
65
|
+
function removeHighlight() {
|
|
66
|
+
view.change(writer => {
|
|
67
|
+
for (const item of highlightedElements.values()) {
|
|
68
|
+
writer.removeClass(className, item);
|
|
69
|
+
highlightedElements.delete(item);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|