Code Monkey home page Code Monkey logo

Comments (2)

wxfred avatar wxfred commented on September 25, 2024

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)

from hocuspocus.

wxfred avatar wxfred commented on September 25, 2024

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' ]

from hocuspocus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.