Skip to content

Commit

Permalink
Irmerk dselman ciceroui (#53)
Browse files Browse the repository at this point in the history
* fix(slate): move text value from data to nodes

Signed-off-by: irmerk <[email protected]>

* (chore) update tests to accomodate inlines with nested text nodes

Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman authored Oct 5, 2019
1 parent 3878ac6 commit b0996d0
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 184 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 84 additions & 70 deletions packages/markdown-cli/test/data/acceptance-slate.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"shipper",
"value":"%22Party%20A%22"
"id":"shipper"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20A%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -103,12 +104,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"receiver",
"value":"%22Party%20B%22"
"id":"receiver"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20B%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -128,12 +130,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"deliverable",
"value":"%22Widgets%22"
"id":"deliverable"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Widgets%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -146,12 +149,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"receiver",
"value":"%22Party%20B%22"
"id":"receiver"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20B%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -164,12 +168,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"shipper",
"value":"%22Party%20A%22"
"id":"shipper"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20A%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -182,12 +187,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"deliverable",
"value":"%22Widgets%22"
"id":"deliverable"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Widgets%22",
"marks" : []
}]
},
{
"object":"text",
Expand Down Expand Up @@ -216,12 +222,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"receiver",
"value":"%22Party%20B%22"
"id":"receiver"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20B%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -234,12 +241,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"businessDays",
"value":"10"
"id":"businessDays"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"10",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -266,12 +274,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"deliverable",
"value":"%22Widgets%22"
"id":"deliverable"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Widgets%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -284,12 +293,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"shipper",
"value":"%22Party%20A%22"
"id":"shipper"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20A%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -302,12 +312,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"deliverable",
"value":"%22Widgets%22"
"id":"deliverable"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Widgets%22",
"marks" : []
}]
},
{
"object":"text",
Expand Down Expand Up @@ -364,12 +375,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"deliverable",
"value":"%22Widgets%22"
"id":"deliverable"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Widgets%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -382,12 +394,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"shipper",
"value":"%22Party%20A%22"
"id":"shipper"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Party%20A%22",
"marks" : []
}]
},
{
"object":"text",
Expand All @@ -400,12 +413,13 @@
"object":"inline",
"type":"variable",
"data":{
"id":"attachment",
"value":"%22Attachment%20X%22"
"id":"attachment"
},
"nodes":[

]
"nodes":[{
"object":"text",
"text":"%22Attachment%20X%22",
"marks" : []
}]
},
{
"object":"text",
Expand Down
19 changes: 12 additions & 7 deletions packages/markdown-slate/src/SlateTransformer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ describe('slate', () => {
'object': 'inline',
'type': 'variable',
'data': {
'id': 'foo',
'value': 'bar'
'id': 'foo'
},
'nodes': []
'nodes': [{
'marks': [],
'object': 'text',
'text': 'bar'
}]
}
]
}
Expand Down Expand Up @@ -138,10 +141,12 @@ describe('slate', () => {
{
'object': 'inline',
'type': 'computed',
'data': {
'value': 'bar'
},
'nodes': []
'data': {},
'nodes': [{
'marks': [],
'object': 'text',
'text': 'bar'
}]
}
]
}
Expand Down
15 changes: 9 additions & 6 deletions packages/markdown-slate/src/ToSlateVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,22 @@ class ToSlateVisitor {
type: 'variable',
data: {
id: thing.id,
value: thing.value
},
nodes: [],
nodes: [{
object: 'text',
text: thing.value,
}],
};
break;
case 'ComputedVariable':
result = {
object: 'inline',
type: 'computed',
data: {
value: thing.value
},
nodes: [],
data: {},
nodes: [{
object: 'text',
text: thing.value,
}],
};
break;
case 'CodeBlock':
Expand Down
Loading

0 comments on commit b0996d0

Please sign in to comment.