Module

table/utils

@ckeditor/ckeditor5-table/src/utils

module

Filtering

Functions

  • getColumnIndexes( tableCells ) → Object

    static

    Returns an object with the first and last column index contained in the given tableCells.

    const selectedTableCells = getSelectedTableCells( editor.model.document.selection );
    
    const { first, last } = getColumnIndexes( selectedTableCells );
    
    console.log( `Selected columns: ${ first } to ${ last }` );

    Parameters

    tableCells : Array.<Element>

    Returns

    Object

    Returns an object with the first and last table column indexes.

  • getRowIndexes( tableCells ) → Object

    static

    Returns an object with the first and last row index contained in the given tableCells.

    const selectedTableCells = getSelectedTableCells( editor.model.document.selection );
    
    const { first, last } = getRowIndexes( selectedTableCells );
    
    console.log( `Selected rows: ${ first } to ${ last }` );

    Parameters

    tableCells : Array.<Element>

    Returns

    Object

    Returns an object with the first and last table row indexes.

  • getSelectedTableCells( selection ) → Array.<Element>

    static

    Returns all model table cells that are fully selected (from the outside) within the provided model selection's ranges.

    To obtain the cells selected from the inside, use getTableCellsContainingSelection.

    Parameters

    selection : Selection

    Returns

    Array.<Element>
  • getSelectedTableWidget( selection ) → Element | null

    static

    Returns a table widget editing view element if one is selected.

    Parameters

    selection : Selection | DocumentSelection

    Returns

    Element | null
  • getSelectionAffectedTableCells( selection ) → Array.<Element>

    static

    Returns all model table cells that are either completely selected by selection ranges or host selection range start positions inside them.

    Combines getTableCellsContainingSelection and getSelectedTableCells.

    Parameters

    selection : Selection

    Returns

    Array.<Element>
  • getTableCellsContainingSelection( selection ) → Array.<Element>

    static

    Returns all model table cells that the provided model selection's ranges start inside.

    To obtain the cells selected from the outside, use getSelectedTableCells.

    Parameters

    selection : Selection

    Returns

    Array.<Element>
  • getTableWidgetAncestor( selection ) → Element | null

    static

    Returns a table widget editing view element if one is among the selection's ancestors.

    Parameters

    selection : Selection | DocumentSelection

    Returns

    Element | null
  • isTableWidget( viewElement ) → Boolean

    static

    Checks if a given view element is a table widget.

    Parameters

    viewElement : Element

    Returns

    Boolean
  • toTableWidget( viewElement, writer, label ) → Element

    static

    Converts a given Element to a table widget:

    • Adds a custom property allowing to recognize the table widget element.
    • Calls the toWidget function with the proper element's label creator.

    Parameters

    viewElement : Element
    writer : DowncastWriter

    An instance of the view writer.

    label : String

    The element's label. It will be concatenated with the table alt attribute if one is present.

    Returns

    Element