@ckeditor/ckeditor5-ui 35.2.1 → 35.3.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 (59) hide show
  1. package/package.json +31 -23
  2. package/src/bindings/addkeyboardhandlingforgrid.js +45 -57
  3. package/src/bindings/clickoutsidehandler.js +15 -21
  4. package/src/bindings/injectcsstransitiondisabler.js +16 -20
  5. package/src/bindings/preventdefault.js +6 -8
  6. package/src/bindings/submithandler.js +5 -7
  7. package/src/button/button.js +5 -0
  8. package/src/button/buttonview.js +220 -259
  9. package/src/button/switchbuttonview.js +56 -71
  10. package/src/colorgrid/colorgridview.js +135 -197
  11. package/src/colorgrid/colortileview.js +37 -47
  12. package/src/colorgrid/utils.js +57 -66
  13. package/src/componentfactory.js +79 -93
  14. package/src/dropdown/button/dropdownbutton.js +5 -0
  15. package/src/dropdown/button/dropdownbuttonview.js +44 -57
  16. package/src/dropdown/button/splitbuttonview.js +159 -207
  17. package/src/dropdown/dropdownpanelfocusable.js +5 -0
  18. package/src/dropdown/dropdownpanelview.js +101 -112
  19. package/src/dropdown/dropdownview.js +396 -438
  20. package/src/dropdown/utils.js +164 -213
  21. package/src/editableui/editableuiview.js +125 -141
  22. package/src/editableui/inline/inlineeditableuiview.js +44 -54
  23. package/src/editorui/bodycollection.js +61 -75
  24. package/src/editorui/boxed/boxededitoruiview.js +91 -104
  25. package/src/editorui/editoruiview.js +30 -39
  26. package/src/focuscycler.js +214 -245
  27. package/src/formheader/formheaderview.js +58 -70
  28. package/src/icon/iconview.js +145 -111
  29. package/src/iframe/iframeview.js +37 -49
  30. package/src/index.js +0 -17
  31. package/src/input/inputview.js +170 -198
  32. package/src/inputnumber/inputnumberview.js +48 -56
  33. package/src/inputtext/inputtextview.js +14 -18
  34. package/src/label/labelview.js +44 -53
  35. package/src/labeledfield/labeledfieldview.js +212 -235
  36. package/src/labeledfield/utils.js +39 -57
  37. package/src/labeledinput/labeledinputview.js +190 -221
  38. package/src/list/listitemview.js +40 -50
  39. package/src/list/listseparatorview.js +15 -19
  40. package/src/list/listview.js +94 -115
  41. package/src/model.js +19 -25
  42. package/src/notification/notification.js +151 -202
  43. package/src/panel/balloon/balloonpanelview.js +535 -628
  44. package/src/panel/balloon/contextualballoon.js +611 -732
  45. package/src/panel/sticky/stickypanelview.js +238 -270
  46. package/src/template.js +1049 -1479
  47. package/src/toolbar/balloon/balloontoolbar.js +337 -424
  48. package/src/toolbar/block/blockbuttonview.js +32 -42
  49. package/src/toolbar/block/blocktoolbar.js +375 -477
  50. package/src/toolbar/normalizetoolbarconfig.js +17 -21
  51. package/src/toolbar/toolbarlinebreakview.js +15 -19
  52. package/src/toolbar/toolbarseparatorview.js +15 -19
  53. package/src/toolbar/toolbarview.js +866 -1053
  54. package/src/tooltipmanager.js +324 -353
  55. package/src/view.js +389 -430
  56. package/src/viewcollection.js +147 -178
  57. package/src/button/button.jsdoc +0 -165
  58. package/src/dropdown/button/dropdownbutton.jsdoc +0 -22
  59. package/src/dropdown/dropdownpanelfocusable.jsdoc +0 -27
@@ -2,13 +2,10 @@
2
2
  * @license Copyright (c) 2003-2022, 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
-
6
5
  /**
7
6
  * @module ui/componentfactory
8
7
  */
9
-
10
8
  import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
11
-
12
9
  /**
13
10
  * A helper class implementing the UI component ({@link module:ui/view~View view}) factory.
14
11
  *
@@ -32,101 +29,90 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
32
29
  * function when {@link module:ui/componentfactory~ComponentFactory#create} is called.
33
30
  */
34
31
  export default class ComponentFactory {
35
- /**
36
- * Creates an instance of the factory.
37
- *
38
- * @constructor
39
- * @param {module:core/editor/editor~Editor} editor The editor instance.
40
- */
41
- constructor( editor ) {
42
- /**
43
- * The editor instance that the factory belongs to.
44
- *
45
- * @readonly
46
- * @member {module:core/editor/editor~Editor}
47
- */
48
- this.editor = editor;
49
-
50
- /**
51
- * Registered component factories.
52
- *
53
- * @private
54
- * @member {Map}
55
- */
56
- this._components = new Map();
57
- }
58
-
59
- /**
60
- * Returns an iterator of registered component names. Names are returned in lower case.
61
- *
62
- * @returns {Iterable.<String>}
63
- */
64
- * names() {
65
- for ( const value of this._components.values() ) {
66
- yield value.originalName;
67
- }
68
- }
69
-
70
- /**
71
- * Registers a component factory function that will be used by the
72
- * {@link #create create} method and called with the
73
- * {@link module:core/editor/editor~Editor#locale editor locale} as an argument,
74
- * allowing localization of the {@link module:ui/view~View view}.
75
- *
76
- * @param {String} name The name of the component.
77
- * @param {Function} callback The callback that returns the component.
78
- */
79
- add( name, callback ) {
80
- this._components.set( getNormalized( name ), { callback, originalName: name } );
81
- }
82
-
83
- /**
84
- * Creates an instance of a component registered in the factory under a specific name.
85
- *
86
- * When called, the {@link module:core/editor/editor~Editor#locale editor locale} is passed to
87
- * the previously {@link #add added} factory function, allowing localization of the
88
- * {@link module:ui/view~View view}.
89
- *
90
- * @param {String} name The name of the component.
91
- * @returns {module:ui/view~View} The instantiated component view.
92
- */
93
- create( name ) {
94
- if ( !this.has( name ) ) {
95
- /**
96
- * The required component is not registered in the component factory. Please make sure
97
- * the provided name is correct and the component has been correctly
98
- * {@link #add added} to the factory.
99
- *
100
- * @error componentfactory-item-missing
101
- * @param {String} name The name of the missing component.
102
- */
103
- throw new CKEditorError(
104
- 'componentfactory-item-missing',
105
- this,
106
- { name }
107
- );
108
- }
109
-
110
- return this._components.get( getNormalized( name ) ).callback( this.editor.locale );
111
- }
112
-
113
- /**
114
- * Checks if a component of a given name is registered in the factory.
115
- *
116
- * @param {String} name The name of the component.
117
- * @returns {Boolean}
118
- */
119
- has( name ) {
120
- return this._components.has( getNormalized( name ) );
121
- }
32
+ /**
33
+ * Creates an instance of the factory.
34
+ *
35
+ * @constructor
36
+ * @param {module:core/editor/editor~Editor} editor The editor instance.
37
+ */
38
+ constructor(editor) {
39
+ /**
40
+ * The editor instance that the factory belongs to.
41
+ *
42
+ * @readonly
43
+ * @member {module:core/editor/editor~Editor}
44
+ */
45
+ this.editor = editor;
46
+ /**
47
+ * Registered component factories.
48
+ *
49
+ * @private
50
+ * @member {Map}
51
+ */
52
+ this._components = new Map();
53
+ }
54
+ /**
55
+ * Returns an iterator of registered component names. Names are returned in lower case.
56
+ *
57
+ * @returns {Iterable.<String>}
58
+ */
59
+ *names() {
60
+ for (const value of this._components.values()) {
61
+ yield value.originalName;
62
+ }
63
+ }
64
+ /**
65
+ * Registers a component factory function that will be used by the
66
+ * {@link #create create} method and called with the
67
+ * {@link module:core/editor/editor~Editor#locale editor locale} as an argument,
68
+ * allowing localization of the {@link module:ui/view~View view}.
69
+ *
70
+ * @param {String} name The name of the component.
71
+ * @param {Function} callback The callback that returns the component.
72
+ */
73
+ add(name, callback) {
74
+ this._components.set(getNormalized(name), { callback, originalName: name });
75
+ }
76
+ /**
77
+ * Creates an instance of a component registered in the factory under a specific name.
78
+ *
79
+ * When called, the {@link module:core/editor/editor~Editor#locale editor locale} is passed to
80
+ * the previously {@link #add added} factory function, allowing localization of the
81
+ * {@link module:ui/view~View view}.
82
+ *
83
+ * @param {String} name The name of the component.
84
+ * @returns {module:ui/view~View} The instantiated component view.
85
+ */
86
+ create(name) {
87
+ if (!this.has(name)) {
88
+ /**
89
+ * The required component is not registered in the component factory. Please make sure
90
+ * the provided name is correct and the component has been correctly
91
+ * {@link #add added} to the factory.
92
+ *
93
+ * @error componentfactory-item-missing
94
+ * @param {String} name The name of the missing component.
95
+ */
96
+ throw new CKEditorError('componentfactory-item-missing', this, { name });
97
+ }
98
+ return this._components.get(getNormalized(name)).callback(this.editor.locale);
99
+ }
100
+ /**
101
+ * Checks if a component of a given name is registered in the factory.
102
+ *
103
+ * @param {String} name The name of the component.
104
+ * @returns {Boolean}
105
+ */
106
+ has(name) {
107
+ return this._components.has(getNormalized(name));
108
+ }
122
109
  }
123
-
124
110
  //
125
111
  // Ensures that the component name used as the key in the internal map is in lower case.
126
112
  //
127
113
  // @private
128
114
  // @param {String} name
129
115
  // @returns {String}
130
- function getNormalized( name ) {
131
- return String( name ).toLowerCase();
116
+ function getNormalized(name) {
117
+ return String(name).toLowerCase();
132
118
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2022, 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
+ export {};
@@ -2,16 +2,12 @@
2
2
  * @license Copyright (c) 2003-2022, 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
-
6
5
  /**
7
6
  * @module ui/dropdown/button/dropdownbuttonview
8
7
  */
9
-
10
8
  import ButtonView from '../../button/buttonview';
11
-
12
9
  import dropdownArrowIcon from '../../../theme/icons/dropdown-arrow.svg';
13
10
  import IconView from '../../icon/iconview';
14
-
15
11
  /**
16
12
  * The default dropdown button view class.
17
13
  *
@@ -33,57 +29,48 @@ import IconView from '../../icon/iconview';
33
29
  * @extends module:ui/button/buttonview~ButtonView
34
30
  */
35
31
  export default class DropdownButtonView extends ButtonView {
36
- /**
37
- * @inheritDoc
38
- */
39
- constructor( locale ) {
40
- super( locale );
41
-
42
- /**
43
- * An icon that displays arrow to indicate a dropdown button.
44
- *
45
- * @readonly
46
- * @member {module:ui/icon/iconview~IconView}
47
- */
48
- this.arrowView = this._createArrowView();
49
-
50
- this.extendTemplate( {
51
- attributes: {
52
- 'aria-haspopup': true,
53
- 'aria-expanded': this.bindTemplate.to( 'isOn', value => String( value ) )
54
- }
55
- } );
56
-
57
- // The DropdownButton interface expects the open event upon which will open the dropdown.
58
- this.delegate( 'execute' ).to( this, 'open' );
59
- }
60
-
61
- /**
62
- * @inheritDoc
63
- */
64
- render() {
65
- super.render();
66
-
67
- this.children.add( this.arrowView );
68
- }
69
-
70
- /**
71
- * Creates a {@link module:ui/icon/iconview~IconView} instance as {@link #arrowView}.
72
- *
73
- * @private
74
- * @returns {module:ui/icon/iconview~IconView}
75
- */
76
- _createArrowView() {
77
- const arrowView = new IconView();
78
-
79
- arrowView.content = dropdownArrowIcon;
80
-
81
- arrowView.extendTemplate( {
82
- attributes: {
83
- class: 'ck-dropdown__arrow'
84
- }
85
- } );
86
-
87
- return arrowView;
88
- }
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ constructor(locale) {
36
+ super(locale);
37
+ /**
38
+ * An icon that displays arrow to indicate a dropdown button.
39
+ *
40
+ * @readonly
41
+ * @member {module:ui/icon/iconview~IconView}
42
+ */
43
+ this.arrowView = this._createArrowView();
44
+ this.extendTemplate({
45
+ attributes: {
46
+ 'aria-haspopup': true,
47
+ 'aria-expanded': this.bindTemplate.to('isOn', value => String(value))
48
+ }
49
+ });
50
+ // The DropdownButton interface expects the open event upon which will open the dropdown.
51
+ this.delegate('execute').to(this, 'open');
52
+ }
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ render() {
57
+ super.render();
58
+ this.children.add(this.arrowView);
59
+ }
60
+ /**
61
+ * Creates a {@link module:ui/icon/iconview~IconView} instance as {@link #arrowView}.
62
+ *
63
+ * @private
64
+ * @returns {module:ui/icon/iconview~IconView}
65
+ */
66
+ _createArrowView() {
67
+ const arrowView = new IconView();
68
+ arrowView.content = dropdownArrowIcon;
69
+ arrowView.extendTemplate({
70
+ attributes: {
71
+ class: 'ck-dropdown__arrow'
72
+ }
73
+ });
74
+ return arrowView;
75
+ }
89
76
  }