@surrealdb/codemirror 1.0.0-beta.1 → 1.0.0-beta.3
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/README.md +79 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/surrealql.ts +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<br>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img width=120 src="https://raw.githubusercontent.com/surrealdb/icons/main/surreal.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h3 align="center">SurrealQL Support for CodeMirror</h3>
|
|
8
|
+
|
|
9
|
+
<br>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/surrealdb/surrealql-codemirror"><img src="https://img.shields.io/badge/status-beta-ff00bb.svg?style=flat-square"></a>
|
|
13
|
+
|
|
14
|
+
<a href="https://www.npmjs.com/package/@surrealdb/codemirror"><img src="https://img.shields.io/npm/v/%40surrealdb%2Fcodemirror?style=flat-square"></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://surrealdb.com/discord"><img src="https://img.shields.io/discord/902568124350599239?label=discord&style=flat-square&color=5a66f6"></a>
|
|
19
|
+
|
|
20
|
+
<a href="https://twitter.com/surrealdb"><img src="https://img.shields.io/badge/twitter-follow_us-1d9bf0.svg?style=flat-square"></a>
|
|
21
|
+
|
|
22
|
+
<a href="https://www.linkedin.com/company/surrealdb/"><img src="https://img.shields.io/badge/linkedin-connect_with_us-0a66c2.svg?style=flat-square"></a>
|
|
23
|
+
|
|
24
|
+
<a href="https://www.youtube.com/channel/UCjf2teVEuYVvvVC-gFZNq6w"><img src="https://img.shields.io/badge/youtube-subscribe-fc1c1c.svg?style=flat-square"></a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
# @surrealdb/codemirror
|
|
28
|
+
|
|
29
|
+
This library provides full support for the SurrealQL language within your CodeMirror editors.
|
|
30
|
+
|
|
31
|
+
Some features include:
|
|
32
|
+
- Intelligent SurrealQL highlighting
|
|
33
|
+
- Folding support for blocks, objects, and arrays
|
|
34
|
+
- Automatic indentation support
|
|
35
|
+
- Support for comment toggling
|
|
36
|
+
- Embedded JavaScript highlighting
|
|
37
|
+
|
|
38
|
+
## How to install
|
|
39
|
+
|
|
40
|
+
Install it with:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
# using npm
|
|
44
|
+
npm i @surrealdb/codemirror
|
|
45
|
+
# or using pnpm
|
|
46
|
+
pnpm i @surrealdb/codemirror
|
|
47
|
+
# or using yarn
|
|
48
|
+
yarn add @surrealdb/codemirror
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Next, just import it with:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
const { surrealql } = require("@surrealdb/codemirror");
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
or when you use modules:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { surrealql } from "@surrealdb/codemirror";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Example usage
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { surrealql } from "@surrealdb/codemirror";
|
|
67
|
+
|
|
68
|
+
const state = EditorState.create({
|
|
69
|
+
doc: "SELECT * FROM table",
|
|
70
|
+
extensions: [
|
|
71
|
+
surrealql()
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const editor = new EditorView({
|
|
76
|
+
parent: document.getElementById("editor"),
|
|
77
|
+
state: state,
|
|
78
|
+
});
|
|
79
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var language = require('@codemirror/language');
|
|
4
|
-
var
|
|
4
|
+
var lezer = require('@surrealdb/lezer');
|
|
5
5
|
var common = require('@lezer/common');
|
|
6
6
|
var javascript = require('@lezer/javascript');
|
|
7
7
|
|
|
8
8
|
const surrealqlLanguage = language.LRLanguage.define({
|
|
9
9
|
name: "surrealql",
|
|
10
|
-
parser:
|
|
10
|
+
parser: lezer.parser.configure({
|
|
11
11
|
props: [
|
|
12
12
|
language.indentNodeProp.add({
|
|
13
13
|
Object: language.continuedIndent({ except: /^\s*}/ }),
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
|
|
2
|
-
import { parser } from 'lezer
|
|
2
|
+
import { parser } from '@surrealdb/lezer';
|
|
3
3
|
import { parseMixed } from '@lezer/common';
|
|
4
4
|
import { parser as parser$1 } from '@lezer/javascript';
|
|
5
5
|
|
package/package.json
CHANGED
package/src/surrealql.ts
CHANGED