8
0
Quellcode durchsuchen

Fix: Force showing link balloon after pressing Ctrl + K also if caret is already inside a link.

Szymon Cofalik vor 6 Jahren
Ursprung
Commit
51f43b7570
2 geänderte Dateien mit 37 neuen und 1 gelöschten Zeilen
  1. 5 0
      packages/ckeditor5-link/src/linkui.js
  2. 32 1
      packages/ckeditor5-link/tests/linkui.js

+ 5 - 0
packages/ckeditor5-link/src/linkui.js

@@ -380,6 +380,11 @@ export default class LinkUI extends Plugin {
 			else {
 				this._addActionsView();
 			}
+
+			// Be sure panel with link is visible.
+			if ( forceVisible ) {
+				this._balloon.showStack( 'main' );
+			}
 		}
 
 		// Begin responding to ui#update once the UI is added.

+ 32 - 1
packages/ckeditor5-link/tests/linkui.js

@@ -504,7 +504,7 @@ describe( 'LinkUI', () => {
 			sinon.assert.calledOnce( stopPropagationSpy );
 		} );
 
-		it( 'should make stack with link visible on Ctrl+K keystroke', () => {
+		it( 'should make stack with link visible on Ctrl+K keystroke - no link', () => {
 			const command = editor.commands.get( 'link' );
 
 			command.isEnabled = true;
@@ -524,6 +524,37 @@ describe( 'LinkUI', () => {
 			expect( balloon.visibleView ).to.equal( formView );
 		} );
 
+		it( 'should make stack with link visible on Ctrl+K keystroke - link', () => {
+			setModelData( editor.model, '<paragraph><$text linkHref="foo.html">f[]oo</$text></paragraph>' );
+
+			const customView = new View();
+
+			balloon.add( {
+				view: customView,
+				stackId: 'custom'
+			} );
+
+			expect( balloon.visibleView ).to.equal( customView );
+
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
+
+			expect( balloon.visibleView ).to.equal( actionsView );
+
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
+
+			expect( balloon.visibleView ).to.equal( formView );
+		} );
+
 		it( 'should focus the the #actionsView on `Tab` key press when #actionsView is visible', () => {
 			const keyEvtData = {
 				keyCode: keyCodes.tab,