@liveblocks/node-prosemirror
provides a Node.js package to export and modify
ProseMirror. Because Tiptap uses ProseMirror under
the hood, this package can be used to modify
Tiptap documents as well.
withProsemirrorDocument
is the main entry point to modifying a document on the
server. It takes a room ID and a
Liveblocks Node client,
and returns a callback used to work with ProseMirror documents stored in
Liveblocks.
Get your editor’s text content by returning api.getText()
inside the callback.
You can easily modify your document with the ProseMirror document API.
Liveblocks provides api.update
which is a callback that provides the current
document and a ProseMirror transaction. This makes it easy to use ProseMirror’s
built in functions. When you've finished, return the transaction and any changes
will be persisted, and appear in realtime to connected users as soon as the
update
promise resolves.
Returns the text content of the document.: This api uses Tiptap’s getText
internally. TextSerializers are a concept from
Tiptap.
If you are having trouble with a ProseMirror document, you may want to use
api.getEditorState().doc.textBetween()
instead.
For convenience, some methods such as setContent
are provided at the API
level. Here’s an example that sets a document and returns the JSON content after
it has been updated.
Returns the current ProseMirror state.
Returns a serialized JSON object representation of your document. See ProseMirror’s .toJSON documentation for more information.
Clears the content of the document.
Returns a markdown string
of your document.
You can use a custom markdown serializer.
We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.