Browse Source

Added unlink option to manual test.

Oskar Wrobel 9 years ago
parent
commit
6b57043a93
2 changed files with 17 additions and 6 deletions
  1. 15 4
      packages/ckeditor5-link/src/link.js
  2. 2 2
      packages/ckeditor5-link/tests/manual/link.js

+ 15 - 4
packages/ckeditor5-link/src/link.js

@@ -31,7 +31,7 @@ export default class Link extends Feature {
 	init() {
 		const editor = this.editor;
 		const t = editor.t;
-		const command = editor.commands.get( 'link' );
+		const linkCommand = editor.commands.get( 'link' );
 
 		// Create button model.
 		const buttonModel = new Model( {
@@ -41,14 +41,25 @@ export default class Link extends Feature {
 			icon: 'link'
 		} );
 
-		// Bind button model to command.
-		buttonModel.bind( 'isOn', 'isEnabled' ).to( command, 'isValue', 'isEnabled' );
+		const unlinkButtonModel = new Model( {
+			isEnabled: true,
+			isOn: false,
+			label: t( 'Unlink' ),
+			icon: 'unlink'
+		} );
 
-		// Execute command.
+		// Button <-> Command binding.
+		buttonModel.bind( 'isOn', 'isEnabled' ).to( linkCommand, 'hasValue', 'isEnabled' );
+
+		// Execute linking.
 		const hrefValue = 'http://www.cksource.com'; // Temporary href value.
 		this.listenTo( buttonModel, 'execute', () => editor.execute( 'link', hrefValue ) );
 
+		// Execute unlinking.
+		this.listenTo( unlinkButtonModel, 'execute', () => editor.execute( 'unlink' ) );
+
 		// Add link button to feature components.
 		editor.ui.featureComponents.add( 'link', ButtonController, ButtonView, buttonModel );
+		editor.ui.featureComponents.add( 'unlink', ButtonController, ButtonView, unlinkButtonModel );
 	}
 }

+ 2 - 2
packages/ckeditor5-link/tests/manual/link.js

@@ -8,8 +8,8 @@
 import ClassicEditor from '/ckeditor5/editor-classic/classic.js';
 
 ClassicEditor.create( document.querySelector( '#editor' ), {
-	features: [ 'link', 'typing', 'paragraph', 'undo' ],
-	toolbar: [ 'link', 'undo', 'redo' ]
+	features: [ 'link', 'typing', 'paragraph', 'enter', 'undo' ],
+	toolbar: [ 'link', 'unlink', 'undo', 'redo' ]
 } )
 .then( editor => {
 	window.editor = editor;