Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: adding new keybinding for open in full width and improvements in entrymenu

Ilian Sapundshiev95c7a6e64d82
diff --git a/src/main/electron-menus.ts b/src/main/electron-menus.ts
index e9458920c..8ea9f2026 100644
--- a/src/main/electron-menus.ts
+++ b/src/main/electron-menus.ts
@@ -139,7 +139,7 @@ export default function buildDesktopMenu(props: any, i18n) {
},
{
label: i18n.t('reloadApplication'),
- accelerator: 'CmdOrCtrl+Shift+R',
+ accelerator: 'Alt+Shift+R',
click: (item, focusedWindow) => {
focusedWindow.webContents.reload();
},
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsx
index d619bf699..73fbd371f 100644
--- a/src/renderer/components/EntryContainer.tsx
+++ b/src/renderer/components/EntryContainer.tsx
@@ -88,6 +88,7 @@ function EntryContainer() {
openPrevFile,
updateOpenedFile,
reloadOpenedFile,
+ toggleEntryFullWidth,
} = useOpenedEntryContext();
const { saveDescription } = useDescriptionContext();
const { readOnlyMode, switchLocationTypeByID, switchCurrentLocationType } =
@@ -457,7 +458,7 @@ function EntryContainer() {
}
};
- const startClosingFile = (event) => {
+ const startClosingEntry = (event) => {
if (event) {
event.preventDefault(); // Let's stop this event.
event.stopPropagation();
@@ -835,19 +836,23 @@ function EntryContainer() {
return (
<GlobalHotKeys
handlers={{
- closeViewer: startClosingFile,
+ closeViewer: startClosingEntry,
saveDocument: startSavingFile,
editDocument: editOpenedFile,
nextDocument: openNextFileAction,
prevDocument: openPrevFileAction,
+ reloadDocument: reloadDocument,
+ openInFullWidth: toggleEntryFullWidth,
toggleFullScreen,
}}
keyMap={{
- nextDocument: keyBindings.nextDocument,
- prevDocument: keyBindings.prevDocument,
closeViewer: keyBindings.closeViewer,
saveDocument: keyBindings.saveDocument,
editDocument: keyBindings.editDocument,
+ nextDocument: keyBindings.nextDocument,
+ prevDocument: keyBindings.prevDocument,
+ reloadDocument: keyBindings.reloadDocument,
+ openInFullWidth: keyBindings.openInFullWidth,
toggleFullScreen: keyBindings.toggleFullScreen,
}}
>
@@ -882,10 +887,11 @@ function EntryContainer() {
isFileChanged={fileChanged.current}
reloadDocument={reloadDocument}
toggleFullScreen={toggleFullScreen}
+ startClosingEntry={startClosingEntry}
/>
<EntryContainerNav
isFile={openedFile.isFile}
- startClosingFile={startClosingFile}
+ startClosingEntry={startClosingEntry}
/>
</Box>
{tabs()}
diff --git a/src/renderer/components/EntryContainerMenu.tsx b/src/renderer/components/EntryContainerMenu.tsx
index f7f02a7db..f82e8284a 100644
--- a/src/renderer/components/EntryContainerMenu.tsx
+++ b/src/renderer/components/EntryContainerMenu.tsx
@@ -23,17 +23,20 @@ import {
OpenNewWindowIcon,
ParentFolderIcon,
ReloadIcon,
+ CloseIcon,
} from '-/components/CommonIcons';
import ExpandIcon from '@mui/icons-material/SettingsEthernet';
import OpenNativelyIcon from '@mui/icons-material/Launch';
import FullScreenIcon from '@mui/icons-material/ZoomOutMap';
import FileDownloadIcon from '@mui/icons-material/AssignmentReturned';
import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
+import MenuKeyBinding from '-/components/menus/MenuKeyBinding';
import {
getWarningOpeningFilesExternally,
isDesktopMode,
} from '-/reducers/settings';
import { useTranslation } from 'react-i18next';
+import { getKeyBindingObject } from '-/reducers/settings';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
@@ -43,6 +46,7 @@ interface Props {
anchorEl: null | HTMLElement;
handleClose: () => void;
openedEntry: OpenedEntry;
+ startClosingEntry: (event) => void;
toggleFullScreen: () => void;
reloadDocument: () => void;
}
@@ -54,6 +58,7 @@ function EntryContainerMenu(props: Props) {
openedEntry,
toggleFullScreen,
reloadDocument,
+ startClosingEntry,
} = props;
const { t } = useTranslation();
// const theme = useTheme();
@@ -63,6 +68,7 @@ function EntryContainerMenu(props: Props) {
sharingLink,
sharingParentFolderLink,
} = useOpenedEntryContext();
+ const keyBindings = useSelector(getKeyBindingObject);
const { readOnlyMode } = useCurrentLocationContext();
const { deleteFile } = useIOActionsContext();
const { showNotification } = useNotificationContext();
@@ -199,6 +205,7 @@ function EntryContainerMenu(props: Props) {
<ReloadIcon />
</ListItemIcon>
<ListItemText primary={t('core:reloadFile')} />
+ <MenuKeyBinding keyBinding={keyBindings['reloadDocument']} />
</MenuItem>,
);
menuItems.push(
@@ -229,6 +236,7 @@ function EntryContainerMenu(props: Props) {
<FullScreenIcon />
</ListItemIcon>
<ListItemText primary={t('core:switchToFullscreen')} />
+ <MenuKeyBinding keyBinding={keyBindings['toggleFullScreen']} />
</MenuItem>,
);
if (desktopMode) {
@@ -246,6 +254,7 @@ function EntryContainerMenu(props: Props) {
<ExpandIcon />
</ListItemIcon>
<ListItemText primary={t('core:openInFullWidth')} />
+ <MenuKeyBinding keyBinding={keyBindings['openInFullWidth']} />
</MenuItem>,
);
}
@@ -349,6 +358,7 @@ function EntryContainerMenu(props: Props) {
<ReloadIcon />
</ListItemIcon>
<ListItemText primary={t('core:reloadDirectory')} />
+ <MenuKeyBinding keyBinding={keyBindings['reloadDocument']} />
</MenuItem>,
);
menuItems.push(<Divider key={'divider6'} />);
@@ -416,6 +426,7 @@ function EntryContainerMenu(props: Props) {
<ExpandIcon />
</ListItemIcon>
<ListItemText primary={t('core:openInFullWidth')} />
+ <MenuKeyBinding keyBinding={keyBindings['openInFullWidth']} />
</MenuItem>,
);
}
@@ -435,11 +446,28 @@ function EntryContainerMenu(props: Props) {
<DeleteIcon />
</ListItemIcon>
<ListItemText primary={t('core:deleteDirectory')} />
+ {/* <MenuKeyBinding keyBinding={keyBindings['deleteDocument']} /> */}
</MenuItem>,
);
}
}
+ menuItems.push(<Divider key={'divider5'} />);
+ menuItems.push(
+ <MenuItem
+ key={'openDirectoryExternallyKey'}
+ data-tid="closeEntryTID"
+ aria-label={t('core:closeEntry')}
+ onClick={startClosingEntry}
+ >
+ <ListItemIcon>
+ <CloseIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('core:closeEntry')} />
+ <MenuKeyBinding keyBinding={keyBindings['closeViewer']} />
+ </MenuItem>,
+ );
+
return (
<>
<Menu
@@ -456,7 +484,7 @@ function EntryContainerMenu(props: Props) {
horizontal: 'left',
}}
>
- <MenuList>{menuItems}</MenuList>
+ <MenuList sx={{ minWidth: 300 }}>{menuItems}</MenuList>
</Menu>
{isDeleteEntryModalOpened && (
<ConfirmDialog
diff --git a/src/renderer/components/EntryContainerNav.tsx b/src/renderer/components/EntryContainerNav.tsx
index 84a5d5bc2..253ba9ea4 100644
--- a/src/renderer/components/EntryContainerNav.tsx
+++ b/src/renderer/components/EntryContainerNav.tsx
@@ -9,11 +9,11 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
interface Props {
isFile: boolean;
- startClosingFile: (event) => void;
+ startClosingEntry: (event) => void;
}
function EntryContainerNav(props: Props) {
- const { isFile, startClosingFile } = props;
+ const { isFile, startClosingEntry } = props;
const { t } = useTranslation();
const { openNextFile, openPrevFile } = useOpenedEntryContext();
const theme = useTheme();
@@ -55,7 +55,7 @@ function EntryContainerNav(props: Props) {
)}
<Tooltip title={t('core:closeEntry')}>
<IconButton
- onClick={startClosingFile}
+ onClick={startClosingEntry}
aria-label={t('core:closeEntry')}
data-tid="fileContainerCloseOpenedFile"
size="large"
diff --git a/src/renderer/components/EntryContainerTitle.tsx b/src/renderer/components/EntryContainerTitle.tsx
index ab28498bb..1088f8326 100644
--- a/src/renderer/components/EntryContainerTitle.tsx
+++ b/src/renderer/components/EntryContainerTitle.tsx
@@ -57,10 +57,12 @@ interface Props {
isFileChanged: boolean;
toggleFullScreen: () => void;
reloadDocument: () => void;
+ startClosingEntry: (event) => void;
}
function EntryContainerTitle(props: Props) {
- const { isFileChanged, reloadDocument, toggleFullScreen } = props;
+ const { isFileChanged, reloadDocument, toggleFullScreen, startClosingEntry } =
+ props;
const { t } = useTranslation();
const theme = useTheme();
const { openedEntries, sharingLink, sharingParentFolderLink } =
@@ -239,6 +241,7 @@ function EntryContainerTitle(props: Props) {
<TagsPreview tags={openedFile.tags} />
<EntryContainerMenu
anchorEl={anchorEl}
+ startClosingEntry={startClosingEntry}
handleClose={() => setAnchorEl(null)}
openedEntry={openedFile}
reloadDocument={reloadDocument}
diff --git a/src/renderer/components/dialogs/KeyboardDialog.tsx b/src/renderer/components/dialogs/KeyboardDialog.tsx
index 952a154d9..3a3bcb0fd 100644
--- a/src/renderer/components/dialogs/KeyboardDialog.tsx
+++ b/src/renderer/components/dialogs/KeyboardDialog.tsx
@@ -35,6 +35,7 @@ import { useTranslation } from 'react-i18next';
import AppConfig from '-/AppConfig';
export function adjustKeyBinding(keyBinding: string) {
+ if (!keyBinding) return '';
let adjKB = keyBinding.toLowerCase();
if (AppConfig.isMacLike) {
adjKB = adjKB
diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsx
index a2563c5db..70f2cc3cb 100644
--- a/src/renderer/components/menus/FileMenu.tsx
+++ b/src/renderer/components/menus/FileMenu.tsx
@@ -541,19 +541,17 @@ function FileMenu(props: Props) {
}
return (
- <div style={{ overflowY: 'hidden' }}>
- <Menu
- anchorEl={anchorEl}
- anchorReference={mouseY && mouseX ? 'anchorPosition' : undefined}
- anchorPosition={
- mouseY && mouseX ? { top: mouseY, left: mouseX } : undefined
- }
- open={open}
- onClose={onClose}
- >
- {menuItems}
- </Menu>
- </div>
+ <Menu
+ anchorEl={anchorEl}
+ anchorReference={mouseY && mouseX ? 'anchorPosition' : undefined}
+ anchorPosition={
+ mouseY && mouseX ? { top: mouseY, left: mouseX } : undefined
+ }
+ open={open}
+ onClose={onClose}
+ >
+ {menuItems}
+ </Menu>
);
}
diff --git a/src/renderer/reducers/keybindings-default.ts b/src/renderer/reducers/keybindings-default.ts
index 327409f74..f1ff35563 100644
--- a/src/renderer/reducers/keybindings-default.ts
+++ b/src/renderer/reducers/keybindings-default.ts
@@ -48,10 +48,6 @@ export default function keyBindings(isMacLike) {
name: 'addRemoveTags',
command: (isMacLike ? 'command' : 'ctrl') + '+t',
},
- /* {
- name: 'propertiesDocument',
- command: 'alt+enter',
- }, */
{
name: 'nextDocument',
command: 'down',
@@ -74,12 +70,12 @@ export default function keyBindings(isMacLike) {
// },
{
name: 'toggleFullScreen',
- command: 'f11',
+ command: isMacLike ? 'command+f11' : 'f11',
+ },
+ {
+ name: 'openInFullWidth',
+ command: 'f10',
},
- // {
- // name: 'openDevTools',
- // command: 'f10'
- // },
{
name: 'openSearch',
command: (isMacLike ? 'command' : 'ctrl') + '+f',