ProsemirrorEx.Transform.StepMap (prosemirror_ex v0.3.0)

Copy Markdown View Source

A map describing the deletions and insertions made by a step, which can be used to find the correspondence between positions in the pre-step version of a document and the same position in the post-step version.

Ports StepMap from prosemirror-transform/src/map.ts.

Summary

Functions

A StepMap that contains no changed ranges.

Calls the given function on each of the changed ranges included in this map. The function receives (old_start, old_end, new_start, new_end). Returns a list of the results.

Create an inverted version of this map. The result can be used to map positions in the post-step document to the pre-step document.

Create a map that moves all positions by offset n (which may be negative).

Types

t()

@type t() :: %ProsemirrorEx.Transform.StepMap{
  inverted: boolean(),
  ranges: [non_neg_integer()]
}

Functions

empty()

A StepMap that contains no changed ranges.

for_each(step_map, f)

Calls the given function on each of the changed ranges included in this map. The function receives (old_start, old_end, new_start, new_end). Returns a list of the results.

invert(step_map)

Create an inverted version of this map. The result can be used to map positions in the post-step document to the pre-step document.

offset(n)

Create a map that moves all positions by offset n (which may be negative).