@neo4j-cypher/react-codemirror
Advanced tools
Comparing version 2.0.0-canary-af87a8b to 2.0.0-canary-b08f11e
# @neo4j-cypher/react-codemirror | ||
## 2.0.0-next.12 | ||
### Patch Changes | ||
- dcbe67d: Expose moveFocusOnTab property on the CypherEditor component to conditionally disable tab keymappings | ||
- e9621c8: Re-export language support from react codemirror | ||
- Updated dependencies [2e72ac8] | ||
- @neo4j-cypher/language-support@2.0.0-next.9 | ||
## 2.0.0-next.11 | ||
### Patch Changes | ||
- Updated dependencies [05663bd] | ||
- @neo4j-cypher/language-support@2.0.0-next.8 | ||
## 2.0.0-next.10 | ||
### Patch Changes | ||
- bb7e9d3: Simplify detection and handling of value prop updates | ||
## 2.0.0-next.9 | ||
@@ -4,0 +26,0 @@ |
@@ -138,5 +138,14 @@ import { EditorState, Extension } from '@codemirror/state'; | ||
/** | ||
* String value to assign to the aria-label attribute of the editor | ||
* String value to assign to the aria-label attribute of the editor. | ||
*/ | ||
ariaLabel?: string; | ||
/** | ||
* Whether keybindings for inserting indents with the Tab key should be disabled. | ||
* | ||
* true will not create keybindings for inserting indents. | ||
* false will create keybindings for inserting indents. | ||
* | ||
* @default false | ||
*/ | ||
moveFocusOnTab?: boolean; | ||
} | ||
@@ -143,0 +152,0 @@ type CypherEditorState = { |
@@ -132,2 +132,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
newLineOnEnter: false, | ||
moveFocusOnTab: false, | ||
}; | ||
@@ -176,3 +177,3 @@ debouncedOnChange = this.props.onChange | ||
historyNavigation(this.props), | ||
basicNeo4jSetup(), | ||
basicNeo4jSetup(this.props), | ||
themeCompartment.of(themeExtension), | ||
@@ -179,0 +180,0 @@ changeListener, |
import { jsx as _jsx } from "react/jsx-runtime"; | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
import { testData } from '@neo4j-cypher/language-support'; | ||
@@ -6,2 +7,3 @@ import { expect, test } from '@playwright/experimental-ct-react'; | ||
test.use({ viewport: { width: 1000, height: 500 } }); | ||
const importCsvProc = testData.mockSchema.procedures['apoc.import.csv']; | ||
function testTooltip(tooltip, expectations) { | ||
@@ -42,4 +44,5 @@ const includes = expectations.includes ?? []; | ||
includes: [ | ||
'nodes :: LIST<MAP>', | ||
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file', | ||
testData.mockSchema.procedures['apoc.import.csv'].argumentDescription[0] | ||
.description, | ||
testData.mockSchema.procedures['apoc.import.csv'].description, | ||
], | ||
@@ -54,4 +57,4 @@ }); | ||
includes: [ | ||
'nodes :: LIST<MAP>', | ||
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file', | ||
importCsvProc.argumentDescription[0].description, | ||
importCsvProc.description, | ||
], | ||
@@ -66,4 +69,4 @@ }); | ||
includes: [ | ||
'rels :: LIST<MAP>', | ||
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file', | ||
importCsvProc.argumentDescription[1].description, | ||
importCsvProc.description, | ||
], | ||
@@ -78,4 +81,4 @@ }); | ||
includes: [ | ||
'rels :: LIST<MAP>', | ||
'Imports `NODE` and `RELATIONSHIP` values with the given labels and types from the provided CSV file', | ||
importCsvProc.argumentDescription[1].description, | ||
importCsvProc.description, | ||
], | ||
@@ -82,0 +85,0 @@ }); |
@@ -1,4 +0,4 @@ | ||
export { CypherParser, _internalFeatureFlags, } from '@neo4j-cypher/language-support'; | ||
export * as LanguageSupport from '@neo4j-cypher/language-support'; | ||
export { CypherEditor } from './CypherEditor'; | ||
export { cypher } from './lang-cypher/langCypher'; | ||
export { darkThemeConstants, lightThemeConstants } from './themes'; |
@@ -1,2 +0,2 @@ | ||
export { CypherParser, _internalFeatureFlags, } from '@neo4j-cypher/language-support'; | ||
export * as LanguageSupport from '@neo4j-cypher/language-support'; | ||
export { CypherEditor } from './CypherEditor'; | ||
@@ -3,0 +3,0 @@ export { cypher } from './lang-cypher/langCypher'; |
@@ -79,2 +79,5 @@ import { HighlightStyle, syntaxHighlighting, } from '@codemirror/language'; | ||
}, | ||
'& .cm-signature-help-panel-arg-description': { | ||
padding: '5px', | ||
}, | ||
'& .cm-signature-help-panel-description': { | ||
@@ -81,0 +84,0 @@ padding: '5px', |
import { StateField } from '@codemirror/state'; | ||
import { showTooltip } from '@codemirror/view'; | ||
import { signatureHelp } from '@neo4j-cypher/language-support'; | ||
import { MarkupContent, } from 'vscode-languageserver-types'; | ||
import { getDocString } from './utils'; | ||
@@ -25,7 +26,10 @@ function getTriggerCharacter(query, caretPosition) { | ||
signatureLabel.className = 'cm-signature-help-panel-name'; | ||
signatureLabel.appendChild(document.createTextNode(`${signature.label}(`)); | ||
const methodName = signature.label.slice(0, signature.label.indexOf('(')); | ||
const returnType = signature.label.slice(signature.label.indexOf(')') + 1); | ||
signatureLabel.appendChild(document.createTextNode(`${methodName}(`)); | ||
let currentParamDescription = undefined; | ||
parameters.forEach((param, index) => { | ||
if (typeof param.documentation === 'string') { | ||
if (typeof param.label === 'string') { | ||
const span = document.createElement('span'); | ||
span.appendChild(document.createTextNode(param.documentation)); | ||
span.appendChild(document.createTextNode(param.label)); | ||
if (index !== parameters.length - 1) { | ||
@@ -36,2 +40,6 @@ span.appendChild(document.createTextNode(', ')); | ||
span.className = 'cm-signature-help-panel-current-argument'; | ||
const paramDoc = param.documentation; | ||
currentParamDescription = MarkupContent.is(paramDoc) | ||
? paramDoc.value | ||
: paramDoc; | ||
} | ||
@@ -42,2 +50,3 @@ signatureLabel.appendChild(span); | ||
signatureLabel.appendChild(document.createTextNode(')')); | ||
signatureLabel.appendChild(document.createTextNode(returnType)); | ||
contents.appendChild(signatureLabel); | ||
@@ -47,6 +56,12 @@ const separator = document.createElement('div'); | ||
contents.appendChild(separator); | ||
const description = document.createElement('div'); | ||
description.className = 'cm-signature-help-panel-description'; | ||
description.appendChild(document.createTextNode(doc)); | ||
contents.appendChild(description); | ||
if (currentParamDescription !== undefined) { | ||
const argDescription = document.createElement('div'); | ||
argDescription.className = 'cm-signature-help-panel-arg-description'; | ||
argDescription.appendChild(document.createTextNode(currentParamDescription)); | ||
contents.appendChild(argDescription); | ||
} | ||
const methodDescription = document.createElement('div'); | ||
methodDescription.className = 'cm-signature-help-panel-description'; | ||
methodDescription.appendChild(document.createTextNode(doc)); | ||
contents.appendChild(methodDescription); | ||
return { dom }; | ||
@@ -53,0 +68,0 @@ }; |
@@ -38,4 +38,3 @@ import { linter } from '@codemirror/lint'; | ||
const statements = parse.statementsParsing; | ||
const anySyntacticError = statements.filter((statement) => statement.diagnostics.length !== 0) | ||
.length > 0; | ||
const anySyntacticError = statements.some((statement) => statement.syntaxErrors.length !== 0); | ||
if (anySyntacticError) { | ||
@@ -42,0 +41,0 @@ return []; |
import { Extension } from '@codemirror/state'; | ||
export declare const basicNeo4jSetup: () => Extension[]; | ||
type SetupProps = { | ||
moveFocusOnTab?: boolean; | ||
}; | ||
export declare const basicNeo4jSetup: ({ moveFocusOnTab, }: SetupProps) => Extension[]; | ||
export {}; |
@@ -27,3 +27,3 @@ import { acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completionKeymap, nextSnippetField, prevSnippetField, snippetKeymap, } from '@codemirror/autocomplete'; | ||
}; | ||
export const basicNeo4jSetup = () => { | ||
export const basicNeo4jSetup = ({ moveFocusOnTab = false, }) => { | ||
const keymaps = [ | ||
@@ -37,18 +37,18 @@ closeBracketsKeymap, | ||
lintKeymap, | ||
{ | ||
].flat(); | ||
if (!moveFocusOnTab) { | ||
keymaps.push({ | ||
key: 'Tab', | ||
preventDefault: true, | ||
run: acceptCompletion, | ||
}, | ||
{ | ||
}, { | ||
key: 'Tab', | ||
preventDefault: true, | ||
run: insertTab, | ||
}, | ||
{ | ||
}, { | ||
key: 'Shift-Tab', | ||
preventDefault: true, | ||
run: indentLess, | ||
}, | ||
].flat(); | ||
}); | ||
} | ||
const extensions = []; | ||
@@ -55,0 +55,0 @@ extensions.push(highlightSpecialChars()); |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.0.0-canary-af87a8b", | ||
"version": "2.0.0-canary-b08f11e", | ||
"main": "./dist/index.js", | ||
@@ -55,3 +55,3 @@ "types": "./dist/index.d.ts", | ||
"@lezer/highlight": "^1.1.3", | ||
"@neo4j-cypher/language-support": "2.0.0-canary-af87a8b", | ||
"@neo4j-cypher/language-support": "2.0.0-canary-b08f11e", | ||
"@types/prismjs": "^1.26.3", | ||
@@ -58,0 +58,0 @@ "@types/workerpool": "^6.4.7", |
@@ -1,7 +0,4 @@ | ||
export { | ||
CypherParser, | ||
_internalFeatureFlags, | ||
} from '@neo4j-cypher/language-support'; | ||
export * as LanguageSupport from '@neo4j-cypher/language-support'; | ||
export { CypherEditor } from './CypherEditor'; | ||
export { cypher } from './lang-cypher/langCypher'; | ||
export { darkThemeConstants, lightThemeConstants } from './themes'; |
@@ -124,2 +124,5 @@ import { | ||
}, | ||
'& .cm-signature-help-panel-arg-description': { | ||
padding: '5px', | ||
}, | ||
'& .cm-signature-help-panel-description': { | ||
@@ -126,0 +129,0 @@ padding: '5px', |
import { EditorState, StateField } from '@codemirror/state'; | ||
import { showTooltip, Tooltip } from '@codemirror/view'; | ||
import { signatureHelp } from '@neo4j-cypher/language-support'; | ||
import { SignatureInformation } from 'vscode-languageserver-types'; | ||
import { | ||
MarkupContent, | ||
SignatureInformation, | ||
} from 'vscode-languageserver-types'; | ||
import { CypherConfig } from './langCypher'; | ||
@@ -41,8 +44,11 @@ import { getDocString } from './utils'; | ||
signatureLabel.className = 'cm-signature-help-panel-name'; | ||
signatureLabel.appendChild(document.createTextNode(`${signature.label}(`)); | ||
const methodName = signature.label.slice(0, signature.label.indexOf('(')); | ||
const returnType = signature.label.slice(signature.label.indexOf(')') + 1); | ||
signatureLabel.appendChild(document.createTextNode(`${methodName}(`)); | ||
let currentParamDescription: string | undefined = undefined; | ||
parameters.forEach((param, index) => { | ||
if (typeof param.documentation === 'string') { | ||
if (typeof param.label === 'string') { | ||
const span = document.createElement('span'); | ||
span.appendChild(document.createTextNode(param.documentation)); | ||
span.appendChild(document.createTextNode(param.label)); | ||
if (index !== parameters.length - 1) { | ||
@@ -54,2 +60,6 @@ span.appendChild(document.createTextNode(', ')); | ||
span.className = 'cm-signature-help-panel-current-argument'; | ||
const paramDoc = param.documentation; | ||
currentParamDescription = MarkupContent.is(paramDoc) | ||
? paramDoc.value | ||
: paramDoc; | ||
} | ||
@@ -61,2 +71,3 @@ signatureLabel.appendChild(span); | ||
signatureLabel.appendChild(document.createTextNode(')')); | ||
signatureLabel.appendChild(document.createTextNode(returnType)); | ||
@@ -70,8 +81,15 @@ contents.appendChild(signatureLabel); | ||
const description = document.createElement('div'); | ||
description.className = 'cm-signature-help-panel-description'; | ||
description.appendChild(document.createTextNode(doc)); | ||
if (currentParamDescription !== undefined) { | ||
const argDescription = document.createElement('div'); | ||
argDescription.className = 'cm-signature-help-panel-arg-description'; | ||
argDescription.appendChild( | ||
document.createTextNode(currentParamDescription), | ||
); | ||
contents.appendChild(argDescription); | ||
} | ||
const methodDescription = document.createElement('div'); | ||
methodDescription.className = 'cm-signature-help-panel-description'; | ||
methodDescription.appendChild(document.createTextNode(doc)); | ||
contents.appendChild(methodDescription); | ||
contents.appendChild(description); | ||
return { dom }; | ||
@@ -78,0 +96,0 @@ }; |
@@ -57,5 +57,5 @@ import { Diagnostic, linter } from '@codemirror/lint'; | ||
const anySyntacticError = | ||
statements.filter((statement) => statement.diagnostics.length !== 0) | ||
.length > 0; | ||
const anySyntacticError = statements.some( | ||
(statement) => statement.syntaxErrors.length !== 0, | ||
); | ||
@@ -62,0 +62,0 @@ if (anySyntacticError) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
674858
9010
+ Added@neo4j-cypher/language-support@2.0.0-canary-b08f11e(transitive)
- Removed@neo4j-cypher/language-support@2.0.0-canary-af87a8b(transitive)