Skip to content

Commit 3fb3c5d

Browse files
committed
fix(slate) Adjust empty text node removal
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 0bfad83 commit 3fb3c5d

File tree

2 files changed

+41
-58
lines changed

2 files changed

+41
-58
lines changed

packages/markdown-slate/src/__snapshots__/SlateTransformer.test.js.snap

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ Object {
183183
],
184184
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1f",
185185
},
186-
Object {
187-
"$class": "org.accordproject.commonmark.Paragraph",
188-
"nodes": Array [],
189-
},
190186
],
191187
"xmlns": "http://commonmark.org/xml/1.0",
192188
}
@@ -714,10 +710,6 @@ Object {
714710
],
715711
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1f",
716712
},
717-
Object {
718-
"$class": "org.accordproject.commonmark.Paragraph",
719-
"nodes": Array [],
720-
},
721713
],
722714
"xmlns": "http://commonmark.org/xml/1.0",
723715
}
@@ -1517,12 +1509,7 @@ Object {
15171509
exports[`slate converts empty.json to and from CiceroMark 1`] = `
15181510
Object {
15191511
"$class": "org.accordproject.commonmark.Document",
1520-
"nodes": Array [
1521-
Object {
1522-
"$class": "org.accordproject.commonmark.Paragraph",
1523-
"nodes": Array [],
1524-
},
1525-
],
1512+
"nodes": Array [],
15261513
"xmlns": "http://commonmark.org/xml/1.0",
15271514
}
15281515
`;
@@ -1554,12 +1541,7 @@ Object {
15541541
exports[`slate converts empty.json to and from CiceroMark 4`] = `
15551542
Object {
15561543
"$class": "org.accordproject.commonmark.Document",
1557-
"nodes": Array [
1558-
Object {
1559-
"$class": "org.accordproject.commonmark.Paragraph",
1560-
"nodes": Array [],
1561-
},
1562-
],
1544+
"nodes": Array [],
15631545
"xmlns": "http://commonmark.org/xml/1.0",
15641546
}
15651547
`;
@@ -2122,7 +2104,12 @@ Object {
21222104
Object {
21232105
"$class": "org.accordproject.commonmark.Image",
21242106
"destination": "https://studio.accordproject.org/static/img/logo.png",
2125-
"nodes": Array [],
2107+
"nodes": Array [
2108+
Object {
2109+
"$class": "org.accordproject.commonmark.Text",
2110+
"text": "",
2111+
},
2112+
],
21262113
"title": "title",
21272114
},
21282115
],
@@ -2204,7 +2191,12 @@ Object {
22042191
Object {
22052192
"$class": "org.accordproject.commonmark.Image",
22062193
"destination": "https://studio.accordproject.org/static/img/logo.png",
2207-
"nodes": Array [],
2194+
"nodes": Array [
2195+
Object {
2196+
"$class": "org.accordproject.commonmark.Text",
2197+
"text": "",
2198+
},
2199+
],
22082200
"title": "title",
22092201
},
22102202
],
@@ -2233,7 +2225,12 @@ Object {
22332225
Object {
22342226
"$class": "org.accordproject.commonmark.Image",
22352227
"destination": "https://studio.accordproject.org/static/img/logo.png",
2236-
"nodes": Array [],
2228+
"nodes": Array [
2229+
Object {
2230+
"$class": "org.accordproject.commonmark.Text",
2231+
"text": "",
2232+
},
2233+
],
22372234
"title": "",
22382235
},
22392236
],
@@ -2315,7 +2312,12 @@ Object {
23152312
Object {
23162313
"$class": "org.accordproject.commonmark.Image",
23172314
"destination": "https://studio.accordproject.org/static/img/logo.png",
2318-
"nodes": Array [],
2315+
"nodes": Array [
2316+
Object {
2317+
"$class": "org.accordproject.commonmark.Text",
2318+
"text": "",
2319+
},
2320+
],
23192321
"title": "",
23202322
},
23212323
],
@@ -2571,10 +2573,6 @@ Object {
25712573
],
25722574
"src": "https://templates.accordproject.org/archives/[email protected]",
25732575
},
2574-
Object {
2575-
"$class": "org.accordproject.commonmark.Paragraph",
2576-
"nodes": Array [],
2577-
},
25782576
],
25792577
"xmlns": "http://commonmark.org/xml/1.0",
25802578
}
@@ -3104,10 +3102,6 @@ Object {
31043102
],
31053103
"src": "https://templates.accordproject.org/archives/[email protected]",
31063104
},
3107-
Object {
3108-
"$class": "org.accordproject.commonmark.Paragraph",
3109-
"nodes": Array [],
3110-
},
31113105
],
31123106
"xmlns": "http://commonmark.org/xml/1.0",
31133107
}
@@ -4154,10 +4148,6 @@ Object {
41544148
],
41554149
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1f",
41564150
},
4157-
Object {
4158-
"$class": "org.accordproject.commonmark.Paragraph",
4159-
"nodes": Array [],
4160-
},
41614151
Object {
41624152
"$class": "org.accordproject.ciceromark.Clause",
41634153
"clauseid": "479adbb4-dc55-4d1a-ab12-z6c5e16900c0",
@@ -4199,10 +4189,6 @@ Object {
41994189
],
42004190
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1b",
42014191
},
4202-
Object {
4203-
"$class": "org.accordproject.commonmark.Paragraph",
4204-
"nodes": Array [],
4205-
},
42064192
Object {
42074193
"$class": "org.accordproject.ciceromark.Clause",
42084194
"clauseid": "479adbb4-dc55-4d1a-ab12-c6c5e16900c0",
@@ -4219,10 +4205,6 @@ Object {
42194205
],
42204206
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1c",
42214207
},
4222-
Object {
4223-
"$class": "org.accordproject.commonmark.Paragraph",
4224-
"nodes": Array [],
4225-
},
42264208
],
42274209
"xmlns": "http://commonmark.org/xml/1.0",
42284210
}
@@ -4858,10 +4840,6 @@ Object {
48584840
],
48594841
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1f",
48604842
},
4861-
Object {
4862-
"$class": "org.accordproject.commonmark.Paragraph",
4863-
"nodes": Array [],
4864-
},
48654843
Object {
48664844
"$class": "org.accordproject.ciceromark.Clause",
48674845
"clauseid": "479adbb4-dc55-4d1a-ab12-z6c5e16900c0",
@@ -4903,10 +4881,6 @@ Object {
49034881
],
49044882
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1b",
49054883
},
4906-
Object {
4907-
"$class": "org.accordproject.commonmark.Paragraph",
4908-
"nodes": Array [],
4909-
},
49104884
Object {
49114885
"$class": "org.accordproject.ciceromark.Clause",
49124886
"clauseid": "479adbb4-dc55-4d1a-ab12-c6c5e16900c0",
@@ -4923,10 +4897,6 @@ Object {
49234897
],
49244898
"src": "ap://[email protected]#721d1aa0999a5d278653e211ae2a64b75fdd8ca6fa1f34255533c942404c5c1c",
49254899
},
4926-
Object {
4927-
"$class": "org.accordproject.commonmark.Paragraph",
4928-
"nodes": Array [],
4929-
},
49304900
],
49314901
"xmlns": "http://commonmark.org/xml/1.0",
49324902
}
@@ -5016,7 +4986,12 @@ Object {
50164986
},
50174987
Object {
50184988
"$class": "org.accordproject.commonmark.Item",
5019-
"nodes": Array [],
4989+
"nodes": Array [
4990+
Object {
4991+
"$class": "org.accordproject.commonmark.Text",
4992+
"text": "",
4993+
},
4994+
],
50204995
},
50214996
],
50224997
"start": undefined,
@@ -5294,7 +5269,12 @@ Object {
52945269
},
52955270
Object {
52965271
"$class": "org.accordproject.commonmark.Item",
5297-
"nodes": Array [],
5272+
"nodes": Array [
5273+
Object {
5274+
"$class": "org.accordproject.commonmark.Text",
5275+
"text": "",
5276+
},
5277+
],
52985278
},
52995279
],
53005280
"start": undefined,

packages/markdown-slate/src/slateToCiceroMarkDom.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ function _recursive(parent, nodes) {
163163
// process any children, attaching to first child if it exists (for list items)
164164
if(node.children && result && result.nodes) {
165165
_recursive(result.nodes[0] ? result.nodes[0] : result, node.children);
166+
if (result.nodes.length === 0) {
167+
result.nodes.push({$class : `${NS}.Text`, text : ''});
168+
}
166169
}
167170

168171
if(!parent.nodes) {

0 commit comments

Comments
 (0)