Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Refactor convertFromHTMLtoContentBlocks
Browse files Browse the repository at this point in the history
Summary: One of the utility helper methods commonly used to manage state with Draft.js is the `convertFromHTMLtoContentBlocks` method, which converts an HTML string into a data structure used by Draft.js for tracking state. This is a helpful utility, but it was written in an overly complex way. This commits adds a new simpler implementation of `convertFromHTMLToContentBlocks`.

Reviewed By: flarnie

Differential Revision: D7158000

fbshipit-source-id: 3424cdeb03663dc6c5a194da3d317c6ab97507dc
  • Loading branch information
Nicolas Champsavoir authored and facebook-github-bot committed Mar 12, 2018
1 parent 6ef6c66 commit 732b69d
Show file tree
Hide file tree
Showing 6 changed files with 3,367 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,120 @@ Array [
]
`;

exports[`Should preserve spacing around inline tags 1`] = `
Array [
Object {
"characterList": Array [
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [
"ITALIC",
],
},
Object {
"entity": null,
"style": Array [],
},
Object {
"entity": null,
"style": Array [
"BOLD",
],
},
Object {
"entity": null,
"style": Array [
"BOLD",
],
},
Object {
"entity": null,
"style": Array [
"BOLD",
],
},
Object {
"entity": null,
"style": Array [
"BOLD",
],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": null,
"parent": undefined,
"prevSibling": null,
"text": "Some stylised text",
"type": "unstyled",
},
]
`;

exports[`converts deeply nested html blocks when experimentalTreeDataSupport is enabled 1`] = `
Array [
Object {
Expand Down
Loading

0 comments on commit 732b69d

Please sign in to comment.