Skip to content

Commit

Permalink
Merge pull request #305 from kzimny/master
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
kzimny authored Dec 8, 2020
2 parents 7084164 + 5ada62c commit 29dad4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-ckeditor",
"version": "1.2.9",
"version": "1.3.0",
"description": "Angular CKEditor component",
"main": "lib/bundles/ng2-ckeditor.umd.min.js",
"typings": "lib/ng2-ckeditor.d.ts",
Expand Down
17 changes: 10 additions & 7 deletions src/ckeditor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ContentChildren,
SimpleChanges,
OnChanges,
OnDestroy
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { CKButtonDirective } from './ckbutton.directive';
Expand All @@ -35,7 +36,7 @@ declare var CKEDITOR: any;
],
template: `<textarea #host></textarea>`,
})
export class CKEditorComponent implements OnChanges, AfterViewInit {
export class CKEditorComponent implements OnChanges, AfterViewInit, OnDestroy {
@Input() config: any;
@Input() readonly: boolean;
@Input() debounce: string;
Expand Down Expand Up @@ -86,12 +87,14 @@ export class CKEditorComponent implements OnChanges, AfterViewInit {
* On component destroy
*/
ngOnDestroy() {
if (this.instance) {
this.instance.removeAllListeners();
CKEDITOR.instances[this.instance.name].destroy();
this.instance.destroy();
this.instance = null;
}
this.zone.runOutsideAngular( () => {
if (this.instance) {
CKEDITOR.removeAllListeners();
CKEDITOR.instances[this.instance.name].destroy();
this.instance.destroy();
this.instance = null;
}
});
}

/**
Expand Down

0 comments on commit 29dad4a

Please sign in to comment.