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

Commit

Permalink
Fixes HTML importer to make image entity immutable (#2184)
Browse files Browse the repository at this point in the history
Summary:
**Summary**
Makes image entities created with the HTML importer immutable

This diff also adds the `flow` annotation to the `convertFromHTMLToContentBlocks` test case and fixes typechecking failures that are surfaced by its addition.

To support a more modern syntax to handle nullable fields, it adds the `babel/plugin-proposal-optional-chaining` plugin to Babel config.

Fixes #2149

**Test Plan**
Adds tests to verify created entities are immutable
Pull Request resolved: #2184

Reviewed By: j-nolan

Differential Revision: D17474930

Pulled By: claudiopro

fbshipit-source-id: c60ef368ff471914c2e188277a0ecc050115533b
  • Loading branch information
Claudio Procida authored and facebook-github-bot committed Sep 19, 2019
1 parent cd4adaa commit b858f43
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"]
"plugins": ["@babel/plugin-proposal-nullish-coalescing-operator", "@babel/plugin-proposal-optional-chaining"]
}
2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.js.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion meta/bundle-size-stats/Draft.min.js.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
"babel-eslint": "^8.1.1",
"babel-preset-fbjs": "^3.2.0",
"cross-env": "^5.1.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,8 @@ exports[`img with data protocol should be correctly parsed 1`] = `"\\ud83d\\udcf

exports[`img with http protocol should have camera emoji content 1`] = `"\\ud83d\\udcf7"`;

exports[`img with https protocol should have camera emoji content 1`] = `"\\ud83d\\udcf7"`;

exports[`img with role presentation should not be rendered 1`] = `Array []`;

exports[`line break should be correctly parsed - multiple <br> in a content block 1`] = `
Expand Down Expand Up @@ -3475,9 +3477,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "blockquote",
},
Expand All @@ -3488,9 +3494,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "blockquote",
},
Expand Down Expand Up @@ -3537,9 +3547,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "unstyled",
},
Expand All @@ -3550,9 +3564,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "unstyled",
},
Expand Down Expand Up @@ -3599,9 +3617,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "atomic",
},
Expand All @@ -3612,9 +3634,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "atomic",
},
Expand Down Expand Up @@ -3661,9 +3687,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-one",
},
Expand All @@ -3674,9 +3704,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-one",
},
Expand Down Expand Up @@ -3723,9 +3757,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-two",
},
Expand All @@ -3736,9 +3774,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-two",
},
Expand Down Expand Up @@ -3785,9 +3827,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-three",
},
Expand All @@ -3798,9 +3844,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-three",
},
Expand Down Expand Up @@ -3847,9 +3897,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-four",
},
Expand All @@ -3860,9 +3914,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-four",
},
Expand Down Expand Up @@ -3909,9 +3967,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-five",
},
Expand All @@ -3922,9 +3984,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-five",
},
Expand Down Expand Up @@ -3971,9 +4037,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "header-six",
},
Expand All @@ -3984,9 +4054,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "header-six",
},
Expand Down Expand Up @@ -4033,9 +4107,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "unordered-list-item",
},
Expand All @@ -4046,9 +4124,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "unordered-list-item",
},
Expand Down Expand Up @@ -4095,9 +4177,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "unstyled",
},
Expand All @@ -4108,9 +4194,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "unstyled",
},
Expand Down Expand Up @@ -4157,9 +4247,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key0",
"nextSibling": "key1",
"parent": null,
"prevSibling": null,
"text": "a",
"type": "code-block",
},
Expand All @@ -4170,9 +4264,13 @@ Array [
"style": Array [],
},
],
"children": Array [],
"data": Object {},
"depth": 0,
"key": "key1",
"nextSibling": null,
"parent": null,
"prevSibling": "key0",
"text": "b",
"type": "code-block",
},
Expand Down
Loading

0 comments on commit b858f43

Please sign in to comment.