mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
improved style for snippet list
This commit is contained in:
@@ -2,6 +2,8 @@ import CodeMirror from 'codemirror'
|
||||
import PropTypes from 'prop-types'
|
||||
import React from 'react'
|
||||
import _ from 'lodash'
|
||||
import fs from 'fs'
|
||||
import { findStorage } from 'browser/lib/findStorage'
|
||||
|
||||
const defaultEditorFontFamily = ['Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'monospace']
|
||||
const buildCMRulers = (rulers, enableRulers) =>
|
||||
@@ -14,7 +16,7 @@ export default class SnippetEditor extends React.Component {
|
||||
|
||||
componentDidMount () {
|
||||
const { rulers, enableRulers } = this.props
|
||||
let cm = CodeMirror(this.refs.root, {
|
||||
this.cm = CodeMirror(this.refs.root, {
|
||||
rulers: buildCMRulers(rulers, enableRulers),
|
||||
lineNumbers: this.props.displayLineNumbers,
|
||||
lineWrapping: true,
|
||||
@@ -29,11 +31,34 @@ export default class SnippetEditor extends React.Component {
|
||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
|
||||
autoCloseBrackets: true,
|
||||
})
|
||||
cm.setValue("asdasd")
|
||||
cm.setSize("100%", "100%")
|
||||
this.cm.setSize("100%", "100%")
|
||||
let snippetId = this.props.snippetId
|
||||
|
||||
const storagePath = findStorage(this.props.storageKey).path
|
||||
const expandDataFile = path.join(storagePath, 'expandData.json')
|
||||
if (!fs.existsSync(expandDataFile)) {
|
||||
const defaultExpandData = [
|
||||
{
|
||||
matches: ['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.'
|
||||
},
|
||||
{ match: 'h1', content: '# '},
|
||||
{ match: 'h2', content: '## '},
|
||||
{ match: 'h3', content: '### '},
|
||||
{ match: 'h4', content: '#### '},
|
||||
{ match: 'h5', content: '##### '},
|
||||
{ match: 'h6', content: '###### '}
|
||||
];
|
||||
fs.writeFileSync(expandDataFile, JSON.stringify(defaultExpandData), 'utf8')
|
||||
}
|
||||
const expandData = JSON.parse(fs.readFileSync(expandDataFile, 'utf8'))
|
||||
}
|
||||
|
||||
render() {
|
||||
componentWillReceiveProps(newProps) {
|
||||
this.cm.setValue(newProps.value)
|
||||
}
|
||||
|
||||
render () {
|
||||
const { fontSize } = this.props
|
||||
let fontFamily = this.props.fontFamily
|
||||
fontFamily = _.isString(fontFamily) && fontFamily.length > 0
|
||||
|
||||
Reference in New Issue
Block a user