Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #54 from ckeditor/t/53
Browse files Browse the repository at this point in the history
Fix: It should be possible to use `ClassicEditor.create()` in its child classes. Closes #53.
  • Loading branch information
Reinmar authored Mar 21, 2017
2 parents b3c066c + cc416bc commit 95798ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 16 additions & 0 deletions tests/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 95798ba

Please sign in to comment.