@neo4j-cypher/react-codemirror
Advanced tools
Comparing version 2.0.0-canary-245fb6a to 2.0.0-canary-255ec41
@@ -169,2 +169,6 @@ import { EditorState, Extension } from '@codemirror/state'; | ||
/** | ||
* Format Cypher query | ||
*/ | ||
format(): void; | ||
/** | ||
* Focus the editor | ||
@@ -171,0 +175,0 @@ */ |
@@ -5,2 +5,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { EditorView, keymap, lineNumbers, placeholder, } from '@codemirror/view'; | ||
import { formatQuery } from '@neo4j-cypher/language-support'; | ||
import debounce from 'lodash.debounce'; | ||
@@ -14,2 +15,14 @@ import { Component, createRef } from 'react'; | ||
import { getThemeExtension } from './themes'; | ||
const format = (view) => { | ||
const doc = view.state.doc.toString(); | ||
const { formattedString, newCursorPos } = formatQuery(doc, view.state.selection.main.anchor); | ||
view.dispatch({ | ||
changes: { | ||
from: 0, | ||
to: doc.length, | ||
insert: formattedString, | ||
}, | ||
selection: { anchor: newCursorPos }, | ||
}); | ||
}; | ||
const executeKeybinding = (onExecute, newLineOnEnter, flush) => { | ||
@@ -94,2 +107,8 @@ const keybindings = { | ||
/** | ||
* Format Cypher query | ||
*/ | ||
format() { | ||
format(this.editorView.current); | ||
} | ||
/** | ||
* Focus the editor | ||
@@ -96,0 +115,0 @@ */ |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.0.0-canary-245fb6a", | ||
"version": "2.0.0-canary-255ec41", | ||
"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-245fb6a", | ||
"@neo4j-cypher/language-support": "2.0.0-canary-255ec41", | ||
"@types/prismjs": "^1.26.3", | ||
@@ -58,0 +58,0 @@ "@types/workerpool": "^6.4.7", |
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
705195
9655
+ Added@neo4j-cypher/language-support@2.0.0-canary-255ec41(transitive)
- Removed@neo4j-cypher/language-support@2.0.0-canary-245fb6a(transitive)