Repository navigation
Description
Overview
Implement hybrid markdown rendering where users see both syntax characters AND formatting simultaneously during editing. This builds on the simplified CodeMirror foundation from Issue #46.
Scope
Core hybrid syntax + formatting feature:
- Build on always-editing CodeMirror foundation from CodeMirror Foundation Setup #46
- Apply heading font sizes (H1-H6) while preserving syntax characters (
#,##, etc.) - Match font sizes to existing MarkdownRenderer display mode exactly
- Real-time updates as user types (using CodeMirror's debounced events)
- TextNode extends BaseNode with
multiline={true}andmarkdown={true}
Technical Specifications
Exact Font Size Requirements
Match existing MarkdownRenderer heading sizes:
```css
/* Heading sizes to replicate in CodeMirror theme */
.cm-header1 { font-size: 2rem; font-weight: 600; line-height: 1.38em; }
.cm-header2 { font-size: 1.5rem; font-weight: 600; line-height: 1.38em; }
.cm-header3 { font-size: 1.2rem; font-weight: 600; line-height: 1.15em; }
.cm-header4 { font-size: 1rem; font-weight: 600; line-height: 1.15em; }
.cm-header5 { font-size: 0.9rem; font-weight: 600; line-height: 1.15em; }
.cm-header6 { font-size: 0.8rem; font-weight: 600; line-height: 1.15em; }
```
CodeMirror Theme Configuration
```javascript
import { EditorView } from '@codemirror/view'
import { markdown } from '@codemirror/lang-markdown'
// NodeSpace hybrid theme with heading sizes
const nodeSpaceHybridTheme = EditorView.theme({
'.cm-header1': { fontSize: '2rem', fontWeight: '600', lineHeight: '1.38em' },
'.cm-header2': { fontSize: '1.5rem', fontWeight: '600', lineHeight: '1.38em' },
'.cm-header3': { fontSize: '1.2rem', fontWeight: '600', lineHeight: '1.15em' },
'.cm-header4': { fontSize: '1rem', fontWeight: '600', lineHeight: '1.15em' },
'.cm-header5': { fontSize: '0.9rem', fontWeight: '600', lineHeight: '1.15em' },
'.cm-header6': { fontSize: '0.8rem', fontWeight: '600', lineHeight: '1.15em' },
});
// Extensions for TextNode (markdown={true})
const markdownExtensions = [
markdown(),
nodeSpaceHybridTheme
];
```
Component Integration
TextNode extends BaseNode with markdown enabled:
```svelte
<!-- TextNode.svelte -->
<BaseNode
{nodeId}
{content}
multiline={true} <!-- Enable multiline editing -->
markdown={true} <!-- Enable hybrid markdown rendering -->
on:contentChanged
/>
```
CodeMirrorEditor applies theme when `markdown={true}`:
```svelte
<!-- CodeMirrorEditor.svelte -->
```
Implementation Tasks
- Create NodeSpace hybrid markdown theme with exact heading font sizes
- Integrate theme into CodeMirrorEditor when `markdown={true}`
- Implement real-time syntax detection and class application
- Verify font sizes match MarkdownRenderer output exactly
- Test all markdown heading levels (H1-H6)
- Verify syntax characters remain visible during formatting
- Ensure smooth real-time updates without lag
- Test TextNode inheritance pattern works correctly
Acceptance Criteria
- Typing `# Header` shows large font (2rem) immediately while keeping `#` visible
- Removing `#` character returns to normal font size immediately
- All heading levels (H1-H6) work with exact font sizes specified above
- Font sizes match MarkdownRenderer display mode pixel-perfectly
- No visual lag or glitches during real-time updates (< 50ms)
- Syntax characters (`#`, `##`, etc.) remain fully visible
- Cursor position preserved during font size changes
- Multiple headings in same document work correctly
- Heading detection only occurs at line start (not mid-line)
- TextNode properly extends BaseNode with `markdown={true}`
Definition of Done
- Hybrid markdown rendering works end-to-end in TextNode
- All acceptance criteria met and verified
- Font size matching verified visually and through tests
- Performance benchmarks pass (< 50ms update times)
- Real-time updates work smoothly across all heading levels
- Code follows project standards (linting passes)
- Component composition inheritance verified working
- Ready for Performance & Bundle Optimization #49 (performance optimization)
Dependencies
- CodeMirror Foundation Setup #46 must be completed (CodeMirror foundation)
Related Issues
- Hybrid Markdown Rendering System - Live Preview with Syntax Visibility #26 (parent issue)
- Performance & Bundle Optimization #49 (next - Performance & Bundle Optimization)
Activity
Complete Issue #26 breakdown and process documentation
Improve startup sequence CLI commands with JSON+jq approach
Implement CodeMirror Foundation Setup (addresses #46)
Implement hybrid markdown rendering (addresses #47)
Complete Issue #26: Hybrid Markdown Rendering System
malibio commentedon Aug 16, 2025
🔄 Architecture Decision Update
Closing CodeMirror-based hybrid markdown rendering as our research determined that enhanced contenteditable with Logseq patterns is the optimal approach.
Key Decision Points:
Superseded by:
The hybrid markdown functionality will be implemented using our enhanced contenteditable foundation with real-time AST processing for seamless syntax/formatting display.
Complete architecture refactor with Logseq-inspired enhanced contente…
Complete Issue #26 breakdown and process documentation
Improve startup sequence CLI commands with JSON+jq approach