table/utils/common
Functions
createEmptyTableCell( writer, insertPosition, attributes ) → ModelElementinternalmodule:table/utils/common~createEmptyTableCellA common method to create an empty table cell. It creates a proper model structure as a table cell must have at least one block inside.
Parameters
writer: ModelWriterThe model writer.
insertPosition: ModelPositionThe position at which the table cell should be inserted.
attributes: Record<string, unknown>The element attributes.
Defaults to
{}
Returns
ModelElementCreated table cell.
enableProperty( schema, conversion, options = { options.attributeName?, options.attributeType?, options.defaultValue, options.modelAttribute, options.reduceBoxSides?, options.styleName } ) → voidinternalmodule:table/utils/common~enablePropertyEnables conversion for an attribute for simple view-model mappings.
Parameters
schema: ModelSchemaconversion: Conversionoptions: object- Properties
options.attributeName?: stringoptions.attributeType?: 'length' | 'color'options.defaultValue: stringThe default value for the specified
modelAttribute.options.modelAttribute: stringoptions.reduceBoxSides?: booleanoptions.styleName: string
Returns
void
getEmptyTableCellBlocks( table ) → IterableIterator<ModelElement>internalmodule:table/utils/common~getEmptyTableCellBlocksYields every empty block (typically a
paragraph) found inside the given table's cells.Parameters
table: ModelElement
Returns
IterableIterator<ModelElement>
getSelectionAffectedTable( selection ) → ModelElementinternalmodule:table/utils/common~getSelectionAffectedTableDepending on the position of the selection we either return the table under cursor or look for the table higher in the hierarchy.
Parameters
selection: ModelDocumentSelection
Returns
groupCellsByTable( tableCells ) → Map<ModelElement, Array<ModelElement>>internalmodule:table/utils/common~groupCellsByTableGroups table cells by their parent table.
Parameters
tableCells: Array<ModelElement>
Returns
Map<ModelElement, Array<ModelElement>>
isEntireCellsLineHeader( __namedParameters = { __namedParameters.column?, __namedParameters.row?, __namedParameters.table } ) → booleaninternalmodule:table/utils/common~isEntireCellsLineHeaderChecks if all cells in a given row or column are header cells.
Parameters
__namedParameters: object- Properties
__namedParameters.column?: number__namedParameters.row?: number__namedParameters.table: ModelElement
Returns
boolean
isHeadingColumnCell( tableUtils, tableCell ) → booleaninternalmodule:table/utils/common~isHeadingColumnCellChecks if a table cell belongs to the heading column section.
Parameters
tableUtils: TableUtilstableCell: ModelElement
Returns
boolean
isTableCellTypeEnabled( editor ) → booleaninternalmodule:table/utils/common~isTableCellTypeEnabledChecks whether the
tableCellTypeattribute is enabled in the editor schema and the experimental flag is set.Parameters
editor: Editor
Returns
boolean
updateNumericAttribute( key, value, item, writer, defaultValue ) → voidinternalmodule:table/utils/common~updateNumericAttributeA common method to update the numeric value. If a value is the default one, it will be unset.
Parameters
key: stringAn attribute key.
value: unknownThe new attribute value.
item: ModelItemA model item on which the attribute will be set.
writer: ModelWriterdefaultValue: unknownThe default attribute value. If a value is lower or equal, it will be unset.
Defaults to
1
Returns
void