nuxt-tiptap-editor
Version:
Essentials to Quickly Integrate TipTap Editor into your Nuxt App
29 lines (28 loc) • 807 B
JavaScript
import { Extension } from "@tiptap/core";
import { imageUploader, getFileCache } from "./imageUploader.js";
export const ImageUpload = Extension.create({
name: "imageUploadExtension",
addOptions() {
return {
id: () => Math.random().toString(36).substring(7),
acceptMimes: ["image/jpeg", "image/gif", "image/png", "image/jpg"],
upload: () => Promise.reject("Image Upload Extension Failed"),
ignoreDomains: []
};
},
addCommands() {
return {
uploadImage: (options) => ({ tr }) => {
tr.setMeta("uploadImages", options.file);
return true;
},
getFileCache: (key) => () => {
return getFileCache(key);
}
};
},
addProseMirrorPlugins() {
const options = this.options;
return [imageUploader(options)];
}
});