mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
chore(code): reintegrate hcl syntax
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user