feat(editor): header history, save line and Abandonner les modifications
Header Annuler/Retablir on every tab (aria-disabled, commit on pointerdown, refused blur commit skips the undo). Save line: unsaved count selector (savedDistance), saveLineState forms, server save time via readSaveTime (lastSave in the store, never the browser clock). Discard relabelled and names the stored copy. Tool column pair removed, glyphs in EditorGlyph. Rewritten or removed assertions (R-24): - editor-route.test: Revision 3 / unsaved text / Annuler les modifications -> save-line testid, Abandonner label, copy sentence in the dialog - editor-route-conflict, editor-route-recovery: Revision n and copy_cap/ copy_quota text queries -> save-line testid - editor-no-loss: discard button label - editor-annotations-tab: tool column undo/redo test -> no pair left (behaviour moved to editor-history-buttons.test) - e2e journey/annotations/recovery/structures/support saveDraft/lan: undo/redo and revision/unsaved text -> historyButton, saveLine helpers; structures toHaveCount(0) on old text -> exact Revision n line - editor-shell clickability: header Annuler/Retablir added
This commit is contained in:
1 parent
ab51ea764d
commit
99b669bf8f
29 files changed
+1397
-248
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { canRedo, canUndo, useEditorStore } from '@/editor/state/editorStore'
|
||||
import type { ToolId } from '@/editor/annotations/uiState'
|
||||
import { useT } from '@/i18n/useT'
|
||||
import EditorGlyph, { type GlyphName } from '../EditorGlyph'
|
||||
|
||||
export interface ToolColumnProps {
|
||||
tool: ToolId
|
||||
@@ -21,18 +21,6 @@ const BUTTON =
|
||||
'focus-visible:outline-none focus-visible:ring-2 ' +
|
||||
'focus-visible:ring-[var(--color-accent)]'
|
||||
|
||||
const GLYPHS: Record<string, string> = {
|
||||
select: 'M5 3l12 7-5 1-3 5z',
|
||||
point: 'M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zM12 3v3M12 18v3M3 12h3M18 12h3',
|
||||
zone: 'M12 3l8 6-3 10H7L4 9z',
|
||||
link: 'M4 4h8v8H4zM12 12h8v8h-8z',
|
||||
in: 'M11 5v12M5 11h12M20 20l-4-4',
|
||||
out: 'M5 11h12M20 20l-4-4',
|
||||
fit: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5',
|
||||
undo: 'M9 7L4 12l5 5M4 12h11a5 5 0 0 1 0 10',
|
||||
redo: 'M15 7l5 5-5 5M20 12H9a5 5 0 0 0 0 10',
|
||||
}
|
||||
|
||||
function ToolButton({
|
||||
glyph,
|
||||
label,
|
||||
@@ -40,7 +28,7 @@ function ToolButton({
|
||||
disabled,
|
||||
onClick,
|
||||
}: {
|
||||
glyph: string
|
||||
glyph: GlyphName
|
||||
label: string
|
||||
pressed?: boolean
|
||||
disabled?: boolean
|
||||
@@ -60,28 +48,14 @@ function ToolButton({
|
||||
: 'bg-[var(--color-surface)] text-[var(--color-ink)]'
|
||||
}`}
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
width="20"
|
||||
height="20"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.8"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d={GLYPHS[glyph]} />
|
||||
</svg>
|
||||
<EditorGlyph name={glyph} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** Board 04's tool column: tools, zoom, then undo and redo (icon buttons). */
|
||||
/** Board 04's tool column: tools and zoom (the history sits in the header). */
|
||||
export default function ToolColumn(props: ToolColumnProps) {
|
||||
const t = useT()
|
||||
const undoable = useEditorStore(canUndo)
|
||||
const redoable = useEditorStore(canRedo)
|
||||
const tool = (id: ToolId, disabled: boolean) => (
|
||||
<ToolButton
|
||||
glyph={id}
|
||||
@@ -118,19 +92,6 @@ export default function ToolColumn(props: ToolColumnProps) {
|
||||
label={t('catalogue.zoom.fit')}
|
||||
onClick={props.onFit}
|
||||
/>
|
||||
<hr className="hidden border-[var(--color-border)] lg:block" />
|
||||
<ToolButton
|
||||
glyph="undo"
|
||||
label={t('editor.annotations.undo')}
|
||||
disabled={!undoable}
|
||||
onClick={() => useEditorStore.getState().undoStep()}
|
||||
/>
|
||||
<ToolButton
|
||||
glyph="redo"
|
||||
label={t('editor.annotations.redo')}
|
||||
disabled={!redoable}
|
||||
onClick={() => useEditorStore.getState().redoStep()}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user