ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.79k stars 2.47k forks source link

Font color not preserved on paste #984

Open bplbplus opened 6 years ago

bplbplus commented 6 years ago

Are you reporting a feature request or a bug?

Bug

Provide detailed reproduction steps (if any)

  1. …GO TO https://www.w3schools.com/html/html_styles.asp

  2. … Copy the three items from that site which have red ,blue and black colors.

  3. … try to paste in CKeditor... Noticed styles or colors are not getting preserved...

Expected result

What is the expected result of the above steps? I expect the styles get preserved as is when copied from external website or any other place.

Note: Inline styles (e.g. <p style="color:red">Sth</p>) are not preserved during copy, even with ACF turned off.

msamsel commented 6 years ago

Hi, I was able to reproduce the problem.

mlewand commented 6 years ago

@msamsel please make sure to modify the titles. Making it all-caps doesn't bump the issue visibility, we're using GitHub reactions for that. Also in cases like this see if you can adjust the title to convey more value.

As for this issue, the reason why this is happening is because of paste filter. The formatting in your source document is formatted using p[style="color:#xyz"] which is stripped by the paste filter. Following config fixes the case:

config.extraAllowedContent = 'p{color}';
config.pasteFilter = null;

General Solution

An issue that I see here is that disabling ACF in the editor (as a last resort) should also cause pasteFilter to be disabled.

I mean, in this case user would be left with content like:

<p style="box-sizing: inherit; font-family: Verdana, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: 20px; color: red;">I am Red</p>

<p style="box-sizing: inherit; font-family: Verdana, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: 20px; color: blue;">I am Blue</p>

<p style="box-sizing: inherit; color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: 36px; margin: 12px 0px;">I am Big</p>

But this is what browser gives (Chrome).

OR there should be new filter option, that would allow setting pasteFilter to simply use editor's paste filter, which I like even more.

bplbplus commented 6 years ago

What about this scenrio...

https://www.w3schools.com/html/html_tables.asp

I see the paste is not AS is... I see no colors getting pasted for alternate rows and table border is almost not visible..

bplbplus commented 6 years ago

Also when we tried a 2 pages document from Word and try to copy and paste it looks like browser WAS IN FREEZE STATE and was not pasting immediately. IS there a separate configuration for this ???

jannakha commented 6 years ago

here's another bug for you, if you remove clipboard plugin from custom build - it will paste everything with ALL styles, even if I try to turn them off using pasteFilter etc. you should at least add to documentation that pasteFilter requires clipboard plugin, or it's a bug...

mlewand commented 6 years ago

@jannakha Adding this information is a really good idea as there are many config properties like that. I have reported a proper issue to the doc repo, feel free to follow it at ckeditor/ckeditor-docs#138

@bplbplus I think it's an unrelated issue, did the document happen to contain images in it? Processing images takes a substantial amount of time as this is a synchronous process, locking the browser UI thread. Currently there's no API for us to get around that (though I know Chrome is working on async clipboard access but this will take time). You can disable image inlining with config.pasteFromWord_inlineImages to help the performance.)

khvr000 commented 5 years ago

how to fix the same issue which is font color not preserving in ckEditor 5 ..