瀏覽代碼

Bootstrap MentionsEditing plugin.

Maciej Gołaszewski 6 年之前
父節點
當前提交
dc5505d3ae

+ 9 - 0
packages/ckeditor5-mention/src/mention.js

@@ -9,6 +9,8 @@
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
+import MentionEditing from './mentionediting';
+
 /**
  * The mention plugin.
  *
@@ -23,4 +25,11 @@ export default class Mention extends Plugin {
 	static get pluginName() {
 		return 'Mention';
 	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get requires() {
+		return [ MentionEditing ];
+	}
 }

+ 24 - 0
packages/ckeditor5-mention/src/mentionediting.js

@@ -0,0 +1,24 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/**
+ * @module mention/mentionediting
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+
+/**
+ * The mention editing feature.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class MentionEditing extends Plugin {
+	/**
+	 * @inheritDoc
+	 */
+	static get pluginName() {
+		return 'MentionEditing';
+	}
+}

+ 7 - 1
packages/ckeditor5-mention/tests/mention.js

@@ -4,9 +4,11 @@
  */
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-import Mention from '../src/mention';
 import global from '@ckeditor/ckeditor5-utils/src/dom/global';
 
+import Mention from '../src/mention';
+import MentionEditing from '../src/mentionediting';
+
 describe( 'Mention', () => {
 	let editorElement, editor;
 
@@ -36,4 +38,8 @@ describe( 'Mention', () => {
 	it( 'has proper name', () => {
 		expect( Mention.pluginName ).to.equal( 'Mention' );
 	} );
+
+	it( 'should load MentionEditing plugin', () => {
+		expect( editor.plugins.get( MentionEditing ) ).to.instanceOf( MentionEditing );
+	} );
 } );

+ 33 - 0
packages/ckeditor5-mention/tests/mentionediting.js

@@ -0,0 +1,33 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
+import MentionEditing from '../src/mentionediting';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
+
+describe( 'MentionEditing', () => {
+	testUtils.createSinonSandbox();
+
+	it( 'should be named', () => {
+		expect( MentionEditing.pluginName ).to.equal( 'MentionEditing' );
+	} );
+
+	describe( 'init()', () => {
+		it( 'should be loaded', () => {
+			return createTestEditor()
+				.then( newEditor => {
+					expect( newEditor.plugins.get( MentionEditing ) ).to.be.instanceOf( MentionEditing );
+				} );
+		} );
+	} );
+
+	function createTestEditor( mentionConfig ) {
+		return VirtualTestEditor
+			.create( {
+				plugins: [ MentionEditing ],
+				mention: mentionConfig
+			} );
+	}
+} );