django-tinymce
django-tinymce copied to clipboard
images_upload_handler doesn't work for TinyMCE 6
As you may know, the feature has changed a bit in version 6.
Kindly check the comment below for details.
Thanks to @rsevs3.
The outcome is -
- If using image_upload_url, the code doesn't embed the csrf token in the request headers so the corresponding django view has to be csrf exempted, which is insecure.
- If using images_upload_handler, the new const wouldn't be called.
Just some additional information for this, the way that images_upload_handler works is different.
See: https://www.tiny.cloud/docs/tinymce/6/image/#images_upload_handler
In the new example code, example_image_upload_handler is declared as a const, so is not a property of the window object.
See for more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const#description
I am fairly new to coding and have virtually no JS experience, so I do no know how to rewrite this to make it work. I have played around with putting the example code into init_tinymce.js and modifying to suit, which works, but isn't easily user changeable, so not a good solution. I have spent all day trying to find a nice solution, but it is beyond my skill levels currently.
Originally posted by @rsevs3 in https://github.com/jazzband/django-tinymce/issues/426#issuecomment-1472369152