-
Notifications
You must be signed in to change notification settings - Fork 21
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 import support #2
Conversation
import {stateFromElement} from 'draft-js-import-element'; | ||
import remark from 'remark'; | ||
import html from 'remark-html'; | ||
import {jsdom} from 'jsdom'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to pull in jsdom
dependency since the browser natively does everything that jsdom does. But this is an interesting approach to go markdown -> ast -> html-string -> dom -> contentState
. I'm curious to know what the downsides, if any are to double-parsing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to browser parser module from Your link. Currently i'm having some difficulties with blockquote test not passing, will need to look whats the issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like issue with this test is connected to #1 and i think the problem is in stateFromElement module -> given blockquote markdown example: > test
, remark translates it to <blockquote><p>test</p></blockquote>
which is translated by stateFromElement to 'unstyled' type block with 'test' text, instead of 'blockquote' type.
This is an interesting approach. I see you're doing I have been working on a dev branch that uses remark to parse the markdown to ast, but in my implementation I started writing custom code to go from |
Since draft-js doesn't support nested blocks for elements other then lists - https://facebook.github.io/draft-js/docs/advanced-topics-nested-lists.html i will make temporary fix for blockquote by removing inner paragraph node |
Added temp fix for blockquote. About this approach i think that using external, well tested code, outweights cons of double parsing. It makes code simple, short and easy to read / maintain :) |
This is an old issue and has some conflicts. I'll close for now, but I'd be open for another attempt in the future. |
Removed custom parser and used remark + jsdom