@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
@@ -0,0 +1,167 @@
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 { ColorGridView, FocusCycler, View, ViewCollection, type ColorDefinition } from 'ckeditor5/src/ui';
6
+ import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
7
+ import type { Model } from 'ckeditor5/src/engine';
8
+ import DocumentColorCollection from '../documentcolorcollection';
9
+ import '../../theme/fontcolor.css';
10
+ /**
11
+ * A class which represents a view with the following sub–components:
12
+ *
13
+ * * A remove color button,
14
+ * * A static {@link module:ui/colorgrid/colorgridview~ColorGridView} of colors defined in the configuration,
15
+ * * A dynamic {@link module:ui/colorgrid/colorgridview~ColorGridView} of colors used in the document.
16
+ */
17
+ export default class ColorTableView extends View {
18
+ /**
19
+ * A collection of the children of the table.
20
+ */
21
+ readonly items: ViewCollection;
22
+ /**
23
+ * An array with objects representing colors to be displayed in the grid.
24
+ */
25
+ colorDefinitions: Array<ColorDefinition>;
26
+ /**
27
+ * Tracks information about the DOM focus in the list.
28
+ */
29
+ readonly focusTracker: FocusTracker;
30
+ /**
31
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
32
+ */
33
+ readonly keystrokes: KeystrokeHandler;
34
+ /**
35
+ * The label of the button responsible for removing color attributes.
36
+ */
37
+ removeButtonLabel: string;
38
+ /**
39
+ * The number of columns in the color grid.
40
+ */
41
+ columns: number;
42
+ /**
43
+ * A collection of definitions that store the document colors.
44
+ *
45
+ * @readonly
46
+ */
47
+ documentColors: DocumentColorCollection;
48
+ /**
49
+ * The maximum number of colors in the document colors section.
50
+ * If it equals 0, the document colors section is not added.
51
+ *
52
+ * @readonly
53
+ */
54
+ documentColorsCount?: number;
55
+ /**
56
+ * A collection of views that can be focused in the view.
57
+ *
58
+ * @readonly
59
+ */
60
+ protected _focusables: ViewCollection;
61
+ /**
62
+ * Helps cycling over focusable {@link #items} in the list.
63
+ *
64
+ * @readonly
65
+ */
66
+ protected _focusCycler: FocusCycler;
67
+ /**
68
+ * Document color section's label.
69
+ *
70
+ * @readonly
71
+ */
72
+ private _documentColorsLabel?;
73
+ /**
74
+ * Keeps the value of the command associated with the table for the current selection.
75
+ */
76
+ selectedColor?: string;
77
+ /**
78
+ * Preserves the reference to {@link module:ui/colorgrid/colorgridview~ColorGridView} used to create
79
+ * the default (static) color set.
80
+ *
81
+ * The property is loaded once the the parent dropdown is opened the first time.
82
+ *
83
+ * @readonly
84
+ */
85
+ staticColorsGrid: ColorGridView | undefined;
86
+ /**
87
+ * Preserves the reference to {@link module:ui/colorgrid/colorgridview~ColorGridView} used to create
88
+ * the document colors. It remains undefined if the document colors feature is disabled.
89
+ *
90
+ * The property is loaded once the the parent dropdown is opened the first time.
91
+ *
92
+ * @readonly
93
+ */
94
+ documentColorsGrid: ColorGridView | undefined;
95
+ /**
96
+ * Creates a view to be inserted as a child of {@link module:ui/dropdown/dropdownview~DropdownView}.
97
+ *
98
+ * @param locale The localization services instance.
99
+ * @param colors An array with definitions of colors to be displayed in the table.
100
+ * @param columns The number of columns in the color grid.
101
+ * @param removeButtonLabel The label of the button responsible for removing the color.
102
+ * @param documentColorsLabel The label for the section with the document colors.
103
+ * @param documentColorsCount The number of colors in the document colors section inside the color dropdown.
104
+ */
105
+ constructor(locale: Locale, { colors, columns, removeButtonLabel, documentColorsLabel, documentColorsCount }: {
106
+ colors: Array<ColorDefinition>;
107
+ columns: number;
108
+ removeButtonLabel: string;
109
+ documentColorsLabel?: string;
110
+ documentColorsCount?: number;
111
+ });
112
+ /**
113
+ * Scans through the editor model and searches for text node attributes with the given attribute name.
114
+ * Found entries are set as document colors.
115
+ *
116
+ * All the previously stored document colors will be lost in the process.
117
+ *
118
+ * @param model The model used as a source to obtain the document colors.
119
+ * @param attributeName Determines the name of the related model's attribute for a given dropdown.
120
+ */
121
+ updateDocumentColors(model: Model, attributeName: string): void;
122
+ /**
123
+ * Refreshes the state of the selected color in one or both {@link module:ui/colorgrid/colorgridview~ColorGridView}s
124
+ * available in the {@link module:font/ui/colortableview~ColorTableView}. It guarantees that the selection will occur only in one
125
+ * of them.
126
+ */
127
+ updateSelectedColors(): void;
128
+ /**
129
+ * @inheritDoc
130
+ */
131
+ render(): void;
132
+ /**
133
+ * @inheritDoc
134
+ */
135
+ destroy(): void;
136
+ /**
137
+ * Appends {@link #staticColorsGrid} and {@link #documentColorsGrid} views.
138
+ */
139
+ appendGrids(): void;
140
+ /**
141
+ * Focuses the first focusable element in {@link #items}.
142
+ */
143
+ focus(): void;
144
+ /**
145
+ * Focuses the last focusable element in {@link #items}.
146
+ */
147
+ focusLast(): void;
148
+ /**
149
+ * Adds the remove color button as a child of the current view.
150
+ */
151
+ private _createRemoveColorButton;
152
+ /**
153
+ * Creates a static color table grid based on the editor configuration.
154
+ */
155
+ private _createStaticColorsGrid;
156
+ /**
157
+ * Creates the document colors section view and binds it to {@link #documentColors}.
158
+ */
159
+ private _createDocumentColorsGrid;
160
+ /**
161
+ * Adds a given color to the document colors list. If possible, the method will attempt to use
162
+ * data from the {@link #colorDefinitions} (label, color options).
163
+ *
164
+ * @param color A string that stores the value of the recently applied color.
165
+ */
166
+ private _addColorToDocumentColors;
167
+ }