2023-11-14 15:10:00 +00:00
|
|
|
import { Editor } from '@tiptap/core'
|
|
|
|
|
2024-06-24 17:50:27 +00:00
|
|
|
export const renderUploadedImage = (editor: Editor, image: { url: string; originalFilename?: string }) => {
|
2023-08-15 09:38:49 +00:00
|
|
|
editor
|
|
|
|
.chain()
|
|
|
|
.focus()
|
|
|
|
.insertContent({
|
2024-01-16 09:13:23 +00:00
|
|
|
type: 'figure',
|
|
|
|
attrs: { 'data-type': 'image' },
|
2023-08-15 09:38:49 +00:00
|
|
|
content: [
|
|
|
|
{
|
2024-01-16 09:13:23 +00:00
|
|
|
type: 'image',
|
2024-06-26 08:22:05 +00:00
|
|
|
attrs: { src: image.url }
|
2023-08-15 09:38:49 +00:00
|
|
|
},
|
|
|
|
{
|
2024-01-16 09:13:23 +00:00
|
|
|
type: 'figcaption',
|
2024-06-26 08:22:05 +00:00
|
|
|
content: [{ type: 'text', text: image.originalFilename }]
|
|
|
|
}
|
|
|
|
]
|
2023-08-15 09:38:49 +00:00
|
|
|
})
|
|
|
|
.run()
|
|
|
|
}
|