mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
Improve hotkeys
This commit is contained in:
parent
bc31df77a9
commit
38b661f290
|
@ -30,7 +30,7 @@ function ConstituentaToolbar({
|
||||||
return (
|
return (
|
||||||
<Overlay position='right-1/2 translate-x-1/2 top-1 flex items-start'>
|
<Overlay position='right-1/2 translate-x-1/2 top-1 flex items-start'>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Сохранить изменения'
|
tooltip='Сохранить изменения [Ctrl + S]'
|
||||||
disabled={!canSave}
|
disabled={!canSave}
|
||||||
icon={<SaveIcon size={5} color={canSave ? 'text-primary' : ''}/>}
|
icon={<SaveIcon size={5} color={canSave ? 'text-primary' : ''}/>}
|
||||||
onClick={onSubmit}
|
onClick={onSubmit}
|
||||||
|
@ -48,13 +48,13 @@ function ConstituentaToolbar({
|
||||||
icon={<SmallPlusIcon size={5} color={isMutable ? 'text-success' : ''} />}
|
icon={<SmallPlusIcon size={5} color={isMutable ? 'text-success' : ''} />}
|
||||||
/>
|
/>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Клонировать конституенту'
|
tooltip='Клонировать конституенту [Alt + V]'
|
||||||
disabled={!isMutable}
|
disabled={!isMutable}
|
||||||
onClick={onClone}
|
onClick={onClone}
|
||||||
icon={<CloneIcon size={5} color={isMutable ? 'text-success' : ''} />}
|
icon={<CloneIcon size={5} color={isMutable ? 'text-success' : ''} />}
|
||||||
/>
|
/>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Создать конституенту из шаблона'
|
tooltip='Создать конституенту из шаблона [Alt + E]'
|
||||||
icon={<DiamondIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
icon={<DiamondIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
||||||
disabled={!isMutable}
|
disabled={!isMutable}
|
||||||
onClick={onTemplates}
|
onClick={onTemplates}
|
||||||
|
|
|
@ -48,7 +48,7 @@ function EditorConstituenta({
|
||||||
onDeleteCst([activeID]);
|
onDeleteCst([activeID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCreateCst() {
|
function handleCreate() {
|
||||||
if (!activeID || !schema) {
|
if (!activeID || !schema) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ function EditorConstituenta({
|
||||||
onCreateCst(data);
|
onCreateCst(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCloneCst() {
|
function handleClone() {
|
||||||
if (!activeID || !schema || !activeCst) {
|
if (!activeID || !schema || !activeCst) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,19 +82,39 @@ function EditorConstituenta({
|
||||||
onCreateCst(data, true);
|
onCreateCst(data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleInput(event: React.KeyboardEvent<HTMLDivElement>) {
|
||||||
|
if (!isMutable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.ctrlKey && event.code === 'KeyS') {
|
||||||
|
if (isModified) {
|
||||||
|
initiateSubmit();
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!event.altKey || event.shiftKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (processAltKey(event.code)) {
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initiateSubmit() {
|
function initiateSubmit() {
|
||||||
const element = document.getElementById(globalIDs.constituenta_editor) as HTMLFormElement;
|
const element = document.getElementById(globalIDs.constituenta_editor) as HTMLFormElement;
|
||||||
if (element) {
|
if (element) {
|
||||||
element.requestSubmit();
|
element.requestSubmit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleInput(event: React.KeyboardEvent<HTMLDivElement>) {
|
|
||||||
if (event.ctrlKey && event.code === 'KeyS') {
|
function processAltKey(code: string): boolean {
|
||||||
if (isModified) {
|
switch (code) {
|
||||||
initiateSubmit();
|
case 'KeyE': onTemplates(); return true;
|
||||||
}
|
case 'KeyV': handleClone(); return true;
|
||||||
event.preventDefault();
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -110,8 +130,8 @@ function EditorConstituenta({
|
||||||
onReset={() => setToggleReset(prev => !prev)}
|
onReset={() => setToggleReset(prev => !prev)}
|
||||||
|
|
||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
onClone={handleCloneCst}
|
onClone={handleClone}
|
||||||
onCreate={handleCreateCst}
|
onCreate={handleCreate}
|
||||||
onTemplates={() => onTemplates(activeID)}
|
onTemplates={() => onTemplates(activeID)}
|
||||||
/>
|
/>
|
||||||
<div className='flex justify-start'>
|
<div className='flex justify-start'>
|
||||||
|
|
|
@ -28,7 +28,7 @@ function RSFormToolbar({
|
||||||
return (
|
return (
|
||||||
<Overlay position='w-full top-1 flex items-start justify-center'>
|
<Overlay position='w-full top-1 flex items-start justify-center'>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Сохранить изменения'
|
tooltip='Сохранить изменения [Ctrl + S]'
|
||||||
disabled={!canSave}
|
disabled={!canSave}
|
||||||
icon={<SaveIcon size={5} color={canSave ? 'text-primary' : ''}/>}
|
icon={<SaveIcon size={5} color={canSave ? 'text-primary' : ''}/>}
|
||||||
onClick={onSubmit}
|
onClick={onSubmit}
|
||||||
|
|
|
@ -177,11 +177,14 @@ function EditorRSList({ onOpenEdit, onCreateCst, onDeleteCst, onTemplates }: Edi
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'ArrowUp': handleMoveUp(); return true;
|
case 'ArrowUp': handleMoveUp(); return true;
|
||||||
case 'ArrowDown': handleMoveDown(); return true;
|
case 'ArrowDown': handleMoveDown(); return true;
|
||||||
case 'KeyV': handleClone(); return true;
|
case 'KeyV': handleClone(); return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'Backquote': handleCreateCst(); return true;
|
case 'Backquote': handleCreateCst(); return true;
|
||||||
|
case 'KeyE': onTemplates(); return true;
|
||||||
|
case 'KeyR': handleReindex(); return true;
|
||||||
|
|
||||||
case 'Digit1': handleCreateCst(CstType.BASE); return true;
|
case 'Digit1': handleCreateCst(CstType.BASE); return true;
|
||||||
case 'Digit2': handleCreateCst(CstType.STRUCTURED); return true;
|
case 'Digit2': handleCreateCst(CstType.STRUCTURED); return true;
|
||||||
case 'Digit3': handleCreateCst(CstType.TERM); return true;
|
case 'Digit3': handleCreateCst(CstType.TERM); return true;
|
||||||
|
|
|
@ -86,13 +86,13 @@ function RSListToolbar({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Создать конституенту из шаблона'
|
tooltip='Создать конституенту из шаблона [Alt + E]'
|
||||||
icon={<DiamondIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
icon={<DiamondIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
||||||
disabled={!isMutable}
|
disabled={!isMutable}
|
||||||
onClick={onTemplates}
|
onClick={onTemplates}
|
||||||
/>
|
/>
|
||||||
<MiniButton
|
<MiniButton
|
||||||
tooltip='Сброс имен: присвоить порядковые имена'
|
tooltip='Сброс имен: присвоить порядковые имена [Alt + R]'
|
||||||
icon={<UpdateIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
icon={<UpdateIcon color={isMutable ? 'text-primary': ''} size={5}/>}
|
||||||
disabled={!isMutable}
|
disabled={!isMutable}
|
||||||
onClick={onReindex}
|
onClick={onReindex}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user