Improve annotations (#5919)

* Text box/notes movement improvements 
* Fix the issue where hiding, then showing annotations looses progress 
* Fix the issue where hidig/showing annotations jumps you back up to the
top of your open document 
* Support ctrl+c and  ctrl+v and backspace to delete 
* Better handling when moving to different tool from annotate 
* Added a color picker eyedropper button  
* Auto-switch to Select after note/text placement, so users can quickly
place and type 
This commit is contained in:
EthanHealy01
2026-03-13 14:03:27 +00:00
committed by GitHub
parent 44e036da5a
commit c9d693f1eb
13 changed files with 409 additions and 245 deletions
@@ -45,7 +45,7 @@ export default function ViewerAnnotationControls({ currentView, disabled = false
// Get redaction pending state and navigation guard
const { isRedacting: _isRedacting } = useRedactionMode();
const { requestNavigation, setHasUnsavedChanges } = useNavigationGuard();
const { requestNavigation, setHasUnsavedChanges, hasUnsavedChanges } = useNavigationGuard();
const { setRedactionMode, activateRedact, setRedactionConfig, setRedactionsApplied, redactionApiRef, setActiveType } = useRedaction();
@@ -131,6 +131,15 @@ export default function ViewerAnnotationControls({ currentView, disabled = false
}
};
const handleToggleAnnotationsVisibility = useCallback(() => {
// When going from visible → hidden with unsaved changes, prompt to save first
if (!annotationsHidden && hasUnsavedChanges) {
requestNavigation(() => viewerContext?.toggleAnnotationsVisibility());
} else {
viewerContext?.toggleAnnotationsVisibility();
}
}, [annotationsHidden, hasUnsavedChanges, requestNavigation, viewerContext]);
// Don't show any annotation controls in sign mode
// NOTE: This early return is placed AFTER all hooks to satisfy React's rules of hooks
if (isSignMode) {
@@ -164,9 +173,7 @@ export default function ViewerAnnotationControls({ currentView, disabled = false
color={annotationsHidden ? "blue" : undefined}
radius="md"
className="right-rail-icon"
onClick={() => {
viewerContext?.toggleAnnotationsVisibility();
}}
onClick={handleToggleAnnotationsVisibility}
disabled={disabled || currentView !== 'viewer' || (isInAnnotationTool && !isAnnotateActive) || isPlacementMode}
data-active={annotationsHidden ? 'true' : undefined}
aria-pressed={annotationsHidden}