mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 13:56:11 +01:00
chore(ckeditor5/plugins): add file-upload
Original commit: a440988df452ab4367f5288269ba3c05aa5e6b8e
This commit is contained in:
68
_regroup/ckeditor5-file-upload/theme/progressbarview.js
Normal file
68
_regroup/ckeditor5-file-upload/theme/progressbarview.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import View from "@ckeditor/ckeditor5-ui/src/view";
|
||||
import toUnit from '@ckeditor/ckeditor5-utils/src/dom/tounit';
|
||||
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
|
||||
|
||||
import cancelIcon from '@ckeditor/ckeditor5-core/theme/icons/cancel.svg';
|
||||
|
||||
const toPx = toUnit('%');
|
||||
|
||||
export default class ProgressBarView extends View {
|
||||
constructor(locale) {
|
||||
super(locale);
|
||||
|
||||
const bind = this.bindTemplate;
|
||||
this.cancelButton = this._createCancelButton(locale);
|
||||
|
||||
// Views define their interface (state) using observable attributes.
|
||||
this.set('width', 100);
|
||||
this.set('customWidth', 0);
|
||||
|
||||
|
||||
this.setTemplate({
|
||||
tag: 'div',
|
||||
|
||||
// The element of the view can be defined with its children.
|
||||
children: [
|
||||
{
|
||||
tag: 'div',
|
||||
children: ['Uploading...'],
|
||||
attributes: {
|
||||
class: ['ck-uploading-progress'],
|
||||
style: {
|
||||
width: bind.to('customWidth', toPx),
|
||||
}
|
||||
}
|
||||
},
|
||||
this.cancelButton,
|
||||
],
|
||||
attributes: {
|
||||
class: [
|
||||
'ck-progress-bar',
|
||||
|
||||
// Observable attributes control the state of the view in DOM.
|
||||
bind.to('elementClass')
|
||||
],
|
||||
style: {
|
||||
width: bind.to('width', toPx),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_createCancelButton(locale) {
|
||||
const view = new ButtonView(locale);
|
||||
view.set({
|
||||
icon: cancelIcon,
|
||||
tooltip: true,
|
||||
label: 'Cancel',
|
||||
attributes: {
|
||||
class: ['ck', 'ck-button', 'ck-off', 'ck-button-cancel', 'ck-uploading-cancel']
|
||||
}
|
||||
});
|
||||
|
||||
view.on('execute', () => {
|
||||
this.fire('cancel')
|
||||
});
|
||||
return view;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user