tinymce-react
tinymce-react copied to clipboard
Events to handle with errors
Is your feature request related to a problem? Please describe. The current version of tinymce-react hasn't support for some events, such as events to handle with errors:
- SkinLoadError
- ThemeLoadError
- ModelLoadError
- PluginLoadError
- IconsLoadError
- LanguageLoadError
Describe the solution you'd like I would like to handle with errors following the TinyMCE documentation: https://www.tiny.cloud/docs/tinymce/6/events/#editor-core-events
ScriptLoader I guess it's important to have a callback error when loading the TinyMCE script, so it's possible to show an error message when this happens. Currently the ScriptLoader file only accepts a success callback: https://github.com/tinymce/tinymce-react/blob/main/src/main/ts/ScriptLoader.ts#L47
However tinymce-react hasn't a onScriptsLoaded prop to support the ScriptsLoaded event from TinyMCE. So in this case would be interesting add support for the following props in Editor component
- onScriptsLoaded
- onScriptsLoadError
Describe alternatives you've considered
I've resolved using the setup from the init prop.
const options = {
setup: (editor) => {
editor.on('ScriptsLoaded', () => {
console.log('Scripts loaded');
});
editor.on('SkinLoadError', () => {
console.log('Skin load error');
});
editor.on('ThemeLoadError', () => {
console.log('Theme load error');
});
}
};
<Editor
apiKey="no-api-key"
init={options}
/>
NOTE: I didn't find a workaround to handle with error when loading the TinyMCE script.
This is a great idea but it can only be done by the TinyMCE editor team as tinymce-react is just a wrapper. I will transfer the issue to them.
Apologies. I've just realized that I misread this. Transferring back.
Yes we should be able to expose those events. I'll put together a PR.
Ref: INT-2871, INT-2872
Note: adding events for the script loading (INT-2872) will require rewriting the script loader so that'll have to wait for scheduling.
Note: adding events for the script loading (INT-2872) will require rewriting the script loader so that'll have to wait for scheduling.
No worries @tiny-james , thanks for your attention.
Ref: INT-2893
In the 4.3.0 release I have added the event props onScriptsLoad and onScriptsLoadError which will be called when no tinymce global is present and it has to add a script tag to load TinyMCE.