@ckeditor/ckeditor5-ui 35.2.0 → 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,127 +2,161 @@
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
  /* global DOMParser */
7
-
8
6
  /**
9
7
  * @module ui/icon/iconview
10
8
  */
11
-
12
9
  import View from '../view';
13
-
14
10
  import '../../theme/components/icon/icon.css';
15
-
16
11
  /**
17
12
  * The icon view class.
18
13
  *
19
14
  * @extends module:ui/view~View
20
15
  */
21
16
  export default class IconView extends View {
22
- /**
23
- * @inheritDoc
24
- */
25
- constructor() {
26
- super();
27
-
28
- const bind = this.bindTemplate;
29
-
30
- /**
31
- * The SVG source of the icon.
32
- *
33
- * @observable
34
- * @member {String} #content
35
- */
36
- this.set( 'content', '' );
37
-
38
- /**
39
- * This attribute specifies the boundaries to which the
40
- * icon content should stretch.
41
- *
42
- * @observable
43
- * @default '0 0 20 20'
44
- * @member {String} #viewBox
45
- */
46
- this.set( 'viewBox', '0 0 20 20' );
47
-
48
- /**
49
- * The fill color of the child `path.ck-icon__fill`.
50
- *
51
- * @observable
52
- * @default ''
53
- * @member {String} #fillColor
54
- */
55
- this.set( 'fillColor', '' );
56
-
57
- this.setTemplate( {
58
- tag: 'svg',
59
- ns: 'http://www.w3.org/2000/svg',
60
- attributes: {
61
- class: [
62
- 'ck',
63
- 'ck-icon'
64
- ],
65
- viewBox: bind.to( 'viewBox' )
66
- }
67
- } );
68
- }
69
-
70
- /**
71
- * @inheritDoc
72
- */
73
- render() {
74
- super.render();
75
-
76
- this._updateXMLContent();
77
- this._colorFillPaths();
78
-
79
- // This is a hack for lack of innerHTML binding.
80
- // See: https://github.com/ckeditor/ckeditor5-ui/issues/99.
81
- this.on( 'change:content', () => {
82
- this._updateXMLContent();
83
- this._colorFillPaths();
84
- } );
85
-
86
- this.on( 'change:fillColor', () => {
87
- this._colorFillPaths();
88
- } );
89
- }
90
-
91
- /**
92
- * Updates the {@link #element} with the value of {@link #content}.
93
- *
94
- * @private
95
- */
96
- _updateXMLContent() {
97
- if ( this.content ) {
98
- const parsed = new DOMParser().parseFromString( this.content.trim(), 'image/svg+xml' );
99
- const svg = parsed.querySelector( 'svg' );
100
- const viewBox = svg.getAttribute( 'viewBox' );
101
-
102
- if ( viewBox ) {
103
- this.viewBox = viewBox;
104
- }
105
-
106
- while ( this.element.firstChild ) {
107
- this.element.removeChild( this.element.firstChild );
108
- }
109
-
110
- while ( svg.childNodes.length > 0 ) {
111
- this.element.appendChild( svg.childNodes[ 0 ] );
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * Fills all child `path.ck-icon__fill` with the `#fillColor`.
118
- *
119
- * @private
120
- */
121
- _colorFillPaths() {
122
- if ( this.fillColor ) {
123
- this.element.querySelectorAll( '.ck-icon__fill' ).forEach( path => {
124
- path.style.fill = this.fillColor;
125
- } );
126
- }
127
- }
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ constructor() {
21
+ super();
22
+ const bind = this.bindTemplate;
23
+ /**
24
+ * The SVG source of the icon.
25
+ *
26
+ * @observable
27
+ * @member {String} #content
28
+ */
29
+ this.set('content', '');
30
+ /**
31
+ * This attribute specifies the boundaries to which the
32
+ * icon content should stretch.
33
+ *
34
+ * @observable
35
+ * @default '0 0 20 20'
36
+ * @member {String} #viewBox
37
+ */
38
+ this.set('viewBox', '0 0 20 20');
39
+ /**
40
+ * The fill color of the child `path.ck-icon__fill`.
41
+ *
42
+ * @observable
43
+ * @default ''
44
+ * @member {String} #fillColor
45
+ */
46
+ this.set('fillColor', '');
47
+ /**
48
+ * When set true (default), all parts of the icon inherit the fill color from the CSS `color` property of the
49
+ * icon's DOM parent.
50
+ *
51
+ * This effectively makes the icon monochromatic and allows it to change its fill color dynamically, for instance,
52
+ * when a {@link module:ui/button/buttonview~ButtonView} displays an icon and it switches between different states
53
+ * (pushed, hovered, etc.) the icon will follow along.
54
+ *
55
+ * **Note**: For the monochromatic icon to render properly, it must be made up of shapes that can be filled
56
+ * with color instead of, for instance, paths with strokes. Be sure to use the *outline stroke* tool
57
+ * (the name could be different in your vector graphics editor) before exporting your icon. Also, remove any
58
+ * excess `fill="..."` attributes that could break the color inheritance.
59
+ *
60
+ * **Note**: If you want to preserve the original look of your icon and disable dynamic color inheritance,
61
+ * set this flag to `false`.
62
+ *
63
+ * @observable
64
+ * @default true
65
+ * @member {Boolean} #isColorInherited
66
+ */
67
+ this.set('isColorInherited', true);
68
+ this.setTemplate({
69
+ tag: 'svg',
70
+ ns: 'http://www.w3.org/2000/svg',
71
+ attributes: {
72
+ class: [
73
+ 'ck',
74
+ 'ck-icon',
75
+ // Exclude icon internals from the CSS reset to allow rich (non-monochromatic) icons
76
+ // (https://github.com/ckeditor/ckeditor5/issues/12599).
77
+ 'ck-reset_all-excluded',
78
+ // The class to remove the dynamic color inheritance is toggleable
79
+ // (https://github.com/ckeditor/ckeditor5/issues/12599).
80
+ bind.if('isColorInherited', 'ck-icon_inherit-color')
81
+ ],
82
+ viewBox: bind.to('viewBox')
83
+ }
84
+ });
85
+ }
86
+ /**
87
+ * @inheritDoc
88
+ */
89
+ render() {
90
+ super.render();
91
+ this._updateXMLContent();
92
+ this._colorFillPaths();
93
+ // This is a hack for lack of innerHTML binding.
94
+ // See: https://github.com/ckeditor/ckeditor5-ui/issues/99.
95
+ this.on('change:content', () => {
96
+ this._updateXMLContent();
97
+ this._colorFillPaths();
98
+ });
99
+ this.on('change:fillColor', () => {
100
+ this._colorFillPaths();
101
+ });
102
+ }
103
+ /**
104
+ * Updates the {@link #element} with the value of {@link #content}.
105
+ *
106
+ * @private
107
+ */
108
+ _updateXMLContent() {
109
+ if (this.content) {
110
+ const parsed = new DOMParser().parseFromString(this.content.trim(), 'image/svg+xml');
111
+ const svg = parsed.querySelector('svg');
112
+ const viewBox = svg.getAttribute('viewBox');
113
+ if (viewBox) {
114
+ this.viewBox = viewBox;
115
+ }
116
+ // Preserve presentational attributes of the <svg> element from the source.
117
+ // They can affect rendering of the entire icon (https://github.com/ckeditor/ckeditor5/issues/12597).
118
+ for (const { name, value } of Array.from(svg.attributes)) {
119
+ if (IconView.presentationalAttributeNames.includes(name)) {
120
+ this.element.setAttribute(name, value);
121
+ }
122
+ }
123
+ while (this.element.firstChild) {
124
+ this.element.removeChild(this.element.firstChild);
125
+ }
126
+ while (svg.childNodes.length > 0) {
127
+ this.element.appendChild(svg.childNodes[0]);
128
+ }
129
+ }
130
+ }
131
+ /**
132
+ * Fills all child `path.ck-icon__fill` with the `#fillColor`.
133
+ *
134
+ * @private
135
+ */
136
+ _colorFillPaths() {
137
+ if (this.fillColor) {
138
+ this.element.querySelectorAll('.ck-icon__fill').forEach(path => {
139
+ path.style.fill = this.fillColor;
140
+ });
141
+ }
142
+ }
128
143
  }
144
+ /**
145
+ * A list of presentational attributes that can be set on the `<svg>` element and should be preserved
146
+ * when the icon {@link module:ui/icon/iconview~IconView#content content} is loaded.
147
+ *
148
+ * See the [specification](https://www.w3.org/TR/SVG/styling.html#TermPresentationAttribute) to learn more.
149
+ *
150
+ * @protected
151
+ * @member {Array.<String>} module:ui/icon/iconview~IconView.presentationalAttributeNames
152
+ */
153
+ IconView.presentationalAttributeNames = [
154
+ 'alignment-baseline', 'baseline-shift', 'clip-path', 'clip-rule', 'color', 'color-interpolation',
155
+ 'color-interpolation-filters', 'color-rendering', 'cursor', 'direction', 'display', 'dominant-baseline', 'fill', 'fill-opacity',
156
+ 'fill-rule', 'filter', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style',
157
+ 'font-variant', 'font-weight', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start',
158
+ 'mask', 'opacity', 'overflow', 'paint-order', 'pointer-events', 'shape-rendering', 'stop-color', 'stop-opacity', 'stroke',
159
+ 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width',
160
+ 'text-anchor', 'text-decoration', 'text-overflow', 'text-rendering', 'transform', 'unicode-bidi', 'vector-effect',
161
+ 'visibility', 'white-space', 'word-spacing', 'writing-mode'
162
+ ];
@@ -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/iframe/iframeview
8
7
  */
9
-
10
8
  import View from '../view';
11
-
12
9
  /**
13
10
  * The iframe view class.
14
11
  *
@@ -26,50 +23,41 @@ import View from '../view';
26
23
  * @extends module:ui/view~View
27
24
  */
28
25
  export default class IframeView extends View {
29
- /**
30
- * Creates a new instance of the iframe view.
31
- *
32
- * @param {module:utils/locale~Locale} [locale] The locale instance.
33
- */
34
- constructor( locale ) {
35
- super( locale );
36
-
37
- const bind = this.bindTemplate;
38
-
39
- this.setTemplate( {
40
- tag: 'iframe',
41
- attributes: {
42
- class: [
43
- 'ck',
44
- 'ck-reset_all'
45
- ],
46
- // It seems that we need to allow scripts in order to be able to listen to events.
47
- // TODO: Research that. Perhaps the src must be set?
48
- sandbox: 'allow-same-origin allow-scripts'
49
- },
50
- on: {
51
- load: bind.to( 'loaded' )
52
- }
53
- } );
54
- }
55
-
56
- /**
57
- * Renders the iframe's {@link #element} and returns a `Promise` for asynchronous
58
- * child `contentDocument` loading process.
59
- *
60
- * @returns {Promise} A promise which resolves once the iframe `contentDocument` has
61
- * been {@link #event:loaded}.
62
- */
63
- render() {
64
- return new Promise( resolve => {
65
- this.on( 'loaded', resolve );
66
- super.render();
67
- } );
68
- }
26
+ /**
27
+ * Creates a new instance of the iframe view.
28
+ *
29
+ * @param {module:utils/locale~Locale} [locale] The locale instance.
30
+ */
31
+ constructor(locale) {
32
+ super(locale);
33
+ const bind = this.bindTemplate;
34
+ this.setTemplate({
35
+ tag: 'iframe',
36
+ attributes: {
37
+ class: [
38
+ 'ck',
39
+ 'ck-reset_all'
40
+ ],
41
+ // It seems that we need to allow scripts in order to be able to listen to events.
42
+ // TODO: Research that. Perhaps the src must be set?
43
+ sandbox: 'allow-same-origin allow-scripts'
44
+ },
45
+ on: {
46
+ load: bind.to('loaded')
47
+ }
48
+ });
49
+ }
50
+ /**
51
+ * Renders the iframe's {@link #element} and returns a `Promise` for asynchronous
52
+ * child `contentDocument` loading process.
53
+ *
54
+ * @returns {Promise} A promise which resolves once the iframe `contentDocument` has
55
+ * been {@link #event:loaded}.
56
+ */
57
+ render() {
58
+ return new Promise(resolve => {
59
+ this.on('loaded', resolve);
60
+ return super.render();
61
+ });
62
+ }
69
63
  }
70
-
71
- /**
72
- * Fired when the DOM iframe's `contentDocument` finished loading.
73
- *
74
- * @event loaded
75
- */
package/src/index.js CHANGED
@@ -2,65 +2,48 @@
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
8
7
  */
9
-
10
8
  export { default as clickOutsideHandler } from './bindings/clickoutsidehandler';
11
9
  export { default as injectCssTransitionDisabler } from './bindings/injectcsstransitiondisabler';
12
10
  export { default as submitHandler } from './bindings/submithandler';
13
11
  export { default as addKeyboardHandlingForGrid } from './bindings/addkeyboardhandlingforgrid';
14
-
15
12
  export { default as BodyCollection } from './editorui/bodycollection';
16
-
17
13
  export { default as ButtonView } from './button/buttonview';
18
14
  export { default as SwitchButtonView } from './button/switchbuttonview';
19
-
20
15
  export * from './colorgrid/utils';
21
16
  export { default as ColorGridView } from './colorgrid/colorgridview';
22
17
  export { default as ColorTileView } from './colorgrid/colortileview';
23
-
24
18
  export { default as DropdownButtonView } from './dropdown/button/dropdownbuttonview';
25
19
  export { default as SplitButtonView } from './dropdown/button/splitbuttonview';
26
20
  export * from './dropdown/utils';
27
-
28
21
  export { default as EditorUIView } from './editorui/editoruiview';
29
22
  export { default as BoxedEditorUIView } from './editorui/boxed/boxededitoruiview';
30
23
  export { default as InlineEditableUIView } from './editableui/inline/inlineeditableuiview';
31
-
32
24
  export { default as FormHeaderView } from './formheader/formheaderview';
33
25
  export { default as FocusCycler } from './focuscycler';
34
-
35
26
  export { default as IconView } from './icon/iconview';
36
27
  export { default as InputView } from './input/inputview';
37
28
  export { default as InputTextView } from './inputtext/inputtextview';
38
29
  export { default as InputNumberView } from './inputnumber/inputnumberview';
39
-
40
30
  export { default as IframeView } from './iframe/iframeview';
41
-
42
31
  export { default as LabelView } from './label/labelview';
43
32
  export { default as LabeledFieldView } from './labeledfield/labeledfieldview';
44
33
  export * from './labeledfield/utils';
45
-
46
34
  export { default as ListItemView } from './list/listitemview';
47
35
  export { default as ListView } from './list/listview';
48
-
49
36
  export { default as Notification } from './notification/notification';
50
-
51
37
  export { default as Model } from './model';
52
38
  export { default as BalloonPanelView } from './panel/balloon/balloonpanelview';
53
39
  export { default as ContextualBalloon } from './panel/balloon/contextualballoon';
54
40
  export { default as StickyPanelView } from './panel/sticky/stickypanelview';
55
-
56
41
  export { default as TooltipManager } from './tooltipmanager';
57
42
  export { default as Template } from './template';
58
-
59
43
  export { default as ToolbarView } from './toolbar/toolbarview';
60
44
  export { default as ToolbarSeparatorView } from './toolbar/toolbarseparatorview';
61
45
  export { default as normalizeToolbarConfig } from './toolbar/normalizetoolbarconfig';
62
46
  export { default as BalloonToolbar } from './toolbar/balloon/balloontoolbar';
63
47
  export { default as BlockToolbar } from './toolbar/block/blocktoolbar';
64
-
65
48
  export { default as View } from './view';
66
49
  export { default as ViewCollection } from './viewcollection';