Skip to content

Commit 50e52df

Browse files
committed
fix(slate) Encapsulate Slate's from JSON call
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 943ad30 commit 50e52df

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
const fs = require('fs');
2020
const path = require('path');
21-
const Value = require('slate').Value;
2221
const CommonMark = require('@accordproject/markdown-common').CommonMark;
2322
const SlateMark = require('./SlateMark');
2423

@@ -53,9 +52,7 @@ describe('slate', () => {
5352
getSlateFiles().forEach( ([file, jsonText], index) => {
5453
it(`converts ${file} to concerto`, () => {
5554
const slateDom = JSON.parse(jsonText);
56-
const value = Value.fromJSON(slateDom);
57-
const json = slateMark.toCommonMark(value.document);
58-
console.log('From slate', JSON.stringify(json, null, 4));
55+
const json = slateMark.toCommonMark(slateDom);
5956

6057
// check no changes to the concerto
6158
expect(json).toMatchSnapshot();

packages/markdown-slate/src/SlateMark.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
'use strict';
1616

17+
const Value = require('slate').Value;
1718
const ToSlateVisitor = require('./ToSlateVisitor');
1819
const slateToCommonMarkAst = require('./slateToCommonMarkAst');
1920

@@ -77,7 +78,8 @@ class SlateMark {
7778
* @returns {*} the common mark AST
7879
*/
7980
toCommonMark(json) {
80-
return this.serializer.toJSON(slateToCommonMarkAst(json));
81+
const value = Value.fromJSON(json);
82+
return this.serializer.toJSON(slateToCommonMarkAst(value.document));
8183
}
8284
}
8385

0 commit comments

Comments
 (0)