How to use the @ckeditor/ckeditor5-utils/src/keyboard.keyCodes.arrowright function in @ckeditor/ckeditor5-utils

To help you get started, we’ve selected a few @ckeditor/ckeditor5-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-engine / src / utils / bindtwostepcarettoattribute.js View on Github external
emitter.listenTo( view.document, 'keydown', ( evt, data ) => {
		// This implementation works only for collapsed selection.
		if ( !modelSelection.isCollapsed ) {
			return;
		}

		// When user tries to expand the selection or jump over the whole word or to the beginning/end then
		// two-steps movement is not necessary.
		if ( data.shiftKey || data.altKey || data.ctrlKey ) {
			return;
		}

		const arrowRightPressed = data.keyCode == keyCodes.arrowright;
		const arrowLeftPressed = data.keyCode == keyCodes.arrowleft;

		// When neither left or right arrow has been pressed then do noting.
		if ( !arrowRightPressed && !arrowLeftPressed ) {
			return;
		}

		const position = modelSelection.getFirstPosition();
		const contentDirection = locale.contentLanguageDirection;
		let isMovementHandled;

		if ( ( contentDirection === 'ltr' && arrowRightPressed ) || ( contentDirection === 'rtl' && arrowLeftPressed ) ) {
			isMovementHandled = twoStepCaretHandler.handleForwardMovement( position, data );
		} else {
			isMovementHandled = twoStepCaretHandler.handleBackwardMovement( position, data );
		}
github ckeditor / ckeditor5-image / tests / widget / widget.js View on Github external
'[]foo',
				{ keyCode: keyCodes.arrowright, ctrlKey: true },
				'[]foo'
			);

			test(
				'should work correctly with modifier key: right arrow + alt',
				'[]foo',
				{ keyCode: keyCodes.arrowright, altKey: true },
				'[]foo'
			);

			test(
				'should work correctly with modifier key: right arrow + shift',
				'[]foo',
				{ keyCode: keyCodes.arrowright, shiftKey: true },
				'[]foo'
			);

			test(
				'should work correctly with modifier key: down arrow + ctrl',
				'[]foo',
				{ keyCode: keyCodes.arrowdown, ctrlKey: true },
				'[]foo'
			);

			test(
				'should work correctly with modifier key: down arrow + alt',
				'[]foo',
				{ keyCode: keyCodes.arrowdown, altKey: true },
				'[]foo'
			);
github ckeditor / ckeditor5-engine / tests / utils / bindtwostepcarettoattribute.js View on Github external
it( 'should listen with the high+1 priority on view.document#keydown', () => {
		const highestPrioritySpy = sinon.spy();
		const highPrioritySpy = sinon.spy();
		const normalPrioritySpy = sinon.spy();

		setData( model, '<$text c="true">foo[]<$text a="true" b="true">bar' );

		emitter.listenTo( view.document, 'keydown', highestPrioritySpy, { priority: 'highest' } );
		emitter.listenTo( view.document, 'keydown', highPrioritySpy, { priority: 'high' } );
		emitter.listenTo( view.document, 'keydown', normalPrioritySpy, { priority: 'normal' } );

		fireKeyDownEvent( {
			keyCode: keyCodes.arrowright,
			preventDefault: preventDefaultSpy
		} );

		sinon.assert.callOrder(
			highestPrioritySpy,
			preventDefaultSpy );

		sinon.assert.notCalled( highPrioritySpy );
		sinon.assert.notCalled( normalPrioritySpy );
	} );
github ckeditor / ckeditor5-image / tests / widget / widget.js View on Github external
describe( 'arrows', () => {
			test(
				'should move selection forward from selected object - right arrow',
				'[]foo',
				keyCodes.arrowright,
				'[]foo'
			);

			test(
				'should move selection forward from selected object - down arrow',
				'[]foo',
				keyCodes.arrowdown,
				'[]foo'
			);

			test(
				'should move selection backward from selected object - left arrow',
				'foo[]',
				keyCodes.arrowleft,
				'foo[]'
			);
github ckeditor / ckeditor5-image / tests / widget / widget.js View on Github external
'[]',
				keyCodes.arrowleft,
				'[]'
			);

			test(
				'should move selection to previous widget - up arrow',
				'[]',
				keyCodes.arrowup,
				'[]'
			);

			test(
				'should do nothing on non-collapsed selection next to object - right arrow',
				'ba[r]',
				keyCodes.arrowright,
				'ba[r]'
			);

			test(
				'should do nothing on non-collapsed selection next to object - down arrow',
				'ba[r]',
				keyCodes.arrowdown,
				'ba[r]'
			);

			test(
				'should do nothing on non-collapsed selection next to object - left arrow',
				'[b]ar',
				keyCodes.arrowleft,
				'[b]ar'
			);
github ckeditor / ckeditor5-engine / tests / view / view / jumpoverinlinefiller.js View on Github external
it( 'should do nothing when another key is pressed', () => {
			setData( view, 'foo[]bar' );
			view.forceRender();

			viewDocument.fire( 'keydown', { keyCode: keyCodes.arrowright, domTarget: view.domRoots.get( 'main' ) } );

			const domSelection = document.getSelection();

			expect( isInlineFiller( domSelection.anchorNode ) ).to.be.true;
			expect( domSelection.anchorOffset ).to.equal( INLINE_FILLER_LENGTH );
			expect( domSelection.isCollapsed ).to.be.true;
		} );
github ckeditor / ckeditor5-engine / tests / view / view / jumpoveruielement.js View on Github external
function renderAndFireKeydownEvent( options ) {
		view.forceRender();

		const eventData = Object.assign( { keyCode: keyCodes.arrowright, domTarget: view.domRoots.get( 'main' ) }, options );
		viewDocument.fire( 'keydown', eventData );
	}
github ckeditor / ckeditor5-image / src / widget / widget.js View on Github external
function isArrowKeyCode( keyCode ) {
	return keyCode == keyCodes.arrowright ||
		keyCode == keyCodes.arrowleft ||
		keyCode == keyCodes.arrowup ||
		keyCode == keyCodes.arrowdown;
}