Module

table/tablecolumnresize/utils

@ckeditor/ckeditor5-table/src/tablecolumnresize/utils

module

Filtering

Functions

  • clamp( number, min, max ) → Number

    Clamps the number within the inclusive lower (min) and upper (max) bounds. Returned number is rounded using the toPrecision() function.

    Parameters

    number : Number

    A number to be clamped.

    min : Number

    A lower bound.

    max : Number

    An upper bound.

    Returns

    Number

    The clamped number.

  • createFilledArray( length, value ) → Array.<*>

    Creates an array with defined length and fills all elements with defined value.

    Parameters

    length : Number

    The length of the array.

    value : *

    The value to fill the array with.

    Returns

    Array.<*>

    An array with defined length and filled with defined value.

  • getChangedResizedTables( model ) → Set.<Element>

    Returns all the inserted or changed table model elements in a given change set. Only the tables with 'columnsWidth' attribute are taken into account. The returned set may be empty.

    Most notably if an entire table is removed it will not be included in returned set.

    Parameters

    model : Model

    The model to collect the affected elements from.

    Returns

    Set.<Element>

    A set of table model elements.

  • getColumnEdgesIndexes( cell, tableUtils ) → Object

    Returns the column indexes on the left and right edges of a cell. They differ if the cell spans across multiple columns.

    Parameters

    cell : Element

    A table cell model element.

    tableUtils : TableUtils

    The Table Utils plugin instance.

    Returns

    Object

    An object containing the indexes of the left and right edges of the cell.

    Number

    return.leftEdge The index of the left edge of the cell.

    Number

    return.rightEdge The index of the right edge of the cell.

  • getColumnMinWidthAsPercentage( modelTable, editor ) → Number

    Calculates the percentage of the minimum column width given in pixels for a given table.

    Parameters

    modelTable : Element

    A table model element.

    editor : Editor

    The editor instance.

    Returns

    Number

    The minimal column width in percentage.

  • getDomCellOuterWidth( domCell ) → Number

    Calculates the total horizontal space taken by the cell. That includes:

    • width,
    • left and red padding,
    • border width.

    Parameters

    domCell : HTMLElement

    A DOM cell element.

    Returns

    Number

    Width in pixels without px at the end.

  • getElementWidthInPixels( domElement ) → Number

    Returns the computed width (in pixels) of the DOM element without padding and borders.

    Parameters

    domElement : HTMLElement

    A DOM element.

    Returns

    Number

    The width of the DOM element in pixels.

  • getTableWidthInPixels( modelTable, editor ) → Number

    Calculates the table width in pixels.

    Parameters

    modelTable : Element

    A table model element.

    editor : Editor

    The editor instance.

    Returns

    Number

    The width of the table in pixels.

  • normalizeColumnWidths( columnWidths ) → Array.<Number>

    Makes sure that the sum of the widths from all columns is 100%. If the sum of all the widths is not equal 100%, all the widths are changed proportionally so that they all sum back to 100%. If there are columns without specified width, the amount remaining after assigning the known widths will be distributed equally between them.

    Currently, only widths provided as percentage values are supported.

    Parameters

    columnWidths : Array.<Number>

    An array of column widths.

    Returns

    Array.<Number>

    An array of column widths guaranteed to sum up to 100%.

  • sumArray( array ) → Number

    Sums all array values that can be parsed to a float.

    Parameters

    array : Array.<Number>

    An array of numbers.

    Returns

    Number

    The sum of all array values.

  • toPrecision( value ) → Number

    Rounds the provided value to a fixed-point number with defined number of digits after the decimal point.

    Parameters

    value : Number | String

    A number to be rounded.

    Returns

    Number

    The rounded number.