@@ -137,8 +137,7 @@ const runWithTransaction = async (callback) => {
137137
138138Saves a document along with its docId, version, and lastUpdatedTimestamp to your database.
139139
140- If a transaction ` tr ` is provided, it must be used for all database operations. If ` tr ` is null, all
141- database operations in this function should still be performed as an atomic unit.
140+ If a transaction ` tr ` is provided, it must be used for all database operations.
142141
143142``` ts
144143const saveDoc = async (tr , docId , docJSON , version ) => {
@@ -167,8 +166,7 @@ If you are using Postgres or MySql, getDoc should select the row holding the doc
167166` SELECT FOR UPDATE ` . This ensures that conflicting commits do not overwrite each other. We also
168167recommend putting a unique constraint on the commit table for the fields docId and commit version.
169168
170- If a transaction ` tr ` is provided, it must be used for all database operations. If ` tr ` is null, all
171- database operations in this function should still be performed as an atomic unit.
169+ If a transaction ` tr ` is provided, it must be used for all database operations.
172170
173171``` ts
174172const getDoc = async (tr , docId ) => {
@@ -190,8 +188,7 @@ export async function getDocument(tr: Transaction<DB> | null, id: string) {
190188
191189Saves a commit along with its version and ref to your database.
192190
193- If a transaction ` tr ` is provided, it must be used for all database operations. If ` tr ` is null, all
194- database operations in this function should still be performed as an atomic unit.
191+ If a transaction ` tr ` is provided, it must be used for all database operations.
195192
196193``` ts
197194const saveCommit = async (tr , docId , commitRef , commitVersion , commitSteps ) => {
@@ -215,8 +212,7 @@ export async function createCommit(tr: Transaction<DB> | null, commit: Insertabl
215212Given a docId and commitRef, retrieves the associated commit's steps and version from your database
216213and returns a joined CommitJSON object.
217214
218- If a transaction ` tr ` is provided, it must be used for all database operations. If ` tr ` is null, all
219- database operations in this function should still be performed as an atomic unit.
215+ If a transaction ` tr ` is provided, it must be used for all database operations.
220216
221217``` ts
222218const getCommit = async (tr , docId , commitRef ) => {
@@ -270,7 +266,7 @@ const broadcastManager = new RedisBroadcastManager({
270266
271267### [ Schema] ( https://pitter-patter.dev/docs/collab/reference/collab-server/interfaces/CollabAuthorityConfig#schema )
272268
273- This is just the schema for your Prosemirror document.
269+ This is just the schema for your ProseMirror document.
274270
275271### All together
276272
@@ -392,10 +388,7 @@ Next we need to create a listener for commit changes. The built-in
392388import { LongPollListener as CollabLongPollListener } from " @pitter-patter/collab-client" ;
393389
394390const commitListener = new CollabLongPollListener (
395- new URL (
396- ` /api/docs/${doc .id }/commits ` ,
397- typeof window !== " undefined" ? window .location .href : " http://localhost:3000" ,
398- ),
391+ new URL (` /api/docs/${doc .id }/commits ` , " http://localhost:3000" ),
399392);
400393```
401394
@@ -429,7 +422,8 @@ const collabConfig = {
429422 },
430423 receiveCommits : (commits ) => {
431424 // merge a new set of commits into your editor state for example:
432- // const newEditorState = commits.reduce((acc, commit) => acc.apply(receiveCommitTransaction(acc, commit)), oldEditorState),
425+ // const newEditorState = commits.reduce((acc, commit) => acc.apply(receiveCommitTransaction(acc, commit)), oldEditorState)
426+ // view.setState(newEditorState)
433427 },
434428 listener: commitListener ,
435429};
@@ -451,4 +445,4 @@ When the local editor state changes, you need to tell collabClient to create and
451445collabClient .send (state ).catch ((e ) => console .error (e ));
452446```
453447
454- That's it! Your document can now be edited collaboratively by mulitiple simultaneous users.
448+ That's it! Your document can now be edited collaboratively by multiple simultaneous users.
0 commit comments