table/utils
@ckeditor/ckeditor5-table/src/utils
Filtering
Functions
-
getColumnIndexes( tableCells ) → Object
static
Returns an object with the
first
andlast
column index contained in the giventableCells
.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
andlast
table column indexes.
-
getRowIndexes( tableCells ) → Object
static
Returns an object with the
first
andlast
row index contained in the giventableCells
.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
andlast
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.
-
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
andgetSelectedTableCells
.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.
-
isTableWidget( viewElement ) → Boolean
static
Checks if a given view element is a table widget.
-
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