@ckeditor/ckeditor5-ui 38.2.0-alpha.0 → 38.2.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 (111) hide show
  1. package/lang/contexts.json +2 -1
  2. package/package.json +3 -3
  3. package/src/augmentation.d.ts +1 -1
  4. package/src/bindings/addkeyboardhandlingforgrid.d.ts +1 -1
  5. package/src/bindings/csstransitiondisablermixin.d.ts +1 -1
  6. package/src/bindings/injectcsstransitiondisabler.d.ts +2 -2
  7. package/src/bindings/injectcsstransitiondisabler.js +1 -1
  8. package/src/bindings/preventdefault.d.ts +3 -3
  9. package/src/bindings/preventdefault.js +1 -1
  10. package/src/bindings/submithandler.d.ts +2 -2
  11. package/src/bindings/submithandler.js +1 -1
  12. package/src/button/buttonview.d.ts +4 -4
  13. package/src/button/buttonview.js +2 -2
  14. package/src/button/switchbuttonview.d.ts +2 -2
  15. package/src/button/switchbuttonview.js +2 -2
  16. package/src/colorgrid/colorgridview.d.ts +4 -4
  17. package/src/colorgrid/colorgridview.js +3 -3
  18. package/src/colorgrid/colortileview.d.ts +1 -1
  19. package/src/colorgrid/colortileview.js +2 -2
  20. package/src/colorpicker/colorpickerview.d.ts +37 -10
  21. package/src/colorpicker/colorpickerview.js +33 -16
  22. package/src/colorpicker/utils.d.ts +8 -0
  23. package/src/colorselector/colorgridsfragmentview.d.ts +194 -0
  24. package/src/colorselector/colorgridsfragmentview.js +290 -0
  25. package/src/colorselector/colorpickerfragmentview.d.ts +128 -0
  26. package/src/colorselector/colorpickerfragmentview.js +205 -0
  27. package/src/colorselector/colorselectorview.d.ts +242 -0
  28. package/src/colorselector/colorselectorview.js +256 -0
  29. package/src/colorselector/documentcolorcollection.d.ts +70 -0
  30. package/src/colorselector/documentcolorcollection.js +42 -0
  31. package/src/componentfactory.d.ts +1 -1
  32. package/src/dropdown/button/dropdownbutton.d.ts +2 -2
  33. package/src/dropdown/button/dropdownbuttonview.d.ts +3 -3
  34. package/src/dropdown/button/dropdownbuttonview.js +2 -2
  35. package/src/dropdown/button/splitbuttonview.d.ts +5 -5
  36. package/src/dropdown/button/splitbuttonview.js +2 -2
  37. package/src/dropdown/dropdownpanelview.d.ts +3 -3
  38. package/src/dropdown/dropdownpanelview.js +1 -1
  39. package/src/dropdown/dropdownview.d.ts +6 -6
  40. package/src/dropdown/dropdownview.js +1 -1
  41. package/src/dropdown/utils.d.ts +7 -7
  42. package/src/dropdown/utils.js +16 -13
  43. package/src/editableui/editableuiview.d.ts +1 -1
  44. package/src/editableui/editableuiview.js +1 -1
  45. package/src/editableui/inline/inlineeditableuiview.d.ts +1 -1
  46. package/src/editableui/inline/inlineeditableuiview.js +1 -1
  47. package/src/editorui/bodycollection.d.ts +2 -2
  48. package/src/editorui/bodycollection.js +2 -2
  49. package/src/editorui/boxed/boxededitoruiview.d.ts +2 -2
  50. package/src/editorui/boxed/boxededitoruiview.js +2 -2
  51. package/src/editorui/editorui.d.ts +5 -5
  52. package/src/editorui/editorui.js +3 -3
  53. package/src/editorui/editoruiview.d.ts +3 -3
  54. package/src/editorui/editoruiview.js +2 -2
  55. package/src/editorui/poweredby.js +3 -3
  56. package/src/focuscycler.d.ts +2 -2
  57. package/src/formheader/formheaderview.d.ts +2 -2
  58. package/src/formheader/formheaderview.js +1 -1
  59. package/src/icon/iconview.d.ts +1 -1
  60. package/src/icon/iconview.js +1 -1
  61. package/src/iframe/iframeview.d.ts +1 -1
  62. package/src/iframe/iframeview.js +1 -1
  63. package/src/index.d.ts +53 -52
  64. package/src/index.js +51 -50
  65. package/src/input/inputview.d.ts +1 -1
  66. package/src/input/inputview.js +1 -1
  67. package/src/inputnumber/inputnumberview.d.ts +1 -1
  68. package/src/inputnumber/inputnumberview.js +1 -1
  69. package/src/inputtext/inputtextview.d.ts +1 -1
  70. package/src/inputtext/inputtextview.js +1 -1
  71. package/src/label/labelview.d.ts +1 -1
  72. package/src/label/labelview.js +1 -1
  73. package/src/labeledfield/labeledfieldview.d.ts +4 -4
  74. package/src/labeledfield/labeledfieldview.js +2 -2
  75. package/src/labeledfield/utils.d.ts +4 -4
  76. package/src/labeledfield/utils.js +3 -3
  77. package/src/labeledinput/labeledinputview.d.ts +3 -3
  78. package/src/labeledinput/labeledinputview.js +2 -2
  79. package/src/list/listitemview.d.ts +2 -2
  80. package/src/list/listitemview.js +1 -1
  81. package/src/list/listseparatorview.d.ts +1 -1
  82. package/src/list/listseparatorview.js +1 -1
  83. package/src/list/listview.d.ts +3 -3
  84. package/src/list/listview.js +2 -2
  85. package/src/panel/balloon/balloonpanelview.d.ts +2 -2
  86. package/src/panel/balloon/balloonpanelview.js +1 -1
  87. package/src/panel/balloon/contextualballoon.d.ts +4 -4
  88. package/src/panel/balloon/contextualballoon.js +3 -3
  89. package/src/panel/sticky/stickypanelview.d.ts +41 -17
  90. package/src/panel/sticky/stickypanelview.js +179 -46
  91. package/src/template.d.ts +2 -2
  92. package/src/template.js +2 -2
  93. package/src/toolbar/balloon/balloontoolbar.d.ts +2 -2
  94. package/src/toolbar/balloon/balloontoolbar.js +4 -4
  95. package/src/toolbar/block/blockbuttonview.d.ts +1 -1
  96. package/src/toolbar/block/blockbuttonview.js +1 -1
  97. package/src/toolbar/block/blocktoolbar.d.ts +3 -3
  98. package/src/toolbar/block/blocktoolbar.js +5 -5
  99. package/src/toolbar/toolbarlinebreakview.d.ts +1 -1
  100. package/src/toolbar/toolbarlinebreakview.js +1 -1
  101. package/src/toolbar/toolbarseparatorview.d.ts +1 -1
  102. package/src/toolbar/toolbarseparatorview.js +1 -1
  103. package/src/toolbar/toolbarview.d.ts +4 -4
  104. package/src/toolbar/toolbarview.js +7 -7
  105. package/src/tooltipmanager.d.ts +2 -2
  106. package/src/tooltipmanager.js +2 -2
  107. package/src/view.d.ts +2 -2
  108. package/src/view.js +2 -2
  109. package/src/viewcollection.d.ts +1 -1
  110. package/theme/components/colorpicker/colorpicker.css +10 -0
  111. package/theme/components/colorselector/colorselector.css +35 -0
@@ -23,5 +23,6 @@
23
23
  "Purple": "Label of a button that applies a purple color in color pickers.",
24
24
  "Editor block content toolbar": "Accessible label of a toolbar that shows up next to the blocks of content (e.g. headings, paragraphs).",
25
25
  "Editor contextual toolbar": "Accessible label of a balloon toolbar that shows up right next to the user selection (the caret).",
26
- "HEX": "Label of an input field for typing colors in the HEX color format."
26
+ "HEX": "Label of an input field for typing colors in the HEX color format.",
27
+ "Accept": "Label of the button closing the color picker and confirming the changes done in the color selector component."
27
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-ui",
3
- "version": "38.2.0-alpha.0",
3
+ "version": "38.2.0-alpha.1",
4
4
  "description": "The UI framework and standard UI library of CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,8 +12,8 @@
12
12
  "main": "src/index.js",
13
13
  "type": "module",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "38.2.0-alpha.0",
16
- "@ckeditor/ckeditor5-utils": "38.2.0-alpha.0",
15
+ "@ckeditor/ckeditor5-core": "38.2.0-alpha.1",
16
+ "@ckeditor/ckeditor5-utils": "38.2.0-alpha.1",
17
17
  "color-convert": "2.0.1",
18
18
  "color-parse": "1.4.2",
19
19
  "lodash-es": "^4.17.15",
@@ -2,7 +2,7 @@
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import type { BalloonToolbar, BlockToolbar, ContextualBalloon, Notification } from './index';
5
+ import type { BalloonToolbar, BlockToolbar, ContextualBalloon, Notification } from './index.js';
6
6
  import type { ToolbarConfig } from '@ckeditor/ckeditor5-core';
7
7
  declare module '@ckeditor/ckeditor5-core' {
8
8
  interface EditorConfig {
@@ -6,7 +6,7 @@
6
6
  * @module ui/bindings/addkeyboardhandlingforgrid
7
7
  */
8
8
  import type { FocusTracker, KeystrokeHandler } from '@ckeditor/ckeditor5-utils';
9
- import type ViewCollection from '../viewcollection';
9
+ import type ViewCollection from '../viewcollection.js';
10
10
  /**
11
11
  * A helper that adds a keyboard navigation support (arrow up/down/left/right) for grids.
12
12
  *
@@ -6,7 +6,7 @@
6
6
  * @module ui/bindings/csstransitiondisablermixin
7
7
  */
8
8
  import type { Constructor, Mixed } from '@ckeditor/ckeditor5-utils';
9
- import type View from '../view';
9
+ import type View from '../view.js';
10
10
  /**
11
11
  * A mixin that brings the possibility to temporarily disable CSS transitions using
12
12
  * {@link module:ui/view~View} methods. It is helpful when, for instance, the transitions should not happen
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module ui/bindings/injectcsstransitiondisabler
7
7
  */
8
- import type View from '../view';
8
+ import type View from '../view.js';
9
9
  /**
10
10
  * A decorator that brings the possibility to temporarily disable CSS transitions using
11
11
  * {@link module:ui/view~View} methods. It is helpful when, for instance, the transitions should not happen
@@ -21,7 +21,7 @@ import type View from '../view';
21
21
  * {@link module:ui/view~View#setTemplate} is called:
22
22
  *
23
23
  * ```ts
24
- * import injectCssTransitionDisabler from '@ckeditor/ckeditor5-ui/src/bindings/injectcsstransitiondisabler';
24
+ * import injectCssTransitionDisabler from '@ckeditor/ckeditor5-ui/src/bindings/injectcsstransitiondisabler.js';
25
25
  *
26
26
  * class MyView extends View {
27
27
  * constructor() {
@@ -17,7 +17,7 @@
17
17
  * {@link module:ui/view~View#setTemplate} is called:
18
18
  *
19
19
  * ```ts
20
- * import injectCssTransitionDisabler from '@ckeditor/ckeditor5-ui/src/bindings/injectcsstransitiondisabler';
20
+ * import injectCssTransitionDisabler from '@ckeditor/ckeditor5-ui/src/bindings/injectcsstransitiondisabler.js';
21
21
  *
22
22
  * class MyView extends View {
23
23
  * constructor() {
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module ui/bindings/preventdefault
7
7
  */
8
- import type { ListenerBinding } from '../template';
9
- import type View from '../view';
8
+ import type { ListenerBinding } from '../template.js';
9
+ import type View from '../view.js';
10
10
  /**
11
11
  * A helper which executes a native `Event.preventDefault()` if the target of an event equals the
12
12
  * {@link module:ui/view~View#element element of the view}. It shortens the definition of a
@@ -14,7 +14,7 @@ import type View from '../view';
14
14
  *
15
15
  * ```ts
16
16
  * // In a class extending View.
17
- * import preventDefault from '@ckeditor/ckeditor5-ui/src/bindings/preventdefault';
17
+ * import preventDefault from '@ckeditor/ckeditor5-ui/src/bindings/preventdefault.js';
18
18
  *
19
19
  * // ...
20
20
  *
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * ```ts
11
11
  * // In a class extending View.
12
- * import preventDefault from '@ckeditor/ckeditor5-ui/src/bindings/preventdefault';
12
+ * import preventDefault from '@ckeditor/ckeditor5-ui/src/bindings/preventdefault.js';
13
13
  *
14
14
  * // ...
15
15
  *
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module ui/bindings/submithandler
7
7
  */
8
- import type View from '../view';
8
+ import type View from '../view.js';
9
9
  /**
10
10
  * A handler useful for {@link module:ui/view~View views} working as HTML forms. It intercepts a native DOM
11
11
  * `submit` event, prevents the default web browser behavior (navigation and page reload) and
@@ -13,7 +13,7 @@ import type View from '../view';
13
13
  * {@link module:utils/dom/emittermixin~DomEmitter emitter}, e.g. to serialize the form data.
14
14
  *
15
15
  * ```ts
16
- * import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler';
16
+ * import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler.js';
17
17
  *
18
18
  * // ...
19
19
  *
@@ -9,7 +9,7 @@
9
9
  * {@link module:utils/dom/emittermixin~DomEmitter emitter}, e.g. to serialize the form data.
10
10
  *
11
11
  * ```ts
12
- * import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler';
12
+ * import submitHandler from '@ckeditor/ckeditor5-ui/src/bindings/submithandler.js';
13
13
  *
14
14
  * // ...
15
15
  *
@@ -5,10 +5,10 @@
5
5
  /**
6
6
  * @module ui/button/buttonview
7
7
  */
8
- import View from '../view';
9
- import IconView from '../icon/iconview';
10
- import type ViewCollection from '../viewcollection';
11
- import type { default as Button } from './button';
8
+ import View from '../view.js';
9
+ import IconView from '../icon/iconview.js';
10
+ import type ViewCollection from '../viewcollection.js';
11
+ import type { default as Button } from './button.js';
12
12
  import { type Locale } from '@ckeditor/ckeditor5-utils';
13
13
  import '../../theme/components/button/button.css';
14
14
  /**
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module ui/button/buttonview
7
7
  */
8
- import View from '../view';
9
- import IconView from '../icon/iconview';
8
+ import View from '../view.js';
9
+ import IconView from '../icon/iconview.js';
10
10
  import { env, getEnvKeystrokeText, uid, delay } from '@ckeditor/ckeditor5-utils';
11
11
  import '../../theme/components/button/button.css';
12
12
  /**
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module ui/button/switchbuttonview
7
7
  */
8
- import View from '../view';
9
- import ButtonView from './buttonview';
8
+ import View from '../view.js';
9
+ import ButtonView from './buttonview.js';
10
10
  import type { Locale } from '@ckeditor/ckeditor5-utils';
11
11
  import '../../theme/components/button/switchbutton.css';
12
12
  /**
@@ -5,8 +5,8 @@
5
5
  /**
6
6
  * @module ui/button/switchbuttonview
7
7
  */
8
- import View from '../view';
9
- import ButtonView from './buttonview';
8
+ import View from '../view.js';
9
+ import ButtonView from './buttonview.js';
10
10
  import '../../theme/components/button/switchbutton.css';
11
11
  /**
12
12
  * The switch button view class.
@@ -5,10 +5,10 @@
5
5
  /**
6
6
  * @module ui/colorgrid/colorgridview
7
7
  */
8
- import View from '../view';
9
- import ColorTileView from './colortileview';
10
- import type DropdownPanelFocusable from '../dropdown/dropdownpanelfocusable';
11
- import type ViewCollection from '../viewcollection';
8
+ import View from '../view.js';
9
+ import ColorTileView from './colortileview.js';
10
+ import type DropdownPanelFocusable from '../dropdown/dropdownpanelfocusable.js';
11
+ import type ViewCollection from '../viewcollection.js';
12
12
  import { FocusTracker, KeystrokeHandler, type Locale } from '@ckeditor/ckeditor5-utils';
13
13
  import '../../theme/components/colorgrid/colorgrid.css';
14
14
  /**
@@ -5,9 +5,9 @@
5
5
  /**
6
6
  * @module ui/colorgrid/colorgridview
7
7
  */
8
- import View from '../view';
9
- import ColorTileView from './colortileview';
10
- import addKeyboardHandlingForGrid from '../bindings/addkeyboardhandlingforgrid';
8
+ import View from '../view.js';
9
+ import ColorTileView from './colortileview.js';
10
+ import addKeyboardHandlingForGrid from '../bindings/addkeyboardhandlingforgrid.js';
11
11
  import { FocusTracker, KeystrokeHandler } from '@ckeditor/ckeditor5-utils';
12
12
  import '../../theme/components/colorgrid/colorgrid.css';
13
13
  /**
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module ui/colorgrid/colortileview
7
7
  */
8
- import ButtonView from '../button/buttonview';
8
+ import ButtonView from '../button/buttonview.js';
9
9
  import type { Locale } from '@ckeditor/ckeditor5-utils';
10
10
  /**
11
11
  * This class represents a single color tile in the {@link module:ui/colorgrid/colorgridview~ColorGridView}.
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module ui/colorgrid/colortileview
7
7
  */
8
- import ButtonView from '../button/buttonview';
8
+ import ButtonView from '../button/buttonview.js';
9
9
  import checkIcon from '../../theme/icons/color-tile-check.svg';
10
10
  /**
11
11
  * This class represents a single color tile in the {@link module:ui/colorgrid/colorgridview~ColorGridView}.
@@ -25,7 +25,7 @@ export default class ColorTileView extends ButtonView {
25
25
  class: [
26
26
  'ck',
27
27
  'ck-color-grid__tile',
28
- bind.if('hasBorder', 'ck-color-table__color-tile_bordered')
28
+ bind.if('hasBorder', 'ck-color-selector__color-tile_bordered')
29
29
  ]
30
30
  }
31
31
  });
@@ -5,12 +5,15 @@
5
5
  /**
6
6
  * @module ui/colorpicker/colorpickerview
7
7
  */
8
- import { type ColorPickerConfig } from './utils';
8
+ import { type ColorPickerViewConfig } from './utils.js';
9
9
  import { type Locale } from '@ckeditor/ckeditor5-utils';
10
- import View from '../view';
11
- import type ViewCollection from '../viewcollection';
10
+ import View from '../view.js';
11
+ import type ViewCollection from '../viewcollection.js';
12
12
  import 'vanilla-colorful/hex-color-picker.js';
13
13
  import '../../theme/components/colorpicker/colorpicker.css';
14
+ /**
15
+ * A class which represents a color picker with an input field for defining custom colors.
16
+ */
14
17
  export default class ColorPickerView extends View {
15
18
  /**
16
19
  * Element with saturation and hue sliders.
@@ -22,7 +25,8 @@ export default class ColorPickerView extends View {
22
25
  */
23
26
  hexInputRow: ColorPickerInputRowView;
24
27
  /**
25
- * Current color state in color picker.
28
+ * Current color selected in the color picker. It can be set by the component itself
29
+ * (through the palette or input) or from the outside (e.g. to reflect the current selection color).
26
30
  */
27
31
  color: string;
28
32
  /**
@@ -42,21 +46,26 @@ export default class ColorPickerView extends View {
42
46
  */
43
47
  _hexColor: string;
44
48
  /**
45
- * Debounced event method. The `colorPickerEvent()` method is called the specified `waitingTime` after
46
- * `debouncedPickerEvent()` is called, unless a new action happens in the meantime.
47
- */
49
+ * Debounced function updating the `color` property in the component
50
+ * and firing the `ColorPickerColorSelectedEvent`. Executed whenever color in component
51
+ * is changed by the user interaction (through the palette or input).
52
+ *
53
+ * @private
54
+ */
48
55
  private _debounceColorPickerEvent;
49
56
  /**
50
- * The output format (the one in which colors are applied in the model) of color picker.
57
+ * A reference to the configuration of the color picker specified in the constructor.
58
+ *
59
+ * @private
51
60
  */
52
- private _format;
61
+ private _config;
53
62
  /**
54
63
  * Creates a view of color picker.
55
64
  *
56
65
  * @param locale
57
66
  * @param config
58
67
  */
59
- constructor(locale: Locale | undefined, config: ColorPickerConfig);
68
+ constructor(locale: Locale | undefined, config?: ColorPickerViewConfig);
60
69
  /**
61
70
  * Renders color picker in the view.
62
71
  */
@@ -107,4 +116,22 @@ declare class ColorPickerInputRowView extends View {
107
116
  */
108
117
  constructor(locale: Locale, children?: Array<View>);
109
118
  }
119
+ /**
120
+ * An event fired whenever the color was selected through the color picker palette
121
+ * or the color picker input.
122
+ *
123
+ * This even fires only when the user changes the color. It does not fire when the color
124
+ * is changed programmatically, e.g. via
125
+ * {@link module:ui/colorpicker/colorpickerview~ColorPickerView#color}.
126
+ *
127
+ * @eventName ~ColorPickerView#colorSelected
128
+ */
129
+ export type ColorPickerColorSelectedEvent = {
130
+ name: 'colorSelected';
131
+ args: [
132
+ {
133
+ color: string;
134
+ }
135
+ ];
136
+ };
110
137
  export {};
@@ -5,15 +5,18 @@
5
5
  /**
6
6
  * @module ui/colorpicker/colorpickerview
7
7
  */
8
- import { convertColor, convertToHex } from './utils';
8
+ import { convertColor, convertToHex } from './utils.js';
9
9
  import { global, env } from '@ckeditor/ckeditor5-utils';
10
10
  import { debounce } from 'lodash-es';
11
- import View from '../view';
12
- import LabeledFieldView from '../labeledfield/labeledfieldview';
13
- import { createLabeledInputText } from '../labeledfield/utils';
11
+ import View from '../view.js';
12
+ import LabeledFieldView from '../labeledfield/labeledfieldview.js';
13
+ import { createLabeledInputText } from '../labeledfield/utils.js';
14
14
  import 'vanilla-colorful/hex-color-picker.js';
15
15
  import '../../theme/components/colorpicker/colorpicker.css';
16
16
  const waitingTime = 150;
17
+ /**
18
+ * A class which represents a color picker with an input field for defining custom colors.
19
+ */
17
20
  export default class ColorPickerView extends View {
18
21
  /**
19
22
  * Creates a view of color picker.
@@ -21,14 +24,17 @@ export default class ColorPickerView extends View {
21
24
  * @param locale
22
25
  * @param config
23
26
  */
24
- constructor(locale, config) {
27
+ constructor(locale, config = {}) {
25
28
  super(locale);
26
- this.set('color', '');
27
- this.set('_hexColor', '');
28
- this._format = config.format || 'hsl';
29
+ this.set({
30
+ color: '',
31
+ _hexColor: ''
32
+ });
29
33
  this.hexInputRow = this._createInputRow();
30
34
  const children = this.createCollection();
31
- children.add(this.hexInputRow);
35
+ if (!config.hideInput) {
36
+ children.add(this.hexInputRow);
37
+ }
32
38
  this.setTemplate({
33
39
  tag: 'div',
34
40
  attributes: {
@@ -37,21 +43,27 @@ export default class ColorPickerView extends View {
37
43
  },
38
44
  children
39
45
  });
46
+ this._config = config;
40
47
  this._debounceColorPickerEvent = debounce((color) => {
48
+ // At first, set the color internally in the component. It's converted to the configured output format.
41
49
  this.set('color', color);
50
+ // Then let the outside world know that the user changed the color.
51
+ this.fire('colorSelected', { color: this.color });
42
52
  }, waitingTime, {
43
53
  leading: true
44
54
  });
45
- // Sets color in the picker if color was updated.
55
+ // The `color` property holds the color in the configured output format.
56
+ // Ensure it before actually setting the value.
46
57
  this.on('set:color', (evt, propertyName, newValue) => {
47
- // The color needs always to be kept in the output format.
48
- evt.return = convertColor(newValue, this._format);
58
+ evt.return = convertColor(newValue, this._config.format || 'hsl');
49
59
  });
60
+ // The `_hexColor` property is bound to the `color` one, but requires conversion.
50
61
  this.on('change:color', () => {
51
62
  this._hexColor = convertColorToCommonHexFormat(this.color);
52
63
  });
53
64
  this.on('change:_hexColor', () => {
54
- // Should update color in color picker when its not focused
65
+ // Update the selected color in the color picker palette when it's not focused.
66
+ // It means the user typed the color in the input.
55
67
  if (document.activeElement !== this.picker) {
56
68
  this.picker.setAttribute('color', this._hexColor);
57
69
  }
@@ -72,7 +84,12 @@ export default class ColorPickerView extends View {
72
84
  this.picker.setAttribute('tabindex', '-1');
73
85
  this._createSlidersView();
74
86
  if (this.element) {
75
- this.element.insertBefore(this.picker, this.hexInputRow.element);
87
+ if (this.hexInputRow.element) {
88
+ this.element.insertBefore(this.picker, this.hexInputRow.element);
89
+ }
90
+ else {
91
+ this.element.appendChild(this.picker);
92
+ }
76
93
  // Create custom stylesheet with a look of focused pointer in color picker and append it into the color picker shadowDom
77
94
  const styleSheetForFocusedColorPicker = document.createElement('style');
78
95
  styleSheetForFocusedColorPicker.textContent = '[role="slider"]:focus [part$="pointer"] {' +
@@ -101,7 +118,7 @@ export default class ColorPickerView extends View {
101
118
  // See: https://github.com/cksource/ckeditor5-internal/issues/3245, https://github.com/ckeditor/ckeditor5/issues/14119,
102
119
  // https://github.com/cksource/ckeditor5-internal/issues/3268.
103
120
  /* istanbul ignore next -- @preserve */
104
- if (env.isGecko || env.isiOS || env.isSafari) {
121
+ if (!this._config.hideInput && (env.isGecko || env.isiOS || env.isSafari)) {
105
122
  const input = this.hexInputRow.children.get(1);
106
123
  input.focus();
107
124
  }
@@ -209,7 +226,7 @@ class SliderView extends View {
209
226
  this.element.focus();
210
227
  }
211
228
  }
212
- // View abstaction over the `#` character before color input.
229
+ // View abstraction over the `#` character before color input.
213
230
  class HashView extends View {
214
231
  constructor(locale) {
215
232
  super(locale);
@@ -18,6 +18,14 @@ export type ColorPickerOutputFormat = 'hex' | 'rgb' | 'hsl' | 'hwb' | 'lab' | 'l
18
18
  export type ColorPickerConfig = {
19
19
  format?: ColorPickerOutputFormat;
20
20
  };
21
+ /**
22
+ * Configuration of the color picker view.
23
+ *
24
+ * It can be used to enforce a particular color format or hide the color input.
25
+ */
26
+ export type ColorPickerViewConfig = ColorPickerConfig & {
27
+ hideInput?: boolean;
28
+ };
21
29
  /**
22
30
  * Parses and converts the color string to requested format. Handles variety of color spaces
23
31
  * like `hsl`, `hex` or `rgb`.