Skip to content

WYSIWYG Processing (hide syntax, show formatting) #57

Closed

Description

@malibio

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 styling

Integration with Pattern Detection

Visual Processing Pipeline

  1. Input Processing: User types markdown syntax
  2. Pattern Recognition: Use APIs from Basic Markdown Pattern Detection (4 block types + 3 inline types) #56 to identify patterns
  3. Syntax Hiding: Hide markdown characters from display
  4. Visual Formatting: Apply CSS styles for formatting
  5. 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 code displays 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

Integration Requirements

Testing Strategy

Unit Tests

  • WYSIWYG transformation functions
  • Cursor position calculations
  • CSS style application
  • Raw markdown preservation

Integration Tests

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

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

  1. added
    enhancement
    on Aug 11, 2025
  2. self-assigned this
    on Aug 12, 2025
  3. malibio commented on Aug 16, 2025

    @malibio
    CollaboratorAuthor

    ✅ COMPLETED - Part of Epic #63 which has been successfully implemented. The ContentEditable foundation with smart markdown features is working correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions