Opened 5 years ago

Closed 4 years ago

#11621 closed New Feature (fixed)

Less extreme paste as plain text - keep semantic but strip styles

Reported by: Piotrek Koszuliński Owned by: Artur Delura
Priority: Normal Milestone: CKEditor 4.5.0 Beta
Component: General Version:
Keywords: Cc:

Description (last modified by Piotrek Koszuliński)

In the current situation we have the ACF and forcePasteAsPlainText (forcePAPT). The ACF works perfectly unless following happen:

  1. Editor has so many features enabled (e.g. fonts and colors) that it does not filter pasted content as precisely as user would want.
  2. Developer decided to disable ACF because of complexity of content which is going to be edited.
  3. Developer makes a decision that paste content should be filtered more strictly than content being edited. In this case he can use forcePAPT, but this option is too strict for many cases. For example one may want to preserve semantic, but no styling. See e.g. #11619.

The proposed solution is to replace forcePAPT with a separate ACF instance, which can be configured independently from the main one. We could have some presets available, like "semantic" preset which would allow HTML tags and some semantic attributes and "plaintext" preset which would allow only paragraphs and line breaks.

Note: these presets do not have to be correlated with editor features like main ACF is, because main ACF would be still applied to the inserted content.

Change History (13)

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

Description: modified (diff)
Status: newconfirmed

comment:2 Changed 4 years ago by Artur Delura

Owner: set to Artur Delura
Status: confirmedassigned

comment:3 Changed 4 years ago by Artur Delura

Status: assignedreview

Now, there is a parallel CKEDITOR.filter instance defined in clipboard plugin. It's behaviour depends on various config options. They are listed in documentation. I introduced CKEDITOR.pasteFilter option.

I'm not sure whether this option is handled properly.

I'm also not sure what if we comment out second condition in this statement. Some tests fails but I wonder whether we should update them.

Anyway, changes in branch:t/11621b.

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

Milestone: CKEditor 4.5.0

comment:5 Changed 4 years ago by Jakub Ś

#12943 was marked as duplicate.

comment:6 Changed 4 years ago by Piotrek Koszuliński

I would love to review this ticket now, but unfortunately we need to check for #12806.

comment:7 Changed 4 years ago by Piotrek Koszuliński

Owner: changed from Artur Delura to Piotrek Koszuliński
Status: reviewassigned

comment:8 Changed 4 years ago by Piotrek Koszuliński

Status: assignedreview

Back on review after few changes. The whole filtering logic is pretty complex, so I needed to change some things. I tried to wrote a good API docs for this feature and reflected nearly all changes in the tests, so you'll find there the explanation.

comment:9 Changed 4 years ago by Artur Delura

I think we (I) forgot about one thing here:

  • Filters factory is an editor instance independent.
  • Filters factory creates specific filter once and then cache it.
  • We exposed pasteFilter as an property of editor instance which means user can modify it.

According to this, everything is fine until user work on just one editor instance. But if they create a new one - it will use cached filter mich might be previously modified.

comment:10 Changed 4 years ago by Piotrek Koszuliński

Status: reviewreview_failed

Absolutely right. I haven't thought about it first too.

comment:11 Changed 4 years ago by Artur Delura

Owner: changed from Piotrek Koszuliński to Artur Delura
Status: review_failedassigned

comment:12 Changed 4 years ago by Artur Delura

Status: assignedreview

Changes in branch:t/11621b.

comment:13 Changed 4 years ago by Piotrek Koszuliński

Resolution: fixed
Status: reviewclosed

Merged to major with git:e18dcf8 after few additional improvements.

One thing that I understood is that we don't really need a factory anymore. But because of the paste as plain text option (so a dynamically changing paste filter) the code without the factory couldn't be simplified that much (if any).

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy