Ability to select which inline styles, block types, links should be retained on paste#1057
Ability to select which inline styles, block types, links should be retained on paste#1057mkhazov wants to merge 16 commits intofacebookarchive:mainfrom
Conversation
…d be retained on paste
…lag from editor props)
docs/APIReference-Editor.md
Outdated
| #### pasteSupport | ||
| ``` | ||
| stripPastedStyles?: boolean | ||
| stripPastedStyles?: Object |
There was a problem hiding this comment.
Minor: this is still using the old new
| export type DraftPasteSupport = { | ||
| inlineStyles: List<string>, | ||
| blockTypes: List<string>, | ||
| links: boolean, |
There was a problem hiding this comment.
If we're going to go this far, why not also allow images to be blocked?
docs/APIReference-Editor.md
Outdated
| stripPastedStyles?: boolean | ||
| stripPastedStyles?: Object | ||
| ``` | ||
| Optionally define which inline styles, block types and links should be retained on paste. |
There was a problem hiding this comment.
We should go into more depth here to make the documentation easier to use. For example, we should clarify that the supported block types is the intersection between those defined in the block render map and those defined in this structure. We should provide an example, non-empty, value for this field as well so that users don't need to spelunk through the source to find how each field is being interpreted and used.
…ckRenderMap will be supported on paste
|
@colinjeanne thanks, I've added ability to strip images and updated the docs. |
44edb5b to
211541e
Compare
There was a problem hiding this comment.
I made a separate library that does the same thing as this PR, and thought I should mention a few other things that should IMHO be configurable in the paste support:
- What amount of block nesting to preserve – If the editor only allows flat lists, then it shouldn't be possible to paste nested ones.
- For entities (images/links), what data to keep – if I remember correctly, for links Draft.js will have both
hrefandurlwith slightly different content, and images havewidth/heightwhich are of no use in many cases. - For entities again, whether to keep them or not based on their data. For example, you might not want your editor to allow pasting images from Word (local file path), but might be ok with hotlinked images from your own website.
It would also make sense to allow to decide what entities to allow paste for beyond links/images if #787 gets fixed (see #1784).
For further reference (API, tests), the lib is https://github.com/thibaudcolas/draftjs-filters.
fixes #166