html-to-draftjs
html-to-draftjs copied to clipboard
html-to-draftjs.js:2 Uncaught TypeError: Cannot read property 'type' of undefined
@jpuri I'm still getting the same issue:
My package.json
"html-to-draftjs": "^0.1.0-beta11"
"react-draft-wysiwyg": "^1.10.7"
As I need this feature soon, is there any workaround?
@mayconbeserra : can you plz share the HTML which are are trying to convert to editor content.
Hi @jpuri it's a blank text. the RichEditor.Render
log is printing what I'm receiving.
Should it be <p></p>
?
@jpuri I added <p></p>
when the content is Empty Or Null, and then I started getting another error:
@mayconbeserra : which version of lib are you using ?
@jpuri
here
for rendering, I'm doing as suggested in the readme:
render() { console.log('RichEditor:render', this.props.content);
const blocksFromHtml = htmlToDraft(this.props.content || '<p></p>');
const { contentBlocks, entityMap } = blocksFromHtml.contentBlocks;
const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap);
const editorState = EditorState.createWithContent(contentState);`
And I'm using editorState
variable to link to the component
@jpuri the error above, I managed to solve with the example from that guy: https://github.com/facebook/draft-js/issues/809
However, when I started typing and pause, and type again, the new text is added at the beginning of the RichEditor, which is wrong. It should be added at the end of the editor.
This only happens when I'm converting from Html
to ContentState
and binding it to the Editor.
Any thoughts about that?
@mayconbeserra : it works for m here if I use
: https://github.com/jpuri/html-to-draftjs/blob/master/src/index.js#L21Are you marking editor controlled component ?
yes, it's a controlled component
Are you converting each time from html, I will not suggest that - it will slow down editor.
Also [email protected]
has fix for above issue with input html is empty.
That error has occurred with example code in README.md. Try to use that code:
const {contentBlocks, entityMap} = htmlToDraft(this.props.content);
const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap);
const editorState = EditorState.createWithContent(contentState);
It fixed in #26
@jpuri It can not show the font-size when i use the html-to-draft, but the attribute of color is showing correctly.
@jpuri help, help, help.
重复刷新当前页面出现的问题 TypeError: Cannot read property 'trim' of undefined 有没有解决办法
重复刷新当前页面出现的问题 TypeError: Cannot read property 'trim' of undefined 有没有解决办法
I have the same 'trim' problem...
@codigoisaac 问题解决了吗?我也遇到同样的问题