2023-11-14 15:10:00 +00:00
|
|
|
import { Editor } from '@tiptap/core'
|
|
|
|
|
2023-08-15 09:38:49 +00:00
|
|
|
import { UploadedFile } from '../pages/types'
|
|
|
|
import { hideModal } from '../stores/ui'
|
|
|
|
|
|
|
|
export const renderUploadedImage = (editor: Editor, image: UploadedFile) => {
|
|
|
|
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',
|
|
|
|
attrs: { src: image.url },
|
2023-08-15 09:38:49 +00:00
|
|
|
},
|
|
|
|
{
|
2024-01-16 09:13:23 +00:00
|
|
|
type: 'figcaption',
|
|
|
|
content: [{ type: 'text', text: image.originalFilename }],
|
2023-11-14 15:10:00 +00:00
|
|
|
},
|
|
|
|
],
|
2023-08-15 09:38:49 +00:00
|
|
|
})
|
|
|
|
.run()
|
|
|
|
hideModal()
|
|
|
|
}
|