如何在tiptap中制作节点可以在里面添加另一个节点

问题描述

代码有效但绝对无效(未创建节点)

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

代码引发错误

const PageNode = Node.create({
  name: 'PageNode',content: 'block+',inline: false,group: "block",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',})
...

error while need to place node

也许我丢失了重要参数?

我正在检查 TableCell 节点作为示例,工作正常,但我未能在我的代码中执行相同的功能

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)