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

Good copy/pasting support #9

Closed
7 of 10 tasks
thibaudcolas opened this issue Nov 14, 2016 · 5 comments
Closed
7 of 10 tasks

Good copy/pasting support #9

thibaudcolas opened this issue Nov 14, 2016 · 5 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@thibaudcolas
Copy link
Collaborator

thibaudcolas commented Nov 14, 2016

Expected behavior

  • Flattens lists that are too nested.
  • Strip all blocks which aren't allowed in the current field – One needs to be careful when removing default blocks from the block map, and/or aliasing elements. If an element is missing, the editor will crash.
  • IMAGE entities are created, but come with an unstyled block instead of atomic. This should be normalised.
  • There is no built-in way to configure whether IMAGE and LINK are available in the first place. They should be removed if necessary (both from the block, and the entity map).
  • There is no way to customise which styles are available. Styles should be removed if necessary.

Unexpected behavior

  • Drops the style of the first block in the clipboard
  • Concatenates multiple paragraphs into one block (whitespace is missing)
  • Drops whitespace in front of text node right after inline entity
  • [ ] Be smart about pasting of uppercase text? IS SHOUTING ALLOWED? WHAT IF YOU COPY/PASTE AN H2?

Example big content to copy paste:

@thibaudcolas thibaudcolas added the enhancement New feature or request label Nov 14, 2016
@thibaudcolas thibaudcolas added this to the 1.0 milestone Nov 14, 2016
@loicteixeira
Copy link

I also think copy/paste should strip all blocks which aren't allowed in the current field.

At the moment, if you paste some text with a list or a link in a field which doesn't allow them (no buttons), they will remain and appear in the output.

@thibaudcolas
Copy link
Collaborator Author

thibaudcolas commented Jan 31, 2017

After struggling with this and arriving where I'm at in 58866cd, obvious difficulties I can think of:

  • IMAGE entities are created, but come with an unstyled block instead of atomic. This should be normalised.
  • One needs to be careful when removing default blocks from the block map, and/or aliasing elements. If an element is missing, the editor will crash.
  • There is no built-in way to configure whether IMAGE and LINK are available in the first place. They should be removed if necessary (both from the block, and the entity map).
  • There is no way to customise which styles are available. Styles should be removed if necessary.

For now I've started normalising content after insertion, via onChange. Another approach could be to use https://facebook.github.io/draft-js/docs/api-reference-data-conversion.html#convertfromhtml in handlePastedText, then normalise, then insert the new blocks where the selection is.

@thibaudcolas thibaudcolas added the help wanted Extra attention is needed label May 2, 2017
@thibaudcolas thibaudcolas self-assigned this Jul 31, 2017
@thibaudcolas
Copy link
Collaborator Author

This is under way at #50. I've made good progress, but I'm sure there are a lot of edge cases this is not handling.

@thibaudcolas thibaudcolas modified the milestones: v1.0.0, For Wagtail Dec 1, 2017
@thibaudcolas
Copy link
Collaborator Author

Fixed by #50. I have more testing to do but this looks fairly solid so far. The PR is only/mostly about removing styles that are not allowed, and isn't much concerned with ensuring that retained styles actually are what they are meant to be. I'll open separate issue(s) for that, and document gotchas next.

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

No branches or pull requests

2 participants