mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Add ability to sort lines with a hot key combination
This commit is contained in:
@@ -241,6 +241,15 @@ export default class CodeEditor extends React.Component {
|
|||||||
const newCursorPos = cm.doc.posFromIndex(formattedCursorPos)
|
const newCursorPos = cm.doc.posFromIndex(formattedCursorPos)
|
||||||
cm.doc.setCursor(newCursorPos)
|
cm.doc.setCursor(newCursorPos)
|
||||||
},
|
},
|
||||||
|
[translateHotkey(hotkey.sortLines)]: cm => {
|
||||||
|
const selection = cm.doc.getSelection()
|
||||||
|
const appendLineBreak = /\n$/.test(selection)
|
||||||
|
|
||||||
|
const sorted = _.split(selection.trim(), '\n').sort()
|
||||||
|
const sortedString = _.join(sorted, '\n') + (appendLineBreak ? '\n' : '')
|
||||||
|
|
||||||
|
cm.doc.replaceSelection(sortedString)
|
||||||
|
},
|
||||||
[translateHotkey(hotkey.pasteSmartly)]: cm => {
|
[translateHotkey(hotkey.pasteSmartly)]: cm => {
|
||||||
this.handlePaste(cm, true)
|
this.handlePaste(cm, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace',
|
deleteNote: OSX ? 'Command + Shift + Backspace' : 'Ctrl + Shift + Backspace',
|
||||||
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V',
|
pasteSmartly: OSX ? 'Command + Shift + V' : 'Ctrl + Shift + V',
|
||||||
prettifyMarkdown: 'Shift + F',
|
prettifyMarkdown: 'Shift + F',
|
||||||
|
sortLines: OSX ? 'Command + Shift + S' : 'Ctrl + Shift + S',
|
||||||
insertDate: OSX ? 'Command + /' : 'Ctrl + /',
|
insertDate: OSX ? 'Command + /' : 'Ctrl + /',
|
||||||
insertDateTime: OSX ? 'Command + Alt + /' : 'Ctrl + Shift + /',
|
insertDateTime: OSX ? 'Command + Alt + /' : 'Ctrl + Shift + /',
|
||||||
toggleMenuBar: 'Alt'
|
toggleMenuBar: 'Alt'
|
||||||
|
|||||||
Reference in New Issue
Block a user