Skip to content

Commit b0996d0

Browse files
authored
Irmerk dselman ciceroui (#53)
* fix(slate): move text value from data to nodes Signed-off-by: irmerk <jolenelanglinais@gmail.com> * (chore) update tests to accomodate inlines with nested text nodes Signed-off-by: Dan Selman <danscode@selman.org>
1 parent 3878ac6 commit b0996d0

7 files changed

Lines changed: 276 additions & 184 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/markdown-cli/test/data/acceptance-slate.json

Lines changed: 84 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@
8585
"object":"inline",
8686
"type":"variable",
8787
"data":{
88-
"id":"shipper",
89-
"value":"%22Party%20A%22"
88+
"id":"shipper"
9089
},
91-
"nodes":[
92-
93-
]
90+
"nodes":[{
91+
"object":"text",
92+
"text":"%22Party%20A%22",
93+
"marks" : []
94+
}]
9495
},
9596
{
9697
"object":"text",
@@ -103,12 +104,13 @@
103104
"object":"inline",
104105
"type":"variable",
105106
"data":{
106-
"id":"receiver",
107-
"value":"%22Party%20B%22"
107+
"id":"receiver"
108108
},
109-
"nodes":[
110-
111-
]
109+
"nodes":[{
110+
"object":"text",
111+
"text":"%22Party%20B%22",
112+
"marks" : []
113+
}]
112114
},
113115
{
114116
"object":"text",
@@ -128,12 +130,13 @@
128130
"object":"inline",
129131
"type":"variable",
130132
"data":{
131-
"id":"deliverable",
132-
"value":"%22Widgets%22"
133+
"id":"deliverable"
133134
},
134-
"nodes":[
135-
136-
]
135+
"nodes":[{
136+
"object":"text",
137+
"text":"%22Widgets%22",
138+
"marks" : []
139+
}]
137140
},
138141
{
139142
"object":"text",
@@ -146,12 +149,13 @@
146149
"object":"inline",
147150
"type":"variable",
148151
"data":{
149-
"id":"receiver",
150-
"value":"%22Party%20B%22"
152+
"id":"receiver"
151153
},
152-
"nodes":[
153-
154-
]
154+
"nodes":[{
155+
"object":"text",
156+
"text":"%22Party%20B%22",
157+
"marks" : []
158+
}]
155159
},
156160
{
157161
"object":"text",
@@ -164,12 +168,13 @@
164168
"object":"inline",
165169
"type":"variable",
166170
"data":{
167-
"id":"shipper",
168-
"value":"%22Party%20A%22"
171+
"id":"shipper"
169172
},
170-
"nodes":[
171-
172-
]
173+
"nodes":[{
174+
"object":"text",
175+
"text":"%22Party%20A%22",
176+
"marks" : []
177+
}]
173178
},
174179
{
175180
"object":"text",
@@ -182,12 +187,13 @@
182187
"object":"inline",
183188
"type":"variable",
184189
"data":{
185-
"id":"deliverable",
186-
"value":"%22Widgets%22"
190+
"id":"deliverable"
187191
},
188-
"nodes":[
189-
190-
]
192+
"nodes":[{
193+
"object":"text",
194+
"text":"%22Widgets%22",
195+
"marks" : []
196+
}]
191197
},
192198
{
193199
"object":"text",
@@ -216,12 +222,13 @@
216222
"object":"inline",
217223
"type":"variable",
218224
"data":{
219-
"id":"receiver",
220-
"value":"%22Party%20B%22"
225+
"id":"receiver"
221226
},
222-
"nodes":[
223-
224-
]
227+
"nodes":[{
228+
"object":"text",
229+
"text":"%22Party%20B%22",
230+
"marks" : []
231+
}]
225232
},
226233
{
227234
"object":"text",
@@ -234,12 +241,13 @@
234241
"object":"inline",
235242
"type":"variable",
236243
"data":{
237-
"id":"businessDays",
238-
"value":"10"
244+
"id":"businessDays"
239245
},
240-
"nodes":[
241-
242-
]
246+
"nodes":[{
247+
"object":"text",
248+
"text":"10",
249+
"marks" : []
250+
}]
243251
},
244252
{
245253
"object":"text",
@@ -266,12 +274,13 @@
266274
"object":"inline",
267275
"type":"variable",
268276
"data":{
269-
"id":"deliverable",
270-
"value":"%22Widgets%22"
277+
"id":"deliverable"
271278
},
272-
"nodes":[
273-
274-
]
279+
"nodes":[{
280+
"object":"text",
281+
"text":"%22Widgets%22",
282+
"marks" : []
283+
}]
275284
},
276285
{
277286
"object":"text",
@@ -284,12 +293,13 @@
284293
"object":"inline",
285294
"type":"variable",
286295
"data":{
287-
"id":"shipper",
288-
"value":"%22Party%20A%22"
296+
"id":"shipper"
289297
},
290-
"nodes":[
291-
292-
]
298+
"nodes":[{
299+
"object":"text",
300+
"text":"%22Party%20A%22",
301+
"marks" : []
302+
}]
293303
},
294304
{
295305
"object":"text",
@@ -302,12 +312,13 @@
302312
"object":"inline",
303313
"type":"variable",
304314
"data":{
305-
"id":"deliverable",
306-
"value":"%22Widgets%22"
315+
"id":"deliverable"
307316
},
308-
"nodes":[
309-
310-
]
317+
"nodes":[{
318+
"object":"text",
319+
"text":"%22Widgets%22",
320+
"marks" : []
321+
}]
311322
},
312323
{
313324
"object":"text",
@@ -364,12 +375,13 @@
364375
"object":"inline",
365376
"type":"variable",
366377
"data":{
367-
"id":"deliverable",
368-
"value":"%22Widgets%22"
378+
"id":"deliverable"
369379
},
370-
"nodes":[
371-
372-
]
380+
"nodes":[{
381+
"object":"text",
382+
"text":"%22Widgets%22",
383+
"marks" : []
384+
}]
373385
},
374386
{
375387
"object":"text",
@@ -382,12 +394,13 @@
382394
"object":"inline",
383395
"type":"variable",
384396
"data":{
385-
"id":"shipper",
386-
"value":"%22Party%20A%22"
397+
"id":"shipper"
387398
},
388-
"nodes":[
389-
390-
]
399+
"nodes":[{
400+
"object":"text",
401+
"text":"%22Party%20A%22",
402+
"marks" : []
403+
}]
391404
},
392405
{
393406
"object":"text",
@@ -400,12 +413,13 @@
400413
"object":"inline",
401414
"type":"variable",
402415
"data":{
403-
"id":"attachment",
404-
"value":"%22Attachment%20X%22"
416+
"id":"attachment"
405417
},
406-
"nodes":[
407-
408-
]
418+
"nodes":[{
419+
"object":"text",
420+
"text":"%22Attachment%20X%22",
421+
"marks" : []
422+
}]
409423
},
410424
{
411425
"object":"text",

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ describe('slate', () => {
102102
'object': 'inline',
103103
'type': 'variable',
104104
'data': {
105-
'id': 'foo',
106-
'value': 'bar'
105+
'id': 'foo'
107106
},
108-
'nodes': []
107+
'nodes': [{
108+
'marks': [],
109+
'object': 'text',
110+
'text': 'bar'
111+
}]
109112
}
110113
]
111114
}
@@ -138,10 +141,12 @@ describe('slate', () => {
138141
{
139142
'object': 'inline',
140143
'type': 'computed',
141-
'data': {
142-
'value': 'bar'
143-
},
144-
'nodes': []
144+
'data': {},
145+
'nodes': [{
146+
'marks': [],
147+
'object': 'text',
148+
'text': 'bar'
149+
}]
145150
}
146151
]
147152
}

packages/markdown-slate/src/ToSlateVisitor.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,22 @@ class ToSlateVisitor {
153153
type: 'variable',
154154
data: {
155155
id: thing.id,
156-
value: thing.value
157156
},
158-
nodes: [],
157+
nodes: [{
158+
object: 'text',
159+
text: thing.value,
160+
}],
159161
};
160162
break;
161163
case 'ComputedVariable':
162164
result = {
163165
object: 'inline',
164166
type: 'computed',
165-
data: {
166-
value: thing.value
167-
},
168-
nodes: [],
167+
data: {},
168+
nodes: [{
169+
object: 'text',
170+
text: thing.value,
171+
}],
169172
};
170173
break;
171174
case 'CodeBlock':

0 commit comments

Comments
 (0)