mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Added Ctrl/Meta + F to open advanced search screen
Cleanup search field onEnter
This commit is contained in:
parent
e0498895bc
commit
6f2f5bce86
11 changed files with 73 additions and 71 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { Scope } from 'Common/Enums';
|
||||
import { moveAction } from 'Common/Globals';
|
||||
import { moveAction, addShortcut } from 'Common/Globals';
|
||||
import { mailBox, settings } from 'Common/Links';
|
||||
import { setFolderHash } from 'Common/Cache';
|
||||
import { addComputablesTo } from 'External/ko';
|
||||
|
|
@ -117,7 +117,7 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
}
|
||||
});
|
||||
|
||||
shortcuts.add('arrowup,arrowdown', '', Scope.FolderList, event => {
|
||||
addShortcut('arrowup,arrowdown', '', Scope.FolderList, event => {
|
||||
let items = [], index = 0;
|
||||
dom.querySelectorAll('li a:not(.hidden)').forEach(node => {
|
||||
if (node.offsetHeight || node.getClientRects().length) {
|
||||
|
|
@ -141,7 +141,7 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('enter,open', '', Scope.FolderList, () => {
|
||||
addShortcut('enter,open', '', Scope.FolderList, () => {
|
||||
const item = qs('li a:not(.hidden).focused');
|
||||
if (item) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
|
|
@ -151,7 +151,7 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('space', '', Scope.FolderList, () => {
|
||||
addShortcut('space', '', Scope.FolderList, () => {
|
||||
const item = qs('li a:not(.hidden).focused'),
|
||||
folder = item && ko.dataFor(item);
|
||||
if (folder) {
|
||||
|
|
@ -163,8 +163,8 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
return false;
|
||||
});
|
||||
|
||||
// shortcuts.add('tab', 'shift', Scope.FolderList, () => {
|
||||
shortcuts.add('escape,tab,arrowright', '', Scope.FolderList, () => {
|
||||
// addShortcut('tab', 'shift', Scope.FolderList, () => {
|
||||
addShortcut('escape,tab,arrowright', '', Scope.FolderList, () => {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
moveAction(false);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
|||
|
||||
import { doc, leftPanelDisabled, moveAction,
|
||||
Settings, SettingsCapa, SettingsGet,
|
||||
fireEvent, addEventsListeners,
|
||||
registerShortcut
|
||||
addEventsListeners,
|
||||
addShortcut, registerShortcut, formFieldFocused
|
||||
} from 'Common/Globals';
|
||||
|
||||
import { computedPaginatorHelper, showMessageComposer, populateMessageBody } from 'Common/UtilsUser';
|
||||
|
|
@ -412,10 +412,6 @@ export class MailMessageList extends AbstractViewRight {
|
|||
&& SettingsUserStore.usePreviewPane();
|
||||
}
|
||||
|
||||
searchEnterAction() {
|
||||
MessagelistUserStore.mainSearch(this.sLastSearchValue);
|
||||
}
|
||||
|
||||
cancelSearch() {
|
||||
MessagelistUserStore.mainSearch('');
|
||||
this.inputMessageListSearchFocus(false);
|
||||
|
|
@ -697,9 +693,13 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
// initShortcuts
|
||||
|
||||
registerShortcut('enter,open', '', Scope.MessageList, () => {
|
||||
addShortcut('enter,open', '', Scope.MessageList, () => {
|
||||
if (formFieldFocused()) {
|
||||
MessagelistUserStore.mainSearch(this.sLastSearchValue);
|
||||
return false;
|
||||
}
|
||||
if (MessageUserStore.message() && this.useAutoSelect()) {
|
||||
fireEvent('mailbox.message-view.toggle-full-screen');
|
||||
MessageUserStore.toggleFullScreen();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
@ -722,7 +722,7 @@ export class MailMessageList extends AbstractViewRight {
|
|||
});
|
||||
|
||||
// check mail
|
||||
shortcuts.add('r', 'meta', [Scope.FolderList, Scope.MessageList, Scope.MessageView], () => {
|
||||
addShortcut('r', 'meta', [Scope.FolderList, Scope.MessageList, Scope.MessageView], () => {
|
||||
this.reload();
|
||||
return false;
|
||||
});
|
||||
|
|
@ -781,21 +781,21 @@ export class MailMessageList extends AbstractViewRight {
|
|||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('f,mailforward', 'shift', [Scope.MessageList, Scope.MessageView], () => {
|
||||
addShortcut('f,mailforward', 'shift', [Scope.MessageList, Scope.MessageView], () => {
|
||||
this.multyForwardCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
if (SettingsCapa('Search')) {
|
||||
// search input focus
|
||||
shortcuts.add('/', '', [Scope.MessageList, Scope.MessageView], () => {
|
||||
addShortcut('/', '', [Scope.MessageList, Scope.MessageView], () => {
|
||||
this.inputMessageListSearchFocus(true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// cancel search
|
||||
shortcuts.add('escape', '', Scope.MessageList, () => {
|
||||
addShortcut('escape', '', Scope.MessageList, () => {
|
||||
if (this.messageListSearchDesc()) {
|
||||
this.cancelSearch();
|
||||
return false;
|
||||
|
|
@ -806,23 +806,25 @@ export class MailMessageList extends AbstractViewRight {
|
|||
});
|
||||
|
||||
// change focused state
|
||||
shortcuts.add('tab', 'shift', Scope.MessageList, () => {
|
||||
addShortcut('tab', 'shift', Scope.MessageList, () => {
|
||||
AppUserStore.focusedState(Scope.FolderList);
|
||||
return false;
|
||||
});
|
||||
shortcuts.add('arrowleft', '', Scope.MessageList, () => {
|
||||
addShortcut('arrowleft', '', Scope.MessageList, () => {
|
||||
AppUserStore.focusedState(Scope.FolderList);
|
||||
return false;
|
||||
});
|
||||
shortcuts.add('tab,arrowright', '', Scope.MessageList, () => {
|
||||
addShortcut('tab,arrowright', '', Scope.MessageList, () => {
|
||||
if (MessageUserStore.message()){
|
||||
AppUserStore.focusedState(Scope.MessageView);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
shortcuts.add('arrowleft', 'meta', Scope.MessageView, ()=>false);
|
||||
shortcuts.add('arrowright', 'meta', Scope.MessageView, ()=>false);
|
||||
addShortcut('arrowleft', 'meta', Scope.MessageView, ()=>false);
|
||||
addShortcut('arrowright', 'meta', Scope.MessageView, ()=>false);
|
||||
|
||||
addShortcut('f', 'meta', Scope.MessageList, ()=>this.advancedSearchClick());
|
||||
|
||||
if (!ThemeStore.isMobile() && SettingsCapa('Prefetch')) {
|
||||
ifvisible.idle(this.prefetchNextTick.bind(this));
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import {
|
|||
getFullscreenElement,
|
||||
exitFullscreen,
|
||||
fireEvent,
|
||||
addShortcut,
|
||||
registerShortcut
|
||||
} from 'Common/Globals';
|
||||
|
||||
|
|
@ -118,6 +119,7 @@ export class MailMessageView extends AbstractViewRight {
|
|||
this.messageError = MessageUserStore.error;
|
||||
|
||||
this.fullScreenMode = MessageUserStore.fullScreen;
|
||||
this.toggleFullScreen = MessageUserStore.toggleFullScreen;
|
||||
|
||||
this.messageListOfThreadsLoading = ko.observable(false).extend({ rateLimit: 1 });
|
||||
this.highlightUnselectedAttachments = ko.observable(false).extend({ falseTimeout: 2000 });
|
||||
|
|
@ -225,8 +227,6 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
this.lastReplyAction(Local.get(ClientSideKeyName.LastReplyAction) || ComposeType.Reply);
|
||||
|
||||
addEventListener('mailbox.message-view.toggle-full-screen', () => this.toggleFullScreen());
|
||||
|
||||
// commands
|
||||
this.replyCommand = createCommandReplyHelper(ComposeType.Reply);
|
||||
this.replyAllCommand = createCommandReplyHelper(ComposeType.ReplyAll);
|
||||
|
|
@ -269,14 +269,6 @@ export class MailMessageView extends AbstractViewRight {
|
|||
);
|
||||
}
|
||||
|
||||
toggleFullScreen() {
|
||||
try {
|
||||
getSelection().removeAllRanges();
|
||||
} catch (e) {} // eslint-disable-line no-empty
|
||||
|
||||
this.fullScreenMode(!this.fullScreenMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sType
|
||||
* @returns {void}
|
||||
|
|
@ -288,7 +280,7 @@ export class MailMessageView extends AbstractViewRight {
|
|||
|
||||
onBuild(dom) {
|
||||
const el = dom.querySelector('.b-content');
|
||||
this.oContent = initFullscreen(el, () => this.fullScreenMode(getFullscreenElement() === el));
|
||||
this.oContent = initFullscreen(el, () => MessageUserStore.fullScreen(getFullscreenElement() === el));
|
||||
|
||||
const eqs = (ev, s) => ev.target.closestWithin(s, dom);
|
||||
dom.addEventListener('click', event => {
|
||||
|
|
@ -354,11 +346,11 @@ export class MailMessageView extends AbstractViewRight {
|
|||
// initShortcuts
|
||||
|
||||
// exit fullscreen, back
|
||||
shortcuts.add('escape', '', Scope.MessageView, () => {
|
||||
addShortcut('escape', '', Scope.MessageView, () => {
|
||||
if (!this.viewModelDom.hidden && currentMessage()) {
|
||||
const preview = SettingsUserStore.usePreviewPane();
|
||||
if (this.fullScreenMode()) {
|
||||
this.fullScreenMode(false);
|
||||
if (MessageUserStore.fullScreen()) {
|
||||
MessageUserStore.fullScreen(false);
|
||||
|
||||
if (preview) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
|
|
@ -374,8 +366,8 @@ export class MailMessageView extends AbstractViewRight {
|
|||
});
|
||||
|
||||
// fullscreen
|
||||
shortcuts.add('enter,open', '', Scope.MessageView, () => {
|
||||
this.toggleFullScreen();
|
||||
addShortcut('enter,open', '', Scope.MessageView, () => {
|
||||
MessageUserStore.toggleFullScreen();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
|
@ -427,42 +419,42 @@ export class MailMessageView extends AbstractViewRight {
|
|||
}
|
||||
});
|
||||
|
||||
shortcuts.add('arrowup,arrowleft', 'meta', [Scope.MessageList, Scope.MessageView], () => {
|
||||
addShortcut('arrowup,arrowleft', 'meta', [Scope.MessageList, Scope.MessageView], () => {
|
||||
this.goUpCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
shortcuts.add('arrowdown,arrowright', 'meta', [Scope.MessageList, Scope.MessageView], () => {
|
||||
addShortcut('arrowdown,arrowright', 'meta', [Scope.MessageList, Scope.MessageView], () => {
|
||||
this.goDownCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// print
|
||||
shortcuts.add('p,printscreen', 'meta', [Scope.MessageView, Scope.MessageList], () => {
|
||||
addShortcut('p,printscreen', 'meta', [Scope.MessageView, Scope.MessageList], () => {
|
||||
currentMessage() && currentMessage().printMessage();
|
||||
return false;
|
||||
});
|
||||
|
||||
// delete
|
||||
shortcuts.add('delete', '', Scope.MessageView, () => {
|
||||
addShortcut('delete', '', Scope.MessageView, () => {
|
||||
this.deleteCommand();
|
||||
return false;
|
||||
});
|
||||
shortcuts.add('delete', 'shift', Scope.MessageView, () => {
|
||||
addShortcut('delete', 'shift', Scope.MessageView, () => {
|
||||
this.deleteWithoutMoveCommand();
|
||||
return false;
|
||||
});
|
||||
|
||||
// change focused state
|
||||
shortcuts.add('arrowleft', '', Scope.MessageView, () => {
|
||||
if (!this.fullScreenMode() && currentMessage() && SettingsUserStore.usePreviewPane()
|
||||
addShortcut('arrowleft', '', Scope.MessageView, () => {
|
||||
if (!MessageUserStore.fullScreen() && currentMessage() && SettingsUserStore.usePreviewPane()
|
||||
&& !oMessageScrollerDom().scrollLeft) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
shortcuts.add('tab', 'shift', Scope.MessageView, () => {
|
||||
if (!this.fullScreenMode() && currentMessage() && SettingsUserStore.usePreviewPane()) {
|
||||
addShortcut('tab', 'shift', Scope.MessageView, () => {
|
||||
if (!MessageUserStore.fullScreen() && currentMessage() && SettingsUserStore.usePreviewPane()) {
|
||||
AppUserStore.focusedState(Scope.MessageList);
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue