Something went wrong. Try again.
A local-first note taking app
Something went wrong. Try again.
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445/** * Editor layer types. Sync-backend-specific payloads live beside each editor * under `editors/<kind>/`; only that editor reads `EditorBinding.payload`. */import type { ComponentType } from 'react';
/** Sync/editor backend id. */export type EditorKind = 'automerge';
/** * Editor rendering mode: * - `edit` — live preview (raw syntax reveals near the cursor for editing). * - `view` — reading mode (everything stays rendered; read-only). */export type EditorMode = 'edit' | 'view';
export type EditorBinding = { kind: EditorKind; payload: unknown;};
/** Props passed from workspaces into every registered editor component. */export type EditorProps = { binding: EditorBinding; className?: string; placeholder?: string; /** Rendering mode for this view; defaults to `edit`. */ mode?: EditorMode; /** * Called when a link to an internal (schemeless) target is activated — the raw * link string, for the workspace to resolve against the current document and * open. External links (with a URI scheme) are opened by the editor itself. */ onOpenLink?: (target: string) => void;};
/** * A registered editor: UI for one sync method, keyed by `kind`. * Implementations live under `editors/<kind>/` and are listed in `registry.ts`. */export type Editor = { readonly kind: EditorKind; readonly Component: ComponentType<EditorProps>;};