@monaco-editor/react
Advanced tools
Comparing version 2.1.1 to 2.2.0
### Versions | ||
## 2.2.0 | ||
###### *Nov 9, 2019* | ||
- force additional tokenization in controlled mode to avoid blinking | ||
## 2.1.1 | ||
@@ -4,0 +9,0 @@ ###### *Oct 25, 2019* |
@@ -8,3 +8,3 @@ "use strict"; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _react = _interopRequireWildcard(require("react")); | ||
@@ -19,2 +19,6 @@ var _propTypes = _interopRequireDefault(require("prop-types")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
@@ -32,10 +36,17 @@ | ||
var previousValue = (0, _react.useRef)(value); | ||
var handleEditorDidMount = function handleEditorDidMount(getValue, editor) { | ||
editor.onDidChangeModelContent(function (ev) { | ||
var currentValue = editor.getValue(); | ||
var value = onChange(ev, currentValue); | ||
if (typeof value === 'string') { | ||
if (currentValue !== value) { | ||
editor.setValue(value); | ||
if (currentValue !== previousValue.current) { | ||
previousValue.current = currentValue; | ||
var _value = onChange(ev, currentValue); | ||
if (typeof _value === 'string') { | ||
if (currentValue !== _value) { | ||
editor.setValue(_value); | ||
} | ||
} | ||
@@ -49,3 +60,4 @@ } | ||
value: value, | ||
editorDidMount: handleEditorDidMount | ||
editorDidMount: handleEditorDidMount, | ||
_isControlledMode: true | ||
}, props)); | ||
@@ -52,0 +64,0 @@ }; |
@@ -51,3 +51,4 @@ "use strict"; | ||
loading = _ref.loading, | ||
options = _ref.options; | ||
options = _ref.options, | ||
_isControlledMode = _ref._isControlledMode; | ||
@@ -84,2 +85,8 @@ var _useState = (0, _react.useState)(false), | ||
}]); | ||
if (_isControlledMode) { | ||
var model = editorRef.current.getModel(); | ||
model.forceTokenization(model.getLineCount()); | ||
} | ||
editorRef.current.pushUndoStop(); | ||
@@ -145,3 +152,4 @@ } | ||
loading: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.string]), | ||
options: _propTypes.default.object | ||
options: _propTypes.default.object, | ||
_isControlledMode: _propTypes.default.bool | ||
}; | ||
@@ -154,5 +162,6 @@ Editor.defaultProps = { | ||
loading: 'Loading...', | ||
options: {} | ||
options: {}, | ||
_isControlledMode: false | ||
}; | ||
var _default = Editor; | ||
exports.default = _default; |
@@ -96,3 +96,3 @@ // TODO: the whole content should be improved in the next version. | ||
getModifiedEditorValue: () => string, | ||
editor: monacoEditor.editor.IStandaloneDiffEditor, | ||
editor: monacoEditor.editor.IStandaloneDiffEditor, | ||
) => void; | ||
@@ -99,0 +99,0 @@ |
{ | ||
"name": "@monaco-editor/react", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"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", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
69414
872