mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-27 12:48:49 +01:00
34 lines
777 B
TypeScript
34 lines
777 B
TypeScript
|
|
import {Component, OnDestroy, AfterViewInit, Output, EventEmitter, ElementRef} from '@angular/core';
|
||
|
|
|
||
|
|
@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', () => {
|
||
|
|
let content = editor.getContent();
|
||
|
|
this.editorKeyup.emit(content);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
ngOnDestroy() {
|
||
|
|
tinymce.remove(this.editor);
|
||
|
|
}
|
||
|
|
}
|