@neo4j-cypher/react-codemirror 1.0.2 → 2.0.0-alpha.0

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
@@ -1,58 +1,51 @@
1
1
  {
2
2
  "name": "@neo4j-cypher/react-codemirror",
3
- "description": "React CodeMirror 6 Cypher editor",
4
- "keywords": [
5
- "react",
6
- "cypher",
7
- "codemirror",
8
- "codemirror 6"
9
- ],
10
- "version": "1.0.2",
11
- "author": "Neo4j Inc.",
12
3
  "license": "Apache-2.0",
13
- "main": "./lib/react-codemirror.js",
14
- "module": "./es/react-codemirror.js",
15
- "exports": {
16
- ".": {
17
- "import": "./es/react-codemirror.js",
18
- "require": "./lib/react-codemirror.js"
19
- },
20
- "./src/react-codemirror.d.ts": {
21
- "import": "./src/react-codemirror.d.ts"
22
- },
23
- "./src/react-codemirror.js": {
24
- "import": "./src/react-codemirror.js"
25
- }
26
- },
27
- "types": "src/react-codemirror.d.ts",
28
- "repository": {
29
- "type": "git",
30
- "url": "git://github.com/neo4j/cypher-editor.git"
31
- },
32
- "bugs": {
33
- "url": "https://github.com/neo4j/cypher-editor/issues"
34
- },
35
- "scripts": {
36
- "build-lib": "babel --config-file ../../babel.react.config.js --extensions \".js\" --out-dir lib ./src",
37
- "build-es": "cross-env ES=true babel --config-file ../../babel.react.config.js --extensions \".js\" --out-dir es ./src",
38
- "build": "npm run build-lib && npm run build-es",
39
- "clean:build": "rimraf lib && rimraf es"
40
- },
41
4
  "files": [
42
- "src/*.d.ts",
43
- "es/",
44
- "lib/",
5
+ "dist",
6
+ "esm",
7
+ "package.json",
45
8
  "README.md"
46
9
  ],
47
- "engineStrict": true,
48
- "engines": {
49
- "node": ">=16"
10
+ "version": "2.0.0-alpha.0",
11
+ "main": "dist/index.cjs",
12
+ "module": "esm/index.mjs",
13
+ "sideEffects": false,
14
+ "scripts": {
15
+ "build": "concurrently \"npm:build-esm\" \"npm:build-commonjs\"",
16
+ "build-esm": "esbuild --bundle --format=esm --outfile=esm/index.mjs --packages=external src/index.ts",
17
+ "build-commonjs": "esbuild --bundle --format=cjs --outfile=dist/index.cjs --packages=external src/index.ts",
18
+ "test": "jest",
19
+ "test:e2e": "playwright test",
20
+ "e2e-http-server": "vite dev"
50
21
  },
51
22
  "dependencies": {
52
- "@babel/runtime": "^7.20.13",
53
- "@neo4j-cypher/codemirror": "1.0.2"
23
+ "@codemirror/autocomplete": "^6.5.1",
24
+ "@codemirror/commands": "^6.2.2",
25
+ "@codemirror/language": "^6.6.0",
26
+ "@codemirror/lint": "^6.2.2",
27
+ "@codemirror/search": "^6.5.0",
28
+ "@codemirror/state": "^6.2.1",
29
+ "@codemirror/view": "^6.13.2",
30
+ "@lezer/common": "^1.0.2",
31
+ "@lezer/highlight": "^1.1.3",
32
+ "@uiw/react-codemirror": "^4.19.9",
33
+ "ayu": "^8.0.1",
34
+ "fastest-levenshtein": "^1.0.16",
35
+ "react": "^18.2.0",
36
+ "vscode-languageserver-types": "^3.17.3"
54
37
  },
55
- "peerDependencies": {
56
- "react": ">=16"
38
+ "devDependencies": {
39
+ "@neo4j-ndl/base": "^1.10.1",
40
+ "@playwright/test": "^1.36.2",
41
+ "@types/react": "^18.0.28",
42
+ "@vitejs/plugin-react": "^3.1.0",
43
+ "concurrently": "^8.2.1",
44
+ "esbuild": "^0.19.4",
45
+ "lodash": "^4.17.21",
46
+ "playwright": "^1.36.2",
47
+ "typescript": "^4.9.3",
48
+ "vite": "^4.4.8",
49
+ "vite-plugin-node-stdlib-browser": "^0.2.1"
57
50
  }
58
51
  }
@@ -1,260 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import React, { Component } from "react";
3
- import { createCypherEditor, reactiveOptionKeys, defaultOptions } from "@neo4j-cypher/codemirror";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- class CypherEditor extends Component {
6
- constructor(props) {
7
- super(props);
8
- _defineProperty(this, "setEditorRef", ref => {
9
- this.editorRef = ref;
10
- });
11
- _defineProperty(this, "valueChanged", (value, changes) => {
12
- this.lastValue = value;
13
- const {
14
- onValueChanged
15
- } = this.props;
16
- onValueChanged && onValueChanged(value, changes);
17
- });
18
- _defineProperty(this, "focusChanged", focused => {
19
- const {
20
- onFocusChanged
21
- } = this.props;
22
- this.setState({
23
- focused
24
- });
25
- onFocusChanged && onFocusChanged(focused);
26
- });
27
- _defineProperty(this, "scrollChanged", scrollInfo => {
28
- const {
29
- onScrollChanged
30
- } = this.props;
31
- onScrollChanged && onScrollChanged(scrollInfo);
32
- });
33
- _defineProperty(this, "positionChanged", positionObject => {
34
- this.lastPosition = (positionObject || {
35
- position: null
36
- }).position;
37
- const {
38
- onPositionChanged
39
- } = this.props;
40
- onPositionChanged && onPositionChanged(positionObject);
41
- });
42
- _defineProperty(this, "selectionChanged", selection => {
43
- this.lastSelection = selection;
44
- const {
45
- onSelectionChanged
46
- } = this.props;
47
- onSelectionChanged && onSelectionChanged(selection);
48
- });
49
- _defineProperty(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
50
- const {
51
- onAutocompleteChanged
52
- } = this.props;
53
- onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
54
- });
55
- _defineProperty(this, "searchChanged", (searchOpen, text, matches) => {
56
- const {
57
- onSearchChanged
58
- } = this.props;
59
- onSearchChanged && onSearchChanged(searchOpen, text, matches);
60
- });
61
- _defineProperty(this, "lineNumberClick", (line, event) => {
62
- const {
63
- onLineNumberClick
64
- } = this.props;
65
- onLineNumberClick && onLineNumberClick(line, event);
66
- });
67
- _defineProperty(this, "keyDown", event => {
68
- const {
69
- onKeyDown
70
- } = this.props;
71
- onKeyDown && onKeyDown(event);
72
- });
73
- _defineProperty(this, "keyUp", event => {
74
- const {
75
- onKeyUp
76
- } = this.props;
77
- onKeyUp && onKeyUp(event);
78
- });
79
- this.state = {
80
- focused: false
81
- };
82
- this.lastValue = null;
83
- this.lastPosition = null;
84
- this.lastSelection = null;
85
- }
86
- componentDidMount() {
87
- const {
88
- autocomplete,
89
- autocompleteCloseOnBlur,
90
- autocompleteOpen,
91
- autocompleteTriggerStrings,
92
- autofocus,
93
- bracketMatching,
94
- closeBrackets,
95
- cursorWide,
96
- cypherLanguage,
97
- history,
98
- indentUnit,
99
- lineNumberFormatter,
100
- lineNumbers,
101
- lineWrapping,
102
- lint,
103
- placeholder,
104
- position,
105
- readOnly,
106
- readOnlyCursor,
107
- schema,
108
- search,
109
- searchMatches,
110
- searchOpen,
111
- searchText,
112
- searchTop,
113
- selection,
114
- tabKey,
115
- theme,
116
- tooltipAbsolute,
117
- parseOnSetValue,
118
- value,
119
- onEditorCreated,
120
- preExtensions,
121
- postExtensions
122
- } = this.props;
123
- this.value = value;
124
- const {
125
- editor
126
- } = createCypherEditor(this.editorRef, {
127
- autocomplete,
128
- autocompleteCloseOnBlur,
129
- autocompleteOpen,
130
- autocompleteTriggerStrings,
131
- autofocus,
132
- bracketMatching,
133
- closeBrackets,
134
- cursorWide,
135
- cypherLanguage,
136
- history,
137
- indentUnit,
138
- lineNumberFormatter,
139
- lineNumbers,
140
- lineWrapping,
141
- lint,
142
- placeholder,
143
- position,
144
- readOnly,
145
- readOnlyCursor,
146
- schema,
147
- search,
148
- searchMatches,
149
- searchOpen,
150
- searchText,
151
- searchTop,
152
- selection,
153
- tabKey,
154
- theme,
155
- tooltipAbsolute,
156
- parseOnSetValue,
157
- value,
158
- preExtensions,
159
- postExtensions
160
- });
161
- this.cypherEditor = editor;
162
- this.cypherEditor.onValueChanged(this.valueChanged);
163
- this.cypherEditor.onFocusChanged(this.focusChanged);
164
- this.cypherEditor.onScrollChanged(this.scrollChanged);
165
- this.cypherEditor.onPositionChanged(this.positionChanged);
166
- this.cypherEditor.onSelectionChanged(this.selectionChanged);
167
- this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
168
- this.cypherEditor.onSearchChanged(this.searchChanged);
169
- this.cypherEditor.onLineNumberClick(this.lineNumberClick);
170
- this.cypherEditor.onKeyDown(this.keyDown);
171
- this.cypherEditor.onKeyUp(this.keyUp);
172
- onEditorCreated && onEditorCreated(this.cypherEditor);
173
- }
174
- componentWillUnmount() {
175
- if (this.cypherEditor) {
176
- this.cypherEditor.offValueChanged(this.valueChanged);
177
- this.cypherEditor.offFocusChanged(this.focusChanged);
178
- this.cypherEditor.offScrollChanged(this.scrollChanged);
179
- this.cypherEditor.offPositionChanged(this.positionChanged);
180
- this.cypherEditor.offSelectionChanged(this.selectionChanged);
181
- this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
182
- this.cypherEditor.offSearchChanged(this.searchChanged);
183
- this.cypherEditor.offLineNumberClick(this.lineNumberClick);
184
- this.cypherEditor.offKeyDown(this.keyDown);
185
- this.cypherEditor.offKeyUp(this.keyUp);
186
- this.cypherEditor.destroy();
187
- }
188
- }
189
- componentDidUpdate(prevProps) {
190
- if (prevProps.value !== this.props.value) {
191
- this.value = this.props.value;
192
- }
193
- for (let key of reactiveOptionKeys) {
194
- if (prevProps[key] !== this.props[key]) {
195
- this.updateOption({
196
- [key]: this.props[key]
197
- });
198
- }
199
- }
200
- }
201
- updateOption(prop) {
202
- if (!this.cypherEditor) {
203
- return;
204
- }
205
- const key = Object.keys(prop).pop();
206
- if (key === "value") {
207
- if (prop[key] === this.lastValue) {
208
- return;
209
- } else {
210
- this.lastValue = prop[key];
211
- }
212
- }
213
- if (key === "position") {
214
- const {
215
- position
216
- } = this.cypherEditor.getPositionForValue(prop[key]) || {
217
- position: null
218
- };
219
- if (position === this.lastPosition) {
220
- return;
221
- } else {
222
- this.lastPosition = position;
223
- }
224
- }
225
- if (key === "selection") {
226
- if (prop[key] === this.lastSelection) {
227
- return;
228
- } else {
229
- this.lastSelection = prop[key];
230
- }
231
- }
232
- const methodName = "set" + key[0].toUpperCase() + key.slice(1);
233
- if (this.cypherEditor[methodName]) {
234
- this.cypherEditor[methodName](prop[key]);
235
- }
236
- const autofocusProps = this.props.autofocusProps !== undefined ? this.props.autofocusProps : defaultOptions.autofocusProps;
237
- if (autofocusProps.includes(key)) {
238
- this.cypherEditor.focus();
239
- }
240
- const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : defaultOptions.clearHistoryProps;
241
- if (clearHistoryProps.includes(key)) {
242
- this.cypherEditor.clearHistory();
243
- }
244
- }
245
- render() {
246
- const {
247
- className,
248
- focusedClassName
249
- } = this.props;
250
- const {
251
- focused
252
- } = this.state;
253
- const editorClassName = (className ? className + " " : "") + (focused && focusedClassName ? focusedClassName : "");
254
- return /*#__PURE__*/_jsx("div", {
255
- className: editorClassName,
256
- ref: this.setEditorRef
257
- });
258
- }
259
- }
260
- export default CypherEditor;
@@ -1 +0,0 @@
1
- export { default as CypherEditor } from "./CypherEditor";
@@ -1,270 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _codemirror = require("@neo4j-cypher/codemirror");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
- class CypherEditor extends _react.Component {
15
- constructor(props) {
16
- super(props);
17
- (0, _defineProperty2.default)(this, "setEditorRef", ref => {
18
- this.editorRef = ref;
19
- });
20
- (0, _defineProperty2.default)(this, "valueChanged", (value, changes) => {
21
- this.lastValue = value;
22
- const {
23
- onValueChanged
24
- } = this.props;
25
- onValueChanged && onValueChanged(value, changes);
26
- });
27
- (0, _defineProperty2.default)(this, "focusChanged", focused => {
28
- const {
29
- onFocusChanged
30
- } = this.props;
31
- this.setState({
32
- focused
33
- });
34
- onFocusChanged && onFocusChanged(focused);
35
- });
36
- (0, _defineProperty2.default)(this, "scrollChanged", scrollInfo => {
37
- const {
38
- onScrollChanged
39
- } = this.props;
40
- onScrollChanged && onScrollChanged(scrollInfo);
41
- });
42
- (0, _defineProperty2.default)(this, "positionChanged", positionObject => {
43
- this.lastPosition = (positionObject || {
44
- position: null
45
- }).position;
46
- const {
47
- onPositionChanged
48
- } = this.props;
49
- onPositionChanged && onPositionChanged(positionObject);
50
- });
51
- (0, _defineProperty2.default)(this, "selectionChanged", selection => {
52
- this.lastSelection = selection;
53
- const {
54
- onSelectionChanged
55
- } = this.props;
56
- onSelectionChanged && onSelectionChanged(selection);
57
- });
58
- (0, _defineProperty2.default)(this, "autocompleteChanged", (autocompleteOpen, options, option) => {
59
- const {
60
- onAutocompleteChanged
61
- } = this.props;
62
- onAutocompleteChanged && onAutocompleteChanged(autocompleteOpen, options, option);
63
- });
64
- (0, _defineProperty2.default)(this, "searchChanged", (searchOpen, text, matches) => {
65
- const {
66
- onSearchChanged
67
- } = this.props;
68
- onSearchChanged && onSearchChanged(searchOpen, text, matches);
69
- });
70
- (0, _defineProperty2.default)(this, "lineNumberClick", (line, event) => {
71
- const {
72
- onLineNumberClick
73
- } = this.props;
74
- onLineNumberClick && onLineNumberClick(line, event);
75
- });
76
- (0, _defineProperty2.default)(this, "keyDown", event => {
77
- const {
78
- onKeyDown
79
- } = this.props;
80
- onKeyDown && onKeyDown(event);
81
- });
82
- (0, _defineProperty2.default)(this, "keyUp", event => {
83
- const {
84
- onKeyUp
85
- } = this.props;
86
- onKeyUp && onKeyUp(event);
87
- });
88
- this.state = {
89
- focused: false
90
- };
91
- this.lastValue = null;
92
- this.lastPosition = null;
93
- this.lastSelection = null;
94
- }
95
- componentDidMount() {
96
- const {
97
- autocomplete,
98
- autocompleteCloseOnBlur,
99
- autocompleteOpen,
100
- autocompleteTriggerStrings,
101
- autofocus,
102
- bracketMatching,
103
- closeBrackets,
104
- cursorWide,
105
- cypherLanguage,
106
- history,
107
- indentUnit,
108
- lineNumberFormatter,
109
- lineNumbers,
110
- lineWrapping,
111
- lint,
112
- placeholder,
113
- position,
114
- readOnly,
115
- readOnlyCursor,
116
- schema,
117
- search,
118
- searchMatches,
119
- searchOpen,
120
- searchText,
121
- searchTop,
122
- selection,
123
- tabKey,
124
- theme,
125
- tooltipAbsolute,
126
- parseOnSetValue,
127
- value,
128
- onEditorCreated,
129
- preExtensions,
130
- postExtensions
131
- } = this.props;
132
- this.value = value;
133
- const {
134
- editor
135
- } = (0, _codemirror.createCypherEditor)(this.editorRef, {
136
- autocomplete,
137
- autocompleteCloseOnBlur,
138
- autocompleteOpen,
139
- autocompleteTriggerStrings,
140
- autofocus,
141
- bracketMatching,
142
- closeBrackets,
143
- cursorWide,
144
- cypherLanguage,
145
- history,
146
- indentUnit,
147
- lineNumberFormatter,
148
- lineNumbers,
149
- lineWrapping,
150
- lint,
151
- placeholder,
152
- position,
153
- readOnly,
154
- readOnlyCursor,
155
- schema,
156
- search,
157
- searchMatches,
158
- searchOpen,
159
- searchText,
160
- searchTop,
161
- selection,
162
- tabKey,
163
- theme,
164
- tooltipAbsolute,
165
- parseOnSetValue,
166
- value,
167
- preExtensions,
168
- postExtensions
169
- });
170
- this.cypherEditor = editor;
171
- this.cypherEditor.onValueChanged(this.valueChanged);
172
- this.cypherEditor.onFocusChanged(this.focusChanged);
173
- this.cypherEditor.onScrollChanged(this.scrollChanged);
174
- this.cypherEditor.onPositionChanged(this.positionChanged);
175
- this.cypherEditor.onSelectionChanged(this.selectionChanged);
176
- this.cypherEditor.onAutocompleteChanged(this.autocompleteChanged);
177
- this.cypherEditor.onSearchChanged(this.searchChanged);
178
- this.cypherEditor.onLineNumberClick(this.lineNumberClick);
179
- this.cypherEditor.onKeyDown(this.keyDown);
180
- this.cypherEditor.onKeyUp(this.keyUp);
181
- onEditorCreated && onEditorCreated(this.cypherEditor);
182
- }
183
- componentWillUnmount() {
184
- if (this.cypherEditor) {
185
- this.cypherEditor.offValueChanged(this.valueChanged);
186
- this.cypherEditor.offFocusChanged(this.focusChanged);
187
- this.cypherEditor.offScrollChanged(this.scrollChanged);
188
- this.cypherEditor.offPositionChanged(this.positionChanged);
189
- this.cypherEditor.offSelectionChanged(this.selectionChanged);
190
- this.cypherEditor.offAutocompleteChanged(this.autocompleteChanged);
191
- this.cypherEditor.offSearchChanged(this.searchChanged);
192
- this.cypherEditor.offLineNumberClick(this.lineNumberClick);
193
- this.cypherEditor.offKeyDown(this.keyDown);
194
- this.cypherEditor.offKeyUp(this.keyUp);
195
- this.cypherEditor.destroy();
196
- }
197
- }
198
- componentDidUpdate(prevProps) {
199
- if (prevProps.value !== this.props.value) {
200
- this.value = this.props.value;
201
- }
202
- for (let key of _codemirror.reactiveOptionKeys) {
203
- if (prevProps[key] !== this.props[key]) {
204
- this.updateOption({
205
- [key]: this.props[key]
206
- });
207
- }
208
- }
209
- }
210
- updateOption(prop) {
211
- if (!this.cypherEditor) {
212
- return;
213
- }
214
- const key = Object.keys(prop).pop();
215
- if (key === "value") {
216
- if (prop[key] === this.lastValue) {
217
- return;
218
- } else {
219
- this.lastValue = prop[key];
220
- }
221
- }
222
- if (key === "position") {
223
- const {
224
- position
225
- } = this.cypherEditor.getPositionForValue(prop[key]) || {
226
- position: null
227
- };
228
- if (position === this.lastPosition) {
229
- return;
230
- } else {
231
- this.lastPosition = position;
232
- }
233
- }
234
- if (key === "selection") {
235
- if (prop[key] === this.lastSelection) {
236
- return;
237
- } else {
238
- this.lastSelection = prop[key];
239
- }
240
- }
241
- const methodName = "set" + key[0].toUpperCase() + key.slice(1);
242
- if (this.cypherEditor[methodName]) {
243
- this.cypherEditor[methodName](prop[key]);
244
- }
245
- const autofocusProps = this.props.autofocusProps !== undefined ? this.props.autofocusProps : _codemirror.defaultOptions.autofocusProps;
246
- if (autofocusProps.includes(key)) {
247
- this.cypherEditor.focus();
248
- }
249
- const clearHistoryProps = this.props.clearHistoryProps !== undefined ? this.props.clearHistoryProps : _codemirror.defaultOptions.clearHistoryProps;
250
- if (clearHistoryProps.includes(key)) {
251
- this.cypherEditor.clearHistory();
252
- }
253
- }
254
- render() {
255
- const {
256
- className,
257
- focusedClassName
258
- } = this.props;
259
- const {
260
- focused
261
- } = this.state;
262
- const editorClassName = (className ? className + " " : "") + (focused && focusedClassName ? focusedClassName : "");
263
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
264
- className: editorClassName,
265
- ref: this.setEditorRef
266
- });
267
- }
268
- }
269
- var _default = CypherEditor;
270
- exports.default = _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "CypherEditor", {
8
- enumerable: true,
9
- get: function () {
10
- return _CypherEditor.default;
11
- }
12
- });
13
- var _CypherEditor = _interopRequireDefault(require("./CypherEditor"));