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 table/tableproperties/ui/tablepropertiesview
|
7 | */
|
8 | import { ButtonView, FocusCycler, LabeledFieldView, ToolbarView, View, ViewCollection, type DropdownView, type InputTextView, type NormalizedColorOption } from 'ckeditor5/src/ui';
|
9 | import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
|
10 | import '../../../theme/form.css';
|
11 | import '../../../theme/tableform.css';
|
12 | import '../../../theme/tableproperties.css';
|
13 | import type ColorInputView from '../../ui/colorinputview';
|
14 | import type { TablePropertiesOptions } from '../../tableconfig';
|
15 | /**
|
16 | * Additional configuration of the view.
|
17 | */
|
18 | export interface TablePropertiesViewOptions {
|
19 | /**
|
20 | * A configuration of the border color palette used by the
|
21 | * {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView#borderColorInput}.
|
22 | */
|
23 | borderColors: Array<NormalizedColorOption>;
|
24 | /**
|
25 | * A configuration of the background color palette used by the
|
26 | * {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView#backgroundInput}.
|
27 | */
|
28 | backgroundColors: Array<NormalizedColorOption>;
|
29 | /**
|
30 | * The default table properties.
|
31 | */
|
32 | defaultTableProperties: TablePropertiesOptions;
|
33 | }
|
34 | /**
|
35 | * The class representing a table properties form, allowing users to customize
|
36 | * certain style aspects of a table, for instance, border, background color, alignment, etc..
|
37 | */
|
38 | export default class TablePropertiesView extends View {
|
39 | /**
|
40 | * The value of the border style.
|
41 | *
|
42 | * @observable
|
43 | * @default ''
|
44 | */
|
45 | borderStyle: string;
|
46 | /**
|
47 | * The value of the border width style.
|
48 | *
|
49 | * @observable
|
50 | * @default ''
|
51 | */
|
52 | borderWidth: string;
|
53 | /**
|
54 | * The value of the border color style.
|
55 | *
|
56 | * @observable
|
57 | * @default ''
|
58 | */
|
59 | borderColor: string;
|
60 | /**
|
61 | * The value of the background color style.
|
62 | *
|
63 | * @observable
|
64 | * @default ''
|
65 | */
|
66 | backgroundColor: string;
|
67 | /**
|
68 | * The value of the table width style.
|
69 | *
|
70 | * @observable
|
71 | * @default ''
|
72 | */
|
73 | width: string;
|
74 | /**
|
75 | * The value of the table height style.
|
76 | *
|
77 | * @observable
|
78 | * @default ''
|
79 | */
|
80 | height: string;
|
81 | /**
|
82 | * The value of the table alignment style.
|
83 | *
|
84 | * @observable
|
85 | * @default ''
|
86 | */
|
87 | alignment: string;
|
88 | /**
|
89 | * Options passed to the view. See {@link #constructor} to learn more.
|
90 | */
|
91 | readonly options: TablePropertiesViewOptions;
|
92 | /**
|
93 | * Tracks information about the DOM focus in the form.
|
94 | */
|
95 | readonly focusTracker: FocusTracker;
|
96 | /**
|
97 | * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
98 | */
|
99 | readonly keystrokes: KeystrokeHandler;
|
100 | /**
|
101 | * A collection of child views in the form.
|
102 | */
|
103 | readonly children: ViewCollection;
|
104 | /**
|
105 | * A dropdown that allows selecting the style of the table border.
|
106 | */
|
107 | readonly borderStyleDropdown: LabeledFieldView<DropdownView>;
|
108 | /**
|
109 | * An input that allows specifying the width of the table border.
|
110 | */
|
111 | readonly borderWidthInput: LabeledFieldView<InputTextView>;
|
112 | /**
|
113 | * An input that allows specifying the color of the table border.
|
114 | */
|
115 | readonly borderColorInput: LabeledFieldView<ColorInputView>;
|
116 | /**
|
117 | * An input that allows specifying the table background color.
|
118 | */
|
119 | readonly backgroundInput: LabeledFieldView<ColorInputView>;
|
120 | /**
|
121 | * An input that allows specifying the table width.
|
122 | */
|
123 | readonly widthInput: LabeledFieldView<InputTextView>;
|
124 | /**
|
125 | * An input that allows specifying the table height.
|
126 | */
|
127 | readonly heightInput: LabeledFieldView<InputTextView>;
|
128 | /**
|
129 | * A toolbar with buttons that allow changing the alignment of an entire table.
|
130 | */
|
131 | readonly alignmentToolbar: ToolbarView;
|
132 | /**
|
133 | * The "Save" button view.
|
134 | */
|
135 | saveButtonView: ButtonView;
|
136 | /**
|
137 | * The "Cancel" button view.
|
138 | */
|
139 | cancelButtonView: ButtonView;
|
140 | /**
|
141 | * A collection of views that can be focused in the form.
|
142 | */
|
143 | protected readonly _focusables: ViewCollection;
|
144 | /**
|
145 | * Helps cycling over {@link #_focusables} in the form.
|
146 | */
|
147 | protected readonly _focusCycler: FocusCycler;
|
148 | /**
|
149 | * @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
150 | * @param options Additional configuration of the view.
|
151 | */
|
152 | constructor(locale: Locale, options: TablePropertiesViewOptions);
|
153 | /**
|
154 | * @inheritDoc
|
155 | */
|
156 | render(): void;
|
157 | /**
|
158 | * @inheritDoc
|
159 | */
|
160 | destroy(): void;
|
161 | /**
|
162 | * Focuses the fist focusable field in the form.
|
163 | */
|
164 | focus(): void;
|
165 | /**
|
166 | * Creates the following form fields:
|
167 | *
|
168 | * * { #borderStyleDropdown},
|
169 | * * { #borderWidthInput},
|
170 | * * { #borderColorInput}.
|
171 | */
|
172 | private _createBorderFields;
|
173 | /**
|
174 | * Creates the following form fields:
|
175 | *
|
176 | * * {@link #backgroundInput}.
|
177 | */
|
178 | private _createBackgroundFields;
|
179 | /**
|
180 | * Creates the following form fields:
|
181 | *
|
182 | * * {@link #widthInput},
|
183 | * * {@link #heightInput}.
|
184 | */
|
185 | private _createDimensionFields;
|
186 | /**
|
187 | * Creates the following form fields:
|
188 | *
|
189 | * * {@link #alignmentToolbar}.
|
190 | */
|
191 | private _createAlignmentFields;
|
192 | /**
|
193 | * Creates the following form controls:
|
194 | *
|
195 | * * {@link #saveButtonView},
|
196 | * * {@link #cancelButtonView}.
|
197 | */
|
198 | private _createActionButtons;
|
199 | /**
|
200 | * Provides localized labels for {@link #alignmentToolbar} buttons.
|
201 | */
|
202 | private get _alignmentLabels();
|
203 | }
|