tinymce / tinymce-blazor

Blazor integration
MIT License
45 stars 13 forks source link

Unable to set config values where javascript function is expected. #60

Closed jrees closed 1 year ago

jrees commented 1 year ago

I'm trying to set the value of 'images_upload_handler' within the editor configuration dictionary<string, object> but it's unclear to me how I can do this, or perhaps if I can do this? (I'm trying to do this within a Blazor WebAssembly client app)

The js function is going to invoke a C# method similar to the advice given in this issue https://github.com/tinymce/tinymce-blazor/issues/19

I've tried injecting IJSRuntime and using this to InvokeVoidAsync my javascript function, however, I cannot use this to set the value as it's a lambda function that invokes the js function rather than the function itself.

Is it perhaps possible to set JsConfSrc to point to a js file that contains a config and also the function?

Any help or guidance would be greatly appreciated, thanks!

exalate-issue-sync[bot] commented 1 year ago

Ref: INT-3133

jscasca commented 1 year ago

Unfortunately, everything that requires JS needs to go over the JS side of the wrapper. You will need to pass the functions as JS code and load those functions via the JsConfSrc. Then JsConfSrc will look for a JS object attached to the window and pass that as the initial config. You can add your functions here.

If you need to call C# code, you can use you own interop functions as long as they are attached to that window object.

Hope this helps!

jrees commented 1 year ago

Many thanks @jscasca this has helped and is working now!