feat(annotator): support quick actions for text selection, closes #2505 (#2813)

This commit is contained in:
Huang Xin
2025-12-30 10:32:01 +01:00
committed by GitHub
parent 58a5c1625c
commit a42897ec5c
47 changed files with 1036 additions and 122 deletions
@@ -0,0 +1,43 @@
import clsx from 'clsx';
import React, { useState } from 'react';
interface AnnotationToolButtonProps {
showTooltip: boolean;
tooltipText: string;
disabled?: boolean;
Icon: React.ElementType;
onClick: () => void;
}
const AnnotationToolButton: React.FC<AnnotationToolButtonProps> = ({
showTooltip,
tooltipText,
disabled,
Icon,
onClick,
}) => {
const [buttonClicked, setButtonClicked] = useState(false);
const handleClick = () => {
setButtonClicked(true);
onClick();
};
return (
<div
className='lg:tooltip lg:tooltip-bottom'
title={!buttonClicked && showTooltip ? tooltipText : undefined}
>
<button
onClick={handleClick}
className={clsx(
'flex h-8 min-h-8 w-8 items-center justify-center p-0',
disabled ? 'cursor-not-allowed opacity-50' : 'rounded-md hover:bg-gray-500',
)}
disabled={disabled}
>
<Icon />
</button>
</div>
);
};
export default AnnotationToolButton;