Add custom schema key on Node

Hi,

I wanted to add a custom schema key similar to isTextBlock or isLeaf on existing nodes. Please suggest if there is a way to implement this.

Put some property on the node spec objects you use to define the schema, and read node.type.spec.myProperty.

Thanks @marijn. I am actually using tiptap library for the editor and it seems like this isn’t working via tiptap. Any chance you know if this is restricted or a bug may be?

Just to be clear, this is what I tried.

const customBlock = Node.create({
  name: 'customBlock',
  group: 'block',
  content: 'block+',
  inline: false,
  isMeta: true,
  isContainer: true,
  spec: {
    isMeta: true,
    isContainer: true,
  },
  renderHTML({ HTMLAttributes }) {
    return ['div', HTMLAttributes, 0]
  },
});

I could be completely wrong because I don’t know this subject well, but maybe the code of tiptap for tables could give you some hints.

See the code at line 69 and line 267, where they extend the node schema with the tableRole field.

Thanks @massi. I’ll definitely try that out. :pray:t4: