Getting Tiptap state on the server
Using
@liveblocks/node-prosemirror
,
it’s possible to retrieve the state of your Tiptap document on the server.
Tiptap is not easy to edit on the server directly, which is why it’s necessary
to use the ProseMirror package. Tiptap is an extension of ProseMirror.
Getting document state
To get your document state, you can use
withProsemirrorDocument
and
api.getText
.
Modifying document state
To modify document state with transactions, use
api.update
. On
the ProseMirror website you can find a full list of
transforms
and
transactions functions.
You’ve now learned to fetch and modify document state!
Using Yjs APIs instead
We don’t generally recommend it, but it’s also possible to use
@liveblocks/node
to retrieve the state
of your Tiptap document, and its Y.Doc
, on
the server. This may give you more control in some cases.
With
Liveblocks.getYjsDocumentAsBinaryUpdate
you can fetch your Yjs data, and place it inside a Y.Doc
. Because Tiptap is a
wrapper around ProseMirror, we can then call yDocToProseMirror
from
y-prosemirror
to retrieve the Tiptap
editor’s state.
If you’d like to edit your Y.Doc
, make sure to read
how to use your Y.Doc
on the server.