Compare commits
No commits in common. "111f303b2afbafe114bd7baba8d4e4f8d3e9bbd2" and "959978a2c7320f1283274063dffe9dc2f5f080da" have entirely different histories.
111f303b2a
...
959978a2c7
@ -236,8 +236,7 @@ const editor = useEditor({
|
|||||||
},
|
},
|
||||||
editorProps: {
|
editorProps: {
|
||||||
handlePaste: (view, event) => {
|
handlePaste: (view, event) => {
|
||||||
const clipboardData = event.clipboardData || event.originalEvent.clipboardData
|
const items = (event.clipboardData || event.originalEvent.clipboardData).items
|
||||||
const items = clipboardData.items
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item.type.indexOf('image') === 0) {
|
if (item.type.indexOf('image') === 0) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -262,7 +261,9 @@ const editor = useEditor({
|
|||||||
const pos = findImagePos(tempUrl)
|
const pos = findImagePos(tempUrl)
|
||||||
if (pos !== -1) {
|
if (pos !== -1) {
|
||||||
const { tr } = view.state
|
const { tr } = view.state
|
||||||
view.dispatch(tr.setNodeMarkup(pos, null, { src: data.ori_url }))
|
view.dispatch(
|
||||||
|
tr.setNodeMarkup(pos, null, { src: data.ori_url })
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
window['$message'].error(message || '图片上传失败')
|
window['$message'].error(message || '图片上传失败')
|
||||||
@ -278,20 +279,10 @@ const editor = useEditor({
|
|||||||
URL.revokeObjectURL(tempUrl)
|
URL.revokeObjectURL(tempUrl)
|
||||||
})
|
})
|
||||||
|
|
||||||
return true // Handled
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
// If no image was handled, check for text and paste as plain text.
|
|
||||||
const text = clipboardData.getData('text/plain')
|
|
||||||
if (text) {
|
|
||||||
event.preventDefault()
|
|
||||||
const { state, dispatch } = view
|
|
||||||
dispatch(state.tr.insertText(text))
|
|
||||||
return true // Handled
|
|
||||||
}
|
|
||||||
|
|
||||||
return false // Fallback for other cases
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -99,14 +99,10 @@ export default {
|
|||||||
this.onExit()
|
this.onExit()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if(!component?.props.items?.length){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return component.ref.onKeyDown(props)
|
return component.ref.onKeyDown(props)
|
||||||
},
|
},
|
||||||
|
|
||||||
onExit() {
|
onExit() {
|
||||||
console.log('component.element',component.element)
|
|
||||||
component.element.remove()
|
component.element.remove()
|
||||||
component.destroy()
|
component.destroy()
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user