@neo4j-cypher/react-codemirror 2.0.0-next.2 → 2.0.0-next.21

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.
Files changed (155) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/dist/{types/CypherEditor.d.ts → CypherEditor.d.ts} +82 -3
  3. package/dist/CypherEditor.js +326 -0
  4. package/dist/CypherEditor.js.map +1 -0
  5. package/dist/CypherEditor.test.js +151 -0
  6. package/dist/CypherEditor.test.js.map +1 -0
  7. package/dist/constants.d.ts +1 -0
  8. package/dist/constants.js +2 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/e2e_tests/autoCompletion.spec.js +318 -0
  11. package/dist/e2e_tests/autoCompletion.spec.js.map +1 -0
  12. package/dist/e2e_tests/configuration.spec.js +83 -0
  13. package/dist/e2e_tests/configuration.spec.js.map +1 -0
  14. package/dist/e2e_tests/debounce.spec.js +66 -0
  15. package/dist/e2e_tests/debounce.spec.js.map +1 -0
  16. package/dist/{types/e2e_tests/e2e-utils.d.ts → e2e_tests/e2eUtils.d.ts} +1 -0
  17. package/dist/e2e_tests/e2eUtils.js +71 -0
  18. package/dist/e2e_tests/e2eUtils.js.map +1 -0
  19. package/dist/e2e_tests/extraKeybindings.spec.js +43 -0
  20. package/dist/e2e_tests/extraKeybindings.spec.js.map +1 -0
  21. package/dist/e2e_tests/historyNavigation.spec.js +227 -0
  22. package/dist/e2e_tests/historyNavigation.spec.js.map +1 -0
  23. package/dist/e2e_tests/performanceTest.spec.d.ts +6 -0
  24. package/dist/e2e_tests/performanceTest.spec.js +97 -0
  25. package/dist/e2e_tests/performanceTest.spec.js.map +1 -0
  26. package/dist/e2e_tests/sanityChecks.spec.js +53 -0
  27. package/dist/e2e_tests/sanityChecks.spec.js.map +1 -0
  28. package/dist/e2e_tests/signatureHelp.spec.js +228 -0
  29. package/dist/e2e_tests/signatureHelp.spec.js.map +1 -0
  30. package/dist/e2e_tests/snippets.spec.js +62 -0
  31. package/dist/e2e_tests/snippets.spec.js.map +1 -0
  32. package/dist/e2e_tests/syntaxHighlighting.spec.d.ts +1 -0
  33. package/dist/e2e_tests/syntaxHighlighting.spec.js +90 -0
  34. package/dist/e2e_tests/syntaxHighlighting.spec.js.map +1 -0
  35. package/dist/e2e_tests/syntaxValidation.spec.d.ts +1 -0
  36. package/dist/e2e_tests/syntaxValidation.spec.js +116 -0
  37. package/dist/e2e_tests/syntaxValidation.spec.js.map +1 -0
  38. package/dist/historyNavigation.js +163 -0
  39. package/dist/historyNavigation.js.map +1 -0
  40. package/dist/{types/icons.d.ts → icons.d.ts} +1 -1
  41. package/dist/icons.js +62 -0
  42. package/dist/icons.js.map +1 -0
  43. package/dist/index.d.ts +4 -0
  44. package/dist/index.js +5 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/lang-cypher/autocomplete.d.ts +6 -0
  47. package/dist/lang-cypher/autocomplete.js +115 -0
  48. package/dist/lang-cypher/autocomplete.js.map +1 -0
  49. package/dist/{types/lang-cypher → lang-cypher}/constants.d.ts +11 -0
  50. package/dist/lang-cypher/constants.js +69 -0
  51. package/dist/lang-cypher/constants.js.map +1 -0
  52. package/dist/lang-cypher/contants.test.d.ts +1 -0
  53. package/dist/lang-cypher/contants.test.js +103 -0
  54. package/dist/lang-cypher/contants.test.js.map +1 -0
  55. package/dist/lang-cypher/createCypherTheme.js +182 -0
  56. package/dist/lang-cypher/createCypherTheme.js.map +1 -0
  57. package/dist/lang-cypher/langCypher.d.ts +14 -0
  58. package/dist/lang-cypher/langCypher.js +23 -0
  59. package/dist/lang-cypher/langCypher.js.map +1 -0
  60. package/dist/lang-cypher/lintWorker.d.ts +12 -0
  61. package/dist/lang-cypher/lintWorker.js +14 -0
  62. package/dist/lang-cypher/lintWorker.js.map +1 -0
  63. package/dist/lang-cypher/parser-adapter.d.ts +19 -0
  64. package/dist/lang-cypher/parser-adapter.js +113 -0
  65. package/dist/lang-cypher/parser-adapter.js.map +1 -0
  66. package/dist/lang-cypher/signatureHelp.d.ts +4 -0
  67. package/dist/lang-cypher/signatureHelp.js +109 -0
  68. package/dist/lang-cypher/signatureHelp.js.map +1 -0
  69. package/dist/{types/lang-cypher/syntax-validation.d.ts → lang-cypher/syntaxValidation.d.ts} +2 -1
  70. package/dist/lang-cypher/syntaxValidation.js +52 -0
  71. package/dist/lang-cypher/syntaxValidation.js.map +1 -0
  72. package/dist/lang-cypher/themeIcons.js +22 -0
  73. package/dist/lang-cypher/themeIcons.js.map +1 -0
  74. package/dist/lang-cypher/utils.d.ts +2 -0
  75. package/dist/lang-cypher/utils.js +10 -0
  76. package/dist/lang-cypher/utils.js.map +1 -0
  77. package/dist/ndlTokensCopy.d.ts +570 -0
  78. package/dist/ndlTokensCopy.js +571 -0
  79. package/dist/ndlTokensCopy.js.map +1 -0
  80. package/dist/ndlTokensCopy.test.d.ts +1 -0
  81. package/dist/ndlTokensCopy.test.js +12 -0
  82. package/dist/ndlTokensCopy.test.js.map +1 -0
  83. package/dist/neo4jSetup.d.ts +6 -0
  84. package/dist/neo4jSetup.js +120 -0
  85. package/dist/neo4jSetup.js.map +1 -0
  86. package/dist/{types/themes.d.ts → themes.d.ts} +1 -1
  87. package/dist/themes.js +93 -0
  88. package/dist/themes.js.map +1 -0
  89. package/dist/tsconfig.tsbuildinfo +1 -0
  90. package/package.json +32 -34
  91. package/src/CypherEditor.test.tsx +200 -0
  92. package/src/CypherEditor.tsx +311 -41
  93. package/src/constants.ts +1 -0
  94. package/src/e2e_tests/autoCompletion.spec.tsx +546 -0
  95. package/src/e2e_tests/configuration.spec.tsx +111 -0
  96. package/src/e2e_tests/debounce.spec.tsx +106 -0
  97. package/src/e2e_tests/{e2e-utils.ts → e2eUtils.ts} +24 -2
  98. package/src/e2e_tests/{extra-keybindings.spec.tsx → extraKeybindings.spec.tsx} +1 -3
  99. package/src/e2e_tests/{history-navigation.spec.tsx → historyNavigation.spec.tsx} +137 -18
  100. package/src/e2e_tests/performanceTest.spec.tsx +163 -0
  101. package/src/e2e_tests/{sanity-checks.spec.tsx → sanityChecks.spec.tsx} +7 -22
  102. package/src/e2e_tests/signatureHelp.spec.tsx +445 -0
  103. package/src/e2e_tests/snippets.spec.tsx +92 -0
  104. package/src/e2e_tests/{syntax-highlighting.spec.tsx → syntaxHighlighting.spec.tsx} +26 -24
  105. package/src/e2e_tests/{syntax-validation.spec.tsx → syntaxValidation.spec.tsx} +97 -10
  106. package/src/{history-navigation.ts → historyNavigation.ts} +1 -1
  107. package/src/icons.ts +3 -0
  108. package/src/index.ts +2 -2
  109. package/src/lang-cypher/autocomplete.ts +100 -18
  110. package/src/lang-cypher/constants.ts +27 -0
  111. package/src/lang-cypher/contants.test.ts +6 -2
  112. package/src/lang-cypher/{create-cypher-theme.ts → createCypherTheme.ts} +44 -2
  113. package/src/lang-cypher/langCypher.ts +43 -0
  114. package/src/lang-cypher/lintWorker.ts +31 -0
  115. package/src/lang-cypher/parser-adapter.ts +145 -0
  116. package/src/lang-cypher/signatureHelp.ts +151 -0
  117. package/src/lang-cypher/syntaxValidation.ts +66 -0
  118. package/src/lang-cypher/utils.ts +9 -0
  119. package/src/{ndl-tokens-copy.test.ts → ndlTokensCopy.test.ts} +2 -1
  120. package/src/ndlTokensCopy.ts +570 -0
  121. package/src/{neo4j-setup.tsx → neo4jSetup.tsx} +78 -17
  122. package/src/themes.ts +45 -70
  123. package/src/viteEnv.d.ts +1 -0
  124. package/dist/cjs/index.cjs +0 -1440
  125. package/dist/cjs/index.cjs.map +0 -7
  126. package/dist/esm/index.mjs +0 -1463
  127. package/dist/esm/index.mjs.map +0 -7
  128. package/dist/types/e2e_tests/mock-data.d.ts +0 -3779
  129. package/dist/types/index.d.ts +0 -4
  130. package/dist/types/lang-cypher/ParserAdapter.d.ts +0 -14
  131. package/dist/types/lang-cypher/autocomplete.d.ts +0 -3
  132. package/dist/types/lang-cypher/lang-cypher.d.ts +0 -7
  133. package/dist/types/ndl-tokens-copy.d.ts +0 -379
  134. package/dist/types/neo4j-setup.d.ts +0 -2
  135. package/dist/types/tsconfig.tsbuildinfo +0 -1
  136. package/src/e2e_tests/auto-completion.spec.tsx +0 -232
  137. package/src/e2e_tests/mock-data.ts +0 -4310
  138. package/src/e2e_tests/performance-test.spec.tsx +0 -71
  139. package/src/lang-cypher/ParserAdapter.ts +0 -92
  140. package/src/lang-cypher/lang-cypher.ts +0 -32
  141. package/src/lang-cypher/syntax-validation.ts +0 -24
  142. package/src/ndl-tokens-copy.ts +0 -379
  143. /package/dist/{types/e2e_tests/auto-completion.spec.d.ts → CypherEditor.test.d.ts} +0 -0
  144. /package/dist/{types/e2e_tests/extra-keybindings.spec.d.ts → e2e_tests/autoCompletion.spec.d.ts} +0 -0
  145. /package/dist/{types/e2e_tests/history-navigation.spec.d.ts → e2e_tests/configuration.spec.d.ts} +0 -0
  146. /package/dist/{types/e2e_tests/performance-test.spec.d.ts → e2e_tests/debounce.spec.d.ts} +0 -0
  147. /package/dist/{types/e2e_tests/sanity-checks.spec.d.ts → e2e_tests/extraKeybindings.spec.d.ts} +0 -0
  148. /package/dist/{types/e2e_tests/syntax-highlighting.spec.d.ts → e2e_tests/historyNavigation.spec.d.ts} +0 -0
  149. /package/dist/{types/e2e_tests/syntax-validation.spec.d.ts → e2e_tests/sanityChecks.spec.d.ts} +0 -0
  150. /package/dist/{types/lang-cypher/contants.test.d.ts → e2e_tests/signatureHelp.spec.d.ts} +0 -0
  151. /package/dist/{types/ndl-tokens-copy.test.d.ts → e2e_tests/snippets.spec.d.ts} +0 -0
  152. /package/dist/{types/history-navigation.d.ts → historyNavigation.d.ts} +0 -0
  153. /package/dist/{types/lang-cypher/create-cypher-theme.d.ts → lang-cypher/createCypherTheme.d.ts} +0 -0
  154. /package/dist/{types/lang-cypher/theme-icons.d.ts → lang-cypher/themeIcons.d.ts} +0 -0
  155. /package/src/lang-cypher/{theme-icons.ts → themeIcons.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,179 @@
1
1
  # @neo4j-cypher/react-codemirror
2
2
 
3
+ ## 2.0.0-next.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [1b971aa]
8
+ - Updated dependencies [07ac90f]
9
+ - @neo4j-cypher/language-support@2.0.0-next.18
10
+
11
+ ## 2.0.0-next.20
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [bffbb19]
16
+ - Updated dependencies [826d922]
17
+ - Updated dependencies [1caab0c]
18
+ - @neo4j-cypher/language-support@2.0.0-next.17
19
+
20
+ ## 2.0.0-next.19
21
+
22
+ ### Patch Changes
23
+
24
+ - a3e3e50: updating themes to use needle colors
25
+ - Updated dependencies [68f55d4]
26
+ - Updated dependencies [6d00433]
27
+ - Updated dependencies [c01b32a]
28
+ - @neo4j-cypher/language-support@2.0.0-next.16
29
+
30
+ ## 2.0.0-next.18
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [50cc73e]
35
+ - Updated dependencies [5ef538d]
36
+ - Updated dependencies [b988d3b]
37
+ - @neo4j-cypher/language-support@2.0.0-next.15
38
+
39
+ ## 2.0.0-next.17
40
+
41
+ ### Patch Changes
42
+
43
+ - 245fb6a: Automatically opens autocompletions after "YIELD "
44
+ - Updated dependencies [8ec797d]
45
+ - Updated dependencies [7aa9c3a]
46
+ - Updated dependencies [2be5469]
47
+ - Updated dependencies [245fb6a]
48
+ - Updated dependencies [c587b81]
49
+ - Updated dependencies [3f8b64f]
50
+ - Updated dependencies [043d766]
51
+ - Updated dependencies [704d1c5]
52
+ - @neo4j-cypher/language-support@2.0.0-next.14
53
+
54
+ ## 2.0.0-next.16
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [84a12fc]
59
+ - Updated dependencies [d329252]
60
+ - Updated dependencies [b0e419e]
61
+ - @neo4j-cypher/language-support@2.0.0-next.13
62
+
63
+ ## 2.0.0-next.15
64
+
65
+ ### Patch Changes
66
+
67
+ - adc5b64: using custom light color theme for the cypher editor
68
+ - Updated dependencies [88fbe63]
69
+ - Updated dependencies [22081b0]
70
+ - Updated dependencies [62ac442]
71
+ - @neo4j-cypher/language-support@2.0.0-next.12
72
+
73
+ ## 2.0.0-next.14
74
+
75
+ ### Patch Changes
76
+
77
+ - d85c1e0: Fixes bug with auto-completions
78
+ - Updated dependencies [bccf518]
79
+ - @neo4j-cypher/language-support@2.0.0-next.11
80
+
81
+ ## 2.0.0-next.13
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [8760c02]
86
+ - @neo4j-cypher/language-support@2.0.0-next.10
87
+
88
+ ## 2.0.0-next.12
89
+
90
+ ### Patch Changes
91
+
92
+ - dcbe67d: Expose moveFocusOnTab property on the CypherEditor component to conditionally disable tab keymappings
93
+ - e9621c8: Re-export language support from react codemirror
94
+ - Updated dependencies [2e72ac8]
95
+ - @neo4j-cypher/language-support@2.0.0-next.9
96
+
97
+ ## 2.0.0-next.11
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [05663bd]
102
+ - @neo4j-cypher/language-support@2.0.0-next.8
103
+
104
+ ## 2.0.0-next.10
105
+
106
+ ### Patch Changes
107
+
108
+ - bb7e9d3: Simplify detection and handling of value prop updates
109
+
110
+ ## 2.0.0-next.9
111
+
112
+ ### Patch Changes
113
+
114
+ - fbd5f7e: allow signature help panel to render below editor when there's not enough space above it
115
+ - 09dfae2: Add an ariaLabel prop to CypherEditor
116
+ - 7154e94: Fix bug causing debouncing to override value
117
+ - 62c152f: execute single line query on enter by default
118
+ - cbfc75e: Fix a bug causing debounced value updates to get cancelled erroneously
119
+ - 04ae35e: Set initial latestDispatchedValue and flush debounced changes onExecute
120
+ Add tests for debounce behaviour
121
+ - Updated dependencies [3661e9d]
122
+ - Updated dependencies [b76af58]
123
+ - Updated dependencies [21699b7]
124
+ - Updated dependencies [6afc0e3]
125
+ - Updated dependencies [39b924d]
126
+ - @neo4j-cypher/language-support@2.0.0-next.7
127
+
128
+ ## 2.0.0-next.8
129
+
130
+ ### Patch Changes
131
+
132
+ - 6cc9022: Adds more props to the CypherEditor component
133
+ - Updated dependencies [e92d8c7]
134
+ - @neo4j-cypher/language-support@2.0.0-next.6
135
+
136
+ ## 2.0.0-next.7
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [1f790d0]
141
+ - @neo4j-cypher/language-support@2.0.0-next.5
142
+
143
+ ## 2.0.0-next.6
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies
148
+ - @neo4j-cypher/language-support@2.0.0-next.4
149
+
150
+ ## 2.0.0-next.5
151
+
152
+ ### Patch Changes
153
+
154
+ - 8cc77c6: Add support for console commands
155
+ - 1e210cb: Moves semantic analysis to a separate worker file
156
+ - Updated dependencies [8cc77c6]
157
+ - Updated dependencies [1e210cb]
158
+ - Updated dependencies [f6d20b2]
159
+ - @neo4j-cypher/language-support@2.0.0-next.3
160
+
161
+ ## 2.0.0-next.4
162
+
163
+ ### Patch Changes
164
+
165
+ - 8de605b: Improved history prop change detection
166
+ - Updated dependencies [17909e3]
167
+ - @neo4j-cypher/language-support@2.0.0-next.2
168
+
169
+ ## 2.0.0-next.3
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [a790700]
174
+ - Updated dependencies [08db455]
175
+ - @neo4j-cypher/language-support@2.0.0-next.1
176
+
3
177
  ## 2.0.0-next.2
4
178
 
5
179
  ### Patch Changes
@@ -1,7 +1,8 @@
1
1
  import { EditorState, Extension } from '@codemirror/state';
2
2
  import { EditorView, KeyBinding, ViewUpdate } from '@codemirror/view';
3
- import type { DbSchema } from '@neo4j-cypher/language-support';
3
+ import { type DbSchema } from '@neo4j-cypher/language-support';
4
4
  import { Component } from 'react';
5
+ type DomEventHandlers = Parameters<typeof EditorView.domEventHandlers>[0];
5
6
  export interface CypherEditorProps {
6
7
  /**
7
8
  * The prompt to show on single line editors
@@ -21,7 +22,14 @@ export interface CypherEditorProps {
21
22
  */
22
23
  onExecute?: (cmd: string) => void;
23
24
  /**
24
- * The editor history navigateable via up/down arrow keys. Order newest to oldest.
25
+ * If true, pressing enter will add a new line to the editor and cmd/ctrl + enter will execute the query.
26
+ * Otherwise pressing enter on a single line will execute the query.
27
+ *
28
+ * @default false
29
+ */
30
+ newLineOnEnter?: boolean;
31
+ /**
32
+ * The editor history navigable via up/down arrow keys. Order newest to oldest.
25
33
  * Add to this list with the `onExecute` callback for REPL style history.
26
34
  */
27
35
  history?: string[];
@@ -38,6 +46,10 @@ export interface CypherEditorProps {
38
46
  * @default false
39
47
  */
40
48
  autofocus?: boolean;
49
+ /**
50
+ * Where to place the cursor in the query. Cannot be enabled at the same time than autofocus
51
+ */
52
+ offset?: number;
41
53
  /**
42
54
  * Whether the editor should wrap lines.
43
55
  *
@@ -50,6 +62,21 @@ export interface CypherEditorProps {
50
62
  * @default true
51
63
  */
52
64
  lint?: boolean;
65
+ /**
66
+ * Whether the signature help tooltip should be shown below the text.
67
+ * If false, it will be shown above.
68
+ *
69
+ * @default true
70
+ */
71
+ showSignatureTooltipBelow?: boolean;
72
+ /**
73
+ * Internal feature flags for the editor. Don't use in production
74
+ *
75
+ */
76
+ featureFlags?: {
77
+ consoleCommands?: boolean;
78
+ cypher25?: boolean;
79
+ };
53
80
  /**
54
81
  * The schema to use for autocompletion and linting.
55
82
  *
@@ -77,8 +104,54 @@ export interface CypherEditorProps {
77
104
  * @param {ViewUpdate} viewUpdate - the view update from codemirror
78
105
  */
79
106
  onChange?(value: string, viewUpdate: ViewUpdate): void;
107
+ /**
108
+ * Map of event handlers to add to the editor.
109
+ *
110
+ * Note that the props are compared by reference, meaning object defined inline
111
+ * will cause the editor to re-render (much like the style prop does in this example:
112
+ * <div style={{}} />
113
+ *
114
+ * Memoize the object if you want/need to avoid this.
115
+ *
116
+ * @example
117
+ * // listen to blur events
118
+ * <CypherEditor domEventHandlers={{blur: () => console.log("blur event fired")}} />
119
+ */
120
+ domEventHandlers?: DomEventHandlers;
121
+ /**
122
+ * Placeholder text to display when the editor is empty.
123
+ */
124
+ placeholder?: string;
125
+ /**
126
+ * Whether the editor should show line numbers.
127
+ *
128
+ * @default true
129
+ */
130
+ lineNumbers?: boolean;
131
+ /**
132
+ * Whether the editor is read-only.
133
+ *
134
+ * @default false
135
+ */
136
+ readonly?: boolean;
137
+ /**
138
+ * String value to assign to the aria-label attribute of the editor.
139
+ */
140
+ ariaLabel?: string;
141
+ /**
142
+ * Whether keybindings for inserting indents with the Tab key should be disabled.
143
+ *
144
+ * true will not create keybindings for inserting indents.
145
+ * false will create keybindings for inserting indents.
146
+ *
147
+ * @default false
148
+ */
149
+ moveFocusOnTab?: boolean;
80
150
  }
81
- export declare class CypherEditor extends Component<CypherEditorProps> {
151
+ type CypherEditorState = {
152
+ cypherSupportEnabled: boolean;
153
+ };
154
+ export declare class CypherEditor extends Component<CypherEditorProps, CypherEditorState> {
82
155
  /**
83
156
  * The codemirror editor container.
84
157
  */
@@ -92,6 +165,10 @@ export declare class CypherEditor extends Component<CypherEditorProps> {
92
165
  */
93
166
  editorView: React.MutableRefObject<EditorView>;
94
167
  private schemaRef;
168
+ /**
169
+ * Format Cypher query
170
+ */
171
+ format(): void;
95
172
  /**
96
173
  * Focus the editor
97
174
  */
@@ -106,8 +183,10 @@ export declare class CypherEditor extends Component<CypherEditorProps> {
106
183
  */
107
184
  setValueAndFocus(value?: string): void;
108
185
  static defaultProps: CypherEditorProps;
186
+ private debouncedOnChange;
109
187
  componentDidMount(): void;
110
188
  componentDidUpdate(prevProps: CypherEditorProps): void;
111
189
  componentWillUnmount(): void;
112
190
  render(): React.ReactNode;
113
191
  }
192
+ export {};
@@ -0,0 +1,326 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { insertNewline } from '@codemirror/commands';
3
+ import { Annotation, Compartment, EditorState, } from '@codemirror/state';
4
+ import { EditorView, keymap, lineNumbers, placeholder, } from '@codemirror/view';
5
+ import { formatQuery, _internalFeatureFlags, } from '@neo4j-cypher/language-support';
6
+ import debounce from 'lodash.debounce';
7
+ import { Component, createRef } from 'react';
8
+ import { DEBOUNCE_TIME } from './constants';
9
+ import { replaceHistory, replMode as historyNavigation, } from './historyNavigation';
10
+ import { cypher } from './lang-cypher/langCypher';
11
+ import { cleanupWorkers } from './lang-cypher/syntaxValidation';
12
+ import { basicNeo4jSetup } from './neo4jSetup';
13
+ import { getThemeExtension } from './themes';
14
+ const format = (view) => {
15
+ try {
16
+ const doc = view.state.doc.toString();
17
+ const { formattedString, newCursorPos } = formatQuery(doc, view.state.selection.main.anchor);
18
+ view.dispatch({
19
+ changes: {
20
+ from: 0,
21
+ to: doc.length,
22
+ insert: formattedString,
23
+ },
24
+ selection: { anchor: newCursorPos },
25
+ });
26
+ }
27
+ catch (error) {
28
+ // Formatting failed, likely because of a syntax error
29
+ }
30
+ };
31
+ const executeKeybinding = (onExecute, newLineOnEnter, flush) => {
32
+ const keybindings = {
33
+ 'Shift-Enter': {
34
+ key: 'Shift-Enter',
35
+ run: insertNewline,
36
+ },
37
+ 'Ctrl-Enter': {
38
+ key: 'Ctrl-Enter',
39
+ run: () => true,
40
+ },
41
+ Enter: {
42
+ key: 'Enter',
43
+ run: insertNewline,
44
+ },
45
+ };
46
+ if (onExecute) {
47
+ keybindings['Ctrl-Enter'] = {
48
+ key: 'Ctrl-Enter',
49
+ mac: 'Mod-Enter',
50
+ preventDefault: true,
51
+ run: (view) => {
52
+ const doc = view.state.doc.toString();
53
+ if (doc.trim() !== '') {
54
+ flush?.();
55
+ onExecute(doc);
56
+ }
57
+ return true;
58
+ },
59
+ };
60
+ if (!newLineOnEnter) {
61
+ keybindings['Enter'] = {
62
+ key: 'Enter',
63
+ preventDefault: true,
64
+ run: (view) => {
65
+ const doc = view.state.doc.toString();
66
+ if (doc.includes('\n')) {
67
+ // Returning false means the event will mark the event
68
+ // as not handled and the default behavior will be executed
69
+ return false;
70
+ }
71
+ if (doc.trim() !== '') {
72
+ flush?.();
73
+ onExecute(doc);
74
+ }
75
+ return true;
76
+ },
77
+ };
78
+ }
79
+ }
80
+ return Object.values(keybindings);
81
+ };
82
+ const themeCompartment = new Compartment();
83
+ const keyBindingCompartment = new Compartment();
84
+ const lineNumbersCompartment = new Compartment();
85
+ const readOnlyCompartment = new Compartment();
86
+ const placeholderCompartment = new Compartment();
87
+ const domEventHandlerCompartment = new Compartment();
88
+ const formatLineNumber = (prompt) => (a, state) => {
89
+ if (state.doc.lines === 1 && prompt !== undefined) {
90
+ return prompt;
91
+ }
92
+ return a.toString();
93
+ };
94
+ const ExternalEdit = Annotation.define();
95
+ export class CypherEditor extends Component {
96
+ /**
97
+ * The codemirror editor container.
98
+ */
99
+ editorContainer = createRef();
100
+ /**
101
+ * The codemirror editor state.
102
+ */
103
+ editorState = createRef();
104
+ /**
105
+ * The codemirror editor view.
106
+ */
107
+ editorView = createRef();
108
+ schemaRef = createRef();
109
+ /**
110
+ * Format Cypher query
111
+ */
112
+ format() {
113
+ format(this.editorView.current);
114
+ }
115
+ /**
116
+ * Focus the editor
117
+ */
118
+ focus() {
119
+ this.editorView.current?.focus();
120
+ }
121
+ /**
122
+ * Move the cursor to the supplied position.
123
+ * For example, to move the cursor to the end of the editor, use `value.length`
124
+ */
125
+ updateCursorPosition(position) {
126
+ this.editorView.current?.dispatch({
127
+ selection: { anchor: position, head: position },
128
+ });
129
+ }
130
+ /**
131
+ * Externally set the editor value and focus the editor.
132
+ */
133
+ setValueAndFocus(value = '') {
134
+ const currentCmValue = this.editorView.current.state?.doc.toString() ?? '';
135
+ this.editorView.current.dispatch({
136
+ changes: {
137
+ from: 0,
138
+ to: currentCmValue.length,
139
+ insert: value,
140
+ },
141
+ selection: { anchor: value.length, head: value.length },
142
+ });
143
+ this.editorView.current?.focus();
144
+ }
145
+ static defaultProps = {
146
+ lint: true,
147
+ schema: {},
148
+ overrideThemeBackgroundColor: false,
149
+ lineWrap: false,
150
+ showSignatureTooltipBelow: true,
151
+ extraKeybindings: [],
152
+ history: [],
153
+ theme: 'light',
154
+ lineNumbers: true,
155
+ newLineOnEnter: false,
156
+ moveFocusOnTab: false,
157
+ };
158
+ debouncedOnChange = this.props.onChange
159
+ ? debounce(((value, viewUpdate) => {
160
+ this.props.onChange(value, viewUpdate);
161
+ }), DEBOUNCE_TIME)
162
+ : undefined;
163
+ componentDidMount() {
164
+ const { theme, extraKeybindings, lineWrap, overrideThemeBackgroundColor, schema, lint, showSignatureTooltipBelow, featureFlags, onExecute, newLineOnEnter, } = this.props;
165
+ _internalFeatureFlags.cypher25 = featureFlags?.cypher25 ?? false;
166
+ this.schemaRef.current = {
167
+ schema,
168
+ lint,
169
+ showSignatureTooltipBelow,
170
+ featureFlags: {
171
+ consoleCommands: true,
172
+ ...featureFlags,
173
+ },
174
+ useLightVersion: false,
175
+ setUseLightVersion: (newVal) => {
176
+ if (this.schemaRef.current !== undefined) {
177
+ this.schemaRef.current.useLightVersion = newVal;
178
+ }
179
+ },
180
+ };
181
+ const themeExtension = getThemeExtension(theme, overrideThemeBackgroundColor);
182
+ const changeListener = this.debouncedOnChange
183
+ ? [
184
+ EditorView.updateListener.of((upt) => {
185
+ const wasUserEdit = !upt.transactions.some((tr) => tr.annotation(ExternalEdit));
186
+ if (upt.docChanged && wasUserEdit) {
187
+ const doc = upt.state.doc;
188
+ const value = doc.toString();
189
+ this.debouncedOnChange(value, upt);
190
+ }
191
+ }),
192
+ ]
193
+ : [];
194
+ this.editorState.current = EditorState.create({
195
+ extensions: [
196
+ keyBindingCompartment.of(keymap.of([
197
+ ...executeKeybinding(onExecute, newLineOnEnter, () => this.debouncedOnChange?.flush()),
198
+ ...extraKeybindings,
199
+ ])),
200
+ historyNavigation(this.props),
201
+ basicNeo4jSetup(this.props),
202
+ themeCompartment.of(themeExtension),
203
+ changeListener,
204
+ cypher(this.schemaRef.current),
205
+ lineWrap ? EditorView.lineWrapping : [],
206
+ lineNumbersCompartment.of(this.props.lineNumbers
207
+ ? lineNumbers({ formatNumber: formatLineNumber(this.props.prompt) })
208
+ : []),
209
+ readOnlyCompartment.of(EditorState.readOnly.of(this.props.readonly)),
210
+ placeholderCompartment.of(this.props.placeholder ? placeholder(this.props.placeholder) : []),
211
+ domEventHandlerCompartment.of(this.props.domEventHandlers
212
+ ? EditorView.domEventHandlers(this.props.domEventHandlers)
213
+ : []),
214
+ this.props.ariaLabel
215
+ ? EditorView.contentAttributes.of({
216
+ 'aria-label': this.props.ariaLabel,
217
+ })
218
+ : [],
219
+ ],
220
+ doc: this.props.value,
221
+ });
222
+ this.editorView.current = new EditorView({
223
+ state: this.editorState.current,
224
+ parent: this.editorContainer.current,
225
+ });
226
+ if (this.props.autofocus) {
227
+ this.focus();
228
+ if (this.props.value) {
229
+ this.updateCursorPosition(this.props.value.length);
230
+ }
231
+ }
232
+ else if (this.props.offset) {
233
+ this.updateCursorPosition(this.props.offset);
234
+ }
235
+ }
236
+ componentDidUpdate(prevProps) {
237
+ if (!this.editorView.current) {
238
+ return;
239
+ }
240
+ // Handle externally set value
241
+ const currentCmValue = this.editorView.current.state?.doc.toString() ?? '';
242
+ if (this.props.value !== undefined && // If the component becomes uncontolled, we just leave the value as is
243
+ this.props.value !== prevProps.value && // The value prop has changed, we need to update the editor
244
+ this.props.value !== currentCmValue // No need to dispatch an update if the value is the same
245
+ ) {
246
+ this.editorView.current.dispatch({
247
+ changes: {
248
+ from: 0,
249
+ to: currentCmValue.length,
250
+ insert: this.props.value ?? '',
251
+ },
252
+ annotations: [ExternalEdit.of(true)],
253
+ });
254
+ }
255
+ // Handle theme change
256
+ const didChangeTheme = prevProps.theme !== this.props.theme ||
257
+ prevProps.overrideThemeBackgroundColor !==
258
+ this.props.overrideThemeBackgroundColor;
259
+ if (didChangeTheme) {
260
+ this.editorView.current.dispatch({
261
+ effects: themeCompartment.reconfigure(getThemeExtension(this.props.theme, this.props.overrideThemeBackgroundColor)),
262
+ });
263
+ }
264
+ if (prevProps.lineNumbers !== this.props.lineNumbers ||
265
+ prevProps.prompt !== this.props.prompt) {
266
+ this.editorView.current.dispatch({
267
+ effects: lineNumbersCompartment.reconfigure(this.props.lineNumbers
268
+ ? lineNumbers({ formatNumber: formatLineNumber(this.props.prompt) })
269
+ : []),
270
+ });
271
+ }
272
+ if (prevProps.readonly !== this.props.readonly) {
273
+ this.editorView.current.dispatch({
274
+ effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(this.props.readonly)),
275
+ });
276
+ }
277
+ if (prevProps.placeholder !== this.props.placeholder) {
278
+ this.editorView.current.dispatch({
279
+ effects: placeholderCompartment.reconfigure(this.props.placeholder ? placeholder(this.props.placeholder) : []),
280
+ });
281
+ }
282
+ if (prevProps.extraKeybindings !== this.props.extraKeybindings ||
283
+ prevProps.onExecute !== this.props.onExecute) {
284
+ this.editorView.current.dispatch({
285
+ effects: keyBindingCompartment.reconfigure(keymap.of([
286
+ ...executeKeybinding(this.props.onExecute, this.props.newLineOnEnter, () => this.debouncedOnChange?.flush()),
287
+ ...this.props.extraKeybindings,
288
+ ])),
289
+ });
290
+ }
291
+ if (prevProps.domEventHandlers !== this.props.domEventHandlers) {
292
+ this.editorView.current.dispatch({
293
+ effects: domEventHandlerCompartment.reconfigure(this.props.domEventHandlers
294
+ ? EditorView.domEventHandlers(this.props.domEventHandlers)
295
+ : []),
296
+ });
297
+ }
298
+ // This component rerenders on every keystroke and comparing the
299
+ // full lists of editor strings on every render could be expensive.
300
+ const didChangeHistoryEstimate = prevProps.history?.length !== this.props.history?.length ||
301
+ prevProps.history?.[0] !== this.props.history?.[0];
302
+ if (didChangeHistoryEstimate) {
303
+ this.editorView.current.dispatch({
304
+ effects: replaceHistory.of(this.props.history ?? []),
305
+ });
306
+ }
307
+ /*
308
+ The cypher configuration is a mutable object that is passed to the cypher language extension.
309
+ Much like how the schema based completions work in the official sql language extension.
310
+ https://github.com/codemirror/lang-sql/blob/4b7b2564dff7cdb1a15f8ccd08142f2cc8a0006f/src/sql.ts#L178C17-L178C18
311
+ */
312
+ this.schemaRef.current.schema = this.props.schema;
313
+ this.schemaRef.current.lint = this.props.lint;
314
+ this.schemaRef.current.featureFlags = this.props.featureFlags;
315
+ }
316
+ componentWillUnmount() {
317
+ this.editorView.current?.destroy();
318
+ cleanupWorkers();
319
+ }
320
+ render() {
321
+ const { className, theme } = this.props;
322
+ const themeClass = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';
323
+ return (_jsx("div", { ref: this.editorContainer, className: `${themeClass}${className ? ` ${className}` : ''}` }));
324
+ }
325
+ }
326
+ //# sourceMappingURL=CypherEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CypherEditor.js","sourceRoot":"","sources":["../src/CypherEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,UAAU,EAEV,MAAM,EACN,WAAW,EACX,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,qBAAqB,GAEtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,QAAQ,IAAI,iBAAiB,GAC9B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAgB,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAwJ7C,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAQ,EAAE;IACxC,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACtC,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC,GAAG,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