diff --git a/.changeset/add-ability-to-customize-pronoun-limits.md b/.changeset/add-ability-to-customize-pronoun-limits.md
new file mode 100644
index 000000000..7b5c04bdf
--- /dev/null
+++ b/.changeset/add-ability-to-customize-pronoun-limits.md
@@ -0,0 +1,5 @@
+---
+default: minor
+---
+
+Added configurable max pronoun pill count and max pill length rendering settings.
diff --git a/.changeset/add-hover-pronouns-list.md b/.changeset/add-hover-pronouns-list.md
new file mode 100644
index 000000000..4d71893f6
--- /dev/null
+++ b/.changeset/add-hover-pronouns-list.md
@@ -0,0 +1,5 @@
+---
+default: minor
+---
+
+Adds the ability to hover/tap over `...` to see the rest of someone's pronouns.
diff --git a/.changeset/change-pixelation-behavior.md b/.changeset/change-pixelation-behavior.md
new file mode 100644
index 000000000..b5d53bbfe
--- /dev/null
+++ b/.changeset/change-pixelation-behavior.md
@@ -0,0 +1,5 @@
+---
+default: patch
+---
+
+Change image rendering to allow enabling anti-aliasing in the image viewer
diff --git a/.changeset/fix-list-rendering-p-tags.md b/.changeset/fix-list-rendering-p-tags.md
new file mode 100644
index 000000000..813308d6c
--- /dev/null
+++ b/.changeset/fix-list-rendering-p-tags.md
@@ -0,0 +1,5 @@
+---
+default: patch
+---
+
+Fixed lists rendering `p` html tags on new lines.
diff --git a/.changeset/fix-math-in-color.md b/.changeset/fix-math-in-color.md
new file mode 100644
index 000000000..cb09b6eeb
--- /dev/null
+++ b/.changeset/fix-math-in-color.md
@@ -0,0 +1,5 @@
+---
+default: patch
+---
+
+Fix math parsing inside of color blocks not being parsed properly.
diff --git a/.changeset/fix-nested-lists-behavior.md b/.changeset/fix-nested-lists-behavior.md
new file mode 100644
index 000000000..f5b3113e4
--- /dev/null
+++ b/.changeset/fix-nested-lists-behavior.md
@@ -0,0 +1,5 @@
+---
+default: patch
+---
+
+Fixed nested lists having wrong indentation levels when editing.
diff --git a/.changeset/fix-small-styling-fixes.md b/.changeset/fix-small-styling-fixes.md
new file mode 100644
index 000000000..c9d4c3e49
--- /dev/null
+++ b/.changeset/fix-small-styling-fixes.md
@@ -0,0 +1,5 @@
+---
+default: patch
+---
+
+Fix missing filename breaking edits, and missing a fallback, and codeblock titles overflowing
diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx
index c3b95a04d..104e74e21 100644
--- a/src/app/components/RenderMessageContent.tsx
+++ b/src/app/components/RenderMessageContent.tsx
@@ -1,3 +1,4 @@
+import type { CSSProperties } from 'react';
import { memo, useMemo, useCallback } from 'react';
import type { IPreviewUrlResponse, MatrixClient, MatrixEvent, Room } from '$types/matrix-sdk';
import { MsgType } from '$types/matrix-sdk';
@@ -47,6 +48,7 @@ import { ClientSideHoverFreeze } from './ClientSideHoverFreeze';
import { CuteEventType, MCuteEvent } from './message/MCuteEvent';
import { PollEvent } from './message/PollEvent';
import { M_TEXT } from 'matrix-js-sdk';
+import type { IImageInfo } from '$types/matrix/common';
type RenderMessageContentProps = {
displayName: string;
@@ -80,7 +82,8 @@ const isSableChatEmbedCandidate = (url: string): boolean =>
/^https:\/\//i.test(url) &&
(/\.preview\.sable\.css(\?|#|$)/i.test(url) || isHttpsFullSableCssUrl(url));
-const CAPTION_STYLE = { marginTop: config.space.S200 };
+const CAPTION_STYLE: CSSProperties = { marginTop: config.space.S200, maxWidth: '100%' };
+const TEXT_STYLE: CSSProperties = { maxWidth: '100%' };
function RenderMessageContentInternal({
displayName,
@@ -224,6 +227,7 @@ function RenderMessageContentInternal({
);
@@ -301,6 +306,7 @@ function RenderMessageContentInternal({
renderBody={renderBody}
renderUrlsPreview={messageUrlsPreview}
renderBundledPreviews={messageBundlePreview}
+ style={TEXT_STYLE}
/>
);
}
@@ -342,7 +348,7 @@ function RenderMessageContentInternal({
}
if (msgType === (MsgType.Image as string)) {
- const info = (content as { info?: { mimetype?: string } }).info;
+ const { info } = content as { info?: IImageInfo };
const isGif =
info?.mimetype === 'image/gif' ||
info?.mimetype === 'image/apng' ||
@@ -366,11 +372,11 @@ function RenderMessageContentInternal({
if (isGif && !autoplayGifs && p.src) {
return (
-
+
);
}
- return ;
+ return ;
}}
renderViewer={(p) => }
/>
diff --git a/src/app/components/image-viewer/ImageViewer.tsx b/src/app/components/image-viewer/ImageViewer.tsx
index 214347b3d..573ef0cfa 100644
--- a/src/app/components/image-viewer/ImageViewer.tsx
+++ b/src/app/components/image-viewer/ImageViewer.tsx
@@ -4,24 +4,30 @@ import classNames from 'classnames';
import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds';
import { useImageGestures } from '$hooks/useImageGestures';
import { useSetting } from '$state/hooks/settings';
-import { isPixelatedViewerRendering, settingsAtom } from '$state/settings';
+import { isPixelatedRendering, settingsAtom } from '$state/settings';
import { downloadMedia } from '$utils/matrix';
import * as css from './ImageViewer.css';
+import type { IImageInfo } from '$types/matrix/common';
+import { CheckerboardIcon } from '@phosphor-icons/react';
export type ImageViewerProps = {
alt: string;
src: string;
requestClose: () => void;
+ info?: IImageInfo;
};
export const ImageViewer = as<'div', ImageViewerProps>(
- ({ className, alt, src, requestClose, ...props }, ref) => {
+ ({ className, alt, src, requestClose, info, ...props }, ref) => {
const zoomInputRef = useRef(null);
const [pixelatedImageRendering] = useSetting(settingsAtom, 'pixelatedImageRendering');
const [isImageReady, setIsImageReady] = useState(false);
const [isEditingZoom, setIsEditingZoom] = useState(false);
const [zoomInput, setZoomInput] = useState('100');
+ const [isPixelated, setIsPixelated] = useState(
+ isPixelatedRendering(pixelatedImageRendering, info)
+ );
const {
transforms,
@@ -84,6 +90,16 @@ export const ImageViewer = as<'div', ImageViewerProps>(
+ setIsPixelated(!isPixelated)}
+ aria-label="Toggle Pixelation"
+ title={`Turn ${isPixelated ? 'Anti-aliasing' : 'Pixelation'} on`}
+ >
+
+
(
onPointerDown={onPointerDown}
>
>(
- ({ className, alt, ...props }, ref) => {
+type ImageProps = ImgHTMLAttributes & { info?: IImageInfo };
+
+export const Image = forwardRef(
+ ({ className, alt, info, ...props }, ref) => {
const [pixelatedImageRendering] = useSetting(settingsAtom, 'pixelatedImageRendering');
return (
{renderImageContent({
- body: content.filename || 'Image',
+ body: content.filename || content.body || 'Image',
info: imgInfo,
mimeType: imgInfo?.mimetype,
url: mxcUrl,
diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx
index 9904fa9f3..590736760 100644
--- a/src/app/components/message/content/ImageContent.tsx
+++ b/src/app/components/message/content/ImageContent.tsx
@@ -59,6 +59,7 @@ type RenderViewerProps = {
src: string;
alt: string;
requestClose: () => void;
+ info?: IImageInfo;
};
type RenderImageProps = {
alt: string;
@@ -242,6 +243,7 @@ export const ImageContent = as<'div', ImageContentProps>(
src: viewerFullSrc ?? srcState.data,
alt: body,
requestClose: () => setViewer(false),
+ info: info,
})}
diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx
index 34383df76..648be314e 100644
--- a/src/app/components/url-preview/UrlPreviewCard.tsx
+++ b/src/app/components/url-preview/UrlPreviewCard.tsx
@@ -305,6 +305,7 @@ export const UrlPreviewCard = as<
renderViewer={(p) => }
renderImage={(p) => (
void, delay = 300) {
const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str);
+type MorePronounsPillProps = {
+ pronouns: PronounSet[];
+ tagColor: string;
+ maxPillLength: number;
+};
+
+function MorePronounsPill({ pronouns, tagColor, maxPillLength }: MorePronounsPillProps) {
+ const [anchor, setAnchor] = useState();
+
+ const toggleAnchor = (target: HTMLElement) => {
+ setAnchor((prev) => (prev ? undefined : target.getBoundingClientRect()));
+ };
+
+ const handleClick: MouseEventHandler = (e) => {
+ e.stopPropagation();
+ toggleAnchor(e.currentTarget);
+ };
+
+ const handleKeyDown: KeyboardEventHandler = (e) => {
+ if (e.key !== 'Enter' && e.key !== ' ') return;
+ e.preventDefault();
+ e.stopPropagation();
+ toggleAnchor(e.currentTarget);
+ };
+
+ // On mobile, tapping the pill pins the tooltip open.
+ // Tapping anywhere else dismisses it.
+ useEffect(() => {
+ if (!anchor) return undefined;
+ const dismiss = () => setAnchor(undefined);
+ document.addEventListener('click', dismiss, { once: true });
+ return () => document.removeEventListener('click', dismiss);
+ }, [anchor]);
+
+ const tooltipText = pronouns.map((p) => clamp(p.summary, maxPillLength)).join(', ');
+
+ const tooltipContent = (
+
+ {tooltipText}
+
+ );
+
+ return (
+ <>
+
+ {(triggerRef) => (
+ }
+ style={{ color: tagColor, cursor: 'help' }}
+ onClick={handleClick}
+ onKeyDown={handleKeyDown}
+ role="button"
+ tabIndex={0}
+ >
+ ...
+
+ )}
+
+ {anchor && (
+
+ {null}
+
+ )}
+ >
+ );
+}
+
/**
* Component to render pronouns in the chat timeline.
* It also filters them.
@@ -307,7 +377,8 @@ const Pronouns = as<
selectedLanguages
);
- const limit = mobileOrTablet() ? 1 : 3;
+ const limit = getSettings().pronounPillMaxCount ?? 3;
+ const maxPillLength = getSettings().pronounPillMaxLength ?? 16;
// if language specific pronouns can't be found matching the filter return unfiltered
if (visiblePronouns.length === 0) {
@@ -318,10 +389,16 @@ const Pronouns = as<
{visiblePronouns.slice(0, limit).map((p) => (
- {clamp(p.summary, 16)}
+ {clamp(p.summary, maxPillLength)}
))}
- {visiblePronouns.length > limit && ...}
+ {visiblePronouns.length > limit && (
+
+ )}
);
});
diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx
index 10dbca6d7..bc0566ad5 100644
--- a/src/app/features/room/message/MessageEditor.tsx
+++ b/src/app/features/room/message/MessageEditor.tsx
@@ -292,9 +292,10 @@ export const MessageEditor = as<'div', MessageEditorProps>(
content.format = contentBody.format;
content.formatted_body = contentBody.formatted_body;
content['m.new_content'] = newContent;
- if (oldContent.info !== undefined && oldContent.filename?.length > 0) {
- content.filename = oldContent.filename;
- content['m.new_content'].filename = oldContent.filename;
+ if (oldContent.info !== undefined && oldContent.msgtype !== 'm.text') {
+ content.filename = 'filename' in oldContent ? oldContent.filename : oldContent.body;
+ content['m.new_content'].filename =
+ 'filename' in oldContent ? oldContent.filename : oldContent.body;
content.info = oldContent.info;
content['m.new_content'].info = oldContent.info;
diff --git a/src/app/features/room/message/styles.css.ts b/src/app/features/room/message/styles.css.ts
index f8946e188..031adf300 100644
--- a/src/app/features/room/message/styles.css.ts
+++ b/src/app/features/room/message/styles.css.ts
@@ -3,6 +3,7 @@ import { DefaultReset, config, toRem } from 'folds';
export const MessageBase = style({
position: 'relative',
+ maxWidth: '100%',
});
export const MessageBaseBubbleCollapsed = style({
paddingTop: 0,
diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx
index 49ab59374..bb938a855 100644
--- a/src/app/features/settings/cosmetics/Cosmetics.tsx
+++ b/src/app/features/settings/cosmetics/Cosmetics.tsx
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react';
-import type { MouseEventHandler } from 'react';
+import type { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react';
import type { RectCords } from 'folds';
import {
Box,
@@ -7,13 +7,16 @@ import {
config,
Icon,
Icons,
+ Input,
Menu,
MenuItem,
PopOut,
Scroll,
Switch,
Text,
+ toRem,
} from 'folds';
+import { isKeyHotkey } from 'is-hotkey';
import FocusTrap from 'focus-trap-react';
import { PageContent } from '$components/page';
import { SequenceCard } from '$components/sequence-card';
@@ -27,6 +30,94 @@ import { SettingsSectionPage } from '../SettingsSectionPage';
import { Appearance } from './Themes';
import { LanguageSpecificPronouns } from './LanguageSpecificPronouns';
+function PronounPillMaxCountInput({ disabled }: { disabled: boolean }) {
+ const [maxCount, setMaxCount] = useSetting(settingsAtom, 'pronounPillMaxCount');
+ const [inputValue, setInputValue] = useState(maxCount.toString());
+
+ const handleChange: ChangeEventHandler = (evt) => {
+ const val = evt.target.value;
+ setInputValue(val);
+
+ const parsed = Number.parseInt(val, 10);
+ if (!Number.isNaN(parsed) && parsed >= 1 && parsed <= 10) {
+ setMaxCount(parsed);
+ }
+ };
+
+ const handleKeyDown: KeyboardEventHandler = (evt) => {
+ if (isKeyHotkey('escape', evt)) {
+ evt.stopPropagation();
+ setInputValue(maxCount.toString());
+ (evt.target as HTMLInputElement).blur();
+ }
+
+ if (isKeyHotkey('enter', evt)) {
+ (evt.target as HTMLInputElement).blur();
+ }
+ };
+
+ return (
+
+ );
+}
+
+function PronounPillMaxLengthInput({ disabled }: { disabled: boolean }) {
+ const [maxLength, setMaxLength] = useSetting(settingsAtom, 'pronounPillMaxLength');
+ const [inputValue, setInputValue] = useState(maxLength.toString());
+
+ const handleChange: ChangeEventHandler = (evt) => {
+ const val = evt.target.value;
+ setInputValue(val);
+
+ const parsed = Number.parseInt(val, 10);
+ if (!Number.isNaN(parsed) && parsed >= 1 && parsed <= 64) {
+ setMaxLength(parsed);
+ }
+ };
+
+ const handleKeyDown: KeyboardEventHandler = (evt) => {
+ if (isKeyHotkey('escape', evt)) {
+ evt.stopPropagation();
+ setInputValue(maxLength.toString());
+ (evt.target as HTMLInputElement).blur();
+ }
+
+ if (isKeyHotkey('enter', evt)) {
+ (evt.target as HTMLInputElement).blur();
+ }
+ };
+
+ return (
+
+ );
+}
+
const emojiSizeItems = [
{ id: 'none', name: 'None (Same size as text)' },
{ id: 'extraSmall', name: 'Extra Small' },
@@ -282,6 +373,32 @@ function IdentityCosmetics() {
after={}
/>
+
+ }
+ />
+
+
+ }
+ />
+
[] = [
- { value: 'both', label: 'Both' },
- { value: 'chat', label: 'Chat' },
- { value: 'viewer', label: 'Image viewer' },
- { value: 'none', label: 'Neither' },
+ { value: 'always', label: 'Always' },
+ { value: 'smart', label: 'Smart' },
+ { value: 'never', label: 'never' },
];
const [incomingInlineImagesDefaultHeight, setIncomingInlineImagesDefaultHeight] = useSetting(
settingsAtom,
diff --git a/src/app/features/settings/settingsLink.ts b/src/app/features/settings/settingsLink.ts
index ca57bbfdb..d2ae99a1d 100644
--- a/src/app/features/settings/settingsLink.ts
+++ b/src/app/features/settings/settingsLink.ts
@@ -110,6 +110,8 @@ const settingsLinkFocusIdsBySection: Record {
expect(result).toContain('2. Second');
});
+ it('round-trips nested sublists with four-space indent', () => {
+ const markdown = '1. parent\n - child';
+ const html = markdownToHtml(markdown);
+ expect(html).toMatch(/[\s\S]* {
+ const markdown = '1. parent\n - child';
+ const html = markdownToHtml(markdown);
+ expect(html).toMatch(/- [\s\S]*
{
const markdown = '||hidden message||';
const html = markdownToHtml(markdown);
diff --git a/src/app/plugins/markdown/expandBlockNewlines.test.ts b/src/app/plugins/markdown/expandBlockNewlines.test.ts
index 700d743a7..154284191 100644
--- a/src/app/plugins/markdown/expandBlockNewlines.test.ts
+++ b/src/app/plugins/markdown/expandBlockNewlines.test.ts
@@ -15,6 +15,24 @@ describe('expandBlockBoundariesAfterSingleNewlines', () => {
it('still expands when a blockquote ends', () => {
expect(expandBlockBoundariesAfterSingleNewlines('> quote\nplain')).toBe('> quote\n\nplain');
});
+
+ it('does not expand between consecutive ordered list items', () => {
+ expect(expandBlockBoundariesAfterSingleNewlines('1. one\n2. two')).toBe('1. one\n2. two');
+ });
+
+ it('does not expand before a 2-space nested sublist', () => {
+ expect(expandBlockBoundariesAfterSingleNewlines('1. test\n - sub')).toBe('1. test\n - sub');
+ });
+
+ it('does not expand before a 4-space nested sublist', () => {
+ expect(expandBlockBoundariesAfterSingleNewlines('1. test\n - sub')).toBe(
+ '1. test\n - sub'
+ );
+ });
+
+ it('still expands before the first top-level list item after prose', () => {
+ expect(expandBlockBoundariesAfterSingleNewlines('intro\n- item')).toBe('intro\n\n- item');
+ });
});
describe('consecutive blockquotes', () => {
diff --git a/src/app/plugins/markdown/expandBlockNewlines.ts b/src/app/plugins/markdown/expandBlockNewlines.ts
index d4164ba3a..f436bb66d 100644
--- a/src/app/plugins/markdown/expandBlockNewlines.ts
+++ b/src/app/plugins/markdown/expandBlockNewlines.ts
@@ -135,11 +135,41 @@ function nextLineIsBlockStarter(md: string, newlineIdx: number): boolean {
return looksLikeBlockStart(effective);
}
+function leadingSpaces(line: string): number {
+ let k = 0;
+ while (k < line.length && line[k] === ' ') k++;
+ return k;
+}
+
+function lineLooksLikeListItem(line: string): boolean {
+ const effective = effectiveContentAfterEscapes(line);
+ if (effective === null) return false;
+ return /^\d{1,9}\.\s/.test(effective) || /^[-*+]\s/.test(effective);
+}
+
+function nextLineIsNestedListItem(md: string, newlineIdx: number): boolean {
+ const prevLine = lineAtNewline(md, newlineIdx);
+ const nextLine = lineAfterNewline(md, newlineIdx);
+ if (!lineLooksLikeListItem(nextLine)) return false;
+ return leadingSpaces(nextLine) > leadingSpaces(prevLine);
+}
+
+function nextLineIsSiblingListItem(md: string, newlineIdx: number): boolean {
+ const prevLine = lineAtNewline(md, newlineIdx);
+ const nextLine = lineAfterNewline(md, newlineIdx);
+ if (!lineLooksLikeListItem(prevLine) || !lineLooksLikeListItem(nextLine)) return false;
+ return leadingSpaces(prevLine) === leadingSpaces(nextLine);
+}
+
function shouldExpandSingleNewline(md: string, newlineIdx: number): boolean {
// Consecutive `>` lines belong to one blockquote, keep the single `\n` between them.
if (prevLineIsBlockquote(md, newlineIdx) && nextLineContinuesBlockquote(md, newlineIdx)) {
return false;
}
+ // Keep single `\n` between list items (siblings) and before nested sublists (2- or 4-space indent).
+ if (nextLineIsSiblingListItem(md, newlineIdx) || nextLineIsNestedListItem(md, newlineIdx)) {
+ return false;
+ }
if (nextLineIsBlockStarter(md, newlineIdx)) return true;
// CommonMark lazy continuation keeps non-`>` lines inside blockquotes, close on single `\n`.
if (prevLineIsBlockquote(md, newlineIdx) && !nextLineContinuesBlockquote(md, newlineIdx)) {
diff --git a/src/app/plugins/markdown/extensions/matrix-math.ts b/src/app/plugins/markdown/extensions/matrix-math.ts
index 21265f70f..26248a0b8 100644
--- a/src/app/plugins/markdown/extensions/matrix-math.ts
+++ b/src/app/plugins/markdown/extensions/matrix-math.ts
@@ -221,12 +221,18 @@ function isIgnorableMathContent(latex: string): boolean {
* - the closing `$` is not preceded by whitespace, and
* - the closing `$` is not immediately followed by an ASCII digit.
*/
+/** Opening `$[fg.color=…]` / `$[bg.color=…]` */
+const MFM_COLOR_FN_OPEN = /^\$\[(?:fg|bg)\.color=/;
+
function tryTokenizeInlineMath(
src: string
): { type: 'math'; raw: string; latex: string } | undefined {
if (!src.startsWith('$')) {
return undefined;
}
+ if (MFM_COLOR_FN_OPEN.test(src)) {
+ return undefined;
+ }
if (src.startsWith('$$') && (src.length < 3 || src.charAt(2) !== '$')) {
return undefined;
}
@@ -256,7 +262,7 @@ export const matrixMathExtension = {
name: 'math',
level: 'inline',
start(src: string) {
- if (/^\$\[(?:fg|bg)\.color=/.test(src)) return -1;
+ if (MFM_COLOR_FN_OPEN.test(src)) return -1;
return src.indexOf('$');
},
tokenizer(src: string) {
diff --git a/src/app/plugins/markdown/htmlToMarkdown.test.ts b/src/app/plugins/markdown/htmlToMarkdown.test.ts
index 57e5e25bd..219e67089 100644
--- a/src/app/plugins/markdown/htmlToMarkdown.test.ts
+++ b/src/app/plugins/markdown/htmlToMarkdown.test.ts
@@ -4,9 +4,12 @@ import {
MX_EMOTICON_MD_SEP,
MX_EMOTICON_MD_START,
} from './extensions/matrix-emoticon';
+import { toMatrixCustomHTML, trimCustomHtml } from '$components/editor/output';
import { plainToEditorInput } from '$components/editor/input';
import { BlockType } from '$components/editor/types';
+import { injectDataMd } from './injectDataMd';
import { htmlToMarkdown } from './htmlToMarkdown';
+import { markdownToHtml } from './markdownToHtml';
describe('htmlToMarkdown', () => {
it('converts headings', () => {
@@ -125,6 +128,20 @@ describe('htmlToMarkdown', () => {
expect(result).toContain('Item 1');
});
+ it('indents nested sublists with four spaces per level', () => {
+ const html = 'parent
';
+ expect(htmlToMarkdown(html)).toContain('1. parent');
+ expect(htmlToMarkdown(html)).toContain(' - child');
+ });
+
+ it('edit-load and save round-trip keeps nested sublist', () => {
+ const md = '1. test\n - sub\n';
+ const loaded = htmlToMarkdown(injectDataMd(markdownToHtml(md)));
+ expect(loaded).toContain(' - sub');
+ const html = trimCustomHtml(toMatrixCustomHTML(plainToEditorInput(loaded), {}));
+ expect(html).toMatch(/- [\s\S]*
{
const result = htmlToMarkdown('bold');
expect(result).toContain('**bold**');
diff --git a/src/app/plugins/markdown/htmlToMarkdown.ts b/src/app/plugins/markdown/htmlToMarkdown.ts
index cf00d0dd4..0e3756d8d 100644
--- a/src/app/plugins/markdown/htmlToMarkdown.ts
+++ b/src/app/plugins/markdown/htmlToMarkdown.ts
@@ -11,6 +11,9 @@ import { isAllowedHtmlTag } from './allowedHtmlTags';
import { formatMfmColorDataMd } from './extensions/matrix-mfm-color';
import { isMatrixHexColor } from '$utils/matrixHtml';
+/** CommonMark list nesting indent (four spaces per level). */
+const LIST_MARKDOWN_INDENT = ' ';
+
/**
* Converts Matrix-compatible HTML back to markdown for round-trip editing.
* Preserves original markdown syntax via data-md attributes and converts
@@ -419,7 +422,7 @@ function processUnorderedList(
insideCode: boolean = false
): string {
const mdSequence = node.attribs['data-md'] || '-';
- const indent = ' '.repeat(depth);
+ const indent = LIST_MARKDOWN_INDENT.repeat(depth);
const items = node.children
.filter((c): c is Element => isTag(c) && c.name === 'li')
.map((li) => {
@@ -439,7 +442,7 @@ function processOrderedList(node: Element, depth: number = 0, insideCode: boolea
? mdSequence
: `${mdSequence}.`;
- const indent = ' '.repeat(depth);
+ const indent = LIST_MARKDOWN_INDENT.repeat(depth);
const items = node.children
.filter((c): c is Element => isTag(c) && c.name === 'li')
.map((li, index) => {
diff --git a/src/app/plugins/react-custom-html-parser.test.tsx b/src/app/plugins/react-custom-html-parser.test.tsx
index 5f0cb8fb3..c29158224 100644
--- a/src/app/plugins/react-custom-html-parser.test.tsx
+++ b/src/app/plugins/react-custom-html-parser.test.tsx
@@ -446,4 +446,15 @@ describe('react custom html parser', () => {
expect(screen.queryByText('<test>')).not.toBeInTheDocument();
}
);
+
+ it('unwraps paragraph tags inside list items instead of rendering block breaks', () => {
+ const { container } = renderMessage(
+ 'one
two
'
+ );
+
+ expect(container.querySelector('p')).toBeNull();
+ expect(container.textContent).toContain('one');
+ expect(container.textContent).toContain('two');
+ expect(container.textContent).toContain('bullet');
+ });
});
diff --git a/src/app/plugins/react-custom-html-parser.tsx b/src/app/plugins/react-custom-html-parser.tsx
index 8a15df7ea..adb78f3a6 100644
--- a/src/app/plugins/react-custom-html-parser.tsx
+++ b/src/app/plugins/react-custom-html-parser.tsx
@@ -111,7 +111,7 @@ function KatexRenderer({
useEffect(() => {
let mounted = true;
- Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => {
+ void Promise.all([import('katex'), import('katex/dist/katex.min.css')]).then(([katex]) => {
if (mounted) {
setHtml(katex.default.renderToString(math, { throwOnError: false, displayMode }));
}
@@ -430,7 +430,7 @@ export function CodeBlock({
const [copied, setCopied] = useTimeoutToggle();
const handleCopy = () => {
- copyToClipboard(extractTextFromChildren(children));
+ void copyToClipboard(extractTextFromChildren(children));
setCopied();
};
@@ -631,6 +631,9 @@ export const getReactCustomHtmlParser = (
}
if (name === 'p') {
+ if (parent instanceof Element && parent.name === 'li') {
+ return <>{renderChildren()}>;
+ }
return (
{renderChildren()}
diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts
index 04e6b19ca..f1f587fa5 100644
--- a/src/app/state/settings.ts
+++ b/src/app/state/settings.ts
@@ -1,6 +1,7 @@
import { atom, type WritableAtom } from 'jotai';
import type { Store } from 'jotai/vanilla/store';
import { mobileOrTablet } from '$utils/user-agent';
+import type { IImageInfo } from '$types/matrix/common';
const STORAGE_KEY = 'settings';
export type DateFormat = 'D MMM YYYY' | 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'YYYY/MM/DD' | '';
@@ -56,14 +57,14 @@ export type ThemeRemoteTweakFavorite = {
export type RenderUserCardsMode = 'both' | 'light' | 'dark' | 'none';
/** Where to use crisp nearest-neighbor (pixelated) image scaling. */
-export type PixelatedImageRenderingMode = 'both' | 'chat' | 'viewer' | 'none';
+export type PixelatedImageRenderingMode = 'always' | 'smart' | 'never';
-export function isPixelatedChatRendering(mode: PixelatedImageRenderingMode): boolean {
- return mode === 'both' || mode === 'chat';
-}
-
-export function isPixelatedViewerRendering(mode: PixelatedImageRenderingMode): boolean {
- return mode === 'both' || mode === 'viewer';
+export function isPixelatedRendering(
+ mode: PixelatedImageRenderingMode,
+ info?: IImageInfo
+): boolean {
+ if (mode === 'smart') return !!info && !!info.w && !!info.h && (info.w < 192 || info.h < 192);
+ return mode === 'always';
}
export function shouldApplyUserHeroCards(
@@ -138,6 +139,8 @@ export interface Settings {
privacyBlurEmotes: boolean;
showPronouns: boolean;
parsePronouns: boolean;
+ pronounPillMaxCount: number;
+ pronounPillMaxLength: number;
renderGlobalNameColors: boolean;
renderUserCards: RenderUserCardsMode;
filterPronounsBasedOnLanguage?: boolean;
@@ -276,6 +279,8 @@ export const defaultSettings: Settings = {
privacyBlurEmotes: false,
showPronouns: true,
parsePronouns: true,
+ pronounPillMaxCount: 3,
+ pronounPillMaxLength: 16,
renderGlobalNameColors: true,
renderUserCards: 'both',
renderRoomColors: true,
@@ -300,7 +305,7 @@ export const defaultSettings: Settings = {
autoplayGifs: true,
autoplayStickers: true,
autoplayEmojis: true,
- pixelatedImageRendering: 'viewer',
+ pixelatedImageRendering: 'smart',
incomingInlineImagesDefaultHeight: 32,
incomingInlineImagesMaxHeight: 64,
linkPreviewImageMaxHeight: 640,
@@ -380,10 +385,9 @@ function migrateParsedLocalStorage(parsed: Record): void {
if (typeof parsed.pixelatedImageRendering === 'boolean') {
parsed.pixelatedImageRendering = parsed.pixelatedImageRendering ? 'both' : 'none';
} else if (
- parsed.pixelatedImageRendering !== 'both' &&
- parsed.pixelatedImageRendering !== 'chat' &&
- parsed.pixelatedImageRendering !== 'viewer' &&
- parsed.pixelatedImageRendering !== 'none'
+ parsed.pixelatedImageRendering !== 'always' &&
+ parsed.pixelatedImageRendering !== 'smart' &&
+ parsed.pixelatedImageRendering !== 'never'
) {
delete parsed.pixelatedImageRendering;
}
@@ -512,13 +516,19 @@ function sanitizeSettingsKey(key: keyof Settings, val: unknown): unknown {
? val
: undefined;
case 'pixelatedImageRendering':
- return val === 'both' || val === 'chat' || val === 'viewer' || val === 'none'
- ? val
- : undefined;
+ return val === 'always' || val === 'smart' || val === 'never' ? val : undefined;
case 'jumboEmojiSize':
return typeof val === 'string' && JUMBO_EMOJI_VALUES.has(val as JumboEmojiSize)
? val
: undefined;
+ case 'pronounPillMaxCount':
+ return typeof val === 'number' && Number.isInteger(val) && val >= 1 && val <= 10
+ ? val
+ : undefined;
+ case 'pronounPillMaxLength':
+ return typeof val === 'number' && Number.isInteger(val) && val >= 1 && val <= 64
+ ? val
+ : undefined;
case 'themeRemoteManualKind':
case 'themeRemoteLightKind':
case 'themeRemoteDarkKind':