fix(editor): image paste handling
This commit is contained in:
parent
c3e53970de
commit
f45303c2e3
@ -493,14 +493,20 @@ function setLink() {
|
||||
|
||||
onMounted(() => {
|
||||
internalMode.value = initialMode
|
||||
document.addEventListener('paste', handleImagePaste)
|
||||
nextTick(() => {
|
||||
const input = tiptapInstanceRef.value.querySelectorAll('.tiptap__editor')[0].children[0]
|
||||
input.addEventListener('paste', handleImagePaste)
|
||||
})
|
||||
if (editShortcut !== '') {
|
||||
document.addEventListener('keydown', setFocusToEditor)
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('paste', handleImagePaste)
|
||||
nextTick(() => {
|
||||
const input = tiptapInstanceRef.value.querySelectorAll('.tiptap__editor')[0].children[0]
|
||||
input.removeEventListener('paste', handleImagePaste)
|
||||
})
|
||||
if (editShortcut !== '') {
|
||||
document.removeEventListener('keydown', setFocusToEditor)
|
||||
}
|
||||
@ -510,11 +516,12 @@ function handleImagePaste(event) {
|
||||
if (event?.clipboardData?.items?.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
event.preventDefault()
|
||||
|
||||
const image = event.clipboardData.items[0]
|
||||
if (image.kind === 'file' && image.type.startsWith('image/')) {
|
||||
console.log('img', image.getAsFile())
|
||||
uploadAndInsertFiles([image.getAsFile()])
|
||||
}
|
||||
}
|
||||
|
@ -218,13 +218,19 @@ const actions = computed(() => {
|
||||
])))
|
||||
})
|
||||
|
||||
function attachmentUpload(
|
||||
file: File,
|
||||
onSuccess: (url: string) => void,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
onError: (error: string) => void,
|
||||
) {
|
||||
return uploadFile(props.taskId, file, onSuccess)
|
||||
async function attachmentUpload(files: File[] | FileList): (Promise<string[]>) {
|
||||
|
||||
const uploadPromises: Promise<string>[] = []
|
||||
|
||||
files.forEach((file: File) => {
|
||||
const promise = new Promise<string>((resolve) => {
|
||||
uploadFile(props.taskId, file, (uploadedFileUrl: string) => resolve(uploadedFileUrl))
|
||||
})
|
||||
|
||||
uploadPromises.push(promise)
|
||||
})
|
||||
|
||||
return await Promise.all(uploadPromises)
|
||||
}
|
||||
|
||||
const taskCommentService = shallowReactive(new TaskCommentService())
|
||||
@ -299,7 +305,7 @@ async function editComment() {
|
||||
if (commentEdit.comment === '') {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (changeTimeout.value !== null) {
|
||||
clearTimeout(changeTimeout.value)
|
||||
}
|
||||
@ -368,7 +374,7 @@ async function deleteComment(commentToDelete: ITaskComment) {
|
||||
}
|
||||
|
||||
.image.is-avatar {
|
||||
border-radius: 100%;
|
||||
border-radius: 100%;
|
||||
}
|
||||
|
||||
.media-content {
|
||||
|
Loading…
x
Reference in New Issue
Block a user