Trilium Frontend API
    Preparing search index...

    Class ChangeDesc

    A change description is a variant of change set that doesn't store the inserted text. As such, it can't be applied, but is cheaper to store and manipulate.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get empty(): boolean

      False when there are actual changes in this set.

      Returns boolean

    • get invertedDesc(): ChangeDesc

      Get a description of the inverted form of these changes.

      Returns ChangeDesc

    • get length(): number

      The length of the document before the change.

      Returns number

    • get newLength(): number

      The length of the document after the change.

      Returns number

    Methods

    • Compute the combined effect of applying another set of changes after this one. The length of the document after this set should match the length before other.

      Parameters

      Returns ChangeDesc

    • Iterate over the ranges changed by these changes. (See ChangeSet.iterChanges for a variant that also provides you with the inserted text.) fromA/toA provides the extent of the change in the starting document, fromB/toB the extent of the replacement in the changed document.

      When individual is true, adjacent changes (which are kept separate for position mapping) are reported separately.

      Parameters

      • f: (fromA: number, toA: number, fromB: number, toB: number) => void
      • Optionalindividual: boolean

      Returns void

    • Iterate over the unchanged parts left by these changes. posA provides the position of the range in the old document, posB the new position in the changed document.

      Parameters

      • f: (posA: number, posB: number, length: number) => void

      Returns void

    • Map this description, which should start with the same document as other, over another set of changes, so that it can be applied after it. When before is true, map as if the changes in this happened before the ones in other.

      Parameters

      Returns ChangeDesc

    • mode determines whether deletions should be reported. It defaults to MapMode.Simple (don't report deletions).

      Parameters

      • pos: number
      • Optionalassoc: number

      Returns number

    • mode determines whether deletions should be reported. It defaults to MapMode.Simple (don't report deletions).

      Parameters

      • pos: number
      • assoc: number
      • mode: MapMode

      Returns number

    • Serialize this change desc to a JSON-representable value.

      Returns readonly number[]

    • Check whether these changes touch a given range. When one of the changes entirely covers the range, the string "cover" is returned.

      Parameters

      • from: number
      • Optionalto: number

      Returns boolean | "cover"

    • Create a change desc from its JSON representation (as produced by toJSON.

      Parameters

      • json: any

      Returns ChangeDesc