diff --git a/.changeset/fix-weird-empty-items-list.md b/.changeset/fix-weird-empty-items-list.md new file mode 100644 index 000000000..6595b3ad9 --- /dev/null +++ b/.changeset/fix-weird-empty-items-list.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix lists with empty items looking wrong on FireFox diff --git a/src/app/components/editor/input.ts b/src/app/components/editor/input.ts index b2476e437..8f6b3c17d 100644 --- a/src/app/components/editor/input.ts +++ b/src/app/components/editor/input.ts @@ -139,6 +139,7 @@ const getInlineElement = (node: ChildNode, processText: ProcessTextCallback): In } if (isTag(node)) { + if (node.name === 'p' && node?.children?.length === 0) return [{ text: '' }]; const markType = getInlineNodeMarkType(node); if (markType) { return getInlineMarkElement(markType, node, (child) => { diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 399228cc2..83289090a 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -106,10 +106,15 @@ export function MText({ const customBody = typeof content.formatted_body === 'string' ? content.formatted_body : undefined; + const cleanedMessage = useMemo( + () => customBody?.replace(/
  • (

    <\/p>)?<\/li>/gi, '


  • '), + [customBody] + ); + const trimmedBody = useMemo(() => trimReplyFromBody(body), [body]); const unwrappedForwardedContent = useMemo( - () => unwrapForwardedContent(customBody ?? body), - [customBody, body] + () => unwrapForwardedContent(cleanedMessage ?? customBody ?? body), + [cleanedMessage, customBody, body] ); const isForwarded = useMemo(() => { @@ -121,8 +126,9 @@ export function MText({ * For the unwrapping of per-message profile fallbacks, we look for tags with the data-mx-profile-fallback attribute */ const unwrappedPerMessageProfileMessage = useMemo( - () => customBody?.replace(/]*data-mx-profile-fallback[^>]*>(.*?):\s*<\/strong>/i, ''), - [customBody] + () => + cleanedMessage?.replace(/]*data-mx-profile-fallback[^>]*>(.*?):\s*<\/strong>/i, ''), + [cleanedMessage] ); const isJumbo = useMemo(() => { @@ -189,13 +195,13 @@ export function MText({ return ( <> {renderBody({ body: trimmedBody, - customBody: typeof customBody === 'string' ? customBody : undefined, + customBody: typeof cleanedMessage === 'string' ? cleanedMessage : undefined, })} {edited && }