|
|
@@ -12,9 +12,12 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
|
import { isLinkElement } from '../src/utils';
|
|
|
+import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
|
|
|
|
import { downcastAttributeToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
|
|
|
|
|
|
+/* global document */
|
|
|
+
|
|
|
describe( 'LinkEditing', () => {
|
|
|
let editor, model;
|
|
|
|
|
|
@@ -40,6 +43,26 @@ describe( 'LinkEditing', () => {
|
|
|
expect( model.schema.checkAttribute( [ '$block' ], 'linkHref' ) ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
+ it( 'should bind two-step caret movement to `linkHref` attribute', () => {
|
|
|
+ // Let's check only the minimum to not duplicated `bindTwoStepCaretToAttribute()` tests.
|
|
|
+ // Testing minimum is better then testing using spies that might give false positive results.
|
|
|
+
|
|
|
+ // Put selection before the link element.
|
|
|
+ setModelData( editor.model, '<paragraph>foo[]<$text linkHref="url">b</$text>ar</paragraph>' );
|
|
|
+
|
|
|
+ // The selection's gravity is not overridden because selection land here not as a result of `keydown`.
|
|
|
+ expect( editor.model.document.selection.isGravityOverridden ).to.false;
|
|
|
+
|
|
|
+ // So let's simulate `keydown` event.
|
|
|
+ editor.editing.view.document.fire( 'keydown', {
|
|
|
+ keyCode: keyCodes.arrowright,
|
|
|
+ preventDefault: () => {},
|
|
|
+ domTarget: document.body
|
|
|
+ } );
|
|
|
+
|
|
|
+ expect( editor.model.document.selection.isGravityOverridden ).to.true;
|
|
|
+ } );
|
|
|
+
|
|
|
describe( 'command', () => {
|
|
|
it( 'should register link command', () => {
|
|
|
const command = editor.commands.get( 'link' );
|