@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
|
@@ -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/colorgrid~ColorGridView} of colors defined in the configuration,
|
|
15
|
+
* * A dynamic {@link module:ui/colorgrid/colorgrid~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/colorgrid~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/colorgrid~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/colorgrid~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
|
+
}
|