From d0147b87c0ff4165a383e51713f5a154d4a45a9f Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 7 Aug 2017 11:30:13 +0200 Subject: [PATCH 1/4] Fix: Link balloon should follow its target when the content is being indented (outdented). --- src/link.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/link.js b/src/link.js index 1e08493..ad2aa53 100644 --- a/src/link.js +++ b/src/link.js @@ -276,14 +276,9 @@ export default class Link extends Plugin { // * there was no link element in the first place, i.e. creating a new link else { // If still in a link element, simply update the position of the balloon. - if ( renderSelectedLink ) { - this._balloon.updatePosition(); - } // If there was no link, upon #render, the balloon must be moved // to the new position in the editing view (a new native DOM range). - else { - this._balloon.updatePosition( this._getBalloonPositionData() ); - } + this._balloon.updatePosition( this._getBalloonPositionData() ); } } ); From 291b87bba711d15ac03c7310b460c3044abe862f Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 7 Aug 2017 16:05:07 +0200 Subject: [PATCH 2/4] Ensured the Tab key focuses the LinkFormView with the high priority. --- src/link.js | 2 +- tests/link.js | 16 +++++++++++++++- tests/ui/linkformview.js | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/link.js b/src/link.js index ad2aa53..c300d62 100644 --- a/src/link.js +++ b/src/link.js @@ -213,7 +213,7 @@ export default class Link extends Plugin { this.formView.focus(); cancel(); } - } ); + }, { priority: 'high' } ); // Close the panel on the Esc key press when the editable has focus and the balloon is visible. this.editor.keystrokes.set( 'Esc', ( data, cancel ) => { diff --git a/tests/link.js b/tests/link.js index 9f8fe5a..25ca4b2 100644 --- a/tests/link.js +++ b/tests/link.js @@ -268,7 +268,10 @@ describe( 'Link', () => { viewDocument.render(); sinon.assert.calledOnce( spy ); - sinon.assert.calledWithExactly( spy ); + sinon.assert.calledWithExactly( spy, { + target: viewDocument.domConverter.mapViewToDom( root.getChild( 0 ).getChild( 0 ) ), + limiter: editorElement + } ); } ); // https://github.com/ckeditor/ckeditor5-link/issues/113 @@ -484,6 +487,11 @@ describe( 'Link', () => { stopPropagation: sinon.spy() }; + const normalPriorityTabCallbackSpy = sinon.spy(); + const highestPriorityTabCallbackSpy = sinon.spy(); + editor.keystrokes.set( 'Tab', normalPriorityTabCallbackSpy ); + editor.keystrokes.set( 'Tab', highestPriorityTabCallbackSpy, { priority: 'highest' } ); + // Balloon is invisible, form not focused. formView.focusTracker.isFocused = false; @@ -493,6 +501,8 @@ describe( 'Link', () => { sinon.assert.notCalled( keyEvtData.preventDefault ); sinon.assert.notCalled( keyEvtData.stopPropagation ); sinon.assert.notCalled( spy ); + sinon.assert.calledOnce( normalPriorityTabCallbackSpy ); + sinon.assert.calledOnce( highestPriorityTabCallbackSpy ); // Balloon is visible, form focused. linkFeature._showPanel( true ); @@ -502,6 +512,8 @@ describe( 'Link', () => { sinon.assert.notCalled( keyEvtData.preventDefault ); sinon.assert.notCalled( keyEvtData.stopPropagation ); sinon.assert.notCalled( spy ); + sinon.assert.calledTwice( normalPriorityTabCallbackSpy ); + sinon.assert.calledTwice( highestPriorityTabCallbackSpy ); // Balloon is still visible, form not focused. formView.focusTracker.isFocused = false; @@ -510,6 +522,8 @@ describe( 'Link', () => { sinon.assert.calledOnce( keyEvtData.preventDefault ); sinon.assert.calledOnce( keyEvtData.stopPropagation ); sinon.assert.calledOnce( spy ); + sinon.assert.calledTwice( normalPriorityTabCallbackSpy ); + sinon.assert.calledThrice( highestPriorityTabCallbackSpy ); } ); it( 'should hide the #_balloon after Esc key press (from editor) and not focus the editable', () => { diff --git a/tests/ui/linkformview.js b/tests/ui/linkformview.js index e983cf0..b524f55 100644 --- a/tests/ui/linkformview.js +++ b/tests/ui/linkformview.js @@ -136,7 +136,7 @@ describe( 'LinkFormView', () => { } ); describe( 'activates keyboard navigation for the toolbar', () => { - it( 'so "tab" the next focusable item', () => { + it( 'so "tab" focuses the next focusable item', () => { const keyEvtData = { keyCode: keyCodes.tab, preventDefault: sinon.spy(), From be71d78992cfab3e85fe610c55851ac6210aff91 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 22 Aug 2017 11:50:23 +0200 Subject: [PATCH 3/4] Docs: Documented the high priority Tab key listener in the Link plugin. --- src/link.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/link.js b/src/link.js index 616102d..35fc800 100644 --- a/src/link.js +++ b/src/link.js @@ -215,7 +215,12 @@ export default class Link extends Plugin { this.formView.focus(); cancel(); } - }, { priority: 'high' } ); + }, { + // Use the high priority because the link UI navigation is more important + // than other feature's actions, e.g. list indentation. + // https://github.com/ckeditor/ckeditor5-link/issues/146 + priority: 'high' + } ); // Close the panel on the Esc key press when the editable has focus and the balloon is visible. this.editor.keystrokes.set( 'Esc', ( data, cancel ) => { From 24c5e0ee22495644e7bdc96693b7f48e50df3f34 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 22 Aug 2017 11:52:03 +0200 Subject: [PATCH 4/4] Tests: Fixed a broken Link test after ckeditor/ckeditor5-ui#288. --- tests/link.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/link.js b/tests/link.js index f998145..890a435 100644 --- a/tests/link.js +++ b/tests/link.js @@ -267,8 +267,7 @@ describe( 'Link', () => { sinon.assert.calledOnce( spy ); sinon.assert.calledWithExactly( spy, { - target: viewDocument.domConverter.mapViewToDom( root.getChild( 0 ).getChild( 0 ) ), - limiter: editorElement + target: viewDocument.domConverter.mapViewToDom( root.getChild( 0 ).getChild( 0 ) ) } ); } );