@ckeditor/ckeditor5-font 38.1.0 → 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 (57) hide show
  1. package/build/font.js +1 -1
  2. package/build/font.js.map +1 -0
  3. package/package.json +3 -3
  4. package/src/augmentation.d.ts +58 -58
  5. package/src/augmentation.js +5 -5
  6. package/src/documentcolorcollection.d.ts +70 -70
  7. package/src/documentcolorcollection.js +42 -42
  8. package/src/font.d.ts +33 -33
  9. package/src/font.js +37 -37
  10. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.d.ts +26 -26
  11. package/src/fontbackgroundcolor/fontbackgroundcolorcommand.js +25 -25
  12. package/src/fontbackgroundcolor/fontbackgroundcolorediting.d.ts +26 -26
  13. package/src/fontbackgroundcolor/fontbackgroundcolorediting.js +123 -123
  14. package/src/fontbackgroundcolor/fontbackgroundcolorui.d.ts +22 -22
  15. package/src/fontbackgroundcolor/fontbackgroundcolorui.js +33 -33
  16. package/src/fontbackgroundcolor.d.ts +30 -30
  17. package/src/fontbackgroundcolor.js +34 -34
  18. package/src/fontcolor/fontcolorcommand.d.ts +25 -25
  19. package/src/fontcolor/fontcolorcommand.js +24 -24
  20. package/src/fontcolor/fontcolorediting.d.ts +26 -26
  21. package/src/fontcolor/fontcolorediting.js +134 -134
  22. package/src/fontcolor/fontcolorui.d.ts +22 -22
  23. package/src/fontcolor/fontcolorui.js +33 -33
  24. package/src/fontcolor.d.ts +29 -29
  25. package/src/fontcolor.js +33 -33
  26. package/src/fontcommand.d.ts +48 -48
  27. package/src/fontcommand.js +79 -79
  28. package/src/fontconfig.d.ts +373 -373
  29. package/src/fontconfig.js +5 -5
  30. package/src/fontfamily/fontfamilycommand.d.ts +25 -25
  31. package/src/fontfamily/fontfamilycommand.js +24 -24
  32. package/src/fontfamily/fontfamilyediting.d.ts +39 -39
  33. package/src/fontfamily/fontfamilyediting.js +115 -115
  34. package/src/fontfamily/fontfamilyui.d.ts +30 -30
  35. package/src/fontfamily/fontfamilyui.js +114 -114
  36. package/src/fontfamily/utils.d.ts +15 -15
  37. package/src/fontfamily/utils.js +80 -80
  38. package/src/fontfamily.d.ts +29 -29
  39. package/src/fontfamily.js +33 -33
  40. package/src/fontsize/fontsizecommand.d.ts +25 -25
  41. package/src/fontsize/fontsizecommand.js +24 -24
  42. package/src/fontsize/fontsizeediting.d.ts +44 -44
  43. package/src/fontsize/fontsizeediting.js +165 -165
  44. package/src/fontsize/fontsizeui.d.ts +31 -31
  45. package/src/fontsize/fontsizeui.js +122 -122
  46. package/src/fontsize/utils.d.ts +12 -12
  47. package/src/fontsize/utils.js +166 -166
  48. package/src/fontsize.d.ts +37 -37
  49. package/src/fontsize.js +43 -43
  50. package/src/index.d.ts +27 -27
  51. package/src/index.js +21 -21
  52. package/src/ui/colortableview.d.ts +459 -459
  53. package/src/ui/colortableview.js +645 -645
  54. package/src/ui/colorui.d.ts +67 -67
  55. package/src/ui/colorui.js +128 -128
  56. package/src/utils.d.ts +79 -79
  57. package/src/utils.js +98 -98
@@ -1,67 +1,67 @@
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/ui/colorui
7
- */
8
- import { Plugin, type Editor } from 'ckeditor5/src/core';
9
- import { type FONT_BACKGROUND_COLOR, type FONT_COLOR } from '../utils';
10
- import { type default as ColorTableView } from './colortableview';
11
- /**
12
- * The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
13
- *
14
- * It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
15
- * a {@link module:font/ui/colortableview~ColorTableView}.
16
- */
17
- export default class ColorUI extends Plugin {
18
- /**
19
- * The name of the command which will be executed when a color tile is clicked.
20
- */
21
- commandName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
22
- /**
23
- * The name of this component in the {@link module:ui/componentfactory~ComponentFactory}.
24
- * Also the configuration scope name in `editor.config`.
25
- */
26
- componentName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
27
- /**
28
- * The SVG icon used by the dropdown.
29
- */
30
- icon: string;
31
- /**
32
- * The label used by the dropdown.
33
- */
34
- dropdownLabel: string;
35
- /**
36
- * The number of columns in the color grid.
37
- */
38
- columns: number;
39
- /**
40
- * Keeps a reference to {@link module:font/ui/colortableview~ColorTableView}.
41
- */
42
- colorTableView: ColorTableView | undefined;
43
- /**
44
- * Keeps all changes in color picker in one batch while dropdown is open.
45
- */
46
- private _undoStepBatch;
47
- /**
48
- * Creates a plugin which introduces a dropdown with a pre–configured {@link module:font/ui/colortableview~ColorTableView}.
49
- *
50
- * @param config The configuration object.
51
- * @param config.commandName The name of the command which will be executed when a color tile is clicked.
52
- * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
53
- * and the configuration scope name in `editor.config`.
54
- * @param config.icon The SVG icon used by the dropdown.
55
- * @param config.dropdownLabel The label used by the dropdown.
56
- */
57
- constructor(editor: Editor, { commandName, componentName, icon, dropdownLabel }: {
58
- commandName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
59
- componentName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
60
- icon: string;
61
- dropdownLabel: string;
62
- });
63
- /**
64
- * @inheritDoc
65
- */
66
- init(): void;
67
- }
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/ui/colorui
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
9
+ import { type FONT_BACKGROUND_COLOR, type FONT_COLOR } from '../utils';
10
+ import { type default as ColorTableView } from './colortableview';
11
+ /**
12
+ * The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
13
+ *
14
+ * It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
15
+ * a {@link module:font/ui/colortableview~ColorTableView}.
16
+ */
17
+ export default class ColorUI extends Plugin {
18
+ /**
19
+ * The name of the command which will be executed when a color tile is clicked.
20
+ */
21
+ commandName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
22
+ /**
23
+ * The name of this component in the {@link module:ui/componentfactory~ComponentFactory}.
24
+ * Also the configuration scope name in `editor.config`.
25
+ */
26
+ componentName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
27
+ /**
28
+ * The SVG icon used by the dropdown.
29
+ */
30
+ icon: string;
31
+ /**
32
+ * The label used by the dropdown.
33
+ */
34
+ dropdownLabel: string;
35
+ /**
36
+ * The number of columns in the color grid.
37
+ */
38
+ columns: number;
39
+ /**
40
+ * Keeps a reference to {@link module:font/ui/colortableview~ColorTableView}.
41
+ */
42
+ colorTableView: ColorTableView | undefined;
43
+ /**
44
+ * Keeps all changes in color picker in one batch while dropdown is open.
45
+ */
46
+ private _undoStepBatch;
47
+ /**
48
+ * Creates a plugin which introduces a dropdown with a pre–configured {@link module:font/ui/colortableview~ColorTableView}.
49
+ *
50
+ * @param config The configuration object.
51
+ * @param config.commandName The name of the command which will be executed when a color tile is clicked.
52
+ * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
53
+ * and the configuration scope name in `editor.config`.
54
+ * @param config.icon The SVG icon used by the dropdown.
55
+ * @param config.dropdownLabel The label used by the dropdown.
56
+ */
57
+ constructor(editor: Editor, { commandName, componentName, icon, dropdownLabel }: {
58
+ commandName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
59
+ componentName: typeof FONT_BACKGROUND_COLOR | typeof FONT_COLOR;
60
+ icon: string;
61
+ dropdownLabel: string;
62
+ });
63
+ /**
64
+ * @inheritDoc
65
+ */
66
+ init(): void;
67
+ }
package/src/ui/colorui.js CHANGED
@@ -1,128 +1,128 @@
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/ui/colorui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { createDropdown, normalizeColorOptions, getLocalizedColorOptions, focusChildOnDropdownOpen } from 'ckeditor5/src/ui';
10
- import { addColorTableToDropdown } from '../utils';
11
- /**
12
- * The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
13
- *
14
- * It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
15
- * a {@link module:font/ui/colortableview~ColorTableView}.
16
- */
17
- export default class ColorUI extends Plugin {
18
- /**
19
- * Creates a plugin which introduces a dropdown with a pre–configured {@link module:font/ui/colortableview~ColorTableView}.
20
- *
21
- * @param config The configuration object.
22
- * @param config.commandName The name of the command which will be executed when a color tile is clicked.
23
- * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
24
- * and the configuration scope name in `editor.config`.
25
- * @param config.icon The SVG icon used by the dropdown.
26
- * @param config.dropdownLabel The label used by the dropdown.
27
- */
28
- constructor(editor, { commandName, componentName, icon, dropdownLabel }) {
29
- super(editor);
30
- this.commandName = commandName;
31
- this.componentName = componentName;
32
- this.icon = icon;
33
- this.dropdownLabel = dropdownLabel;
34
- this.columns = editor.config.get(`${this.componentName}.columns`);
35
- this.colorTableView = undefined;
36
- }
37
- /**
38
- * @inheritDoc
39
- */
40
- init() {
41
- const editor = this.editor;
42
- const locale = editor.locale;
43
- const t = locale.t;
44
- const command = editor.commands.get(this.commandName);
45
- const componentConfig = editor.config.get(this.componentName);
46
- const colorsConfig = normalizeColorOptions(componentConfig.colors);
47
- const localizedColors = getLocalizedColorOptions(locale, colorsConfig);
48
- const documentColorsCount = componentConfig.documentColors;
49
- const hasColorPicker = componentConfig.colorPicker !== false;
50
- // Register the UI component.
51
- editor.ui.componentFactory.add(this.componentName, locale => {
52
- const dropdownView = createDropdown(locale);
53
- // Font color dropdown rendering is deferred once it gets open to improve performance (#6192).
54
- let dropdownContentRendered = false;
55
- this.colorTableView = addColorTableToDropdown({
56
- dropdownView,
57
- colors: localizedColors.map(option => ({
58
- label: option.label,
59
- color: option.model,
60
- options: {
61
- hasBorder: option.hasBorder
62
- }
63
- })),
64
- columns: this.columns,
65
- removeButtonLabel: t('Remove color'),
66
- colorPickerLabel: t('Color picker'),
67
- documentColorsLabel: documentColorsCount !== 0 ? t('Document colors') : '',
68
- documentColorsCount: documentColorsCount === undefined ? this.columns : documentColorsCount,
69
- colorPickerConfig: hasColorPicker ? (componentConfig.colorPicker || {}) : false
70
- });
71
- this.colorTableView.bind('selectedColor').to(command, 'value');
72
- dropdownView.buttonView.set({
73
- label: this.dropdownLabel,
74
- icon: this.icon,
75
- tooltip: true
76
- });
77
- dropdownView.extendTemplate({
78
- attributes: {
79
- class: 'ck-color-ui-dropdown'
80
- }
81
- });
82
- dropdownView.bind('isEnabled').to(command);
83
- this.colorTableView.on('execute', (evt, data) => {
84
- if (dropdownView.isOpen) {
85
- editor.execute(this.commandName, {
86
- value: data.value,
87
- batch: this._undoStepBatch
88
- });
89
- }
90
- if (data.source !== 'colorPicker') {
91
- editor.editing.view.focus();
92
- }
93
- });
94
- this.colorTableView.on('showColorPicker', () => {
95
- this._undoStepBatch = editor.model.createBatch();
96
- });
97
- this.colorTableView.on('cancel', () => {
98
- if (this._undoStepBatch.operations.length) {
99
- // We need to close the dropdown before the undo batch.
100
- // Otherwise, ColorUI treats undo as a selected color change,
101
- // propagating the update to the whole selection.
102
- // That's an issue if spans with various colors were selected.
103
- dropdownView.isOpen = false;
104
- editor.execute('undo', this._undoStepBatch);
105
- }
106
- editor.editing.view.focus();
107
- });
108
- dropdownView.on('change:isOpen', (evt, name, isVisible) => {
109
- if (!dropdownContentRendered) {
110
- dropdownContentRendered = true;
111
- dropdownView.colorTableView.appendUI();
112
- }
113
- if (isVisible) {
114
- if (documentColorsCount !== 0) {
115
- this.colorTableView.updateDocumentColors(editor.model, this.componentName);
116
- }
117
- this.colorTableView.updateSelectedColors();
118
- }
119
- else {
120
- this.colorTableView.showColorGrids();
121
- }
122
- });
123
- // Accessibility: focus the first active color when opening the dropdown.
124
- focusChildOnDropdownOpen(dropdownView, () => dropdownView.colorTableView.colorGridsPageView.staticColorsGrid.items.find((item) => item.isOn));
125
- return dropdownView;
126
- });
127
- }
128
- }
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/ui/colorui
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { createDropdown, normalizeColorOptions, getLocalizedColorOptions, focusChildOnDropdownOpen } from 'ckeditor5/src/ui';
10
+ import { addColorTableToDropdown } from '../utils';
11
+ /**
12
+ * The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
13
+ *
14
+ * It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
15
+ * a {@link module:font/ui/colortableview~ColorTableView}.
16
+ */
17
+ export default class ColorUI extends Plugin {
18
+ /**
19
+ * Creates a plugin which introduces a dropdown with a pre–configured {@link module:font/ui/colortableview~ColorTableView}.
20
+ *
21
+ * @param config The configuration object.
22
+ * @param config.commandName The name of the command which will be executed when a color tile is clicked.
23
+ * @param config.componentName The name of the dropdown in the {@link module:ui/componentfactory~ComponentFactory}
24
+ * and the configuration scope name in `editor.config`.
25
+ * @param config.icon The SVG icon used by the dropdown.
26
+ * @param config.dropdownLabel The label used by the dropdown.
27
+ */
28
+ constructor(editor, { commandName, componentName, icon, dropdownLabel }) {
29
+ super(editor);
30
+ this.commandName = commandName;
31
+ this.componentName = componentName;
32
+ this.icon = icon;
33
+ this.dropdownLabel = dropdownLabel;
34
+ this.columns = editor.config.get(`${this.componentName}.columns`);
35
+ this.colorTableView = undefined;
36
+ }
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ init() {
41
+ const editor = this.editor;
42
+ const locale = editor.locale;
43
+ const t = locale.t;
44
+ const command = editor.commands.get(this.commandName);
45
+ const componentConfig = editor.config.get(this.componentName);
46
+ const colorsConfig = normalizeColorOptions(componentConfig.colors);
47
+ const localizedColors = getLocalizedColorOptions(locale, colorsConfig);
48
+ const documentColorsCount = componentConfig.documentColors;
49
+ const hasColorPicker = componentConfig.colorPicker !== false;
50
+ // Register the UI component.
51
+ editor.ui.componentFactory.add(this.componentName, locale => {
52
+ const dropdownView = createDropdown(locale);
53
+ // Font color dropdown rendering is deferred once it gets open to improve performance (#6192).
54
+ let dropdownContentRendered = false;
55
+ this.colorTableView = addColorTableToDropdown({
56
+ dropdownView,
57
+ colors: localizedColors.map(option => ({
58
+ label: option.label,
59
+ color: option.model,
60
+ options: {
61
+ hasBorder: option.hasBorder
62
+ }
63
+ })),
64
+ columns: this.columns,
65
+ removeButtonLabel: t('Remove color'),
66
+ colorPickerLabel: t('Color picker'),
67
+ documentColorsLabel: documentColorsCount !== 0 ? t('Document colors') : '',
68
+ documentColorsCount: documentColorsCount === undefined ? this.columns : documentColorsCount,
69
+ colorPickerConfig: hasColorPicker ? (componentConfig.colorPicker || {}) : false
70
+ });
71
+ this.colorTableView.bind('selectedColor').to(command, 'value');
72
+ dropdownView.buttonView.set({
73
+ label: this.dropdownLabel,
74
+ icon: this.icon,
75
+ tooltip: true
76
+ });
77
+ dropdownView.extendTemplate({
78
+ attributes: {
79
+ class: 'ck-color-ui-dropdown'
80
+ }
81
+ });
82
+ dropdownView.bind('isEnabled').to(command);
83
+ this.colorTableView.on('execute', (evt, data) => {
84
+ if (dropdownView.isOpen) {
85
+ editor.execute(this.commandName, {
86
+ value: data.value,
87
+ batch: this._undoStepBatch
88
+ });
89
+ }
90
+ if (data.source !== 'colorPicker') {
91
+ editor.editing.view.focus();
92
+ }
93
+ });
94
+ this.colorTableView.on('showColorPicker', () => {
95
+ this._undoStepBatch = editor.model.createBatch();
96
+ });
97
+ this.colorTableView.on('cancel', () => {
98
+ if (this._undoStepBatch.operations.length) {
99
+ // We need to close the dropdown before the undo batch.
100
+ // Otherwise, ColorUI treats undo as a selected color change,
101
+ // propagating the update to the whole selection.
102
+ // That's an issue if spans with various colors were selected.
103
+ dropdownView.isOpen = false;
104
+ editor.execute('undo', this._undoStepBatch);
105
+ }
106
+ editor.editing.view.focus();
107
+ });
108
+ dropdownView.on('change:isOpen', (evt, name, isVisible) => {
109
+ if (!dropdownContentRendered) {
110
+ dropdownContentRendered = true;
111
+ dropdownView.colorTableView.appendUI();
112
+ }
113
+ if (isVisible) {
114
+ if (documentColorsCount !== 0) {
115
+ this.colorTableView.updateDocumentColors(editor.model, this.componentName);
116
+ }
117
+ this.colorTableView.updateSelectedColors();
118
+ }
119
+ else {
120
+ this.colorTableView.showColorGrids();
121
+ }
122
+ });
123
+ // Accessibility: focus the first active color when opening the dropdown.
124
+ focusChildOnDropdownOpen(dropdownView, () => dropdownView.colorTableView.colorGridsPageView.staticColorsGrid.items.find((item) => item.isOn));
125
+ return dropdownView;
126
+ });
127
+ }
128
+ }
package/src/utils.d.ts CHANGED
@@ -1,79 +1,79 @@
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/utils
7
- */
8
- import ColorTableView from './ui/colortableview';
9
- import type { FontFamilyOption, FontSizeOption } from './fontconfig';
10
- import type { ColorDefinition, ColorPickerConfig, DropdownView } from 'ckeditor5/src/ui';
11
- import type { ArrayOrItem } from 'ckeditor5/src/utils';
12
- import type { ViewAttributeElement, ViewElement, MatcherPattern, ViewElementDefinition, DowncastConversionApi } from 'ckeditor5/src/engine';
13
- /**
14
- * The name of the font size plugin.
15
- */
16
- export declare const FONT_SIZE = "fontSize";
17
- /**
18
- * The name of the font family plugin.
19
- */
20
- export declare const FONT_FAMILY = "fontFamily";
21
- /**
22
- * The name of the font color plugin.
23
- */
24
- export declare const FONT_COLOR = "fontColor";
25
- /**
26
- * The name of the font background color plugin.
27
- */
28
- export declare const FONT_BACKGROUND_COLOR = "fontBackgroundColor";
29
- /**
30
- * Builds a proper converter definition out of input data.
31
- */
32
- export declare function buildDefinition(modelAttributeKey: string, options: Array<FontFamilyOption> | Array<FontSizeOption>): FontConverterDefinition;
33
- export type FontConverterDefinition = {
34
- model: {
35
- key: string;
36
- values: Array<string>;
37
- };
38
- view: Record<string, ViewElementDefinition>;
39
- upcastAlso: Record<string, ArrayOrItem<MatcherPattern>>;
40
- };
41
- /**
42
- * A {@link module:font/fontcolor~FontColor font color} and
43
- * {@link module:font/fontbackgroundcolor~FontBackgroundColor font background color} helper
44
- * responsible for upcasting data to the model.
45
- *
46
- * **Note**: The `styleAttr` parameter should be either `'color'` or `'background-color'`.
47
- */
48
- export declare function renderUpcastAttribute(styleAttr: string): (viewElement: ViewElement) => string;
49
- /**
50
- * A {@link module:font/fontcolor~FontColor font color} and
51
- * {@link module:font/fontbackgroundcolor~FontBackgroundColor font background color} helper
52
- * responsible for downcasting a color attribute to a `<span>` element.
53
- *
54
- * **Note**: The `styleAttr` parameter should be either `'color'` or `'background-color'`.
55
- */
56
- export declare function renderDowncastElement(styleAttr: string): (modelAttributeValue: string, { writer }: DowncastConversionApi) => ViewAttributeElement;
57
- /**
58
- * A helper that adds {@link module:font/ui/colortableview~ColorTableView} to the color dropdown with proper initial values.
59
- *
60
- * @param config.dropdownView The dropdown view to which a {@link module:font/ui/colortableview~ColorTableView} will be added.
61
- * @param config.colors An array with definitions representing colors to be displayed in the color table.
62
- * @param config.removeButtonLabel The label for the button responsible for removing the color.
63
- * @param config.documentColorsLabel The label for the section with document colors.
64
- * @param config.documentColorsCount The number of document colors inside the dropdown.
65
- * @returns The new color table view.
66
- */
67
- export declare function addColorTableToDropdown({ dropdownView, colors, columns, removeButtonLabel, colorPickerLabel, documentColorsLabel, documentColorsCount, colorPickerConfig }: {
68
- dropdownView: ColorTableDropdownView;
69
- colors: Array<ColorDefinition>;
70
- columns: number;
71
- removeButtonLabel: string;
72
- colorPickerLabel: string;
73
- documentColorsLabel?: string;
74
- documentColorsCount?: number;
75
- colorPickerConfig: ColorPickerConfig | false;
76
- }): ColorTableView;
77
- export type ColorTableDropdownView = DropdownView & {
78
- colorTableView?: ColorTableView;
79
- };
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/utils
7
+ */
8
+ import ColorTableView from './ui/colortableview';
9
+ import type { FontFamilyOption, FontSizeOption } from './fontconfig';
10
+ import type { ColorDefinition, ColorPickerConfig, DropdownView } from 'ckeditor5/src/ui';
11
+ import type { ArrayOrItem } from 'ckeditor5/src/utils';
12
+ import type { ViewAttributeElement, ViewElement, MatcherPattern, ViewElementDefinition, DowncastConversionApi } from 'ckeditor5/src/engine';
13
+ /**
14
+ * The name of the font size plugin.
15
+ */
16
+ export declare const FONT_SIZE = "fontSize";
17
+ /**
18
+ * The name of the font family plugin.
19
+ */
20
+ export declare const FONT_FAMILY = "fontFamily";
21
+ /**
22
+ * The name of the font color plugin.
23
+ */
24
+ export declare const FONT_COLOR = "fontColor";
25
+ /**
26
+ * The name of the font background color plugin.
27
+ */
28
+ export declare const FONT_BACKGROUND_COLOR = "fontBackgroundColor";
29
+ /**
30
+ * Builds a proper converter definition out of input data.
31
+ */
32
+ export declare function buildDefinition(modelAttributeKey: string, options: Array<FontFamilyOption> | Array<FontSizeOption>): FontConverterDefinition;
33
+ export type FontConverterDefinition = {
34
+ model: {
35
+ key: string;
36
+ values: Array<string>;
37
+ };
38
+ view: Record<string, ViewElementDefinition>;
39
+ upcastAlso: Record<string, ArrayOrItem<MatcherPattern>>;
40
+ };
41
+ /**
42
+ * A {@link module:font/fontcolor~FontColor font color} and
43
+ * {@link module:font/fontbackgroundcolor~FontBackgroundColor font background color} helper
44
+ * responsible for upcasting data to the model.
45
+ *
46
+ * **Note**: The `styleAttr` parameter should be either `'color'` or `'background-color'`.
47
+ */
48
+ export declare function renderUpcastAttribute(styleAttr: string): (viewElement: ViewElement) => string;
49
+ /**
50
+ * A {@link module:font/fontcolor~FontColor font color} and
51
+ * {@link module:font/fontbackgroundcolor~FontBackgroundColor font background color} helper
52
+ * responsible for downcasting a color attribute to a `<span>` element.
53
+ *
54
+ * **Note**: The `styleAttr` parameter should be either `'color'` or `'background-color'`.
55
+ */
56
+ export declare function renderDowncastElement(styleAttr: string): (modelAttributeValue: string, { writer }: DowncastConversionApi) => ViewAttributeElement;
57
+ /**
58
+ * A helper that adds {@link module:font/ui/colortableview~ColorTableView} to the color dropdown with proper initial values.
59
+ *
60
+ * @param config.dropdownView The dropdown view to which a {@link module:font/ui/colortableview~ColorTableView} will be added.
61
+ * @param config.colors An array with definitions representing colors to be displayed in the color table.
62
+ * @param config.removeButtonLabel The label for the button responsible for removing the color.
63
+ * @param config.documentColorsLabel The label for the section with document colors.
64
+ * @param config.documentColorsCount The number of document colors inside the dropdown.
65
+ * @returns The new color table view.
66
+ */
67
+ export declare function addColorTableToDropdown({ dropdownView, colors, columns, removeButtonLabel, colorPickerLabel, documentColorsLabel, documentColorsCount, colorPickerConfig }: {
68
+ dropdownView: ColorTableDropdownView;
69
+ colors: Array<ColorDefinition>;
70
+ columns: number;
71
+ removeButtonLabel: string;
72
+ colorPickerLabel: string;
73
+ documentColorsLabel?: string;
74
+ documentColorsCount?: number;
75
+ colorPickerConfig: ColorPickerConfig | false;
76
+ }): ColorTableView;
77
+ export type ColorTableDropdownView = DropdownView & {
78
+ colorTableView?: ColorTableView;
79
+ };