Skip to content

Instantly share code, notes, and snippets.

@saranrapjs
Created September 9, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saranrapjs/467dce66e298c8589c780879fb2a559b to your computer and use it in GitHub Desktop.
Save saranrapjs/467dce66e298c8589c780879fb2a559b to your computer and use it in GitHub Desktop.
Converts real & present ProseMirror nodes to their test-builder equivalents
// suitable for use w/ this: https://github.com/ProseMirror/prosemirror-test-builder
function toProseMirrorTestBuilder(node, funcPrefix = 'nodes.') {
if (node.isText) {
return `"${node.textContent}"`;
}
return `${funcPrefix}${node.type.name}(${node.content.content.map(child => toProseMirrorTestBuilder(child))})`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment