8
0
Просмотр исходного кода

Added ParagraphButtonUI class.

Szymon Kupś 7 лет назад
Родитель
Сommit
26a2b008fe

+ 34 - 0
packages/ckeditor5-paragraph/src/paragraphbuttonui.js

@@ -0,0 +1,34 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/**
+ * @module paragraph/paragraphbuttonui
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+import icon from '../theme/icons/paragraph.svg';
+
+export default class ParagraphButtonUI extends Plugin {
+	init() {
+		const editor = this.editor;
+		editor.ui.componentFactory.add( 'paragraph', locale => {
+			const view = new ButtonView( locale );
+			const command = editor.commands.get( 'paragraph' );
+
+			view.label = 'Paragraph';
+			view.icon = icon;
+			view.tooltip = true;
+			view.bind( 'isEnabled' ).to( command );
+			view.bind( 'isOn' ).to( command, 'value' );
+
+			view.on( 'execute', () => {
+				editor.execute( 'paragraph' );
+			} );
+
+			return view;
+		} );
+	}
+}

+ 1 - 0
packages/ckeditor5-paragraph/theme/icons/paragraph.svg

@@ -0,0 +1 @@
+<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="#000"><path d="M7.5 5.4V10l.1.2H9c1 0 2-.3 2.5-.7.5-.4 1-1 1-2 0-1.6-1.4-2.3-3.5-2.3H7.6l-.1.2zM6.1 17a1 1 0 0 1-.8-.3 1 1 0 0 1-.3-.8V4.4l.3-.9c.2-.2.5-.3.8-.3L9 3c2 0 3.4.4 4.3 1.1 1 .8 1.4 1.9 1.4 3.3 0 1.6-.4 2.8-1.3 3.6-1 .8-2.3 1.2-4 1.2L7.5 12l-.1.2v3.6c0 .3-.1.6-.3.8a1 1 0 0 1-.8.3H6z"/></g></g></svg>