Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
Checks / checks (push) Successful in 2m11s
Trigger cinny-mobile / dispatch (push) Successful in 1s

This commit is contained in:
2026-11-01 04:23:53 +11:00
parent 3cd159a63e
commit a6ad8651b3
605 changed files with 11480 additions and 9125 deletions
+52 -28
View File
@@ -1,4 +1,3 @@
/* eslint-disable jsx-a11y/alt-text */
import React, {
ComponentPropsWithoutRef,
MouseEvent,
@@ -32,11 +31,12 @@ import {
Text,
toRem,
} from 'folds';
import { Icon, Icons } from '../components/icons';
import { IntermediateRepresentation, Opts as LinkifyOpts, OptFn } from 'linkifyjs';
import Linkify from 'linkify-react';
import { ErrorBoundary } from 'react-error-boundary';
import { ChildNode } from 'domhandler';
import FocusTrap from 'focus-trap-react';
import { Icon, Icons } from '../components/icons';
import * as css from '../styles/CustomHtml.css';
import {
getMxIdLocalPart,
@@ -59,12 +59,7 @@ import { copyToClipboard, tryDecodeURIComponent } from '../utils/dom';
import { useTimeoutToggle } from '../hooks/useTimeoutToggle';
import { settingsAtom } from '../state/settings';
import { useSetting } from '../state/hooks/settings';
import FocusTrap from 'focus-trap-react';
import {
AUTO_LANGUAGE,
LANGUAGE_OPTIONS,
PLAIN_LANGUAGE,
} from './react-prism/languages';
import { AUTO_LANGUAGE, LANGUAGE_OPTIONS, PLAIN_LANGUAGE } from './react-prism/languages';
import { AuthenticatedImg } from '../components/authenticated-media';
import { openExternalUrl } from '../utils/tauri';
@@ -75,7 +70,7 @@ const PrismCode = lazy(() => import('./react-prism/PrismCode'));
* Click handler for external links - uses Tauri shell on desktop/mobile
*/
const handleExternalLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
const href = e.currentTarget.href;
const { href } = e.currentTarget;
console.log('[handleExternalLinkClick] clicked link:', href);
if (href && (href.startsWith('http://') || href.startsWith('https://'))) {
e.preventDefault();
@@ -99,7 +94,7 @@ export const LINKIFY_OPTS: LinkifyOpts = {
export const makeMentionCustomProps = (
handleMentionClick?: ReactEventHandler<HTMLElement>,
content?: string
content?: string,
): ComponentPropsWithoutRef<'a'> => ({
style: { cursor: 'pointer' },
target: '_blank',
@@ -115,7 +110,7 @@ export const renderMatrixMention = (
mx: MatrixClient,
currentRoomId: string | undefined,
href: string,
customProps: ComponentPropsWithoutRef<'a'>
customProps: ComponentPropsWithoutRef<'a'>,
) => {
const userId = parseMatrixToUser(href);
if (userId) {
@@ -140,7 +135,7 @@ export const renderMatrixMention = (
if (matrixToRoom) {
const { roomIdOrAlias, viaServers } = matrixToRoom;
const mentionRoom = mx.getRoom(
isRoomAlias(roomIdOrAlias) ? getCanonicalAliasRoomId(mx, roomIdOrAlias) : roomIdOrAlias
isRoomAlias(roomIdOrAlias) ? getCanonicalAliasRoomId(mx, roomIdOrAlias) : roomIdOrAlias,
);
const fallbackContent = mentionRoom ? `#${mentionRoom.name}` : roomIdOrAlias;
@@ -164,7 +159,7 @@ export const renderMatrixMention = (
if (matrixToRoomEvent) {
const { roomIdOrAlias, eventId, viaServers } = matrixToRoomEvent;
const mentionRoom = mx.getRoom(
isRoomAlias(roomIdOrAlias) ? getCanonicalAliasRoomId(mx, roomIdOrAlias) : roomIdOrAlias
isRoomAlias(roomIdOrAlias) ? getCanonicalAliasRoomId(mx, roomIdOrAlias) : roomIdOrAlias,
);
return (
@@ -189,7 +184,7 @@ export const renderMatrixMention = (
};
export const factoryRenderLinkifyWithMention = (
mentionRender: (href: string) => JSX.Element | undefined
mentionRender: (href: string) => JSX.Element | undefined,
): OptFn<(ir: IntermediateRepresentation) => any> => {
const render: OptFn<(ir: IntermediateRepresentation) => any> = ({
tagName,
@@ -201,7 +196,11 @@ export const factoryRenderLinkifyWithMention = (
if (mention) return mention;
}
return <a {...attributes} onClick={handleExternalLinkClick}>{content}</a>;
return (
<a {...attributes} onClick={handleExternalLinkClick}>
{content}
</a>
);
};
return render;
};
@@ -211,13 +210,17 @@ export const scaleSystemEmoji = (text: string): (string | JSX.Element)[] =>
text,
EMOJI_REG_G,
(match, pushIndex) => (
<span key={`scaleSystemEmoji-${pushIndex}`} className={css.EmoticonBase} data-emoticon={match[0]}>
<span
key={`scaleSystemEmoji-${pushIndex}`}
className={css.EmoticonBase}
data-emoticon={match[0]}
>
<span className={css.Emoticon()} title={getShortcodeFor(getHexcodeForEmoji(match[0]))}>
{match[0]}
</span>
</span>
),
(txt) => txt
(txt) => txt,
);
export const makeHighlightRegex = (highlights: string[]): RegExp | undefined => {
@@ -228,7 +231,7 @@ export const makeHighlightRegex = (highlights: string[]): RegExp | undefined =>
export const highlightText = (
regex: RegExp,
data: (string | JSX.Element)[]
data: (string | JSX.Element)[],
): (string | JSX.Element)[] =>
data.flatMap((text) => {
if (typeof text !== 'string') return text;
@@ -241,7 +244,7 @@ export const highlightText = (
{match[0]}
</span>
),
(txt) => txt
(txt) => txt,
);
});
@@ -296,7 +299,7 @@ export function CodeBlock({ children }: { children: ChildNode[] }) {
override === AUTO_LANGUAGE ? language : override === PLAIN_LANGUAGE ? undefined : override;
const languageLabel =
override === AUTO_LANGUAGE
? language ?? 'Code'
? (language ?? 'Code')
: (LANGUAGE_OPTIONS.find((option) => option.value === override)?.label ?? override);
const handleCopy = () => {
@@ -378,8 +381,14 @@ export function CodeBlock({ children }: { children: ChildNode[] }) {
copied ? (
<Icon size="50" src={Icons.Check} />
) : (
<svg width="12" height="12" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="M3 5V12.73C2.4 12.38 2 11.74 2 11V5C2 2.79 3.79 1 6 1H9C9.74 1 10.38 1.4 10.73 2H6C4.35 2 3 3.35 3 5ZM11 15H6C4.897 15 4 14.103 4 13V5C4 3.897 4.897 3 6 3H11C12.103 3 13 3.897 13 5V13C13 14.103 12.103 15 11 15ZM12 5C12 4.448 11.552 4 11 4H6C5.448 4 5 4.448 5 5V13C5 13.552 5.448 14 6 14H11C11.552 14 12 13.552 12 13V5Z"/>
<svg
width="12"
height="12"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
>
<path d="M3 5V12.73C2.4 12.38 2 11.74 2 11V5C2 2.79 3.79 1 6 1H9C9.74 1 10.38 1.4 10.73 2H6C4.35 2 3 3.35 3 5ZM11 15H6C4.897 15 4 14.103 4 13V5C4 3.897 4.897 3 6 3H11C12.103 3 13 3.897 13 5V13C13 14.103 12.103 15 11 15ZM12 5C12 4.448 11.552 4 11 4H6C5.448 4 5 4.448 5 5V13C5 13.552 5.448 14 6 14H11C11.552 14 12 13.552 12 13V5Z" />
</svg>
)
}
@@ -499,8 +508,14 @@ export function InlineCode({
{copied ? (
<Icon size="50" src={Icons.Check} />
) : (
<svg width="12" height="12" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="M3 5V12.73C2.4 12.38 2 11.74 2 11V5C2 2.79 3.79 1 6 1H9C9.74 1 10.38 1.4 10.73 2H6C4.35 2 3 3.35 3 5ZM11 15H6C4.897 15 4 14.103 4 13V5C4 3.897 4.897 3 6 3H11C12.103 3 13 3.897 13 5V13C13 14.103 12.103 15 11 15ZM12 5C12 4.448 11.552 4 11 4H6C5.448 4 5 4.448 5 5V13C5 13.552 5.448 14 6 14H11C11.552 14 12 13.552 12 13V5Z"/>
<svg
width="12"
height="12"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
>
<path d="M3 5V12.73C2.4 12.38 2 11.74 2 11V5C2 2.79 3.79 1 6 1H9C9.74 1 10.38 1.4 10.73 2H6C4.35 2 3 3.35 3 5ZM11 15H6C4.897 15 4 14.103 4 13V5C4 3.897 4.897 3 6 3H11C12.103 3 13 3.897 13 5V13C13 14.103 12.103 15 11 15ZM12 5C12 4.448 11.552 4 11 4H6C5.448 4 5 4.448 5 5V13C5 13.552 5.448 14 6 14H11C11.552 14 12 13.552 12 13V5Z" />
</svg>
)}
</span>
@@ -520,7 +535,7 @@ export const getReactCustomHtmlParser = (
handleSpoilerClick?: ReactEventHandler<HTMLElement>;
handleMentionClick?: ReactEventHandler<HTMLElement>;
useAuthentication?: boolean;
}
},
): HTMLReactParserOptions => {
const opts: HTMLReactParserOptions = {
replace: (domNode) => {
@@ -634,7 +649,11 @@ export const getReactCustomHtmlParser = (
);
}
} else {
return <InlineCode opts={opts} props={props}>{children}</InlineCode>;
return (
<InlineCode opts={opts} props={props}>
{children}
</InlineCode>
);
}
}
@@ -650,7 +669,7 @@ export const getReactCustomHtmlParser = (
mx,
roomId,
href,
makeMentionCustomProps(params.handleMentionClick, content)
makeMentionCustomProps(params.handleMentionClick, content),
);
if (mention) return mention;
@@ -686,7 +705,12 @@ export const getReactCustomHtmlParser = (
const htmlSrc = mxcUrlToHttp(mx, props.src, params.useAuthentication);
if (htmlSrc && props.src.startsWith('mxc://') === false) {
return (
<a href={htmlSrc} target="_blank" rel="noreferrer noopener" onClick={handleExternalLinkClick}>
<a
href={htmlSrc}
target="_blank"
rel="noreferrer noopener"
onClick={handleExternalLinkClick}
>
{props.alt || props.title || htmlSrc}
</a>
);