Skip to content

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

improving key binding handling

Ilian Sapundshiev5c1d5c3a2357
diff --git a/app/components/EntryContainer.js b/app/components/EntryContainer.js
index b8cf65f3e..35c902151 100644
--- a/app/components/EntryContainer.js
+++ b/app/components/EntryContainer.js
@@ -921,8 +921,6 @@ class EntryContainer extends React.Component<Props, State> {
saveDocument: this.startSavingFile,
editDocument: this.editFile,
reloadDocument: this.reloadDocument,
- nextDocument: this.isPropertiesEditMode ? () => {} : this.openNextFile,
- prevDocument: this.isPropertiesEditMode ? () => {} : this.openPrevFile
}}
>
<ConfirmDialog
diff --git a/app/components/FolderContainer.js b/app/components/FolderContainer.js
index c85ab9bf6..9b629dba2 100644
--- a/app/components/FolderContainer.js
+++ b/app/components/FolderContainer.js
@@ -358,95 +358,97 @@ class FolderContainer extends React.Component<Props, State> {
searchResultCounterText = 'More than ' + (maxSearchResults - 1) + ' entries found, showing only the first ' + maxSearchResults;
}
return (
- <div className={classes.mainPanel}>
- <div className={classes.topPanel}>
- <div className={classes.toolbar}>
- {isDesktopMode ? (
- <LocationMenu />
- ) : (
- <Button style={{ marginLeft: -8 }} onClick={showDrawer}>
- <MenuIcon />
- </Button>
- )}
- <CounterBadge
- showZero={true}
- title={searchResultCounterText}
- badgeContent={searchResultCount}
- color="secondary"
- max={maxSearchResults - 1}
- onClick={() => {
- openSearchPanel();
- }}
- />
- <div className={classes.flexMiddle} />
- {currentDirectoryPath && (
- <React.Fragment>
- {isDesktopMode && this.state.pathParts &&
- this.state.pathParts.map(pathPart => (
- <Button
- key={pathPart}
- onClick={() => loadDirectoryContent(pathPart)}
- title={'Navigate to: ' + pathPart}
- style={{ paddingLeft: 3, paddingRight: 0, minWidth: 10 }}
- >
- {extractShortDirectoryName(pathPart, '/')}
- &nbsp;/&nbsp;
- </Button>
- ))}
- {!isDesktopMode && this.state.pathParts && this.state.pathParts.length > 0 && (
- <React.Fragment>
- <Button
- onClick={loadParentDirectoryContent}
- data-tid="openParentDirectory"
- style={{ paddingLeft: 3, paddingRight: 0}}
- >
- <BackButtonIcon />
- </Button>
- </React.Fragment>
- )}
- <Button
- data-tid="folderContainerOpenDirMenu"
- title={
- i18n.t('core:openDirectoryMenu') +
- ' - ' +
- (currentDirectoryPath || '')
- }
- className={classes.folderButton}
- onClick={this.openDirectoryMenu}
- onContextMenu={this.openDirectoryMenu}
- >
- {extractShortDirectoryName(
- normalizePath(normalizedCurrentDirPath), '/'
- )}
- <MoreVertIcon />
+ <div>
+ <div className={classes.mainPanel}>
+ <div className={classes.topPanel}>
+ <div className={classes.toolbar}>
+ {isDesktopMode ? (
+ <LocationMenu />
+ ) : (
+ <Button style={{ marginLeft: -8 }} onClick={showDrawer}>
+ <MenuIcon />
</Button>
- <DirectoryMenu
- open={this.state.directoryContextMenuOpened}
- onClose={this.closeDirectoryMenu}
- anchorEl={this.state.directoryContextMenuAnchorEl}
- directoryPath={currentDirectoryPath}
- loadDirectoryContent={this.props.loadDirectoryContent}
- openFileNatively={this.props.openFileNatively}
- openDirectory={this.props.openDirectory}
- loadParentDirectoryContent={loadParentDirectoryContent}
- showInFileManager={this.props.showInFileManager}
- reflectCreateEntry={this.props.reflectCreateEntry}
- openFile={this.props.openFile}
- toggleCreateFileDialog={this.props.toggleCreateFileDialog}
- deleteDirectory={this.props.deleteDirectory}
- showNotification={this.props.showNotification}
- switchPerspective={this.switchPerspective}
- isReadOnlyMode={this.props.isReadOnlyMode}
- />
- </React.Fragment>
- )}
+ )}
+ <CounterBadge
+ showZero={true}
+ title={searchResultCounterText}
+ badgeContent={searchResultCount}
+ color="secondary"
+ max={maxSearchResults - 1}
+ onClick={() => {
+ openSearchPanel();
+ }}
+ />
+ <div className={classes.flexMiddle} />
+ {currentDirectoryPath && (
+ <React.Fragment>
+ {isDesktopMode && this.state.pathParts &&
+ this.state.pathParts.map(pathPart => (
+ <Button
+ key={pathPart}
+ onClick={() => loadDirectoryContent(pathPart)}
+ title={'Navigate to: ' + pathPart}
+ style={{ paddingLeft: 3, paddingRight: 0, minWidth: 10 }}
+ >
+ {extractShortDirectoryName(pathPart, '/')}
+ &nbsp;/&nbsp;
+ </Button>
+ ))}
+ {!isDesktopMode && this.state.pathParts && this.state.pathParts.length > 0 && (
+ <React.Fragment>
+ <Button
+ onClick={loadParentDirectoryContent}
+ data-tid="openParentDirectory"
+ style={{ paddingLeft: 3, paddingRight: 0 }}
+ >
+ <BackButtonIcon />
+ </Button>
+ </React.Fragment>
+ )}
+ <Button
+ data-tid="folderContainerOpenDirMenu"
+ title={
+ i18n.t('core:openDirectoryMenu') +
+ ' - ' +
+ (currentDirectoryPath || '')
+ }
+ className={classes.folderButton}
+ onClick={this.openDirectoryMenu}
+ onContextMenu={this.openDirectoryMenu}
+ >
+ {extractShortDirectoryName(
+ normalizePath(normalizedCurrentDirPath), '/'
+ )}
+ <MoreVertIcon />
+ </Button>
+ <DirectoryMenu
+ open={this.state.directoryContextMenuOpened}
+ onClose={this.closeDirectoryMenu}
+ anchorEl={this.state.directoryContextMenuAnchorEl}
+ directoryPath={currentDirectoryPath}
+ loadDirectoryContent={this.props.loadDirectoryContent}
+ openFileNatively={this.props.openFileNatively}
+ openDirectory={this.props.openDirectory}
+ loadParentDirectoryContent={loadParentDirectoryContent}
+ showInFileManager={this.props.showInFileManager}
+ reflectCreateEntry={this.props.reflectCreateEntry}
+ openFile={this.props.openFile}
+ toggleCreateFileDialog={this.props.toggleCreateFileDialog}
+ deleteDirectory={this.props.deleteDirectory}
+ showNotification={this.props.showNotification}
+ switchPerspective={this.switchPerspective}
+ isReadOnlyMode={this.props.isReadOnlyMode}
+ />
+ </React.Fragment>
+ )}
+ </div>
+ </div>
+ <div
+ className={classes.centerPanel}
+ style={{ height: this.props.windowHeight }}
+ >
+ {this.renderPerspective()}
</div>
- </div>
- <div
- className={classes.centerPanel}
- style={{ height: this.props.windowHeight }}
- >
- {this.renderPerspective()}
</div>
</div>
);
diff --git a/app/containers/MainPage.js b/app/containers/MainPage.js
index 4f3d6b91d..8f6abf884 100644
--- a/app/containers/MainPage.js
+++ b/app/containers/MainPage.js
@@ -137,25 +137,17 @@ type Props = {
isUpdateAvailable: boolean,
isReadOnlyMode: boolean,
isSettingsDialogOpened: boolean,
- toggleSettingsDialog: () => void,
isCreateFileDialogOpened: boolean,
- toggleCreateFileDialog: () => void,
isCreateDirectoryOpened: boolean,
toggleCreateDirectoryDialog: () => void,
isAboutDialogOpened: boolean,
- toggleAboutDialog: () => void,
isCreateDirectoryOpened: boolean,
toggleCreateDirectoryDialog: () => void,
isCreateFileDialogOpened: boolean,
- toggleCreateFileDialog: () => void,
isKeysDialogOpened: boolean,
- toggleKeysDialog: () => void,
isLicenseDialogOpened: boolean,
- toggleLicenseDialog: () => void,
isThirdPartyLibsDialogOpened: boolean,
- toggleThirdPartyLibsDialog: () => void,
isOnboardingDialogOpened: boolean,
- toggleOnboardingDialog: () => void,
isSelectDirectoryDialogOpened: boolean,
toggleSelectDirectoryDialog: () => void,
isEditTagDialogOpened: boolean,
@@ -818,16 +810,9 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return bindActionCreators({
loadParentDirectoryContent: AppActions.loadParentDirectoryContent,
- toggleSettingsDialog: AppActions.toggleSettingsDialog,
- toggleCreateFileDialog: AppActions.toggleCreateFileDialog,
toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,
toggleSelectDirectoryDialog: AppActions.toggleSelectDirectoryDialog,
toggleEditTagDialog: AppActions.toggleEditTagDialog,
- toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
- toggleLicenseDialog: AppActions.toggleLicenseDialog,
- toggleThirdPartyLibsDialog: AppActions.toggleThirdPartyLibsDialog,
- toggleAboutDialog: AppActions.toggleAboutDialog,
- toggleKeysDialog: AppActions.toggleKeysDialog,
hideNotifications: AppActions.hideNotifications,
cancelDirectoryIndexing: LocationIndexActions.cancelDirectoryIndexing,
saveFile: AppActions.saveFile,
diff --git a/app/perspectives/grid-perspective/components/MainContainer.js b/app/perspectives/grid-perspective/components/MainContainer.js
index 91db23298..39a29c6f6 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.js
+++ b/app/perspectives/grid-perspective/components/MainContainer.js
@@ -104,6 +104,8 @@ type Props = {
isAppLoading: boolean,
isReadOnlyMode: boolean,
openFile: (path: string, isFile?: boolean) => void,
+ getNextFile: () => void,
+ getPrevFile: () => void,
deleteFile: (path: string) => void,
deleteDirectory: (path: string) => void,
loadDirectoryContent: (path: string) => void,
@@ -629,18 +631,22 @@ class GridPerspective extends React.Component<Props, State> {
keyMap = this.props.keyBindings;
keyBindingHandlers = {
- // nextDocument: () => {
- // const nextFilePath = this.props.getNextFile();
- // if (nextFilePath) {
- // this.props.setLastSelectedEntry(nextFilePath);
- // }
- // },
- // prevDocument: () => {
- // const prevFilePath = this.props.getPrevFile();
- // if (prevFilePath) {
- // this.props.setLastSelectedEntry(prevFilePath);
- // }
- // },
+ nextDocument: () => {
+ const nextFilePath = this.props.getNextFile();
+ if (nextFilePath) {
+ const nextFile = this.props.directoryContent.filter(entry => entry.path === nextFilePath);
+ this.props.setLastSelectedEntry(nextFilePath);
+ this.props.setSelectedEntries(nextFile);
+ }
+ },
+ prevDocument: () => {
+ const prevFilePath = this.props.getPrevFile();
+ if (prevFilePath) {
+ const prevFile = this.props.directoryContent.filter(entry => entry.path === prevFilePath);
+ this.props.setLastSelectedEntry(prevFilePath);
+ this.props.setSelectedEntries(prevFile);
+ }
+ },
selectAll: () => this.toggleSelectAllFiles(),
deleteDocument: () => {
if (this.state.fileOperationsEnabled) {
@@ -659,7 +665,8 @@ class GridPerspective extends React.Component<Props, State> {
});
}
},
- openEntry: () => {
+ openEntry: (e) => {
+ e.preventDefault();
const { lastSelectedEntryPath } = this.props;
if (lastSelectedEntryPath) {
const isLastSelectedEntryFile = this.props.directoryContent.some(
@@ -812,7 +819,7 @@ class GridPerspective extends React.Component<Props, State> {
<MoreVertIcon />
</IconButton>
</Toolbar>
- {/* <GlobalHotKeys keyMap={this.keyMap} handlers={this.keyBindingHandlers}> */}
+ <GlobalHotKeys keyMap={this.keyMap} handlers={this.keyBindingHandlers}>
<div style={{
height: '100%',
backgroundColor: theme.palette.background.default
@@ -854,7 +861,7 @@ class GridPerspective extends React.Component<Props, State> {
</div>
</div>
</div>
- {/* </GlobalHotKeys> */}
+ </GlobalHotKeys>
<AddRemoveTagsDialog
open={this.state.isAddRemoveTagsDialogOpened}
onClose={this.handleCloseDialogs}
@@ -1125,6 +1132,8 @@ function mapActionCreatorsToProps(dispatch) {
showNotification: AppActions.showNotification,
openFileNatively: AppActions.openFileNatively,
openURLExternally: AppActions.openURLExternally,
+ getNextFile: AppActions.getNextFile,
+ getPrevFile: AppActions.getPrevFile,
addTags: TaggingActions.addTags,
}, dispatch);
}
diff --git a/app/reducers/settings-default.js b/app/reducers/settings-default.js
index 1bcbdf3f1..3963beafb 100644
--- a/app/reducers/settings-default.js
+++ b/app/reducers/settings-default.js
@@ -228,17 +228,11 @@ export default {
}, */
{
name: 'nextDocument',
- command: [
- 'right',
- 'down'
- ],
+ command: 'down'
},
{
name: 'prevDocument',
- command: [
- 'left',
- 'up'
- ],
+ command: 'up',
},
{
name: 'showHelp',