23 lines
509 B
TypeScript
23 lines
509 B
TypeScript
import { Editor } from '@tiptap/core'
|
|
|
|
export const renderUploadedImage = (editor: Editor, image: { url: string; originalFilename?: string }) => {
|
|
editor
|
|
.chain()
|
|
.focus()
|
|
.insertContent({
|
|
type: 'figure',
|
|
attrs: { 'data-type': 'image' },
|
|
content: [
|
|
{
|
|
type: 'image',
|
|
attrs: { src: image.url }
|
|
},
|
|
{
|
|
type: 'figcaption',
|
|
content: [{ type: 'text', text: image.originalFilename }]
|
|
}
|
|
]
|
|
})
|
|
.run()
|
|
}
|