feat: add pdf extension to editor

This commit is contained in:
swve 2023-02-19 19:28:38 +01:00
parent 429a95c50a
commit fdcee29a0d
7 changed files with 297 additions and 6 deletions

View file

@ -0,0 +1,35 @@
import { mergeAttributes, Node } from "@tiptap/core";
import { ReactNodeViewRenderer } from "@tiptap/react";
import PDFBlockComponent from "./PDFBlockComponent";
export default Node.create({
name: "blockPDF",
group: "block",
atom: true,
addAttributes() {
return {
fileObject: {
default: null,
},
};
},
parseHTML() {
return [
{
tag: "block-pdf",
},
];
},
renderHTML({ HTMLAttributes }) {
return ["block-pdf", mergeAttributes(HTMLAttributes), 0];
},
addNodeView() {
return ReactNodeViewRenderer(PDFBlockComponent);
},
});