2022-04-05 15:02:17 +00:00
|
|
|
import { syscall } from "./syscall";
|
2022-04-25 08:33:38 +00:00
|
|
|
import { FilterOption } from "../common/types";
|
2022-04-01 15:07:08 +00:00
|
|
|
|
|
|
|
export function getCurrentPage(): Promise<string> {
|
|
|
|
return syscall("editor.getCurrentPage");
|
|
|
|
}
|
|
|
|
|
2022-04-24 16:06:34 +00:00
|
|
|
export function setPage(newName: string): Promise<void> {
|
|
|
|
return syscall("editor.setPage", newName);
|
|
|
|
}
|
|
|
|
|
2022-04-01 15:07:08 +00:00
|
|
|
export function getText(): Promise<string> {
|
|
|
|
return syscall("editor.getText");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getCursor(): Promise<number> {
|
|
|
|
return syscall("editor.getCursor");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function save(): Promise<void> {
|
|
|
|
return syscall("editor.save");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function navigate(name: string, pos?: number): Promise<void> {
|
|
|
|
return syscall("editor.navigate", name, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reloadPage(): Promise<void> {
|
|
|
|
return syscall("editor.reloadPage");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function openUrl(url: string): Promise<void> {
|
|
|
|
return syscall("editor.openUrl", url);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function flashNotification(message: string): Promise<void> {
|
|
|
|
return syscall("editor.flashNotification", message);
|
|
|
|
}
|
|
|
|
|
2022-04-13 12:46:52 +00:00
|
|
|
export function filterBox(
|
|
|
|
label: string,
|
|
|
|
options: FilterOption[],
|
|
|
|
helpText: string = "",
|
|
|
|
placeHolder: string = ""
|
|
|
|
): Promise<FilterOption | undefined> {
|
|
|
|
return syscall("editor.filterBox", label, options, helpText, placeHolder);
|
|
|
|
}
|
|
|
|
|
2022-05-09 12:59:12 +00:00
|
|
|
export function showRhs(
|
|
|
|
html: string,
|
|
|
|
script?: string,
|
|
|
|
flex = 1
|
|
|
|
): Promise<void> {
|
|
|
|
return syscall("editor.showRhs", html, script, flex);
|
2022-04-01 15:07:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-04 13:25:07 +00:00
|
|
|
export function hideRhs(): Promise<void> {
|
|
|
|
return syscall("editor.hideRhs");
|
|
|
|
}
|
|
|
|
|
2022-05-09 12:59:12 +00:00
|
|
|
export function showLhs(
|
|
|
|
html: string,
|
|
|
|
script?: string,
|
|
|
|
flex = 1
|
|
|
|
): Promise<void> {
|
|
|
|
return syscall("editor.showLhs", html, script, flex);
|
2022-04-04 16:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function hideLhs(): Promise<void> {
|
|
|
|
return syscall("editor.hideLhs");
|
|
|
|
}
|
|
|
|
|
2022-05-09 12:59:12 +00:00
|
|
|
export function showBhs(
|
|
|
|
html: string,
|
|
|
|
script?: string,
|
|
|
|
flex = 1
|
|
|
|
): Promise<void> {
|
|
|
|
return syscall("editor.showBhs", html, script, flex);
|
2022-04-26 17:04:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function hideBhs(): Promise<void> {
|
|
|
|
return syscall("editor.hideBhs");
|
|
|
|
}
|
|
|
|
|
2022-04-01 15:07:08 +00:00
|
|
|
export function insertAtPos(text: string, pos: number): Promise<void> {
|
|
|
|
return syscall("editor.insertAtPos", text, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function replaceRange(
|
|
|
|
from: number,
|
|
|
|
to: number,
|
|
|
|
text: string
|
|
|
|
): Promise<void> {
|
|
|
|
return syscall("editor.replaceRange", from, to, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function moveCursor(pos: number): Promise<void> {
|
|
|
|
return syscall("editor.moveCursor", pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function insertAtCursor(text: string): Promise<void> {
|
|
|
|
return syscall("editor.insertAtCursor", text);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function matchBefore(
|
|
|
|
re: string
|
|
|
|
): Promise<{ from: number; to: number; text: string } | null> {
|
|
|
|
return syscall("editor.matchBefore", re);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function dispatch(change: any): Promise<void> {
|
|
|
|
return syscall("editor.dispatch", change);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function prompt(
|
|
|
|
message: string,
|
|
|
|
defaultValue = ""
|
|
|
|
): Promise<string | undefined> {
|
|
|
|
return syscall("editor.prompt", message, defaultValue);
|
|
|
|
}
|