-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Feature (to address a bug in Draft.js). See facebookarchive/draft-js#523 (comment) and facebookarchive/draft-js#1082.
What is the current behavior?
[...] when copy-pasting Draft.js images from one editor to another. If the unstyled blocks in-between the images are empty, then they will be removed in the target editor... and it becomes impossible to select the images to remove them or add content before/after.
This also happens for other block types than unstyled – all that's needed is for the blocks to be empty.
What is the expected behavior?
Blocks should be preserved. The filters can't preserve the right block type (would require a fix in Draft.js), but they could at least inject unstyled blocks where appropriate. There are three cases I know of:
- The image is the first block, so it needs to be preceded with an empty block.
- The image is the last block, so it needs to be followed by an empty block.
- Two images one after the other need to have an empty block in-between.
For the implementation, I think this should probably go after removeInvalidAtomicBlocks in filterEditorState, so it only happens where really necessary.
I imagine the implementation would need to reduce through the blocks, inserting new ones where appropriate. This probably needs to happen for atomic blocks rather than just images, but AFAIK only images are preserved on copy-paste anyway, at least for now.