Opened 3 years ago

Last modified 2 years ago

#13753 confirmed Bug

Chrome: Text Style lost when we paste content after refreshing the page

Reported by: Satya Minnekanti Owned by:
Priority: Normal Milestone:
Component: General Version: 4.5.0
Keywords: IBM Cc: chrisgui, Irina


Steps to reproduce

  1. Open Nightly build, type few paragraphs of text.
  2. Apply some format(Font: Georgia, size: 36) to a paragraph
  3. Copy the Paragraph.
  4. Refresh the page
  5. Keep curosor in a paragraph & paste content using Ctrl + V

Expected result

Pasted text has all the formatting that was applied to it. Actual result

Actual result

All the formatting applied to pasted text is removed. This is working in 4.4.8

Same issue happens with Indentation, Alignment etc.

Change History (5)

comment:1 Changed 3 years ago by Piotrek Koszuliński

Status: newconfirmed

That's caused by the paste filter:

This setting defaults to 'semantic-content' in Chrome, Opera and Safari (all Blink and Webkit based browsers) due to messy HTML which these browsers keep in the clipboard. In other browsers it defaults to null.

The paste filter is only applied to external content – the content that wasn't copied from any CKEditor. The reason is that a custom copy and cut handlers which we implemented put a clean content into the clipboard, when copying from an editor. However, when a content is copied from outside the editor we cannot handle it and unfortunately Chrome and Safari put an awful mess into the clipboard.

In order to be able to tell whether a content comes from the editor we add a custom data type. On paste we check for this data type and I guess that somehow the value of this data changes with page load. I don't think this is necessary, as it is enough for us to know that this data type was set. The only doubt I have is.... whether this data type is put into the native clipboard. If it's not (and it looks as if it isn't), then we have a problem...

However, we had problem already because other browsers than Chrome don't support custom data types. So instead I would propose adding some <meta> tag to the HTML that we put to the clipboard. I'm not sure though, what we can do if the HTML type wasn't set ;/

PS. It may happen that we won't be able to change this (data transfer type recoginition) and then the only solution will be to disable the paste filter.

comment:2 Changed 3 years ago by Piotrek Koszuliński

A bit different case: #13752.

comment:3 Changed 3 years ago by Piotrek Koszuliński

Another related issue: #13751.

comment:4 Changed 3 years ago by Piotr Jasiun

Data is stored in the system clipboard on Chrome so this seems to be enough: The problem is because the paste is recognized as external and semantic-content filter is applied, as @Reinmar said.

The solution does not work on Firefox, where we can not set custom data types (like cke/id), but also an issue does not occur there, because there is no paste filter. And we can do nothing on IE where we can set only text data.

Saving ID as <meta> data could fix the issue not Firefox, but it may be not that easy as we expect, because browsers like to modify data we put as the text/html. It may need a research and may be a reason of future issues, so I think the change should be minimal.

Last edited 3 years ago by Piotr Jasiun (previous) (diff)

comment:5 Changed 2 years ago by Jakub Ś

It turns out we have quite a few issues with pasting and they all may be related as they all can be reproduced from 4.5.0:
Styles Stripping: #13860, #13926, #14250, #14358
Styles stripping on Chrome in various test cases: #14921, #14593, #13753, #13751, #16454
ForcePasteAsPlainText pastes formatted HTML with Ctrl+V: #13969
Weird event pasting relation (not sure): #13763
White spaces not preserved: #14614
Problem with pasting in LibreOffice: #14622 (we do not support it but I have added this issue because general solution might also bring back old behaviour).

Last edited 2 years ago by Jakub Ś (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy