Fix scrolling + codemirror render

This commit is contained in:
Jori Lallo
2016-06-03 01:01:01 -07:00
parent 6206acfad0
commit 1345f9629d
4 changed files with 11 additions and 8 deletions

View File

@@ -17,9 +17,13 @@ import { client } from '../../utils/ApiClient';
@observer
class MarkdownAtlas extends React.Component {
static propTypes = {
text: React.PropTypes.string,
onChange: React.PropTypes.func,
replaceText: React.PropTypes.func,
text: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired,
replaceText: React.PropTypes.func.isRequired,
// This is actually not used but it triggers
// re-render to help with CodeMirror focus issues
preview: React.PropTypes.bool.isRequired,
}
getEditorInstance = () => {

View File

@@ -43,9 +43,7 @@ class DocumentEdit extends Component {
}
onPreviewToggle = () => {
// Force re-render to fix issues with
// Codemirror cursor (gets out of sync)
state.togglePreview(this.forceUpdate());
state.togglePreview();
}
render() {
@@ -94,6 +92,7 @@ class DocumentEdit extends Component {
onChange={ state.updateText }
text={ state.text }
replaceText={ state.replaceText }
preview={ state.preview }
/>
</EditorPane>
{ state.preview ? (

View File

@@ -27,6 +27,7 @@
.paneContent {
flex: 1;
justify-content: center;
height: 100%;
}
.fullWidth {

View File

@@ -83,9 +83,8 @@ const documentEditState = new class DocumentEditState {
this.text = this.text.replace(args.original, args.new);
}
@action togglePreview = (callback) => {
@action togglePreview = () => {
this.preview = !this.preview;
callback();
}
constructor() {