Repository navigation
Description
Phase 1.3: WYSIWYG Processing (hide syntax, show formatting)
Parent Epic: #54
Depends on: #55, #56 (can start with stub interfaces)
Enables: Phase 2 issues (#58, #59, #60)
Overview
Implement WYSIWYG (What You See Is What You Get) processing that hides markdown syntax characters and applies visual formatting in real-time as users type, creating an intuitive editing experience similar to Notion or modern markdown editors.
Parallel Development Note
✅ Can develop in parallel with #56 using mocked pattern detection interfaces. Once #56 provides the actual pattern detection APIs, integrate the real implementations.
Context
After basic markdown pattern detection (#56) can identify syntax patterns, this feature transforms the editing experience by:
- Hiding syntax characters (**, *, `, #, >, etc.)
- Applying visual formatting (bold, italic, code, headers, quotes)
- Maintaining raw markdown storage while showing formatted display
- Preserving cursor positioning during syntax hiding
Implementation Approach
Core WYSIWYG System
// Example transformation pipeline
"**bold text**" → hide "**" → show styled bold text
"# Header" → hide "#" → show large header styling
"`code`" → hide "`" → show code stylingIntegration with Pattern Detection
- Use pattern detection results from Basic Markdown Pattern Detection (4 block types + 3 inline types) #56
- Apply CSS-based visual transformations
- Maintain ContentEditable compatibility from ContentEditable Foundation - Replace CodeMirror with ContentEditable in TextNode #55
Visual Processing Pipeline
- Input Processing: User types markdown syntax
- Pattern Recognition: Use APIs from Basic Markdown Pattern Detection (4 block types + 3 inline types) #56 to identify patterns
- Syntax Hiding: Hide markdown characters from display
- Visual Formatting: Apply CSS styles for formatting
- Storage: Maintain raw markdown in content field
Technical Implementation
WYSIWYG Transformation Engine
interface WYSIWYGProcessor {
// Process content for display (hide syntax, show formatting)
processForDisplay(content: string, patterns: MarkdownPattern[]): HTMLElement;
// Process user input (maintain raw markdown)
processInput(event: InputEvent): string;
// Handle cursor positioning during transformations
maintainCursorPosition(before: number, after: number): void;
}CSS-Based Formatting
/* Example WYSIWYG styles */
.markdown-bold { font-weight: 600; }
.markdown-italic { font-style: italic; }
.markdown-code {
background: hsl(var(--muted));
padding: 0.125rem 0.25rem;
border-radius: 0.25rem;
font-family: var(--font-mono);
}
.markdown-header-1 { font-size: 2rem; font-weight: 700; }
.markdown-header-2 { font-size: 1.5rem; font-weight: 600; }Cursor Position Management
- Track cursor position before WYSIWYG transformations
- Calculate offset changes from hidden characters
- Restore cursor to correct logical position
- Handle edge cases (cursor at syntax boundaries)
Integration Points
With Pattern Detection (#56)
- Use
MarkdownPattern[]results for transformation targets - Subscribe to pattern detection events for real-time updates
- Handle pattern parsing errors gracefully
With ContentEditable Foundation (#55)
- Apply WYSIWYG to ContentEditable elements
- Maintain native text editing behaviors
- Preserve tab/shift-tab indentation from BaseNode
With Node Conversion (Phase 2)
- WYSIWYG display prepares content for bullet-to-node conversion
- Formatted display helps users understand structure before conversion
- Maintain compatibility with smart conversion features
Acceptance Criteria
Visual Formatting
- Bold text (
**text**) displays as bold with hidden syntax markers - Italic text (
*text*) displays as italic with hidden syntax markers -
Inline codedisplays with code styling and hidden backticks - # Headers display with appropriate font sizes and hidden # markers
- > Blockquotes display with quote styling and hidden > markers
User Experience
- Cursor positioning remains accurate during syntax hiding
- Typing experience feels natural and responsive
- Undo/redo works correctly with WYSIWYG transformations
- Copy/paste preserves raw markdown content
- Selection highlighting works across formatted content
Technical Quality
- No performance issues during real-time processing
- Raw markdown content always preserved in storage
- Cross-browser compatibility (Chrome, Firefox, Safari)
- Integration with ContentEditable editing from ContentEditable Foundation - Replace CodeMirror with ContentEditable in TextNode #55
- Clean separation from pattern detection APIs (Basic Markdown Pattern Detection (4 block types + 3 inline types) #56)
Integration Requirements
- Works with mocked pattern detection during parallel development
- Smooth integration when Basic Markdown Pattern Detection (4 block types + 3 inline types) #56 provides actual pattern detection
- Compatible with BaseNode keyboard handlers and events
- Prepares foundation for Phase 2 smart conversion features
Testing Strategy
Unit Tests
- WYSIWYG transformation functions
- Cursor position calculations
- CSS style application
- Raw markdown preservation
Integration Tests
- Combined with ContentEditable foundation (ContentEditable Foundation - Replace CodeMirror with ContentEditable in TextNode #55)
- Pattern detection integration (initially mocked)
- Keyboard shortcuts and node events
- Cross-browser rendering consistency
User Experience Tests
- Real-time typing responsiveness
- Complex markdown document handling
- Edge cases (nested formatting, cursor boundaries)
- Accessibility with screen readers
Coordination Requirements
Interface Contracts
Define stable APIs for pattern detection integration:
interface PatternDetectionAPI {
detectPatterns(content: string): MarkdownPattern[];
subscribeToChanges(callback: (patterns: MarkdownPattern[]) => void): void;
}Mocked Dependencies
For parallel development with #56:
- Mock pattern detection that returns basic patterns
- Stub interfaces that can be replaced with real implementations
- Test data that covers common markdown patterns
Resources & References
Similar Implementations
- Notion: Hides markdown syntax, shows formatting
- Typora: Seamless markdown WYSIWYG experience
- Ghost Editor: Clean syntax hiding with live formatting
Technical Patterns
- Pattern Detection Results: Data structures from Basic Markdown Pattern Detection (4 block types + 3 inline types) #56
- ContentEditable Integration: Foundation from ContentEditable Foundation - Replace CodeMirror with ContentEditable in TextNode #55
- CSS Styling: NodeSpace design system tokens
- Cursor Management: Browser selection APIs
Definition of Done
- Users can type markdown and see formatted output with hidden syntax
- All common markdown patterns (bold, italic, code, headers, quotes) work
- Cursor positioning is accurate and natural during editing
- Raw markdown is always preserved in storage
- Performance is smooth and responsive
- Integration points are well-defined for coordination with other features
- Comprehensive test coverage (unit + integration + UX)
- Ready for Phase 2 smart conversion integration
This WYSIWYG processing provides the visual foundation that makes NodeSpace's ContentEditable system intuitive and user-friendly, preparing for the smart conversion features in Phase 2.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
Activity
Implement comprehensive markdown pattern detection system (addresses #56
Implement comprehensive WYSIWYG processing for real-time markdown for…
Implement comprehensive AI Integration Service for NodeSpace markdown…
Complete ContentEditable Text Editing Epic (addresses #54)
malibio commentedon Aug 16, 2025
✅ COMPLETED - Part of Epic #63 which has been successfully implemented. The ContentEditable foundation with smart markdown features is working correctly.