From 621104653793b801aca4a2d794c83b8eefe37eb9 Mon Sep 17 00:00:00 2001 From: bchanot Date: Tue, 17 Nov 2026 20:24:49 +0100 Subject: [PATCH] feat(editor): vertex handles, insert and remove, zone move, redraw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit U2 Task 5. A selected polygon gets its vertex, « + » and « − » handles (R-9, hidden « + » under two hit radii, R-18 zoom hint in the strip), the handle cap at 40 (R-7), vertex drag and keys, the move mode on the zone or the chosen vertex, « Redessiner » as a redraw mode kept in step with its tracing (R-12 guard, R-13 drop), close radius in CSS px (R-11). The numeric group leaves the properties panel (D1). Removed or rewritten assertions (numeric group -> replacement): - tab « shows its exact stored numbers » (Centre x field) -> the overlay selection circle's cx attribute, same exact value. - tab « a numeric edit » x3 -> « an edit on the drawing »: Enter on the handle without a step commits nothing, a step + Enter commits once; a refused handle drag keeps the stored shape then a drag inside the frame repairs it (issues gone); Escape drops a pending series. - tab C26 « Centre x 15 » -> overlay cx 15. - tab C32 unmeasured « Centre x as text » -> no handle, no field. - tab « adds and removes a vertex as part of the whole group » -> « + » then « − » on the drawing; « never offers to remove below three » -> « − » aria-disabled at 3. - tab H8 « refused Remplacer drops the tracing » -> keeps it open with « Fermeture refusée » (board 33 A); « refused vertex add/remove stay non appliqué » -> a refused vertex drag restores the shape exactly. - tab Désélectionner and D6b (typed Centre x committed, refused, undone) x6 and strip « a new commit replaces the message » -> the same with the Nom (FR) field (a blank name is the refused value). - focus-request « Centre x 20 » -> overlay cx 20. - escape « strip commands keep their Escape » -> a redraw: Escape on the strip or the box cancels it (R-12 row 4); kept for a new zone tracing. - keep-alive « Remplacer tracing kept across Aller à » -> ended by a tab when empty, asked once a vertex is placed (R-12). - e2e annotations: numeric cx edit + undo/redo -> handle keys + undo/ redo; jitter/drag and Task 4 point reads -> overlay attributes (the stored place during the mode -> overlay-old-place); keyboard-only cy and vertex x typed -> handle and vertex keys. - e2e deselect: Centre x typed/refused/committed -> Nom (FR). - e2e geometry, shell-crossing: Centre x/cy reads -> overlay attributes. - e2e journey: cx +3 and vertex x +4 typed -> 3 and 4 arrow steps + Enter; a far typed value + revert -> a far handle drag refused. - e2e equine latency: typed cx rounds -> handle arrow + Enter rounds. --- apps/app/e2e/shell/editor-annotations.spec.ts | 101 ++- apps/app/e2e/shell/editor-deselect.spec.ts | 36 +- apps/app/e2e/shell/editor-equine.spec.ts | 15 +- apps/app/e2e/shell/editor-geometry.spec.ts | 23 +- apps/app/e2e/shell/editor-journey.spec.ts | 83 +- .../e2e/shell/editor-shell-crossing.spec.ts | 8 +- apps/app/e2e/shell/editor-zones.spec.ts | 292 ++++++ apps/app/e2e/support/editor.ts | 31 +- .../editor/annotations/AnnotationCanvas.tsx | 19 +- .../editor/annotations/AnnotationOverlay.tsx | 11 +- .../annotations/EditableAnnotations.tsx | 203 ++--- .../editor/annotations/HandleLayer.tsx | 45 + .../editor/annotations/PropertiesPanel.tsx | 40 +- .../editor/annotations/TracingCommands.tsx | 57 ++ .../editor/annotations/ZoneCommands.tsx | 99 +++ .../editor/annotations/ZoneHandles.tsx | 325 +++++++ .../components/editor/tabs/AnnotationsTab.tsx | 1 - apps/app/src/editor/annotations/gesture.ts | 22 + apps/app/src/editor/annotations/handleSize.ts | 18 +- apps/app/src/editor/annotations/modeEnds.ts | 38 + .../app/src/editor/annotations/polygonEdit.ts | 64 ++ apps/app/src/editor/annotations/press.ts | 6 + .../src/editor/annotations/previewCommit.ts | 17 +- apps/app/src/editor/annotations/redraw.ts | 42 + apps/app/src/editor/annotations/stripLead.ts | 48 +- apps/app/src/editor/annotations/uiState.ts | 12 +- .../src/editor/annotations/useBlockDrag.ts | 58 +- .../src/editor/annotations/usePlacement.ts | 109 ++- .../src/editor/annotations/usePointEdit.ts | 23 +- .../src/editor/annotations/usePressGesture.ts | 56 +- .../app/src/editor/annotations/useZoneEdit.ts | 149 ++++ apps/app/src/editor/annotations/workStore.ts | 27 +- apps/app/src/editor/annotations/zoneEdit.ts | 24 + apps/app/src/i18n/en.ts | 744 ++++++++++------ apps/app/src/i18n/fr.ts | 838 ++++++++++++------ .../unit/annotations.polygonEdit.test.ts | 120 +++ .../tests/unit/annotations.workStore.test.ts | 8 +- .../unit/components.SignOutButton.test.tsx | 43 + .../unit/editor-annotations-tab.test.tsx | 226 +++-- apps/app/tests/unit/editor-escape.test.tsx | 24 +- .../tests/unit/editor-focus-request.test.tsx | 6 +- .../app/tests/unit/editor-keep-alive.test.tsx | 36 +- apps/app/tests/unit/editor-zone-edit.test.tsx | 676 ++++++++++++++ apps/app/tests/unit/shell.AppLayout.test.tsx | 17 + 44 files changed, 3790 insertions(+), 1050 deletions(-) create mode 100644 apps/app/e2e/shell/editor-zones.spec.ts create mode 100644 apps/app/src/components/editor/annotations/TracingCommands.tsx create mode 100644 apps/app/src/components/editor/annotations/ZoneCommands.tsx create mode 100644 apps/app/src/components/editor/annotations/ZoneHandles.tsx create mode 100644 apps/app/src/editor/annotations/modeEnds.ts create mode 100644 apps/app/src/editor/annotations/polygonEdit.ts create mode 100644 apps/app/src/editor/annotations/redraw.ts create mode 100644 apps/app/src/editor/annotations/useZoneEdit.ts create mode 100644 apps/app/src/editor/annotations/zoneEdit.ts create mode 100644 apps/app/tests/unit/annotations.polygonEdit.test.ts create mode 100644 apps/app/tests/unit/editor-zone-edit.test.tsx diff --git a/apps/app/e2e/shell/editor-annotations.spec.ts b/apps/app/e2e/shell/editor-annotations.spec.ts index 2afefcdc..8f749612 100644 --- a/apps/app/e2e/shell/editor-annotations.spec.ts +++ b/apps/app/e2e/shell/editor-annotations.spec.ts @@ -6,8 +6,12 @@ import { clickDrawing, clientOf, editorActor, - geometryField, historyButton, + round2, + shownNumber, + shownPoints, + shownShape, + storedShape, pressAtBox, openEditor, pickAnnotation, @@ -25,7 +29,7 @@ import { import { expectNoShift, keepNativeFrames } from '../support/layout' // V1-2.6 A3 (contract C7, C8, C21): points, zones and links by clicks and by keyboard, -// move by drag, numeric edits, undo and redo, then the save that carries them. +// move by drag, edits on the handles (U2 Task 5), undo and redo, then the save. const dict = fr @@ -84,7 +88,7 @@ test.describe('editor annotations (A3)', () => { await dropLateReplays(context) }) - test('point, zone and link by clicks; numeric edit; undo and redo; save', async ({ + test('point, zone and link by clicks; handle edit; undo and redo; save', async ({ page, requests, }) => { @@ -103,8 +107,8 @@ test.describe('editor annotations (A3)', () => { await createFromPanel(page) await expect(selectionTag(page)).toContainText('Point un') await expect(properties(page)).toBeVisible() - const placed = await geometryField(page, dict, 'cx').inputValue() - expect(Math.abs(Number(placed) - 300)).toBeLessThan(1) + const placed = await shownNumber(page, 'cx') + expect(Math.abs(placed - 300)).toBeLessThan(1) // A zone: three clicks, then « Fermer le tracé ». await tool(page, 'zone').click() @@ -137,19 +141,22 @@ test.describe('editor annotations (A3)', () => { await expect(selectionTag(page)).toContainText('Accès un') await expect(historyButton(page, dict, 'undo')).toBeEnabled() - // A numeric edit of the point, then undo and redo. + // A keyboard edit on the point's handle (two steps of 5 units), then undo and redo. + await tool(page, 'select').click() await pickAnnotation(page, dict, /Point un/) - const cx = geometryField(page, dict, 'cx') - await cx.fill('420') - await cx.press('Enter') - await expect(cx).toHaveValue('420') + await page.getByRole('button', { name: 'Point Point un' }).focus() + await page.keyboard.press('ArrowRight') + await page.keyboard.press('ArrowRight') + await page.keyboard.press('Enter') + const moved = String(round2(round2(placed + 5) + 5)) + await expect(shownShape(page)).toHaveAttribute('cx', moved) await historyButton(page, dict, 'undo').click() - await expect(geometryField(page, dict, 'cx')).toHaveValue(placed) + await expect(shownShape(page)).toHaveAttribute('cx', String(placed)) await historyButton(page, dict, 'redo').click() - await expect(geometryField(page, dict, 'cx')).toHaveValue('420') + await expect(shownShape(page)).toHaveAttribute('cx', moved) // Nothing left to redo: the button is aria-disabled and a press changes nothing. await pressAtBox(page, historyButton(page, dict, 'redo')) - await expect(geometryField(page, dict, 'cx')).toHaveValue('420') + await expect(shownShape(page)).toHaveAttribute('cx', moved) await saveDraft(page, dict, seed.revision + 1) const saved = await serverDocument<{ @@ -176,9 +183,8 @@ test.describe('editor annotations (A3)', () => { await fillCreation(page, { fr: 'Mobile', en: 'Movable' }) await createFromPanel(page) await tool(page, 'select').click() - const cx = geometryField(page, dict, 'cx') - const cy = geometryField(page, dict, 'cy') - const [x0, y0] = [await cx.inputValue(), await cy.inputValue()] + const x0 = String(await shownNumber(page, 'cx')) + const y0 = String(await shownNumber(page, 'cy')) expect(Math.abs(Number(x0) - 300)).toBeLessThan(1) // Jitter under the 4 px threshold: pressed, moved by 3 px, released. @@ -187,8 +193,8 @@ test.describe('editor annotations (A3)', () => { await page.mouse.down() await page.mouse.move(from.x + 2, from.y + 2) await page.mouse.up() - await expect(cx).toHaveValue(x0) - await expect(cy).toHaveValue(y0) + await expect(shownShape(page)).toHaveAttribute('cx', x0) + await expect(shownShape(page)).toHaveAttribute('cy', y0) // A real drag: the point follows to (400, 360) in drawing units. const to = await clientOf(page, 400, 360) @@ -199,14 +205,14 @@ test.describe('editor annotations (A3)', () => { }) await page.mouse.move(to.x, to.y, { steps: 5 }) await page.mouse.up() - await expect(cx).not.toHaveValue(x0) - expect(Math.abs(Number(await cx.inputValue()) - 400)).toBeLessThan(2) - expect(Math.abs(Number(await cy.inputValue()) - 360)).toBeLessThan(2) + await expect(shownShape(page)).not.toHaveAttribute('cx', x0) + expect(Math.abs((await shownNumber(page, 'cx')) - 400)).toBeLessThan(2) + expect(Math.abs((await shownNumber(page, 'cy')) - 360)).toBeLessThan(2) await page.keyboard.press('Control+z') - await expect(geometryField(page, dict, 'cx')).toHaveValue(x0) + await expect(shownShape(page)).toHaveAttribute('cx', x0) }) - test('keyboard only: creation by the add buttons, numeric position, numeric edit', async ({ + test('keyboard only: creation by the add buttons, numeric position, edit by the handle keys', async ({ page, requests, }) => { @@ -230,14 +236,20 @@ test.describe('editor annotations (A3)', () => { await page.keyboard.press('Enter') await expect(creation(page)).toHaveCount(0) await expect(selectionTag(page)).toContainText('Clavier') - await expect(geometryField(page, dict, 'cx')).toHaveValue('250') + await expect(shownShape(page)).toHaveAttribute('cx', '250') - const cy = geometryField(page, dict, 'cy') - await cy.fill('510.5') - await cy.press('Enter') - await expect(cy).toHaveValue('510.5') + // The handle keys (U2 Task 5): two steps of 5 units down, one commit on Enter. + const cy0 = await shownNumber(page, 'cy') + await page.getByRole('button', { name: 'Point Clavier' }).focus() + await page.keyboard.press('ArrowDown') + await page.keyboard.press('ArrowDown') + await page.keyboard.press('Enter') + await expect(shownShape(page)).toHaveAttribute( + 'cy', + String(round2(round2(cy0 + 5) + 5)), + ) - // A polygon edit: the zone added by keyboard, a vertex typed. + // A polygon edit: the zone added by keyboard, its first vertex moved by its keys. await page .getByRole('button', { name: dict['editor.annotations.add.zone'] }) .focus() @@ -248,13 +260,14 @@ test.describe('editor annotations (A3)', () => { .focus() await page.keyboard.press('Enter') await expect(selectionTag(page)).toContainText('Zone clavier') - const vertexX = page.getByLabel( - dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'), - ) - const before = Number(await vertexX.inputValue()) - await vertexX.fill(String(before + 10)) - await vertexX.press('Enter') - await expect(vertexX).toHaveValue(String(before + 10)) + const [[before]] = await shownPoints(page) + await page.getByRole('button', { name: 'Sommet 1', exact: true }).focus() + await page.keyboard.press('ArrowRight') + await page.keyboard.press('ArrowRight') + await page.keyboard.press('Enter') + await expect + .poll(async () => (await shownPoints(page))[0][0]) + .toBe(round2(round2(before + 5) + 5)) await saveDraft(page, dict, seed.revision + 1) }) @@ -416,7 +429,6 @@ test.describe('editor annotations (A3)', () => { await expectAccessible(page, 'a selected point: handle, slider, move') // The handle follows the pointer; the drop is one commit. - const cx = geometryField(page, dict, 'cx') await expectNoShift( page, async () => { @@ -427,10 +439,9 @@ test.describe('editor annotations (A3)', () => { }, swaps, ) - expect(Math.abs(Number(await cx.inputValue()) - 560)).toBeLessThan(2) + expect(Math.abs((await shownNumber(page, 'cx')) - 560)).toBeLessThan(2) // A click on the track, no drag (WCAG 2.5.7): one commit at the release. - const r = geometryField(page, dict, 'r') const track = (await slider.boundingBox())! await expectNoShift( page, @@ -445,12 +456,12 @@ test.describe('editor annotations (A3)', () => { }, swaps, ) - expect(Number(await r.inputValue())).toBeGreaterThan(40) + expect(await shownNumber(page, 'r')).toBeGreaterThan(40) await page.keyboard.press('Control+z') - await expect(r).toHaveValue('40') + await expect(shownShape(page)).toHaveAttribute('r', '40') // The move mode: three steps (5 units each on a 1 000 px wide frame), validated once. - const x0 = Number(await cx.inputValue()) + const x0 = await shownNumber(page, 'cx') await expectNoShift( page, () => button(page, 'editor.annotations.move.point').click(), @@ -466,7 +477,8 @@ test.describe('editor annotations (A3)', () => { }, swaps, ) - await expect(cx).toHaveValue(String(x0)) + // Nothing committed yet: the stored place stays, drawn as the old place. + await expect(storedShape(page)).toHaveAttribute('cx', String(x0)) await expectNoShift( page, async () => { @@ -475,7 +487,8 @@ test.describe('editor annotations (A3)', () => { }, swaps, ) - await expect(cx).toHaveValue(String(x0 + 15)) + await expect(shownShape(page)).toHaveAttribute('cx', String(x0 + 15)) + await expect(storedShape(page)).toHaveCount(0) await expect(button(page, 'editor.annotations.move.point')).toBeFocused() }) diff --git a/apps/app/e2e/shell/editor-deselect.spec.ts b/apps/app/e2e/shell/editor-deselect.spec.ts index 20fad57b..19c566ae 100644 --- a/apps/app/e2e/shell/editor-deselect.spec.ts +++ b/apps/app/e2e/shell/editor-deselect.spec.ts @@ -8,7 +8,6 @@ import { clientOf, creationPanel, editorActor, - geometryField, historyButton, openEditor, expectNoDialog, @@ -39,6 +38,10 @@ import { const dict = fr const isPhone = (info: TestInfo) => info.project.name === 'chromium-375' const properties = (page: Page) => page.getByTestId('annotation-properties') +const nameField = (page: Page) => + properties(page).getByLabel(dict['editor.annotations.name_fr'], { + exact: true, + }) const overview = (page: Page) => page.getByTestId('annotation-overview') const box = (page: Page) => page.getByTestId('annotation-canvas') const liveRegion = (page: Page) => @@ -211,11 +214,11 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { // A field focused: nothing happens, the field keeps the focus. await select(page, POINT) - const cx = geometryField(page, dict, 'cx') - await cx.focus() + const name = nameField(page) + await name.focus() await page.keyboard.press('Escape') await expectKept(page, POINT) - await expect(cx).toBeFocused() + await expect(name).toBeFocused() // The delete dialog: only it closes (LRN-111: wait until it is gone). await properties(page) @@ -389,12 +392,13 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { }) => { const { actor, saves } = await open(page) requests.forbid(actor.account.email, actor.account.password) - const cx = geometryField(page, dict, 'cx') + // U2 Task 5: the coordinate fields left the panel; the name field carries the typing. + const name = nameField(page) // Valid value, no blur, ONE click on the drawing. await select(page, POINT) - await expect(cx).toHaveValue('700') - await cx.fill('720') + await expect(name).toHaveValue(POINT) + await name.fill('Pt Delta') await clickAt(page, IN_CIRCLE) await expectDeselected(page) await expect(saveLine(page)).toHaveText(/1 modification non enregistrée/) @@ -402,26 +406,27 @@ test.describe('deselect and D6b (editor, mouse and keyboard)', () => { await historyButton(page, dict, 'undo').click() await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) await select(page, POINT) - await expect(cx).toHaveValue('700') + await expect(name).toHaveValue(POINT) // « Désélectionner » with an unblurred refused value: closed at once, unchanged. + // A blank name is refused (both names are required). const deselect = properties(page).getByRole('button', { name: dict['editor.annotations.deselect'], }) - await cx.fill('abc') + await name.fill('') await deselect.click() await expectDeselected(page) await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) await select(page, POINT) - await expect(cx).toHaveValue('700') + await expect(name).toHaveValue(POINT) // « Désélectionner » with an unblurred valid value: committed and closed. - await cx.fill('730') + await name.fill('Pt Epsilon') await deselect.click() await expectDeselected(page) await expect(saveLine(page)).toHaveText(/1 modification non enregistrée/) - await select(page, POINT) - await expect(cx).toHaveValue('730') + await select(page, 'Pt Epsilon') + await expect(name).toHaveValue('Pt Epsilon') expect(saves).toEqual([]) }) }) @@ -612,6 +617,11 @@ test.describe('deselect and D6b (touch, editor at 1 280 px)', () => { // c. Within 36 px of the canvas bottom, above the add buttons. await select(page, POINT) await takeRecord(page) + // U2 Task 5: without the coordinate fields the properties panel is shorter than the + // overview, so with the page scrolled to its end the deselect's swap (aside content, + // until Task 6) grows the page and scrolls it before the tap's click lands. The tap + // is made from the top of the page; the hazard is reported for Task 6. + await page.evaluate(() => window.scrollTo(0, 0)) await box(page).scrollIntoViewIfNeeded() const rect = (await box(page).boundingBox())! const bottom = { x: rect.x + rect.width / 2, y: rect.y + rect.height - 36 } diff --git a/apps/app/e2e/shell/editor-equine.spec.ts b/apps/app/e2e/shell/editor-equine.spec.ts index 76afaeb3..fc937541 100644 --- a/apps/app/e2e/shell/editor-equine.spec.ts +++ b/apps/app/e2e/shell/editor-equine.spec.ts @@ -361,21 +361,18 @@ test.describe('equine working copy and commit latency', () => { page, 'equine: add category (insert)', ) - // A geometry edit: the first annotation's centre, through the geometry group. + // A geometry edit: a point's centre, through its handle keys (U2 Task 5: the + // coordinate fields left the panel). Each round is one step and one commit (Enter). await showDrawing(page, dict) await page .getByRole('list', { name: dict['editor.annotations.list'] }) - .getByRole('button') - .first() + .getByRole('button', { name: /C7-T1/ }) .click() - const cx = page.getByLabel(dict['editor.annotations.geometry.cx'], { - exact: true, - }) - const base = Number(await cx.inputValue()) + await page.getByTestId('point-handle').focus() await startProbe(page) for (let round = 0; round <= SAMPLES; round++) { - await cx.fill(String(base + ((round % 2) + 1) * 0.5)) - await cx.press('Enter') + await page.keyboard.press(round % 2 ? 'ArrowLeft' : 'ArrowRight') + await page.keyboard.press('Enter') } await page.waitForTimeout(200) const moves = report( diff --git a/apps/app/e2e/shell/editor-geometry.spec.ts b/apps/app/e2e/shell/editor-geometry.spec.ts index ff8415ad..d6484663 100644 --- a/apps/app/e2e/shell/editor-geometry.spec.ts +++ b/apps/app/e2e/shell/editor-geometry.spec.ts @@ -8,7 +8,8 @@ import { clickDrawing, clientOf, editorActor, - geometryField, + shownNumber, + shownShape, openEditor, openSection, pickAnnotation, @@ -130,8 +131,8 @@ test.describe('editor geometry (adversarial)', () => { .click() await expect(creation(page)).toHaveCount(0) await expect(selectionTag(page)).toContainText('Bord') - await expect(geometryField(page, dict, 'cx')).toHaveValue(shown.x) - await expect(geometryField(page, dict, 'cy')).toHaveValue(shown.y) + await expect(shownShape(page)).toHaveAttribute('cx', shown.x) + await expect(shownShape(page)).toHaveAttribute('cy', shown.y) }) test('a click near the edge of a detail crop is corrected inside the crop', async ({ @@ -190,7 +191,6 @@ test.describe('editor geometry (adversarial)', () => { (await verification.innerText()).replace(/\D/g, ''), ) expect(errorsBefore).toBeGreaterThan(0) - const cx = geometryField(page, dict, 'cx') const move = page.getByRole('button', { name: dict['editor.annotations.move.point'], }) @@ -201,6 +201,10 @@ test.describe('editor geometry (adversarial)', () => { // A partial move (still out of the frame): refused by the core, the point restored. // Nothing around the drawing moves (A14); the side panel's content may (Task 6). const swaps = ['aside-content'] as const + // The list row scrolled the page to its end. Without the coordinate fields (U2 Task 5) + // the panel is short enough that the issue list leaving it (aside content, exempt until + // Task 6) would clamp that scroll: the check starts from the top. + await page.evaluate(() => window.scrollTo(0, 0)) await expectNoShift(page, () => move.click(), swaps) await dragInMode(page, { x: 250, y: 250 }, { x: 260, y: 260 }) await expectNoShift( @@ -215,7 +219,7 @@ test.describe('editor geometry (adversarial)', () => { dict['editor.annotations.message.move_refused'].split(' :')[0], ) await expect(page.getByTestId('overlay-refused-place')).toBeAttached() - await expect(cx).toHaveValue('110') + await expect(shownShape(page)).toHaveAttribute('cx', '110') await expect(issues).toBeVisible() // Far enough inside: kept, the issue gone, one error less. @@ -229,7 +233,7 @@ test.describe('editor geometry (adversarial)', () => { }, swaps, ) - expect(Math.abs(Number(await cx.inputValue()) - 150)).toBeLessThan(2) + expect(Math.abs((await shownNumber(page, 'cx')) - 150)).toBeLessThan(2) const after = (await verification.innerText()).replace(/\D/g, '') expect(Number(after || 0)).toBeLessThan(errorsBefore) }) @@ -501,8 +505,7 @@ test.describe('editor touch path (real browser)', () => { // touchstart, so a drag of the selected marker must not be left to the pan. await pickAnnotation(page, dict, /Tactile/) await expect.poll(touchAction).toBe('none') - const cx = geometryField(page, dict, 'cx') - await expect(cx).toHaveValue('500') + await expect(shownShape(page)).toHaveAttribute('cx', '500') const from = await clientOf(page, 500, 400) const to = await clientOf(page, 620, 400) const cdp = await context.newCDPSession(page) @@ -521,7 +524,7 @@ test.describe('editor touch path (real browser)', () => { y: from.y, }) await touch('touchEnd', null) - await expect(cx).not.toHaveValue('500') - expect(Math.abs(Number(await cx.inputValue()) - 620)).toBeLessThan(3) + await expect(shownShape(page)).not.toHaveAttribute('cx', '500') + expect(Math.abs((await shownNumber(page, 'cx')) - 620)).toBeLessThan(3) }) }) diff --git a/apps/app/e2e/shell/editor-journey.spec.ts b/apps/app/e2e/shell/editor-journey.spec.ts index c553a13c..41b8690a 100644 --- a/apps/app/e2e/shell/editor-journey.spec.ts +++ b/apps/app/e2e/shell/editor-journey.spec.ts @@ -6,12 +6,16 @@ import { expect, expectAccessible, test } from '../support/browser' import { dropLateReplays, routeToSandbox } from '../support/sandbox' import { clickDrawing, + clientOf, closeFinding, createFromPanel, creationPanel, editorActor, fillCreation, - geometryField, + round2, + shownNumber, + shownPoints, + shownShape, historyButton, INKSCAPE_EXPORT, openDraft, @@ -185,28 +189,52 @@ async function createAnnotations(page: Page) { const MODIFIED = { point: 3, vertex: 4 } -/** Applies (not only refuses) changes to a point, a zone and a link; read back at the save. */ +/** + * `steps` arrow presses on the focused handle (one unit each on this 200-unit drawing, + * R-11), then Enter: one commit. Returns where `from` lands, rounded as the page does. + */ +async function stepRight( + page: Page, + handle: Locator, + from: number, + steps: number, +) { + await handle.focus() + let to = from + for (let step = 0; step < steps; step++) { + await page.keyboard.press('ArrowRight') + to = round2(to + 1) + } + await page.keyboard.press('Enter') + return to +} + +/** + * Applies (not only refuses) changes to a point, a zone and a link; read back at the save. + * U2 Task 5: the point and the vertex move by their handle keys (no coordinate field). + */ async function modifyAnnotations(page: Page) { await pickAnnotation(page, dict, /Point essai/) - const cx = geometryField(page, dict, 'cx') - const before = Number(await cx.inputValue()) - await commitText(cx, String(before + MODIFIED.point)) - await expect(cx).toHaveValue(String(before + MODIFIED.point)) + const before = await shownNumber(page, 'cx') + const handle = page.getByTestId('point-handle') + const point = await stepRight(page, handle, before, MODIFIED.point) + await expect(shownShape(page)).toHaveAttribute('cx', String(point)) await pickAnnotation(page, dict, /Zone dessinée/) - const vertex = page.getByLabel( - dict['editor.annotations.geometry.vertex_x'].replace('{n}', '1'), - ) - const start = Number(await vertex.inputValue()) - await commitText(vertex, String(start + MODIFIED.vertex)) - await expect(vertex).toHaveValue(String(start + MODIFIED.vertex)) + const [[start]] = await shownPoints(page) + const first = page.getByRole('button', { name: 'Sommet 1', exact: true }) + const vertex = await stepRight(page, first, start, MODIFIED.vertex) + await expect.poll(async () => (await shownPoints(page))[0][0]).toBe(vertex) await pickAnnotation(page, dict, /Accès essai/) await commitText(page.locator('#annotation-name-fr'), 'Accès modifié') await page.locator('#annotation-laterality').selectOption('bilateral') await expect(page.locator('#annotation-name-fr')).toHaveValue('Accès modifié') - return { point: before + MODIFIED.point, vertex: start + MODIFIED.vertex } + return { point, vertex } } -/** Guide 4.4: a click near the edge proposes a position; a far value is refused. */ +/** + * Guide 4.4: a click near the edge proposes a position; a far place is refused (U2 Task + * 5: dragged by the handle, the coordinate fields left the panel). + */ async function repairGeometry(page: Page) { await toolButton(page, dict, 'point').click() // On this 200 x 150 drawing the core keeps a shrunk marker at 1 unit from the edge: the @@ -216,16 +244,20 @@ async function repairGeometry(page: Page) { await fillCreation(page, dict, { fr: 'Point de bord', en: 'Edge point' }) await createFromPanel(page, dict) await expect(selectionTag(page)).toContainText('Point de bord') - const cx = geometryField(page, dict, 'cx') - await cx.fill('9999') - await cx.press('Enter') - await expect( - page.getByText(dict['editor.annotations.geometry.unapplied']), - ).toBeVisible() - await clickButton(page, dict['editor.annotations.geometry.revert']) - await expect( - page.getByText(dict['editor.annotations.geometry.unapplied']), - ).toHaveCount(0) + // The point tool stays on after « Créer » (A7 lands with Task 7): the handle needs select. + await toolButton(page, dict, 'select').click() + const cx = String(await shownNumber(page, 'cx')) + const cy = await shownNumber(page, 'cy') + const from = await clientOf(page, Number(cx), cy) + const to = await clientOf(page, 260, cy) + await page.mouse.move(from.x, from.y) + await page.mouse.down() + await page.mouse.move(to.x, to.y, { steps: 6 }) + await page.mouse.up() + await expect(page.getByTestId('gesture-message')).toContainText( + dict['editor.annotations.message.move_refused'].split(' :')[0], + ) + await expect(shownShape(page)).toHaveAttribute('cx', cx) } /** Guide 4.5: an unsaved change, a reload (beforeunload accepted), the offer, a restore. */ @@ -284,6 +316,9 @@ test.describe('editor journey (owner trial steps)', () => { await historyButton(page, dict, 'undo').click() await historyButton(page, dict, 'redo').click() const modified = await modifyAnnotations(page) + // The last list row scrolled the page: the shell's top bar would cover « Enregistrer » + // (axe target-size); the shorter panel of U2 Task 5 made that scroll reach it. + await page.evaluate(() => window.scrollTo(0, 0)) await expectAccessible(page, 'the editor with annotations') await saveDraft(page, dict, 1) const draftId = await sql( diff --git a/apps/app/e2e/shell/editor-shell-crossing.spec.ts b/apps/app/e2e/shell/editor-shell-crossing.spec.ts index 2c254b1f..0580db40 100644 --- a/apps/app/e2e/shell/editor-shell-crossing.spec.ts +++ b/apps/app/e2e/shell/editor-shell-crossing.spec.ts @@ -9,7 +9,8 @@ import { copyKeyOf, editorActor, expectNoDialog, - geometryField, + shownNumber, + shownShape, historyButton, openEditor, openCitations, @@ -362,8 +363,7 @@ test.describe('editor shell, width crossing (H)', () => { ) await selectTab(page, dict, 'annotations') await pickAnnotation(page, dict, 'Point libre') - const cx = geometryField(page, dict, 'cx') - const before = await cx.inputValue() + const before = String(await shownNumber(page, 'cx')) const from = await clientOf(page, 120, 120) const to = await clientOf(page, 200, 160) await page.mouse.move(from.x, from.y) @@ -372,7 +372,7 @@ test.describe('editor shell, width crossing (H)', () => { await cross(page, NARROW) await page.mouse.up() await cross(page, WIDE) - await expect(geometryField(page, dict, 'cx')).toHaveValue(before) + await expect(shownShape(page)).toHaveAttribute('cx', before) await expect(saveLine(page)).not.toHaveText(UNSAVED_LINE) await expect(historyButton(page, dict, 'undo')).toHaveAttribute( 'aria-disabled', diff --git a/apps/app/e2e/shell/editor-zones.spec.ts b/apps/app/e2e/shell/editor-zones.spec.ts new file mode 100644 index 00000000..3e0e7d18 --- /dev/null +++ b/apps/app/e2e/shell/editor-zones.spec.ts @@ -0,0 +1,292 @@ +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import { fr } from '@/i18n/fr' +import type { Page, TestInfo } from '@playwright/test' +import { expect, expectAccessible, test } from '../support/browser' +import { dropLateReplays, routeToSandbox } from '../support/sandbox' +import { + clientOf, + editorActor, + openEditor, + pickAnnotation, + seedDraft, + selectionTag, + shownPoints, + toolButton, +} from '../support/editor' +import { expectNoShift } from '../support/layout' + +// V1-2.6 U2 Task 5: a zone edited on the drawing, « Vertèbres thoraciques » of the equine +// draft on its own drawing: vertex drag, « + », « − », zone drag, redraw accepted and +// refused, each undone, nothing around the drawing moving (A14); the topmost rule. + +const dict = fr +const isPhone = (info: TestInfo) => info.project.name === 'chromium-375' +const DRAFT = join( + __dirname, + '../../../../supabase/seed/anatomical-sheets/equine/draft', +) +const THORACIC = /Vertèbres thoraciques/ +// The side panel's content may change (U2 Task 6 moves it into a dialog). +const SWAPS = ['aside-content'] as const + +interface Draft { + vertebral_config: unknown + references: unknown + categories: unknown + finding_zones: unknown + views: { id: string; svg_asset_id: string | null }[] + annotations: { view_id: string; kind: string }[] +} + +/** The equine draft's main view, its annotations and structures, on the seeded drawing. */ +function equineShape(document: Record) { + const draft = JSON.parse( + readFileSync(join(DRAFT, 'document.json'), 'utf8'), + ) as Draft + const [seeded] = document.views as Draft['views'] + const main = draft.views.find((view) => view.id === 'main')! + Object.assign(document, { + vertebral_config: draft.vertebral_config, + references: draft.references, + categories: draft.categories, + finding_zones: draft.finding_zones, + views: [{ ...main, svg_asset_id: seeded.svg_asset_id }], + // The detail view is left out, so is the link that opens it. + annotations: draft.annotations.filter( + (a) => a.view_id === 'main' && a.kind !== 'detail_trigger', + ), + }) +} + +async function openThoracic(page: Page) { + await page.setViewportSize({ width: 1280, height: 800 }) + const actor = await editorActor('fr') + const seed = await seedDraft(actor, { + drawing: readFileSync(join(DRAFT, 'assets/horse.svg'), 'utf8'), + shape: equineShape, + }) + await openEditor(page, dict, actor, seed.sheetId) + await expect(toolButton(page, dict, 'point')).toBeEnabled() + return actor +} + +const handle = (page: Page, name: string) => + page.getByRole('button', { name, exact: true }) +const line = (page: Page) => page.getByTestId('gesture-line') +const button = (page: Page, key: string) => + page.getByRole('button', { name: dict[key], exact: true }) +const undo = (page: Page) => page.keyboard.press('Control+z') + +/** A press and release at the centre of a handle's hit shape. */ +async function pressHandle(page: Page, name: string) { + const box = (await handle(page, name).locator('[data-handle]').boundingBox())! + await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2) +} + +/** A mouse drag between two drawing points, past the slop. */ +async function dragDrawing( + page: Page, + from: { x: number; y: number }, + to: { x: number; y: number }, +) { + const start = await clientOf(page, from.x, from.y) + const end = await clientOf(page, to.x, to.y) + await page.mouse.move(start.x, start.y) + await page.mouse.down() + await page.mouse.move(end.x, end.y, { steps: 6 }) + await page.mouse.up() +} + +async function clickAt(page: Page, x: number, y: number) { + const at = await clientOf(page, x, y) + await page.mouse.click(at.x, at.y) +} + +const count = async (page: Page) => (await shownPoints(page)).length + +test.describe('editor zones on the drawing (U2 Task 5)', () => { + test.use({ locale: 'fr-FR', actionTimeout: 15_000 }) + test.beforeEach(async ({ context }, info) => { + test.skip(isPhone(info), 'editing needs 1 024 px') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access + await routeToSandbox(context) + }) + test.afterEach(async ({ context }) => { + await dropLateReplays(context) + }) + + test('Thoraciques: vertex drag, « + », « − », zone drag, each undone', async ({ + page, + requests, + }) => { + const actor = await openThoracic(page) + requests.forbid(actor.account.email, actor.account.password) + await pickAnnotation(page, dict, THORACIC) + await expect(selectionTag(page)).toContainText('Vertèbres thoraciques') + await expect(handle(page, 'Sommet 9')).toBeAttached() + // R-18: at fit zoom some segments are too short for their « + ». + await expect(page.getByTestId('edit-strip-notice')).toContainText( + dict['editor.annotations.strip.zoom_hint'], + ) + // The list row scrolled the page: the shell's top bar would cover the header's buttons. + await page.evaluate(() => window.scrollTo(0, 0)) + await expectAccessible(page, 'a selected zone: vertices and « + »') + const stored = await shownPoints(page) + + // A vertex dragged: one commit, the vertex chosen, then undone. + await expectNoShift( + page, + async () => { + await dragDrawing(page, { x: 1103, y: 558.9 }, { x: 1103, y: 620 }) + await expect(line(page)).toContainText( + dict['editor.annotations.message.vertex_moved'], + ) + }, + SWAPS, + ) + const [, moved] = await shownPoints(page) + expect(Math.abs(moved[1] - 620)).toBeLessThan(3) + await undo(page) + await expect.poll(() => shownPoints(page)).toEqual(stored) + + // « + » on the segment from vertex 2: a vertex added and chosen, then undone. + await expectNoShift( + page, + async () => { + await pressHandle(page, 'Ajouter un sommet après le sommet 2') + await expect(line(page)).toContainText( + dict['editor.annotations.message.vertex_added'], + ) + }, + SWAPS, + ) + expect(await count(page)).toBe(10) + await expect(page.getByTestId('edit-strip-detail')).toContainText( + 'sommet 3 choisi', + ) + await undo(page) + await expect.poll(() => count(page)).toBe(9) + + // « − » on the chosen vertex 3, then undone. + await pressHandle(page, 'Sommet 3') + await expectNoShift( + page, + async () => { + await pressHandle(page, 'Retirer le sommet 3') + await expect(line(page)).toContainText( + dict['editor.annotations.message.vertex_removed'], + ) + }, + SWAPS, + ) + expect(await count(page)).toBe(8) + await undo(page) + await expect.poll(() => shownPoints(page)).toEqual(stored) + + // The interior dragged by the mouse moves the zone as a block, then undone. + await expectNoShift( + page, + async () => { + await dragDrawing(page, { x: 914, y: 498 }, { x: 954, y: 538 }) + await expect(line(page)).toContainText( + dict['editor.annotations.message.moved.zone'], + ) + }, + SWAPS, + ) + const [first] = await shownPoints(page) + expect(Math.abs(first[0] - (stored[0][0] + 40))).toBeLessThan(3) + await undo(page) + await expect.poll(() => shownPoints(page)).toEqual(stored) + }) + + test('Thoraciques: redraw accepted, then refused, the old outline kept meanwhile', async ({ + page, + requests, + }) => { + const actor = await openThoracic(page) + requests.forbid(actor.account.email, actor.account.password) + await pickAnnotation(page, dict, THORACIC) + const stored = await shownPoints(page) + + // Accepted: four clicks, « Fermer le tracé », one commit, every property kept. + await expectNoShift( + page, + () => button(page, 'editor.annotations.redraw').click(), + SWAPS, + ) + for (const [x, y] of [ + [850, 440], + [1100, 470], + [1100, 560], + [850, 545], + ]) + await expectNoShift(page, () => clickAt(page, x, y), SWAPS) + await expect(page.getByTestId('overlay-old-place')).toBeAttached() + await expectNoShift( + page, + async () => { + await button(page, 'editor.annotations.trace_close').click() + await expect(line(page)).toContainText( + dict['editor.annotations.message.redrawn.zone'], + ) + }, + SWAPS, + ) + await expect(selectionTag(page)).toContainText('Vertèbres thoraciques') + expect(await count(page)).toBe(4) + await undo(page) + await expect.poll(() => shownPoints(page)).toEqual(stored) + + // Refused: a sliver; the tracing stays open with the core's message, then cancelled. + await button(page, 'editor.annotations.redraw').click() + for (const [x, y] of [ + [900, 450], + [1100, 452], + [1300, 455], + ]) + await clickAt(page, x, y) + await expectNoShift( + page, + async () => { + await button(page, 'editor.annotations.trace_close').click() + await expect(page.getByTestId('edit-strip-title')).toHaveText( + dict['editor.annotations.strip.close_refused'], + ) + }, + SWAPS, + ) + await expect(button(page, 'editor.annotations.trace_close')).toBeVisible() + await expectNoShift( + page, + () => button(page, 'editor.annotations.trace_cancel').click(), + SWAPS, + ) + await expect.poll(() => shownPoints(page)).toEqual(stored) + }) + + test('a click inside Thoraciques on C7-T1 selects the point drawn on top', async ({ + page, + requests, + }) => { + const actor = await openThoracic(page) + requests.forbid(actor.account.email, actor.account.password) + await clickAt(page, 865, 528) + await expect(selectionTag(page)).toContainText('C7-T1') + + // Thoraciques selected: zoomed at C7-T1 so that its vertex handles leave room, a click + // inside both shapes still selects the point (the selection's interior comes after). + await pickAnnotation(page, dict, THORACIC) + const at = await clientOf(page, 870, 515) + await page.mouse.move(at.x, at.y) + await page.keyboard.down('Control') + for (let notch = 0; notch < 14; notch++) await page.mouse.wheel(0, -100) + await page.keyboard.up('Control') + // R-18: zoomed enough, every « + » shows and the zoom line is gone. + await expect(page.getByTestId('edit-strip-notice')).not.toContainText( + dict['editor.annotations.strip.zoom_hint'], + ) + await clickAt(page, 870, 515) + await expect(selectionTag(page)).toContainText('C7-T1') + }) +}) diff --git a/apps/app/e2e/support/editor.ts b/apps/app/e2e/support/editor.ts index 053006d9..4760f3aa 100644 --- a/apps/app/e2e/support/editor.ts +++ b/apps/app/e2e/support/editor.ts @@ -676,10 +676,39 @@ export async function clickDrawing(page: Page, x: number, y: number) { await page.mouse.click(at.x, at.y) } -/** The geometry fields of the open creation panel or properties panel. */ +/** The geometry fields of the open creation panel (until U2 Task 7) or repair dialog. */ export const geometryField = (page: Page, dict: Dict, key: string) => page.getByLabel(dict[`editor.annotations.geometry.${key}`], { exact: true }) +/** + * The selected shape as the overlay draws it, its circle or polygon: read `cx`, `cy`, `r` + * or `points` (U2 Task 5: the coordinate fields left the properties panel). During a + * pending move it draws the preview; the stored place is `storedShape`. + */ +export const shownShape = (page: Page) => + page.getByTestId('overlay-selection').locator('circle, polygon').first() + +/** The stored shape while a preview moves it: the old place in grey dashes. */ +export const storedShape = (page: Page) => + page.getByTestId('overlay-old-place').locator('circle, polygon').first() + +/** One number of the shown shape (`cx`, `cy`, `r`). */ +export async function shownNumber(page: Page, name: string): Promise { + return Number(await shownShape(page).getAttribute(name)) +} + +/** The vertices of the shown polygon, from its `points` attribute. */ +export async function shownPoints(page: Page): Promise { + const points = (await shownShape(page).getAttribute('points')) ?? '' + return points + .trim() + .split(/\s+/) + .map((pair) => pair.split(',').map(Number)) +} + +/** The page's own rounding of a coordinate (0.01 grid). */ +export const round2 = (value: number) => Math.round(value * 100) / 100 + /** A point annotation of the fixtures (a circle in drawing units, reviewed). */ export function pointOf( id: string, diff --git a/apps/app/src/components/editor/annotations/AnnotationCanvas.tsx b/apps/app/src/components/editor/annotations/AnnotationCanvas.tsx index 8d74700c..833a985a 100644 --- a/apps/app/src/components/editor/annotations/AnnotationCanvas.tsx +++ b/apps/app/src/components/editor/annotations/AnnotationCanvas.tsx @@ -13,6 +13,8 @@ import { } from '@/editor/annotations/useCanvasBuild' import { useCanvasGestures } from '@/editor/annotations/useCanvasGestures' import type { MoveTarget } from '@/editor/annotations/useBlockDrag' +import type { Drop } from '@/editor/annotations/usePlacement' +import type { HandleAction } from '@/editor/annotations/usePressGesture' import type { ToolId } from '@/editor/annotations/uiState' import { useT } from '@/i18n/useT' import AnnotationOverlay, { type OverlayProps } from './AnnotationOverlay' @@ -27,7 +29,7 @@ type OverlayData = Omit< /** The handle layer's content: the handle and its keys (the layer measures itself). */ export type HandleData = Pick< HandleLayerProps, - 'handle' | 'onKeyDown' | 'onBlur' + 'handle' | 'onKeyDown' | 'onBlur' | 'zone' | 'zoneKeys' | 'onInsertsHidden' > export interface AnnotationCanvasProps { @@ -43,9 +45,10 @@ export interface AnnotationCanvasProps { /** The composed root as rebuilt (with its view); null on failure. */ onRoot: (root: RootAttributes | null) => void onSelect: (id: string) => void - /** A click with a drawing tool, in drawing units. */ - onPlace: (at: XY) => void - onDrop: (id: string, geometry: Geometry) => void + /** A click with a drawing tool, in drawing units, and its closing reach (R-11). */ + onPlace: (at: XY, reach: number) => void + onDrop: Drop + onHandle: (action: HandleAction) => void onDeselect: () => void onTraceKey: (event: KeyboardEvent) => void } @@ -88,7 +91,11 @@ export default function AnnotationCanvas(props: AnnotationCanvasProps) { svgRef: overlay, dragged: gestures.drag, }, - handles: { ...props.handles, scale: gestures.framing.framing.scale }, + handles: { + ...props.handles, + scale: gestures.framing.framing.scale, + dragged: gestures.drag, + }, }} /> @@ -144,7 +151,7 @@ interface LayerProps { root: RootAttributes | null transform: string overlay: Omit - handles: HandleData & { scale: number } + handles: HandleData & { scale: number; dragged: Geometry | null } } /** diff --git a/apps/app/src/components/editor/annotations/AnnotationOverlay.tsx b/apps/app/src/components/editor/annotations/AnnotationOverlay.tsx index 80e834da..33184c5d 100644 --- a/apps/app/src/components/editor/annotations/AnnotationOverlay.tsx +++ b/apps/app/src/components/editor/annotations/AnnotationOverlay.tsx @@ -19,6 +19,8 @@ export interface OverlayProps { pending: Geometry | null tracing: Point[] | null correction: Correction | null + /** A redraw runs: the stored outline stays as the old place until the close (06 C). */ + redrawing: boolean } const STROKE = { fill: 'none', vectorEffect: 'non-scaling-stroke' } as const @@ -130,7 +132,8 @@ export default function AnnotationOverlay(props: OverlayProps) { const size = frame ? Math.max(frame.w, frame.h) / 200 : 1 const preview = usePreviewOf(props.selectedId) const moved = props.dragged ?? preview - const shown = moved ?? selected + const old = moved !== null || props.redrawing + const shown = props.redrawing ? null : (moved ?? selected) return ( - {moved && selected && isEditable(selected) && ( + {old && selected && isEditable(selected) && ( @@ -155,10 +158,10 @@ export default function AnnotationOverlay(props: OverlayProps) { )} {shown && isEditable(shown) && ( - <> + - + )} {pending && ( -/** - * The move mode belongs to the selection: another selection (a list row, a view change) - * ends it. A read-only flip keeps the body and its selection, so it suspends the mode - * instead (R-14). - */ -function useModeFollowsSelection(selectedId: string | null) { - const modeId = useAnnotationWork((s) => s.mode?.annotationId ?? null) - useEffect(() => { - if (modeId === null || modeId === selectedId) return - const { mode } = useAnnotationWork.getState() - endMode() - // Never silent (R-13): a started move that ends this way is said. - if (mode?.started) useAnnotationWork.setState({ dropped: mode.kind }) - }, [modeId, selectedId]) -} - -/** - * R-13: a started mode a change made elsewhere dropped is said on the line, once the body - * is shown (a drop while read-only is said on the way back). - */ -function useDroppedNotice(message: GestureMessages) { - const t = useT() - const visible = usePlaceVisible() - const dropped = useAnnotationWork((s) => s.dropped) - const show = message.show - useEffect(() => { - if (dropped === null || !visible) return - useAnnotationWork.setState({ dropped: null }) - const text = t(`editor.annotations.dropped.${dropped}`) - show(text, { undo: false, tone: 'info' }) - }, [dropped, visible, show, t]) -} - export default function EditableAnnotations(props: Props) { const scene = useScene(props) const work = useWork(scene) @@ -206,7 +195,10 @@ export default function EditableAnnotations(props: Props) { const { asideRef, byDrawing } = useSelectionEscape( selected?.id ?? null, () => scene.dispatch({ type: 'select', id: null }), - visible && selected !== undefined && ui.tracing === null, + // A redraw's Escape cancels it at once (R-12); a new tracing keeps its own keys. + visible && + selected !== undefined && + (ui.tracing === null || ui.tracing.target === 'replace'), { editable: true, creating: ui.pending !== null }, ) return ( @@ -222,8 +214,6 @@ export default function EditableAnnotations(props: Props) { ) } -type Placement = ReturnType - /** A move that drops the drawing's work asks first (R-12): the action runs once allowed. */ const guarded = (action: () => void) => () => { if (guardDrawing(action)) action() @@ -265,7 +255,7 @@ function CanvasColumn({ function useHandle(target: Annotation | null, doc: AnatomicalSheetDocument) { const t = useT() const locale = useLocaleStore((s) => s.locale) - if (!target?.geometry) return null + if (target?.geometry?.type !== 'circle') return null const name = annotationName(target, doc.views, locale) const kind = t(`editor.annotations.kind.${target.kind}`) const label = t('editor.annotations.handle.shape') @@ -292,6 +282,8 @@ function CanvasStage({ const shown = usePlaceVisible() const { doc, ui, dispatch, model, frame, selected } = scene const handle = useHandle(shown ? work.target : null, doc) + const points = shown ? handledPoints(work.target?.geometry ?? null) : null + const zone = points && { annotationId: work.target!.id, points } const view = doc.views.find((v) => v.id === scene.viewId) const blocked = !model.measured || doc.categories.length === 0 if (!view) return null @@ -307,6 +299,9 @@ function CanvasStage({ handle, onKeyDown: work.edit.onHandleKey, onBlur: work.edit.onHandleBlur, + zone, + zoneKeys: work.zone, + onInsertsHidden: work.setInsertsHidden, }} tools={{ tool: ui.tool, @@ -318,6 +313,7 @@ function CanvasStage({ onSelect={(id) => dispatch({ type: 'select', id })} onPlace={work.placement.onPlace} onDrop={work.placement.onDrop} + onHandle={work.zone.onHandle} onDeselect={onDeselect} onTraceKey={work.placement.onTraceKey} /> @@ -379,7 +375,6 @@ function SidePanel({ readOnly={false} geometryLocked={!model.measured} dispatch={dispatch} - context={context} navigate={scene.navigate} // « Tout afficher » leaves the selection: a started move asks first (R-12). onShowAll={guarded(() => dispatch({ type: 'select', id: null }))} @@ -399,14 +394,13 @@ function moveTargetOf( : null } -/** The selected point or link circle, when it can be moved now (R-9: its handle). */ -function circleTargetOf( +/** The selection when it can be moved now: a circle (its handle) or a polygon (R-9). */ +function movableOf( selected: Annotation | undefined, model: ViewModel, tool: ToolId, ): Annotation | null { - const movable = moveTargetOf(selected, model, tool) !== null - return movable && selected?.geometry?.type === 'circle' ? selected : null + return moveTargetOf(selected, model, tool) !== null ? selected! : null } function overlayOf( @@ -423,6 +417,7 @@ function overlayOf( pending: ui.pending?.geometry ?? null, tracing: ui.tracing?.points ?? null, correction: ui.pending?.correction ?? null, + redrawing: ui.tracing?.target === 'replace', } } @@ -433,31 +428,47 @@ function overlayOf( function SceneStrip({ scene, work }: { scene: Scene; work: Work }) { const t = useT() const locale = useLocaleStore((s) => s.locale) - const notice = useStripNotice(scene, work.message.message) - const moving = useAnnotationWork((s) => s.mode?.kind === 'move') - useMoveFocusReturn(moving) + const notice = useStripNotice(scene, work) + const mode = useAnnotationWork((s) => + s.mode?.kind === 'move' ? s.mode : null, + ) + useMoveFocusReturn(mode !== null) const { ui, selected, doc } = scene - const lead = moving + const chosenVertex = useChosenVertex(selected?.id) + const lead = mode ? { - title: t('editor.annotations.move.point'), + title: t(moveTitleKey(mode, work.target?.kind)), detail: t('editor.annotations.move.hint'), icon: 'move' as const, } - : stripLeadOf(ui, selected, doc, { t, locale }) + : stripLeadOf(ui, selected, doc, { t, locale, chosenVertex }) + const commandsKey = commandsKeyOf( + ui, + mode !== null, + work.target, + chosenVertex, + ) return ( } - commandsKey={commandsKeyOf(ui, moving, work.target?.kind === 'point')} + commandsKey={commandsKey} /> ) } -function commandsKeyOf(ui: UiState, moving: boolean, point: boolean) { +/** One box per set of commands: a wider set never moves an existing box (A14). */ +function commandsKeyOf( + ui: UiState, + moving: boolean, + target: Annotation | null, + chosen: number | null, +) { if (ui.tracing) return 'tracing' if (moving) return 'move' - return point ? 'point' : `tool-${ui.tool}` + if (target?.geometry?.type === 'polygon') return `zone-${chosen !== null}` + return target?.kind === 'point' ? 'point' : `tool-${ui.tool}` } /** A tracing's commands, a movable point's, or the Point tool's size (A5). */ @@ -467,11 +478,18 @@ function SceneCommands({ scene, work }: { scene: Scene; work: Work }) { return ( dispatch({ type: 'trace_cancel' })} /> ) } + if (work.target?.geometry?.type === 'polygon') { + const edit = work.edit + return ( + + ) + } // A link circle keeps its handle but has no size and no move mode (R-10; no label). if (work.target?.kind === 'point') { const props = { doc, viewId, frame, edit: work.edit } @@ -497,10 +515,12 @@ function SceneCommands({ scene, work }: { scene: Scene; work: Work }) { */ function useStripNotice( scene: Scene, - message: ShownMessage | null, + work: Pick, ): StripNotice | null { const t = useT() const issues = useGeometryIssues(scene.selected?.id ?? '') + const inMode = useAnnotationWork((s) => s.mode !== null) + const message: ShownMessage | null = work.message.message const { ui, model, doc } = scene if (ui.hint) return { tone: 'error', text: ui.hint } if (message?.tone === 'error') { @@ -509,6 +529,10 @@ function useStripNotice( if (scene.selected && issues.length > 0) { return { tone: 'error', text: issues[0]!, more: issues.length - 1 } } + // R-18: a « + » hidden for its short segment; never in a mode (move, redraw). + if (work.insertsHidden && !inMode && !ui.tracing) { + return { tone: 'info', text: t('editor.annotations.strip.zoom_hint') } + } if (!model.measured) return unmeasuredNotice(scene, t) if (doc.categories.length === 0) { return { tone: 'info', text: t('editor.annotations.no_category') } @@ -534,54 +558,3 @@ function unmeasuredNotice( }, } } - -const COMMAND = 'min-h-11 xl:min-h-9' - -/** While a zone or link is traced: close (3 vertices at least), take one back, or drop it. */ -function TracingCommands({ - count, - placement, - onCancel, -}: { - count: number - placement: Placement - onCancel: () => void -}) { - const t = useT() - return ( -
- - - -
- ) -} diff --git a/apps/app/src/components/editor/annotations/HandleLayer.tsx b/apps/app/src/components/editor/annotations/HandleLayer.tsx index 3a687250..0c3848d8 100644 --- a/apps/app/src/components/editor/annotations/HandleLayer.tsx +++ b/apps/app/src/components/editor/annotations/HandleLayer.tsx @@ -1,4 +1,5 @@ import { + useEffect, useLayoutEffect, useRef, useState, @@ -13,6 +14,11 @@ import { type HandleSizes, } from '@/editor/annotations/handleSize' import { useAnnotationWork } from '@/editor/annotations/workStore' +import ZoneHandles, { + shownInserts, + type ZoneHandle, + type ZoneKeys, +} from './ZoneHandles' /** The selected point (or link circle) whose handle the layer draws. */ export interface PointHandle { @@ -30,6 +36,13 @@ export interface HandleLayerProps { handle: PointHandle | null onKeyDown: (event: KeyboardEvent) => void onBlur: (event: FocusEvent) => void + /** The selected polygon under the cap, and its handles' keys. */ + zone: ZoneHandle | null + zoneKeys: ZoneKeys + /** The canvas-local drag preview: the handles follow it. */ + dragged: Geometry | null + /** Whether a « + » is hidden for its short segment (R-18's hint). */ + onInsertsHidden: (hidden: boolean) => void } /** The svg's own box in CSS px before the framing's transform. */ @@ -79,6 +92,8 @@ export default function HandleLayer(props: HandleLayerProps) { const svg = useRef(null) const unit = unitsPerPx(props.viewBox, useBoxSize(svg), props.scale) const sizes = useHandleSizes() + const zone = useShownZone(props.zone, props.dragged) + useReportHidden(zone, { unit, sizes }, props.onInsertsHidden) return ( )} + {zone && ( + + )} ) } +/** The polygon as shown now: the drag in flight, the pending preview, else the stored one. */ +function useShownZone( + zone: ZoneHandle | null, + dragged: Geometry | null, +): ZoneHandle | null { + const id = zone?.annotationId ?? null + const preview = useAnnotationWork((s) => + id !== null && s.preview?.annotationId === id ? s.preview.geometry : null, + ) + const shown = dragged ?? preview + if (!zone || shown?.type !== 'polygon') return zone + return { ...zone, points: shown.points } +} + +function useReportHidden( + zone: ZoneHandle | null, + scale: Parameters[1], + report: (hidden: boolean) => void, +) { + const hidden = zone ? shownInserts(zone.points, scale).includes(false) : false + useEffect(() => report(hidden), [hidden, report]) +} + function PointHandleShape({ handle, unit, diff --git a/apps/app/src/components/editor/annotations/PropertiesPanel.tsx b/apps/app/src/components/editor/annotations/PropertiesPanel.tsx index a6f94260..72b233ae 100644 --- a/apps/app/src/components/editor/annotations/PropertiesPanel.tsx +++ b/apps/app/src/components/editor/annotations/PropertiesPanel.tsx @@ -3,19 +3,15 @@ import { flushSync } from 'react-dom' import type { AnatomicalSheetDocument, Annotation, - Geometry, Marking, } from '@faunosteo/core-wasm/types' import ActionButton from '@/components/editor/fields/ActionButton' import DeleteDialog from '@/components/editor/DeleteDialog' import Button from '@/components/ui/Button' -import { - updateGeometry, - type CommitContext, -} from '@/editor/annotations/annotationCommit' import { useDeselect } from '@/editor/annotations/deselect' import EditorGlyph from '@/components/editor/EditorGlyph' import { isEditable } from '@/editor/annotations/geometryEdit' +import { beginRedraw } from '@/editor/annotations/redraw' import type { UiAction } from '@/editor/annotations/uiState' import { geometryErrorsById } from '@/editor/issues' import { focusRow } from '@/editor/focusRequest' @@ -26,9 +22,7 @@ import { useEditorStore } from '@/editor/state/editorStore' import { useT } from '@/i18n/useT' import { useLocaleStore } from '@/state/localeStore' import AnnotationFields from './AnnotationFields' -import type { ApplyResult } from './GeometryGroup' import { annotationName } from './AnnotationList' -import GeometryGroup from './GeometryGroup' import ReviewBadge from './ReviewBadge' export interface PropertiesPanelProps { @@ -39,7 +33,6 @@ export interface PropertiesPanelProps { /** The view is not measured: geometry is shown as text only, the rest stays editable. */ geometryLocked: boolean dispatch: Dispatch - context: CommitContext navigate: EditorPlaceProps['navigate'] /** Clears the selection: the overview shows again. */ onShowAll: () => void @@ -142,25 +135,22 @@ function DeselectButton({ ) } +/** + * The geometry's state: no coordinate field (A8, U2 Task 5: circles and polygons are + * edited on the drawing); a path or a missing geometry says so and offers the redraw. + */ function GeometrySection(props: PropertiesPanelProps) { const t = useT() const { annotation, readOnly, geometryLocked } = props const locked = readOnly || geometryLocked const { geometry } = annotation + const editable = isEditable(geometry) return (
{geometryLocked && !readOnly && ( )} - {isEditable(geometry) ? ( - applyGeometry(annotation, next, props.context)} - /> - ) : ( + {!editable && (

{t( geometry === null @@ -169,7 +159,7 @@ function GeometrySection(props: PropertiesPanelProps) { )}

)} - {!locked && !isEditable(geometry) && ( + {!locked && !editable && ( )} @@ -177,15 +167,6 @@ function GeometrySection(props: PropertiesPanelProps) { ) } -function applyGeometry( - annotation: Annotation, - next: Geometry, - context: CommitContext, -): ApplyResult { - const result = updateGeometry(annotation, next, context) - return result.ok ? { ok: true } : { ok: false, messages: result.messages } -} - function TraceReplacement({ id, dispatch, @@ -199,9 +180,8 @@ function TraceReplacement({ type="button" variant="secondary" size="sm" - onClick={() => - dispatch({ type: 'trace_start', target: 'replace', annotationId: id }) - } + // The same redraw as « Redessiner »: the drawing guard asks before it is lost. + onClick={() => beginRedraw(id, dispatch)} > {t('editor.annotations.replace_polygon')} diff --git a/apps/app/src/components/editor/annotations/TracingCommands.tsx b/apps/app/src/components/editor/annotations/TracingCommands.tsx new file mode 100644 index 00000000..4773311e --- /dev/null +++ b/apps/app/src/components/editor/annotations/TracingCommands.tsx @@ -0,0 +1,57 @@ +import Button from '@/components/ui/Button' +import { useT } from '@/i18n/useT' + +const COMMAND = 'min-h-11 xl:min-h-9' + +export interface TracingCommandsProps { + count: number + onClose: () => void + onPop: () => void + onCancel: () => void +} + +/** While a zone or link is traced: close (3 vertices at least), take one back, or drop it. */ +export default function TracingCommands({ + count, + onClose, + onPop, + onCancel, +}: TracingCommandsProps) { + const t = useT() + return ( +
+ + + +
+ ) +} diff --git a/apps/app/src/components/editor/annotations/ZoneCommands.tsx b/apps/app/src/components/editor/annotations/ZoneCommands.tsx new file mode 100644 index 00000000..9c86367e --- /dev/null +++ b/apps/app/src/components/editor/annotations/ZoneCommands.tsx @@ -0,0 +1,99 @@ +import type { Dispatch } from 'react' +import type { Annotation } from '@faunosteo/core-wasm/types' +import Button from '@/components/ui/Button' +import { beginRedraw } from '@/editor/annotations/redraw' +import type { UiAction } from '@/editor/annotations/uiState' +import type { PointEdit } from '@/editor/annotations/usePointEdit' +import { + useAnnotationWork, + type ModeWork, +} from '@/editor/annotations/workStore' +import { useT } from '@/i18n/useT' +import EditorGlyph from '../EditorGlyph' +import MoveModeBar from './MoveModeBar' + +const COMMAND = 'min-h-11 gap-1.5 xl:min-h-9' + +/** The move mode's title: « Déplacer le sommet », « … la zone » or « … le point ». */ +export function moveTitleKey( + mode: ModeWork, + kind: Annotation['kind'] | undefined, +) { + if (mode.vertex !== null) return 'editor.annotations.move.vertex' + return kind === 'zone' + ? 'editor.annotations.move.zone' + : 'editor.annotations.move.point' +} + +/** The chosen vertex of `annotationId`, as the work store holds it. */ +export function useChosenVertex( + annotationId: string | undefined, +): number | null { + return useAnnotationWork((s) => + annotationId !== undefined && s.chosen?.annotationId === annotationId + ? s.chosen.vertex + : null, + ) +} + +export interface ZoneCommandsProps { + /** The selected polygon, movable now. */ + annotation: Annotation + edit: PointEdit + dispatch: Dispatch +} + +/** + * The strip's commands for a selected polygon (board 05): « Déplacer la zone » (« Déplacer + * le sommet » while a vertex is chosen) and « Redessiner »; during the move mode, its bar + * (board 06 B). A link traced as a polygon gets « Redessiner » only (no move label). + */ +export default function ZoneCommands({ + annotation, + edit, + dispatch, +}: ZoneCommandsProps) { + const t = useT() + const chosen = useChosenVertex(annotation.id) + const inMode = useAnnotationWork( + (s) => s.mode?.kind === 'move' && s.mode.annotationId === annotation.id, + ) + if (inMode) { + return ( + + ) + } + const moveKey = chosen === null ? 'move.zone' : 'move.vertex' + return ( + <> + {annotation.kind === 'zone' && ( + + )} + + + ) +} diff --git a/apps/app/src/components/editor/annotations/ZoneHandles.tsx b/apps/app/src/components/editor/annotations/ZoneHandles.tsx new file mode 100644 index 00000000..8099bbbb --- /dev/null +++ b/apps/app/src/components/editor/annotations/ZoneHandles.tsx @@ -0,0 +1,325 @@ +import { useLayoutEffect, useRef, type KeyboardEvent } from 'react' +import type { Point } from '@faunosteo/core-wasm/types' +import type { HandleSizes } from '@/editor/annotations/handleSize' +import { MIN_VERTICES, showsInsert } from '@/editor/annotations/polygonEdit' +import type { ZoneEdit } from '@/editor/annotations/useZoneEdit' +import { useAnnotationWork } from '@/editor/annotations/workStore' +import { useT } from '@/i18n/useT' + +/** The selected polygon whose vertex, « + » and « − » handles the layer draws. */ +export interface ZoneHandle { + annotationId: string + points: Point[] +} + +export type ZoneKeys = Pick< + ZoneEdit, + | 'onVertexKey' + | 'onVertexFocus' + | 'onVertexBlur' + | 'onInsertKey' + | 'onRemoveKey' +> + +interface Scale { + /** Drawing units per CSS px. */ + unit: number + sizes: HandleSizes +} + +const segmentPx = (a: Point, b: Point, unit: number) => + Math.hypot(b[0] - a[0], b[1] - a[1]) / unit + +/** R-9: the « + » of segment `i` (vertex i to the next) shows at the current zoom. */ +export function shownInserts(points: readonly Point[], { unit, sizes }: Scale) { + return points.map((p, i) => + showsInsert(segmentPx(p, points[(i + 1) % points.length], unit), sizes.hit), + ) +} + +const RING = 'invisible group-focus-visible:visible' + +function FocusRing({ cx, cy, r }: { cx: number; cy: number; r: number }) { + return ( + + ) +} + +const LINE = { vectorEffect: 'non-scaling-stroke', strokeWidth: 2 } as const + +function Insert({ + at, + after, + label, + scale, + onKeyDown, +}: { + at: [number, number] + after: number + label: string + scale: Scale + onKeyDown: (event: KeyboardEvent) => void +}) { + const { unit, sizes } = scale + const [cx, cy] = at + const r = (sizes.insert / 2) * unit + const arm = r * 0.5 + return ( + + + + + + + ) +} + +function Vertex({ + at, + index, + chosen, + label, + scale, + keys, +}: { + at: Point + index: number + chosen: boolean + label: string + scale: Scale + keys: ZoneKeys +}) { + const { unit, sizes } = scale + const [cx, cy] = at + // A chosen vertex is bigger, filled and ringed: never told by colour alone. + const r = (sizes.vertex / 2 + (chosen ? 2 : 0)) * unit + return ( + keys.onVertexKey(index, event)} + onFocus={() => keys.onVertexFocus(index)} + onBlur={keys.onVertexBlur} + > + {chosen && ( + + )} + + + + + ) +} + +/** The « − » bubble over the chosen vertex (board 05), greyed at three vertices (12 B). */ +function Remove({ + at, + index, + disabled, + label, + scale, + onKeyDown, +}: { + at: Point + index: number + disabled: boolean + label: string + scale: Scale + onKeyDown: (event: KeyboardEvent) => void +}) { + const { unit, sizes } = scale + const w = sizes.bubble.w * unit + const h = sizes.bubble.h * unit + const x = at[0] - w / 2 + const y = at[1] - (sizes.vertex / 2 + 6) * unit - h + const fill = disabled + ? 'var(--color-ink-muted)' + : 'var(--color-danger-strong)' + return ( + + + + + + ) +} + +/** The chosen vertex of this polygon, as the store holds it now. */ +function useChosen(annotationId: string, count: number): number | null { + return useAnnotationWork((s) => { + const chosen = s.chosen + if (chosen?.annotationId !== annotationId) return null + return chosen.vertex < count ? chosen.vertex : null + }) +} + +/** + * A keyboard choice (« + », Insert, Delete) moves the focus to the vertex now chosen, so + * the keys keep acting where the user looks; a pointer choice leaves the focus alone. + */ +function useFocusFollowsChoice(chosen: number | null) { + const group = useRef(null) + useLayoutEffect(() => { + const active = document.activeElement + if (chosen === null || !group.current?.contains(active)) return + if (active?.getAttribute('data-vertex') === String(chosen)) return + const target = group.current.querySelector(`[data-vertex="${chosen}"]`) + if (target instanceof SVGElement) target.focus() + }, [chosen]) + return group +} + +const midpoint = (a: Point, b: Point): [number, number] => [ + (a[0] + b[0]) / 2, + (a[1] + b[1]) / 2, +] + +/** + * The polygon's handles (docs/ANNOTATION-RENDERING.md « Editor overlay »): the « + » of the + * segments long enough on screen, every vertex, then the « − » bubble of the chosen one, + * in that order (Tab walks them so). No handle covers the interior. + */ +export default function ZoneHandles({ + zone, + scale, + keys, +}: { + zone: ZoneHandle + scale: Scale + keys: ZoneKeys +}) { + const t = useT() + const { points } = zone + const chosen = useChosen(zone.annotationId, points.length) + const group = useFocusFollowsChoice(chosen) + const inserts = shownInserts(points, scale) + const named = (key: string, n: number) => + t(`editor.annotations.handle.${key}`).replace('{n}', String(n + 1)) + return ( + + {points.map((p, i) => + inserts[i] ? ( + keys.onInsertKey(i, event)} + /> + ) : null, + )} + {points.map((p, i) => ( + + ))} + {chosen !== null && ( + keys.onRemoveKey(chosen, event)} + /> + )} + + ) +} diff --git a/apps/app/src/components/editor/tabs/AnnotationsTab.tsx b/apps/app/src/components/editor/tabs/AnnotationsTab.tsx index 74ada879..257d5bb6 100644 --- a/apps/app/src/components/editor/tabs/AnnotationsTab.tsx +++ b/apps/app/src/components/editor/tabs/AnnotationsTab.tsx @@ -208,7 +208,6 @@ function ReadOnlyAnnotations({ readOnly geometryLocked={!model.measured} dispatch={() => undefined} - context={{ t: (key) => key, locale }} navigate={navigate} onShowAll={() => setSelectedId(null)} /> diff --git a/apps/app/src/editor/annotations/gesture.ts b/apps/app/src/editor/annotations/gesture.ts index 5b9366c9..7b515515 100644 --- a/apps/app/src/editor/annotations/gesture.ts +++ b/apps/app/src/editor/annotations/gesture.ts @@ -1,5 +1,6 @@ import type { Geometry } from '@faunosteo/core-wasm/types' import { round2, type XY } from './frame' +import { moveVertex } from './polygonEdit' /** A circle or polygon translated as a block by a drawing-unit delta, rounded to 0.01. */ export function translatedGeometry( @@ -25,6 +26,21 @@ export function translatedGeometry( return null } +/** `geometry` moved by `delta`: as a block, or only its vertex `vertex` (a polygon's). */ +export function movedBy( + geometry: Geometry, + delta: XY, + vertex: number | null, +): Geometry | null { + if (vertex === null) return translatedGeometry(geometry, delta) + if (geometry.type !== 'polygon') return null + const at = geometry.points[vertex] + if (!at) return null + const to = { x: at[0] + delta.x, y: at[1] + delta.y } + const points = moveVertex(geometry.points, vertex, to) + return points && { type: 'polygon', points } +} + interface Matrix { a: number b: number @@ -50,3 +66,9 @@ export function clientToDrawing( y: inverse.b * client.x + inverse.d * client.y + inverse.f, } } + +/** Drawing units per client px, through the same matrix; null without one. */ +export function drawingPerClientPx(svg: SVGSVGElement | null): number | null { + const inverse: Matrix | undefined = svg?.getScreenCTM?.()?.inverse() + return inverse ? Math.hypot(inverse.a, inverse.b) : null +} diff --git a/apps/app/src/editor/annotations/handleSize.ts b/apps/app/src/editor/annotations/handleSize.ts index c170ae92..9b5a48fb 100644 --- a/apps/app/src/editor/annotations/handleSize.ts +++ b/apps/app/src/editor/annotations/handleSize.ts @@ -6,10 +6,24 @@ export interface HandleSizes { insert: number /** The radius around a handle's centre that a press reaches. */ hit: number + /** The « − » bubble over the chosen vertex. */ + bubble: { w: number; h: number } } -const FINE: HandleSizes = { vertex: 12, insert: 16, hit: 10 } -const COARSE: HandleSizes = { vertex: 18, insert: 24, hit: 22 } +// shortcut: the fine bubble size is read off board 05 (no number given by R-9). Upgrade: +// take the owner's value if the trial asks for another. +const FINE: HandleSizes = { + vertex: 12, + insert: 16, + hit: 10, + bubble: { w: 28, h: 22 }, +} +const COARSE: HandleSizes = { + vertex: 18, + insert: 24, + hit: 22, + bubble: { w: 44, h: 36 }, +} function deviceSizes(): HandleSizes { const coarse = diff --git a/apps/app/src/editor/annotations/modeEnds.ts b/apps/app/src/editor/annotations/modeEnds.ts new file mode 100644 index 00000000..12d1b2c1 --- /dev/null +++ b/apps/app/src/editor/annotations/modeEnds.ts @@ -0,0 +1,38 @@ +import { useEffect } from 'react' +import { usePlaceVisible } from '@/lib/placeVisibility' +import { useT } from '@/i18n/useT' +import type { GestureMessages } from './useGestureMessage' +import { endMode, useAnnotationWork } from './workStore' + +/** + * The move mode belongs to the selection: another selection (a list row, a view change) + * ends it. A read-only flip keeps the body and its selection, so it suspends the mode + * instead (R-14). + */ +export function useModeFollowsSelection(selectedId: string | null) { + const modeId = useAnnotationWork((s) => s.mode?.annotationId ?? null) + useEffect(() => { + if (modeId === null || modeId === selectedId) return + const { mode } = useAnnotationWork.getState() + endMode() + // Never silent (R-13): a started move that ends this way is said. + if (mode?.started) useAnnotationWork.setState({ dropped: mode.kind }) + }, [modeId, selectedId]) +} + +/** + * R-13: a started mode a change made elsewhere dropped is said on the line, once the body + * is shown (a drop while read-only is said on the way back). + */ +export function useDroppedNotice(message: GestureMessages) { + const t = useT() + const visible = usePlaceVisible() + const dropped = useAnnotationWork((s) => s.dropped) + const show = message.show + useEffect(() => { + if (dropped === null || !visible) return + useAnnotationWork.setState({ dropped: null }) + const text = t(`editor.annotations.dropped.${dropped}`) + show(text, { undo: false, tone: 'info' }) + }, [dropped, visible, show, t]) +} diff --git a/apps/app/src/editor/annotations/polygonEdit.ts b/apps/app/src/editor/annotations/polygonEdit.ts new file mode 100644 index 00000000..fab881f9 --- /dev/null +++ b/apps/app/src/editor/annotations/polygonEdit.ts @@ -0,0 +1,64 @@ +import type { Point } from '@faunosteo/core-wasm/types' +import { round2, type XY } from './frame' + +/** T18 (R-7): above this many vertices, outline and message, no handle. */ +export const HANDLE_CAP = 40 +export const MIN_VERTICES = 3 + +const inRange = (points: readonly Point[], i: number) => + Number.isInteger(i) && i >= 0 && i < points.length + +/** « + » on the segment from vertex `after` to the next (wrapping): its midpoint, 0.01 grid. */ +export function insertMidpoint( + points: readonly Point[], + after: number, +): Point[] | null { + if (!inRange(points, after)) return null + const [ax, ay] = points[after] + const [bx, by] = points[(after + 1) % points.length] + const middle: Point = [round2((ax + bx) / 2), round2((ay + by) / 2)] + return [...points.slice(0, after + 1), middle, ...points.slice(after + 1)] +} + +/** « − »: null at 3 vertices (board 12 B reason shown by the caller). */ +export function removeVertex( + points: readonly Point[], + index: number, +): Point[] | null { + if (!inRange(points, index) || points.length <= MIN_VERTICES) return null + return points.filter((_, i) => i !== index) +} + +export function moveVertex( + points: readonly Point[], + index: number, + to: XY, +): Point[] | null { + if ( + !inRange(points, index) || + !Number.isFinite(to.x) || + !Number.isFinite(to.y) + ) + return null + return points.map( + (p, i): Point => (i === index ? [round2(to.x), round2(to.y)] : p), + ) +} + +/** A vertex released on itself or on a neighbour is no change (no commit). */ +export function isNoOpMove( + points: readonly Point[], + index: number, + moved: readonly Point[], +): boolean { + const n = points.length + const [x, y] = moved[index] + return [index, (index + 1) % n, (index + n - 1) % n].some( + (j) => points[j][0] === x && points[j][1] === y, + ) +} + +/** R-9: a « + » shows only when its segment is at least two hit radii long on screen. */ +export function showsInsert(segmentPx: number, hitRadiusPx: number): boolean { + return segmentPx >= 2 * hitRadiusPx +} diff --git a/apps/app/src/editor/annotations/press.ts b/apps/app/src/editor/annotations/press.ts index 0def7390..41eea31d 100644 --- a/apps/app/src/editor/annotations/press.ts +++ b/apps/app/src/editor/annotations/press.ts @@ -7,6 +7,12 @@ export const SLOP_PX: Readonly> = { pen: 6, touch: 10, } +/** R-11: CSS px from the first vertex within which a click closes a tracing. */ +export const CLOSE_PX: Readonly> = { + mouse: 12, + pen: 22, + touch: 22, +} export const DOUBLE_MS = 400 export const DOUBLE_PX = 8 diff --git a/apps/app/src/editor/annotations/previewCommit.ts b/apps/app/src/editor/annotations/previewCommit.ts index 6dd7879c..26a21577 100644 --- a/apps/app/src/editor/annotations/previewCommit.ts +++ b/apps/app/src/editor/annotations/previewCommit.ts @@ -1,6 +1,6 @@ import type { Geometry } from '@faunosteo/core-wasm/types' import { useEditorStore } from '../state/editorStore' -import { translatedGeometry } from './gesture' +import { movedBy } from './gesture' import { endMode, setModePreview, @@ -42,19 +42,22 @@ export function shownGeometry( } /** - * One step of the selection by `delta` drawing units: into the move mode when it is on, - * else as a keyboard series (`keys`), stamped with the current text. + * One step of the selection by `delta` drawing units: into the move mode when it is on + * (its vertex, or the shape), else as a keyboard series (`keys`) of the shape or of + * `vertex`, stamped with the current text. */ export function stepSelection( annotationId: string, stored: Geometry, delta: { x: number; y: number }, + vertex: number | null = null, ): void { - const moved = translatedGeometry(shownGeometry(annotationId, stored), delta) + const { mode } = useAnnotationWork.getState() + const inMode = mode?.kind === 'move' + const shown = shownGeometry(annotationId, stored) + const moved = movedBy(shown, delta, inMode ? mode.vertex : vertex) if (!moved) return - if (useAnnotationWork.getState().mode?.kind === 'move') { - return setModePreview(moved, stored) - } + if (inMode) return setModePreview(moved, stored) const base = useEditorStore.getState().documentText const preview: Preview = { annotationId, diff --git a/apps/app/src/editor/annotations/redraw.ts b/apps/app/src/editor/annotations/redraw.ts new file mode 100644 index 00000000..62a3f74a --- /dev/null +++ b/apps/app/src/editor/annotations/redraw.ts @@ -0,0 +1,42 @@ +import { useEffect, useRef, type Dispatch } from 'react' +import { useEditorStore } from '../state/editorStore' +import type { Tracing, UiAction } from './uiState' +import { + endMode, + markRedraw, + startRedraw, + useAnnotationWork, +} from './workStore' + +/** + * « Redessiner » (or « Remplacer par un polygone »): the redraw mode, which the drawing + * guard reads (R-12), and the tracing target `replace` that draws the new polygon. + */ +export function beginRedraw(id: string, dispatch: Dispatch): void { + startRedraw(id, useEditorStore.getState().documentText) + dispatch({ type: 'trace_start', target: 'replace', annotationId: id }) +} + +/** + * The redraw lives in two places, the tab's tracing and the work store's mode; whichever + * ends first ends the other: a tracing gone (closed, « Annuler le tracé », Escape, a + * tool, a view, a selection) ends the mode; a mode gone (« Abandonner », an undo, a + * document change made elsewhere) ends the tracing. The mode is started once the + * tracing holds a vertex, and no longer when it is back to none. + */ +export function useRedrawFollowsTracing( + tracing: Tracing | null, + dispatch: Dispatch, +): void { + const redraw = useAnnotationWork((s) => s.mode?.kind === 'redraw') + const count = tracing?.target === 'replace' ? tracing.points.length : null + // Only the body whose tracing it was ends the mode: another body kept alive has none. + const traced = useRef(false) + useEffect(() => { + const was = traced.current + traced.current = count !== null + if (redraw && count === null && was) endMode() + else if (!redraw && count !== null) dispatch({ type: 'trace_cancel' }) + else if (count !== null) markRedraw(count > 0) + }, [redraw, count, dispatch]) +} diff --git a/apps/app/src/editor/annotations/stripLead.ts b/apps/app/src/editor/annotations/stripLead.ts index 5b7a2079..c8a2a39b 100644 --- a/apps/app/src/editor/annotations/stripLead.ts +++ b/apps/app/src/editor/annotations/stripLead.ts @@ -9,6 +9,7 @@ import type { GlyphName } from '@/components/editor/EditorGlyph' import type { Locale } from '@/i18n/types' import { pluralKey } from '../plural' import type { PendingElement } from './creation' +import { HANDLE_CAP } from './polygonEdit' import type { ToolId, Tracing, UiState } from './uiState' /** The strip's left part: what is selected or in progress, then its type and detail. */ @@ -24,6 +25,8 @@ export interface LeadContext { locale: Locale /** The sheet cannot be edited now: the detail says so (board 33 E). */ readOnly?: boolean + /** The chosen vertex of the selected polygon, said after its count. */ + chosenVertex?: number | null } const ICON: Record = { @@ -45,6 +48,23 @@ function counted( .replace('{kind}', () => kind) } +/** + * « Zone · 9 sommets », « … · sommet 7 choisi », or above the cap (T18) « Zone · 41 + * sommets, trop pour les poignées ». + */ +function polygonDetail(count: number, kind: string, ctx: LeadContext): string { + if (count > HANDLE_CAP && !ctx.readOnly) { + return counted(ctx, 'editor.annotations.strip.too_many', count, kind) + } + const shape = counted(ctx, 'editor.annotations.strip.vertices', count, kind) + const chosen = ctx.chosenVertex + if (chosen === null || chosen === undefined || ctx.readOnly) return shape + return ctx + .t('editor.annotations.strip.vertex_chosen') + .replace('{detail}', () => shape) + .replace('{n}', String(chosen + 1)) +} + /** « Point », « Zone · 9 sommets »; « … · fiche en lecture seule » when read-only. */ export function selectionLead( annotation: Annotation, @@ -55,12 +75,7 @@ export function selectionLead( const geometry = annotation.geometry const shape = geometry?.type === 'polygon' - ? counted( - ctx, - 'editor.annotations.strip.vertices', - geometry.points.length, - kind, - ) + ? polygonDetail(geometry.points.length, kind, ctx) : kind return { title: annotationName(annotation, views, ctx.locale), @@ -74,17 +89,22 @@ export function selectionLead( } } -/** A tracing: « Ajouter une zone » or « Redessiner · {nom} », then the vertices placed. */ +/** + * A tracing: « Ajouter une zone » or « Redessiner · {nom} », then the vertices placed; + * « Fermeture refusée » while the core's refusal of its close shows (board 33 A). + */ function tracingLead( tracing: Tracing, replaced: string, - ctx: LeadContext, + ctx: LeadContext & { refused: boolean }, ): StripLead { - const title = - tracing.target === 'replace' - ? ctx - .t('editor.annotations.strip.redraw') - .replace('{name}', () => replaced) + const redraw = ctx + .t('editor.annotations.strip.redraw') + .replace('{name}', () => replaced) + const title = ctx.refused + ? ctx.t('editor.annotations.strip.close_refused') + : tracing.target === 'replace' + ? redraw : ctx.t(`editor.annotations.add.${tracing.target}`) return { title, @@ -149,7 +169,7 @@ export function stripLeadOf( (a) => a.id === ui.tracing?.annotationId, ) const name = replaced ? annotationName(replaced, doc.views, ctx.locale) : '' - return tracingLead(ui.tracing, name, ctx) + return tracingLead(ui.tracing, name, { ...ctx, refused: ui.hint !== null }) } if (selected) return selectionLead(selected, doc.views, ctx) const lead = TOOL_LEAD[ui.tool] diff --git a/apps/app/src/editor/annotations/uiState.ts b/apps/app/src/editor/annotations/uiState.ts index d1ca6661..a2728700 100644 --- a/apps/app/src/editor/annotations/uiState.ts +++ b/apps/app/src/editor/annotations/uiState.ts @@ -60,6 +60,10 @@ const TOOL_OF: Record = { replace: 'zone', } +/** A redraw lends the zone tool to its tracing: whatever ends it gives the select tool back. */ +const toolAfterTracing = (state: UiState): ToolId => + state.tracing?.target === 'replace' ? 'select' : state.tool + export function uiReducer(state: UiState, action: UiAction): UiState { switch (action.type) { case 'view': @@ -69,6 +73,7 @@ export function uiReducer(state: UiState, action: UiAction): UiState { case 'select': return { ...state, + tool: toolAfterTracing(state), selectedId: action.id, pending: null, tracing: null, @@ -124,7 +129,12 @@ export function uiReducer(state: UiState, action: UiAction): UiState { } : state case 'trace_cancel': - return { ...state, tracing: null, hint: null } + return { + ...state, + tool: toolAfterTracing(state), + tracing: null, + hint: null, + } case 'hint': return { ...state, hint: action.hint } case 'filter': diff --git a/apps/app/src/editor/annotations/useBlockDrag.ts b/apps/app/src/editor/annotations/useBlockDrag.ts index aa7112ce..0a0cf845 100644 --- a/apps/app/src/editor/annotations/useBlockDrag.ts +++ b/apps/app/src/editor/annotations/useBlockDrag.ts @@ -2,9 +2,12 @@ import { useEffect, useRef, useState, type RefObject } from 'react' import type { Annotation, Geometry } from '@faunosteo/core-wasm/types' import { useEditorStore } from '../state/editorStore' import type { XY } from './frame' -import { clientToDrawing, translatedGeometry } from './gesture' +import { clientToDrawing, movedBy } from './gesture' +import { isNoOpMove } from './polygonEdit' import { shownGeometry } from './previewCommit' -import { setModePreview } from './workStore' +import type { GeometryChange } from './usePlacement' +import { chooseVertex } from './zoneEdit' +import { setModePreview, useAnnotationWork } from './workStore' import type { EditableGeometry } from './geometryEdit' export interface MoveTarget { @@ -18,7 +21,7 @@ export interface BlockDragInput { /** The selected annotation, when it can be moved (editable, measured, circle or polygon). */ target: MoveTarget | null /** One `update` on the drop; the verdict and the message are the caller's. */ - onDrop: (id: string, geometry: Geometry) => void + onDrop: (id: string, geometry: Geometry, change?: GeometryChange) => boolean } interface Drag { @@ -29,6 +32,8 @@ interface Drag { base: Geometry /** A drag of the move mode (board 06 B): it moves the mode's preview, never commits. */ mode: boolean + /** The vertex dragged alone (a vertex handle, or the mode's chosen vertex). */ + vertex: number | null } function translatedAt( @@ -38,10 +43,27 @@ function translatedAt( ): Geometry | null { const now = clientToDrawing(overlay.current, client) if (!now) return null - return translatedGeometry(drag.base, { - x: now.x - drag.origin.x, - y: now.y - drag.origin.y, - }) + const delta = { x: now.x - drag.origin.x, y: now.y - drag.origin.y } + return movedBy(drag.base, delta, drag.vertex) +} + +/** A vertex released on itself or on a neighbour moves nothing: no commit. */ +function isNoOp(drag: Drag, dropped: Geometry): boolean { + const { base, vertex } = drag + if (vertex === null || base.type !== 'polygon') return false + return ( + dropped.type === 'polygon' && + isNoOpMove(base.points, vertex, dropped.points) + ) +} + +/** A drop outside the mode commits once: the shape moved, or its vertex. */ +function commitDrop(input: BlockDragInput, drag: Drag, dropped: Geometry) { + if (drag.mode || isNoOp(drag, dropped)) return + const { id } = drag.target + if (drag.vertex === null) return void input.onDrop(id, dropped, 'move') + // The dragged vertex stays chosen on the new text (board 05 B). + if (input.onDrop(id, dropped, 'vertex')) chooseVertex(id, drag.vertex) } /** Losing the target (read-only, another selection) or a document change drops the drag. */ @@ -77,14 +99,24 @@ function dragActions( drag.current = null setPreview(null) } - const start = (pressedAt: XY, client: XY, mode = false) => { + /** `vertex`: a vertex handle's drag; the move mode drags its own vertex, if any. */ + const start = ( + pressedAt: XY, + client: XY, + mode: boolean, + vertex: number | null, + ) => { const origin = clientToDrawing(input.overlay.current, pressedAt) const { target } = input if (!target || !origin) return const base = mode ? shownGeometry(target.id, target.geometry) : target.geometry - drag.current = { target, origin, base, mode } + const own = mode + ? (useAnnotationWork.getState().mode?.vertex ?? null) + : vertex + if (!mode && vertex !== null) chooseVertex(target.id, vertex) + drag.current = { target, origin, base, mode, vertex: own } show(translatedAt(input.overlay, drag.current, client)) } const follow = (client: XY) => { @@ -98,15 +130,15 @@ function dragActions( if (gesture?.mode) show(dropped) drag.current = null setPreview(null) - if (gesture && !gesture.mode && dropped) - input.onDrop(gesture.target.id, dropped) + if (gesture && dropped) commitDrop(input, gesture, dropped) } return { start, follow, drop, cancel } } /** - * The selection moved as a block (`drag_shape`, `drag_point`): the overlay previews the - * translated outline, kept local to the canvas for speed; the drop commits once. A drag + * The selection moved as a block (`drag_shape`, `drag_point`) or one of its vertices + * (`drag_vertex`): the overlay previews the outline, kept local to the canvas for speed; + * the drop commits once. A drag * of the move mode (`drag_mode`) moves the mode's preview instead, and commits nothing. */ export function useBlockDrag(input: BlockDragInput) { diff --git a/apps/app/src/editor/annotations/usePlacement.ts b/apps/app/src/editor/annotations/usePlacement.ts index 214d15bd..e5ea3228 100644 --- a/apps/app/src/editor/annotations/usePlacement.ts +++ b/apps/app/src/editor/annotations/usePlacement.ts @@ -10,12 +10,10 @@ import { updateGeometry, type CommitContext } from './annotationCommit' import { pendingForClick, type NewKind } from './creation' import { round2, type Frame, type XY } from './frame' import { newPointSize } from './pointSize' +import { endMode, useAnnotationWork } from './workStore' import type { ToolId, Tracing, UiAction, UiState } from './uiState' import type { GestureMessages } from './useGestureMessage' -/** A click on the first vertex closes the tracing when within this share of F's span. */ -const CLOSE_SHARE = 0.015 - const TOOL_TARGET: Record, NewKind> = { point: 'point', zone: 'zone', @@ -35,47 +33,56 @@ export interface PlacementInput { const asPoint = (at: XY): Point => [round2(at.x), round2(at.y)] -function nearFirstVertex(tracing: Tracing, at: XY, frame: Frame): boolean { +/** R-11: `reach` is the closing radius of the pointer, in drawing units. */ +function nearFirstVertex(tracing: Tracing, at: XY, reach: number): boolean { const first = tracing.points[0] if (!first || tracing.points.length < 3) return false - const reach = CLOSE_SHARE * Math.max(frame.w, frame.h) return Math.hypot(first[0] - at.x, first[1] - at.y) <= reach } /** - * What closing a tracing does: a new zone or link becomes the pending element; a polygon - * replacing a geometry is committed at once under `accept`, and a refusal drops the - * tracing with the core's message (the annotation is unchanged). + * A redraw's close commits the polygon at once. The mode leaves first, so the commit is + * never said as an abandoned redraw (R-13); a refusal brings it back and keeps the + * tracing open with the core's message (board 33 A). */ -export function closingActions( - tracing: Tracing | null, - doc: AnatomicalSheetDocument, - context: CommitContext, -): UiAction[] { - if (!tracing || tracing.points.length < 3) return [] - const polygon = { type: 'polygon' as const, points: tracing.points } - if (tracing.target !== 'replace') { - const pending = { kind: tracing.target, geometry: polygon } - return [{ type: 'pending_new', pending }] - } +function closeRedraw(input: PlacementInput, tracing: Tracing): void { + const { doc, context, dispatch } = input const annotation = doc.annotations.find((a) => a.id === tracing.annotationId) - if (!annotation) return [{ type: 'trace_cancel' }] + if (!annotation) return dispatch({ type: 'trace_cancel' }) + const held = useAnnotationWork.getState().mode + endMode() + const polygon = { type: 'polygon' as const, points: tracing.points } const result = updateGeometry(annotation, polygon, context) - if (result.ok) return [{ type: 'select', id: annotation.id }] - return [ - { type: 'trace_cancel' }, - { type: 'hint', hint: result.messages.join(' ') }, - ] + if (!result.ok) { + useAnnotationWork.setState({ mode: held }) + return dispatch({ type: 'hint', hint: result.messages.join(' ') }) + } + dispatch({ type: 'select', id: annotation.id }) + const text = context.t( + `editor.annotations.message.redrawn.${annotation.kind}`, + ) + input.message.show(text, { undo: true, tone: 'info' }) } /** Tracing with the zone and link tools: vertices, closing, Enter, Backspace and Escape. */ function tracingActions(input: PlacementInput) { - const { ui, dispatch, frame } = input - const closeTracing = () => - closingActions(ui.tracing, input.doc, input.context).forEach(dispatch) - const trace = (tool: Exclude, at: XY) => { - if (!frame) return - if (ui.tracing && nearFirstVertex(ui.tracing, at, frame)) { + const { ui, dispatch } = input + const closeTracing = () => { + const tracing = ui.tracing + if (!tracing || tracing.points.length < 3) return + if (tracing.target === 'replace') return closeRedraw(input, tracing) + const pending = { + kind: tracing.target, + geometry: { type: 'polygon' as const, points: tracing.points }, + } + dispatch({ type: 'pending_new', pending }) + } + const trace = ( + tool: Exclude, + at: XY, + reach: number, + ) => { + if (ui.tracing && nearFirstVertex(ui.tracing, at, reach)) { return closeTracing() } if (!ui.tracing) @@ -97,14 +104,25 @@ function tracingActions(input: PlacementInput) { return { closeTracing, trace, onTraceKey } } -/** A move (drag, move mode, arrow keys) or a size change of the selection. */ -export type GeometryChange = 'move' | 'size' +/** + * A move (drag, move mode, arrow keys) or a size change of the selection, a vertex + * moved, added or removed. + */ +export type GeometryChange = 'move' | 'size' | 'vertex' | 'insert' | 'remove' + +const KEPT: Record, string> = { + size: 'resized', + vertex: 'vertex_moved', + insert: 'vertex_added', + remove: 'vertex_removed', +} /** The message keys of a kept and of a refused change. */ function changeKeys(change: GeometryChange, kind: Annotation['kind']) { - return change === 'size' - ? { kept: 'resized', refused: 'size_refused' } - : { kept: `moved.${kind}`, refused: 'move_refused' } + const kept = change === 'move' ? `moved.${kind}` : KEPT[change] + if (change === 'size') return { kept, refused: 'size_refused' } + const moved = change === 'move' || change === 'vertex' + return { kept, refused: moved ? 'move_refused' : 'edit_refused' } } /** @@ -112,24 +130,32 @@ function changeKeys(change: GeometryChange, kind: Annotation['kind']) { * with the refused place drawn (the shape stays where it was). */ function dropAction({ doc, context, message, dispatch }: PlacementInput) { - return (id: string, geometry: Geometry, change: GeometryChange = 'move') => { + return ( + id: string, + geometry: Geometry, + change: GeometryChange = 'move', + ): boolean => { const annotation = doc.annotations.find((a) => a.id === id) - if (!annotation) return + if (!annotation) return false const keys = changeKeys(change, annotation.kind) const result = updateGeometry(annotation, geometry, context) if (result.ok) { // A kept move ends any refusal the strip still shows. dispatch({ type: 'hint', hint: null }) const text = context.t(`editor.annotations.message.${keys.kept}`) - return message.show(text, { undo: true, tone: 'info' }) + message.show(text, { undo: true, tone: 'info' }) + return true } const text = context .t(`editor.annotations.message.${keys.refused}`) .replace('{text}', () => result.messages.join(' ')) message.show(text, { undo: false, tone: 'error', place: geometry }) + return false } } +export type Drop = ReturnType + /** * What a click, a key or a drop does with the current tool. Every geometry it proposes is * arithmetic over F; the core decides at « Créer » or at the commit of an existing one. @@ -139,9 +165,10 @@ export function usePlacement(input: PlacementInput) { const t = useT() const tracing = tracingActions(input) const { ui, dispatch, frame } = input - const onPlace = (at: XY) => { + /** `reach`: the pointer's closing radius in drawing units (R-11). */ + const onPlace = (at: XY, reach: number) => { if (ui.tool === 'zone' || ui.tool === 'link') - return tracing.trace(ui.tool, at) + return tracing.trace(ui.tool, at, reach) if (ui.tool !== 'point' || !frame) return const { doc, viewId } = input const size = newPointSize(doc.annotations, viewId, frame, ui.size) diff --git a/apps/app/src/editor/annotations/usePointEdit.ts b/apps/app/src/editor/annotations/usePointEdit.ts index b48dbe08..d0335ed4 100644 --- a/apps/app/src/editor/annotations/usePointEdit.ts +++ b/apps/app/src/editor/annotations/usePointEdit.ts @@ -1,9 +1,10 @@ import type { KeyboardEvent } from 'react' -import type { Annotation, Geometry } from '@faunosteo/core-wasm/types' +import type { Annotation } from '@faunosteo/core-wasm/types' import { useEditorStore } from '../state/editorStore' import { moveStep, type Frame } from './frame' -import type { GeometryChange } from './usePlacement' +import type { Drop } from './usePlacement' import { takeMove, takePreview, stepSelection } from './previewCommit' +import { chooseVertex, freshChosen } from './zoneEdit' import { endMode, startMove, @@ -11,10 +12,8 @@ import { type Preview, } from './workStore' -type Drop = (id: string, geometry: Geometry, change?: GeometryChange) => void - export interface PointEditInput { - /** The selection when it can be moved now (a circle: a point or a link). */ + /** The selection when it can be moved now: a circle (point, link) or a polygon. */ target: Annotation | null frame: Frame | null onDrop: Drop @@ -67,8 +66,13 @@ function commits({ onDrop, target }: PointEditInput) { } } const move = () => { + const vertex = useAnnotationWork.getState().mode?.vertex ?? null const preview = takeMove() - if (preview) onDrop(preview.annotationId, preview.geometry) + if (!preview) return + const { annotationId: id, geometry } = preview + if (vertex === null) return void onDrop(id, geometry) + // The moved vertex stays chosen on the new text. + if (onDrop(id, geometry, 'vertex')) chooseVertex(id, vertex) } return { keys, size, move } } @@ -102,9 +106,12 @@ export function usePointEdit(input: PointEditInput) { // BDR-050: leaving the handle commits its series; a move mode waits for « Valider ». onHandleBlur: () => commit.keys(), commitSize: commit.size, + // « Déplacer le sommet » while a vertex is chosen, else the whole shape. startMove: () => { - if (!input.target) return - startMove(input.target.id, useEditorStore.getState().documentText) + const id = input.target?.id + if (!id) return + const base = useEditorStore.getState().documentText + startMove(id, base, freshChosen(id)) }, stepMove: (direction: Direction) => step(input, direction, false), confirmMove: commit.move, diff --git a/apps/app/src/editor/annotations/usePressGesture.ts b/apps/app/src/editor/annotations/usePressGesture.ts index 8b18f35f..72db7f21 100644 --- a/apps/app/src/editor/annotations/usePressGesture.ts +++ b/apps/app/src/editor/annotations/usePressGesture.ts @@ -1,7 +1,9 @@ import { useEffect, useRef, type PointerEvent, type RefObject } from 'react' import type { XY } from './frame' -import { clientToDrawing } from './gesture' +import { clientToDrawing, drawingPerClientPx } from './gesture' +import { HANDLE_CAP } from './polygonEdit' import { + CLOSE_PX, clickAction, dragAction, isDoubleClick, @@ -28,8 +30,10 @@ export interface PressInput extends BlockDragInput { selectedId: string | null viewport: RefObject onSelect: (id: string) => void - /** A click with a drawing tool, in drawing units. */ - onPlace: (at: XY) => void + /** A click with a drawing tool, in drawing units, with its closing reach (R-11). */ + onPlace: (at: XY, reach: number) => void + /** A click on a vertex handle, a « + » or the « − » bubble. */ + onHandle: (action: HandleAction) => void /** A tap on the empty drawing with the select tool. */ onDeselect: () => void } @@ -91,16 +95,23 @@ function doubled( return id === null ? action : { type: 'open', id } } -/** - * What a click does with the select tool. `open` (the properties dialog) and the vertex - * handles (`choose_vertex`, `insert`, `remove`) have nothing to act on yet. - */ +export type HandleAction = Extract< + ClickAction, + { type: 'choose_vertex' | 'insert' | 'remove' } +> + +const isHandleAction = (action: ClickAction): action is HandleAction => + action.type === 'choose_vertex' || + action.type === 'insert' || + action.type === 'remove' + +/** What a click does with the select tool. `open` (the properties dialog) has nothing yet. */ function runClick(action: ClickAction, input: PressInput): void { if (action.type === 'select') input.onSelect(action.id) else if (action.type === 'deselect') input.onDeselect() else if (action.type === 'unchoose') { useAnnotationWork.setState({ chosen: null }) - } + } else if (isHandleAction(action)) input.onHandle(action) } interface Machine { @@ -123,8 +134,11 @@ interface Feed { /** A click with a drawing tool places at the pointer-up, in drawing units. */ function place(input: PressInput, event: PointerEvent): void { - const drawn = clientToDrawing(input.overlay.current, clientOf(event)) - if (drawn) input.onPlace(drawn) + const svg = input.overlay.current + const drawn = clientToDrawing(svg, clientOf(event)) + const perPx = drawingPerClientPx(svg) + if (!drawn || perPx === null) return + input.onPlace(drawn, CLOSE_PX[pointerKindOf(event.pointerType)] * perPx) } /** A click with the select tool: its action, or `open` as the second of a double click. */ @@ -144,7 +158,12 @@ function onClick(f: Feed, target: PressTarget, event: PointerEvent): void { if (!inMoveMode()) selectClick(f, target, event) } -const BLOCK_DRAGS = new Set(['drag_shape', 'drag_point', 'drag_mode']) +const BLOCK_DRAGS = new Set([ + 'drag_shape', + 'drag_point', + 'drag_mode', + 'drag_vertex', +]) function applyEffect(f: Feed, effect: PressEffect, event: PointerEvent | null) { if (effect?.type === 'drag_cancel') f.drag.cancel() @@ -152,13 +171,22 @@ function applyEffect(f: Feed, effect: PressEffect, event: PointerEvent | null) { if (effect.type === 'click') onClick(f, effect.target, event) if (effect.type === 'drag_end') f.drag.drop(clientOf(event)) if (effect.type === 'drag_start' && BLOCK_DRAGS.has(effect.action.type)) { - const mode = effect.action.type === 'drag_mode' - f.drag.start(f.machine.current.pressedAt, clientOf(event), mode) + const { action } = effect + const vertex = action.type === 'drag_vertex' ? action.index : null + const mode = action.type === 'drag_mode' + f.drag.start(f.machine.current.pressedAt, clientOf(event), mode, vertex) } } +/** R-7: above the handle cap a polygon keeps the move mode and the redraw only. */ +function movable(input: PressInput): boolean { + const geometry = input.target?.geometry + if (!geometry) return false + return geometry.type !== 'polygon' || geometry.points.length <= HANDLE_CAP +} + const contextOf = (input: PressInput) => ({ - movable: input.target !== null, + movable: movable(input), moveMode: inMoveMode(), }) diff --git a/apps/app/src/editor/annotations/useZoneEdit.ts b/apps/app/src/editor/annotations/useZoneEdit.ts new file mode 100644 index 00000000..184bc2b7 --- /dev/null +++ b/apps/app/src/editor/annotations/useZoneEdit.ts @@ -0,0 +1,149 @@ +import type { KeyboardEvent } from 'react' +import type { Annotation, Point } from '@faunosteo/core-wasm/types' +import { moveStep, type Frame } from './frame' +import { insertMidpoint, removeVertex } from './polygonEdit' +import { stepSelection, takePreview } from './previewCommit' +import type { Drop } from './usePlacement' +import type { GestureMessages } from './useGestureMessage' +import type { HandleAction } from './usePressGesture' +import { chooseVertex, freshChosen } from './zoneEdit' +import { useAnnotationWork } from './workStore' + +export interface ZoneEditInput { + /** The selected polygon when its vertices can be edited now (editable, measured). */ + target: Annotation | null + frame: Frame | null + onDrop: Drop + message: Pick + t: (key: string) => string + /** The move mode's own Enter: « Valider la position ». */ + confirmMove: () => void +} + +const STEP: Record = { + ArrowLeft: [-1, 0], + ArrowUp: [0, -1], + ArrowDown: [0, 1], + ArrowRight: [1, 0], +} + +const pointsOf = (target: Annotation | null): Point[] | null => + target?.geometry?.type === 'polygon' ? target.geometry.points : null + +/** « + »: the midpoint commits once, and the new vertex is chosen on the new text. */ +function insertAfter(input: ZoneEditInput, after: number): void { + const { target, onDrop } = input + const next = insertMidpoint(pointsOf(target) ?? [], after) + if (!target || !next) return + const polygon = { type: 'polygon' as const, points: next } + if (onDrop(target.id, polygon, 'insert')) chooseVertex(target.id, after + 1) +} + +/** + * « − »: only the vertex chosen on the current text (Review Focus 2: an undo drops it, so a + * stale bubble or key removes nothing). At three vertices the reason is said instead. + */ +function removeChosen(input: ZoneEditInput, index: number): boolean { + const { target, onDrop } = input + const points = pointsOf(target) + if (!target || !points || freshChosen(target.id) !== index) return false + const next = removeVertex(points, index) + if (!next) { + const text = input.t('editor.annotations.message.vertex_min') + input.message.show(text, { undo: false, tone: 'error' }) + return false + } + return onDrop(target.id, { type: 'polygon', points: next }, 'remove') +} + +/** The keyboard series of a vertex commits once, the vertex still chosen after. */ +function commitKeys(input: ZoneEditInput): void { + const { target, onDrop } = input + const preview = takePreview('keys') + if (!target || !preview || preview.annotationId !== target.id) return + const same = + JSON.stringify(preview.geometry) === JSON.stringify(target.geometry) + if (same) return + const vertex = freshChosen(target.id) + const kept = onDrop(target.id, preview.geometry, 'vertex') + if (kept && vertex !== null) chooseVertex(target.id, vertex) +} + +function stepVertex(input: ZoneEditInput, index: number, event: KeyboardEvent) { + const { target, frame } = input + const [x, y] = STEP[event.key] + if (!target?.geometry || !frame) return + const size = moveStep(frame, event.shiftKey) + stepSelection(target.id, target.geometry, { x: x * size, y: y * size }, index) +} + +const inMoveMode = () => useAnnotationWork.getState().mode?.kind === 'move' + +/** Delete removes the chosen vertex; the next one is chosen so the focus stays on a vertex. */ +function deleteChosen(input: ZoneEditInput): void { + const id = input.target?.id + const chosen = id ? freshChosen(id) : null + if (id === undefined || chosen === null || !removeChosen(input, chosen)) + return + const left = pointsOf(input.target)!.length - 2 + chooseVertex(id, Math.min(chosen, left)) +} + +/** A vertex handle's keys (board 32): arrows step it, Enter commits, Insert adds, Delete. */ +function vertexKey(input: ZoneEditInput, index: number, event: KeyboardEvent) { + const id = input.target?.id + if (STEP[event.key]) { + event.preventDefault() + return stepVertex(input, index, event) + } + if (event.key === 'Enter') { + event.preventDefault() + return inMoveMode() ? input.confirmMove() : commitKeys(input) + } + const chosen = id ? freshChosen(id) : null + if (event.key === 'Insert' && chosen !== null) insertAfter(input, chosen) + if (event.key === 'Delete') deleteChosen(input) +} + +/** Enter or Space on a « + » or on the « − » bubble is its click. */ +const isPress = (event: KeyboardEvent) => + event.key === 'Enter' || event.key === ' ' + +/** + * Zone editing (R-7 to R-13): a click on a vertex chooses it, « + » inserts at a segment's + * midpoint, « − » removes the chosen vertex, and the vertex handles' keys. Every change + * commits once through `onDrop`, the core deciding. + */ +export function useZoneEdit(input: ZoneEditInput) { + const onHandle = (action: HandleAction) => { + const id = input.target?.id + if (!id) return + if (action.type === 'choose_vertex') chooseVertex(id, action.index) + if (action.type === 'insert') insertAfter(input, action.after) + if (action.type === 'remove') removeChosen(input, action.index) + } + return { + onHandle, + onVertexKey: (index: number, event: KeyboardEvent) => + vertexKey(input, index, event), + // Focus chooses (board 32: Insert and Delete act on the chosen vertex). + onVertexFocus: (index: number) => { + const id = input.target?.id + if (id && freshChosen(id) !== index) chooseVertex(id, index) + }, + // BDR-050: leaving the vertex commits its series; a move mode waits for « Valider ». + onVertexBlur: () => commitKeys(input), + onInsertKey: (after: number, event: KeyboardEvent) => { + if (!isPress(event)) return + event.preventDefault() + insertAfter(input, after) + }, + onRemoveKey: (index: number, event: KeyboardEvent) => { + if (!isPress(event)) return + event.preventDefault() + removeChosen(input, index) + }, + } +} + +export type ZoneEdit = ReturnType diff --git a/apps/app/src/editor/annotations/workStore.ts b/apps/app/src/editor/annotations/workStore.ts index 7b692a4b..9da66847 100644 --- a/apps/app/src/editor/annotations/workStore.ts +++ b/apps/app/src/editor/annotations/workStore.ts @@ -31,6 +31,8 @@ export interface ModeWork { annotationId: string started: boolean base: string + /** The chosen vertex a move mode moves alone (« Déplacer le sommet »); null: the shape. */ + vertex: number | null } export type GuardWork = 'creation' | 'move' | 'redraw' | null /** A navigation held by the drawing guard (R-12): what it asks about, and the move itself. */ @@ -68,15 +70,34 @@ export function endMode(): void { useAnnotationWork.setState({ mode: null, preview: null }) } -/** « Déplacer … »: the mode on `annotationId`, nothing moved yet. */ -export function startMove(annotationId: string, base: string): void { +/** « Déplacer … »: the mode on `annotationId` (or its vertex `vertex`), nothing moved yet. */ +export function startMove( + annotationId: string, + base: string, + vertex: number | null = null, +): void { useAnnotationWork.setState({ - mode: { kind: 'move', annotationId, started: false, base }, + mode: { kind: 'move', annotationId, started: false, base, vertex }, + preview: null, + }) +} + +/** « Redessiner »: the redraw of `annotationId`, no vertex placed yet (R-12). */ +export function startRedraw(annotationId: string, base: string): void { + useAnnotationWork.setState({ + mode: { kind: 'redraw', annotationId, started: false, base, vertex: null }, preview: null, chosen: null, }) } +/** The redraw is started once its tracing holds a vertex, and no longer at none. */ +export function markRedraw(started: boolean): void { + const { mode } = useAnnotationWork.getState() + if (mode?.kind !== 'redraw' || mode.started === started) return + useAnnotationWork.setState({ mode: { ...mode, started } }) +} + const sameGeometry = (a: Geometry, b: Geometry) => JSON.stringify(a) === JSON.stringify(b) diff --git a/apps/app/src/editor/annotations/zoneEdit.ts b/apps/app/src/editor/annotations/zoneEdit.ts new file mode 100644 index 00000000..023cb16b --- /dev/null +++ b/apps/app/src/editor/annotations/zoneEdit.ts @@ -0,0 +1,24 @@ +import type { Geometry, Point } from '@faunosteo/core-wasm/types' +import { useEditorStore } from '../state/editorStore' +import { HANDLE_CAP } from './polygonEdit' +import { useAnnotationWork } from './workStore' + +/** A polygon's vertices when it gets handles (R-7: at most HANDLE_CAP), else null. */ +export function handledPoints(geometry: Geometry | null): Point[] | null { + if (geometry?.type !== 'polygon') return null + return geometry.points.length > HANDLE_CAP ? null : geometry.points +} + +/** The vertex `vertex` of `annotationId` is chosen, stamped with the current text (R-13). */ +export function chooseVertex(annotationId: string, vertex: number): void { + const base = useEditorStore.getState().documentText + useAnnotationWork.setState({ chosen: { annotationId, vertex, base } }) +} + +/** The chosen vertex of `annotationId`, only when it was chosen on the current text. */ +export function freshChosen(annotationId: string): number | null { + const { chosen } = useAnnotationWork.getState() + if (chosen?.annotationId !== annotationId) return null + const current = useEditorStore.getState().documentText + return chosen.base === current ? chosen.vertex : null +} diff --git a/apps/app/src/i18n/en.ts b/apps/app/src/i18n/en.ts index 3fd05bbc..66851daf 100644 --- a/apps/app/src/i18n/en.ts +++ b/apps/app/src/i18n/en.ts @@ -35,8 +35,7 @@ export const en: Dict = { 'home.import.error_incompatible_version': 'This PDF uses format v{version}, which this version of the application cannot read (accepted formats: v2 and v3).', 'home.import.complete': 'Full restoration.', - 'home.import.degraded': - 'Partial recovery: check the items flagged below.', + 'home.import.degraded': 'Partial recovery: check the items flagged below.', 'home.import.migrated': 'Report imported from an older format. Findings not found in the current sheet: {count} (kept with their labels).', 'home.import.archive_ok': @@ -88,55 +87,42 @@ export const en: Dict = { "This tab's storage is full: your latest changes are no longer saved in the tab. Export the PDF to keep them.", 'session.held.notice': "Some data in this tab could not be set aside in the browser's storage (not enough space, or the slot is taken). It is kept as it is; nothing was deleted. Until it is resolved, no report can be created or imported in this tab.", - 'session.held.draft_unreadable': - "Draft this version cannot read ({size})", + 'session.held.draft_unreadable': 'Draft this version cannot read ({size})', 'session.held.draft_pre_rebase': - "Draft to adapt to the current anatomical sheet; its original could not be set aside ({size})", + 'Draft to adapt to the current anatomical sheet; its original could not be set aside ({size})', 'session.held.archive_unreadable': - "Archive of the imported report, unreadable ({size})", + 'Archive of the imported report, unreadable ({size})', 'session.held.archive_companion': - "Archive of the imported report that goes with this draft ({size})", - 'session.held.size_kb': - "{n} KB", - 'session.held.download': - "Download a copy", - 'session.held.download_original': - "Download the original", - 'session.held.discard': - "Delete permanently…", - 'session.held.open_adapted': - "Open the adapted version…", - 'session.held.retry': - "Retry", - 'session.held.discard_title_draft': - "Delete this draft permanently?", - 'session.held.discard_title_archive': - "Delete this archive permanently?", + 'Archive of the imported report that goes with this draft ({size})', + 'session.held.size_kb': '{n} KB', + 'session.held.download': 'Download a copy', + 'session.held.download_original': 'Download the original', + 'session.held.discard': 'Delete permanently…', + 'session.held.open_adapted': 'Open the adapted version…', + 'session.held.retry': 'Retry', + 'session.held.discard_title_draft': 'Delete this draft permanently?', + 'session.held.discard_title_archive': 'Delete this archive permanently?', 'session.held.discard_body': - "This text will be erased from this tab and cannot be recovered. Download a copy first to keep it.", - 'session.held.discard_confirm': - "Delete", - 'session.held.open_title': - "Open the adapted version?", + 'This text will be erased from this tab and cannot be recovered. Download a copy first to keep it.', + 'session.held.discard_confirm': 'Delete', + 'session.held.open_title': 'Open the adapted version?', 'session.held.open_body': - "The original will be replaced in this tab by the version adapted to the current anatomical sheet (items not found are kept with their labels). Download the original first to keep it.", - 'session.held.open_confirm': - "Open", + 'The original will be replaced in this tab by the version adapted to the current anatomical sheet (items not found are kept with their labels). Download the original first to keep it.', + 'session.held.open_confirm': 'Open', 'session.held_blocked': - "A draft in this tab must be recovered or deleted first: it could not be set aside and would be overwritten. The editor will open to resolve it.", + 'A draft in this tab must be recovered or deleted first: it could not be set aside and would be overwritten. The editor will open to resolve it.', 'session.held.notice_engine': "Faunosteo's computation engine cannot open a draft of this tab. It is kept as is; nothing was deleted. Download a copy, try again, or delete it to start a new report.", 'session.held.draft_engine_failure': - "Draft the computation engine cannot open ({size})", + 'Draft the computation engine cannot open ({size})', 'session.held_blocked_engine': - "A draft of this tab makes the computation engine fail: recover or delete it first. The editor will open to resolve it.", + 'A draft of this tab makes the computation engine fail: recover or delete it first. The editor will open to resolve it.', 'session.replace.title': 'Replace the report in progress?', 'session.replace.body': - "The report of {animal} will be replaced in this tab. Export it as a PDF to keep it.", + 'The report of {animal} will be replaced in this tab. Export it as a PDF to keep it.', 'session.replace.body_unloaded': - "The report in progress in this tab will be replaced. Open it and export it as a PDF to keep it.", - 'session.replace.unsaved': - "Its latest changes are not saved in this tab.", + 'The report in progress in this tab will be replaced. Open it and export it as a PDF to keep it.', + 'session.replace.unsaved': 'Its latest changes are not saved in this tab.', 'session.replace.open': 'Open the report in progress', 'session.replace.confirm': 'Replace', 'editor.edit_infos': 'Edit info', @@ -224,7 +210,7 @@ export const en: Dict = { "Faunosteo's computation engine stopped after several errors, and this tab's storage is full: your latest changes are not saved and would be lost if you reload the page. Download a copy before reloading.", 'core.reload': 'Reload the page', 'canvas.view_unavailable': - "This anatomical view cannot be displayed: its drawing was refused by the safety checks or could not be composed. Your report is not changed.", + 'This anatomical view cannot be displayed: its drawing was refused by the safety checks or could not be composed. Your report is not changed.', 'core.action_failed': 'This action could not be applied. Try again; your report was not changed.', @@ -341,10 +327,12 @@ export const en: Dict = { 'auth.failure.invalid_credentials': 'Incorrect email or password.', 'auth.failure.email_not_confirmed': 'Your email address is not confirmed yet. Open the link you received by email.', - 'auth.failure.user_exists': 'An account already exists with this email address.', + 'auth.failure.user_exists': + 'An account already exists with this email address.', 'auth.failure.weak_password': 'Password too weak: at least 12 characters, with a lowercase letter, an uppercase letter and a digit.', - 'auth.failure.same_password': 'The new password must differ from the old one.', + 'auth.failure.same_password': + 'The new password must differ from the old one.', 'auth.failure.invalid_email': 'This email address is not accepted.', 'auth.failure.rate_limited': 'Too many attempts. Wait a few minutes before trying again.', @@ -440,7 +428,8 @@ export const en: Dict = { 'The language is saved on your account and applies on every device.', 'account.preferences.language': 'Language', 'account.preferences.timezone': 'Time zone', - 'account.preferences.timezone_hint': 'Used for dates and future appointments.', + 'account.preferences.timezone_hint': + 'Used for dates and future appointments.', 'account.security.title': 'Security', 'account.security.description': 'Password and sessions.', 'account.security.email_label': 'Sign-in address', @@ -475,8 +464,7 @@ export const en: Dict = { 'Unsupported format: choose a JPEG, PNG or WebP image.', 'account.avatar.error.rate_limited': 'Too many attempts. Try again in an hour.', - 'account.avatar.error.storage_full': - 'Storage is full. Try again later.', + 'account.avatar.error.storage_full': 'Storage is full. Try again later.', 'account.avatar.error.upload_missing': 'The upload did not complete. Try again.', 'account.avatar.error.invalid_state': @@ -801,8 +789,7 @@ export const en: Dict = { 'relations.failure.already_ended': 'This relation has already ended.', 'relations.failure.session_expired': 'Your session has expired. Sign in again.', - 'relations.failure.network': - 'No connection. Check your network, then retry.', + 'relations.failure.network': 'No connection. Check your network, then retry.', 'relations.failure.unavailable': 'The service is not answering right now. Retry.', 'relations.title': 'Linked clients', @@ -829,12 +816,12 @@ export const en: Dict = { 'relations.panel.save_animal': 'Link this animal', 'relations.panel.saving': 'Saving…', 'relations.picker.client_label': 'Search a client', - 'relations.picker.client_hint': - 'Active clients: name, city, email or phone', + 'relations.picker.client_hint': 'Active clients: name, city, email or phone', 'relations.picker.client_results': 'Suggested clients', 'relations.picker.client_none': 'No active client matches.', 'relations.picker.animal_label': 'Search an animal', - 'relations.picker.animal_hint': 'Active animals: name, breed or species detail', + 'relations.picker.animal_hint': + 'Active animals: name, breed or species detail', 'relations.picker.animal_results': 'Suggested animals', 'relations.picker.animal_none': 'No active animal matches.', 'relations.picker.loading': 'Searching…', @@ -862,23 +849,28 @@ export const en: Dict = { 'relations.error.end_before_start': 'The end cannot come before the start.', // V1-2.5: catalogue and administration entries, access denied, MFA - 'auth.failure.aal2_required': 'Your account is protected by two-factor authentication: enter a code from your authenticator app first.', + 'auth.failure.aal2_required': + 'Your account is protected by two-factor authentication: enter a code from your authenticator app first.', 'shell.nav.anatomy': 'Anatomical sheets', 'shell.nav.admin': 'Administration', 'access_denied.title': 'Access denied', 'access_denied.body': "You don't have permission to access this page.", 'access_denied.back': 'Back to dashboard', 'permissions_unavailable.title': 'Unable to verify your permissions', - 'permissions_unavailable.body': 'The check did not complete, probably because of a connection problem. This error does not change your permissions.', + 'permissions_unavailable.body': + 'The check did not complete, probably because of a connection problem. This error does not change your permissions.', 'admin.sheets.title': 'Official sheets', 'admin.sheets.new': 'New sheet', 'admin.species.title': 'Species', 'admin.access.title': 'Access and permissions', 'admin.step_up.title': 'Two-factor authentication required', - 'admin.step_up.body': 'Administration needs a strengthened session: enter the 6-digit code from your authenticator app.', - 'admin.step_up.no_factor': 'Administration requires two-factor authentication. First add a factor in My account, Security.', + 'admin.step_up.body': + 'Administration needs a strengthened session: enter the 6-digit code from your authenticator app.', + 'admin.step_up.no_factor': + 'Administration requires two-factor authentication. First add a factor in My account, Security.', 'admin.step_up.to_security': 'Open My account, Security', - 'mfa.description': 'A 6-digit code from an authenticator app, on top of your password. Required for administration.', + 'mfa.description': + 'A 6-digit code from an authenticator app, on top of your password. Required for administration.', 'mfa.factor.loading': 'Loading factors…', 'mfa.factor.none': 'No factor yet.', 'mfa.factor.list_label': 'Authentication factors', @@ -889,37 +881,50 @@ export const en: Dict = { 'mfa.factor.remove': 'Remove', 'mfa.factor.removed': 'Factor removed.', 'mfa.remove.title': 'Remove this factor?', - 'mfa.remove.body': '“{name}” will no longer strengthen your session. Removing a verified factor needs a strengthened session.', + 'mfa.remove.body': + '“{name}” will no longer strengthen your session. Removing a verified factor needs a strengthened session.', 'mfa.remove.confirm': 'Remove', 'mfa.enrol.start': 'Add a factor', 'mfa.enrol.name': 'Factor name', - 'mfa.enrol.name_hint': 'To recognise it in the list, for example “Personal phone”.', + 'mfa.enrol.name_hint': + 'To recognise it in the list, for example “Personal phone”.', 'mfa.enrol.continue': 'Continue', 'mfa.enrol.creating': 'Creating…', - 'mfa.enrol.scan': 'Scan this QR code with your authenticator app, then enter the code it shows.', + 'mfa.enrol.scan': + 'Scan this QR code with your authenticator app, then enter the code it shows.', 'mfa.enrol.qr_alt': 'QR code to scan with your authenticator app', 'mfa.enrol.secret_label': 'Setup key for manual entry', - 'mfa.enrol.secret_hint': 'If you cannot scan the QR code. It is shown only once: do not keep it anywhere else.', + 'mfa.enrol.secret_hint': + 'If you cannot scan the QR code. It is shown only once: do not keep it anywhere else.', 'mfa.enrol.done': 'Factor added and verified.', 'mfa.code.label': 'Verification code', 'mfa.code.hint': 'The 6 digits shown by your authenticator app.', 'mfa.code.verify': 'Verify', 'mfa.code.verifying': 'Verifying…', 'mfa.step_up.factor': 'Factor', - 'mfa.step_up.required': 'This action needs a strengthened session: enter a code from your authenticator app.', + 'mfa.step_up.required': + 'This action needs a strengthened session: enter a code from your authenticator app.', 'mfa.error.code_format': 'The code has 6 digits.', 'mfa.error.name_required': 'Give the factor a name.', 'mfa.error.name_too_long': 'Name too long ({max} characters maximum).', - 'mfa.failure.aal2_required': 'This action needs a session strengthened by two-factor authentication.', - 'mfa.failure.invalid_code': 'Incorrect or expired code. Enter the code shown now.', - 'mfa.failure.factor_not_found': 'This factor no longer exists. Reload the page.', - 'mfa.failure.challenge_expired': 'The verification expired. Enter a new code.', - 'mfa.failure.too_many_factors': 'Maximum number of factors reached. Remove one before adding another.', - 'mfa.failure.name_taken': 'A factor already has this name. Choose another one.', - 'mfa.failure.rate_limited': 'Too many attempts. Wait a few minutes before trying again.', + 'mfa.failure.aal2_required': + 'This action needs a session strengthened by two-factor authentication.', + 'mfa.failure.invalid_code': + 'Incorrect or expired code. Enter the code shown now.', + 'mfa.failure.factor_not_found': + 'This factor no longer exists. Reload the page.', + 'mfa.failure.challenge_expired': + 'The verification expired. Enter a new code.', + 'mfa.failure.too_many_factors': + 'Maximum number of factors reached. Remove one before adding another.', + 'mfa.failure.name_taken': + 'A factor already has this name. Choose another one.', + 'mfa.failure.rate_limited': + 'Too many attempts. Wait a few minutes before trying again.', 'mfa.failure.session_expired': 'Your session has expired. Sign in again.', 'mfa.failure.network': 'Cannot reach the server. Check your network.', - 'mfa.failure.unavailable': 'Two-factor authentication is temporarily unavailable. Try again later.', + 'mfa.failure.unavailable': + 'Two-factor authentication is temporarily unavailable. Try again later.', // V1-2.5 G, H: administration page, species, rights, official sheets 'admin.home.permissions': 'Your permissions: {list}', @@ -928,10 +933,12 @@ export const en: Dict = { 'admin.home.capability.sheet_reviewer': 'reviewer', 'admin.home.capability.sheet_publisher': 'publisher', 'admin.home.owner_role': 'owner role', - 'admin.home.session': 'strengthened session (two-factor authentication) active', + 'admin.home.session': + 'strengthened session (two-factor authentication) active', 'admin.home.sheets_body': 'Drafts, reviews, versions.', 'admin.home.species_body': 'Catalogue species, active or not.', - 'admin.home.access_body': 'Catalogue access and permissions: grant, expiry, revocation.', + 'admin.home.access_body': + 'Catalogue access and permissions: grant, expiry, revocation.', 'admin.home.open': 'Open', 'admin.home.all_sheets': 'All official sheets', 'admin.home.latest': 'Latest changes', @@ -940,8 +947,10 @@ export const en: Dict = { 'admin.badge.working_copy': 'Working copy', 'admin.badge.to_review': '{count} awaiting review', 'admin.working_copy.create': 'Create a working copy', - 'admin.working_copy.active': 'An active working copy already exists (one at a time).', - 'admin.working_copy.body': "A new draft takes the historical sheet's content and drawings, without changing it. Choose the copy's identifier.", + 'admin.working_copy.active': + 'An active working copy already exists (one at a time).', + 'admin.working_copy.body': + "A new draft takes the historical sheet's content and drawings, without changing it. Choose the copy's identifier.", 'admin.working_copy.confirm': 'Create the copy', 'admin.working_copy.pending': 'Creating…', 'admin.sheet_status.active': 'Active', @@ -969,7 +978,8 @@ export const en: Dict = { 'admin.grant_state.expiring': 'Expires within 30 days', 'admin.grant_state.expired': 'Expired', 'admin.grant_state.revoked': 'Revoked', - 'admin.access.lede': 'Grant and revoke catalogue access and permissions. Every right carries a reason and stays on record.', + 'admin.access.lede': + 'Grant and revoke catalogue access and permissions. Every right carries a reason and stays on record.', 'admin.access.loading': 'Loading rights…', 'admin.access.grant_title': 'Grant a right', 'admin.access.lookup.email': 'Account e-mail address', @@ -986,18 +996,22 @@ export const en: Dict = { 'admin.access.account.no_role': 'No platform role', 'admin.access.form.kind': 'Right', 'admin.access.form.reason': 'Reason', - 'admin.access.form.reason_hint': 'Why this right is granted, 1,000 characters at most.', + 'admin.access.form.reason_hint': + 'Why this right is granted, 1,000 characters at most.', 'admin.access.form.note': 'Verification note', - 'admin.access.form.note_hint': 'Required for a permission: the qualification declared and what you checked, never a certification.', + 'admin.access.form.note_hint': + 'Required for a permission: the qualification declared and what you checked, never a certification.', 'admin.access.form.note_hint_reader': 'Optional for catalogue access.', 'admin.access.form.expiry': 'Expiry', - 'admin.access.form.expiry_hint': 'The right ends at the end of this day. Without a date, it lasts until revoked.', + 'admin.access.form.expiry_hint': + 'The right ends at the end of this day. Without a date, it lasts until revoked.', 'admin.access.form.submit': 'Grant', 'admin.access.form.pending': 'Granting…', 'admin.access.error.kind': 'Choose a right.', 'admin.access.error.expiry': 'Choose a date after today.', 'admin.access.granted': 'Right granted.', - 'admin.access.ineligible_detail': 'Conditions: an active account with a confirmed e-mail for every right; a verified authentication factor for a permission; the owner or admin platform role for Sheet editor and Publisher.', + 'admin.access.ineligible_detail': + 'Conditions: an active account with a confirmed e-mail for every right; a verified authentication factor for a permission; the owner or admin platform role for Sheet editor and Publisher.', 'admin.access.list.title': 'Granted rights', 'admin.access.list.filter': 'State', 'admin.access.list.all': 'All', @@ -1010,7 +1024,8 @@ export const en: Dict = { 'admin.access.list.suspended': 'Suspended: conditions not met', 'admin.access.revoke.action': 'Revoke', 'admin.access.revoke.title': 'Revoke this right?', - 'admin.access.revoke.body': "{subject}. Revocation takes effect at the account's next request and cannot be undone; a new right can be granted later.", + 'admin.access.revoke.body': + "{subject}. Revocation takes effect at the account's next request and cannot be undone; a new right can be granted later.", 'admin.access.revoke.reason': 'Reason for revocation', 'admin.access.revoke.confirm': 'Revoke', 'admin.access.revoke.pending': 'Revoking…', @@ -1042,22 +1057,27 @@ export const en: Dict = { 'admin.sheets.filters_active': 'Filters ({count})', 'admin.sheets.filters_reset': 'Reset filters', 'admin.sheets.no_result': 'No sheet name contains “{q}”.', - 'admin.sheet_form.lede': 'The sheet starts empty: views, annotations and findings are entered later in the editor.', + 'admin.sheet_form.lede': + 'The sheet starts empty: views, annotations and findings are entered later in the editor.', 'admin.sheet_form.species': 'Species', - 'admin.sheet_form.species_hint': 'Active or not. Creating a sheet does not activate the species.', + 'admin.sheet_form.species_hint': + 'Active or not. Creating a sheet does not activate the species.', 'admin.sheet_form.species_choose': 'Choose a species', 'admin.sheet_form.species_inactive': '{name} (inactive)', 'admin.sheet_form.name_fr': 'Name (French)', 'admin.sheet_form.name_en': 'Name (English)', 'admin.sheet_form.slug': 'Identifier (slug)', - 'admin.sheet_form.slug_hint': 'Lower-case letters without accents, digits and hyphens, 2 to 80 characters; unique among official sheets.', + 'admin.sheet_form.slug_hint': + 'Lower-case letters without accents, digits and hyphens, 2 to 80 characters; unique among official sheets.', 'admin.sheet_form.submit': 'Create the sheet', 'admin.sheet_form.creating': 'Creating…', 'admin.sheet_form.error.species': 'Choose a species.', - 'admin.sheet_form.error.slug': 'Lower-case letters without accents, digits and hyphens, 2 to 80 characters, not starting with a hyphen.', + 'admin.sheet_form.error.slug': + 'Lower-case letters without accents, digits and hyphens, 2 to 80 characters, not starting with a hyphen.', 'admin.overview.loading': 'Loading the sheet…', 'admin.overview.not_found_title': 'Sheet not found', - 'admin.overview.not_found_body': 'This sheet does not exist or is not available with your permissions.', + 'admin.overview.not_found_body': + 'This sheet does not exist or is not available with your permissions.', 'admin.overview.back': 'Back to official sheets', 'admin.overview.copy_of': 'copy of version {number} of the historical sheet', 'admin.overview.to_catalogue': 'View in the catalogue', @@ -1078,7 +1098,8 @@ export const en: Dict = { 'admin.overview.decided_on': 'decided on {date}', 'admin.overview.decided_on_by': 'decided on {date} by {name}', 'admin.overview.withdrawn_on': 'withdrawn on {date}', - 'admin.species.lede': 'The species of the sheet catalogue. An inactive species does not appear in the animal forms.', + 'admin.species.lede': + 'The species of the sheet catalogue. An inactive species does not appear in the animal forms.', 'admin.species.loading': 'Loading species…', 'admin.species.empty': 'No species.', 'admin.species.new': 'New species', @@ -1092,7 +1113,8 @@ export const en: Dict = { 'admin.species.activate.action': 'Activate', 'admin.species.activate.action_named': 'Activate {name}', 'admin.species.activate.title': 'Activate “{name}”?', - 'admin.species.activate.body': 'The animal forms will then offer this species to every account. An activated species cannot be deactivated.', + 'admin.species.activate.body': + 'The animal forms will then offer this species to every account. An activated species cannot be deactivated.', 'admin.species.activate.confirm': 'Activate', 'admin.species.activate.pending': 'Activating…', 'admin.species.activate.done': 'Species activated.', @@ -1101,56 +1123,80 @@ export const en: Dict = { 'admin.species.dialog.create_title': 'New species', 'admin.species.dialog.edit_title': 'Edit the species', 'admin.species.dialog.rename_title': 'Rename the species', - 'admin.species.dialog.create_body': 'Created inactive: the animal forms offer it only once the owner activates it. Its identifier never changes afterwards.', + 'admin.species.dialog.create_body': + 'Created inactive: the animal forms offer it only once the owner activates it. Its identifier never changes afterwards.', 'admin.species.field.id': 'Identifier', - 'admin.species.field.id_hint': 'Lower-case letters without accents, digits, hyphens and underscores, 64 characters at most; “other” is reserved.', + 'admin.species.field.id_hint': + 'Lower-case letters without accents, digits, hyphens and underscores, 64 characters at most; “other” is reserved.', 'admin.species.field.id_value': 'Identifier: {id}', 'admin.species.field.name_fr': 'Name (French)', 'admin.species.field.name_en': 'Name (English)', 'admin.species.field.order': 'Display order', 'admin.species.field.order_hint': 'A number from 0 to 9999, smaller first.', - 'admin.species.error.id': 'Invalid identifier: lower-case letters without accents, digits, hyphens and underscores; “other” is reserved.', + 'admin.species.error.id': + 'Invalid identifier: lower-case letters without accents, digits, hyphens and underscores; “other” is reserved.', 'admin.species.error.order': 'A whole number from 0 to 9999.', 'admin.failure.authentication_required': 'Sign in to continue.', - 'admin.failure.mfa_required': 'This action needs a session strengthened by two-factor authentication.', + 'admin.failure.mfa_required': + 'This action needs a session strengthened by two-factor authentication.', 'admin.failure.forbidden': 'Action not allowed.', - 'admin.failure.rights.account': 'Your account must be active, with a confirmed e-mail, for this action.', - 'admin.failure.rights.capability': 'Your permissions do not allow this action.', - 'admin.failure.rights.mfa': 'This action needs a session strengthened by two-factor authentication.', + 'admin.failure.rights.account': + 'Your account must be active, with a confirmed e-mail, for this action.', + 'admin.failure.rights.capability': + 'Your permissions do not allow this action.', + 'admin.failure.rights.mfa': + 'This action needs a session strengthened by two-factor authentication.', 'admin.failure.rights.owner': 'Only the platform owner can do this.', - 'admin.failure.not_found': 'Item not found or not available. Reload the page.', + 'admin.failure.not_found': + 'Item not found or not available. Reload the page.', 'admin.failure.grant.active': 'This account already holds this right.', - 'admin.failure.grant.ineligible': 'This account does not meet the conditions of this right.', + 'admin.failure.grant.ineligible': + 'This account does not meet the conditions of this right.', 'admin.failure.grant.revoked': 'This right is already revoked.', 'admin.failure.grant.target_invalid': 'This account no longer exists.', - 'admin.failure.document.shape': 'The server did not accept the sheet document.', - 'admin.failure.document.schema_version': 'The server does not accept this sheet format version.', - 'admin.failure.document.species': "The document's species does not match the sheet's.", - 'admin.failure.document.too_large': 'The sheet document exceeds the allowed size.', - 'admin.failure.sheet.species_invalid': 'This species cannot have an official sheet.', - 'admin.failure.sheet.slug_taken': 'Another official sheet already uses this identifier.', + 'admin.failure.document.shape': + 'The server did not accept the sheet document.', + 'admin.failure.document.schema_version': + 'The server does not accept this sheet format version.', + 'admin.failure.document.species': + "The document's species does not match the sheet's.", + 'admin.failure.document.too_large': + 'The sheet document exceeds the allowed size.', + 'admin.failure.sheet.species_invalid': + 'This species cannot have an official sheet.', + 'admin.failure.sheet.slug_taken': + 'Another official sheet already uses this identifier.', 'admin.failure.species.exists': 'A species already has this identifier.', - 'admin.failure.species.not_active': 'This species is not active: edit it instead of renaming it.', - 'admin.failure.species.not_inactive': 'This species is already active: only the owner can rename it.', - 'admin.failure.working_copy.source_invalid': 'Only a version of the historical sheet can be copied.', - 'admin.failure.working_copy.exists': 'An active working copy already exists (one at a time).', - 'admin.failure.working_copy.assets_missing': 'Some drawings of the historical sheet are missing from storage: no copy was created. They must be uploaded first.', + 'admin.failure.species.not_active': + 'This species is not active: edit it instead of renaming it.', + 'admin.failure.species.not_inactive': + 'This species is already active: only the owner can rename it.', + 'admin.failure.working_copy.source_invalid': + 'Only a version of the historical sheet can be copied.', + 'admin.failure.working_copy.exists': + 'An active working copy already exists (one at a time).', + 'admin.failure.working_copy.assets_missing': + 'Some drawings of the historical sheet are missing from storage: no copy was created. They must be uploaded first.', 'admin.failure.invalid_input': 'A value was not accepted. Check the fields.', - 'admin.failure.rate_limited': 'Too many actions in a short time. Try again in a few minutes.', + 'admin.failure.rate_limited': + 'Too many actions in a short time. Try again in a few minutes.', 'admin.failure.conflict_retry': 'Another action was in progress. Retry.', 'admin.failure.session_expired': 'Your session has expired. Sign in again.', 'admin.failure.network': 'No connection. Check your network, then retry.', 'admin.failure.unavailable': 'The service is not answering right now. Retry.', // V1-2.5: anatomical catalogue (slice I) - 'catalogue.lede': 'Published official sheets, by species. Read-only: nothing is changed here.', + 'catalogue.lede': + 'Published official sheets, by species. Read-only: nothing is changed here.', 'catalogue.search': 'Search for a sheet', 'catalogue.species_filter': 'Filter by species', 'catalogue.all_species': 'All species', 'catalogue.loading': 'Loading the catalogue…', 'catalogue.results': 'Published sheets', - 'catalogue.empty': 'A species appears here as soon as an official sheet is published for it.', - 'catalogue.empty_hint': 'Drafts and reviews are never listed in the catalogue.', + 'catalogue.empty': + 'A species appears here as soon as an official sheet is published for it.', + 'catalogue.empty_hint': + 'Drafts and reviews are never listed in the catalogue.', 'catalogue.no_results': 'No sheet matches this search.', 'catalogue.status.published': 'Published', 'catalogue.status.deprecated': 'Withdrawn', @@ -1160,7 +1206,8 @@ export const en: Dict = { 'catalogue.card.views_other': '{count} views', 'catalogue.card.zones_one': '1 finding zone', 'catalogue.card.zones_other': '{count} finding zones', - 'catalogue.card.integrity_failed': 'Integrity check failed: this version cannot be displayed.', + 'catalogue.card.integrity_failed': + 'Integrity check failed: this version cannot be displayed.', 'catalogue.view': 'View', 'catalogue.view_sheet': 'View {name}', 'catalogue.loading_sheet': 'Loading the sheet…', @@ -1172,14 +1219,17 @@ export const en: Dict = { 'catalogue.versions.title': 'Sheet versions', 'catalogue.views': 'Sheet views', 'catalogue.canvas.label': 'Drawing: {view}', - 'catalogue.canvas.help': 'Pinch to zoom, drag to move. Tap a zone to see its findings.', - 'catalogue.canvas.keys': 'With the keyboard: arrows to move, + and − to zoom, 0 to show the whole drawing.', + 'catalogue.canvas.help': + 'Pinch to zoom, drag to move. Tap a zone to see its findings.', + 'catalogue.canvas.keys': + 'With the keyboard: arrows to move, + and − to zoom, 0 to show the whole drawing.', 'catalogue.zoom.out': 'Zoom out', 'catalogue.zoom.in': 'Zoom in', 'catalogue.zoom.fit': 'Fit', 'catalogue.zone.choose': 'Zone', 'catalogue.zone.none': 'Choose a zone', - 'catalogue.zone.prompt': 'Tap a zone on the drawing, or choose it in the list, to see its findings.', + 'catalogue.zone.prompt': + 'Tap a zone on the drawing, or choose it in the list, to see its findings.', 'catalogue.zone.title': 'Zone: {name}', 'catalogue.zone.category': 'Category: {name}', 'catalogue.zone.vertebrae': 'vertebrae {first} to {last}', @@ -1187,26 +1237,40 @@ export const en: Dict = { 'catalogue.references.title': 'References', 'catalogue.references.none': 'This sheet cites no reference.', 'catalogue.references.link': 'Link', - 'catalogue.failure.view': 'This view cannot be shown: its drawing was refused by the security checks or could not be composed.', + 'catalogue.failure.view': + 'This view cannot be shown: its drawing was refused by the security checks or could not be composed.', 'catalogue.failure.network': 'Cannot reach the server. Check your network.', - 'catalogue.failure.session_expired': 'Your session has expired. Sign in again.', - 'catalogue.failure.rate_limited': 'Too many requests. Wait a few minutes before trying again.', - 'catalogue.failure.unavailable': 'The catalogue is temporarily unavailable. Try again later.', - 'catalogue.failure.drawing_missing': 'A drawing of this version cannot be found.', - 'catalogue.failure.drawing_hash_mismatch': "The illustration file's contents do not match its recorded SHA-256 hash.", - 'catalogue.failure.fingerprint_mismatch': "This version's fingerprint does not match the one recorded at its publication.", - 'catalogue.failure.invalid_document': "This version's content cannot be read.", + 'catalogue.failure.session_expired': + 'Your session has expired. Sign in again.', + 'catalogue.failure.rate_limited': + 'Too many requests. Wait a few minutes before trying again.', + 'catalogue.failure.unavailable': + 'The catalogue is temporarily unavailable. Try again later.', + 'catalogue.failure.drawing_missing': + 'A drawing of this version cannot be found.', + 'catalogue.failure.drawing_hash_mismatch': + "The illustration file's contents do not match its recorded SHA-256 hash.", + 'catalogue.failure.fingerprint_mismatch': + "This version's fingerprint does not match the one recorded at its publication.", + 'catalogue.failure.invalid_document': + "This version's content cannot be read.", 'catalogue.failure.caps': 'This version exceeds the size limits of a sheet.', // V1-2.6 E: draft editor route, header, tabs, recovery, conflict 'admin.overview.open_draft': 'Open the draft', 'admin.overview.view_draft': 'View the draft', - 'admin.failure.round.open': 'A review is already under way on this draft: it cannot be submitted again.', - 'admin.failure.view.asset.unknown': "A drawing of the draft is not registered for this sheet: choose it again in Annotations, Views section.", - 'admin.failure.draft.frozen': 'A review is under way on this draft: it can no longer be edited.', + 'admin.failure.round.open': + 'A review is already under way on this draft: it cannot be submitted again.', + 'admin.failure.view.asset.unknown': + 'A drawing of the draft is not registered for this sheet: choose it again in Annotations, Views section.', + 'admin.failure.draft.frozen': + 'A review is under way on this draft: it can no longer be edited.', 'admin.failure.draft.not_a_draft': 'This version is no longer a draft.', - 'admin.failure.sheet.inactive': 'This sheet is archived: its draft can no longer be edited.', - 'admin.failure.sheet.state': "The sheet's state does not allow this action. Reload the page.", - 'admin.failure.sheet.historical_read_only': 'The historical sheet cannot be edited: create a working copy.', + 'admin.failure.sheet.inactive': + 'This sheet is archived: its draft can no longer be edited.', + 'admin.failure.sheet.state': + "The sheet's state does not allow this action. Reload the page.", + 'admin.failure.sheet.historical_read_only': + 'The historical sheet cannot be edited: create a working copy.', 'editor.tab.list': 'Draft sections', 'editor.tab.general': 'General', 'editor.tab.annotations': 'Annotations', @@ -1222,8 +1286,10 @@ export const en: Dict = { 'editor.place.regions': 'Vertebral regions', 'editor.place.references': 'References', 'editor.section.back': 'Back to the drawing', - 'editor.live.creation_kept': "A creation is in progress: finish or abandon it to reach this annotation.", - 'editor.live.tracing_kept': "A tracing is in progress: finish or cancel it to reach this annotation.", + 'editor.live.creation_kept': + 'A creation is in progress: finish or abandon it to reach this annotation.', + 'editor.live.tracing_kept': + 'A tracing is in progress: finish or cancel it to reach this annotation.', 'editor.overview.label': 'Sheet overview', 'editor.overview.views': 'Views', 'editor.overview.view_main': 'Main view', @@ -1253,16 +1319,23 @@ export const en: Dict = { 'editor.citations.edit_reference': 'Edit the reference', 'editor.citations.new_reference': 'New reference', 'editor.citations.cite': 'Cite', - 'editor.citations.pending_choice': 'Reference chosen but not cited yet: choose « Cite » or go back to the empty choice.', - 'editor.citations.created_draft': 'New reference cited in the draft: {citation}. It will be saved with the citations.', + 'editor.citations.pending_choice': + 'Reference chosen but not cited yet: choose « Cite » or go back to the empty choice.', + 'editor.citations.created_draft': + 'New reference cited in the draft: {citation}. It will be saved with the citations.', 'editor.citations.pending_removed': 'New reference removed: {citation}', 'editor.citations.pending_updated': 'New reference edited: {citation}', 'editor.citations.pending': 'New', - 'editor.citations.pending_kept': 'New reference not saved, still in the draft: {citation}', - 'editor.references.panel_count_one': '{count} reference cited by this finding', - 'editor.references.panel_count_other': '{count} references cited by this finding', - 'editor.references.panel_count_family_one': '{count} reference cited by this family', - 'editor.references.panel_count_family_other': '{count} references cited by this family', + 'editor.citations.pending_kept': + 'New reference not saved, still in the draft: {citation}', + 'editor.references.panel_count_one': + '{count} reference cited by this finding', + 'editor.references.panel_count_other': + '{count} references cited by this finding', + 'editor.references.panel_count_family_one': + '{count} reference cited by this family', + 'editor.references.panel_count_family_other': + '{count} references cited by this family', 'editor.references.panel_show_all': 'Show all in the References tab', 'editor.references.panel_empty': 'This finding cites no reference.', 'editor.references.panel_empty_family': 'This family cites no reference.', @@ -1283,7 +1356,8 @@ export const en: Dict = { 'editor.references.none_doi': 'None', 'editor.references.none_url': 'None', 'editor.references.new_tab': '(new tab)', - 'editor.references.delete_hint': 'To delete this reference, first remove each of its citations: “Go to”, then “X references”, “Edit” and “Remove” in the references of the finding or the family.', + 'editor.references.delete_hint': + 'To delete this reference, first remove each of its citations: “Go to”, then “X references”, “Edit” and “Remove” in the references of the finding or the family.', 'editor.references.add': 'Add a reference', 'editor.references.added': 'Reference added: {citation}', 'editor.references.added_show': 'Show', @@ -1291,11 +1365,14 @@ export const en: Dict = { 'editor.references.filter_chip': 'References of the finding: {name}', 'editor.references.filter_chip_family': 'References of the family: {name}', 'editor.references.filter_remove': 'Remove the filter of the finding {name}', - 'editor.references.filter_remove_family': 'Remove the filter of the family {name}', + 'editor.references.filter_remove_family': + 'Remove the filter of the family {name}', 'editor.references.filter_back': 'Back to the finding', 'editor.references.filter_back_family': 'Back to the family', - 'editor.references.filter_gone': 'The finding no longer exists: the filter is removed', - 'editor.references.filter_gone_family': 'The family no longer exists: the filter is removed', + 'editor.references.filter_gone': + 'The finding no longer exists: the filter is removed', + 'editor.references.filter_gone_family': + 'The family no longer exists: the filter is removed', 'editor.references.clear_search': 'Clear the search', 'editor.references.sort_by': 'Sort by', 'editor.references.sort.sheet': 'Sheet order', @@ -1306,9 +1383,11 @@ export const en: Dict = { 'editor.references.count_other': '{count} references', 'editor.references.count_of_one': '{count} reference of {total}', 'editor.references.count_of_other': '{count} references of {total}', - 'editor.references.reorder_hint': 'To reorder, show the sheet order without a search.', + 'editor.references.reorder_hint': + 'To reorder, show the sheet order without a search.', 'editor.references.no_result': 'No reference contains “{q}”.', - 'editor.references.no_result_scope': 'The search covers the citation, the DOI and the URL.', + 'editor.references.no_result_scope': + 'The search covers the citation, the DOI and the URL.', 'editor.references.outside_search': 'Does not match the search', 'editor.findings.references_open_one': '{count} reference', 'editor.findings.references_open_other': '{count} references', @@ -1318,8 +1397,10 @@ export const en: Dict = { 'editor.draft.title': 'Draft, version {number}', 'editor.draft.read_only': 'Read-only', 'editor.draft.discard': 'Discard changes', - 'editor.draft.discard_copy': 'The temporary local copy of these changes will be deleted too.', - 'editor.draft.discard_ask': 'Discard the unsaved changes? The draft will return to the last revision saved on the server.', + 'editor.draft.discard_copy': + 'The temporary local copy of these changes will be deleted too.', + 'editor.draft.discard_ask': + 'Discard the unsaved changes? The draft will return to the last revision saved on the server.', 'editor.draft.discard_confirm': 'Discard changes', 'editor.draft.status.revision': 'Revision {revision}', 'editor.draft.status.unsaved': 'Unsaved changes', @@ -1334,32 +1415,52 @@ export const en: Dict = { 'editor.history.redo_title': 'Redo the last undone change', 'editor.history.redo_shortcut': 'Ctrl+Shift+Z or ⇧⌘Z', 'editor.draft.status.saving': 'Saving…', - 'editor.draft.status.copy_quota': "Temporary local copy impossible (tab full): not saved on the server", - 'editor.draft.status.copy_cap': "Temporary local copy impossible (two other copies in this tab): not saved on the server", - 'editor.draft.copy_kept': "A temporary local copy, limited to this tab, is kept; it is not saved on the server.", - 'editor.draft.copy_not_kept': "No temporary local copy could be written in this tab: these changes are saved nowhere, neither in the tab nor on the server.", - 'editor.draft.mode.narrow': 'Editing requires a screen at least 1,024 px wide.', - 'editor.draft.mode.rights': 'Your permissions do not allow editing this draft. It remains readable.', + 'editor.draft.status.copy_quota': + 'Temporary local copy impossible (tab full): not saved on the server', + 'editor.draft.status.copy_cap': + 'Temporary local copy impossible (two other copies in this tab): not saved on the server', + 'editor.draft.copy_kept': + 'A temporary local copy, limited to this tab, is kept; it is not saved on the server.', + 'editor.draft.copy_not_kept': + 'No temporary local copy could be written in this tab: these changes are saved nowhere, neither in the tab nor on the server.', + 'editor.draft.mode.narrow': + 'Editing requires a screen at least 1,024 px wide.', + 'editor.draft.mode.rights': + 'Your permissions do not allow editing this draft. It remains readable.', 'editor.draft.mode.frozen_verifying': '{round} · verification in progress', - 'editor.draft.mode.frozen_generic': 'A review is under way: the draft can no longer be edited.', - 'editor.draft.mode.historical': 'The historical sheet cannot be edited: create a working copy to edit it.', - 'editor.draft.mode.inactive': 'This sheet is archived: its draft can no longer be edited.', - 'editor.draft.mode.unusable_copy': "A temporary local copy of this draft exists in this tab; it is not saved on the server and cannot be used in this state.", - 'editor.draft.recovery.offer': 'A temporary local copy of this draft exists in this tab (revision {revision}, {time}). It is not saved on the server. Choose before editing the draft.', - 'editor.draft.recovery.older': 'It is based on revision {revision}; the server is at revision {server}.', - 'editor.draft.recovery.unreadable': "A temporary local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost.", - 'editor.draft.recovery.refused': "The document check refuses this copy: {kind}. It stays in this tab.", - 'editor.draft.recovery.refused_kind.invalid_shape': "the document does not follow the sheet format", - 'editor.draft.recovery.refused_kind.core_unavailable': "the calculation engine is not available", - 'editor.draft.recovery.refused_kind.unknown': "reason not recognised", - 'editor.draft.recovery.refused_kind.other': "reason not recognised", + 'editor.draft.mode.frozen_generic': + 'A review is under way: the draft can no longer be edited.', + 'editor.draft.mode.historical': + 'The historical sheet cannot be edited: create a working copy to edit it.', + 'editor.draft.mode.inactive': + 'This sheet is archived: its draft can no longer be edited.', + 'editor.draft.mode.unusable_copy': + 'A temporary local copy of this draft exists in this tab; it is not saved on the server and cannot be used in this state.', + 'editor.draft.recovery.offer': + 'A temporary local copy of this draft exists in this tab (revision {revision}, {time}). It is not saved on the server. Choose before editing the draft.', + 'editor.draft.recovery.older': + 'It is based on revision {revision}; the server is at revision {server}.', + 'editor.draft.recovery.unreadable': + 'A temporary local copy of this draft exists in this tab but cannot be read. It is not saved on the server. Ignoring it deletes it from this tab: its content will be lost.', + 'editor.draft.recovery.refused': + 'The document check refuses this copy: {kind}. It stays in this tab.', + 'editor.draft.recovery.refused_kind.invalid_shape': + 'the document does not follow the sheet format', + 'editor.draft.recovery.refused_kind.core_unavailable': + 'the calculation engine is not available', + 'editor.draft.recovery.refused_kind.unknown': 'reason not recognised', + 'editor.draft.recovery.refused_kind.other': 'reason not recognised', 'editor.draft.recovery.restore': 'Restore the copy', 'editor.draft.recovery.ignore': 'Ignore the copy', - 'editor.draft.recovery.ignore_body': "Abandon this tab's temporary local copy, not saved on the server (revision {revision}, {time})? It will be deleted from this tab.", - 'editor.draft.recovery.ignore_unreadable_body': "Abandon this tab's unreadable temporary local copy, not saved on the server? It will be deleted from this tab and its content will be lost.", + 'editor.draft.recovery.ignore_body': + "Abandon this tab's temporary local copy, not saved on the server (revision {revision}, {time})? It will be deleted from this tab.", + 'editor.draft.recovery.ignore_unreadable_body': + "Abandon this tab's unreadable temporary local copy, not saved on the server? It will be deleted from this tab and its content will be lost.", 'editor.draft.recovery.ignore_confirm': 'Abandon the copy', - 'editor.draft.copy_issue.cap': "Two other drafts already have a temporary local copy in this tab. The changes to this one are kept nowhere (nothing is saved on the server) until you abandon one.", - 'editor.draft.copy_issue.quota': "This tab's storage is full: the temporary local copy of this draft cannot be written, and its changes not saved on the server are not kept. Save the draft or abandon a copy below.", + 'editor.draft.copy_issue.cap': + 'Two other drafts already have a temporary local copy in this tab. The changes to this one are kept nowhere (nothing is saved on the server) until you abandon one.', + 'editor.draft.copy_issue.quota': + "This tab's storage is full: the temporary local copy of this draft cannot be written, and its changes not saved on the server are not kept. Save the draft or abandon a copy below.", 'editor.draft.copy.open': 'Open this draft', 'editor.draft.copy.abandon': 'Abandon this copy', 'editor.draft.copy.revision': 'revision {revision}', @@ -1367,18 +1468,25 @@ export const en: Dict = { 'editor.draft.conflict.reading_title': 'Save conflict', 'editor.draft.conflict.reading': 'Reading the server revision…', 'editor.draft.conflict.known': 'Another session saved revision {revision}', - 'editor.draft.conflict.unknown': 'Another session saved a newer version of this draft.', + 'editor.draft.conflict.unknown': + 'Another session saved a newer version of this draft.', 'editor.draft.conflict.by_other': 'by {name}, on {date}', - 'editor.draft.conflict.by_you': 'from another session of your account, on {date}', + 'editor.draft.conflict.by_you': + 'from another session of your account, on {date}', 'editor.draft.conflict.by_you_short': 'another session of your account', 'editor.draft.conflict.reload': 'Reload', 'editor.draft.conflict.retry': 'Retry', 'editor.draft.conflict.keep': 'Keep my version', - 'editor.draft.conflict.keep_hint': 'Server revision unknown: reload or retry.', - 'editor.draft.conflict.reload_ask': 'Abandon your changes and reload revision {revision}?', - 'editor.draft.conflict.reload_unknown_ask': 'Abandon your changes and reload the server version?', - 'editor.draft.conflict.keep_ask': 'Replace revision {revision} with your version?', - 'editor.draft.conflict.keep_ask_by': 'Replace revision {revision} ({who}, {date}) with your version?', + 'editor.draft.conflict.keep_hint': + 'Server revision unknown: reload or retry.', + 'editor.draft.conflict.reload_ask': + 'Abandon your changes and reload revision {revision}?', + 'editor.draft.conflict.reload_unknown_ask': + 'Abandon your changes and reload the server version?', + 'editor.draft.conflict.keep_ask': + 'Replace revision {revision} with your version?', + 'editor.draft.conflict.keep_ask_by': + 'Replace revision {revision} ({who}, {date}) with your version?', 'editor.action.delete': 'Delete', 'editor.action.remove': 'Remove', 'editor.action.move_up': 'Move up', @@ -1388,15 +1496,22 @@ export const en: Dict = { 'editor.field.integer': 'Enter a whole number.', 'editor.field.choose': 'Choose…', 'editor.refusal.blocked': 'The change was not applied.', - 'editor.refusal.recovery': "First answer this tab's temporary local copy offered at the top of the page: it is not saved on the server.", - 'editor.refusal.core.unknown_key': 'This element no longer exists in the draft.', - 'editor.refusal.core.duplicate_key': 'An element already has this identifier.', - 'editor.refusal.core.invalid_target': 'This change does not apply to this element.', - 'editor.refusal.core.id_changed': 'An element\'s identifier or code cannot be changed.', - 'editor.refusal.core.invalid_position': 'This position does not exist in the list.', + 'editor.refusal.recovery': + "First answer this tab's temporary local copy offered at the top of the page: it is not saved on the server.", + 'editor.refusal.core.unknown_key': + 'This element no longer exists in the draft.', + 'editor.refusal.core.duplicate_key': + 'An element already has this identifier.', + 'editor.refusal.core.invalid_target': + 'This change does not apply to this element.', + 'editor.refusal.core.id_changed': + "An element's identifier or code cannot be changed.", + 'editor.refusal.core.invalid_position': + 'This position does not exist in the list.', 'editor.refusal.core.too_deep': 'The tree is too deep (8 levels at most).', 'editor.refusal.core.has_dependents': 'Other elements still use this one.', - 'editor.refusal.core.other': 'The document check refuses this value ({kind}).', + 'editor.refusal.core.other': + 'The document check refuses this value ({kind}).', 'editor.element.sheet': 'Sheet', 'editor.element.reference': 'Reference', 'editor.element.region': 'Vertebral region', @@ -1416,8 +1531,10 @@ export const en: Dict = { 'editor.delete.title': 'Delete "{name}"?', 'editor.delete.ask': 'Delete "{name}" from the draft?', 'editor.delete.descendants': 'These elements will be deleted too:', - 'editor.delete.blocked': '"{name}" cannot be deleted: the following elements still use it.', - 'editor.delete.lookup_failed': 'Could not check what uses this element. Try again.', + 'editor.delete.blocked': + '"{name}" cannot be deleted: the following elements still use it.', + 'editor.delete.lookup_failed': + 'Could not check what uses this element. Try again.', 'editor.delete.confirm': 'Delete', 'editor.delete.cancel': 'Cancel', 'editor.delete.close': 'Close', @@ -1447,7 +1564,8 @@ export const en: Dict = { 'editor.reference.url': 'Web address (URL)', 'editor.reference.doi': 'DOI', 'editor.reference.new': 'New reference', - 'editor.reference.url_invalid': 'Enter an address starting with http:// or https://.', + 'editor.reference.url_invalid': + 'Enter an address starting with http:// or https://.', 'editor.reference.add': 'Add the reference', 'editor.reference.type.book': 'Book', 'editor.reference.type.journal': 'Journal article', @@ -1468,7 +1586,8 @@ export const en: Dict = { 'editor.vertebra.range_number': 'The range bounds are whole numbers.', 'editor.vertebra.new': 'New vertebral region', 'editor.vertebra.add': 'Add the region', - 'editor.vertebra.required': 'Fill in the code and the French and English names.', + 'editor.vertebra.required': + 'Fill in the code and the French and English names.', 'editor.views.main_title': 'Main view', 'editor.views.details_title': 'Detail views', 'editor.views.empty': 'No detail view yet.', @@ -1480,21 +1599,28 @@ export const en: Dict = { 'editor.views.drawing.ok': 'Drawing valid', 'editor.views.drawing.missing': 'Drawing not found', 'editor.views.drawing.rejected': 'Drawing rejected', - 'editor.views.drawing.not_canonical': "Drawing refused: it is not in the stored form. Choose the original file again to replace it.", - 'editor.views.drawing.rejected_reason': "Drawing refused ({reason}).", + 'editor.views.drawing.not_canonical': + 'Drawing refused: it is not in the stored form. Choose the original file again to replace it.', + 'editor.views.drawing.rejected_reason': 'Drawing refused ({reason}).', 'editor.views.drawing.inherited': "Uses the parent view's drawing.", - 'editor.views.drawing.hint': "Use « Choose a drawing » to add or replace this view's drawing.", - 'editor.views.drawing.unmeasured': 'This view cannot be measured: add or fix its drawing before placing or moving elements.', + 'editor.views.drawing.hint': + "Use « Choose a drawing » to add or replace this view's drawing.", + 'editor.views.drawing.unmeasured': + 'This view cannot be measured: add or fix its drawing before placing or moving elements.', 'editor.views.drawing.choose': 'Choose a drawing', 'editor.views.drawing.file': 'Drawing file (SVG)', 'editor.views.drawing.use_parent': "Use the parent view's drawing", 'editor.views.drawing.use_parent_title': "Use the parent view's drawing?", - 'editor.views.drawing.use_parent_body': "The view will show the parent view's drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view's annotations go back to \"to confirm\".", - 'editor.views.drawing.use_parent_confirm': "Use the parent drawing", + 'editor.views.drawing.use_parent_body': + 'The view will show the parent view\'s drawing through its crop. Its own drawing file stays stored, and you can undo this change (Undo). The view\'s annotations go back to "to confirm".', + 'editor.views.drawing.use_parent_confirm': 'Use the parent drawing', 'editor.views.drawing.use_parent_cancel': 'Cancel', - 'editor.views.pending.cleaning': 'A drawing cleaning is waiting for your decision.', - 'editor.views.pending.repair': 'An annotation repair is waiting for your decision.', - 'editor.views.pending.parent': "Going back to the parent view's drawing is waiting for your confirmation.", + 'editor.views.pending.cleaning': + 'A drawing cleaning is waiting for your decision.', + 'editor.views.pending.repair': + 'An annotation repair is waiting for your decision.', + 'editor.views.pending.parent': + "Going back to the parent view's drawing is waiting for your confirmation.", 'editor.views.pending.resume': 'Resume', 'editor.views.crop.title': 'Crop', 'editor.views.crop.toggle': 'Edit the crop', @@ -1502,7 +1628,8 @@ export const en: Dict = { 'editor.views.crop.min_y': 'Crop: minimum y', 'editor.views.crop.width': 'Crop: width', 'editor.views.crop.height': 'Crop: height', - 'editor.views.crop.hint': "Rectangle in the parent drawing's units. Four values, or none for no crop. They apply together.", + 'editor.views.crop.hint': + "Rectangle in the parent drawing's units. Four values, or none for no crop. They apply together.", 'editor.views.crop.incomplete': 'Fill in all four crop values, or none.', 'editor.views.crop.number': 'The crop values are numbers.', 'editor.views.crop.not_applied': 'Not applied', @@ -1510,35 +1637,53 @@ export const en: Dict = { 'editor.views.crop.canvas': 'Parent view with the crop rectangle', 'editor.views.crop.canvas_failed': 'The parent view cannot be displayed.', 'editor.views.new': 'New detail view', - 'editor.views.new_hint': 'Fill in the crop for a cropped view; leave it empty for a view that will have its own drawing (chosen once the view is added).', + 'editor.views.new_hint': + 'Fill in the crop for a cropped view; leave it empty for a view that will have its own drawing (chosen once the view is added).', 'editor.views.add': 'Add the view', 'editor.views.required': 'Fill in the French and English names of the view.', - 'editor.views.frame.newly_invalid': 'This frame change would put the geometry of these elements in error: {names}. Move them first (Annotations, drawing).', - 'editor.views.frame.view_unmeasured': 'This change would make a view that holds annotations unmeasurable: {names}.', - 'editor.views.frame.kept': 'The drawing stays uploaded; the view keeps its previous drawing.', - 'editor.views.frame.newly_invalid_repairable': 'These elements fall outside the new frame: {names}. Choose the drawing again to repair them as you attach it.', + 'editor.views.frame.newly_invalid': + 'This frame change would put the geometry of these elements in error: {names}. Move them first (Annotations, drawing).', + 'editor.views.frame.view_unmeasured': + 'This change would make a view that holds annotations unmeasurable: {names}.', + 'editor.views.frame.kept': + 'The drawing stays uploaded; the view keeps its previous drawing.', + 'editor.views.frame.newly_invalid_repairable': + 'These elements fall outside the new frame: {names}. Choose the drawing again to repair them as you attach it.', 'editor.views.repair.title': 'Repair the annotations outside the new frame', - 'editor.views.repair.body_one': '{count} annotation falls outside the new frame of this drawing. The proposed values are computed in that frame. Nothing is applied before "Attach and apply": the drawing and the new values are then applied together, and a single Undo restores them together.', - 'editor.views.repair.body_other': '{count} annotations fall outside the new frame of this drawing. The proposed values are computed in that frame. Nothing is applied before "Attach and apply": the drawing and the new values are then applied together, and a single Undo restores them together.', + 'editor.views.repair.body_one': + '{count} annotation falls outside the new frame of this drawing. The proposed values are computed in that frame. Nothing is applied before "Attach and apply": the drawing and the new values are then applied together, and a single Undo restores them together.', + 'editor.views.repair.body_other': + '{count} annotations fall outside the new frame of this drawing. The proposed values are computed in that frame. Nothing is applied before "Attach and apply": the drawing and the new values are then applied together, and a single Undo restores them together.', 'editor.views.repair.row': '{kind} "{name}"', 'editor.views.repair.path_blocked': - "This free path is kept as it is. The drawing cannot be attached while it falls outside the new frame: the editor cannot yet correct the points of a free path.", - 'editor.views.repair.refused': 'Nothing was applied: the document check refuses these values.', - 'editor.views.repair.more_outside': 'Other elements would also fall outside the new frame: {names}. Nothing was applied. Cancel, fix them, then choose the drawing again.', - 'editor.views.repair.not_measurable': 'With this drawing, a view holding annotations would not be measurable. Nothing was applied.', + 'This free path is kept as it is. The drawing cannot be attached while it falls outside the new frame: the editor cannot yet correct the points of a free path.', + 'editor.views.repair.refused': + 'Nothing was applied: the document check refuses these values.', + 'editor.views.repair.more_outside': + 'Other elements would also fall outside the new frame: {names}. Nothing was applied. Cancel, fix them, then choose the drawing again.', + 'editor.views.repair.not_measurable': + 'With this drawing, a view holding annotations would not be measurable. Nothing was applied.', 'editor.views.repair.apply': 'Attach and apply', 'editor.views.repair.cancel': 'Cancel', 'editor.upload.working': 'Checking and sending the drawing…', 'editor.upload.done': 'The drawing is added to the view.', 'editor.upload.err.too_large': 'This file is larger than 2 MiB.', - 'editor.upload.err.svg_active_content': 'This file contains active or external content (script, link, remote image): it is refused.', - 'editor.upload.err.svg_rejected': 'This file is not a usable SVG drawing ({reason}).', - 'editor.upload.err.svg_not_canonical': "This drawing is not in the stored form: it is refused. Choose the original file again.", - 'editor.upload.err.size_mismatch': "A drawing's file size differs from the recorded size.", - 'editor.upload.err.upload_missing': 'The file did not reach the server. Try again.', - 'editor.upload.err.upload.pending_other': 'Another account is sending this drawing. Try again in a moment.', - 'editor.upload.err.object_conflict': "The illustration file's contents do not match its recorded SHA-256 hash.", - 'editor.upload.err.caps': 'Too many drawings in this editing session (16 at most). Save, then reload the draft.', + 'editor.upload.err.svg_active_content': + 'This file contains active or external content (script, link, remote image): it is refused.', + 'editor.upload.err.svg_rejected': + 'This file is not a usable SVG drawing ({reason}).', + 'editor.upload.err.svg_not_canonical': + 'This drawing is not in the stored form: it is refused. Choose the original file again.', + 'editor.upload.err.size_mismatch': + "A drawing's file size differs from the recorded size.", + 'editor.upload.err.upload_missing': + 'The file did not reach the server. Try again.', + 'editor.upload.err.upload.pending_other': + 'Another account is sending this drawing. Try again in a moment.', + 'editor.upload.err.object_conflict': + "The illustration file's contents do not match its recorded SHA-256 hash.", + 'editor.upload.err.caps': + 'Too many drawings in this editing session (16 at most). Save, then reload the draft.', 'editor.upload.err.core': 'The document check refused this drawing.', 'editor.upload.reason.malformed': 'malformed file', 'editor.upload.reason.doctype': 'DOCTYPE declaration not allowed', @@ -1551,16 +1696,20 @@ export const en: Dict = { 'editor.upload.reason.dangling_reference': 'reference to a missing element', 'editor.upload.reason.reserved_id': 'reserved identifier', 'editor.upload.reason.root_visibility': 'hidden root element', - 'editor.upload.reason.processing_instruction': "processing instruction not allowed", - 'editor.upload.reason.removal': "the file contains elements to remove", + 'editor.upload.reason.processing_instruction': + 'processing instruction not allowed', + 'editor.upload.reason.removal': 'the file contains elements to remove', 'editor.upload.reason.other': 'unrecognised reason', 'editor.cleaning.title': 'Clean this drawing?', - 'editor.cleaning.body': 'This file contains elements that are not kept. The preview shows the drawing as it will be saved.', + 'editor.cleaning.body': + 'This file contains elements that are not kept. The preview shows the drawing as it will be saved.', 'editor.cleaning.preview': 'Preview of the cleaned drawing', - 'editor.cleaning.preview_failed': 'The preview of the cleaned drawing cannot be composed.', + 'editor.cleaning.preview_failed': + 'The preview of the cleaned drawing cannot be composed.', 'editor.cleaning.removed': 'Removed elements:', 'editor.cleaning.active': 'Active or external content removed:', - 'editor.cleaning.style': 'The