Module

table/commands/utils

@ckeditor/ckeditor5-table/src/commands/utils

module

Filtering

Functions

  • addDefaultUnitToNumericValue( value, defaultUnit ) → String | *

    static

    Adds a unit to a value if the value is a number or a string representing a number.

    Note: It does nothing to non-numeric values.

    getSingleValue( 25, 'px' );        // '25px'
    getSingleValue( 25, 'em' );        // '25em'
    getSingleValue( '25em', 'px' );    // '25em'
    getSingleValue( 'foo', 'px' );    // 'foo'

    Parameters

    value : *
    defaultUnit : String

    A default unit added to a numeric value.

    Returns

    String | *
  • createEmptyTableCell( writer, insertPosition, attributes )

    static

    A 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 : Writer

    The model writer.

    insertPosition : Position

    The position at which the table cell should be inserted.

    attributes : Object

    The element attributes.

  • findAncestor( parentName, positionOrElement ) → Element | DocumentFragment

    static

    Returns the parent element of the given name. Returns undefined if the position or the element is not inside the desired parent.

    Parameters

    parentName : String

    The name of the parent element to find.

    positionOrElement : Position | Position

    The position or the parentElement to start searching.

    Returns

    Element | DocumentFragment
  • getSingleValue( objectOrString ) → BoxSides | String

    static

    Returns a string if all four values of box sides are equal.

    If a string is passed, it is treated as a single value (pass-through).

    // Returns 'foo':
    getSingleValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'foo' } );
    getSingleValue( 'foo' );
    
    // Returns undefined:
    getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );
    getSingleValue( { top: 'foo', right: 'foo' } );

    Parameters

    objectOrString

    Returns

    BoxSides | String
  • isHeadingColumnCell( tableUtils, tableCell ) → Boolean

    static

    Checks if a table cell belongs to the heading column section.

    Parameters

    tableUtils : TableUtils
    tableCell : Element

    Returns

    Boolean
  • updateNumericAttribute( key, value, item, writer, defaultValue )

    static

    A common method to update the numeric value. If a value is the default one, it will be unset.

    Parameters

    key : String

    An attribute key.

    value : *

    The new attribute value.

    item : Item

    A model item on which the attribute will be set.

    writer : Writer
    defaultValue : *

    The default attribute value. If a value is lower or equal, it will be unset.