feat(editor): cancel adding a reference by button or Escape
Draft tile gets « Annuler l'ajout »; Escape cancels from non-text targets and from a pristine text field, never while composing or already handled. Nothing reaches the document, history untouched, focus back on the add button.
This commit is contained in:
1 parent
1e19479853
commit
d1779928a9
10 files changed
+1138
-524
No files matched your search
@@ -10,6 +10,7 @@ import { referenceMatches } from '@/editor/references/filter'
|
||||
import { useSheetDocument } from '@/editor/sheetDocument'
|
||||
import { tileKeys, useTileState } from './useTileState'
|
||||
import { useReferenceView } from './useReferenceView'
|
||||
import { ADD_BUTTON_ID } from './addButton'
|
||||
|
||||
const NO_CITERS = new Map<string, never[]>()
|
||||
|
||||
@@ -95,6 +96,11 @@ export function useReferenceActions(
|
||||
tiles.reveal(`${id}#0`)
|
||||
later({ kind: 'reference', id })
|
||||
},
|
||||
// C2: nothing was written; the search and sort reset by the add stay as they are.
|
||||
cancelAdd: () => {
|
||||
setDraft(null)
|
||||
document.getElementById(ADD_BUTTON_ID)?.focus()
|
||||
},
|
||||
edit: (position: number) => {
|
||||
if (tiles.startEdit(keys[position])) shown.markEdited(keys[position])
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user