@umbraco-cms/backoffice
    Preparing search index...

    Class NodeSelection

    A node selection is a selection that points at a single node. All nodes marked selectable can be the target of a node selection. In such a selection, from and to point directly before and after the selected node, anchor equals from, and head equals to..

    Hierarchy

    • Selection
      • NodeSelection
    Index

    Constructors

    • Create a node selection. Does not verify the validity of its argument.

      Parameters

      • $pos: ResolvedPos

      Returns NodeSelection

    Properties

    $anchor: ResolvedPos

    The resolved anchor of the selection (the side that stays in place when the selection is modified).

    $head: ResolvedPos

    The resolved head of the selection (the side that moves when the selection is modified).

    The selected node.

    ranges: readonly SelectionRange[]

    The ranges covered by the selection.

    visible: boolean

    Controls whether, when a selection of this type is active in the browser, the selected range should be visible to the user. Defaults to true.

    Accessors

    • get $from(): ResolvedPos

      The resolved lower bound of the selection's main range.

      Returns ResolvedPos

    • get $to(): ResolvedPos

      The resolved upper bound of the selection's main range.

      Returns ResolvedPos

    • get anchor(): number

      The selection's anchor, as an unresolved position.

      Returns number

    • get empty(): boolean

      Indicates whether the selection contains any content.

      Returns boolean

    • get from(): number

      The lower bound of the selection's main range.

      Returns number

    • get head(): number

      The selection's head.

      Returns number

    • get to(): number

      The upper bound of the selection's main range.

      Returns number

    Methods

    • Get the content of this selection as a slice.

      Returns Slice

    • Test whether the selection is the same as another selection.

      Parameters

      • other: Selection

      Returns boolean

    • Get a bookmark for this selection, which is a value that can be mapped without having access to a current document, and later resolved to a real selection for a given document again. (This is used mostly by the history to track and restore old selections.) The default implementation of this method just converts the selection to a text selection and returns the bookmark for that.

      Returns NodeBookmark

    • Map this selection through a mappable thing. doc should be the new document to which we are mapping.

      Parameters

      Returns Selection

    • Replace the selection with a slice or, if no slice is given, delete the selection. Will append to the given transaction.

      Parameters

      • tr: Transaction
      • Optionalcontent: Slice

      Returns void

    • Replace the selection with the given node, appending the changes to the given transaction.

      Parameters

      Returns void

    • Convert the selection to a JSON representation. When implementing this for a custom selection class, make sure to give the object a type property whose value matches the ID under which you registered your class.

      Returns any

    • Find the cursor or leaf node selection closest to the end of the given document.

      Parameters

      Returns Selection

    • Find the cursor or leaf node selection closest to the start of the given document. Will return an AllSelection if no valid position exists.

      Parameters

      Returns Selection

    • Find a valid cursor or leaf node selection starting at the given position and searching back if dir is negative, and forward if positive. When textOnly is true, only consider cursor selections. Will return null when no valid selection position is found.

      Parameters

      • $pos: ResolvedPos
      • dir: number
      • OptionaltextOnly: boolean

      Returns null | Selection

    • Deserialize the JSON representation of a selection. Must be implemented for custom classes (as a static class method).

      Parameters

      Returns Selection

    • Determines whether the given node may be selected as a node selection.

      Parameters

      Returns boolean

    • To be able to deserialize selections from JSON, custom selection classes must register themselves with an ID string, so that they can be disambiguated. Try to pick something that's unlikely to clash with classes from other modules.

      Parameters

      • id: string
      • selectionClass: { fromJSON: (doc: ProseMirrorNode, json: any) => Selection }

      Returns { fromJSON: (doc: ProseMirrorNode, json: any) => Selection }

    • Find a valid cursor or leaf node selection near the given position. Searches forward first by default, but if bias is negative, it will search backwards first.

      Parameters

      • $pos: ResolvedPos
      • Optionalbias: number

      Returns Selection