Improve style retention on paste from MS Word
This epic stems from #9879. While analyzing how we could improve paste from Word by inlining stylesheets carried in the clipboard, we realized that we need to do more than just that to have a real impact on the UX. Most importantly, we need to move text-level styles from block elements to the text, as otherwise features like FontSize or Bold will not pick these styles up.
If you'd like to see this improvement implemented, add a 👍 reaction to this post.
Notes from the refinement
- Possible scope:
-
#9879: Paste from Word should inline stylesheets
- When inlining we need to filter out all the
mso-styles and possibly some stupid defaults likemargin:0cm
- When inlining we need to filter out all the
-
#7964: Apply default styles when pasting from Word
- In fact, it seems to be a part of #9879.
- Moving text styles from block elements to text
- Thanks to that GHS will not be necessary to make it all work. If we keep the styles on block elements, they will only be retained by GHS, not by features like FontSize, FontFamily, etc.
- Also, if they'll be moved to text, they will better work with e.g. the UI of FontSize.
- This is what CKE4 does.
- This can be done in particular features (like FontSize) as a conversion from view block element's styles to model attribute.
- However, it should only be done in the clipboard pipeline (see
$clipboardHolder). - We need to keep performance in mind. Most likely, we should test how the fix affects it.
- However, it should only be done in the clipboard pipeline (see
- Improving paste from Excel may be a reasonable followup.
-
#9879: Paste from Word should inline stylesheets
- First step: Spikes:
- S1:
- Analyze the spectrum of cases, so that we can choose these with the highest ROI. Give it max 1MD.
- S2:
- Analyze CKE4's solution to that (how the styles are inlined).
- Implement a PoC of inlining stylesheets.
- S3:
- Implement a PoC of converting block styles to text attributes.
- FontSize, Family, FontColor, basic styles (Bold, Italic, etc)
- Verify the toll of the new converters on setData() and paste performance
- S1:
When inlining we need to filter out all the mso- styles and possibly some stupid defaults like margin:0cm @Reinmar those stupid defaults are source of many complaints from clients about huge line spaces because if you filter
margin:0out then browser will assign default margins.
Please preserve 0 margins if they are assigned because not having them generates numerous complaints.
@Reinmar should we close it after PFOE? I think most items are already introduced.