@neo4j-cypher/react-codemirror 2.0.0-next.26 → 2.0.0-next.27

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/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "codemirror",
18
18
  "codemirror 6"
19
19
  ],
20
- "version": "2.0.0-next.26",
20
+ "version": "2.0.0-next.27",
21
21
  "main": "./dist/src/index.js",
22
22
  "types": "./dist/src/index.d.ts",
23
23
  "type": "module",
@@ -34,13 +34,13 @@
34
34
  "node": ">=22.15.0"
35
35
  },
36
36
  "dependencies": {
37
- "@codemirror/autocomplete": "^6.17.0",
38
- "@codemirror/commands": "^6.6.0",
39
- "@codemirror/language": "^6.10.2",
40
- "@codemirror/lint": "^6.8.1",
41
- "@codemirror/search": "^6.5.6",
42
- "@codemirror/state": "^6.4.1",
43
- "@codemirror/view": "^6.29.1",
37
+ "@codemirror/autocomplete": "^6.18.6",
38
+ "@codemirror/commands": "^6.8.1",
39
+ "@codemirror/language": "^6.11.2",
40
+ "@codemirror/lint": "^6.8.5",
41
+ "@codemirror/search": "^6.5.11",
42
+ "@codemirror/state": "^6.5.2",
43
+ "@codemirror/view": "^6.38.1",
44
44
  "@lezer/common": "^1.0.2",
45
45
  "@lezer/highlight": "^1.1.3",
46
46
  "@types/prismjs": "^1.26.3",
@@ -50,14 +50,14 @@
50
50
  "prismjs": "^1.29.0",
51
51
  "style-mod": "^4.1.2",
52
52
  "vscode-languageserver-types": "^3.17.3",
53
- "workerpool": "^9.0.4",
54
- "@neo4j-cypher/language-support": "2.0.0-next.23",
55
- "@neo4j-cypher/lint-worker": "1.10.1-next.0"
53
+ "workerpool": "^9.3.3",
54
+ "@neo4j-cypher/language-support": "2.0.0-next.24",
55
+ "@neo4j-cypher/lint-worker": "1.10.1-next.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@neo4j-ndl/base": "^3.2.10",
59
- "@playwright/experimental-ct-react": "^1.51.1",
60
- "@playwright/test": "^1.51.1",
59
+ "@playwright/experimental-ct-react": "^1.54.2",
60
+ "@playwright/test": "^1.54.2",
61
61
  "@types/lodash.debounce": "^4.0.9",
62
62
  "@types/react": "^18.0.28",
63
63
  "@types/react-dom": "^18.0.11",
@@ -65,7 +65,7 @@
65
65
  "copyfiles": "^2.4.1",
66
66
  "jsdom": "^24.1.1",
67
67
  "lodash": "^4.17.21",
68
- "playwright": "^1.51.1",
68
+ "playwright": "^1.54.2",
69
69
  "react": "^18.2.0",
70
70
  "react-dom": "^18.2.0",
71
71
  "vite": "^4.5.10"
@@ -13,10 +13,7 @@ import {
13
13
  placeholder,
14
14
  ViewUpdate,
15
15
  } from '@codemirror/view';
16
- import {
17
- formatQuery,
18
- type DbSchema,
19
- } from '@neo4j-cypher/language-support';
16
+ import { formatQuery, type DbSchema } from '@neo4j-cypher/language-support';
20
17
  import debounce from 'lodash.debounce';
21
18
  import { Component, createRef } from 'react';
22
19
  import { DEBOUNCE_TIME } from './constants';
@@ -28,6 +25,7 @@ import { cypher, CypherConfig } from './lang-cypher/langCypher';
28
25
  import { cleanupWorkers } from './lang-cypher/syntaxValidation';
29
26
  import { basicNeo4jSetup } from './neo4jSetup';
30
27
  import { getThemeExtension } from './themes';
28
+ import { richClipboardCopier } from './richClipboardCopier';
31
29
 
32
30
  type DomEventHandlers = Parameters<typeof EditorView.domEventHandlers>[0];
33
31
  export interface CypherEditorProps {
@@ -181,7 +179,9 @@ export interface CypherEditorProps {
181
179
  const format = (view: EditorView): void => {
182
180
  try {
183
181
  const doc = view.state.doc.toString();
184
- const { formattedQuery, newCursorPos } = formatQuery(doc, { cursorPosition: view.state.selection.main.anchor });
182
+ const { formattedQuery, newCursorPos } = formatQuery(doc, {
183
+ cursorPosition: view.state.selection.main.anchor,
184
+ });
185
185
  view.dispatch({
186
186
  changes: {
187
187
  from: 0,
@@ -333,7 +333,10 @@ export class CypherEditor extends Component<
333
333
  to: currentCmValue.length,
334
334
  insert: normalizedValue,
335
335
  },
336
- selection: { anchor: normalizedValue.length, head: normalizedValue.length },
336
+ selection: {
337
+ anchor: normalizedValue.length,
338
+ head: normalizedValue.length,
339
+ },
337
340
  });
338
341
  this.editorView.current?.focus();
339
342
  }
@@ -354,11 +357,11 @@ export class CypherEditor extends Component<
354
357
 
355
358
  private debouncedOnChange = this.props.onChange
356
359
  ? debounce(
357
- ((value, viewUpdate) => {
358
- this.props.onChange(value, viewUpdate);
359
- }) satisfies CypherEditorProps['onChange'],
360
- DEBOUNCE_TIME,
361
- )
360
+ ((value, viewUpdate) => {
361
+ this.props.onChange(value, viewUpdate);
362
+ }) satisfies CypherEditorProps['onChange'],
363
+ DEBOUNCE_TIME,
364
+ )
362
365
  : undefined;
363
366
 
364
367
  componentDidMount(): void {
@@ -398,18 +401,18 @@ export class CypherEditor extends Component<
398
401
 
399
402
  const changeListener = this.debouncedOnChange
400
403
  ? [
401
- EditorView.updateListener.of((upt: ViewUpdate) => {
402
- const wasUserEdit = !upt.transactions.some((tr) =>
403
- tr.annotation(ExternalEdit),
404
- );
405
-
406
- if (upt.docChanged && wasUserEdit) {
407
- const doc = upt.state.doc;
408
- const value = doc.toString();
409
- this.debouncedOnChange(value, upt);
410
- }
411
- }),
412
- ]
404
+ EditorView.updateListener.of((upt: ViewUpdate) => {
405
+ const wasUserEdit = !upt.transactions.some((tr) =>
406
+ tr.annotation(ExternalEdit),
407
+ );
408
+
409
+ if (upt.docChanged && wasUserEdit) {
410
+ const doc = upt.state.doc;
411
+ const value = doc.toString();
412
+ this.debouncedOnChange(value, upt);
413
+ }
414
+ }),
415
+ ]
413
416
  : [];
414
417
 
415
418
  this.editorState.current = EditorState.create({
@@ -422,6 +425,7 @@ export class CypherEditor extends Component<
422
425
  ...extraKeybindings,
423
426
  ]),
424
427
  ),
428
+ richClipboardCopier,
425
429
  historyNavigation(this.props),
426
430
  basicNeo4jSetup(this.props),
427
431
  themeCompartment.of(themeExtension),
@@ -445,8 +449,8 @@ export class CypherEditor extends Component<
445
449
  ),
446
450
  this.props.ariaLabel
447
451
  ? EditorView.contentAttributes.of({
448
- 'aria-label': this.props.ariaLabel,
449
- })
452
+ 'aria-label': this.props.ariaLabel,
453
+ })
450
454
  : [],
451
455
  ],
452
456
  doc: this.props.value,
@@ -494,7 +498,7 @@ export class CypherEditor extends Component<
494
498
  const didChangeTheme =
495
499
  prevProps.theme !== this.props.theme ||
496
500
  prevProps.overrideThemeBackgroundColor !==
497
- this.props.overrideThemeBackgroundColor;
501
+ this.props.overrideThemeBackgroundColor;
498
502
 
499
503
  if (didChangeTheme) {
500
504
  this.editorView.current.dispatch({
@@ -204,14 +204,13 @@ test('Strikethroughs are shown for deprecated functions', async ({
204
204
  mount,
205
205
  }) => {
206
206
  const editorPage = new CypherEditorPage(page);
207
- const query = `RETURN id()`;
207
+ const query = `RETURN id(1)`;
208
208
 
209
209
  await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
210
210
  await expect(
211
211
  editorPage.page.locator('.cm-deprecated-element').last(),
212
212
  ).toBeVisible({ timeout: 10000 });
213
213
  await editorPage.checkWarningMessage('id', 'Function id is deprecated.');
214
- await editorPage.checkErrorMessage('id', `Insufficient parameters for function 'id'`);
215
214
  });
216
215
 
217
216
  test('Strikethroughs are shown for deprecated procedures', async ({
@@ -219,7 +218,7 @@ test('Strikethroughs are shown for deprecated procedures', async ({
219
218
  mount,
220
219
  }) => {
221
220
  const editorPage = new CypherEditorPage(page);
222
- const query = `CALL apoc.create.uuids()`;
221
+ const query = `CALL apoc.create.uuids(5)`;
223
222
 
224
223
  await mount(<CypherEditor value={query} schema={testData.mockSchema} />);
225
224
  await expect(