Skip to content

Commit c4fcd00

Browse files
authored
Merge pull request hinesboy#206 from leftstick/master
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
2 parents e339bc5 + 5478276 commit c4fcd00

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/lib/util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ export function p_urlParse() {
3939
return obj;
4040
};
4141

42+
export function stopEvent(e) {
43+
if (!e) {
44+
return;
45+
}
46+
if (e.preventDefault) {
47+
e.preventDefault();
48+
}
49+
if (e.stopPropagation) {
50+
e.stopPropagation();
51+
}
52+
};
53+

src/mavon-editor.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
loadScript,
9595
ImagePreviewListener
9696
} from './lib/core/extra-function.js'
97-
import {p_ObjectCopy_DEEP} from './lib/util.js'
97+
import {p_ObjectCopy_DEEP, stopEvent} from './lib/util.js'
9898
import {toolbar_left_click, toolbar_left_addlink} from './lib/toolbar_left_click.js'
9999
import {toolbar_right_click} from './lib/toolbar_right_click.js'
100100
import {CONFIG} from './lib/config.js'
@@ -351,6 +351,9 @@
351351
}
352352
}
353353
if (item && item.kind === 'file') {
354+
// prevent filename being pasted parallel along
355+
// with the image pasting process
356+
stopEvent($e)
354357
var oFile = item.getAsFile();
355358
this.$refs.toolbar_left.$imgFilesAdd([oFile,]);
356359
}

0 commit comments

Comments
 (0)