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

Schema

A document schema. Holds node and mark type objects for the nodes and marks that may occur in conforming documents, and provides functionality for creating and deserializing such documents.

When given, the type parameters provide the names of the nodes and marks in this schema.

class Schema<Nodes extends string = any, Marks extends string = any> {
constructor(spec: SchemaSpec<Nodes, Marks>);
cached: {
[key: string]: any;
}
;
linebreakReplacement: NodeType | null;
marks: readonly [name in Marks]: MarkType & {
readonly [key: string]: MarkType;
}
;
nodes: readonly [name in Nodes]: NodeType & {
readonly [key: string]: NodeType;
}
;
spec: {
topNode?: string;
}
;
topNodeType: NodeType;
 
mark(type: string | MarkType, attrs?: Attrs | null): Mark;
markFromJSON(json: any): Mark;
node(
type: string | NodeType,
attrs?: Attrs | null,
content?: Fragment | Node | readonly Node[],
marks?: readonly Mark[],
): Node;
nodeFromJSON(json: any): Node;
text(text: string, marks?: readonly Mark[] | null): Node;
}

§Type Parameters

§
Nodes extends string = any
[src]
§
Marks extends string = any
[src]

§Constructors

§
new Schema(spec: SchemaSpec<Nodes, Marks>)
[src]

Construct a schema from a schema specification.

§Properties

§
cached: {
[key: string]: any;
}
[src]

An object for storing whatever values modules may want to compute and cache per schema. (If you want to store something in it, try to use property names unlikely to clash.)

§
linebreakReplacement: NodeType | null
[src]

The linebreak replacement node defined in this schema, if any.

§
marks: readonly [name in Marks]: MarkType & {
readonly [key: string]: MarkType;
}
[src]

A map from mark names to mark type objects.

§
nodes: readonly [name in Nodes]: NodeType & {
readonly [key: string]: NodeType;
}
[src]

An object mapping the schema's node names to node type objects.

§
spec: {
topNode?: string;
}
[src]

The spec on which the schema is based, with the added guarantee that its nodes and marks properties are OrderedMap instances (not raw objects).

§
topNodeType: NodeType
[src]

The type of the default top node for this schema.

§Methods

§
mark(type: string | MarkType, attrs?: Attrs | null): Mark
[src]

Create a mark with the given type and attributes.

§
markFromJSON(json: any): Mark
[src]

Deserialize a mark from its JSON representation. This method is bound.

§
node(type: string | NodeType, attrs?: Attrs | null, content?: Fragment | Node | readonly Node[], marks?: readonly Mark[]): Node
[src]

Create a node in this schema. The type may be a string or a NodeType instance. Attributes will be extended with defaults, content may be a Fragment, null, a Node, or an array of nodes.

§
nodeFromJSON(json: any): Node
[src]

Deserialize a node from its JSON representation. This method is bound.

§
text(text: string, marks?: readonly Mark[] | null): Node
[src]

Create a text node in the schema. Empty text nodes are not allowed.