fix(editor): Task 12 review minors, delete hint and cite label

This commit is contained in:
bchanot committed 2026-11-15 16:58:50 +01:00
1 parent 8c420d4b53
commit 11c2b0c5ee
12 files changed
+113 -47

No files matched your search

+7 -4
View File
@@ -138,7 +138,7 @@ export interface EditorNavigation {
openCitations: (citedBy: ElementKey, opener?: Opener) => void
/**
* A close of the citations dialog: a user one is refused by its draft (it asks first),
* a forced one goes (the draft is dropped).
* a forced one goes (the draft is dropped, and said so).
*/
closeCitations: (forced?: boolean) => boolean
/** « X références », where the focus returns once the citations dialog is closed. */
@@ -393,7 +393,7 @@ function useFindingClosing({ dispatch, announce, guards, mark }: LayerContext) {
/** The citations dialog over the finding dialog: opened for a family or a node only. */
function useCitationsLayer(ctx: LayerContext, openers: Openers) {
const { dispatch, guards, mark } = ctx
const { dispatch, announce, guards, mark } = ctx
const openCitations = useCallback(
(citedBy: ElementKey, opener?: Opener) => {
if (!isCitable(citedBy)) return
@@ -406,12 +406,15 @@ function useCitationsLayer(ctx: LayerContext, openers: Openers) {
)
const closeCitations = useCallback(
(forced = false) => {
if (!guards.ask('citations', forced).allowed) return false
const answer = guards.ask('citations', forced)
if (!answer.allowed) return false
// A forced close of a draft says it was dropped, as the other forced closes.
if (answer.note) announce(answer.note)
mark()
dispatch({ type: 'close_citations' })
return true
},
[guards, dispatch, mark],
[guards, announce, dispatch, mark],
)
return { openCitations, closeCitations }
}
+14 -8
View File
@@ -42,7 +42,10 @@ export interface ReferenceMoves {
backToFinding: (key: ElementKey) => void
}
/** What the open dialog was started from: its opener, and a citing form for a creation. */
/**
* What the open dialog was started from: its opener, and a citing form for a creation
* (forgotten once the dialog closes or is replaced).
*/
interface Held {
opener: Opener
cite: CiteCreated | null
@@ -72,22 +75,25 @@ function useOpening({ dispatch, mark }: LayerContext, held: Held) {
}
/** A user close: the form may refuse it (a dirty draft asks first). */
function useClose({ dispatch, guards, mark }: LayerContext) {
function useClose({ dispatch, guards, mark }: LayerContext, held: Held) {
return useCallback(
(forced = false) => {
if (!guards.ask('reference', forced).allowed) return false
held.cite = null
mark()
dispatch({ type: 'close_reference' })
return true
},
[guards, dispatch, mark],
[guards, dispatch, mark, held],
)
}
/** The replace that is no Back step; with `text`, forced and said with a dropped draft. */
function useReplace({ dispatch, announce, guards, mark }: LayerContext) {
function useReplace(ctx: LayerContext, held: Held) {
const { dispatch, announce, guards, mark } = ctx
return useCallback(
(id: string | null, text?: string) => {
held.cite = null
const note = text ? guards.ask('reference', true).note : undefined
if (text) announce(note ? `${note}. ${text}` : text)
mark(true)
@@ -95,13 +101,13 @@ function useReplace({ dispatch, announce, guards, mark }: LayerContext) {
id ? { type: 'open_reference', id } : { type: 'close_reference' },
)
},
[guards, announce, dispatch, mark],
[guards, announce, dispatch, mark, held],
)
}
/** The moves that take it away: a user close, and the replace that is no Back step. */
function useClosing(ctx: LayerContext) {
return { close: useClose(ctx), replace: useReplace(ctx) }
function useClosing(ctx: LayerContext, held: Held) {
return { close: useClose(ctx, held), replace: useReplace(ctx, held) }
}
/**
@@ -169,7 +175,7 @@ export function useReferenceMoves(
const element = held.opener
return element?.isConnected && !element.closest('[hidden]') ? element : null
}, [held])
const closing = useClosing(ctx)
const closing = useClosing(ctx, held)
return {
...useOpening(ctx, held),
...closing,