diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js
index d12e17ac..92bc6599 100644
--- a/browser/components/CodeEditor.js
+++ b/browser/components/CodeEditor.js
@@ -499,6 +499,7 @@ export default class CodeEditor extends React.Component {
fontFamily = _.isString(fontFamily) && fontFamily.length > 0
? [fontFamily].concat(defaultEditorFontFamily)
: defaultEditorFontFamily
+ let width = this.props.width
return (
this.handleDropImage(e)}
/>
diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js
index 5c35c22c..8fa3cc07 100644
--- a/browser/components/MarkdownSplitEditor.js
+++ b/browser/components/MarkdownSplitEditor.js
@@ -14,6 +14,10 @@ class MarkdownSplitEditor extends React.Component {
this.focus = () => this.refs.code.focus()
this.reload = () => this.refs.code.reload()
this.userScroll = true
+ this.state = {
+ isSliderFocused: false,
+ codeEditorWidthInPercent: 50
+ }
}
handleOnChange () {
@@ -87,6 +91,42 @@ class MarkdownSplitEditor extends React.Component {
}
}
+ handleMouseMove (e) {
+ if (this.state.isSliderFocused) {
+ const rootRect = this.refs.root.getBoundingClientRect()
+ const rootWidth = rootRect.width
+ const offset = rootRect.left
+ let newCodeEditorWidthInPercent = (e.pageX - offset) / rootWidth * 100
+
+ // limit minSize to 10%, maxSize to 90%
+ if (newCodeEditorWidthInPercent <= 10) {
+ newCodeEditorWidthInPercent = 10
+ }
+
+ if (newCodeEditorWidthInPercent >= 90) {
+ newCodeEditorWidthInPercent = 90
+ }
+
+ this.setState({
+ codeEditorWidthInPercent: newCodeEditorWidthInPercent
+ })
+ }
+ }
+
+ handleMouseUp (e) {
+ e.preventDefault()
+ this.setState({
+ isSliderFocused: false
+ })
+ }
+
+ handleMouseDown (e) {
+ e.preventDefault()
+ this.setState({
+ isSliderFocused: true
+ })
+ }
+
render () {
const {config, value, storageKey, noteKey} = this.props
const storage = findStorage(storageKey)
@@ -95,12 +135,16 @@ class MarkdownSplitEditor extends React.Component {
let editorIndentSize = parseInt(config.editor.indentSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
const previewStyle = {}
- if (this.props.ignorePreviewPointerEvents) previewStyle.pointerEvents = 'none'
+ previewStyle.width = (100 - this.state.codeEditorWidthInPercent) + '%'
+ if (this.props.ignorePreviewPointerEvents || this.state.isSliderFocused) previewStyle.pointerEvents = 'none'
return (
-
+
this.handleMouseMove(e)}
+ onMouseUp={e => this.handleMouseUp(e)}>
+
this.handleMouseDown(e)} >
+
+