Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

feat(app): add nodeShape to node property

dextmorgn531bcf970e9a
diff --git a/flowsint-app/src/components/sketches/add-item-dialog.tsx b/flowsint-app/src/components/sketches/add-item-dialog.tsx
index 01096ac1..0330468e 100644
--- a/flowsint-app/src/components/sketches/add-item-dialog.tsx
+++ b/flowsint-app/src/components/sketches/add-item-dialog.tsx
@@ -95,6 +95,7 @@ export default function AddItemDialog() {
x: nodeX, // Position at viewport center
y: nodeY,
nodeSize: 4,
+ nodeShape: 'circle',
nodeColor: null,
nodeFlag: null,
nodeIcon: null,
diff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
index 2835633d..7fd21bb2 100644
--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx
@@ -14,7 +14,7 @@ import { useGraphStore } from '@/stores/graph-store'
import DOMPurify from 'dompurify'
import { useIcon } from '@/hooks/use-icon'
import { Switch } from '@/components/ui/switch'
-import type { GraphNode, NodeProperties, NodeMetadata } from '@/types'
+import type { GraphNode, NodeProperties, NodeMetadata, NodeShape } from '@/types'
import { sketchService } from '@/api/sketch-service'
import { toast } from 'sonner'
import { useMutation, useQueryClient } from '@tanstack/react-query'
@@ -23,6 +23,9 @@ import IconPicker from '@/components/shared/icon-picker'
import { ResizableDetailsPanel, Row } from './resizable-details-panels'
import Relationships from './relationships'
import NeighborsGraph from './neighbors'
+import { Circle, Square, Triangle, Hexagon } from 'lucide-react'
+import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
+import { Slider } from '@/components/ui/slider'
// Types
type FormData = {
nodeLabel: string
@@ -30,6 +33,8 @@ type FormData = {
nodeIcon: string | null
nodeImage: string | null
nodeFlag: string | null
+ nodeShape: string | null
+ nodeSize: number | null
nodeProperties: NodeProperties
nodeMetadata: NodeMetadata
notes: string
@@ -47,6 +52,12 @@ const COLORS = [
{ name: 'pink', value: '#ec4899' }
]
+const NODE_SHAPES = {
+ circle: Circle,
+ square: Square,
+ hexagon: Hexagon,
+ triangle: Triangle
+} satisfies Record<NodeShape, React.ComponentType<{ size?: number; className?: string }>>
// Extended Row Component with copy support
const RowWithCopy = memo(
({
@@ -128,10 +139,13 @@ const DetailsPanel = memo(() => {
nodeIcon: null,
nodeImage: null,
nodeFlag: null,
+ nodeShape: null,
+ nodeSize: 0,
nodeProperties: {},
nodeMetadata: {},
notes: ''
})
+ const [nodeSize, setNodeSize] = useState<number>(0)
const IconComponent = useIcon(node?.nodeType as string, {
nodeColor: node?.nodeColor,
@@ -139,11 +153,24 @@ const DetailsPanel = memo(() => {
nodeImage: node?.nodeImage
})
+ useEffect(() => {
+ nodeSize !== node?.nodeSize && setHasChanges(true)
+ }, [nodeSize])
+
// Sync form data when node changes
useEffect(() => {
if (node) {
- const { nodeLabel, nodeImage, nodeIcon, nodeFlag, nodeColor, nodeMetadata, nodeProperties } =
- node
+ const {
+ nodeLabel,
+ nodeImage,
+ nodeIcon,
+ nodeFlag,
+ nodeColor,
+ nodeShape,
+ nodeMetadata,
+ nodeProperties,
+ nodeSize
+ } = node
setFormData({
nodeLabel: nodeLabel || '',
nodeProperties: nodeProperties || {},
@@ -152,8 +179,11 @@ const DetailsPanel = memo(() => {
nodeIcon,
nodeImage,
nodeFlag,
+ nodeShape,
+ nodeSize,
notes: (nodeMetadata?.notes as string) || ''
})
+ setNodeSize(node.nodeSize ?? 0)
setHasChanges(false)
}
}, [node])
@@ -174,7 +204,7 @@ const DetailsPanel = memo(() => {
onSuccess: (result) => {
if (result.status === 'node updated' && node) {
const { notes, ...rest } = formData
- const updates = { ...rest, nodeMetadata: { ...rest.nodeMetadata, notes } }
+ const updates = { ...rest, nodeMetadata: { ...rest.nodeMetadata, notes }, nodeSize }
updateNode(node.id, updates as Partial<GraphNode>)
if (sketchId) {
queryClient.invalidateQueries({ queryKey: queryKeys.sketches.detail(sketchId) })
@@ -408,6 +438,18 @@ const DetailsPanel = memo(() => {
minSize: 10,
content: (
<div className="p-3">
+ <Row label={`Size (${nodeSize})`}>
+ <div className="flex w-full items-center">
+ <Slider
+ value={[nodeSize]}
+ onValueChange={([value]) => setNodeSize(value)}
+ min={0}
+ max={100}
+ step={1}
+ className="flex-1 grow"
+ />
+ </div>
+ </Row>
<Row label="Color">
<div className="flex items-center gap-1">
{COLORS.map((color) => (
@@ -433,6 +475,29 @@ const DetailsPanel = memo(() => {
{formData.nodeIcon || 'Default'}
</button>
</Row>
+ <Row label="Shape">
+ <div className="flex items-center gap-1">
+ <ToggleGroup
+ onValueChange={(value) => handleChange('nodeShape', value || null)}
+ type="single"
+ size="sm"
+ defaultValue={node.nodeShape || 'circle'}
+ variant="outline"
+ className="shadow-none!"
+ >
+ {(
+ Object.entries(NODE_SHAPES) as [
+ NodeShape,
+ (typeof NODE_SHAPES)[NodeShape]
+ ][]
+ ).map(([shape, Icon]) => (
+ <ToggleGroupItem value={shape} aria-label={shape}>
+ <Icon size={14} />
+ </ToggleGroupItem>
+ ))}
+ </ToggleGroup>
+ </div>
+ </Row>
<Row label="Image">
<input
type="text"
@@ -505,6 +570,8 @@ const DetailsPanel = memo(() => {
nodeFlag,
nodeColor,
nodeMetadata,
+ nodeShape,
+ nodeSize,
nodeProperties
} = node
setFormData({
@@ -515,6 +582,8 @@ const DetailsPanel = memo(() => {
nodeIcon,
nodeImage,
nodeFlag,
+ nodeShape,
+ nodeSize,
notes: (nodeMetadata?.notes as string) || ''
})
setHasChanges(false)
diff --git a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
index 83878a51..3658a225 100644
--- a/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/neighbors.tsx
@@ -33,13 +33,14 @@ const NeighborsGraph = memo(
const nodes = useMemo(
() =>
neighborsData?.nds.map(
- ({ id, nodeType, nodeColor, nodeIcon, nodeLabel, nodeImage }: GraphNode) => ({
+ ({ id, nodeType, nodeColor, nodeIcon, nodeLabel, nodeImage, nodeShape }: GraphNode) => ({
id,
nodeType,
nodeColor,
nodeIcon,
nodeLabel,
- nodeImage
+ nodeImage,
+ nodeShape
})
),
[neighborsData?.nds]
diff --git a/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx b/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx
index e47f654f..798ce514 100644
--- a/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx
+++ b/flowsint-app/src/components/sketches/details-panel/resizable-details-panels.tsx
@@ -177,9 +177,11 @@ export function ResizableDetailsPanel({
// Row Component for displaying key-value pairs
export const Row = memo(({ label, children }: { label: string; children: React.ReactNode }) => (
- <div className="flex items-center justify-between py-1.5 group hover:bg-muted/20 -mx-2 px-2 rounded-sm transition-colors">
+ <div className="flex items-center justify-between gap-4 py-1.5 group hover:bg-muted/20 -mx-2 px-2 rounded-sm transition-colors">
<span className="text-[13px] text-muted-foreground">{label.replace(/_/g, ' ')}</span>
- <div className="text-[13px] text-foreground flex items-center gap-1">{children}</div>
+ <div className="text-[13px] grow text-foreground flex items-center justify-end gap-1">
+ {children}
+ </div>
</div>
))
Row.displayName = 'Row'
diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts b/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts
new file mode 100644
index 00000000..c2c3e112
--- /dev/null
+++ b/flowsint-app/src/components/sketches/graph/hooks/use-create-on-paste.ts
@@ -0,0 +1,97 @@
+import { usePasteListener } from '@/hooks/use-paste-listener'
+import { useGraphStore } from '@/stores/graph-store'
+import { type GraphNode, NodeProperties } from '@/types/graph'
+import { v4 as uuidv4 } from 'uuid'
+import { toast } from 'sonner'
+import { useCallback } from 'react'
+import { sketchService } from '@/api/sketch-service'
+
+export function useCreateOnPaste(sketchId: string) {
+ const addNode = useGraphStore((s) => s.addNode)
+ const replaceNode = useGraphStore((s) => s.replaceNode)
+
+ const onText = useCallback(
+ async (text: string) => {
+ try {
+ const nodeWithTempId: GraphNode = {
+ id: uuidv4(),
+ nodeType: 'phrase', // Required at root level for API validation
+ nodeLabel: text,
+ x: 100, // Position at viewport center
+ y: 100,
+ nodeSize: 4,
+ nodeColor: null,
+ nodeShape: 'circle',
+ nodeFlag: null,
+ nodeIcon: null,
+ nodeImage: null,
+ nodeProperties: {
+ text: text
+ },
+ nodeMetadata: {}
+ }
+
+ await createNode(nodeWithTempId, sketchId, addNode, replaceNode)
+ } catch (e) {
+ toast.error(e.message)
+ }
+ },
+ [sketchId]
+ )
+
+ const onImage = useCallback(
+ async (file: File) => {
+ const url = URL.createObjectURL(file)
+ try {
+ const title = file.name
+ const nodeWithTempId: GraphNode = {
+ id: uuidv4(),
+ nodeType: 'document', // Required at root level for API validation
+ nodeLabel: title,
+ x: Math.floor(Math.random() * 1000), // Position at viewport center
+ y: Math.floor(Math.random() * 1000),
+ nodeSize: 30,
+ nodeColor: null,
+ nodeFlag: null,
+ nodeIcon: null,
+ nodeImage: url || 'https://upload.wikimedia.org/wikipedia/en/d/dc/MichaelScott.png',
+ nodeShape: 'square',
+ nodeProperties: {
+ title: title
+ },
+ nodeMetadata: {}
+ }
+ await createNode(nodeWithTempId, sketchId, addNode, replaceNode)
+ } catch (e) {
+ toast.error(e.message)
+ }
+ },
+ [sketchId]
+ )
+ return usePasteListener(
+ {
+ text: onText,
+ image: onImage
+ },
+ { global: true, preventDefault: true }
+ )
+}
+
+const createNode = async (
+ node: GraphNode,
+ sketchId: string,
+ addNode: (node: GraphNode) => void,
+ replaceNode: (oldId: string, newId: string, nodeProperties: NodeProperties) => void
+) => {
+ try {
+ addNode(node)
+ // Create the node via API to get the real database ID
+ const newNodeResponse = await sketchService.addNode(sketchId, JSON.stringify(node))
+ const newNode: GraphNode = newNodeResponse.node
+ if (newNode) {
+ replaceNode(node.id, newNode.id, newNode.nodeProperties)
+ }
+ } catch (e) {
+ toast.error('Could not create node.')
+ }
+}
diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts b/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts
index ff6615f6..c9d0d7bc 100644
--- a/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts
+++ b/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts
@@ -39,7 +39,11 @@ export const useGraphEvents = ({
const isMultiSelect = event.ctrlKey || event.shiftKey
if (autoZoomOnCurrentNode && !isMultiSelect && node?.x && node?.y && graphRef.current) {
setTimeout(() => {
- if (graphRef.current && autoZoomOnNode && typeof graphRef.current.centerAt === 'function') {
+ if (
+ graphRef.current &&
+ autoZoomOnNode &&
+ typeof graphRef.current.centerAt === 'function'
+ ) {
graphRef.current.centerAt(node.x, node.y, 400)
if (typeof graphRef.current.zoom === 'function') {
graphRef.current.zoom(6, 400)
@@ -87,18 +91,24 @@ export const useGraphEvents = ({
onBackgroundClick?.()
}, [onBackgroundClick])
- const handleBackgroundRightClick = useCallback((event: MouseEvent) => {
- onBackgroundRightClick?.(event)
- }, [onBackgroundRightClick])
+ const handleBackgroundRightClick = useCallback(
+ (event: MouseEvent) => {
+ onBackgroundRightClick?.(event)
+ },
+ [onBackgroundRightClick]
+ )
- const handleNodeDragEnd = useCallback((node: any, graphData: any) => {
- node.fx = node.x
- node.fy = node.y
+ const handleNodeDragEnd = useCallback(
+ (node: any, graphData: any) => {
+ node.fx = node.x
+ node.fy = node.y
- if (graphData?.nodes) {
- saveAllNodePositions(graphData.nodes)
- }
- }, [saveAllNodePositions])
+ if (graphData?.nodes) {
+ saveAllNodePositions(graphData.nodes)
+ }
+ },
+ [saveAllNodePositions]
+ )
return {
handleNodeClick,
diff --git a/flowsint-app/src/components/sketches/graph/hooks/use-keyboard-events.ts b/flowsint-app/src/components/sketches/graph/hooks/use-keyboard-events.ts
new file mode 100644
index 00000000..4386b3c0
--- /dev/null
+++ b/flowsint-app/src/components/sketches/graph/hooks/use-keyboard-events.ts
@@ -0,0 +1,20 @@
+import { useCallback } from 'react'
+import { useGraphStore } from '@/stores/graph-store'
+import { useCreateOnPaste } from './use-create-on-paste'
+import { useKeyboardShortcut } from '@/hooks/use-keyboard-shortcut'
+
+export const useKeyboardEvents = (sketchId: string) => {
+ const setSelectedNodes = useGraphStore((s) => s.setSelectedNodes)
+ const filteredNodes = useGraphStore((s) => s.filteredNodes)
+
+ const handleCheckAll = useCallback(() => {
+ setSelectedNodes(filteredNodes)
+ }, [filteredNodes, setSelectedNodes])
+
+ useCreateOnPaste(sketchId)
+ useKeyboardShortcut({
+ key: 'a',
+ ctrlOrCmd: true,
+ callback: handleCheckAll
+ })
+}
diff --git a/flowsint-app/src/components/sketches/graph/index.tsx b/flowsint-app/src/components/sketches/graph/index.tsx
index 798a9a2e..376897ef 100644
--- a/flowsint-app/src/components/sketches/graph/index.tsx
+++ b/flowsint-app/src/components/sketches/graph/index.tsx
@@ -16,6 +16,7 @@ import {
preloadFlagImage
} from './utils/image-cache'
import { renderNode } from './node/node-renderer'
+import { useKeyboardEvents } from './hooks/use-keyboard-events'
import { renderLink } from './edge/link-renderer'
import { useHighlightState } from './hooks/use-highlight-state'
import { useTooltip } from './hooks/use-tooltip'
@@ -246,6 +247,8 @@ const GraphViewer: React.FC<GraphViewerProps> = ({
[handleNodeHover, showTooltip, hideTooltip]
)
+ useKeyboardEvents(sketchId)
+
const {
handleNodeClick,
handleNodeRightClick,
diff --git a/flowsint-app/src/components/sketches/graph/node/node-renderer.ts b/flowsint-app/src/components/sketches/graph/node/node-renderer.ts
index 2e24ec83..fc1978ec 100644
--- a/flowsint-app/src/components/sketches/graph/node/node-renderer.ts
+++ b/flowsint-app/src/components/sketches/graph/node/node-renderer.ts
@@ -1,4 +1,4 @@
-import { GraphNode } from '@/types'
+import { GraphNode, NodeShape } from '@/types'
import { CONSTANTS, GRAPH_COLORS } from '../utils/constants'
import {
getCachedImage,
@@ -13,18 +13,78 @@ type NodeVisual = {
isExternal: boolean
} | null
-// Draws an image with object-cover behavior inside a circular clip
-const drawCircularImage = (
+// Shape path helpers - each creates a path centered at (x, y) with given size
+const drawCirclePath = (ctx: CanvasRenderingContext2D, x: number, y: number, size: number) => {
+ ctx.arc(x, y, size, 0, 2 * Math.PI)
+}
+
+const drawSquarePath = (ctx: CanvasRenderingContext2D, x: number, y: number, size: number) => {
+ const half = size
+ ctx.rect(x - half, y - half, half * 2, half * 2)
+}
+
+const drawHexagonPath = (ctx: CanvasRenderingContext2D, x: number, y: number, size: number) => {
+ // Flat-top hexagon
+ for (let i = 0; i < 6; i++) {
+ const angle = (Math.PI / 3) * i - Math.PI / 6
+ const px = x + size * Math.cos(angle)
+ const py = y + size * Math.sin(angle)
+ if (i === 0) ctx.moveTo(px, py)
+ else ctx.lineTo(px, py)
+ }
+ ctx.closePath()
+}
+
+const drawTrianglePath = (ctx: CanvasRenderingContext2D, x: number, y: number, size: number) => {
+ // Equilateral triangle pointing up
+ const height = size * Math.sqrt(3)
+ const topY = y - height / 2
+ const bottomY = y + height / 2
+ ctx.moveTo(x, topY)
+ ctx.lineTo(x + size, bottomY)
+ ctx.lineTo(x - size, bottomY)
+ ctx.closePath()
+}
+
+// Unified shape path drawer
+const drawNodePath = (
+ ctx: CanvasRenderingContext2D,
+ x: number,
+ y: number,
+ size: number,
+ shape: NodeShape
+) => {
+ ctx.beginPath()
+ switch (shape) {
+ case 'square':
+ drawSquarePath(ctx, x, y, size)
+ break
+ case 'hexagon':
+ drawHexagonPath(ctx, x, y, size)
+ break
+ case 'triangle':
+ drawTrianglePath(ctx, x, y, size)
+ break
+ case 'circle':
+ default:
+ drawCirclePath(ctx, x, y, size)
+ break
+ }
+}
+
+// Draws an image with object-cover behavior inside a shape clip
+const drawClippedImage = (
ctx: CanvasRenderingContext2D,
img: HTMLImageElement,
x: number,
y: number,
- radius: number
+ size: number,
+ shape: NodeShape
) => {
- const diameter = radius * 2
+ const diameter = size * 2
const imgAspect = img.naturalWidth / img.naturalHeight
- // Calculate cover dimensions (fill the circle, crop excess)
+ // Calculate cover dimensions (fill the shape, crop excess)
let drawWidth: number, drawHeight: number
if (imgAspect > 1) {
// Landscape: height fills, width overflows
@@ -36,8 +96,7 @@ const drawCircularImage = (
drawHeight = diameter / imgAspect
}
- ctx.beginPath()
- ctx.arc(x, y, radius, 0, 2 * Math.PI)
+ drawNodePath(ctx, x, y, size, shape)
ctx.clip()
ctx.drawImage(img, x - drawWidth / 2, y - drawHeight / 2, drawWidth, drawHeight)
}
@@ -128,12 +187,12 @@ export const renderNode = ({
const isHighlighted = highlightNodes.has(node.id) || isSelected(node.id) || isCurrent(node.id)
const hasAnyHighlight = highlightNodes.size > 0 || highlightLinks.size > 0
const isHovered = hoverNode === node.id || isCurrent(node.id)
+ const shape: NodeShape = node.nodeShape ?? 'circle'
// Draw highlight ring
if (isHighlighted) {
const borderWidth = 3 / globalScale
- ctx.beginPath()
- ctx.arc(node.x, node.y, size + borderWidth, 0, 2 * Math.PI)
+ drawNodePath(ctx, node.x, node.y, size + borderWidth, shape)
ctx.fillStyle = isHovered
? GRAPH_COLORS.NODE_HIGHLIGHT_HOVER
: GRAPH_COLORS.NODE_HIGHLIGHT_DEFAULT
@@ -149,9 +208,8 @@ export const renderNode = ({
const isOutlined = forceSettings.nodeOutlined?.value ?? false
- // Draw node circle (filled or outlined)
- ctx.beginPath()
- ctx.arc(node.x, node.y, size, 0, 2 * Math.PI)
+ // Draw node shape (filled or outlined)
+ drawNodePath(ctx, node.x, node.y, size, shape)
if (isOutlined) {
// Fill background: white in light mode, dark in dark mode
@@ -165,8 +223,7 @@ export const renderNode = ({
ctx.fillStyle = nodeColor
ctx.fill()
// Draw subtle border for filled nodes
- ctx.beginPath()
- ctx.arc(node.x, node.y, size, 0, 2 * Math.PI)
+ drawNodePath(ctx, node.x, node.y, size, shape)
ctx.strokeStyle = theme === 'light' ? 'rgba(44, 44, 44, 0.19)' : 'rgba(222, 222, 222, 0.13)'
ctx.lineWidth = 0.3
ctx.stroke()
@@ -260,9 +317,9 @@ export const renderNode = ({
ctx.globalAlpha = iconAlpha
if (visual.isExternal) {
- // External image: circular, 90% of node size, object-cover
- const imgRadius = size * 0.9
- drawCircularImage(ctx, visual.image, node.x, node.y, imgRadius)
+ // External image: clipped to shape, 90% of node size, object-cover
+ const imgSize = size * 0.9
+ drawClippedImage(ctx, visual.image, node.x, node.y, imgSize, shape)
} else {
// Icon: draw normally
const iconSize = size * 1.2
diff --git a/flowsint-app/src/hooks/use-paste-listener.ts b/flowsint-app/src/hooks/use-paste-listener.ts
new file mode 100644
index 00000000..7b580844
--- /dev/null
+++ b/flowsint-app/src/hooks/use-paste-listener.ts
@@ -0,0 +1,96 @@
+import { useCallback, useEffect, useRef } from 'react'
+
+export type ClipboardPayload =
+ | { type: 'text'; text: string }
+ | { type: 'html'; html: string }
+ | { type: 'image'; file: File }
+ | { type: 'files'; files: File[] }
+
+export type PasteHandlers = Partial<{
+ text: (text: string, event: ClipboardEvent | React.ClipboardEvent) => void
+ html: (html: string, event: ClipboardEvent | React.ClipboardEvent) => void
+ image: (file: File, event: ClipboardEvent | React.ClipboardEvent) => void
+ files: (files: File[], event: ClipboardEvent | React.ClipboardEvent) => void
+}>
+
+export type UsePasteListenerOptions = {
+ global?: boolean
+ preventDefault?: boolean
+}
+
+function parseClipboard(data: DataTransfer): ClipboardPayload[] {
+ const result: ClipboardPayload[] = []
+
+ const text = data.getData('text/plain')
+ if (text) {
+ result.push({ type: 'text', text })
+ }
+
+ const html = data.getData('text/html')
+ if (html) {
+ result.push({ type: 'html', html })
+ }
+
+ const files = Array.from(data.files)
+ if (files.length) {
+ const images = files.filter((f) => f.type.startsWith('image/'))
+ const others = files.filter((f) => !f.type.startsWith('image/'))
+
+ images.forEach((file) => result.push({ type: 'image', file }))
+ if (others.length) {
+ result.push({ type: 'files', files: others })
+ }
+ }
+
+ return result
+}
+
+export function usePasteListener(handlers: PasteHandlers, options: UsePasteListenerOptions = {}) {
+ const { global = false, preventDefault = false } = options
+
+ const handlersRef = useRef(handlers)
+ handlersRef.current = handlers
+
+ const listener = useCallback(
+ (event: ClipboardEvent | React.ClipboardEvent) => {
+ if (preventDefault) {
+ event.preventDefault()
+ }
+
+ const clipboardData = event.clipboardData
+ if (!clipboardData) return
+
+ const payloads = parseClipboard(clipboardData)
+
+ payloads.forEach((payload) => {
+ const handler = handlersRef.current[payload.type]
+ if (!handler) return
+
+ switch (payload.type) {
+ case 'text':
+ handler(payload.text, event)
+ break
+ case 'html':
+ handler(payload.html, event)
+ break
+ case 'image':
+ handler(payload.file, event)
+ break
+ case 'files':
+ handler(payload.files, event)
+ break
+ }
+ })
+ },
+ [preventDefault]
+ )
+
+ useEffect(() => {
+ if (!global) return
+
+ window.addEventListener('paste', listener)
+ return () => window.removeEventListener('paste', listener)
+ }, [global, listener])
+
+ return global ? undefined : listener
+}
diff --git a/flowsint-app/src/types/graph.ts b/flowsint-app/src/types/graph.ts
index 038c057d..10a5fc3e 100644
--- a/flowsint-app/src/types/graph.ts
+++ b/flowsint-app/src/types/graph.ts
@@ -18,6 +18,8 @@ export type NodeMetadata = {
[key: string]: any
}
+export type NodeShape = 'circle' | 'square' | 'hexagon' | 'triangle'
+
export type GraphNode = {
id: string
nodeType: string
@@ -28,6 +30,7 @@ export type GraphNode = {
nodeIcon: keyof typeof LucideIcons | null
nodeImage: string | null
nodeFlag: flagColor | null
+ nodeShape: NodeShape | null
nodeMetadata: NodeMetadata
x: number
y: number