feat: paste original elements by api
This commit is contained in:
@@ -157,10 +157,18 @@ export async function pasteByApi(host: CanvasEvent, options?: IPasteOption) {
|
|||||||
paste()
|
paste()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// 优先读取编辑器内部粘贴板数据
|
||||||
|
const clipboardText = await navigator.clipboard.readText()
|
||||||
|
const editorClipboardData = getClipboardData()
|
||||||
|
if (clipboardText === editorClipboardData?.text) {
|
||||||
|
pasteElement(host, editorClipboardData.elementList)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
removeClipboardData()
|
||||||
|
// 从内存粘贴板获取数据
|
||||||
if (options?.isPlainText) {
|
if (options?.isPlainText) {
|
||||||
const text = await navigator.clipboard.readText()
|
if (clipboardText) {
|
||||||
if (text) {
|
host.input(clipboardText)
|
||||||
host.input(text)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const clipboardData = await navigator.clipboard.read()
|
const clipboardData = await navigator.clipboard.read()
|
||||||
|
|||||||
Reference in New Issue
Block a user