### Defining ChangeSet Class in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Tracks changes to a document from a specific starting point. It condenses step maps into a sequence of replacements and simplifies changes. It holds an array of Change objects representing the replaced regions and a reference to the starting document. ```TypeScript class ChangeSet { changes: readonly Change[]; startDoc: Node; } ``` -------------------------------- ### Defining Change Class in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Represents a replaced range in a document with associated metadata. It tracks the start and end positions in both the old and new documents and holds arrays of Span objects for deleted and inserted content. ```TypeScript class Change { fromA: number; toA: number; fromB: number; toB: number; deleted: readonly Span[]; inserted: readonly Span[]; } ``` -------------------------------- ### Merging Changesets in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md A static method on the Change class that combines two changesets into a single one. The end document of the first changeset must match the start document of the second. A combine function is used to merge metadata from overlapping spans. ```TypeScript static merge(x: readonly Change[], y: readonly Change[], combine: fn(dataA: Data, dataB: Data) → Data) → readonly Change[] ``` -------------------------------- ### Creating ChangeSet in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md A static method to create a new ChangeSet instance. It requires the base document and allows optional configuration for combining metadata (`combine`) and specifying a token encoder (`tokenEncoder`) for content comparison during simplification. ```TypeScript static create(doc: Node, combine?: fn(dataA: Data, dataB: Data) → Data = (a, b) => a === b ? a : null as any, tokenEncoder?: TokenEncoder = DefaultEncoder) → ChangeSet ``` -------------------------------- ### Simplifying Changes for Presentation in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Simplifies a given array of Change objects for better presentation. It aims to expand word-internal changes to cover entire words in the new document, unless the change is a single-character replacement. ```TypeScript simplifyChanges(changes: readonly Change[], doc: Node) → Change[] ``` -------------------------------- ### Comparing ChangeSets for Range in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Compares the current ChangeSet with another ChangeSet `b` and returns the range in the new document coordinates where they differ. If the document changed between the sets, the step maps for those changes should be provided as the second argument. ```TypeScript changedRange(b: ChangeSet, maps?: readonly StepMap[]) → {from: number, to: number} ``` -------------------------------- ### Adding Steps to ChangeSet in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Computes and returns a new ChangeSet by incorporating the given step maps and associated metadata into the current set. This method does not mutate the original ChangeSet. Note that incremental additions might yield different results than batch processing due to simplification logic. ```TypeScript addSteps(newDoc: Node, maps: readonly StepMap[], data: Data | readonly Data[]) → ChangeSet ``` -------------------------------- ### Mapping Span Data in ChangeSet in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Applies a provided function `f` to the data associated with each span within the changeset. It constructs and returns a new ChangeSet containing the results of this mapping operation. ```TypeScript map(f: fn(range: Span) → Data) → ChangeSet ``` -------------------------------- ### Defining Span Class in TypeScript Source: https://github.com/prosemirror/prosemirror-changeset/blob/master/README.md Represents a segment within a change (either deleted or inserted content) and stores metadata associated with that specific segment. It has properties for the length of the segment and the arbitrary data associated with it. ```TypeScript class Span { length: number; data: Data; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.