Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forced, custom layouts with y-prosemirror
The following commit allows y-prosemirror to work with documents with forced, custom layouts. An example of this is a document with a required title, with the schema defined as `content: "title block+"`. Previously, it was assumed that an empty ProseMirror document is a single paragraph node, with content size of 2. As a result, when ProseMirror initializes an empty document with a custom layout (with content size > 2), the sync-plugin erroneously triggers a call to `binding._prosemirrorChanged` even though the initial content has not changed. To calculate the size of an empty ProseMirror document with *any* custom layout, we use `view.state.doc` to obtain the node describing the schema (layout) and call `createAndFill().content.size` (ProseMirror documentation [here](https://prosemirror.net/docs/ref/#model.NodeType.createAndFill)). We then use this constant instead of 2 in the comparison for `changedInitialContent`.
- Loading branch information