mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Add a shortcut for supporting to input bold
This commit is contained in:
@@ -11,6 +11,8 @@ class MarkdownEditor extends React.Component {
|
|||||||
|
|
||||||
this.escapeFromEditor = ['Control', 'w']
|
this.escapeFromEditor = ['Control', 'w']
|
||||||
|
|
||||||
|
this.supportBold = ['Control', 'b']
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
status: 'PREVIEW',
|
status: 'PREVIEW',
|
||||||
renderValue: props.value,
|
renderValue: props.value,
|
||||||
@@ -166,6 +168,16 @@ class MarkdownEditor extends React.Component {
|
|||||||
if (!this.state.isLocked && this.state.status === 'CODE' && this.escapeFromEditor.every(isNoteHandlerKey)) {
|
if (!this.state.isLocked && this.state.status === 'CODE' && this.escapeFromEditor.every(isNoteHandlerKey)) {
|
||||||
document.activeElement.blur()
|
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) {
|
handleKeyUp (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user