rita-workspace 0.1.1 → 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/dist/index.d.mts +84 -2
- package/dist/index.d.ts +84 -2
- package/dist/index.js +534 -15
- package/dist/index.mjs +517 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -22,7 +32,9 @@ var index_exports = {};
|
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
DrawingList: () => DrawingList,
|
|
24
34
|
DrawingListItem: () => DrawingListItem,
|
|
35
|
+
DrawingsDialog: () => DrawingsDialog,
|
|
25
36
|
Sidebar: () => Sidebar,
|
|
37
|
+
WorkspaceMenuItems: () => WorkspaceMenuItems,
|
|
26
38
|
WorkspacePlugin: () => WorkspacePlugin,
|
|
27
39
|
WorkspaceProvider: () => WorkspaceProvider,
|
|
28
40
|
addDrawingToWorkspace: () => addDrawingToWorkspace,
|
|
@@ -529,16 +541,521 @@ function Sidebar({ isOpen = true, onToggle, width = 250 }) {
|
|
|
529
541
|
] });
|
|
530
542
|
}
|
|
531
543
|
|
|
544
|
+
// src/ui/Menu/WorkspaceMenuItems.tsx
|
|
545
|
+
var import_react4 = __toESM(require("react"));
|
|
546
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
547
|
+
var DrawingsIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "14", y: "3", width: "7", height: "7", rx: "1" }),
|
|
550
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" }),
|
|
551
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "14", y: "14", width: "7", height: "7", rx: "1" })
|
|
552
|
+
] });
|
|
553
|
+
var PlusIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
554
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
555
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
556
|
+
] });
|
|
557
|
+
var DefaultMenuItem = ({ icon, children, onSelect, shortcut }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
558
|
+
"button",
|
|
559
|
+
{
|
|
560
|
+
onClick: onSelect,
|
|
561
|
+
className: "rita-workspace-menu-item",
|
|
562
|
+
style: {
|
|
563
|
+
display: "flex",
|
|
564
|
+
alignItems: "center",
|
|
565
|
+
gap: "8px",
|
|
566
|
+
width: "100%",
|
|
567
|
+
padding: "8px 12px",
|
|
568
|
+
border: "none",
|
|
569
|
+
background: "none",
|
|
570
|
+
cursor: "pointer",
|
|
571
|
+
textAlign: "left",
|
|
572
|
+
fontSize: "14px"
|
|
573
|
+
},
|
|
574
|
+
children: [
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { width: "20px", height: "20px" }, children: icon }),
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { flex: 1 }, children }),
|
|
577
|
+
shortcut && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { opacity: 0.5, fontSize: "12px" }, children: shortcut })
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
var WorkspaceMenuItems = ({
|
|
582
|
+
onDrawingSelect,
|
|
583
|
+
onManageDrawings,
|
|
584
|
+
renderMenuItem,
|
|
585
|
+
renderSubMenu,
|
|
586
|
+
renderSeparator
|
|
587
|
+
}) => {
|
|
588
|
+
const { drawings, activeDrawing, switchDrawing, createNewDrawing } = useWorkspace();
|
|
589
|
+
const MenuItem = renderMenuItem || ((props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DefaultMenuItem, { ...props }));
|
|
590
|
+
const Separator = renderSeparator || (() => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("hr", { style: { margin: "4px 0", border: "none", borderTop: "1px solid #ccc" } }));
|
|
591
|
+
const handleDrawingSelect = async (drawing) => {
|
|
592
|
+
await switchDrawing(drawing.id);
|
|
593
|
+
onDrawingSelect?.(drawing);
|
|
594
|
+
};
|
|
595
|
+
const handleNewDrawing = async () => {
|
|
596
|
+
await createNewDrawing();
|
|
597
|
+
};
|
|
598
|
+
if (renderSubMenu) {
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: renderSubMenu({
|
|
600
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
601
|
+
DrawingsIcon,
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
603
|
+
"Ritningar (",
|
|
604
|
+
drawings.length,
|
|
605
|
+
")"
|
|
606
|
+
] })
|
|
607
|
+
] }),
|
|
608
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
609
|
+
drawings.map((drawing) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.default.Fragment, { children: MenuItem({
|
|
610
|
+
icon: activeDrawing?.id === drawing.id ? "\u2713" : " ",
|
|
611
|
+
children: drawing.name,
|
|
612
|
+
onSelect: () => handleDrawingSelect(drawing)
|
|
613
|
+
}) }, drawing.id)),
|
|
614
|
+
drawings.length > 0 && Separator(),
|
|
615
|
+
MenuItem({
|
|
616
|
+
icon: PlusIcon,
|
|
617
|
+
children: "Ny ritning",
|
|
618
|
+
onSelect: handleNewDrawing,
|
|
619
|
+
shortcut: "Ctrl+Alt+N"
|
|
620
|
+
}),
|
|
621
|
+
onManageDrawings && MenuItem({
|
|
622
|
+
icon: DrawingsIcon,
|
|
623
|
+
children: "Hantera ritningar...",
|
|
624
|
+
onSelect: onManageDrawings
|
|
625
|
+
})
|
|
626
|
+
] })
|
|
627
|
+
}) });
|
|
628
|
+
}
|
|
629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
630
|
+
MenuItem({
|
|
631
|
+
icon: PlusIcon,
|
|
632
|
+
children: "Ny ritning",
|
|
633
|
+
onSelect: handleNewDrawing,
|
|
634
|
+
shortcut: "Ctrl+Alt+N"
|
|
635
|
+
}),
|
|
636
|
+
drawings.slice(0, 5).map((drawing) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react4.default.Fragment, { children: MenuItem({
|
|
637
|
+
icon: activeDrawing?.id === drawing.id ? "\u2713" : DrawingsIcon,
|
|
638
|
+
children: drawing.name,
|
|
639
|
+
onSelect: () => handleDrawingSelect(drawing)
|
|
640
|
+
}) }, drawing.id)),
|
|
641
|
+
onManageDrawings && drawings.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
642
|
+
Separator(),
|
|
643
|
+
MenuItem({
|
|
644
|
+
icon: DrawingsIcon,
|
|
645
|
+
children: `Alla ritningar (${drawings.length})...`,
|
|
646
|
+
onSelect: onManageDrawings
|
|
647
|
+
})
|
|
648
|
+
] })
|
|
649
|
+
] });
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
// src/ui/Dialog/DrawingsDialog.tsx
|
|
653
|
+
var import_react5 = require("react");
|
|
654
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
655
|
+
var DrawingsDialog = ({
|
|
656
|
+
open,
|
|
657
|
+
onClose,
|
|
658
|
+
onDrawingSelect
|
|
659
|
+
}) => {
|
|
660
|
+
const {
|
|
661
|
+
drawings,
|
|
662
|
+
activeDrawing,
|
|
663
|
+
switchDrawing,
|
|
664
|
+
createNewDrawing,
|
|
665
|
+
renameDrawing,
|
|
666
|
+
removeDrawing
|
|
667
|
+
} = useWorkspace();
|
|
668
|
+
const [editingId, setEditingId] = (0, import_react5.useState)(null);
|
|
669
|
+
const [editName, setEditName] = (0, import_react5.useState)("");
|
|
670
|
+
const [confirmDeleteId, setConfirmDeleteId] = (0, import_react5.useState)(null);
|
|
671
|
+
const handleSelect = (0, import_react5.useCallback)(async (drawing) => {
|
|
672
|
+
await switchDrawing(drawing.id);
|
|
673
|
+
onDrawingSelect?.(drawing);
|
|
674
|
+
onClose();
|
|
675
|
+
}, [switchDrawing, onDrawingSelect, onClose]);
|
|
676
|
+
const handleCreate = (0, import_react5.useCallback)(async () => {
|
|
677
|
+
const newDrawing = await createNewDrawing();
|
|
678
|
+
if (newDrawing) {
|
|
679
|
+
onDrawingSelect?.(newDrawing);
|
|
680
|
+
onClose();
|
|
681
|
+
}
|
|
682
|
+
}, [createNewDrawing, onDrawingSelect, onClose]);
|
|
683
|
+
const handleStartEdit = (0, import_react5.useCallback)((drawing) => {
|
|
684
|
+
setEditingId(drawing.id);
|
|
685
|
+
setEditName(drawing.name);
|
|
686
|
+
}, []);
|
|
687
|
+
const handleSaveEdit = (0, import_react5.useCallback)(async () => {
|
|
688
|
+
if (editingId && editName.trim()) {
|
|
689
|
+
await renameDrawing(editingId, editName.trim());
|
|
690
|
+
setEditingId(null);
|
|
691
|
+
setEditName("");
|
|
692
|
+
}
|
|
693
|
+
}, [editingId, editName, renameDrawing]);
|
|
694
|
+
const handleCancelEdit = (0, import_react5.useCallback)(() => {
|
|
695
|
+
setEditingId(null);
|
|
696
|
+
setEditName("");
|
|
697
|
+
}, []);
|
|
698
|
+
const handleDelete = (0, import_react5.useCallback)(async (id) => {
|
|
699
|
+
await removeDrawing(id);
|
|
700
|
+
setConfirmDeleteId(null);
|
|
701
|
+
}, [removeDrawing]);
|
|
702
|
+
const formatDate = (timestamp) => {
|
|
703
|
+
return new Date(timestamp).toLocaleString("sv-SE", {
|
|
704
|
+
year: "numeric",
|
|
705
|
+
month: "short",
|
|
706
|
+
day: "numeric",
|
|
707
|
+
hour: "2-digit",
|
|
708
|
+
minute: "2-digit"
|
|
709
|
+
});
|
|
710
|
+
};
|
|
711
|
+
if (!open) return null;
|
|
712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
713
|
+
"div",
|
|
714
|
+
{
|
|
715
|
+
className: "rita-workspace-dialog-overlay",
|
|
716
|
+
style: {
|
|
717
|
+
position: "fixed",
|
|
718
|
+
top: 0,
|
|
719
|
+
left: 0,
|
|
720
|
+
right: 0,
|
|
721
|
+
bottom: 0,
|
|
722
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
723
|
+
display: "flex",
|
|
724
|
+
alignItems: "center",
|
|
725
|
+
justifyContent: "center",
|
|
726
|
+
zIndex: 9999
|
|
727
|
+
},
|
|
728
|
+
onClick: (e) => {
|
|
729
|
+
if (e.target === e.currentTarget) onClose();
|
|
730
|
+
},
|
|
731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
732
|
+
"div",
|
|
733
|
+
{
|
|
734
|
+
className: "rita-workspace-dialog",
|
|
735
|
+
style: {
|
|
736
|
+
backgroundColor: "var(--island-bg-color, #fff)",
|
|
737
|
+
borderRadius: "8px",
|
|
738
|
+
boxShadow: "0 4px 24px rgba(0, 0, 0, 0.2)",
|
|
739
|
+
width: "90%",
|
|
740
|
+
maxWidth: "600px",
|
|
741
|
+
maxHeight: "80vh",
|
|
742
|
+
display: "flex",
|
|
743
|
+
flexDirection: "column",
|
|
744
|
+
color: "var(--text-primary-color, #1b1b1f)"
|
|
745
|
+
},
|
|
746
|
+
children: [
|
|
747
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
748
|
+
"div",
|
|
749
|
+
{
|
|
750
|
+
style: {
|
|
751
|
+
padding: "16px 20px",
|
|
752
|
+
borderBottom: "1px solid var(--default-border-color, #e0e0e0)",
|
|
753
|
+
display: "flex",
|
|
754
|
+
alignItems: "center",
|
|
755
|
+
justifyContent: "space-between"
|
|
756
|
+
},
|
|
757
|
+
children: [
|
|
758
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("h2", { style: { margin: 0, fontSize: "18px", fontWeight: 600 }, children: [
|
|
759
|
+
"Ritningar (",
|
|
760
|
+
drawings.length,
|
|
761
|
+
")"
|
|
762
|
+
] }),
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
764
|
+
"button",
|
|
765
|
+
{
|
|
766
|
+
onClick: onClose,
|
|
767
|
+
style: {
|
|
768
|
+
background: "none",
|
|
769
|
+
border: "none",
|
|
770
|
+
fontSize: "24px",
|
|
771
|
+
cursor: "pointer",
|
|
772
|
+
padding: "4px",
|
|
773
|
+
lineHeight: 1,
|
|
774
|
+
color: "inherit"
|
|
775
|
+
},
|
|
776
|
+
"aria-label": "St\xE4ng",
|
|
777
|
+
children: "\xD7"
|
|
778
|
+
}
|
|
779
|
+
)
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
784
|
+
"div",
|
|
785
|
+
{
|
|
786
|
+
style: {
|
|
787
|
+
flex: 1,
|
|
788
|
+
overflow: "auto",
|
|
789
|
+
padding: "8px 0"
|
|
790
|
+
},
|
|
791
|
+
children: drawings.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
792
|
+
"div",
|
|
793
|
+
{
|
|
794
|
+
style: {
|
|
795
|
+
padding: "40px 20px",
|
|
796
|
+
textAlign: "center",
|
|
797
|
+
color: "var(--text-secondary-color, #666)"
|
|
798
|
+
},
|
|
799
|
+
children: [
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "Inga ritningar \xE4nnu." }),
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: 'Klicka "Ny ritning" f\xF6r att b\xF6rja.' })
|
|
802
|
+
]
|
|
803
|
+
}
|
|
804
|
+
) : drawings.map((drawing) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
805
|
+
"div",
|
|
806
|
+
{
|
|
807
|
+
className: "rita-workspace-dialog-item",
|
|
808
|
+
style: {
|
|
809
|
+
padding: "12px 20px",
|
|
810
|
+
display: "flex",
|
|
811
|
+
alignItems: "center",
|
|
812
|
+
gap: "12px",
|
|
813
|
+
borderBottom: "1px solid var(--default-border-color, #f0f0f0)",
|
|
814
|
+
backgroundColor: activeDrawing?.id === drawing.id ? "var(--color-primary-light, rgba(108, 99, 255, 0.1))" : "transparent"
|
|
815
|
+
},
|
|
816
|
+
children: [
|
|
817
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, minWidth: 0 }, children: editingId === drawing.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
818
|
+
"input",
|
|
819
|
+
{
|
|
820
|
+
type: "text",
|
|
821
|
+
value: editName,
|
|
822
|
+
onChange: (e) => setEditName(e.target.value),
|
|
823
|
+
onKeyDown: (e) => {
|
|
824
|
+
if (e.key === "Enter") handleSaveEdit();
|
|
825
|
+
if (e.key === "Escape") handleCancelEdit();
|
|
826
|
+
},
|
|
827
|
+
autoFocus: true,
|
|
828
|
+
style: {
|
|
829
|
+
width: "100%",
|
|
830
|
+
padding: "4px 8px",
|
|
831
|
+
fontSize: "14px",
|
|
832
|
+
border: "1px solid var(--color-primary, #6c63ff)",
|
|
833
|
+
borderRadius: "4px",
|
|
834
|
+
outline: "none"
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
838
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
839
|
+
"div",
|
|
840
|
+
{
|
|
841
|
+
style: {
|
|
842
|
+
fontWeight: activeDrawing?.id === drawing.id ? 600 : 400,
|
|
843
|
+
fontSize: "14px",
|
|
844
|
+
overflow: "hidden",
|
|
845
|
+
textOverflow: "ellipsis",
|
|
846
|
+
whiteSpace: "nowrap"
|
|
847
|
+
},
|
|
848
|
+
children: [
|
|
849
|
+
activeDrawing?.id === drawing.id && "\u2713 ",
|
|
850
|
+
drawing.name
|
|
851
|
+
]
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
855
|
+
"div",
|
|
856
|
+
{
|
|
857
|
+
style: {
|
|
858
|
+
fontSize: "12px",
|
|
859
|
+
color: "var(--text-secondary-color, #888)",
|
|
860
|
+
marginTop: "2px"
|
|
861
|
+
},
|
|
862
|
+
children: [
|
|
863
|
+
"\xC4ndrad: ",
|
|
864
|
+
formatDate(drawing.updatedAt)
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
)
|
|
868
|
+
] }) }),
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { display: "flex", gap: "4px" }, children: editingId === drawing.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
870
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
871
|
+
"button",
|
|
872
|
+
{
|
|
873
|
+
onClick: handleSaveEdit,
|
|
874
|
+
style: {
|
|
875
|
+
padding: "6px 12px",
|
|
876
|
+
fontSize: "12px",
|
|
877
|
+
backgroundColor: "var(--color-primary, #6c63ff)",
|
|
878
|
+
color: "#fff",
|
|
879
|
+
border: "none",
|
|
880
|
+
borderRadius: "4px",
|
|
881
|
+
cursor: "pointer"
|
|
882
|
+
},
|
|
883
|
+
children: "Spara"
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
887
|
+
"button",
|
|
888
|
+
{
|
|
889
|
+
onClick: handleCancelEdit,
|
|
890
|
+
style: {
|
|
891
|
+
padding: "6px 12px",
|
|
892
|
+
fontSize: "12px",
|
|
893
|
+
backgroundColor: "transparent",
|
|
894
|
+
border: "1px solid var(--default-border-color, #ccc)",
|
|
895
|
+
borderRadius: "4px",
|
|
896
|
+
cursor: "pointer",
|
|
897
|
+
color: "inherit"
|
|
898
|
+
},
|
|
899
|
+
children: "Avbryt"
|
|
900
|
+
}
|
|
901
|
+
)
|
|
902
|
+
] }) : confirmDeleteId === drawing.id ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
903
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
904
|
+
"button",
|
|
905
|
+
{
|
|
906
|
+
onClick: () => handleDelete(drawing.id),
|
|
907
|
+
style: {
|
|
908
|
+
padding: "6px 12px",
|
|
909
|
+
fontSize: "12px",
|
|
910
|
+
backgroundColor: "#dc3545",
|
|
911
|
+
color: "#fff",
|
|
912
|
+
border: "none",
|
|
913
|
+
borderRadius: "4px",
|
|
914
|
+
cursor: "pointer"
|
|
915
|
+
},
|
|
916
|
+
children: "Ta bort"
|
|
917
|
+
}
|
|
918
|
+
),
|
|
919
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
920
|
+
"button",
|
|
921
|
+
{
|
|
922
|
+
onClick: () => setConfirmDeleteId(null),
|
|
923
|
+
style: {
|
|
924
|
+
padding: "6px 12px",
|
|
925
|
+
fontSize: "12px",
|
|
926
|
+
backgroundColor: "transparent",
|
|
927
|
+
border: "1px solid var(--default-border-color, #ccc)",
|
|
928
|
+
borderRadius: "4px",
|
|
929
|
+
cursor: "pointer",
|
|
930
|
+
color: "inherit"
|
|
931
|
+
},
|
|
932
|
+
children: "Avbryt"
|
|
933
|
+
}
|
|
934
|
+
)
|
|
935
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
937
|
+
"button",
|
|
938
|
+
{
|
|
939
|
+
onClick: () => handleSelect(drawing),
|
|
940
|
+
style: {
|
|
941
|
+
padding: "6px 12px",
|
|
942
|
+
fontSize: "12px",
|
|
943
|
+
backgroundColor: "var(--color-primary, #6c63ff)",
|
|
944
|
+
color: "#fff",
|
|
945
|
+
border: "none",
|
|
946
|
+
borderRadius: "4px",
|
|
947
|
+
cursor: "pointer"
|
|
948
|
+
},
|
|
949
|
+
disabled: activeDrawing?.id === drawing.id,
|
|
950
|
+
children: "\xD6ppna"
|
|
951
|
+
}
|
|
952
|
+
),
|
|
953
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
954
|
+
"button",
|
|
955
|
+
{
|
|
956
|
+
onClick: () => handleStartEdit(drawing),
|
|
957
|
+
style: {
|
|
958
|
+
padding: "6px 12px",
|
|
959
|
+
fontSize: "12px",
|
|
960
|
+
backgroundColor: "transparent",
|
|
961
|
+
border: "1px solid var(--default-border-color, #ccc)",
|
|
962
|
+
borderRadius: "4px",
|
|
963
|
+
cursor: "pointer",
|
|
964
|
+
color: "inherit"
|
|
965
|
+
},
|
|
966
|
+
title: "Byt namn",
|
|
967
|
+
children: "\u270F\uFE0F"
|
|
968
|
+
}
|
|
969
|
+
),
|
|
970
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
971
|
+
"button",
|
|
972
|
+
{
|
|
973
|
+
onClick: () => setConfirmDeleteId(drawing.id),
|
|
974
|
+
style: {
|
|
975
|
+
padding: "6px 12px",
|
|
976
|
+
fontSize: "12px",
|
|
977
|
+
backgroundColor: "transparent",
|
|
978
|
+
border: "1px solid var(--default-border-color, #ccc)",
|
|
979
|
+
borderRadius: "4px",
|
|
980
|
+
cursor: "pointer",
|
|
981
|
+
color: "inherit"
|
|
982
|
+
},
|
|
983
|
+
title: "Ta bort",
|
|
984
|
+
disabled: drawings.length <= 1,
|
|
985
|
+
children: "\u{1F5D1}\uFE0F"
|
|
986
|
+
}
|
|
987
|
+
)
|
|
988
|
+
] }) })
|
|
989
|
+
]
|
|
990
|
+
},
|
|
991
|
+
drawing.id
|
|
992
|
+
))
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
996
|
+
"div",
|
|
997
|
+
{
|
|
998
|
+
style: {
|
|
999
|
+
padding: "16px 20px",
|
|
1000
|
+
borderTop: "1px solid var(--default-border-color, #e0e0e0)",
|
|
1001
|
+
display: "flex",
|
|
1002
|
+
justifyContent: "space-between",
|
|
1003
|
+
alignItems: "center"
|
|
1004
|
+
},
|
|
1005
|
+
children: [
|
|
1006
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
onClick: handleCreate,
|
|
1010
|
+
style: {
|
|
1011
|
+
padding: "10px 20px",
|
|
1012
|
+
fontSize: "14px",
|
|
1013
|
+
backgroundColor: "var(--color-primary, #6c63ff)",
|
|
1014
|
+
color: "#fff",
|
|
1015
|
+
border: "none",
|
|
1016
|
+
borderRadius: "6px",
|
|
1017
|
+
cursor: "pointer",
|
|
1018
|
+
fontWeight: 500
|
|
1019
|
+
},
|
|
1020
|
+
children: "+ Ny ritning"
|
|
1021
|
+
}
|
|
1022
|
+
),
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1024
|
+
"button",
|
|
1025
|
+
{
|
|
1026
|
+
onClick: onClose,
|
|
1027
|
+
style: {
|
|
1028
|
+
padding: "10px 20px",
|
|
1029
|
+
fontSize: "14px",
|
|
1030
|
+
backgroundColor: "transparent",
|
|
1031
|
+
border: "1px solid var(--default-border-color, #ccc)",
|
|
1032
|
+
borderRadius: "6px",
|
|
1033
|
+
cursor: "pointer",
|
|
1034
|
+
color: "inherit"
|
|
1035
|
+
},
|
|
1036
|
+
children: "St\xE4ng"
|
|
1037
|
+
}
|
|
1038
|
+
)
|
|
1039
|
+
]
|
|
1040
|
+
}
|
|
1041
|
+
)
|
|
1042
|
+
]
|
|
1043
|
+
}
|
|
1044
|
+
)
|
|
1045
|
+
}
|
|
1046
|
+
);
|
|
1047
|
+
};
|
|
1048
|
+
|
|
532
1049
|
// src/integration/useExcalidrawBridge.ts
|
|
533
|
-
var
|
|
1050
|
+
var import_react6 = require("react");
|
|
534
1051
|
function useExcalidrawBridge({
|
|
535
1052
|
excalidrawAPI,
|
|
536
1053
|
autoSaveInterval = 2e3
|
|
537
1054
|
}) {
|
|
538
1055
|
const { activeDrawing, saveCurrentDrawing } = useWorkspace();
|
|
539
|
-
const saveTimeoutRef = (0,
|
|
540
|
-
const lastDrawingIdRef = (0,
|
|
541
|
-
(0,
|
|
1056
|
+
const saveTimeoutRef = (0, import_react6.useRef)(null);
|
|
1057
|
+
const lastDrawingIdRef = (0, import_react6.useRef)(null);
|
|
1058
|
+
(0, import_react6.useEffect)(() => {
|
|
542
1059
|
if (!excalidrawAPI || !activeDrawing) return;
|
|
543
1060
|
if (lastDrawingIdRef.current === activeDrawing.id) return;
|
|
544
1061
|
lastDrawingIdRef.current = activeDrawing.id;
|
|
@@ -547,7 +1064,7 @@ function useExcalidrawBridge({
|
|
|
547
1064
|
appState: activeDrawing.appState
|
|
548
1065
|
});
|
|
549
1066
|
}, [excalidrawAPI, activeDrawing]);
|
|
550
|
-
const scheduleSave = (0,
|
|
1067
|
+
const scheduleSave = (0, import_react6.useCallback)(() => {
|
|
551
1068
|
if (!excalidrawAPI) return;
|
|
552
1069
|
if (saveTimeoutRef.current) {
|
|
553
1070
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -558,7 +1075,7 @@ function useExcalidrawBridge({
|
|
|
558
1075
|
await saveCurrentDrawing(elements, appState);
|
|
559
1076
|
}, autoSaveInterval);
|
|
560
1077
|
}, [excalidrawAPI, saveCurrentDrawing, autoSaveInterval]);
|
|
561
|
-
(0,
|
|
1078
|
+
(0, import_react6.useEffect)(() => {
|
|
562
1079
|
return () => {
|
|
563
1080
|
if (saveTimeoutRef.current) {
|
|
564
1081
|
clearTimeout(saveTimeoutRef.current);
|
|
@@ -571,16 +1088,16 @@ function useExcalidrawBridge({
|
|
|
571
1088
|
}
|
|
572
1089
|
|
|
573
1090
|
// src/WorkspacePlugin.tsx
|
|
574
|
-
var
|
|
575
|
-
var
|
|
1091
|
+
var import_react7 = require("react");
|
|
1092
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
576
1093
|
function WorkspacePluginInner({
|
|
577
1094
|
children,
|
|
578
1095
|
defaultSidebarOpen = true,
|
|
579
1096
|
sidebarWidth = 250
|
|
580
1097
|
}) {
|
|
581
|
-
const [sidebarOpen, setSidebarOpen] = (0,
|
|
1098
|
+
const [sidebarOpen, setSidebarOpen] = (0, import_react7.useState)(defaultSidebarOpen);
|
|
582
1099
|
const { activeDrawing } = useWorkspace();
|
|
583
|
-
(0,
|
|
1100
|
+
(0, import_react7.useEffect)(() => {
|
|
584
1101
|
const handleKeyDown = (e) => {
|
|
585
1102
|
if (e.ctrlKey && e.key === "b") {
|
|
586
1103
|
e.preventDefault();
|
|
@@ -593,10 +1110,10 @@ function WorkspacePluginInner({
|
|
|
593
1110
|
window.addEventListener("keydown", handleKeyDown);
|
|
594
1111
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
595
1112
|
}, []);
|
|
596
|
-
const handleToggleSidebar = (0,
|
|
1113
|
+
const handleToggleSidebar = (0, import_react7.useCallback)(() => {
|
|
597
1114
|
setSidebarOpen((prev) => !prev);
|
|
598
1115
|
}, []);
|
|
599
|
-
return /* @__PURE__ */ (0,
|
|
1116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
600
1117
|
"div",
|
|
601
1118
|
{
|
|
602
1119
|
style: {
|
|
@@ -605,7 +1122,7 @@ function WorkspacePluginInner({
|
|
|
605
1122
|
width: "100%"
|
|
606
1123
|
},
|
|
607
1124
|
children: [
|
|
608
|
-
/* @__PURE__ */ (0,
|
|
1125
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
609
1126
|
Sidebar,
|
|
610
1127
|
{
|
|
611
1128
|
isOpen: sidebarOpen,
|
|
@@ -613,7 +1130,7 @@ function WorkspacePluginInner({
|
|
|
613
1130
|
width: sidebarWidth
|
|
614
1131
|
}
|
|
615
1132
|
),
|
|
616
|
-
/* @__PURE__ */ (0,
|
|
1133
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
617
1134
|
"main",
|
|
618
1135
|
{
|
|
619
1136
|
style: {
|
|
@@ -629,13 +1146,15 @@ function WorkspacePluginInner({
|
|
|
629
1146
|
);
|
|
630
1147
|
}
|
|
631
1148
|
function WorkspacePlugin(props) {
|
|
632
|
-
return /* @__PURE__ */ (0,
|
|
1149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WorkspaceProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(WorkspacePluginInner, { ...props }) });
|
|
633
1150
|
}
|
|
634
1151
|
// Annotate the CommonJS export names for ESM import in node:
|
|
635
1152
|
0 && (module.exports = {
|
|
636
1153
|
DrawingList,
|
|
637
1154
|
DrawingListItem,
|
|
1155
|
+
DrawingsDialog,
|
|
638
1156
|
Sidebar,
|
|
1157
|
+
WorkspaceMenuItems,
|
|
639
1158
|
WorkspacePlugin,
|
|
640
1159
|
WorkspaceProvider,
|
|
641
1160
|
addDrawingToWorkspace,
|