This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export default class InlineEditor extends StandardEditor {
7474 */
7575 static create ( element , config ) {
7676 return new Promise ( resolve => {
77- const editor = new InlineEditor ( element , config ) ;
77+ const editor = new this ( element , config ) ;
7878
7979 resolve (
8080 editor . initPlugins ( )
Original file line number Diff line number Diff line change @@ -89,6 +89,32 @@ describe( 'InlineEditor', () => {
8989 it ( 'loads data from the editor element' , ( ) => {
9090 expect ( editor . getData ( ) ) . to . equal ( '<p><strong>foo</strong> bar</p>' ) ;
9191 } ) ;
92+
93+ // #25
94+ it ( 'creates an instance of a InlineEditor child class' , ( ) => {
95+ // Fun fact: Remove the next 3 lines and you'll get a lovely inf loop due to two
96+ // editor being initialized on one element.
97+ const editorElement = document . createElement ( 'div' ) ;
98+ editorElement . innerHTML = '<p><strong>foo</strong> bar</p>' ;
99+
100+ document . body . appendChild ( editorElement ) ;
101+
102+ class CustomInlineEditor extends InlineEditor { }
103+
104+ return CustomInlineEditor . create ( editorElement , {
105+ plugins : [ Paragraph , Bold ]
106+ } )
107+ . then ( newEditor => {
108+ expect ( newEditor ) . to . be . instanceof ( CustomInlineEditor ) ;
109+ expect ( newEditor ) . to . be . instanceof ( InlineEditor ) ;
110+
111+ expect ( newEditor . getData ( ) ) . to . equal ( '<p><strong>foo</strong> bar</p>' ) ;
112+
113+ editorElement . remove ( ) ;
114+
115+ return newEditor . destroy ( ) ;
116+ } ) ;
117+ } ) ;
92118 } ) ;
93119
94120 describe ( 'create - events' , ( ) => {
You can’t perform that action at this time.
0 commit comments