From edb04320caee8dcea60cfd2f9de5938078f604fd Mon Sep 17 00:00:00 2001 From: Ahmad Kadri Date: Mon, 6 Jan 2025 08:38:21 +0100 Subject: [PATCH 1/5] add transparen line to extend the padding of the arrwo and line element Signed-off-by: Ahmad Kadri --- .../react-sdk/src/components/elements/line/Display.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-sdk/src/components/elements/line/Display.tsx b/packages/react-sdk/src/components/elements/line/Display.tsx index 50520f1e..cf86a6ed 100644 --- a/packages/react-sdk/src/components/elements/line/Display.tsx +++ b/packages/react-sdk/src/components/elements/line/Display.tsx @@ -46,6 +46,15 @@ const LineDisplay = ({ const renderedChild = ( {endMarker} + Date: Mon, 6 Jan 2025 08:46:37 +0100 Subject: [PATCH 2/5] add changeset Signed-off-by: Ahmad Kadri --- .changeset/quiet-starfishes-cough.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/quiet-starfishes-cough.md diff --git a/.changeset/quiet-starfishes-cough.md b/.changeset/quiet-starfishes-cough.md new file mode 100644 index 00000000..05e83609 --- /dev/null +++ b/.changeset/quiet-starfishes-cough.md @@ -0,0 +1,6 @@ +--- +'@nordeck/matrix-neoboard-react-sdk': patch +'@nordeck/matrix-neoboard-widget': patch +--- + +Enhance the interactivity of arrows and lines by increasing the clickable area around them From 0048e2fae20c585513fcc8516d952cc39f8f135b Mon Sep 17 00:00:00 2001 From: Ahmad Kadri Date: Mon, 6 Jan 2025 09:13:56 +0100 Subject: [PATCH 3/5] fix the tests Signed-off-by: Ahmad Kadri --- .../components/elements/line/Display.test.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/react-sdk/src/components/elements/line/Display.test.tsx b/packages/react-sdk/src/components/elements/line/Display.test.tsx index f35a9e9c..56de8e4c 100644 --- a/packages/react-sdk/src/components/elements/line/Display.test.tsx +++ b/packages/react-sdk/src/components/elements/line/Display.test.tsx @@ -95,6 +95,15 @@ describe('', () => { + ', () => { stroke="#ffffff" /> + Date: Mon, 6 Jan 2025 10:19:15 +0100 Subject: [PATCH 4/5] calculate the strokWidth depanding on the scale Signed-off-by: Ahmad Kadri --- .../react-sdk/src/components/elements/line/Display.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-sdk/src/components/elements/line/Display.tsx b/packages/react-sdk/src/components/elements/line/Display.tsx index cf86a6ed..e54f0cb1 100644 --- a/packages/react-sdk/src/components/elements/line/Display.tsx +++ b/packages/react-sdk/src/components/elements/line/Display.tsx @@ -22,6 +22,7 @@ import { SelectableElement, WithExtendedSelectionProps, } from '../../Whiteboard'; +import { useSvgCanvasContext } from '../../Whiteboard/SvgCanvas'; import { getRenderProperties } from './getRenderProperties'; import { useEndMarker } from './useEndMarker'; @@ -40,6 +41,10 @@ const LineDisplay = ({ strokeWidth, points: { start, end }, } = getRenderProperties(element); + const { scale } = useSvgCanvasContext(); + // Fallback to scale = 1 if scale is 0 + const adjustedScale = scale === 0 ? 1 : scale; + const adjustedStrokeWidth = (strokeWidth + 10) * adjustedScale; const { endMarkerId, endMarker } = useEndMarker(element); @@ -49,7 +54,7 @@ const LineDisplay = ({ Date: Mon, 6 Jan 2025 11:17:26 +0100 Subject: [PATCH 5/5] improve the calculate of the width Signed-off-by: Ahmad Kadri --- packages/react-sdk/src/components/elements/line/Display.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-sdk/src/components/elements/line/Display.tsx b/packages/react-sdk/src/components/elements/line/Display.tsx index e54f0cb1..c076b01a 100644 --- a/packages/react-sdk/src/components/elements/line/Display.tsx +++ b/packages/react-sdk/src/components/elements/line/Display.tsx @@ -44,7 +44,7 @@ const LineDisplay = ({ const { scale } = useSvgCanvasContext(); // Fallback to scale = 1 if scale is 0 const adjustedScale = scale === 0 ? 1 : scale; - const adjustedStrokeWidth = (strokeWidth + 10) * adjustedScale; + const adjustedStrokeWidth = strokeWidth + 10 / adjustedScale; const { endMarkerId, endMarker } = useEndMarker(element);