Download this file
| 1 | import assert from 'node:assert/strict' |
| 2 | import fs from 'node:fs' |
| 3 | import * as Y from 'yjs' |
| 4 | import { yXmlFragmentToProseMirrorRootNode } from 'y-prosemirror' |
| 5 | import { schema } from 'prosemirror-schema-basic' |
| 6 | const doc = new Y.Doc() |
| 7 | Y.applyUpdate(doc, fs.readFileSync(0)) |
| 8 | const root = yXmlFragmentToProseMirrorRootNode(doc.getXmlFragment('prosemirror'), schema) |
| 9 | root.check() |
| 10 | assert.equal(root.childCount, 2) |
| 11 | assert.equal(root.child(0).type.name, 'heading') |
| 12 | assert.equal(root.child(0).attrs.level, 2) |
| 13 | assert.equal(root.child(0).textContent, 'Agenda 😀') |
| 14 | assert.equal(root.child(1).type.name, 'paragraph') |
| 15 | assert.equal(root.child(1).textContent, '<script>& Café\n二') |
| 16 | console.log('initial content: real Yjs/ProseMirror parity passed') |
| 17 | |