learnhouse/apps/web/components/Objects/Editor/Extensions/MathEquation/MathEquationBlock.ts
2024-02-09 21:22:15 +01:00

35 lines
662 B
TypeScript

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)
},
})