rita-workspace 0.5.36 → 0.5.38

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 CHANGED
@@ -26,6 +26,8 @@ yarn add rita-workspace
26
26
 
27
27
  ## Integration Guide
28
28
 
29
+ > 📘 For the full host-app integration walkthrough (10 steps including auto-save debounce, switch effect, conflict handling, and replacing Excalidraw's "Open from file"), see [docs/INTEGRATION.md](./docs/INTEGRATION.md).
30
+
29
31
  ### 1. `App.tsx` - Add Provider
30
32
 
31
33
  ```tsx
@@ -124,6 +126,19 @@ const [workspaceEnabled] = useState(() =>
124
126
  - State stored in `sessionStorage` (not shared between tabs)
125
127
  - When disabled: auto-save to workspace skipped, drawing-switch disabled, footer hidden
126
128
 
129
+ ### Auto-start preference
130
+
131
+ Users can opt into starting every new tab in workspace mode via a checkbox in `DrawingsDialog`. The preference is stored in `localStorage['rita-workspace-auto-start']` (`"true"` to enable, removed when disabled). The host app reads this flag at init time as a fallback when `sessionStorage` has no explicit value:
132
+
133
+ ```tsx
134
+ const [workspaceEnabled] = useState(() => {
135
+ const sessionVal = sessionStorage.getItem("rita-workspace-enabled");
136
+ if (sessionVal === "true") return true;
137
+ if (sessionVal === "false") return false;
138
+ return localStorage.getItem("rita-workspace-auto-start") === "true";
139
+ });
140
+ ```
141
+
127
142
  ## API Reference
128
143
 
129
144
  ### Components
@@ -131,7 +146,7 @@ const [workspaceEnabled] = useState(() =>
131
146
  | Component | Description |
132
147
  |-----------|-------------|
133
148
  | `WorkspaceProvider` | React context provider. Props: `lang`, `children` |
134
- | `DrawingsDialog` | Management dialog. Props: `open`, `onClose`, `onDrawingSelect`, `renderThumbnail` |
149
+ | `DrawingsDialog` | Management dialog. Props: `open`, `onClose`, `onDrawingSelect` (called on both switch and create), `renderThumbnail` |
135
150
 
136
151
  ### Hooks
137
152
 
@@ -185,7 +200,7 @@ const {
185
200
  importWorkspace, // () => Promise<void>
186
201
  exportDrawingAsExcalidraw, // (id) => Promise<void>
187
202
  exportAllDrawingsAsExcalidraw, // () => Promise<void> — downloads all as .excalidraw files
188
- importExcalidrawFile, // () => Promise<void>
203
+ importExcalidrawFile, // () => Promise<void> — imports .excalidraw files; switches to the last imported drawing
189
204
  } = useWorkspace();
190
205
  ```
191
206
 
package/dist/index.js CHANGED
@@ -794,7 +794,13 @@ function WorkspaceProvider({ children, lang = "en" }) {
794
794
  active = wsDrawings.find((d) => d.id === lastDrawingId) || null;
795
795
  }
796
796
  if (!active && wsDrawings.length > 0) {
797
- active = wsDrawings[0];
797
+ const globalLastActiveId = localStorage.getItem("rita-workspace-last-active-drawing");
798
+ if (globalLastActiveId) {
799
+ active = wsDrawings.find((d) => d.id === globalLastActiveId) || null;
800
+ }
801
+ if (!active) {
802
+ active = wsDrawings[0];
803
+ }
798
804
  }
799
805
  if (active) {
800
806
  setActiveDrawing2(active);
@@ -808,6 +814,11 @@ function WorkspaceProvider({ children, lang = "en" }) {
808
814
  }
809
815
  init();
810
816
  }, []);
817
+ (0, import_react.useEffect)(() => {
818
+ if (activeDrawing?.id) {
819
+ localStorage.setItem("rita-workspace-last-active-drawing", activeDrawing.id);
820
+ }
821
+ }, [activeDrawing?.id]);
811
822
  const refreshDrawings = (0, import_react.useCallback)(async () => {
812
823
  if (!workspace) return;
813
824
  try {
@@ -2197,7 +2208,6 @@ var DrawingsDialog = ({
2197
2208
  },
2198
2209
  style: { background: "none", border: "none", cursor: "pointer", padding: "4px", fontSize: "14px", opacity: 0.5 },
2199
2210
  title: t.delete,
2200
- disabled: drawings.length <= 1,
2201
2211
  children: "\u{1F5D1}\uFE0F"
2202
2212
  }
2203
2213
  )
package/dist/index.mjs CHANGED
@@ -722,7 +722,13 @@ function WorkspaceProvider({ children, lang = "en" }) {
722
722
  active = wsDrawings.find((d) => d.id === lastDrawingId) || null;
723
723
  }
724
724
  if (!active && wsDrawings.length > 0) {
725
- active = wsDrawings[0];
725
+ const globalLastActiveId = localStorage.getItem("rita-workspace-last-active-drawing");
726
+ if (globalLastActiveId) {
727
+ active = wsDrawings.find((d) => d.id === globalLastActiveId) || null;
728
+ }
729
+ if (!active) {
730
+ active = wsDrawings[0];
731
+ }
726
732
  }
727
733
  if (active) {
728
734
  setActiveDrawing2(active);
@@ -736,6 +742,11 @@ function WorkspaceProvider({ children, lang = "en" }) {
736
742
  }
737
743
  init();
738
744
  }, []);
745
+ useEffect(() => {
746
+ if (activeDrawing?.id) {
747
+ localStorage.setItem("rita-workspace-last-active-drawing", activeDrawing.id);
748
+ }
749
+ }, [activeDrawing?.id]);
739
750
  const refreshDrawings = useCallback(async () => {
740
751
  if (!workspace) return;
741
752
  try {
@@ -2125,7 +2136,6 @@ var DrawingsDialog = ({
2125
2136
  },
2126
2137
  style: { background: "none", border: "none", cursor: "pointer", padding: "4px", fontSize: "14px", opacity: 0.5 },
2127
2138
  title: t.delete,
2128
- disabled: drawings.length <= 1,
2129
2139
  children: "\u{1F5D1}\uFE0F"
2130
2140
  }
2131
2141
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rita-workspace",
3
- "version": "0.5.36",
3
+ "version": "0.5.38",
4
4
  "description": "Multi-drawing workspace feature for Rita (Excalidraw fork)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",