Use presence for live cursors and remote selection, anchored threads for review conversations, and presentation for a camera that other viewers follow. Presence is ephemeral; comments belong to the document; following a camera and locking edits are independent operations.
Start in the project left by your JavaScript, React, Vue, Angular, or Qwik quick start. Keep its entry point, configuration, styles and framework wrappers. Add the files below and render the review component from the existing root component or route.
The quick starts already install the packages these samples use. If you add this to another project, install the matching binding and its Grafloria peers; your framework starter supplies the framework itself.
For JavaScript:
bashnpm install @grafloria/element @grafloria/engine @grafloria/renderer
For React:
bashnpm install @grafloria/react @grafloria/element @grafloria/engine @grafloria/renderer
For Vue:
bashnpm install @grafloria/vue @grafloria/element @grafloria/engine @grafloria/renderer
For Angular:
bashnpm install @grafloria/angular @grafloria/element @grafloria/engine @grafloria/renderer
For Qwik, install in devDependencies as its starter does:
bashnpm install -D @grafloria/qwik @grafloria/element @grafloria/engine @grafloria/renderer
1. Show live cursors and selection
Create two peers in one shipped MemoryHub. Move your pointer over Ana's canvas: Bo's canvas displays Ana's cursor. Press a node in Ana's canvas: Bo sees its remote-selection outline. Leaving the canvas clears the cursor.
The framework bindings accept this configuration through collab and mount presence for you. The JavaScript sample below uses bindPresence on a mounted DiagramInstance. Its source is the session returned by createSyncSession. Type the shared data with NodeSpec and EdgeSpec.
Create src/review.ts in JavaScript, React and Vue, src/app/review.ts in Angular, or src/components/review.ts in Qwik. The later files import this shared module.
tsimport { MemoryHub } from '@grafloria/engine';
import type { EdgeSpec, NodeSpec } from '@grafloria/renderer';
export function reviewNodes(): NodeSpec[] {
return [
{ id: 'design', label: 'Design', position: { x: 60, y: 90 },
size: { width: 150, height: 66 } },
{ id: 'review', label: 'Review', position: { x: 300, y: 90 },
size: { width: 150, height: 66 } },
];
}
export function reviewEdges(): EdgeSpec[] {
return [{ id: 'e1', source: 'design', target: 'review' }];
}
export function createReviewRoom() {
const hub = new MemoryHub();
return {
ana: { transport: hub.connect('ana'), actor: 'ana',
presence: { name: 'Ana', color: '#2563eb', smoothing: 0 } },
bo: { transport: hub.connect('bo'), actor: 'bo',
presence: { name: 'Bo', color: '#9333ea', smoothing: 0 } },
};
}
The two canvases share edits as well as presence. For a network room and transport ownership, continue with Sync collaborators. Try the live cursors demo to see the separate presence layer in action.
2. Add anchored comment threads
Enable comments on the canvas, retrieve its store with getCommentStore(), and give the same store to the conversation panel. CommentStore writes threads into the live model, not a parallel application array. createThread() returns a thread id; reply() returns a message id; resolve() returns whether the status write succeeds.
Create seed-comments.ts beside review.ts. It creates an open review thread with a reply from Bo and a separate resolved thread. The resolved thread stays in the document but the panel hides it unless showResolved is enabled. The returned cleanup owns only the additional Bo store; the canvas owns Ana's store.
tsimport { CommentStore } from '@grafloria/engine';
export function seedComments(store: CommentStore): () => void {
const thread = store.createThread(
{ kind: 'node', id: 'review' }, 'Can we tighten the hero copy?',
);
const bo = new CommentStore(store.diagram, { viewer: 'bo' });
bo.reply(thread, 'On it — draft by Friday.');
const answered = store.createThread(
{ kind: 'node', id: 'design' }, 'Use the approved design.',
);
store.resolve(answered);
return () => bo.dispose();
}
Click the open thread's heading to read the messages and reveal the shipped reply form and resolve action. Opening a thread marks it read for this viewer. The samples subscribe with onChange() so the unread count also updates after replies and reads, not only after a button in your own UI changes it.
Deleting a thread's node leaves a detached conversation, not a deleted conversation. It remains readable and replyable. Use reanchor(threadId, { kind: 'node', id: 'design' }) to attach it to a surviving node; orphans() lists threads whose subjects are gone. This is the lifecycle shown in the threaded comments demo.
Anchor kind | What the thread addresses |
|---|---|
node | A node id; the pin follows its live position. |
link | A link id; attachment is derived from the live link. |
region | A world-space x, y, with optional width and height; no entity is required. |
messageOrder orders messages by (createdAt, author, id) for consistent display across peers; it does not decide merge conflicts. The store already applies it. ReadState stores this viewer's local watermarks, never shared read receipts. Its toJSON() and fromJSON() methods provide the user-scoped persistence format; the store accepts a restored instance through readState.
3. Follow a presenter and lock the document
Create presentation.ts beside review.ts. presentTo publishes Ana's current camera immediately and then on camera changes. followPresenter applies those broadcasts to Bo's mounted canvas. The shipped InMemoryViewportChannel also replays the latest camera to a late follower. Both calls accept a PresentationHost; the mounted instance satisfies that interface. Pass the follower's DiagramEngine to enforce its document lock.
lockDocument switches Bo's engine into presentation mode. isDocumentLocked checks the document's actual lock. The helper refuses to start following if a mode guard prevents the lock. Cleanup stops both subscriptions and restores the previous engine mode with setMode().
tsimport type { DiagramEngine } from '@grafloria/engine';
import {
InMemoryViewportChannel, followPresenter, isDocumentLocked,
lockDocument, presentTo,
} from '@grafloria/renderer';
import type { PresentationHost } from '@grafloria/renderer';
export function startPresentation(
presenter: PresentationHost,
follower: PresentationHost,
engine: DiagramEngine,
): () => void {
const previous = engine.getMode();
lockDocument(engine);
if (!isDocumentLocked(engine)) {
throw new Error('Presentation requires a locked follower document');
}
const channel = new InMemoryViewportChannel();
const presenting = presentTo(presenter, channel, {
presenterId: 'ana', throttleMs: 0,
});
const following = followPresenter(follower, channel, {
ignorePresenterId: 'bo',
});
return () => {
following.stop();
presenting.stop();
channel.dispose();
engine.setMode(previous);
};
}
Bo keeps its own canvas dimensions while following Ana's center and zoom. The lock refuses document edits; camera gestures remain available. Use wheel scrolling to pan Ana's canvas, or Ctrl/⌘ + wheel to zoom it, and watch Bo follow. Following is not a synchronization transport for document data; collab supplies that separately in these examples. See the presentation mode demo.
4. Mount the review surface
Each tab mounts two real canvases with the same nodes and edge. Ana has comments; Bo follows her camera with a locked document. The conversation panel displays the seeded review thread. Select its heading to reveal the messages. The selected-thread id below the panel comes from the panel's selection event. Angular's ready callback receives a GrafloriaCanvasInstance; its camera comes from the canvas's viewportController().
Build on the canvas mounting pattern in Validate connections by adding collab, enabling comments on Ana's canvas, and connecting her comment store to the shipped conversation panel.
tsimport './style.css';
import { render } from '@grafloria/element';
import { createSyncSession } from '@grafloria/engine';
import { bindPresence, CommentPanelView, PRESENCE_LAYER_CLASS } from '@grafloria/renderer';
import { createReviewRoom, reviewNodes, reviewEdges } from './review';
import { seedComments } from './seed-comments';
import { startPresentation } from './presentation';
const app = document.querySelector<HTMLDivElement>('#app');
if (!app) throw new Error('Missing #app');
app.innerHTML = `
<h1>Review together</h1><button id="close">Close review</button>
<p>Ana presents; Bo follows read-only.</p>
<div style="display:flex;height:400px">
<div id="ana" style="flex:1;min-width:0"></div>
<div id="bo" style="flex:1;min-width:0"></div>
</div>
<p id="unread"></p><div id="comments"></div><p id="selected"></p>`;
const room = createReviewRoom();
const ana = render({ nodes: reviewNodes(), edges: reviewEdges() }, '#ana', {
comments: true, commentsViewer: 'ana',
});
const bo = render({ nodes: reviewNodes(), edges: reviewEdges() }, '#bo');
const sessionA = createSyncSession(ana.getModel(), room.ana.transport, { actor: 'ana' });
const sessionB = createSyncSession(bo.getModel(), room.bo.transport, { actor: 'bo' });
sessionA.join();
sessionB.join();
const presenceA = bindPresence(ana, sessionA, room.ana.presence);
const presenceB = bindPresence(bo, sessionB, room.bo.presence);
ana.container.querySelector(`.${PRESENCE_LAYER_CLASS}`)?.setAttribute('data-review-presence', '');
const store = ana.getCommentStore();
if (!store) throw new Error('Comments are not enabled');
const stopSeed = seedComments(store);
const panelHost = document.querySelector<HTMLDivElement>('#comments');
const unread = document.querySelector<HTMLParagraphElement>('#unread');
const selected = document.querySelector<HTMLParagraphElement>('#selected');
if (!panelHost || !unread || !selected) throw new Error('Missing review UI');
const panel = new CommentPanelView(panelHost, store, {
label: 'Review comments',
onSelect: (id) => { selected.textContent = id ?? 'No thread selected'; },
onDismiss: () => ana.container.querySelector<HTMLElement>('[tabindex="0"]')?.focus(),
});
const update = () => {
panel.update();
unread.textContent = `${store.totalUnread()} unread`;
};
const off = store.onChange(update);
update();
const stopPresentation = startPresentation(ana, bo, bo.getEngine());
document.querySelector<HTMLButtonElement>('#close')?.addEventListener('click', () => {
stopPresentation();
off();
panel.dispose();
stopSeed();
presenceA.dispose();
presenceB.dispose();
sessionA.awareness.remove('bo');
sessionB.awareness.remove('ana');
sessionA.dispose();
sessionB.dispose();
room.ana.transport.close();
room.bo.transport.close();
ana.dispose();
bo.dispose();
app.replaceChildren();
}, { once: true });
tsximport { useEffect, useRef, useState } from 'react';
import { GrafloriaFlow, GrafloriaCommentPanel } from '@grafloria/react';
import type { CommentStore } from '@grafloria/engine';
import type { DiagramInstance } from '@grafloria/renderer';
import { createReviewRoom, reviewNodes, reviewEdges } from './review';
import { seedComments } from './seed-comments';
import { startPresentation } from './presentation';
export function Review() {
const [room] = useState(createReviewRoom);
const [nodesA] = useState(reviewNodes);
const [nodesB] = useState(reviewNodes);
const [edgesA] = useState(reviewEdges);
const [edgesB] = useState(reviewEdges);
const [store, setStore] = useState<CommentStore | null>(null);
const [unread, setUnread] = useState(0);
const [selected, setSelected] = useState<string | null>(null);
const ana = useRef<DiagramInstance | null>(null);
const bo = useRef<DiagramInstance | null>(null);
const stops = useRef<Array<() => void>>([]);
const connected = useRef(false);
const connect = () => {
if (!connected.current && ana.current && bo.current) {
connected.current = true;
stops.current.push(startPresentation(ana.current, bo.current, bo.current.getEngine()));
}
};
useEffect(() => () => {
stops.current.splice(0).forEach(stop => stop());
ana.current = null;
bo.current = null;
connected.current = false;
// The bindings leave their sessions; the room owns its transports.
room.ana.transport.disconnect();
room.bo.transport.disconnect();
}, [room]);
return <section>
<p>Ana presents; Bo follows read-only. {unread} unread.</p>
<div style={{ display: 'flex', height: 400 }}>
<GrafloriaFlow defaultNodes={nodesA} defaultEdges={edgesA}
collab={room.ana} comments commentsViewer="ana" style={{ flex: 1, minWidth: 0 }}
onInit={instance => {
ana.current = instance;
const s = instance.getCommentStore();
if (s) {
stops.current.push(seedComments(s));
const update = () => setUnread(s.totalUnread());
stops.current.push(s.onChange(update));
update();
setStore(s);
}
connect();
}} />
<GrafloriaFlow defaultNodes={nodesB} defaultEdges={edgesB}
collab={room.bo} style={{ flex: 1, minWidth: 0 }}
onInit={instance => { bo.current = instance; connect(); }} />
</div>
{store && <GrafloriaCommentPanel store={store} className="review-comments"
style={{ maxHeight: 300, overflow: 'auto' }}
options={{ label: 'Review comments', onDismiss: () =>
ana.current?.container.querySelector<HTMLElement>('[tabindex="0"]')?.focus() }}
onSelect={setSelected} />}
<p>{selected ?? 'No thread selected'}</p>
</section>;
}
vue<script setup lang="ts"> import { onBeforeUnmount, ref, shallowRef } from 'vue'; import { GrafloriaFlow, GrafloriaCommentPanel } from '@grafloria/vue'; import type { CommentStore } from '@grafloria/engine'; import type { DiagramInstance } from '@grafloria/renderer'; import { createReviewRoom, reviewNodes, reviewEdges } from './review'; import { seedComments } from './seed-comments'; import { startPresentation } from './presentation'; const room = createReviewRoom(); const nodesA = reviewNodes(); const nodesB = reviewNodes(); const edgesA = reviewEdges(); const edgesB = reviewEdges(); const ana = shallowRef<DiagramInstance>(); const bo = shallowRef<DiagramInstance>(); const store = shallowRef<CommentStore>(); const unread = ref(0); const selected = ref<string | null>(null); const stops: Array<() => void> = []; function connect() { if (ana.value && bo.value) { stops.push(startPresentation(ana.value, bo.value, bo.value.getEngine())); } } function readyA(instance: DiagramInstance) { ana.value = instance; const s = instance.getCommentStore(); if (s) { stops.push(seedComments(s)); const update = () => { unread.value = s.totalUnread(); }; stops.push(s.onChange(update)); update(); store.value = s; } connect(); } function readyB(instance: DiagramInstance) { bo.value = instance; connect(); } function dismiss() { ana.value?.container.querySelector<HTMLElement>('[tabindex="0"]')?.focus(); } onBeforeUnmount(() => { stops.forEach(stop => stop()); room.ana.transport.close(); room.bo.transport.close(); }); </script> <template> <section> <p>Ana presents; Bo follows read-only. {{ unread }} unread.</p> <div style="display:flex;height:400px"> <GrafloriaFlow :default-nodes="nodesA" :default-edges="edgesA" :collab="room.ana" :comments="true" comments-viewer="ana" style="flex:1;min-width:0" @init="readyA" /> <GrafloriaFlow :default-nodes="nodesB" :default-edges="edgesB" :collab="room.bo" style="flex:1;min-width:0" @init="readyB" /> </div> <GrafloriaCommentPanel v-if="store" :store="store" :options="{ label: 'Review comments', onDismiss: dismiss }" @select="selected = $event" /> <p>{{ selected ?? 'No thread selected' }}</p> </section> </template>
tsimport { Component, DestroyRef, ElementRef, inject, signal, viewChild } from '@angular/core';
import { DiagramCanvasComponent, GrafloriaCommentPanelComponent } from '@grafloria/angular';
import type { GrafloriaCanvasInstance } from '@grafloria/angular';
import type { CommentStore } from '@grafloria/engine';
import { createReviewRoom, reviewNodes, reviewEdges } from './review';
import { seedComments } from './seed-comments';
import { startPresentation } from './presentation';
@Component({
selector: 'app-review',
imports: [DiagramCanvasComponent, GrafloriaCommentPanelComponent],
template: `
<p>Ana presents; Bo follows read-only. {{ unread() }} unread.</p>
<div style="display:flex;height:400px">
<grafloria-diagram-canvas #a [(nodes)]="nodesA" [(edges)]="edgesA"
[collab]="room.ana" [comments]="true" (ready)="readyA($event)"
style="display:block;flex:1;min-width:0" />
<grafloria-diagram-canvas #b [(nodes)]="nodesB" [(edges)]="edgesB"
[collab]="room.bo" (ready)="readyB($event)"
style="display:block;flex:1;min-width:0" />
</div>
@if (store(); as comments) {
<grafloria-comment-panel [store]="comments" [options]="panelOptions"
(threadSelect)="selected.set($event)" />
}
<p>{{ selected() ?? 'No thread selected' }}</p>
`,
})
export class ReviewComponent {
readonly room = createReviewRoom();
readonly nodesA = signal(reviewNodes());
readonly nodesB = signal(reviewNodes());
readonly edgesA = signal(reviewEdges());
readonly edgesB = signal(reviewEdges());
readonly store = signal<CommentStore | null>(null);
readonly unread = signal(0);
readonly selected = signal<string | null>(null);
readonly canvasA = viewChild.required<DiagramCanvasComponent>('a');
readonly canvasB = viewChild.required<DiagramCanvasComponent>('b');
readonly panelOptions = { label: 'Review comments', onDismiss: () => this.focusCanvas() };
private readonly destroyRef = inject(DestroyRef);
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
private readonly stops: Array<() => void> = [];
private a?: GrafloriaCanvasInstance;
private b?: GrafloriaCanvasInstance;
constructor() {
this.destroyRef.onDestroy(() => {
this.stops.forEach(stop => stop());
this.room.ana.transport.close();
this.room.bo.transport.close();
});
}
focusCanvas() {
this.host.nativeElement.querySelector<HTMLElement>('[tabindex="0"]')?.focus();
}
readyA(instance: GrafloriaCanvasInstance) {
this.a = instance;
const store = instance.getCommentStore();
if (store) {
this.stops.push(seedComments(store));
const update = () => this.unread.set(store.totalUnread());
this.stops.push(store.onChange(update));
update();
this.store.set(store);
}
this.connect();
}
readyB(instance: GrafloriaCanvasInstance) { this.b = instance; this.connect(); }
private connect() {
const a = this.canvasA().viewportController();
const b = this.canvasB().viewportController();
if (this.a && this.b && a && b) {
this.stops.push(startPresentation(
{ viewport: a, render: () => this.a?.render() },
{ viewport: b, render: () => this.b?.render() }, this.b.getEngine(),
));
}
}
}
tsximport { $, component$, noSerialize, useSignal, useVisibleTask$ } from '@builder.io/qwik';
import type { NoSerialize } from '@builder.io/qwik';
import { GrafloriaFlow, GrafloriaCommentPanel } from '@grafloria/qwik';
import type { CommentStore } from '@grafloria/engine';
import type { DiagramInstance } from '@grafloria/renderer';
import { createReviewRoom, reviewNodes, reviewEdges } from './review';
import { seedComments } from './seed-comments';
import { startPresentation } from './presentation';
export const ReviewSurface = component$(() => {
const room = useSignal<NoSerialize<ReturnType<typeof createReviewRoom>>>();
const ana = useSignal<NoSerialize<DiagramInstance>>();
const bo = useSignal<NoSerialize<DiagramInstance>>();
const store = useSignal<NoSerialize<CommentStore>>();
const unread = useSignal(0);
const selected = useSignal<string | null>(null);
const root = useSignal<HTMLElement>();
useVisibleTask$(({ cleanup }) => {
const live = createReviewRoom();
room.value = noSerialize(live);
cleanup(() => { live.ana.transport.close(); live.bo.transport.close(); });
});
useVisibleTask$(({ track, cleanup }) => {
const instance = track(() => ana.value);
if (!instance) return;
const s = instance.getCommentStore();
if (!s) return;
const stopSeed = seedComments(s);
store.value = noSerialize(s);
const update = () => { unread.value = s.totalUnread(); };
const off = s.onChange(update);
update();
cleanup(() => { off(); stopSeed(); });
});
useVisibleTask$(({ track, cleanup }) => {
const a = track(() => ana.value), b = track(() => bo.value);
if (a && b) cleanup(startPresentation(a, b, b.getEngine()));
});
return <section ref={root}>
<p>Ana presents; Bo follows read-only. {unread.value} unread.</p>
{room.value && <div style={{ display: 'flex', height: '400px' }}>
<GrafloriaFlow defaultNodes={reviewNodes()} defaultEdges={reviewEdges()}
collab={noSerialize(room.value.ana)} comments commentsViewer="ana"
style={{ flex: '1', minWidth: '0' }}
onInit$={instance => { ana.value = noSerialize(instance); }} />
<GrafloriaFlow defaultNodes={reviewNodes()} defaultEdges={reviewEdges()}
collab={noSerialize(room.value.bo)} style={{ flex: '1', minWidth: '0' }}
onInit$={instance => { bo.value = noSerialize(instance); }} />
</div>}
{store.value && <div style={{ maxHeight: '300px', overflow: 'auto' }}>
<GrafloriaCommentPanel store={store.value} class="review-comments"
options={{ label: 'Review comments', onDismiss: $(() => {
root.value?.querySelector<HTMLElement>('[tabindex="0"]')?.focus();
}) }}
onSelect$={id => { selected.value = id; }} />
<button onClick$={() => root.value?.querySelector<HTMLElement>('[tabindex="0"]')?.focus()}>
Return to canvas
</button>
</div>}
<p>{selected.value ?? 'No thread selected'}</p>
</section>;
});
The Vue surface displays the seeded conversation beneath its two canvases.
The Angular surface also starts with no thread selected and displays the same two flows and collapsed review thread.
Qwik adds the Return to canvas button below the thread.
Qwik creates the hub and subscriber stores in browser tasks and keeps them with noSerialize(). Put the panel's dimensions on its wrapper: its declared styling prop is class, not style. For resumable integration rules, see Qwik: resumable integration.
PRESENCE_LAYER_CLASS identifies the separate DOM layer; the JavaScript sample adds a host-specific attribute to it. PresenceOverlay owns that layer. Prefer bindPresence() rather than constructing an overlay and manually publishing peers. Its setPeers(), remove(), clear() and dispose() manage the displayed peer set; peerCount, element and framesRun expose inspection state.
Options that matter
| Option | Type | Default | What it does |
|---|---|---|---|
Presence name | string | Omitted | Sets the label other peers see. |
Presence color | string | Derived from actor id | Sets your cursor and selection color. |
Presence publishCursor | boolean | true | Set false to see others without publishing your cursor. |
Presence publishSelection | boolean | true | Set false to stop publishing selected entity ids. |
Presence smoothing | number | 0.35 | Interpolates remote cursors; 0 snaps to each received position. |
Canvas commentsViewer | string | 'local' | Names the viewer of a store created by comments: true; use a person id, not a session id. |
Panel label | string | 'Comments' | Names the complementary landmark and heading. |
Panel showResolved | boolean | false | Includes answered threads in the panel. |
Presentation presenterId | string | Omitted | Identifies the sender in each camera payload. |
Presentation throttleMs | number | 50 | Coalesces broadcasts, including the final camera position; the local sample uses 0. |
Following ignorePresenterId | string | Omitted | Ignores your own camera broadcasts. |
The panel's options also accepts onDismiss for returning focus to the canvas, formatTime for timestamp rendering, and onSelect. Prefer the binding's selection surface: React onSelect, Vue @select, Angular (threadSelect), or Qwik onSelect$. React supplies className and style; Qwik supplies class. These style the panel host, not the comment data.
Engine modes and transitions
The mounted instance's DiagramEngine owns the lock. Its DiagramMode choices are:
| Value | Meaning |
|---|---|
DESIGNER ('designer') | Full document editing; the default. |
RUNNING ('running') | Execution/simulation with document editing disabled. |
VIEW ('view') | Read-only inspection. |
DEBUG ('debug') | Debugging with structural editing disabled. |
PRESENTATION ('presentation') | Read-only presentation. |
getMode() returns the current choice. isDesignerMode(), isRunningMode(), isViewMode(), isDebugMode() and isPresentationMode() test one choice; isReadOnlyMode() is true for every choice except designer. setMode() applies the mode to the document's edit lock. Unlocking with lockDocument(engine, false) selects designer mode rather than restoring an earlier mode; the sample retains the earlier mode explicitly.
Use addModeGuard(name, guard) to authorize transitions; the guard returns { allowed, reason? }. Remove one with removeModeGuard(name) or all with clearModeGuards(). beforeModeChange() can return false to prevent a transition; afterModeChange() observes an accepted transition. Both return unsubscribe functions. Verify the resulting document lock before presenting a read-only review, as the helper does.
configureModeViewport() stores per-mode viewport preferences; getModeViewportSettings() returns them, falling back to pan and zoom enabled. Mode changes publish these preferences through viewport-settings-changed; this is distinct from following a presenter's camera.
getModeHistory() returns the mode entries, and clearModeHistory() retains the latest recorded entry. After history navigation, that entry can differ from getMode(). previousMode() and nextMode() navigate that history without guards or new history entries. pushMode() saves the current choice before switching; popMode() returns to a saved choice. For a document lock, retain a mode in application state and restore it through setMode(), as above. getModeAnalytics() summarizes completed visits with count, total time and average time.
getLinkBehaviorForMode() returns deletable and selectable flags adjusted for the current choice: non-designer modes force deletion off while retaining the supplied selection flag. Use the document lock to enforce editing policy, not this returned object.
Pitfalls
- Give both canvases resolved dimensions. See container sizing when embedding the surface in a layout.
- Presence outlines in
bindPresence()cover nodes. It publishes edge selection ids but does not invent a rectangular outline for routed edges. - Keep the panel attached to one store for its lifetime. Remount it when switching documents rather than replacing its store prop on an existing panel.
- A transport-confirmed departure can call
awareness.remove(actor)on the session'sAwarenessto drop the peer locally. The JavaScript close handler demonstrates this; normal session departure and timeout also remove peers. Removal does not delete that person's comments. - Stop presentation handles and presence bindings when their view closes. Do not dispose them immediately after setup, or on a page-unload event that leaves a restored page without its instance.
Related
- Sync collaborators connects document edits to network transports.
- Save and restore documents preserves the full document rather than only the visible node specs.
- Navigate accessible canvases covers camera controls and keyboard navigation.
Was this page helpful?