feat(editor): four tabs, Annotations sections, references from the header

U1 Lot B1. Four tabs (Général, Annotations, Constats, Vérification); views,
categories and regions become full-width Annotations sections opened from the
overview panel; references move to a header-toggled panel (minimal, Lot D
completes it); « Aller à » goes through EditorTarget and the navigation hook.
EditorWorkspace owns the navigation; DraftHeader split in HeaderActions and
SaveLine; EditorTabs split in TabList and MoreTabs.

R-24, assertions removed or rewritten (file: old -> new):
unit
- editor-route.test: seven tab names -> four; « Plus » at 800 px with
  Références clicked -> no « Plus »; below 640 px five others -> Général,
  Constats, and Constats opens the findings tab; + references panel cases
- editor-route-recovery.test: tab Références + editor-tab-references label ->
  header button + editor-references-panel labelled by its heading
- editor-mode.test: small tier `more` of five -> [general, findings]
- editor-focus-request.test: {key,serial} -> {target,serial}; ReferencesTab and
  VertebraeTab -> ReferencesPanel and RegionsSection; issueTarget tab/key ->
  target place/section/key (vertebrae tab -> annotations/regions); consumed
  context (serial) -> (serial, outcome); annotation case adds heading focus
- editor-verification.test: onGoTo('annotations', key) -> navigate(targetOfKey
  (key), opener); props onSelectTab/onGoTo -> navigate
- editor-annotations-tab.test: props onSelectTab -> navigate + section props;
  no_category text « (onglet Général) » -> « (Annotations, section
  Catégories) »
- editor-tabs-general.test: categories cases render GeneralTab ->
  CategoriesSection(doc); + Général holds no categories editor
- editor-tabs-lists.test: tab imports -> panel and section; read-only
  references « no button » -> only « Fermer les références »
- editor-tabs-views, editor-drawing-upload, editor-repair.test: ViewsTab ->
  ViewsSection import, assertions kept; editor-findings.test: navigate prop
e2e
- support/editor selectTab: exact name -> pattern (error badge in the name);
  + place, openSection, showDrawing, backToDrawing, openReferences, TABS
- support/warm-up: seven tabs -> four + sections + references panel
- editor-access: seven-tab axe loops -> four tabs + three sections + panel
  (edit and read-only); narrow widths add panel overflow and axe
- editor-drawings: tab Vues -> openSection views; tab Annotations ->
  showDrawing
- editor-structures: tab Général (categories) -> openSection categories, axe
  label « general tab » -> « categories section »; tab Références ->
  openReferences/closeReferences; tab Vertèbres -> openSection regions; tab
  Annotations -> showDrawing
- editor-geometry: three tab Vues -> openSection views
- editor-equine: tab Général (categories add) -> openSection categories; five
  tabs loop -> two tabs + sections + panel; tab Annotations -> showDrawing
- editor-journey: tab Vues, tab Général (category), tab Annotations ->
  openSection views/categories, showDrawing; frozen axe scrolls to the header
- lan/trial-lan (not run): tab Vues -> Annotations tab + views entry

Verified: typecheck, lint, vitest 107 files / 1125 tests, whole shell suite on
the sandbox 151 passed, 49 skipped, 0 failed.
This commit is contained in:
bchanot committed 2026-11-06 20:25:35 +01:00
1 parent 95b1b7e461
commit bc2dba7c14
56 files changed
+2419 -699

No files matched your search

@@ -1,10 +1,10 @@
import { useReducer, useState, type Dispatch } from 'react'
import { useEffect, useReducer, useState, type Dispatch } from 'react'
import type {
AnatomicalSheetDocument,
Annotation,
} from '@faunosteo/core-wasm/types'
import type { CommitContext } from '@/editor/annotations/annotationCommit'
import { annotationFocus } from '@/editor/annotations/focusTarget'
import { useAnnotationRequest } from '@/editor/annotations/focusTarget'
import { keyboardPending, type NewKind } from '@/editor/annotations/creation'
import { parseFrame, type Frame } from '@/editor/annotations/frame'
import { isEditable } from '@/editor/annotations/geometryEdit'
@@ -22,14 +22,15 @@ import {
useViewModel,
type ViewModel,
} from '@/editor/annotations/useViewModel'
import { useFocusRequest } from '@/editor/focusRequest'
import type { EditorTabProps } from '@/editor/tabs'
import type { AnnotationSection } from '@/editor/navigation'
import type { EditorPlaceProps } from '@/editor/tabs'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import AnnotationCanvas from './AnnotationCanvas'
import AnnotationList, { annotationName } from './AnnotationList'
import CreationPanel from './CreationPanel'
import KeyboardAdd from './KeyboardAdd'
import OverviewPanel from './OverviewPanel'
import PropertiesPanel, { UnmeasuredHint } from './PropertiesPanel'
import SelectionTag from './SelectionTag'
import TracingBar from './TracingBar'
@@ -37,8 +38,9 @@ import ViewSwitcher from './ViewSwitcher'
interface Props {
doc: AnatomicalSheetDocument
onSelectTab: EditorTabProps['onSelectTab']
focus: EditorTabProps['focus']
navigate: EditorPlaceProps['navigate']
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
focus: EditorPlaceProps['focus']
}
/** What both columns read: the tab's state, the view, its frame and its selection. */
@@ -52,21 +54,46 @@ interface Scene {
frame: Frame | null
selected: Annotation | undefined
setRoot: (root: RootAttributes | null) => void
onSelectTab: EditorTabProps['onSelectTab']
navigate: EditorPlaceProps['navigate']
onOpenSection: Props['onOpenSection']
}
function useScene({ doc, onSelectTab, focus }: Props): Scene {
/**
* The shown view no longer exists (an undo, a deletion in the views section): the full
* reset to the main view drops the pending creation, the tracing and the selection, so
* nothing pending is inserted on another view. It fires only for a view absent from the
* document, since `view` always returns a new state.
*/
function useViewFallback(
doc: AnatomicalSheetDocument,
shown: string | null,
dispatch: Dispatch<UiAction>,
) {
useEffect(() => {
if (shown === null || doc.views.some((view) => view.id === shown)) return
const main = mainViewId(doc)
if (doc.views.some((view) => view.id === main)) {
dispatch({ type: 'view', viewId: main })
}
}, [doc, shown, dispatch])
}
function useScene({ doc, navigate, onOpenSection, focus }: Props): Scene {
const [ui, dispatch] = useReducer(uiReducer, initialUi)
useFocusRequest(focus, (key) => {
const target = annotationFocus(doc, key)
if (!target) return
dispatch({ type: 'view', viewId: target.viewId })
dispatch({ type: 'select', id: target.annotationId })
})
const [root, setRoot] = useState<RootAttributes | null>(null)
const viewId = ui.viewId ?? mainViewId(doc)
const model = useViewModel(doc, viewId)
const own = model.measured && root?.viewId === viewId
useViewFallback(doc, ui.viewId, dispatch)
useAnnotationRequest(focus, doc, {
viewId,
selectedId: ui.selectedId,
busy: ui.pending ? 'creation' : ui.tracing ? 'tracing' : null,
show: (view, id) => {
dispatch({ type: 'view', viewId: view })
dispatch({ type: 'select', id })
},
})
return {
doc,
ui,
@@ -76,7 +103,8 @@ function useScene({ doc, onSelectTab, focus }: Props): Scene {
frame: own ? parseFrame(root.viewBox) : null,
selected: model.annotations.find((a) => a.id === ui.selectedId),
setRoot,
onSelectTab,
navigate,
onOpenSection,
}
}
@@ -123,7 +151,8 @@ function CanvasColumn({
hint={ui.hint}
model={model}
noCategory={noCategory}
onSelectTab={scene.onSelectTab}
viewId={scene.viewId}
navigate={scene.navigate}
/>
{selected && <TagOf annotation={selected} doc={doc} />}
<CanvasStage scene={scene} placement={placement} />
@@ -217,7 +246,6 @@ function SidePanel({
scene: Scene
context: CommitContext
}) {
const t = useT()
const { doc, ui, dispatch, model, frame, selected } = scene
if (ui.pending) {
return (
@@ -234,9 +262,13 @@ function SidePanel({
}
if (!selected) {
return (
<p className="text-sm text-[var(--color-ink-muted)]">
{t('editor.annotations.select_hint')}
</p>
<OverviewPanel
doc={doc}
viewId={scene.viewId}
readOnly={false}
onSelectView={(id) => dispatch({ type: 'view', viewId: id })}
onOpenSection={scene.onOpenSection}
/>
)
}
return (
@@ -248,7 +280,7 @@ function SidePanel({
geometryLocked={!model.measured}
dispatch={dispatch}
context={context}
onSelectTab={scene.onSelectTab}
navigate={scene.navigate}
/>
)
}
@@ -284,20 +316,24 @@ function ToolNotes({
hint,
model,
noCategory,
onSelectTab,
viewId,
navigate,
}: {
tool: ToolId
hint: string | null
model: ViewModel
noCategory: boolean
onSelectTab: EditorTabProps['onSelectTab']
viewId: string
navigate: EditorPlaceProps['navigate']
}) {
const t = useT()
const linkBlocked = tool === 'link' && model.children.length === 0
return (
<div className="space-y-1 text-sm text-[var(--color-ink-muted)]">
<p>{t(`editor.annotations.tool_hint.${tool}`)}</p>
{!model.measured && <UnmeasuredHint onSelectTab={onSelectTab} />}
{!model.measured && (
<UnmeasuredHint navigate={navigate} viewId={viewId} />
)}
{noCategory && <p>{t('editor.annotations.no_category')}</p>}
{linkBlocked && <p>{t('editor.annotations.no_child_view')}</p>}
{hint && (