mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-16 03:06:27 +00:00
check config before auto detect language
This commit is contained in:
@@ -354,7 +354,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
extraKeys: this.defaultKeyMap
|
extraKeys: this.defaultKeyMap
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!this.props.mode && this.props.value) {
|
if (!this.props.mode && this.props.value && this.props.autoDetect) {
|
||||||
this.autoDetectLanguage(this.props.value)
|
this.autoDetectLanguage(this.props.value)
|
||||||
} else {
|
} else {
|
||||||
this.setMode(this.props.mode)
|
this.setMode(this.props.mode)
|
||||||
@@ -982,7 +982,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.props.mode) {
|
if (!this.props.mode && this.props.autoDetect) {
|
||||||
this.autoDetectLanguage(editor.doc.getValue())
|
this.autoDetectLanguage(editor.doc.getValue())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1184,6 +1184,7 @@ CodeEditor.propTypes = {
|
|||||||
onBlur: PropTypes.func,
|
onBlur: PropTypes.func,
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
readOnly: PropTypes.bool,
|
readOnly: PropTypes.bool,
|
||||||
|
autoDetect: PropTypes.bool,
|
||||||
spellCheck: PropTypes.bool
|
spellCheck: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1195,5 +1196,6 @@ CodeEditor.defaultProps = {
|
|||||||
fontFamily: 'Monaco, Consolas',
|
fontFamily: 'Monaco, Consolas',
|
||||||
indentSize: 4,
|
indentSize: 4,
|
||||||
indentType: 'space',
|
indentType: 'space',
|
||||||
|
autoDetect: false,
|
||||||
spellCheck: false
|
spellCheck: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -674,6 +674,8 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
const storageKey = note.storage
|
const storageKey = note.storage
|
||||||
const folderKey = note.folder
|
const folderKey = note.folder
|
||||||
|
|
||||||
|
const autoDetect = config.editor.snippetDefaultLanguage === 'Auto Detect'
|
||||||
|
|
||||||
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
let editorFontSize = parseInt(config.editor.fontSize, 10)
|
||||||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
|
||||||
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
let editorIndentSize = parseInt(config.editor.indentSize, 10)
|
||||||
@@ -713,7 +715,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
storageKey={storageKey}
|
storageKey={storageKey}
|
||||||
/>
|
/>
|
||||||
: <CodeEditor styleName='tabView-content'
|
: <CodeEditor styleName='tabView-content'
|
||||||
mode={snippet.mode}
|
mode={snippet.mode || (autoDetect ? null : config.editor.snippetDefaultLanguage)}
|
||||||
value={snippet.content}
|
value={snippet.content}
|
||||||
linesHighlighted={snippet.linesHighlighted}
|
linesHighlighted={snippet.linesHighlighted}
|
||||||
theme={config.editor.theme}
|
theme={config.editor.theme}
|
||||||
@@ -733,6 +735,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
ref={'code-' + index}
|
ref={'code-' + index}
|
||||||
enableSmartPaste={config.editor.enableSmartPaste}
|
enableSmartPaste={config.editor.enableSmartPaste}
|
||||||
hotkey={config.hotkey}
|
hotkey={config.hotkey}
|
||||||
|
autoDetect={autoDetect}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user