Explorar el Código

Merge pull request #228 from ckeditor/t/227

Internal: Made sure link balloon will be visible after pressing Ctrl+K. Closes #227.
Piotr Jasiun hace 6 años
padre
commit
64c23b049a
Se han modificado 2 ficheros con 58 adiciones y 2 borrados
  1. 6 1
      packages/ckeditor5-link/src/linkui.js
  2. 52 1
      packages/ckeditor5-link/tests/linkui.js

+ 6 - 1
packages/ckeditor5-link/src/linkui.js

@@ -188,7 +188,7 @@ export default class LinkUI extends Plugin {
 			cancel();
 
 			if ( linkCommand.isEnabled ) {
-				this._showUI();
+				this._showUI( true );
 			}
 		} );
 
@@ -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.

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

@@ -486,7 +486,7 @@ describe( 'LinkUI', () => {
 				preventDefault: sinon.spy(),
 				stopPropagation: sinon.spy()
 			} );
-			sinon.assert.calledWithExactly( spy );
+			sinon.assert.calledWithExactly( spy, true );
 		} );
 
 		it( 'should prevent default action on Ctrl+K keystroke', () => {
@@ -504,6 +504,57 @@ describe( 'LinkUI', () => {
 			sinon.assert.calledOnce( stopPropagationSpy );
 		} );
 
+		it( 'should make stack with link visible on Ctrl+K keystroke - no link', () => {
+			const command = editor.commands.get( 'link' );
+
+			command.isEnabled = true;
+
+			balloon.add( {
+				view: new View(),
+				stackId: 'custom'
+			} );
+
+			editor.keystrokes.press( {
+				keyCode: keyCodes.k,
+				ctrlKey: true,
+				preventDefault: sinon.spy(),
+				stopPropagation: sinon.spy()
+			} );
+
+			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,