ソースを参照

Plugin bootstrap.

Kamil Piechaczek 6 年 前
コミット
48768b6d42

+ 17 - 0
packages/ckeditor5-special-characters/src/insertspecialcharactercommand.js

@@ -0,0 +1,17 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module special-characters/insertspecialcharactercommand
+ */
+
+import Command from '@ckeditor/ckeditor5-core/src/command';
+
+/**
+ * @extends module:core/command~Command
+ */
+export default class InsertSpecialCharacterCommand extends Command {
+
+}

+ 32 - 0
packages/ckeditor5-special-characters/src/specialcharacters.js

@@ -0,0 +1,32 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module special-characters/specialcharacters
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import SpecialCharactersUI from './specialcharactersui';
+
+/**
+ * The special characters feature.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class SpecialCharacters extends Plugin {
+	/**
+	 * @inheritDoc
+	 */
+	static get requires() {
+		return [ SpecialCharactersUI ];
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get pluginName() {
+		return 'SpecialCharacters';
+	}
+}

+ 40 - 0
packages/ckeditor5-special-characters/src/specialcharactersui.js

@@ -0,0 +1,40 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module special-characters/specialcharactersui
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
+import specialCharactersIcon from '../theme/icons/specialcharacters.svg';
+
+/**
+ * The special characters UI plugin.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class SpecialCharactersUI extends Plugin {
+	init() {
+		const editor = this.editor;
+		const t = editor.t;
+
+		// Add the `specialCharacters` button to feature components.
+		editor.ui.componentFactory.add( 'specialCharacters', locale => {
+			const command = editor.commands.get( 'specialCharacters' );
+			const view = new ButtonView( locale );
+
+			view.set( {
+				label: t( 'Special characters' ),
+				icon: specialCharactersIcon,
+				tooltip: true
+			} );
+
+			view.bind( 'isEnabled' ).to( command, 'isEnabled' );
+
+			return view;
+		} );
+	}
+}