feat: implement room list reordering and animation hooks; add scroll to latest behavior settings
This commit is contained in:
@@ -289,7 +289,15 @@ export function CodeBlock({
|
||||
fill="None"
|
||||
radii="Pill"
|
||||
onClick={handleCopy}
|
||||
before={copied && <Icon size="50" src={Icons.Check} />}
|
||||
before={
|
||||
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>
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text size="B300">{copied ? 'Copied' : 'Copy'}</Text>
|
||||
</Chip>
|
||||
@@ -327,6 +335,41 @@ export function CodeBlock({
|
||||
);
|
||||
}
|
||||
|
||||
export function InlineCode({
|
||||
children,
|
||||
opts,
|
||||
props,
|
||||
}: {
|
||||
children: ChildNode[];
|
||||
opts: HTMLReactParserOptions;
|
||||
props: any;
|
||||
}) {
|
||||
const [copied, setCopied] = useTimeoutToggle();
|
||||
|
||||
const handleCopy = (e: MouseEvent<HTMLSpanElement>) => {
|
||||
e.stopPropagation();
|
||||
copyToClipboard(extractTextFromChildren(children));
|
||||
setCopied();
|
||||
};
|
||||
|
||||
return (
|
||||
<span className={css.InlineCodeWrapper}>
|
||||
<span className={css.InlineCodeCopyButton} onClick={handleCopy}>
|
||||
{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>
|
||||
)}
|
||||
</span>
|
||||
<Text as="code" size="T300" className={css.Code} {...props}>
|
||||
{domToReact(children, opts)}
|
||||
</Text>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export const getReactCustomHtmlParser = (
|
||||
mx: MatrixClient,
|
||||
roomId: string | undefined,
|
||||
@@ -450,11 +493,7 @@ export const getReactCustomHtmlParser = (
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
<Text as="code" size="T300" className={css.Code} {...props}>
|
||||
{domToReact(children, opts)}
|
||||
</Text>
|
||||
);
|
||||
return <InlineCode opts={opts} props={props}>{children}</InlineCode>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user