Skip to content
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

Compatibility witk CKEditor plugin #32

Open
LuisSerrano opened this issue Mar 7, 2014 · 4 comments
Open

Compatibility witk CKEditor plugin #32

LuisSerrano opened this issue Mar 7, 2014 · 4 comments

Comments

@LuisSerrano
Copy link

Please could you make this change (add compatibility with ckeditor plugin)

Inside clipboard_image_paste.js, add the function:

// Add createObjectURL function
function createObjectURL ( file ) {
if ( window.webkitURL ) {
return window.webkitURL.createObjectURL( file );
} else if ( window.URL && window.URL.createObjectURL ) {
return window.URL.createObjectURL( file );
} else {
return null;
}
};

And use the function insdide pasteHandler:

// Handle paste events
function pasteHandler(e) {
// We need to check if event.clipboardData is supported (Chrome)
if (hasClipboard && e.clipboardData) {
// Get the items from the clipboard
var items = e.clipboardData.items;
if (!items)
alert(cbImagePaste.cbp_txt_empty_cb);
else {
// Loop through all items, looking for any kind of image
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") !== -1) {
// We need to represent the image as a file,
var blob = items[i].getAsFile();
// and use a URL or webkitURL (whichever is available to the browser)
// to create a temporary URL to the object
//***********************************************************
var source = createObjectURL(blob);
//***********************************************************
// The URL can then be used as the source of an image
createImage(source);
return;
}
}
alert(cbImagePaste.cbp_txt_no_image_cb);
}
// If we can't handle clipboard data directly (Firefox),
// we need to read what was pasted from the contenteditable element
} else {
// This is a cheap trick to make sure we read the data
// AFTER it has been inserted.
setTimeout(checkInput, 1);
}
};

This patch works with textile and ckeditor

@zawadaa
Copy link

zawadaa commented Apr 23, 2014

I've pasted your code but still copy-paste in CKeditor doesn't work.
When I'm editing issue then I see a pasted image but after save, image doesn't show in issue.

@LeDistordu
Copy link

Need CKeditor compatibility to make this plugin perfect !

@msneet
Copy link

msneet commented Aug 11, 2017

Up

@cg200776
Copy link

Up too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants