Skip to content

how do I extend existing heading/paragraphs specs/pluggings to add extra data (like userId) #169

Answered by kepta
rilopez asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like userId will be a part of the attrs. paragraph.spec() returns a plain object (see this) and you can modify that:

export const specRegistry = new SpecRegistry([
... other specs
 {...paragraph.spec(), 
  schema: {
      ...paragraph.spec().schema,
     attrs: { userId: {  default: '' } }
  },
 }
])

Read more about node attrs https://prosemirror.net/docs/ref/#model.AttributeSpec

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rilopez
Comment options

Answer selected by rilopez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants