Skip to content

Commit

Permalink
remove try catch block for covertfromHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkao0902 committed Nov 2, 2020
1 parent 18c52c8 commit 6612ebe
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,12 @@ function embedToBlock(block) {
}

function paragraphToBlock(block) {
try{
return convertFromHTML(block.data);
} catch(err) {
console.log("paragraphToBlock error");
}
return convertFromHTML(block.data)
}

function headerToBlock(block) {
try{
const contentBlocks = convertFromHTML(block.data.content).contentBlocks
.map(contentBlock => contentBlock.set('type', DRAFT_TYPES.HEADER));
} catch(err) {
console.log("headerToBlock error");
}
const contentBlocks = convertFromHTML(block.data.content).contentBlocks
.map(contentBlock => contentBlock.set('type', DRAFT_TYPES.HEADER))

return {
contentBlocks: contentBlocks,
Expand All @@ -134,13 +126,9 @@ function headerToBlock(block) {
}

function listToBlock(block) {
try{
const contentBlocks = block.data
.map(text => convertFromHTML(text).contentBlocks[0])
.map(contentBlock => contentBlock.set('type', DRAFT_TYPES.LIST))
} catch(err){
console.log("listToBlock error");
}

return {
contentBlocks: contentBlocks,
Expand Down Expand Up @@ -210,4 +198,4 @@ function toJSON(contentState) {
export {
toJSON,
fromJSON
}
}

0 comments on commit 6612ebe

Please sign in to comment.