Skip to content

Build your personal knowledge base with Trilium Notes

chore(code): reintegrate hcl syntax

Elian Doran9f3e990c9504
diff --git a/packages/codemirror/package.json b/packages/codemirror/package.json
index 556feebcd1..fdf4319279 100644
--- a/packages/codemirror/package.json
+++ b/packages/codemirror/package.json
@@ -21,6 +21,7 @@
"dependencies": {
"@codemirror/commands": "6.8.1",
"@codemirror/legacy-modes": "6.5.1",
- "@codemirror/view": "6.36.7"
+ "@codemirror/view": "6.36.7",
+ "codemirror-lang-hcl": "0.1.0"
}
}
diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.ts
index caf72234c9..74e9a2ed48 100644
--- a/packages/codemirror/src/index.ts
+++ b/packages/codemirror/src/index.ts
@@ -68,8 +68,14 @@ export default class CodeMirror extends EditorView {
const correspondingSyntax = byMimeType[mime];
if (correspondingSyntax) {
- const extension = StreamLanguage.define(await correspondingSyntax());
- newExtension.push(extension);
+ const resolvedSyntax = await correspondingSyntax();
+
+ if ("token" in resolvedSyntax) {
+ const extension = StreamLanguage.define(resolvedSyntax);
+ newExtension.push(extension);
+ } else {
+ newExtension.push(resolvedSyntax());
+ }
}
this.dispatch({
diff --git a/packages/codemirror/src/syntax_highlighting.ts b/packages/codemirror/src/syntax_highlighting.ts
index ea71698819..562db0480b 100644
--- a/packages/codemirror/src/syntax_highlighting.ts
+++ b/packages/codemirror/src/syntax_highlighting.ts
@@ -1,6 +1,6 @@
-import { type StreamParser } from "@codemirror/language"
+import { LanguageSupport, type StreamParser } from "@codemirror/language"
-const byMimeType: Record<string, (() => Promise<StreamParser<unknown>>) | null> = {
+const byMimeType: Record<string, (() => Promise<StreamParser<unknown> | (() => LanguageSupport)>) | null> = {
"text/plain": null,
"text/apl": async () => (await import('@codemirror/legacy-modes/mode/apl')).apl,
"text/x-ttcn-asn": async () => (await import('@codemirror/legacy-modes/mode/ttcn')).ttcn,
@@ -134,7 +134,7 @@ const byMimeType: Record<string, (() => Promise<StreamParser<unknown>>) | null>
"text/x-swift": async () => (await import('@codemirror/legacy-modes/mode/swift')).swift,
"text/x-systemverilog": null,
"text/x-tcl": async () => (await import('@codemirror/legacy-modes/mode/tcl')).tcl,
- "text/x-hcl": null,
+ "text/x-hcl": async () => (await import('codemirror-lang-hcl')).hcl,
"text/x-textile": async () => (await import('@codemirror/legacy-modes/mode/textile')).textile,
"text/x-tiddlywiki": async () => (await import('@codemirror/legacy-modes/mode/tiddlywiki')).tiddlyWiki,
"text/tiki": async () => (await import('@codemirror/legacy-modes/mode/tiki')).tiki,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 873d9c0734..8fc0ba49c9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1163,6 +1163,9 @@ importers:
'@codemirror/view':
specifier: 6.36.7
version: 6.36.7
+ codemirror-lang-hcl:
+ specifier: 0.1.0
+ version: 0.1.0
packages/commons:
dependencies:
@@ -6330,6 +6333,9 @@ packages:
resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==}
engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'}
+ resolution: {integrity: sha512-duwKEaQDhkJWad4YQ9pv4282BS6hCdR+gS/qTAj3f9bypXNNZ42bIN43h9WK3DjyZRENtVlUQdrQM1sA44wHmA==}
+
resolution: {integrity: sha512-+aFkvqhaAVr1gferNMuN8vkTSrWIFvzlMV9I2KBLCWS2WpZ2+UAkZjlMZmEuT+gcXTi6RrGQCkWq1/bDtGqhIA==}
@@ -15014,15 +15020,6 @@ snapshots:
- supports-color
- utf-8-validate
- '@ckeditor/[email protected]':
- dependencies:
- '@ckeditor/ckeditor5-core': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-engine': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-heading': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-typing': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-utils': 45.0.0([email protected])([email protected])
- ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
-
dependencies:
'@ckeditor/ckeditor5-core': 45.0.0([email protected])([email protected])
@@ -15193,27 +15190,23 @@ snapshots:
- supports-color
- utf-8-validate
+ '@ckeditor/[email protected]':
dependencies:
'@ckeditor/ckeditor5-comments': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-icons': 45.0.0
'@ckeditor/ckeditor5-theme-lark': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-track-changes': 45.0.0([email protected])([email protected])
+ '@ckeditor/ckeditor5-track-changes': 45.0.0
'@ckeditor/ckeditor5-ui': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-utils': 45.0.0([email protected])([email protected])
'@types/luxon': 3.4.2
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
luxon: 3.5.0
- transitivePeerDependencies:
- - bufferutil
- - supports-color
- - utf-8-validate
'@ckeditor/[email protected]':
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-collaboration-core': 45.0.0([email protected])([email protected])
+ '@ckeditor/ckeditor5-collaboration-core': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-engine': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-enter': 45.0.0([email protected])([email protected])
@@ -15234,7 +15227,7 @@ snapshots:
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-collaboration-core': 45.0.0([email protected])([email protected])
+ '@ckeditor/ckeditor5-collaboration-core': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-engine': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-enter': 45.0.0([email protected])([email protected])
@@ -16055,7 +16048,7 @@ snapshots:
'@ckeditor/ckeditor5-operations-compressor': 45.0.0
'@ckeditor/ckeditor5-revision-history': 45.0.0
'@ckeditor/ckeditor5-theme-lark': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-track-changes': 45.0.0([email protected])([email protected])
+ '@ckeditor/ckeditor5-track-changes': 45.0.0
'@ckeditor/ckeditor5-ui': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-utils': 45.0.0([email protected])([email protected])
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
@@ -16256,7 +16249,7 @@ snapshots:
- supports-color
- utf-8-validate
+ '@ckeditor/[email protected]':
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-code-block': 45.0.0(patch_hash=2361d8caad7d6b5bddacc3a3b4aa37dbfba260b1c1b22a450413a79c1bb1ce95)
@@ -16285,10 +16278,6 @@ snapshots:
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
ckeditor5-collaboration: 45.0.0
es-toolkit: 1.32.0
- transitivePeerDependencies:
- - bufferutil
- - supports-color
- - utf-8-validate
dependencies:
@@ -21582,13 +21571,13 @@ snapshots:
dependencies:
- '@ckeditor/ckeditor5-collaboration-core': 45.0.0([email protected])([email protected])
+ '@ckeditor/ckeditor5-collaboration-core': 45.0.0
[email protected](patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41):
dependencies:
'@ckeditor/ckeditor5-adapter-ckfinder': 45.0.0
'@ckeditor/ckeditor5-alignment': 45.0.0([email protected])([email protected])
- '@ckeditor/ckeditor5-autoformat': 45.0.0
+ '@ckeditor/ckeditor5-autoformat': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-autosave': 45.0.0([email protected])([email protected])
'@ckeditor/ckeditor5-basic-styles': 45.0.0
'@ckeditor/ckeditor5-block-quote': 45.0.0
@@ -21791,6 +21780,12 @@ snapshots:
+ dependencies:
+ '@codemirror/language': 6.11.0
+ '@lezer/highlight': 1.2.1
+ '@lezer/lr': 1.4.2
+