Browse Source

Make asset selection more consistent. Fixes #3613

pull/3725/head
Artur Arseniev 5 years ago
parent
commit
dd090a9f58
  1. 18
      src/asset_manager/view/AssetImageView.js
  2. 14
      src/dom_components/view/ComponentImageView.js
  3. 11
      src/style_manager/view/PropertyFileView.js

18
src/asset_manager/view/AssetImageView.js

@ -42,15 +42,16 @@ export default AssetView.extend({
* @private
* */
onClick() {
var onClick = this.config.onClick;
var model = this.model;
this.collection.trigger('deselectAll');
this.$el.addClass(this.pfx + 'highlight');
const { model, pfx } = this;
const { onClick } = this.config;
const coll = this.collection;
coll.trigger('deselectAll');
this.$el.addClass(pfx + 'highlight');
if (isFunction(onClick)) {
onClick(model);
} else {
this.updateTarget(this.collection.target);
this.updateTarget(coll.target);
}
},
@ -60,16 +61,15 @@ export default AssetView.extend({
* */
onDblClick() {
const { em, model } = this;
const onDblClick = this.config.onDblClick;
const { onDblClick } = this.config;
const { target, onSelect } = this.collection;
if (isFunction(onDblClick)) {
onDblClick(model);
} else {
this.updateTarget(this.collection.target);
this.updateTarget(target);
em && em.get('Modal').close();
}
var onSelect = this.collection.onSelect;
isFunction(onSelect) && onSelect(model);
},

14
src/dom_components/view/ComponentImageView.js

@ -62,17 +62,17 @@ export default ComponentView.extend({
* */
onActive(ev) {
ev && ev.stopPropagation();
var em = this.opts.config.em;
var editor = em ? em.get('Editor') : '';
const { em, model } = this;
const ed = em && em.get('Editor');
if (editor && this.model.get('editable')) {
editor.runCommand('open-assets', {
target: this.model,
if (ed && model.get('editable')) {
ed.runCommand('open-assets', {
target: model,
types: ['image'],
accept: 'image/*',
onSelect() {
editor.Modal.close();
editor.AssetManager.setTarget(null);
ed.Modal.close();
ed.AssetManager.setTarget(null);
}
});
}

11
src/style_manager/view/PropertyFileView.js

@ -120,21 +120,20 @@ export default PropertyView.extend({
*
* @return void
* */
openAssetManager(e) {
openAssetManager() {
const { em, modal } = this;
const editor = em ? em.get('Editor') : '';
const handleAsset = a => this.spreadUrl(isString(a) ? a : a.get('src'));
if (editor) {
editor.runCommand('open-assets', {
types: ['image'],
accept: 'image/*',
target: this.getTargetModel(),
onClick() {},
onDblClick() {},
onSelect: asset => {
onClick: handleAsset,
onDblClick(asset) {
modal.close();
const url = isString(asset) ? asset : asset.get('src');
this.spreadUrl(url);
handleAsset(asset);
}
});
}

Loading…
Cancel
Save