提交 96413b98 编写于 作者: S Sota Sugiura 提交者: GitHub

Merge pull request #218 from asmsuechan/feature-vim-keymap

Adds vim keymap setting
......@@ -52,7 +52,7 @@ export default class CodeEditor extends React.Component {
indentUnit: this.props.indentSize,
tabSize: this.props.indentSize,
indentWithTabs: this.props.indentType !== 'space',
keyMap: 'sublime',
keyMap: this.props.keyMap,
inputStyle: 'textarea',
extraKeys: {
Tab: function (cm) {
......@@ -102,6 +102,9 @@ export default class CodeEditor extends React.Component {
if (prevProps.fontFamily !== this.props.fontFamily) {
needRefresh = true
}
if (prevProps.keyMap !== this.props.keyMap) {
needRefresh = true
}
if (prevProps.indentSize !== this.props.indentSize) {
this.editor.setOption('indentUnit', this.props.indentSize)
......@@ -194,6 +197,7 @@ CodeEditor.propTypes = {
CodeEditor.defaultProps = {
readOnly: false,
theme: 'xcode',
keyMap: 'sublime',
fontSize: 14,
fontFamily: 'Monaco, Consolas',
indentSize: 4,
......
......@@ -166,6 +166,7 @@ class MarkdownEditor extends React.Component {
mode='GitHub Flavored Markdown'
value={value}
theme={config.editor.theme}
keyMap={config.editor.keyMap}
fontFamily={config.editor.fontFamily}
fontSize={editorFontSize}
indentType={config.editor.indentType}
......@@ -179,6 +180,7 @@ class MarkdownEditor extends React.Component {
}
style={previewStyle}
theme={config.ui.theme}
keyMap={config.editor.keyMap}
fontSize={config.preview.fontSize}
fontFamily={config.preview.fontFamily}
codeBlockTheme={config.preview.codeBlockTheme}
......
......@@ -152,6 +152,7 @@ class NoteDetail extends React.Component {
fontSize={editorFontSize}
indentType={config.editor.indentType}
indentSize={editorIndentSize}
keyMap={config.editor.keyMap}
readOnly
ref={'code-' + index}
/>
......
......@@ -509,6 +509,7 @@ class SnippetNoteDetail extends React.Component {
fontSize={editorFontSize}
indentType={config.editor.indentType}
indentSize={editorIndentSize}
keyMap={config.editor.keyMap}
onChange={(e) => this.handleCodeChange(index)(e)}
ref={'code-' + index}
/>
......
......@@ -25,6 +25,7 @@ export const DEFAULT_CONFIG = {
},
editor: {
theme: 'default',
keyMap: 'sublime',
fontSize: '14',
fontFamily: 'Monaco, Consolas',
indentType: 'space',
......
......@@ -94,6 +94,10 @@
p
line-height 1.2
.note-for-keymap
margin-left: 10px
font-size: 12px
colorDarkControl()
border-color $ui-dark-borderColor
background-color $ui-dark-backgroundColor
......
......@@ -31,7 +31,8 @@ class UiTab extends React.Component {
fontFamily: this.refs.editorFontFamily.value,
indentType: this.refs.editorIndentType.value,
indentSize: this.refs.editorIndentSize.value,
switchPreview: this.refs.editorSwitchPreview.value
switchPreview: this.refs.editorSwitchPreview.value,
keyMap: this.refs.editorKeyMap.value
}
config.preview = {
fontSize: this.refs.previewFontSize.value,
......@@ -178,6 +179,23 @@ class UiTab extends React.Component {
</select>
</div>
</div>
<div styleName='group-section'>
<div styleName='group-section-label'>
Editor Keymap
</div>
<div styleName='group-section-control'>
<select value={config.editor.keyMap}
ref='editorKeyMap'
onChange={(e) => this.handleUIChange(e)}
>
<option value='sublime'>default</option>
<option value='vim'>vim</option>
</select>
<span styleName='note-for-keymap'>Please reload boostnote after you change the keymap</span>
</div>
</div>
<div styleName='group-header2'>Preview</div>
<div styleName='group-section'>
<div styleName='group-section-label'>
......
......@@ -31,6 +31,7 @@
<script src="../node_modules/codemirror/addon/mode/overlay.js"></script>
<script src="../node_modules/codemirror/addon/mode/loadmode.js"></script>
<script src="../node_modules/codemirror/keymap/sublime.js"></script>
<script src="../node_modules/codemirror/keymap/vim.js"></script>
<script src="../node_modules/codemirror/addon/runmode/runmode.js"></script>
<script src="../node_modules/raphael/raphael.min.js"></script>
......
......@@ -57,6 +57,7 @@
<script src="../node_modules/codemirror/addon/mode/overlay.js"></script>
<script src="../node_modules/codemirror/addon/mode/loadmode.js"></script>
<script src="../node_modules/codemirror/keymap/sublime.js"></script>
<script src="../node_modules/codemirror/keymap/vim.js"></script>
<script src="../node_modules/codemirror/addon/runmode/runmode.js"></script>
<script src="../node_modules/codemirror/addon/edit/continuelist.js"></script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册