From ebc39a6388b25af8475306647c46f1111a43d045 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 1 Aug 2025 02:12:22 +0800 Subject: [PATCH] Revert "Fix paste upload handler" This reverts commit 97118e7bc822176db700dde6e8c5cac00a51eb6c. --- open-isle-cli/src/utils/vditor.js | 43 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/open-isle-cli/src/utils/vditor.js b/open-isle-cli/src/utils/vditor.js index b017034f3..68b1a5bfe 100644 --- a/open-isle-cli/src/utils/vditor.js +++ b/open-isle-cli/src/utils/vditor.js @@ -162,32 +162,27 @@ export function createVditor(editorId, options = {}) { input, after }) - const pasteHandler = async (e) => { - const items = e.clipboardData && e.clipboardData.items - if (!items) return - const files = [] - for (let i = 0; i < items.length; i++) { - const item = items[i] - if (item.kind === 'file') { - const file = item.getAsFile() - if (file) files.push(file) + const container = document.getElementById(editorId) + if (container) { + container.addEventListener('paste', async (e) => { + const items = e.clipboardData && e.clipboardData.items + if (!items) return + const files = [] + for (let i = 0; i < items.length; i++) { + const item = items[i] + if (item.kind === 'file') { + const file = item.getAsFile() + if (file) files.push(file) + } } - } - if (files.length > 0) { - e.preventDefault() - const err = await vditor.options.upload.handler(files) - if (typeof err === 'string') { - vditor.tip(err) + if (files.length > 0) { + e.preventDefault() + const err = await vditor.options.upload.handler(files) + if (typeof err === 'string') { + vditor.tip(err) + } } - } + }) } - - const elements = [] - if (vditor.wysiwyg) elements.push(vditor.wysiwyg.element) - if (vditor.ir) elements.push(vditor.ir.element) - if (vditor.sv) elements.push(vditor.sv.element) - elements.forEach(el => { - el.addEventListener('paste', pasteHandler) - }) return vditor }