@surrealdb/codemirror 1.0.0-beta.8 → 1.0.0-beta.9

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/dist/index.cjs CHANGED
@@ -27,21 +27,26 @@ const surrealqlLanguage = language.LRLanguage.define({
27
27
  commentTokens: { line: "--" },
28
28
  },
29
29
  });
30
- const languageMap = new Map([
31
- ["default", surrealqlLanguage.configure({ top: "SurrealQL" })],
32
- ["permission", surrealqlLanguage.configure({ top: "PermissionInput" })],
33
- ["combined-results", surrealqlLanguage.configure({ top: "CombinedResults" })],
34
- ["syntax", surrealqlLanguage.configure({ top: "Syntax" })],
30
+ const scopeMap = new Map([
31
+ ["permission", "PermissionInput"],
32
+ ["index", "IndexInput"],
33
+ ["combined-results", "CombinedResults"],
34
+ ["syntax", "Syntax"],
35
35
  ]);
36
36
  /**
37
37
  * The CodeMirror extension used to add support for the SurrealQL language
38
+ *
39
+ * @param scope Limit the scope of the highlighting
38
40
  */
39
- function surrealql(scope = "default") {
40
- const language$1 = languageMap.get(scope);
41
- if (!language$1) {
41
+ function surrealql(scope) {
42
+ if (!scope) {
43
+ return new language.LanguageSupport(surrealqlLanguage);
44
+ }
45
+ const scopeId = scopeMap.get(scope);
46
+ if (!scopeId) {
42
47
  throw new Error(`Unknown language scope: ${scope}`);
43
48
  }
44
- return new language.LanguageSupport(language$1);
49
+ return new language.LanguageSupport(surrealqlLanguage.configure({ top: scopeId }));
45
50
  }
46
51
 
47
52
  exports.surrealql = surrealql;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { LRLanguage, LanguageSupport } from '@codemirror/language';
2
2
 
3
3
  declare const surrealqlLanguage: LRLanguage;
4
- type Scope = "default" | "permission" | "combined-results" | "syntax";
4
+ type Scope = "permission" | "index" | "combined-results" | "syntax";
5
5
  /**
6
6
  * The CodeMirror extension used to add support for the SurrealQL language
7
+ *
8
+ * @param scope Limit the scope of the highlighting
7
9
  */
8
10
  declare function surrealql(scope?: Scope): LanguageSupport;
9
11
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { LRLanguage, LanguageSupport } from '@codemirror/language';
2
2
 
3
3
  declare const surrealqlLanguage: LRLanguage;
4
- type Scope = "default" | "permission" | "combined-results" | "syntax";
4
+ type Scope = "permission" | "index" | "combined-results" | "syntax";
5
5
  /**
6
6
  * The CodeMirror extension used to add support for the SurrealQL language
7
+ *
8
+ * @param scope Limit the scope of the highlighting
7
9
  */
8
10
  declare function surrealql(scope?: Scope): LanguageSupport;
9
11
 
package/dist/index.js CHANGED
@@ -25,21 +25,26 @@ const surrealqlLanguage = /*@__PURE__*/LRLanguage.define({
25
25
  commentTokens: { line: "--" },
26
26
  },
27
27
  });
28
- const languageMap = /*@__PURE__*/new Map([
29
- ["default", /*@__PURE__*/surrealqlLanguage.configure({ top: "SurrealQL" })],
30
- ["permission", /*@__PURE__*/surrealqlLanguage.configure({ top: "PermissionInput" })],
31
- ["combined-results", /*@__PURE__*/surrealqlLanguage.configure({ top: "CombinedResults" })],
32
- ["syntax", /*@__PURE__*/surrealqlLanguage.configure({ top: "Syntax" })],
28
+ const scopeMap = /*@__PURE__*/new Map([
29
+ ["permission", "PermissionInput"],
30
+ ["index", "IndexInput"],
31
+ ["combined-results", "CombinedResults"],
32
+ ["syntax", "Syntax"],
33
33
  ]);
34
34
  /**
35
35
  * The CodeMirror extension used to add support for the SurrealQL language
36
+ *
37
+ * @param scope Limit the scope of the highlighting
36
38
  */
37
- function surrealql(scope = "default") {
38
- const language = languageMap.get(scope);
39
- if (!language) {
39
+ function surrealql(scope) {
40
+ if (!scope) {
41
+ return new LanguageSupport(surrealqlLanguage);
42
+ }
43
+ const scopeId = scopeMap.get(scope);
44
+ if (!scopeId) {
40
45
  throw new Error(`Unknown language scope: ${scope}`);
41
46
  }
42
- return new LanguageSupport(language);
47
+ return new LanguageSupport(surrealqlLanguage.configure({ top: scopeId }));
43
48
  }
44
49
 
45
50
  export { surrealql, surrealqlLanguage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surrealdb/codemirror",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-beta.9",
4
4
  "author": "SurrealDB",
5
5
  "description": "SurrealQL language support for CodeMirror",
6
6
  "type": "module",
package/src/surrealql.ts CHANGED
@@ -34,24 +34,30 @@ export const surrealqlLanguage = LRLanguage.define({
34
34
  },
35
35
  });
36
36
 
37
- type Scope = "default" | "permission" | "combined-results" | "syntax";
37
+ type Scope ="permission" | "index" | "combined-results" | "syntax";
38
38
 
39
- const languageMap = new Map<Scope, LRLanguage>([
40
- ["default", surrealqlLanguage.configure({ top: "SurrealQL" })],
41
- ["permission", surrealqlLanguage.configure({ top: "PermissionInput" })],
42
- ["combined-results", surrealqlLanguage.configure({ top: "CombinedResults" })],
43
- ["syntax", surrealqlLanguage.configure({ top: "Syntax" })],
39
+ const scopeMap = new Map<Scope, string>([
40
+ ["permission", "PermissionInput"],
41
+ ["index", "IndexInput"],
42
+ ["combined-results", "CombinedResults"],
43
+ ["syntax", "Syntax"],
44
44
  ]);
45
45
 
46
46
  /**
47
47
  * The CodeMirror extension used to add support for the SurrealQL language
48
+ *
49
+ * @param scope Limit the scope of the highlighting
48
50
  */
49
- export function surrealql(scope: Scope = "default") {
50
- const language = languageMap.get(scope);
51
+ export function surrealql(scope?: Scope) {
52
+ if (!scope) {
53
+ return new LanguageSupport(surrealqlLanguage);
54
+ }
55
+
56
+ const scopeId = scopeMap.get(scope);
51
57
 
52
- if (!language) {
58
+ if (!scopeId) {
53
59
  throw new Error(`Unknown language scope: ${scope}`);
54
60
  }
55
61
 
56
- return new LanguageSupport(language);
62
+ return new LanguageSupport(surrealqlLanguage.configure({ top: scopeId }));
57
63
  }