Public sharing (#218): - Bind public-share content to the requested shareId. getSharedPage now enforces dto.shareId (forwarded from /share/:shareId/p/:slug): the page must be reachable THROUGH that exact share (its own share, or an includeSubPages ancestor that contains it). A forged/mismatched shareId 404s instead of rendering off the slug alone and no longer leaks the real canonical key via redirect. A request with no shareId keeps the legacy slug-capability path. - Trim /shares/page-info: drop internal metadata (creatorId, spaceId, workspaceId, contributorIds, lastUpdated*, parent/position, lock/template flags, timestamps) from the anonymous payload. - Default share-to-web includeSubPages to false (opt-in), so enabling a share no longer silently exposes the whole sub-tree (#216). Editor (#218): - Harden the new-page pre-sync window: the body editor is kept read-only until the collab provider is Connected and synced, so early keystrokes can't land only in local ProseMirror and then be clobbered by the server's empty doc. - Surface a "Connecting… (read-only)" affordance during the static phase so input isn't silently swallowed. Other: - Breadcrumb: resolve from the page's own ancestor data (/pages/breadcrumbs) instead of waiting for the lazily-built sidebar tree, so deep pages don't render a blank breadcrumb for seconds. - Pasting GitHub `> [!type]` callouts now converts to a callout node instead of a literal blockquote (new marked extension wired into markdownToHtml). Tests: editor-sync-state gate (client), getSharedPage share-binding (server), github-callout markdown conversion (editor-ext). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { WebSocketStatus } from "@hocuspocus/provider";
|
|
|
|
/**
|
|
* The collab document is usable only once the provider is Connected AND has
|
|
* synced (both the local IndexedDB replica and the remote room). Until then the
|
|
* in-browser Y.Doc is empty/stale, so edits would either be dropped or clobber
|
|
* the server's authoritative doc when it finally arrives.
|
|
*/
|
|
export function isCollabSynced(
|
|
status: WebSocketStatus | string,
|
|
isSynced: boolean,
|
|
): boolean {
|
|
return status === WebSocketStatus.Connected && isSynced;
|
|
}
|
|
|
|
/**
|
|
* Whether the page BODY editor may accept edits.
|
|
*
|
|
* `showStatic` is true during the pre-sync window (a read-only static editor is
|
|
* shown). Gating editability on `!showStatic` guarantees the body never becomes
|
|
* editable before the collab doc is synced, so early keystrokes on a freshly
|
|
* created page can't land only in local ProseMirror and then be lost when the
|
|
* server's initial empty doc syncs in (#218). Read-only and view modes are
|
|
* still honored via `editable`/`inEditMode`.
|
|
*/
|
|
export function isBodyEditable(opts: {
|
|
editable: boolean;
|
|
inEditMode: boolean;
|
|
showStatic: boolean;
|
|
}): boolean {
|
|
return opts.editable && opts.inEditMode && !opts.showStatic;
|
|
}
|