Collaborating on decks
Several people can edit a deck at once: everyone sees the others' edits within a network round trip, where they are and what they have selected, can comment on slides and shapes, and can browse and restore versions. @nextgensoftwares/folio-slides-collab does this on the same collaboration stack as documents; it adds no protocol and no server.
How it fits (design note)
The deck is stored and synced as a Folio document: one deckInfo node (size...), one theme node per theme, one sheet node per master and layout, one slide node per slide, slideShape nodes inside sheets and slides (and inside groups, for their children), and the shapes' text as slidePara paragraphs with slideRun marks. Each property users edit on its own (position and size, fill, outline, geometry, name, transition, animations, notes, background...) is its own node attribute. A deck edit is turned into ProseMirror steps (deckTransaction); remote steps turn back into deck objects (docToDeck, unchanged slides and shapes keep their identity, so only what changed is laid out again).
| Reused unchanged | From |
|---|---|
| Wire protocol, step sync, rebasing, outbox (offline edits survive reloads), reconnects/backoff, push-parts for big decks | folio-plugin-collab CollabClient, folio-sync |
Server: storage, /docs create/list, WebSocket rooms, version + checksum verification of every push, mass-delete guard | folio-server-node (only its schema is the deck schema) |
| Presence (names, colours, status, typing), the people bar | PresencePayload, PeerView, SlidesApp people |
| Comments: threads, replies, resolve, server store and routes, live updates | folio-plugin-comments (ServerCommentStore, commentIds node anchors) |
| Version history: timeline, deltas, checksummed views, named versions, restore | folio-plugin-collab HistoryStore / HistoryClient |
| Undo of your own changes only | prosemirror-history on the shared document |
| Text merging inside a shape | ProseMirror steps (two people typing in one box merge by character) |
| New (small) | Where |
|---|---|
| The deck node types and the deck ⇄ document mapping | deckSchema, deckToDoc / docToDeck |
| Deck diff → steps | deckTransaction |
| Ids for new slides/shapes no one else can create at once | claimIds |
extra presence data (slide, selected shapes, pointer) | an optional field in PresencePayload (plugin-collab) |
| Overlays: remote selections and pointers, collaborators on thumbnails; deck Comments and Versions tabs | /react |
| Extension points in the slides UI | 'surface' and 'thumbnail' slots (plugin-slides); history option (slides-editor) |
Merging rules
Edits to different slides, shapes or properties merge.
The same property of the same shape (or slide) is last-writer-wins in the order the server accepts the steps: everyone ends with the same value.
Text edits in one box merge by character, like a document.
Slides and shapes are ordered by fractional order keys (
order,z), not by node position: moving a slide or changing z-order is an attribute change, so two people moving the same slide at once get one slide, in the last mover's place. The stored document never holds duplicates (the property test checks it).Table cells are nodes with their own paragraphs: two people typing in different cells merge; the table's structure (rows, columns) is last-writer-wins.
Masters and layouts merge like slides (property by property, shape by shape); a theme's colour slots, its two font sets and its style lists are separate properties (one person changing Accent 1 while another changes the heading font keeps both). A group's children merge one by one. Documents created before this kept themes, masters and layouts as whole attributes of
deckInfo: they read as before and move into nodes on the next edit.An edit to a slide someone deleted at the same time goes with it; the editor is told ("Slide 3 was deleted by a collaborator...") and Restore slide puts their version back as a new, undoable change.
Ids: new slides and shapes get ids no collaborator can make at the same time (part names tagged per client, shape ids from a per-client range).
Media: pictures, audio and video go to the server's asset store (server-node
assets: new FileAssetStorage(dir)); the document holds their URLs, so steps and snapshots stay small and every collaborator loads a file once from its immutable URL:tsconst uploader = createAssetUploader({ baseUrl, docId }); await createDeckDoc(api, docId, await uploadDeckMedia(deck, uploader)); // data: URLs uploaded first <SlidesApp storeImage={uploader.storeImage} storeMedia={uploader.storeMedia} … /> exportPptx(await embedAssets(deck, uploader)); // the .pptx embeds them againmedia:references point into one user's package: upload them (importPptx(bytes, { media: 'data-url' }), thenuploadDeckMedia).
Convergence is tested by a property test (3 clients making random concurrent edits, undo included, over a lossy, reordering, duplicating network with disconnects: 25 seeds, every client and the server end identical, checksums equal), an integration test against the reference server over WebSockets, and a two-browser check (tools/slides-collab-check.mjs).
Versions
The Versions tab lists the deck's history (who changed it, when, how many changes; named versions). Picking an entry shows what it changed: a summary ("2 changed · 1 added · 1 removed · design: theme changed"), then each slide added, removed, moved or changed with before / after thumbnails and what changed on it in words. Restore this version brings it back as a new change everyone receives (undoable). The diff is deckDiff(before, after) (DOM-free) and the view VersionDiff.
Presence
Pointers and selections travel in slide px (screenToSlide through the page's on-screen box, so zoom, scroll, panel widths, CSS transforms and devicePixelRatio don't matter) and each viewer maps them back through its own slide → screen transform (slideToElement); pointers and name tags keep their screen size at any zoom. A tab never draws its own presence: client ids are sessionClientId(session) and everything from the same session is skipped (createCollabDeck({ session })), so a reconnect or a remount can't leave a "ghost" of yourself. Pointers show only on the slide their owner is on, disappear when they leave the slide, fade after 3 s without moving, update at about 30 Hz and glide between updates. tools/slides-collab-pointer.mjs checks two windows at different sizes, zooms and pixel ratios: the remote pointer lands within 0.5 slide px.
Set it up
Server (Node): the reference server with the deck schema.
import { toProseMirrorSchema } from '@nextgensoftwares/folio-editor';
import { createFolioServer } from '@nextgensoftwares/folio-server-node';
import { deckDocSchema } from '@nextgensoftwares/folio-slides-collab';
const app = createFolioServer({ schema: toProseMirrorSchema(deckDocSchema()), allowCreate: true, comments: { ... }, collab: { ... } });Client:
const api = createHttpApi({ baseUrl });
await createDeckDoc(api, 'q3', deck); // once
const { doc, version } = await loadDeckDoc(api, 'q3');
const live = createCollabDeck({
doc: pm.nodeFromJSON(doc), version, clientID, docId: 'q3', user,
transport: new WebSocketTransport(`${wsBase}/docs/q3/collab`),
editor: { plugins: [motionUiPlugin(), deckCollabPlugin(() => live, { comments: { store, user } })] },
});
<SlidesApp deck={live.deck} measurer={fonts} resolveSrc={resolve} people={useDeckPeers(live).map((p) => ({ name: p.name, color: p.color }))} />The playground's slides.html?live=<id> is this, against server/slides.ts: open the same URL in two browsers.
Saving over REST (folio-sync)
Without a WebSocket server, a deck saves through folio-sync's REST protocol, the same createHttpApi endpoints (manifest, chunks, push, pull) and the same SyncClient as documents: debounced batched pushes with the version, pull and rebase when someone saved first, polling for others' changes, offline backoff and a durable outbox. No presence or live pointers (that is the WebSocket session above).
import { createHttpApi, IndexedDbStore } from '@nextgensoftwares/folio-sync';
import { createDeckDoc, openSyncedDeck } from '@nextgensoftwares/folio-slides-collab';
const api = createHttpApi({ baseUrl, headers: () => ({ Authorization: `Bearer ${token}` }) });
await createDeckDoc(api, docId, deck); // once (or your server stores deckToDoc(deck))
const synced = await openSyncedDeck(api, docId, { clientID, cache: new IndexedDbStore() });
synced.subscribe((s) => showSaveStatus(s)); // synced | saving | offline | error | ...
<SlidesApp deck={synced.deck} measurer={fonts} resolveSrc={resolve} />
await synced.flush(); // before leaving: every edit savedcreateSyncedDeck({ api, docId, clientID, doc, manifest }) does the same for a document you loaded yourself (loadDeckDoc returns both). synced.saveHandle() has FolioBookApp's createSync shape (start, stop, flush, a save status) for a host's save indicator.
Epochs (as for documents, see loading and saving): if your server can reset or restore a deck's history, give the deck an epoch that changes on such a reset (Manifest.epoch, or the epoch option). Offline edits are recorded under it, and an outbox from another epoch is never replayed: openSyncedDeck checks it before opening (against epoch, else the server's manifest when online), hands it to onStaleOutbox (keep it for recovery) and clears it; createSyncedDeck refuses a stale restore the same way. A pull that reports another epoch stops the deck with reason: 'epoch'.
Server: any folio-sync server verifies deck pushes like document pushes; give it the deck schema, toProseMirrorSchema(deckDocSchema()) (folio-editor and folio-slides-collab both run in Node). A step the deck schema doesn't allow (an unknown node, a shape outside a slide) is refused, and the client stops with reason: 'unsupported', its edits kept in the outbox.
Publishing to readers: docToDeck(doc) turns the stored document into a Presentation, and the reader shows it as a chapter with deckChapter (folio-plugin-slides, see the reader guide).