Report an issue
Module

engine/utils/bindtwostepcarettoattribute

@ckeditor/ckeditor5-engine/src/utils/bindtwostepcarettoattribute

module

Filtering

Classes

Functions

  • bindTwoStepCaretToAttribute( view, model, emitter, attribute )

    static

    This helper enabled the two-step caret (phantom) movement behavior for the given Model attribute on arrow right () and left () key press.

    Thanks to this (phantom) caret movement the user is able to type before/after as well as at the beginning/end of an attribute.

    Forward movement

    "Entering" an attribute:

    When this behavior is enabled for the a attribute and the selection is right before it (at the attribute boundary), pressing the right arrow key will not move the selection but update its attributes accordingly:

    • When enabled:

      foo{}<$text a="true">bar</$text>

      foo<$text a="true">{}bar</$text>
    • When disabled:

      foo{}<$text a="true">bar</$text>

      foo<$text a="true">b{}ar</$text>
    "Leaving" an attribute:
    • When enabled:

      <$text a="true">bar{}</$text>baz

      <$text a="true">bar</$text>{}baz
    • When disabled:

      <$text a="true">bar{}</$text>baz

      <$text a="true">bar</$text>b{}az

    Backward movement

    • When enabled:

      <$text a="true">bar</$text>{}baz

      <$text a="true">bar{}</$text>baz
    • When disabled:

      <$text a="true">bar</$text>{}baz

      <$text a="true">ba{}r</$text>b{}az

    Parameters

    view : View

    View controller instance.

    model : Model

    Data model instance.

    emitter : Emitter

    The emitter to which this behavior should be added (e.g. a plugin instance).

    attribute : String

    Attribute for which this behavior will be added.