Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/helpers/markdownToState.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {convertFromRaw} from 'draft-js'
import _ from 'lodash'
const Remarkable = require('remarkable')

// Block level items, key is Remarkable's key for them, value returned is
Expand Down Expand Up @@ -285,7 +284,12 @@ function markdownToState(markdown, options = {}) {
// but right now this code doesn't support that.
if (item.level === 0 || item.type === 'list_item_open') {
const block = Object.assign({
depth: 0
depth: 0,
// set default values when creating a block, usually the block would have some inline items and
// so these default values would be overwritten because of inline items by `blockToModify` object above
text: '',
inlineStyleRanges: [],
entityRanges: [],
}, BlockTypes[itemType](item))

blocks.push(block)
Expand All @@ -295,7 +299,7 @@ function markdownToState(markdown, options = {}) {

return convertFromRaw({
entityMap,
blocks: _.filter(blocks, b => b.text)
blocks,
})
}

Expand Down