# TASK-011: Advanced Code Editor Features **Status:** 📝 Planned (Future) **Priority:** Low-Medium **Estimated Effort:** 1-2 weeks **Dependencies:** TASK-009 (Monaco Replacement) --- ## Problem Statement The current JavaScriptEditor (from TASK-009) is functional and reliable but lacks advanced IDE features: - No syntax highlighting (monochrome code) - No autocomplete/IntelliSense - No hover tooltips for variables/functions - No code folding - No minimap These features would improve the developer experience, especially for: - Complex function nodes with multiple variables - Script nodes with longer code - Users coming from IDEs who expect these features --- ## Proposed Solutions ### Option A: Add Syntax Highlighting Only (Lightweight) **Use Prism.js** - 2KB library, just visual colors **Pros:** - Very lightweight (~2KB gzipped) - No web workers needed - Works with textarea overlay - Many language support - Easy to integrate **Cons:** - No semantic understanding - No autocomplete - Just visual enhancement **Implementation:** ```typescript import Prism from 'prismjs'; import 'prismjs/components/prism-javascript'; // Overlay highlighted version on top of textarea function HighlightedCode({ code }) { const highlighted = Prism.highlight(code, Prism.languages.javascript, 'javascript'); return
; } ``` --- ### Option B: Upgrade to CodeMirror 6 (Moderate) **CodeMirror 6** - Modern, modular editor library **Pros:** - Lighter than Monaco - Works well in Electron - Syntax highlighting - Basic autocomplete - Extensible plugin system - Active development **Cons:** - Larger bundle (~100KB) - More complex integration - Learning curve - Still need to configure autocomplete **Features Available:** - ✅ Syntax highlighting - ✅ Line numbers - ✅ Code folding - ✅ Search/replace - ✅ Multiple cursors - ⚠️ Autocomplete (requires configuration) - ❌ Full IntelliSense (not as good as Monaco/VSCode) --- ### Option C: Monaco with Web Worker Fix (Complex) **Go back to Monaco** but fix the web worker issues **Pros:** - Best-in-class editor - Full IntelliSense - Same as VSCode - TypeScript support - All IDE features **Cons:** - **Very** complex web worker setup in Electron - Large bundle size (~2MB) - We already abandoned this approach - High maintenance burden **Verdict:** Not recommended - defeats purpose of TASK-009 --- ## Recommended Approach **Phase 1: Syntax Highlighting with Prism.js** - Low effort, high impact - Makes code more readable - No performance impact - Keeps the editor simple **Phase 2 (Optional): Consider CodeMirror 6** - Only if users strongly request advanced features - After Phase 1 has proven stable - Requires user feedback to justify effort --- ## Phase 1 Implementation: Prism.js ### Architecture ```tsx /** * Enhanced JavaScriptEditor with syntax highlighting */
{/* Line numbers (existing) */}
...
{/* Syntax highlighted overlay */}
{/* Actual textarea (transparent text) */}