ProsemirrorEx.Transform.Replace (prosemirror_ex v0.3.0)

Copy Markdown View Source

Fitter algorithm and replace helpers for fitting slices into document gaps.

Ports replace.ts from prosemirror-transform/src/replace.ts.

Summary

Functions

Smart delete that expands to cover parent nodes when appropriate.

Find a position at or around the given position where a node of the given type can be inserted. Returns nil when no position was found.

WYSIWYG-aware replace. Expands/contracts the range for best structural fit.

WYSIWYG-aware single-node replacement.

'Fit' a slice into a given position in the document, producing a step that inserts it. Will return nil if there's no meaningful way to insert the slice here, or inserting it would be a no-op.

Functions

delete_range(tr, from, to)

Smart delete that expands to cover parent nodes when appropriate.

insert_point(doc, pos, node_type)

Find a position at or around the given position where a node of the given type can be inserted. Returns nil when no position was found.

replace_range(tr, from, to, slice)

WYSIWYG-aware replace. Expands/contracts the range for best structural fit.

replace_range_with(tr, from, to, node)

WYSIWYG-aware single-node replacement.

replace_step(doc, from, to \\ nil, slice \\ nil)

'Fit' a slice into a given position in the document, producing a step that inserts it. Will return nil if there's no meaningful way to insert the slice here, or inserting it would be a no-op.