froala / angular-froala-wysiwyg

Angular 4, 5, 6, 7, 8 and 9 plugin for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
735 stars 202 forks source link

textColor (or other commands event) doesn't fire #497

Closed CiordasFlorentina closed 2 years ago

CiordasFlorentina commented 2 years ago

Hello, I can't seem to get any event from commands to fire. I tried adding them to events object and they never get called.

public options: any = { toolbarButtons: { moreText: { buttons: ['bold', 'italic', 'underline', 'textColor', 'clearFormatting'] }, moreParagraph: { buttons: ['paragraphFormat', 'formatOLSimple', 'formatUL'] }, moreRich: { buttons: ['insertLink', 'insertTable'] }, moreMisc: { buttons: ['undo', 'redo', 'print', 'getPDF'] } }, events: { 'commands.textColor': (cmd, param1, param2) => { console.log(cmd, param1, param2); }, textColor: (cmd, param1, param2) => { console.log(cmd, param1, param2); } } };

I also tried to set them like this and still nothing: this.editor.events.on('commands.bold', function(event:any) { console.log('bold triggered'); });

Could somebody tell me where I'm doing things wrong? Thank you. (I'm using version 4.0.10)

CiordasFlorentina commented 2 years ago

Sorry, my mistake. If anyone is struggling with the same thing, it should be used like this: events: { 'commands.before': function(cmd,p1,p2) { if(cmd === "textColor"){ //event code } } }