Open milahu opened 1 year ago
Checklist
Describe the bug
the prosemirror-versions demo throws TypeError when permanentUserData is not passed to ySyncPlugin
prosemirror-versions
permanentUserData
ySyncPlugin
To Reproduce
in yjs-demos/prosemirror-versions/prosemirror-versions.js
replace
ySyncPlugin(yXmlFragment, { permanentUserData, colors }),
with
ySyncPlugin(yXmlFragment),
edit, create snapshot edit, create snapshot click old snapshot -> error
Expected behavior
better error message or different error handling
Environment Information
y-prosemirror@1.2.0
Additional context
the error is caused by this call
editorview.dispatch(editorview.state.tr.setMeta(ySyncPluginKey, { snapshot: Y.decodeSnapshot(version.snapshot), prevSnapshot: prevSnapshot == null ? Y.emptySnapshot : Y.decodeSnapshot(prevSnapshot) }))
which calls
y-prosemirror/src/plugins/sync-plugin.js
/** * @param {Y.Snapshot} snapshot * @param {Y.Snapshot} prevSnapshot * @param {Object} pluginState */ _renderSnapshot (snapshot, prevSnapshot, pluginState) { if (!snapshot) { snapshot = Y.snapshot(this.doc) } // clear mapping because we are going to rerender this.mapping = new Map() this.mux(() => { this.doc.transact((transaction) => { // before rendering, we are going to sanitize ops and split deleted ops // if they were deleted by seperate users. const pud = pluginState.permanentUserData // pud == null if (pud) { pud.dss.forEach((ds) => { Y.iterateDeletedStructs(transaction, ds, (_item) => {}) }) } /** * @param {'removed'|'added'} type * @param {Y.ID} id */ const computeYChange = (type, id) => { const user = type === 'added' ? pud.getUserByClientId(id.client) : pud.getUserByDeletedId(id) // TypeError: Cannot read properties of null (reading 'getUserByClientId')
Hey @milahu, did you find some workaround maybe?
this works
thank you. will need to tweak a bit as using hocuspocus with tiptap
hocuspocus
tiptap
Checklist
Describe the bug
the
prosemirror-versions
demo throws TypeError whenpermanentUserData
is not passed toySyncPlugin
To Reproduce
in yjs-demos/prosemirror-versions/prosemirror-versions.js
replace
with
edit, create snapshot edit, create snapshot click old snapshot -> error
Expected behavior
better error message or different error handling
Environment Information
y-prosemirror@1.2.0
Additional context
the error is caused by this call
which calls
y-prosemirror/src/plugins/sync-plugin.js