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

Commit b858f43

Browse files
Claudio Procidafacebook-github-bot
Claudio Procida
authored andcommitted
Fixes HTML importer to make image entity immutable (#2184)
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
1 parent cd4adaa commit b858f43

File tree

8 files changed

+162
-23
lines changed

8 files changed

+162
-23
lines changed

.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"plugins": ["@babel/plugin-proposal-nullish-coalescing-operator"]
2+
"plugins": ["@babel/plugin-proposal-nullish-coalescing-operator", "@babel/plugin-proposal-optional-chaining"]
33
}

meta/bundle-size-stats/Draft.js.json

+1-1
Large diffs are not rendered by default.

meta/bundle-size-stats/Draft.min.js.json

+1-1
Large diffs are not rendered by default.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"devDependencies": {
4444
"@babel/core": "^7.3.4",
4545
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
46+
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
4647
"babel-eslint": "^8.1.1",
4748
"babel-preset-fbjs": "^3.2.0",
4849
"cross-env": "^5.1.3",

src/model/encoding/__tests__/__snapshots__/convertFromHTMLToContentBlocks-test.js.snap

+98
Original file line numberDiff line numberDiff line change
@@ -3074,6 +3074,8 @@ exports[`img with data protocol should be correctly parsed 1`] = `"\\ud83d\\udcf
30743074

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

3077+
exports[`img with https protocol should have camera emoji content 1`] = `"\\ud83d\\udcf7"`;
3078+
30773079
exports[`img with role presentation should not be rendered 1`] = `Array []`;
30783080

30793081
exports[`line break should be correctly parsed - multiple <br> in a content block 1`] = `
@@ -3475,9 +3477,13 @@ Array [
34753477
"style": Array [],
34763478
},
34773479
],
3480+
"children": Array [],
34783481
"data": Object {},
34793482
"depth": 0,
34803483
"key": "key0",
3484+
"nextSibling": "key1",
3485+
"parent": null,
3486+
"prevSibling": null,
34813487
"text": "a",
34823488
"type": "blockquote",
34833489
},
@@ -3488,9 +3494,13 @@ Array [
34883494
"style": Array [],
34893495
},
34903496
],
3497+
"children": Array [],
34913498
"data": Object {},
34923499
"depth": 0,
34933500
"key": "key1",
3501+
"nextSibling": null,
3502+
"parent": null,
3503+
"prevSibling": "key0",
34943504
"text": "b",
34953505
"type": "blockquote",
34963506
},
@@ -3537,9 +3547,13 @@ Array [
35373547
"style": Array [],
35383548
},
35393549
],
3550+
"children": Array [],
35403551
"data": Object {},
35413552
"depth": 0,
35423553
"key": "key0",
3554+
"nextSibling": "key1",
3555+
"parent": null,
3556+
"prevSibling": null,
35433557
"text": "a",
35443558
"type": "unstyled",
35453559
},
@@ -3550,9 +3564,13 @@ Array [
35503564
"style": Array [],
35513565
},
35523566
],
3567+
"children": Array [],
35533568
"data": Object {},
35543569
"depth": 0,
35553570
"key": "key1",
3571+
"nextSibling": null,
3572+
"parent": null,
3573+
"prevSibling": "key0",
35563574
"text": "b",
35573575
"type": "unstyled",
35583576
},
@@ -3599,9 +3617,13 @@ Array [
35993617
"style": Array [],
36003618
},
36013619
],
3620+
"children": Array [],
36023621
"data": Object {},
36033622
"depth": 0,
36043623
"key": "key0",
3624+
"nextSibling": "key1",
3625+
"parent": null,
3626+
"prevSibling": null,
36053627
"text": "a",
36063628
"type": "atomic",
36073629
},
@@ -3612,9 +3634,13 @@ Array [
36123634
"style": Array [],
36133635
},
36143636
],
3637+
"children": Array [],
36153638
"data": Object {},
36163639
"depth": 0,
36173640
"key": "key1",
3641+
"nextSibling": null,
3642+
"parent": null,
3643+
"prevSibling": "key0",
36183644
"text": "b",
36193645
"type": "atomic",
36203646
},
@@ -3661,9 +3687,13 @@ Array [
36613687
"style": Array [],
36623688
},
36633689
],
3690+
"children": Array [],
36643691
"data": Object {},
36653692
"depth": 0,
36663693
"key": "key0",
3694+
"nextSibling": "key1",
3695+
"parent": null,
3696+
"prevSibling": null,
36673697
"text": "a",
36683698
"type": "header-one",
36693699
},
@@ -3674,9 +3704,13 @@ Array [
36743704
"style": Array [],
36753705
},
36763706
],
3707+
"children": Array [],
36773708
"data": Object {},
36783709
"depth": 0,
36793710
"key": "key1",
3711+
"nextSibling": null,
3712+
"parent": null,
3713+
"prevSibling": "key0",
36803714
"text": "b",
36813715
"type": "header-one",
36823716
},
@@ -3723,9 +3757,13 @@ Array [
37233757
"style": Array [],
37243758
},
37253759
],
3760+
"children": Array [],
37263761
"data": Object {},
37273762
"depth": 0,
37283763
"key": "key0",
3764+
"nextSibling": "key1",
3765+
"parent": null,
3766+
"prevSibling": null,
37293767
"text": "a",
37303768
"type": "header-two",
37313769
},
@@ -3736,9 +3774,13 @@ Array [
37363774
"style": Array [],
37373775
},
37383776
],
3777+
"children": Array [],
37393778
"data": Object {},
37403779
"depth": 0,
37413780
"key": "key1",
3781+
"nextSibling": null,
3782+
"parent": null,
3783+
"prevSibling": "key0",
37423784
"text": "b",
37433785
"type": "header-two",
37443786
},
@@ -3785,9 +3827,13 @@ Array [
37853827
"style": Array [],
37863828
},
37873829
],
3830+
"children": Array [],
37883831
"data": Object {},
37893832
"depth": 0,
37903833
"key": "key0",
3834+
"nextSibling": "key1",
3835+
"parent": null,
3836+
"prevSibling": null,
37913837
"text": "a",
37923838
"type": "header-three",
37933839
},
@@ -3798,9 +3844,13 @@ Array [
37983844
"style": Array [],
37993845
},
38003846
],
3847+
"children": Array [],
38013848
"data": Object {},
38023849
"depth": 0,
38033850
"key": "key1",
3851+
"nextSibling": null,
3852+
"parent": null,
3853+
"prevSibling": "key0",
38043854
"text": "b",
38053855
"type": "header-three",
38063856
},
@@ -3847,9 +3897,13 @@ Array [
38473897
"style": Array [],
38483898
},
38493899
],
3900+
"children": Array [],
38503901
"data": Object {},
38513902
"depth": 0,
38523903
"key": "key0",
3904+
"nextSibling": "key1",
3905+
"parent": null,
3906+
"prevSibling": null,
38533907
"text": "a",
38543908
"type": "header-four",
38553909
},
@@ -3860,9 +3914,13 @@ Array [
38603914
"style": Array [],
38613915
},
38623916
],
3917+
"children": Array [],
38633918
"data": Object {},
38643919
"depth": 0,
38653920
"key": "key1",
3921+
"nextSibling": null,
3922+
"parent": null,
3923+
"prevSibling": "key0",
38663924
"text": "b",
38673925
"type": "header-four",
38683926
},
@@ -3909,9 +3967,13 @@ Array [
39093967
"style": Array [],
39103968
},
39113969
],
3970+
"children": Array [],
39123971
"data": Object {},
39133972
"depth": 0,
39143973
"key": "key0",
3974+
"nextSibling": "key1",
3975+
"parent": null,
3976+
"prevSibling": null,
39153977
"text": "a",
39163978
"type": "header-five",
39173979
},
@@ -3922,9 +3984,13 @@ Array [
39223984
"style": Array [],
39233985
},
39243986
],
3987+
"children": Array [],
39253988
"data": Object {},
39263989
"depth": 0,
39273990
"key": "key1",
3991+
"nextSibling": null,
3992+
"parent": null,
3993+
"prevSibling": "key0",
39283994
"text": "b",
39293995
"type": "header-five",
39303996
},
@@ -3971,9 +4037,13 @@ Array [
39714037
"style": Array [],
39724038
},
39734039
],
4040+
"children": Array [],
39744041
"data": Object {},
39754042
"depth": 0,
39764043
"key": "key0",
4044+
"nextSibling": "key1",
4045+
"parent": null,
4046+
"prevSibling": null,
39774047
"text": "a",
39784048
"type": "header-six",
39794049
},
@@ -3984,9 +4054,13 @@ Array [
39844054
"style": Array [],
39854055
},
39864056
],
4057+
"children": Array [],
39874058
"data": Object {},
39884059
"depth": 0,
39894060
"key": "key1",
4061+
"nextSibling": null,
4062+
"parent": null,
4063+
"prevSibling": "key0",
39904064
"text": "b",
39914065
"type": "header-six",
39924066
},
@@ -4033,9 +4107,13 @@ Array [
40334107
"style": Array [],
40344108
},
40354109
],
4110+
"children": Array [],
40364111
"data": Object {},
40374112
"depth": 0,
40384113
"key": "key0",
4114+
"nextSibling": "key1",
4115+
"parent": null,
4116+
"prevSibling": null,
40394117
"text": "a",
40404118
"type": "unordered-list-item",
40414119
},
@@ -4046,9 +4124,13 @@ Array [
40464124
"style": Array [],
40474125
},
40484126
],
4127+
"children": Array [],
40494128
"data": Object {},
40504129
"depth": 0,
40514130
"key": "key1",
4131+
"nextSibling": null,
4132+
"parent": null,
4133+
"prevSibling": "key0",
40524134
"text": "b",
40534135
"type": "unordered-list-item",
40544136
},
@@ -4095,9 +4177,13 @@ Array [
40954177
"style": Array [],
40964178
},
40974179
],
4180+
"children": Array [],
40984181
"data": Object {},
40994182
"depth": 0,
41004183
"key": "key0",
4184+
"nextSibling": "key1",
4185+
"parent": null,
4186+
"prevSibling": null,
41014187
"text": "a",
41024188
"type": "unstyled",
41034189
},
@@ -4108,9 +4194,13 @@ Array [
41084194
"style": Array [],
41094195
},
41104196
],
4197+
"children": Array [],
41114198
"data": Object {},
41124199
"depth": 0,
41134200
"key": "key1",
4201+
"nextSibling": null,
4202+
"parent": null,
4203+
"prevSibling": "key0",
41144204
"text": "b",
41154205
"type": "unstyled",
41164206
},
@@ -4157,9 +4247,13 @@ Array [
41574247
"style": Array [],
41584248
},
41594249
],
4250+
"children": Array [],
41604251
"data": Object {},
41614252
"depth": 0,
41624253
"key": "key0",
4254+
"nextSibling": "key1",
4255+
"parent": null,
4256+
"prevSibling": null,
41634257
"text": "a",
41644258
"type": "code-block",
41654259
},
@@ -4170,9 +4264,13 @@ Array [
41704264
"style": Array [],
41714265
},
41724266
],
4267+
"children": Array [],
41734268
"data": Object {},
41744269
"depth": 0,
41754270
"key": "key1",
4271+
"nextSibling": null,
4272+
"parent": null,
4273+
"prevSibling": "key0",
41764274
"text": "b",
41774275
"type": "code-block",
41784276
},

0 commit comments

Comments
 (0)