|
|
@@ -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.
|
|
|
*
|