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
729 stars 200 forks source link

onkeyup event expecting incorrect type #532

Open timandella opened 10 months ago

timandella commented 10 months ago

We have the following line of code in our angular project (where this.editor is the FroalaEditor component)

this.editor.events.on('keyup', (e: Event) => this.onKeyup.emit(new ComponentEvent('keyup', null, e)), false);

This was building fine in 4.1.0, but in 4.1.1 we now get a typescript error

Argument of type '(e: Event) => void' is not assignable to parameter of type '(event: string, param1?: any, param2?: any) => boolean | void'.

However, I added a console.log(e) to the function like so:

this.editor.events.on(
    'keyup',
    (e: string) => {
        console.log(e);
        this.onKeyup.emit(new ComponentEvent('keyup', null));
    },
    false,
);

This then reveals that although it may be expecting a string, it is actually still being passed in an event.

{altKey: false, bubbles: true, cancelable: true, changedTouches: undefined, ctrlKey: false, …}