Skip to content

Commit

Permalink
feat: paste original elements by api
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Jan 30, 2024
1 parent 565a220 commit 7ab103e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/editor/core/event/handlers/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,18 @@ export async function pasteByApi(host: CanvasEvent, options?: IPasteOption) {
paste()
return
}
// 优先读取编辑器内部粘贴板数据
const clipboardText = await navigator.clipboard.readText()
const editorClipboardData = getClipboardData()
if (clipboardText === editorClipboardData?.text) {
pasteElement(host, editorClipboardData.elementList)
return
}
removeClipboardData()
// 从内存粘贴板获取数据
if (options?.isPlainText) {
const text = await navigator.clipboard.readText()
if (text) {
host.input(text)
if (clipboardText) {
host.input(clipboardText)
}
} else {
const clipboardData = await navigator.clipboard.read()
Expand Down

0 comments on commit 7ab103e

Please sign in to comment.