I am trying to create a rich text editor on my application's modal by using tinymce instead of text area. But my HTML code can't be displayed as a text on rich text's content area. I am using Angular 2.
Any help would be appriciated
import { Component, AfterViewInit, OnDestroy, Input, Output, EventEmitter } from 'angular2/core';
import { RdComponent, RdLib } from '../../../../../node_modules/mulberry/core';
declare let tinymce: any;
@Component({
selector: 'mail-template',
template: `
<textarea style="height:15em"><p>{{ content }}</p></textarea>
`
})
export class MailTemplatesComponent extends RdComponent {
@Input("rd-model") model: string;
@Output() onEditorKeyup = new EventEmitter<any>();
public editor: any;
ngAfterViewInit() {
console.log(this.model);
tinymce.init({
selector: 'textarea',
setup: editor => {
this.editor = editor;
editor.on('keyup', () => {
const content = editor.getContent();
this.onEditorKeyup.emit(content);
})
}
});
}
ngOnDestroy() {
tinymce.remove(this.editor);
}
}
<div class="col-md-12">
<rd-field [rd-text]="translate('Mail İçeriği')"></rd-field>
<mail-template [(rd-model)]="data.MailContent" rd-height="25em"></mail-template>
</div>
I am using angular2-froala-wyswiyg
https://libraries.io/npm/angular2-froala-wyswiyg#usage
package.json (file) after the installation of module
Imports in your module
angular-cli.json(file) make changes in styles and scripts as shown below
In your component template