react-codemirror2
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -0,1 +1,5 @@ | ||
3.0.5 | ||
================== | ||
* https://github.com/scniro/react-codemirror2/issues/31 (take 2) | ||
3.0.4 | ||
@@ -2,0 +6,0 @@ ================== |
38
index.js
@@ -195,3 +195,6 @@ 'use strict'; | ||
var _this = this; | ||
Object.keys(props.options || {}).forEach(function (key) { return _this.editor.setOption(key, props.options[key]); }); | ||
Object.keys(props.options || {}).forEach(function (key) { | ||
_this.editor.setOption(key, props.options[key]); | ||
_this.mirror.setOption(key, props.options[key]); | ||
}); | ||
if (!this.hydrated) { | ||
@@ -223,22 +226,22 @@ if (!this.mounted) { | ||
Controlled.prototype.resolveChange = function () { | ||
var _this = this; | ||
this.editor.operation(function () { | ||
_this.emulating = true; | ||
if (_this.deferred.origin === 'redo') { | ||
_this.editor.setCursor(_this.mirror.getCursor()); | ||
} | ||
_this.editor.replaceRange(_this.deferred.text.join('\n'), _this.deferred.from, _this.deferred.to, _this.deferred.origin); | ||
_this.editor.setHistory(_this.mirror.getHistory()); | ||
if (_this.deferred.origin === 'undo') { | ||
_this.editor.setCursor(_this.mirror.getCursor()); | ||
} | ||
_this.emulating = false; | ||
_this.deferred = null; | ||
}); | ||
this.emulating = true; | ||
if (this.deferred.origin === 'undo') { | ||
this.editor.undo(); | ||
} | ||
else if (this.deferred.origin === 'redo') { | ||
this.editor.redo(); | ||
} | ||
else { | ||
this.editor.replaceRange(this.deferred.text, this.deferred.from, this.deferred.to, this.deferred.origin); | ||
} | ||
this.emulating = false; | ||
this.deferred = null; | ||
}; | ||
Controlled.prototype.mirrorChange = function (deferred) { | ||
if (deferred.origin === 'undo') { | ||
this.editor.setHistory(this.mirror.getHistory()); | ||
this.mirror.undo(); | ||
} | ||
else if (deferred.origin === 'redo') { | ||
this.editor.setHistory(this.mirror.getHistory()); | ||
this.mirror.redo(); | ||
@@ -268,4 +271,6 @@ } | ||
}); | ||
this.editor.on('electricInput', function () { | ||
_this.mirror.setHistory(_this.editor.getHistory()); | ||
}); | ||
this.editor.on('cursorActivity', function () { | ||
_this.mirror.setHistory(_this.editor.getHistory()); | ||
_this.mirror.setCursor(_this.editor.getCursor()); | ||
@@ -490,2 +495,3 @@ }); | ||
this.mounted = true; | ||
this.editor.clearHistory(); | ||
if (this.props.editorDidMount) { | ||
@@ -492,0 +498,0 @@ this.props.editorDidMount(this.editor, this.editor.getValue(), this.initCb); |
{ | ||
"name": "react-codemirror2", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "a tiny react codemirror component wrapper", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
36257
592