feat: controllable highlight state for embedding hosts
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
Direzione di ricerca
Start with HighlightProvider, useHighlight, and the NMRium/InnerNMRium prop flow described in the issue. Trace the existing reducer and dispatch behavior, then verify that controlled and uncontrolled modes preserve current behavior, expose the proposed state types, and report every highlight change through onHighlightChange.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
NMRium's highlight state is currently private to HighlightProvider / useHighlight. Embedding hosts (for example via nmrium-react-wrapper) sometimes need to drive that state from outside NMRium — typically across a cross-origin iframe with postMessage.
Proposed API
export interface NMRiumHighlightState {
highlighted: string[];
highlightedPermanently: string[];
sourceData: HighlightEventSource | null;
}
interface NMRiumProps {
// ...existing
/** When provided, highlight state is controlled by the host. */
highlight?: NMRiumHighlightState;
/** Called for every highlight change, including internal hover/click. */
onHighlightChange?: (state: NMRiumHighlightState) => void;
}
Leaving highlight out keeps today's behaviour unchanged (uncontrolled).
Implementation sketch
HighlightProvideraccepts optionalvalue/onChange.- In controlled mode, render from
value;dispatchruns the existing reducer against a latest-state ref and callsonChange(next)instead of updating internal state. - Keep that ref in sync with each reduced value (not only with props), so consecutive dispatches such as the
useHighlightunmount cleanup (HIDEthenUNSET_PERMANENT) do not drop updates. - The internal
highlightsrecord can stay derived fromhighlightedand remain private. - Wire
highlight/onHighlightChangefromNMRiumPropsthroughInnerNMRiumintoHighlightProvider. - Export
NMRiumHighlightState(andHighlightEventSourceif not already public).
Out of scope (separate discussion)
NMRium regenerates peak ids on load, so imported ids from a host never match. Hosts currently fall back to matching by nucleus + ppm. Keeping imported peak ids stable would let hosts highlight by id; that can be a follow-up.
Questions for the team
- Is the controlled-prop shape preferred over an imperative
NMRiumRefAPI.highlight(ids)/clearHighlight()method? - Any concern about
onHighlightChangefiring on every hover (performance for large spectra / embedding hosts)?
- Lingua principale
- TypeScript
- Stelle
- 81
- Fork
- 35
- Merge medio
- 3g 5h
- PR unite (30g)
- 19
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cheminfo/nmrium
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
reedit of simulated spectra ?Forse già presa @hamed-musallam l’ha presa 21 giorni fa. Aperta
cheminfo/nmrium#4396 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Remove Node.js types from frontend-only codeForse di nuovo libera @targos l’ha presa 31 giorni fa e non c’è nessuna pull request aperta. Aperta
cheminfo/nmrium#4386 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cheminfo/nmrium
Issue simili
-
Unsampled pageload span is profiled when profileLifecycle is 'trace' (browser UI profiling)Forse già presa @Jxxunnn l’ha presa oggi. ApertaBrowser Waiting for: Product Owner
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
getsentry/sentry-javascript#25497 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
redhat-developer/rhdh-plugin-export-overlays#4438 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
resource: destroying a resource calls AbortController.abort() without a reason, creating an AbortError with a stack trace each timeForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaarea: core
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
angular/angular#71422 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
facebook/docusaurus#12739 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
vercel/ai#23537 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno