Report an issue
Class

Widget (widget)

@ckeditor/ckeditor5-widget/src/widget

class

The widget plugin. Registers model to view selection converter for editing pipeline. It is hooked after default selection conversion. If converted selection is placed around widget element, selection is marked as fake. Additionally, proper CSS class is added to indicate that widget has been selected. Adds default mousedown handling on widget elements.

Filtering

Properties

Static properties

  • pluginName

    static

Methods

  • init()

  • _clearPreviouslySelectedWidgets( writer )

    private

    Removes CSS class from previously selected widgets.

    Parameters

    writer : Writer
  • _getObjectElementNextToSelection( forward ) → Element | null

    private

    Checks if element placed next to the current model selection exists and is marked in schema as object.

    Parameters

    forward : Boolean

    Direction of checking.

    Returns

    Element | null
  • _handleArrowKeys( isForward ) → Boolean | undefined

    private

    Handles arrow keys.

    Parameters

    isForward : Boolean

    Set to true if arrow key should be handled in forward direction.

    Returns

    Boolean | undefined

    Returns true if keys were handled correctly.

  • _handleDelete( isForward ) → Boolean | undefined

    private

    Handles delete keys: backspace and delete.

    Parameters

    isForward : Boolean

    Set to true if delete was performed in forward direction.

    Returns

    Boolean | undefined

    Returns true if keys were handled correctly.

  • _handleEnterKey( isBackwards ) → Boolean | undefined

    private

    Handles the enter key, giving users and access to positions in the editable directly before (Shift+Enter) or after (Enter) the selected widget. It improves the UX, mainly when the widget is the first or last child of the root editable and there's no other way to type after or before it.

    Parameters

    isBackwards : Boolean

    Set to true if the new paragraph is to be inserted before the selected widget (Shift+Enter).

    Returns

    Boolean | undefined

    Returns true if keys were handled correctly.

  • _onKeydown( eventInfo, domEventData )

    private

    Handles keydown events.

    Parameters

    eventInfo : EventInfo
    domEventData : DomEventData
  • _onMousedown( eventInfo, domEventData )

    private

    Handles mousedown events on widget elements.

    Parameters

    eventInfo : EventInfo
    domEventData : DomEventData
  • _selectAllContent() → Boolean

    private

    Handles CTRL + A when widget is selected.

    Returns

    Boolean

    Returns true if widget was selected and selecting all was handled by this method.

  • _selectAllNestedEditableContent()

    private

    Extends the document's selection to span the entire content of the nested editable if already anchored in one.

  • _setSelectionOverElement( element )

    private

    Sets document's selection over given element.

    Parameters

    element : Element