CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-slidev--types

Comprehensive TypeScript type definitions and interfaces for the Slidev presentation framework ecosystem

Pending
Overview
Eval results
Files

setup-plugins.mddocs/

Setup and Plugin System

Interfaces for extending Slidev with custom functionality including app initialization, Monaco editor setup, code runners, and various plugin hooks.

Capabilities

App Setup

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;

Monaco Editor Setup

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;

Root Setup

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;

Routes Setup

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;

Shortcuts Setup

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;

Code Runners Setup

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;

Context Menu Setup

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;

Shiki Highlighter Setup

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;

Mermaid Setup

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;

KaTeX Setup

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;

UnoCSS Setup

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;

Transformers Setup

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;

Preparser Setup

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;

Vite Plugins Setup

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;

Usage Examples

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

docs

cli-build.md

clicks-interactions.md

code-execution.md

config-frontmatter.md

context-menu.md

index.md

markdown-transform.md

options-system.md

setup-plugins.md

slide-data.md

table-of-contents.md

tile.json