浏览代码

Made the keystroke and the toolbar button always open the link actions UI first, if there's a link under the selection.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
35fb6772ae
共有 1 个文件被更改,包括 23 次插入6 次删除
  1. 23 6
      packages/ckeditor5-link/src/link.js

+ 23 - 6
packages/ckeditor5-link/src/link.js

@@ -170,9 +170,7 @@ export default class Link extends Plugin {
 			// Prevent focusing the search bar in FF and opening new tab in Edge. #153, #154.
 			cancel();
 
-			if ( linkCommand.isEnabled ) {
-				this._showForm( true );
-			}
+			this._showUI();
 		} );
 
 		editor.ui.componentFactory.add( 'link', locale => {
@@ -188,9 +186,7 @@ export default class Link extends Plugin {
 			button.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' );
 
 			// Show the panel on button click.
-			this.listenTo( button, 'execute', () => {
-				this._showForm( true );
-			} );
+			this.listenTo( button, 'execute', () => this._showUI() );
 
 			return button;
 		} );
@@ -302,6 +298,27 @@ export default class Link extends Plugin {
 	}
 
 	/**
+	 * Shows the right kind of the UI for current state of the command. It's either
+	 * {@link #formView} or {@link #actionsView}.
+	 *
+	 * @private
+	 */
+	_showUI() {
+		const editor = this.editor;
+		const linkCommand = editor.commands.get( 'link' );
+
+		if ( !linkCommand.isEnabled ) {
+			return;
+		}
+
+		if ( linkCommand.value ) {
+			this._showActions();
+		} else {
+			this._showForm( true );
+		}
+	}
+
+	/**
 	 * Makes the UI react to the {@link module:engine/view/document~Document#event:render} in the view
 	 * document to reposition itself as the document changes.
 	 *