mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +08:00
fix(preferences): Display multiple keybindings when available
This commit is contained in:
parent
94372f22c8
commit
e7fce1f120
4 changed files with 33 additions and 8 deletions
|
@ -42,8 +42,7 @@ class PreferencesKeymaps extends React.Component
|
||||||
_getStateFromKeymaps: =>
|
_getStateFromKeymaps: =>
|
||||||
bindings = {}
|
bindings = {}
|
||||||
for [command, label] in DisplayedKeybindings
|
for [command, label] in DisplayedKeybindings
|
||||||
[found] = atom.keymaps.findKeyBindings(command: command, target: document.body) || []
|
bindings[command] = atom.keymaps.findKeyBindings(command: command, target: document.body) || []
|
||||||
bindings[command] = found
|
|
||||||
bindings
|
bindings
|
||||||
|
|
||||||
render: =>
|
render: =>
|
||||||
|
@ -69,19 +68,32 @@ class PreferencesKeymaps extends React.Component
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
_renderBindingFor: ([command, label]) =>
|
_renderBindingFor: ([command, label]) =>
|
||||||
description = "None"
|
descriptions = []
|
||||||
if @state.bindings[command]
|
if @state.bindings[command]
|
||||||
{keystrokes} = @state.bindings[command]
|
for binding in @state.bindings[command]
|
||||||
description = keystrokes.replace(/-/gi,'').replace(/cmd/gi, '⌘').replace(/alt/gi, '⌥').replace(/shift/gi, '⇧').replace(/ctrl/gi, '^').toUpperCase()
|
descriptions.push(@_formatKeystrokes(binding.keystrokes))
|
||||||
|
|
||||||
|
if descriptions.length is 0
|
||||||
|
value = 'None'
|
||||||
|
else
|
||||||
|
value = _.uniq(descriptions).join(', ')
|
||||||
|
|
||||||
<Flexbox className="shortcut" key={command}>
|
<Flexbox className="shortcut" key={command}>
|
||||||
<div className="shortcut-name">{label}</div>
|
<div className="shortcut-name">{label}</div>
|
||||||
<div className="shortcut-value">{description}</div>
|
<div className="shortcut-value">{value}</div>
|
||||||
</Flexbox>
|
</Flexbox>
|
||||||
|
|
||||||
_renderBindings: =>
|
_renderBindings: =>
|
||||||
DisplayedKeybindings.map(@_renderBindingFor)
|
DisplayedKeybindings.map(@_renderBindingFor)
|
||||||
|
|
||||||
|
_formatKeystrokes: (keystrokes) ->
|
||||||
|
if process.platform is 'win32'
|
||||||
|
# On Windows, display cmd-shift-c
|
||||||
|
return keystrokes
|
||||||
|
else
|
||||||
|
# On Mac and Linux, display ⌘⇧C
|
||||||
|
return keystrokes.replace(/-/gi,'').replace(/cmd/gi, '⌘').replace(/alt/gi, '⌥').replace(/shift/gi, '⇧').replace(/ctrl/gi, '^').toUpperCase()
|
||||||
|
|
||||||
_onShowUserKeymaps: =>
|
_onShowUserKeymaps: =>
|
||||||
require('shell').openItem(atom.keymaps.getUserKeymapPath())
|
require('shell').openItem(atom.keymaps.getUserKeymapPath())
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,6 @@ body.platform-darwin {
|
||||||
&.shortcut-select {
|
&.shortcut-select {
|
||||||
padding: 5px 0px 20px 0px;
|
padding: 5px 0px 20px 0px;
|
||||||
select {
|
select {
|
||||||
font-size: @font-size-larger;
|
|
||||||
width: 75%;
|
width: 75%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,3 +23,17 @@
|
||||||
'e' : 'core:remove-item' # Gmail
|
'e' : 'core:remove-item' # Gmail
|
||||||
's' : 'core:star-item' #Gmail
|
's' : 'core:star-item' #Gmail
|
||||||
'x' : 'core:select-item'
|
'x' : 'core:select-item'
|
||||||
|
|
||||||
|
# Gmail also includes some more basic ones that users expect from desktop software.
|
||||||
|
|
||||||
|
'body.platform-darwin':
|
||||||
|
'cmd-n' : 'application:new-message'
|
||||||
|
'cmd-r' : 'application:reply'
|
||||||
|
'cmd-R' : 'application:reply-all'
|
||||||
|
'cmd-F' : 'application:forward'
|
||||||
|
|
||||||
|
'body.platform-linux, body.platform-win32':
|
||||||
|
'ctrl-n' : 'application:new-message'
|
||||||
|
'ctrl-r' : 'application:reply'
|
||||||
|
'ctrl-R' : 'application:reply-all'
|
||||||
|
'ctrl-F' : 'application:forward'
|
||||||
|
|
2
src/react-remote/react-remote-parent.js
vendored
2
src/react-remote/react-remote-parent.js
vendored
|
@ -196,7 +196,7 @@ var openWindowForComponent = function(Component, options) {
|
||||||
if (!styleNode.sourcePath) {
|
if (!styleNode.sourcePath) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((styleNode.sourcePath.indexOf("static/index") > 0) || (options.stylesheetRegex && options.stylesheetRegex.test(styleNode.sourcePath))) {
|
if ((styleNode.sourcePath.indexOf('index') > 0) || (options.stylesheetRegex && options.stylesheetRegex.test(styleNode.sourcePath))) {
|
||||||
thinStyles = thinStyles + styleNode.innerText;
|
thinStyles = thinStyles + styleNode.innerText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue