2017-05-06 15:35:15 +03:00
|
|
|
import { Component, OnDestroy, AfterViewInit, Output, EventEmitter, ElementRef } from '@angular/core';
|
2017-05-06 14:52:41 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ngx-tiny-mce',
|
|
|
|
|
template: '',
|
|
|
|
|
})
|
|
|
|
|
export class TinyMCEComponent implements OnDestroy, AfterViewInit {
|
|
|
|
|
|
|
|
|
|
@Output() editorKeyup = new EventEmitter<any>();
|
|
|
|
|
|
|
|
|
|
editor: any;
|
|
|
|
|
|
|
|
|
|
constructor(private host: ElementRef) { }
|
|
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
|
|
tinymce.init({
|
|
|
|
|
target: this.host.nativeElement,
|
|
|
|
|
plugins: ['link', 'paste', 'table'],
|
|
|
|
|
skin_url: 'assets/skins/lightgray',
|
|
|
|
|
setup: editor => {
|
|
|
|
|
this.editor = editor;
|
|
|
|
|
editor.on('keyup', () => {
|
2017-05-06 15:35:15 +03:00
|
|
|
this.editorKeyup.emit(editor.getContent());
|
2017-05-06 14:52:41 +03:00
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
tinymce.remove(this.editor);
|
|
|
|
|
}
|
|
|
|
|
}
|