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

Step

abstract

A step object represents an atomic change. It generally applies only to the document it was created for, since the positions stored in it will only make sense for that document.

New steps are defined by creating classes that extend Step, overriding the apply, invert, map, getMap and fromJSON methods, and registering your class with a unique JSON-serialization identifier using Step.jsonID.

abstract class Step {
abstract apply(doc: Node): StepResult;
getMap(): StepMap;
abstract invert(doc: Node): Step;
abstract map(mapping: Mappable): Step | null;
merge(other: Step): Step | null;
abstract toJSON(): any;
 
static fromJSON(schema: Schema, json: any): Step;
static jsonID(id: string, stepClass: {
fromJSON(schema: Schema, json: any): Step;
}
): {
fromJSON(schema: Schema, json: any): Step;
}
;
}

§Methods

§
apply(doc: Node): StepResult abstract
[src]

Applies this step to the given document, returning a result object that either indicates failure, if the step can not be applied to this document, or indicates success by containing a transformed document.

§
getMap(): StepMap
[src]

Get the step map that represents the changes made by this step, and which can be used to transform between positions in the old and the new document.

§
invert(doc: Node): Step abstract
[src]

Create an inverted version of this step. Needs the document as it was before the step as argument.

§
map(mapping: Mappable): Step | null abstract
[src]

Map this step through a mappable thing, returning either a version of that step with its positions adjusted, or null if the step was entirely deleted by the mapping.

§
merge(other: Step): Step | null
[src]

Try to merge this step with another one, to be applied directly after it. Returns the merged step when possible, null if the steps can't be merged.

§
toJSON(): any abstract
[src]

Create a JSON-serializeable representation of this step. When defining this for a custom subclass, make sure the result object includes the step type's JSON id under the stepType property.

§Static Methods

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

Deserialize a step from its JSON representation. Will call through to the step class' own implementation of this method.

§
jsonID(id: string, stepClass: {
fromJSON(schema: Schema, json: any): Step;
}
): {
fromJSON(schema: Schema, json: any): Step;
}
[src]

To be able to serialize steps to JSON, each step needs a string ID to attach to its JSON representation. Use this method to register an ID for your step classes. Try to pick something that's unlikely to clash with steps from other modules.