@ckeditor/ckeditor5-font 36.0.1 → 37.0.0-alpha.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.
Files changed (56) hide show
  1. package/build/font.js +1 -1
  2. package/package.json +20 -15
  3. package/src/augmentation.d.ts +58 -0
  4. package/src/augmentation.js +5 -0
  5. package/src/documentcolorcollection.d.ts +70 -0
  6. package/src/documentcolorcollection.js +34 -63
  7. package/src/font.d.ts +29 -0
  8. package/src/font.js +12 -19
  9. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -0
  10. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +9 -15
  11. package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +26 -0
  12. package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +103 -116
  13. package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -0
  14. package/src/fontbackgroundcolor/fontbackgroundcolorui.js +18 -25
  15. package/src/fontbackgroundcolor.d.ts +28 -0
  16. package/src/fontbackgroundcolor.js +12 -165
  17. package/src/fontcolor/fontcolorcommand.d.ts +25 -0
  18. package/src/fontcolor/fontcolorcommand.js +9 -15
  19. package/src/fontcolor/fontcolorediting.d.ts +26 -0
  20. package/src/fontcolor/fontcolorediting.js +115 -128
  21. package/src/fontcolor/fontcolorui.d.ts +22 -0
  22. package/src/fontcolor/fontcolorui.js +18 -25
  23. package/src/fontcolor.d.ts +24 -0
  24. package/src/fontcolor.js +12 -168
  25. package/src/fontcommand.d.ts +46 -0
  26. package/src/fontcommand.js +54 -78
  27. package/src/fontconfig.d.ts +367 -0
  28. package/src/fontconfig.js +5 -0
  29. package/src/fontfamily/fontfamilycommand.d.ts +25 -0
  30. package/src/fontfamily/fontfamilycommand.js +9 -15
  31. package/src/fontfamily/fontfamilyediting.d.ts +39 -0
  32. package/src/fontfamily/fontfamilyediting.js +95 -116
  33. package/src/fontfamily/fontfamilyui.d.ts +30 -0
  34. package/src/fontfamily/fontfamilyui.js +90 -122
  35. package/src/fontfamily/utils.d.ts +15 -0
  36. package/src/fontfamily/utils.js +66 -79
  37. package/src/fontfamily.d.ts +24 -0
  38. package/src/fontfamily.js +12 -112
  39. package/src/fontsize/fontsizecommand.d.ts +25 -0
  40. package/src/fontsize/fontsizecommand.js +9 -15
  41. package/src/fontsize/fontsizeediting.d.ts +44 -0
  42. package/src/fontsize/fontsizeediting.js +137 -169
  43. package/src/fontsize/fontsizeui.d.ts +31 -0
  44. package/src/fontsize/fontsizeui.js +98 -130
  45. package/src/fontsize/utils.d.ts +12 -0
  46. package/src/fontsize/utils.js +145 -174
  47. package/src/fontsize.d.ts +35 -0
  48. package/src/fontsize.js +21 -141
  49. package/src/index.d.ts +27 -0
  50. package/src/index.js +1 -2
  51. package/src/ui/colortableview.d.ts +167 -0
  52. package/src/ui/colortableview.js +242 -418
  53. package/src/ui/colorui.d.ts +63 -0
  54. package/src/ui/colorui.js +78 -132
  55. package/src/utils.d.ts +77 -0
  56. package/src/utils.js +42 -72
@@ -2,31 +2,26 @@
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/fontsizeediting
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import { CKEditorError } from 'ckeditor5/src/utils';
12
10
  import { isLength, isPercentage } from 'ckeditor5/src/engine';
13
-
14
11
  import FontSizeCommand from './fontsizecommand';
15
12
  import { normalizeOptions } from './utils';
16
13
  import { buildDefinition, FONT_SIZE } from '../utils';
17
-
18
14
  // Mapping of `<font size="..">` styling to CSS's `font-size` values.
19
15
  const styleFontSize = [
20
- 'x-small', // Size "0" equal to "1".
21
- 'x-small',
22
- 'small',
23
- 'medium',
24
- 'large',
25
- 'x-large',
26
- 'xx-large',
27
- 'xxx-large'
16
+ 'x-small',
17
+ 'x-small',
18
+ 'small',
19
+ 'medium',
20
+ 'large',
21
+ 'x-large',
22
+ 'xx-large',
23
+ 'xxx-large'
28
24
  ];
29
-
30
25
  /**
31
26
  * The font size editing feature.
32
27
  *
@@ -36,162 +31,135 @@ const styleFontSize = [
36
31
  * * a style attribute (`<span style="font-size:12px">...</span>`),
37
32
  * * or a class attribute (`<span class="text-small">...</span>`)
38
33
  *
39
- * depending on the {@link module:font/fontsize~FontSizeConfig configuration}.
40
- *
41
- * @extends module:core/plugin~Plugin
34
+ * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
42
35
  */
43
36
  export default class FontSizeEditing extends Plugin {
44
- /**
45
- * @inheritDoc
46
- */
47
- static get pluginName() {
48
- return 'FontSizeEditing';
49
- }
50
-
51
- /**
52
- * @inheritDoc
53
- */
54
- constructor( editor ) {
55
- super( editor );
56
-
57
- // Define default configuration using named presets.
58
- editor.config.define( FONT_SIZE, {
59
- options: [
60
- 'tiny',
61
- 'small',
62
- 'default',
63
- 'big',
64
- 'huge'
65
- ],
66
- supportAllValues: false
67
- } );
68
- }
69
-
70
- /**
71
- * @inheritDoc
72
- */
73
- init() {
74
- const editor = this.editor;
75
-
76
- // Allow fontSize attribute on text nodes.
77
- editor.model.schema.extend( '$text', { allowAttributes: FONT_SIZE } );
78
- editor.model.schema.setAttributeProperties( FONT_SIZE, {
79
- isFormatting: true,
80
- copyOnEnter: true
81
- } );
82
-
83
- const supportAllValues = editor.config.get( 'fontSize.supportAllValues' );
84
-
85
- // Define view to model conversion.
86
- const options = normalizeOptions( this.editor.config.get( 'fontSize.options' ) )
87
- .filter( item => item.model );
88
- const definition = buildDefinition( FONT_SIZE, options );
89
-
90
- // Set-up the two-way conversion.
91
- if ( supportAllValues ) {
92
- this._prepareAnyValueConverters( definition );
93
- this._prepareCompatibilityConverter();
94
- } else {
95
- editor.conversion.attributeToElement( definition );
96
- }
97
-
98
- // Add FontSize command.
99
- editor.commands.add( FONT_SIZE, new FontSizeCommand( editor ) );
100
- }
101
-
102
- /**
103
- * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
104
- * if it is not defined in the plugin configuration.
105
- *
106
- * @param {Object} definition {@link module:engine/conversion/conversion~ConverterDefinition Converter definition} out of input data.
107
- * @private
108
- */
109
- _prepareAnyValueConverters( definition ) {
110
- const editor = this.editor;
111
-
112
- // If `fontSize.supportAllValues=true`, we do not allow to use named presets in the plugin's configuration.
113
- const presets = definition.model.values.filter( value => {
114
- return !isLength( String( value ) ) && !isPercentage( String( value ) );
115
- } );
116
-
117
- if ( presets.length ) {
118
- /**
119
- * If {@link module:font/fontsize~FontSizeConfig#supportAllValues `config.fontSize.supportAllValues`} is `true`,
120
- * you need to use numerical values as font size options.
121
- *
122
- * See valid examples described in the {@link module:font/fontsize~FontSizeConfig#options plugin configuration}.
123
- *
124
- * @error font-size-invalid-use-of-named-presets
125
- * @param {Array.<String>} presets Invalid values.
126
- */
127
- throw new CKEditorError(
128
- 'font-size-invalid-use-of-named-presets',
129
- null, { presets }
130
- );
131
- }
132
-
133
- editor.conversion.for( 'downcast' ).attributeToElement( {
134
- model: FONT_SIZE,
135
- view: ( attributeValue, { writer } ) => {
136
- if ( !attributeValue ) {
137
- return;
138
- }
139
-
140
- return writer.createAttributeElement( 'span', { style: 'font-size:' + attributeValue }, { priority: 7 } );
141
- }
142
- } );
143
-
144
- editor.conversion.for( 'upcast' ).elementToAttribute( {
145
- model: {
146
- key: FONT_SIZE,
147
- value: viewElement => viewElement.getStyle( 'font-size' )
148
- },
149
- view: {
150
- name: 'span',
151
- styles: {
152
- 'font-size': /.*/
153
- }
154
- }
155
- } );
156
- }
157
-
158
- /**
159
- * Adds support for legacy `<font size="..">` formatting.
160
- *
161
- * @private
162
- */
163
- _prepareCompatibilityConverter() {
164
- const editor = this.editor;
165
-
166
- editor.conversion.for( 'upcast' ).elementToAttribute( {
167
- view: {
168
- name: 'font',
169
- attributes: {
170
- // Documentation mentions sizes from 1 to 7. To handle old content we support all values
171
- // up to 999 but clamp it to the valid range. Why 999? It should cover accidental values
172
- // similar to percentage, e.g. 100%, 200% which could be the usual mistake for font size.
173
- 'size': /^[+-]?\d{1,3}$/
174
- }
175
- },
176
- model: {
177
- key: FONT_SIZE,
178
- value: viewElement => {
179
- const value = viewElement.getAttribute( 'size' );
180
- const isRelative = value[ 0 ] === '-' || value[ 0 ] === '+';
181
-
182
- let size = parseInt( value, 10 );
183
-
184
- if ( isRelative ) {
185
- // Add relative size (which can be negative) to the default size = 3.
186
- size = 3 + size;
187
- }
188
-
189
- const maxSize = styleFontSize.length - 1;
190
- const clampedSize = Math.min( Math.max( size, 0 ), maxSize );
191
-
192
- return styleFontSize[ clampedSize ];
193
- }
194
- }
195
- } );
196
- }
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ static get pluginName() {
41
+ return 'FontSizeEditing';
42
+ }
43
+ /**
44
+ * @inheritDoc
45
+ */
46
+ constructor(editor) {
47
+ super(editor);
48
+ // Define default configuration using named presets.
49
+ editor.config.define(FONT_SIZE, {
50
+ options: [
51
+ 'tiny',
52
+ 'small',
53
+ 'default',
54
+ 'big',
55
+ 'huge'
56
+ ],
57
+ supportAllValues: false
58
+ });
59
+ }
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ init() {
64
+ const editor = this.editor;
65
+ // Allow fontSize attribute on text nodes.
66
+ editor.model.schema.extend('$text', { allowAttributes: FONT_SIZE });
67
+ editor.model.schema.setAttributeProperties(FONT_SIZE, {
68
+ isFormatting: true,
69
+ copyOnEnter: true
70
+ });
71
+ const supportAllValues = editor.config.get('fontSize.supportAllValues');
72
+ // Define view to model conversion.
73
+ const options = normalizeOptions(this.editor.config.get('fontSize.options'))
74
+ .filter(item => item.model);
75
+ const definition = buildDefinition(FONT_SIZE, options);
76
+ // Set-up the two-way conversion.
77
+ if (supportAllValues) {
78
+ this._prepareAnyValueConverters(definition);
79
+ this._prepareCompatibilityConverter();
80
+ }
81
+ else {
82
+ editor.conversion.attributeToElement(definition);
83
+ }
84
+ // Add FontSize command.
85
+ editor.commands.add(FONT_SIZE, new FontSizeCommand(editor));
86
+ }
87
+ /**
88
+ * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
89
+ * if it is not defined in the plugin configuration.
90
+ *
91
+ * @param definition Converter definition out of input data.
92
+ */
93
+ _prepareAnyValueConverters(definition) {
94
+ const editor = this.editor;
95
+ // If `fontSize.supportAllValues=true`, we do not allow to use named presets in the plugin's configuration.
96
+ const presets = definition.model.values.filter((value) => {
97
+ return !isLength(String(value)) && !isPercentage(String(value));
98
+ });
99
+ if (presets.length) {
100
+ /**
101
+ * If {@link module:font/fontconfig~FontSizeConfig#supportAllValues `config.fontSize.supportAllValues`} is `true`,
102
+ * you need to use numerical values as font size options.
103
+ *
104
+ * See valid examples described in the {@link module:font/fontconfig~FontSizeConfig#options plugin configuration}.
105
+ *
106
+ * @error font-size-invalid-use-of-named-presets
107
+ * @param {Array.<String>} presets Invalid values.
108
+ */
109
+ throw new CKEditorError('font-size-invalid-use-of-named-presets', null, { presets });
110
+ }
111
+ editor.conversion.for('downcast').attributeToElement({
112
+ model: FONT_SIZE,
113
+ view: (attributeValue, { writer }) => {
114
+ if (!attributeValue) {
115
+ return;
116
+ }
117
+ return writer.createAttributeElement('span', { style: 'font-size:' + attributeValue }, { priority: 7 });
118
+ }
119
+ });
120
+ editor.conversion.for('upcast').elementToAttribute({
121
+ model: {
122
+ key: FONT_SIZE,
123
+ value: (viewElement) => viewElement.getStyle('font-size')
124
+ },
125
+ view: {
126
+ name: 'span',
127
+ styles: {
128
+ 'font-size': /.*/
129
+ }
130
+ }
131
+ });
132
+ }
133
+ /**
134
+ * Adds support for legacy `<font size="..">` formatting.
135
+ */
136
+ _prepareCompatibilityConverter() {
137
+ const editor = this.editor;
138
+ editor.conversion.for('upcast').elementToAttribute({
139
+ view: {
140
+ name: 'font',
141
+ attributes: {
142
+ // Documentation mentions sizes from 1 to 7. To handle old content we support all values
143
+ // up to 999 but clamp it to the valid range. Why 999? It should cover accidental values
144
+ // similar to percentage, e.g. 100%, 200% which could be the usual mistake for font size.
145
+ 'size': /^[+-]?\d{1,3}$/
146
+ }
147
+ },
148
+ model: {
149
+ key: FONT_SIZE,
150
+ value: (viewElement) => {
151
+ const value = viewElement.getAttribute('size');
152
+ const isRelative = value[0] === '-' || value[0] === '+';
153
+ let size = parseInt(value, 10);
154
+ if (isRelative) {
155
+ // Add relative size (which can be negative) to the default size = 3.
156
+ size = 3 + size;
157
+ }
158
+ const maxSize = styleFontSize.length - 1;
159
+ const clampedSize = Math.min(Math.max(size, 0), maxSize);
160
+ return styleFontSize[clampedSize];
161
+ }
162
+ }
163
+ });
164
+ }
197
165
  }
@@ -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 font/fontsize/fontsizeui
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import '../../theme/fontsize.css';
10
+ /**
11
+ * The font size UI plugin. It introduces the `'fontSize'` dropdown.
12
+ */
13
+ export default class FontSizeUI extends Plugin {
14
+ /**
15
+ * @inheritDoc
16
+ */
17
+ static get pluginName(): 'FontSizeUI';
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ init(): void;
22
+ /**
23
+ * Returns options as defined in `config.fontSize.options` but processed to account for
24
+ * editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
25
+ * in the correct language.
26
+ *
27
+ * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
28
+ * when the user configuration is defined because the editor does not exist yet.
29
+ */
30
+ private _getLocalizedOptions;
31
+ }
@@ -2,148 +2,116 @@
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/fontsizeui
8
7
  */
9
-
10
8
  import { Plugin } from 'ckeditor5/src/core';
11
9
  import { Model, createDropdown, addListToDropdown } from 'ckeditor5/src/ui';
12
10
  import { Collection } from 'ckeditor5/src/utils';
13
-
14
11
  import { normalizeOptions } from './utils';
15
12
  import { FONT_SIZE } from '../utils';
16
-
17
- import fontSizeIcon from '../../theme/icons/font-size.svg';
18
13
  import '../../theme/fontsize.css';
19
-
14
+ import fontSizeIcon from '../../theme/icons/font-size.svg';
20
15
  /**
21
16
  * The font size UI plugin. It introduces the `'fontSize'` dropdown.
22
- *
23
- * @extends module:core/plugin~Plugin
24
17
  */
25
18
  export default class FontSizeUI extends Plugin {
26
- /**
27
- * @inheritDoc
28
- */
29
- static get pluginName() {
30
- return 'FontSizeUI';
31
- }
32
-
33
- /**
34
- * @inheritDoc
35
- */
36
- init() {
37
- const editor = this.editor;
38
- const t = editor.t;
39
-
40
- const options = this._getLocalizedOptions();
41
-
42
- const command = editor.commands.get( FONT_SIZE );
43
-
44
- // Register UI component.
45
- editor.ui.componentFactory.add( FONT_SIZE, locale => {
46
- const dropdownView = createDropdown( locale );
47
-
48
- addListToDropdown( dropdownView, () => _prepareListOptions( options, command ) );
49
-
50
- // Create dropdown model.
51
- dropdownView.buttonView.set( {
52
- label: t( 'Font Size' ),
53
- icon: fontSizeIcon,
54
- tooltip: true
55
- } );
56
-
57
- dropdownView.extendTemplate( {
58
- attributes: {
59
- class: [
60
- 'ck-font-size-dropdown'
61
- ]
62
- }
63
- } );
64
-
65
- dropdownView.bind( 'isEnabled' ).to( command );
66
-
67
- // Execute command when an item from the dropdown is selected.
68
- this.listenTo( dropdownView, 'execute', evt => {
69
- editor.execute( evt.source.commandName, { value: evt.source.commandParam } );
70
- editor.editing.view.focus();
71
- } );
72
-
73
- return dropdownView;
74
- } );
75
- }
76
-
77
- /**
78
- * Returns options as defined in `config.fontSize.options` but processed to account for
79
- * editor localization, i.e. to display {@link module:font/fontsize~FontSizeOption}
80
- * in the correct language.
81
- *
82
- * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
83
- * when the user configuration is defined because the editor does not exist yet.
84
- *
85
- * @private
86
- * @returns {Array.<module:font/fontsize~FontSizeOption>}.
87
- */
88
- _getLocalizedOptions() {
89
- const editor = this.editor;
90
- const t = editor.t;
91
-
92
- const localizedTitles = {
93
- Default: t( 'Default' ),
94
- Tiny: t( 'Tiny' ),
95
- Small: t( 'Small' ),
96
- Big: t( 'Big' ),
97
- Huge: t( 'Huge' )
98
- };
99
-
100
- const options = normalizeOptions( editor.config.get( FONT_SIZE ).options );
101
-
102
- return options.map( option => {
103
- const title = localizedTitles[ option.title ];
104
-
105
- if ( title && title != option.title ) {
106
- // Clone the option to avoid altering the original `namedPresets` from `./utils.js`.
107
- option = Object.assign( {}, option, { title } );
108
- }
109
-
110
- return option;
111
- } );
112
- }
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get pluginName() {
23
+ return 'FontSizeUI';
24
+ }
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ init() {
29
+ const editor = this.editor;
30
+ const t = editor.t;
31
+ const options = this._getLocalizedOptions();
32
+ const command = editor.commands.get(FONT_SIZE);
33
+ // Register UI component.
34
+ editor.ui.componentFactory.add(FONT_SIZE, locale => {
35
+ const dropdownView = createDropdown(locale);
36
+ addListToDropdown(dropdownView, () => _prepareListOptions(options, command));
37
+ // Create dropdown model.
38
+ dropdownView.buttonView.set({
39
+ label: t('Font Size'),
40
+ icon: fontSizeIcon,
41
+ tooltip: true
42
+ });
43
+ dropdownView.extendTemplate({
44
+ attributes: {
45
+ class: [
46
+ 'ck-font-size-dropdown'
47
+ ]
48
+ }
49
+ });
50
+ dropdownView.bind('isEnabled').to(command);
51
+ // Execute command when an item from the dropdown is selected.
52
+ this.listenTo(dropdownView, 'execute', evt => {
53
+ editor.execute(evt.source.commandName, { value: evt.source.commandParam });
54
+ editor.editing.view.focus();
55
+ });
56
+ return dropdownView;
57
+ });
58
+ }
59
+ /**
60
+ * Returns options as defined in `config.fontSize.options` but processed to account for
61
+ * editor localization, i.e. to display {@link module:font/fontconfig~FontSizeOption}
62
+ * in the correct language.
63
+ *
64
+ * Note: The reason behind this method is that there is no way to use {@link module:utils/locale~Locale#t}
65
+ * when the user configuration is defined because the editor does not exist yet.
66
+ */
67
+ _getLocalizedOptions() {
68
+ const editor = this.editor;
69
+ const t = editor.t;
70
+ const localizedTitles = {
71
+ Default: t('Default'),
72
+ Tiny: t('Tiny'),
73
+ Small: t('Small'),
74
+ Big: t('Big'),
75
+ Huge: t('Huge')
76
+ };
77
+ const options = normalizeOptions((editor.config.get(FONT_SIZE)).options);
78
+ return options.map(option => {
79
+ const title = localizedTitles[option.title];
80
+ if (title && title != option.title) {
81
+ // Clone the option to avoid altering the original `namedPresets` from `./utils.js`.
82
+ option = Object.assign({}, option, { title });
83
+ }
84
+ return option;
85
+ });
86
+ }
113
87
  }
114
-
115
- // Prepares FontSize dropdown items.
116
- // @private
117
- // @param {Array.<module:font/fontsize~FontSizeOption>} options
118
- // @param {module:font/fontsize/fontsizecommand~FontSizeCommand} command
119
- function _prepareListOptions( options, command ) {
120
- const itemDefinitions = new Collection();
121
-
122
- for ( const option of options ) {
123
- const def = {
124
- type: 'button',
125
- model: new Model( {
126
- commandName: FONT_SIZE,
127
- commandParam: option.model,
128
- label: option.title,
129
- class: 'ck-fontsize-option',
130
- withText: true
131
- } )
132
- };
133
-
134
- if ( option.view && option.view.styles ) {
135
- def.model.set( 'labelStyle', `font-size:${ option.view.styles[ 'font-size' ] }` );
136
- }
137
-
138
- if ( option.view && option.view.classes ) {
139
- def.model.set( 'class', `${ def.model.class } ${ option.view.classes }` );
140
- }
141
-
142
- def.model.bind( 'isOn' ).to( command, 'value', value => value === option.model );
143
-
144
- // Add the option to the collection.
145
- itemDefinitions.add( def );
146
- }
147
-
148
- return itemDefinitions;
88
+ /**
89
+ * Prepares FontSize dropdown items.
90
+ */
91
+ function _prepareListOptions(options, command) {
92
+ const itemDefinitions = new Collection();
93
+ for (const option of options) {
94
+ const def = {
95
+ type: 'button',
96
+ model: new Model({
97
+ commandName: FONT_SIZE,
98
+ commandParam: option.model,
99
+ label: option.title,
100
+ class: 'ck-fontsize-option',
101
+ withText: true
102
+ })
103
+ };
104
+ if (option.view && typeof option.view !== 'string') {
105
+ if (option.view.styles) {
106
+ def.model.set('labelStyle', `font-size:${option.view.styles['font-size']}`);
107
+ }
108
+ if (option.view.classes) {
109
+ def.model.set('class', `${def.model.class} ${option.view.classes}`);
110
+ }
111
+ }
112
+ def.model.bind('isOn').to(command, 'value', value => value === option.model);
113
+ // Add the option to the collection.
114
+ itemDefinitions.add(def);
115
+ }
116
+ return itemDefinitions;
149
117
  }
@@ -0,0 +1,12 @@
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 FontSizeOption } from '../fontconfig';
6
+ /**
7
+ * Normalizes and translates the {@link module:font/fontconfig~FontSizeConfig#options configuration options}
8
+ * to the {@link module:font/fontconfig~FontSizeOption} format.
9
+ *
10
+ * @param configuredOptions An array of options taken from the configuration.
11
+ */
12
+ export declare function normalizeOptions(configuredOptions: Array<string | number | FontSizeOption>): Array<FontSizeOption>;