diff --git a/src/link.js b/src/link.js index 63ea05f..3c5f730 100644 --- a/src/link.js +++ b/src/link.js @@ -241,14 +241,15 @@ export default class Link extends Plugin { */ _showPanel( focusInput ) { const editor = this.editor; - const command = editor.commands.get( 'link' ); + const linkCommand = editor.commands.get( 'link' ); + const unlinkCommand = editor.commands.get( 'unlink' ); const editing = editor.editing; const showViewDocument = editing.view; const showIsCollapsed = showViewDocument.selection.isCollapsed; const showSelectedLink = this._getSelectedLinkElement(); // https://github.com/ckeditor/ckeditor5-link/issues/53 - this.formView.unlinkButtonView.isVisible = !!showSelectedLink; + this.formView.unlinkButtonView.isVisible = unlinkCommand.isEnabled; // Make sure that each time the panel shows up, the URL field remains in sync with the value of // the command. If the user typed in the input, then canceled the balloon (`urlInputView#value` stays @@ -256,7 +257,7 @@ export default class Link extends Plugin { // clicked the same link), they would see the old value instead of the actual value of the command. // https://github.com/ckeditor/ckeditor5-link/issues/78 // https://github.com/ckeditor/ckeditor5-link/issues/123 - this.formView.urlInputView.inputView.element.value = command.value || ''; + this.formView.urlInputView.inputView.element.value = linkCommand.value || ''; this.listenTo( showViewDocument, 'render', () => { const renderSelectedLink = this._getSelectedLinkElement(); diff --git a/tests/link.js b/tests/link.js index 999e970..9f8fe5a 100644 --- a/tests/link.js +++ b/tests/link.js @@ -208,6 +208,11 @@ describe( 'Link', () => { linkFeature._showPanel(); expect( formView.unlinkButtonView.isVisible ).to.be.true; + + setModelData( editor.document, '<$text linkHref="url">[fo]o' ); + + linkFeature._showPanel(); + expect( formView.unlinkButtonView.isVisible ).to.be.true; } ); // https://github.com/ckeditor/ckeditor5-link/issues/78