tinymce-react icon indicating copy to clipboard operation
tinymce-react copied to clipboard

Events to handle with errors

Open felipeloge opened this issue 3 years ago • 7 comments

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.

felipeloge avatar May 02 '22 15:05 felipeloge

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.

tiny-james avatar May 02 '22 23:05 tiny-james

Apologies. I've just realized that I misread this. Transferring back.

tiny-james avatar May 02 '22 23:05 tiny-james

Yes we should be able to expose those events. I'll put together a PR.

tiny-james avatar May 02 '22 23:05 tiny-james

Ref: INT-2871, INT-2872

tiny-james avatar May 03 '22 00:05 tiny-james

Note: adding events for the script loading (INT-2872) will require rewriting the script loader so that'll have to wait for scheduling.

tiny-james avatar May 03 '22 00:05 tiny-james

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.

felipeloge avatar May 04 '22 23:05 felipeloge

Ref: INT-2893

exalate-issue-sync[bot] avatar May 18 '22 06:05 exalate-issue-sync[bot]

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.

tiny-james avatar Jan 18 '23 02:01 tiny-james