rita-workspace 0.5.5 → 0.5.7

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/dist/index.js CHANGED
@@ -1359,6 +1359,7 @@ var DrawingsDialog = ({
1359
1359
  const [editName, setEditName] = (0, import_react5.useState)("");
1360
1360
  const [confirmDeleteId, setConfirmDeleteId] = (0, import_react5.useState)(null);
1361
1361
  const [switchingId, setSwitchingId] = (0, import_react5.useState)(null);
1362
+ const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
1362
1363
  const [expandedFolders, setExpandedFolders] = (0, import_react5.useState)(/* @__PURE__ */ new Set());
1363
1364
  const [creatingFolder, setCreatingFolder] = (0, import_react5.useState)(false);
1364
1365
  const [newFolderName, setNewFolderName] = (0, import_react5.useState)("");
@@ -1367,7 +1368,6 @@ var DrawingsDialog = ({
1367
1368
  const [confirmDeleteFolderId, setConfirmDeleteFolderId] = (0, import_react5.useState)(null);
1368
1369
  const [movingDrawingId, setMovingDrawingId] = (0, import_react5.useState)(null);
1369
1370
  const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
1370
- const [busyFolderId, setBusyFolderId] = (0, import_react5.useState)(null);
1371
1371
  const [isRefreshing, setIsRefreshing] = (0, import_react5.useState)(false);
1372
1372
  const [draggingDrawingId, setDraggingDrawingId] = (0, import_react5.useState)(null);
1373
1373
  const [dropTargetFolderId, setDropTargetFolderId] = (0, import_react5.useState)(null);
@@ -1376,6 +1376,8 @@ var DrawingsDialog = ({
1376
1376
  const dialogRef = (0, import_react5.useRef)(null);
1377
1377
  const newFolderInputRef = (0, import_react5.useRef)(null);
1378
1378
  const prevOpenRef = (0, import_react5.useRef)(false);
1379
+ const foldersRef = (0, import_react5.useRef)(folders);
1380
+ foldersRef.current = folders;
1379
1381
  (0, import_react5.useEffect)(() => {
1380
1382
  if (open) {
1381
1383
  setIsRefreshing(true);
@@ -1383,11 +1385,12 @@ var DrawingsDialog = ({
1383
1385
  if (!prevOpenRef.current) {
1384
1386
  setPosition(null);
1385
1387
  setSearchQuery("");
1386
- setExpandedFolders(new Set(folders.map((f) => f.id)));
1388
+ setSelectedId(null);
1389
+ setExpandedFolders(new Set(foldersRef.current.map((f) => f.id)));
1387
1390
  }
1388
1391
  }
1389
1392
  prevOpenRef.current = open;
1390
- }, [open, refreshDrawings, folders]);
1393
+ }, [open, refreshDrawings]);
1391
1394
  (0, import_react5.useEffect)(() => {
1392
1395
  if (creatingFolder && newFolderInputRef.current) {
1393
1396
  newFolderInputRef.current.focus();
@@ -1417,6 +1420,7 @@ var DrawingsDialog = ({
1417
1420
  }, [position]);
1418
1421
  const handleSelect = (0, import_react5.useCallback)(async (drawing) => {
1419
1422
  setSwitchingId(drawing.id);
1423
+ setSelectedId(null);
1420
1424
  await switchDrawing(drawing.id);
1421
1425
  onDrawingSelect?.(drawing);
1422
1426
  setSwitchingId(null);
@@ -1429,9 +1433,9 @@ var DrawingsDialog = ({
1429
1433
  setEditingId(drawing.id);
1430
1434
  setEditName(drawing.name);
1431
1435
  }, []);
1432
- const handleSaveEdit = (0, import_react5.useCallback)(async () => {
1436
+ const handleSaveEdit = (0, import_react5.useCallback)(() => {
1433
1437
  if (editingId && editName.trim()) {
1434
- await renameDrawing(editingId, editName.trim());
1438
+ renameDrawing(editingId, editName.trim());
1435
1439
  setEditingId(null);
1436
1440
  setEditName("");
1437
1441
  }
@@ -1440,40 +1444,35 @@ var DrawingsDialog = ({
1440
1444
  setEditingId(null);
1441
1445
  setEditName("");
1442
1446
  }, []);
1443
- const handleDelete = (0, import_react5.useCallback)(async (id) => {
1444
- await removeDrawing(id);
1447
+ const handleDelete = (0, import_react5.useCallback)((id) => {
1448
+ removeDrawing(id);
1445
1449
  setConfirmDeleteId(null);
1446
1450
  }, [removeDrawing]);
1447
- const handleCreateFolder = (0, import_react5.useCallback)(async () => {
1451
+ const handleCreateFolder = (0, import_react5.useCallback)(() => {
1448
1452
  if (newFolderName.trim()) {
1449
- setBusyFolderId("__creating__");
1450
- const folder = await createFolder2(newFolderName.trim());
1451
- if (folder) {
1452
- setExpandedFolders((prev) => /* @__PURE__ */ new Set([...prev, folder.id]));
1453
- }
1454
- setBusyFolderId(null);
1453
+ createFolder2(newFolderName.trim()).then((folder) => {
1454
+ if (folder) {
1455
+ setExpandedFolders((prev) => /* @__PURE__ */ new Set([...prev, folder.id]));
1456
+ }
1457
+ });
1455
1458
  }
1456
1459
  setCreatingFolder(false);
1457
1460
  setNewFolderName("");
1458
1461
  }, [newFolderName, createFolder2]);
1459
- const handleSaveFolderEdit = (0, import_react5.useCallback)(async () => {
1462
+ const handleSaveFolderEdit = (0, import_react5.useCallback)(() => {
1460
1463
  if (editingFolderId && editFolderName.trim()) {
1461
- setBusyFolderId(editingFolderId);
1462
- await renameFolder2(editingFolderId, editFolderName.trim());
1463
- setBusyFolderId(null);
1464
+ renameFolder2(editingFolderId, editFolderName.trim());
1464
1465
  }
1465
1466
  setEditingFolderId(null);
1466
1467
  setEditFolderName("");
1467
1468
  }, [editingFolderId, editFolderName, renameFolder2]);
1468
- const handleDeleteFolder = (0, import_react5.useCallback)(async (id) => {
1469
- setBusyFolderId(id);
1470
- await deleteFolder2(id);
1471
- setBusyFolderId(null);
1469
+ const handleDeleteFolder = (0, import_react5.useCallback)((id) => {
1470
+ deleteFolder2(id);
1472
1471
  setConfirmDeleteFolderId(null);
1473
1472
  }, [deleteFolder2]);
1474
- const handleMoveToFolder = (0, import_react5.useCallback)(async (drawingId, folderId) => {
1475
- await moveDrawingToFolder2(drawingId, folderId);
1473
+ const handleMoveToFolder = (0, import_react5.useCallback)((drawingId, folderId) => {
1476
1474
  setMovingDrawingId(null);
1475
+ moveDrawingToFolder2(drawingId, folderId);
1477
1476
  }, [moveDrawingToFolder2]);
1478
1477
  const toggleFolder = (0, import_react5.useCallback)((folderId) => {
1479
1478
  setExpandedFolders((prev) => {
@@ -1558,6 +1557,10 @@ var DrawingsDialog = ({
1558
1557
  setDropTargetFolderId("__none__");
1559
1558
  setTimeout(() => setDropTargetFolderId(null), 0);
1560
1559
  },
1560
+ onClick: () => {
1561
+ if (editingId || confirmDeleteId || movingDrawingId) return;
1562
+ setSelectedId(drawing.id);
1563
+ },
1561
1564
  style: {
1562
1565
  padding: "10px 12px",
1563
1566
  display: "flex",
@@ -1565,9 +1568,10 @@ var DrawingsDialog = ({
1565
1568
  gap: "12px",
1566
1569
  borderRadius: "8px",
1567
1570
  marginBottom: "4px",
1568
- cursor: draggingDrawingId ? "grabbing" : "default",
1569
- backgroundColor: activeDrawing?.id === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.1))" : "transparent",
1570
- transition: "background-color 0.15s",
1571
+ cursor: draggingDrawingId ? "grabbing" : "pointer",
1572
+ backgroundColor: activeDrawing?.id === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.1))" : selectedId === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.06))" : "transparent",
1573
+ border: selectedId === drawing.id && activeDrawing?.id !== drawing.id ? "1px solid var(--color-primary, #6c63ff)" : "1px solid transparent",
1574
+ transition: "background-color 0.15s, border-color 0.15s",
1571
1575
  opacity: draggingDrawingId === drawing.id ? 0.4 : switchingId && switchingId !== drawing.id ? 0.5 : 1
1572
1576
  },
1573
1577
  children: [
@@ -1818,7 +1822,7 @@ var DrawingsDialog = ({
1818
1822
  },
1819
1823
  children: [
1820
1824
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "12px", width: "16px", textAlign: "center", flexShrink: 0 }, children: isExpanded ? "\u25BC" : "\u25B6" }),
1821
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px", flexShrink: 0 }, children: busyFolderId === folder.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { display: "inline-block", animation: "spin 1s linear infinite" }, children: "\u23F3" }) : "\u{1F4C1}" }),
1825
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "16px", flexShrink: 0 }, children: "\u{1F4C1}" }),
1822
1826
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, minWidth: 0 }, children: editingFolderId === folder.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", gap: "6px", alignItems: "center" }, onClick: (e) => e.stopPropagation(), children: [
1823
1827
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1824
1828
  "input",
@@ -2070,9 +2074,8 @@ var DrawingsDialog = ({
2070
2074
  "button",
2071
2075
  {
2072
2076
  onClick: handleCreateFolder,
2073
- disabled: busyFolderId === "__creating__",
2074
- style: { padding: "8px 16px", fontSize: "14px", backgroundColor: "var(--color-primary, #6c63ff)", color: "#fff", border: "none", borderRadius: "8px", cursor: "pointer", opacity: busyFolderId === "__creating__" ? 0.6 : 1 },
2075
- children: busyFolderId === "__creating__" ? "\u23F3" : t.save
2077
+ style: { padding: "8px 16px", fontSize: "14px", backgroundColor: "var(--color-primary, #6c63ff)", color: "#fff", border: "none", borderRadius: "8px", cursor: "pointer" },
2078
+ children: t.save
2076
2079
  }
2077
2080
  ),
2078
2081
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
package/dist/index.mjs CHANGED
@@ -1291,6 +1291,7 @@ var DrawingsDialog = ({
1291
1291
  const [editName, setEditName] = useState4("");
1292
1292
  const [confirmDeleteId, setConfirmDeleteId] = useState4(null);
1293
1293
  const [switchingId, setSwitchingId] = useState4(null);
1294
+ const [selectedId, setSelectedId] = useState4(null);
1294
1295
  const [expandedFolders, setExpandedFolders] = useState4(/* @__PURE__ */ new Set());
1295
1296
  const [creatingFolder, setCreatingFolder] = useState4(false);
1296
1297
  const [newFolderName, setNewFolderName] = useState4("");
@@ -1299,7 +1300,6 @@ var DrawingsDialog = ({
1299
1300
  const [confirmDeleteFolderId, setConfirmDeleteFolderId] = useState4(null);
1300
1301
  const [movingDrawingId, setMovingDrawingId] = useState4(null);
1301
1302
  const [searchQuery, setSearchQuery] = useState4("");
1302
- const [busyFolderId, setBusyFolderId] = useState4(null);
1303
1303
  const [isRefreshing, setIsRefreshing] = useState4(false);
1304
1304
  const [draggingDrawingId, setDraggingDrawingId] = useState4(null);
1305
1305
  const [dropTargetFolderId, setDropTargetFolderId] = useState4(null);
@@ -1308,6 +1308,8 @@ var DrawingsDialog = ({
1308
1308
  const dialogRef = useRef3(null);
1309
1309
  const newFolderInputRef = useRef3(null);
1310
1310
  const prevOpenRef = useRef3(false);
1311
+ const foldersRef = useRef3(folders);
1312
+ foldersRef.current = folders;
1311
1313
  useEffect3(() => {
1312
1314
  if (open) {
1313
1315
  setIsRefreshing(true);
@@ -1315,11 +1317,12 @@ var DrawingsDialog = ({
1315
1317
  if (!prevOpenRef.current) {
1316
1318
  setPosition(null);
1317
1319
  setSearchQuery("");
1318
- setExpandedFolders(new Set(folders.map((f) => f.id)));
1320
+ setSelectedId(null);
1321
+ setExpandedFolders(new Set(foldersRef.current.map((f) => f.id)));
1319
1322
  }
1320
1323
  }
1321
1324
  prevOpenRef.current = open;
1322
- }, [open, refreshDrawings, folders]);
1325
+ }, [open, refreshDrawings]);
1323
1326
  useEffect3(() => {
1324
1327
  if (creatingFolder && newFolderInputRef.current) {
1325
1328
  newFolderInputRef.current.focus();
@@ -1349,6 +1352,7 @@ var DrawingsDialog = ({
1349
1352
  }, [position]);
1350
1353
  const handleSelect = useCallback2(async (drawing) => {
1351
1354
  setSwitchingId(drawing.id);
1355
+ setSelectedId(null);
1352
1356
  await switchDrawing(drawing.id);
1353
1357
  onDrawingSelect?.(drawing);
1354
1358
  setSwitchingId(null);
@@ -1361,9 +1365,9 @@ var DrawingsDialog = ({
1361
1365
  setEditingId(drawing.id);
1362
1366
  setEditName(drawing.name);
1363
1367
  }, []);
1364
- const handleSaveEdit = useCallback2(async () => {
1368
+ const handleSaveEdit = useCallback2(() => {
1365
1369
  if (editingId && editName.trim()) {
1366
- await renameDrawing(editingId, editName.trim());
1370
+ renameDrawing(editingId, editName.trim());
1367
1371
  setEditingId(null);
1368
1372
  setEditName("");
1369
1373
  }
@@ -1372,40 +1376,35 @@ var DrawingsDialog = ({
1372
1376
  setEditingId(null);
1373
1377
  setEditName("");
1374
1378
  }, []);
1375
- const handleDelete = useCallback2(async (id) => {
1376
- await removeDrawing(id);
1379
+ const handleDelete = useCallback2((id) => {
1380
+ removeDrawing(id);
1377
1381
  setConfirmDeleteId(null);
1378
1382
  }, [removeDrawing]);
1379
- const handleCreateFolder = useCallback2(async () => {
1383
+ const handleCreateFolder = useCallback2(() => {
1380
1384
  if (newFolderName.trim()) {
1381
- setBusyFolderId("__creating__");
1382
- const folder = await createFolder2(newFolderName.trim());
1383
- if (folder) {
1384
- setExpandedFolders((prev) => /* @__PURE__ */ new Set([...prev, folder.id]));
1385
- }
1386
- setBusyFolderId(null);
1385
+ createFolder2(newFolderName.trim()).then((folder) => {
1386
+ if (folder) {
1387
+ setExpandedFolders((prev) => /* @__PURE__ */ new Set([...prev, folder.id]));
1388
+ }
1389
+ });
1387
1390
  }
1388
1391
  setCreatingFolder(false);
1389
1392
  setNewFolderName("");
1390
1393
  }, [newFolderName, createFolder2]);
1391
- const handleSaveFolderEdit = useCallback2(async () => {
1394
+ const handleSaveFolderEdit = useCallback2(() => {
1392
1395
  if (editingFolderId && editFolderName.trim()) {
1393
- setBusyFolderId(editingFolderId);
1394
- await renameFolder2(editingFolderId, editFolderName.trim());
1395
- setBusyFolderId(null);
1396
+ renameFolder2(editingFolderId, editFolderName.trim());
1396
1397
  }
1397
1398
  setEditingFolderId(null);
1398
1399
  setEditFolderName("");
1399
1400
  }, [editingFolderId, editFolderName, renameFolder2]);
1400
- const handleDeleteFolder = useCallback2(async (id) => {
1401
- setBusyFolderId(id);
1402
- await deleteFolder2(id);
1403
- setBusyFolderId(null);
1401
+ const handleDeleteFolder = useCallback2((id) => {
1402
+ deleteFolder2(id);
1404
1403
  setConfirmDeleteFolderId(null);
1405
1404
  }, [deleteFolder2]);
1406
- const handleMoveToFolder = useCallback2(async (drawingId, folderId) => {
1407
- await moveDrawingToFolder2(drawingId, folderId);
1405
+ const handleMoveToFolder = useCallback2((drawingId, folderId) => {
1408
1406
  setMovingDrawingId(null);
1407
+ moveDrawingToFolder2(drawingId, folderId);
1409
1408
  }, [moveDrawingToFolder2]);
1410
1409
  const toggleFolder = useCallback2((folderId) => {
1411
1410
  setExpandedFolders((prev) => {
@@ -1490,6 +1489,10 @@ var DrawingsDialog = ({
1490
1489
  setDropTargetFolderId("__none__");
1491
1490
  setTimeout(() => setDropTargetFolderId(null), 0);
1492
1491
  },
1492
+ onClick: () => {
1493
+ if (editingId || confirmDeleteId || movingDrawingId) return;
1494
+ setSelectedId(drawing.id);
1495
+ },
1493
1496
  style: {
1494
1497
  padding: "10px 12px",
1495
1498
  display: "flex",
@@ -1497,9 +1500,10 @@ var DrawingsDialog = ({
1497
1500
  gap: "12px",
1498
1501
  borderRadius: "8px",
1499
1502
  marginBottom: "4px",
1500
- cursor: draggingDrawingId ? "grabbing" : "default",
1501
- backgroundColor: activeDrawing?.id === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.1))" : "transparent",
1502
- transition: "background-color 0.15s",
1503
+ cursor: draggingDrawingId ? "grabbing" : "pointer",
1504
+ backgroundColor: activeDrawing?.id === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.1))" : selectedId === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.06))" : "transparent",
1505
+ border: selectedId === drawing.id && activeDrawing?.id !== drawing.id ? "1px solid var(--color-primary, #6c63ff)" : "1px solid transparent",
1506
+ transition: "background-color 0.15s, border-color 0.15s",
1503
1507
  opacity: draggingDrawingId === drawing.id ? 0.4 : switchingId && switchingId !== drawing.id ? 0.5 : 1
1504
1508
  },
1505
1509
  children: [
@@ -1750,7 +1754,7 @@ var DrawingsDialog = ({
1750
1754
  },
1751
1755
  children: [
1752
1756
  /* @__PURE__ */ jsx6("span", { style: { fontSize: "12px", width: "16px", textAlign: "center", flexShrink: 0 }, children: isExpanded ? "\u25BC" : "\u25B6" }),
1753
- /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px", flexShrink: 0 }, children: busyFolderId === folder.id ? /* @__PURE__ */ jsx6("span", { style: { display: "inline-block", animation: "spin 1s linear infinite" }, children: "\u23F3" }) : "\u{1F4C1}" }),
1757
+ /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px", flexShrink: 0 }, children: "\u{1F4C1}" }),
1754
1758
  /* @__PURE__ */ jsx6("div", { style: { flex: 1, minWidth: 0 }, children: editingFolderId === folder.id ? /* @__PURE__ */ jsxs4("div", { style: { display: "flex", gap: "6px", alignItems: "center" }, onClick: (e) => e.stopPropagation(), children: [
1755
1759
  /* @__PURE__ */ jsx6(
1756
1760
  "input",
@@ -2002,9 +2006,8 @@ var DrawingsDialog = ({
2002
2006
  "button",
2003
2007
  {
2004
2008
  onClick: handleCreateFolder,
2005
- disabled: busyFolderId === "__creating__",
2006
- style: { padding: "8px 16px", fontSize: "14px", backgroundColor: "var(--color-primary, #6c63ff)", color: "#fff", border: "none", borderRadius: "8px", cursor: "pointer", opacity: busyFolderId === "__creating__" ? 0.6 : 1 },
2007
- children: busyFolderId === "__creating__" ? "\u23F3" : t.save
2009
+ style: { padding: "8px 16px", fontSize: "14px", backgroundColor: "var(--color-primary, #6c63ff)", color: "#fff", border: "none", borderRadius: "8px", cursor: "pointer" },
2010
+ children: t.save
2008
2011
  }
2009
2012
  ),
2010
2013
  /* @__PURE__ */ jsx6(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rita-workspace",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Multi-drawing workspace feature for Rita (Excalidraw fork)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",