From cc10c24ae39812fb9fffd8c016494ccaede0c345 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Thu, 8 Jan 2026 09:49:39 +0330 Subject: [PATCH] live arrow shape --- .../editor/components/tools/ArrowShape.tsx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pages/editor/components/tools/ArrowShape.tsx b/src/pages/editor/components/tools/ArrowShape.tsx index 594fabb..37942ab 100644 --- a/src/pages/editor/components/tools/ArrowShape.tsx +++ b/src/pages/editor/components/tools/ArrowShape.tsx @@ -1,4 +1,4 @@ -import { useRef } from "react"; +import { useRef, useEffect } from "react"; import { Arrow } from "react-konva"; import Konva from "konva"; import type { ShapeProps } from "./types"; @@ -14,6 +14,20 @@ const ArrowShape = ({ obj, isSelected, onSelect, onUpdate, draggable }: ShapePro const endY = obj.height || 0; const actualStrokeWidth = obj.strokeWidth ?? 2; + const actualStroke = obj.stroke || "#000000"; + + // اگر انتخاب شده و strokeWidth = 0 است، ضخامت را 3 کن تا مشخص باشد + const displayStrokeWidth = isSelected && actualStrokeWidth === 0 ? 3 : actualStrokeWidth; + + // به‌روزرسانی رنگ و ضخامت به‌صورت لایو + useEffect(() => { + if (shapeRef.current) { + shapeRef.current.stroke(actualStroke); + shapeRef.current.fill(actualStroke); + shapeRef.current.strokeWidth(displayStrokeWidth); + shapeRef.current.getLayer()?.batchDraw(); + } + }, [actualStroke, displayStrokeWidth, obj.stroke, obj.strokeWidth, isSelected]); return (