-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
How to disable image pasting? #407
Comments
Add the "remove format pasted" option:
|
That will prevent images from being pasted in, but it also prevents bold, italics, etc. I'm still looking for a solution to this problem... is there someway to blacklist or whitelist tags? |
You need to create a simple plugin. You can give a "pasteHandler" in options: https://github.com/Alex-D/Trumbowyg/blob/develop/src/trumbowyg.js#L377 Example of use: https://github.com/Alex-D/Trumbowyg/blob/develop/plugins/pasteimage/trumbowyg.pasteimage.js There is no option for white/blacklisted elements because it should be managed in backend or in a plugin. |
Ok, that sounds reasonable, thank you. |
@hurricane766 have you find a way to disable image pasting ? |
@oza75 This was a while ago, but I believe we did as Alex-D suggested. In the end we moved away from Trumbowyg to a different editor, so I can't say for sure if this still works. |
What other editor ? I so far couldnt find better WYSIWYG editor for free |
I believe we used ckeditor (4) at the time. It looks like v5 might still offer the core features for free. |
(function ($) {
'use strict';
$.extend(true, $.trumbowyg, {
plugins: {
preventImagePaste: {
init: function (trumbowyg) {
trumbowyg.pasteHandlers.push(function (pasteEvent) {
try {
var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items,
mustPreventDefault = false,
reader;
for (var i = items.length - 1; i >= 0; i -= 1) {
if (items[i].type.match(/^image\//)) {
mustPreventDefault = true;
}
}
if (mustPreventDefault) {
pasteEvent.stopPropagation();
pasteEvent.preventDefault();
}
} catch (c) {
}
});
}
}
}
});
})(jQuery); |
I just want to have a text editor without the ability to embed images. Is it possible to disable image pasting?
The text was updated successfully, but these errors were encountered: