5 Commits
Author SHA1 Message Date
litruv ec7b4f04c5 Resync index.css onto the base and keep the mobile and stationery additions.
Checks / checks (push) Successful in 1m59s
Trigger cinny-mobile / dispatch (push) Successful in 1s
2026-11-03 09:30:12 +11:00
litruv fcfb40549a Raise ContainerColor's specificity so the theme text color beats folds' DefaultReset in any stylesheet order. 2026-11-03 09:30:11 +11:00
litruv 9b3956d85f Turn off the prism index-key rule and drop the stale directives.
Checks / checks (push) Successful in 2m0s
Trigger cinny-mobile / dispatch (push) Successful in 1s
2026-11-03 02:53:34 +11:00
litruv f81461c044 Merge the mutually recursive CSS scope helpers. [skip build]
Checks / checks (push) Successful in 2m0s
Trigger cinny-mobile / dispatch (push) Successful in 1s
2026-11-03 02:32:08 +11:00
litruv 96d0d27549 Remove the TikTok embeds and the raw oEmbed HTML injection. [skip build] 2026-11-03 02:25:42 +11:00
13 changed files with 215 additions and 440 deletions
+3
View File
@@ -117,6 +117,9 @@ export default [
// Matrix video events carry no caption field, so there is no caption source to read.
'jsx-a11y/media-has-caption': 'off',
// Prism tokens are not unique within a line, so the array index is the only key available.
'react/no-array-index-key': 'off',
},
},
].flatMap((config) =>
@@ -136,7 +136,6 @@ function CompareEmoji({ sasData }: { sasData: ShowSasCallbacks }) {
>
{sasData.sas.emoji?.map(([emoji, name], index) => (
<Box
// eslint-disable-next-line react/no-array-index-key
key={`${emoji}${name}${index}`}
direction="Column"
gap="100"
+1 -10
View File
@@ -30,8 +30,6 @@ import {
UrlPreviewHolder,
YouTubeEmbed,
isYouTubeUrl,
TikTokEmbed,
isTikTokUrl,
GiphyEmbed,
isGiphyUrl,
} from './url-preview';
@@ -88,11 +86,8 @@ export function RenderMessageContent({
// Separate special URLs from generic ones
const youtubeUrls = filteredUrls.filter(isYouTubeUrl);
const tiktokUrls = filteredUrls.filter(isTikTokUrl);
const giphyUrls = filteredUrls.filter(isGiphyUrl);
const otherUrls = filteredUrls.filter(
(url) => !isYouTubeUrl(url) && !isTikTokUrl(url) && !isGiphyUrl(url),
);
const otherUrls = filteredUrls.filter((url) => !isYouTubeUrl(url) && !isGiphyUrl(url));
return (
<>
@@ -100,10 +95,6 @@ export function RenderMessageContent({
{youtubeUrls.map((url) => (
<YouTubeEmbed key={url} url={url} />
))}
{/* Render TikTok embeds */}
{tiktokUrls.map((url) => (
<TikTokEmbed key={url} url={url} />
))}
{/* Render Giphy embeds */}
{giphyUrls.map((url) => (
<GiphyEmbed key={url} url={url} />
@@ -1,117 +0,0 @@
import { style } from '@vanilla-extract/css';
import { DefaultReset, color, config, toRem } from 'folds';
export const TikTokEmbed = style([
DefaultReset,
{
width: toRem(360),
maxWidth: '100%',
backgroundColor: color.SurfaceVariant.Container,
border: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`,
borderRadius: config.radii.R300,
overflow: 'hidden',
},
]);
export const TikTokEmbedHeader = style([
DefaultReset,
{
padding: `${config.space.S200} ${config.space.S300}`,
backgroundColor: color.SurfaceVariant.ContainerActive,
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: config.space.S200,
},
]);
export const TikTokEmbedInfo = style([
DefaultReset,
{
display: 'flex',
flexDirection: 'column',
gap: config.space.S100,
flex: 1,
minWidth: 0,
},
]);
export const TikTokEmbedTitle = style({
color: color.Primary.Main,
textDecoration: 'none',
fontWeight: config.fontWeight.W500,
':hover': {
textDecoration: 'underline',
},
});
export const TikTokEmbedAuthor = style({
color: color.SurfaceVariant.OnContainer,
textDecoration: 'none',
opacity: 0.8,
':hover': {
textDecoration: 'underline',
opacity: 1,
},
});
export const TikTokEmbedLink = style({
color: color.Success.Main,
textDecoration: 'none',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
':hover': {
textDecoration: 'underline',
},
});
export const TikTokThumbnailContainer = style([
DefaultReset,
{
position: 'relative',
width: '100%',
height: toRem(550),
backgroundColor: '#000',
display: 'block',
},
]);
export const TikTokThumbnailButton = style([
DefaultReset,
{
position: 'relative',
width: '100%',
height: toRem(550),
border: 'none',
padding: 0,
cursor: 'pointer',
backgroundColor: '#000',
display: 'block',
overflow: 'hidden',
},
]);
export const TikTokThumbnail = style([
DefaultReset,
{
width: '100%',
height: '100%',
display: 'block',
objectFit: 'cover',
objectPosition: 'center',
},
]);
export const TikTokEmbedContainer = style([
DefaultReset,
{
width: '100%',
height: toRem(550),
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#000',
border: 'none',
display: 'block',
},
]);
@@ -1,277 +0,0 @@
import React, { MouseEvent, useEffect, useState } from 'react';
import { Box, Spinner, Text, as } from 'folds';
import * as css from './TikTokEmbed.css';
import { openExternalUrl } from '../../utils/tauri';
/**
* Regex patterns to match TikTok URLs
*/
const TIKTOK_URL_PATTERNS = [
// Standard tiktok.com/@username/video/VIDEO_ID
/(?:https?:\/\/)?(?:www\.)?tiktok\.com\/@[\w.-]+\/video\/(\d+)/i,
// Short vm.tiktok.com/VIDEO_CODE
/(?:https?:\/\/)?(?:www\.)?vm\.tiktok\.com\/([\w]+)/i,
// Short vt.tiktok.com/VIDEO_CODE
/(?:https?:\/\/)?(?:www\.)?vt\.tiktok\.com\/([\w]+)/i,
// Mobile m.tiktok.com
/(?:https?:\/\/)?(?:www\.)?m\.tiktok\.com\/v\/(\d+)/i,
];
/**
* TikTok oEmbed API base
*/
const TIKTOK_OEMBED_API = 'https://www.tiktok.com/oembed';
/**
* Click handler for external links - uses Tauri shell on desktop/mobile
*/
const handleExternalLinkClick = (e: MouseEvent<HTMLAnchorElement>) => {
const { href } = e.currentTarget;
if (href && (href.startsWith('http://') || href.startsWith('https://'))) {
e.preventDefault();
openExternalUrl(href);
}
};
/**
* Checks if a URL is a TikTok URL
* @param url The URL to check
* @returns True if the URL is a TikTok URL
*/
export function isTikTokUrl(url: string): boolean {
return TIKTOK_URL_PATTERNS.some((pattern) => pattern.test(url));
}
function extractTikTokVideoId(url: string, embedHtml = ''): string | null {
const urlMatch = url.match(/\/video\/(\d+)/i) ?? url.match(/\/v\/(\d+)/i);
const embedMatch = embedHtml.match(/data-video-id=["'](\d+)["']/i);
return urlMatch?.[1] ?? embedMatch?.[1] ?? null;
}
/**
* Fetches TikTok video metadata using oEmbed API
* @param url The TikTok video URL
* @returns Video metadata including title, author, and thumbnail
*/
async function fetchTikTokOEmbed(url: string): Promise<{
title: string;
authorName: string;
authorUrl: string;
thumbnailUrl: string;
embedHtml: string;
videoId: string | null;
} | null> {
try {
const { electron } = window as any;
let data;
if (electron?.tiktok?.getOEmbed) {
data = await electron.tiktok.getOEmbed(url);
} else {
const oembedUrl = `${TIKTOK_OEMBED_API}?url=${encodeURIComponent(url)}`;
const response = await fetch(oembedUrl);
if (!response.ok) return null;
data = await response.json();
}
if (!data) return null;
return {
title: data.title || 'TikTok Video',
authorName: data.author_name || 'Unknown',
authorUrl: data.author_url || url,
thumbnailUrl: data.thumbnail_url || '',
embedHtml: data.html || '',
videoId: extractTikTokVideoId(url, data.html || ''),
};
} catch {
return null;
}
}
type TikTokEmbedState =
| { status: 'loading' }
| {
status: 'loaded';
title: string;
authorName: string;
authorUrl: string;
thumbnailUrl: string;
embedHtml: string;
videoId: string | null;
}
| { status: 'error' };
type TikTokEmbedProps = {
/** The original TikTok URL */
url: string;
};
/**
* TikTok embed component that shows video preview with metadata
*/
export const TikTokEmbed = as<'div', TikTokEmbedProps>(({ url, ...props }, ref) => {
const [state, setState] = useState<TikTokEmbedState>({ status: 'loading' });
const [showPlayer, setShowPlayer] = useState(false);
// Fetch video info on mount
useEffect(() => {
let cancelled = false;
fetchTikTokOEmbed(url).then((info) => {
if (cancelled) return;
if (info) {
setState({
status: 'loaded',
title: info.title,
authorName: info.authorName,
authorUrl: info.authorUrl,
thumbnailUrl: info.thumbnailUrl,
embedHtml: info.embedHtml,
videoId: info.videoId,
});
} else {
setState({ status: 'error' });
}
});
return () => {
cancelled = true;
};
}, [url]);
// Loading state
if (state.status === 'loading') {
return (
<Box shrink="No" className={css.TikTokEmbed} direction="Column" {...props} ref={ref}>
<div className={css.TikTokEmbedHeader}>
<Text
as="a"
href={url}
target="_blank"
rel="noopener noreferrer"
size="T200"
className={css.TikTokEmbedLink}
onClick={handleExternalLinkClick}
truncate
>
TikTok - Loading...
</Text>
</div>
<Box
className={css.TikTokThumbnailContainer}
alignItems="Center"
justifyContent="Center"
style={{ background: '#000', display: 'flex' }}
>
<Spinner variant="Secondary" size="600" />
</Box>
</Box>
);
}
// Error state - show basic link
if (state.status === 'error') {
return (
<Box shrink="No" className={css.TikTokEmbed} direction="Column" {...props} ref={ref}>
<div className={css.TikTokEmbedHeader}>
<Text
as="a"
href={url}
target="_blank"
rel="noopener noreferrer"
size="T200"
className={css.TikTokEmbedLink}
onClick={handleExternalLinkClick}
truncate
>
TikTok Video
</Text>
</div>
</Box>
);
}
// Loaded state - show thumbnail or embed
if (!showPlayer) {
return (
<Box shrink="No" className={css.TikTokEmbed} direction="Column" {...props} ref={ref}>
<div className={css.TikTokEmbedHeader}>
<div className={css.TikTokEmbedInfo}>
<Text
as="a"
href={url}
target="_blank"
rel="noopener noreferrer"
size="T300"
className={css.TikTokEmbedTitle}
onClick={handleExternalLinkClick}
truncate
>
{state.title}
</Text>
<Text
as="a"
href={state.authorUrl}
target="_blank"
rel="noopener noreferrer"
size="T200"
className={css.TikTokEmbedAuthor}
onClick={handleExternalLinkClick}
truncate
>
{state.authorName}
</Text>
</div>
</div>
<button
type="button"
className={css.TikTokThumbnailButton}
onClick={() => setShowPlayer(true)}
aria-label="Play TikTok video"
>
{state.thumbnailUrl ? (
<img src={state.thumbnailUrl} alt={state.title} className={css.TikTokThumbnail} />
) : null}
</button>
</Box>
);
}
const playerUrl = state.videoId
? `https://www.tiktok.com/player/v1/${state.videoId}?autoplay=1`
: null;
// Use TikTok's documented player instead of injecting the oEmbed script.
return (
<Box shrink="No" className={css.TikTokEmbed} direction="Column" {...props} ref={ref}>
<div className={css.TikTokEmbedHeader}>
<Text
as="a"
href={url}
target="_blank"
rel="noopener noreferrer"
size="T200"
className={css.TikTokEmbedLink}
onClick={handleExternalLinkClick}
truncate
>
{state.title}
</Text>
</div>
{playerUrl ? (
<iframe
className={css.TikTokEmbedContainer}
src={playerUrl}
title="TikTok video player"
allow="autoplay; encrypted-media; fullscreen; picture-in-picture"
allowFullScreen
/>
) : (
<div
className={css.TikTokEmbedContainer}
dangerouslySetInnerHTML={{ __html: state.embedHtml }}
/>
)}
</Box>
);
});
-1
View File
@@ -1,5 +1,4 @@
export * from './UrlPreview';
export * from './UrlPreviewCard';
export * from './YouTubeEmbed';
export * from './TikTokEmbed';
export * from './GiphyEmbed';
@@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Badge, Box, Button, Chip, config, Menu, Spinner, Text } from 'folds';
import { EventType } from 'matrix-js-sdk';
@@ -1,4 +1,3 @@
/* eslint-disable react/no-array-index-key */
import React, { useState, MouseEventHandler, ReactNode } from 'react';
import FocusTrap from 'focus-trap-react';
import {
@@ -180,7 +180,6 @@ export function ForumPostUploadField({
.reverse()
.map((fileItem, index) => (
<UploadCardRenderer
// eslint-disable-next-line react/no-array-index-key
key={index}
isEncrypted={!!fileItem.encInfo}
fileItem={fileItem}
+21 -29
View File
@@ -35,32 +35,7 @@ export function scopeRoomAppCss(css: string, scopeSelector: string): string {
return `${scoped}{${body}}`;
};
const rewriteBlock = (block: string): string => {
const trimmed = block.trim();
if (!trimmed) return '';
if (trimmed.startsWith('@')) {
const open = trimmed.indexOf('{');
if (open === -1) return `${trimmed};`;
const header = trimmed.slice(0, open).trim();
const inner = trimmed.slice(open + 1);
// @keyframes / @font-face: keep as-is (namespaced risk is low for MVP)
if (/^@(keyframes|font-face)\b/i.test(header)) {
return `${header}{${inner}}`;
}
// @media / @supports: re-scope nested rules
const nested = rewriteCssChunk(inner);
return `${header}{${nested}}`;
}
const open = trimmed.indexOf('{');
if (open === -1) return '';
const selectors = trimmed.slice(0, open);
const body = trimmed.slice(open + 1);
return scopeRule(selectors, body);
};
const rewriteCssChunk = (chunk: string): string => {
function rewriteChunk(chunk: string): string {
const parts: string[] = [];
let depth = 0;
let start = 0;
@@ -70,15 +45,32 @@ export function scopeRoomAppCss(css: string, scopeSelector: string): string {
else if (ch === '}') {
depth -= 1;
if (depth === 0) {
parts.push(rewriteBlock(chunk.slice(start, i)));
const block = chunk.slice(start, i).trim();
start = i + 1;
if (block) {
const open = block.indexOf('{');
if (open === -1) {
parts.push(`${block};`);
} else {
const header = block.slice(0, open).trim();
const inner = block.slice(open + 1);
if (!header.startsWith('@')) {
parts.push(scopeRule(header, inner));
} else if (/^@(keyframes|font-face)\b/i.test(header)) {
parts.push(`${header}{${inner}}`);
} else {
// @media / @supports: re-scope nested rules
parts.push(`${header}{${rewriteChunk(inner)}}`);
}
}
}
}
}
}
return parts.filter(Boolean).join('\n');
};
}
return rewriteCssChunk(sanitized);
return rewriteChunk(sanitized);
}
export function isAllowedRoomAppImageSrc(src: string): boolean {
-1
View File
@@ -635,7 +635,6 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
.reverse()
.map((fileItem, index) => (
<UploadCardRenderer
// eslint-disable-next-line react/no-array-index-key
key={index}
isEncrypted={!!fileItem.encInfo}
fileItem={fileItem}
+8 -1
View File
@@ -7,9 +7,16 @@ const getVariant = (variant: TContainerColor): ComplexStyleRule => ({
backgroundColor: color[variant].Container,
borderColor: color[variant].ContainerLine,
outlineColor: color[variant].ContainerLine,
color: color[variant].OnContainer,
},
selectors: {
// DefaultReset sets `color: inherit` with the same specificity as this rule,
// so which one wins depends on stylesheet order. In the Android build the
// ContainerColor chunk is emitted before folds' reset, so the theme color
// loses and text falls back to the initial color. Raise specificity so the
// theme color wins regardless of order.
'&[class]': {
color: color[variant].OnContainer,
},
'button&[aria-pressed=true]': {
backgroundColor: color[variant].ContainerActive,
},
+182
View File
@@ -2007,3 +2007,185 @@ textarea {
audio:not([controls]) {
display: none !important;
}
html.immersive-landscape-keyboard {
--safe-area-inset-top: 0px;
}
.twilight-theme [role='navigation'],
.twilight-theme aside {
background: linear-gradient(180deg, rgba(20, 18, 31, 0.8) 0%, rgba(28, 26, 46, 0.9) 100%);
backdrop-filter: blur(8px);
}
[data-route-transition='true'] {
animation: fadeSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@media (max-width: 750px) {
[data-route-transition='true'] {
animation: none;
}
}
html.mobile-gesture-lock,
html.mobile-gesture-lock body {
overscroll-behavior: none;
}
html.mobile-gesture-lock [data-timeline-scroll] {
overflow: hidden !important;
touch-action: none;
}
.twilight-theme [data-route-transition='true'] {
animation: fadeSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.twilight-theme button,
.twilight-theme [role='button'],
.twilight-theme a,
.twilight-theme input,
.twilight-theme textarea {
transition:
background-color 0.2s ease,
color 0.2s ease,
transform 0.15s ease;
}
.twilight-theme button:hover,
.twilight-theme [role='button']:hover {
transform: translateY(-1px);
}
.twilight-theme button:active,
.twilight-theme [role='button']:active {
transform: translateY(0);
}
.twilight-theme [data-selected='true'],
.twilight-theme [aria-selected='true'],
.twilight-theme [aria-current='true'] {
position: relative;
transition: all 0.2s ease;
}
.twilight-theme [data-selected='true']::before,
.twilight-theme [aria-selected='true']::before,
.twilight-theme [aria-current='true']::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background: linear-gradient(180deg, #8b7fff 0%, #6e62e8 100%);
transition: width 0.2s ease;
}
.twilight-theme ::-webkit-scrollbar-thumb:hover {
background: linear-gradient(180deg, #4a4580 0%, #625bac 100%);
}
.mocha-theme [role='navigation'],
.mocha-theme aside {
background: linear-gradient(180deg, rgba(26, 22, 20, 0.8) 0%, rgba(36, 32, 25, 0.9) 100%);
backdrop-filter: blur(8px);
}
.mocha-theme [data-route-transition='true'] {
animation: fadeSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.mocha-theme button,
.mocha-theme [role='button'],
.mocha-theme a,
.mocha-theme input,
.mocha-theme textarea {
transition:
background-color 0.2s ease,
color 0.2s ease,
transform 0.15s ease;
}
.mocha-theme button:hover,
.mocha-theme [role='button']:hover {
transform: translateY(-1px);
}
.mocha-theme button:active,
.mocha-theme [role='button']:active {
transform: translateY(0);
}
.mocha-theme [data-selected='true'],
.mocha-theme [aria-selected='true'],
.mocha-theme [aria-current='true'] {
position: relative;
transition: all 0.2s ease;
}
.mocha-theme [data-selected='true']::before,
.mocha-theme [aria-selected='true']::before,
.mocha-theme [aria-current='true']::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background: linear-gradient(180deg, #d4a574 0%, #b48660 100%);
transition: width 0.2s ease;
}
.mocha-theme ::-webkit-scrollbar-thumb:hover {
background: linear-gradient(180deg, #625548 0%, #7e6d5a 100%);
}
.stationery ::-webkit-scrollbar-thumb:hover {
background: linear-gradient(180deg, var(--manila-edge) 0%, var(--manila-dark) 100%);
}
html.android-capacitor,
html.android-capacitor.dark-theme,
html.android-capacitor.butter-theme,
html.android-capacitor.discord-theme,
html.android-capacitor.discord-darker-theme,
html.android-capacitor.twilight-theme,
html.android-capacitor.mocha-theme,
html.android-capacitor.light-theme,
html.android-capacitor.silver-theme,
html.android-capacitor.stationery-theme,
html.android-capacitor.stationery-dark-theme {
--font-secondary: system-ui, Roboto, 'Noto Sans', sans-serif;
}
html.android-capacitor body {
font-family: system-ui, Roboto, 'Noto Sans', sans-serif;
letter-spacing: normal;
word-spacing: normal;
font-variant-ligatures: normal;
}
@media (max-width: 750px) {
*,
*::before,
*::after {
scrollbar-width: none;
-ms-overflow-style: none;
}
*::-webkit-scrollbar,
*::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
display: none;
width: 0;
height: 0;
background: transparent;
}
.twilight-theme ::-webkit-scrollbar,
.twilight-theme ::-webkit-scrollbar-thumb,
.twilight-theme ::-webkit-scrollbar-track,
.mocha-theme ::-webkit-scrollbar,
.mocha-theme ::-webkit-scrollbar-thumb,
.mocha-theme ::-webkit-scrollbar-track {
display: none;
width: 0;
height: 0;
background: transparent;
}
}
html.android-capacitor,
html.android-capacitor *,
html.android-capacitor *::before,
html.android-capacitor *::after {
scrollbar-width: none;
-ms-overflow-style: none;
}
html.android-capacitor *::-webkit-scrollbar,
html.android-capacitor *::-webkit-scrollbar-thumb,
html.android-capacitor *::-webkit-scrollbar-track,
html.android-capacitor *::-webkit-scrollbar-corner {
display: none;
width: 0;
height: 0;
background: transparent;
}