@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.
- package/CHANGELOG.md +20 -0
- package/dist/src/CypherEditor.d.ts +4 -2
- package/dist/src/CypherEditor.js +2 -2
- package/dist/src/CypherEditor.js.map +1 -1
- package/dist/src/CypherEditor.test.js +19 -11
- package/dist/src/CypherEditor.test.js.map +1 -1
- package/dist/src/e2e_tests/autoCompletion.spec.js +0 -1
- package/dist/src/e2e_tests/autoCompletion.spec.js.map +1 -1
- package/dist/src/e2e_tests/historyNavigation.spec.js.map +1 -1
- package/dist/src/e2e_tests/signatureHelp.spec.js +0 -1
- package/dist/src/e2e_tests/signatureHelp.spec.js.map +1 -1
- package/dist/src/editorActions.js +83 -18
- package/dist/src/editorActions.js.map +1 -1
- package/dist/src/historyNavigation.d.ts +1 -1
- package/dist/src/historyNavigation.js.map +1 -1
- package/dist/src/lang-cypher/autocomplete.d.ts +1 -1
- package/dist/src/lang-cypher/autocomplete.js +1 -1
- package/dist/src/lang-cypher/autocomplete.js.map +1 -1
- package/dist/src/lang-cypher/constants.d.ts +2 -2
- package/dist/src/lang-cypher/constants.js.map +1 -1
- package/dist/src/lang-cypher/createCypherTheme.d.ts +2 -2
- package/dist/src/lang-cypher/createCypherTheme.js +1 -1
- package/dist/src/lang-cypher/createCypherTheme.js.map +1 -1
- package/dist/src/lang-cypher/langCypher.d.ts +2 -1
- package/dist/src/lang-cypher/langCypher.js.map +1 -1
- package/dist/src/lang-cypher/lintWorker.mjs +144 -140
- package/dist/src/lang-cypher/parser-adapter.d.ts +6 -4
- package/dist/src/lang-cypher/parser-adapter.js +4 -1
- package/dist/src/lang-cypher/parser-adapter.js.map +1 -1
- package/dist/src/lang-cypher/prism-global.d.ts +1 -0
- package/dist/src/lang-cypher/prism-global.js +7 -0
- package/dist/src/lang-cypher/prism-global.js.map +1 -0
- package/dist/src/lang-cypher/signatureHelp.d.ts +2 -2
- package/dist/src/lang-cypher/signatureHelp.js +1 -1
- package/dist/src/lang-cypher/signatureHelp.js.map +1 -1
- package/dist/src/lang-cypher/syntaxValidation.d.ts +1 -1
- package/dist/src/lang-cypher/syntaxValidation.js +7 -2
- package/dist/src/lang-cypher/syntaxValidation.js.map +1 -1
- package/dist/src/neo4jSetup.d.ts +1 -1
- package/dist/src/neo4jSetup.js.map +1 -1
- package/dist/src/richClipboardCopier.js +2 -2
- package/dist/src/richClipboardCopier.js.map +1 -1
- package/dist/src/richClipboardCopier.test.js.map +1 -1
- package/dist/src/themes.d.ts +2 -2
- package/dist/src/themes.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/src/CypherEditor.test.tsx +27 -19
- package/src/CypherEditor.tsx +7 -16
- package/src/e2e_tests/autoCompletion.spec.tsx +0 -1
- package/src/e2e_tests/historyNavigation.spec.tsx +1 -1
- package/src/e2e_tests/signatureHelp.spec.tsx +1 -2
- package/src/editorActions.ts +103 -22
- package/src/historyNavigation.ts +5 -3
- package/src/lang-cypher/autocomplete.ts +3 -6
- package/src/lang-cypher/constants.ts +3 -2
- package/src/lang-cypher/createCypherTheme.ts +12 -10
- package/src/lang-cypher/langCypher.ts +2 -4
- package/src/lang-cypher/lintWorker.mjs +144 -140
- package/src/lang-cypher/parser-adapter.ts +10 -9
- package/src/lang-cypher/prism-global.ts +7 -0
- package/src/lang-cypher/signatureHelp.ts +7 -7
- package/src/lang-cypher/syntaxValidation.ts +9 -4
- package/src/neo4jSetup.tsx +3 -3
- package/src/richClipboardCopier.test.ts +7 -5
- package/src/richClipboardCopier.ts +2 -2
- package/src/themes.ts +2 -2
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Facet } from '@codemirror/state';
|
|
2
|
-
import { Input, NodeType,
|
|
3
|
-
import {
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
2
|
-
import {
|
|
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 (
|
|
68
|
-
|
|
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 [];
|
package/src/neo4jSetup.tsx
CHANGED
|
@@ -25,15 +25,15 @@ import {
|
|
|
25
25
|
syntaxHighlighting,
|
|
26
26
|
} from '@codemirror/language';
|
|
27
27
|
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
|
28
|
-
import {
|
|
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(
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
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
|
|