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.
TextDocument
Section titled “TextDocument”TextDocument.read
Section titled “TextDocument.read”Supported hosts: Lite Mobile
Read the current working-copy snapshot, including unsaved changes.
read(): Promise<TextSnapshot>;Returns: Promise<TextSnapshot>.
TextDocument.observe
Section titled “TextDocument.observe”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; }>.
TextDocument.edit
Section titled “TextDocument.edit”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" | "stale"; snapshot: TextSnapshot; }>.
TextDocument.save
Section titled “TextDocument.save”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" | "conflict"; snapshot: TextSnapshot; }>.
TextDocument.undo
Section titled “TextDocument.undo”Supported hosts: Lite
Undo an edit and return the resulting snapshot.
undo(): Promise<TextSnapshot>;Returns: Promise<TextSnapshot>.
TextDocument.redo
Section titled “TextDocument.redo”Supported hosts: Lite
Redo an edit and return the resulting snapshot.
redo(): Promise<TextSnapshot>;Returns: Promise<TextSnapshot>.
Related types: TextSnapshot, ObserverErrorHandler, Disposable.