feat: add math extension to editor

This commit is contained in:
swve 2023-02-05 14:26:29 +01:00
parent 1d0ce89aa3
commit 5dacaa4871
7 changed files with 255 additions and 1 deletions

View file

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