Reputation: 1
I am copying a Word document and pasting in the CKEditor, it changes the font style and size and shows anchor tags by default.
Upvotes: 0
Views: 1249
Reputation: 79
I had this issue when using ck editor 4.21 with online builder. First issue was i could not get the dialog to show when i clicked paste from word. It gave the following error when i click the button.
"Your browser doesn't allow you to paste this way. Press Ctrl+V to paste"
The following block of code solved it .
CKEDITOR.on("instanceReady", function(event) {
event.editor.on("beforeCommandExec", function(event) {
// Show the paste dialog for the paste buttons and right-click paste
if (event.data.name == "paste") {
event.editor._.forcePasteDialog = true;
}
// Don't show the paste dialog for Ctrl+Shift+V
if (event.data.name == "pastetext" && event.data.commandData.from == "keystrokeHandler") {
event.cancel();
}
})
});
Then after pasting in the dialog and clicking ok the ckeditor does not retain the word document styling . The following block of code solved it
CKEDITOR.replace( 'editor',{
allowedContent: true,
contentsCss: [
'http://cdn.ckeditor.com/4.21.0/full-all/contents.css',
'https://ckeditor.com/docs/ckeditor4/4.21.0/examples/https://ckeditor.com/docs/ckeditor4/4.21.0/examples/assets/css/pastefromword.css'
],
bodyClass: 'document-editor'
});
Hope this helps someone.
Upvotes: 0
Reputation: 1
On the CKEditor site they list that the plugin Paste From Word is standard from 4.6 and up (http://sdk.ckeditor.com/samples/pastefromword.html) and that could be causing your problem. Tried excluding the plugin 'pastefromword' and it seems to have helped. Haven't tested in all browsers, but it could do the trick.
Would post as comment, but I don't have the reputation to comment :(
Upvotes: 0