@ckeditor/ckeditor5-upload 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.
package/src/index.js CHANGED
@@ -2,11 +2,9 @@
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 upload
8
7
  */
9
-
10
8
  export { default as FileRepository } from './filerepository';
11
9
  export { default as FileDialogButtonView } from './ui/filedialogbuttonview';
12
10
  export { default as Base64UploadAdapter } from './adapters/base64uploadadapter';
@@ -2,14 +2,11 @@
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 upload/ui/filedialogbuttonview
8
7
  */
9
-
10
8
  import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
11
9
  import View from '@ckeditor/ckeditor5-ui/src/view';
12
-
13
10
  /**
14
11
  * The file dialog button view.
15
12
  *
@@ -38,84 +35,75 @@ import View from '@ckeditor/ckeditor5-ui/src/view';
38
35
  * @extends module:ui/view~View
39
36
  */
40
37
  export default class FileDialogButtonView extends View {
41
- /**
42
- * @inheritDoc
43
- */
44
- constructor( locale ) {
45
- super( locale );
46
-
47
- /**
48
- * The button view of the component.
49
- *
50
- * @member {module:ui/button/buttonview~ButtonView}
51
- */
52
- this.buttonView = new ButtonView( locale );
53
-
54
- /**
55
- * A hidden `<input>` view used to execute file dialog.
56
- *
57
- * @protected
58
- * @member {module:upload/ui/filedialogbuttonview~FileInputView}
59
- */
60
- this._fileInputView = new FileInputView( locale );
61
-
62
- /**
63
- * Accepted file types. Can be provided in form of file extensions, media type or one of:
64
- * * `audio/*`,
65
- * * `video/*`,
66
- * * `image/*`.
67
- *
68
- * @observable
69
- * @member {String} #acceptedType
70
- */
71
- this._fileInputView.bind( 'acceptedType' ).to( this );
72
-
73
- /**
74
- * Indicates if multiple files can be selected. Defaults to `true`.
75
- *
76
- * @observable
77
- * @member {Boolean} #allowMultipleFiles
78
- */
79
- this._fileInputView.bind( 'allowMultipleFiles' ).to( this );
80
-
81
- /**
82
- * Fired when file dialog is closed with file selected.
83
- *
84
- * view.on( 'done', ( evt, files ) => {
85
- * for ( const file of files ) {
86
- * console.log( 'Selected file', file );
87
- * }
88
- * }
89
- *
90
- * @event done
91
- * @param {Array.<File>} files Array of selected files.
92
- */
93
- this._fileInputView.delegate( 'done' ).to( this );
94
-
95
- this.setTemplate( {
96
- tag: 'span',
97
- attributes: {
98
- class: 'ck-file-dialog-button'
99
- },
100
- children: [
101
- this.buttonView,
102
- this._fileInputView
103
- ]
104
- } );
105
-
106
- this.buttonView.on( 'execute', () => {
107
- this._fileInputView.open();
108
- } );
109
- }
110
-
111
- /**
112
- * Focuses the {@link #buttonView}.
113
- */
114
- focus() {
115
- this.buttonView.focus();
116
- }
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ constructor(locale) {
42
+ super(locale);
43
+ /**
44
+ * The button view of the component.
45
+ *
46
+ * @member {module:ui/button/buttonview~ButtonView}
47
+ */
48
+ this.buttonView = new ButtonView(locale);
49
+ /**
50
+ * A hidden `<input>` view used to execute file dialog.
51
+ *
52
+ * @protected
53
+ * @member {module:upload/ui/filedialogbuttonview~FileInputView}
54
+ */
55
+ this._fileInputView = new FileInputView(locale);
56
+ /**
57
+ * Accepted file types. Can be provided in form of file extensions, media type or one of:
58
+ * * `audio/*`,
59
+ * * `video/*`,
60
+ * * `image/*`.
61
+ *
62
+ * @observable
63
+ * @member {String} #acceptedType
64
+ */
65
+ this._fileInputView.bind('acceptedType').to(this);
66
+ /**
67
+ * Indicates if multiple files can be selected. Defaults to `true`.
68
+ *
69
+ * @observable
70
+ * @member {Boolean} #allowMultipleFiles
71
+ */
72
+ this._fileInputView.bind('allowMultipleFiles').to(this);
73
+ /**
74
+ * Fired when file dialog is closed with file selected.
75
+ *
76
+ * view.on( 'done', ( evt, files ) => {
77
+ * for ( const file of files ) {
78
+ * console.log( 'Selected file', file );
79
+ * }
80
+ * }
81
+ *
82
+ * @event done
83
+ * @param {Array.<File>} files Array of selected files.
84
+ */
85
+ this._fileInputView.delegate('done').to(this);
86
+ this.setTemplate({
87
+ tag: 'span',
88
+ attributes: {
89
+ class: 'ck-file-dialog-button'
90
+ },
91
+ children: [
92
+ this.buttonView,
93
+ this._fileInputView
94
+ ]
95
+ });
96
+ this.buttonView.on('execute', () => {
97
+ this._fileInputView.open();
98
+ });
99
+ }
100
+ /**
101
+ * Focuses the {@link #buttonView}.
102
+ */
103
+ focus() {
104
+ this.buttonView.focus();
105
+ }
117
106
  }
118
-
119
107
  /**
120
108
  * The hidden file input view class.
121
109
  *
@@ -123,63 +111,55 @@ export default class FileDialogButtonView extends View {
123
111
  * @extends module:ui/view~View
124
112
  */
125
113
  class FileInputView extends View {
126
- /**
127
- * @inheritDoc
128
- */
129
- constructor( locale ) {
130
- super( locale );
131
-
132
- /**
133
- * Accepted file types. Can be provided in form of file extensions, media type or one of:
134
- * * `audio/*`,
135
- * * `video/*`,
136
- * * `image/*`.
137
- *
138
- * @observable
139
- * @member {String} #acceptedType
140
- */
141
- this.set( 'acceptedType' );
142
-
143
- /**
144
- * Indicates if multiple files can be selected. Defaults to `false`.
145
- *
146
- * @observable
147
- * @member {Boolean} #allowMultipleFiles
148
- */
149
- this.set( 'allowMultipleFiles', false );
150
-
151
- const bind = this.bindTemplate;
152
-
153
- this.setTemplate( {
154
- tag: 'input',
155
-
156
- attributes: {
157
- class: [
158
- 'ck-hidden'
159
- ],
160
- type: 'file',
161
- tabindex: '-1',
162
- accept: bind.to( 'acceptedType' ),
163
- multiple: bind.to( 'allowMultipleFiles' )
164
- },
165
-
166
- on: {
167
- // Removing from code coverage since we cannot programmatically set input element files.
168
- change: bind.to( /* istanbul ignore next */ () => {
169
- if ( this.element && this.element.files && this.element.files.length ) {
170
- this.fire( 'done', this.element.files );
171
- }
172
-
173
- this.element.value = '';
174
- } )
175
- }
176
- } );
177
- }
178
-
179
- /**
180
- * Opens file dialog.
181
- */
182
- open() {
183
- this.element.click();
184
- }
114
+ /**
115
+ * @inheritDoc
116
+ */
117
+ constructor(locale) {
118
+ super(locale);
119
+ /**
120
+ * Accepted file types. Can be provided in form of file extensions, media type or one of:
121
+ * * `audio/*`,
122
+ * * `video/*`,
123
+ * * `image/*`.
124
+ *
125
+ * @observable
126
+ * @member {String} #acceptedType
127
+ */
128
+ this.set('acceptedType', undefined);
129
+ /**
130
+ * Indicates if multiple files can be selected. Defaults to `false`.
131
+ *
132
+ * @observable
133
+ * @member {Boolean} #allowMultipleFiles
134
+ */
135
+ this.set('allowMultipleFiles', false);
136
+ const bind = this.bindTemplate;
137
+ this.setTemplate({
138
+ tag: 'input',
139
+ attributes: {
140
+ class: [
141
+ 'ck-hidden'
142
+ ],
143
+ type: 'file',
144
+ tabindex: '-1',
145
+ accept: bind.to('acceptedType'),
146
+ multiple: bind.to('allowMultipleFiles')
147
+ },
148
+ on: {
149
+ // Removing from code coverage since we cannot programmatically set input element files.
150
+ change: bind.to(/* istanbul ignore next */ () => {
151
+ if (this.element && this.element.files && this.element.files.length) {
152
+ this.fire('done', this.element.files);
153
+ }
154
+ this.element.value = '';
155
+ })
156
+ }
157
+ });
158
+ }
159
+ /**
160
+ * Opens file dialog.
161
+ */
162
+ open() {
163
+ this.element.click();
164
+ }
185
165
  }