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

images_upload_handler doesn't work for TinyMCE 6

Open justinqian42 opened this issue 3 months ago • 1 comments

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 -

  1. 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.
  2. 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

justinqian42 avatar Apr 17 '24 01:04 justinqian42