rita-workspace 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -78
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,103 +2,170 @@
|
|
|
2
2
|
|
|
3
3
|
Multi-drawing workspace feature for Rita (Excalidraw fork based on B310-digital/excalidraw).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **Multiple drawings** - Create and manage multiple drawings in one workspace
|
|
8
|
+
- **Menu integration** - Seamlessly integrates with Excalidraw's hamburger menu
|
|
9
|
+
- **Auto-save** - All drawings saved locally in IndexedDB
|
|
10
|
+
- **Rename & delete** - Full drawing management via dialog
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Installation
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
```bash
|
|
15
|
+
npm install rita-workspace
|
|
16
|
+
# or
|
|
17
|
+
yarn add rita-workspace
|
|
18
|
+
```
|
|
16
19
|
|
|
17
|
-
##
|
|
20
|
+
## Integration Guide
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
- [ ] Sidebar with list of drawings
|
|
21
|
-
- [ ] Create new drawing button
|
|
22
|
-
- [ ] Switch between drawings (preserves state)
|
|
23
|
-
- [ ] Rename drawings
|
|
24
|
-
- [ ] Delete drawings
|
|
25
|
-
- [ ] Auto-save to browser storage (IndexedDB)
|
|
26
|
-
- [ ] Import existing .excalidraw files into workspace
|
|
27
|
-
|
|
28
|
-
### Future (v2.0+)
|
|
29
|
-
- [ ] Folders/categories for drawings
|
|
30
|
-
- [ ] Search drawings
|
|
31
|
-
- [ ] Thumbnail previews
|
|
32
|
-
- [ ] Export entire workspace
|
|
33
|
-
- [ ] Cloud sync (optional)
|
|
34
|
-
- [ ] Link/reference between drawings
|
|
35
|
-
|
|
36
|
-
## Technical Approach
|
|
37
|
-
|
|
38
|
-
### Storage
|
|
39
|
-
- Use IndexedDB for persistent storage (better than localStorage for binary data)
|
|
40
|
-
- Each drawing stored as separate entry with metadata
|
|
41
|
-
- Workspace metadata stored separately
|
|
42
|
-
|
|
43
|
-
### Data Structure
|
|
44
|
-
```typescript
|
|
45
|
-
interface Drawing {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
createdAt: Date;
|
|
49
|
-
updatedAt: Date;
|
|
50
|
-
elements: ExcalidrawElement[];
|
|
51
|
-
appState: Partial<AppState>;
|
|
52
|
-
files: BinaryFiles;
|
|
53
|
-
}
|
|
22
|
+
Two files need to be modified in the B310/Excalidraw fork:
|
|
54
23
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
24
|
+
### 1. `excalidraw-app/App.tsx`
|
|
25
|
+
|
|
26
|
+
**Add import** (at the top with other imports):
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { WorkspaceProvider } from "rita-workspace";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Wrap with WorkspaceProvider** (in the `ExcalidrawApp` component):
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
const ExcalidrawApp = () => {
|
|
36
|
+
// ...
|
|
37
|
+
return (
|
|
38
|
+
<TopErrorBoundary>
|
|
39
|
+
<Provider store={appJotaiStore}>
|
|
40
|
+
<WorkspaceProvider> {/* <-- Add this */}
|
|
41
|
+
<ExcalidrawWrapper />
|
|
42
|
+
</WorkspaceProvider> {/* <-- And this */}
|
|
43
|
+
</Provider>
|
|
44
|
+
</TopErrorBoundary>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
63
47
|
```
|
|
64
48
|
|
|
65
|
-
###
|
|
66
|
-
- `WorkspaceSidebar` - Collapsible sidebar showing drawing list
|
|
67
|
-
- `DrawingListItem` - Individual drawing entry with actions
|
|
68
|
-
- `NewDrawingButton` - Creates new blank drawing
|
|
69
|
-
- `WorkspaceProvider` - React context for workspace state
|
|
49
|
+
### 2. `excalidraw-app/components/AppMainMenu.tsx`
|
|
70
50
|
|
|
71
|
-
|
|
51
|
+
**Add imports** (at the top):
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
2. Maintained as a separate layer/plugin for Rita
|
|
53
|
+
```tsx
|
|
54
|
+
import React, { useState } from "react"; // Add useState
|
|
76
55
|
|
|
77
|
-
|
|
56
|
+
// Add after other imports:
|
|
57
|
+
import { WorkspaceMenuItems, DrawingsDialog } from "rita-workspace";
|
|
58
|
+
```
|
|
78
59
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
**Add state and menu items** (inside the component):
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
export const AppMainMenu: React.FC<{...}> = React.memo((props) => {
|
|
64
|
+
const [showDrawingsDialog, setShowDrawingsDialog] = useState(false); // Add this
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<> {/* Add fragment */}
|
|
68
|
+
<MainMenu>
|
|
69
|
+
<MainMenu.DefaultItems.LoadScene />
|
|
70
|
+
<MainMenu.DefaultItems.SaveToActiveFile />
|
|
71
|
+
|
|
72
|
+
{/* === RITA WORKSPACE: Add this block === */}
|
|
73
|
+
<MainMenu.Sub>
|
|
74
|
+
<MainMenu.Sub.Trigger>📄 Ritningar</MainMenu.Sub.Trigger>
|
|
75
|
+
<MainMenu.Sub.Content>
|
|
76
|
+
<WorkspaceMenuItems
|
|
77
|
+
onManageDrawings={() => setShowDrawingsDialog(true)}
|
|
78
|
+
/>
|
|
79
|
+
</MainMenu.Sub.Content>
|
|
80
|
+
</MainMenu.Sub>
|
|
81
|
+
{/* === END RITA WORKSPACE === */}
|
|
82
|
+
|
|
83
|
+
<MainMenu.DefaultItems.Export />
|
|
84
|
+
{/* ... rest of menu items ... */}
|
|
85
|
+
</MainMenu>
|
|
86
|
+
|
|
87
|
+
{/* === RITA WORKSPACE: Add dialog === */}
|
|
88
|
+
<DrawingsDialog
|
|
89
|
+
open={showDrawingsDialog}
|
|
90
|
+
onClose={() => setShowDrawingsDialog(false)}
|
|
91
|
+
/>
|
|
92
|
+
</> {/* Close fragment */}
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
```
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
## Result
|
|
98
|
+
|
|
99
|
+
After integration, a "📄 Ritningar" submenu appears in the hamburger menu:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
┌─────────────────────────┐
|
|
103
|
+
│ 📂 Open │
|
|
104
|
+
│ 💾 Save │
|
|
105
|
+
│ 📄 Ritningar ▶ │──┐
|
|
106
|
+
│ 📤 Export │ │ ┌─────────────────────┐
|
|
107
|
+
│ ... │ └──│ ✓ Current drawing │
|
|
108
|
+
└─────────────────────────┘ │ Sketch 2 │
|
|
109
|
+
│ Project X │
|
|
110
|
+
│ ─────────────────── │
|
|
111
|
+
│ + Ny ritning │
|
|
112
|
+
│ 📄 Hantera... │
|
|
113
|
+
└─────────────────────┘
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## API Reference
|
|
117
|
+
|
|
118
|
+
### Components
|
|
119
|
+
|
|
120
|
+
| Component | Description |
|
|
121
|
+
|-----------|-------------|
|
|
122
|
+
| `WorkspaceProvider` | React context provider - wrap your app with this |
|
|
123
|
+
| `WorkspaceMenuItems` | Menu items for Excalidraw's MainMenu |
|
|
124
|
+
| `DrawingsDialog` | Modal dialog for managing all drawings |
|
|
125
|
+
|
|
126
|
+
### Hooks
|
|
127
|
+
|
|
128
|
+
| Hook | Description |
|
|
129
|
+
|------|-------------|
|
|
130
|
+
| `useWorkspace()` | Access workspace state and actions |
|
|
131
|
+
|
|
132
|
+
### useWorkspace() returns
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
const {
|
|
136
|
+
drawings, // Drawing[] - all drawings
|
|
137
|
+
activeDrawing, // Drawing | null - currently active
|
|
138
|
+
isLoading, // boolean
|
|
139
|
+
createNewDrawing, // () => Promise<Drawing>
|
|
140
|
+
switchDrawing, // (id: string) => Promise<void>
|
|
141
|
+
renameDrawing, // (id: string, name: string) => Promise<void>
|
|
142
|
+
removeDrawing, // (id: string) => Promise<void>
|
|
143
|
+
saveCurrentDrawing, // (elements, appState, files?) => Promise<void>
|
|
144
|
+
} = useWorkspace();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Data Storage
|
|
148
|
+
|
|
149
|
+
Drawings are stored in IndexedDB with the following structure:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface Drawing {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
elements: ExcalidrawElement[];
|
|
156
|
+
appState: Record<string, unknown>;
|
|
157
|
+
files: Record<string, unknown>;
|
|
158
|
+
createdAt: number;
|
|
159
|
+
updatedAt: number;
|
|
160
|
+
}
|
|
94
161
|
```
|
|
95
162
|
|
|
96
163
|
## Links
|
|
97
164
|
|
|
165
|
+
- **npm:** https://www.npmjs.com/package/rita-workspace
|
|
98
166
|
- **B310 Excalidraw Fork:** https://github.com/b310-digital/excalidraw
|
|
99
167
|
- **Original Excalidraw:** https://github.com/excalidraw/excalidraw
|
|
100
|
-
- **Rita:** Your local Rita deployment
|
|
101
168
|
|
|
102
169
|
## License
|
|
103
170
|
|
|
104
|
-
MIT
|
|
171
|
+
MIT
|