Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image pasted from Word is not properly processed #27

Closed
thibaudcolas opened this issue Jan 10, 2019 · 2 comments
Closed

Image pasted from Word is not properly processed #27

thibaudcolas opened this issue Jan 10, 2019 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@thibaudcolas
Copy link
Owner

thibaudcolas commented Jan 10, 2019

Do you want to request a feature or report a bug?

Bug. See springload/draftail#179.

What is the current behavior?

Pasting a particular image formatting from Word, the content coming from the filters contains an image block that trips up the editor’s rendering.

Input document: draftail-crash-elon-musk-article.docx

Draft.js output on https://thibaudcolas.github.io/draftjs-filters/:

Without filters
{
  "blocks": [
    {
      "key": "f8beh",
      "text": "  ",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [],
      "data": {}
    },
    {
      "key": "35q1g",
      "text": "Test",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [],
      "data": {}
    },
    {
      "key": "82iof",
      "text": "📷",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [
        {
          "offset": 0,
          "length": 1,
          "key": 0
        }
      ],
      "data": {}
    }
  ],
  "entityMap": {
    "0": {
      "type": "IMAGE",
      "mutability": "MUTABLE",
      "data": {
        "alt": "Image result for ross geller annulment",
        "height": "226",
        "src": "file://localhost/Users/thibaud/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_image002.png",
        "width": "340"
      }
    }
  }
}
With filters
{
  "blocks": [
    {
      "key": "378gv",
      "text": "  ",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [],
      "data": {}
    },
    {
      "key": "4h5in",
      "text": "Test",
      "type": "unstyled",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [],
      "data": {}
    },
    {
      "key": "53d8u",
      "text": " ",
      "type": "atomic",
      "depth": 0,
      "inlineStyleRanges": [],
      "entityRanges": [
        {
          "offset": 0,
          "length": 1,
          "key": 0
        }
      ],
      "data": {}
    }
  ],
  "entityMap": {
    "0": {
      "type": "IMAGE",
      "mutability": "MUTABLE",
      "data": {
        "src": "file://localhost/Users/thibaud/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_image002.png"
      }
    }
  }
}

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. GIFs and screenshots are very helpful too.

  1. Open the input document linked above with Word (might also work with other word processors).
  2. Copy the content around the image
  3. Paste in the editor

What is the expected behavior?

The editor shouldn't have to render problematic content. Either:

@thibaudcolas
Copy link
Owner Author

I had another look, it's indeed related to the selection, that's not updated to move to another block after the image one has been removed. This would happen when the last item in the paste is an image, and also presumably on Apple Pages with nested list items if they were the last thing in the paste. I'm surprised it's only coming up now!

thibaudcolas added a commit that referenced this issue Jan 22, 2019
# [2.2.0](v2.1.0...v2.2.0) (2019-01-22)

### Bug Fixes

* **filters:** handle removal of all blocks, inserting one unstyled ([652750f](652750f))
* **filters:** move selection after filtering. Fix [#27](#27) ([df3b8a6](df3b8a6))

### Features

* **api:** expose applyContentWithSelection in the package API ([25d1983](25d1983))
@thibaudcolas
Copy link
Owner Author

🎉 This issue is fixed in v2.2.0, available on npm: [email protected].

Generated by 📦🚀 semantic-release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant