Skip to content

Commit f6f267d

Browse files
Highlight YAML Dag source in the Code tab (#74633)
The AIP-85 YAML importer (#74586) stores its Dag source with language "yaml", but the Code tab's Monaco setup only registers the Python, TypeScript, Java and Go grammars, so YAML Dags rendered as plain text. Register Monaco's YAML grammar the same way as the others.
1 parent a52e9f9 commit f6f267d

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎airflow-core/src/airflow/ui/src/components/MonacoEditor/configureMonaco.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const grammars = [
2727
{ id: "java", load: () => import("monaco-editor/languages/definitions/java/java") },
2828
{ id: "python", load: () => import("monaco-editor/languages/definitions/python/python") },
2929
{ id: "typescript", load: () => import("monaco-editor/languages/definitions/typescript/typescript") },
30+
{ id: "yaml", load: () => import("monaco-editor/languages/definitions/yaml/yaml") },
3031
] as const;
3132

3233
describe("Monaco Dag-code grammars", () => {

‎airflow-core/src/airflow/ui/src/components/MonacoEditor/configureMonaco.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const loadMonacoModules = async () => {
6969
const typescriptGrammar = import("monaco-editor/languages/definitions/typescript/typescript");
7070
const javaGrammar = import("monaco-editor/languages/definitions/java/java");
7171
const goGrammar = import("monaco-editor/languages/definitions/go/go");
72+
const yamlGrammar = import("monaco-editor/languages/definitions/yaml/yaml");
7273

7374
const [
7475
monaco,
@@ -77,13 +78,15 @@ const loadMonacoModules = async () => {
7778
{ conf: typescriptConf, language: typescriptLanguage },
7879
{ conf: javaConf, language: javaLanguage },
7980
{ conf: goConf, language: goLanguage },
81+
{ conf: yamlConf, language: yamlLanguage },
8082
] = await Promise.all([
8183
monacoApi,
8284
workerUrls,
8385
pythonGrammar,
8486
typescriptGrammar,
8587
javaGrammar,
8688
goGrammar,
89+
yamlGrammar,
8790
jsonContribution,
8891
]);
8992

@@ -99,6 +102,8 @@ const loadMonacoModules = async () => {
99102
pythonLanguage,
100103
typescriptConf,
101104
typescriptLanguage,
105+
yamlConf,
106+
yamlLanguage,
102107
};
103108
};
104109

@@ -129,6 +134,8 @@ export const configureMonaco = () => {
129134
pythonLanguage,
130135
typescriptConf,
131136
typescriptLanguage,
137+
yamlConf,
138+
yamlLanguage,
132139
}) => {
133140
Reflect.set(globalThis, "MonacoEnvironment", {
134141
getWorker: (_moduleId: string, label: string) =>
@@ -147,6 +154,7 @@ export const configureMonaco = () => {
147154
{ conf: typescriptConf, id: "typescript", language: typescriptLanguage },
148155
{ conf: javaConf, id: "java", language: javaLanguage },
149156
{ conf: goConf, id: "go", language: goLanguage },
157+
{ conf: yamlConf, id: "yaml", language: yamlLanguage },
150158
] as const;
151159

152160
for (const grammar of grammars) {

‎airflow-core/src/airflow/ui/src/vite-env.d.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ declare module "monaco-editor/languages/definitions/go/go" {
5656
export const language: import("monaco-editor").languages.IMonarchLanguage;
5757
/* eslint-enable @typescript-eslint/consistent-type-imports */
5858
}
59+
60+
declare module "monaco-editor/languages/definitions/yaml/yaml" {
61+
/* eslint-disable @typescript-eslint/consistent-type-imports */
62+
export const conf: import("monaco-editor").languages.LanguageConfiguration;
63+
export const language: import("monaco-editor").languages.IMonarchLanguage;
64+
/* eslint-enable @typescript-eslint/consistent-type-imports */
65+
}

0 commit comments

Comments
 (0)