import { Image, ImageUpload } from 'vue-echo-editor'
const extensions = [
BaseKit,
Image,
ImageUpload.configure({
// Return the public URL of the uploaded file
upload: async (file: File) => {
const body = new FormData()
body.append('file', file)
const res = await fetch('/api/upload', { method: 'POST', body })
const { url } = await res.json()
return url
},
acceptMimes: ['image/png', 'image/jpeg', 'image/webp', 'image/gif'],
maxSize: 5 * 1024 * 1024, // bytes
}),
]
Image renders resizable images with an image bubble menu (flip, size presets, alignment, remove). Images can also be pasted or dropped into the editor.
ImportWord imports .docx files. Provide a convert function (for example calling a server that uses mammoth) and an optional upload for embedded images:
import { ImportWord } from 'vue-echo-editor'
ImportWord.configure({
convert: async (file: File) => {
const body = new FormData()
body.append('file', file)
return (await fetch('/api/docx-to-html', { method: 'POST', body })).text()
},
limit: 10 * 1024 * 1024,
})