Skip to content

Commit 094dd84

Browse files
feat: add markdown editor and integrate with content renderer
- Implemented a new MarkdownEditor component for editing markdown files. - Updated ContentRenderer to use MarkdownEditor for files with .md and .markdown extensions. - Enhanced editor area layout in WorkspacePage for better usability. - Registered a new dark theme "Dark Summer Night" for the Monaco editor. - Added styles for the new markdown editor and its toolbar. - Created a markdown outline component to navigate headings within the editor. - Introduced utility functions for markdown to HTML conversion and vice versa.
1 parent ed9c191 commit 094dd84

16 files changed

Lines changed: 1667 additions & 459 deletions

EDITOR_PERFORMANCE_REFACTOR.md

Lines changed: 117 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,141 @@
22

33
## Summary of Changes
44

5-
### 1. Performance Optimizations
5+
### 1\. Performance Optimizations
66

77
**Problem**: Monaco editor keystrokes were extremely slow due to direct Zustand store updates on every keystroke.
88

9-
**Solution**:
10-
- Created `useBufferSyncManager` hook that maintains local state and debounces store updates (500ms delay)
11-
- Minimized Zustand subscriptions by using specific selectors instead of broad store subscriptions
12-
- Separated Monaco editor logic into `CodeEditor` component with optimized re-rendering
13-
14-
### 2. Content Architecture Refactoring
15-
16-
**Problem**: Mixed code and non-code content handling in a single editor component.
17-
189
**Solution**:
19-
- Created `ContentRenderer` component that routes to appropriate content handler
20-
- Created `CodeEditor` for text/code files with Monaco
21-
- Created `ContentViewer` for images, videos, audio, PDFs, and binary files
22-
- Extended `BufferType` to include `video` and `audio` types
23-
24-
### 3. Key Components Created
2510

26-
1. **`CodeEditor`** (`code-editor.tsx`)
27-
- High-performance Monaco editor with debounced sync
28-
- LSP integration for TypeScript/JavaScript
29-
- Keybindings and theme support
30-
- Focus management
11+
* Created `useBufferSyncManager` hook that maintains local state and debounces store updates (500ms delay)
12+
13+
* Minimized Zustand subscriptions by using specific selectors instead of broad store subscriptions
14+
15+
* Separated Monaco editor logic into `CodeEditor` component with optimized re-rendering
16+
3117

32-
2. **`ContentViewer`** (`content-viewer.tsx`)
33-
- Image viewer with zoom/pan
34-
- Video/audio players
35-
- PDF viewer (iframe-based)
36-
- Binary file info display
18+
### 2\. Content Architecture Refactoring
3719

38-
3. **`ContentRenderer`** (`content-renderer.tsx`)
39-
- Smart routing between CodeEditor and ContentViewer
40-
- Based on buffer type and editability
20+
**Problem**: Mixed code and non-code content handling in a single editor component.
4121

42-
4. **`useBufferSyncManager`** (`hooks/useBufferSyncManager.ts`)
43-
- Debounced sync to prevent store thrashing
44-
- Local state management for editor content
45-
- External change detection and sync
46-
- Dirty state tracking
22+
**Solution**:
4723

48-
### 4. Buffer Type System Extended
24+
* Created `ContentRenderer` component that routes to appropriate content handler
25+
26+
* Created `CodeEditor` for text/code files with Monaco
27+
28+
* Created `ContentViewer` for images, videos, audio, PDFs, and binary files
29+
30+
* Extended `BufferType` to include `video` and `audio` types
31+
32+
33+
### 3\. Key Components Created
34+
35+
1. `CodeEditor` (`code-editor.tsx`)
36+
37+
* High-performance Monaco editor with debounced sync
38+
39+
* LSP integration for TypeScript/JavaScript
40+
41+
* Keybindings and theme support
42+
43+
* Focus management
44+
45+
2. `ContentViewer` (`content-viewer.tsx`)
46+
47+
* Image viewer with zoom/pan
48+
49+
* Video/audio players
50+
51+
* PDF viewer (iframe-based)
52+
53+
* Binary file info display
54+
55+
3. `ContentRenderer` (`content-renderer.tsx`)
56+
57+
* Smart routing between CodeEditor and ContentViewer
58+
59+
* Based on buffer type and editability
60+
61+
4. `useBufferSyncManager` (`hooks/useBufferSyncManager.ts`)
62+
63+
* Debounced sync to prevent store thrashing
64+
65+
* Local state management for editor content
66+
67+
* External change detection and sync
68+
69+
* Dirty state tracking
70+
71+
72+
# Hello Heading
73+
74+
## H2 
75+
76+
### H3
77+
78+
```ts
79+
const func = () => { console.log("Wow such codeblock")}
80+
```
81+
82+
### 4\. Buffer Type System Extended
4983

5084
Extended `BufferType` to support:
51-
- `video`: MP4, AVI, MOV, WebM, etc.
52-
- `audio`: MP3, WAV, OGG, FLAC, etc.
53-
- Updated MIME type detection
54-
- Updated file extension mappings
55-
56-
### 5. Performance Benefits
57-
58-
- **Reduced Store Updates**: Editor changes are debounced (500ms) instead of immediate
59-
- **Minimal Re-renders**: Components only subscribe to specific data they need
60-
- **Local State**: Monaco editor maintains local content, syncing periodically
61-
- **External Sync**: Still supports external modifications (LLM agents, other splits)
62-
- **Memory Efficiency**: Better garbage collection with proper cleanup
6385

64-
### 6. Future Extensibility
86+
* `video`: MP4, AVI, MOV, WebM, etc.
87+
88+
* `audio`: MP3, WAV, OGG, FLAC, etc.
89+
90+
* Updated MIME type detection
91+
92+
* Updated file extension mappings
93+
94+
95+
### 5\. Performance Benefits
96+
97+
* **Reduced Store Updates**: Editor changes are debounced (500ms) instead of immediate
98+
99+
* **Minimal Re-renders**: Components only subscribe to specific data they need
100+
101+
* **Local State**: Monaco editor maintains local content, syncing periodically
102+
103+
* **External Sync**: Still supports external modifications (LLM agents, other splits)
104+
105+
* **Memory Efficiency**: Better garbage collection with proper cleanup
106+
107+
108+
### 6\. Future Extensibility
65109

66110
The new architecture makes it easy to add:
67-
- More content viewers (3D models, spreadsheets, etc.)
68-
- Custom editors for specific file types
69-
- Preview modes and split editing
70-
- Real-time collaboration features
111+
112+
* More content viewers (3D models, spreadsheets, etc.)
113+
114+
* Custom editors for specific file types
115+
116+
* Preview modes and split editing
117+
118+
* Real-time collaboration features
119+
71120

72121
## Usage
73122

74123
The refactored `EditorPane` now automatically:
75-
1. Uses `ContentRenderer` to choose appropriate component
76-
2. Provides focus management
77-
3. Handles both code and non-code content seamlessly
124+
125+
1. Uses `ContentRenderer` to choose appropriate component
126+
127+
2. Provides focus management
128+
129+
3. Handles both code and non-code content seamlessly
130+
78131

79132
## Migration Notes
80133

81-
- Existing `Editor` component is replaced by `CodeEditor`
82-
- `EditorPane` now uses `ContentRenderer`
83-
- Performance should be dramatically improved for typing
84-
- All existing functionality is preserved
85-
- Non-code files now have proper viewers instead of error states
134+
* Existing `Editor` component is replaced by `CodeEditor`
135+
136+
* `EditorPane` now uses `ContentRenderer`
137+
138+
* Performance should be dramatically improved for typing
139+
140+
* All existing functionality is preserved
141+
142+
* Non-code files now have proper viewers instead of error states

PRESENCE_FEATURE_IMPLEMENTATION.md

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)