webapp/src/utils/renderUploadedImage.ts

33 lines
648 B
TypeScript
Raw Normal View History

import { Editor } from '@tiptap/core'
import { UploadedFile } from '../pages/types'
import { hideModal } from '../stores/ui'
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: image.url,
},
},
],
})
.run()
hideModal()
}