@nextgensoftwares/folio-slides-collab
Realtime collaboration for decks on Folio's own collaboration stack: the deck is a ProseMirror document (deckInfo, slide, slideShape, slidePara with slideRun marks), so deck edits are ordinary steps through folio-plugin-collab, folio-sync and folio-server-node, with the same server verification (version, step application, checksum), presence, offline outbox, history and comments as documents. Guide: Collaborating on decks.
ts
import { createCollabDeck, deckDocSchema, loadDeckDoc } from '@nextgensoftwares/folio-slides-collab';
import { deckCollabPlugin } from '@nextgensoftwares/folio-slides-collab/react';
const pm = toProseMirrorSchema(deckDocSchema()); // the server uses the same schema
const { doc, version } = await loadDeckDoc(api, 'q3-review');
const live = createCollabDeck({
doc: pm.nodeFromJSON(doc), version, clientID, docId: 'q3-review', user,
transport: new WebSocketTransport(`${ws}/docs/q3-review/collab`),
editor: { plugins: [deckCollabPlugin(() => live, { comments: { store, user } })] },
});
<SlidesApp deck={live.deck} ... />Document
| Export | Description |
|---|---|
deckSchema, deckDocSchema(base?), DECK_COMMENT_TYPES, DECK_ATTR_CHARS | the deck nodes (Folio SchemaSpec part); the full schema: a host schema (default standardSchema) + deck nodes + comment anchors on slides and shapes |
deckToDoc(deck), docToDeck(doc) | deck ⇄ document; reading memoizes per node, so unchanged slides and shapes come back as the same objects |
deckInfoNode, slideNode, shapeNode, cellNode, paraNode, readSlide, readShape, readPara, hasNodeText | the per-node conversions (table cells are nodes with their own paragraphs; a group's children are shape nodes; the deck's sections are deckInfo's own sections attribute, so a section edit is one attribute step) |
themeNode, sheetNode, readTheme, readSheet, THEME_SLOTS, Sheet | themes (each colour slot, font set and style list its own attribute) and masters / layouts (sheet nodes: properties as attributes, shapes as nodes) |
keyBetween(a, b), spreadKeys(n), byKey(list, key, id), ordered(parent, 'order' | 'z') | fractional order keys: slides and shapes are ordered by key, not node position, so moving one is an attribute change |
bindDeck(doc, deck), bindSlide, bindShape | ties nodes built from a deck to its objects; false when the document normalized something (the caller adopts the document's form) |
deckTransaction(state, next) | the steps from a document to a deck: one attribute step per changed property, inserts/deletes for added, removed and moved slides and shapes, minimal replaces for text |
dedupeTransaction(state) | removes extra copies of an id (two people undoing one deletion or restoring one slide); clients run it on a confirmed document |
claimIds(prev, next, clientID, counter), shapeIdBase(clientID), IdClaim | ids for new slides and shapes no collaborator can create at the same time |
createDeckDoc(api, docId, deck, title?), loadDeckDoc(api, docId, opts?) | store a deck as a new shared document; load one whole ({ doc, version, manifest }; opts: folio-sync's load options, e.g. a chunk cache or an outbox's manifest) |
createAssetUploader({ baseUrl, docId, headers?, fetch? }), AssetUploader, AssetUploaderOptions | pictures, audio and video to the server's asset store (server-node assets): upload(bytes) → URL, owns(src), and storeImage / storeMedia for SlidesApp (other image formats converted to PNG). The document syncs the URL, never the bytes |
uploadDeckMedia(deck, uploader), embedAssets(deck, uploader, fetch?) | a deck's data: URLs uploaded (before createDeckDoc); uploaded files inlined as data: URLs again (before exportPptx, so the .pptx embeds them) |
Session
| Export | Description |
|---|---|
createCollabDeck(options), CollabDeckOptions, CollabDeck | a DeckEditor kept in sync with the shared document through a CollabClient (all its options: transport, user, connectivity, outbox, role...); undo/redo of this user's steps only; setPointer(at); destroy() |
createSyncedDeck(options), openSyncedDeck(api, docId, options), SyncedDeck, SyncedDeckOptions, OpenSyncedDeckOptions | a DeckEditor saved over folio-sync's REST protocol (SyncClient: debounced pushes with the version, polling, outbox): status, subscribe(fn), flush(), saveHandle() (FolioBookApp's createSync shape), onConflict(fn), destroy(); openSyncedDeck loads the document first and resumes its offline outbox (cache: an IndexedDbStore) |
bindDeckDocument(doc, version, clientID, editorOptions?), BoundDeck | the binding both sessions use: a DeckEditor and the deck document's headless editor kept in step (bring your own sync client) |
deckDiff(before, after), DeckDiff, SlideChange | what changed between two versions: slides added / removed / moved / changed (with their indices and, in words, what changed: text, position or size, format, shapes added, transition, animations, notes...), theme / master / layout changes, slide size |
ConflictWatch, DeckConflict | collab.onConflict(fn): a collaborator deleted a slide this user was editing; restore() brings back their version |
screenToSlide(x, y, rect, size), slideToElement(point, width, size), Rect | pointer coordinates: screen → slide px through the on-screen box; slide px → the page element's own px |
sessionClientId(session) | a client id in this tab's session (its presence is never drawn here) |
deckPeers(peers, deck, self?), peersOf(client), DeckPeer | collaborators as a deck shows them (never self): slide, selected shapes, pointer and when it last moved, status |
anchorComment(state, target, threadId), unanchorComment(state, threadId), deckAnchor(target), deckThreads(doc), findTarget(doc, target), DeckTarget | comments on slides and shapes: the anchor (the node's commentIds, synced like any edit) and where each thread lives |
React (/react)
| Export | Description |
|---|---|
deckCollabPlugin(deck, options?), DeckCollabUiOptions | a SlidesPlugin: remote selections and pointers over the slide ('surface' slot), collaborators on thumbnails ('thumbnail' slot), Comments ({ store, user }) and Versions inspector tabs |
RemotePresence, PeerMarks, DeckComments, DeckCommentsProps, DeckVersions, VersionDiff, ConflictToasts, CollabAnnouncer | the pieces (the plugin also adds Comments and Versions toolbar buttons; CollabAnnouncer tells screen readers who joined or left and when the connection drops or comes back) |
useDeckPeers(deck), useCollabStatus(deck) | hooks |
COLLAB_CSS, ensureCollabCss(doc?) | styles |