1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Add a shortcut for supporting to input bold

This commit is contained in:
asmsuechan
2017-02-22 01:51:02 +09:00
parent 7845bbd881
commit e78492983a

View File

@@ -11,6 +11,8 @@ class MarkdownEditor extends React.Component {
this.escapeFromEditor = ['Control', 'w']
this.supportBold = ['Control', 'b']
this.state = {
status: 'PREVIEW',
renderValue: props.value,
@@ -166,6 +168,16 @@ class MarkdownEditor extends React.Component {
if (!this.state.isLocked && this.state.status === 'CODE' && this.escapeFromEditor.every(isNoteHandlerKey)) {
document.activeElement.blur()
}
if (this.state.status === 'CODE' && this.supportBold.every(isNoteHandlerKey)) {
this.addMdAndMoveCaretToCenter('****')
}
}
addMdAndMoveCaretToCenter (md) {
const currentCaret = this.refs.code.editor.getCursor()
const cmDoc = this.refs.code.editor.getDoc()
cmDoc.replaceRange(md, currentCaret)
this.refs.code.editor.setCursor({line: currentCaret.line, ch: currentCaret.ch + md.length/2})
}
handleKeyUp (e) {