chore(code): reintegrate hcl syntax

This commit is contained in:
Elian Doran 2025-05-11 10:54:15 +03:00
parent efc08a61ef
commit 9f3e990c95
No known key found for this signature in database
4 changed files with 33 additions and 31 deletions

View File

@ -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"
}
}

View File

@ -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({

View File

@ -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,

45
pnpm-lock.yaml generated
View File

@ -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'}
codemirror-lang-hcl@0.1.0:
resolution: {integrity: sha512-duwKEaQDhkJWad4YQ9pv4282BS6hCdR+gS/qTAj3f9bypXNNZ42bIN43h9WK3DjyZRENtVlUQdrQM1sA44wHmA==}
codemirror@5.65.19:
resolution: {integrity: sha512-+aFkvqhaAVr1gferNMuN8vkTSrWIFvzlMV9I2KBLCWS2WpZ2+UAkZjlMZmEuT+gcXTi6RrGQCkWq1/bDtGqhIA==}
@ -15014,15 +15020,6 @@ snapshots:
- supports-color
- utf-8-validate
'@ckeditor/ckeditor5-autoformat@45.0.0':
dependencies:
'@ckeditor/ckeditor5-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-engine': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-heading': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-typing': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-utils': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
'@ckeditor/ckeditor5-autoformat@45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)':
dependencies:
'@ckeditor/ckeditor5-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
@ -15193,27 +15190,23 @@ snapshots:
- supports-color
- utf-8-validate
'@ckeditor/ckeditor5-collaboration-core@45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)':
'@ckeditor/ckeditor5-collaboration-core@45.0.0':
dependencies:
'@ckeditor/ckeditor5-comments': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-icons': 45.0.0
'@ckeditor/ckeditor5-theme-lark': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-track-changes': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-track-changes': 45.0.0
'@ckeditor/ckeditor5-ui': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-utils': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@types/luxon': 3.4.2
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
luxon: 3.5.0
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
'@ckeditor/ckeditor5-comments@45.0.0':
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-collaboration-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-collaboration-core': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-engine': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-enter': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
@ -15234,7 +15227,7 @@ snapshots:
'@ckeditor/ckeditor5-comments@45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)':
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-collaboration-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-collaboration-core': 45.0.0
'@ckeditor/ckeditor5-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-engine': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-enter': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
@ -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(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-track-changes': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-track-changes': 45.0.0
'@ckeditor/ckeditor5-ui': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-utils': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
ckeditor5: 45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41)
@ -16256,7 +16249,7 @@ snapshots:
- supports-color
- utf-8-validate
'@ckeditor/ckeditor5-track-changes@45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)':
'@ckeditor/ckeditor5-track-changes@45.0.0':
dependencies:
'@ckeditor/ckeditor5-clipboard': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@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
'@ckeditor/ckeditor5-typing@45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)':
dependencies:
@ -21582,13 +21571,13 @@ snapshots:
ckeditor5-collaboration@45.0.0:
dependencies:
'@ckeditor/ckeditor5-collaboration-core': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-collaboration-core': 45.0.0
ckeditor5@45.0.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41):
dependencies:
'@ckeditor/ckeditor5-adapter-ckfinder': 45.0.0
'@ckeditor/ckeditor5-alignment': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-autoformat': 45.0.0
'@ckeditor/ckeditor5-autoformat': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-autosave': 45.0.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)
'@ckeditor/ckeditor5-basic-styles': 45.0.0
'@ckeditor/ckeditor5-block-quote': 45.0.0
@ -21791,6 +21780,12 @@ snapshots:
co@4.6.0: {}
codemirror-lang-hcl@0.1.0:
dependencies:
'@codemirror/language': 6.11.0
'@lezer/highlight': 1.2.1
'@lezer/lr': 1.4.2
codemirror@5.65.19: {}
collect-v8-coverage@1.0.2: {}