@ckeditor/ckeditor5-highlight 40.0.0 → 40.1.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/LICENSE.md +2 -2
- package/package.json +2 -2
- package/src/augmentation.d.ts +23 -23
- package/src/augmentation.js +5 -5
- package/src/highlight.d.ts +28 -28
- package/src/highlight.js +32 -32
- package/src/highlightcommand.d.ts +45 -45
- package/src/highlightcommand.js +91 -91
- package/src/highlightconfig.d.ts +171 -171
- package/src/highlightconfig.js +5 -5
- package/src/highlightediting.d.ts +28 -28
- package/src/highlightediting.js +109 -109
- package/src/highlightui.d.ts +73 -73
- package/src/highlightui.js +216 -216
- package/src/index.d.ts +13 -13
- package/src/index.js +11 -11
- package/build/highlight.js.map +0 -1
package/LICENSE.md
CHANGED
@@ -2,7 +2,7 @@ Software License Agreement
|
|
2
2
|
==========================
|
3
3
|
|
4
4
|
**CKEditor 5 highlight feature** – https://github.com/ckeditor/ckeditor5-highlight <br>
|
5
|
-
Copyright (c) 2003
|
5
|
+
Copyright (c) 2003–2023, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
6
6
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
8
8
|
|
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
14
14
|
Trademarks
|
15
15
|
----------
|
16
16
|
|
17
|
-
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
17
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks, or service marks of their respective holders.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-highlight",
|
3
|
-
"version": "40.
|
3
|
+
"version": "40.1.0",
|
4
4
|
"description": "Highlight feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
],
|
13
13
|
"main": "src/index.js",
|
14
14
|
"dependencies": {
|
15
|
-
"ckeditor5": "40.
|
15
|
+
"ckeditor5": "40.1.0"
|
16
16
|
},
|
17
17
|
"author": "CKSource (http://cksource.com/)",
|
18
18
|
"license": "GPL-2.0-or-later",
|
package/src/augmentation.d.ts
CHANGED
@@ -1,23 +1,23 @@
|
|
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 { Highlight, HighlightCommand, HighlightConfig, HighlightEditing, HighlightUI } from './index';
|
6
|
-
declare module '@ckeditor/ckeditor5-core' {
|
7
|
-
interface EditorConfig {
|
8
|
-
/**
|
9
|
-
* The configuration of the {@link module:highlight/highlight~Highlight} feature.
|
10
|
-
*
|
11
|
-
* Read more in {@link module:highlight/highlightconfig~HighlightConfig}.
|
12
|
-
*/
|
13
|
-
highlight?: HighlightConfig;
|
14
|
-
}
|
15
|
-
interface PluginsMap {
|
16
|
-
[Highlight.pluginName]: Highlight;
|
17
|
-
[HighlightEditing.pluginName]: HighlightEditing;
|
18
|
-
[HighlightUI.pluginName]: HighlightUI;
|
19
|
-
}
|
20
|
-
interface CommandsMap {
|
21
|
-
highlight: HighlightCommand;
|
22
|
-
}
|
23
|
-
}
|
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 { Highlight, HighlightCommand, HighlightConfig, HighlightEditing, HighlightUI } from './index';
|
6
|
+
declare module '@ckeditor/ckeditor5-core' {
|
7
|
+
interface EditorConfig {
|
8
|
+
/**
|
9
|
+
* The configuration of the {@link module:highlight/highlight~Highlight} feature.
|
10
|
+
*
|
11
|
+
* Read more in {@link module:highlight/highlightconfig~HighlightConfig}.
|
12
|
+
*/
|
13
|
+
highlight?: HighlightConfig;
|
14
|
+
}
|
15
|
+
interface PluginsMap {
|
16
|
+
[Highlight.pluginName]: Highlight;
|
17
|
+
[HighlightEditing.pluginName]: HighlightEditing;
|
18
|
+
[HighlightUI.pluginName]: HighlightUI;
|
19
|
+
}
|
20
|
+
interface CommandsMap {
|
21
|
+
highlight: HighlightCommand;
|
22
|
+
}
|
23
|
+
}
|
package/src/augmentation.js
CHANGED
@@ -1,5 +1,5 @@
|
|
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
|
-
export {};
|
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
|
+
export {};
|
package/src/highlight.d.ts
CHANGED
@@ -1,28 +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 highlight/highlight
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import HighlightEditing from './highlightediting';
|
10
|
-
import HighlightUI from './highlightui';
|
11
|
-
/**
|
12
|
-
* The highlight plugin.
|
13
|
-
*
|
14
|
-
* For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
|
15
|
-
*
|
16
|
-
* This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
|
17
|
-
* {@link module:highlight/highlightui~HighlightUI} plugins.
|
18
|
-
*/
|
19
|
-
export default class Highlight extends Plugin {
|
20
|
-
/**
|
21
|
-
* @inheritDoc
|
22
|
-
*/
|
23
|
-
static get requires(): readonly [typeof HighlightEditing, typeof HighlightUI];
|
24
|
-
/**
|
25
|
-
* @inheritDoc
|
26
|
-
*/
|
27
|
-
static get pluginName(): "Highlight";
|
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 highlight/highlight
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import HighlightEditing from './highlightediting';
|
10
|
+
import HighlightUI from './highlightui';
|
11
|
+
/**
|
12
|
+
* The highlight plugin.
|
13
|
+
*
|
14
|
+
* For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
|
15
|
+
*
|
16
|
+
* This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
|
17
|
+
* {@link module:highlight/highlightui~HighlightUI} plugins.
|
18
|
+
*/
|
19
|
+
export default class Highlight extends Plugin {
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
static get requires(): readonly [typeof HighlightEditing, typeof HighlightUI];
|
24
|
+
/**
|
25
|
+
* @inheritDoc
|
26
|
+
*/
|
27
|
+
static get pluginName(): "Highlight";
|
28
|
+
}
|
package/src/highlight.js
CHANGED
@@ -1,32 +1,32 @@
|
|
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 highlight/highlight
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import HighlightEditing from './highlightediting';
|
10
|
-
import HighlightUI from './highlightui';
|
11
|
-
/**
|
12
|
-
* The highlight plugin.
|
13
|
-
*
|
14
|
-
* For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
|
15
|
-
*
|
16
|
-
* This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
|
17
|
-
* {@link module:highlight/highlightui~HighlightUI} plugins.
|
18
|
-
*/
|
19
|
-
export default class Highlight extends Plugin {
|
20
|
-
/**
|
21
|
-
* @inheritDoc
|
22
|
-
*/
|
23
|
-
static get requires() {
|
24
|
-
return [HighlightEditing, HighlightUI];
|
25
|
-
}
|
26
|
-
/**
|
27
|
-
* @inheritDoc
|
28
|
-
*/
|
29
|
-
static get pluginName() {
|
30
|
-
return 'Highlight';
|
31
|
-
}
|
32
|
-
}
|
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 highlight/highlight
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import HighlightEditing from './highlightediting';
|
10
|
+
import HighlightUI from './highlightui';
|
11
|
+
/**
|
12
|
+
* The highlight plugin.
|
13
|
+
*
|
14
|
+
* For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
|
15
|
+
*
|
16
|
+
* This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
|
17
|
+
* {@link module:highlight/highlightui~HighlightUI} plugins.
|
18
|
+
*/
|
19
|
+
export default class Highlight extends Plugin {
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
static get requires() {
|
24
|
+
return [HighlightEditing, HighlightUI];
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get pluginName() {
|
30
|
+
return 'Highlight';
|
31
|
+
}
|
32
|
+
}
|
@@ -1,45 +1,45 @@
|
|
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 highlight/highlightcommand
|
7
|
-
*/
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
9
|
-
/**
|
10
|
-
* The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature}
|
11
|
-
* to apply the text highlighting.
|
12
|
-
*
|
13
|
-
* ```ts
|
14
|
-
* editor.execute( 'highlight', { value: 'greenMarker' } );
|
15
|
-
* ```
|
16
|
-
*
|
17
|
-
* **Note**: Executing the command without a value removes the attribute from the model. If the selection is collapsed
|
18
|
-
* inside a text with the highlight attribute, the command will remove the attribute from the entire range
|
19
|
-
* of that text.
|
20
|
-
*/
|
21
|
-
export default class HighlightCommand extends Command {
|
22
|
-
/**
|
23
|
-
* A value indicating whether the command is active. If the selection has some highlight attribute,
|
24
|
-
* it corresponds to the value of that attribute.
|
25
|
-
*
|
26
|
-
* @observable
|
27
|
-
* @readonly
|
28
|
-
*/
|
29
|
-
value: string | undefined;
|
30
|
-
/**
|
31
|
-
* @inheritDoc
|
32
|
-
*/
|
33
|
-
refresh(): void;
|
34
|
-
/**
|
35
|
-
* Executes the command.
|
36
|
-
*
|
37
|
-
* @param options Options for the executed command.
|
38
|
-
* @param options.value The value to apply.
|
39
|
-
*
|
40
|
-
* @fires execute
|
41
|
-
*/
|
42
|
-
execute(options?: {
|
43
|
-
value?: string | null;
|
44
|
-
}): void;
|
45
|
-
}
|
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 highlight/highlightcommand
|
7
|
+
*/
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
9
|
+
/**
|
10
|
+
* The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature}
|
11
|
+
* to apply the text highlighting.
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* editor.execute( 'highlight', { value: 'greenMarker' } );
|
15
|
+
* ```
|
16
|
+
*
|
17
|
+
* **Note**: Executing the command without a value removes the attribute from the model. If the selection is collapsed
|
18
|
+
* inside a text with the highlight attribute, the command will remove the attribute from the entire range
|
19
|
+
* of that text.
|
20
|
+
*/
|
21
|
+
export default class HighlightCommand extends Command {
|
22
|
+
/**
|
23
|
+
* A value indicating whether the command is active. If the selection has some highlight attribute,
|
24
|
+
* it corresponds to the value of that attribute.
|
25
|
+
*
|
26
|
+
* @observable
|
27
|
+
* @readonly
|
28
|
+
*/
|
29
|
+
value: string | undefined;
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
refresh(): void;
|
34
|
+
/**
|
35
|
+
* Executes the command.
|
36
|
+
*
|
37
|
+
* @param options Options for the executed command.
|
38
|
+
* @param options.value The value to apply.
|
39
|
+
*
|
40
|
+
* @fires execute
|
41
|
+
*/
|
42
|
+
execute(options?: {
|
43
|
+
value?: string | null;
|
44
|
+
}): void;
|
45
|
+
}
|
package/src/highlightcommand.js
CHANGED
@@ -1,91 +1,91 @@
|
|
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 highlight/highlightcommand
|
7
|
-
*/
|
8
|
-
import { Command } from 'ckeditor5/src/core';
|
9
|
-
/**
|
10
|
-
* The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature}
|
11
|
-
* to apply the text highlighting.
|
12
|
-
*
|
13
|
-
* ```ts
|
14
|
-
* editor.execute( 'highlight', { value: 'greenMarker' } );
|
15
|
-
* ```
|
16
|
-
*
|
17
|
-
* **Note**: Executing the command without a value removes the attribute from the model. If the selection is collapsed
|
18
|
-
* inside a text with the highlight attribute, the command will remove the attribute from the entire range
|
19
|
-
* of that text.
|
20
|
-
*/
|
21
|
-
export default class HighlightCommand extends Command {
|
22
|
-
/**
|
23
|
-
* @inheritDoc
|
24
|
-
*/
|
25
|
-
refresh() {
|
26
|
-
const model = this.editor.model;
|
27
|
-
const doc = model.document;
|
28
|
-
this.value = doc.selection.getAttribute('highlight');
|
29
|
-
this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, 'highlight');
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Executes the command.
|
33
|
-
*
|
34
|
-
* @param options Options for the executed command.
|
35
|
-
* @param options.value The value to apply.
|
36
|
-
*
|
37
|
-
* @fires execute
|
38
|
-
*/
|
39
|
-
execute(options = {}) {
|
40
|
-
const model = this.editor.model;
|
41
|
-
const document = model.document;
|
42
|
-
const selection = document.selection;
|
43
|
-
const highlighter = options.value;
|
44
|
-
model.change(writer => {
|
45
|
-
if (selection.isCollapsed) {
|
46
|
-
const position = selection.getFirstPosition();
|
47
|
-
// When selection is inside text with `highlight` attribute.
|
48
|
-
if (selection.hasAttribute('highlight')) {
|
49
|
-
// Find the full highlighted range.
|
50
|
-
const isSameHighlight = (value) => {
|
51
|
-
return value.item.hasAttribute('highlight') && value.item.getAttribute('highlight') === this.value;
|
52
|
-
};
|
53
|
-
const highlightStart = position.getLastMatchingPosition(isSameHighlight, { direction: 'backward' });
|
54
|
-
const highlightEnd = position.getLastMatchingPosition(isSameHighlight);
|
55
|
-
const highlightRange = writer.createRange(highlightStart, highlightEnd);
|
56
|
-
// Then depending on current value...
|
57
|
-
if (!highlighter || this.value === highlighter) {
|
58
|
-
// ...remove attribute when passing highlighter different then current or executing "eraser".
|
59
|
-
// If we're at the end of the highlighted range, we don't want to remove highlight of the range.
|
60
|
-
if (!position.isEqual(highlightEnd)) {
|
61
|
-
writer.removeAttribute('highlight', highlightRange);
|
62
|
-
}
|
63
|
-
writer.removeSelectionAttribute('highlight');
|
64
|
-
}
|
65
|
-
else {
|
66
|
-
// ...update `highlight` value.
|
67
|
-
// If we're at the end of the highlighted range, we don't want to change the highlight of the range.
|
68
|
-
if (!position.isEqual(highlightEnd)) {
|
69
|
-
writer.setAttribute('highlight', highlighter, highlightRange);
|
70
|
-
}
|
71
|
-
writer.setSelectionAttribute('highlight', highlighter);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
else if (highlighter) {
|
75
|
-
writer.setSelectionAttribute('highlight', highlighter);
|
76
|
-
}
|
77
|
-
}
|
78
|
-
else {
|
79
|
-
const ranges = model.schema.getValidRanges(selection.getRanges(), 'highlight');
|
80
|
-
for (const range of ranges) {
|
81
|
-
if (highlighter) {
|
82
|
-
writer.setAttribute('highlight', highlighter, range);
|
83
|
-
}
|
84
|
-
else {
|
85
|
-
writer.removeAttribute('highlight', range);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
});
|
90
|
-
}
|
91
|
-
}
|
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 highlight/highlightcommand
|
7
|
+
*/
|
8
|
+
import { Command } from 'ckeditor5/src/core';
|
9
|
+
/**
|
10
|
+
* The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature}
|
11
|
+
* to apply the text highlighting.
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* editor.execute( 'highlight', { value: 'greenMarker' } );
|
15
|
+
* ```
|
16
|
+
*
|
17
|
+
* **Note**: Executing the command without a value removes the attribute from the model. If the selection is collapsed
|
18
|
+
* inside a text with the highlight attribute, the command will remove the attribute from the entire range
|
19
|
+
* of that text.
|
20
|
+
*/
|
21
|
+
export default class HighlightCommand extends Command {
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
refresh() {
|
26
|
+
const model = this.editor.model;
|
27
|
+
const doc = model.document;
|
28
|
+
this.value = doc.selection.getAttribute('highlight');
|
29
|
+
this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, 'highlight');
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Executes the command.
|
33
|
+
*
|
34
|
+
* @param options Options for the executed command.
|
35
|
+
* @param options.value The value to apply.
|
36
|
+
*
|
37
|
+
* @fires execute
|
38
|
+
*/
|
39
|
+
execute(options = {}) {
|
40
|
+
const model = this.editor.model;
|
41
|
+
const document = model.document;
|
42
|
+
const selection = document.selection;
|
43
|
+
const highlighter = options.value;
|
44
|
+
model.change(writer => {
|
45
|
+
if (selection.isCollapsed) {
|
46
|
+
const position = selection.getFirstPosition();
|
47
|
+
// When selection is inside text with `highlight` attribute.
|
48
|
+
if (selection.hasAttribute('highlight')) {
|
49
|
+
// Find the full highlighted range.
|
50
|
+
const isSameHighlight = (value) => {
|
51
|
+
return value.item.hasAttribute('highlight') && value.item.getAttribute('highlight') === this.value;
|
52
|
+
};
|
53
|
+
const highlightStart = position.getLastMatchingPosition(isSameHighlight, { direction: 'backward' });
|
54
|
+
const highlightEnd = position.getLastMatchingPosition(isSameHighlight);
|
55
|
+
const highlightRange = writer.createRange(highlightStart, highlightEnd);
|
56
|
+
// Then depending on current value...
|
57
|
+
if (!highlighter || this.value === highlighter) {
|
58
|
+
// ...remove attribute when passing highlighter different then current or executing "eraser".
|
59
|
+
// If we're at the end of the highlighted range, we don't want to remove highlight of the range.
|
60
|
+
if (!position.isEqual(highlightEnd)) {
|
61
|
+
writer.removeAttribute('highlight', highlightRange);
|
62
|
+
}
|
63
|
+
writer.removeSelectionAttribute('highlight');
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
// ...update `highlight` value.
|
67
|
+
// If we're at the end of the highlighted range, we don't want to change the highlight of the range.
|
68
|
+
if (!position.isEqual(highlightEnd)) {
|
69
|
+
writer.setAttribute('highlight', highlighter, highlightRange);
|
70
|
+
}
|
71
|
+
writer.setSelectionAttribute('highlight', highlighter);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
else if (highlighter) {
|
75
|
+
writer.setSelectionAttribute('highlight', highlighter);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
const ranges = model.schema.getValidRanges(selection.getRanges(), 'highlight');
|
80
|
+
for (const range of ranges) {
|
81
|
+
if (highlighter) {
|
82
|
+
writer.setAttribute('highlight', highlighter, range);
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
writer.removeAttribute('highlight', range);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}
|