mirror of https://github.com/artf/grapesjs.git
nocodeframeworkdrag-and-dropsite-buildersite-generatortemplate-builderui-builderweb-builderweb-builder-frameworkwebsite-builderno-codepage-builder
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
export default {
|
|
run(editor, sender, opts = {}) {
|
|
const modal = editor.Modal;
|
|
const am = editor.AssetManager;
|
|
const config = am.getConfig();
|
|
const amContainer = am.getContainer();
|
|
const title = opts.modalTitle || config.modalTitle || '';
|
|
const types = opts.types;
|
|
const accept = opts.accept;
|
|
|
|
am.setTarget(opts.target);
|
|
am.onClick(opts.onClick);
|
|
am.onDblClick(opts.onDblClick);
|
|
am.onSelect(opts.onSelect);
|
|
|
|
if (!this.rendered || types) {
|
|
let assets = am.getAll().filter(i => 1);
|
|
|
|
if (types && types.length) {
|
|
assets = assets.filter(a => types.indexOf(a.get('type')) !== -1);
|
|
}
|
|
|
|
am.render(assets);
|
|
this.rendered = 1;
|
|
}
|
|
|
|
if (accept) {
|
|
const uploadEl = amContainer.querySelector(
|
|
`input#${config.stylePrefix}uploadFile`
|
|
);
|
|
uploadEl && uploadEl.setAttribute('accept', accept);
|
|
}
|
|
|
|
modal
|
|
.open({
|
|
title,
|
|
content: amContainer
|
|
})
|
|
.getModel()
|
|
.once('change:open', () => editor.stopCommand(this.id));
|
|
return this;
|
|
},
|
|
|
|
stop(editor) {
|
|
editor.Modal.close();
|
|
return this;
|
|
}
|
|
};
|
|
|