table/tablecolumnresize/utils
@ckeditor/ckeditor5-table/src/tablecolumnresize/utils
Filtering
Functions
-
clamp( number, min, max ) → number
module:table/tablecolumnresize/utils~clamp
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>
module:table/tablecolumnresize/utils~createFilledArray
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>
module:table/tablecolumnresize/utils~getChangedResizedTables
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
module:table/tablecolumnresize/utils~getColumnEdgesIndexes
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
module:table/tablecolumnresize/utils~getColumnGroupElement
-
getColumnMinWidthAsPercentage( modelTable, editor ) → number
module:table/tablecolumnresize/utils~getColumnMinWidthAsPercentage
Calculates the percentage of the minimum column width given in pixels for a given table.
Parameters
Returns
number
The minimal column width in percentage.
-
getDomCellOuterWidth( domCell ) → number
module:table/tablecolumnresize/utils~getDomCellOuterWidth
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
module:table/tablecolumnresize/utils~getElementWidthInPixels
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>
module:table/tablecolumnresize/utils~getTableColumnElements
-
internal
getTableColumnsWidths( element ) → Array<string>
module:table/tablecolumnresize/utils~getTableColumnsWidths
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
module:table/tablecolumnresize/utils~getTableWidthInPixels
Calculates the table width in pixels.
Parameters
Returns
number
The width of the table in pixels.
-
normalizeColumnWidths( columnWidths ) → Array<string>
module:table/tablecolumnresize/utils~normalizeColumnWidths
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
module:table/tablecolumnresize/utils~sumArray
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
module:table/tablecolumnresize/utils~toPrecision
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>
module:table/tablecolumnresize/utils~translateColSpanAttribute
Translates the
colSpan
model attribute into additional column widths and returns the resulting array.Parameters
Returns
Array<string>
An array of table column widths.
-
updateColumnElements( columns, tableColumnGroup, normalizedWidths, writer ) → void
module:table/tablecolumnresize/utils~updateColumnElements
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.