tinymce / tinymce-react

Offical TinyMCE React component
MIT License
937 stars 152 forks source link

Useless Image reload triggered at keyup event, when cache is disabled #500

Open enoh-barbu opened 4 months ago

enoh-barbu commented 4 months ago

Same bug described as here https://github.com/tinymce/tinymce-angular/issues/138

https://stackblitz.com/edit/vitejs-vite-zwyxe1?file=src%2FApp.tsx

image image

danoaky-tiny commented 4 months ago

Could you please provide a code sandbox or a code snippet? I've tried replicating with the React integration, but I've only found this problem when deleting a selection of text, nothing with keyup events. And this can also be replicated in core TinyMCE, see this TinyMCE fiddle. In which case this would be an issue to do with core and not the React integration.

enoh-barbu commented 4 months ago

@danoaky-tiny I have updated my description, and after some debugging I found out that the bug can be reproduced if:

  1. codesample plugin is used
  2. onEditorChange is used
  3. disable cache setting in dev tookls is checked

Just go ahead on that example, paste/insert an image, and start typing in the editor

danoaky-tiny commented 3 months ago

Internal ref: INT-3288

danoaky-tiny commented 3 months ago

The problem is there's a required call to editor.getContent within onEditorChange, in order to supply the content for the callback. This is where the setup you provided will cause an image refetch.

If applicable, you could opt to use the editor as an uncontrolled component and call getContent when you need it.

Another solution that could work (depending on your use case) is to have something like a changeEvents prop added. This would be used to override the default list of events that onEditorChange fires on. So to fix this particular case, you'd want to not fire on the 'input' event.

Otherwise this would need to be addressed as a core TinyMCE issue. As it's replicable in a TinyMCE fiddle and in the Angular integration too, see: https://codesandbox.io/p/sandbox/int-3288-539h9p

enoh-barbu commented 3 months ago

For now I just removed codesample plugin, as I don't use it at all

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity. Respond with a comment or this will be closed in 7 days.

enoh-barbu commented 2 months ago

Not sure what prio has this one, but I think it's still an issue which might need some attention, if possible