@neo4j-cypher/react-codemirror 1.0.0-next.12 → 1.0.0-next.13

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.
@@ -59,11 +59,17 @@ class CypherEditor extends Component {
59
59
  } = this.props;
60
60
  onPositionChanged && onPositionChanged(positionObject);
61
61
  });
62
- _defineProperty(this, "autocompleteChanged", (autocompleteOpen, from, options) => {
62
+ _defineProperty(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
63
63
  const {
64
64
  onAutocompleteChanged
65
65
  } = this.props;
66
- onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, from, options);
66
+ onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
67
+ });
68
+ _defineProperty(this, "searchChanged", (searchOpen, text, matches) => {
69
+ const {
70
+ onSearchChanged
71
+ } = this.props;
72
+ onSearchChanged && onSearchChanged(searchOpen, text, matches);
67
73
  });
68
74
  _defineProperty(this, "lineNumberClick", (line, event) => {
69
75
  const {
@@ -90,6 +96,8 @@ class CypherEditor extends Component {
90
96
  autocompleteOpen,
91
97
  autocompleteTriggerStrings,
92
98
  autofocus,
99
+ cursorWide,
100
+ cypherLanguage,
93
101
  history,
94
102
  indentUnit,
95
103
  lineNumberFormatter,
@@ -102,6 +110,9 @@ class CypherEditor extends Component {
102
110
  readOnlyCursor,
103
111
  schema,
104
112
  search,
113
+ searchMatches,
114
+ searchOpen,
115
+ searchText,
105
116
  searchTop,
106
117
  tabKey,
107
118
  theme,
@@ -119,6 +130,8 @@ class CypherEditor extends Component {
119
130
  autocompleteOpen,
120
131
  autocompleteTriggerStrings,
121
132
  autofocus,
133
+ cursorWide,
134
+ cypherLanguage,
122
135
  history,
123
136
  indentUnit,
124
137
  lineNumberFormatter,
@@ -131,6 +144,9 @@ class CypherEditor extends Component {
131
144
  readOnlyCursor,
132
145
  schema,
133
146
  search,
147
+ searchMatches,
148
+ searchOpen,
149
+ searchText,
134
150
  searchTop,
135
151
  tabKey,
136
152
  theme,
@@ -144,6 +160,7 @@ class CypherEditor extends Component {
144
160
  this.cypherEditor.onScrollChanged(this.scrollChanged);
145
161
  this.cypherEditor.onPositionChanged(this.positionChanged);
146
162
  this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
163
+ this.cypherEditor.onSearchChanged(this.searchChanged);
147
164
  this.cypherEditor.onLineNumberClick(this.lineNumberClick);
148
165
  this.cypherEditor.onKeyDown(this.keyDown);
149
166
  onEditorCreated && onEditorCreated(this.cypherEditor);
@@ -155,6 +172,7 @@ class CypherEditor extends Component {
155
172
  this.cypherEditor.offScrollChanged(this.scrollChanged);
156
173
  this.cypherEditor.offPositionChanged(this.positionChanged);
157
174
  this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
175
+ this.cypherEditor.offSearchChanged(this.searchChanged);
158
176
  this.cypherEditor.offLineNumberClick(this.lineNumberClick);
159
177
  this.cypherEditor.offKeyDown(this.keyDown);
160
178
  this.cypherEditor.destroy();
@@ -204,6 +222,10 @@ class CypherEditor extends Component {
204
222
  if (autofocusProps.includes(key)) {
205
223
  this.cypherEditor.focus();
206
224
  }
225
+ const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : defaultOptions.clearHistoryProps;
226
+ if (clearHistoryProps.includes(key)) {
227
+ this.cypherEditor.clearHistory();
228
+ }
207
229
  }
208
230
  render() {
209
231
  const {
@@ -68,11 +68,17 @@ class CypherEditor extends _react.Component {
68
68
  } = this.props;
69
69
  onPositionChanged && onPositionChanged(positionObject);
70
70
  });
71
- (0, _defineProperty2.default)(this, "autocompleteChanged", (autocompleteOpen, from, options) => {
71
+ (0, _defineProperty2.default)(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
72
72
  const {
73
73
  onAutocompleteChanged
74
74
  } = this.props;
75
- onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, from, options);
75
+ onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
76
+ });
77
+ (0, _defineProperty2.default)(this, "searchChanged", (searchOpen, text, matches) => {
78
+ const {
79
+ onSearchChanged
80
+ } = this.props;
81
+ onSearchChanged && onSearchChanged(searchOpen, text, matches);
76
82
  });
77
83
  (0, _defineProperty2.default)(this, "lineNumberClick", (line, event) => {
78
84
  const {
@@ -99,6 +105,8 @@ class CypherEditor extends _react.Component {
99
105
  autocompleteOpen,
100
106
  autocompleteTriggerStrings,
101
107
  autofocus,
108
+ cursorWide,
109
+ cypherLanguage,
102
110
  history,
103
111
  indentUnit,
104
112
  lineNumberFormatter,
@@ -111,6 +119,9 @@ class CypherEditor extends _react.Component {
111
119
  readOnlyCursor,
112
120
  schema,
113
121
  search,
122
+ searchMatches,
123
+ searchOpen,
124
+ searchText,
114
125
  searchTop,
115
126
  tabKey,
116
127
  theme,
@@ -128,6 +139,8 @@ class CypherEditor extends _react.Component {
128
139
  autocompleteOpen,
129
140
  autocompleteTriggerStrings,
130
141
  autofocus,
142
+ cursorWide,
143
+ cypherLanguage,
131
144
  history,
132
145
  indentUnit,
133
146
  lineNumberFormatter,
@@ -140,6 +153,9 @@ class CypherEditor extends _react.Component {
140
153
  readOnlyCursor,
141
154
  schema,
142
155
  search,
156
+ searchMatches,
157
+ searchOpen,
158
+ searchText,
143
159
  searchTop,
144
160
  tabKey,
145
161
  theme,
@@ -153,6 +169,7 @@ class CypherEditor extends _react.Component {
153
169
  this.cypherEditor.onScrollChanged(this.scrollChanged);
154
170
  this.cypherEditor.onPositionChanged(this.positionChanged);
155
171
  this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
172
+ this.cypherEditor.onSearchChanged(this.searchChanged);
156
173
  this.cypherEditor.onLineNumberClick(this.lineNumberClick);
157
174
  this.cypherEditor.onKeyDown(this.keyDown);
158
175
  onEditorCreated && onEditorCreated(this.cypherEditor);
@@ -164,6 +181,7 @@ class CypherEditor extends _react.Component {
164
181
  this.cypherEditor.offScrollChanged(this.scrollChanged);
165
182
  this.cypherEditor.offPositionChanged(this.positionChanged);
166
183
  this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
184
+ this.cypherEditor.offSearchChanged(this.searchChanged);
167
185
  this.cypherEditor.offLineNumberClick(this.lineNumberClick);
168
186
  this.cypherEditor.offKeyDown(this.keyDown);
169
187
  this.cypherEditor.destroy();
@@ -213,6 +231,10 @@ class CypherEditor extends _react.Component {
213
231
  if (autofocusProps.includes(key)) {
214
232
  this.cypherEditor.focus();
215
233
  }
234
+ const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : _codemirror.defaultOptions.clearHistoryProps;
235
+ if (clearHistoryProps.includes(key)) {
236
+ this.cypherEditor.clearHistory();
237
+ }
216
238
  }
217
239
  render() {
218
240
  const {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "codemirror",
8
8
  "codemirror 6"
9
9
  ],
10
- "version": "1.0.0-next.12",
10
+ "version": "1.0.0-next.13",
11
11
  "author": "Neo4j Inc.",
12
12
  "license": "GPL-3.0",
13
13
  "main": "./lib/react-codemirror.js",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "^7.20.6",
41
- "@neo4j-cypher/codemirror": "1.0.0-next.11",
41
+ "@neo4j-cypher/codemirror": "1.0.0-next.12",
42
42
  "codemirror": "^6.0.1"
43
43
  },
44
44
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- // import type { Extension } from "@codemirror/state";
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,6 +10,7 @@ import type {
10
10
  PositionChangedListener,
11
11
  FocusChangedListener,
12
12
  ScrollChangedListener,
13
+ SearchChangedListener,
13
14
  ValueChangedListener,
14
15
  KeyDownListener,
15
16
  LineNumberClickListener,
@@ -33,7 +34,7 @@ export interface CypherEditorProps {
33
34
  */
34
35
  autocompleteCloseOnBlur?: boolean;
35
36
  /**
36
- * Whether the autocomplete window is open
37
+ * Whether the autocomplete panel is open
37
38
  *
38
39
  * @remarks
39
40
  *
@@ -60,6 +61,24 @@ export interface CypherEditorProps {
60
61
  * @defaultValue ["position", "readOnly", "value"]
61
62
  */
62
63
  autofocusProps?: AutofocusProp[];
64
+ /**
65
+ * setting any of these props will trigger the editor to clear its undo/redo history
66
+ *
67
+ * @defaultValue ["cypherLanguage"]
68
+ */
69
+ clearHistoryProps?: AutofocusProp[];
70
+ /**
71
+ * Whether the wide cursor should be shown
72
+ *
73
+ * @defaultValue true
74
+ */
75
+ cursorWide?: boolean;
76
+ /**
77
+ * Whether or not cypher language extensions are enabled
78
+ *
79
+ * @defaultValue true
80
+ */
81
+ cypherLanguage?: boolean;
63
82
  /**
64
83
  * Whether the editor maintains an undo/redo history
65
84
  *
@@ -132,6 +151,36 @@ export interface CypherEditorProps {
132
151
  * @defaultValue true
133
152
  */
134
153
  search?: boolean;
154
+ /**
155
+ * The max number of search matches to be included with search changed callbacks
156
+ *
157
+ * @remarks
158
+ *
159
+ * Must be between 0 and 1000, 0 means no searching for matches (better for performance)
160
+ *
161
+ * @defaultValue 0
162
+ */
163
+ searchMatches?: number;
164
+ /**
165
+ * Whether the search panel is open
166
+ *
167
+ * @remarks
168
+ *
169
+ * Changing this can be used to manually control the search open state
170
+ *
171
+ * @defaultValue `false`
172
+ */
173
+ searchOpen?: boolean;
174
+ /**
175
+ * The search text for the search panel
176
+ *
177
+ * @remarks
178
+ *
179
+ * Changing this can be used to manually control the search panel text
180
+ *
181
+ * @defaultValue ""
182
+ */
183
+ searchText?: string;
135
184
  /**
136
185
  * Whether search is shown at the top of the editor window
137
186
  *
@@ -195,6 +244,10 @@ export interface CypherEditorProps {
195
244
  * A listener for when the editor autocompletion state changes
196
245
  */
197
246
  onAutocompleteChanged?: AutocompleteChangedListener;
247
+ /**
248
+ * A listener for when the editor search state changes
249
+ */
250
+ onSearchChanged?: SearchChangedListener;
198
251
  /**
199
252
  * A listener for when the user clicks an editor line number
200
253
  */
@@ -204,9 +257,18 @@ export interface CypherEditorProps {
204
257
  */
205
258
  onKeyDown?: KeyDownListener;
206
259
 
207
- // TODO - add these props
208
- // preExtensions?: Extension[],
209
- // postExtensions?: Extension[]
260
+ /**
261
+ * The codemirror 6 extensions that should be added to the editor before the cypher language support extensions.
262
+ *
263
+ * @defaultValue undefined
264
+ */
265
+ preExtensions?: Extension[];
266
+ /**
267
+ * The codemirror 6 extensions that should be added to the editor after the cypher language support extensions.
268
+ *
269
+ * @defaultValue undefined
270
+ */
271
+ postExtensions?: Extension[];
210
272
  }
211
273
 
212
274
  /**