differences between code and code-block
yunlzhang opened this issue · comments
In the draftjs's document 'code-block' was rendered as block-level element and 'code' was as inline-level,but in your code, 'code' was mapped to block-level element . Maybe you should think to change it to adjust to the draftjs's document
I've noticed this too (and I think #49 is the same issue. When rendering headers we get <h2>
and paragraphs <p>
but code blocks disappear.
From what I can tell a code block looks like the following:
{
key: '2r3t',
text: 'console.log(1);',
type: 'code-block',
depth: 0,
inlineStyleRanges: [],
entityRanges: [],
data: {}
},
In the docs https://www.npmjs.com/package/draftjs-to-html#supported-conversions it says code
is converted to <pre>
but I suspect that should be code-block
.
Sure enough, if I change https://github.com/jpuri/draftjs-to-html/blob/master/lib/draftjs-to-html.js#L47 from code: 'pre'
to 'code-block': 'pre'
I can get the <pre>
tags out.
I'm happy to create an PR for this @jpuri if you confirm you're happy with the above diagnosis and solution? :)
hello :)
Is it merge into master ?
I've got same issue here.