1

I am trying to use angular2-tinymce library in my project. I have successfully integrated tinymce in my module. But i could not trigger any callback for change event when any changes happened in the tinymce editor.

// in add-progress-note.module.ts file
@NgModule({
  declarations: [
    AddProgressNotePage,
  ],
  imports: [
    IonicPageModule.forChild(AddProgressNotePage),
    TinymceModule.withConfig({
      menubar: false,
      plugins: ['textcolor'],
      toolbar: 'forecolor',
      resize: false,
      statusbar: false
    })
  ]
})

// in add-progress-note.html file           
<ion-row class="note-editor" id="noteArea">
            <app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (change)="onChangeNote()"></app-tinymce>
</ion-row>

// in add-progress-note.ts file
  onChangeNote(): void {
    console.log(this.noteText);
  }

My onChangeNote did not fire.

How to trigger a callback event for any change event in tinymce editor?

Setu Kumar Basak
  • 11,460
  • 9
  • 53
  • 85

2 Answers2

6

If you are using ngModel, you can easily use ngModelChange instead of change.

<app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (ngModelChange)="onChangeNote()"></app-tinymce>
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • can i append text where the cursor is using this approach in tinymce editor? – Setu Kumar Basak Feb 13 '18 at 12:14
  • 1
    does https://stackoverflow.com/questions/38521392/using-tinymce-in-angular2-project and https://stackoverflow.com/questions/13393892/inserting-text-in-tinymce-editor-where-the-cursor-is help? – Suraj Rao Feb 13 '18 at 12:28
0

Ok, i use that and it's work, thanks Suraj Rao

html :

<editor [(ngModel)]="html" [init]="init" (ngModelChange)="removeColor($event)"></editor>

TS :

    public removeColor(value) {
        this.html = value.replace(/color(.*?);/i, '');;
    }
Ismail
  • 1,188
  • 13
  • 31