MCPcopy Create free account
hub / github.com/SplootCode/splootcode / MicroNodeInternal

Function MicroNodeInternal

packages/editor/src/components/tray/category.tsx:31–58  ·  view source on GitHub ↗
(props: {
  fragment: RenderedFragment
  startDrag: (fragment: RenderedFragment, offsetX: number, offsetY: number) => any
})

Source from the content-addressed store, hash-verified

29}
30
31const MicroNodeInternal = (props: {
32 fragment: RenderedFragment
33 startDrag: (fragment: RenderedFragment, offsetX: number, offsetY: number) => any
34}) => {
35 const { fragment: fragment, startDrag } = props
36
37 const onDragStart = (event: React.DragEvent<HTMLDivElement>) => {
38 event.dataTransfer.effectAllowed = 'copyMove'
39 const data = JSON.stringify(fragment.fragment.serialize())
40 event.dataTransfer.setData('sploot-fragment', data)
41 startDrag(fragment, 0, 0)
42 }
43
44 if (fragment === null) {
45 return null
46 }
47
48 const height = fragment.height
49 const width = fragment.width
50
51 return (
52 <div draggable={true} onDragStart={onDragStart}>
53 <svg className="autocomplete-inline-svg" height={height} width={width}>
54 <FragmentView fragment={fragment} />
55 </svg>
56 </div>
57 )
58}
59
60export const MicroNode = React.memo(MicroNodeInternal)
61

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected