Skip to content

document

Available to document file Views and document actions. Declare document; writes require access: write. observe returns the initial snapshot and a subscription. edit changes the working copy and returns stale on a version mismatch; save returns conflict on a disk conflict. Neither result is an exception. Preserve drafts and serialize edits.

Usage guide: files. API index.

Signatures, parameters and return types are generated from the SDK. Optional members are not available in every host and context.

Source

Supported hosts: Lite Mobile

Read the current working-copy snapshot, including unsaved changes.

read(): Promise<TextSnapshot>;

Returns: Promise<TextSnapshot>.

Supported hosts: Lite Mobile

Return an initial snapshot together with a subscription to later changes.

observe(listener: (state: TextSnapshot) => void, onError?: ObserverErrorHandler): Promise<{
snapshot: TextSnapshot;
subscription: Disposable;
}>;
Parameter Type Required
listener (state: TextSnapshot) => void Yes
onError ObserverErrorHandler No

Returns: Promise<{ snapshot: TextSnapshot; subscription: Disposable; }>.

Supported hosts: Lite

Replace working-copy text when expectedVersion matches. A stale result leaves newer content intact.

edit(change: {
text: string;
expectedVersion: string;
label?: string;
group?: string;
}): Promise<{
status: "applied" | "stale";
snapshot: TextSnapshot;
}>;
Parameter Type Required
change { text: string; expectedVersion: string; label?: string; group?: string; } Yes

Returns: Promise<{ status: "applied" &#124; "stale"; snapshot: TextSnapshot; }>.

Supported hosts: Lite

Save the working copy. A disk conflict returns conflict and preserves the draft.

save(): Promise<{
status: "saved" | "conflict";
snapshot: TextSnapshot;
}>;

Returns: Promise<{ status: "saved" &#124; "conflict"; snapshot: TextSnapshot; }>.

Supported hosts: Lite

Undo an edit and return the resulting snapshot.

undo(): Promise<TextSnapshot>;

Returns: Promise<TextSnapshot>.

Supported hosts: Lite

Redo an edit and return the resulting snapshot.

redo(): Promise<TextSnapshot>;

Returns: Promise<TextSnapshot>.

Related types: TextSnapshot, ObserverErrorHandler, Disposable.