Перейти к содержимому
FastOffice

Browser Surface API

Встраивание готовой Web Surface, mount/unmount и события хоста.

Окно терминала
fastdoc-cli surface --port 0 --doc /absolute/input.docx --save /absolute/output.docx
interface HostConfig { theme?:"light"|"dark"; locale?:string; readOnly?:boolean; cssVariables?:Record<`--fastdoc-${string}`,string>; }
interface Handle { container:HTMLElement; hostConfig:Readonly<HostConfig>; unmount():void; }
interface FastDocSurface { version:"fastdoc.surface-mount.v1"; mount(container:HTMLElement, config?:HostConfig):Handle; unmount():void; }
// window.fastdocSurface: FastDocSurface
type SurfaceEvent =
| {schema:"fastdoc.surface-host-event.v1";type:"ready";documentPath:string;savePath:string;theme:string;locale:string}
| {schema:"fastdoc.surface-host-event.v1";type:"dirty";dirty:boolean}
| {schema:"fastdoc.surface-host-event.v1";type:"saved";dirty:false;path:string;byteCount:number}
| {schema:"fastdoc.surface-host-event.v1";type:"error";operation:"connect"|"save";message:string}
| {schema:"fastdoc.surface-host-event.v1";type:"unmounted"};
window.addEventListener("fastdoc-host-event", e => consume((e as CustomEvent<SurfaceEvent>).detail));
// WKWebView handler: fastdocHost; WebView2: WebMessageReceived

Bounded current surface. Реализованы mount/unmount, чтение/правка первого абзаца, save/shutdown и пять событий. Произвольная структура/selection/context-menu не опубликованы.

Ассистент документации

Ответ собран из документации и может быть неточным — сверяйтесь с источниками.