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

Copied content from Word Doc crashes Draftail/Wagtail #179

Closed
xfxf opened this Issue Jan 9, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@xfxf
Copy link

xfxf commented Jan 9, 2019

Copying and pasting the attached document (at least using Word for Mac version 16.15, but am fairly sure will do using Word for Windows too) into Draftail or Wagtail causes the editor to crash: "Oops. The editor just crashed." or "The editor just crashed. Content has been reset to the last saved version.".

This is reproducible in the latest version of Wagtail, as well as the editor at https://www.draftail.org/

I assume there is a wonky character or element here which Draftail/Draft.js isn't handling properly related to the anchored image (my expectation is Draftail/Wagtail should ignore the image, as it normally does), but copying the image only doesn't seem to make the editor crash, only when the text and image is copied in.

draftail-crash-elon-musk-article.docx

@xfxf xfxf changed the title Copied content fro, Word Doc crashes Draftail/Wagtail Copied content from Word Doc crashes Draftail/Wagtail Jan 9, 2019

@thibaudcolas thibaudcolas added the bug label Jan 10, 2019

@thibaudcolas thibaudcolas added this to the v1.1.0 milestone Jan 10, 2019

@thibaudcolas thibaudcolas self-assigned this Jan 10, 2019

@thibaudcolas

This comment has been minimized.

Copy link
Collaborator

thibaudcolas commented Jan 10, 2019

👌 I have opened this at wagtail/wagtail#4985 as well so people following the Wagtail issue tracker are aware of the issue.

Copy-pasting my notes from Slack:

Thanks for reporting this @xfxf. It's caused by the image but I'm not entirely sure what's going wrong. At least it seems to be caused by Draftail, rather than Draft.js itself, so should be simple to fix once the issue is identified

The crash is due to Draftail trying to move the selection to the image block as if it was text after insertion. I'm not quite sure which of the filters (https://github.com/thibaudcolas/draftjs-filters/blob/008fe2c012d0157392feabf1572fe6232f5867e8/src/lib/filters/editor.js#L116-L136) fails to catch this. Or maybe they do catch it, but Draft.js doesn't update the selection to move to the block above.


@xfxf if you or anyone else wants to investigate this further, the first step is to create a failing test case with the "Draft.js output without filters" I pasted in thibaudcolas/draftjs-filters#27 as an input, and the same content without the atomic block as output. Then figure out why the block is kept by the filters.

thibaudcolas added a commit that referenced this issue Jan 23, 2019

thibaudcolas added a commit that referenced this issue Jan 23, 2019

@thibaudcolas

This comment has been minimized.

Copy link
Collaborator

thibaudcolas commented Jan 23, 2019

@xfxf this should now be fixed in https://www.draftail.org/, if you have a moment to try and confirm that would help. Hopefully this will reach Wagtail as part of the v2.5 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment