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({
|
|
|
|
type: 'capturedImage',
|
|
|
|
content: [
|
|
|
|
{
|
|
|
|
type: 'figcaption',
|
|
|
|
content: [
|
|
|
|
{
|
|
|
|
type: 'text',
|
2023-11-14 15:10:00 +00:00
|
|
|
text: image.originalFilename ?? '',
|
|
|
|
},
|
|
|
|
],
|
2023-08-15 09:38:49 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'image',
|
|
|
|
attrs: {
|
2023-11-14 15:10:00 +00:00
|
|
|
src: image.url,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2023-08-15 09:38:49 +00:00
|
|
|
})
|
|
|
|
.run()
|
|
|
|
hideModal()
|
|
|
|
}
|