webapp/src/utils/renderUploadedImage.ts
Ilya Y f593d95358
Feature/paste image from buffer (#251)
Editor: Paste images from clipboard
2023-10-09 08:14:58 +03:00

33 lines
694 B
TypeScript

import { UploadedFile } from '../pages/types'
import { imageProxy } from './imageProxy'
import { hideModal } from '../stores/ui'
import { Editor } from '@tiptap/core'
export const renderUploadedImage = (editor: Editor, image: UploadedFile) => {
editor
.chain()
.focus()
.insertContent({
type: 'capturedImage',
content: [
{
type: 'figcaption',
content: [
{
type: 'text',
text: image.originalFilename ?? ''
}
]
},
{
type: 'image',
attrs: {
src: imageProxy(image.url)
}
}
]
})
.run()
hideModal()
}