Skip to content

Commit

Permalink
Merge pull request #206 from leftstick/master
Browse files Browse the repository at this point in the history
while pasting image at macOS/chrome, the filename is pasted parallel along with the pasting process, which leads to an unexpected string appears in the editor
  • Loading branch information
hinesboy authored Apr 18, 2018
2 parents e339bc5 + 5478276 commit c4fcd00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ export function p_urlParse() {
return obj;
};

export function stopEvent(e) {
if (!e) {
return;
}
if (e.preventDefault) {
e.preventDefault();
}
if (e.stopPropagation) {
e.stopPropagation();
}
};

5 changes: 4 additions & 1 deletion src/mavon-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
loadScript,
ImagePreviewListener
} from './lib/core/extra-function.js'
import {p_ObjectCopy_DEEP} from './lib/util.js'
import {p_ObjectCopy_DEEP, stopEvent} from './lib/util.js'
import {toolbar_left_click, toolbar_left_addlink} from './lib/toolbar_left_click.js'
import {toolbar_right_click} from './lib/toolbar_right_click.js'
import {CONFIG} from './lib/config.js'
Expand Down Expand Up @@ -351,6 +351,9 @@
}
}
if (item && item.kind === 'file') {
// prevent filename being pasted parallel along
// with the image pasting process
stopEvent($e)
var oFile = item.getAsFile();
this.$refs.toolbar_left.$imgFilesAdd([oFile,]);
}
Expand Down

0 comments on commit c4fcd00

Please sign in to comment.