From 9e85e6adf4132d279059b824503427aeab8f3e5c Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 21 Aug 2017 13:32:17 +0200 Subject: [PATCH 1/3] Other: Removed the "Unlink" button from the toolbars. Closes #52. --- tests/manual/link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/manual/link.js b/tests/manual/link.js index c1304f0..b4d3b09 100644 --- a/tests/manual/link.js +++ b/tests/manual/link.js @@ -15,7 +15,7 @@ import Undo from '@ckeditor/ckeditor5-undo/src/undo'; ClassicEditor .create( document.querySelector( '#editor' ), { plugins: [ Link, Typing, Paragraph, Undo, Enter ], - toolbar: [ 'link', 'unlink', 'undo', 'redo' ] + toolbar: [ 'link', 'undo', 'redo' ] } ) .then( editor => { window.editor = editor; From 6b3bfd8b891db799646564b72dde7dce413dd47d Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Mon, 21 Aug 2017 13:55:55 +0200 Subject: [PATCH 2/3] Tests: Updated manual test because the Unlink toolbar button has been removed. --- tests/manual/link.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/manual/link.md b/tests/manual/link.md index e8be387..c3f9485 100644 --- a/tests/manual/link.md +++ b/tests/manual/link.md @@ -33,8 +33,9 @@ ### Unlink link fragment 1. Select link fragment. -2. Click toolbar unlink button. -3. Check if selected text has been converted into a regular text. +2. Click the toolbar link button. +3. Click the "Unlink" button. +4. Check if selected text has been converted into a regular text. ### Unlink whole link From aad5cc61f6a953a25ccf2c0f4baa01f835d2dbb9 Mon Sep 17 00:00:00 2001 From: Aleksander Nowodzinski Date: Tue, 22 Aug 2017 14:55:16 +0200 Subject: [PATCH 3/3] Removed Unlink UI component from the ComponentFactory. --- src/link.js | 32 -------------------------------- tests/link.js | 28 +--------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/src/link.js b/src/link.js index 35fc800..6c1a13d 100644 --- a/src/link.js +++ b/src/link.js @@ -20,8 +20,6 @@ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; import LinkFormView from './ui/linkformview'; import linkIcon from '../theme/icons/link.svg'; -import unlinkIcon from '../theme/icons/unlink.svg'; - import '../theme/theme.scss'; const linkKeystroke = 'Ctrl+K'; @@ -74,7 +72,6 @@ export default class Link extends Plugin { // Create toolbar buttons. this._createToolbarLinkButton(); - this._createToolbarUnlinkButton(); // Attach lifecycle actions to the the balloon. this._attachActions(); @@ -160,35 +157,6 @@ export default class Link extends Plugin { } ); } - /** - * Creates a toolbar Unlink button. Clicking this button will unlink - * the selected link. - * - * @private - */ - _createToolbarUnlinkButton() { - const editor = this.editor; - const t = editor.t; - const unlinkCommand = editor.commands.get( 'unlink' ); - - editor.ui.componentFactory.add( 'unlink', locale => { - const button = new ButtonView( locale ); - - button.isEnabled = false; - button.label = t( 'Unlink' ); - button.icon = unlinkIcon; - button.tooltip = true; - - // Bind button to the command. - button.bind( 'isEnabled' ).to( unlinkCommand, 'isEnabled' ); - - // Execute unlink command and hide panel, if open on button click. - this.listenTo( button, 'execute', () => editor.execute( 'unlink' ) ); - - return button; - } ); - } - /** * Attaches actions that control whether the balloon panel containing the * {@link #formView} is visible or not. diff --git a/tests/link.js b/tests/link.js index 890a435..ebab8f8 100644 --- a/tests/link.js +++ b/tests/link.js @@ -22,7 +22,7 @@ import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobs testUtils.createSinonSandbox(); describe( 'Link', () => { - let editor, linkFeature, linkButton, unlinkButton, balloon, formView, editorElement; + let editor, linkFeature, linkButton, balloon, formView, editorElement; beforeEach( () => { editorElement = document.createElement( 'div' ); @@ -39,7 +39,6 @@ describe( 'Link', () => { linkFeature = editor.plugins.get( Link ); linkButton = editor.ui.componentFactory.create( 'link' ); - unlinkButton = editor.ui.componentFactory.create( 'unlink' ); balloon = editor.plugins.get( ContextualBalloon ); formView = linkFeature.formView; @@ -437,31 +436,6 @@ describe( 'Link', () => { } ); } ); - describe( 'unlink toolbar button', () => { - it( 'should register unlink button', () => { - expect( unlinkButton ).to.instanceOf( ButtonView ); - } ); - - it( 'should bind unlinkButtonView to unlink command', () => { - const command = editor.commands.get( 'unlink' ); - - command.isEnabled = true; - expect( unlinkButton.isEnabled ).to.be.true; - - command.isEnabled = false; - expect( unlinkButton.isEnabled ).to.be.false; - } ); - - it( 'should execute unlink command on unlinkButtonView execute event', () => { - const executeSpy = testUtils.sinon.spy( editor, 'execute' ); - - unlinkButton.fire( 'execute' ); - - expect( executeSpy.calledOnce ).to.true; - expect( executeSpy.calledWithExactly( 'unlink' ) ).to.true; - } ); - } ); - describe( 'keyboard support', () => { it( 'should show the #_balloon with selected #formView on Ctrl+K keystroke', () => { const spy = testUtils.sinon.stub( linkFeature, '_showPanel' ).returns( {} );