@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.
Returns the value you return from the api
callback.
The ID of the room to use.
The Liveblocks client to use.
Optional. The ProseMirror schema to use for the document. If no schema is provided, the default schema is Tiptap StarterKit, Liveblocks mentions, and Liveblocks comments.
Optional. The
field to use
for the document. Defaults to default
.
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.
doc
is the ProseMirror document. tr
is an editor state transaction.
Transaction is a subclass of ProseMirror’s Transforms. On the ProseMirror
website you can find a full list of
transforms
and transactions
functions.
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.
Returns the text retrieved from the document.
Optional. The separator to use for blocks, e.g. <br />
. Defaults to \n\n
.
Optional. The serializers to use for text. Defaults to {}
.
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.
The content to replace your document.
Returns the current ProseMirror state.
Your editor’s ProseMirror state.
Returns a serialized JSON object representation of your document. See ProseMirror’s .toJSON documentation for more information.
Your editor’s serialized JSON state.
Clears the content of the document.
Returns a markdown string
of your document.
Returns the markdown string.
Optional. A markdown serializer to use. By default it uses the
defaultMarkdownSerializer
from
prosemirror-markdown.
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.