ckeditor5-angular icon indicating copy to clipboard operation
ckeditor5-angular copied to clipboard

CKEditor 5 extra plugin passed as a function doesn't work in Angular 10

Open Alexander091 opened this issue 3 years ago • 5 comments

Hi! I am trying to add custom upload adapter to my ckeditor using an example: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/configuration.html But I am getting an error:

ckeditor.js:5 plugincollection-load Object 
Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-plugincollection-load
r @ ckeditor.js:5

core.js:4442 ERROR Error: Uncaught (in promise): TypeError: t is not a constructor
TypeError: t is not a constructor
    at ckeditor.js:5
    at new ZoneAwarePromise (zone-evergreen.js:960)
    at ckeditor.js:5
    at l (ckeditor.js:5)
    at Array.map (<anonymous>)
    at Cn.init (ckeditor.js:5)
    at Rb.initPlugins (ckeditor.js:5)
    at ckeditor.js:5
    at new ZoneAwarePromise (zone-evergreen.js:960)
    at Function.create (ckeditor.js:5)
    at resolvePromise (zone-evergreen.js:798)
    at resolvePromise (zone-evergreen.js:750)
    at zone-evergreen.js:860
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:27492)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at drainMicroTaskQueue (zone-evergreen.js:569)

see source code: https://github.com/Alexander091/angular-ckeditor5

That happened when I upgraded to Angular 10.

Thank you!

Alexander091 avatar Nov 09 '20 16:11 Alexander091

Hi @Alexander091,

I'm not sure why it happens. I guess that it might be again a problem with the Zone.js as there's a lot of Zone.js mess in the stack trace. 

Could you test if it works when your plugin would implement the Plugin interface API instead of being a function?

ma2ciek avatar Nov 09 '20 17:11 ma2ciek

Hi @ma2ciek

Thank you for the advice. Indeed that works. I use original CKFinderUploadAdapter as an example I only changed the implementation of UploadAdapter

If plugin as function doesn't work anymore, could you please update docs, at least. But that feature very convenient and helps to avoid any changes in my custom editor.

Alexander091 avatar Nov 10 '20 07:11 Alexander091

It seems to be a bug, so I'd rather fix it than describe this exception in docs. But in 99% it seems to be on the Angular's side.

ma2ciek avatar Nov 10 '20 08:11 ma2ciek

I've just updated from Angular 7 to 9, I had the mentions plugin working with customized output. Since updating, I am getting this error, I haven't been able to find a fix for this.

Simon245 avatar Nov 04 '21 15:11 Simon245

I'm using Mithril.js (not Angular) and did a few changes to my dependencies and toolchain: I migrated from Parcel to Webpack, upgraded my version of typescript and did other things that I'm too lazy to look up. It stopped working after my changes with this error.

I fixed it by using a function instead of an arrow function.

I got from ( editor:any ) => { ... } to function ( editor:any ) { ... } and everything is back to normal.

Hope it helps

pieroxy avatar Sep 08 '22 16:09 pieroxy

I'm using Mithril.js (not Angular) and did a few changes to my dependencies and toolchain: I migrated from Parcel to Webpack, upgraded my version of typescript and did other things that I'm too lazy to look up. It stopped working after my changes with this error.

I fixed it by using a function instead of an arrow function.

I got from ( editor:any ) => { ... } to function ( editor:any ) { ... } and everything is back to normal.

Hope it helps

works

milon27 avatar Nov 23 '22 12:11 milon27

The latest CKEditor 5 Angular component does not support Angular 10. Hence, I am closing the issue. If you can still reproduce it, please, report a new issue, and we will look at that.

pomek avatar Jul 21 '23 06:07 pomek

@pomek It's not Angular specific. There's a report in Mithril and I ran into it using Vue.

It appears that the extraPlugins functions are expected to be able to bind to a different this. However, this is an incorrect assumption in the case of arrow functions, which cannot be re-binded.

raineorshine avatar Jul 21 '23 13:07 raineorshine

cc: @Witoso ☝️

pomek avatar Jul 21 '23 13:07 pomek