@ckeditor/ckeditor5-highlight 38.0.1 → 38.1.1

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.
@@ -1,109 +1,109 @@
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/highlightediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import HighlightCommand from './highlightcommand';
10
- /**
11
- * The highlight editing feature. It introduces the {@link module:highlight/highlightcommand~HighlightCommand command} and the `highlight`
12
- * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
13
- * as a `<mark>` element with a `class` attribute (`<mark class="marker-green">...</mark>`) depending
14
- * on the {@link module:highlight/highlightconfig~HighlightConfig configuration}.
15
- */
16
- export default class HighlightEditing extends Plugin {
17
- /**
18
- * @inheritDoc
19
- */
20
- static get pluginName() {
21
- return 'HighlightEditing';
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- constructor(editor) {
27
- super(editor);
28
- editor.config.define('highlight', {
29
- options: [
30
- {
31
- model: 'yellowMarker',
32
- class: 'marker-yellow',
33
- title: 'Yellow marker',
34
- color: 'var(--ck-highlight-marker-yellow)',
35
- type: 'marker'
36
- },
37
- {
38
- model: 'greenMarker',
39
- class: 'marker-green',
40
- title: 'Green marker',
41
- color: 'var(--ck-highlight-marker-green)',
42
- type: 'marker'
43
- },
44
- {
45
- model: 'pinkMarker',
46
- class: 'marker-pink',
47
- title: 'Pink marker',
48
- color: 'var(--ck-highlight-marker-pink)',
49
- type: 'marker'
50
- },
51
- {
52
- model: 'blueMarker',
53
- class: 'marker-blue',
54
- title: 'Blue marker',
55
- color: 'var(--ck-highlight-marker-blue)',
56
- type: 'marker'
57
- },
58
- {
59
- model: 'redPen',
60
- class: 'pen-red',
61
- title: 'Red pen',
62
- color: 'var(--ck-highlight-pen-red)',
63
- type: 'pen'
64
- },
65
- {
66
- model: 'greenPen',
67
- class: 'pen-green',
68
- title: 'Green pen',
69
- color: 'var(--ck-highlight-pen-green)',
70
- type: 'pen'
71
- }
72
- ]
73
- });
74
- }
75
- /**
76
- * @inheritDoc
77
- */
78
- init() {
79
- const editor = this.editor;
80
- // Allow highlight attribute on text nodes.
81
- editor.model.schema.extend('$text', { allowAttributes: 'highlight' });
82
- const options = editor.config.get('highlight.options');
83
- // Set-up the two-way conversion.
84
- editor.conversion.attributeToElement(_buildDefinition(options));
85
- editor.commands.add('highlight', new HighlightCommand(editor));
86
- }
87
- }
88
- /**
89
- * Converts the options array to a converter definition.
90
- *
91
- * @param options An array with configured options.
92
- */
93
- function _buildDefinition(options) {
94
- const definition = {
95
- model: {
96
- key: 'highlight',
97
- values: []
98
- },
99
- view: {}
100
- };
101
- for (const option of options) {
102
- definition.model.values.push(option.model);
103
- definition.view[option.model] = {
104
- name: 'mark',
105
- classes: option.class
106
- };
107
- }
108
- return definition;
109
- }
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/highlightediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import HighlightCommand from './highlightcommand';
10
+ /**
11
+ * The highlight editing feature. It introduces the {@link module:highlight/highlightcommand~HighlightCommand command} and the `highlight`
12
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
13
+ * as a `<mark>` element with a `class` attribute (`<mark class="marker-green">...</mark>`) depending
14
+ * on the {@link module:highlight/highlightconfig~HighlightConfig configuration}.
15
+ */
16
+ export default class HighlightEditing extends Plugin {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get pluginName() {
21
+ return 'HighlightEditing';
22
+ }
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ constructor(editor) {
27
+ super(editor);
28
+ editor.config.define('highlight', {
29
+ options: [
30
+ {
31
+ model: 'yellowMarker',
32
+ class: 'marker-yellow',
33
+ title: 'Yellow marker',
34
+ color: 'var(--ck-highlight-marker-yellow)',
35
+ type: 'marker'
36
+ },
37
+ {
38
+ model: 'greenMarker',
39
+ class: 'marker-green',
40
+ title: 'Green marker',
41
+ color: 'var(--ck-highlight-marker-green)',
42
+ type: 'marker'
43
+ },
44
+ {
45
+ model: 'pinkMarker',
46
+ class: 'marker-pink',
47
+ title: 'Pink marker',
48
+ color: 'var(--ck-highlight-marker-pink)',
49
+ type: 'marker'
50
+ },
51
+ {
52
+ model: 'blueMarker',
53
+ class: 'marker-blue',
54
+ title: 'Blue marker',
55
+ color: 'var(--ck-highlight-marker-blue)',
56
+ type: 'marker'
57
+ },
58
+ {
59
+ model: 'redPen',
60
+ class: 'pen-red',
61
+ title: 'Red pen',
62
+ color: 'var(--ck-highlight-pen-red)',
63
+ type: 'pen'
64
+ },
65
+ {
66
+ model: 'greenPen',
67
+ class: 'pen-green',
68
+ title: 'Green pen',
69
+ color: 'var(--ck-highlight-pen-green)',
70
+ type: 'pen'
71
+ }
72
+ ]
73
+ });
74
+ }
75
+ /**
76
+ * @inheritDoc
77
+ */
78
+ init() {
79
+ const editor = this.editor;
80
+ // Allow highlight attribute on text nodes.
81
+ editor.model.schema.extend('$text', { allowAttributes: 'highlight' });
82
+ const options = editor.config.get('highlight.options');
83
+ // Set-up the two-way conversion.
84
+ editor.conversion.attributeToElement(_buildDefinition(options));
85
+ editor.commands.add('highlight', new HighlightCommand(editor));
86
+ }
87
+ }
88
+ /**
89
+ * Converts the options array to a converter definition.
90
+ *
91
+ * @param options An array with configured options.
92
+ */
93
+ function _buildDefinition(options) {
94
+ const definition = {
95
+ model: {
96
+ key: 'highlight',
97
+ values: []
98
+ },
99
+ view: {}
100
+ };
101
+ for (const option of options) {
102
+ definition.model.values.push(option.model);
103
+ definition.view[option.model] = {
104
+ name: 'mark',
105
+ classes: option.class
106
+ };
107
+ }
108
+ return definition;
109
+ }
@@ -1,73 +1,73 @@
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/highlightui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import './../theme/highlight.css';
10
- /**
11
- * The default highlight UI plugin. It introduces:
12
- *
13
- * * The `'highlight'` dropdown,
14
- * * The `'removeHighlight'` and `'highlight:*'` buttons.
15
- *
16
- * The default configuration includes the following buttons:
17
- *
18
- * * `'highlight:yellowMarker'`
19
- * * `'highlight:greenMarker'`
20
- * * `'highlight:pinkMarker'`
21
- * * `'highlight:blueMarker'`
22
- * * `'highlight:redPen'`
23
- * * `'highlight:greenPen'`
24
- *
25
- * See the {@link module:highlight/highlightconfig~HighlightConfig#options configuration} to learn more
26
- * about the defaults.
27
- */
28
- export default class HighlightUI extends Plugin {
29
- /**
30
- * Returns the localized option titles provided by the plugin.
31
- *
32
- * The following localized titles corresponding with default
33
- * {@link module:highlight/highlightconfig~HighlightConfig#options} are available:
34
- *
35
- * * `'Yellow marker'`,
36
- * * `'Green marker'`,
37
- * * `'Pink marker'`,
38
- * * `'Blue marker'`,
39
- * * `'Red pen'`,
40
- * * `'Green pen'`.
41
- */
42
- get localizedOptionTitles(): Record<string, string>;
43
- /**
44
- * @inheritDoc
45
- */
46
- static get pluginName(): 'HighlightUI';
47
- /**
48
- * @inheritDoc
49
- */
50
- init(): void;
51
- /**
52
- * Creates the "Remove highlight" button.
53
- */
54
- private _addRemoveHighlightButton;
55
- /**
56
- * Creates a toolbar button from the provided highlight option.
57
- */
58
- private _addHighlighterButton;
59
- /**
60
- * Internal method for creating highlight buttons.
61
- *
62
- * @param name The name of the button.
63
- * @param label The label for the button.
64
- * @param icon The button icon.
65
- * @param value The `value` property passed to the executed command.
66
- * @param decorateButton A callback getting ButtonView instance so that it can be further customized.
67
- */
68
- private _addButton;
69
- /**
70
- * Creates the split button dropdown UI from the provided highlight options.
71
- */
72
- private _addDropdown;
73
- }
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/highlightui
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import './../theme/highlight.css';
10
+ /**
11
+ * The default highlight UI plugin. It introduces:
12
+ *
13
+ * * The `'highlight'` dropdown,
14
+ * * The `'removeHighlight'` and `'highlight:*'` buttons.
15
+ *
16
+ * The default configuration includes the following buttons:
17
+ *
18
+ * * `'highlight:yellowMarker'`
19
+ * * `'highlight:greenMarker'`
20
+ * * `'highlight:pinkMarker'`
21
+ * * `'highlight:blueMarker'`
22
+ * * `'highlight:redPen'`
23
+ * * `'highlight:greenPen'`
24
+ *
25
+ * See the {@link module:highlight/highlightconfig~HighlightConfig#options configuration} to learn more
26
+ * about the defaults.
27
+ */
28
+ export default class HighlightUI extends Plugin {
29
+ /**
30
+ * Returns the localized option titles provided by the plugin.
31
+ *
32
+ * The following localized titles corresponding with default
33
+ * {@link module:highlight/highlightconfig~HighlightConfig#options} are available:
34
+ *
35
+ * * `'Yellow marker'`,
36
+ * * `'Green marker'`,
37
+ * * `'Pink marker'`,
38
+ * * `'Blue marker'`,
39
+ * * `'Red pen'`,
40
+ * * `'Green pen'`.
41
+ */
42
+ get localizedOptionTitles(): Record<string, string>;
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ static get pluginName(): "HighlightUI";
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ init(): void;
51
+ /**
52
+ * Creates the "Remove highlight" button.
53
+ */
54
+ private _addRemoveHighlightButton;
55
+ /**
56
+ * Creates a toolbar button from the provided highlight option.
57
+ */
58
+ private _addHighlighterButton;
59
+ /**
60
+ * Internal method for creating highlight buttons.
61
+ *
62
+ * @param name The name of the button.
63
+ * @param label The label for the button.
64
+ * @param icon The button icon.
65
+ * @param value The `value` property passed to the executed command.
66
+ * @param decorateButton A callback getting ButtonView instance so that it can be further customized.
67
+ */
68
+ private _addButton;
69
+ /**
70
+ * Creates the split button dropdown UI from the provided highlight options.
71
+ */
72
+ private _addDropdown;
73
+ }