import type { CommandDef, SlashCommandDef } from "./manifest.ts"; import type { SlashCompletions } from "@silverbulletmd/silverbullet/types"; export type RunnableCommand = { run?: (args?: any[]) => Promise; }; export type Command = CommandDef & RunnableCommand; export type SlashCommand = SlashCommandDef & { run: (...args: any[]) => Promise; }; export type CommandHookEvents = { commandsUpdated(commands: Map): void; }; // TODO: Move this elsewhere export function isValidEditor( currentEditor: string | undefined, requiredEditor: string | undefined, ): boolean { return (requiredEditor === undefined) || (currentEditor === undefined && requiredEditor === "page") || (requiredEditor === "any") || (currentEditor === requiredEditor) || (currentEditor !== undefined && requiredEditor === "notpage"); }