43 lines
682 B
JavaScript
43 lines
682 B
JavaScript
import { Node, mergeAttributes } from '@tiptap/core'
|
|
import { VueNodeViewRenderer } from '@tiptap/vue-2'
|
|
import Component from './Component.vue'
|
|
|
|
export default Node.create({
|
|
name: 'tableOfContents',
|
|
|
|
group: 'block',
|
|
|
|
atom: true,
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: 'toc',
|
|
},
|
|
]
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ['toc', mergeAttributes(HTMLAttributes)]
|
|
},
|
|
|
|
addNodeView() {
|
|
return VueNodeViewRenderer(Component)
|
|
},
|
|
|
|
addGlobalAttributes() {
|
|
return [
|
|
{
|
|
types: [
|
|
'heading',
|
|
],
|
|
attributes: {
|
|
id: {
|
|
default: null,
|
|
},
|
|
},
|
|
},
|
|
]
|
|
},
|
|
})
|