Hi! Currently, when I create an EditorView’s state, I use the ‘doc’ attribute, which automatically creates a schema. I was wondering how to extend that schema to add a mark? I tried ‘setProps’ after initially defining the view, and created a new state using the previous ‘doc’, as well as a new Schema object where I added to spec.marks using the 'doc’s schema.
Here’s the state for the initial view. It parses pre-existing markdown to generate a Node.
It doesn’t really create a schema, it just uses the schema that was used to create that document.
So if you want to extend the schema, you’ll have to do that with the original schema, before you create the document. To use that schema with the markdown parser, you’ll have to create a new instance of the MarkdownParser class, which usually involves adding extra parse rules to defaultMarkdownParser.tokens.
Ah, thank you for that clarification. I’ll look into extending via the markdown parser. So just to be clear, when the library guide says
When initializing a state, you can give it an initial document to use. In that case, the schema field is optional, since the schema can be taken from the document.
you really shouldn’t be using the schema field in conjunction with the doc field? Or are there cases where that’s possible and recommended? Thank you.