Different document block than doc

Hi

I believe it is answered somewhere, but I just simply got confused. Saw also few of you picking similar area (for instance in questions about lockable nodes).

I want to set heading as top node type. Is such notation valid for this: ?

const defaultSpec = new SchemaSpec({
  doc: Heading,
  heading: Heading,
  text: Text,
  image: Image
}, {
  em: EmMark,
  strong: StrongMark,
  link: LinkMark
})

if so, is it ok that when I put there document where root element type is heading it throws me an error that I try to use different schema than defined?

Reason why I wanted to keep it heading rather than doc is that while rendering content later on backend I want to be sure that proper dom node is applied.

Any good practice here?

You can’t set your doc node type to be a heading, for any sane definition of a heading, because that is the node that should contain all of your document. You’ll usually want a dedicated node type for this.

The error you mention sounds like you are giving the editor a document with a different schema than the one you’re passing as the schema option.

Got it. Imagine then I would have to keep multiple instances of PM on site. Some of them for editing blocks that contains only inline elements (like headings). How would you suggest to approach this?

Create different schemas for your different editor roles and pass the right schema option to each of your editors.

Thank you. I know it may sound dummy question, but do you have (could you add to doc or point if exists) example of Schema that won’t allow new paragraphs? When I tried to achieve that I have ran to issues so far. Reference would be most useful.

You could create a schema where the top node is a textblock. That hasn’t been tested yet, and it’s possible that it’ll expose bugs, but that would be the way to do this.

Unfortunately, there’s no guide docs for working with schemas yet, so the API reference is all you have.

Yes I had problem (I think we discussed it elsewhere) that each schema expect both doc to be defined and be root of the document. I worked it around using this Header as doc, but that turned to be as well buggy solution. Thanks anyhow.

Feel free to report the bugs that came up on the issue tracker.