@ckeditor/ckeditor5-ui 35.3.2 → 36.0.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.
Files changed (89) hide show
  1. package/LICENSE.md +1 -1
  2. package/package.json +21 -21
  3. package/src/bindings/addkeyboardhandlingforgrid.js +49 -14
  4. package/src/bindings/clickoutsidehandler.js +5 -7
  5. package/src/bindings/injectcsstransitiondisabler.js +1 -1
  6. package/src/bindings/preventdefault.js +1 -1
  7. package/src/bindings/submithandler.js +1 -1
  8. package/src/button/button.js +1 -1
  9. package/src/button/buttonview.js +2 -4
  10. package/src/button/switchbuttonview.js +1 -1
  11. package/src/colorgrid/colorgridview.js +4 -3
  12. package/src/colorgrid/colortileview.js +1 -1
  13. package/src/colorgrid/utils.js +1 -1
  14. package/src/componentfactory.js +3 -3
  15. package/src/dropdown/button/dropdownbutton.js +1 -1
  16. package/src/dropdown/button/dropdownbuttonview.js +1 -1
  17. package/src/dropdown/button/splitbuttonview.js +2 -3
  18. package/src/dropdown/dropdownpanelfocusable.js +1 -1
  19. package/src/dropdown/dropdownpanelview.js +2 -2
  20. package/src/dropdown/dropdownview.js +2 -4
  21. package/src/dropdown/utils.js +84 -27
  22. package/src/editableui/editableuiview.js +1 -1
  23. package/src/editableui/inline/inlineeditableuiview.js +1 -1
  24. package/src/editorui/bodycollection.js +2 -2
  25. package/src/editorui/boxed/boxededitoruiview.js +1 -1
  26. package/src/editorui/editorui.js +476 -0
  27. package/src/editorui/editoruiview.js +1 -1
  28. package/src/focuscycler.js +2 -2
  29. package/src/formheader/formheaderview.js +2 -2
  30. package/src/icon/iconview.js +1 -1
  31. package/src/iframe/iframeview.js +10 -10
  32. package/src/index.js +4 -1
  33. package/src/input/inputview.js +2 -2
  34. package/src/inputnumber/inputnumberview.js +1 -1
  35. package/src/inputtext/inputtextview.js +1 -1
  36. package/src/label/labelview.js +2 -2
  37. package/src/labeledfield/labeledfieldview.js +2 -2
  38. package/src/labeledfield/utils.js +1 -1
  39. package/src/labeledinput/labeledinputview.js +2 -2
  40. package/src/list/listitemview.js +1 -1
  41. package/src/list/listseparatorview.js +1 -1
  42. package/src/list/listview.js +11 -4
  43. package/src/model.js +3 -3
  44. package/src/notification/notification.js +2 -2
  45. package/src/panel/balloon/balloonpanelview.js +2 -5
  46. package/src/panel/balloon/contextualballoon.js +39 -20
  47. package/src/panel/sticky/stickypanelview.js +2 -3
  48. package/src/template.js +3 -6
  49. package/src/toolbar/balloon/balloontoolbar.js +5 -9
  50. package/src/toolbar/block/blockbuttonview.js +2 -2
  51. package/src/toolbar/block/blocktoolbar.js +4 -8
  52. package/src/toolbar/normalizetoolbarconfig.js +1 -1
  53. package/src/toolbar/toolbarlinebreakview.js +1 -1
  54. package/src/toolbar/toolbarseparatorview.js +1 -1
  55. package/src/toolbar/toolbarview.js +19 -19
  56. package/src/tooltipmanager.js +3 -4
  57. package/src/view.js +4 -8
  58. package/src/viewcollection.js +2 -3
  59. package/theme/components/button/button.css +1 -1
  60. package/theme/components/button/switchbutton.css +1 -1
  61. package/theme/components/colorgrid/colorgrid.css +1 -1
  62. package/theme/components/dropdown/dropdown.css +1 -1
  63. package/theme/components/dropdown/listdropdown.css +1 -1
  64. package/theme/components/dropdown/splitbutton.css +1 -1
  65. package/theme/components/dropdown/toolbardropdown.css +1 -1
  66. package/theme/components/editorui/editorui.css +1 -1
  67. package/theme/components/formheader/formheader.css +1 -1
  68. package/theme/components/icon/icon.css +1 -1
  69. package/theme/components/input/input.css +1 -1
  70. package/theme/components/label/label.css +1 -1
  71. package/theme/components/labeledfield/labeledfieldview.css +1 -1
  72. package/theme/components/labeledinput/labeledinput.css +1 -1
  73. package/theme/components/list/list.css +1 -1
  74. package/theme/components/panel/balloonpanel.css +1 -1
  75. package/theme/components/panel/balloonrotator.css +1 -1
  76. package/theme/components/panel/fakepanel.css +1 -1
  77. package/theme/components/panel/stickypanel.css +1 -1
  78. package/theme/components/responsive-form/responsiveform.css +1 -1
  79. package/theme/components/toolbar/blocktoolbar.css +1 -1
  80. package/theme/components/toolbar/toolbar.css +1 -1
  81. package/theme/components/tooltip/tooltip.css +1 -1
  82. package/theme/globals/_hidden.css +1 -1
  83. package/theme/globals/_reset.css +1 -1
  84. package/theme/globals/_transition.css +1 -1
  85. package/theme/globals/_zindex.css +1 -1
  86. package/theme/globals/globals.css +1 -1
  87. package/theme/mixins/_dir.css +1 -1
  88. package/theme/mixins/_rwd.css +1 -1
  89. package/theme/mixins/_unselectable.css +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -1,14 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/list/listview
7
7
  */
8
8
  import View from '../view';
9
- import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
10
9
  import FocusCycler from '../focuscycler';
11
- import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
10
+ import { FocusTracker, KeystrokeHandler } from '@ckeditor/ckeditor5-utils';
12
11
  import '../../theme/components/list/list.css';
13
12
  /**
14
13
  * The list view class.
@@ -22,6 +21,7 @@ export default class ListView extends View {
22
21
  */
23
22
  constructor(locale) {
24
23
  super(locale);
24
+ const bind = this.bindTemplate;
25
25
  /**
26
26
  * Collection of the child list views.
27
27
  *
@@ -61,6 +61,12 @@ export default class ListView extends View {
61
61
  focusNext: 'arrowdown'
62
62
  }
63
63
  });
64
+ /**
65
+ * Label used by assistive technologies to describe this list element.
66
+ *
67
+ * @member {String} #ariaLabel
68
+ */
69
+ this.set('ariaLabel', undefined);
64
70
  this.setTemplate({
65
71
  tag: 'ul',
66
72
  attributes: {
@@ -68,7 +74,8 @@ export default class ListView extends View {
68
74
  'ck',
69
75
  'ck-reset',
70
76
  'ck-list'
71
- ]
77
+ ],
78
+ 'aria-label': bind.to('ariaLabel')
72
79
  },
73
80
  children: this.items
74
81
  });
package/src/model.js CHANGED
@@ -1,18 +1,18 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/model
7
7
  */
8
- import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
8
+ import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
9
9
  import { extend } from 'lodash-es';
10
10
  /**
11
11
  * The base MVC model class.
12
12
  *
13
13
  * @mixes module:utils/observablemixin~ObservableMixin
14
14
  */
15
- export default class Model extends Observable {
15
+ export default class Model extends ObservableMixin() {
16
16
  /**
17
17
  * Creates a new Model instance.
18
18
  *
@@ -1,12 +1,12 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/notification/notification
7
7
  */
8
8
  /* globals window */
9
- import ContextPlugin from '@ckeditor/ckeditor5-core/src/contextplugin';
9
+ import { ContextPlugin } from '@ckeditor/ckeditor5-core';
10
10
  /**
11
11
  * The Notification plugin.
12
12
  *
@@ -1,15 +1,12 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/panel/balloon/balloonpanelview
7
7
  */
8
8
  import View from '../../view';
9
- import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position';
10
- import isRange from '@ckeditor/ckeditor5-utils/src/dom/isrange';
11
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
12
- import global from '@ckeditor/ckeditor5-utils/src/dom/global';
9
+ import { getOptimalPosition, global, isRange, toUnit } from '@ckeditor/ckeditor5-utils';
13
10
  import { isElement } from 'lodash-es';
14
11
  import '../../../theme/components/panel/balloonpanel.css';
15
12
  const toPx = toUnit('px');
@@ -1,18 +1,15 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/panel/balloon/contextualballoon
7
7
  */
8
- import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
9
  import BalloonPanelView from './balloonpanelview';
10
10
  import View from '../../view';
11
11
  import ButtonView from '../../button/buttonview';
12
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
13
- import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
14
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
15
- import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
12
+ import { CKEditorError, FocusTracker, Rect, toUnit } from '@ckeditor/ckeditor5-utils';
16
13
  import prevIcon from '../../../theme/icons/previous-arrow.svg';
17
14
  import nextIcon from '../../../theme/icons/next-arrow.svg';
18
15
  import '../../../theme/components/panel/balloonrotator.css';
@@ -66,6 +63,9 @@ export default class ContextualBalloon extends Plugin {
66
63
  */
67
64
  constructor(editor) {
68
65
  super(editor);
66
+ this._view = null;
67
+ this._rotatorView = null;
68
+ this._fakePanelsView = null;
69
69
  /**
70
70
  * The {@link module:utils/dom/position~Options#limiter position limiter}
71
71
  * for the {@link #view balloon}, used when no `limiter` has been passed into {@link #add}
@@ -94,15 +94,6 @@ export default class ContextualBalloon extends Plugin {
94
94
  * @member {module:ui/view~View|null} #visibleView
95
95
  */
96
96
  this.set('visibleView', null);
97
- /**
98
- * The common balloon panel view.
99
- *
100
- * @readonly
101
- * @member {module:ui/panel/balloon/balloonpanelview~BalloonPanelView} #view
102
- */
103
- this.view = new BalloonPanelView(editor.locale);
104
- editor.ui.view.body.add(this.view);
105
- editor.ui.focusTracker.add(this.view.element);
106
97
  /**
107
98
  * The map of views and their stacks.
108
99
  *
@@ -142,23 +133,38 @@ export default class ContextualBalloon extends Plugin {
142
133
  * @private
143
134
  * @type {module:ui/panel/balloon/contextualballoon~RotatorView}
144
135
  */
145
- this._rotatorView = this._createRotatorView();
136
+ this._rotatorView = null;
146
137
  /**
147
138
  * Displays fake panels under the balloon panel view when multiple stacks are added to the balloon.
148
139
  *
149
140
  * @private
150
141
  * @type {module:ui/view~View}
151
142
  */
152
- this._fakePanelsView = this._createFakePanelsView();
143
+ this._fakePanelsView = null;
153
144
  }
154
145
  /**
155
146
  * @inheritDoc
156
147
  */
157
148
  destroy() {
158
149
  super.destroy();
159
- this.view.destroy();
160
- this._rotatorView.destroy();
161
- this._fakePanelsView.destroy();
150
+ if (this._view) {
151
+ this._view.destroy();
152
+ }
153
+ if (this._rotatorView) {
154
+ this._rotatorView.destroy();
155
+ }
156
+ if (this._fakePanelsView) {
157
+ this._fakePanelsView.destroy();
158
+ }
159
+ }
160
+ /**
161
+ * The common balloon panel view.
162
+ */
163
+ get view() {
164
+ if (!this._view) {
165
+ this._createPanelView();
166
+ }
167
+ return this._view;
162
168
  }
163
169
  /**
164
170
  * Returns `true` when the given view is in one of the stacks. Otherwise returns `false`.
@@ -182,6 +188,9 @@ export default class ContextualBalloon extends Plugin {
182
188
  * @param {Boolean} [data.singleViewMode=false] Whether the view should be the only visible view even if other stacks were added.
183
189
  */
184
190
  add(data) {
191
+ if (!this._view) {
192
+ this._createPanelView();
193
+ }
185
194
  if (this.hasView(data.view)) {
186
195
  /**
187
196
  * Trying to add configuration of the same view more than once.
@@ -294,6 +303,16 @@ export default class ContextualBalloon extends Plugin {
294
303
  }
295
304
  this._showView(Array.from(stack.values()).pop());
296
305
  }
306
+ /**
307
+ * Initializes view instances.
308
+ */
309
+ _createPanelView() {
310
+ this._view = new BalloonPanelView(this.editor.locale);
311
+ this.editor.ui.view.body.add(this._view);
312
+ this.editor.ui.focusTracker.add(this._view.element);
313
+ this._rotatorView = this._createRotatorView();
314
+ this._fakePanelsView = this._createFakePanelsView();
315
+ }
297
316
  /**
298
317
  * Returns the stack of the currently visible view.
299
318
  *
@@ -1,14 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/panel/sticky/stickypanelview
7
7
  */
8
- import global from '@ckeditor/ckeditor5-utils/src/dom/global';
9
8
  import View from '../../view';
10
9
  import Template from '../../template';
11
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
10
+ import { global, toUnit } from '@ckeditor/ckeditor5-utils';
12
11
  import '../../../theme/components/panel/stickypanel.css';
13
12
  const toPx = toUnit('px');
14
13
  /**
package/src/template.js CHANGED
@@ -1,18 +1,15 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/template
7
7
  */
8
8
  /* global document */
9
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
10
- import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
11
9
  import View from './view';
12
10
  import ViewCollection from './viewcollection';
13
- import isNode from '@ckeditor/ckeditor5-utils/src/dom/isnode';
11
+ import { CKEditorError, EmitterMixin, isNode, toArray } from '@ckeditor/ckeditor5-utils';
14
12
  import { isObject, cloneDeepWith } from 'lodash-es';
15
- import toArray from '@ckeditor/ckeditor5-utils/src/toarray';
16
13
  const xhtmlNs = 'http://www.w3.org/1999/xhtml';
17
14
  /**
18
15
  * A basic Template class. It renders a DOM HTML element or text from a
@@ -50,7 +47,7 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
50
47
  *
51
48
  * @mixes module:utils/emittermixin~EmitterMixin
52
49
  */
53
- export default class Template extends Emitter {
50
+ export default class Template extends EmitterMixin() {
54
51
  /**
55
52
  * Creates an instance of the {@link ~Template} class.
56
53
  *
@@ -1,21 +1,17 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/toolbar/balloon/balloontoolbar
7
7
  */
8
- import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
8
+ import { Plugin } from '@ckeditor/ckeditor5-core';
9
+ import { FocusTracker, Rect, ResizeObserver, env, global, toUnit } from '@ckeditor/ckeditor5-utils';
9
10
  import ContextualBalloon from '../../panel/balloon/contextualballoon';
10
11
  import ToolbarView from '../toolbarview';
11
12
  import BalloonPanelView, { generatePositions } from '../../panel/balloon/balloonpanelview';
12
- import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
13
- import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
14
13
  import normalizeToolbarConfig from '../normalizetoolbarconfig';
15
14
  import { debounce } from 'lodash-es';
16
- import ResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/resizeobserver';
17
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
18
- import { env, global } from '@ckeditor/ckeditor5-utils';
19
15
  const toPx = toUnit('px');
20
16
  /**
21
17
  * The contextual toolbar.
@@ -143,11 +139,11 @@ export default class BalloonToolbar extends Plugin {
143
139
  this.listenTo(editor, 'ready', () => {
144
140
  const editableElement = editor.ui.view.editable.element;
145
141
  // Set #toolbarView's max-width on the initialization and update it on the editable resize.
146
- this._resizeObserver = new ResizeObserver(editableElement, () => {
142
+ this._resizeObserver = new ResizeObserver(editableElement, entry => {
147
143
  // The max-width equals 90% of the editable's width for the best user experience.
148
144
  // The value keeps the balloon very close to the boundaries of the editable and limits the cases
149
145
  // when the balloon juts out from the editable element it belongs to.
150
- this.toolbarView.maxWidth = toPx(new Rect(editableElement).width * .9);
146
+ this.toolbarView.maxWidth = toPx(entry.contentRect.width * .9);
151
147
  });
152
148
  });
153
149
  }
@@ -1,13 +1,13 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/toolbar/block/blockbuttonview
7
7
  */
8
8
  import ButtonView from '../../button/buttonview';
9
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
10
9
  import '../../../theme/components/toolbar/blocktoolbar.css';
10
+ import { toUnit } from '@ckeditor/ckeditor5-utils';
11
11
  const toPx = toUnit('px');
12
12
  /**
13
13
  * The block button view class.
@@ -1,24 +1,20 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/toolbar/block/blocktoolbar
7
7
  */
8
8
  /* global window */
9
- import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
10
- import pilcrow from '@ckeditor/ckeditor5-core/theme/icons/pilcrow.svg';
9
+ import { Plugin, icons } from '@ckeditor/ckeditor5-core';
10
+ import { Rect, ResizeObserver, getOptimalPosition, env, toUnit } from '@ckeditor/ckeditor5-utils';
11
11
  import BlockButtonView from './blockbuttonview';
12
12
  import BalloonPanelView from '../../panel/balloon/balloonpanelview';
13
13
  import ToolbarView from '../toolbarview';
14
14
  import clickOutsideHandler from '../../bindings/clickoutsidehandler';
15
- import { getOptimalPosition } from '@ckeditor/ckeditor5-utils/src/dom/position';
16
- import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
17
15
  import normalizeToolbarConfig from '../normalizetoolbarconfig';
18
- import ResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/resizeobserver';
19
- import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
20
- import env from '@ckeditor/ckeditor5-utils/src/env';
21
16
  const toPx = toUnit('px');
17
+ const { pilcrow } = icons;
22
18
  /**
23
19
  * The block toolbar plugin.
24
20
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -1,27 +1,21 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/toolbar/toolbarview
7
7
  */
8
8
  import View from '../view';
9
- import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
10
9
  import FocusCycler from '../focuscycler';
11
- import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
12
10
  import ToolbarSeparatorView from './toolbarseparatorview';
13
11
  import ToolbarLineBreakView from './toolbarlinebreakview';
14
- import ResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/resizeobserver';
15
12
  import preventDefault from '../bindings/preventdefault';
16
- import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
17
- import isVisible from '@ckeditor/ckeditor5-utils/src/dom/isvisible';
18
- import global from '@ckeditor/ckeditor5-utils/src/dom/global';
19
13
  import { createDropdown, addToolbarToDropdown } from '../dropdown/utils';
20
- import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
21
14
  import normalizeToolbarConfig from './normalizetoolbarconfig';
15
+ import { FocusTracker, KeystrokeHandler, Rect, ResizeObserver, global, isVisible, logWarning } from '@ckeditor/ckeditor5-utils';
16
+ import { icons } from '@ckeditor/ckeditor5-core';
22
17
  import { isObject } from 'lodash-es';
23
18
  import '../../theme/components/toolbar/toolbar.css';
24
- import { icons } from '@ckeditor/ckeditor5-core';
25
19
  const { threeVerticalDots } = icons;
26
20
  const NESTED_TOOLBAR_ICONS = {
27
21
  alignLeft: icons.alignLeft,
@@ -263,6 +257,17 @@ export default class ToolbarView extends View {
263
257
  * to this toolbar and all nested ones as well.
264
258
  */
265
259
  fillFromConfig(itemsOrConfig, factory, removeItems) {
260
+ this.items.addMany(this._buildItemsFromConfig(itemsOrConfig, factory, removeItems));
261
+ }
262
+ /**
263
+ * A utility that expands the plain toolbar configuration into a list of view items using a given component factory.
264
+ *
265
+ * @param {Array.<String>|Object} itemsOrConfig The toolbar items or the entire toolbar configuration object.
266
+ * @param {module:ui/componentfactory~ComponentFactory} factory A factory producing toolbar items.
267
+ * @param {Array.<String>} [removeItems] An array of items names to be removed from the configuration. When present, applies
268
+ * to this toolbar and all nested ones as well.
269
+ */
270
+ _buildItemsFromConfig(itemsOrConfig, factory, removeItems) {
266
271
  const config = normalizeToolbarConfig(itemsOrConfig);
267
272
  const normalizedRemoveItems = removeItems || config.removeItems;
268
273
  const itemsToAdd = this._cleanItemsConfiguration(config.items, factory, normalizedRemoveItems)
@@ -279,7 +284,7 @@ export default class ToolbarView extends View {
279
284
  return factory.create(item);
280
285
  })
281
286
  .filter((item) => !!item);
282
- this.items.addMany(itemsToAdd);
287
+ return itemsToAdd;
283
288
  }
284
289
  /**
285
290
  * Cleans up the {@link module:ui/toolbar/toolbarview~ToolbarView#items} of the toolbar by removing unwanted items and
@@ -445,8 +450,7 @@ export default class ToolbarView extends View {
445
450
  else {
446
451
  dropdownView.buttonView.withText = true;
447
452
  }
448
- addToolbarToDropdown(dropdownView, []);
449
- dropdownView.toolbarView.fillFromConfig(items, componentFactory, removeItems);
453
+ addToolbarToDropdown(dropdownView, () => (dropdownView.toolbarView._buildItemsFromConfig(items, componentFactory, removeItems)));
450
454
  return dropdownView;
451
455
  }
452
456
  }
@@ -666,11 +670,9 @@ class DynamicGrouping {
666
670
  // Only those items that were not grouped are visible to the user.
667
671
  view.itemsView.children.bindTo(this.ungroupedItems).using(item => item);
668
672
  // Make sure all #items visible in the main space of the toolbar are "focuscycleable".
669
- this.ungroupedItems.on('add', this._updateFocusCycleableItems.bind(this));
670
- this.ungroupedItems.on('remove', this._updateFocusCycleableItems.bind(this));
673
+ this.ungroupedItems.on('change', this._updateFocusCycleableItems.bind(this));
671
674
  // Make sure the #groupedItemsDropdown is also included in cycling when it appears.
672
- view.children.on('add', this._updateFocusCycleableItems.bind(this));
673
- view.children.on('remove', this._updateFocusCycleableItems.bind(this));
675
+ view.children.on('change', this._updateFocusCycleableItems.bind(this));
674
676
  // ToolbarView#items is dynamic. When an item is added or removed, it should be automatically
675
677
  // represented in either grouped or ungrouped items at the right index.
676
678
  // In other words #items == concat( #ungroupedItems, #groupedItems )
@@ -904,15 +906,13 @@ class DynamicGrouping {
904
906
  // Make sure the dropdown never sticks out to the left/right. It should be under the main toolbar.
905
907
  // (https://github.com/ckeditor/ckeditor5/issues/5608)
906
908
  dropdown.panelPosition = locale.uiLanguageDirection === 'ltr' ? 'sw' : 'se';
907
- addToolbarToDropdown(dropdown, []);
909
+ addToolbarToDropdown(dropdown, this.groupedItems);
908
910
  dropdown.buttonView.set({
909
911
  label: t('Show more items'),
910
912
  tooltip: true,
911
913
  tooltipPosition: locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw',
912
914
  icon: threeVerticalDots
913
915
  });
914
- // 1:1 pass–through binding.
915
- dropdown.toolbarView.items.bindTo(this.groupedItems).using(item => item);
916
916
  return dropdown;
917
917
  }
918
918
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
@@ -7,8 +7,7 @@
7
7
  */
8
8
  import View from './view';
9
9
  import BalloonPanelView, { generatePositions } from './panel/balloon/balloonpanelview';
10
- import { Emitter as DomEmitter } from '@ckeditor/ckeditor5-utils/src/dom/emittermixin';
11
- import { global, isVisible, first, ResizeObserver } from '@ckeditor/ckeditor5-utils';
10
+ import { DomEmitterMixin, ResizeObserver, first, global, isVisible } from '@ckeditor/ckeditor5-utils';
12
11
  import { isElement, debounce } from 'lodash-es';
13
12
  import '../theme/components/tooltip/tooltip.css';
14
13
  const BALLOON_CLASS = 'ck-tooltip';
@@ -59,7 +58,7 @@ const BALLOON_CLASS = 'ck-tooltip';
59
58
  *
60
59
  * @mixes module:utils/domemittermixin~DomEmitterMixin
61
60
  */
62
- export default class TooltipManager extends DomEmitter {
61
+ export default class TooltipManager extends DomEmitterMixin() {
63
62
  /**
64
63
  * Creates an instance of the tooltip manager.
65
64
  *
package/src/view.js CHANGED
@@ -1,18 +1,14 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
- /* eslint-disable @typescript-eslint/no-invalid-void-type, new-cap */
5
+ /* eslint-disable @typescript-eslint/no-invalid-void-type */
6
6
  /**
7
7
  * @module ui/view
8
8
  */
9
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
10
9
  import ViewCollection from './viewcollection';
11
10
  import Template from './template';
12
- import DomEmitterMixin from '@ckeditor/ckeditor5-utils/src/dom/emittermixin';
13
- import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
14
- import Collection from '@ckeditor/ckeditor5-utils/src/collection';
15
- import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
11
+ import { CKEditorError, Collection, DomEmitterMixin, ObservableMixin, isIterable } from '@ckeditor/ckeditor5-utils';
16
12
  import '../theme/globals/globals.css';
17
13
  /**
18
14
  * The basic view class, which represents an HTML element created out of a
@@ -79,7 +75,7 @@ import '../theme/globals/globals.css';
79
75
  *
80
76
  * @mixes module:utils/observablemixin~ObservableMixin
81
77
  */
82
- export default class View extends DomEmitterMixin(Observable) {
78
+ export default class View extends DomEmitterMixin(ObservableMixin()) {
83
79
  /**
84
80
  * Creates an instance of the {@link module:ui/view~View} class.
85
81
  *
@@ -1,12 +1,11 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
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
5
  /**
6
6
  * @module ui/viewcollection
7
7
  */
8
- import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
9
- import Collection from '@ckeditor/ckeditor5-utils/src/collection';
8
+ import { CKEditorError, Collection } from '@ckeditor/ckeditor5-utils';
10
9
  /**
11
10
  * Collects {@link module:ui/view~View} instances.
12
11
  *
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
2
+ * 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
5