UNPKG

@jager-ai/holy-editor

Version:

Rich text editor with Bible verse slash commands and PWA keyboard tracking, extracted from Holy Habit project

195 lines (171 loc) 4.17 kB
/** * HolyEditor Types * * Type definitions for the HolyEditor system */ // Bible reference interfaces export interface BibleVerse { book: string; chapter: number; verse: number; text: string; } export interface BibleVerseData { verses: BibleVerse[]; isRange: boolean; } export interface BibleApiResponse { success: boolean; verses: BibleVerse[]; } // Editor configuration export interface EditorConfig { apiEndpoint?: string; enableSlashCommands?: boolean; enableBibleVerses?: boolean; enableToolbar?: boolean; enablePWATracking?: boolean; enableToasts?: boolean; enableAutoSave?: boolean; cacheEnabled?: boolean; debounceMs?: number; autoSaveInterval?: number; autoSaveKey?: string; colors?: string[]; colorNames?: string[]; enableTextFormatting?: boolean; enablePWAKeyboard?: boolean; keyboardSettings?: KeyboardTrackingSettings; enableColorPicker?: boolean; } // Slash command interfaces export interface SlashCommandMatch { ref: string; position: number; fullMatch: string; } // PWA keyboard tracking interfaces export interface PWAEnvironment { isPWA: boolean; isIOS: boolean; isAndroid: boolean; hasVisualViewport: boolean; isAndroidChrome: boolean; isSamsungInternet: boolean; } export interface KeyboardTrackingSettings { threshold: number; keyboardMin: number; debounceTime: number; } // Toolbar interfaces export interface ToolbarButtonState { action: string; isActive: boolean; } export type FormatAction = 'bold' | 'underline' | 'heading1' | 'quote' | 'textcolor'; // Color picker interfaces export interface ColorOption { color: string; name: string; } // Toast notification interfaces export interface ToastOptions { message: string; duration?: number; type?: 'info' | 'success' | 'warning' | 'error'; } // Error handling export class EditorError extends Error { constructor( message: string, public code?: string, public originalError?: Error ) { super(message); this.name = 'EditorError'; } } export class BibleApiError extends EditorError { constructor( message: string, public statusCode?: number, originalError?: Error ) { super(message, 'BIBLE_API_ERROR', originalError); this.name = 'BibleApiError'; } } // Event handler types export type EditorEventHandler = (event: Event) => void; export type KeyboardEventHandler = (event: KeyboardEvent) => void; export type SelectionChangeHandler = () => void; // Selection and range interfaces export interface EditorSelection { range: Range; selectedText: string; hasSelection: boolean; } // Format state interface export interface FormatState { bold: boolean; underline: boolean; heading1: boolean; quote: boolean; textcolor: boolean; } // Bible book mappings export interface BibleBookMapping { [abbr: string]: string; } // Cache interface export interface VerseCache { [ref: string]: BibleVerseData; } // Platform detection export interface PlatformInfo { isIOS: boolean; isAndroid: boolean; isAndroidChrome: boolean; isSamsungInternet: boolean; isPWA: boolean; hasVisualViewport: boolean; } // Keyboard offset calculation export interface KeyboardOffsetData { offset: number; visualHeight?: number; innerHeight: number; keyboardHeight: number; } // Component lifecycle export interface EditorLifecycle { onInit?: () => void; onDestroy?: () => void; onContentChange?: (content: string) => void; onSelectionChange?: () => void; onFormatChange?: (formatState: FormatState) => void; } // Auto-save types export interface AutoSaveData { content: string; timestamp: number; version: string; editorId: string; } export interface AutoSaveOptions { interval?: number; key?: string; maxSize?: number; onSave?: (data: AutoSaveData) => void; onRestore?: (data: AutoSaveData) => void; onError?: (error: Error) => void; } // External integrations export interface ExternalIntegration { insertContent?: (content: string, position?: 'cursor' | 'end') => boolean; getContent?: () => string; setContent?: (content: string) => void; focus?: () => void; blur?: () => void; }