mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-08-12 06:10:59 +00:00
@@ -162,32 +162,27 @@ export function createVditor(editorId, options = {}) {
|
|||||||
input,
|
input,
|
||||||
after
|
after
|
||||||
})
|
})
|
||||||
const pasteHandler = async (e) => {
|
const container = document.getElementById(editorId)
|
||||||
const items = e.clipboardData && e.clipboardData.items
|
if (container) {
|
||||||
if (!items) return
|
container.addEventListener('paste', async (e) => {
|
||||||
const files = []
|
const items = e.clipboardData && e.clipboardData.items
|
||||||
for (let i = 0; i < items.length; i++) {
|
if (!items) return
|
||||||
const item = items[i]
|
const files = []
|
||||||
if (item.kind === 'file') {
|
for (let i = 0; i < items.length; i++) {
|
||||||
const file = item.getAsFile()
|
const item = items[i]
|
||||||
if (file) files.push(file)
|
if (item.kind === 'file') {
|
||||||
|
const file = item.getAsFile()
|
||||||
|
if (file) files.push(file)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (files.length > 0) {
|
||||||
if (files.length > 0) {
|
e.preventDefault()
|
||||||
e.preventDefault()
|
const err = await vditor.options.upload.handler(files)
|
||||||
const err = await vditor.options.upload.handler(files)
|
if (typeof err === 'string') {
|
||||||
if (typeof err === 'string') {
|
vditor.tip(err)
|
||||||
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
|
return vditor
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user