Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Slice

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 side are ‘open’ (cut through).

class Slice {
constructor(
content: Fragment,
openStart: number,
openEnd: number,
);
readonly content: Fragment;
readonly openEnd: number;
readonly openStart: number;
get size(): number;
 
eq(other: Slice): boolean;
toJSON(): any;
 
static empty: Slice;
 
static fromJSON(schema: Schema, json: any): Slice;
static maxOpen(fragment: Fragment, openIsolating?: boolean): Slice;
}

§Constructors

§
new Slice(content: Fragment, openStart: number, openEnd: number)
[src]

Create a slice. When specifying a non-zero open depth, you must make sure that there are nodes of at least that depth at the appropriate side of the fragment—i.e. if the fragment is an empty paragraph node, openStart and openEnd can't be greater than 1.

It is not necessary for the content of open nodes to conform to
the schema's content constraints, though it should be a valid
start/end/middle for such a node, depending on which sides are
open.

§Properties

§
content: Fragment
[src]

The slice's content.

§
openEnd: number
[src]

The open depth at the end.

§
openStart: number
[src]

The open depth at the start of the fragment.

§
size: number readonly
[src]

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

§Methods

§
eq(other: Slice): boolean
[src]

Tests whether this slice is equal to another slice.

§
toJSON(): any
[src]

Convert a slice to a JSON-serializable representation.

§Static Properties

§
empty: Slice
[src]

The empty slice.

§Static Methods

§
fromJSON(schema: Schema, json: any): Slice
[src]

Deserialize a slice from its JSON representation.

§
maxOpen(fragment: Fragment, openIsolating?: boolean): Slice
[src]

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