Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more copy-paste filtering #123

Closed
3 tasks done
thibaudcolas opened this issue Dec 4, 2017 · 1 comment
Closed
3 tasks done

Add more copy-paste filtering #123

thibaudcolas opened this issue Dec 4, 2017 · 1 comment
Labels
enhancement New feature or request

Comments

@thibaudcolas
Copy link
Collaborator

thibaudcolas commented Dec 4, 2017

Follow-up to #50, #9.

The current implementation filters blocks, styles, entities by type. What formats it preserves (or how well it does that) depends a lot on the specific browser + OS + copy source being used. I've done lots of testing, and started collecting unfiltered ContentStates to be able to review and unit test this further.

First test run

Editor - Browser Chrome Windows Chrome macOS Firefox Windows Firefox macOS Edge Windows IE11 Windows Safari macOS Safari iOS Chrome Android
Word 2016 iOS11
Word 2013 N/A N/A N/A N/A N/A
Word 2010 v62, Win8.1 N/A v57, Win8.1 N/A Win8.1 N/A N/A N/A
Apple Pages N/A v62, macOS10.13 N/A v62, macOS10.13 N/A N/A v11, macOS10.13 iOS11 N/A
Google Docs v62, Win8.1 v62, macOS10.13 v57, Win8.1 v62, macOS10.13 v16, Win10 Win8.1 v11, macOS10.13 iOS11
Word Online v62, Win8.1 v62, macOS10.13 v57, Win8.1 v62, macOS10.13 v16, Win10 Unsupported v11, macOS10.13 No paste ?
Dropbox Paper v62, Win8.1 v62, macOS10.13 v57, Win8.1 v62, macOS10.13 v16, Win10 Unsupported v11, macOS10.13 iOS11 ?

Next steps

Based on a quick review,

  • Drop line breaks
  • Drop unneeded entity data
  • Drop images based on criteria to be defined (data: URLs should be dropped, file: URLs should be dropped, potentially more).

Here are my detailed findings after reviewing the "Word 2010 on Chrome in Windows"

Special attention:

  • Preserves line breaks
  • Link entities have both href (source?) and url (added by Draft.js) attributes

Correctly retained

  • Bold, italic, bold + italic, strikethrough, underline
  • Unstyled, h1, h2, h3, h4, h5, h6
  • Special chars (ellipsis, emojis, etc)
  • "Link info" saved in title attribute

Not retained

  • Superscript / subscript: unstyled
  • Quote: unstyled
  • Link target ("frame" in Word): no attribute for this
  • Bulleted list: unstyled preceded with small middot bullet
  • Nested bulleted list (1): unstyled preceded with medium empty circle bullet
  • Nested bulleted list (2): unstyled preceded with special symbol
  • Numbered list: unstyled preceded with (correct) count / letter (1., 2., a. for 1-level nesting)
  • Star list: image with * in alt, and src set to local file

Incorrectly retained

  • Outline: retained as bold
  • Double strikethrough: retained as strikethrough
  • Empty unstyled block inserted at the top
  • Internal document link saved as link anchor in href attribute, and added by Draft.js at the end of url to point at the current page
    • eg. href: '#_Inline_styles'
  • Comment reference text saved as [T.C1] (user initials)
  • Comment saved as both link anchor in href attributes with special text on comment location, and end-of-document comment body with other special link anchor in href
    • eg. href: '#_msocom_1' for ref, href: '#_msoanchor_1' for body
  • Image retained with height and width attributes (string repr of number)
  • Image src is a file:/// protocol URL
@thibaudcolas thibaudcolas added the enhancement New feature or request label Dec 4, 2017
@thibaudcolas thibaudcolas added this to the Wagtail 2.0 milestone Dec 4, 2017
@thibaudcolas
Copy link
Collaborator Author

See https://github.com/thibaudcolas/draftjs-paste for current progress. The test suite is going to be tens of MBs of JSON, and this isn't really related to Draftail, so I'm considering making a separate package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant