This code works but absolutely no effect (node not created)
const PageNode = Node.create({
name: 'PageNode',
// content: 'block+',
content: 'inline*',
marks: '_',
inline: true,
group: "inline",
draggable: true,
code: true,
isolating: true,
defining: true,
// draggable: true
defaultOptions: {
HTMLAttributes: {
class: 'page pagebreak',
},
},
This code throws an error
const PageNode = Node.create({
name: 'PageNode',
// content: 'block+',
content: 'block+',
marks: '_',
inline: false,
group: "block",
draggable: true,
code: true,
isolating: true,
defining: true,
// draggable: true
defaultOptions: {
HTMLAttributes: {
class: 'page pagebreak',
},
},
addAttributes() {
// Return an object with attribute configuration
return {
class: {
default: 'page pagebreak',
},
}
},
parseHTML() {
return [
{
tag: 'div',
preserveWhitespace: 'full',
},
]
},
renderHTML({ HTMLAttributes }) {
return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
},
addCommands() {
return {
setPage: attributes => ({ commands }) => {
return commands.setNode('PageNode', attributes)
},
togglePage: attributes => ({ commands }) => {
return commands.toggleNode('PageNode', 'PageNode', attributes)
},
}
},
})
...
error while need to place node
<button @click="editor.chain().focus().togglePage().run()" :class="{ 'is-active': editor.isActive('PageNode') }">
toggle page
</button>
Maybe I lost important parameter?
I was check TableCell node as example, works fine, but I failed to perform the same functionality in my code