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<T>

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

    Type parameters

    T

    Parameters

    length : number

    The length of the array.

    value : T

    The value to fill the array with.

    Returns

    Array<T>

    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.

  • internal

    getColumnGroupElement( element ) → Element

    Returns a 'tableColumnGroup' element from the 'table'.

    Parameters

    element : Element

    A 'table' or 'tableColumnGroup' element.

    Returns

    Element

    A 'tableColumnGroup' element.

  • 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.

  • internal

    getTableColumnElements( element ) → Array<Element>

    Returns an array of 'tableColumn' elements. It may be empty if there's no tableColumnGroup element.

    Parameters

    element : Element

    A 'table' or 'tableColumnGroup' element.

    Returns

    Array<Element>

    An array of 'tableColumn' elements.

  • internal

    getTableColumnsWidths( element ) → Array<string>

    Returns an array of table column widths.

    Parameters

    element : Element

    A 'table' or 'tableColumnGroup' element.

    Returns

    Array<string>

    An array of table column widths.

  • 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<string>

    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.

    Parameters

    columnWidths : Array<string>

    An array of column widths.

    Returns

    Array<string>

    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<string | 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 : string | number

    A number to be rounded.

    Returns

    number

    The rounded number.

  • internal

    translateColSpanAttribute( element, writer ) → Array<string>

    Translates the colSpan model attribute into additional column widths and returns the resulting array.

    Parameters

    element : Element

    A 'table' or 'tableColumnGroup' element.

    writer : Writer

    A writer instance.

    Returns

    Array<string>

    An array of table column widths.

  • updateColumnElements( columns, tableColumnGroup, normalizedWidths, writer ) → void

    Updates column elements to match columns widths.

    Parameters

    columns : Array<Element>
    tableColumnGroup : Element
    normalizedWidths : Array<string>
    writer : Writer

    Returns

    void