1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +00:00

Bracket matching option added to config

This commit is contained in:
Guilherme Silva
2018-11-08 11:44:03 +00:00
parent 37933782d2
commit db97ab51ac
8 changed files with 284 additions and 122 deletions

View File

@@ -5,22 +5,32 @@ import CodeMirror from 'codemirror'
import 'codemirror-mode-elixir' import 'codemirror-mode-elixir'
import attachmentManagement from 'browser/main/lib/dataApi/attachmentManagement' import attachmentManagement from 'browser/main/lib/dataApi/attachmentManagement'
import convertModeName from 'browser/lib/convertModeName' import convertModeName from 'browser/lib/convertModeName'
import { options, TableEditor, Alignment } from '@susisu/mte-kernel' import {
options,
TableEditor,
Alignment
} from '@susisu/mte-kernel'
import TextEditorInterface from 'browser/lib/TextEditorInterface' import TextEditorInterface from 'browser/lib/TextEditorInterface'
import eventEmitter from 'browser/main/lib/eventEmitter' import eventEmitter from 'browser/main/lib/eventEmitter'
import iconv from 'iconv-lite' import iconv from 'iconv-lite'
import crypto from 'crypto' import crypto from 'crypto'
import consts from 'browser/lib/consts' import consts from 'browser/lib/consts'
import fs from 'fs' import fs from 'fs'
const { ipcRenderer } = require('electron') const {
ipcRenderer
} = require('electron')
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily' import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
import TurndownService from 'turndown' import TurndownService from 'turndown'
import { gfm } from 'turndown-plugin-gfm' import {
gfm
} from 'turndown-plugin-gfm'
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
const buildCMRulers = (rulers, enableRulers) => const buildCMRulers = (rulers, enableRulers) =>
(enableRulers ? rulers.map(ruler => ({ column: ruler })) : []) (enableRulers ? rulers.map(ruler => ({
column: ruler
})) : [])
export default class CodeEditor extends React.Component { export default class CodeEditor extends React.Component {
constructor(props) { constructor(props) {
@@ -46,7 +56,10 @@ export default class CodeEditor extends React.Component {
} }
this.props.onBlur != null && this.props.onBlur(e) this.props.onBlur != null && this.props.onBlur(e)
const { storageKey, noteKey } = this.props const {
storageKey,
noteKey
} = this.props
attachmentManagement.deleteAttachmentsNotPresentInNote( attachmentManagement.deleteAttachmentsNotPresentInNote(
this.editor.getValue(), this.editor.getValue(),
storageKey, storageKey,
@@ -100,7 +113,9 @@ export default class CodeEditor extends React.Component {
} }
handleFormatTable() { handleFormatTable() {
this.tableEditor.formatAll(options({textWidthOptions: {}})) this.tableEditor.formatAll(options({
textWidthOptions: {}
}))
} }
handleEditorActivity() { handleEditorActivity() {
@@ -126,18 +141,19 @@ export default class CodeEditor extends React.Component {
} }
componentDidMount() { componentDidMount() {
const { rulers, enableRulers } = this.props const {
rulers,
enableRulers
} = this.props
const expandSnippet = this.expandSnippet.bind(this) const expandSnippet = this.expandSnippet.bind(this)
eventEmitter.on('line:jump', this.scrollToLineHandeler) eventEmitter.on('line:jump', this.scrollToLineHandeler)
const defaultSnippet = [ const defaultSnippet = [{
{
id: crypto.randomBytes(16).toString('hex'), id: crypto.randomBytes(16).toString('hex'),
name: 'Dummy text', name: 'Dummy text',
prefix: ['lorem', 'ipsum'], prefix: ['lorem', 'ipsum'],
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.' content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
} }]
]
if (!fs.existsSync(consts.SNIPPET_FILE)) { if (!fs.existsSync(consts.SNIPPET_FILE)) {
fs.writeFileSync( fs.writeFileSync(
consts.SNIPPET_FILE, consts.SNIPPET_FILE,
@@ -215,12 +231,17 @@ export default class CodeEditor extends React.Component {
dragDrop: false, dragDrop: false,
foldGutter: true, foldGutter: true,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'], gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
autoCloseBrackets: { autoCloseBrackets: (this.props.enableBracketMatching ? {
pairs: '()[]{}\'\'""$$**``', pairs: '()[]{}\'\'""$$**``ll',
triples: '```"""\'\'\'', triples: '```"""\'\'\'',
explode: '[]{}``$$', explode: '[]{}``$$',
override: true override: true
}, } : {
pairs: '',
triples: '',
explode: '',
override: true
}),
extraKeys: this.defaultKeyMap extraKeys: this.defaultKeyMap
}) })
@@ -253,43 +274,117 @@ export default class CodeEditor extends React.Component {
}) })
this.editorKeyMap = CodeMirror.normalizeKeyMap({ this.editorKeyMap = CodeMirror.normalizeKeyMap({
'Tab': () => { this.tableEditor.nextCell(this.tableEditorOptions) }, 'Tab': () => {
'Shift-Tab': () => { this.tableEditor.previousCell(this.tableEditorOptions) }, this.tableEditor.nextCell(this.tableEditorOptions)
'Enter': () => { this.tableEditor.nextRow(this.tableEditorOptions) }, },
'Ctrl-Enter': () => { this.tableEditor.escape(this.tableEditorOptions) }, 'Shift-Tab': () => {
'Cmd-Enter': () => { this.tableEditor.escape(this.tableEditorOptions) }, this.tableEditor.previousCell(this.tableEditorOptions)
'Shift-Ctrl-Left': () => { this.tableEditor.alignColumn(Alignment.LEFT, this.tableEditorOptions) }, },
'Shift-Cmd-Left': () => { this.tableEditor.alignColumn(Alignment.LEFT, this.tableEditorOptions) }, 'Enter': () => {
'Shift-Ctrl-Right': () => { this.tableEditor.alignColumn(Alignment.RIGHT, this.tableEditorOptions) }, this.tableEditor.nextRow(this.tableEditorOptions)
'Shift-Cmd-Right': () => { this.tableEditor.alignColumn(Alignment.RIGHT, this.tableEditorOptions) }, },
'Shift-Ctrl-Up': () => { this.tableEditor.alignColumn(Alignment.CENTER, this.tableEditorOptions) }, 'Ctrl-Enter': () => {
'Shift-Cmd-Up': () => { this.tableEditor.alignColumn(Alignment.CENTER, this.tableEditorOptions) }, this.tableEditor.escape(this.tableEditorOptions)
'Shift-Ctrl-Down': () => { this.tableEditor.alignColumn(Alignment.NONE, this.tableEditorOptions) }, },
'Shift-Cmd-Down': () => { this.tableEditor.alignColumn(Alignment.NONE, this.tableEditorOptions) }, 'Cmd-Enter': () => {
'Ctrl-Left': () => { this.tableEditor.moveFocus(0, -1, this.tableEditorOptions) }, this.tableEditor.escape(this.tableEditorOptions)
'Cmd-Left': () => { this.tableEditor.moveFocus(0, -1, this.tableEditorOptions) }, },
'Ctrl-Right': () => { this.tableEditor.moveFocus(0, 1, this.tableEditorOptions) }, 'Shift-Ctrl-Left': () => {
'Cmd-Right': () => { this.tableEditor.moveFocus(0, 1, this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.LEFT, this.tableEditorOptions)
'Ctrl-Up': () => { this.tableEditor.moveFocus(-1, 0, this.tableEditorOptions) }, },
'Cmd-Up': () => { this.tableEditor.moveFocus(-1, 0, this.tableEditorOptions) }, 'Shift-Cmd-Left': () => {
'Ctrl-Down': () => { this.tableEditor.moveFocus(1, 0, this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.LEFT, this.tableEditorOptions)
'Cmd-Down': () => { this.tableEditor.moveFocus(1, 0, this.tableEditorOptions) }, },
'Ctrl-K Ctrl-I': () => { this.tableEditor.insertRow(this.tableEditorOptions) }, 'Shift-Ctrl-Right': () => {
'Cmd-K Cmd-I': () => { this.tableEditor.insertRow(this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.RIGHT, this.tableEditorOptions)
'Ctrl-L Ctrl-I': () => { this.tableEditor.deleteRow(this.tableEditorOptions) }, },
'Cmd-L Cmd-I': () => { this.tableEditor.deleteRow(this.tableEditorOptions) }, 'Shift-Cmd-Right': () => {
'Ctrl-K Ctrl-J': () => { this.tableEditor.insertColumn(this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.RIGHT, this.tableEditorOptions)
'Cmd-K Cmd-J': () => { this.tableEditor.insertColumn(this.tableEditorOptions) }, },
'Ctrl-L Ctrl-J': () => { this.tableEditor.deleteColumn(this.tableEditorOptions) }, 'Shift-Ctrl-Up': () => {
'Cmd-L Cmd-J': () => { this.tableEditor.deleteColumn(this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.CENTER, this.tableEditorOptions)
'Alt-Shift-Ctrl-Left': () => { this.tableEditor.moveColumn(-1, this.tableEditorOptions) }, },
'Alt-Shift-Cmd-Left': () => { this.tableEditor.moveColumn(-1, this.tableEditorOptions) }, 'Shift-Cmd-Up': () => {
'Alt-Shift-Ctrl-Right': () => { this.tableEditor.moveColumn(1, this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.CENTER, this.tableEditorOptions)
'Alt-Shift-Cmd-Right': () => { this.tableEditor.moveColumn(1, this.tableEditorOptions) }, },
'Alt-Shift-Ctrl-Up': () => { this.tableEditor.moveRow(-1, this.tableEditorOptions) }, 'Shift-Ctrl-Down': () => {
'Alt-Shift-Cmd-Up': () => { this.tableEditor.moveRow(-1, this.tableEditorOptions) }, this.tableEditor.alignColumn(Alignment.NONE, this.tableEditorOptions)
'Alt-Shift-Ctrl-Down': () => { this.tableEditor.moveRow(1, this.tableEditorOptions) }, },
'Alt-Shift-Cmd-Down': () => { this.tableEditor.moveRow(1, this.tableEditorOptions) } 'Shift-Cmd-Down': () => {
this.tableEditor.alignColumn(Alignment.NONE, this.tableEditorOptions)
},
'Ctrl-Left': () => {
this.tableEditor.moveFocus(0, -1, this.tableEditorOptions)
},
'Cmd-Left': () => {
this.tableEditor.moveFocus(0, -1, this.tableEditorOptions)
},
'Ctrl-Right': () => {
this.tableEditor.moveFocus(0, 1, this.tableEditorOptions)
},
'Cmd-Right': () => {
this.tableEditor.moveFocus(0, 1, this.tableEditorOptions)
},
'Ctrl-Up': () => {
this.tableEditor.moveFocus(-1, 0, this.tableEditorOptions)
},
'Cmd-Up': () => {
this.tableEditor.moveFocus(-1, 0, this.tableEditorOptions)
},
'Ctrl-Down': () => {
this.tableEditor.moveFocus(1, 0, this.tableEditorOptions)
},
'Cmd-Down': () => {
this.tableEditor.moveFocus(1, 0, this.tableEditorOptions)
},
'Ctrl-K Ctrl-I': () => {
this.tableEditor.insertRow(this.tableEditorOptions)
},
'Cmd-K Cmd-I': () => {
this.tableEditor.insertRow(this.tableEditorOptions)
},
'Ctrl-L Ctrl-I': () => {
this.tableEditor.deleteRow(this.tableEditorOptions)
},
'Cmd-L Cmd-I': () => {
this.tableEditor.deleteRow(this.tableEditorOptions)
},
'Ctrl-K Ctrl-J': () => {
this.tableEditor.insertColumn(this.tableEditorOptions)
},
'Cmd-K Cmd-J': () => {
this.tableEditor.insertColumn(this.tableEditorOptions)
},
'Ctrl-L Ctrl-J': () => {
this.tableEditor.deleteColumn(this.tableEditorOptions)
},
'Cmd-L Cmd-J': () => {
this.tableEditor.deleteColumn(this.tableEditorOptions)
},
'Alt-Shift-Ctrl-Left': () => {
this.tableEditor.moveColumn(-1, this.tableEditorOptions)
},
'Alt-Shift-Cmd-Left': () => {
this.tableEditor.moveColumn(-1, this.tableEditorOptions)
},
'Alt-Shift-Ctrl-Right': () => {
this.tableEditor.moveColumn(1, this.tableEditorOptions)
},
'Alt-Shift-Cmd-Right': () => {
this.tableEditor.moveColumn(1, this.tableEditorOptions)
},
'Alt-Shift-Ctrl-Up': () => {
this.tableEditor.moveRow(-1, this.tableEditorOptions)
},
'Alt-Shift-Cmd-Up': () => {
this.tableEditor.moveRow(-1, this.tableEditorOptions)
},
'Alt-Shift-Ctrl-Down': () => {
this.tableEditor.moveRow(1, this.tableEditorOptions)
},
'Alt-Shift-Cmd-Down': () => {
this.tableEditor.moveRow(1, this.tableEditorOptions)
}
}) })
if (this.props.enableTableEditor) { if (this.props.enableTableEditor) {
@@ -370,8 +465,14 @@ export default class CodeEditor extends React.Component {
return { return {
text: wordBeforeCursor, text: wordBeforeCursor,
range: { range: {
from: { line: lineNumber, ch: originCursorPosition }, from: {
to: { line: lineNumber, ch: cursorPosition } line: lineNumber,
ch: originCursorPosition
},
to: {
line: lineNumber,
ch: cursorPosition
}
} }
} }
} }
@@ -395,7 +496,10 @@ export default class CodeEditor extends React.Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
let needRefresh = false let needRefresh = false
const { rulers, enableRulers } = this.props const {
rulers,
enableRulers
} = this.props
if (prevProps.mode !== this.props.mode) { if (prevProps.mode !== this.props.mode) {
this.setMode(this.props.mode) this.setMode(this.props.mode)
} }
@@ -436,6 +540,21 @@ export default class CodeEditor extends React.Component {
this.editor.setOption('scrollPastEnd', this.props.scrollPastEnd) this.editor.setOption('scrollPastEnd', this.props.scrollPastEnd)
} }
if (prevProps.enableBracketMatching !== this.props.enableBracketMatching) {
const bracketObject = (this.props.enableBracketMatching ? {
pairs: '()[]{}\'\'""$$**``ll',
triples: '```"""\'\'\'',
explode: '[]{}``$$',
override: true
} : {
pairs: '',
triples: '',
explode: '',
override: true
});
this.editor.setOption('autoCloseBrackets', bracketObject)
}
if (prevProps.enableTableEditor !== this.props.enableTableEditor) { if (prevProps.enableTableEditor !== this.props.enableTableEditor) {
if (this.props.enableTableEditor) { if (this.props.enableTableEditor) {
this.editor.on('cursorActivity', this.editorActivityHandler) this.editor.on('cursorActivity', this.editorActivityHandler)
@@ -513,7 +632,10 @@ export default class CodeEditor extends React.Component {
handleDropImage(dropEvent) { handleDropImage(dropEvent) {
dropEvent.preventDefault() dropEvent.preventDefault()
const { storageKey, noteKey } = this.props const {
storageKey,
noteKey
} = this.props
attachmentManagement.handleAttachmentDrop( attachmentManagement.handleAttachmentDrop(
this, this,
storageKey, storageKey,
@@ -528,7 +650,10 @@ export default class CodeEditor extends React.Component {
handlePaste(editor, e) { handlePaste(editor, e) {
const clipboardData = e.clipboardData const clipboardData = e.clipboardData
const { storageKey, noteKey } = this.props const {
storageKey,
noteKey
} = this.props
const dataTransferItem = clipboardData.items[0] const dataTransferItem = clipboardData.items[0]
const pastedTxt = clipboardData.getData('text') const pastedTxt = clipboardData.getData('text')
const isURL = str => { const isURL = str => {
@@ -537,15 +662,21 @@ export default class CodeEditor extends React.Component {
} }
const isInLinkTag = editor => { const isInLinkTag = editor => {
const startCursor = editor.getCursor('start') const startCursor = editor.getCursor('start')
const prevChar = editor.getRange( const prevChar = editor.getRange({
{ line: startCursor.line, ch: startCursor.ch - 2 }, line: startCursor.line,
{ line: startCursor.line, ch: startCursor.ch } ch: startCursor.ch - 2
) }, {
line: startCursor.line,
ch: startCursor.ch
})
const endCursor = editor.getCursor('end') const endCursor = editor.getCursor('end')
const nextChar = editor.getRange( const nextChar = editor.getRange({
{ line: endCursor.line, ch: endCursor.ch }, line: endCursor.line,
{ line: endCursor.line, ch: endCursor.ch + 1 } ch: endCursor.ch
) }, {
line: endCursor.line,
ch: endCursor.ch + 1
})
return prevChar === '](' && nextChar === ')' return prevChar === '](' && nextChar === ')'
} }
@@ -663,16 +794,16 @@ export default class CodeEditor extends React.Component {
decodeResponse(response) { decodeResponse(response) {
const headers = response.headers const headers = response.headers
const _charset = headers.has('content-type') const _charset = headers.has('content-type') ?
? this.extractContentTypeCharset(headers.get('content-type')) this.extractContentTypeCharset(headers.get('content-type')) :
: undefined undefined
return response.arrayBuffer().then(buff => { return response.arrayBuffer().then(buff => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
const charset = _charset !== undefined && const charset = _charset !== undefined &&
iconv.encodingExists(_charset) iconv.encodingExists(_charset) ?
? _charset _charset :
: 'utf-8' 'utf-8'
resolve(iconv.decode(new Buffer(buff), charset).toString()) resolve(iconv.decode(new Buffer(buff), charset).toString())
} catch (e) { } catch (e) {
reject(e) reject(e)
@@ -693,20 +824,28 @@ export default class CodeEditor extends React.Component {
} }
render() { render() {
const {className, fontSize} = this.props const {
className,
fontSize
} = this.props
const fontFamily = normalizeEditorFontFamily(this.props.fontFamily) const fontFamily = normalizeEditorFontFamily(this.props.fontFamily)
const width = this.props.width const width = this.props.width
return ( return ( <
<div div className = {
className={className == null ? 'CodeEditor' : `CodeEditor ${className}`} className == null ? 'CodeEditor' : `CodeEditor ${className}`
}
ref = 'root' ref = 'root'
tabIndex = '-1' tabIndex = '-1'
style={{ style = {
{
fontFamily, fontFamily,
fontSize: fontSize, fontSize: fontSize,
width: width width: width
}} }
onDrop={e => this.handleDropImage(e)} }
onDrop = {
e => this.handleDropImage(e)
}
/> />
) )
} }

View File

@@ -268,6 +268,7 @@ class MarkdownEditor extends React.Component {
enableRulers={config.editor.enableRulers} enableRulers={config.editor.enableRulers}
rulers={config.editor.rulers} rulers={config.editor.rulers}
displayLineNumbers={config.editor.displayLineNumbers} displayLineNumbers={config.editor.displayLineNumbers}
enableBracketMatching={config.editor.enableBracketMatching}
scrollPastEnd={config.editor.scrollPastEnd} scrollPastEnd={config.editor.scrollPastEnd}
storageKey={storageKey} storageKey={storageKey}
noteKey={noteKey} noteKey={noteKey}

View File

@@ -158,6 +158,7 @@ class MarkdownSplitEditor extends React.Component {
fontFamily={config.editor.fontFamily} fontFamily={config.editor.fontFamily}
fontSize={editorFontSize} fontSize={editorFontSize}
displayLineNumbers={config.editor.displayLineNumbers} displayLineNumbers={config.editor.displayLineNumbers}
enableBracketMatching={config.editor.enableBracketMatching}
indentType={config.editor.indentType} indentType={config.editor.indentType}
indentSize={editorIndentSize} indentSize={editorIndentSize}
enableRulers={config.editor.enableRulers} enableRulers={config.editor.enableRulers}

View File

@@ -699,6 +699,7 @@ class SnippetNoteDetail extends React.Component {
indentType={config.editor.indentType} indentType={config.editor.indentType}
indentSize={editorIndentSize} indentSize={editorIndentSize}
displayLineNumbers={config.editor.displayLineNumbers} displayLineNumbers={config.editor.displayLineNumbers}
enableBracketMatching={config.editor.enableBracketMatching}
keyMap={config.editor.keyMap} keyMap={config.editor.keyMap}
scrollPastEnd={config.editor.scrollPastEnd} scrollPastEnd={config.editor.scrollPastEnd}
fetchUrlTitle={config.editor.fetchUrlTitle} fetchUrlTitle={config.editor.fetchUrlTitle}

View File

@@ -44,6 +44,7 @@ export const DEFAULT_CONFIG = {
enableRulers: false, enableRulers: false,
rulers: [80, 120], rulers: [80, 120],
displayLineNumbers: true, displayLineNumbers: true,
enableBracketMatching: true,
switchPreview: 'BLUR', // 'BLUR', 'DBL_CLICK', 'RIGHTCLICK' switchPreview: 'BLUR', // 'BLUR', 'DBL_CLICK', 'RIGHTCLICK'
delfaultStatus: 'PREVIEW', // 'PREVIEW', 'CODE' delfaultStatus: 'PREVIEW', // 'PREVIEW', 'CODE'
scrollPastEnd: false, scrollPastEnd: false,

View File

@@ -27,12 +27,17 @@ class SnippetEditor extends React.Component {
dragDrop: false, dragDrop: false,
foldGutter: true, foldGutter: true,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'], gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
autoCloseBrackets: { autoCloseBrackets: (this.enableBracketMatching ? {
pairs: '()[]{}\'\'""$$**``', pairs: '()[]{}\'\'""$$**``ll',
triples: '```"""\'\'\'', triples: '```"""\'\'\'',
explode: '[]{}``$$', explode: '[]{}``$$',
override: true override: true
}, }: {
pairs: '',
triples: '',
explode: '',
override: true
}),
mode: 'null' mode: 'null'
}) })
this.cm.setSize('100%', '100%') this.cm.setSize('100%', '100%')

View File

@@ -136,6 +136,7 @@ class SnippetTab extends React.Component {
enableRulers={config.editor.enableRulers} enableRulers={config.editor.enableRulers}
rulers={config.editor.rulers} rulers={config.editor.rulers}
displayLineNumbers={config.editor.displayLineNumbers} displayLineNumbers={config.editor.displayLineNumbers}
enableBracketMatching={config.editor.enableBracketMatching}
scrollPastEnd={config.editor.scrollPastEnd} scrollPastEnd={config.editor.scrollPastEnd}
onRef={ref => { this.snippetEditor = ref }} /> onRef={ref => { this.snippetEditor = ref }} />
</div> </div>

View File

@@ -62,6 +62,7 @@ class UiTab extends React.Component {
checkHighLight.setAttribute('rel', 'stylesheet') checkHighLight.setAttribute('rel', 'stylesheet')
document.head.appendChild(checkHighLight) document.head.appendChild(checkHighLight)
} }
console.log("This is a console log")
const newConfig = { const newConfig = {
ui: { ui: {
@@ -94,7 +95,8 @@ class UiTab extends React.Component {
fetchUrlTitle: this.refs.editorFetchUrlTitle.checked, fetchUrlTitle: this.refs.editorFetchUrlTitle.checked,
enableTableEditor: this.refs.enableTableEditor.checked, enableTableEditor: this.refs.enableTableEditor.checked,
enableFrontMatterTitle: this.refs.enableFrontMatterTitle.checked, enableFrontMatterTitle: this.refs.enableFrontMatterTitle.checked,
frontMatterTitleField: this.refs.frontMatterTitleField.value frontMatterTitleField: this.refs.frontMatterTitleField.value,
enableBracketMatching: this.refs.enableBracketMatching.checked
}, },
preview: { preview: {
fontSize: this.refs.previewFontSize.value, fontSize: this.refs.previewFontSize.value,
@@ -539,6 +541,17 @@ class UiTab extends React.Component {
</label> </label>
</div> </div>
<div styleName='group-checkBoxSection'>
<label>
<input onChange={(e) => this.handleUIChange(e)}
checked={this.state.config.editor.enableBracketMatching}
ref='enableBracketMatching'
type='checkbox'
/>&nbsp;
{i18n.__('Enable bracket matching')}
</label>
</div>
<div styleName='group-header2'>{i18n.__('Preview')}</div> <div styleName='group-header2'>{i18n.__('Preview')}</div>
<div styleName='group-section'> <div styleName='group-section'>
<div styleName='group-section-label'> <div styleName='group-section-label'>