UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

33 lines 1.48 kB
/** * Warms ALL the live-editing dependencies a block needs — the editing engine * (contentEditable + source-editing), the per-language grammars, the emphasis * enhancer, and the off-main-thread worker — so they are in flight before the * user edits. Mirrors {@link useSpeculativeCodePreload}: detection is cheap and * synchronous, the work runs in a mount/activation effect (never blocking first * paint), and each fetch is deduped page-wide with the eventual consumer. * * Timing follows `editActivation`: * - `'eager'` (default): warms on mount once the block is `enabled` (editable). * - `'interaction'`: warms only once the block is `activated` — `useEditable` * fires `onActivate` on first engagement (hover / focus / click), and * `CodeHighlighter` flips `activated`. This is the single moment that kicks off * every editing dependency, rather than each loading on its own trigger. * * A read-only block sets `enabled = false` and warms nothing. */ export declare function useSpeculativeEditingPreload({ enabled, editActivation, activated, scopes }: { enabled: boolean; editActivation?: 'eager' | 'interaction'; /** Whether an `'interaction'` block has engaged yet (ignored when `'eager'`). */ activated?: boolean; /** * Grammar scopes the editable block uses, so its grammars (main thread) and the * worker can be warmed for live re-highlighting (should be memoized by the caller). */ scopes?: string[]; }): void;