ProsemirrorEx.Transform.Mark (prosemirror_ex v0.3.0)

Copy Markdown View Source

Helper functions for adding and removing marks via Transform steps.

Ports addMark, removeMark, and clearIncompatible from prosemirror-transform/src/mark.ts.

Summary

Functions

Add the given mark to inline content between from and to.

Removes all marks and nodes from the content of the node at pos that don't match the given new parent node type. Optionally accepts a starting content match and a flag for clearing newlines.

Remove marks from inline nodes between from and to.

Functions

add_mark(tr, from, to, mark)

Add the given mark to inline content between from and to.

Walks the document, collecting RemoveMarkStep entries for any marks that the new mark excludes, and AddMarkStep entries for ranges that need the mark. Adjacent ranges are coalesced into a single step.

clear_incompatible(tr, pos, parent_type, match \\ nil, clear_newlines \\ true)

Removes all marks and nodes from the content of the node at pos that don't match the given new parent node type. Optionally accepts a starting content match and a flag for clearing newlines.

remove_mark(tr, from, to, mark \\ nil)

Remove marks from inline nodes between from and to.

When mark is a Mark, remove precisely that mark. When it is a MarkType, remove all marks of that type. When it is nil, remove all marks.