I am able to get it working to add the steps to the doc.
doc_json = readFileSync('data/doc.txt', () => { null })
doc_json = JSON.parse(doc_json)
// read the initial document (or have it somewhere)
// var doc_node = Node.fromJSON(custom_schema, doc_json);
var doc_node = custom_schema.nodeFromJSON(doc_json)
step_jsons = readFileSync('data/step.txt', () => { null })
step_jsons = step_jsons.toString().split('\n').filter(Boolean)
for (var step_json of step_jsons) {
step_json = JSON.parse(step_json)
for (var step of step_json['steps']) {
var step = Step.fromJSON(custom_schema, step)
var result = step.apply(doc_node)
if (result.failed) {
} else {
doc_node = result.doc
// console.log(doc_node.toJSON())
}
}
}
console.log(doc_node)
but it seems like there are some unexpected mark_type:
RangeError: There is no mark type mark-font-test in this schema
This is the step.txt
{"version":300,"steps":[{"stepType":"replace","from":265,"to":265,"slice":{"content":[{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null,"objectId":null}},{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null,"objectId":null}}],"openStart":1,"openEnd":1},"structure":true}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":301,"steps":[{"stepType":"replace","from":267,"to":267,"slice":{"content":[{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null,"objectId":null}},{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null,"objectId":null}}],"openStart":1,"openEnd":1},"structure":true}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":302,"steps":[{"stepType":"addMark","mark":{"type":"mark-font-test","attrs":{"name":"Acme"}},"from":147,"to":156}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":303,"steps":[{"stepType":"addMark","mark":{"type":"mark-font-size","attrs":{"pt":30}},"from":18,"to":27}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":304,"steps":[{"stepType":"addMark","mark":{"type":"strike"},"from":13,"to":16}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":305,"steps":[{"stepType":"replace","from":11,"to":11,"slice":{"content":[{"type":"text","marks":[{"type":"super"}],"text":"a"}]}}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
{"version":306,"steps":[{"stepType":"replace","from":12,"to":12,"slice":{"content":[{"type":"text","marks":[{"type":"super"}],"text":"w"}]}}],"clientID":"827fec50-fca0-11ea-9678-71616149d424"}
I looked all over the library, but seems like I cannot find anything called: mark-font-test
. Could anyone point me in the right direction?
Thank you!