@visualli/react 0.1.2 → 0.1.4
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.cjs +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/VisualliCanvas.tsx +14 -14
- package/src/components/KonvaEdge.tsx +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visualli/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "React canvas renderer for .visualli files \u2014 built on @visualli/core",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,10 +30,12 @@
|
|
|
30
30
|
"react-dom": "^18.0.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@visualli/bindings": "*",
|
|
33
34
|
"@visualli/core": "*",
|
|
34
35
|
"zustand": "^4.5.2",
|
|
35
36
|
"konva": "^9.3.6",
|
|
36
|
-
"react-konva": "^18.2.10"
|
|
37
|
+
"react-konva": "^18.2.10",
|
|
38
|
+
"react-use-measure": "^1.1.2"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@types/react": "^18.3.0",
|
package/src/VisualliCanvas.tsx
CHANGED
|
@@ -212,20 +212,20 @@ export default function VisualliCanvas(props: VisualliCanvasProps) {
|
|
|
212
212
|
containers: getContainersForLayer(doc, currentLayerId) as ContainerGroup[],
|
|
213
213
|
};
|
|
214
214
|
} catch { return { flatNodes: [] as FlatNode[], connections: [] as MindMapConnection[], containers: [] as ContainerGroup[] }; }
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
215
|
+
}, [doc, currentLayerId]);
|
|
216
|
+
const viewport = useViewportStore(s => ({
|
|
217
|
+
centerX: s.centerX, centerY: s.centerY, zoomLevel: s.zoomLevel,
|
|
218
|
+
canvasWidth: s.canvasWidth, canvasHeight: s.canvasHeight,
|
|
219
|
+
}));
|
|
220
|
+
const setCenter = useViewportStore(s => s.setCenter);
|
|
221
|
+
const setZoom = useViewportStore(s => s.setZoom);
|
|
222
|
+
|
|
223
|
+
const nodes = useNodeStore(s => s.nodes);
|
|
224
|
+
const setNodes = useNodeStore(s => s.setNodes);
|
|
225
|
+
const updateNodePosition = useNodeStore(s => s.updateNodePosition);
|
|
226
|
+
|
|
227
|
+
const clearSel = useSelectionStore(s => s.clear);
|
|
228
|
+
const select = useSelectionStore(s => s.select);
|
|
229
229
|
|
|
230
230
|
// Sync nodes → store
|
|
231
231
|
useEffect(() => {
|
|
@@ -46,12 +46,14 @@ export interface KonvaEdgeProps {
|
|
|
46
46
|
|
|
47
47
|
const EDGE_SPACING = 25; // Increased spacing to ensure arrow head stays out of organic shapes
|
|
48
48
|
const STROKE_COLOR = '#000000';
|
|
49
|
+
const STROKE_COLOR_DARK = '#ffffff';
|
|
49
50
|
const STROKE_WIDTH = 2.5;
|
|
50
51
|
|
|
51
52
|
const KonvaEdge = memo(function KonvaEdge({
|
|
52
53
|
sourceNode: from,
|
|
53
54
|
targetNode: to,
|
|
54
55
|
connection,
|
|
56
|
+
isDark = false,
|
|
55
57
|
zoomLevel = 1.0,
|
|
56
58
|
}: KonvaEdgeProps) {
|
|
57
59
|
const label = (connection as { label?: string } | undefined)?.label;
|
|
@@ -194,11 +196,13 @@ const KonvaEdge = memo(function KonvaEdge({
|
|
|
194
196
|
}, [from.x, from.y, from.width, from.branchCount, to.x, to.y, to.width, to.branchCount, label, zoomLevel]);
|
|
195
197
|
|
|
196
198
|
// ── Render ────────────────────────────────────────────────────────────────
|
|
199
|
+
const strokeColor = isDark ? STROKE_COLOR_DARK : STROKE_COLOR;
|
|
200
|
+
|
|
197
201
|
return (
|
|
198
202
|
<Group>
|
|
199
203
|
<Line
|
|
200
204
|
points={points}
|
|
201
|
-
stroke={
|
|
205
|
+
stroke={strokeColor}
|
|
202
206
|
strokeWidth={STROKE_WIDTH}
|
|
203
207
|
tension={0}
|
|
204
208
|
opacity={0.9}
|
|
@@ -209,7 +213,7 @@ const KonvaEdge = memo(function KonvaEdge({
|
|
|
209
213
|
/>
|
|
210
214
|
<Line
|
|
211
215
|
points={arrowHeadPoints}
|
|
212
|
-
stroke={
|
|
216
|
+
stroke={strokeColor}
|
|
213
217
|
strokeWidth={STROKE_WIDTH}
|
|
214
218
|
lineCap="round"
|
|
215
219
|
lineJoin="round"
|