@neo4j-cypher/react-codemirror 2.0.0-next.40 → 2.0.0-next.41

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 (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/CypherEditor.d.ts +4 -2
  3. package/dist/src/CypherEditor.js +2 -2
  4. package/dist/src/CypherEditor.js.map +1 -1
  5. package/dist/src/CypherEditor.test.js +19 -11
  6. package/dist/src/CypherEditor.test.js.map +1 -1
  7. package/dist/src/e2e_tests/autoCompletion.spec.js +0 -1
  8. package/dist/src/e2e_tests/autoCompletion.spec.js.map +1 -1
  9. package/dist/src/e2e_tests/historyNavigation.spec.js.map +1 -1
  10. package/dist/src/e2e_tests/signatureHelp.spec.js +0 -1
  11. package/dist/src/e2e_tests/signatureHelp.spec.js.map +1 -1
  12. package/dist/src/editorActions.js +83 -18
  13. package/dist/src/editorActions.js.map +1 -1
  14. package/dist/src/historyNavigation.d.ts +1 -1
  15. package/dist/src/historyNavigation.js.map +1 -1
  16. package/dist/src/lang-cypher/autocomplete.d.ts +1 -1
  17. package/dist/src/lang-cypher/autocomplete.js +1 -1
  18. package/dist/src/lang-cypher/autocomplete.js.map +1 -1
  19. package/dist/src/lang-cypher/constants.d.ts +2 -2
  20. package/dist/src/lang-cypher/constants.js.map +1 -1
  21. package/dist/src/lang-cypher/createCypherTheme.d.ts +2 -2
  22. package/dist/src/lang-cypher/createCypherTheme.js +1 -1
  23. package/dist/src/lang-cypher/createCypherTheme.js.map +1 -1
  24. package/dist/src/lang-cypher/langCypher.d.ts +2 -1
  25. package/dist/src/lang-cypher/langCypher.js.map +1 -1
  26. package/dist/src/lang-cypher/lintWorker.mjs +144 -140
  27. package/dist/src/lang-cypher/parser-adapter.d.ts +6 -4
  28. package/dist/src/lang-cypher/parser-adapter.js +4 -1
  29. package/dist/src/lang-cypher/parser-adapter.js.map +1 -1
  30. package/dist/src/lang-cypher/prism-global.d.ts +1 -0
  31. package/dist/src/lang-cypher/prism-global.js +7 -0
  32. package/dist/src/lang-cypher/prism-global.js.map +1 -0
  33. package/dist/src/lang-cypher/signatureHelp.d.ts +2 -2
  34. package/dist/src/lang-cypher/signatureHelp.js +1 -1
  35. package/dist/src/lang-cypher/signatureHelp.js.map +1 -1
  36. package/dist/src/lang-cypher/syntaxValidation.d.ts +1 -1
  37. package/dist/src/lang-cypher/syntaxValidation.js +7 -2
  38. package/dist/src/lang-cypher/syntaxValidation.js.map +1 -1
  39. package/dist/src/neo4jSetup.d.ts +1 -1
  40. package/dist/src/neo4jSetup.js.map +1 -1
  41. package/dist/src/richClipboardCopier.js +2 -2
  42. package/dist/src/richClipboardCopier.js.map +1 -1
  43. package/dist/src/richClipboardCopier.test.js.map +1 -1
  44. package/dist/src/themes.d.ts +2 -2
  45. package/dist/src/themes.js.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +12 -10
  48. package/src/CypherEditor.test.tsx +27 -19
  49. package/src/CypherEditor.tsx +7 -16
  50. package/src/e2e_tests/autoCompletion.spec.tsx +0 -1
  51. package/src/e2e_tests/historyNavigation.spec.tsx +1 -1
  52. package/src/e2e_tests/signatureHelp.spec.tsx +1 -2
  53. package/src/editorActions.ts +103 -22
  54. package/src/historyNavigation.ts +5 -3
  55. package/src/lang-cypher/autocomplete.ts +3 -6
  56. package/src/lang-cypher/constants.ts +3 -2
  57. package/src/lang-cypher/createCypherTheme.ts +12 -10
  58. package/src/lang-cypher/langCypher.ts +2 -4
  59. package/src/lang-cypher/lintWorker.mjs +144 -140
  60. package/src/lang-cypher/parser-adapter.ts +10 -9
  61. package/src/lang-cypher/prism-global.ts +7 -0
  62. package/src/lang-cypher/signatureHelp.ts +7 -7
  63. package/src/lang-cypher/syntaxValidation.ts +9 -4
  64. package/src/neo4jSetup.tsx +3 -3
  65. package/src/richClipboardCopier.test.ts +7 -5
  66. package/src/richClipboardCopier.ts +2 -2
  67. package/src/themes.ts +2 -2
@@ -1,16 +1,17 @@
1
- import { Facet } from '@codemirror/state';
2
- import { Input, NodeType, Parser, PartialParse, Tree } from '@lezer/common';
3
- import { ParsedCypherToken } from '@neo4j-cypher/language-support';
1
+ import type { Facet } from '@codemirror/state';
2
+ import type { Input, NodeType, PartialParse } from '@lezer/common';
3
+ import { Parser, Tree } from '@lezer/common';
4
+ import type { ParsedCypherToken } from '@neo4j-cypher/language-support';
4
5
 
5
6
  import Prism from 'prismjs';
6
- import {
7
- CodemirrorParseTokenType,
8
- cypherTokenTypeToNode,
9
- parserAdapterNodeSet,
10
- } from './constants';
7
+ import type { CodemirrorParseTokenType } from './constants';
8
+ import { cypherTokenTypeToNode, parserAdapterNodeSet } from './constants';
9
+ // Must come before prism-cypher: it publishes the global `Prism` that the
10
+ // component script assigns onto.
11
+ import './prism-global.js';
11
12
  // This import will load the cypher support in prisma
12
13
  import 'prismjs/components/prism-cypher';
13
- import { CypherConfig } from './langCypher';
14
+ import type { CypherConfig } from './langCypher';
14
15
 
15
16
  const DEFAULT_NODE_GROUP_SIZE = 4;
16
17
  Prism.manual = true;
@@ -0,0 +1,7 @@
1
+ import Prism from 'prismjs';
2
+
3
+ // `prismjs/components/prism-cypher` (used in parser-adapter) is a plain script that mutates the global
4
+ // `Prism`. Bundlers keep prismjs' CJS core lazy and may evaluate the component
5
+ // before the core has run, so force the core to initialise (and publish the
6
+ // global) from a module that is imported first.
7
+ (globalThis as { Prism?: typeof Prism }).Prism = Prism;
@@ -1,10 +1,10 @@
1
- import { EditorState, StateField } from '@codemirror/state';
2
- import { showTooltip, Tooltip } from '@codemirror/view';
3
- import {
4
- MarkupContent,
5
- SignatureInformation,
6
- } from 'vscode-languageserver-types';
7
- import { CypherConfig } from './langCypher';
1
+ import type { EditorState } from '@codemirror/state';
2
+ import { StateField } from '@codemirror/state';
3
+ import type { Tooltip } from '@codemirror/view';
4
+ import { showTooltip } from '@codemirror/view';
5
+ import type { SignatureInformation } from 'vscode-languageserver-types';
6
+ import { MarkupContent } from 'vscode-languageserver-types';
7
+ import type { CypherConfig } from './langCypher';
8
8
  import { getDocString } from './utils';
9
9
 
10
10
  function getTriggerCharacter(query: string, caretPosition: number) {
@@ -1,5 +1,6 @@
1
- import { Diagnostic, linter } from '@codemirror/lint';
2
- import { Extension } from '@codemirror/state';
1
+ import type { Diagnostic } from '@codemirror/lint';
2
+ import { linter } from '@codemirror/lint';
3
+ import type { Extension } from '@codemirror/state';
3
4
  import { DiagnosticSeverity, DiagnosticTag } from 'vscode-languageserver-types';
4
5
  import workerpool from 'workerpool';
5
6
  import type { CypherConfig } from './langCypher';
@@ -64,8 +65,12 @@ export const cypherLinter: (config: CypherConfig) => Extension = (config) =>
64
65
  }
65
66
  return a;
66
67
  } catch (err) {
67
- if (!String(err).includes('Worker terminated')) {
68
- console.error(String(err) + ' ' + query);
68
+ if (err instanceof Error) {
69
+ if (!err.message.includes('Worker terminated')) {
70
+ console.error(String(err) + ' ' + query);
71
+ }
72
+ } else {
73
+ console.error(JSON.stringify(err));
69
74
  }
70
75
  }
71
76
  return [];
@@ -25,15 +25,15 @@ import {
25
25
  syntaxHighlighting,
26
26
  } from '@codemirror/language';
27
27
  import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
28
- import { EditorState, Extension, StateCommand } from '@codemirror/state';
28
+ import type { Extension, StateCommand } from '@codemirror/state';
29
+ import { EditorState } from '@codemirror/state';
30
+ import type { Command, KeyBinding } from '@codemirror/view';
29
31
  import {
30
- Command,
31
32
  crosshairCursor,
32
33
  drawSelection,
33
34
  dropCursor,
34
35
  EditorView,
35
36
  highlightSpecialChars,
36
- KeyBinding,
37
37
  keymap,
38
38
  rectangularSelection,
39
39
  } from '@codemirror/view';
@@ -1,6 +1,6 @@
1
1
  // @vitest-environment jsdom
2
2
  import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import { EditorView } from '@codemirror/view';
3
+ import type { EditorView } from '@codemirror/view';
4
4
  import { getHTML, getCSSStyleForClass } from './richClipboardCopier';
5
5
 
6
6
  function createStyleSheet(rules: string): CSSStyleSheet {
@@ -47,10 +47,12 @@ describe('getHTML', () => {
47
47
  document.body.appendChild(wrapper);
48
48
 
49
49
  const mockView = {
50
- domAtPos: vi.fn((pos: number) => ({
51
- node: wrapper,
52
- offset: pos === 0 ? 0 : 1,
53
- })),
50
+ domAtPos: vi.fn<(pos: number) => { node: Node; offset: number }>(
51
+ (pos) => ({
52
+ node: wrapper,
53
+ offset: pos === 0 ? 0 : 1,
54
+ }),
55
+ ),
54
56
  } as unknown as EditorView;
55
57
 
56
58
  const html = getHTML(mockView, 0, 1);
@@ -3,8 +3,8 @@ import { EditorView } from '@codemirror/view';
3
3
  export function getCSSStyleForClass(className: string): string {
4
4
  return Array.from(document.styleSheets).reduce((cssText, sheet) => {
5
5
  try {
6
- const rules = sheet.cssRules ?? [];
7
- for (const rule of Array.from(rules)) {
6
+ const rules = Array.from(sheet.cssRules ?? []);
7
+ for (const rule of rules) {
8
8
  if (
9
9
  rule instanceof CSSStyleRule &&
10
10
  rule.selectorText
package/src/themes.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Extension } from '@codemirror/state';
1
+ import type { Extension } from '@codemirror/state';
2
+ import type { ThemeOptions } from './lang-cypher/createCypherTheme';
2
3
  import {
3
4
  createCypherTheme,
4
5
  type DiffColors,
5
- ThemeOptions,
6
6
  } from './lang-cypher/createCypherTheme';
7
7
  import { tokens } from './ndlTokensCopy';
8
8