The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
UXW-3922 Design review fixes (#83892)
Denis Berezinb36e401426fb
diff --git a/.loki/reference/chrome_laptop_Components_CodeEditor_Markdown.png b/.loki/reference/chrome_laptop_Components_CodeEditor_Markdown.pngindex 13394302973..d7bf8f14226 100644Binary files a/.loki/reference/chrome_laptop_Components_CodeEditor_Markdown.png and b/.loki/reference/chrome_laptop_Components_CodeEditor_Markdown.png differdiff --git a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotSystemPromptsPage/MetabotSystemPromptsPage.module.css b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotSystemPromptsPage/MetabotSystemPromptsPage.module.cssindex 0ad4fff5127..3d4c52519ae 100644--- a/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotSystemPromptsPage/MetabotSystemPromptsPage.module.css+++ b/enterprise/frontend/src/metabase-enterprise/ai-controls/pages/MetabotSystemPromptsPage/MetabotSystemPromptsPage.module.css@@ -13,6 +13,8 @@min-height: 0;/* Keeps the editor's internal scroller inside the rounded border */overflow: hidden;+ padding: 1rem;+ background-color: var(--mb-color-background_surface-primary);border: 1px solid var(--mb-color-border);border-radius: 0.5rem;}diff --git a/frontend/src/metabase/common/components/CodeEditor/utils.ts b/frontend/src/metabase/common/components/CodeEditor/utils.tsindex 156753deea7..c930f89e8b7 100644--- a/frontend/src/metabase/common/components/CodeEditor/utils.ts+++ b/frontend/src/metabase/common/components/CodeEditor/utils.ts@@ -1,13 +1,14 @@import { html } from "@codemirror/lang-html";import { javascript } from "@codemirror/lang-javascript";import { json } from "@codemirror/lang-json";-import { markdown } from "@codemirror/lang-markdown";+import { markdown, markdownLanguage } from "@codemirror/lang-markdown";import { python } from "@codemirror/lang-python";import { sql } from "@codemirror/lang-sql";import {LanguageDescription,StreamLanguage,indentUnit,+ syntaxHighlighting,} from "@codemirror/language";import { clojure } from "@codemirror/legacy-modes/mode/clojure";import { pug } from "@codemirror/legacy-modes/mode/pug";@@ -18,6 +19,8 @@ import { handlebarsLanguage as handlebars } from "@xiechao/codemirror-lang-handlimport { useMemo } from "react";import _ from "underscore";+import { markdownMarkHighlighting } from "metabase/ui/syntax";+import type { CodeLanguage } from "./types";export function useExtensions({@@ -46,7 +49,9 @@ export function useExtensions({}, [language, extensions, originalValue, proposedValue]);}-export function getLanguageExtension(language: CodeLanguage | Extension) {+export function getLanguageExtension(+ language: CodeLanguage | Extension,+): Extension {if (typeof language !== "string") {return language;}@@ -59,14 +64,17 @@ export function getLanguageExtension(language: CodeLanguage | Extension) {case "json":return json();case "markdown":- return markdown({- codeLanguages: [- LanguageDescription.of({- name: "sql",- support: sql(),- }),- ],- });+ return [+ markdown({+ codeLanguages: [+ LanguageDescription.of({+ name: "sql",+ support: sql(),+ }),+ ],+ }),+ syntaxHighlighting(markdownMarkHighlighting(markdownLanguage)),+ ];case "python":return [python(), indentUnit.of(" ")];case "mustache":diff --git a/frontend/src/metabase/ui/syntax/highlight.module.css b/frontend/src/metabase/ui/syntax/highlight.module.cssindex d91b958e9ec..e412cd43834 100644--- a/frontend/src/metabase/ui/syntax/highlight.module.css+++ b/frontend/src/metabase/ui/syntax/highlight.module.css@@ -74,6 +74,11 @@font-weight: bold;}+/* Markdown markup (#, *, -, backticks) carries .processingInstruction too; this must follow it to win the cascade */+.markdownMark {+ color: var(--mb-color-text-primary);+}+.strong {font-weight: bold;}diff --git a/frontend/src/metabase/ui/syntax/highlight.ts b/frontend/src/metabase/ui/syntax/highlight.tsindex 234ff9994d7..95159cdf807 100644--- a/frontend/src/metabase/ui/syntax/highlight.ts+++ b/frontend/src/metabase/ui/syntax/highlight.ts@@ -1,4 +1,4 @@-import { HighlightStyle } from "@codemirror/language";+import { HighlightStyle, type Language } from "@codemirror/language";import type { Tag } from "@lezer/highlight";import { tags } from "@lezer/highlight";@@ -32,6 +32,17 @@ const styledTags = [export const metabaseSyntaxHighlighting = HighlightStyle.define(styledTags);+/**+ * Markdown markup characters (`#`, `*`, `-`, backticks) share the processingInstruction tag with other+ * grammars, so they are recolored only within the Markdown language passed as `scope`.+ */+export function markdownMarkHighlighting(scope: Language) {+ return HighlightStyle.define(+ [{ tag: tags.processingInstruction, class: S.markdownMark }],+ { scope },+ );+}+/*** Returns the correct css class name for a @lezer/highlight tag.*/