Skip to content

Build your personal knowledge base with Trilium Notes

style/backend log: extract the syntax highlighting colors

Adorian Dorandd2aca4e2210
diff --git a/apps/client/src/stylesheets/theme-next-dark.css b/apps/client/src/stylesheets/theme-next-dark.css
index 7bdd242539..a1272c1052 100644
--- a/apps/client/src/stylesheets/theme-next-dark.css
+++ b/apps/client/src/stylesheets/theme-next-dark.css
@@ -269,6 +269,17 @@
--code-block-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
+ /* Backend log (the `text/x-trilium-log` code note MIME) */
+ --log-http-line-background-color: rgba(255, 255, 255, 0.03);
+ --log-http-verb-color: #539bf5;
+ --log-http-url-color: #268a8a;
+ --log-status-success-color: #2ea043;
+ --log-status-redirect-color: var(--muted-text-color);
+ --log-status-client-error-color: #d29922;
+ --log-status-server-error-color: #e5534b;
+ --log-error-color: #e5534b;
+ --log-info-color: inherit; /* Placeholder: give it a colour to make info lines stand out. */
+
--card-background-color: #ffffff12;
--card-background-hover-color: #ffffff20;
--card-border-color: transparent;
diff --git a/apps/client/src/stylesheets/theme-next-light.css b/apps/client/src/stylesheets/theme-next-light.css
index d11cecf216..9010c274b9 100644
--- a/apps/client/src/stylesheets/theme-next-light.css
+++ b/apps/client/src/stylesheets/theme-next-light.css
@@ -267,6 +267,17 @@
--code-block-box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1), 0px 0px 2px rgba(0, 0, 0, 0.2);
+ /* Backend log (the `text/x-trilium-log` code note MIME) */
+ --log-http-line-background-color: rgba(0, 0, 0, 0.03);
+ --log-http-verb-color: #0969da;
+ --log-http-url-color: #1b6b6b;
+ --log-status-success-color: #1a7f37;
+ --log-status-redirect-color: var(--muted-text-color);
+ --log-status-client-error-color: #9a6700;
+ --log-status-server-error-color: #cf222e;
+ --log-error-color: #cf222e;
+ --log-info-color: inherit; /* Placeholder: give it a colour to make info lines stand out. */
+
--card-background-color: #0000000d;
--card-background-hover-color: #0000001c;
--card-border-color: transparent;
diff --git a/packages/codemirror/src/extensions/trilium_log_highlighter.ts b/packages/codemirror/src/extensions/trilium_log_highlighter.ts
index c79f9413ff..8358d8e955 100644
--- a/packages/codemirror/src/extensions/trilium_log_highlighter.ts
+++ b/packages/codemirror/src/extensions/trilium_log_highlighter.ts
@@ -47,6 +47,10 @@ const statusMarks: Record<string, Decoration> = {
"5": Decoration.mark({ class: "cm-log-status cm-log-status-5xx" })
};
+/**
+ * The Next themes own the palette (`--log-*` in theme-next-light.css / theme-next-dark.css). The
+ * fallbacks below are what the legacy themes — which don't define those variables — render with.
+ */
const logHighlightTheme = EditorView.baseTheme({
".cm-log-timestamp": { color: "var(--muted-text-color)" },
".cm-log-http": { backgroundColor: "var(--log-http-line-background-color, color-mix(in srgb, var(--main-text-color) 3%, transparent))" },
@@ -57,7 +61,7 @@ const logHighlightTheme = EditorView.baseTheme({
".cm-log-status-3xx": { color: "var(--log-status-redirect-color, var(--muted-text-color))" },
".cm-log-status-4xx": { color: "var(--log-status-client-error-color, #d29922)" },
".cm-log-status-5xx": { color: "var(--log-status-server-error-color, #e5534b)" },
- ".cm-log-error": { color: "var(--log-error-color, #e5534b)" },
+ ".cm-log-error": { color: "var(--log-error-color, #e5534b)", backgroundColor: "transparent" },
// Placeholder: no colour yet — set `--log-info-color` to activate.
".cm-log-info": { color: "var(--log-info-color, inherit)" }
});