Image delete keep entity into state
See original GitHub issueWhen deleting an image, the entity remains binded to the block above into the entityRanges and the entity is not removed from the entityMap. https://codesandbox.io/s/4ql8746pl7 Step to reproduce:
- delete the image
- log the state in console with the proper button
state before:
{
"entityMap": {
"0": {
"type": "image",
"mutability": "IMMUTABLE",
"data": {
"src": "https://www.draft-js-plugins.com/images/canada-landscape-small.jpg"
}
}
},
"blocks": [
{
"key": "9gm3s",
"text": "You can have images in your text field. This is a very rudimentary example, but you can enhance the image plugin with resizing, focus or alignment plugins.",
"type": "unstyled",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [],
"data": {}
},
{
"key": "ov7r",
"text": " ",
"type": "atomic",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [
{
"offset": 0,
"length": 1,
"key": 0
}
],
"data": {}
},
{
"key": "e23a8",
"text": "See advanced examples further down …",
"type": "unstyled",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [],
"data": {}
}
]
}
state after:
{
"entityMap": {
"0": {
"type": "image",
"mutability": "IMMUTABLE",
"data": {
"src": "https://www.draft-js-plugins.com/images/canada-landscape-small.jpg"
}
}
},
"blocks": [
{
"key": "9gm3s",
"text": "You can have images in your text field. This is a very rudimentary example, but you can enhance the image plugin with resizing, focus or alignment plugins. See advanced examples further down …",
"type": "unstyled",
"depth": 0,
"inlineStyleRanges": [],
"entityRanges": [
{
"offset": 155,
"length": 1,
"key": 0
}
],
"data": {}
}
]
}
i noticed that in the draft-js media example this didn’t happen, but for now I’ve not been able to solve the problem
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Deleting an entity with revisions and file/image field does not ...
Images /files uploaded to a file/image fields on entities with multiple revisions are never deleted, even when the entity is deleted.
Read more >Entity Framework: Deleting an Item from a Collection - TechNet
In this article, let's see how we can remove/delete an item from a collection in terms of Entity Framework. It's always better to...
Read more >Remove an entity from draft-js Editor Current State on button ...
I'm trying to remove images on my rich text editor with a click of a button embedded in the image div using a...
Read more >More Efficient Deletes With Entity Framework Core
Using EF Core's Change Tracker to generate DELETE SQL Statements and ... You change the EntityEntry<Person> to have a State of Deleted ....
Read more >entity:delete - Drush
Delete content entities. To delete configuration entities, see config:delete command. Examples¶. drush entity:delete node --bundle=article .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s not a real bug-fix but i fixed it like this as a tricky hack.
I just tried to move cursor after the atomic block when it is focused so that I could delete images without the bug.
I found a solution but it doesn’t solve the problem at all. Adding
to the returned object of image plugin it solves the problem. But i think this happens with all the atomic blocks, so putting this code in image-plugin could not be the better solution. The same problem also happen when using the focus plugin and deleting the image when is focused and this “quick fix” doesn’t solve that.
Anyone have some idea where is the best place to fix them? And how fix the problem also for the focus plugin without having some conflicts between the 2 fix?