@neo4j-cypher/react-codemirror
Advanced tools
Comparing version 2.0.0-canary-62c152f to 2.0.0-canary-64da99d
@@ -159,2 +159,3 @@ import { EditorState, Extension } from '@codemirror/state'; | ||
private schemaRef; | ||
private latestDispatchedValue; | ||
/** | ||
@@ -161,0 +162,0 @@ * Focus the editor |
@@ -88,2 +88,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
schemaRef = createRef(); | ||
latestDispatchedValue; | ||
/** | ||
@@ -132,3 +133,6 @@ * Focus the editor | ||
debouncedOnChange = this.props.onChange | ||
? debounce(this.props.onChange, 200) | ||
? debounce(((value, viewUpdate) => { | ||
this.latestDispatchedValue = value; | ||
this.props.onChange(value, viewUpdate); | ||
}), 200) | ||
: undefined; | ||
@@ -213,3 +217,5 @@ componentDidMount() { | ||
const currentCmValue = this.editorView.current.state?.doc.toString() ?? ''; | ||
if (this.props.value !== undefined && currentCmValue !== this.props.value) { | ||
if (this.props.value !== undefined && | ||
this.props.value !== this.latestDispatchedValue) { | ||
this.debouncedOnChange?.cancel(); | ||
this.editorView.current.dispatch({ | ||
@@ -216,0 +222,0 @@ changes: { |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.0.0-canary-62c152f", | ||
"version": "2.0.0-canary-64da99d", | ||
"main": "./dist/index.js", | ||
@@ -55,3 +55,3 @@ "types": "./dist/index.d.ts", | ||
"@lezer/highlight": "^1.1.3", | ||
"@neo4j-cypher/language-support": "2.0.0-canary-62c152f", | ||
"@neo4j-cypher/language-support": "2.0.0-canary-64da99d", | ||
"@types/prismjs": "^1.26.3", | ||
@@ -58,0 +58,0 @@ "@types/workerpool": "^6.4.7", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
633267
8428
+ Added@neo4j-cypher/language-support@2.0.0-canary-64da99d(transitive)
- Removed@neo4j-cypher/language-support@2.0.0-canary-62c152f(transitive)