diff --git a/src/linkui.js b/src/linkui.js index 2ef5245..391d576 100644 --- a/src/linkui.js +++ b/src/linkui.js @@ -201,9 +201,11 @@ export default class LinkUI extends Plugin { button.icon = linkIcon; button.keystroke = linkKeystroke; button.tooltip = true; + button.isToggleable = true; // Bind button to the command. - button.bind( 'isOn', 'isEnabled' ).to( linkCommand, 'value', 'isEnabled' ); + button.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' ); + button.bind( 'isOn' ).to( linkCommand, 'value', value => !!value ); // Show the panel on button click. this.listenTo( button, 'execute', () => this._showUI( true ) ); diff --git a/tests/linkui.js b/tests/linkui.js index 652b2b5..bdab445 100644 --- a/tests/linkui.js +++ b/tests/linkui.js @@ -85,17 +85,21 @@ describe( 'LinkUI', () => { expect( linkButton ).to.be.instanceOf( ButtonView ); } ); + it( 'should be toggleable button', () => { + expect( linkButton.isToggleable ).to.be.true; + } ); + it( 'should be bound to the link command', () => { const command = editor.commands.get( 'link' ); command.isEnabled = true; - command.value = true; + command.value = 'http://ckeditor.com'; expect( linkButton.isOn ).to.be.true; expect( linkButton.isEnabled ).to.be.true; command.isEnabled = false; - command.value = false; + command.value = undefined; expect( linkButton.isOn ).to.be.false; expect( linkButton.isEnabled ).to.be.false;