Comprehensive TypeScript type definitions and interfaces for the Slidev presentation framework ecosystem
—
Interfaces for extending Slidev with custom functionality including app initialization, Monaco editor setup, code runners, and various plugin hooks.
Setup function for configuring the Vue application and router.
/**
* Setup function for configuring the Vue application
* @param context - App context containing Vue app and router instances
*/
type AppSetup = (context: AppContext) => Awaitable<void>;
interface AppContext {
app: App;
router: Router;
}
/**
* Define an app setup function
*/
function defineAppSetup(fn: AppSetup): AppSetup;Setup function for configuring Monaco editor options and behavior.
/**
* Setup function for configuring Monaco editor
* @param m - Monaco editor module
* @returns Editor configuration options
*/
type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>;
interface MonacoSetupReturn {
editorOptions?: monaco.editor.IEditorOptions;
}
/**
* Define a Monaco setup function
*/
function defineMonacoSetup(fn: MonacoSetup): MonacoSetup;Setup function for root-level initialization.
/**
* Setup function for root-level initialization
*/
type RootSetup = () => Awaitable<void>;
/**
* Define a root setup function
*/
function defineRootSetup(fn: RootSetup): RootSetup;Setup function for configuring Vue router routes.
/**
* Setup function for configuring Vue router routes
* @param routes - Array of route record raw objects
* @returns Modified array of route records
*/
type RoutesSetup = (routes: RouteRecordRaw[]) => RouteRecordRaw[];
/**
* Define a routes setup function
*/
function defineRoutesSetup(fn: RoutesSetup): RoutesSetup;Setup function for configuring keyboard shortcuts.
/**
* Setup function for configuring keyboard shortcuts
* @param nav - Navigation operations
* @param defaultShortcuts - Default shortcut options
* @returns Array of shortcut options
*/
type ShortcutsSetup = (nav: NavOperations, defaultShortcuts: ShortcutOptions[]) => Array<ShortcutOptions>;
interface NavOperations {
next: () => void;
prev: () => Promise<void>;
nextSlide: () => void;
prevSlide: () => Promise<void>;
go: (index: number) => void;
goFirst: () => void;
goLast: () => void;
downloadPDF: () => Promise<void>;
toggleDark: () => void;
toggleOverview: () => void;
toggleDrawing: () => void;
escapeOverview: () => void;
showGotoDialog: () => void;
}
interface ShortcutOptions {
key: string | Ref<boolean>;
fn?: () => void;
autoRepeat?: boolean;
name?: string;
}
/**
* Define a shortcuts setup function
*/
function defineShortcutsSetup(fn: ShortcutsSetup): ShortcutsSetup;Setup function for configuring code execution providers.
/**
* Setup function for configuring code runners
* @param runners - Existing code runner providers
* @returns Modified or new code runner providers
*/
type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>;
/**
* Define a code runners setup function
*/
function defineCodeRunnersSetup(fn: CodeRunnersSetup): CodeRunnersSetup;Setup function for configuring context menu items.
/**
* Context menu item type
*/
type ContextMenuItem = ContextMenuOption | 'separator';
type ContextMenuOption = {
action: () => void;
disabled?: boolean;
} & (
| {
small?: false;
icon?: Component | string;
label: string | Component;
}
| {
small: true;
icon: Component | string;
label: string;
}
);
/**
* Setup function for configuring context menu
* @param items - Computed ref of existing context menu items
* @returns Modified computed ref of context menu items
*/
type ContextMenuSetup = (items: ComputedRef<ContextMenuItem[]>) => ComputedRef<ContextMenuItem[]>;
/**
* Define a context menu setup function
*/
function defineContextMenuSetup(fn: ContextMenuSetup): ContextMenuSetup;Setup function for configuring Shiki syntax highlighting.
/**
* Setup function for configuring Shiki highlighter
* @param shiki - Shiki context with theme loading capability
* @returns Shiki configuration options
*/
type ShikiSetup = (shiki: ShikiContext) => Awaitable<ShikiSetupReturn | void>;
interface ShikiContext {
/** @deprecated Pass directly the theme name */
loadTheme: (path: string) => Promise<any>;
}
type ShikiSetupReturn = Partial<
& Omit<CodeToHastOptionsCommon<BuiltinLanguage>, 'lang'>
& CodeOptionsThemes<BuiltinTheme>
& CodeOptionsMeta
& {
setup: (highlighter: Highlighter) => Awaitable<void>;
langs: (LanguageInput | BuiltinLanguage)[];
}
>;
/**
* Define a Shiki setup function
*/
function defineShikiSetup(fn: ShikiSetup): ShikiSetup;Setup function for configuring Mermaid diagram rendering.
/**
* Setup function for configuring Mermaid diagrams
* @returns Mermaid configuration options
*/
type MermaidSetup = () => Awaitable<Partial<MermaidConfig> | void>;
/**
* Define a Mermaid setup function
*/
function defineMermaidSetup(fn: MermaidSetup): MermaidSetup;Setup function for configuring KaTeX math rendering.
/**
* Setup function for configuring KaTeX math rendering
* @returns KaTeX configuration options
*/
type KatexSetup = () => Awaitable<Partial<KatexOptions> | void>;
/**
* Define a KaTeX setup function
*/
function defineKatexSetup(fn: KatexSetup): KatexSetup;Setup function for configuring UnoCSS.
/**
* Setup function for configuring UnoCSS
* @returns UnoCSS configuration options
*/
type UnoSetup = () => Awaitable<Partial<UnoCssConfig> | void>;
/**
* Define a UnoCSS setup function
*/
function defineUnoSetup(fn: UnoSetup): UnoSetup;Setup function for configuring markdown transformers.
/**
* Setup function for configuring markdown transformers
* @returns Transformer configuration
*/
type TransformersSetup = () => Awaitable<Partial<TransformersSetupReturn>>;
interface TransformersSetupReturn {
pre: (MarkdownTransformer | false)[];
preCodeblock: (MarkdownTransformer | false)[];
postCodeblock: (MarkdownTransformer | false)[];
post: (MarkdownTransformer | false)[];
}
/**
* Define a transformers setup function
*/
function defineTransformersSetup(fn: TransformersSetup): TransformersSetup;Setup function for configuring content preparsers.
/**
* Setup function for configuring preparsers
* @param context - Context with filepath, headmatter, and mode
* @returns Array of preparser extensions
*/
type PreparserSetup = (context: {
filepath: string;
headmatter: Record<string, unknown>;
mode?: string;
}) => Awaitable<SlidevPreparserExtension[]>;
/**
* Define a preparser setup function
*/
function definePreparserSetup(fn: PreparserSetup): PreparserSetup;Setup function for configuring Vite plugins.
/**
* Setup function for configuring Vite plugins (server-side)
* @param options - Resolved Slidev options
* @returns Array of Vite plugins
*/
type VitePluginsSetup = (options: ResolvedSlidevOptions) => Awaitable<VitePlugin[]>;
/**
* Define a Vite plugins setup function
*/
function defineVitePluginsSetup(fn: VitePluginsSetup): VitePluginsSetup;import {
defineAppSetup,
defineMonacoSetup,
defineShortcutsSetup,
defineCodeRunnersSetup
} from "@slidev/types";
// App setup example
export default defineAppSetup(({ app, router }) => {
// Configure Vue app
app.config.globalProperties.$myGlobal = "value";
// Add router guards
router.beforeEach((to, from, next) => {
console.log(`Navigating to ${to.path}`);
next();
});
});
// Monaco setup example
export default defineMonacoSetup((monaco) => {
// Configure Monaco editor
monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
return {
editorOptions: {
fontSize: 14,
theme: 'vs-dark'
}
};
});
// Shortcuts setup example
export default defineShortcutsSetup((nav, shortcuts) => {
return [
...shortcuts,
{
key: 'ctrl+shift+p',
fn: () => console.log('Custom shortcut pressed'),
name: 'Custom Action'
}
];
});Install with Tessl CLI
npx tessl i tessl/npm-slidev--types