-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clipboard plugin's handling of images should be configurable - will break other plugins by default #4874
Comments
I can confirm the issue. I can think of two possible solutions:
Probably adding config variable would be less invasive solution. |
This will allow 3rd party plugins to handle images being pasted.
Thanks for confirming @Comandeer 👍😊 I took the liberty to take a go at it. I agree with the suggested approach; adding an option to control the behaviour. Pull request: #4896 The new option is called "handleImagePasting" (boolean). Example
|
This will allow 3rd party plugins to handle images being pasted.
Closed in #4896 |
When pasting an image in CKEditor, the image was displayed twice. This behaviour is due to the new paste-as-base64 feature implemented in CKE, which conflict with existing plugins implementing the same feature. To solve it, add `clipboard_handleImages` option to the CKE configuration object, which disables its own image-pasting feature. See ckeditor/ckeditor4#4874 for the corresponding issue on CKEditor’s repository. /cc @jerome @Romain @tomo /reviewed-by @jerome /reviewed-on https://lab.nexedi.com/nexedi/erp5/-/merge_requests/1951
When pasting an image in CKEditor, the image was displayed twice. This behaviour is due to the new paste-as-base64 feature implemented in CKE, which conflict with existing plugins implementing the same feature. To solve it, add `clipboard_handleImages` option to the CKE configuration object, which disables its own image-pasting feature. See ckeditor/ckeditor4#4874 for the corresponding issue on CKEditor’s repository. /cc @jerome @Romain @tomo /reviewed-by @jerome /reviewed-on https://lab.nexedi.com/nexedi/erp5/-/merge_requests/1951
Type of report
Bug
Provide detailed reproduction steps (if any)
In june 2021 the built-in clipboard plugin was extended to offer native support for pasting images as base64.
But since there is already multiple plugins out there offering similar functionality (some with additional features), pasting an image will now result in two images being inserted.
Code causing the problem starts here:
ckeditor4/plugins/clipboard/plugin.js
Line 149 in 70649e5
While native support for pasting images is wonderful, the current implementation seems to break support for custom image paste plugins as there is no way to prevent the clipboard event from inserting the image too, without stopping the event chain. At least not exposed as public API. One can hack it using
CKEDITOR.plugins.clipboard.isCustomDataTypesSupported = false;
Furthermore, base64 images can be huge and it may severely hurt performance, especially if using the change event to continuously validate data or push changes to application state - although this use case is discouraged:
https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-change
In addition, the clipboard event even stops the event chain once the image has been processed, preventing other plugins registered later from receiving the image data.
ckeditor4/plugins/clipboard/plugin.js
Line 199 in 70649e5
Why would you even use a custom image plugin to handle image pasting?
To automatically upload images immediately. To temporarily store images in blob storage rather than using base64, which greatly increases performance when working with large documents (we use this). To optimize/modify images before inserting them. To support pasting of multiple images at once (we use this). There could be many reasons.
A small sample has been put together which lets the user switch between CKEditor 4.16.1 and the current Major, to test image pasting in both of them.
Download: https://codemagic.dk/CKEditorDemo.zip
Now test with the current major.
Expected result
Clipboard plugin should allow for other plugins to handle image pasting
Actual result
Clipboard plugin causes duplicate images
Other details
The text was updated successfully, but these errors were encountered: