Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #142 from ckeditor/t/141
Browse files Browse the repository at this point in the history
Fix: Then unlink button in the link balloon should be visible when a link is partially selected. Closes #141.
  • Loading branch information
Reinmar authored Jul 21, 2017
2 parents af73903 + a3666bc commit 2a4e9d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,23 @@ 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
// unaltered) and re-opened it without changing the value of the link command (e.g. because they
// 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();
Expand Down
5 changes: 5 additions & 0 deletions tests/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ describe( 'Link', () => {

linkFeature._showPanel();
expect( formView.unlinkButtonView.isVisible ).to.be.true;

setModelData( editor.document, '<paragraph><$text linkHref="url">[fo]o</$text></paragraph>' );

linkFeature._showPanel();
expect( formView.unlinkButtonView.isVisible ).to.be.true;
} );

// https://github.com/ckeditor/ckeditor5-link/issues/78
Expand Down

0 comments on commit 2a4e9d8

Please sign in to comment.