ProsemirrorEx.Model.Slice (prosemirror_ex v0.3.0)

Copy Markdown View Source

A slice represents a piece cut out of a larger document. It stores not only a fragment, but also the depth up to which nodes on both sides are 'open' (cut through).

Ported from ProseMirror's replace.ts Slice class.

Summary

Functions

The empty slice.

Test whether this slice is equal to another slice.

Deserialize a slice from its JSON representation.

Insert a fragment at the given position in this slice.

Create a slice from a fragment by taking the maximum possible open value on both sides of the fragment.

Remove content between the given positions in this slice.

The size this slice would add when inserted into a document.

Convert a slice to a JSON-serializable representation.

String representation of this slice.

Types

t()

@type t() :: %ProsemirrorEx.Model.Slice{
  content: term(),
  open_end: term(),
  open_start: term()
}

Functions

empty()

The empty slice.

eq(a, b)

Test whether this slice is equal to another slice.

from_json(schema, json)

Deserialize a slice from its JSON representation.

insert_at(slice, pos, fragment)

Insert a fragment at the given position in this slice.

max_open(fragment, open_isolating \\ true)

Create a slice from a fragment by taking the maximum possible open value on both sides of the fragment.

new(content, open_start, open_end)

Create a new slice.

remove_between(slice, from, to)

Remove content between the given positions in this slice.

size(slice)

The size this slice would add when inserted into a document.

to_json(slice)

Convert a slice to a JSON-serializable representation.

to_string(slice)

String representation of this slice.