diff --git a/rsconcept/frontend/src/components/Common/ConceptTab.tsx b/rsconcept/frontend/src/components/Common/ConceptTab.tsx index a21e00f2..fd114ed0 100644 --- a/rsconcept/frontend/src/components/Common/ConceptTab.tsx +++ b/rsconcept/frontend/src/components/Common/ConceptTab.tsx @@ -2,19 +2,20 @@ import type { TabProps } from 'react-tabs'; import { Tab } from 'react-tabs'; interface ConceptTabProps -extends Omit { +extends Omit { className?: string tooltip?: string + label?: string } -function ConceptTab({ children, tooltip, className, ...otherProps }: ConceptTabProps) { +function ConceptTab({ label, tooltip, className, ...otherProps }: ConceptTabProps) { return ( - {children} + {label} ); } diff --git a/rsconcept/frontend/src/components/RSInput/RSInput.tsx b/rsconcept/frontend/src/components/RSInput/RSInput.tsx index abe31189..6b5a8157 100644 --- a/rsconcept/frontend/src/components/RSInput/RSInput.tsx +++ b/rsconcept/frontend/src/components/RSInput/RSInput.tsx @@ -8,7 +8,6 @@ import { RefObject, useCallback, useMemo, useRef } from 'react'; import { useRSForm } from '../../context/RSFormContext'; import { useConceptTheme } from '../../context/ThemeContext'; -import { TokenID } from '../../models/rslang'; import Label from '../Common/Label'; import { ccBracketMatching } from './bracketMatching'; import { RSLanguage } from './rslang'; @@ -105,39 +104,7 @@ function RSInput({ return; } const text = new RSTextWrapper(thisRef.current as Required); - if (event.shiftKey && !event.altKey) { - if (event.key === '*') { - text.insertToken(TokenID.DECART); - event.preventDefault(); - } else if (event.code === 'KeyB') { - text.insertChar('ℬ'); - event.preventDefault(); - } else if (event.code === 'KeyZ') { - text.insertChar('Z'); - event.preventDefault(); - } else if (event.code === 'KeyR') { - text.insertChar('R'); - event.preventDefault(); - } else if (event.code === 'KeyF') { - text.insertChar('F'); - event.preventDefault(); - } else if (event.code === 'KeyP') { - text.insertChar('P'); - event.preventDefault(); - } else if (event.code === 'KeyX') { - text.insertChar('X'); - event.preventDefault(); - } else if (event.code === 'KeyS') { - text.insertChar('S'); - event.preventDefault(); - } else if (event.code === 'KeyD') { - text.insertChar('D'); - event.preventDefault(); - } else if (event.code === 'KeyC') { - text.insertChar('C'); - event.preventDefault(); - } - } else if (event.altKey) { + if (event.altKey) { if (text.processAltKey(event.code, event.shiftKey)) { event.preventDefault(); } diff --git a/rsconcept/frontend/src/components/RSInput/textEditing.ts b/rsconcept/frontend/src/components/RSInput/textEditing.ts index b75229e1..1eb34bc5 100644 --- a/rsconcept/frontend/src/components/RSInput/textEditing.ts +++ b/rsconcept/frontend/src/components/RSInput/textEditing.ts @@ -6,9 +6,24 @@ import { TokenID } from '../../models/rslang'; import { CodeMirrorWrapper } from '../../utils/codemirror'; export function getSymbolSubstitute(keyCode: string, shiftPressed: boolean): string | undefined { + console.log(keyCode); if (shiftPressed) { switch (keyCode) { case 'Backquote': return '∃'; + case 'Backslash': return '|'; + case 'BracketLeft': return '{'; + case 'BracketRight': return '}'; + + case 'Digit8': return '×'; + case 'KeyB': return 'ℬ'; + case 'KeyZ': return 'Z'; + case 'KeyR': return 'R'; + case 'KeyF': return 'F'; + case 'KeyP': return 'P'; + case 'KeyX': return 'X'; + case 'KeyS': return 'S'; + case 'KeyD': return 'D'; + case 'KeyC': return 'C'; } } else { switch (keyCode) { @@ -37,6 +52,11 @@ export function getSymbolSubstitute(keyCode: string, shiftPressed: boolean): str case 'KeyV': return 'θ'; case 'KeyB': return 'β'; case 'KeyN': return 'η'; + + // punctuation + case 'BracketLeft': return '['; + case 'BracketRight': return ']'; + case 'Comma': return ','; } } return undefined; diff --git a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx index 20f87e0a..364aa994 100644 --- a/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx +++ b/rsconcept/frontend/src/dialogs/DlgConstituentaTemplate/DlgConstituentaTemplate.tsx @@ -28,9 +28,9 @@ export enum TabID { } function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }: DlgConstituentaTemplateProps) { - const [ validated, setValidated ] = useState(false); - const [ template, updateTemplate ] = usePartialUpdate({}); - const [ substitutes, updateSubstitutes ] = usePartialUpdate({ + const [validated, setValidated] = useState(false); + const [template, updateTemplate] = usePartialUpdate({}); + const [substitutes, updateSubstitutes] = usePartialUpdate({ definition: '', arguments: [] }); @@ -116,26 +116,29 @@ function DlgConstituentaTemplate({ hideWindow, schema, onCreate, insertAfter }: submitText='Создать' >
-
- - Шаблон - - - Аргументы - - - Конституента - + + +
diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/ConstituentaToolbar.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/ConstituentaToolbar.tsx index 683669e7..602fbe04 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/ConstituentaToolbar.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/ConstituentaToolbar.tsx @@ -26,7 +26,8 @@ function ConstituentaToolbar({ const canSave = useMemo(() => (isModified && editorMode), [isModified, editorMode]); return (
-
+
+
+
); } diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx index 9e2b9535..72f8d65d 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/FormConstituenta.tsx @@ -103,7 +103,7 @@ function FormConstituenta({ return (<> {readyForEdit ?
-
+
} /> -
+
Имя {constituenta?.alias ?? ''}
diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/EditorRSForm.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/EditorRSForm.tsx index 2d493af7..335862f4 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/EditorRSForm.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorRSForm/EditorRSForm.tsx @@ -53,8 +53,8 @@ function EditorRSForm({ onDestroy, onClaim, onShare, isModified, setIsModified, onDestroy={onDestroy} />
-
-
+
+
+
cst.id === selected[0]); @@ -164,30 +164,30 @@ function EditorRSList({ onOpenEdit, onCreateCst, onDeleteCst, onTemplates }: Edi if (!event.altKey || event.shiftKey) { return; } - if (processAltKey(event.key)) { + if (processAltKey(event.code)) { event.preventDefault(); return; } } - function processAltKey(key: string): boolean { + function processAltKey(code: string): boolean { if (selected.length > 0) { - switch (key) { + switch (code) { case 'ArrowUp': handleMoveUp(); return true; case 'ArrowDown': handleMoveDown(); return true; + case 'KeyV': handleClone(); return true; } } - switch (key) { - case '1': handleCreateCst(CstType.BASE); return true; - case '2': handleCreateCst(CstType.STRUCTURED); return true; - case '3': handleCreateCst(CstType.TERM); return true; - case '4': handleCreateCst(CstType.AXIOM); return true; - case 'й': - case 'q': handleCreateCst(CstType.FUNCTION); return true; - case 'ц': - case 'w': handleCreateCst(CstType.PREDICATE); return true; - case '5': handleCreateCst(CstType.CONSTANT); return true; - case '6': handleCreateCst(CstType.THEOREM); return true; + switch (code) { + case 'Backquote': handleCreateCst(); return true; + case 'Digit1': handleCreateCst(CstType.BASE); return true; + case 'Digit2': handleCreateCst(CstType.STRUCTURED); return true; + case 'Digit3': handleCreateCst(CstType.TERM); return true; + case 'Digit4': handleCreateCst(CstType.AXIOM); return true; + case 'KeyQ': handleCreateCst(CstType.FUNCTION); return true; + case 'KeyW': handleCreateCst(CstType.PREDICATE); return true; + case 'Digit5': handleCreateCst(CstType.CONSTANT); return true; + case 'Digit6': handleCreateCst(CstType.THEOREM); return true; } return false; } @@ -295,8 +295,8 @@ function EditorRSList({ onOpenEdit, onCreateCst, onDeleteCst, onTemplates }: Edi style={{minHeight: mainHeight}} onKeyDown={handleTableKey} > -
-
+
+
Выбор {selected.length} из {schema?.stats?.count_all ?? 0}
selectedCount === 0, [selectedCount]); return ( -
+
} disabled={!editorMode || nothingSelected} onClick={onMoveUp} /> } disabled={!editorMode || nothingSelected} onClick={onMoveDown} /> } - disabled={!editorMode || nothingSelected} - onClick={onDelete} - /> - } disabled={!editorMode || selectedCount !== 1} onClick={onClone} /> } disabled={!editorMode} onClick={() => onCreate()} @@ -72,7 +66,7 @@ function RSListToolbar({ disabled={!editorMode} onClick={insertMenu.toggle} /> - { insertMenu.isActive && + {insertMenu.isActive ? {(Object.values(CstType)).map( (typeStr) => { @@ -86,7 +80,7 @@ function RSListToolbar({ {`${getCstTypePrefix(type)}1 — ${labelCstType(type)}`} ); })} - } + : null}
- + } + disabled={!editorMode || nothingSelected} + onClick={onDelete} + />
diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx index 94348fa0..77a89b76 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx @@ -327,142 +327,143 @@ function RSTabs() { cstUpdate(data, () => toast.success('Изменения сохранены')); }, [cstUpdate, activeID]); - return ( -
- {loading ? : null} - {error ? : null} - {(schema && !loading) ? <> - {showUpload ? - setShowUpload(false)} - /> : null} - {showClone ? - setShowClone(false)} - /> : null} - {showAST ? - setShowAST(false)} - /> : null} - {showCreateCst ? - setShowCreateCst(false)} - onCreate={handleCreateCst} - schema={schema} - initial={createInitialData} - /> : null} - {showRenameCst ? - setShowRenameCst(false)} - onRename={handleRenameCst} - initial={renameInitialData!} - /> : null} - {showDeleteCst ? - setShowDeleteCst(false)} - onDelete={handleDeleteCst} - selected={toBeDeleted} - /> : null} - {showEditTerm ? - setShowEditTerm(false)} - onSave={handleSaveWordforms} - target={activeCst!} - /> : null} - {showTemplates ? - setShowTemplates(false)} - insertAfter={insertCstID} - onCreate={handleCreateCst} - /> : null} - - - + {loading ? : null} + {error ? : null} + + {showUpload ? + setShowUpload(false)} + /> : null} + {showClone ? + setShowClone(false)} + /> : null} + {showAST ? + setShowAST(false)} + /> : null} + {showCreateCst ? + setShowCreateCst(false)} + onCreate={handleCreateCst} + schema={schema!} + initial={createInitialData} + /> : null} + {showRenameCst ? + setShowRenameCst(false)} + onRename={handleRenameCst} + initial={renameInitialData!} + /> : null} + {showDeleteCst ? + setShowDeleteCst(false)} + onDelete={handleDeleteCst} + selected={toBeDeleted} + /> : null} + {showEditTerm ? + setShowEditTerm(false)} + onSave={handleSaveWordforms} + target={activeCst!} + /> : null} + {showTemplates ? + setShowTemplates(false)} + insertAfter={insertCstID} + onCreate={handleCreateCst} + /> : null} + + {(schema && !loading) ? + +
+ + setShowUpload(true)} + /> + + + + + +
+ +
+ + setShowUpload(true)} /> - - Карточка - - - Содержание - - - Редактор - - - Граф термов - - + -
- - - + + + - - - + + + - - - - - - - -
- - : null} -
); + + + +
+ : null} + ); } export default RSTabs;