engine/utils/bindtwostepcarettoattribute
@ckeditor/ckeditor5-engine/src/utils/bindtwostepcarettoattribute
Filtering
Classes
-
TwoStepCaretHandlerprotected
This is a protected helper–class for
bindtwostepcarettoattribute. It handles the state of the 2-step caret movement for a singleModelattribute upon thekeypressin theView.
Functions
-
bindTwoStepCaretToAttribute( options = { options.view, options.model, options.emitter, options.attribute, options.locale } )static
This helper enables the two-step caret (phantom) movement behavior for the given
Modelattribute 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.
Note: This helper support right–to–left (Arabic, Hebrew, etc.) content by mirroring its behavior but for the sake of simplicity examples showcase only left–to–right use–cases.
Forward movement
"Entering" an attribute:
When this behavior is enabled for the
aattribute 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>{}bazWhen 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>bazWhen disabled:
<$text a="true">bar</$text>{}baz←
<$text a="true">ba{}r</$text>b{}az
Parameters
options : ObjectHelper options.
Propertiesoptions.view : ViewView controller instance.
options.model : ModelData model instance.
options.emitter : EmitterThe emitter to which this behavior should be added (e.g. a plugin instance).
options.attribute : StringAttribute for which this behavior will be added.
options.locale : LocaleThe
localeinstance.