feat(editor): fifth tab « Références », citations panel from a finding
The reference library moves into a fifth editor tab (Général,
Annotations, Constats, Références, Vérification; under « Plus » below
640 px with Général and Constats). The header « Références » button is
removed. The side panel becomes the citations list of one finding,
opened only from a finding's trigger (owner GO 2026-11-12: never from a
family; the family keeps its inline list with « Retirer »). Selecting a
tab closes it; every close records one pending move applied after the
panel is gone, focus back to the trigger else the active tab button.
Vérification's reference issues land on the tab. e2e seed gains a
reference cited by « Constat A ».
Gates: typecheck, lint, test:run (app 1396), build, e2e:ui 251 passed;
e2e:shell 15 specs on db:sandbox (editor-equine never listed): 107
passed / 95 skipped / 2 failed (test remap dropped its edit), fixed and
rerun: editor-shell.spec 11 passed; full-row data guard: no
pre-existing row changed in any table. editor-equine.spec.ts helper
calls updated, not run.
## R-24 table (removed or rewritten assertions; old = fc3fec7 line, new = current file)
Unit tests:
| file:old line | old | new |
|---|---|---|
| editor-verification.test.tsx:87-96 | `navigate` called with target AND `expect.any(HTMLElement)` | called with the target only (opener dropped) |
| editor-verification.test.tsx:238-241 | `references[0]` path -> `{place:'references', citedBy:null}` | `{place:'tab', tab:'references', section:null}` |
| editor-verification.test.tsx:262-264 | `placeKey(references[9])` = `editor.place.references` | `editor.tab.references` |
| editor-navigation.test.ts:63 | targetOfKey reference -> `{place:'references', key, citedBy:null}` | `{place:'tab', tab:'references', section:null, key}` |
| editor-navigation.test.ts:80 | `referencesMounted` false at start | `citationsOf` null and `libraryReset` 0 |
| editor-navigation.test.ts:95-110 | go_to a reference opens the panel over the place | go_to a reference shows the Références tab with its focus request |
| editor-navigation.test.ts:112-122 | go_to a tab closes the panel (`references` object) | same, via `citationsOf` null |
| editor-navigation.test.ts:124-136 | select_tab keeps the panel | select_tab CLOSES the panel (P21), keeps section, no request |
| editor-navigation.test.ts:138-146 | `clear_cited_by` drops the filter | removed (action gone); replaced by `open_citations` refuses family/zone/view, `show_all_references` (closes, tab, reset bump), plain go_to leaves reset alone |
| editor-navigation.test.ts:160-175 | open/close references keep tab and section | open/close citations, same assertions on `citationsOf` |
| editor-mode.test.ts:100-109 | tabsFor four tabs, small more = general, findings | five tabs, small more = general, findings, references |
| editor-route.test.tsx:46,50 | TABS four, title « four tabs » | five |
| editor-route.test.tsx:139-146 | 640-1023 px four tabs | five tabs, tablist has `flex-wrap` |
| editor-route.test.tsx:149-161 | « Plus » lists Général, Constats | lists Général, Constats, Références |
| editor-route.test.tsx:168-190 | header button opens panel, ✕ returns focus to button | no header button, panel not mounted at start (full panel flow moved to editor-references-panel.test.tsx) |
| editor-route.test.tsx:192-206 | Escape closes, panel content kept for next opening | removed: the panel is no longer kept mounted (design choice 3); Escape/close covered in editor-references-panel + editor-escape |
| editor-route.test.tsx:208-218 | read-only: panel lists references, no edit control | read-only: the Références tab lists them, no textbox, no add button; plus new: tab keeps mounted when left |
| editor-tabs-lists.test.tsx:47,75,114,130 | render `ReferencesPanel` | render `ReferencesTab` |
| editor-tabs-lists.test.tsx:77 | selector `#reference-ref-a-url` | `#tab-reference-ref-a-url` |
| editor-tabs-lists.test.tsx:131-135 | read-only buttons = only « Fermer les références » | no button at all |
| editor-focus-request.test.tsx:166-171,200-202,346 | `ReferencesPanel` with `panel` props and focus | `ReferenceLibrary` with focus (same assertions) |
| editor-focus-request.test.tsx:226 | `ownedBy(ref,'citations')` is the request | `ownedBy(ref,'references')` is the request, `'citations'` undefined |
| editor-focus-request.test.tsx (Probe) | none | new: Vérification « Aller à » reference -> tab + focused row; reference path naming no element -> tab heading |
| editor-keep-alive.test.tsx:71,178-190 | add form survives closing/reopening the panel | survives leaving/returning to the Références tab (`#tab-reference-new-citation`) |
| editor-keep-alive.test.tsx:300-326 | « Aller à » without focus move commits Références text | a tab click without focus move commits it (one undo entry): « Aller à » is not reachable from the Références tab in R2.1 |
| editor-keep-alive.test.tsx:333-347 | Escape in panel reference field commits, panel hides | same, panel opened from a finding node, field `#panel-reference-ref-1-citation` |
| editor-keep-alive.test.tsx:350-363 | header toggle (no focus move) closes after committing | scrim click (no focus move) closes after committing |
| editor-keep-alive.test.tsx:425 | `referencesButton` click in the all-places sweep | `Références` added to the tab loop |
| editor-escape.test.tsx:218-227 | header button toggle, Escape on body closes panel, annotation selection kept | trigger-opened panel (A5), Escape closes it, `aria-expanded` back to false, selection kept after returning to Annotations |
| editor-escape.test.tsx:255-266 | Escape from tab row closes panel | same from the Constats tab button |
| editor-no-loss.test.tsx:146-153 | reference creation form, in the panel | in the Références tab, id `tab-reference-new-citation` |
| editor-no-loss.test.tsx:285-291 | focused header button survives crossing | focused tab button (Constats) survives crossing: no header button left |
| editor-no-loss.test.tsx:293-307 | references search in panel keeps focus/text | same in the Références tab body |
| editor-no-loss.test.tsx:390-400 | `everyPlace` ends by opening the panel | visits Références in the tab loop, no panel open |
| editor-no-loss-decisions.test.tsx:248-259 | open references panel holds the decision back | REMOVED: the panel exists only over Constats, decisions live in Annotations (hidden then); « a widening on another tab opens nothing » (same file) covers the withholding |
| editor-route-recovery.test.tsx:93-97 | recovery offer: header button opens panel, `aria-labelledby` | tab Références shows `editor-tab-references` labelled by `editor-references-title` |
| editor-references-panel.test.tsx (all) | header-button-driven panel tests incl. search, order, add, « Aller à » | split: panel tests (finding path only) stay in this file; library tests moved to new editor-references-tab.test.tsx (search matching, ↑/↓ only without search, counts, Ctrl+Z, read-only, « Aller à », add clears search, refused add keeps it); new: reset signal, ids unique with both mounted (P14), P6 fallback under « Plus » |
e2e (updated only, not run):
| file:old line | old | new |
|---|---|---|
| editor-shell.spec.ts:95-108 | panel keeps form text, no id repeats | Références tab keeps form text (`#tab-reference-new-citation`), ids unique with the panel open |
| editor-shell.spec.ts:121-142 | open panel leaves header and tab row clickable (incl. header Références button, add form) | `openCitations`; header button target and form steps dropped |
| editor-shell-journeys.spec.ts:113-123 | four tabs, `old` list includes « Références » | five tabs, « Références » removed from the old-layout list |
| editor-shell-journeys.spec.ts:246-249 | Aller à reference -> panel visible, close | `place('references')` visible, tab Références selected, row focus key, no close |
| editor-shell-layout.spec.ts:84-103 | overflow on four tabs + panel over drawing | five tabs + `openCitations`/`closeCitations` |
| editor-shell-layout.spec.ts:54-63 | local `goToTab` | removed, uses `openTab` |
| editor-shell-layout.spec.ts:140-158 | canvas width without/with panel over the drawing | E1: width measured before open and after a P21 switch to Annotations, asserted equal |
| editor-shell-layout.spec.ts:161-189 | axe on four tabs + open panel | five tabs + citations panel |
| editor-shell-layout.spec.ts:~255-310 | keyboard order began with `header` (the Références button) | `header` dropped from both orders (no focusable header control while the draft is clean); panel test selects Annotations before walking to `side` |
| editor-access.spec.ts:150-152,191-194,219-220 | axe/overflow with the panel at 320/375/768/800, 1024, read-only | same checks through `openCitations` (`showDrawing` calls dropped) |
| editor-shell-crossing.spec.ts:194-206 | references form with panel open, tab `annotations` | in the tab, focus expected on `editor-tab-references` |
| editor-shell-crossing.spec.ts:264-282 | panel open + add-form text across crossing | citations panel over a crossing, no typed-text step |
| editor-shell-crossing.spec.ts:~385-410 | decision withheld while panel open, Reprendre | REMOVED (state unreachable, see unit row) |
| editor-deselect.spec.ts:226-229 | Escape closes header-opened panel, selection kept | opened via Constats, Escape, back to Annotations, selection kept |
| editor-structures.spec.ts:80-122 | two references added, counts 2/1 | shape now holds `ref-a`: counts 3/2, `nth(1)` after move, saved list `['Référence A','Seconde référence']`, no panel |
| editor-equine.spec.ts:304-305,404-405 | openReferences/closeReferences | `openTab(page, dict, 'references')`: mis à jour, non exécuté, non vérifié |
Fix round 1: 1. e2e/shell/editor-shell.spec.ts « the open citations panel leaves the header and the tab row clickable »: before `openCitations`, the test now opens the Références tab and adds a reference through the library form (`#tab-reference-new-type` book, `#tab-reference-new-citation` « Smith 1999 », « Ajouter la référence »), so the draft is dirty and Save is enabled. All original assertion
This commit is contained in:
1 parent
fc3fec7654
commit
4499bc740c
50 files changed
+1487
-917
No files matched your search
@@ -45,19 +45,15 @@ function Breadcrumb({
|
||||
}
|
||||
|
||||
/**
|
||||
* The draft's header: breadcrumb, title and badges, then the actions (references, the
|
||||
* save line, « Abandonner les modifications » and « Enregistrer » in edit mode).
|
||||
* The draft's header: breadcrumb, title and badges, then the actions (the save line,
|
||||
* « Abandonner les modifications » and « Enregistrer » in edit mode).
|
||||
*/
|
||||
export default function DraftHeader({
|
||||
sheet,
|
||||
mode,
|
||||
referencesOpen,
|
||||
onToggleReferences,
|
||||
}: {
|
||||
sheet: OfficialSheetAdmin
|
||||
mode: EditorMode
|
||||
referencesOpen: boolean
|
||||
onToggleReferences: (opener: HTMLElement) => void
|
||||
}) {
|
||||
const t = useT()
|
||||
const heading = usePageHeading()
|
||||
@@ -85,12 +81,7 @@ export default function DraftHeader({
|
||||
{t('editor.draft.read_only')}
|
||||
</Badge>
|
||||
)}
|
||||
<HeaderActions
|
||||
editable={mode === 'edit'}
|
||||
referencesOpen={referencesOpen}
|
||||
onToggleReferences={onToggleReferences}
|
||||
onFailure={setFailure}
|
||||
/>
|
||||
<HeaderActions editable={mode === 'edit'} onFailure={setFailure} />
|
||||
</div>
|
||||
{failure && <Notice tone="error">{failure}</Notice>}
|
||||
</header>
|
||||
|
||||
@@ -11,6 +11,7 @@ import KeptPlace from './KeptPlace'
|
||||
import AnnotationsTab from './tabs/AnnotationsTab'
|
||||
import FindingsTab from './tabs/FindingsTab'
|
||||
import GeneralTab from './tabs/GeneralTab'
|
||||
import ReferencesTab from './tabs/ReferencesTab'
|
||||
import VerificationTab from './tabs/VerificationTab'
|
||||
|
||||
const BODIES: Record<
|
||||
@@ -19,6 +20,7 @@ const BODIES: Record<
|
||||
> = {
|
||||
general: GeneralTab,
|
||||
findings: FindingsTab,
|
||||
references: ReferencesTab,
|
||||
verification: VerificationTab,
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ function TabList({ shown, active, onSelect }: TabListProps) {
|
||||
role="tablist"
|
||||
aria-label={t('editor.tab.list')}
|
||||
onKeyDown={onKeyDown}
|
||||
className="flex gap-1"
|
||||
className="flex flex-wrap gap-1"
|
||||
>
|
||||
{shown.map((tab) => (
|
||||
<button
|
||||
@@ -168,7 +168,8 @@ interface EditorTabsProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* The draft's tab row (boards 04 and 05): the four tabs from 640 px, Annotations and
|
||||
* The draft's tab row (boards 04 and 05): the five tabs from 640 px (the row may wrap
|
||||
* between 640 and 1 023 px, never scroll sideways), Annotations and
|
||||
* Vérification below it with « Plus » opening a disclosure of the others (no measurement).
|
||||
* « Défaire » and « Refaire » sit at the right end of the row on every tab.
|
||||
*/
|
||||
|
||||
@@ -2,11 +2,7 @@ import { useEffect, useRef, type ReactNode } from 'react'
|
||||
import type { OfficialSheetAdmin } from '@faunosteo/supabase'
|
||||
import Notice from '@/components/ui/Notice'
|
||||
import { ReadOnlyContext, ReferencesOpenContext } from '@/editor/editingContext'
|
||||
import {
|
||||
AnnounceContext,
|
||||
FocusConsumedContext,
|
||||
ownedBy,
|
||||
} from '@/editor/focusRequest'
|
||||
import { AnnounceContext, FocusConsumedContext } from '@/editor/focusRequest'
|
||||
import { saveFailureMessage } from '@/editor/messages'
|
||||
import type { EditorMode } from '@/editor/mode'
|
||||
import { useEditorStore } from '@/editor/state/editorStore'
|
||||
@@ -78,26 +74,25 @@ interface PlacesProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* Under the tab row: the tab panels and the references panel beside them. The container
|
||||
* starts after the tab row, so the panel and its scrim never cover the header or the tabs;
|
||||
* while the panel is open the tab panels are inert (the scrim sits over them).
|
||||
* Under the tab row: the tab panels and the citations panel of a finding beside them. The
|
||||
* container starts after the tab row, so the panel and its scrim never cover the header or
|
||||
* the tabs; while the panel is open the tab panels are inert (the scrim sits over them).
|
||||
*/
|
||||
function Places({ nav, readOnly, reloadSheet }: PlacesProps) {
|
||||
const { state } = nav
|
||||
const open = state.references.open
|
||||
const open = state.citationsOf !== null
|
||||
return (
|
||||
<div className={`relative ${open ? 'min-h-[calc(100dvh-3.5rem)]' : ''}`}>
|
||||
{state.referencesMounted && (
|
||||
{state.citationsOf && (
|
||||
<KeptPlace
|
||||
name="citations"
|
||||
visible={open}
|
||||
visible
|
||||
className="absolute bottom-0 right-0 top-0 z-20 w-[min(27rem,100%)]"
|
||||
>
|
||||
<ReferencesPanel
|
||||
readOnly={readOnly}
|
||||
focus={ownedBy(state.focus, 'citations')}
|
||||
onClose={nav.closeReferences}
|
||||
citedBy={state.references.citedBy}
|
||||
citedBy={state.citationsOf}
|
||||
onClose={nav.closeCitations}
|
||||
onShowAll={nav.showAllReferences}
|
||||
/>
|
||||
</KeptPlace>
|
||||
@@ -106,7 +101,7 @@ function Places({ nav, readOnly, reloadSheet }: PlacesProps) {
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-testid="references-scrim"
|
||||
onClick={nav.closeReferences}
|
||||
onClick={nav.closeCitations}
|
||||
className="absolute inset-0 z-10 bg-[rgba(31,27,22,0.25)]"
|
||||
/>
|
||||
)}
|
||||
@@ -116,6 +111,8 @@ function Places({ nav, readOnly, reloadSheet }: PlacesProps) {
|
||||
visited={state.visitedTabs}
|
||||
readOnly={readOnly}
|
||||
navigate={nav.navigate}
|
||||
openCitations={nav.openCitations}
|
||||
libraryReset={state.libraryReset}
|
||||
focus={state.focus}
|
||||
reloadSheet={reloadSheet}
|
||||
annotations={{
|
||||
@@ -132,7 +129,7 @@ function Places({ nav, readOnly, reloadSheet }: PlacesProps) {
|
||||
|
||||
/**
|
||||
* A keydown aimed at `body` (nothing focused) never reaches the workspace's own handler:
|
||||
* while the references panel is open, Escape there closes it all the same, unless a
|
||||
* while the citations panel is open, Escape there closes it all the same, unless a
|
||||
* modal dialog is open or the key was already handled.
|
||||
*/
|
||||
function useBodyEscape(open: boolean, close: () => void) {
|
||||
@@ -153,7 +150,7 @@ function useBodyEscape(open: boolean, close: () => void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The draft page once the version is ready: header, notices, tab row, the references
|
||||
* The draft page once the version is ready: header, notices, tab row, the citations
|
||||
* panel and the shown place. Owns the navigation state, so the first tab is known at
|
||||
* mount (`initialTab`) and later edits never move the user off their tab.
|
||||
*/
|
||||
@@ -163,35 +160,30 @@ export default function EditorWorkspace(props: Props) {
|
||||
const nav = useEditorNavigation(
|
||||
previewState ? initialTab(previewState, tier) : 'annotations',
|
||||
)
|
||||
const { state } = nav
|
||||
const toggleReferences = (opener: HTMLElement) =>
|
||||
state.references.open
|
||||
? nav.closeReferences()
|
||||
: nav.openReferences(null, opener)
|
||||
useBodyEscape(state.references.open, nav.closeReferences)
|
||||
const open = nav.state.citationsOf !== null
|
||||
useBodyEscape(open, nav.closeCitations)
|
||||
return (
|
||||
<EditingState readOnly={readOnly} referencesOpen={state.references.open}>
|
||||
<EditingState readOnly={readOnly} referencesOpen={open}>
|
||||
<div
|
||||
className="space-y-4"
|
||||
data-editor-workspace
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== 'Escape' || event.defaultPrevented) return
|
||||
if (event.nativeEvent.isComposing || !state.references.open) return
|
||||
if (event.nativeEvent.isComposing || !open) return
|
||||
event.preventDefault()
|
||||
nav.closeReferences()
|
||||
nav.closeCitations()
|
||||
}}
|
||||
>
|
||||
<DraftHeader
|
||||
sheet={sheet}
|
||||
mode={mode}
|
||||
referencesOpen={state.references.open}
|
||||
onToggleReferences={toggleReferences}
|
||||
/>
|
||||
<DraftHeader sheet={sheet} mode={mode} />
|
||||
<ModeNotice mode={mode} sheet={sheet} />
|
||||
<SaveFailureNotice />
|
||||
<RecoveryNotice />
|
||||
<CopyIssueNotice />
|
||||
<EditorTabs active={state.tab} tier={tier} onSelect={nav.selectTab} />
|
||||
<EditorTabs
|
||||
active={nav.state.tab}
|
||||
tier={tier}
|
||||
onSelect={nav.selectTab}
|
||||
/>
|
||||
<FocusConsumedContext value={nav.consumed}>
|
||||
<AnnounceContext value={nav.announce}>
|
||||
<Places nav={nav} readOnly={readOnly} reloadSheet={reloadSheet} />
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import Button from '@/components/ui/Button'
|
||||
import Icon from '@/components/ui/Icon'
|
||||
import { useEditorStore } from '@/editor/state/editorStore'
|
||||
import { REFERENCES_BUTTON_ID } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import DiscardButton from './DiscardButton'
|
||||
import SaveLine from './SaveLine'
|
||||
@@ -9,8 +7,6 @@ import SaveLine from './SaveLine'
|
||||
interface Props {
|
||||
/** Edit mode: « Abandonner » and « Enregistrer » are offered. */
|
||||
editable: boolean
|
||||
referencesOpen: boolean
|
||||
onToggleReferences: (opener: HTMLElement) => void
|
||||
/** A failed reload after a discard, worded for the notice under the header. */
|
||||
onFailure: (message: string | null) => void
|
||||
}
|
||||
@@ -31,26 +27,10 @@ function SaveButton() {
|
||||
)
|
||||
}
|
||||
|
||||
/** The right group of the header: references, the save line, discard and save. */
|
||||
/** The right group of the header: the save line, discard and save. */
|
||||
export default function HeaderActions(props: Props) {
|
||||
const t = useT()
|
||||
return (
|
||||
<div className="ml-auto flex flex-wrap items-center gap-2">
|
||||
<Button
|
||||
id={REFERENCES_BUTTON_ID}
|
||||
type="button"
|
||||
variant="secondary"
|
||||
aria-expanded={props.referencesOpen}
|
||||
aria-controls="editor-citations-panel"
|
||||
onClick={(event) => props.onToggleReferences(event.currentTarget)}
|
||||
>
|
||||
<Icon name="book" size={16} className="mr-2" />
|
||||
{t('editor.references.open')}
|
||||
</Button>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="hidden h-6 w-px bg-[var(--color-border)] sm:block"
|
||||
/>
|
||||
<SaveLine />
|
||||
{props.editable && (
|
||||
<>
|
||||
|
||||
@@ -236,12 +236,7 @@ export function UnmeasuredHint({
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={(event) =>
|
||||
navigate(
|
||||
targetOfKey({ kind: 'view', id: viewId }),
|
||||
event.currentTarget,
|
||||
)
|
||||
}
|
||||
onClick={() => navigate(targetOfKey({ kind: 'view', id: viewId }))}
|
||||
>
|
||||
{t('editor.place.views')}
|
||||
</button>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useContext } from 'react'
|
||||
import ActionButton from '@/components/editor/fields/ActionButton'
|
||||
import ReadOnlyValue from '@/components/editor/fields/ReadOnlyValue'
|
||||
import SelectField from '@/components/editor/fields/SelectField'
|
||||
import TextField from '@/components/editor/fields/TextField'
|
||||
import Icon from '@/components/ui/Icon'
|
||||
import { ReferencesOpenContext } from '@/editor/editingContext'
|
||||
import {
|
||||
patchElement,
|
||||
type FindingItem,
|
||||
@@ -18,6 +20,7 @@ interface ContentProps {
|
||||
item: FindingItem
|
||||
readOnly: boolean
|
||||
edit: EditCommandApi
|
||||
/** Opens the citations panel; given for a finding only, a family has no panel. */
|
||||
onShowReferences?: (opener: HTMLElement) => void
|
||||
}
|
||||
|
||||
@@ -45,7 +48,14 @@ export default function FindingContent(props: ContentProps) {
|
||||
patch={patch}
|
||||
/>
|
||||
)}
|
||||
<Citations {...props} ids={element.value.reference_ids} patch={patch} />
|
||||
<Citations
|
||||
{...props}
|
||||
ids={element.value.reference_ids}
|
||||
patch={patch}
|
||||
onShowReferences={
|
||||
element.kind === 'finding_node' ? props.onShowReferences : undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -119,6 +129,7 @@ function VetFlag({
|
||||
}
|
||||
|
||||
function Citations({
|
||||
item,
|
||||
readOnly,
|
||||
edit,
|
||||
ids,
|
||||
@@ -128,6 +139,7 @@ function Citations({
|
||||
const t = useT()
|
||||
const plural = usePlural()
|
||||
const doc = useSheetDocument()
|
||||
const panelOpen = useContext(ReferencesOpenContext)
|
||||
const references = doc?.references ?? []
|
||||
const citation = (id: string) =>
|
||||
references.find((r) => r.id === id)?.citation ?? id
|
||||
@@ -144,6 +156,9 @@ function Citations({
|
||||
{ids.length > 0 && onShowReferences && (
|
||||
<button
|
||||
type="button"
|
||||
data-citations-trigger={JSON.stringify(item.key)}
|
||||
aria-expanded={panelOpen}
|
||||
aria-controls="editor-citations-panel"
|
||||
onClick={(event) => onShowReferences(event.currentTarget)}
|
||||
className="inline-flex min-h-11 items-center gap-1 rounded-full border border-[var(--color-border)] px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]"
|
||||
>
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface FindingDetailProps {
|
||||
item: FindingItem
|
||||
readOnly: boolean
|
||||
onDelete: () => void
|
||||
/** Opens the references panel filtered to this element. */
|
||||
/** Opens the citations panel of this finding (a family has none). */
|
||||
onShowReferences?: (opener: HTMLElement) => void
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import SelectField from '@/components/editor/fields/SelectField'
|
||||
import { isBlank, nullable } from '@/editor/sheetDocument'
|
||||
import { useEditCommand } from '@/editor/useEditCommand'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { REFERENCE_TYPES } from './referenceTypes'
|
||||
import { REFERENCE_TYPES, type ReferenceHost } from './referenceTypes'
|
||||
|
||||
const EMPTY = { type: '', citation: '', url: '', doi: '' }
|
||||
|
||||
@@ -14,7 +14,13 @@ const EMPTY = { type: '', citation: '', url: '', doi: '' }
|
||||
* Adds a reference: the type and the citation are required, URL and DOI optional.
|
||||
* `onAdded` runs after a successful add, so the list can show the new reference.
|
||||
*/
|
||||
export default function ReferenceForm({ onAdded }: { onAdded?: () => void }) {
|
||||
export default function ReferenceForm({
|
||||
host,
|
||||
onAdded,
|
||||
}: {
|
||||
host: ReferenceHost
|
||||
onAdded?: () => void
|
||||
}) {
|
||||
const t = useT()
|
||||
const edit = useEditCommand()
|
||||
const [form, setForm] = useState(EMPTY)
|
||||
@@ -53,27 +59,27 @@ export default function ReferenceForm({ onAdded }: { onAdded?: () => void }) {
|
||||
<p className="text-sm font-medium">{t('editor.reference.new')}</p>
|
||||
<div className="grid gap-3">
|
||||
<SelectField
|
||||
id="reference-new-type"
|
||||
id={`${host}-reference-new-type`}
|
||||
label={t('editor.reference.type')}
|
||||
value={form.type}
|
||||
options={options}
|
||||
onCommit={(type) => set({ type })}
|
||||
/>
|
||||
<DraftField
|
||||
id="reference-new-citation"
|
||||
id={`${host}-reference-new-citation`}
|
||||
label={t('editor.reference.citation')}
|
||||
value={form.citation}
|
||||
onChange={(citation) => set({ citation })}
|
||||
multiline
|
||||
/>
|
||||
<DraftField
|
||||
id="reference-new-url"
|
||||
id={`${host}-reference-new-url`}
|
||||
label={t('editor.reference.url')}
|
||||
value={form.url}
|
||||
onChange={(url) => set({ url })}
|
||||
/>
|
||||
<DraftField
|
||||
id="reference-new-doi"
|
||||
id={`${host}-reference-new-doi`}
|
||||
label={t('editor.reference.doi')}
|
||||
value={form.doi}
|
||||
onChange={(doi) => set({ doi })}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { ElementKey, Reference } from '@faunosteo/core-wasm/types'
|
||||
import DeleteDialog, {
|
||||
type DeleteTarget,
|
||||
} from '@/components/editor/DeleteDialog'
|
||||
import EditOnly from '@/components/editor/EditOnly'
|
||||
import Input from '@/components/ui/Input'
|
||||
import {
|
||||
focusRow,
|
||||
useFocusRequest,
|
||||
type FocusRequest,
|
||||
} from '@/editor/focusRequest'
|
||||
import { citationCounts } from '@/editor/references/citations'
|
||||
import { visibleReferences } from '@/editor/references/filter'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import ReferenceForm from './ReferenceForm'
|
||||
import { EmptyLine, ReferenceList } from './ReferenceList'
|
||||
|
||||
interface Props {
|
||||
readOnly: boolean
|
||||
focus?: FocusRequest
|
||||
/** Bumped by « Tout afficher »: the search is emptied once per bump. */
|
||||
resetSignal?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* « Aller à » a reference: the search is cleared first when it may hide the card, and the
|
||||
* card is focused after the commit that shows it (it does not exist while hidden).
|
||||
*/
|
||||
function useReferenceFocus(
|
||||
focus: FocusRequest | undefined,
|
||||
query: string,
|
||||
clearQuery: () => void,
|
||||
) {
|
||||
const [late, setLate] = useState<ElementKey | null>(null)
|
||||
useEffect(() => {
|
||||
if (late === null) return
|
||||
focusRow(late)
|
||||
setLate(null)
|
||||
}, [late])
|
||||
useFocusRequest(focus, (target) => {
|
||||
if (target.key === null) return 'none'
|
||||
if (query === '') return focusRow(target.key) ? 'found' : 'none'
|
||||
clearQuery()
|
||||
setLate(target.key)
|
||||
return 'found'
|
||||
})
|
||||
}
|
||||
|
||||
/** The search text, emptied each time `resetSignal` changes (the tab stays mounted). */
|
||||
function useSearchQuery(resetSignal: number) {
|
||||
const [query, setQuery] = useState('')
|
||||
const [seen, setSeen] = useState(resetSignal)
|
||||
if (seen !== resetSignal) {
|
||||
setSeen(resetSignal)
|
||||
setQuery('')
|
||||
}
|
||||
return [query, setQuery] as const
|
||||
}
|
||||
|
||||
/**
|
||||
* The sheet's bibliography: a search, one card per reference with how often it is cited,
|
||||
* the add form and the delete dialog. Lives in the Références tab (ids prefixed `tab-`).
|
||||
*/
|
||||
export default function ReferenceLibrary({
|
||||
readOnly,
|
||||
focus,
|
||||
resetSignal = 0,
|
||||
}: Props) {
|
||||
const t = useT()
|
||||
const doc = useSheetDocument()
|
||||
const [query, setQuery] = useSearchQuery(resetSignal)
|
||||
const [deleting, setDeleting] = useState<DeleteTarget | null>(null)
|
||||
useReferenceFocus(focus, query, () => setQuery(''))
|
||||
const all: readonly Reference[] = doc?.references ?? []
|
||||
const shown = visibleReferences(all, null, query)
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<Input
|
||||
type="search"
|
||||
aria-label={t('editor.references.search')}
|
||||
placeholder={t('editor.references.search')}
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
/>
|
||||
{doc && (
|
||||
<>
|
||||
<EmptyLine total={all.length} shown={shown.length} />
|
||||
<ReferenceList
|
||||
host="tab"
|
||||
shown={shown}
|
||||
all={all}
|
||||
counts={citationCounts(doc)}
|
||||
movable={query.trim() === ''}
|
||||
readOnly={readOnly}
|
||||
onDelete={(reference) =>
|
||||
setDeleting({
|
||||
key: { kind: 'reference', id: reference.id },
|
||||
label: reference.citation,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<EditOnly readOnly={readOnly}>
|
||||
<ReferenceForm host="tab" onAdded={() => setQuery('')} />
|
||||
</EditOnly>
|
||||
</>
|
||||
)}
|
||||
<DeleteDialog target={deleting} onClose={() => setDeleting(null)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { Reference } from '@faunosteo/core-wasm/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import ReferenceRow from './ReferenceRow'
|
||||
import type { ReferenceHost } from './referenceTypes'
|
||||
|
||||
interface ListProps {
|
||||
host: ReferenceHost
|
||||
shown: readonly Reference[]
|
||||
all: readonly Reference[]
|
||||
counts: ReadonlyMap<string, number>
|
||||
movable: boolean
|
||||
readOnly: boolean
|
||||
onDelete: (reference: Reference) => void
|
||||
}
|
||||
|
||||
/** The cards of `shown`, each knowing its place in the whole bibliography `all`. */
|
||||
export function ReferenceList({ shown, all, counts, ...rest }: ListProps) {
|
||||
return (
|
||||
<ul className="space-y-3">
|
||||
{shown.map((reference) => (
|
||||
<ReferenceRow
|
||||
key={reference.id}
|
||||
host={rest.host}
|
||||
reference={reference}
|
||||
index={all.indexOf(reference)}
|
||||
count={all.length}
|
||||
cited={counts.get(reference.id) ?? 0}
|
||||
movable={rest.movable}
|
||||
readOnly={rest.readOnly}
|
||||
onDelete={() => rest.onDelete(reference)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
/** The empty line: no reference at all, or none that matches. */
|
||||
export function EmptyLine({ total, shown }: { total: number; shown: number }) {
|
||||
const t = useT()
|
||||
if (shown > 0) return null
|
||||
const key =
|
||||
total === 0 ? 'editor.reference.empty' : 'editor.references.no_match'
|
||||
return <p className="text-sm text-[var(--color-ink-muted)]">{t(key)}</p>
|
||||
}
|
||||
@@ -8,12 +8,13 @@ import { isBlank, nullable } from '@/editor/sheetDocument'
|
||||
import { useEditCommand } from '@/editor/useEditCommand'
|
||||
import { usePlural } from '@/editor/plural'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { REFERENCE_TYPES } from './referenceTypes'
|
||||
import { REFERENCE_TYPES, type ReferenceHost } from './referenceTypes'
|
||||
|
||||
const CARD = 'space-y-3 rounded-lg border border-[var(--color-border)] p-3'
|
||||
|
||||
/** One reference: fields commit one by one, ↑ / ↓ reorder, delete asks the core. */
|
||||
export default function ReferenceRow({
|
||||
host,
|
||||
reference,
|
||||
index,
|
||||
count,
|
||||
@@ -22,6 +23,8 @@ export default function ReferenceRow({
|
||||
readOnly,
|
||||
onDelete,
|
||||
}: {
|
||||
/** The place showing the row: its field ids carry it, both can be mounted at once. */
|
||||
host: ReferenceHost
|
||||
reference: Reference
|
||||
/** Position in the whole bibliography, not in a filtered list. */
|
||||
index: number
|
||||
@@ -47,7 +50,7 @@ export default function ReferenceRow({
|
||||
value: type,
|
||||
label: t(`editor.reference.type.${type}`),
|
||||
}))
|
||||
const prefix = `reference-${reference.id}`
|
||||
const prefix = `${host}-reference-${reference.id}`
|
||||
return (
|
||||
<li {...focusAttrs(key)} className={`${CARD} ${FOCUS_CLASS}`}>
|
||||
<p className="text-right text-sm text-[var(--color-ink-muted)]">
|
||||
|
||||
@@ -1,67 +1,28 @@
|
||||
import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type KeyboardEvent,
|
||||
type RefObject,
|
||||
} from 'react'
|
||||
import type { ElementKey, Reference } from '@faunosteo/core-wasm/types'
|
||||
import { useEffect, useMemo, useState, type KeyboardEvent } from 'react'
|
||||
import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import DeleteDialog, {
|
||||
type DeleteTarget,
|
||||
} from '@/components/editor/DeleteDialog'
|
||||
import EditOnly from '@/components/editor/EditOnly'
|
||||
import ReferenceForm from '@/components/editor/references/ReferenceForm'
|
||||
import ReferenceRow from '@/components/editor/references/ReferenceRow'
|
||||
import Icon from '@/components/ui/Icon'
|
||||
import Input from '@/components/ui/Input'
|
||||
import {
|
||||
focusRow,
|
||||
useFocusRequest,
|
||||
type FocusRequest,
|
||||
} from '@/editor/focusRequest'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { citationCounts } from '@/editor/references/citations'
|
||||
import {
|
||||
citedIds,
|
||||
citingFinding,
|
||||
visibleReferences,
|
||||
} from '@/editor/references/filter'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import { useLocaleStore } from '@/state/localeStore'
|
||||
import { ReferenceList } from './ReferenceList'
|
||||
|
||||
interface Props {
|
||||
readOnly: boolean
|
||||
focus?: FocusRequest
|
||||
/** The finding whose citations the panel lists. */
|
||||
citedBy: ElementKey
|
||||
/** ✕, Escape, and the finding vanishing (deleted, or an undo removed it). */
|
||||
onClose: () => void
|
||||
/** The finding the list is filtered to (opened from its detail), if any. */
|
||||
citedBy?: ElementKey | null
|
||||
/** « Tout afficher »: drops the filter. */
|
||||
onShowAll?: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
* « Aller à » a reference: the search is cleared first when it may hide the card, and the
|
||||
* card is focused after the commit that shows it (it does not exist while hidden).
|
||||
*/
|
||||
function useReferenceFocus(
|
||||
focus: FocusRequest | undefined,
|
||||
query: string,
|
||||
clearQuery: () => void,
|
||||
) {
|
||||
const [late, setLate] = useState<ElementKey | null>(null)
|
||||
useEffect(() => {
|
||||
if (late === null) return
|
||||
focusRow(late)
|
||||
setLate(null)
|
||||
}, [late])
|
||||
useFocusRequest(focus, (target) => {
|
||||
if (target.key === null) return 'none'
|
||||
if (query === '') return focusRow(target.key) ? 'found' : 'none'
|
||||
clearQuery()
|
||||
setLate(target.key)
|
||||
return 'found'
|
||||
})
|
||||
/** « Tout afficher »: closes the panel and opens the Références tab. */
|
||||
onShowAll: () => void
|
||||
}
|
||||
|
||||
function PanelHeader({ onClose }: { onClose: () => void }) {
|
||||
@@ -89,7 +50,7 @@ function PanelHeader({ onClose }: { onClose: () => void }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** The finding filter: « Citées par « nom » (n) » and « Tout afficher (N) ». */
|
||||
/** « Citées par « nom » (n) » and « Tout afficher (N) ». */
|
||||
function FilterChip({
|
||||
name,
|
||||
cited,
|
||||
@@ -124,112 +85,32 @@ function FilterChip({
|
||||
)
|
||||
}
|
||||
|
||||
function SearchField({
|
||||
value,
|
||||
onChange,
|
||||
inputRef,
|
||||
}: {
|
||||
value: string
|
||||
onChange: (value: string) => void
|
||||
inputRef: RefObject<HTMLInputElement | null>
|
||||
}) {
|
||||
const t = useT()
|
||||
return (
|
||||
<Input
|
||||
ref={inputRef}
|
||||
type="search"
|
||||
aria-label={t('editor.references.search')}
|
||||
placeholder={t('editor.references.search')}
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
interface ListProps {
|
||||
shown: readonly Reference[]
|
||||
all: readonly Reference[]
|
||||
counts: ReadonlyMap<string, number>
|
||||
movable: boolean
|
||||
readOnly: boolean
|
||||
onDelete: (reference: Reference) => void
|
||||
}
|
||||
|
||||
function ReferenceList({ shown, all, counts, ...rest }: ListProps) {
|
||||
return (
|
||||
<ul className="space-y-3">
|
||||
{shown.map((reference) => (
|
||||
<ReferenceRow
|
||||
key={reference.id}
|
||||
reference={reference}
|
||||
index={all.indexOf(reference)}
|
||||
count={all.length}
|
||||
cited={counts.get(reference.id) ?? 0}
|
||||
movable={rest.movable}
|
||||
readOnly={rest.readOnly}
|
||||
onDelete={() => rest.onDelete(reference)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
/** What the list shows: the finding filter (dropped once the finding is gone) and the query. */
|
||||
function useShownReferences(
|
||||
citedBy: ElementKey | null,
|
||||
query: string,
|
||||
onShowAll: (() => void) | undefined,
|
||||
) {
|
||||
/** The finding read from the current document; `gone` once the document lacks it. */
|
||||
function useCitingFinding(citedBy: ElementKey, onGone: () => void) {
|
||||
const doc = useSheetDocument()
|
||||
const finding = useMemo(
|
||||
() => (doc ? citingFinding(doc, citedBy) : null),
|
||||
[doc, citedBy],
|
||||
)
|
||||
const gone = doc !== null && citedBy !== null && finding === null
|
||||
const gone = doc !== null && finding === null
|
||||
useEffect(() => {
|
||||
if (gone) onShowAll?.()
|
||||
}, [gone, onShowAll])
|
||||
const all = doc?.references ?? []
|
||||
const cited = finding ? citedIds(finding) : null
|
||||
const shown = visibleReferences(all, cited, query)
|
||||
return { doc, finding, all, cited, shown }
|
||||
}
|
||||
|
||||
/** The empty line: no reference at all, or none that matches. */
|
||||
function EmptyLine({ total, shown }: { total: number; shown: number }) {
|
||||
const t = useT()
|
||||
if (shown > 0) return null
|
||||
const key =
|
||||
total === 0 ? 'editor.reference.empty' : 'editor.references.no_match'
|
||||
return <p className="text-sm text-[var(--color-ink-muted)]">{t(key)}</p>
|
||||
if (gone) onGone()
|
||||
}, [gone, onGone])
|
||||
return { doc, finding }
|
||||
}
|
||||
|
||||
/**
|
||||
* The references side panel: the sheet's bibliography, filtered to the finding that opened
|
||||
* it or searched, each reference with how often it is cited. Not a dialog: the page stays
|
||||
* usable. The workspace mounts it at the first opening and keeps it (hidden) afterwards.
|
||||
* The citations of one finding: the references it cites, each with how often it is cited.
|
||||
* Not a dialog: the workspace makes the page behind it inert. Opened only from a finding's
|
||||
* trigger; the whole library lives in the Références tab.
|
||||
*/
|
||||
export default function ReferencesPanel(props: Props) {
|
||||
const { readOnly, focus, onClose, citedBy = null, onShowAll } = props
|
||||
const { readOnly, citedBy, onClose, onShowAll } = props
|
||||
const locale = useLocaleStore((s) => s.locale)
|
||||
const searchRef = useRef<HTMLInputElement>(null)
|
||||
const [query, setQuery] = useState('')
|
||||
const [deleting, setDeleting] = useState<DeleteTarget | null>(null)
|
||||
useReferenceFocus(focus, query, () => setQuery(''))
|
||||
const { doc, finding, all, cited, shown } = useShownReferences(
|
||||
citedBy,
|
||||
query,
|
||||
onShowAll,
|
||||
)
|
||||
const showAll = () => {
|
||||
onShowAll?.()
|
||||
searchRef.current?.focus()
|
||||
}
|
||||
// A new reference is neither cited by the filtered finding nor named by the search.
|
||||
const showAdded = () => {
|
||||
setQuery('')
|
||||
if (citedBy !== null) onShowAll?.()
|
||||
}
|
||||
const { doc, finding } = useCitingFinding(citedBy, onClose)
|
||||
const all = doc?.references ?? []
|
||||
const cited = finding ? citedIds(finding) : []
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key !== 'Escape' || event.defaultPrevented) return
|
||||
event.stopPropagation()
|
||||
@@ -244,35 +125,29 @@ export default function ReferencesPanel(props: Props) {
|
||||
className="sticky top-14 h-[calc(100dvh-3.5rem)] space-y-3 overflow-y-auto border-l border-[var(--color-border)] bg-[var(--color-surface)] p-4 shadow-xl"
|
||||
>
|
||||
<PanelHeader onClose={onClose} />
|
||||
{finding && cited && (
|
||||
{finding && (
|
||||
<FilterChip
|
||||
name={finding.name[locale]}
|
||||
cited={cited.length}
|
||||
total={all.length}
|
||||
onShowAll={showAll}
|
||||
onShowAll={onShowAll}
|
||||
/>
|
||||
)}
|
||||
<SearchField value={query} onChange={setQuery} inputRef={searchRef} />
|
||||
{doc && (
|
||||
<>
|
||||
<EmptyLine total={all.length} shown={shown.length} />
|
||||
<ReferenceList
|
||||
shown={shown}
|
||||
all={all}
|
||||
counts={citationCounts(doc)}
|
||||
movable={cited === null && query.trim() === ''}
|
||||
readOnly={readOnly}
|
||||
onDelete={(reference) =>
|
||||
setDeleting({
|
||||
key: { kind: 'reference', id: reference.id },
|
||||
label: reference.citation,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<EditOnly readOnly={readOnly}>
|
||||
<ReferenceForm onAdded={showAdded} />
|
||||
</EditOnly>
|
||||
</>
|
||||
<ReferenceList
|
||||
host="panel"
|
||||
shown={visibleReferences(all, cited, '')}
|
||||
all={all}
|
||||
counts={citationCounts(doc)}
|
||||
movable={false}
|
||||
readOnly={readOnly}
|
||||
onDelete={(reference) =>
|
||||
setDeleting({
|
||||
key: { kind: 'reference', id: reference.id },
|
||||
label: reference.citation,
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<DeleteDialog target={deleting} onClose={() => setDeleting(null)} />
|
||||
</section>
|
||||
|
||||
@@ -8,3 +8,6 @@ export const REFERENCE_TYPES: readonly ReferenceType[] = [
|
||||
'web',
|
||||
'manual',
|
||||
]
|
||||
|
||||
/** Where reference cards are shown: the Références tab or a finding's citations panel. */
|
||||
export type ReferenceHost = 'tab' | 'panel'
|
||||
@@ -64,7 +64,7 @@ function useFindingDeletion(
|
||||
export default function FindingsTab({
|
||||
readOnly,
|
||||
focus,
|
||||
navigate,
|
||||
openCitations,
|
||||
}: EditorPlaceProps) {
|
||||
const t = useT()
|
||||
const doc = useSheetDocument()
|
||||
@@ -155,11 +155,8 @@ export default function FindingsTab({
|
||||
item={selected}
|
||||
readOnly={readOnly}
|
||||
onDelete={() => askDelete(selected)}
|
||||
onShowReferences={(opener) =>
|
||||
navigate(
|
||||
{ place: 'references', key: null, citedBy: selected.key },
|
||||
opener,
|
||||
)
|
||||
onShowReferences={
|
||||
openCitations && ((opener) => openCitations(selected.key, opener))
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import ReferenceLibrary from '@/components/editor/references/ReferenceLibrary'
|
||||
import type { EditorPlaceProps } from '@/editor/tabs'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
/** The fifth tab: the sheet's reference library under its own heading. */
|
||||
export default function ReferencesTab({
|
||||
readOnly,
|
||||
focus,
|
||||
libraryReset,
|
||||
}: EditorPlaceProps) {
|
||||
const t = useT()
|
||||
return (
|
||||
<section
|
||||
data-testid="editor-tab-references"
|
||||
aria-labelledby="editor-references-title"
|
||||
className="min-h-24 space-y-3"
|
||||
>
|
||||
<h2
|
||||
id="editor-references-title"
|
||||
tabIndex={-1}
|
||||
data-place-heading
|
||||
className="font-serif text-xl outline-none"
|
||||
>
|
||||
{t('editor.tab.references')}
|
||||
</h2>
|
||||
<ReferenceLibrary
|
||||
readOnly={readOnly}
|
||||
focus={focus}
|
||||
resetSignal={libraryReset}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -44,9 +44,7 @@ export default function IssueList({
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="mt-2"
|
||||
onClick={(event) =>
|
||||
navigate(target.target, event.currentTarget)
|
||||
}
|
||||
onClick={() => navigate(target.target)}
|
||||
>
|
||||
{t('editor.verification.goto').replace(
|
||||
'{tab}',
|
||||
|
||||
@@ -4,7 +4,7 @@ import { usePlaceVisible } from '@/lib/placeVisibility'
|
||||
/** The editor cannot be edited now (route rule: mode, recovery, store not in step). */
|
||||
export const ReadOnlyContext = createContext(false)
|
||||
|
||||
/** The references panel is open: a place beside it is not where a modal may open. */
|
||||
/** The citations panel is open: a place beside it is not where a modal may open. */
|
||||
export const ReferencesOpenContext = createContext(false)
|
||||
|
||||
export function useEditorReadOnly(): boolean {
|
||||
@@ -13,7 +13,7 @@ export function useEditorReadOnly(): boolean {
|
||||
|
||||
/**
|
||||
* Whether a decision dialog of a kept part may open: only while editing, in a shown
|
||||
* place, with the references panel closed, so no native modal ever sits inside a hidden
|
||||
* place, with the citations panel closed, so no native modal ever sits inside a hidden
|
||||
* subtree and focus is never lost to `body`.
|
||||
*/
|
||||
export function useDecisionsOpen(): boolean {
|
||||
|
||||
@@ -15,14 +15,16 @@ export type { FocusRequest }
|
||||
*/
|
||||
export type FocusOutcome = 'found' | 'kept' | 'none'
|
||||
|
||||
/** The `data-place` name of the place a target shows. */
|
||||
/**
|
||||
* The `data-place` name of a place. `citations` (the panel) is no navigation target: it
|
||||
* is a name only for its heading and its focus scope.
|
||||
*/
|
||||
export type PlaceName =
|
||||
| EditorTabId
|
||||
| `annotations.${AnnotationSection}`
|
||||
| 'citations'
|
||||
|
||||
export function placeOf(target: EditorTarget): PlaceName {
|
||||
if (target.place === 'references') return 'citations'
|
||||
if (target.tab !== 'annotations') return target.tab
|
||||
return `annotations.${target.section ?? 'drawing'}`
|
||||
}
|
||||
@@ -74,10 +76,16 @@ export function useFocusRequest(
|
||||
}, [focus, apply, consumed])
|
||||
}
|
||||
|
||||
/** The first element matching `selector` that no hidden place contains. */
|
||||
export function visibleElement(selector: string): HTMLElement | null {
|
||||
/** The first element matching `selector` (and `accept`) that no hidden place contains. */
|
||||
export function visibleElement(
|
||||
selector: string,
|
||||
accept: (element: HTMLElement) => boolean = () => true,
|
||||
): HTMLElement | null {
|
||||
const found = [...document.querySelectorAll<HTMLElement>(selector)]
|
||||
return found.find((element) => !element.closest('[hidden]')) ?? null
|
||||
return (
|
||||
found.find((element) => !element.closest('[hidden]') && accept(element)) ??
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
/** Scrolls to and focuses the visible row tagged with `key`; false when there is none. */
|
||||
@@ -117,7 +125,8 @@ const NON_TEXT_INPUTS = new Set([
|
||||
|
||||
/** A field that takes typed text (or a choice): Escape there belongs to the field. */
|
||||
export function isTextField(target: EventTarget | null): boolean {
|
||||
if (target instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(target.type)
|
||||
if (target instanceof HTMLInputElement)
|
||||
return !NON_TEXT_INPUTS.has(target.type)
|
||||
return (
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement ||
|
||||
|
||||
@@ -9,15 +9,16 @@ export const ANNOTATION_SECTIONS = [
|
||||
] as const
|
||||
export type AnnotationSection = (typeof ANNOTATION_SECTIONS)[number]
|
||||
|
||||
/** One encoding: a target on Annotations always names its section, null elsewhere. */
|
||||
export type EditorTarget =
|
||||
| {
|
||||
place: 'tab'
|
||||
tab: EditorTabId
|
||||
section: AnnotationSection | null
|
||||
key: ElementKey | null
|
||||
}
|
||||
| { place: 'references'; key: ElementKey | null; citedBy: ElementKey | null }
|
||||
/**
|
||||
* One encoding: a target on Annotations always names its section, null elsewhere. The
|
||||
* citations panel is no place to go to: it opens only through `open_citations`.
|
||||
*/
|
||||
export interface EditorTarget {
|
||||
place: 'tab'
|
||||
tab: EditorTabId
|
||||
section: AnnotationSection | null
|
||||
key: ElementKey | null
|
||||
}
|
||||
|
||||
/** « Aller à … »: the place to show and a serial so each request is consumed once. */
|
||||
export interface FocusRequest {
|
||||
@@ -28,11 +29,13 @@ export interface FocusRequest {
|
||||
export interface NavigationState {
|
||||
tab: EditorTabId
|
||||
section: AnnotationSection
|
||||
references: { open: boolean; citedBy: ElementKey | null }
|
||||
/** The finding whose citations panel is open; null while it is closed. */
|
||||
citationsOf: ElementKey | null
|
||||
/** Bumped by `show_all_references`: the library resets its search once per bump. */
|
||||
libraryReset: number
|
||||
/** Places already shown, so a body mounts on first visit and stays mounted. */
|
||||
visitedTabs: readonly EditorTabId[]
|
||||
visitedSections: readonly AnnotationSection[]
|
||||
referencesMounted: boolean
|
||||
focus: FocusRequest | undefined
|
||||
/** Last serial issued: it survives `focus_consumed`, so a serial is never reused. */
|
||||
serial: number
|
||||
@@ -42,9 +45,9 @@ export type NavigationAction =
|
||||
| { type: 'select_tab'; tab: EditorTabId }
|
||||
| { type: 'open_section'; section: AnnotationSection }
|
||||
| { type: 'back_to_drawing' }
|
||||
| { type: 'open_references'; citedBy: ElementKey | null }
|
||||
| { type: 'close_references' }
|
||||
| { type: 'clear_cited_by' }
|
||||
| { type: 'open_citations'; citedBy: ElementKey }
|
||||
| { type: 'close_citations' }
|
||||
| { type: 'show_all_references' }
|
||||
| { type: 'go_to'; target: EditorTarget }
|
||||
| { type: 'focus_consumed'; serial: number }
|
||||
|
||||
@@ -69,7 +72,7 @@ export function targetOfKey(key: ElementKey): EditorTarget {
|
||||
case 'finding':
|
||||
return { place: 'tab', tab: TAB_OF_KIND[key.kind], section: null, key }
|
||||
case 'reference':
|
||||
return { place: 'references', key, citedBy: null }
|
||||
return { place: 'tab', tab: 'references', section: null, key }
|
||||
default:
|
||||
return {
|
||||
place: 'tab',
|
||||
@@ -98,57 +101,69 @@ export function initialNavigation(tab: EditorTabId): NavigationState {
|
||||
return shown({
|
||||
tab,
|
||||
section: 'drawing',
|
||||
references: { open: false, citedBy: null },
|
||||
citationsOf: null,
|
||||
libraryReset: 0,
|
||||
visitedTabs: [],
|
||||
visitedSections: [],
|
||||
referencesMounted: false,
|
||||
focus: undefined,
|
||||
serial: 0,
|
||||
})
|
||||
}
|
||||
|
||||
function openReferences(state: NavigationState, citedBy: ElementKey | null) {
|
||||
return {
|
||||
...state,
|
||||
references: { open: true, citedBy },
|
||||
referencesMounted: true,
|
||||
}
|
||||
/**
|
||||
* A finding node (kind `finding` below its family, path of two or more ids). A zone and a
|
||||
* family list their citations inline and have no panel.
|
||||
*/
|
||||
export function isFindingNode(key: ElementKey): boolean {
|
||||
return key.kind === 'finding' && key.path.length > 1
|
||||
}
|
||||
|
||||
/** Only a finding node has a citations panel: any other key leaves the state as it is. */
|
||||
function openCitations(state: NavigationState, citedBy: ElementKey) {
|
||||
return isFindingNode(citedBy) ? { ...state, citationsOf: citedBy } : state
|
||||
}
|
||||
|
||||
function goTo(state: NavigationState, target: EditorTarget): NavigationState {
|
||||
const serial = state.serial + 1
|
||||
const focus = { target, serial }
|
||||
if (target.place === 'references') {
|
||||
return { ...openReferences(state, target.citedBy), focus, serial }
|
||||
}
|
||||
const moved = {
|
||||
...state,
|
||||
tab: target.tab,
|
||||
section: target.section ?? state.section,
|
||||
references: { open: false, citedBy: null },
|
||||
focus,
|
||||
citationsOf: null,
|
||||
focus: { target, serial },
|
||||
serial,
|
||||
}
|
||||
return shown(moved)
|
||||
}
|
||||
|
||||
/** « Tout afficher dans l'onglet Références »: the panel closes, the library starts afresh. */
|
||||
function showAllReferences(state: NavigationState): NavigationState {
|
||||
const moved = {
|
||||
...state,
|
||||
tab: 'references' as const,
|
||||
citationsOf: null,
|
||||
libraryReset: state.libraryReset + 1,
|
||||
}
|
||||
return shown(moved)
|
||||
}
|
||||
|
||||
export function navigationReducer(
|
||||
state: NavigationState,
|
||||
action: NavigationAction,
|
||||
): NavigationState {
|
||||
switch (action.type) {
|
||||
case 'select_tab':
|
||||
return shown({ ...state, tab: action.tab })
|
||||
return shown({ ...state, tab: action.tab, citationsOf: null })
|
||||
case 'open_section':
|
||||
return shown({ ...state, section: action.section })
|
||||
case 'back_to_drawing':
|
||||
return shown({ ...state, section: 'drawing' })
|
||||
case 'open_references':
|
||||
return openReferences(state, action.citedBy)
|
||||
case 'close_references':
|
||||
return { ...state, references: { open: false, citedBy: null } }
|
||||
case 'clear_cited_by':
|
||||
return { ...state, references: { ...state.references, citedBy: null } }
|
||||
case 'open_citations':
|
||||
return openCitations(state, action.citedBy)
|
||||
case 'close_citations':
|
||||
return { ...state, citationsOf: null }
|
||||
case 'show_all_references':
|
||||
return showAllReferences(state)
|
||||
case 'go_to':
|
||||
return goTo(state, action.target)
|
||||
case 'focus_consumed':
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PreviewState } from '@faunosteo/core-wasm/types'
|
||||
import type { ElementKey, PreviewState } from '@faunosteo/core-wasm/types'
|
||||
import type { EditorTarget, FocusRequest } from './navigation'
|
||||
import { unmeasuredViews } from './issues'
|
||||
import type { TabTier } from './useViewport'
|
||||
@@ -7,6 +7,7 @@ export const EDITOR_TABS = [
|
||||
'general',
|
||||
'annotations',
|
||||
'findings',
|
||||
'references',
|
||||
'verification',
|
||||
] as const
|
||||
export type EditorTabId = (typeof EDITOR_TABS)[number]
|
||||
@@ -37,14 +38,18 @@ export function initialTab(state: PreviewState, tier: TabTier): EditorTabId {
|
||||
return SHOWN[tier].includes(wanted) ? wanted : 'annotations'
|
||||
}
|
||||
|
||||
/** Props of every place (tab body, Annotations section, references panel). */
|
||||
/** Props of every place (tab body, Annotations section). */
|
||||
export interface EditorPlaceProps {
|
||||
/** Not editable now: a mode that cannot save, or a recovery offer not answered yet. */
|
||||
readOnly: boolean
|
||||
/** « Aller à … » and any link between places; `opener` takes the focus back on return. */
|
||||
navigate: (target: EditorTarget, opener?: HTMLElement | null) => void
|
||||
/** « Aller à … » and any link between places. */
|
||||
navigate: (target: EditorTarget) => void
|
||||
/** « Aller à … » with an element: the place seeds its own selection from it once. */
|
||||
focus?: FocusRequest
|
||||
/** Opens the citations panel of one finding (only Constats offers it). */
|
||||
openCitations?: (citedBy: ElementKey, opener?: HTMLElement | null) => void
|
||||
/** Bumped by « Tout afficher »: the references library resets its search once per bump. */
|
||||
libraryReset?: number
|
||||
/** Reads the sheet's overview again (after a submission: the round freezes the draft). */
|
||||
reloadSheet: () => void
|
||||
}
|
||||
@@ -53,5 +58,3 @@ export const tabDomId = (tab: EditorTabId) => `editor-tab-${tab}`
|
||||
export const panelDomId = (tab: EditorTabId) => `editor-panel-${tab}`
|
||||
/** The « Plus » disclosure button, focused when the active tab sits under it. */
|
||||
export const MORE_BUTTON_ID = 'editor-tabs-more-button'
|
||||
/** The header button that toggles the references panel. */
|
||||
export const REFERENCES_BUTTON_ID = 'editor-references-button'
|
||||
@@ -11,6 +11,7 @@ import type { ElementKey } from '@faunosteo/core-wasm/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import {
|
||||
commitFocusedField,
|
||||
focusActiveTab,
|
||||
placeOf,
|
||||
visibleElement,
|
||||
type FocusOutcome,
|
||||
@@ -18,25 +19,23 @@ import {
|
||||
} from './focusRequest'
|
||||
import {
|
||||
initialNavigation,
|
||||
isFindingNode,
|
||||
navigationReducer,
|
||||
type AnnotationSection,
|
||||
type EditorTarget,
|
||||
type NavigationAction,
|
||||
type NavigationState,
|
||||
} from './navigation'
|
||||
import {
|
||||
MORE_BUTTON_ID,
|
||||
REFERENCES_BUTTON_ID,
|
||||
tabDomId,
|
||||
type EditorTabId,
|
||||
} from './tabs'
|
||||
import { MORE_BUTTON_ID, tabDomId, type EditorTabId } from './tabs'
|
||||
|
||||
type MoveKind =
|
||||
| 'go_to'
|
||||
| 'section'
|
||||
| 'back'
|
||||
| 'references'
|
||||
| 'references_closed'
|
||||
| 'citations'
|
||||
| 'citations_closed'
|
||||
| 'show_all'
|
||||
| 'tab_selected'
|
||||
|
||||
/** A programmatic move: a new object per move, so the effect after it runs once. */
|
||||
interface Move {
|
||||
@@ -49,13 +48,15 @@ export interface EditorNavigation {
|
||||
state: NavigationState
|
||||
/** The polite live region's text; a repeat alternates a trailing no-break space. */
|
||||
live: string
|
||||
navigate: (target: EditorTarget, opener?: Opener) => void
|
||||
navigate: (target: EditorTarget) => void
|
||||
selectTab: (tab: EditorTabId) => void
|
||||
openSection: (section: AnnotationSection, opener?: Opener) => void
|
||||
backToDrawing: () => void
|
||||
openReferences: (citedBy: ElementKey | null, opener?: Opener) => void
|
||||
closeReferences: () => void
|
||||
/** « Tout afficher »: drops the finding filter; no move, no announcement. */
|
||||
/** Opens the citations panel of a finding node; any other key is ignored. */
|
||||
openCitations: (citedBy: ElementKey, opener?: Opener) => void
|
||||
/** Every close (✕, Escape, scrim, element gone): the focus goes to P6's fallbacks. */
|
||||
closeCitations: () => void
|
||||
/** « Tout afficher dans l'onglet Références »: panel closed, tab shown, library reset. */
|
||||
showAllReferences: () => void
|
||||
consumed: (serial: number, outcome: FocusOutcome) => void
|
||||
announce: (text: string) => void
|
||||
@@ -87,7 +88,6 @@ function useMoveText(): (target: EditorTarget) => string {
|
||||
const t = useT()
|
||||
return useCallback(
|
||||
(target) => {
|
||||
if (target.place === 'references') return t('editor.place.references')
|
||||
const tab = t(`editor.tab.${target.tab}`)
|
||||
if (!target.section) return tab
|
||||
return `${tab} · ${t(`editor.place.${target.section}`)}`
|
||||
@@ -105,7 +105,9 @@ function useLiveRegion() {
|
||||
}
|
||||
|
||||
interface Openers {
|
||||
references: RefObject<HTMLElement | null>
|
||||
/** The trigger that opened the citations panel, and the finding it belongs to. */
|
||||
citations: RefObject<HTMLElement | null>
|
||||
citedBy: RefObject<ElementKey | null>
|
||||
section: RefObject<HTMLElement | null>
|
||||
}
|
||||
|
||||
@@ -132,13 +134,9 @@ function useSectionMoves(go: Go, openers: Openers) {
|
||||
const t = useT()
|
||||
const moveText = useMoveText()
|
||||
const navigate = useCallback(
|
||||
(target: EditorTarget, opener?: Opener) => {
|
||||
if (target.place === 'references') {
|
||||
openers.references.current = opener ?? null
|
||||
}
|
||||
go({ type: 'go_to', target }, 'go_to', moveText(target))
|
||||
},
|
||||
[go, moveText, openers],
|
||||
(target: EditorTarget) =>
|
||||
go({ type: 'go_to', target }, 'go_to', moveText(target)),
|
||||
[go, moveText],
|
||||
)
|
||||
const openSection = useCallback(
|
||||
(section: AnnotationSection, opener?: Opener) => {
|
||||
@@ -156,30 +154,33 @@ function useSectionMoves(go: Go, openers: Openers) {
|
||||
return { navigate, openSection, backToDrawing }
|
||||
}
|
||||
|
||||
/** The references panel moves: open (optionally filtered) and close. */
|
||||
function useReferenceMoves(
|
||||
go: Go,
|
||||
openers: Openers,
|
||||
dispatch: Dispatch<NavigationAction>,
|
||||
) {
|
||||
/** The citations panel moves: open from a finding, close, « Tout afficher ». */
|
||||
function useCitationsMoves(go: Go, openers: Openers) {
|
||||
const t = useT()
|
||||
const openReferences = useCallback(
|
||||
(citedBy: ElementKey | null, opener?: Opener) => {
|
||||
openers.references.current = opener ?? null
|
||||
const action = { type: 'open_references', citedBy } as const
|
||||
go(action, 'references', t('editor.place.references'))
|
||||
const openCitations = useCallback(
|
||||
(citedBy: ElementKey, opener?: Opener) => {
|
||||
if (!isFindingNode(citedBy)) return
|
||||
openers.citations.current = opener ?? null
|
||||
openers.citedBy.current = citedBy
|
||||
const action = { type: 'open_citations', citedBy } as const
|
||||
go(action, 'citations', t('editor.place.references'))
|
||||
},
|
||||
[go, openers, t],
|
||||
)
|
||||
const closeReferences = useCallback(() => {
|
||||
const closeCitations = useCallback(() => {
|
||||
const text = t('editor.live.references_closed')
|
||||
go({ type: 'close_references' }, 'references_closed', text)
|
||||
go({ type: 'close_citations' }, 'citations_closed', text)
|
||||
}, [go, t])
|
||||
const showAllReferences = useCallback(
|
||||
() => dispatch({ type: 'clear_cited_by' }),
|
||||
[dispatch],
|
||||
() =>
|
||||
go(
|
||||
{ type: 'show_all_references' },
|
||||
'show_all',
|
||||
t('editor.tab.references'),
|
||||
),
|
||||
[go, t],
|
||||
)
|
||||
return { openReferences, closeReferences, showAllReferences }
|
||||
return { openCitations, closeCitations, showAllReferences }
|
||||
}
|
||||
|
||||
/** « Retour au dessin »: the entry that opened the section, else the canvas box. */
|
||||
@@ -190,15 +191,34 @@ function backTarget(opener: HTMLElement | null): HTMLElement | null {
|
||||
return again || visibleElement(CANVAS_BOX)
|
||||
}
|
||||
|
||||
/** Panel closed: the opener when it is shown, else the header button. */
|
||||
function referencesBack(opener: HTMLElement | null): HTMLElement | null {
|
||||
/** The trigger of a finding's citations, found by comparing `dataset` values. */
|
||||
function triggerOf(openers: Openers): HTMLElement | null {
|
||||
const opener = openers.citations.current
|
||||
if (opener && isShown(opener)) return opener
|
||||
return document.getElementById(REFERENCES_BUTTON_ID)
|
||||
const wanted = JSON.stringify(openers.citedBy.current)
|
||||
return visibleElement('[data-citations-trigger]', (element) => {
|
||||
return element.dataset.citationsTrigger === wanted
|
||||
})
|
||||
}
|
||||
|
||||
/** Focuses `element` and says whether it really holds the focus now. */
|
||||
function focusHeld(element: HTMLElement | null): boolean {
|
||||
element?.focus()
|
||||
return element !== null && document.activeElement === element
|
||||
}
|
||||
|
||||
/** Panel closed (P6): the trigger when it is shown, else the active tab's button. */
|
||||
function focusAfterClose(openers: Openers) {
|
||||
if (!focusHeld(triggerOf(openers))) focusActiveTab()
|
||||
}
|
||||
|
||||
/** Where the focus lands after a programmatic move; never `body`. */
|
||||
function landingOf(move: Move, state: NavigationState): HTMLElement | null {
|
||||
if (move.kind === 'references') return headingOf('citations')
|
||||
if (move.kind === 'citations') return headingOf('citations')
|
||||
if (move.kind === 'show_all') {
|
||||
return headingOf('references') ?? tabButton(state.tab)
|
||||
}
|
||||
if (move.kind === 'tab_selected') return tabButton(state.tab)
|
||||
const place = state.focus ? placeOf(state.focus.target) : shownPlace(state)
|
||||
return headingOf(place) ?? tabButton(state.tab)
|
||||
}
|
||||
@@ -218,8 +238,8 @@ function useMoveFocus(
|
||||
useEffect(() => {
|
||||
if (!move || handled.current === move) return
|
||||
handled.current = move
|
||||
if (move.kind === 'references_closed') {
|
||||
referencesBack(openers.references.current)?.focus()
|
||||
if (move.kind === 'citations_closed') {
|
||||
focusAfterClose(openers)
|
||||
return
|
||||
}
|
||||
const serial = state.focus?.serial
|
||||
@@ -234,7 +254,7 @@ function useMoveFocus(
|
||||
}, [move, state, outcomes, dispatch, openers])
|
||||
}
|
||||
|
||||
/** Tab selection, and the outcomes the places report for each focus request. */
|
||||
/** The outcomes the places report for each focus request. */
|
||||
function useReceipts(dispatch: Dispatch<NavigationAction>) {
|
||||
const outcomes = useRef(new Map<number, FocusOutcome>())
|
||||
const consumed = useCallback(
|
||||
@@ -244,14 +264,25 @@ function useReceipts(dispatch: Dispatch<NavigationAction>) {
|
||||
},
|
||||
[dispatch],
|
||||
)
|
||||
const selectTab = useCallback(
|
||||
return { outcomes, consumed }
|
||||
}
|
||||
|
||||
/** A tab choice; with the citations panel open it closes and the new tab takes the focus. */
|
||||
function useTabSelect(
|
||||
go: Go,
|
||||
dispatch: Dispatch<NavigationAction>,
|
||||
open: boolean,
|
||||
) {
|
||||
const t = useT()
|
||||
return useCallback(
|
||||
(tab: EditorTabId) => {
|
||||
const action = { type: 'select_tab', tab } as const
|
||||
if (open) return go(action, 'tab_selected', t(`editor.tab.${tab}`))
|
||||
commitFocusedField()
|
||||
dispatch({ type: 'select_tab', tab })
|
||||
dispatch(action)
|
||||
},
|
||||
[dispatch],
|
||||
[go, dispatch, open, t],
|
||||
)
|
||||
return { outcomes, consumed, selectTab }
|
||||
}
|
||||
|
||||
/** Navigation of the draft editor: the reducer plus the DOM side (focus, live region). */
|
||||
@@ -263,7 +294,8 @@ export function useEditorNavigation(initialTab: EditorTabId): EditorNavigation {
|
||||
)
|
||||
const { move, go, live, announce } = useGo(dispatch)
|
||||
const openers = useRef<Openers>({
|
||||
references: { current: null },
|
||||
citations: { current: null },
|
||||
citedBy: { current: null },
|
||||
section: { current: null },
|
||||
}).current
|
||||
const receipts = useReceipts(dispatch)
|
||||
@@ -273,8 +305,8 @@ export function useEditorNavigation(initialTab: EditorTabId): EditorNavigation {
|
||||
live,
|
||||
announce,
|
||||
consumed: receipts.consumed,
|
||||
selectTab: receipts.selectTab,
|
||||
selectTab: useTabSelect(go, dispatch, state.citationsOf !== null),
|
||||
...useSectionMoves(go, openers),
|
||||
...useReferenceMoves(go, openers, dispatch),
|
||||
...useCitationsMoves(go, openers),
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { commitFocusedField, heldElement, refocusIfHidden } from './focusRequest'
|
||||
import { MIN_EDIT_WIDTH } from './mode'
|
||||
|
||||
/** The tab lists of board 05: all, the four of 640 px and over, the two below. */
|
||||
/** The tab lists of board 05: all, the five of 640 px and over, the two below. */
|
||||
export type TabTier = 'wide' | 'medium' | 'small'
|
||||
|
||||
const MEDIUM_WIDTH = 640
|
||||
|
||||
@@ -157,7 +157,6 @@ export function issueTarget(
|
||||
|
||||
/** The i18n key of the name of the place a target shows. */
|
||||
export function placeKey(target: EditorTarget): string {
|
||||
if (target.place === 'references') return 'editor.place.references'
|
||||
if (target.section && target.section !== 'drawing') {
|
||||
return `editor.place.${target.section}`
|
||||
}
|
||||
|
||||
@@ -1194,6 +1194,7 @@ export const en: Dict = {
|
||||
'editor.tab.general': 'General',
|
||||
'editor.tab.annotations': 'Annotations',
|
||||
'editor.tab.findings': 'Findings',
|
||||
'editor.tab.references': 'References',
|
||||
'editor.tab.verification': 'Verification',
|
||||
'editor.tab.more': 'More',
|
||||
'editor.tab.errors_one': '{count} error',
|
||||
@@ -1227,7 +1228,6 @@ export const en: Dict = {
|
||||
'editor.annotations.show_all': 'All annotations',
|
||||
'editor.annotations.deselect': 'Deselect',
|
||||
'editor.annotations.deselected': 'No annotation selected.',
|
||||
'editor.references.open': 'References',
|
||||
'editor.references.close': 'Close the references',
|
||||
'editor.references.search': 'Search a reference',
|
||||
'editor.references.cited_by': 'Cited by « {name} » ({count})',
|
||||
|
||||
@@ -1225,6 +1225,7 @@ export const fr: Dict = {
|
||||
'editor.tab.general': 'Général',
|
||||
'editor.tab.annotations': 'Annotations',
|
||||
'editor.tab.findings': 'Constats',
|
||||
'editor.tab.references': 'Références',
|
||||
'editor.tab.verification': 'Vérification',
|
||||
'editor.tab.more': 'Plus',
|
||||
'editor.tab.errors_one': '{count} erreur',
|
||||
@@ -1258,7 +1259,6 @@ export const fr: Dict = {
|
||||
'editor.annotations.show_all': 'Toutes les annotations',
|
||||
'editor.annotations.deselect': 'Désélectionner',
|
||||
'editor.annotations.deselected': 'Aucune annotation sélectionnée.',
|
||||
'editor.references.open': 'Références',
|
||||
'editor.references.close': 'Fermer les références',
|
||||
'editor.references.search': 'Rechercher une référence',
|
||||
'editor.references.cited_by': 'Citées par « {name} » ({count})',
|
||||
|
||||
Reference in new issue
Block a user