Merge pull request #13169 from overleaf/dk-dropimg-handler

[cm6] added drop handler to rich text

GitOrigin-RevId: 9972b788d680645ee83c3bc9376b9446a2b068e9
This commit is contained in:
Tim Down 2023-05-25 11:04:17 +01:00 committed by Copybot
parent 80a5f4594e
commit 1336ff8196

View file

@ -179,6 +179,24 @@ export const figureModalPasteHandler = (): Extension => {
return []
}
return EditorView.domEventHandlers({
drop: evt => {
if (!evt.dataTransfer || evt.dataTransfer.files.length === 0) {
return
}
const file = evt.dataTransfer.files[0]
if (!ALLOWED_MIME_TYPES.has(file.type)) {
return
}
window.dispatchEvent(
new CustomEvent<PastedImageData>('figure-modal:paste-image', {
detail: {
name: file.name,
type: file.type,
data: file,
},
})
)
},
paste: evt => {
if (!evt.clipboardData || evt.clipboardData.files.length === 0) {
return