From 7e7555adf1a163c7ddfae3f7cd33995652187a2f Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Sat, 7 Mar 2026 12:53:25 +0200 Subject: [PATCH 1/5] moved the bubble arrangement option near the layout settings and made it conditional --- src/app/features/settings/cosmetics/Cosmetics.tsx | 8 -------- src/app/features/settings/general/General.tsx | 11 +++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index 0e2f555ec..601c078d1 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -172,7 +172,6 @@ function IdentityCosmetics() { const [renderRoomColors, setRenderRoomColors] = useSetting(settingsAtom, 'renderRoomColors'); const [renderRoomFonts, setRenderRoomFonts] = useSetting(settingsAtom, 'renderRoomFonts'); const [uniformIcons, setUniformIcons] = useSetting(settingsAtom, 'uniformIcons'); - const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); return ( @@ -229,13 +228,6 @@ function IdentityCosmetics() { after={} /> - - } - /> - ); } diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index b35500b36..e28f39e2c 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -753,6 +753,8 @@ function Messages() { 'hideMembershipInReadOnly' ); + const [messageLayout] = useSetting(settingsAtom, 'messageLayout'); + const [rightBubbles, setRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); return ( Messages @@ -768,6 +770,15 @@ function Messages() { after={} /> + {messageLayout === MessageLayout.Bubble && ( + + } + /> + + )} Date: Sat, 7 Mar 2026 13:14:09 +0200 Subject: [PATCH 2/5] improved the ux of the cardReader and added an info --- .../upload-card/UploadCardRenderer.tsx | 115 ++++++++++++++---- .../upload-card/UploadDescriptionEditor.tsx | 44 +++++-- src/app/features/room/RoomInput.tsx | 1 + 3 files changed, 121 insertions(+), 39 deletions(-) diff --git a/src/app/components/upload-card/UploadCardRenderer.tsx b/src/app/components/upload-card/UploadCardRenderer.tsx index b15a91c6c..55dbba3c7 100644 --- a/src/app/components/upload-card/UploadCardRenderer.tsx +++ b/src/app/components/upload-card/UploadCardRenderer.tsx @@ -1,5 +1,24 @@ -import { ReactNode, useEffect, useState } from 'react'; -import { Box, Chip, Icon, IconButton, Icons, Text, Tooltip, color, config, toRem } from 'folds'; +import { ReactNode, useEffect, useMemo, useState } from 'react'; +import { + Box, + Chip, + Icon, + IconButton, + Icons, + Scroll, + Text, + Tooltip, + TooltipProvider, + color, + config, + toRem, +} from 'folds'; +import { HTMLReactParserOptions } from 'html-react-parser'; +import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; +import { Opts as LinkifyOpts } from 'linkifyjs'; +import { getReactCustomHtmlParser, LINKIFY_OPTS } from '$plugins/react-custom-html-parser'; +import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler'; +import { RenderBody } from '$components/message'; import { UploadStatus, UploadSuccess, useBindUploadAtom } from '$state/upload'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { TUploadContent } from '$utils/matrix'; @@ -102,6 +121,7 @@ type UploadCardRendererProps = { setDesc: (fileItem: TUploadItem, body: string, formatted_body: string) => void; onRemove: (file: TUploadContent) => void; onComplete?: (upload: UploadSuccess) => void; + roomId: string; }; export function UploadCardRenderer({ isEncrypted, @@ -110,6 +130,7 @@ export function UploadCardRenderer({ setDesc, onRemove, onComplete, + roomId, }: UploadCardRendererProps) { const mx = useMatrixClient(); const mediaConfig = useMediaConfig(); @@ -141,6 +162,20 @@ export function UploadCardRenderer({ onComplete?.(upload); } }, [upload, onComplete]); + + const linkifyOpts = useMemo(() => ({ ...LINKIFY_OPTS }), []); + + const spoilerClickHandler = useSpoilerClickHandler(); + const useAuthentication = useMediaAuthentication(); + const htmlReactParserOptions = useMemo( + () => + getReactCustomHtmlParser(mx, roomId, { + linkifyOpts, + useAuthentication, + handleSpoilerClick: spoilerClickHandler, + }), + [linkifyOpts, mx, roomId, spoilerClickHandler, useAuthentication] + ); return ( Retry )} - { - setIsDescribed(!isDescribed); - }} - aria-label="Add Upload Description" - variant="SurfaceVariant" - radii="Pill" - size="300" - > - - + {!isDescribed && ( + { + setIsDescribed(true); + }} + aria-label="Add Upload Description" + variant="SurfaceVariant" + radii="Pill" + size="300" + > + + + )} + {isDescribed && ( + + + Don't forget to save your description before sending the message! + + + } + > + {(triggerRef) => } + + )} )} + {isDescribed && ( setIsDescribed(false)} /> )} {!isDescribed && fileItem.body && fileItem.body.length > 0 && ( - - - {fileItem.body} - - + + + + + + )} } diff --git a/src/app/components/upload-card/UploadDescriptionEditor.tsx b/src/app/components/upload-card/UploadDescriptionEditor.tsx index 4893ba385..447f02437 100644 --- a/src/app/components/upload-card/UploadDescriptionEditor.tsx +++ b/src/app/components/upload-card/UploadDescriptionEditor.tsx @@ -44,6 +44,7 @@ type DescriptionEditorProps = { isSaving?: boolean; imagePackRooms?: any[]; onSave: (plaintext: string, htmlContent: string) => void; + onCancel: () => void; }; export function DescriptionEditor({ @@ -51,6 +52,7 @@ export function DescriptionEditor({ isSaving, imagePackRooms, onSave, + onCancel, }: DescriptionEditorProps) { const editor = useEditor(); const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline'); @@ -129,6 +131,7 @@ export function DescriptionEditor({ (evt) => { if (isKeyHotkey('escape', evt)) { evt.preventDefault(); + onCancel(); return; } const prevWordRange = getPrevWorldRange(editor); @@ -137,7 +140,7 @@ export function DescriptionEditor({ : undefined; setAutocompleteQuery(query); }, - [editor] + [editor, onCancel] ); const handleCloseAutocomplete = useCallback(() => { @@ -180,18 +183,33 @@ export function DescriptionEditor({ justifyContent="SpaceBetween" gap="100" > - - : undefined - } - > - {isSaving ? 'Saving' : 'Save'} - + + + : undefined + } + > + {isSaving ? 'Saving' : 'Save'} + + + + : undefined + } + > + Cancel + + ( setMetadata={handleFileMetadata} onRemove={handleRemoveUpload} setDesc={setDesc} + roomId={roomId} /> ))} From d8e79e3e2df87865fe08ce2a7ba764017f4463a4 Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Sat, 7 Mar 2026 15:59:11 +0200 Subject: [PATCH 3/5] added Description positions --- src/app/components/RenderMessageContent.tsx | 15 ++-- .../components/message/MsgTypeRenderers.tsx | 2 +- src/app/features/settings/general/General.tsx | 73 +++++++++++++++++++ src/app/hooks/useCaptionPosition.ts | 30 ++++++++ src/app/state/settings.ts | 8 ++ 5 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 src/app/hooks/useCaptionPosition.ts diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index 6811b1161..1f4849f38 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -2,7 +2,7 @@ import { memo, useMemo, useCallback } from 'react'; import { MsgType } from '$types/matrix-sdk'; import { testMatrixTo } from '$plugins/matrix-to'; import { useSetting } from '$state/hooks/settings'; -import { settingsAtom } from '$state/settings'; +import { settingsAtom, CaptionPosition } from '$state/settings'; import { HTMLReactParserOptions } from 'html-react-parser'; import { Opts } from 'linkifyjs'; import { config } from 'folds'; @@ -74,6 +74,7 @@ function RenderMessageContentInternal({ const content = useMemo(() => getContent(), [getContent]); const [autoplayGifs] = useSetting(settingsAtom, 'autoplayGifs'); + const [captionPosition] = useSetting(settingsAtom, 'captionPosition'); const renderBody = useCallback( (props: any) => ( @@ -128,6 +129,7 @@ function RenderMessageContentInternal({ const renderFile = () => ( <> + {captionPosition === CaptionPosition.Above && renderCaption()} ( @@ -158,7 +160,7 @@ function RenderMessageContentInternal({ )} outlined={outlineAttachment} /> - {renderCaption()} + {captionPosition === CaptionPosition.Below && renderCaption()} ); @@ -206,6 +208,7 @@ function RenderMessageContentInternal({ return ( <> + {captionPosition === CaptionPosition.Above && renderCaption()} ( @@ -227,7 +230,7 @@ function RenderMessageContentInternal({ )} outlined={outlineAttachment} /> - {renderCaption()} + {captionPosition === CaptionPosition.Below && renderCaption()} ); } @@ -235,6 +238,7 @@ function RenderMessageContentInternal({ if (msgType === MsgType.Video) { return ( <> + {captionPosition === CaptionPosition.Above && renderCaption()} - {renderCaption()} + {captionPosition === CaptionPosition.Below && renderCaption()} ); } @@ -268,6 +272,7 @@ function RenderMessageContentInternal({ if (msgType === MsgType.Audio) { return ( <> + {captionPosition === CaptionPosition.Above && renderCaption()} - {renderCaption()} + {captionPosition === CaptionPosition.Below && renderCaption()} ); } diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index dc738c0a5..ee650be9d 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -238,7 +238,7 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) { }} > {renderImageContent({ - body: content.body || 'Image', + body: content.filename || 'Image', info: imgInfo, mimeType: imgInfo?.mimetype, url: mxcUrl, diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx index e28f39e2c..f4932972d 100644 --- a/src/app/features/settings/general/General.tsx +++ b/src/app/features/settings/general/General.tsx @@ -35,6 +35,7 @@ import { MessageLayout, MessageSpacing, RightSwipeAction, + CaptionPosition, settingsAtom, } from '$state/settings'; import { SettingTile } from '$components/setting-tile'; @@ -42,6 +43,7 @@ import { KeySymbol } from '$utils/key-symbol'; import { isMacOS, mobileOrTablet } from '$utils/user-agent'; import { stopPropagation } from '$utils/keyboard'; import { useMessageLayoutItems } from '$hooks/useMessageLayout'; +import { useCaptionPositionItems } from '$hooks/useCaptionPosition'; import { useMessageSpacingItems } from '$hooks/useMessageSpacing'; import { useDateFormatItems } from '$hooks/useDateFormat'; import { SequenceCardStyle } from '$features/settings/styles.css'; @@ -523,6 +525,74 @@ function SelectMessageLayout() { ); } +function SelectCaptionPosition() { + const [menuCords, setMenuCords] = useState(); + const [captionPosition, setCaptionPosition] = useSetting(settingsAtom, 'captionPosition'); + const captionPositionItems = useCaptionPositionItems(); + + const handleMenu: MouseEventHandler = (evt) => { + setMenuCords(evt.currentTarget.getBoundingClientRect()); + }; + + const handleSelect = (position: CaptionPosition) => { + setCaptionPosition(position); + setMenuCords(undefined); + }; + + return ( + <> + + setMenuCords(undefined), + clickOutsideDeactivates: true, + isKeyForward: (evt: KeyboardEvent) => + evt.key === 'ArrowDown' || evt.key === 'ArrowRight', + isKeyBackward: (evt: KeyboardEvent) => + evt.key === 'ArrowUp' || evt.key === 'ArrowLeft', + escapeDeactivates: stopPropagation, + }} + > + + + {captionPositionItems.map((item) => ( + handleSelect(item.layout)} + > + {item.name} + + ))} + + + + } + /> + + ); +} function SelectMessageSpacing() { const [menuCords, setMenuCords] = useState(); @@ -764,6 +834,9 @@ function Messages() { } /> + + } /> + + useMemo( + () => [ + { + layout: CaptionPosition.Above, + name: 'Above', + }, + { + layout: CaptionPosition.Inline, + name: 'Inline', + }, + { + layout: CaptionPosition.Hidden, + name: 'Hidden', + }, + { + layout: CaptionPosition.Below, + name: 'Below', + }, + ], + [] + ); diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index 6de1ad161..a9c1f2ece 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -15,6 +15,12 @@ export enum RightSwipeAction { Reply = 'reply', } +export enum CaptionPosition { + Above = 'above', + Inline = 'inline', + Hidden = 'hidden', + Below = 'below', +} export type JumboEmojiSize = 'none' | 'extraSmall' | 'small' | 'normal' | 'large' | 'extraLarge'; export interface Settings { @@ -69,6 +75,7 @@ export interface Settings { filterPronounsLanguages?: string[]; renderRoomColors: boolean; renderRoomFonts: boolean; + captionPosition: CaptionPosition; // Sable features! mobileGestures: boolean; @@ -143,6 +150,7 @@ const defaultSettings: Settings = { renderGlobalNameColors: true, renderRoomColors: true, renderRoomFonts: true, + captionPosition: CaptionPosition.Below, // Sable features! mobileGestures: true, From 52398a015ce2d3f9d95e5969d3dba014f1258c02 Mon Sep 17 00:00:00 2001 From: Shea Duma Date: Sun, 8 Mar 2026 01:19:15 +0200 Subject: [PATCH 4/5] added inline descriptions --- src/app/components/RenderMessageContent.tsx | 264 +++++++++++------- .../components/message/MsgTypeRenderers.tsx | 16 +- 2 files changed, 175 insertions(+), 105 deletions(-) diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index 1f4849f38..5fcfb4721 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -5,7 +5,7 @@ import { useSetting } from '$state/hooks/settings'; import { settingsAtom, CaptionPosition } from '$state/settings'; import { HTMLReactParserOptions } from 'html-react-parser'; import { Opts } from 'linkifyjs'; -import { config } from 'folds'; +import { Box, config } from 'folds'; import { AudioContent, DownloadFile, @@ -75,6 +75,12 @@ function RenderMessageContentInternal({ const [autoplayGifs] = useSetting(settingsAtom, 'autoplayGifs'); const [captionPosition] = useSetting(settingsAtom, 'captionPosition'); + const captionPositionMap = { + [CaptionPosition.Above]: 'column-reverse', + [CaptionPosition.Below]: 'column', + [CaptionPosition.Inline]: 'row', + [CaptionPosition.Hidden]: 'row', + } satisfies Record; const renderBody = useCallback( (props: any) => ( @@ -113,55 +119,89 @@ function RenderMessageContentInternal({ ); const renderCaption = () => { + if (captionPosition === CaptionPosition.Hidden) return null; if (content.filename && content.filename !== content.body) { + if (captionPosition !== CaptionPosition.Inline) + return ( + + ); return ( - + + + ); } return null; }; const renderFile = () => ( - <> - {captionPosition === CaptionPosition.Above && renderCaption()} - ( - ( - +
+ ( + ( + } + /> + )} + renderAsTextFile={() => ( + } + /> + )} + > + } + info={info} /> - )} - renderAsTextFile={() => ( - } - /> - )} - > - - - )} - outlined={outlineAttachment} - /> - {captionPosition === CaptionPosition.Below && renderCaption()} - + + )} + outlined={outlineAttachment} + /> +
+ {renderCaption()} + ); if (msgType === MsgType.Text) { @@ -207,82 +247,100 @@ function RenderMessageContentInternal({ (typeof content.url === 'string' && content.url.toLowerCase().includes('gif')); return ( - <> - {captionPosition === CaptionPosition.Above && renderCaption()} - ( - { - if (isGif && !autoplayGifs && p.src) { - return ( - - - - ); - } - return ; - }} - renderViewer={(p) => } - /> - )} - outlined={outlineAttachment} - /> - {captionPosition === CaptionPosition.Below && renderCaption()} - +
+
+ ( + { + if (isGif && !autoplayGifs && p.src) { + return ( + + + + ); + } + return ; + }} + renderViewer={(p) => } + /> + )} + outlined={outlineAttachment} + /> +
+ {renderCaption()} +
); } if (msgType === MsgType.Video) { return ( - <> - {captionPosition === CaptionPosition.Above && renderCaption()} - ( - ( - ( - {body} - )} - /> - ) - : undefined - } - renderVideo={(p) =>