Skip to content

Commit

Permalink
Merge cc264cd into bddd096
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Feb 28, 2019
2 parents bddd096 + cc264cd commit 11c3511
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ckeditor/ckeditor.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ describe( 'CKEditorComponent', () => {
} );

it( 'should be configurable at the start of the component', () => {
fixture.detectChanges();
component.data = 'foo';

fixture.detectChanges();

return wait().then( () => {
expect( component.data ).toEqual( 'foo' );
expect( component.editorInstance!.getData() ).toEqual( '<p>foo</p>' );
} );
} );

it( 'should be writeable by ControlValueAccessor', () => {
fixture.detectChanges();
component.writeValue( 'foo' );
fixture.detectChanges();

return wait().then( () => {
expect( component.editorInstance!.getData() ).toEqual( '<p>foo</p>' );
Expand Down
11 changes: 10 additions & 1 deletion src/ckeditor/ckeditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,22 @@ export class CKEditorComponent implements AfterViewInit, OnDestroy, ControlValue
private createEditor(): Promise<any> {
const element = document.createElement( this.tagName );

// Do not use the `editor.setData()` here because of the issue in the collaboration mode (#6).
// Instead set data to the element on which the editor will be later initialized.
element.innerHTML = this.data;

const oldData = this.data;

this.elementRef.nativeElement.appendChild( element );

return this.editor!.create( element, this.config )
.then( editor => {
this.editorInstance = editor;

editor.setData( this.data );
// Update data if it has changed in the meantime.
if ( this.data !== oldData ) {
this.editorInstance.setData( this.data );
}

if ( this.initialIsDisabled ) {
editor.isReadOnly = this.initialIsDisabled;
Expand Down

0 comments on commit 11c3511

Please sign in to comment.