@ckeditor/ckeditor5-table 0.0.0-nightly-20230630.0 → 0.0.0-nightly-20230702.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-table",
3
- "version": "0.0.0-nightly-20230630.0",
3
+ "version": "0.0.0-nightly-20230702.0",
4
4
  "description": "Table feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "ckeditor5": "0.0.0-nightly-20230630.0",
15
+ "ckeditor5": "0.0.0-nightly-20230702.0",
16
16
  "lodash-es": "^4.17.15"
17
17
  },
18
18
  "engines": {
@@ -108,10 +108,12 @@ export default class TableCellPropertiesUI extends Plugin {
108
108
  const localizedBorderColors = getLocalizedColorOptions(editor.locale, borderColorsConfig);
109
109
  const backgroundColorsConfig = normalizeColorOptions(config.backgroundColors);
110
110
  const localizedBackgroundColors = getLocalizedColorOptions(editor.locale, backgroundColorsConfig);
111
+ const hasColorPicker = config.colorPicker !== false;
111
112
  const view = new TableCellPropertiesView(editor.locale, {
112
113
  borderColors: localizedBorderColors,
113
114
  backgroundColors: localizedBackgroundColors,
114
- defaultTableCellProperties: this._defaultTableCellProperties
115
+ defaultTableCellProperties: this._defaultTableCellProperties,
116
+ colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false
115
117
  });
116
118
  const t = editor.t;
117
119
  // Render the view so its #element is available for the clickOutsideHandler.
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module table/tablecellproperties/ui/tablecellpropertiesview
7
7
  */
8
- import { ButtonView, FocusCycler, LabeledFieldView, View, ViewCollection, type FocusableView, type NormalizedColorOption } from 'ckeditor5/src/ui';
8
+ import { ButtonView, FocusCycler, LabeledFieldView, View, ViewCollection, type FocusableView, type NormalizedColorOption, type ColorPickerConfig } from 'ckeditor5/src/ui';
9
9
  import { KeystrokeHandler, FocusTracker, type Locale } from 'ckeditor5/src/utils';
10
10
  import type ColorInputView from '../../ui/colorinputview';
11
11
  import type { TableCellPropertiesOptions } from '../../tableconfig';
@@ -16,6 +16,7 @@ export interface TableCellPropertiesViewOptions {
16
16
  borderColors: Array<NormalizedColorOption>;
17
17
  backgroundColors: Array<NormalizedColorOption>;
18
18
  defaultTableCellProperties: TableCellPropertiesOptions;
19
+ colorPickerConfig: false | ColorPickerConfig;
19
20
  }
20
21
  /**
21
22
  * The class representing a table cell properties form, allowing users to customize
@@ -228,7 +228,8 @@ export default class TableCellPropertiesView extends View {
228
228
  const colorInputCreator = getLabeledColorInputCreator({
229
229
  colorConfig: this.options.borderColors,
230
230
  columns: 5,
231
- defaultColorValue: defaultBorder.color
231
+ defaultColorValue: defaultBorder.color,
232
+ colorPickerConfig: this.options.colorPickerConfig
232
233
  });
233
234
  const locale = this.locale;
234
235
  const t = this.t;
@@ -319,7 +320,8 @@ export default class TableCellPropertiesView extends View {
319
320
  const colorInputCreator = getLabeledColorInputCreator({
320
321
  colorConfig: this.options.backgroundColors,
321
322
  columns: 5,
322
- defaultColorValue: this.options.defaultTableCellProperties.backgroundColor
323
+ defaultColorValue: this.options.defaultTableCellProperties.backgroundColor,
324
+ colorPickerConfig: this.options.colorPickerConfig
323
325
  });
324
326
  const backgroundInput = new LabeledFieldView(locale, colorInputCreator);
325
327
  backgroundInput.set({
@@ -6,7 +6,7 @@
6
6
  * @module table/tableconfig
7
7
  */
8
8
  import type { ToolbarConfigItem } from 'ckeditor5/src/core';
9
- import type { ColorOption } from 'ckeditor5/src/ui';
9
+ import type { ColorOption, ColorPickerConfig } from 'ckeditor5/src/ui';
10
10
  /**
11
11
  * The configuration of the table feature. Used by the table feature in the `@ckeditor/ckeditor5-table` package.
12
12
  *
@@ -208,6 +208,12 @@ export interface TablePropertiesConfig {
208
208
  borderColors?: TableColorConfig;
209
209
  backgroundColors?: TableColorConfig;
210
210
  defaultProperties?: TablePropertiesOptions;
211
+ /**
212
+ * Configuration of the color picker in the table properties balloon.
213
+ *
214
+ * If set to `false` the picker will not appear.
215
+ */
216
+ colorPicker?: false | ColorPickerConfig;
211
217
  }
212
218
  /**
213
219
  * The configuration of the table default properties feature.
@@ -253,6 +259,12 @@ export interface TableCellPropertiesConfig {
253
259
  borderColors?: TableColorConfig;
254
260
  backgroundColors?: TableColorConfig;
255
261
  defaultProperties?: TableCellPropertiesOptions;
262
+ /**
263
+ * Configuration of the color picker in the table cell properties balloon.
264
+ *
265
+ * If set to `false` the picker will not appear.
266
+ */
267
+ colorPicker?: false | ColorPickerConfig;
256
268
  }
257
269
  /**
258
270
  * An array of color definitions (either strings or objects).
@@ -105,10 +105,12 @@ export default class TablePropertiesUI extends Plugin {
105
105
  const localizedBorderColors = getLocalizedColorOptions(editor.locale, borderColorsConfig);
106
106
  const backgroundColorsConfig = normalizeColorOptions(config.backgroundColors);
107
107
  const localizedBackgroundColors = getLocalizedColorOptions(editor.locale, backgroundColorsConfig);
108
+ const hasColorPicker = config.colorPicker !== false;
108
109
  const view = new TablePropertiesView(editor.locale, {
109
110
  borderColors: localizedBorderColors,
110
111
  backgroundColors: localizedBackgroundColors,
111
- defaultTableProperties: this._defaultTableProperties
112
+ defaultTableProperties: this._defaultTableProperties,
113
+ colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false
112
114
  });
113
115
  const t = editor.t;
114
116
  // Render the view so its #element is available for the clickOutsideHandler.
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module table/tableproperties/ui/tablepropertiesview
7
7
  */
8
- import { ButtonView, FocusCycler, LabeledFieldView, ToolbarView, View, ViewCollection, type DropdownView, type InputTextView, type NormalizedColorOption } from 'ckeditor5/src/ui';
8
+ import { ButtonView, FocusCycler, LabeledFieldView, ToolbarView, View, ViewCollection, type DropdownView, type InputTextView, type NormalizedColorOption, type ColorPickerConfig } from 'ckeditor5/src/ui';
9
9
  import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
10
10
  import '../../../theme/form.css';
11
11
  import '../../../theme/tableform.css';
@@ -30,6 +30,10 @@ export interface TablePropertiesViewOptions {
30
30
  * The default table properties.
31
31
  */
32
32
  defaultTableProperties: TablePropertiesOptions;
33
+ /**
34
+ * The default color picker config.
35
+ */
36
+ colorPickerConfig: false | ColorPickerConfig;
33
37
  }
34
38
  /**
35
39
  * The class representing a table properties form, allowing users to customize
@@ -204,7 +204,8 @@ export default class TablePropertiesView extends View {
204
204
  const colorInputCreator = getLabeledColorInputCreator({
205
205
  colorConfig: this.options.borderColors,
206
206
  columns: 5,
207
- defaultColorValue: defaultBorder.color
207
+ defaultColorValue: defaultBorder.color,
208
+ colorPickerConfig: this.options.colorPickerConfig
208
209
  });
209
210
  const locale = this.locale;
210
211
  const t = this.t;
@@ -295,7 +296,8 @@ export default class TablePropertiesView extends View {
295
296
  const backgroundInputCreator = getLabeledColorInputCreator({
296
297
  colorConfig: this.options.backgroundColors,
297
298
  columns: 5,
298
- defaultColorValue: this.options.defaultTableProperties.backgroundColor
299
+ defaultColorValue: this.options.defaultTableProperties.backgroundColor,
300
+ colorPickerConfig: this.options.colorPickerConfig
299
301
  });
300
302
  const backgroundInput = new LabeledFieldView(locale, backgroundInputCreator);
301
303
  backgroundInput.set({
@@ -5,13 +5,14 @@
5
5
  /**
6
6
  * @module table/ui/colorinputview
7
7
  */
8
- import { View, InputTextView, FocusCycler, ViewCollection, type ColorDefinition, type DropdownView } from 'ckeditor5/src/ui';
8
+ import { View, InputTextView, FocusCycler, ViewCollection, type ColorDefinition, type DropdownView, type ColorPickerConfig } from 'ckeditor5/src/ui';
9
9
  import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
10
10
  import '../../theme/colorinput.css';
11
11
  export type ColorInputViewOptions = {
12
12
  colorDefinitions: Array<ColorDefinition>;
13
13
  columns: number;
14
14
  defaultColorValue?: string;
15
+ colorPickerConfig: false | ColorPickerConfig;
15
16
  };
16
17
  /**
17
18
  * The color input view class. It allows the user to type in a color (hex, rgb, etc.)
@@ -121,13 +122,9 @@ export default class ColorInputView extends View {
121
122
  */
122
123
  private _createInputTextView;
123
124
  /**
124
- * Creates and configures the button that clears the color.
125
+ * Creates and configures the panel with "color grid" and "color picker" inside the {@link #dropdownView}.
125
126
  */
126
- private _createRemoveColorButton;
127
- /**
128
- * Creates and configures the color grid inside the {@link #dropdownView}.
129
- */
130
- private _createColorGrid;
127
+ private _createColorSelector;
131
128
  /**
132
129
  * Sets {@link #inputView}'s value property to the color value or color label,
133
130
  * if there is one and the user is not typing.
@@ -5,8 +5,7 @@
5
5
  /**
6
6
  * @module table/ui/colorinputview
7
7
  */
8
- import { View, InputTextView, ButtonView, createDropdown, ColorGridView, FocusCycler, ViewCollection } from 'ckeditor5/src/ui';
9
- import { icons } from 'ckeditor5/src/core';
8
+ import { View, InputTextView, createDropdown, FocusCycler, ViewCollection, ColorSelectorView } from 'ckeditor5/src/ui';
10
9
  import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
11
10
  import '../../theme/colorinput.css';
12
11
  /**
@@ -94,10 +93,9 @@ export default class ColorInputView extends View {
94
93
  const locale = this.locale;
95
94
  const t = locale.t;
96
95
  const bind = this.bindTemplate;
97
- const colorGrid = this._createColorGrid(locale);
96
+ const colorSelector = this._createColorSelector(locale);
98
97
  const dropdown = createDropdown(locale);
99
98
  const colorPreview = new View();
100
- const removeColorButton = this._createRemoveColorButton();
101
99
  colorPreview.setTemplate({
102
100
  tag: 'span',
103
101
  attributes: {
@@ -129,13 +127,16 @@ export default class ColorInputView extends View {
129
127
  dropdown.buttonView.label = t('Color picker');
130
128
  dropdown.buttonView.tooltip = true;
131
129
  dropdown.panelPosition = locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';
132
- dropdown.panelView.children.add(removeColorButton);
133
- dropdown.panelView.children.add(colorGrid);
130
+ dropdown.panelView.children.add(colorSelector);
134
131
  dropdown.bind('isEnabled').to(this, 'isReadOnly', value => !value);
135
- this._focusables.add(removeColorButton);
136
- this._focusables.add(colorGrid);
137
- this.focusTracker.add(removeColorButton.element);
138
- this.focusTracker.add(colorGrid.element);
132
+ this._focusables.add(colorSelector);
133
+ this.focusTracker.add(colorSelector.element);
134
+ dropdown.on('change:isOpen', (evt, name, isVisible) => {
135
+ if (isVisible) {
136
+ colorSelector.updateSelectedColors();
137
+ colorSelector.showColorGridsFragment();
138
+ }
139
+ });
139
140
  return dropdown;
140
141
  }
141
142
  /**
@@ -169,40 +170,56 @@ export default class ColorInputView extends View {
169
170
  return inputView;
170
171
  }
171
172
  /**
172
- * Creates and configures the button that clears the color.
173
+ * Creates and configures the panel with "color grid" and "color picker" inside the {@link #dropdownView}.
173
174
  */
174
- _createRemoveColorButton() {
175
- const locale = this.locale;
175
+ _createColorSelector(locale) {
176
176
  const t = locale.t;
177
- const removeColorButton = new ButtonView(locale);
178
177
  const defaultColor = this.options.defaultColorValue || '';
179
178
  const removeColorButtonLabel = defaultColor ? t('Restore default') : t('Remove color');
180
- removeColorButton.class = 'ck-input-color__remove-color';
181
- removeColorButton.withText = true;
182
- removeColorButton.icon = icons.eraser;
183
- removeColorButton.label = removeColorButtonLabel;
184
- removeColorButton.on('execute', () => {
185
- this.value = defaultColor;
186
- this.dropdownView.isOpen = false;
187
- this.fire('input');
179
+ const colorSelector = new ColorSelectorView(locale, {
180
+ colors: this.options.colorDefinitions,
181
+ columns: this.options.columns,
182
+ removeButtonLabel: removeColorButtonLabel,
183
+ colorPickerLabel: t('Color picker'),
184
+ colorPickerViewConfig: this.options.colorPickerConfig === false ? false : {
185
+ ...this.options.colorPickerConfig,
186
+ hideInput: true
187
+ }
188
188
  });
189
- return removeColorButton;
190
- }
191
- /**
192
- * Creates and configures the color grid inside the {@link #dropdownView}.
193
- */
194
- _createColorGrid(locale) {
195
- const colorGrid = new ColorGridView(locale, {
196
- colorDefinitions: this.options.colorDefinitions,
197
- columns: this.options.columns
189
+ colorSelector.appendUI();
190
+ colorSelector.on('execute', (evt, data) => {
191
+ if (data.source === 'colorPickerSaveButton') {
192
+ this.dropdownView.isOpen = false;
193
+ return;
194
+ }
195
+ this.value = data.value || defaultColor;
196
+ // Trigger the listener that actually applies the set value.
197
+ this.fire('input');
198
+ if (data.source !== 'colorPicker') {
199
+ this.dropdownView.isOpen = false;
200
+ }
198
201
  });
199
- colorGrid.on('execute', (evtData, data) => {
200
- this.value = data.value;
201
- this.dropdownView.isOpen = false;
202
+ /**
203
+ * Color is saved before changes in color picker. In case "cancel button" is pressed
204
+ * this color will be applied.
205
+ */
206
+ let backupColor = this.value;
207
+ colorSelector.on('colorPicker:cancel', () => {
208
+ /**
209
+ * Revert color to previous value before changes in color picker.
210
+ */
211
+ this.value = backupColor;
202
212
  this.fire('input');
213
+ this.dropdownView.isOpen = false;
214
+ });
215
+ colorSelector.colorGridsFragmentView.colorPickerButtonView.on('execute', () => {
216
+ /**
217
+ * Save color value before changes in color picker.
218
+ */
219
+ backupColor = this.value;
203
220
  });
204
- colorGrid.bind('selectedColor').to(this, 'value');
205
- return colorGrid;
221
+ colorSelector.bind('selectedColor').to(this, 'value');
222
+ return colorSelector;
206
223
  }
207
224
  /**
208
225
  * Sets {@link #inputView}'s value property to the color value or color label,
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module table/utils/ui/table-properties
7
7
  */
8
- import { type ColorOption, type LabeledFieldView, type ListDropdownItemDefinition, type NormalizedColorOption, type ToolbarView, type View } from 'ckeditor5/src/ui';
8
+ import { type ColorOption, type LabeledFieldView, type ListDropdownItemDefinition, type NormalizedColorOption, type ToolbarView, type View, type ColorPickerConfig } from 'ckeditor5/src/ui';
9
9
  import { Collection, type LocaleTranslate } from 'ckeditor5/src/utils';
10
10
  import type TableCellPropertiesView from '../../tablecellproperties/ui/tablecellpropertiesview';
11
11
  import type TablePropertiesView from '../../tableproperties/ui/tablepropertiesview';
@@ -185,9 +185,11 @@ export declare const defaultColors: Array<ColorOption>;
185
185
  * @param options.columns The configuration of the number of columns the color palette consists of in the input's dropdown.
186
186
  * @param options.defaultColorValue If specified, the color input view will replace the "Remove color" button with
187
187
  * the "Restore default" button. Instead of clearing the input field, the default color value will be set.
188
+ * @param options.colorPickerConfig The configuration of the color picker. You could disable it or define your output format.
188
189
  */
189
190
  export declare function getLabeledColorInputCreator(options: {
190
191
  colorConfig: Array<NormalizedColorOption>;
191
192
  columns: number;
192
193
  defaultColorValue?: string;
194
+ colorPickerConfig: false | ColorPickerConfig;
193
195
  }): (labeledFieldView: LabeledFieldView, viewUid: string, statusUid: string) => ColorInputView;
@@ -318,13 +318,15 @@ export const defaultColors = [
318
318
  * @param options.columns The configuration of the number of columns the color palette consists of in the input's dropdown.
319
319
  * @param options.defaultColorValue If specified, the color input view will replace the "Remove color" button with
320
320
  * the "Restore default" button. Instead of clearing the input field, the default color value will be set.
321
+ * @param options.colorPickerConfig The configuration of the color picker. You could disable it or define your output format.
321
322
  */
322
323
  export function getLabeledColorInputCreator(options) {
323
324
  return (labeledFieldView, viewUid, statusUid) => {
324
325
  const colorInputView = new ColorInputView(labeledFieldView.locale, {
325
326
  colorDefinitions: colorConfigToColorGridDefinitions(options.colorConfig),
326
327
  columns: options.columns,
327
- defaultColorValue: options.defaultColorValue
328
+ defaultColorValue: options.defaultColorValue,
329
+ colorPickerConfig: options.colorPickerConfig
328
330
  });
329
331
  colorInputView.inputView.set({
330
332
  id: viewUid,
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  :root {
7
- --ck-color-table-caption-background: hsl(0, 0%, 97%);
8
- --ck-color-table-caption-text: hsl(0, 0%, 20%);
9
- --ck-color-table-caption-highlighted-background: hsl(52deg 100% 50%);
7
+ --ck-color-selector-caption-background: hsl(0, 0%, 97%);
8
+ --ck-color-selector-caption-text: hsl(0, 0%, 20%);
9
+ --ck-color-selector-caption-highlighted-background: hsl(52deg 100% 50%);
10
10
  }
11
11
 
12
12
  /* Content styles */
@@ -15,8 +15,8 @@
15
15
  caption-side: top;
16
16
  word-break: break-word;
17
17
  text-align: center;
18
- color: var(--ck-color-table-caption-text);
19
- background-color: var(--ck-color-table-caption-background);
18
+ color: var(--ck-color-selector-caption-text);
19
+ background-color: var(--ck-color-selector-caption-background);
20
20
  padding: .6em;
21
21
  font-size: .75em;
22
22
  outline-offset: -1px;
@@ -44,10 +44,10 @@
44
44
 
45
45
  @keyframes ck-table-caption-highlight {
46
46
  0% {
47
- background-color: var(--ck-color-table-caption-highlighted-background);
47
+ background-color: var(--ck-color-selector-caption-highlighted-background);
48
48
  }
49
49
 
50
50
  100% {
51
- background-color: var(--ck-color-table-caption-background);
51
+ background-color: var(--ck-color-selector-caption-background);
52
52
  }
53
53
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  :root {
7
- --ck-color-table-column-resizer-hover: var(--ck-color-base-active);
7
+ --ck-color-selector-column-resizer-hover: var(--ck-color-base-active);
8
8
  --ck-table-column-resizer-width: 7px;
9
9
 
10
10
  /* The offset used for absolute positioning of the resizer element, so that it is placed exactly above the cell border.
@@ -55,7 +55,7 @@
55
55
 
56
56
  .ck.ck-editor__editable .table .ck-table-column-resizer:hover,
57
57
  .ck.ck-editor__editable .table .ck-table-column-resizer__active {
58
- background-color: var(--ck-color-table-column-resizer-hover);
58
+ background-color: var(--ck-color-selector-column-resizer-hover);
59
59
  opacity: 0.25;
60
60
  }
61
61