@ckeditor/ckeditor5-font 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.
Files changed (59) hide show
  1. package/build/font.js +1 -1
  2. package/build/font.js.map +1 -0
  3. package/build/translations/it.js +1 -1
  4. package/lang/translations/it.po +1 -1
  5. package/package.json +3 -23
  6. package/src/augmentation.d.ts +58 -58
  7. package/src/augmentation.js +5 -5
  8. package/src/documentcolorcollection.d.ts +70 -70
  9. package/src/documentcolorcollection.js +42 -42
  10. package/src/font.d.ts +33 -33
  11. package/src/font.js +37 -37
  12. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -26
  13. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +25 -25
  14. package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +26 -26
  15. package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +123 -123
  16. package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -22
  17. package/src/fontbackgroundcolor/fontbackgroundcolorui.js +33 -33
  18. package/src/fontbackgroundcolor.d.ts +30 -30
  19. package/src/fontbackgroundcolor.js +34 -34
  20. package/src/fontcolor/fontcolorcommand.d.ts +25 -25
  21. package/src/fontcolor/fontcolorcommand.js +24 -24
  22. package/src/fontcolor/fontcolorediting.d.ts +26 -26
  23. package/src/fontcolor/fontcolorediting.js +134 -134
  24. package/src/fontcolor/fontcolorui.d.ts +22 -22
  25. package/src/fontcolor/fontcolorui.js +33 -33
  26. package/src/fontcolor.d.ts +29 -29
  27. package/src/fontcolor.js +33 -33
  28. package/src/fontcommand.d.ts +48 -48
  29. package/src/fontcommand.js +79 -79
  30. package/src/fontconfig.d.ts +373 -373
  31. package/src/fontconfig.js +5 -5
  32. package/src/fontfamily/fontfamilycommand.d.ts +25 -25
  33. package/src/fontfamily/fontfamilycommand.js +24 -24
  34. package/src/fontfamily/fontfamilyediting.d.ts +39 -39
  35. package/src/fontfamily/fontfamilyediting.js +115 -115
  36. package/src/fontfamily/fontfamilyui.d.ts +30 -30
  37. package/src/fontfamily/fontfamilyui.js +114 -114
  38. package/src/fontfamily/utils.d.ts +15 -15
  39. package/src/fontfamily/utils.js +80 -80
  40. package/src/fontfamily.d.ts +29 -29
  41. package/src/fontfamily.js +33 -33
  42. package/src/fontsize/fontsizecommand.d.ts +25 -25
  43. package/src/fontsize/fontsizecommand.js +24 -24
  44. package/src/fontsize/fontsizeediting.d.ts +44 -44
  45. package/src/fontsize/fontsizeediting.js +165 -165
  46. package/src/fontsize/fontsizeui.d.ts +31 -31
  47. package/src/fontsize/fontsizeui.js +122 -122
  48. package/src/fontsize/utils.d.ts +12 -12
  49. package/src/fontsize/utils.js +166 -166
  50. package/src/fontsize.d.ts +37 -37
  51. package/src/fontsize.js +43 -43
  52. package/src/index.d.ts +27 -27
  53. package/src/index.js +21 -21
  54. package/src/ui/colortableview.d.ts +459 -459
  55. package/src/ui/colortableview.js +645 -645
  56. package/src/ui/colorui.d.ts +67 -67
  57. package/src/ui/colorui.js +128 -128
  58. package/src/utils.d.ts +79 -79
  59. package/src/utils.js +98 -98
@@ -1,44 +1,44 @@
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/fontsizeediting
7
- */
8
- import { Plugin, type Editor } from 'ckeditor5/src/core';
9
- /**
10
- * The font size editing feature.
11
- *
12
- * It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
13
- * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
14
- * as a `<span>` element with either:
15
- * * a style attribute (`<span style="font-size:12px">...</span>`),
16
- * * or a class attribute (`<span class="text-small">...</span>`)
17
- *
18
- * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
19
- */
20
- export default class FontSizeEditing extends Plugin {
21
- /**
22
- * @inheritDoc
23
- */
24
- static get pluginName(): 'FontSizeEditing';
25
- /**
26
- * @inheritDoc
27
- */
28
- constructor(editor: Editor);
29
- /**
30
- * @inheritDoc
31
- */
32
- init(): void;
33
- /**
34
- * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
35
- * if it is not defined in the plugin configuration.
36
- *
37
- * @param definition Converter definition out of input data.
38
- */
39
- private _prepareAnyValueConverters;
40
- /**
41
- * Adds support for legacy `<font size="..">` formatting.
42
- */
43
- private _prepareCompatibilityConverter;
44
- }
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/fontsizeediting
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
9
+ /**
10
+ * The font size editing feature.
11
+ *
12
+ * It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
13
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
14
+ * as a `<span>` element with either:
15
+ * * a style attribute (`<span style="font-size:12px">...</span>`),
16
+ * * or a class attribute (`<span class="text-small">...</span>`)
17
+ *
18
+ * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
19
+ */
20
+ export default class FontSizeEditing extends Plugin {
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get pluginName(): "FontSizeEditing";
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ constructor(editor: Editor);
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ init(): void;
33
+ /**
34
+ * These converters enable keeping any value found as `style="font-size: *"` as a value of an attribute on a text even
35
+ * if it is not defined in the plugin configuration.
36
+ *
37
+ * @param definition Converter definition out of input data.
38
+ */
39
+ private _prepareAnyValueConverters;
40
+ /**
41
+ * Adds support for legacy `<font size="..">` formatting.
42
+ */
43
+ private _prepareCompatibilityConverter;
44
+ }
@@ -1,165 +1,165 @@
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/fontsizeediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { CKEditorError } from 'ckeditor5/src/utils';
10
- import { isLength, isPercentage } from 'ckeditor5/src/engine';
11
- import FontSizeCommand from './fontsizecommand';
12
- import { normalizeOptions } from './utils';
13
- import { buildDefinition, FONT_SIZE } from '../utils';
14
- // Mapping of `<font size="..">` styling to CSS's `font-size` values.
15
- const styleFontSize = [
16
- 'x-small',
17
- 'x-small',
18
- 'small',
19
- 'medium',
20
- 'large',
21
- 'x-large',
22
- 'xx-large',
23
- 'xxx-large'
24
- ];
25
- /**
26
- * The font size editing feature.
27
- *
28
- * It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
29
- * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
30
- * as a `<span>` element with either:
31
- * * a style attribute (`<span style="font-size:12px">...</span>`),
32
- * * or a class attribute (`<span class="text-small">...</span>`)
33
- *
34
- * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
35
- */
36
- export default class FontSizeEditing extends Plugin {
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
- }
165
- }
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/fontsizeediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { CKEditorError } from 'ckeditor5/src/utils';
10
+ import { isLength, isPercentage } from 'ckeditor5/src/engine';
11
+ import FontSizeCommand from './fontsizecommand';
12
+ import { normalizeOptions } from './utils';
13
+ import { buildDefinition, FONT_SIZE } from '../utils';
14
+ // Mapping of `<font size="..">` styling to CSS's `font-size` values.
15
+ const styleFontSize = [
16
+ 'x-small',
17
+ 'x-small',
18
+ 'small',
19
+ 'medium',
20
+ 'large',
21
+ 'x-large',
22
+ 'xx-large',
23
+ 'xxx-large'
24
+ ];
25
+ /**
26
+ * The font size editing feature.
27
+ *
28
+ * It introduces the {@link module:font/fontsize/fontsizecommand~FontSizeCommand command} and the `fontSize`
29
+ * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}
30
+ * as a `<span>` element with either:
31
+ * * a style attribute (`<span style="font-size:12px">...</span>`),
32
+ * * or a class attribute (`<span class="text-small">...</span>`)
33
+ *
34
+ * depending on the {@link module:font/fontconfig~FontSizeConfig configuration}.
35
+ */
36
+ export default class FontSizeEditing extends Plugin {
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
+ }
165
+ }
@@ -1,31 +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
- }
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
+ }