Skip to content

Commit

Permalink
update version to 3.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
suren-atoyan committed Jul 15, 2020
1 parent a0a7c8a commit ef4b4f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### Versions

## 3.4.2
###### *July 15, 2020*

- controlled editor: fix undo/redo issue

## 3.4.1
###### *July 3, 2020*

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@monaco-editor/react",
"version": "3.4.1",
"version": "3.4.2",
"description": "Monaco editor wrapper for easy/one-line integration with React applications (e.g. powered by create-react-app) without need of webpack configuration files",
"main": "lib/index.js",
"module": "lib/index.js",
Expand Down
9 changes: 4 additions & 5 deletions src/ControlledEditor/ControlledEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ const ControlledEditor = ({ value, onChange, editorDidMount, ...props }) => {
const handleEditorDidMount = (getValue, editor) => {
editor.onDidChangeModelContent(ev => {
const currentValue = editor.getValue();
if ((currentValue !== previousValue.current) && !(ev.isUndoing || ev.isRedoing)) {

if (currentValue !== previousValue.current) {
previousValue.current = currentValue;
const value = onChange(ev, currentValue);

if (typeof value === 'string') {
if (currentValue !== value) {
editor.setValue(value);
}
if (typeof value === 'string' && currentValue !== value) {
editor.setValue(value);
}
}
});
Expand Down
20 changes: 11 additions & 9 deletions src/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ const Editor = ({
if (editorRef.current.getOption(monacoRef.current.editor.EditorOption.readOnly)) {
editorRef.current.setValue(value);
} else {
editorRef.current.executeEdits('', [{
range: editorRef.current.getModel().getFullModelRange(),
text: value,
}]);
if (value !== editorRef.current.getValue()) {
editorRef.current.executeEdits('', [{
range: editorRef.current.getModel().getFullModelRange(),
text: value,
}]);

if (_isControlledMode) {
const model = editorRef.current.getModel();
if (_isControlledMode) {
const model = editorRef.current.getModel();

model.forceTokenization(model.getLineCount());
}
model.forceTokenization(model.getLineCount());
}

editorRef.current.pushUndoStop();
editorRef.current.pushUndoStop();
}
}
}, [value], isEditorReady);

Expand Down

0 comments on commit ef4b4f2

Please sign in to comment.