This commit is contained in:
Anthony Stirling 2025-11-10 18:18:21 +00:00
parent 559ba3ccab
commit 5fadb92f51

View File

@ -756,6 +756,7 @@ const PdfJsonEditorView = ({ data }: PdfJsonEditorViewProps) => {
isChanged: boolean, isChanged: boolean,
content: React.ReactNode, content: React.ReactNode,
onActivate?: (event: React.MouseEvent) => void, onActivate?: (event: React.MouseEvent) => void,
onClick?: (event: React.MouseEvent) => void,
) => ( ) => (
<Box <Box
component="div" component="div"
@ -783,17 +784,15 @@ const PdfJsonEditorView = ({ data }: PdfJsonEditorViewProps) => {
}} }}
onClick={(event) => { onClick={(event) => {
event.stopPropagation(); event.stopPropagation();
if (onClick) {
onClick(event);
} else {
onActivate?.(event); onActivate?.(event);
}}
onMouseEnter={() => setActiveGroupId(groupId)}
onMouseLeave={() => {
if (editingGroupId !== groupId) {
setActiveGroupId((current) => (current === groupId ? null : current));
} }
}} }}
> >
{content} {content}
{isActive && editingGroupId !== groupId && ( {activeGroupId === groupId && editingGroupId !== groupId && (
<ActionIcon <ActionIcon
size="xs" size="xs"
variant="filled" variant="filled"
@ -1502,7 +1501,10 @@ const PdfJsonEditorView = ({ data }: PdfJsonEditorViewProps) => {
{group.text || '\u00A0'} {group.text || '\u00A0'}
</span> </span>
</div>, </div>,
undefined,
(event: React.MouseEvent) => { (event: React.MouseEvent) => {
// Double-click to edit
if (event.detail === 2) {
// Capture click position BEFORE switching to edit mode // Capture click position BEFORE switching to edit mode
const clickX = event.clientX; const clickX = event.clientX;
const clickY = event.clientY; const clickY = event.clientY;
@ -1548,6 +1550,10 @@ const PdfJsonEditorView = ({ data }: PdfJsonEditorViewProps) => {
} }
}, 10); }, 10);
}); });
} else {
// Single click just selects
setActiveGroupId(group.id);
}
}, },
)} )}
</Box> </Box>