Javascript – Copying and pasting into CKEditor from MS Word

ckeditorhtmljavascriptms-word

I have a word document consisting of just two words "Hello to". This is actually a simplified version of the original document. The font-family for this text is Calibri (body). I don't notice any difference in formatting between these two words in the word document.

When attempting to copy and paste this text into ckeditor, the font-family of "Hello" is correctly preserved as Calibri, but the font-family of the word "to" in incorrectly changed to Arial. I don't understand why it doesn't also preserve the font-family of the "to" text.

Here is my config.js:

CKEDITOR.editorConfig = function( config ) {    
    config.pasteFromWordRemoveStyles = false;
    config.pasteFromWordRemoveFontStyles = false;
};

Here is the source HTML in ckeditor upon pasting the text:

<p><span style="font-size:10pt"><span style="font-family:calibri">Hello </span>to</span></p>

The word document is available to download from the following link:

http://s000.tinyupload.com/?file_id=00848535251570855827

The above behaviour is evident using IE 11. Please can someone assist with this?

Best Solution

IMHO, the below with some modification will do.

config.forcePasteAsPlainText = false;
config.pasteFromWordRemoveFontStyles = false;
config.pasteFromWordRemoveStyles = false;
config.allowedContent = true;
config.extraAllowedContent = 'p(mso*,Normal)';
config.pasteFilter = null;
Related Question