citizenos / ep_image_upload

Add images to etherpad and upload them to Amazon S3
Other
9 stars 16 forks source link

ctrl v of an image should create a new file if filesystem is being used #55

Open JohnMcLear opened 2 years ago

JohnMcLear commented 2 years ago

If "set to write to filesystem" is enabled ctrl v of an image should create a new file not write base64 to the pad.

I'd guess we'd need to catch paste events and if it includes an image do an upload to the filesystem instead of writing the contents to the pad.

rhansen commented 2 years ago

I think the right place to fix this is in the collectContentImage hook: If lineAttributes.img is a URL that does not match the expected form then upload the image (like the toolbar button does) and use the resulting URL instead. One problem with this approach: Like many client-side hooks, the collectContentImage hook is executed synchronously. We need to change Etherpad core to execute it asynchronously.

alexeisenhart commented 2 years ago

Is there any way to disable CTRL+V until this issue is resolved? Pasting images is the only way that my team is inserting images at this point, but disabling the feature and forcing them to upload an image file would help them avoid shooting themselves in the foot.

webzwo0i commented 2 years ago

Another problem: Pasting does not respect the maxFileSize limitation, so it's possible to insert arbitrary long images, regardless of the limit. (Only limited by Socket.io's max http buffer setting)

JohnMcLear commented 2 years ago

@webzwo0i yikes.

webzwo0i commented 2 years ago

https://github.com/citizenos/ep_image_upload/pull/56 tries to solve this. Any feedback welcome