fix(web): mermaid code toggle stays in place when switching views (#19601)
This commit is contained in:
1 parent
7bdfed98d7
commit
5a4e998053
1 file changed
+12
-9
@@ -849,7 +849,7 @@ function MarkdownCodeBlock({
|
||||
theme,
|
||||
onRunShellCommand,
|
||||
isStreaming,
|
||||
leadingActions,
|
||||
viewToggle,
|
||||
canWrap = true,
|
||||
diagram = false,
|
||||
children,
|
||||
@@ -860,9 +860,10 @@ function MarkdownCodeBlock({
|
||||
theme: "light" | "dark";
|
||||
onRunShellCommand?: ((command: string) => void) | undefined;
|
||||
isStreaming: boolean;
|
||||
leadingActions?: ReactNode;
|
||||
/** Switches between source and rendered content; sits left of copy in both views. */
|
||||
viewToggle?: ReactNode;
|
||||
canWrap?: boolean;
|
||||
/** Renders content instead of code, with actions below it like tables. */
|
||||
/** Renders content frameless, with the code header's actions above it. */
|
||||
diagram?: boolean;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
@@ -942,12 +943,14 @@ function MarkdownCodeBlock({
|
||||
|
||||
if (diagram) {
|
||||
return (
|
||||
<div className="my-[0.65rem]" data-language={language}>
|
||||
{children}
|
||||
<div className="mt-0.5 flex items-center justify-between select-none">
|
||||
{leadingActions}
|
||||
// The transparent border and header padding match the code frame, so the
|
||||
// actions stay in place when switching views.
|
||||
<div className="my-[0.65rem] border border-transparent" data-language={language}>
|
||||
<div className="flex items-center justify-end gap-0.5 pt-1.5 pr-1.5 select-none">
|
||||
{viewToggle}
|
||||
{copyButton}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -962,7 +965,6 @@ function MarkdownCodeBlock({
|
||||
headerProps={THREAD_FIND_IGNORE_PROPS}
|
||||
actions={
|
||||
<span className="flex items-center gap-0.5" role="toolbar" aria-label="Code block actions">
|
||||
{leadingActions}
|
||||
{canWrap ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -1000,6 +1002,7 @@ function MarkdownCodeBlock({
|
||||
<TooltipPopup side="top">Run in terminal</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
{viewToggle}
|
||||
{copyButton}
|
||||
</span>
|
||||
}
|
||||
@@ -1043,7 +1046,7 @@ function MarkdownMermaidCodeBlock({
|
||||
isStreaming={isStreaming}
|
||||
canWrap={!showDiagram}
|
||||
diagram={showDiagram}
|
||||
leadingActions={
|
||||
viewToggle={
|
||||
isStreaming ? null : (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
|
||||
Reference in new issue
Block a user