mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
fix: 截图粘贴出现两张图的情况
This commit is contained in:
parent
5e8a6af74c
commit
ce7d3f8475
@ -214,8 +214,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from "vuex";
|
import {mapState} from "vuex";
|
||||||
import Quill from 'quill-hitosea';
|
import Quill from 'quill-hi';
|
||||||
import "quill-mention-hitosea";
|
import "quill-mention-hi";
|
||||||
import ChatEmoji from "./emoji";
|
import ChatEmoji from "./emoji";
|
||||||
import touchmouse from "../../../../directives/touchmouse";
|
import touchmouse from "../../../../directives/touchmouse";
|
||||||
import touchclick from "../../../../directives/touchclick";
|
import touchclick from "../../../../directives/touchclick";
|
||||||
@ -1651,47 +1651,9 @@ export default {
|
|||||||
if (postFiles.length > 0) {
|
if (postFiles.length > 0) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.$emit('on-file', files)
|
this.$emit('on-file', files)
|
||||||
} else if (this.pasteRtf(e)) {
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pasteRtf(e) {
|
|
||||||
if (e && e.clipboardData && e.clipboardData.items) {
|
|
||||||
const imgHtml = (new DOMParser).parseFromString(e.clipboardData.getData("text/html") || "", "text/html").querySelector("img");
|
|
||||||
if (!imgHtml) {
|
|
||||||
const array = [];
|
|
||||||
let image = null;
|
|
||||||
if (e.clipboardData.types && -1 != [].indexOf.call(e.clipboardData.types, "text/rtf") || e.clipboardData.getData("text/rtf")) {
|
|
||||||
image = e.clipboardData.items[0].getAsFile();
|
|
||||||
if (image) {
|
|
||||||
array.push(image)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let s = 0; s < e.clipboardData.items.length; s++) {
|
|
||||||
image = e.clipboardData.items[s].getAsFile()
|
|
||||||
if (image) {
|
|
||||||
array.push(image)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (array.length > 0) {
|
|
||||||
array.forEach(image => {
|
|
||||||
const t = new FileReader;
|
|
||||||
t.onload = ({target}) => {
|
|
||||||
const {index} = this.quill.getSelection(true);
|
|
||||||
this.quill.insertEmbed(index, "image", target.result);
|
|
||||||
this.quill.setSelection(index + 1)
|
|
||||||
};
|
|
||||||
t.readAsDataURL(image)
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
|
|
||||||
filterInvalidLine(content) {
|
filterInvalidLine(content) {
|
||||||
let value = (content + '').replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '')
|
let value = (content + '').replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '')
|
||||||
return value.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '')
|
return value.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user