Trilium Frontend API
    Preparing search index...

    Interface RangeComponent

    interface RangeComponent {
        setBounds: (topLeft: CellComponent, bottomRight: CellComponent) => void;
        setEndBound: (cell: CellComponent) => void;
        setStartBound: (cell: CellComponent) => void;
        clearValues(): void;
        getBottomEdge(): number;
        getBounds(): { end: CellComponent; start: CellComponent };
        getCells(): CellComponent[];
        getColumns(): ColumnComponent[];
        getData(): unknown;
        getElement(): unknown;
        getLeftEdge(): number;
        getRightEdge(): number;
        getRows(): RowComponent[];
        getStructuredCells(): CellComponent[][];
        getTopEdge(): number;
        remove(): void;
    }
    Index

    Properties

    setBounds: (topLeft: CellComponent, bottomRight: CellComponent) => void

    You can update the bounds for an existing range using the setBounds function, passing in the Cell Components for the top-left and bottom-right bounds of the selection:

    var topLeft = table.getRows()[2].getCells()[1];
    var bottomRight = table.getRows()[5].getCells()[6];

    range.setBounds(topLeft, bottomRight);
    setEndBound: (cell: CellComponent) => void

    You can change the bottom right ending edge of an existing range using the setEndBound function, passing in the Cell Component for the bottom right bound of the selection:

    var bottomRight = table.getRows()[5].getCells()[6];

    range.setEndBound(bottomRight);
    setStartBound: (cell: CellComponent) => void

    You can change the top left start edge of an existing range using the setStartBound function, passing in the Cell Component for the top left bound of the selection:

    var topLeft = table.getRows()[2].getCells()[1];

    range.setStartBound(topLeft);

    Methods

    • You can clear the value of every cell in a range by calling the clearValues function on the range:

      var data = range.clearValues();
      

      This will set the value of every cell in the range to the value of the selectableRangeClearCellsValue table option, which is set to undefined by default.

      Returns void

    • You can find the position number for the bottom row of the range by calling the getBottomEdge function on the range:

      Returns number

      var bottomPosition = range.getBottomEdge();
      
    • You can retrieve the bounds of a range by calling the getBounds function on the range:

      var bounds = range.getBounds();
      

      This will return an object containing two Cell Components, for the two bounds of the range

      {
      start:Component, //the cell component at the top left of the range
      end:Component, //the cell component at the bottom right of the range
      }

      Returns { end: CellComponent; start: CellComponent }

    • You can retrieve all the Cell Components in a range by calling the getCells function on the range:

      var cells = range.getCells();
      

      This will return a array of Cell Components

      Returns CellComponent[]

    • You can retrieve all the Column Components in a range by calling the getColumns function on the range:

      var columns = range.getColumns();
      

      This will return a array of Column Components

      Returns ColumnComponent[]

    • You can retrieve the cell data for a range by calling the getData function on the range:

      var data = range.getData();
      

      This will return a range data array, which is structured as a series of row data objects with only the props for cells in that range:

      [
      {color:"green", country:"England", driver:true}, //data for selected cells in first row in range
      {color:"red", country:"USA", driver:false}, //data for selected cells in second row in range
      {color:"blue", country:"France", driver:true}, //data for selected cells in third row in range
      ]

      Returns unknown

    • You can retrieve the bounding rectangle element for a range by calling the getElement function on the range:

      Returns unknown

      var element = range.getElement();
      
    • You can find the position number for the left column of the range by calling the getLeftEdge function on the range:

      Returns number

      var leftPosition = range.getLeftEdge();
      
    • You can find the position number for the right column of the range by calling the getRightEdge function on the range:

      Returns number

      var rightPosition = range.getRightEdge();
      
    • You can retrieve all the Row Components in a range by calling the getRows function on the range:

      var rows = range.getRows();
      

      This will return a array of Row Components

      Returns RowComponent[]

    • You can retrieve a structured map of all the Cell Components in a range by calling the getStructuredCells function on the range:

      var cells = range.getStructuredCells();
      

      This will return a array of row arrays, with each row array containing the Cell Components in order for that row:

      [
      [Component, Component, Component], //first row
      [Component, Component, Component], //second row
      [Component, Component, Component], //third row
      ]

      Returns CellComponent[][]

    • You can find the position number for the top row of the range by calling the getTopEdge function on the range:

      Returns number

      var topPosition = range.getTopEdge();
      
    • You can remove a range by calling the remove function on the range:

      Returns void

      range.remove();