Report an issue
Class

UIElement (engine/view)

@ckeditor/ckeditor5-engine/src/view/uielement

class

UIElement class. It is used to represent UI not a content of the document. This element can't be split and selection can't be placed inside this element.

Filtering

Methods

  • constructor( name, [ attributes ] )

    protected

    Creates new instance of UIElement.

    Throws CKEditorError view-uielement-cannot-add when third parameter is passed, to inform that usage of UIElement is incorrect (adding child nodes to UIElement is forbidden).

    Parameters

    name : String

    Node name.

    [ attributes ] : Object | Iterable

    Collection of attributes.

  • _insertChild()

    Overrides _insertChild method. Throws CKEditorError view-uielement-cannot-add to prevent adding any child nodes to UIElement.

  • getFillerOffset() → null

    Returns null because filler is not needed for UIElements.

    Returns

    null

    Always returns null.

  • is()

  • render( domDocument ) → HTMLElement

    Renders this UIElement to DOM. This method is called by DomConverter. Do not use inheritance to create custom rendering method, replace render() method instead:

    const myUIElement = new UIElement( 'span' );
    myUIElement.render = function( domDocument ) {
        const domElement = this.toDomElement( domDocument );
        domElement.innerHTML = '<b>this is ui element</b>';
    
        return domElement;
    };

    Parameters

    domDocument : Document

    Returns

    HTMLElement
  • toDomElement( domDocument ) → HTMLElement

    Creates DOM element based on this view UIElement. Note that each time this method is called new DOM element is created.

    Parameters

    domDocument : Document

    Returns

    HTMLElement