@neo4j-cypher/react-codemirror 1.0.0-next.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/CypherEditor.js +75 -34
- package/es/react-codemirror.js +0 -20
- package/lib/CypherEditor.js +75 -34
- package/package.json +18 -7
- package/src/CypherEditor.d.ts +108 -12
package/es/CypherEditor.js
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) "Neo4j"
|
|
4
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
-
*
|
|
6
|
-
* This file is part of Neo4j.
|
|
7
|
-
*
|
|
8
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU General Public License
|
|
19
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
2
|
import React, { Component } from "react";
|
|
23
3
|
import { createCypherEditor, reactiveOptionKeys, defaultOptions } from "@neo4j-cypher/codemirror";
|
|
24
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -29,8 +9,7 @@ class CypherEditor extends Component {
|
|
|
29
9
|
this.editorRef = ref;
|
|
30
10
|
});
|
|
31
11
|
_defineProperty(this, "valueChanged", (value, changes) => {
|
|
32
|
-
this.
|
|
33
|
-
this.value = value;
|
|
12
|
+
this.lastValue = value;
|
|
34
13
|
const {
|
|
35
14
|
onValueChanged
|
|
36
15
|
} = this.props;
|
|
@@ -52,16 +31,25 @@ class CypherEditor extends Component {
|
|
|
52
31
|
onScrollChanged && onScrollChanged(scrollInfo);
|
|
53
32
|
});
|
|
54
33
|
_defineProperty(this, "positionChanged", positionObject => {
|
|
34
|
+
this.lastPosition = (positionObject || {
|
|
35
|
+
position: null
|
|
36
|
+
}).position;
|
|
55
37
|
const {
|
|
56
38
|
onPositionChanged
|
|
57
39
|
} = this.props;
|
|
58
40
|
onPositionChanged && onPositionChanged(positionObject);
|
|
59
41
|
});
|
|
60
|
-
_defineProperty(this, "autocompleteChanged", (autocompleteOpen,
|
|
42
|
+
_defineProperty(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
|
|
61
43
|
const {
|
|
62
44
|
onAutocompleteChanged
|
|
63
45
|
} = this.props;
|
|
64
|
-
onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen,
|
|
46
|
+
onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
|
|
47
|
+
});
|
|
48
|
+
_defineProperty(this, "searchChanged", (searchOpen, text, matches) => {
|
|
49
|
+
const {
|
|
50
|
+
onSearchChanged
|
|
51
|
+
} = this.props;
|
|
52
|
+
onSearchChanged && onSearchChanged(searchOpen, text, matches);
|
|
65
53
|
});
|
|
66
54
|
_defineProperty(this, "lineNumberClick", (line, event) => {
|
|
67
55
|
const {
|
|
@@ -75,9 +63,17 @@ class CypherEditor extends Component {
|
|
|
75
63
|
} = this.props;
|
|
76
64
|
onKeyDown && onKeyDown(event);
|
|
77
65
|
});
|
|
66
|
+
_defineProperty(this, "keyUp", event => {
|
|
67
|
+
const {
|
|
68
|
+
onKeyUp
|
|
69
|
+
} = this.props;
|
|
70
|
+
onKeyUp && onKeyUp(event);
|
|
71
|
+
});
|
|
78
72
|
this.state = {
|
|
79
73
|
focused: false
|
|
80
74
|
};
|
|
75
|
+
this.lastValue = null;
|
|
76
|
+
this.lastPosition = null;
|
|
81
77
|
}
|
|
82
78
|
componentDidMount() {
|
|
83
79
|
const {
|
|
@@ -86,8 +82,12 @@ class CypherEditor extends Component {
|
|
|
86
82
|
autocompleteOpen,
|
|
87
83
|
autocompleteTriggerStrings,
|
|
88
84
|
autofocus,
|
|
85
|
+
bracketMatching,
|
|
86
|
+
closeBrackets,
|
|
87
|
+
cursorWide,
|
|
88
|
+
cypherLanguage,
|
|
89
89
|
history,
|
|
90
|
-
|
|
90
|
+
indentUnit,
|
|
91
91
|
lineNumberFormatter,
|
|
92
92
|
lineNumbers,
|
|
93
93
|
lineWrapping,
|
|
@@ -97,13 +97,21 @@ class CypherEditor extends Component {
|
|
|
97
97
|
readOnly,
|
|
98
98
|
readOnlyCursor,
|
|
99
99
|
schema,
|
|
100
|
+
search,
|
|
101
|
+
searchMatches,
|
|
102
|
+
searchOpen,
|
|
103
|
+
searchText,
|
|
104
|
+
searchTop,
|
|
105
|
+
tabKey,
|
|
100
106
|
theme,
|
|
101
107
|
tooltipAbsolute,
|
|
102
108
|
parseOnSetValue,
|
|
103
109
|
value,
|
|
104
|
-
onEditorCreated
|
|
110
|
+
onEditorCreated,
|
|
111
|
+
preExtensions,
|
|
112
|
+
postExtensions
|
|
105
113
|
} = this.props;
|
|
106
|
-
this.value =
|
|
114
|
+
this.value = value;
|
|
107
115
|
const {
|
|
108
116
|
editor
|
|
109
117
|
} = createCypherEditor(this.editorRef, {
|
|
@@ -112,8 +120,12 @@ class CypherEditor extends Component {
|
|
|
112
120
|
autocompleteOpen,
|
|
113
121
|
autocompleteTriggerStrings,
|
|
114
122
|
autofocus,
|
|
123
|
+
bracketMatching,
|
|
124
|
+
closeBrackets,
|
|
125
|
+
cursorWide,
|
|
126
|
+
cypherLanguage,
|
|
115
127
|
history,
|
|
116
|
-
|
|
128
|
+
indentUnit,
|
|
117
129
|
lineNumberFormatter,
|
|
118
130
|
lineNumbers,
|
|
119
131
|
lineWrapping,
|
|
@@ -123,10 +135,18 @@ class CypherEditor extends Component {
|
|
|
123
135
|
readOnly,
|
|
124
136
|
readOnlyCursor,
|
|
125
137
|
schema,
|
|
138
|
+
search,
|
|
139
|
+
searchMatches,
|
|
140
|
+
searchOpen,
|
|
141
|
+
searchText,
|
|
142
|
+
searchTop,
|
|
143
|
+
tabKey,
|
|
126
144
|
theme,
|
|
127
145
|
tooltipAbsolute,
|
|
128
146
|
parseOnSetValue,
|
|
129
|
-
value
|
|
147
|
+
value,
|
|
148
|
+
preExtensions,
|
|
149
|
+
postExtensions
|
|
130
150
|
});
|
|
131
151
|
this.cypherEditor = editor;
|
|
132
152
|
this.cypherEditor.onValueChanged(this.valueChanged);
|
|
@@ -134,8 +154,10 @@ class CypherEditor extends Component {
|
|
|
134
154
|
this.cypherEditor.onScrollChanged(this.scrollChanged);
|
|
135
155
|
this.cypherEditor.onPositionChanged(this.positionChanged);
|
|
136
156
|
this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
|
|
157
|
+
this.cypherEditor.onSearchChanged(this.searchChanged);
|
|
137
158
|
this.cypherEditor.onLineNumberClick(this.lineNumberClick);
|
|
138
159
|
this.cypherEditor.onKeyDown(this.keyDown);
|
|
160
|
+
this.cypherEditor.onKeyUp(this.keyUp);
|
|
139
161
|
onEditorCreated && onEditorCreated(this.cypherEditor);
|
|
140
162
|
}
|
|
141
163
|
componentWillUnmount() {
|
|
@@ -145,8 +167,10 @@ class CypherEditor extends Component {
|
|
|
145
167
|
this.cypherEditor.offScrollChanged(this.scrollChanged);
|
|
146
168
|
this.cypherEditor.offPositionChanged(this.positionChanged);
|
|
147
169
|
this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
|
|
170
|
+
this.cypherEditor.offSearchChanged(this.searchChanged);
|
|
148
171
|
this.cypherEditor.offLineNumberClick(this.lineNumberClick);
|
|
149
172
|
this.cypherEditor.offKeyDown(this.keyDown);
|
|
173
|
+
this.cypherEditor.offKeyUp(this.keyUp);
|
|
150
174
|
this.cypherEditor.destroy();
|
|
151
175
|
}
|
|
152
176
|
}
|
|
@@ -167,12 +191,25 @@ class CypherEditor extends Component {
|
|
|
167
191
|
return;
|
|
168
192
|
}
|
|
169
193
|
const key = Object.keys(prop).pop();
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
194
|
+
if (key === "value") {
|
|
195
|
+
if (prop[key] === this.lastValue) {
|
|
196
|
+
return;
|
|
197
|
+
} else {
|
|
198
|
+
this.lastValue = prop[key];
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (key === "position") {
|
|
202
|
+
const {
|
|
203
|
+
position
|
|
204
|
+
} = this.cypherEditor.getPositionForValue(prop[key]) || {
|
|
205
|
+
position: null
|
|
206
|
+
};
|
|
207
|
+
if (position === this.lastPosition) {
|
|
208
|
+
return;
|
|
209
|
+
} else {
|
|
210
|
+
this.lastPosition = position;
|
|
211
|
+
}
|
|
174
212
|
}
|
|
175
|
-
|
|
176
213
|
const methodName = "set" + key[0].toUpperCase() + key.slice(1);
|
|
177
214
|
if (this.cypherEditor[methodName]) {
|
|
178
215
|
this.cypherEditor[methodName](prop[key]);
|
|
@@ -181,6 +218,10 @@ class CypherEditor extends Component {
|
|
|
181
218
|
if (autofocusProps.includes(key)) {
|
|
182
219
|
this.cypherEditor.focus();
|
|
183
220
|
}
|
|
221
|
+
const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : defaultOptions.clearHistoryProps;
|
|
222
|
+
if (clearHistoryProps.includes(key)) {
|
|
223
|
+
this.cypherEditor.clearHistory();
|
|
224
|
+
}
|
|
184
225
|
}
|
|
185
226
|
render() {
|
|
186
227
|
const {
|
package/es/react-codemirror.js
CHANGED
|
@@ -1,21 +1 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) "Neo4j"
|
|
3
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
4
|
-
*
|
|
5
|
-
* This file is part of Neo4j.
|
|
6
|
-
*
|
|
7
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU General Public License
|
|
18
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
1
|
export { default as CypherEditor } from "./CypherEditor";
|
package/lib/CypherEditor.js
CHANGED
|
@@ -11,26 +11,6 @@ var _codemirror = require("@neo4j-cypher/codemirror");
|
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
14
|
-
/*
|
|
15
|
-
* Copyright (c) "Neo4j"
|
|
16
|
-
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
-
*
|
|
18
|
-
* This file is part of Neo4j.
|
|
19
|
-
*
|
|
20
|
-
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
-
* it under the terms of the GNU General Public License as published by
|
|
22
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
-
* (at your option) any later version.
|
|
24
|
-
*
|
|
25
|
-
* This program is distributed in the hope that it will be useful,
|
|
26
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
-
* GNU General Public License for more details.
|
|
29
|
-
*
|
|
30
|
-
* You should have received a copy of the GNU General Public License
|
|
31
|
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
14
|
class CypherEditor extends _react.Component {
|
|
35
15
|
constructor(props) {
|
|
36
16
|
super(props);
|
|
@@ -38,8 +18,7 @@ class CypherEditor extends _react.Component {
|
|
|
38
18
|
this.editorRef = ref;
|
|
39
19
|
});
|
|
40
20
|
(0, _defineProperty2.default)(this, "valueChanged", (value, changes) => {
|
|
41
|
-
this.
|
|
42
|
-
this.value = value;
|
|
21
|
+
this.lastValue = value;
|
|
43
22
|
const {
|
|
44
23
|
onValueChanged
|
|
45
24
|
} = this.props;
|
|
@@ -61,16 +40,25 @@ class CypherEditor extends _react.Component {
|
|
|
61
40
|
onScrollChanged && onScrollChanged(scrollInfo);
|
|
62
41
|
});
|
|
63
42
|
(0, _defineProperty2.default)(this, "positionChanged", positionObject => {
|
|
43
|
+
this.lastPosition = (positionObject || {
|
|
44
|
+
position: null
|
|
45
|
+
}).position;
|
|
64
46
|
const {
|
|
65
47
|
onPositionChanged
|
|
66
48
|
} = this.props;
|
|
67
49
|
onPositionChanged && onPositionChanged(positionObject);
|
|
68
50
|
});
|
|
69
|
-
(0, _defineProperty2.default)(this, "autocompleteChanged", (autocompleteOpen,
|
|
51
|
+
(0, _defineProperty2.default)(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
|
|
70
52
|
const {
|
|
71
53
|
onAutocompleteChanged
|
|
72
54
|
} = this.props;
|
|
73
|
-
onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen,
|
|
55
|
+
onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
|
|
56
|
+
});
|
|
57
|
+
(0, _defineProperty2.default)(this, "searchChanged", (searchOpen, text, matches) => {
|
|
58
|
+
const {
|
|
59
|
+
onSearchChanged
|
|
60
|
+
} = this.props;
|
|
61
|
+
onSearchChanged && onSearchChanged(searchOpen, text, matches);
|
|
74
62
|
});
|
|
75
63
|
(0, _defineProperty2.default)(this, "lineNumberClick", (line, event) => {
|
|
76
64
|
const {
|
|
@@ -84,9 +72,17 @@ class CypherEditor extends _react.Component {
|
|
|
84
72
|
} = this.props;
|
|
85
73
|
onKeyDown && onKeyDown(event);
|
|
86
74
|
});
|
|
75
|
+
(0, _defineProperty2.default)(this, "keyUp", event => {
|
|
76
|
+
const {
|
|
77
|
+
onKeyUp
|
|
78
|
+
} = this.props;
|
|
79
|
+
onKeyUp && onKeyUp(event);
|
|
80
|
+
});
|
|
87
81
|
this.state = {
|
|
88
82
|
focused: false
|
|
89
83
|
};
|
|
84
|
+
this.lastValue = null;
|
|
85
|
+
this.lastPosition = null;
|
|
90
86
|
}
|
|
91
87
|
componentDidMount() {
|
|
92
88
|
const {
|
|
@@ -95,8 +91,12 @@ class CypherEditor extends _react.Component {
|
|
|
95
91
|
autocompleteOpen,
|
|
96
92
|
autocompleteTriggerStrings,
|
|
97
93
|
autofocus,
|
|
94
|
+
bracketMatching,
|
|
95
|
+
closeBrackets,
|
|
96
|
+
cursorWide,
|
|
97
|
+
cypherLanguage,
|
|
98
98
|
history,
|
|
99
|
-
|
|
99
|
+
indentUnit,
|
|
100
100
|
lineNumberFormatter,
|
|
101
101
|
lineNumbers,
|
|
102
102
|
lineWrapping,
|
|
@@ -106,13 +106,21 @@ class CypherEditor extends _react.Component {
|
|
|
106
106
|
readOnly,
|
|
107
107
|
readOnlyCursor,
|
|
108
108
|
schema,
|
|
109
|
+
search,
|
|
110
|
+
searchMatches,
|
|
111
|
+
searchOpen,
|
|
112
|
+
searchText,
|
|
113
|
+
searchTop,
|
|
114
|
+
tabKey,
|
|
109
115
|
theme,
|
|
110
116
|
tooltipAbsolute,
|
|
111
117
|
parseOnSetValue,
|
|
112
118
|
value,
|
|
113
|
-
onEditorCreated
|
|
119
|
+
onEditorCreated,
|
|
120
|
+
preExtensions,
|
|
121
|
+
postExtensions
|
|
114
122
|
} = this.props;
|
|
115
|
-
this.value =
|
|
123
|
+
this.value = value;
|
|
116
124
|
const {
|
|
117
125
|
editor
|
|
118
126
|
} = (0, _codemirror.createCypherEditor)(this.editorRef, {
|
|
@@ -121,8 +129,12 @@ class CypherEditor extends _react.Component {
|
|
|
121
129
|
autocompleteOpen,
|
|
122
130
|
autocompleteTriggerStrings,
|
|
123
131
|
autofocus,
|
|
132
|
+
bracketMatching,
|
|
133
|
+
closeBrackets,
|
|
134
|
+
cursorWide,
|
|
135
|
+
cypherLanguage,
|
|
124
136
|
history,
|
|
125
|
-
|
|
137
|
+
indentUnit,
|
|
126
138
|
lineNumberFormatter,
|
|
127
139
|
lineNumbers,
|
|
128
140
|
lineWrapping,
|
|
@@ -132,10 +144,18 @@ class CypherEditor extends _react.Component {
|
|
|
132
144
|
readOnly,
|
|
133
145
|
readOnlyCursor,
|
|
134
146
|
schema,
|
|
147
|
+
search,
|
|
148
|
+
searchMatches,
|
|
149
|
+
searchOpen,
|
|
150
|
+
searchText,
|
|
151
|
+
searchTop,
|
|
152
|
+
tabKey,
|
|
135
153
|
theme,
|
|
136
154
|
tooltipAbsolute,
|
|
137
155
|
parseOnSetValue,
|
|
138
|
-
value
|
|
156
|
+
value,
|
|
157
|
+
preExtensions,
|
|
158
|
+
postExtensions
|
|
139
159
|
});
|
|
140
160
|
this.cypherEditor = editor;
|
|
141
161
|
this.cypherEditor.onValueChanged(this.valueChanged);
|
|
@@ -143,8 +163,10 @@ class CypherEditor extends _react.Component {
|
|
|
143
163
|
this.cypherEditor.onScrollChanged(this.scrollChanged);
|
|
144
164
|
this.cypherEditor.onPositionChanged(this.positionChanged);
|
|
145
165
|
this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
|
|
166
|
+
this.cypherEditor.onSearchChanged(this.searchChanged);
|
|
146
167
|
this.cypherEditor.onLineNumberClick(this.lineNumberClick);
|
|
147
168
|
this.cypherEditor.onKeyDown(this.keyDown);
|
|
169
|
+
this.cypherEditor.onKeyUp(this.keyUp);
|
|
148
170
|
onEditorCreated && onEditorCreated(this.cypherEditor);
|
|
149
171
|
}
|
|
150
172
|
componentWillUnmount() {
|
|
@@ -154,8 +176,10 @@ class CypherEditor extends _react.Component {
|
|
|
154
176
|
this.cypherEditor.offScrollChanged(this.scrollChanged);
|
|
155
177
|
this.cypherEditor.offPositionChanged(this.positionChanged);
|
|
156
178
|
this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
|
|
179
|
+
this.cypherEditor.offSearchChanged(this.searchChanged);
|
|
157
180
|
this.cypherEditor.offLineNumberClick(this.lineNumberClick);
|
|
158
181
|
this.cypherEditor.offKeyDown(this.keyDown);
|
|
182
|
+
this.cypherEditor.offKeyUp(this.keyUp);
|
|
159
183
|
this.cypherEditor.destroy();
|
|
160
184
|
}
|
|
161
185
|
}
|
|
@@ -176,12 +200,25 @@ class CypherEditor extends _react.Component {
|
|
|
176
200
|
return;
|
|
177
201
|
}
|
|
178
202
|
const key = Object.keys(prop).pop();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
203
|
+
if (key === "value") {
|
|
204
|
+
if (prop[key] === this.lastValue) {
|
|
205
|
+
return;
|
|
206
|
+
} else {
|
|
207
|
+
this.lastValue = prop[key];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (key === "position") {
|
|
211
|
+
const {
|
|
212
|
+
position
|
|
213
|
+
} = this.cypherEditor.getPositionForValue(prop[key]) || {
|
|
214
|
+
position: null
|
|
215
|
+
};
|
|
216
|
+
if (position === this.lastPosition) {
|
|
217
|
+
return;
|
|
218
|
+
} else {
|
|
219
|
+
this.lastPosition = position;
|
|
220
|
+
}
|
|
183
221
|
}
|
|
184
|
-
|
|
185
222
|
const methodName = "set" + key[0].toUpperCase() + key.slice(1);
|
|
186
223
|
if (this.cypherEditor[methodName]) {
|
|
187
224
|
this.cypherEditor[methodName](prop[key]);
|
|
@@ -190,6 +227,10 @@ class CypherEditor extends _react.Component {
|
|
|
190
227
|
if (autofocusProps.includes(key)) {
|
|
191
228
|
this.cypherEditor.focus();
|
|
192
229
|
}
|
|
230
|
+
const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : _codemirror.defaultOptions.clearHistoryProps;
|
|
231
|
+
if (clearHistoryProps.includes(key)) {
|
|
232
|
+
this.cypherEditor.clearHistory();
|
|
233
|
+
}
|
|
193
234
|
}
|
|
194
235
|
render() {
|
|
195
236
|
const {
|
package/package.json
CHANGED
|
@@ -7,18 +7,30 @@
|
|
|
7
7
|
"codemirror",
|
|
8
8
|
"codemirror 6"
|
|
9
9
|
],
|
|
10
|
-
"version": "1.0.
|
|
10
|
+
"version": "1.0.1",
|
|
11
11
|
"author": "Neo4j Inc.",
|
|
12
|
-
"license": "
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
13
|
"main": "./lib/react-codemirror.js",
|
|
14
14
|
"module": "./es/react-codemirror.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./es/react-codemirror.js",
|
|
18
|
+
"require": "./lib/react-codemirror.js"
|
|
19
|
+
},
|
|
20
|
+
"./src/react-codemirror.d.ts": {
|
|
21
|
+
"import": "./src/react-codemirror.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./src/react-codemirror.js": {
|
|
24
|
+
"import": "./src/react-codemirror.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
15
27
|
"types": "src/react-codemirror.d.ts",
|
|
16
28
|
"repository": {
|
|
17
29
|
"type": "git",
|
|
18
|
-
"url": "git://github.com/neo4j
|
|
30
|
+
"url": "git://github.com/neo4j/cypher-editor.git"
|
|
19
31
|
},
|
|
20
32
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/neo4j
|
|
33
|
+
"url": "https://github.com/neo4j/cypher-editor/issues"
|
|
22
34
|
},
|
|
23
35
|
"scripts": {
|
|
24
36
|
"build-lib": "babel --config-file ../../babel.react.config.js --extensions \".js\" --out-dir lib ./src",
|
|
@@ -37,9 +49,8 @@
|
|
|
37
49
|
"node": ">=16"
|
|
38
50
|
},
|
|
39
51
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.20.
|
|
41
|
-
"@neo4j-cypher/codemirror": "1.0.
|
|
42
|
-
"codemirror": "^6.0.1"
|
|
52
|
+
"@babel/runtime": "^7.20.13",
|
|
53
|
+
"@neo4j-cypher/codemirror": "1.0.1"
|
|
43
54
|
},
|
|
44
55
|
"peerDependencies": {
|
|
45
56
|
"react": ">=16"
|
package/src/CypherEditor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import type { Extension } from "@codemirror/state";
|
|
3
3
|
import type { EditorSupportSchema } from "@neo4j-cypher/editor-support";
|
|
4
4
|
import type {
|
|
5
5
|
PositionAny,
|
|
@@ -10,8 +10,9 @@ import type {
|
|
|
10
10
|
PositionChangedListener,
|
|
11
11
|
FocusChangedListener,
|
|
12
12
|
ScrollChangedListener,
|
|
13
|
+
SearchChangedListener,
|
|
13
14
|
ValueChangedListener,
|
|
14
|
-
|
|
15
|
+
KeyListener,
|
|
15
16
|
LineNumberClickListener,
|
|
16
17
|
LineNumberFormatter
|
|
17
18
|
} from "@neo4j-cypher/codemirror";
|
|
@@ -33,7 +34,7 @@ export interface CypherEditorProps {
|
|
|
33
34
|
*/
|
|
34
35
|
autocompleteCloseOnBlur?: boolean;
|
|
35
36
|
/**
|
|
36
|
-
* Whether the autocomplete
|
|
37
|
+
* Whether the autocomplete panel is open
|
|
37
38
|
*
|
|
38
39
|
* @remarks
|
|
39
40
|
*
|
|
@@ -60,6 +61,36 @@ export interface CypherEditorProps {
|
|
|
60
61
|
* @defaultValue ["position", "readOnly", "value"]
|
|
61
62
|
*/
|
|
62
63
|
autofocusProps?: AutofocusProp[];
|
|
64
|
+
/**
|
|
65
|
+
* Whether to show matching brackets in the editor view
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue true
|
|
68
|
+
*/
|
|
69
|
+
bracketMatching?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Setting any of these props will trigger the editor to clear its undo/redo history
|
|
72
|
+
*
|
|
73
|
+
* @defaultValue ["cypherLanguage"]
|
|
74
|
+
*/
|
|
75
|
+
clearHistoryProps?: AutofocusProp[];
|
|
76
|
+
/**
|
|
77
|
+
* Whether to automatically close brackets or wrap selected text with quotes on quote press
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue true
|
|
80
|
+
*/
|
|
81
|
+
closeBrackets?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the wide cursor should be shown
|
|
84
|
+
*
|
|
85
|
+
* @defaultValue true
|
|
86
|
+
*/
|
|
87
|
+
cursorWide?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether or not cypher language extensions are enabled
|
|
90
|
+
*
|
|
91
|
+
* @defaultValue true
|
|
92
|
+
*/
|
|
93
|
+
cypherLanguage?: boolean;
|
|
63
94
|
/**
|
|
64
95
|
* Whether the editor maintains an undo/redo history
|
|
65
96
|
*
|
|
@@ -67,11 +98,11 @@ export interface CypherEditorProps {
|
|
|
67
98
|
*/
|
|
68
99
|
history?: boolean;
|
|
69
100
|
/**
|
|
70
|
-
*
|
|
101
|
+
* The indent text to use when tabKey is enabled
|
|
71
102
|
*
|
|
72
|
-
* @defaultValue
|
|
103
|
+
* @defaultValue " "
|
|
73
104
|
*/
|
|
74
|
-
|
|
105
|
+
indentUnit?: string;
|
|
75
106
|
/**
|
|
76
107
|
* The formatter for the line numbers of the editor
|
|
77
108
|
*
|
|
@@ -126,6 +157,54 @@ export interface CypherEditorProps {
|
|
|
126
157
|
* The schema making the editor aware of things such as node labels & relationship types & procedures in the current graph database
|
|
127
158
|
*/
|
|
128
159
|
schema?: EditorSupportSchema;
|
|
160
|
+
/**
|
|
161
|
+
* Whether search is enabled
|
|
162
|
+
*
|
|
163
|
+
* @defaultValue true
|
|
164
|
+
*/
|
|
165
|
+
search?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* The max number of search matches to be included with search changed callbacks
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
*
|
|
171
|
+
* Must be between 0 and 1000, 0 means no searching for matches (better for performance)
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue 0
|
|
174
|
+
*/
|
|
175
|
+
searchMatches?: number;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the search panel is open
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
*
|
|
181
|
+
* Changing this can be used to manually control the search open state
|
|
182
|
+
*
|
|
183
|
+
* @defaultValue `false`
|
|
184
|
+
*/
|
|
185
|
+
searchOpen?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* The search text for the search panel
|
|
188
|
+
*
|
|
189
|
+
* @remarks
|
|
190
|
+
*
|
|
191
|
+
* Changing this can be used to manually control the search panel text
|
|
192
|
+
*
|
|
193
|
+
* @defaultValue ""
|
|
194
|
+
*/
|
|
195
|
+
searchText?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Whether search is shown at the top of the editor window
|
|
198
|
+
*
|
|
199
|
+
* @defaultValue false
|
|
200
|
+
*/
|
|
201
|
+
searchTop?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Whether the tab key is enabled
|
|
204
|
+
*
|
|
205
|
+
* @defaultValue true
|
|
206
|
+
*/
|
|
207
|
+
tabKey?: boolean;
|
|
129
208
|
/**
|
|
130
209
|
* Whether to use the light or dark theme for the editor
|
|
131
210
|
*
|
|
@@ -135,7 +214,7 @@ export interface CypherEditorProps {
|
|
|
135
214
|
/**
|
|
136
215
|
* Whether or not the tooltips use simple absolute position styling (vs trying to stay within bounds)
|
|
137
216
|
*
|
|
138
|
-
* @defaultValue
|
|
217
|
+
* @defaultValue true
|
|
139
218
|
*/
|
|
140
219
|
tooltipAbsolute?: boolean;
|
|
141
220
|
/**
|
|
@@ -177,18 +256,35 @@ export interface CypherEditorProps {
|
|
|
177
256
|
* A listener for when the editor autocompletion state changes
|
|
178
257
|
*/
|
|
179
258
|
onAutocompleteChanged?: AutocompleteChangedListener;
|
|
259
|
+
/**
|
|
260
|
+
* A listener for when the editor search state changes
|
|
261
|
+
*/
|
|
262
|
+
onSearchChanged?: SearchChangedListener;
|
|
180
263
|
/**
|
|
181
264
|
* A listener for when the user clicks an editor line number
|
|
182
265
|
*/
|
|
183
266
|
onLineNumberClick?: LineNumberClickListener;
|
|
184
267
|
/**
|
|
185
|
-
* A listener for when the user
|
|
268
|
+
* A listener for when the user performs a key down in the editor
|
|
186
269
|
*/
|
|
187
|
-
onKeyDown?:
|
|
270
|
+
onKeyDown?: KeyListener;
|
|
271
|
+
/**
|
|
272
|
+
* A listener for when the user performs a key up in the editor
|
|
273
|
+
*/
|
|
274
|
+
onKeyUp?: KeyListener;
|
|
188
275
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
276
|
+
/**
|
|
277
|
+
* The codemirror 6 extensions that should be added to the editor before the cypher language support extensions.
|
|
278
|
+
*
|
|
279
|
+
* @defaultValue undefined
|
|
280
|
+
*/
|
|
281
|
+
preExtensions?: Extension[];
|
|
282
|
+
/**
|
|
283
|
+
* The codemirror 6 extensions that should be added to the editor after the cypher language support extensions.
|
|
284
|
+
*
|
|
285
|
+
* @defaultValue undefined
|
|
286
|
+
*/
|
|
287
|
+
postExtensions?: Extension[];
|
|
192
288
|
}
|
|
193
289
|
|
|
194
290
|
/**
|