Browse Source

REPORT-56417 feat: 提供通过dataTransfer对象上传文件的接口

es6
iapyang 3 years ago
parent
commit
a4592af5b1
  1. 6
      src/base/single/editor/editor.multifile.js
  2. 10
      src/base/single/input/file.js
  3. 15
      src/polyfill/event.js
  4. 2
      typescript/widget/editor/editor.multifile.ts

6
src/base/single/editor/editor.multifile.js

@ -91,6 +91,12 @@ BI.MultifileEditor = BI.inherit(BI.Widget, {
this.file.upload();
},
sendFiles: function (files) {
this._reset();
this.file.sendFiles(files);
},
reset: function () {
this._reset();
}

10
src/base/single/input/file.js

@ -683,6 +683,16 @@
}
},
sendFiles: function (files) {
if (!this.wrap) return;
this.wrap.dom.input.files = files;
var event = new CustomEvent("change");
this.wrap.dom.input.dispatchEvent(event);
},
_setEnable: function (enable) {
BI.File.superclass._setEnable.apply(this, arguments);
if (enable === true) {

15
src/polyfill/event.js

@ -0,0 +1,15 @@
(function () {
if (typeof window.CustomEvent === "function") return false; // If not IE
function CustomEvent (event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
}());

2
typescript/widget/editor/editor.multifile.ts

@ -30,4 +30,6 @@ export declare class MultifileEditor extends Widget {
size: number;
type: string;
}[];
sendFiles(files: FileList): void;
}

Loading…
Cancel
Save