Compare commits
1
Commits
664b7eb739
...
eaa9ac00dd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaa9ac00dd |
@@ -5,6 +5,7 @@ import { Icon, Icons } from '../icons';
|
||||
import * as css from './ImageViewer.css';
|
||||
import { downloadAndSaveMedia } from '../../utils/saveMedia';
|
||||
import { getCurrentAccessToken } from '../../utils/auth';
|
||||
import { onEnterOrSpace } from '../../utils/keyboard';
|
||||
|
||||
const ZOOM_MIN = 1;
|
||||
const ZOOM_MAX = 5;
|
||||
@@ -270,6 +271,14 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
}
|
||||
};
|
||||
|
||||
const toggleZoomAt = (x: number, y: number) => {
|
||||
if (zoomRef.current.scale <= 1.01) {
|
||||
zoomAround(x, y, ZOOM_CLICK);
|
||||
} else {
|
||||
resetZoom();
|
||||
}
|
||||
};
|
||||
|
||||
const handleClick = (event: React.MouseEvent) => {
|
||||
if (suppressClickRef.current) {
|
||||
suppressClickRef.current = false;
|
||||
@@ -283,13 +292,16 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
if (!img?.src) return;
|
||||
event.preventDefault();
|
||||
const { x, y } = framePoint(event.clientX, event.clientY);
|
||||
if (zoomRef.current.scale <= 1.01) {
|
||||
zoomAround(x, y, ZOOM_CLICK);
|
||||
} else {
|
||||
resetZoom();
|
||||
}
|
||||
toggleZoomAt(x, y);
|
||||
};
|
||||
|
||||
// Keyboard activation has no pointer position, so it zooms around the frame centre.
|
||||
const handleKeyDown = onEnterOrSpace(() => {
|
||||
const frame = frameRef.current;
|
||||
if (!frame || !imgRef.current?.src) return;
|
||||
toggleZoomAt(frame.clientWidth / 2, frame.clientHeight / 2);
|
||||
});
|
||||
|
||||
const handlePointerDown = (event: React.PointerEvent) => {
|
||||
if (event.button !== 0 && event.pointerType === 'mouse') return;
|
||||
|
||||
@@ -410,6 +422,10 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
||||
<div
|
||||
ref={frameRef}
|
||||
className={css.Frame}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label={alt || undefined}
|
||||
onKeyDown={handleKeyDown}
|
||||
data-zoomed={zoomed || undefined}
|
||||
data-pannable={zoomed || undefined}
|
||||
data-dragging={dragging || undefined}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from 'matrix-js-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { onEnterOrSpace } from '../../utils/keyboard';
|
||||
import { WindowControls } from './WindowControls';
|
||||
import { UpdateNotification } from '../update-notification';
|
||||
import * as css from './TitleBar.css';
|
||||
@@ -688,6 +689,9 @@ export function TitleBar({ mx, children }: TitleBarProps) {
|
||||
{notifications.map((notification) => (
|
||||
<div
|
||||
key={notification.id}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={onEnterOrSpace(handleNotificationClick(notification))}
|
||||
className={`${css.NewMessagePill} ${notification.exiting ? css.NewMessagePillExiting : ''}`}
|
||||
onClick={handleNotificationClick(notification)}
|
||||
onMouseDown={(e) => e.stopPropagation()}
|
||||
|
||||
@@ -22,11 +22,10 @@ import { ProfileCollectibleOverlays } from './ProfileCollectibleOverlays';
|
||||
type UserHeroProps = {
|
||||
userId: string;
|
||||
avatarUrl?: string;
|
||||
avatarMxc?: string;
|
||||
presence?: UserPresence;
|
||||
children?: ReactNode;
|
||||
};
|
||||
export function UserHero({ userId, avatarUrl, avatarMxc, presence, children }: UserHeroProps) {
|
||||
export function UserHero({ userId, avatarUrl, presence, children }: UserHeroProps) {
|
||||
const [viewAvatar, setViewAvatar] = useState<string>();
|
||||
const bannerUrl = useOtherUserBanner(userId);
|
||||
const { assetUrls } = useOtherUserCollectibles(userId);
|
||||
|
||||
@@ -94,7 +94,6 @@ export function UserRoomProfile({ userId }: UserRoomProfileProps) {
|
||||
<UserHero
|
||||
userId={userId}
|
||||
avatarUrl={avatarUrl}
|
||||
avatarMxc={avatarMxc}
|
||||
presence={presence && presence.lastActiveTs !== 0 ? presence : undefined}
|
||||
>
|
||||
<Box
|
||||
|
||||
@@ -3,7 +3,6 @@ import { isKeyHotkey } from 'is-hotkey';
|
||||
import { Editor } from 'slate';
|
||||
import { IconButton, Line, PopOut } from 'folds';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { Icon, Icons } from '../../components/icons';
|
||||
import {
|
||||
CustomEditor,
|
||||
@@ -28,7 +27,6 @@ import { PluginButtonSlot } from '../settings/plugins/PluginButtonSlot';
|
||||
type ForumChatComposerProps = {
|
||||
editor: Editor;
|
||||
roomId: string;
|
||||
room: Room;
|
||||
placeholder?: string;
|
||||
onSend?: () => void;
|
||||
showAttachButton?: boolean;
|
||||
@@ -39,7 +37,6 @@ type ForumChatComposerProps = {
|
||||
export function ForumChatComposer({
|
||||
editor,
|
||||
roomId,
|
||||
room,
|
||||
placeholder = 'Send a message…',
|
||||
onSend,
|
||||
showAttachButton = false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { ChangeEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { Box, Text, Input, Avatar, Button, config, Spinner, color, toRem } from 'folds';
|
||||
import { HexColorPicker } from 'react-colorful';
|
||||
@@ -38,13 +38,7 @@ import {
|
||||
/**
|
||||
* Banner upload component for user's profile banner (MSC4427 via MSC4133).
|
||||
*/
|
||||
function ProfileBanner({
|
||||
avatarRef,
|
||||
nameRef,
|
||||
}: {
|
||||
avatarRef: React.RefObject<HTMLDivElement>;
|
||||
nameRef: React.RefObject<HTMLDivElement>;
|
||||
}) {
|
||||
function ProfileBanner() {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const userId = mx.getUserId()!;
|
||||
@@ -1207,8 +1201,5 @@ function ProfileBanner({
|
||||
}
|
||||
|
||||
export function Profile() {
|
||||
const avatarRef = useRef<HTMLDivElement>(null);
|
||||
const nameRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
return <ProfileBanner avatarRef={avatarRef} nameRef={nameRef} />;
|
||||
return <ProfileBanner />;
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ function SpaceNavSection({
|
||||
{section.items.length > 0 && (
|
||||
<div data-nav-rooms="">
|
||||
<div data-nav-room-list="">
|
||||
{section.items.map((item, index) => {
|
||||
{section.items.map((item) => {
|
||||
if (item.type === 'unjoined-subroom') {
|
||||
return (
|
||||
<UnjoinedSubRoomItem
|
||||
key={`${item.roomId}:${index}`}
|
||||
key={item.roomId}
|
||||
roomId={item.roomId}
|
||||
depth={item.depth}
|
||||
isLast={item.isLast}
|
||||
@@ -127,7 +127,7 @@ function SpaceNavSection({
|
||||
if (item.type === 'subroom') {
|
||||
return (
|
||||
<div
|
||||
key={`${item.roomId}:${index}`}
|
||||
key={item.roomId}
|
||||
data-nav-depth={item.depth}
|
||||
style={{
|
||||
display: 'flex',
|
||||
@@ -158,7 +158,7 @@ function SpaceNavSection({
|
||||
|
||||
return (
|
||||
<RoomNavItem
|
||||
key={`${item.roomId}:${index}`}
|
||||
key={item.roomId}
|
||||
room={room}
|
||||
selected={selectedRoomId === item.roomId}
|
||||
showAvatar={mDirects.has(item.roomId)}
|
||||
|
||||
@@ -197,7 +197,13 @@ export const factoryRenderLinkifyWithMention = (
|
||||
}
|
||||
|
||||
return (
|
||||
<a {...attributes} onClick={handleExternalLinkClick}>
|
||||
<a
|
||||
{...attributes}
|
||||
role="link"
|
||||
tabIndex={0}
|
||||
onKeyDown={onEnterOrSpace(handleExternalLinkClick)}
|
||||
onClick={handleExternalLinkClick}
|
||||
>
|
||||
{content}
|
||||
</a>
|
||||
);
|
||||
@@ -508,7 +514,13 @@ export function InlineCode({
|
||||
|
||||
return (
|
||||
<span className={css.InlineCodeWrapper}>
|
||||
<span className={css.InlineCodeCopyButton} onClick={handleCopy}>
|
||||
<span
|
||||
className={css.InlineCodeCopyButton}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onKeyDown={onEnterOrSpace(handleCopy)}
|
||||
onClick={handleCopy}
|
||||
>
|
||||
{copied ? (
|
||||
<Icon size="50" src={Icons.Check} />
|
||||
) : (
|
||||
@@ -681,7 +693,13 @@ export const getReactCustomHtmlParser = (
|
||||
// Handle external links - add click handler for Tauri
|
||||
if (props.href?.startsWith('http://') || props.href?.startsWith('https://')) {
|
||||
return (
|
||||
<a {...props} onClick={handleExternalLinkClick}>
|
||||
<a
|
||||
{...props}
|
||||
role="link"
|
||||
tabIndex={0}
|
||||
onKeyDown={onEnterOrSpace(handleExternalLinkClick)}
|
||||
onClick={handleExternalLinkClick}
|
||||
>
|
||||
{domToReact(children, opts)}
|
||||
</a>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user