浏览代码

Added manual test for bold feature.

Szymon Kupś 9 年之前
父节点
当前提交
6a5cffaf48

+ 26 - 0
packages/ckeditor5-basic-styles/src/bold.js

@@ -7,6 +7,9 @@
 
 import Feature from '../feature.js';
 import BoldEngine from './boldengine.js';
+import ButtonController from '../ui/button/button.js';
+import ButtonView from '../ui/button/buttonview.js';
+import Model from '../ui/model.js';
 
 export default class Bold extends Feature {
 	static get requires() {
@@ -14,5 +17,28 @@ export default class Bold extends Feature {
 	}
 
 	init() {
+		const editor = this.editor;
+		const t = editor.t;
+		const ui = editor.ui;
+		const command = editor.commands.get( 'bold' );
+
+		// Create button model.
+		const buttonModel = new Model( {
+			isEnabled: true,
+			isOn: false,
+			label: t( 'Bold' ),
+			icon: 'bold'
+		} );
+
+		// Bind button model to command.
+		buttonModel.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
+
+		// Execute command.
+		this.listenTo( buttonModel, 'execute', () => {
+			editor.execute( 'bold' );
+		} );
+
+		// Add bold button to feature components.
+		ui.featureComponents.add( 'bold', ButtonController, ButtonView, buttonModel );
 	}
 }

+ 4 - 0
packages/ckeditor5-basic-styles/tests/bold.html

@@ -0,0 +1,4 @@
+<head>
+	<link rel="stylesheet" href="%APPS_DIR%ckeditor/build/amd/theme/ckeditor.css">
+</head>
+<div id="editor"></div>

+ 5 - 4
packages/ckeditor5-basic-styles/tests/bold.js

@@ -8,15 +8,16 @@
 import Editor from '/ckeditor5/editor.js';
 import Bold from '/ckeditor5/basic-styles/bold.js';
 import BoldEngine from '/ckeditor5/basic-styles/boldengine.js';
-import StandardCreator from '/ckeditor5/creator/standardcreator.js';
+import ClassicCreator from '/ckeditor5/creator-classic/classiccreator.js';
 
 describe( 'Bold', () => {
 	let editor;
 
 	beforeEach( () => {
-		editor = new Editor( null, {
-			creator: StandardCreator,
-			features: [ Bold ]
+		editor = new Editor( { 'editor': document.getElementById( 'editor' ) }, {
+			creator: ClassicCreator,
+			features: [ Bold ],
+			toolbar: [ 'bold' ]
 		} );
 
 		return editor.init();

+ 7 - 0
packages/ckeditor5-basic-styles/tests/manual/bold.html

@@ -0,0 +1,7 @@
+<head>
+	<link rel="stylesheet" href="%APPS_DIR%ckeditor/build/amd/theme/ckeditor.css">
+</head>
+
+<div id="editor1">
+	<h1>Hello world!</h1>
+</div>

+ 16 - 0
packages/ckeditor5-basic-styles/tests/manual/bold.js

@@ -0,0 +1,16 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import CKEDITOR from '/ckeditor.js';
+import ClassicCreator from '/ckeditor5/creator-classic/classiccreator.js';
+import Bold from '/ckeditor5/basic-styles/bold.js';
+
+CKEDITOR.create( '#editor1', {
+	creator: ClassicCreator,
+	features: [ Bold ],
+	toolbar: [ 'bold' ]
+} );

+ 4 - 0
packages/ckeditor5-basic-styles/tests/manual/bold.md

@@ -0,0 +1,4 @@
+@bender-ui: collapsed
+## Bold feature
+1. Check if bold button is added to toolbar.
+1. Check if bold button can be toggled on and off.

文件差异内容过多而无法显示
+ 14 - 0
packages/ckeditor5-basic-styles/theme/icons/bold.svg