feat(editor): drawing guard before navigations drop a started move (R-12)

The move mode lives in the work store with its document stamp. guardDrawing
ends an unstarted mode at once and asks « Abandonner le déplacement ? »
(DrawingGuardDialog, at workspace level) once work is started, before a
tab, a section, « Aller à », Back and a history jump out of the editor;
the leave guard and sign-out count started work. An undo from the header,
Ctrl+Z or the message only cancels a pending mode or preview (R-13), and a
document change drops a stale mode, keeping a started one to be said.
ConfirmDialog takes an optional body. Strings for Task 4 added.
This commit is contained in:
bchanot committed 2026-11-17 18:26:49 +01:00
1 parent 8cd1bda6c2
commit 2882821661
18 files changed
+465 -37

No files matched your search

@@ -0,0 +1,28 @@
import { useRef } from 'react'
import { answerDrawing } from '@/editor/annotations/drawingGuard'
import { useAnnotationWork } from '@/editor/annotations/workStore'
import { useT } from '@/i18n/useT'
import ConfirmDialog from '../ConfirmDialog'
/**
* The drawing guard's question (R-12), mounted with the workspace so it shows whatever
* tab is in view: « Continuer » keeps the work, « Abandonner » drops it and makes the move
* that was held.
*/
export default function DrawingGuardDialog() {
const t = useT()
const question = useAnnotationWork((s) => s.question)
// The title stays while the dialog closes.
const title = useRef('')
if (question) title.current = t(`editor.annotations.guard.${question.work}`)
return (
<ConfirmDialog
open={question !== null}
title={title.current}
confirmLabel={t('editor.annotations.guard.discard')}
cancelLabel={t('editor.annotations.guard.continue')}
onConfirm={() => answerDrawing(true)}
onCancel={() => answerDrawing(false)}
/>
)
}