瀏覽代碼

Fix: Allows inheriting from ClassicEditor.

Kamil Piechaczek 8 年之前
父節點
當前提交
d4e9064bd3
共有 2 個文件被更改,包括 17 次插入1 次删除
  1. 1 1
      packages/ckeditor5-editor-classic/src/classic.js
  2. 16 0
      packages/ckeditor5-editor-classic/tests/classic.js

+ 1 - 1
packages/ckeditor5-editor-classic/src/classic.js

@@ -81,7 +81,7 @@ export default class ClassicEditor extends StandardEditor {
 	 */
 	static create( element, config ) {
 		return new Promise( ( resolve ) => {
-			const editor = new ClassicEditor( element, config );
+			const editor = new this( element, config );
 
 			resolve(
 				editor.initPlugins()

+ 16 - 0
packages/ckeditor5-editor-classic/tests/classic.js

@@ -87,6 +87,22 @@ describe( 'ClassicEditor', () => {
 		it( 'loads data from the editor element', () => {
 			expect( editor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' );
 		} );
+
+		it( 'creates an instance of a ClassicEditor child class', () => {
+			class CustomClassicEditor extends ClassicEditor {}
+
+			return CustomClassicEditor.create( editorElement, {
+					plugins: [ Paragraph, Bold ]
+				} )
+				.then( newEditor => {
+					editor = newEditor;
+
+					expect( newEditor ).to.be.instanceof( CustomClassicEditor );
+					expect( newEditor ).to.be.instanceof( ClassicEditor );
+
+					expect( newEditor.getData() ).to.equal( '<p><strong>foo</strong> bar</p>' );
+				} );
+		} );
 	} );
 
 	describe( 'create - events', () => {