From 3ec1b033ce2d2fbca238e27fa94c6ccc25498e86 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Mon, 2 Feb 2026 13:57:28 -0800 Subject: [PATCH] BlockEdit_TextFragment: support 'xs' editing. #961 --- .../BlockEdit_TextFragment.tsx | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/apps/chat/components/message/fragments-content/BlockEdit_TextFragment.tsx b/src/apps/chat/components/message/fragments-content/BlockEdit_TextFragment.tsx index d09e62b73..5a13c57cb 100644 --- a/src/apps/chat/components/message/fragments-content/BlockEdit_TextFragment.tsx +++ b/src/apps/chat/components/message/fragments-content/BlockEdit_TextFragment.tsx @@ -1,5 +1,7 @@ import * as React from 'react'; +import type { SxProps } from '@mui/joy/styles/types'; + import { BlocksTextarea } from '~/modules/blocks/BlocksContainers'; import type { ContentScaling } from '~/common/app.theme'; @@ -122,6 +124,32 @@ export function BlockEdit_TextFragment(props: { { key: ShortcutKey.Esc, description: 'Cancel', level: 3, action: onEscapePressed }, ], [isControlled, isEdited, isFocused, onEscapePressed, onSubmit, props.enableRestart])); + + // memo style + const sx = React.useMemo((): SxProps | undefined => { + // check sources of custom, and early outs + const isXS = props.contentScaling === 'xs'; + const isSquareTop = !!props.squareTopBorder; + if (!isXS && !isSquareTop) return undefined; + if (isSquareTop && !isXS) return _styles.squareTop; + + return { + // scaling note: in Chat, this can go xs/sm/md, while in Beam, this is xs/xs/sm + ...(isXS && { + fontSize: 'xs', + lineHeight: 'md', // was 1.75 on all + // '--Textarea-paddingBlock': 'calc(0.25rem - 0.5px - var(--variant-borderWidth, 0px))', // not used, overridden in BlocksTextarea + '--Textarea-paddingInline': '6px', + '--Textarea-minHeight': '1.75rem', // was 2rem on 'sm' + '--Icon-fontSize': 'lg', // was 'xl' on 'sm' + '--Textarea-focusedThickness': '1px', + boxShadow: 'none', // too small to show this + }), + ...(isSquareTop && _styles.squareTop), + }; + }, [props.contentScaling, props.squareTopBorder]); + + return ( ); }