@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
31 lines • 1.81 kB
text/typescript
import type { Position } from "./useEditableUtils.mjs";
import type { Edit, Options } from "./EditableEngine.mjs";
import { preloadEditingEngine, resetEditingEngineCache } from "./editingEngineCache.mjs";
export type { Position } from "./useEditableUtils.mjs";
export type { Edit, Options } from "./EditableEngine.mjs";
export type { EditingEngineLoader } from "./editingEngineCache.mjs";
/**
* Eagerly loads the editing engine and primes the shared cache so the next
* editable block attaches synchronously instead of after a load round-trip.
* Optional — `useEditable` loads on demand anyway. Pass the provider's
* `editingEngineLoader` to share its deduplication.
*/
export declare const preloadEditableEngine: typeof preloadEditingEngine;
/**
* Clears the shared editing-engine cache so the next editable block resolves its
* loader from scratch. Intended for tests that exercise the cold path.
*/
export declare const resetEditableEngineCache: typeof resetEditingEngineCache;
/**
* The lightweight, always-mounted shell for live code editing. Owns the editing
* state/refs and a stable `edit` proxy; the heavy runtime is loaded on demand
* from `./EditableEngine` and `contentEditable` is applied only once it resolves.
*
* The host element (`elementRef.current`) is expected to be **stable for the
* lifetime of the hook** once the block is editable: the engine attaches once
* and its setup effect does not re-run on a node swap, so a caller that replaces
* the bound element in place would leave `contentEditable` on the stale node.
*/
export declare const useEditable: <TPreParseResult = unknown>(elementRef: {
current: HTMLElement | undefined | null;
}, onChange: (text: string, position: Position, preParseResult?: TPreParseResult) => void, opts?: Options<TPreParseResult>) => Edit;