From 57611679b5b8c3a6e404a74ec19b6e46b99fa99e Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 3 Dec 2024 13:31:25 +0100 Subject: [PATCH 1/3] Show link form on second click in toolbar. --- packages/ckeditor5-link/src/linkui.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/ckeditor5-link/src/linkui.ts b/packages/ckeditor5-link/src/linkui.ts index e8578ec678b..5399cd01cf3 100644 --- a/packages/ckeditor5-link/src/linkui.ts +++ b/packages/ckeditor5-link/src/linkui.ts @@ -884,12 +884,16 @@ export default class LinkUI extends Plugin { } // If there's a link under the selection... else { - // Go to the editing UI if toolbar is already visible. - if ( this._isToolbarVisible ) { + if ( forceVisible && this._getSelectedLinkElement() ) { + // Show the toolbar below of the form view if user selected link and triggered + // the balloon from the toolbar or the menu bar. + this._addToolbarView(); this._addFormView(); - } - // Otherwise display just the toolbar. - else { + } else if ( this._isToolbarVisible ) { + // Go to the editing UI if toolbar is already visible. + this._addFormView(); + } else { + // Otherwise display just the toolbar. this._addToolbarView(); } From 955f077ad8d0a0ab950ea41320cce65afd4ea07a Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 3 Dec 2024 13:46:11 +0100 Subject: [PATCH 2/3] Move stacking form logic from `#_showUI` to toolbar button executor. --- packages/ckeditor5-link/src/linkui.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/ckeditor5-link/src/linkui.ts b/packages/ckeditor5-link/src/linkui.ts index 5399cd01cf3..60b644cab76 100644 --- a/packages/ckeditor5-link/src/linkui.ts +++ b/packages/ckeditor5-link/src/linkui.ts @@ -625,7 +625,15 @@ export default class LinkUI extends Plugin { view.bind( 'isOn' ).to( command, 'value', value => !!value ); // Show the panel on button click. - this.listenTo( view, 'execute', () => this._showUI( true ) ); + this.listenTo( view, 'execute', () => { + this._showUI( true ); + + // Open the form view on-top of the toolbar view if it's already visible. + // It should be visible every time the link is selected. + if ( this._getSelectedLinkElement() ) { + this._addFormView(); + } + } ); return view; } @@ -884,16 +892,12 @@ export default class LinkUI extends Plugin { } // If there's a link under the selection... else { - if ( forceVisible && this._getSelectedLinkElement() ) { - // Show the toolbar below of the form view if user selected link and triggered - // the balloon from the toolbar or the menu bar. - this._addToolbarView(); - this._addFormView(); - } else if ( this._isToolbarVisible ) { - // Go to the editing UI if toolbar is already visible. + // Go to the editing UI if toolbar is already visible. + if ( this._isToolbarVisible ) { this._addFormView(); - } else { - // Otherwise display just the toolbar. + } + // Otherwise display just the toolbar. + else { this._addToolbarView(); } From 97f0eeb7ccdfa9e5aa273be989efb3b483bade71 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 3 Dec 2024 14:04:26 +0100 Subject: [PATCH 3/3] Add test. --- packages/ckeditor5-link/tests/linkui.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/ckeditor5-link/tests/linkui.js b/packages/ckeditor5-link/tests/linkui.js index 05536bf1806..bc5c3387b67 100644 --- a/packages/ckeditor5-link/tests/linkui.js +++ b/packages/ckeditor5-link/tests/linkui.js @@ -172,6 +172,14 @@ describe( 'LinkUI', () => { expect( linkUIFeature.formView.backButtonView.isVisible ).to.be.false; } ); + + it( 'should open on-top of the toolbar if the link is selected', () => { + setModelData( editor.model, '<$text linkHref="url">f[]oo' ); + + linkButton.fire( 'execute' ); + + expect( balloon.visibleView ).to.equal( linkUIFeature.formView ); + } ); } describe( 'the "linkPreview" toolbar button', () => {