Fix curved text selection and dragging
- Remove Group wrapper that was preventing TextPath from receiving click events - Make TextPath directly draggable and selectable with proper event handlers - TextPath now supports: clicking to select, dragging to move, position persistence - Users can now properly interact with curved text on the canvas Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
af4f21938d
commit
8ec34a60c9
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useRef, useState, useEffect, useLayoutEffect, useCallback } from 'react';
|
import { useRef, useState, useEffect, useLayoutEffect, useCallback } from 'react';
|
||||||
import { Stage, Layer, Text, TextPath, Image as KonvaImage, Transformer, Rect, Group } from 'react-konva';
|
import { Stage, Layer, Text, TextPath, Image as KonvaImage, Transformer, Rect } from 'react-konva';
|
||||||
import type Konva from 'konva';
|
import type Konva from 'konva';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import ProductMockup from './ProductMockup';
|
import ProductMockup from './ProductMockup';
|
||||||
@@ -325,29 +325,28 @@ function PrintSurface({
|
|||||||
{elements.map((el) =>
|
{elements.map((el) =>
|
||||||
el.type === 'text' ? (
|
el.type === 'text' ? (
|
||||||
el.curvedPath ? (
|
el.curvedPath ? (
|
||||||
// Curved text path wrapped in a draggable Group
|
// Curved text path - directly draggable
|
||||||
<Group
|
<TextPath
|
||||||
key={el.id}
|
key={el.id}
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
if (node) nodeRefs.current.set(el.id, node);
|
if (node) nodeRefs.current.set(el.id, node);
|
||||||
}}
|
}}
|
||||||
|
data={generateCurvePath(el.curvedPath.type, el.curvedPath.radius, el.curvedPath.reverse)}
|
||||||
|
text={el.text}
|
||||||
|
fontFamily={el.fontFamily}
|
||||||
|
fontSize={el.fontSize}
|
||||||
|
fill={el.fill}
|
||||||
x={el.x}
|
x={el.x}
|
||||||
y={el.y}
|
y={el.y}
|
||||||
draggable
|
draggable
|
||||||
listening={true}
|
listening={true}
|
||||||
onClick={() => setSelectedId(el.id)}
|
onClick={() => setSelectedId(el.id)}
|
||||||
onTap={() => setSelectedId(el.id)}
|
onTap={() => setSelectedId(el.id)}
|
||||||
onDragEnd={(e) => updateElement(el.id, { x: e.target.x(), y: e.target.y() })}
|
onDragEnd={(e) => {
|
||||||
>
|
const node = e.target as any;
|
||||||
<TextPath
|
updateElement(el.id, { x: node.x(), y: node.y() });
|
||||||
data={generateCurvePath(el.curvedPath.type, el.curvedPath.radius, el.curvedPath.reverse)}
|
}}
|
||||||
text={el.text}
|
/>
|
||||||
fontFamily={el.fontFamily}
|
|
||||||
fontSize={el.fontSize}
|
|
||||||
fill={el.fill}
|
|
||||||
listening={false}
|
|
||||||
/>
|
|
||||||
</Group>
|
|
||||||
) : (
|
) : (
|
||||||
// Regular straight text
|
// Regular straight text
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
Reference in New Issue
Block a user