Updated image card to trigger file browse immediately when inserting

no issue

- removes number of clicks required to insert images, especially when using the `/image` shortcut
- strips `triggerBrowse` property from the payload after inserting to avoid triggering file browse when a post with blank image cards is rendered/re-rendered
This commit is contained in:
Kevin Ansfield 2020-02-27 14:36:43 +00:00
parent 74b5327dbe
commit dfe0b6f810
2 changed files with 16 additions and 1 deletions

View File

@ -147,6 +147,18 @@ export default Component.extend({
}
},
didInsertElement() {
if (this.payload.triggerBrowse && !this.payload.src && !this.payload.files) {
// we don't want to persist this in the serialized payload
this._updatePayloadAttr('triggerBrowse', undefined);
let fileInput = this.element.querySelector('input[type="file"]');
if (fileInput) {
fileInput.click();
}
}
},
actions: {
updateSrc(images) {
let [image] = images;

View File

@ -52,7 +52,10 @@ export const CARD_MENU = [
matches: ['image', 'img'],
type: 'card',
replaceArg: 'image',
params: ['src']
params: ['src'],
payload: {
triggerBrowse: true
}
},
{
label: 'Markdown',