/
highlight.js
193 lines (184 loc) · 5.55 KB
/
highlight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module highlight/highlight
*/
import { Plugin } from 'ckeditor5/src/core';
import HighlightEditing from './highlightediting';
import HighlightUI from './highlightui';
/**
* The highlight plugin.
*
* For a detailed overview, check the {@glink features/highlight Highlight feature} documentation.
*
* This is a "glue" plugin which loads the {@link module:highlight/highlightediting~HighlightEditing} and
* {@link module:highlight/highlightui~HighlightUI} plugins.
*
* @extends module:core/plugin~Plugin
*/
export default class Highlight extends Plugin {
/**
* @inheritDoc
*/
static get requires() {
return [ HighlightEditing, HighlightUI ];
}
/**
* @inheritDoc
*/
static get pluginName() {
return 'Highlight';
}
}
/**
* The highlight option descriptor. See {@link module:highlight/highlight~HighlightConfig} to learn more.
*
* {
* model: 'pinkMarker',
* class: 'marker-pink',
* title: 'Pink Marker',
* color: 'var(--ck-highlight-marker-pink)',
* type: 'marker'
* }
*
* @typedef {Object} module:highlight/highlight~HighlightOption
* @property {String} title The user-readable title of the option.
* @property {String} model The unique attribute value in the model.
* @property {String} color The CSS `var()` used for the highlighter. The color is used in the user interface to represent the highlighter.
* 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>`
* by adding CSS classes definition.
* @property {String} class The CSS class used on the `<mark>` element in the view. It should match the `color` setting.
* @property {'marker'|'pen'} type The type of highlighter:
*
* * `'marker'` – Uses the `color` as the `background-color` style,
* * `'pen'` – Uses the `color` as the font `color` style.
*/
/**
* The configuration of the {@link module:highlight/highlight~Highlight} feature.
*
* Read more in {@link module:highlight/highlight~HighlightConfig}.
*
* @member {module:highlight/highlight~HighlightConfig} module:core/editor/editorconfig~EditorConfig#highlight
*/
/**
* The configuration of the {@link module:highlight/highlight~Highlight highlight feature}.
*
* ClassicEditor
* .create( editorElement, {
* highlight: ... // Highlight feature configuration.
* } )
* .then( ... )
* .catch( ... );
*
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
*
* @interface HighlightConfig
*/
/**
* The available highlight options. The default value is:
*
* options: [
* {
* model: 'yellowMarker',
* class: 'marker-yellow',
* title: 'Yellow marker',
* color: 'var(--ck-highlight-marker-yellow)',
* type: 'marker'
* },
* {
* model: 'greenMarker',
* class: 'marker-green',
* title: 'Green marker',
* color: 'var(--ck-highlight-marker-green)',
* type: 'marker'
* },
* {
* model: 'pinkMarker',
* class: 'marker-pink',
* title: 'Pink marker',
* color: 'var(--ck-highlight-marker-pink)',
* type: 'marker'
* },
* {
* model: 'blueMarker',
* class: 'marker-blue',
* title: 'Blue marker',
* color: 'var(--ck-highlight-marker-blue)',
* type: 'marker'
* },
* {
* model: 'redPen',
* class: 'pen-red',
* title: 'Red pen',
* color: 'var(--ck-highlight-pen-red)',
* type: 'pen'
* },
* {
* model: 'greenPen',
* class: 'pen-green',
* title: 'Green pen',
* color: 'var(--ck-highlight-pen-green)',
* type: 'pen'
* }
* ]
*
* There are two types of highlighters available:
*
* * `'marker'` – Rendered as a `<mark>` element, styled with the `background-color`.
* * `'pen'` – Rendered as a `<mark>` element, styled with the font `color`.
*
* **Note**: The highlight feature provides a stylesheet with the CSS classes and corresponding colors defined
* as CSS variables.
*
* :root {
* --ck-highlight-marker-yellow: #fdfd77;
* --ck-highlight-marker-green: #63f963;
* --ck-highlight-marker-pink: #fc7999;
* --ck-highlight-marker-blue: #72cdfd;
* --ck-highlight-pen-red: #e91313;
* --ck-highlight-pen-green: #118800;
* }
*
* .marker-yellow { ... }
* .marker-green { ... }
* .marker-pink { ... }
* .marker-blue { ... }
* .pen-red { ... }
* .pen-green { ... }
*
* It is possible to define the `color` property directly as `rgba(R, G, B, A)`,
* `#RRGGBB[AA]` or `hsla(H, S, L, A)`. In such situation, the color will **only** apply to the UI of
* the editor and the `<mark>` elements in the content must be styled by custom classes provided by
* a dedicated stylesheet.
*
* **Note**: It is recommended for the `color` property to correspond to the class in the content
* stylesheet because it represents the highlighter in the user interface of the editor.
*
* ClassicEditor
* .create( editorElement, {
* highlight: {
* options: [
* {
* model: 'pinkMarker',
* class: 'marker-pink',
* title: 'Pink Marker',
* color: 'var(--ck-highlight-marker-pink)',
* type: 'marker'
* },
* {
* model: 'redPen',
* class: 'pen-red',
* title: 'Red Pen',
* color: 'var(--ck-highlight-pen-red)',
* type: 'pen'
* },
* ]
* }
* } )
* .then( ... )
* .catch( ... );
*
* @member {Array.<module:highlight/highlight~HighlightOption>} module:highlight/highlight~HighlightConfig#options
*/