Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(notebooks): center latex nodes and adapt their height in markdown notebooks (#68552)

Marius Andrab37b31ab3700
diff --git a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
index 2f5f14c0fd7b..09b480016909 100644
--- a/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
+++ b/frontend/src/lib/components/MarkdownNotebook/MarkdownNotebook.scss
@@ -1875,7 +1875,7 @@ button.MarkdownNotebook__component-title:focus-visible {
.MarkdownNotebook__real-node {
display: flex;
flex-direction: column;
- min-height: 8rem;
+ min-height: var(--markdown-notebook-real-node-min-height, 8rem);
background: var(--markdown-notebook-component-background);
}
@@ -1891,7 +1891,7 @@ button.MarkdownNotebook__component-title:focus-visible {
// overrides the inline `height` and the resize drag has no visible effect.
flex: 1 1 auto;
flex-direction: column;
- min-height: 8rem;
+ min-height: var(--markdown-notebook-real-node-min-height, 8rem);
overflow: hidden;
}
diff --git a/frontend/src/scenes/notebooks/Notebook/Notebook.scss b/frontend/src/scenes/notebooks/Notebook/Notebook.scss
index 83345be94560..7c25dd3970e9 100644
--- a/frontend/src/scenes/notebooks/Notebook/Notebook.scss
+++ b/frontend/src/scenes/notebooks/Notebook/Notebook.scss
@@ -447,42 +447,43 @@
cursor: text;
}
}
+ }
- .NotebookLatex {
- font-size: 1.1em;
- line-height: 1.5;
- text-align: center;
-
- &[data-display='true'] {
- display: block;
- margin: 1.5em 0;
- font-size: 1.2em;
- text-align: center;
- }
-
- &[data-display='false'] {
- display: inline;
- vertical-align: middle;
- }
+ // Kept at .Notebook level so LaTeX renders the same in the classic editor and markdown v2
+ .NotebookLatex {
+ font-size: 1.1em;
+ line-height: 1.5;
+ text-align: center;
- // Style for the MathJax rendered content
- .MathJax {
- font-size: 1.1em;
- }
+ &[data-display='true'] {
+ display: block;
+ margin: 1.5em 0;
+ font-size: 1.2em;
+ text-align: center;
}
- .NotebookLatex mjx-container {
- padding: 1em 0;
+ &[data-display='false'] {
+ display: inline;
+ vertical-align: middle;
}
- .NotebookLatex mjx-container,
- .NotebookLatex svg {
- display: block;
- margin-right: auto;
- margin-left: auto;
+ // Style for the MathJax rendered content
+ .MathJax {
+ font-size: 1.1em;
}
}
+ .NotebookLatex mjx-container {
+ padding: 1em 0;
+ }
+
+ .NotebookLatex mjx-container,
+ .NotebookLatex svg {
+ display: block;
+ margin-right: auto;
+ margin-left: auto;
+ }
+
&--compact:not(.Notebook--canvas) {
.NotebookEditor {
max-width: 50rem;
diff --git a/frontend/src/scenes/notebooks/Notebook/markdownNotebookRegistry.tsx b/frontend/src/scenes/notebooks/Notebook/markdownNotebookRegistry.tsx
index ced641577848..e916f25e1c68 100644
--- a/frontend/src/scenes/notebooks/Notebook/markdownNotebookRegistry.tsx
+++ b/frontend/src/scenes/notebooks/Notebook/markdownNotebookRegistry.tsx
@@ -489,6 +489,14 @@ export function MountedRealNotebookNodeComponent({
isResizeable || attributes.height
? { height: attributes.height ?? options.heightEstimate, minHeight: options.minHeight }
: undefined
+ // Nodes that declare their own minHeight (e.g. LaTeX) size to their content instead of the 8rem default
+ const nodeStyle: CSSProperties | undefined =
+ options.minHeight !== undefined
+ ? ({
+ '--markdown-notebook-real-node-min-height':
+ typeof options.minHeight === 'number' ? `${options.minHeight}px` : options.minHeight,
+ } as CSSProperties)
+ : undefined
// Native CSS resize writes to style.height; the new height is persisted on mouseup so the
// table or visualization keeps its size after reloads.
@@ -544,7 +552,7 @@ export function MountedRealNotebookNodeComponent({
return (
<NotebookNodeContext.Provider value={nodeLogic}>
<BindLogic logic={notebookNodeLogic} props={logicProps}>
- <div className="MarkdownNotebook__real-node">
+ <div className="MarkdownNotebook__real-node" style={nodeStyle}>
{showSettings ? (
<div className="MarkdownNotebook__real-node-settings">
<Settings attributes={attributes} updateAttributes={updateAttributes} />