Skip to content

Remove image, embed, document, and link entities on paste if not enabled#103

Merged
thibaudcolas merged 1 commit intowagtail:feature/rich-paste-filteringfrom
inostia:feature/rich-paste-filtering
Dec 1, 2017
Merged

Remove image, embed, document, and link entities on paste if not enabled#103
thibaudcolas merged 1 commit intowagtail:feature/rich-paste-filteringfrom
inostia:feature/rich-paste-filtering

Conversation

@inostia
Copy link
Copy Markdown
Contributor

@inostia inostia commented Oct 20, 2017

Description
This PR includes a call to an additional function normalizeEntityType which aims to remove non-enabled entities from the Draftail editor.

Current State
Currently, pasting from Word or HTML does strip out invalid inline entities and removes blocks that have invalid entities entirely. Similarly, pasting from another Draftail editor strips these out.

TODO

  • If you paste into an existing block, the entity text for images will not be removed (but the entityMap and entityRanges will be).
  • When a block is removed, it is still selected. This is currently solved by moving the selection to the end of the content (moveSelectionToEnd) but this is incorrect. If there are additional blocks after the paste, the selection will still be moved to the end which is not desired behavior.
  • <hr /> are not removed.
  • Not sure if findEntityRanges is the best solution.
  • Currently no validation that blocks removed have the ATOMIC type because the TYPE of the image block is unstyled when it's pasted (unless it's from another draftail editor?)
  • Needs tests

I can potentially work more on this. Please feel free to add comments/suggestions.

@thibaudcolas thibaudcolas self-requested a review October 20, 2017 14:38
Copy link
Copy Markdown
Member

@thibaudcolas thibaudcolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Merging into the other rich paste branch, will tackle the todos there. Thank you @inostia!

@thibaudcolas thibaudcolas merged commit 37bfb8a into wagtail:feature/rich-paste-filtering Dec 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants