@ckeditor/ckeditor5-font 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/build/font.js +1 -1
- package/package.json +20 -15
- package/src/documentcolorcollection.d.ts +47 -0
- package/src/documentcolorcollection.js +34 -63
- package/src/font.d.ts +34 -0
- package/src/font.js +12 -19
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +32 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +9 -15
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +31 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +102 -115
- package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +27 -0
- package/src/fontbackgroundcolor/fontbackgroundcolorui.js +18 -25
- package/src/fontbackgroundcolor.d.ts +33 -0
- package/src/fontbackgroundcolor.js +12 -165
- package/src/fontcolor/fontcolorcommand.d.ts +31 -0
- package/src/fontcolor/fontcolorcommand.js +9 -15
- package/src/fontcolor/fontcolorediting.d.ts +31 -0
- package/src/fontcolor/fontcolorediting.js +115 -128
- package/src/fontcolor/fontcolorui.d.ts +27 -0
- package/src/fontcolor/fontcolorui.js +18 -25
- package/src/fontcolor.d.ts +29 -0
- package/src/fontcolor.js +12 -168
- package/src/fontcommand.d.ts +46 -0
- package/src/fontcommand.js +54 -78
- package/src/fontconfig.d.ts +399 -0
- package/src/fontconfig.js +5 -0
- package/src/fontfamily/fontfamilycommand.d.ts +31 -0
- package/src/fontfamily/fontfamilycommand.js +9 -15
- package/src/fontfamily/fontfamilyediting.d.ts +45 -0
- package/src/fontfamily/fontfamilyediting.js +96 -116
- package/src/fontfamily/fontfamilyui.d.ts +35 -0
- package/src/fontfamily/fontfamilyui.js +90 -122
- package/src/fontfamily/utils.d.ts +15 -0
- package/src/fontfamily/utils.js +66 -79
- package/src/fontfamily.d.ts +29 -0
- package/src/fontfamily.js +12 -112
- package/src/fontsize/fontsizecommand.d.ts +31 -0
- package/src/fontsize/fontsizecommand.js +9 -15
- package/src/fontsize/fontsizeediting.d.ts +50 -0
- package/src/fontsize/fontsizeediting.js +138 -169
- package/src/fontsize/fontsizeui.d.ts +36 -0
- package/src/fontsize/fontsizeui.js +98 -130
- package/src/fontsize/utils.d.ts +12 -0
- package/src/fontsize/utils.js +145 -174
- package/src/fontsize.d.ts +40 -0
- package/src/fontsize.js +21 -141
- package/src/index.d.ts +20 -0
- package/src/index.js +0 -2
- package/src/ui/colortableview.d.ts +167 -0
- package/src/ui/colortableview.js +240 -416
- package/src/ui/colorui.d.ts +64 -0
- package/src/ui/colorui.js +79 -132
- package/src/utils.d.ts +77 -0
- package/src/utils.js +42 -72
package/src/fontsize/utils.js
CHANGED
|
@@ -2,194 +2,165 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module font/fontsize/utils
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { CKEditorError } from 'ckeditor5/src/utils';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
|
-
* Normalizes and translates the {@link module:font/
|
|
14
|
-
* to the {@link module:font/
|
|
10
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
11
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
15
12
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns {Array.<module:font/fontsize~FontSizeOption>}
|
|
13
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
18
14
|
*/
|
|
19
|
-
export function normalizeOptions(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
export function normalizeOptions(configuredOptions) {
|
|
16
|
+
// Convert options to objects.
|
|
17
|
+
return configuredOptions
|
|
18
|
+
.map(item => getOptionDefinition(item))
|
|
19
|
+
// Filter out undefined values that `getOptionDefinition` might return.
|
|
20
|
+
.filter((option) => option !== undefined);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
// Default named presets map. Always create a new instance of the preset object in order to avoid modifying references.
|
|
28
23
|
const namedPresets = {
|
|
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
|
-
|
|
24
|
+
get tiny() {
|
|
25
|
+
return {
|
|
26
|
+
title: 'Tiny',
|
|
27
|
+
model: 'tiny',
|
|
28
|
+
view: {
|
|
29
|
+
name: 'span',
|
|
30
|
+
classes: 'text-tiny',
|
|
31
|
+
priority: 7
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
get small() {
|
|
36
|
+
return {
|
|
37
|
+
title: 'Small',
|
|
38
|
+
model: 'small',
|
|
39
|
+
view: {
|
|
40
|
+
name: 'span',
|
|
41
|
+
classes: 'text-small',
|
|
42
|
+
priority: 7
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
get big() {
|
|
47
|
+
return {
|
|
48
|
+
title: 'Big',
|
|
49
|
+
model: 'big',
|
|
50
|
+
view: {
|
|
51
|
+
name: 'span',
|
|
52
|
+
classes: 'text-big',
|
|
53
|
+
priority: 7
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
get huge() {
|
|
58
|
+
return {
|
|
59
|
+
title: 'Huge',
|
|
60
|
+
model: 'huge',
|
|
61
|
+
view: {
|
|
62
|
+
name: 'span',
|
|
63
|
+
classes: 'text-huge',
|
|
64
|
+
priority: 7
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
73
68
|
};
|
|
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
|
-
// Return font size definition from size value.
|
|
108
|
-
return generatePixelPreset( option );
|
|
69
|
+
/**
|
|
70
|
+
* Returns an option definition either from preset or creates one from number shortcut.
|
|
71
|
+
* If object is passed then this method will return it without alternating it. Returns undefined for item than cannot be parsed.
|
|
72
|
+
*/
|
|
73
|
+
function getOptionDefinition(option) {
|
|
74
|
+
if (typeof option === 'number') {
|
|
75
|
+
option = String(option);
|
|
76
|
+
}
|
|
77
|
+
// Check whether passed option is a full item definition provided by user in configuration.
|
|
78
|
+
if (typeof option === 'object' && isFullItemDefinition(option)) {
|
|
79
|
+
return attachPriority(option);
|
|
80
|
+
}
|
|
81
|
+
const preset = findPreset(option);
|
|
82
|
+
// Item is a named preset.
|
|
83
|
+
if (preset) {
|
|
84
|
+
return attachPriority(preset);
|
|
85
|
+
}
|
|
86
|
+
// 'Default' font size. It will be used to remove the fontSize attribute.
|
|
87
|
+
if (option === 'default') {
|
|
88
|
+
return {
|
|
89
|
+
model: undefined,
|
|
90
|
+
title: 'Default'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// At this stage we probably have numerical value to generate a preset so parse it's value.
|
|
94
|
+
// Discard any faulty values.
|
|
95
|
+
if (isNumericalDefinition(option)) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
// Return font size definition from size value.
|
|
99
|
+
return generatePixelPreset(option);
|
|
109
100
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
function generatePixelPreset(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return attachPriority( definition );
|
|
101
|
+
/**
|
|
102
|
+
* Creates a predefined preset for pixel size.
|
|
103
|
+
* @param definition Font size in pixels.
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
function generatePixelPreset(definition) {
|
|
107
|
+
// Extend a short (numeric value) definition.
|
|
108
|
+
if (typeof definition === 'string') {
|
|
109
|
+
definition = {
|
|
110
|
+
title: definition,
|
|
111
|
+
model: `${parseFloat(definition)}px`
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
definition.view = {
|
|
115
|
+
name: 'span',
|
|
116
|
+
styles: {
|
|
117
|
+
'font-size': definition.model
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return attachPriority(definition);
|
|
132
121
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
function attachPriority( definition ) {
|
|
142
|
-
if ( !definition.view.priority ) {
|
|
143
|
-
definition.view.priority = 7;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return definition;
|
|
122
|
+
/**
|
|
123
|
+
* Adds the priority to the view element definition if missing. It's required due to ckeditor/ckeditor5#2291
|
|
124
|
+
*/
|
|
125
|
+
function attachPriority(definition) {
|
|
126
|
+
if (definition.view && typeof definition.view !== 'string' && !definition.view.priority) {
|
|
127
|
+
definition.view.priority = 7;
|
|
128
|
+
}
|
|
129
|
+
return definition;
|
|
147
130
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return namedPresets[ definition ] || namedPresets[ definition.model ];
|
|
131
|
+
/**
|
|
132
|
+
* Returns a prepared preset definition. If passed an object, a name of preset should be defined as `model` value.
|
|
133
|
+
*
|
|
134
|
+
* @param definition.model A preset name.
|
|
135
|
+
*/
|
|
136
|
+
function findPreset(definition) {
|
|
137
|
+
return typeof definition === 'string' ? namedPresets[definition] : namedPresets[definition.model];
|
|
156
138
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
// @param {String} definition.model
|
|
163
|
-
// @param {Object} definition.view
|
|
164
|
-
// @returns {Boolean}
|
|
165
|
-
function isFullItemDefinition( definition ) {
|
|
166
|
-
return typeof definition === 'object' && definition.title && definition.model && definition.view;
|
|
139
|
+
/**
|
|
140
|
+
* We treat `definition` as completed if it is an object that contains `title`, `model` and `view` values.
|
|
141
|
+
*/
|
|
142
|
+
function isFullItemDefinition(definition) {
|
|
143
|
+
return definition.title && definition.model && definition.view;
|
|
167
144
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
numberValue = parseFloat( definition );
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return isNaN( numberValue );
|
|
145
|
+
function isNumericalDefinition(definition) {
|
|
146
|
+
let numberValue;
|
|
147
|
+
if (typeof definition === 'object') {
|
|
148
|
+
if (!definition.model) {
|
|
149
|
+
/**
|
|
150
|
+
* Provided value as an option for {@link module:font/fontsize~FontSize} seems to invalid.
|
|
151
|
+
*
|
|
152
|
+
* See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
|
|
153
|
+
*
|
|
154
|
+
* @error font-size-invalid-definition
|
|
155
|
+
*/
|
|
156
|
+
throw new CKEditorError('font-size-invalid-definition', null, definition);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
numberValue = parseFloat(definition.model);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
numberValue = parseFloat(definition);
|
|
164
|
+
}
|
|
165
|
+
return isNaN(numberValue);
|
|
195
166
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 font/fontsize
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type PluginDependencies } from 'ckeditor5/src/core';
|
|
9
|
+
import type { FontSizeOption } from './fontconfig';
|
|
10
|
+
/**
|
|
11
|
+
* The font size plugin.
|
|
12
|
+
*
|
|
13
|
+
* For a detailed overview, check the {@glink features/font font feature} documentation
|
|
14
|
+
* and the {@glink api/font package page}.
|
|
15
|
+
*
|
|
16
|
+
* This is a "glue" plugin which loads the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} and
|
|
17
|
+
* {@link module:font/fontsize/fontsizeui~FontSizeUI} features in the editor.
|
|
18
|
+
*/
|
|
19
|
+
export default class FontSize extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get requires(): PluginDependencies;
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
static get pluginName(): 'FontSize';
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
30
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
31
|
+
*
|
|
32
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
33
|
+
*/
|
|
34
|
+
normalizeSizeOptions(options: Array<string | number | FontSizeOption>): Array<FontSizeOption>;
|
|
35
|
+
}
|
|
36
|
+
declare module '@ckeditor/ckeditor5-core' {
|
|
37
|
+
interface PluginsMap {
|
|
38
|
+
[FontSize.pluginName]: FontSize;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/fontsize.js
CHANGED
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module font/fontsize
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
11
9
|
import FontSizeEditing from './fontsize/fontsizeediting';
|
|
12
10
|
import FontSizeUI from './fontsize/fontsizeui';
|
|
13
11
|
import { normalizeOptions } from './fontsize/utils';
|
|
14
|
-
|
|
15
12
|
/**
|
|
16
13
|
* The font size plugin.
|
|
17
14
|
*
|
|
@@ -20,144 +17,27 @@ import { normalizeOptions } from './fontsize/utils';
|
|
|
20
17
|
*
|
|
21
18
|
* This is a "glue" plugin which loads the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} and
|
|
22
19
|
* {@link module:font/fontsize/fontsizeui~FontSizeUI} features in the editor.
|
|
23
|
-
*
|
|
24
|
-
* @extends module:core/plugin~Plugin
|
|
25
20
|
*/
|
|
26
21
|
export default class FontSize extends Plugin {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
normalizeSizeOptions( options ) {
|
|
49
|
-
return normalizeOptions( options );
|
|
50
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get requires() {
|
|
26
|
+
return [FontSizeEditing, FontSizeUI];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @inheritDoc
|
|
30
|
+
*/
|
|
31
|
+
static get pluginName() {
|
|
32
|
+
return 'FontSize';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
|
|
36
|
+
* to the {@link module:font/fontconfig~FontSizeOption} format.
|
|
37
|
+
*
|
|
38
|
+
* @param configuredOptions An array of options taken from the configuration.
|
|
39
|
+
*/
|
|
40
|
+
normalizeSizeOptions(options) {
|
|
41
|
+
return normalizeOptions(options);
|
|
42
|
+
}
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* The font size option descriptor.
|
|
55
|
-
*
|
|
56
|
-
* @typedef {Object} module:font/fontsize~FontSizeOption
|
|
57
|
-
*
|
|
58
|
-
* @property {String} title The user-readable title of the option.
|
|
59
|
-
* @property {String} model The attribute's unique value in the model.
|
|
60
|
-
* @property {module:engine/view/elementdefinition~ElementDefinition} view View element configuration.
|
|
61
|
-
* @property {Array.<module:engine/view/elementdefinition~ElementDefinition>} [upcastAlso] An array with all matched elements that
|
|
62
|
-
* the view-to-model conversion should also accept.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The configuration of the font size feature.
|
|
67
|
-
* It is introduced by the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} feature.
|
|
68
|
-
*
|
|
69
|
-
* Read more in {@link module:font/fontsize~FontSizeConfig}.
|
|
70
|
-
*
|
|
71
|
-
* @member {module:font/fontsize~FontSizeConfig} module:core/editor/editorconfig~EditorConfig#fontSize
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The configuration of the font size feature.
|
|
76
|
-
* This option is used by the {@link module:font/fontsize/fontsizeediting~FontSizeEditing} feature.
|
|
77
|
-
*
|
|
78
|
-
* ClassicEditor
|
|
79
|
-
* .create( {
|
|
80
|
-
* fontSize: ... // Font size feature configuration.
|
|
81
|
-
* } )
|
|
82
|
-
* .then( ... )
|
|
83
|
-
* .catch( ... );
|
|
84
|
-
*
|
|
85
|
-
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
|
86
|
-
*
|
|
87
|
-
* @interface module:font/fontsize~FontSizeConfig
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Available font size options. Expressed as predefined presets, numerical "pixel" values
|
|
92
|
-
* or the {@link module:font/fontsize~FontSizeOption}.
|
|
93
|
-
*
|
|
94
|
-
* The default value is:
|
|
95
|
-
*
|
|
96
|
-
* const fontSizeConfig = {
|
|
97
|
-
* options: [
|
|
98
|
-
* 'tiny',
|
|
99
|
-
* 'small',
|
|
100
|
-
* 'default',
|
|
101
|
-
* 'big',
|
|
102
|
-
* 'huge'
|
|
103
|
-
* ]
|
|
104
|
-
* };
|
|
105
|
-
*
|
|
106
|
-
* It defines 4 sizes: **tiny**, **small**, **big**, and **huge**. These values will be rendered as `<span>` elements in the view.
|
|
107
|
-
* The **default** defines a text without the `fontSize` attribute.
|
|
108
|
-
*
|
|
109
|
-
* Each `<span>` has the the `class` attribute set to the corresponding size name. For instance, this is what the **small** size looks
|
|
110
|
-
* like in the view:
|
|
111
|
-
*
|
|
112
|
-
* <span class="text-small">...</span>
|
|
113
|
-
*
|
|
114
|
-
* As an alternative, the font size might be defined using numerical values (either as a `Number` or as a `String`):
|
|
115
|
-
*
|
|
116
|
-
* const fontSizeConfig = {
|
|
117
|
-
* options: [ 9, 10, 11, 12, 13, 14, 15 ]
|
|
118
|
-
* };
|
|
119
|
-
*
|
|
120
|
-
* Also, you can define a label in the dropdown for numerical values:
|
|
121
|
-
*
|
|
122
|
-
* const fontSizeConfig = {
|
|
123
|
-
* options: [
|
|
124
|
-
* {
|
|
125
|
-
* title: 'Small',
|
|
126
|
-
* model: '8px'
|
|
127
|
-
* },
|
|
128
|
-
* 'default',
|
|
129
|
-
* {
|
|
130
|
-
* title: 'Big',
|
|
131
|
-
* model: '14px'
|
|
132
|
-
* }
|
|
133
|
-
* ]
|
|
134
|
-
* };
|
|
135
|
-
*
|
|
136
|
-
* Font size can be applied using the command API. To do that, use the `'fontSize'` command and pass the desired font size as a `value`.
|
|
137
|
-
* For example, the following code will apply the `fontSize` attribute with the **tiny** value to the current selection:
|
|
138
|
-
*
|
|
139
|
-
* editor.execute( 'fontSize', { value: 'tiny' } );
|
|
140
|
-
*
|
|
141
|
-
* Executing the `fontSize` command without value will remove the `fontSize` attribute from the current selection.
|
|
142
|
-
*
|
|
143
|
-
* @member {Array.<String|Number|module:font/fontsize~FontSizeOption>} module:font/fontsize~FontSizeConfig#options
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* By default the plugin removes any `font-size` value that does not match the plugin's configuration. It means that if you paste content
|
|
148
|
-
* with font sizes that the editor does not understand, the `font-size` attribute will be removed and the content will be displayed
|
|
149
|
-
* with the default size.
|
|
150
|
-
*
|
|
151
|
-
* You can preserve pasted font size values by switching the `supportAllValues` option to `true`:
|
|
152
|
-
*
|
|
153
|
-
* const fontSizeConfig = {
|
|
154
|
-
* options: [ 9, 10, 11, 12, 'default', 14, 15 ],
|
|
155
|
-
* supportAllValues: true
|
|
156
|
-
* };
|
|
157
|
-
*
|
|
158
|
-
* **Note:** This option can only be used with numerical values as font size options.
|
|
159
|
-
*
|
|
160
|
-
* With this configuration font sizes not specified in the editor configuration will not be removed when pasting the content.
|
|
161
|
-
*
|
|
162
|
-
* @member {Boolean} module:font/fontsize~FontSizeConfig#supportAllValues
|
|
163
|
-
*/
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 font
|
|
7
|
+
*/
|
|
8
|
+
export { default as Font } from './font';
|
|
9
|
+
export { default as FontBackgroundColor } from './fontbackgroundcolor';
|
|
10
|
+
export { default as FontColor } from './fontcolor';
|
|
11
|
+
export { default as FontFamily } from './fontfamily';
|
|
12
|
+
export { default as FontSize } from './fontsize';
|
|
13
|
+
export { default as FontBackgroundColorEditing } from './fontbackgroundcolor/fontbackgroundcolorediting';
|
|
14
|
+
export { default as FontBackgroundColorUI } from './fontbackgroundcolor/fontbackgroundcolorui';
|
|
15
|
+
export { default as FontColorEditing } from './fontcolor/fontcolorediting';
|
|
16
|
+
export { default as FontColorUI } from './fontcolor/fontcolorui';
|
|
17
|
+
export { default as FontFamilyEditing } from './fontfamily/fontfamilyediting';
|
|
18
|
+
export { default as FontFamilyUI } from './fontfamily/fontfamilyui';
|
|
19
|
+
export { default as FontSizeEditing } from './fontsize/fontsizeediting';
|
|
20
|
+
export { default as FontSizeUI } from './fontsize/fontsizeui';
|
package/src/index.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module font
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
export { default as Font } from './font';
|
|
11
9
|
export { default as FontBackgroundColor } from './fontbackgroundcolor';
|
|
12
10
|
export { default as FontColor } from './fontcolor';
|