import type { Tokens } from 'marked'; /** * Supported embed providers */ export type EmbedProvider = 'youtube' | 'vimeo' | 'twitter' | 'codepen' | 'codesandbox' | 'github-gist' | 'spotify' | 'soundcloud' | 'slideshare' | 'figma' | 'loom' | 'miro' | 'mermaid' | 'excalidraw' | 'drawio' | 'diagrams-net' | 'pdf' | 'iframe'; /** * Aspect ratio options */ export type AspectRatio = '16:9' | '4:3' | '1:1' | '21:9' | 'custom'; /** * Configuration options for the embed extension */ export interface EmbedOptions { /** CSS class name for the embed container */ className?: string; /** Prefix for generating unique embed IDs */ prefixId?: string; /** Default aspect ratio for embeds */ defaultAspectRatio?: AspectRatio; /** Allow fullscreen for embeds */ allowFullscreen?: boolean; /** Enable lazy loading for embeds */ lazyLoad?: boolean; /** Enable privacy mode (no-cookie domains when available) */ privacyMode?: boolean; /** Custom template for rendering embeds */ template?: string | null; /** Function to customize the embed token */ customizeToken?: ((token: EmbedToken) => void) | null; /** Enable sandbox attributes for iframes */ enableSandbox?: boolean; /** Sandbox permissions (when enableSandbox is true) */ sandboxPermissions?: string[]; /** Custom provider configurations */ providers?: Partial>; /** Callback when embed is loaded */ onEmbedLoad?: ((embedId: string, provider: EmbedProvider) => void) | null; /** Callback when embed fails to load */ onEmbedError?: ((embedId: string, provider: EmbedProvider, error: Error) => void) | null; } /** * Provider-specific configuration */ export interface ProviderConfig { /** Custom domain (e.g., for privacy mode) */ domain?: string; /** Additional query parameters */ params?: Record; /** Enable specific features */ features?: string[]; /** Custom template for this provider */ template?: string; } /** * Metadata for the embed token */ export interface EmbedMeta { /** Embed provider */ provider: EmbedProvider; /** Embed URL or identifier */ url: string; /** Title for the embed */ title?: string; /** Aspect ratio */ aspectRatio?: AspectRatio; /** Custom width */ width?: string; /** Custom height */ height?: string; /** Allow fullscreen */ allowFullscreen?: boolean; /** Enable autoplay */ autoplay?: boolean; /** Enable lazy loading */ lazyLoad?: boolean; /** Privacy mode (no-cookie) */ privacyMode?: boolean; /** Start time (for videos) */ startTime?: string; /** Muted */ muted?: boolean; /** Loop */ loop?: boolean; /** Custom CSS class */ className?: string; /** Unique ID */ id?: string; /** Additional parameters */ params?: Record; /** Theme (light/dark) */ theme?: 'light' | 'dark'; /** Enable controls */ controls?: boolean; [key: string]: string | boolean | Record | undefined; } /** * Token for embed blocks */ export interface EmbedToken extends Tokens.Generic { type: 'embed'; raw: string; meta: EmbedMeta; } /** * Renderer options for the embed */ export interface EmbedRendererOptions { /** Prefix for the embed ID */ prefixId: string; /** Embed metadata */ meta: EmbedMeta; /** CSS class name */ className: string; /** Template for rendering */ template: string | null; /** Enable lazy loading */ lazyLoad: boolean; /** Enable sandbox */ enableSandbox: boolean; /** Sandbox permissions */ sandboxPermissions: string[]; /** Provider configurations */ providers: Partial>; } /** * Parsed embed URL information */ export interface ParsedEmbed { provider: EmbedProvider; id: string; embedUrl: string; originalUrl: string; params?: Record; }