Repository navigation
Description
Parent Issue
Part of Epic #69: Text Editor Architecture Enhancement - Phase 2
Summary
Implement rich node type decoration system that provides contextual visual representations for nodespace:// URI references, where each node type controls its own appearance through the decorateReference() method pattern.
Background
Building on Phase 2.1's Universal Node Reference Service, this adds sophisticated visual decorations that make NodeSpace's node referencing system superior to other knowledge management tools by providing rich, type-specific context.
Architectural Foundation: Content-driven decoration system where BaseNode provides default decoration and derived types override decorateReference() for custom appearance.
Core Functionality
- Node Type Decorations: Visual indicators based on target node type (TaskNode, UserNode, DateNode)
- Content-Driven System: Each node type interprets its
contentproperty for decoration - Contextual Information: Rich metadata display (completion status, due dates, online status)
- Performance Optimized: Viewport-based processing and decoration caching
Decoration Interface
// Base decoration pattern - all nodes inherit this
abstract class BaseNode {
id: string;
content: string; // Raw content - interpretation up to derived types
/**
* Default decoration renders content as simple link
* Derived classes override this method for custom appearance
*/
decorateReference(): string {
return `<a href="nodespace://${this.id}" class="ns-noderef">${this.escapeHtml(this.content)}</a>`;
}
getDisplayText(): string {
return this.content;
}
}
// Node type specific decorations
class TaskNode extends BaseNode {
status: 'not-started' | 'in-progress' | 'completed' | 'blocked';
priority: 'low' | 'medium' | 'high' | 'critical';
due_date?: Date;
decorateReference(): string {
const checkbox = this.status === 'completed' ? '✅' : '☐';
const statusClass = `task-${this.status}`;
const priorityClass = `priority-${this.priority}`;
let decoration = `<a href="nodespace://${this.id}" class="ns-noderef ns-task ${statusClass} ${priorityClass}">`;
decoration += `${checkbox} ${this.escapeHtml(this.content)}`;
if (this.due_date && this.isDueSoon()) {
decoration += `<span class="due-indicator">📅 ${this.formatDueDate()}</span>`;
}
decoration += '</a>';
return decoration;
}
}
class UserNode extends BaseNode {
email: string;
role: string;
is_online: boolean;
avatar_url?: string;
decorateReference(): string {
const statusIndicator = this.is_online ? '🟢' : '⚫';
const roleClass = `role-${this.role.toLowerCase()}`;
let decoration = `<a href="nodespace://${this.id}" class="ns-noderef ns-user ${roleClass}">`;
if (this.avatar_url) {
decoration += `<img src="${this.avatar_url}" class="user-avatar" alt="${this.content}">`;
} else {
decoration += `<span class="user-icon">👤</span>`;
}
decoration += `${this.escapeHtml(this.content)} ${statusIndicator}`;
decoration += '</a>';
return decoration;
}
}
class DateNode extends BaseNode {
date: Date;
date_type: 'date' | 'datetime' | 'time' | 'duration';
decorateReference(): string {
const calendarIcon = this.getCalendarIcon();
const formattedDate = this.formatDate();
const dateClass = `date-${this.date_type}`;
let decoration = `<a href="nodespace://${this.id}" class="ns-noderef ns-date ${dateClass}">`;
decoration += `${calendarIcon} ${formattedDate}`;
const relativeTime = this.getRelativeTime();
if (relativeTime) {
decoration += `<span class="relative-time">(${relativeTime})</span>`;
}
decoration += '</a>';
return decoration;
}
}ContentProcessor Integration
class ContentProcessor {
private nodeRegistry: NodeLookupService;
private NODESPACE_LINK_REGEX = /\[([^\]]+)\]\(nodespace:\/\/([^)]+)\)/g;
/**
* Process nodespace:// links with node-specific decorations
*/
private processNodespaceLinks(content: string): string {
return content.replace(this.NODESPACE_LINK_REGEX, (match, linkText, nodeId) => {
try {
const node = this.nodeRegistry.getNode(nodeId);
if (node && typeof node.decorateReference === 'function') {
return node.decorateReference();
} else {
return `<a href="nodespace://${nodeId}" class="ns-noderef ns-missing">${this.escapeHtml(linkText)}</a>`;
}
} catch (error) {
return `<a href="nodespace://${nodeId}" class="ns-noderef ns-error">${this.escapeHtml(linkText)}</a>`;
}
});
}
}Implementation Tasks
- Enhance ContentProcessor to detect and render
nodespace://URIs - Implement BaseNode
decorateReference()default method - Create TaskNode decorations (checkboxes, status, due dates, priority)
- Implement UserNode decorations (avatars, online status, role indicators)
- Build DateNode decorations (calendar icons, relative time, formatting)
- Create DocumentNode decorations (file types, preview snippets)
- Implement NodeLookupService for UUID resolution and caching
- Build CSS framework for all decoration types (
.ns-noderefsystem) - Add decoration caching for performance optimization
- Integrate with TextNode component for real-time rendering
Acceptance Criteria
-
nodespace://URIs render with appropriate node type decorations - TaskNode references show completion status, due dates, and priority indicators
- UserNode references display avatars, online status, and role information
- DateNode references show calendar icons and relative time formatting
- DocumentNode references display file type icons and preview content
- Missing nodes render with graceful fallback styling
- Performance handles 500+ decorated references efficiently
- All decorations are accessible and keyboard navigable
- Real-time updates when referenced nodes change
- CSS styling preserves NodeSpace's hierarchical design
Dependencies
- Phase 2.1: Implement BacklinkService Foundation #73
- Phase 1.1: Enhanced ContentProcessor with Dual-Representation #70
Estimated Effort
8-9 days
Definition of Done
- ContentProcessor enhanced for
nodespace://link decoration - All major node types implement
decorateReference()method - Rich decorations working for TaskNode, UserNode, DateNode, DocumentNode
- NodeLookupService operational with caching
- CSS framework complete with responsive design
- Performance optimization with viewport-based processing
- Real-time decoration updates via EventBus integration
- Comprehensive testing and documentation completed
Technical Notes
This system leverages the content-driven philosophy where each node type uses its actual content property (not artificial display names) and controls its own visual representation through the decorateReference() method. The approach provides maximum flexibility while maintaining consistency.
Activity
Epic #69 Phase 2: Complete Universal Node Reference System
Complete Phase 2 implementation: Component-based node reference decor…
Complete Design System Integration with NodeViewer (#91)
Epic: Text Editor Architecture Enhancement (#92)
Major Enhancement: Design System Integration with NodeViewer and Prec…
Fix universal references system integration issues
Document unlocked Universal References System (Issues #73, #74)
malibio commentedon Sep 25, 2025
Closing as superseded by business logic layer approach. Link decorations will be handled by the new Rust backend system with proper node behaviors.
Complete Design System Integration with NodeViewer (#91)
Epic: Text Editor Architecture Enhancement (#92)
Major Enhancement: Design System Integration with NodeViewer and Prec…
Fix universal references system integration issues
Document unlocked Universal References System (Issues #73, #74)
Complete Design System Integration with NodeViewer (#91)
Epic: Text Editor Architecture Enhancement (#92)
Major Enhancement: Design System Integration with NodeViewer and Prec…
Fix universal references system integration issues
Document unlocked Universal References System (Issues #73, #74)
Rename methodology "recipe" to "Playbook" across code and docs (#2897)