Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 88x 1418x 1418x 1418x 1418x 1418x 1418x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1418x 1418x 1418x 1418x 1418x 1418x 1418x 42x | import {Box, Container} from '@mui/material' import {useCallback, useContext, useState} from 'react' import {ResourceContext} from './resources' import {AllCategories, BuildContext, BuildEditContext, SettingsContext, type TermTypes} from './building' import {InfoDrawer, InfoDrawerContext} from './infoDrawer' import AddedTerms from './addedTerms' import {EditorTerm, TermEditor} from './termEditor' import {Nav} from './nav' import {PasswordPrompt} from './passwordPrompt' import AnalyzeMenu from './analysisMenu' import type {GridCell} from './table' const categoryPrefix = /^category_/ export function Content() { const [asTable, setAsTable] = useState(true) const dict = useContext(BuildContext) const Cats = useContext(AllCategories) const {terms} = useContext(ResourceContext) const editDictionary = useContext(BuildEditContext) const editFromEvent = useCallback( (value: string | number, row: GridCell) => { const {field, processed, dictEntry} = row const fromEditor = field === 'from_term_editor' Eif (dictEntry && (fromEditor || field.startsWith('category_'))) { const cats = {...dictEntry.categories} const cat = fromEditor ? row.id : field.replace(categoryPrefix, '') Iif (cat in cats && !value) { delete cats[cat] } else Eif (value) { cats[cat] = +value } editDictionary({ type: 'update', term_id: row[fromEditor ? 'term_id' : 'id'], term: processed.term, term_type: processed.term_type, categories: cats, sense: dictEntry.sense, }) } }, [editDictionary] ) const editorTerm = useContext(EditorTerm) const infoDrawerState = useContext(InfoDrawerContext) const showTermEditor = editorTerm in dict const settings = useContext(SettingsContext) const [infoDrawerHeight, setInfoDrawerHeight] = useState(settings.info_drawer_height || 30) const bottomMargin = infoDrawerState.length ? infoDrawerHeight : 0 return ( <Container> <Nav terms={terms} asTable={asTable} setAsTable={setAsTable} add={(term: string | RegExp, type: TermTypes) => { editDictionary({type: 'add', term: term, term_type: type}) }} /> <Box sx={{ position: 'absolute', top: 0, left: 0, bottom: 0, right: (showTermEditor ? settings.term_editor_width || 200 : 0) + 'px', mt: '3em', mb: bottomMargin + 'vh', }} > {asTable ? <AddedTerms editFromEvent={editFromEvent} /> : <AnalyzeMenu />} {showTermEditor && ( <TermEditor categories={Cats} editor={editFromEvent} width={settings.term_editor_width || 200} /> )} <InfoDrawer height={infoDrawerHeight} setHeight={setInfoDrawerHeight} /> </Box> <PasswordPrompt /> </Container> ) } |