Release 0.7.0


0.7.0 is out now. This release’s changes mostly center around the new content expressions, a way to more precisely describe the kind of nodes that parent nodes may hold. You only need to worry about that if you’re defining your own schema.

Another area that has change incompatibly is the collaboration protocol, where a synchronization bug was discovered and had to be addressed.

You can find all new patches here.

Breaking changes

The following properties on node types have lost their meaning: kind, contains, canBeEmpty and containsMarks. The NodeKind type is also gone.

The information they used to encode is now put in a content expression, which is part of the schema spec, not the node. Such expressions can refer directly to other nodes in the schema (by name).

SchemaSpec is now an interface, not a class. Its nodes field refers to NodeSpec objects, rather than directly to NodeType constructors. These hold not only a constructor but also a content expression and optionally a group identifier.

The NodeType methods canContain, canContainFragment, canContainMark, canContainContent, and canContainType are gone, since they can’t accurately express the constraints of the new content expressions.

Instead, nodes now expose canReplace, canReplaceWith, and canAppend. The contentMatchAt method gets you a ContentMatch object which provides further ways to reason about content.

NodeType.findConnection is now at ContentMatch.findWrapping, and takes and returns attributes as well as node types.

Mark types lost their rank property, as their ordering is now determined by the order in which they appear in the schema spec.

Transform steps are now regular classes, AddMarkStep, RemoveMarkStep, ReplaceStep, and ReplaceAroundStep. Transform.step now only takes a step object, not separate values. The "join", "split", and "ancestor" step types have been superseded by ReplaceStep and ReplaceAroundStep.

The collaborative editing protocol was changed, to resolve a synchronization problem. See the guide for an overview of the new protocol.

New features

Node nesting is now expressed through a more powerful mechanism, content expressions.

The ContentMatch class provides a way to apply and reason about such content expressions.

The new OrderedMap class makes it possible to extend and modify the sets of nodes and marks in a schema while keeping control over their order.

Since splitting isn’t always possible any more, a new function canSplit is exported by the transform module.

The new options scrollTreshold and scrollMargin provide more control over scrolling behavior.

nodesBetween now passes the node’s index to its callback as fourth argument.

Node types gained a getter isLeaf to conveniently test whether they allow content.

Resolved positions got a new method indexAfter, and their methods that expect a depth allow the argument to be omitted to specify the position’s own depth, or a negative integer to be passed to specify a depth relative to the position’s depth.


Note: I forgot to publish to NPM before (don’t do releases late at night), but the NPM package is up now.