Class: SelectionCalculations

SelectionCalculations

Class responsible for all of the Selection-related operations on merged cells.

Members

fullySelectedMergedCellClassNameString

Class name used for fully selected merged cells.

pluginMergeCells

Reference to the Merge Cells plugin.

Methods

getSelectedMergedCellClassName(currentRow, currentColumn, cornersOfSelection, layerLevel){String|undefined}

Generate an additional class name for the entirely-selected merged cells.

Parameters:
Name Type Description
currentRow Number

Row index of the currently processed cell.

currentColumn Number

Column index of the currently cell.

cornersOfSelection Array

Array of the current selection in a form of [startRow, startColumn, endRow, endColumn].

layerLevel Number | undefined

Number indicating which layer of selection is currently processed.

Returns: {String|undefined} A String, which will act as an additional className to be added to the currently processed cell.

getSelectedMergedCellClassNameToRemove(){Array.<String>}

Generate an array of the entirely-selected merged cells' class names.

Returns: {Array.<String>} An Array of Strings. Each of these strings will act like class names to be removed from all the cells in the table.

getUpdatedSelectionRange(oldSelectionRange, delta){CellRange}

Get a selection range with to property incremented by the provided delta.

Parameters:
Name Type Description
oldSelectionRange CellRange

The base selection range.

delta Object

The delta object with row and col properties.

Returns: {CellRange} A new CellRange object.

isMergeCellFullySelected(mergedCell, selectionRangesArray){Boolean}

Check if the provided merged cell is fully selected (by one or many layers of selection)

Parameters:
Name Type Description
mergedCell MergedCellCoords

The merged cell to be processed.

selectionRangesArray Array.<CellRange>

Array of selection ranges.

Returns: {Boolean}

snapDelta(delta, selectionRange, mergedCell)

"Snap" the delta value according to defined merged cells. (In other words, compensate the rowspan -
e.g. going up with delta.row = -1 over a merged cell with rowspan = 3, delta.row should change to -3.)

Parameters:
Name Type Description
delta Object

The delta object containing row and col properties.

selectionRange CellRange

The selection range.

mergedCell Object

A merged cell object.