@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,155 +2,139 @@
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/editableui/editableuiview
8
7
  */
9
-
10
8
  import View from '../view';
11
-
12
9
  /**
13
10
  * The editable UI view class.
14
11
  *
15
12
  * @extends module:ui/view~View
16
13
  */
17
14
  export default class EditableUIView extends View {
18
- /**
19
- * Creates an instance of EditableUIView class.
20
- *
21
- * @param {module:utils/locale~Locale} [locale] The locale instance.
22
- * @param {module:engine/view/view~View} editingView The editing view instance the editable is related to.
23
- * @param {HTMLElement} [editableElement] The editable element. If not specified, this view
24
- * should create it. Otherwise, the existing element should be used.
25
- */
26
- constructor( locale, editingView, editableElement ) {
27
- super( locale );
28
-
29
- this.setTemplate( {
30
- tag: 'div',
31
- attributes: {
32
- class: [
33
- 'ck',
34
- 'ck-content',
35
- 'ck-editor__editable',
36
- 'ck-rounded-corners'
37
- ],
38
- lang: locale.contentLanguage,
39
- dir: locale.contentLanguageDirection
40
- }
41
- } );
42
-
43
- /**
44
- * The name of the editable UI view.
45
- *
46
- * @member {String} #name
47
- */
48
- this.name = null;
49
-
50
- /**
51
- * Controls whether the editable is focused, i.e. the user is typing in it.
52
- *
53
- * @observable
54
- * @member {Boolean} #isFocused
55
- */
56
- this.set( 'isFocused', false );
57
-
58
- /**
59
- * The element which is the main editable element (usually the one with `contentEditable="true"`).
60
- *
61
- * @private
62
- * @type {HTMLElement}
63
- */
64
- this._editableElement = editableElement;
65
-
66
- /**
67
- * Whether an external {@link #_editableElement} was passed into the constructor, which also means
68
- * the view will not render its {@link #template}.
69
- *
70
- * @private
71
- * @type {Boolean}
72
- */
73
- this._hasExternalElement = !!this._editableElement;
74
-
75
- /**
76
- * The editing view instance the editable is related to. Editable uses the editing
77
- * view to dynamically modify its certain DOM attributes after {@link #render rendering}.
78
- *
79
- * **Note**: The DOM attributes are performed by the editing view and not UI
80
- * {@link module:ui/view~View#bindTemplate template bindings} because once rendered,
81
- * the editable DOM element must remain under the full control of the engine to work properly.
82
- *
83
- * @protected
84
- * @type {module:engine/view/view~View}
85
- */
86
- this._editingView = editingView;
87
- }
88
-
89
- /**
90
- * Renders the view by either applying the {@link #template} to the existing
91
- * {@link #_editableElement} or assigning {@link #element} as {@link #_editableElement}.
92
- */
93
- render() {
94
- super.render();
95
-
96
- if ( this._hasExternalElement ) {
97
- this.template.apply( this.element = this._editableElement );
98
- } else {
99
- this._editableElement = this.element;
100
- }
101
-
102
- this.on( 'change:isFocused', () => this._updateIsFocusedClasses() );
103
- this._updateIsFocusedClasses();
104
- }
105
-
106
- /**
107
- * @inheritDoc
108
- */
109
- destroy() {
110
- if ( this._hasExternalElement ) {
111
- this.template.revert( this._editableElement );
112
- }
113
-
114
- super.destroy();
115
- }
116
-
117
- /**
118
- * Updates the `ck-focused` and `ck-blurred` CSS classes on the {@link #element} according to
119
- * the {@link #isFocused} property value using the {@link #_editingView editing view} API.
120
- *
121
- * @private
122
- */
123
- _updateIsFocusedClasses() {
124
- const editingView = this._editingView;
125
-
126
- if ( editingView.isRenderingInProgress ) {
127
- updateAfterRender( this );
128
- } else {
129
- update( this );
130
- }
131
-
132
- function update( view ) {
133
- editingView.change( writer => {
134
- const viewRoot = editingView.document.getRoot( view.name );
135
-
136
- writer.addClass( view.isFocused ? 'ck-focused' : 'ck-blurred', viewRoot );
137
- writer.removeClass( view.isFocused ? 'ck-blurred' : 'ck-focused', viewRoot );
138
- } );
139
- }
140
-
141
- // In a case of a multi-root editor, a callback will be attached more than once (one callback for each root).
142
- // While executing one callback the `isRenderingInProgress` observable is changing what causes executing another
143
- // callback and render is called inside the already pending render.
144
- // We need to be sure that callback is executed only when the value has changed from `true` to `false`.
145
- // See https://github.com/ckeditor/ckeditor5/issues/1676.
146
- function updateAfterRender( view ) {
147
- editingView.once( 'change:isRenderingInProgress', ( evt, name, value ) => {
148
- if ( !value ) {
149
- update( view );
150
- } else {
151
- updateAfterRender( view );
152
- }
153
- } );
154
- }
155
- }
15
+ /**
16
+ * Creates an instance of EditableUIView class.
17
+ *
18
+ * @param {module:utils/locale~Locale} [locale] The locale instance.
19
+ * @param {module:engine/view/view~View} editingView The editing view instance the editable is related to.
20
+ * @param {HTMLElement} [editableElement] The editable element. If not specified, this view
21
+ * should create it. Otherwise, the existing element should be used.
22
+ */
23
+ constructor(locale, editingView, editableElement) {
24
+ super(locale);
25
+ this.setTemplate({
26
+ tag: 'div',
27
+ attributes: {
28
+ class: [
29
+ 'ck',
30
+ 'ck-content',
31
+ 'ck-editor__editable',
32
+ 'ck-rounded-corners'
33
+ ],
34
+ lang: locale.contentLanguage,
35
+ dir: locale.contentLanguageDirection
36
+ }
37
+ });
38
+ /**
39
+ * The name of the editable UI view.
40
+ *
41
+ * @member {String} #name
42
+ */
43
+ this.name = null;
44
+ /**
45
+ * Controls whether the editable is focused, i.e. the user is typing in it.
46
+ *
47
+ * @observable
48
+ * @member {Boolean} #isFocused
49
+ */
50
+ this.set('isFocused', false);
51
+ /**
52
+ * The element which is the main editable element (usually the one with `contentEditable="true"`).
53
+ *
54
+ * @private
55
+ * @type {HTMLElement}
56
+ */
57
+ this._editableElement = editableElement;
58
+ /**
59
+ * Whether an external {@link #_editableElement} was passed into the constructor, which also means
60
+ * the view will not render its {@link #template}.
61
+ *
62
+ * @private
63
+ * @type {Boolean}
64
+ */
65
+ this._hasExternalElement = !!this._editableElement;
66
+ /**
67
+ * The editing view instance the editable is related to. Editable uses the editing
68
+ * view to dynamically modify its certain DOM attributes after {@link #render rendering}.
69
+ *
70
+ * **Note**: The DOM attributes are performed by the editing view and not UI
71
+ * {@link module:ui/view~View#bindTemplate template bindings} because once rendered,
72
+ * the editable DOM element must remain under the full control of the engine to work properly.
73
+ *
74
+ * @protected
75
+ * @type {module:engine/view/view~View}
76
+ */
77
+ this._editingView = editingView;
78
+ }
79
+ /**
80
+ * Renders the view by either applying the {@link #template} to the existing
81
+ * {@link #_editableElement} or assigning {@link #element} as {@link #_editableElement}.
82
+ */
83
+ render() {
84
+ super.render();
85
+ if (this._hasExternalElement) {
86
+ this.template.apply(this.element = this._editableElement);
87
+ }
88
+ else {
89
+ this._editableElement = this.element;
90
+ }
91
+ this.on('change:isFocused', () => this._updateIsFocusedClasses());
92
+ this._updateIsFocusedClasses();
93
+ }
94
+ /**
95
+ * @inheritDoc
96
+ */
97
+ destroy() {
98
+ if (this._hasExternalElement) {
99
+ this.template.revert(this._editableElement);
100
+ }
101
+ super.destroy();
102
+ }
103
+ /**
104
+ * Updates the `ck-focused` and `ck-blurred` CSS classes on the {@link #element} according to
105
+ * the {@link #isFocused} property value using the {@link #_editingView editing view} API.
106
+ *
107
+ * @private
108
+ */
109
+ _updateIsFocusedClasses() {
110
+ const editingView = this._editingView;
111
+ if (editingView.isRenderingInProgress) {
112
+ updateAfterRender(this);
113
+ }
114
+ else {
115
+ update(this);
116
+ }
117
+ function update(view) {
118
+ editingView.change(writer => {
119
+ const viewRoot = editingView.document.getRoot(view.name);
120
+ writer.addClass(view.isFocused ? 'ck-focused' : 'ck-blurred', viewRoot);
121
+ writer.removeClass(view.isFocused ? 'ck-blurred' : 'ck-focused', viewRoot);
122
+ });
123
+ }
124
+ // In a case of a multi-root editor, a callback will be attached more than once (one callback for each root).
125
+ // While executing one callback the `isRenderingInProgress` observable is changing what causes executing another
126
+ // callback and render is called inside the already pending render.
127
+ // We need to be sure that callback is executed only when the value has changed from `true` to `false`.
128
+ // See https://github.com/ckeditor/ckeditor5/issues/1676.
129
+ function updateAfterRender(view) {
130
+ editingView.once('change:isRenderingInProgress', (evt, name, value) => {
131
+ if (!value) {
132
+ update(view);
133
+ }
134
+ else {
135
+ updateAfterRender(view);
136
+ }
137
+ });
138
+ }
139
+ }
156
140
  }
@@ -2,67 +2,57 @@
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/editableui/inline/inlineeditableuiview
8
7
  */
9
-
10
- import EditableUIView from '../../editableui/editableuiview';
11
-
8
+ import EditableUIView from '../editableuiview';
12
9
  /**
13
10
  * The inline editable UI class implementing an inline {@link module:ui/editableui/editableuiview~EditableUIView}.
14
11
  *
15
12
  * @extends module:ui/editableui/editableuiview~EditableUIView
16
13
  */
17
14
  export default class InlineEditableUIView extends EditableUIView {
18
- /**
19
- * Creates an instance of the InlineEditableUIView class.
20
- *
21
- * @param {module:utils/locale~Locale} [locale] The locale instance.
22
- * @param {module:engine/view/view~View} editingView The editing view instance the editable is related to.
23
- * @param {HTMLElement} [editableElement] The editable element. If not specified, the
24
- * {@link module:ui/editableui/editableuiview~EditableUIView}
25
- * will create it. Otherwise, the existing element will be used.
26
- * @param {Object} [options] Additional configuration of the view.
27
- * @param {Function} [options.label] A function that gets called with the instance of this view as an argument
28
- * and should return a string that represents the label of the editable for assistive technologies. If not provided,
29
- * a default label generator is used.
30
- */
31
- constructor( locale, editingView, editableElement, options = {} ) {
32
- super( locale, editingView, editableElement );
33
-
34
- const t = locale.t;
35
-
36
- this.extendTemplate( {
37
- attributes: {
38
- role: 'textbox',
39
- class: 'ck-editor__editable_inline'
40
- }
41
- } );
42
-
43
- /**
44
- * A function that gets called with the instance of this view as an argument and should return a string that
45
- * represents the label of the editable for assistive technologies.
46
- *
47
- * @private
48
- * @readonly
49
- * @param {Function}
50
- */
51
- this._generateLabel = options.label || ( () => t( 'Editor editing area: %0', this.name ) );
52
- }
53
-
54
- /**
55
- * @inheritDoc
56
- */
57
- render() {
58
- super.render();
59
-
60
- const editingView = this._editingView;
61
-
62
- editingView.change( writer => {
63
- const viewRoot = editingView.document.getRoot( this.name );
64
-
65
- writer.setAttribute( 'aria-label', this._generateLabel( this ), viewRoot );
66
- } );
67
- }
15
+ /**
16
+ * Creates an instance of the InlineEditableUIView class.
17
+ *
18
+ * @param {module:utils/locale~Locale} [locale] The locale instance.
19
+ * @param {module:engine/view/view~View} editingView The editing view instance the editable is related to.
20
+ * @param {HTMLElement} [editableElement] The editable element. If not specified, the
21
+ * {@link module:ui/editableui/editableuiview~EditableUIView}
22
+ * will create it. Otherwise, the existing element will be used.
23
+ * @param {Object} [options] Additional configuration of the view.
24
+ * @param {Function} [options.label] A function that gets called with the instance of this view as an argument
25
+ * and should return a string that represents the label of the editable for assistive technologies. If not provided,
26
+ * a default label generator is used.
27
+ */
28
+ constructor(locale, editingView, editableElement, options = {}) {
29
+ super(locale, editingView, editableElement);
30
+ const t = locale.t;
31
+ this.extendTemplate({
32
+ attributes: {
33
+ role: 'textbox',
34
+ class: 'ck-editor__editable_inline'
35
+ }
36
+ });
37
+ /**
38
+ * A function that gets called with the instance of this view as an argument and should return a string that
39
+ * represents the label of the editable for assistive technologies.
40
+ *
41
+ * @private
42
+ * @readonly
43
+ * @param {Function}
44
+ */
45
+ this._generateLabel = options.label || (() => t('Editor editing area: %0', this.name));
46
+ }
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ render() {
51
+ super.render();
52
+ const editingView = this._editingView;
53
+ editingView.change(writer => {
54
+ const viewRoot = editingView.document.getRoot(this.name);
55
+ writer.setAttribute('aria-label', this._generateLabel(this), viewRoot);
56
+ });
57
+ }
68
58
  }
@@ -2,18 +2,13 @@
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/editorui/bodycollection
8
7
  */
9
-
10
8
  /* globals document */
11
-
12
9
  import Template from '../template';
13
10
  import ViewCollection from '../viewcollection';
14
-
15
11
  import createElement from '@ckeditor/ckeditor5-utils/src/dom/createelement';
16
-
17
12
  /**
18
13
  * This is a special {@link module:ui/viewcollection~ViewCollection} dedicated to elements that are detached
19
14
  * from the DOM structure of the editor, like panels, icons, etc.
@@ -33,74 +28,65 @@ import createElement from '@ckeditor/ckeditor5-utils/src/dom/createelement';
33
28
  * @extends module:ui/viewcollection~ViewCollection
34
29
  */
35
30
  export default class BodyCollection extends ViewCollection {
36
- /**
37
- * Creates a new instance of the {@link module:ui/editorui/bodycollection~BodyCollection}.
38
- *
39
- * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor editor's locale} instance.
40
- * @param {Iterable.<module:ui/view~View>} [initialItems] The initial items of the collection.
41
- */
42
- constructor( locale, initialItems = [] ) {
43
- super( initialItems );
44
-
45
- /**
46
- * The {@link module:core/editor/editor~Editor#locale editor's locale} instance.
47
- * See the view {@link module:ui/view~View#locale locale} property.
48
- *
49
- * @member {module:utils/locale~Locale}
50
- */
51
- this.locale = locale;
52
- }
53
-
54
- /**
55
- * Attaches the body collection to the DOM body element. You need to execute this method to render the content of
56
- * the body collection.
57
- */
58
- attachToDom() {
59
- /**
60
- * The element holding elements of the body region.
61
- *
62
- * @protected
63
- * @member {HTMLElement} #_bodyCollectionContainer
64
- */
65
- this._bodyCollectionContainer = new Template( {
66
- tag: 'div',
67
- attributes: {
68
- class: [
69
- 'ck',
70
- 'ck-reset_all',
71
- 'ck-body',
72
- 'ck-rounded-corners'
73
- ],
74
- dir: this.locale.uiLanguageDirection
75
- },
76
- children: this
77
- } ).render();
78
-
79
- let wrapper = document.querySelector( '.ck-body-wrapper' );
80
-
81
- if ( !wrapper ) {
82
- wrapper = createElement( document, 'div', { class: 'ck-body-wrapper' } );
83
- document.body.appendChild( wrapper );
84
- }
85
-
86
- wrapper.appendChild( this._bodyCollectionContainer );
87
- }
88
-
89
- /**
90
- * Detaches the collection from the DOM structure. Use this method when you do not need to use the body collection
91
- * anymore to clean-up the DOM structure.
92
- */
93
- detachFromDom() {
94
- super.destroy();
95
-
96
- if ( this._bodyCollectionContainer ) {
97
- this._bodyCollectionContainer.remove();
98
- }
99
-
100
- const wrapper = document.querySelector( '.ck-body-wrapper' );
101
-
102
- if ( wrapper && wrapper.childElementCount == 0 ) {
103
- wrapper.remove();
104
- }
105
- }
31
+ /**
32
+ * Creates a new instance of the {@link module:ui/editorui/bodycollection~BodyCollection}.
33
+ *
34
+ * @param {module:utils/locale~Locale} locale The {@link module:core/editor/editor~Editor editor's locale} instance.
35
+ * @param {Iterable.<module:ui/view~View>} [initialItems] The initial items of the collection.
36
+ */
37
+ constructor(locale, initialItems = []) {
38
+ super(initialItems);
39
+ /**
40
+ * The {@link module:core/editor/editor~Editor#locale editor's locale} instance.
41
+ * See the view {@link module:ui/view~View#locale locale} property.
42
+ *
43
+ * @member {module:utils/locale~Locale}
44
+ */
45
+ this.locale = locale;
46
+ }
47
+ /**
48
+ * Attaches the body collection to the DOM body element. You need to execute this method to render the content of
49
+ * the body collection.
50
+ */
51
+ attachToDom() {
52
+ /**
53
+ * The element holding elements of the body region.
54
+ *
55
+ * @protected
56
+ * @member {HTMLElement} #_bodyCollectionContainer
57
+ */
58
+ this._bodyCollectionContainer = new Template({
59
+ tag: 'div',
60
+ attributes: {
61
+ class: [
62
+ 'ck',
63
+ 'ck-reset_all',
64
+ 'ck-body',
65
+ 'ck-rounded-corners'
66
+ ],
67
+ dir: this.locale.uiLanguageDirection
68
+ },
69
+ children: this
70
+ }).render();
71
+ let wrapper = document.querySelector('.ck-body-wrapper');
72
+ if (!wrapper) {
73
+ wrapper = createElement(document, 'div', { class: 'ck-body-wrapper' });
74
+ document.body.appendChild(wrapper);
75
+ }
76
+ wrapper.appendChild(this._bodyCollectionContainer);
77
+ }
78
+ /**
79
+ * Detaches the collection from the DOM structure. Use this method when you do not need to use the body collection
80
+ * anymore to clean-up the DOM structure.
81
+ */
82
+ detachFromDom() {
83
+ super.destroy();
84
+ if (this._bodyCollectionContainer) {
85
+ this._bodyCollectionContainer.remove();
86
+ }
87
+ const wrapper = document.querySelector('.ck-body-wrapper');
88
+ if (wrapper && wrapper.childElementCount == 0) {
89
+ wrapper.remove();
90
+ }
91
+ }
106
92
  }