-
Notifications
You must be signed in to change notification settings - Fork 118
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
Labels
Comments
I've pasted your code but still copy-paste in CKeditor doesn't work. |
Need CKeditor compatibility to make this plugin perfect ! |
Up |
Up too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: