mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
37 lines
653 B
TypeScript
37 lines
653 B
TypeScript
import { mergeAttributes, Node } from '@tiptap/core'
|
|
import { ReactNodeViewRenderer } from '@tiptap/react'
|
|
|
|
import QuizBlockComponent from './QuizBlockComponent'
|
|
|
|
export default Node.create({
|
|
name: 'blockQuiz',
|
|
group: 'block',
|
|
atom: true,
|
|
|
|
addAttributes() {
|
|
return {
|
|
quizId: {
|
|
value: null,
|
|
},
|
|
questions: {
|
|
default: [],
|
|
},
|
|
}
|
|
},
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: 'block-quiz',
|
|
},
|
|
]
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ['block-quiz', mergeAttributes(HTMLAttributes), 0]
|
|
},
|
|
|
|
addNodeView() {
|
|
return ReactNodeViewRenderer(QuizBlockComponent)
|
|
},
|
|
})
|