EditorSession
interface exported by @mwillbanks/tuil-editor.
interface
Public interface exported by @mwillbanks/tuil-editor.
export interface EditorSession {
snapshot(): EditorSnapshot;
dispatch(transaction: EditorTransaction): EditorSnapshot;
execute(
command: string | EditorCommand,
argument?: unknown,
): boolean | Promise<boolean>;
undo(): boolean;
redo(): boolean;
search(query: string | RegExp): readonly EditorRange[];
replace(query: string | RegExp, replacement: string, all?: boolean): number;
copy(): string | Promise<string>;
cut(): string | Promise<string>;
paste(value?: string): boolean | Promise<boolean>;
serialize(format?: "text" | "json" | "markdown"): string;
subscribe(observer: (snapshot: EditorSnapshot) => void): () => void;
key?(input: string): boolean;
dispose(): void;
}Members
| Member | Type | Required | Description | Related types |
|---|---|---|---|---|
snapshot | () => EditorSnapshot | Yes | The snapshot member uses the () => EditorSnapshot contract. | EditorSnapshot |
dispatch | (transaction: EditorTransaction) => EditorSnapshot | Yes | The dispatch member uses the (transaction: EditorTransaction) => EditorSnapshot contract. | EditorSnapshot, EditorTransaction |
execute | (command: string | EditorCommand, argument?: unknown) => boolean | Promise<boolean> | Yes | The execute member uses the (command: string | EditorCommand, argument?: unknown) => boolean | Promise<boolean> contract. | EditorCommand |
undo | () => boolean | Yes | The undo member uses the () => boolean contract. | — |
redo | () => boolean | Yes | The redo member uses the () => boolean contract. | — |
search | (query: string | RegExp) => readonly EditorRange[] | Yes | The search member uses the (query: string | RegExp) => readonly EditorRange[] contract. | EditorRange |
replace | (query: string | RegExp, replacement: string, all?: boolean) => number | Yes | The replace member uses the (query: string | RegExp, replacement: string, all?: boolean) => number contract. | — |
copy | () => string | Promise<string> | Yes | The copy member uses the () => string | Promise<string> contract. | — |
cut | () => string | Promise<string> | Yes | The cut member uses the () => string | Promise<string> contract. | — |
paste | (value?: string) => boolean | Promise<boolean> | Yes | The paste member uses the (value?: string) => boolean | Promise<boolean> contract. | — |
serialize | (format?: "text" | "json" | "markdown") => string | Yes | The serialize member uses the (format?: "text" | "json" | "markdown") => string contract. | — |
subscribe | (observer: (snapshot: EditorSnapshot) => void) => () => void | Yes | The subscribe member uses the (observer: (snapshot: EditorSnapshot) => void) => () => void contract. | EditorSnapshot |
key | ((input: string) => boolean) | undefined | No | The key member uses the ((input: string) => boolean) | undefined contract. | — |
dispose | () => void | Yes | The dispose member uses the () => void contract. | — |
Parameters
This declaration has no public members.
Returns
This declaration does not return a value.
Throws
No thrown errors are documented for this declaration.
Related types
Source
View the secondary source reference