Repository navigation
Closed
Description
Overview
Refactor arrow key navigation to use node-specific entry/exit methods instead of assuming all nodes behave like textareas.
Current Problem
- Arrow navigation assumes all nodes are textarea-based
- Hard-coded logic in NodeEditor for cursor positioning
- No way for different node types to define custom navigation behavior
- Complex contenteditable nodes can't integrate properly
Proposed Solution
Add optional navigation methods to BaseNode that nodes can implement:
interface NodeNavigationMethods {
// Can this node accept keyboard navigation?
canAcceptNavigation(): boolean;
// Enter node from top (arrow down from previous node)
enterFromTop(columnHint?: number): boolean;
// Enter node from bottom (arrow up from next node)
enterFromBottom(columnHint?: number): boolean;
// Exit node going up (cursor at first line, arrow up pressed)
exitToTop(): { canExit: boolean; columnPosition: number };
// Exit node going down (cursor at last line, arrow down pressed)
exitToBottom(): { canExit: boolean; columnPosition: number };
// Get current cursor column for cross-node consistency
getCurrentColumn(): number;
}Implementation Benefits
- Node autonomy: Each node type controls its own navigation
- Contenteditable support: Rich editors can implement proper selection handling
- Complex widgets: Future inline widgets can define custom navigation
- Fallback behavior: Nodes without navigation methods are skipped
- Cleaner architecture: Remove navigation assumptions from NodeEditor
Examples
TextNode (textarea-based):
enterFromTop(columnHint = 0) {
this.textareaRef.focus();
this.setCursor(Math.min(columnHint, firstLine.length));
return true;
}
exitToBottom() {
const atLastLine = this.cursorInLastLine();
return { canExit: atLastLine, columnPosition: this.getCurrentColumn() };
}RichTextNode (contenteditable):
enterFromTop(columnHint = 0) {
this.contentEditableRef.focus();
this.setSelectionToStart(columnHint);
return true;
}ImageNode (non-navigable):
canAcceptNavigation() { return false; }
// Node is skipped during arrow navigationTaskNode (checkbox + text):
enterFromTop() {
// Focus text portion, not checkbox
this.textRef.focus();
return true;
}Migration Plan
- Add optional navigation interface to BaseNode
- Implement methods in existing TextNode (textarea-based)
- Update NodeEditor to use node methods instead of direct textarea access
- Test with different node types
- Implement in future contenteditable and widget nodes
Dependencies
- Current BaseNode architecture
- Existing arrow key navigation system
Acceptance Criteria
- BaseNode has optional navigation method interface
- TextNode implements navigation methods for textarea
- NodeEditor routes navigation through node methods
- Non-navigable nodes are skipped during arrow navigation
- Column position is preserved across different node types
- Existing navigation behavior remains unchanged for current nodes
- Architecture ready for contenteditable and widget implementations
Metadata
Metadata
Assignees
Labels
No labels
Activity
Fix: Implement accurate arrow key navigation with proper indentation …
malibio commentedon Dec 5, 2025
Outdated - references ContentEditable controller which no longer exists. Arrow key navigation is implemented in textarea-controller.svelte.ts with:
Any further navigation enhancements should be new issues.
Fix: Implement accurate arrow key navigation with proper indentation …
Fix: Implement accurate arrow key navigation with proper indentation …