Opened 11 years ago
Closed 10 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 )
In the current situation we have the ACF and forcePasteAsPlainText (forcePAPT). The ACF works perfectly unless following happen:
- Editor has so many features enabled (e.g. fonts and colors) that it does not filter pasted content as precisely as user would want.
- Developer decided to disable ACF because of complexity of content which is going to be edited.
- 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 11 years ago by
Description: | modified (diff) |
---|---|
Status: | new → confirmed |
comment:2 Changed 10 years ago by
Owner: | set to Artur Delura |
---|---|
Status: | confirmed → assigned |
comment:3 Changed 10 years ago by
Status: | assigned → review |
---|
comment:4 Changed 10 years ago by
Milestone: | → CKEditor 4.5.0 |
---|
comment:6 Changed 10 years ago by
I would love to review this ticket now, but unfortunately we need to check for #12806.
comment:7 Changed 10 years ago by
Owner: | changed from Artur Delura to Piotrek Koszuliński |
---|---|
Status: | review → assigned |
comment:8 Changed 10 years ago by
Status: | assigned → review |
---|
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 10 years ago by
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 10 years ago by
Status: | review → review_failed |
---|
Absolutely right. I haven't thought about it first too.
comment:11 Changed 10 years ago by
Owner: | changed from Piotrek Koszuliński to Artur Delura |
---|---|
Status: | review_failed → assigned |
comment:13 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | review → closed |
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).
Now, there is a parallel
CKEDITOR.filter
instance defined inclipboard
plugin. It's behaviour depends on various config options. They are listed in documentation. I introducedCKEDITOR.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.