@ckeditor/ckeditor5-highlight 36.0.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-highlight",
3
- "version": "36.0.1",
3
+ "version": "37.0.0-alpha.0",
4
4
  "description": "Highlight feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,22 +12,22 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "^36.0.1"
15
+ "ckeditor5": "^37.0.0-alpha.0"
16
16
  },
17
17
  "devDependencies": {
18
- "@ckeditor/ckeditor5-block-quote": "^36.0.1",
19
- "@ckeditor/ckeditor5-core": "^36.0.1",
20
- "@ckeditor/ckeditor5-dev-utils": "^32.0.0",
21
- "@ckeditor/ckeditor5-editor-classic": "^36.0.1",
22
- "@ckeditor/ckeditor5-engine": "^36.0.1",
23
- "@ckeditor/ckeditor5-enter": "^36.0.1",
24
- "@ckeditor/ckeditor5-heading": "^36.0.1",
25
- "@ckeditor/ckeditor5-image": "^36.0.1",
26
- "@ckeditor/ckeditor5-list": "^36.0.1",
27
- "@ckeditor/ckeditor5-paragraph": "^36.0.1",
28
- "@ckeditor/ckeditor5-theme-lark": "^36.0.1",
29
- "@ckeditor/ckeditor5-typing": "^36.0.1",
30
- "@ckeditor/ckeditor5-utils": "^36.0.1",
18
+ "@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.0",
19
+ "@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
20
+ "@ckeditor/ckeditor5-dev-utils": "^34.0.0",
21
+ "@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
22
+ "@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
23
+ "@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
24
+ "@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
25
+ "@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
26
+ "@ckeditor/ckeditor5-list": "^37.0.0-alpha.0",
27
+ "@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
28
+ "@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
29
+ "@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
30
+ "@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
31
31
  "typescript": "^4.8.4",
32
32
  "webpack": "^5.58.1",
33
33
  "webpack-cli": "^4.9.0"
@@ -58,5 +58,6 @@
58
58
  "dll:build": "webpack",
59
59
  "build": "tsc -p ./tsconfig.release.json",
60
60
  "postversion": "npm run build"
61
- }
61
+ },
62
+ "types": "src/index.d.ts"
62
63
  }
@@ -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 highlight/highlight
7
+ */
8
+ import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
9
+ /**
10
+ * The highlight plugin.
11
+ *
12
+ * For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
13
+ *
14
+ * This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
15
+ * {@link module:highlight/highlightui~HighlightUI} plugins.
16
+ */
17
+ export default class Highlight extends Plugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get requires(): PluginDependencies;
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get pluginName(): 'Highlight';
26
+ }
27
+ declare module '@ckeditor/ckeditor5-core' {
28
+ interface PluginsMap {
29
+ [Highlight.pluginName]: Highlight;
30
+ }
31
+ }
@@ -0,0 +1,50 @@
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
+ }
46
+ declare module '@ckeditor/ckeditor5-core' {
47
+ interface CommandsMap {
48
+ highlight: HighlightCommand;
49
+ }
50
+ }
@@ -0,0 +1,181 @@
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/highlightconfig
7
+ */
8
+ /**
9
+ * The highlight option descriptor. See {@link module:highlight/highlightconfig~HighlightConfig} to learn more.
10
+ *
11
+ * ```ts
12
+ * {
13
+ * model: 'pinkMarker',
14
+ * class: 'marker-pink',
15
+ * title: 'Pink Marker',
16
+ * color: 'var(--ck-highlight-marker-pink)',
17
+ * type: 'marker'
18
+ * }
19
+ * ```
20
+ */
21
+ export interface HighlightOption {
22
+ /**
23
+ * The user-readable title of the option.
24
+ */
25
+ title: string;
26
+ /**
27
+ * The unique attribute value in the model.
28
+ */
29
+ model: string;
30
+ /**
31
+ * The CSS `var()` used for the highlighter. The color is used in the user interface to represent the highlighter.
32
+ * There is a possibility to use the default color format like rgb, hex or hsl, but you need to care about the color of `<mark>`
33
+ * by adding CSS classes definition.
34
+ */
35
+ color: string;
36
+ /**
37
+ * The CSS class used on the `<mark>` element in the view. It should match the `color` setting.
38
+ */
39
+ class: string;
40
+ /**
41
+ * The type of highlighter:
42
+ *
43
+ * * `'marker'` &ndash; Uses the `color` as the `background-color` style,
44
+ * * `'pen'` &ndash; Uses the `color` as the font `color` style.
45
+ */
46
+ type: 'marker' | 'pen';
47
+ }
48
+ /**
49
+ * The configuration of the {@link module:highlight/highlight~Highlight highlight feature}.
50
+ * ```ts
51
+ * ClassicEditor
52
+ * .create( editorElement, {
53
+ * highlight: ... // Highlight feature configuration.
54
+ * } )
55
+ * .then( ... )
56
+ * .catch( ... );
57
+ * ```
58
+ * See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
59
+ */
60
+ export interface HighlightConfig {
61
+ /**
62
+ * The available highlight options. The default value is:
63
+ * ```ts
64
+ * options: [
65
+ * {
66
+ * model: 'yellowMarker',
67
+ * class: 'marker-yellow',
68
+ * title: 'Yellow marker',
69
+ * color: 'var(--ck-highlight-marker-yellow)',
70
+ * type: 'marker'
71
+ * },
72
+ * {
73
+ * model: 'greenMarker',
74
+ * class: 'marker-green',
75
+ * title: 'Green marker',
76
+ * color: 'var(--ck-highlight-marker-green)',
77
+ * type: 'marker'
78
+ * },
79
+ * {
80
+ * model: 'pinkMarker',
81
+ * class: 'marker-pink',
82
+ * title: 'Pink marker',
83
+ * color: 'var(--ck-highlight-marker-pink)',
84
+ * type: 'marker'
85
+ * },
86
+ * {
87
+ * model: 'blueMarker',
88
+ * class: 'marker-blue',
89
+ * title: 'Blue marker',
90
+ * color: 'var(--ck-highlight-marker-blue)',
91
+ * type: 'marker'
92
+ * },
93
+ * {
94
+ * model: 'redPen',
95
+ * class: 'pen-red',
96
+ * title: 'Red pen',
97
+ * color: 'var(--ck-highlight-pen-red)',
98
+ * type: 'pen'
99
+ * },
100
+ * {
101
+ * model: 'greenPen',
102
+ * class: 'pen-green',
103
+ * title: 'Green pen',
104
+ * color: 'var(--ck-highlight-pen-green)',
105
+ * type: 'pen'
106
+ * }
107
+ * ]
108
+ * ```
109
+ *
110
+ * There are two types of highlighters available:
111
+ *
112
+ * * `'marker'` &ndash; Rendered as a `<mark>` element, styled with the `background-color`.
113
+ * * `'pen'` &ndash; Rendered as a `<mark>` element, styled with the font `color`.
114
+ *
115
+ * **Note**: The highlight feature provides a stylesheet with the CSS classes and corresponding colors defined
116
+ * as CSS variables.
117
+ *
118
+ * ```css
119
+ * :root {
120
+ * --ck-highlight-marker-yellow: #fdfd77;
121
+ * --ck-highlight-marker-green: #63f963;
122
+ * --ck-highlight-marker-pink: #fc7999;
123
+ * --ck-highlight-marker-blue: #72cdfd;
124
+ * --ck-highlight-pen-red: #e91313;
125
+ * --ck-highlight-pen-green: #118800;
126
+ * }
127
+ *
128
+ * .marker-yellow { ... }
129
+ * .marker-green { ... }
130
+ * .marker-pink { ... }
131
+ * .marker-blue { ... }
132
+ * .pen-red { ... }
133
+ * .pen-green { ... }
134
+ * ```
135
+ *
136
+ * It is possible to define the `color` property directly as `rgba(R, G, B, A)`,
137
+ * `#RRGGBB[AA]` or `hsla(H, S, L, A)`. In such situation, the color will **only** apply to the UI of
138
+ * the editor and the `<mark>` elements in the content must be styled by custom classes provided by
139
+ * a dedicated stylesheet.
140
+ *
141
+ * **Note**: It is recommended for the `color` property to correspond to the class in the content
142
+ * stylesheet because it represents the highlighter in the user interface of the editor.
143
+ *
144
+ * ```ts
145
+ * ClassicEditor
146
+ * .create( editorElement, {
147
+ * highlight: {
148
+ * options: [
149
+ * {
150
+ * model: 'pinkMarker',
151
+ * class: 'marker-pink',
152
+ * title: 'Pink Marker',
153
+ * color: 'var(--ck-highlight-marker-pink)',
154
+ * type: 'marker'
155
+ * },
156
+ * {
157
+ * model: 'redPen',
158
+ * class: 'pen-red',
159
+ * title: 'Red Pen',
160
+ * color: 'var(--ck-highlight-pen-red)',
161
+ * type: 'pen'
162
+ * },
163
+ * ]
164
+ * }
165
+ * } )
166
+ * .then( ... )
167
+ * .catch( ... );
168
+ * ```
169
+ */
170
+ options: Array<HighlightOption>;
171
+ }
172
+ declare module '@ckeditor/ckeditor5-core' {
173
+ interface EditorConfig {
174
+ /**
175
+ * The configuration of the {@link module:highlight/highlight~Highlight} feature.
176
+ *
177
+ * Read more in {@link module:highlight/highlightconfig~HighlightConfig}.
178
+ */
179
+ highlight?: HighlightConfig;
180
+ }
181
+ }
@@ -0,0 +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 {};
@@ -0,0 +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
+ /**
6
+ * @module highlight/highlightediting
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
9
+ /**
10
+ * The highlight editing feature. It introduces the {@link module:highlight/highlightcommand~HighlightCommand command} and the `highlight`
11
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
12
+ * as a `<mark>` element with a `class` attribute (`<mark class="marker-green">...</mark>`) depending
13
+ * on the {@link module:highlight/highlightconfig~HighlightConfig configuration}.
14
+ */
15
+ export default class HighlightEditing extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): 'HighlightEditing';
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ constructor(editor: Editor);
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ init(): void;
28
+ }
29
+ declare module '@ckeditor/ckeditor5-core' {
30
+ interface PluginsMap {
31
+ [HighlightEditing.pluginName]: HighlightEditing;
32
+ }
33
+ }
@@ -11,7 +11,7 @@ import HighlightCommand from './highlightcommand';
11
11
  * The highlight editing feature. It introduces the {@link module:highlight/highlightcommand~HighlightCommand command} and the `highlight`
12
12
  * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
13
13
  * as a `<mark>` element with a `class` attribute (`<mark class="marker-green">...</mark>`) depending
14
- * on the {@link module:highlight/highlight~HighlightConfig configuration}.
14
+ * on the {@link module:highlight/highlightconfig~HighlightConfig configuration}.
15
15
  */
16
16
  export default class HighlightEditing extends Plugin {
17
17
  /**
@@ -0,0 +1,78 @@
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
+ }
74
+ declare module '@ckeditor/ckeditor5-core' {
75
+ interface PluginsMap {
76
+ [HighlightUI.pluginName]: HighlightUI;
77
+ }
78
+ }
@@ -25,7 +25,7 @@ import './../theme/highlight.css';
25
25
  * * `'highlight:redPen'`
26
26
  * * `'highlight:greenPen'`
27
27
  *
28
- * See the {@link module:highlight/highlight~HighlightConfig#options configuration} to learn more
28
+ * See the {@link module:highlight/highlightconfig~HighlightConfig#options configuration} to learn more
29
29
  * about the defaults.
30
30
  */
31
31
  export default class HighlightUI extends Plugin {
@@ -33,7 +33,7 @@ export default class HighlightUI extends Plugin {
33
33
  * Returns the localized option titles provided by the plugin.
34
34
  *
35
35
  * The following localized titles corresponding with default
36
- * {@link module:highlight/highlight~HighlightConfig#options} are available:
36
+ * {@link module:highlight/highlightconfig~HighlightConfig#options} are available:
37
37
  *
38
38
  * * `'Yellow marker'`,
39
39
  * * `'Green marker'`,
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 highlight
7
+ */
8
+ export { default as Highlight } from './highlight';
9
+ export { default as HighlightEditing } from './highlightediting';
10
+ export { default as HighlightUI } from './highlightui';