-
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
Prevent copying images from Word #558
Comments
Thank you for description this situation. I mark this issue as feature request. |
@simogeo I have a question. Of course CKEditor could have such config setting to simply block dropped image. I completely agree here but wouldn't it be better from your application point of view to save HTML pages as CLOB instead of TEXT or perhaps extract, change base64 image into real image on the server side, save it into DB and replace long string with URL to image? |
I think this issue is related to this one: #662 |
thanks @jswiderski for your interesting feedback and sorry for the delay - I was on leave. I agree regarding the DB settings. TEXT could be replaced by CLOB but in some (or many) cases, it would not follow comprehensible developer choice to store images as external files only. I like your proposal of extracting / converting to real image / replacing / and finally save into the DB but it is related to server-side and dependant on programmation language (for my part, i use PHP). Do you think, this should be handled by the word plugin itself or should it be externalised ? Anyway, I still think that the priority is to give the ability to dynamically remove images with plugin config settings. |
I think I wasn't clear enough in my last email. I have meant exactly what you have written - extracting base64 string, converting it to real image, saving the image on e.g. dedicated server, replacing base64string with an image tag with short url and finally saving HTML into DB should be handled by server-side code. |
Hi @jswiderski : any chance to have an option to block dropped image soon or not ? Just to know if I shoul implement some extra code such this myself. Thanks for your reply |
For others : CKEDITOR.on("instanceReady", function(evt) {
var editor = evt.editor;
editor.on("afterPasteFromWord", function(evt) {
// Clone the filter, so that it is based on current editor filter settings.
// Note that this function is added in CKE 4.7.3.
var filter = evt.editor.filter.clone(),
fragment = CKEDITOR.htmlParser.fragment.fromHtml( evt.data.dataValue ),
writer = new CKEDITOR.htmlParser.basicWriter();
// Disallow image copy/paste
filter.disallow('img' );
// Process, and overwrite evt.data.dataValue.
filter.applyTo( fragment );
fragment.writeHtml( writer );
evt.data.dataValue = writer.getHtml();
});
}); |
@simogeo from 4.8.0 we start embed images pasted from word. You should be able now to disallow on embedding images pasted from word with this config option: https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-pasteFromWord_inlineImages |
Hi @msamsel : great option. Thanks for implementing it ! |
No problem :) I hope this solution will cover your case. |
I think it would be better to have a setting to prevent inline images entirely. "Paste from Word" is only one of the many ways to insert a base64 image in CKEditor. I don't see a particular reason to prevent it with a "Paste from Word" action but allow it in another way... |
New feature regarding pastefromword (kind of bug)
Cpy-paste from Word embed images base64 encoded which may caused issue when saving content to database. For example, TEXT type in MySQL does not support more than 65,535 (2^16 – 1) characters.
See : https://stackoverflow.com/questions/2569838/mysql-data-type-text-erroring-data-too-long
Some ckeditor users have already created scripts to prevent this. For example here : http://www.isummation.com/blog/block-drag-drop-image-or-direct-image-paste-into-ckeditor-using-firefox/
I think this should be included in plugin itself as a config parameters.
Images could simply be dynamically removed or an alert should be send to users. Some options may be considered as well....
System information
The text was updated successfully, but these errors were encountered: