brijeshb42 / medium-draft

📝 A medium like Rich Text Editor built on draft-js with a focus on keyboard shortcuts.
https://bitwiser.in/medium-draft/
MIT License
1.73k stars 245 forks source link

After removing a image the data with src isn't removed #115

Open Yoruba opened 6 years ago

Yoruba commented 6 years ago

After uploading a image to the server the image is save in a database as data:image.

  "content": {
    "entityMap": {},
    "blocks": [
      {
        "key": "j4v9",
        "text": "",
        "type": "atomic:image",
        "depth": 0,
        "inlineStyleRanges": [],
        "entityRanges": [],
        "data": {
          "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAMAAAANmfvwAAAAPFBMVEVGgcP////n7/elwuJilMz2+fzV4vFNhsXE1uxKg8S+0+r4+/2hv+Fekcutx+R/qNbu8/lXjcl2otPi6/bFr1xJAAAAoUlEQVQ4jc2RSxLDIAxDsY0NpCHp5/53bSCQVUQW7UyrHeM3liWc+2v5qBr9kFDapCMmUlUcILoj+hGS9cpo7UvQuWkpUxuEzrYRls+HQZh4KiZLAoRRO2FFR0oj7rhTbghDwlEXRvoWMugkxxqScI60RFxSMwhVe5HwmOr3+P0FLJ+vw9IQk+ZbZ2YYL3fmOy0NtvSWBCOtJZioMsNefqk3ivgDP/9IjqIAAAAASUVORK5CYII="
        }
      }
    ]
  }

After deleting the image with medium draft the image data and src is not deleted only the type is change from "type": "atomic:image" to "type": "unstyled".

  "content": {
    "entityMap": {},
    "blocks": [
      {
        "key": "j4v9",
        "text": "",
        "type": "unstyled",
        "depth": 0,
        "inlineStyleRanges": [],
        "entityRanges": [],
        "data": {
          "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACIAAAAiCAMAAAANmfvwAAAAPFBMVEVGgcP////n7/elwuJilMz2+fzV4vFNhsXE1uxKg8S+0+r4+/2hv+Fekcutx+R/qNbu8/lXjcl2otPi6/bFr1xJAAAAoUlEQVQ4jc2RSxLDIAxDsY0NpCHp5/53bSCQVUQW7UyrHeM3liWc+2v5qBr9kFDapCMmUlUcILoj+hGS9cpo7UvQuWkpUxuEzrYRls+HQZh4KiZLAoRRO2FFR0oj7rhTbghDwlEXRvoWMugkxxqScI60RFxSMwhVe5HwmOr3+P0FLJ+vw9IQk+ZbZ2YYL3fmOy0NtvSWBCOtJZioMsNefqk3ivgDP/9IjqIAAAAASUVORK5CYII="
        }
      }
    ]
  }

This result in data:image is not removed from the database and the image is hidden.

Is it possible to remove the data node after removing the image?

Thank, Adri

brijeshb42 commented 6 years ago

With the current implementation, it is not possible. Internal code will have to be updated to handle this.

Yoruba commented 6 years ago

Can I help with trying to fix this problem?