Repository navigation
Implement CodeBlockNode component with textarea-based editing (#276) - #286
Merged
Merged
Conversation
…276) **Overview:** Implements dedicated CodeBlockNode component with language selection, multiline editing, and pattern-based auto-detection following the textarea architecture established in #274. **Frontend Changes:** 1. **CodeBlockIcon** (`src/lib/design/icons/components/code-block-icon.svelte`) - CSS-based approach matching design-system-icons.css - 16px circle with curly braces overlay - Theme-aware colors (light: #fcfcfc, dark: #252523) - Exact SVG paths from design system 2. **CodeBlockNode** (`src/lib/design/components/code-block-node.svelte`) - Wraps BaseNode with code-specific functionality - Multiline editing (Shift+Enter for new lines, Enter creates new code-block) - Language dropdown (17 languages, edit mode only) - Copy button (always visible on hover) - Edit mode: Shows ```\ncode\n``` (language hidden, managed by dropdown) - View mode: Clean code display (fences become empty lines for spacing) - Auto-completion: Type ```, press Shift+Enter → auto-adds closing fence - Storage: ```language\ncode\n``` 3. **BaseNode Enhancement** - Added disableMarkdown metadata flag (generic, not code-block specific) - Code blocks render as raw text without markdown processing - Fixes ___BLANK___ placeholder appearing as formatted text 4. **Plugin System** (`src/lib/plugins/core-plugins.ts`) - Added codeBlockNodePlugin with pattern: /^```(\w+)?\n/ - Requires newline to avoid treating user content as language - Auto-completion on conversion to code-block - Slash command: /code → ```plaintext\n\n``` **Backend Changes:** 1. **Constants** (`src-tauri/src/constants.rs`) - Added 'code-block' to ALLOWED_NODE_TYPES 2. **Behavior System** (`packages/core/src/behaviors/mod.rs`) - Added CodeBlockNodeBehavior - Validation: Allows fences with content, rejects truly empty - Configured as leaf node (no children), no markdown support - Default metadata: { language: 'plaintext' } - Registered in NodeBehaviorRegistry **Tests** (`src/tests/plugins/code-block-plugin.test.ts`) - ✅ 12 tests passing - Pattern detection (with/without newline) - Language extraction (javascript, python, typescript) - Plugin registration and configuration - Slash command validation **Design System Compliance:** - Icon matches design-system-icons.css exactly - CSS-based with background SVG for curly braces - Muted background for code area - Monospace font (SF Mono, Monaco, Cascadia Code, etc.) - Language dropdown positioning and styling per spec **UX Enhancements:** - No content splitting: Enter creates new blank code-block below - Auto-completion: ```\n triggers full structure with cursor ready - Wraps existing content: ```Hello + Shift+Enter → ```plaintext\nHello\n``` - Language managed via dropdown (never typed manually) - Frontend placeholder pattern (empty blocks don't persist until code added) **Acceptance Criteria Met:** - ✅ Auto-detect ``` pattern (with Shift+Enter) - ✅ Language dropdown UI matches design system - ✅ Store fence syntax with language in database - ✅ Multiline support (Shift+Enter) - ✅ Enter creates new code-block below (UX improvement over spec) - ✅ No inline formatting support - ✅ Raw text display (no syntax highlighting - Phase 1) - ✅ Registered in plugin system - ✅ Tests cover pattern detection, configuration, slash command - ✅ Removing opening fence converts to TextNode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
… docs
**Copy Button Fixes:**
- Fixed extractCodeContent to remove both opening and closing fences
- Added visual feedback ("copied!" with green background) for 2 seconds
- Users now get clear confirmation when code is copied to clipboard
**Architecture Documentation:**
- Added CodeBlockNode to component implementations list
- Added comprehensive "Advanced Patterns" section documenting:
- Metadata-driven extension pattern (disableMarkdown flag)
- Three-phase content transformation (storage/edit/display)
- Leaf node implementation pattern
- Icon registry configuration for leaf nodes
- Documented all BaseNode metadata extension points
- Provided reusable patterns for future node implementations
**Files Changed:**
- packages/desktop-app/src/lib/design/components/code-block-node.svelte
- extractCodeContent now strips both fences (was only removing opening)
- Added copied state with timeout
- Added .copied CSS class with success styling
- docs/architecture/components/component-architecture-guide.md
- Added CodeBlockNode to existing implementations
- Added 138-line Advanced Patterns section with code examples
**Benefits:**
- Copy button now works correctly (no fence artifacts in clipboard)
- Better UX with visual feedback
- Future developers have clear patterns to follow
- Metadata extension pattern documented for reuse
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
**UX Improvement:** - Reordered LANGUAGES array alphabetically (easier for users to find languages) - Kept 'plaintext' as first option (default language) - Added explanatory comment about ordering rationale **Before:** plaintext, javascript, typescript, python, rust, go, java, cpp, ruby, php, swift, kotlin, shell, html, css, sql, markdown **After:** plaintext (default), cpp, css, go, html, java, javascript, kotlin, markdown, php, python, ruby, rust, shell, sql, swift, typescript **Benefits:** - Predictable alphabetical ordering improves discoverability - Default plaintext remains easily accessible at top - Clear documentation of ordering decision 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 4, 2026
…286) * feat: Implement CodeBlockNode component with textarea-based editing (#276) **Overview:** Implements dedicated CodeBlockNode component with language selection, multiline editing, and pattern-based auto-detection following the textarea architecture established in #274. **Frontend Changes:** 1. **CodeBlockIcon** (`src/lib/design/icons/components/code-block-icon.svelte`) - CSS-based approach matching design-system-icons.css - 16px circle with curly braces overlay - Theme-aware colors (light: #fcfcfc, dark: #252523) - Exact SVG paths from design system 2. **CodeBlockNode** (`src/lib/design/components/code-block-node.svelte`) - Wraps BaseNode with code-specific functionality - Multiline editing (Shift+Enter for new lines, Enter creates new code-block) - Language dropdown (17 languages, edit mode only) - Copy button (always visible on hover) - Edit mode: Shows ```\ncode\n``` (language hidden, managed by dropdown) - View mode: Clean code display (fences become empty lines for spacing) - Auto-completion: Type ```, press Shift+Enter → auto-adds closing fence - Storage: ```language\ncode\n``` 3. **BaseNode Enhancement** - Added disableMarkdown metadata flag (generic, not code-block specific) - Code blocks render as raw text without markdown processing - Fixes ___BLANK___ placeholder appearing as formatted text 4. **Plugin System** (`src/lib/plugins/core-plugins.ts`) - Added codeBlockNodePlugin with pattern: /^```(\w+)?\n/ - Requires newline to avoid treating user content as language - Auto-completion on conversion to code-block - Slash command: /code → ```plaintext\n\n``` **Backend Changes:** 1. **Constants** (`src-tauri/src/constants.rs`) - Added 'code-block' to ALLOWED_NODE_TYPES 2. **Behavior System** (`packages/core/src/behaviors/mod.rs`) - Added CodeBlockNodeBehavior - Validation: Allows fences with content, rejects truly empty - Configured as leaf node (no children), no markdown support - Default metadata: { language: 'plaintext' } - Registered in NodeBehaviorRegistry **Tests** (`src/tests/plugins/code-block-plugin.test.ts`) - ✅ 12 tests passing - Pattern detection (with/without newline) - Language extraction (javascript, python, typescript) - Plugin registration and configuration - Slash command validation **Design System Compliance:** - Icon matches design-system-icons.css exactly - CSS-based with background SVG for curly braces - Muted background for code area - Monospace font (SF Mono, Monaco, Cascadia Code, etc.) - Language dropdown positioning and styling per spec **UX Enhancements:** - No content splitting: Enter creates new blank code-block below - Auto-completion: ```\n triggers full structure with cursor ready - Wraps existing content: ```Hello + Shift+Enter → ```plaintext\nHello\n``` - Language managed via dropdown (never typed manually) - Frontend placeholder pattern (empty blocks don't persist until code added) **Acceptance Criteria Met:** - ✅ Auto-detect ``` pattern (with Shift+Enter) - ✅ Language dropdown UI matches design system - ✅ Store fence syntax with language in database - ✅ Multiline support (Shift+Enter) - ✅ Enter creates new code-block below (UX improvement over spec) - ✅ No inline formatting support - ✅ Raw text display (no syntax highlighting - Phase 1) - ✅ Registered in plugin system - ✅ Tests cover pattern detection, configuration, slash command - ✅ Removing opening fence converts to TextNode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: Improve CodeBlockNode copy functionality and update architecture docs **Copy Button Fixes:** - Fixed extractCodeContent to remove both opening and closing fences - Added visual feedback ("copied!" with green background) for 2 seconds - Users now get clear confirmation when code is copied to clipboard **Architecture Documentation:** - Added CodeBlockNode to component implementations list - Added comprehensive "Advanced Patterns" section documenting: - Metadata-driven extension pattern (disableMarkdown flag) - Three-phase content transformation (storage/edit/display) - Leaf node implementation pattern - Icon registry configuration for leaf nodes - Documented all BaseNode metadata extension points - Provided reusable patterns for future node implementations **Files Changed:** - packages/desktop-app/src/lib/design/components/code-block-node.svelte - extractCodeContent now strips both fences (was only removing opening) - Added copied state with timeout - Added .copied CSS class with success styling - docs/architecture/components/component-architecture-guide.md - Added CodeBlockNode to existing implementations - Added 138-line Advanced Patterns section with code examples **Benefits:** - Copy button now works correctly (no fence artifacts in clipboard) - Better UX with visual feedback - Future developers have clear patterns to follow - Metadata extension pattern documented for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Sort language list alphabetically with plaintext as default **UX Improvement:** - Reordered LANGUAGES array alphabetically (easier for users to find languages) - Kept 'plaintext' as first option (default language) - Added explanatory comment about ordering rationale **Before:** plaintext, javascript, typescript, python, rust, go, java, cpp, ruby, php, swift, kotlin, shell, html, css, sql, markdown **After:** plaintext (default), cpp, css, go, html, java, javascript, kotlin, markdown, php, python, ruby, rust, shell, sql, swift, typescript **Benefits:** - Predictable alphabetical ordering improves discoverability - Default plaintext remains easily accessible at top - Clear documentation of ordering decision 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 5, 2026
…286) * feat: Implement CodeBlockNode component with textarea-based editing (#276) **Overview:** Implements dedicated CodeBlockNode component with language selection, multiline editing, and pattern-based auto-detection following the textarea architecture established in #274. **Frontend Changes:** 1. **CodeBlockIcon** (`src/lib/design/icons/components/code-block-icon.svelte`) - CSS-based approach matching design-system-icons.css - 16px circle with curly braces overlay - Theme-aware colors (light: #fcfcfc, dark: #252523) - Exact SVG paths from design system 2. **CodeBlockNode** (`src/lib/design/components/code-block-node.svelte`) - Wraps BaseNode with code-specific functionality - Multiline editing (Shift+Enter for new lines, Enter creates new code-block) - Language dropdown (17 languages, edit mode only) - Copy button (always visible on hover) - Edit mode: Shows ```\ncode\n``` (language hidden, managed by dropdown) - View mode: Clean code display (fences become empty lines for spacing) - Auto-completion: Type ```, press Shift+Enter → auto-adds closing fence - Storage: ```language\ncode\n``` 3. **BaseNode Enhancement** - Added disableMarkdown metadata flag (generic, not code-block specific) - Code blocks render as raw text without markdown processing - Fixes ___BLANK___ placeholder appearing as formatted text 4. **Plugin System** (`src/lib/plugins/core-plugins.ts`) - Added codeBlockNodePlugin with pattern: /^```(\w+)?\n/ - Requires newline to avoid treating user content as language - Auto-completion on conversion to code-block - Slash command: /code → ```plaintext\n\n``` **Backend Changes:** 1. **Constants** (`src-tauri/src/constants.rs`) - Added 'code-block' to ALLOWED_NODE_TYPES 2. **Behavior System** (`packages/core/src/behaviors/mod.rs`) - Added CodeBlockNodeBehavior - Validation: Allows fences with content, rejects truly empty - Configured as leaf node (no children), no markdown support - Default metadata: { language: 'plaintext' } - Registered in NodeBehaviorRegistry **Tests** (`src/tests/plugins/code-block-plugin.test.ts`) - ✅ 12 tests passing - Pattern detection (with/without newline) - Language extraction (javascript, python, typescript) - Plugin registration and configuration - Slash command validation **Design System Compliance:** - Icon matches design-system-icons.css exactly - CSS-based with background SVG for curly braces - Muted background for code area - Monospace font (SF Mono, Monaco, Cascadia Code, etc.) - Language dropdown positioning and styling per spec **UX Enhancements:** - No content splitting: Enter creates new blank code-block below - Auto-completion: ```\n triggers full structure with cursor ready - Wraps existing content: ```Hello + Shift+Enter → ```plaintext\nHello\n``` - Language managed via dropdown (never typed manually) - Frontend placeholder pattern (empty blocks don't persist until code added) **Acceptance Criteria Met:** - ✅ Auto-detect ``` pattern (with Shift+Enter) - ✅ Language dropdown UI matches design system - ✅ Store fence syntax with language in database - ✅ Multiline support (Shift+Enter) - ✅ Enter creates new code-block below (UX improvement over spec) - ✅ No inline formatting support - ✅ Raw text display (no syntax highlighting - Phase 1) - ✅ Registered in plugin system - ✅ Tests cover pattern detection, configuration, slash command - ✅ Removing opening fence converts to TextNode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: Improve CodeBlockNode copy functionality and update architecture docs **Copy Button Fixes:** - Fixed extractCodeContent to remove both opening and closing fences - Added visual feedback ("copied!" with green background) for 2 seconds - Users now get clear confirmation when code is copied to clipboard **Architecture Documentation:** - Added CodeBlockNode to component implementations list - Added comprehensive "Advanced Patterns" section documenting: - Metadata-driven extension pattern (disableMarkdown flag) - Three-phase content transformation (storage/edit/display) - Leaf node implementation pattern - Icon registry configuration for leaf nodes - Documented all BaseNode metadata extension points - Provided reusable patterns for future node implementations **Files Changed:** - packages/desktop-app/src/lib/design/components/code-block-node.svelte - extractCodeContent now strips both fences (was only removing opening) - Added copied state with timeout - Added .copied CSS class with success styling - docs/architecture/components/component-architecture-guide.md - Added CodeBlockNode to existing implementations - Added 138-line Advanced Patterns section with code examples **Benefits:** - Copy button now works correctly (no fence artifacts in clipboard) - Better UX with visual feedback - Future developers have clear patterns to follow - Metadata extension pattern documented for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Sort language list alphabetically with plaintext as default **UX Improvement:** - Reordered LANGUAGES array alphabetically (easier for users to find languages) - Kept 'plaintext' as first option (default language) - Added explanatory comment about ordering rationale **Before:** plaintext, javascript, typescript, python, rust, go, java, cpp, ruby, php, swift, kotlin, shell, html, css, sql, markdown **After:** plaintext (default), cpp, css, go, html, java, javascript, kotlin, markdown, php, python, ruby, rust, shell, sql, swift, typescript **Benefits:** - Predictable alphabetical ordering improves discoverability - Default plaintext remains easily accessible at top - Clear documentation of ordering decision 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
malibio
added a commit
that referenced
this pull request
Feb 26, 2026
…286) * feat: Implement CodeBlockNode component with textarea-based editing (#276) **Overview:** Implements dedicated CodeBlockNode component with language selection, multiline editing, and pattern-based auto-detection following the textarea architecture established in #274. **Frontend Changes:** 1. **CodeBlockIcon** (`src/lib/design/icons/components/code-block-icon.svelte`) - CSS-based approach matching design-system-icons.css - 16px circle with curly braces overlay - Theme-aware colors (light: #fcfcfc, dark: #252523) - Exact SVG paths from design system 2. **CodeBlockNode** (`src/lib/design/components/code-block-node.svelte`) - Wraps BaseNode with code-specific functionality - Multiline editing (Shift+Enter for new lines, Enter creates new code-block) - Language dropdown (17 languages, edit mode only) - Copy button (always visible on hover) - Edit mode: Shows ```\ncode\n``` (language hidden, managed by dropdown) - View mode: Clean code display (fences become empty lines for spacing) - Auto-completion: Type ```, press Shift+Enter → auto-adds closing fence - Storage: ```language\ncode\n``` 3. **BaseNode Enhancement** - Added disableMarkdown metadata flag (generic, not code-block specific) - Code blocks render as raw text without markdown processing - Fixes ___BLANK___ placeholder appearing as formatted text 4. **Plugin System** (`src/lib/plugins/core-plugins.ts`) - Added codeBlockNodePlugin with pattern: /^```(\w+)?\n/ - Requires newline to avoid treating user content as language - Auto-completion on conversion to code-block - Slash command: /code → ```plaintext\n\n``` **Backend Changes:** 1. **Constants** (`src-tauri/src/constants.rs`) - Added 'code-block' to ALLOWED_NODE_TYPES 2. **Behavior System** (`packages/core/src/behaviors/mod.rs`) - Added CodeBlockNodeBehavior - Validation: Allows fences with content, rejects truly empty - Configured as leaf node (no children), no markdown support - Default metadata: { language: 'plaintext' } - Registered in NodeBehaviorRegistry **Tests** (`src/tests/plugins/code-block-plugin.test.ts`) - ✅ 12 tests passing - Pattern detection (with/without newline) - Language extraction (javascript, python, typescript) - Plugin registration and configuration - Slash command validation **Design System Compliance:** - Icon matches design-system-icons.css exactly - CSS-based with background SVG for curly braces - Muted background for code area - Monospace font (SF Mono, Monaco, Cascadia Code, etc.) - Language dropdown positioning and styling per spec **UX Enhancements:** - No content splitting: Enter creates new blank code-block below - Auto-completion: ```\n triggers full structure with cursor ready - Wraps existing content: ```Hello + Shift+Enter → ```plaintext\nHello\n``` - Language managed via dropdown (never typed manually) - Frontend placeholder pattern (empty blocks don't persist until code added) **Acceptance Criteria Met:** - ✅ Auto-detect ``` pattern (with Shift+Enter) - ✅ Language dropdown UI matches design system - ✅ Store fence syntax with language in database - ✅ Multiline support (Shift+Enter) - ✅ Enter creates new code-block below (UX improvement over spec) - ✅ No inline formatting support - ✅ Raw text display (no syntax highlighting - Phase 1) - ✅ Registered in plugin system - ✅ Tests cover pattern detection, configuration, slash command - ✅ Removing opening fence converts to TextNode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: Improve CodeBlockNode copy functionality and update architecture docs **Copy Button Fixes:** - Fixed extractCodeContent to remove both opening and closing fences - Added visual feedback ("copied!" with green background) for 2 seconds - Users now get clear confirmation when code is copied to clipboard **Architecture Documentation:** - Added CodeBlockNode to component implementations list - Added comprehensive "Advanced Patterns" section documenting: - Metadata-driven extension pattern (disableMarkdown flag) - Three-phase content transformation (storage/edit/display) - Leaf node implementation pattern - Icon registry configuration for leaf nodes - Documented all BaseNode metadata extension points - Provided reusable patterns for future node implementations **Files Changed:** - packages/desktop-app/src/lib/design/components/code-block-node.svelte - extractCodeContent now strips both fences (was only removing opening) - Added copied state with timeout - Added .copied CSS class with success styling - docs/architecture/components/component-architecture-guide.md - Added CodeBlockNode to existing implementations - Added 138-line Advanced Patterns section with code examples **Benefits:** - Copy button now works correctly (no fence artifacts in clipboard) - Better UX with visual feedback - Future developers have clear patterns to follow - Metadata extension pattern documented for reuse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * refactor: Sort language list alphabetically with plaintext as default **UX Improvement:** - Reordered LANGUAGES array alphabetically (easier for users to find languages) - Kept 'plaintext' as first option (default language) - Added explanatory comment about ordering rationale **Before:** plaintext, javascript, typescript, python, rust, go, java, cpp, ruby, php, swift, kotlin, shell, html, css, sql, markdown **After:** plaintext (default), cpp, css, go, html, java, javascript, kotlin, markdown, php, python, ruby, rust, shell, sql, swift, typescript **Benefits:** - Predictable alphabetical ordering improves discoverability - Default plaintext remains easily accessible at top - Clear documentation of ordering decision 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements dedicated CodeBlockNode component with language selection, multiline editing, and pattern-based auto-detection following the textarea architecture.
Changes
Frontend
disableMarkdownmetadata flagBackend
Features
Testing
🤖 Generated with Claude Code