Skip to content
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: 9 additions & 3 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export default class CodeEditor extends React.Component {
this.updateDefaultKeyMap()

this.value = this.props.value
var enable = true
if (this.props.enableCodeMirror === 'true') {
enable = true
} else {
enable = false
}
this.editor = CodeMirror(this.refs.root, {
rulers: buildCMRulers(rulers, enableRulers),
value: this.props.value,
Expand All @@ -251,11 +257,10 @@ export default class CodeEditor extends React.Component {
pairs: '()[]{}\'\'""$$**``',
triples: '```"""\'\'\'',
explode: '[]{}``$$',
override: true
override: enable
},
extraKeys: this.defaultKeyMap
})

this.setMode(this.props.mode)

this.editor.on('focus', this.focusHandler)
Expand Down Expand Up @@ -850,7 +855,8 @@ CodeEditor.propTypes = {
onBlur: PropTypes.func,
onChange: PropTypes.func,
readOnly: PropTypes.bool,
spellCheck: PropTypes.bool
spellCheck: PropTypes.bool,
enableCodeMirror: PropTypes.bool
}

CodeEditor.defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class MarkdownEditor extends React.Component {
onChange={(e) => this.handleChange(e)}
onBlur={(e) => this.handleBlur(e)}
spellCheck={config.editor.spellcheck}
enableCodeMirror={config.editor.enableCodeMirror}
enableSmartPaste={config.editor.enableSmartPaste}
hotkey={config.hotkey}
switchPreview={config.editor.switchPreview}
Expand Down
1 change: 1 addition & 0 deletions browser/components/MarkdownSplitEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class MarkdownSplitEditor extends React.Component {
onChange={this.handleOnChange.bind(this)}
onScroll={this.handleScroll.bind(this)}
spellCheck={config.editor.spellcheck}
enableCodeMirror={config.editor.enableCodeMirror}
enableSmartPaste={config.editor.enableSmartPaste}
hotkey={config.hotkey}
switchPreview={config.editor.switchPreview}
Expand Down
1 change: 1 addition & 0 deletions browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const DEFAULT_CONFIG = {
enableFrontMatterTitle: true,
frontMatterTitleField: 'title',
spellcheck: false,
enableCodeMirror: true,
enableSmartPaste: false
},
preview: {
Expand Down
24 changes: 23 additions & 1 deletion browser/main/modals/PreferencesModal/UiTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class UiTab extends React.Component {
handleUIChange (e) {
const { codemirrorTheme } = this.state
let checkHighLight = document.getElementById('checkHighLight')
console.log(this.refs.enableCodeMirror.value)

if (checkHighLight === null) {
checkHighLight = document.createElement('link')
Expand Down Expand Up @@ -97,6 +98,7 @@ class UiTab extends React.Component {
enableFrontMatterTitle: this.refs.enableFrontMatterTitle.checked,
frontMatterTitleField: this.refs.frontMatterTitleField.value,
spellcheck: this.refs.spellcheck.checked,
enableCodeMirror: this.refs.enableCodeMirror.value,
enableSmartPaste: this.refs.enableSmartPaste.checked
},
preview: {
Expand Down Expand Up @@ -435,7 +437,27 @@ class UiTab extends React.Component {
/>
</div>
</div>

<div styleName='group-section'>
<div styleName='group-section-label'>
{i18n.__('Double Characters [Needs Refresh] ')}
</div>
<div styleName='group-section-control'>
<div>
<select value={config.editor.enableCodeMirror}
ref='enableCodeMirror'
type='checkbox'
onChange={(e) => this.handleUIChange(e)}
>
<option value='true'>
{i18n.__('Enable')}
</option>
<option value='false'>
{i18n.__('Disable')}
</option>
</select>
</div>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>
{i18n.__('Switch to Preview')}
Expand Down