Overview
CodeInk uses CodeMirror 6, a modern code editor built from the ground up for extensibility and performance. The editor provides a familiar, powerful interface for writing and editing markdown documents.Core Features
Basic Setup
The editor is initialized with a comprehensive set of features through thebasicSetup extension:
The
basicSetup includes line numbers, bracket matching, search/replace, and undo/redo out of the box.Markdown Language Support
CodeInk includes full markdown language support with intelligent keymaps:- Markdown-aware syntax highlighting
- Smart indentation
- Keyboard shortcuts for common markdown operations
- Context-aware completions
Theme System
Dynamic Theme Switching
The editor supports both light and dark themes that can be switched dynamically without reloading:- Light Theme
- Dark Theme
Custom light theme using CSS variables for seamless integration:
Runtime Theme Updates
Themes can be changed without recreating the editor using compartments:Real-time Updates
Document Change Events
The editor emits custom events whenever content changes:- Live preview updates
- Auto-save functionality
- Real-time collaboration features
Content Management
Access and modify editor content programmatically:Performance
Efficient Document Model
CodeMirror 6 uses a sophisticated document model that:- Handles documents of any size efficiently
- Updates only changed portions of the DOM
- Maintains smooth scrolling even with syntax highlighting
Lazy Loading
The editor initializes quickly by deferring non-critical features:Integration Points
Lint Integration
See Markdown Linting for details on how the editor integrates with remark-lint.Auto-save
Changes are automatically saved with a debounce delay:Source Code Reference
Implementation details can be found in:/src/scripts/codemirror-setup.ts- Editor initialization and configuration/src/scripts/editor.ts- Main editor controller and auto-save logic
Related Features
- Syntax Highlighting - Shiki integration for code blocks
- Markdown Linting - Real-time linting with remark
- Mermaid Diagrams - Diagram rendering in preview