#16847 closed New Feature (fixed)
Inline styles from clipboard data transfer when pasting from Word
Reported by: | Marek Lewandowski | Owned by: | Tomasz Jakut |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.7.0 |
Component: | Plugin : Paste from Word | Version: | 4.7.0 |
Keywords: | Cc: |
Description (last modified by )
While serializing to HTML, Word inlines styles to some elements, while leaving classes in others.
A style
element that contains all the styles for a given selector is put in html > head
element of text/html
clipboard which is currently not pasted into CKEditor.
What we need to do here is to make sure that we check text/html
dataTransfer to check for these style
elements, and inline them into matched elements.
One thing to keep in mind that we don't want to inline mso-
specific styles. At the end it's fine for us to inline even unknown css, as it will get stripped by ACF after processing.
Change History (9)
comment:1 Changed 8 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 8 years ago by
Owner: | set to Tomasz Jakut |
---|---|
Status: | confirmed → assigned |
comment:3 Changed 8 years ago by
comment:4 Changed 8 years ago by
Some early review feedback:
- This condition could be merged into one.
- CKEDITOR.plugins.pastefromword.inlineStyles is missing API docs.
- Actually word365 (provided in fixtures) is not an accurate version, AFAIR for our PC currently it's word2013. You'll find this information in about option.
- text/html datatransfer content in fixtures looks good, but we need to reorganize it.
As you see the datatransfer is exact same for every browser and it makes sense, because it's Word which is setting the clipboard, and browser has only to provide API to access it.
- Change
tests/plugins/pastefromword/manual/inlinestyles.md
manual test explicitly be based on provided docx fixture and reference it's path in the manual test description. Also provide precise repro steps, use this missing Verdana font paragraph which is a subject of issue discussion.
- There's some garbage leaked to the end of pasted content, when pasting in Chrome from
InlineStyles.docx
:
Surprisingly I can't repro it on Firefox.
From what I have seen, this garbage is added by the Chrome itself, even though clipboard held by OS is fine - so it's clearly a Chrome fault. You can see it in
tests/plugins/pastefromword/generated/_fixtures/InlineStyles/word2013/chrome.html
.
It's even weirder because it occurs... randomly :D I saw that it happens if I had a lot of plain text in clipboard, and copied content from Word after this? Can't tell exactly.
I've also did minor docs updates, changes were pushed to the branch.
- docs updates,
- added docx fixtures generated on Windows,
- added liststyle, htmlwriter plugins to the manual test
- without liststyle Roman numbering were not preserved,
- htmlwriter plugin for source button output readability.
comment:5 Changed 8 years ago by
Status: | assigned → review |
---|
The inliner is implemented and enabled in browsers that support custom data types via dataTransfer. Also tests are updated. Pushed to branch:t/16847-nbsp.
comment:6 Changed 8 years ago by
Status: | review → review_failed |
---|
Good job! We're almost there!
- This function is not necessary: https://github.com/cksource/ckeditor-dev/blob/6699748/plugins/pastefromword/filter/default.js#L737-L739 it should be inlined.
- You have moved functions into
CKEDITOR.plugins.pastefromword.styles
while it was originally requested to put it in into dedicated ns:CKEDITOR.plugins.pastefromword.styles.inliner
. All 3 of these methods are tightly dependent on each other, so it make sense to put them together, while not generic enough let it sit directly instyle
namespace. Also remember that function names should be simplified. - Test's ignore check reuse same condition as the actual code.
Pushed a minor change to the branch.
comment:7 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | review_failed → closed |
LGTM merged to major with git:e8afc33cd.
comment:8 Changed 8 years ago by
Description: | modified (diff) |
---|
comment:9 Changed 8 years ago by
Summary: | Pick styles from clipboard data transfer when pasting from Word → Inline styles from clipboard data transfer when pasting from Word |
---|
The feature is working, however some tests are still failing:
The first test seems to fail due to changes in HTML markup that are made by using native
DOMParser
. The second test needs more investigation.The main changes made in this ticket are:
CKEDITOR.plugins.clipboard.dataTransfer.getData
that allows to fetch the original pasted HTML (full HTML, not stripped tobody
only)CKEDITOR.plugins.pastefromord.inlineStyles
that parses pasted HTML using nativeDOMParser
, fetches allstyle
tags and rewrite them to[style]
attributes for appropriate elements.Current WIP is on branch:t/16847.