import { useRef, useMemo } from "react"; import { Text } from "react-konva"; import Konva from "konva"; import type { ShapeProps } from "./types"; const getFontWeight = (fontWeight?: string): string => { const weightMap: Record = { bold: "bold", normal: "normal", "300": "300", }; return weightMap[fontWeight || "normal"] || "normal"; }; const LinkShape = ({ obj, onSelect, onUpdate, draggable, }: ShapeProps) => { const shapeRef = useRef(null); const fontWeight = useMemo(() => getFontWeight(obj.fontWeight), [obj.fontWeight]); // Transformer is managed in EditorCanvas for multi-select support return ( { // در حالت editor، لینک‌ها قابل کلیک نیستند // این قابلیت در viewer اضافه خواهد شد if (shapeRef.current) { onSelect(obj.id, shapeRef.current, e); } }} onDragEnd={(e) => { const node = e.target; onUpdate(obj.id, { x: node.x(), y: node.y(), }); }} /> ); }; export default LinkShape;