Closed wxfred closed 5 months ago
I tried this
...
import { TiptapTransformer } from '@hocuspocus/transformer'
...
async onChange(data) {
const prosemirrorJSON = TiptapTransformer.fromYdoc(data.document);
console.log(prosemirrorJSON)
},
crash came out
[onChange] item.toDelta is not a function
file:///xxxx/hocuspocus/node_modules/y-prosemirror/src/lib.js:331
const delta = item.toDelta()
^
TypeError: item.toDelta is not a function
at serialize (file:///xxxx/hocuspocus/node_modules/y-prosemirror/src/lib.js:331:26)
at Array.map (<anonymous>)
at yXmlFragmentToProsemirrorJSON (file:///xxxx/hocuspocus/node_modules/y-prosemirror/src/lib.js:375:20)
at yDocToProsemirrorJSON (file:///xxxx/hocuspocus/node_modules/y-prosemirror/src/lib.js:308:10)
at Prosemirror.fromYdoc (file:///xxxx/hocuspocus/node_modules/@hocuspocus/transformer/dist/hocuspocus-transformer.esm.js:2625:20)
at Tiptap.fromYdoc (file:///xxxx/hocuspocus/node_modules/@hocuspocus/transformer/dist/hocuspocus-transformer.esm.js:2667:39)
at Object.onChange (file:///xxxx/hocuspocus/index.js:14:47)
at file:///xxxx/hocuspocus/node_modules/@hocuspocus/server/dist/hocuspocus-server.esm.js:2806:109
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Sorry, I located my mistakes:
On the backend, I used a get instead of getArray, and data.document.toJSON() is deprecated.
console.log('tasks', data.document.**getArray**('tasks').toJSON()) // logs: tasks [ 'buy milk' ]
Description I followed the example on https://tiptap.dev/docs/hocuspocus/getting-started
My backend
My frontend (Vue)
And the log from frontend
tasks were modified ['buy milk']
But on the server side, the log is
Why tasks on backend is undefined? Is there anything I missed?
Environment?
Additional context Add any other context about the problem here.