Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shortcuts to fold blocks #2597

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ export default class CodeEditor extends React.Component {
}
return CodeMirror.Pass
},
[translateHotkey(hotkey.foldAll)]: 'foldAll',
[translateHotkey(hotkey.unfoldAll)]: 'unfoldAll',
[translateHotkey(hotkey.foldLevel1)]: 'foldLevel1',
[translateHotkey(hotkey.foldLevel2)]: 'foldLevel2',
[translateHotkey(hotkey.foldLevel3)]: 'foldLevel3',
[translateHotkey(hotkey.foldLevel4)]: 'foldLevel4',
[translateHotkey(hotkey.foldLevel5)]: 'foldLevel5',
[translateHotkey(hotkey.unfoldLevel1)]: 'unfoldLevel1',
[translateHotkey(hotkey.unfoldLevel2)]: 'unfoldLevel2',
[translateHotkey(hotkey.unfoldLevel3)]: 'unfoldLevel3',
[translateHotkey(hotkey.unfoldLevel4)]: 'unfoldLevel4',
[translateHotkey(hotkey.unfoldLevel5)]: 'unfoldLevel5',
[translateHotkey(hotkey.pasteSmartly)]: cm => {
this.handlePaste(cm, true)
}
Expand Down
2 changes: 1 addition & 1 deletion browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ class MarkdownEditor extends React.Component {
noteKey={noteKey}
fetchUrlTitle={config.editor.fetchUrlTitle}
enableTableEditor={config.editor.enableTableEditor}
hotkey={config.hotkey}
linesHighlighted={linesHighlighted}
onChange={(e) => this.handleChange(e)}
onBlur={(e) => this.handleBlur(e)}
spellCheck={config.editor.spellcheck}
enableSmartPaste={config.editor.enableSmartPaste}
hotkey={config.hotkey}
switchPreview={config.editor.switchPreview}
/>
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
Expand Down
6 changes: 3 additions & 3 deletions browser/components/MarkdownSplitEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ class MarkdownSplitEditor extends React.Component {
enableTableEditor={config.editor.enableTableEditor}
storageKey={storageKey}
noteKey={noteKey}
hotkey={config.hotkey}
linesHighlighted={linesHighlighted}
onChange={(e) => this.handleOnChange(e)}
onScroll={this.handleScroll.bind(this)}
onScroll={(e) => this.handleScroll(e)}
spellCheck={config.editor.spellcheck}
enableSmartPaste={config.editor.enableSmartPaste}
hotkey={config.hotkey}
switchPreview={config.editor.switchPreview}
/>
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
Expand All @@ -199,7 +199,7 @@ class MarkdownSplitEditor extends React.Component {
tabInde='0'
value={value}
onCheckboxClick={(e) => this.handleCheckboxClick(e)}
onScroll={this.handleScroll.bind(this)}
onScroll={(e) => this.handleScroll(e)}
showCopyNotification={config.ui.showCopyNotification}
storagePath={storage.path}
noteKey={noteKey}
Expand Down
14 changes: 13 additions & 1 deletion browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ export const DEFAULT_CONFIG = {
toggleMain: OSX ? 'Command + Alt + L' : 'Super + Alt + E',
toggleMode: OSX ? 'Command + Alt + M' : 'Ctrl + M',
deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace',
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V'
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V',
foldAll: OSX ? 'Command + O' : 'Control + O',
unfoldAll: OSX ? 'Command + Shift + O' : 'Control + Shift + O',
foldLevel1: OSX ? 'Control + 1' : 'Alt + 1',
foldLevel2: OSX ? 'Control + 2' : 'Alt + 2',
foldLevel3: OSX ? 'Control + 3' : 'Alt + 3',
foldLevel4: OSX ? 'Control + 4' : 'Alt + 4',
foldLevel5: OSX ? 'Control + 5' : 'Alt + 5',
unfoldLevel1: OSX ? 'Control + Alt + 1' : 'Alt + Shift + 1',
unfoldLevel2: OSX ? 'Control + Alt + 2' : 'Alt + Shift + 2',
unfoldLevel3: OSX ? 'Control + Alt + 3' : 'Alt + Shift + 3',
unfoldLevel4: OSX ? 'Control + Alt + 4' : 'Alt + Shift + 4',
unfoldLevel5: OSX ? 'Control + Alt + 5' : 'Alt + Shift + 5'
},
ui: {
language: 'en',
Expand Down
150 changes: 149 additions & 1 deletion browser/main/modals/PreferencesModal/HotkeyTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ class HotkeyTab extends React.Component {
toggleMain: this.refs.toggleMain.value,
toggleMode: this.refs.toggleMode.value,
deleteNote: this.refs.deleteNote.value,
pasteSmartly: this.refs.pasteSmartly.value
pasteSmartly: this.refs.pasteSmartly.value,
foldAll: this.refs.foldAll.value,
unfoldAll: this.refs.unfoldAll.value,
foldLevel1: this.refs.foldLevel1.value,
foldLevel2: this.refs.foldLevel2.value,
foldLevel3: this.refs.foldLevel3.value,
foldLevel4: this.refs.foldLevel4.value,
foldLevel5: this.refs.foldLevel5.value,
unfoldLevel1: this.refs.unfoldLevel1.value,
unfoldLevel2: this.refs.unfoldLevel2.value,
unfoldLevel3: this.refs.unfoldLevel3.value,
unfoldLevel4: this.refs.unfoldLevel4.value,
unfoldLevel5: this.refs.unfoldLevel5.value
}
this.setState({
config
Expand Down Expand Up @@ -150,6 +162,7 @@ class HotkeyTab extends React.Component {
/>
</div>
</div>

<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Paste Smartly')}</div>
<div styleName='group-section-control'>
Expand All @@ -161,6 +174,141 @@ class HotkeyTab extends React.Component {
/>
</div>
</div>

<div styleName='group-header2'>Fold/Unfold</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold All')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldAll'
value={config.hotkey.foldAll}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold All')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldAll'
value={config.hotkey.unfoldAll}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold Level 1')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldLevel1'
value={config.hotkey.foldLevel1}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold Level 2')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldLevel2'
value={config.hotkey.foldLevel2}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold Level 3')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldLevel3'
value={config.hotkey.foldLevel3}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold Level 4')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldLevel4'
value={config.hotkey.foldLevel4}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Fold Level 5')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='foldLevel5'
value={config.hotkey.foldLevel5}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold Level 1')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldLevel1'
value={config.hotkey.unfoldLevel1}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold Level 2')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldLevel2'
value={config.hotkey.unfoldLevel2}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold Level 3')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldLevel3'
value={config.hotkey.unfoldLevel3}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold Level 4')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldLevel4'
value={config.hotkey.unfoldLevel4}
type='text'
/>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>{i18n.__('Unfold Level 5')}</div>
<div styleName='group-section-control'>
<input styleName='group-section-control-input'
onChange={(e) => this.handleHotkeyChange(e)}
ref='unfoldLevel5'
value={config.hotkey.unfoldLevel5}
type='text'
/>
</div>
</div>

<div styleName='group-control'>
<button styleName='group-control-leftButton'
onClick={(e) => this.handleHintToggleButtonClick(e)}
Expand Down
Loading