Skip to content

Commit 066ab4c

Browse files
committed
fix(Slate) HTML Blocks and Inlines now should roundtrip
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 7e1a4f9 commit 066ab4c

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

packages/markdown-slate/src/ToSlateVisitor.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ class ToSlateVisitor {
287287
};
288288
break;
289289
case 'HtmlBlock':
290-
case 'HtmlInline':
291290
result = {
292291
object: 'block',
293292
type: 'html_block',
@@ -310,6 +309,16 @@ class ToSlateVisitor {
310309
}]
311310
};
312311
break;
312+
case 'HtmlInline':
313+
result = {
314+
object: 'inline',
315+
type: 'html_inline',
316+
data: {
317+
content: thing.text,
318+
},
319+
nodes: [] // XXX
320+
};
321+
break;
313322
case 'List':
314323
result = {
315324
'object': 'block',

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,12 @@ Object {
16341634
"nodes": Array [
16351635
Object {
16361636
"$class": "org.accordproject.commonmark.HtmlBlock",
1637-
"text": undefined,
1637+
"text": "<foo>
1638+
this
1639+
is an
1640+
html block.
1641+
</foo>
1642+
end.",
16381643
},
16391644
],
16401645
"xmlns": "http://commonmark.org/xml/1.0",
@@ -1698,7 +1703,12 @@ Object {
16981703
"nodes": Array [
16991704
Object {
17001705
"$class": "org.accordproject.commonmark.HtmlBlock",
1701-
"text": undefined,
1706+
"text": "<foo>
1707+
this
1708+
is an
1709+
html block.
1710+
</foo>
1711+
end.",
17021712
},
17031713
],
17041714
"xmlns": "http://commonmark.org/xml/1.0",

packages/markdown-slate/src/slateToCiceroMarkDom.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ function _recursive(parent, nodes) {
136136
result = {$class : `${NS}.CodeBlock`, text: getText(node)};
137137
break;
138138
case 'html_block':
139-
result = {$class : `${NS}.HtmlBlock`, text: node.text};
139+
result = {$class : `${NS}.HtmlBlock`, text: getText(node)};
140140
break;
141141
case 'html_inline':
142-
result = {$class : `${NS}.HtmlInline`};
142+
result = {$class : `${NS}.HtmlInline`, text: node.data.content};
143143
break;
144144
case 'ol_list':
145145
case 'ul_list': {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This is text with <foo/> inside it
2+
3+
<foo/>
4+
5+
This is more text

0 commit comments

Comments
 (0)