Files
plainleaf/plug-api/types/client.ts
T
Zef HemelandGitHub a524c64884 Go backend (#1555)
* Replaces old Deno server with a Go implementation
* Restructured the code base accordingly
2025-09-19 13:23:20 +02:00

115 lines
2.3 KiB
TypeScript

import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
export type FilterOption = {
name: string;
description?: string;
orderId?: number;
hint?: string;
hintInactive?: boolean;
classes?: string;
category?: string;
prefix?: string;
} & Record<string, any>;
export type Notification = {
id: number;
message: string;
type: "info" | "error";
date: Date;
};
export type PanelMode = number;
export type CodeWidgetContent = {
html?: string;
script?: string;
width?: number;
height?: number;
url?: string;
};
// Document editors stuff
export type DocumentEditorCallback = () => Promise<DocumentEditorContent>;
export type DocumentEditorContent = {
html: string;
};
export type LintDiagnostic = {
from: number;
to: number;
severity: "error" | "warning" | "info" | "hint";
message: string;
};
export type UploadFile = {
name: string;
contentType: string;
content: Uint8Array;
};
export type AppEvent =
| "page:click"
| "editor:complete"
| "minieditor:complete"
| "slash:complete"
| "editor:lint"
| "page:load"
| "editor:init"
| "editor:pageLoaded" // args: pageName, previousPage, isSynced
| "editor:pageReloaded"
| "editor:pageSaving"
| "editor:pageSaved"
| "editor:pageCreating"
| "editor:pageModified"
| "editor:documentSaving"
| "editor:documentSaved"
| "editor:modeswitch"
| "plugs:loaded"
| "cron:secondPassed"
| "hooks:renderTopWidgets"
| "hooks:renderBottomWidgets";
export type ClickEvent = {
page: string;
pos: number;
metaKey: boolean;
ctrlKey: boolean;
altKey: boolean;
};
export type EnrichedClickEvent = ClickEvent & {
parentNodes: string[];
};
export type LintEvent = {
name: string;
tree: ParseTree;
};
export type CompleteEvent = {
pageName: string;
linePrefix: string;
pos: number;
parentNodes: string[];
};
export type SlashCompletionOption = {
label: string;
detail?: string;
invoke: string;
order?: number;
} & Record<string, any>;
export type SlashCompletions = {
// Ignore this one, only for compatibility with regular completions
from?: number;
// The actual completions
options: SlashCompletionOption[];
};
// Code widget stuff
export type CodeWidgetCallback = (
bodyText: string,
pageName: string,
) => Promise<CodeWidgetContent | null>;