4

I am using ckeditor in my application. The application is built on asp.net MVC.
It is working fine.
The issue is when I copy the data from other website and pasting into ck editor the format is getting lost. Like color, underline, bold, etc.

It is working fine from if I copy the content from Microsoft Word.
I did not find any reference whether it is supported or not. Some Links which I visited

https://ckeditor.com/docs/ckeditor4/latest/guide/dev_allowed_content_rules.html

Edit 1

Below is the code which I am using

$(document).ready(function () {        
CKEDITOR.replace("myckeditor",
{
    height: 450,
    bodyClass: 'document-editor',
    contentsCss: [CKEDITOR.basePath + 'contents.css', CKEDITOR.basePath + 'pastefromword.css'],
    extraPlugins: 'pastefromword,tabletools,tableresize,tableselection,colordialog',
    removePlugins: 'elementspath,wsc,scayt',
});
CKEDITOR.config.scayt_sLang = "en_US";
CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
});

edit 1

CKEDITOR.config.pasteFromWordRemoveFontStyles = false;
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.extraAllowedContent = '*(*);*{*}';

above are the additional configuration which I have done in CK editor.

I have created a source file from where I want to copy and past data.

<html>
<head>
    <title>
        this is a test page
    </title>
</head>
<body>
    <div>
    this is a normal text
    <div>
    <div style="color:red;">
        this is red text
    </div>
<body>
</html>

when I am copying the data from browsers like IE and Firefox the color to is copied in the CK editor.
But in Chrome Browser it not proper if it is removing the style attribute from the div.
There are some other function in the code if it is required I can show you that as well.

Similar question which did't helped.
CKEditor strips inline attributes
CKEditor automatically strips classes from div

4
  • 1
    You need to show us your code or we cannot help.
    – DavidG
    May 30, 2019 at 12:47
  • @DavidG I have update my question with the script. May 30, 2019 at 13:04
  • Have you tried cutting down your config here? For example, just the width and remove the rest of the code?
    – DavidG
    May 30, 2019 at 13:19
  • @DavidG I have update my question please help. Jun 5, 2019 at 5:09

1 Answer 1

6

I don't know weather it is correct solution or not but below code worked for me

config.pasteFilter = null;

References:
http://origin-docs.ckeditor.com/ckeditor4/docs/?print=/api/CKEDITOR.config

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.