|
@@ -1,4 +1,4 @@
|
|
|
-import { insertTagToEditor } from "./utils";
|
|
|
+import { checkValidImage, insertTagToEditor } from "./utils";
|
|
|
// import { randomCode } from "../../utils/utils";
|
|
|
|
|
|
let _this = null;
|
|
@@ -210,6 +210,11 @@ async function pasteImage(file, attributes) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (!checkValidImage(file.type)) {
|
|
|
+ _this.$message("只支持png、jpg、jpeg格式图片!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 默认转base64;
|
|
|
const srcBase64 = await fileToBase64(file);
|
|
|
insertTagToEditor(null, "IMG", srcBase64, attributes);
|
|
@@ -251,10 +256,9 @@ export async function pasteHandle(event) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const fileItems = filterItem(
|
|
|
- clipboard.items,
|
|
|
- (item) => item.kind == "file" && item.type.match("^image/")
|
|
|
- );
|
|
|
+ const fileItems = filterItem(clipboard.items, (item) => {
|
|
|
+ return item.kind == "file" && checkValidImage(item.type);
|
|
|
+ });
|
|
|
if (fileItems.length) {
|
|
|
console.log("... paste: file ");
|
|
|
for (let index = 0; index < fileItems.length; index++) {
|