Merge remote-tracking branch 'sable/dev' into feat/add-knip
This commit is contained in:
38 files changed
+555
-234
No files matched your search
+21
-2
@@ -1,9 +1,28 @@
|
||||
# Sable Client Changelog
|
||||
|
||||
## 1.2.2 - in dev
|
||||
|
||||
- Fixed/updated unknown extended profile keys rendering.
|
||||
- Added support for `---`, `-#`, and fixed `-` to be unordered.
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- Update pronouns to match [MSC4247](https://github.com/matrix-org/matrix-spec-proposals/pull/4247) format better and support up to 3 pronoun pills on desktop, 1 on mobile ([#23](https://github.com/7w1/sable/issues/23), [#33](https://github.com/7w1/sable/pull/33)) - [ranidspace](https://github.com/ranidspace)
|
||||
- Unfortunately, **everyone who set pronouns in Sable will need to reset them.**
|
||||
- Fix jumbo-ified non-emojis with colons. ([#32](https://github.com/7w1/sable/issues/32))
|
||||
- Show full timestamps on hover. ([cinnyapp#2699](https://github.com/cinnyapp/cinny/issues/2699))
|
||||
- Enable Twitter-style emojis by default.
|
||||
- Make inline editor buttons buttons.
|
||||
- Name colors in pinned messages.
|
||||
- Rename "Heating up" to "Petting cats"
|
||||
- Concurrency guard for profile lookups.
|
||||
- Hex color input for power level editor.
|
||||
- Editing previous messages with keybinds no longer breaks message bar ([#36](https://github.com/7w1/sable/issues/36))
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Codebase cleanup ([#22](https://github.com/7w1/sable/pull/22))
|
||||
- Fix mono font ([#18](https://github.com/7w1/sable/pull/18))
|
||||
- Codebase cleanup ([#22](https://github.com/7w1/sable/pull/22)) - [haz](https://github.com/hazre)
|
||||
- Fix mono font ([#18](https://github.com/7w1/sable/pull/18)) - [Alexia](https://github.com/cyrneko)
|
||||
- Merge final commits from ([cinnyapp#2599](https://github.com/cinnyapp/cinny/pull/2599))
|
||||
- Unread pin counter & highlighting ([#25](https://github.com/7w1/sable/pull/25), [#31](https://github.com/7w1/sable/pull/31))
|
||||
|
||||
|
||||
+3
-4
@@ -7,14 +7,13 @@ All types of contributions are encouraged and valued. Please make sure to read t
|
||||
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
|
||||
>
|
||||
> - Star the project
|
||||
> - Tweet about it (tag @cinnyapp)
|
||||
> - Talk abot it!
|
||||
> - Refer this project in your project's readme
|
||||
> - Mention the project at local meetups and tell your friends/colleagues
|
||||
> - [Donate to us](https://cinny.in/#sponsor)
|
||||
|
||||
## Bug reports
|
||||
|
||||
Bug reports and feature suggestions must use descriptive and concise titles and be submitted to [GitHub Issues](https://github.com/ajbura/cinny/issues). Please use the search function to make sure that you are not submitting duplicates, and that a similar report or request has not already been resolved or rejected.
|
||||
Bug reports and feature suggestions must use descriptive and concise titles and be submitted to [GitHub Issues](https://github.com/7w1/sable/issues). Please use the search function to make sure that you are not submitting duplicates, and that a similar report or request has not already been resolved or rejected.
|
||||
|
||||
## Pull requests
|
||||
|
||||
@@ -38,7 +37,7 @@ It is not always possible to phrase every change in such a manner, but it is des
|
||||
|
||||
Also, we use [ESLint](https://eslint.org/) for clean and stylistically consistent code syntax, so make sure your pull request follow it.
|
||||
|
||||
**For any query or design discussion, join our [Matrix room](https://matrix.to/#/#cinny:matrix.org).**
|
||||
**For any query or design discussion, join our [Matrix room](https://matrix.to/#/#sable:sable.moe).**
|
||||
|
||||
## Helpful links
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ The web app is available at [app.sable.moe](https://app.sable.moe/) and gets upd
|
||||
You can also download our desktop app for windows and linux from [releases](https://github.com/7w1/sable/releases/latest).
|
||||
|
||||
## Self-hosting
|
||||
To host Cinny on your own, download this repo and built with nginx.
|
||||
To host Sable on your own, download this repo and built with nginx.
|
||||
|
||||
```sh
|
||||
npm ci # Installs all dependencies
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sable",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@atlaskit/pragmatic-drag-and-drop": "^1.7.7",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sable",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"description": "Yet another matrix client fork",
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
|
||||
@@ -226,6 +226,19 @@ export function RenderElement({ attributes, element, children }: RenderElementPr
|
||||
{children}
|
||||
</RenderCommandElement>
|
||||
);
|
||||
case BlockType.Small:
|
||||
return (
|
||||
<Text {...attributes} className={css.Small}>
|
||||
{children}
|
||||
</Text>
|
||||
);
|
||||
case BlockType.HorizontalRule:
|
||||
return (
|
||||
<div {...attributes}>
|
||||
<div contentEditable={false} className={css.HorizontalRule} />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<Text
|
||||
|
||||
@@ -36,6 +36,7 @@ import { KeySymbol } from '$appUtils/key-symbol';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { stopPropagation } from '$appUtils/keyboard';
|
||||
import { floatingToolbar } from '$styles/overrides/Composer.css';
|
||||
|
||||
function BtnTooltip({ text, shortCode }: { text: string; shortCode?: string }) {
|
||||
return (
|
||||
@@ -263,7 +264,7 @@ export function Toolbar() {
|
||||
const [isMarkdown, setIsMarkdown] = useSetting(settingsAtom, 'isMarkdown');
|
||||
|
||||
return (
|
||||
<Box className={css.EditorToolbarBase}>
|
||||
<Box className={`${css.EditorToolbarBase} ${floatingToolbar}`}>
|
||||
<Scroll direction="Horizontal" size="0">
|
||||
<Box className={css.EditorToolbar} alignItems="Center" gap="300">
|
||||
<>
|
||||
|
||||
@@ -11,10 +11,12 @@ import {
|
||||
EmoticonElement,
|
||||
HeadingElement,
|
||||
HeadingLevel,
|
||||
HorizontalRuleElement,
|
||||
InlineElement,
|
||||
MentionElement,
|
||||
OrderedListElement,
|
||||
ParagraphElement,
|
||||
SmallElement,
|
||||
UnorderedListElement,
|
||||
} from './slate';
|
||||
import { createEmoticonElement, createMentionElement } from './utils';
|
||||
@@ -342,6 +344,42 @@ const parseHeadingNode = (
|
||||
};
|
||||
};
|
||||
|
||||
const parseSmallNode = (
|
||||
node: Element,
|
||||
processText: ProcessTextCallback
|
||||
): SmallElement | ParagraphElement => {
|
||||
const children = node.children.flatMap((child) => getInlineElement(child, processText));
|
||||
const mdSequence = node.attribs['data-md'];
|
||||
|
||||
if (mdSequence !== undefined) {
|
||||
return {
|
||||
type: BlockType.Paragraph,
|
||||
children: [{ text: `${mdSequence} ` }, ...children],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: BlockType.Small,
|
||||
children,
|
||||
};
|
||||
};
|
||||
|
||||
const parseHorizontalRuleNode = (node: Element): HorizontalRuleElement | ParagraphElement => {
|
||||
const mdSequence = node.attribs['data-md'];
|
||||
|
||||
if (mdSequence !== undefined) {
|
||||
return {
|
||||
type: BlockType.Paragraph,
|
||||
children: [{ text: mdSequence }],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: BlockType.HorizontalRule,
|
||||
children: [{ text: '' }],
|
||||
};
|
||||
};
|
||||
|
||||
export const domToEditorInput = (
|
||||
domNodes: ChildNode[],
|
||||
processText: ProcessTextCallback,
|
||||
@@ -380,6 +418,18 @@ export const domToEditorInput = (
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.name === 'small') {
|
||||
appendLine();
|
||||
children.push(parseSmallNode(node, processText));
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.name === 'hr') {
|
||||
appendLine();
|
||||
children.push(parseHorizontalRuleNode(node));
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.name === 'p') {
|
||||
appendLine();
|
||||
children.push({
|
||||
|
||||
@@ -57,6 +57,10 @@ const elementToCustomHtml = (node: CustomElement, children: string): string => {
|
||||
return `<ol>${children}</ol>`;
|
||||
case BlockType.UnorderedList:
|
||||
return `<ul>${children}</ul>`;
|
||||
case BlockType.Small:
|
||||
return `<small>${children}</small>`;
|
||||
case BlockType.HorizontalRule:
|
||||
return `<hr/>`;
|
||||
|
||||
case BlockType.Mention: {
|
||||
let fragment = node.id;
|
||||
@@ -159,6 +163,10 @@ const elementToPlainText = (node: CustomElement, children: string): string => {
|
||||
return `[${node.children}](${node.href})`;
|
||||
case BlockType.Command:
|
||||
return `/${node.command}`;
|
||||
case BlockType.Small:
|
||||
return `-# ${children}\n`;
|
||||
case BlockType.HorizontalRule:
|
||||
return `\n---\n`;
|
||||
default:
|
||||
return children;
|
||||
}
|
||||
|
||||
Vendored
+13
-1
@@ -87,6 +87,16 @@ export type UnorderedListElement = {
|
||||
children: ListItemElement[];
|
||||
};
|
||||
|
||||
export type SmallElement = {
|
||||
type: BlockType.Small;
|
||||
children: InlineElement[];
|
||||
};
|
||||
|
||||
export type HorizontalRuleElement = {
|
||||
type: BlockType.HorizontalRule;
|
||||
children: Text[];
|
||||
};
|
||||
|
||||
export type CustomElement =
|
||||
| LinkElement
|
||||
| MentionElement
|
||||
@@ -100,7 +110,9 @@ export type CustomElement =
|
||||
| BlockQuoteElement
|
||||
| ListItemElement
|
||||
| OrderedListElement
|
||||
| UnorderedListElement;
|
||||
| UnorderedListElement
|
||||
| SmallElement
|
||||
| HorizontalRuleElement;
|
||||
|
||||
declare module 'slate' {
|
||||
interface CustomTypes {
|
||||
|
||||
@@ -21,4 +21,6 @@ export enum BlockType {
|
||||
Emoticon = 'emoticon',
|
||||
Link = 'link',
|
||||
Command = 'command',
|
||||
Small = 'small',
|
||||
HorizontalRule = 'hr',
|
||||
}
|
||||
@@ -130,6 +130,19 @@ export const toggleBlock = (editor: Editor, format: BlockType, option?: BlockOpt
|
||||
});
|
||||
}
|
||||
|
||||
if (format === BlockType.HorizontalRule) {
|
||||
Transforms.insertNodes(editor, {
|
||||
type: BlockType.HorizontalRule,
|
||||
children: [{ text: '' }],
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (format === BlockType.Small) {
|
||||
Transforms.setNodes(editor, { type: BlockType.Small });
|
||||
return;
|
||||
}
|
||||
|
||||
Transforms.setNodes(editor, {
|
||||
type: format,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { CSSProperties, ReactNode } from 'react';
|
||||
import React, { CSSProperties, ReactNode, useMemo } from 'react';
|
||||
import { Box, Chip, Icon, Icons, Text, toRem } from 'folds';
|
||||
import { IContent } from '$types/matrix-sdk';
|
||||
import { JUMBO_EMOJI_REG, URL_REG } from '$appUtils/regex';
|
||||
@@ -79,24 +79,37 @@ type MTextProps = {
|
||||
style?: CSSProperties;
|
||||
};
|
||||
export function MText({ edited, content, renderBody, renderUrlsPreview, style }: MTextProps) {
|
||||
const { body, formatted_body: customBody } = content;
|
||||
const [jumboEmojiSize] = useSetting(settingsAtom, 'jumboEmojiSize');
|
||||
|
||||
if (typeof body !== 'string') return <BrokenContent />;
|
||||
const body = typeof content.body === 'string' ? content.body : '';
|
||||
const customBody =
|
||||
typeof content.formatted_body === 'string' ? content.formatted_body : undefined;
|
||||
|
||||
const trimmedBody = trimReplyFromBody(body);
|
||||
const trimmedBody = useMemo(() => trimReplyFromBody(body), [body]);
|
||||
|
||||
let safeCustomBody: string | undefined = typeof customBody === 'string' ? customBody : undefined;
|
||||
if (safeCustomBody && safeCustomBody.length > 8000) {
|
||||
const imageTags = safeCustomBody.match(/<img[^>]*>/g);
|
||||
if (imageTags) {
|
||||
safeCustomBody = imageTags.join(' ');
|
||||
} else {
|
||||
safeCustomBody = undefined;
|
||||
const safeCustomBody = useMemo(() => {
|
||||
if (!customBody) return undefined;
|
||||
if (customBody.length > 8000) {
|
||||
const imageTags = customBody.match(/<img[^>]*>/g);
|
||||
return imageTags ? imageTags.join(' ') : undefined;
|
||||
}
|
||||
}
|
||||
return customBody;
|
||||
}, [customBody]);
|
||||
|
||||
const isJumbo = useMemo(() => {
|
||||
if (!trimmedBody || trimmedBody.length >= 500) return false;
|
||||
if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false;
|
||||
|
||||
if (trimmedBody.includes(':')) {
|
||||
const hasImage = safeCustomBody && /<img[^>]*>/i.test(safeCustomBody);
|
||||
if (!hasImage) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}, [trimmedBody, safeCustomBody]);
|
||||
|
||||
if (!body) return <BrokenContent />;
|
||||
|
||||
const isJumbo = trimmedBody.length < 500 && JUMBO_EMOJI_REG.test(trimmedBody);
|
||||
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
|
||||
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, { ComponentProps } from 'react';
|
||||
import { Text, as } from 'folds';
|
||||
import { timeDayMonYear, timeHourMinute, today, yesterday } from '$appUtils/time';
|
||||
import {
|
||||
timeDayMonYear,
|
||||
timeHourMinute,
|
||||
timeHourMinuteSecond,
|
||||
today,
|
||||
yesterday,
|
||||
} from '$appUtils/time';
|
||||
|
||||
export type TimeProps = {
|
||||
compact?: boolean;
|
||||
@@ -35,9 +41,18 @@ export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
||||
} else {
|
||||
time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`;
|
||||
}
|
||||
const title = `${timeDayMonYear(ts, dateFormatString)} ${timeHourMinuteSecond(ts, hour24Clock)}`;
|
||||
|
||||
return (
|
||||
<Text as="time" style={{ flexShrink: 0 }} size="T200" priority="300" {...props} ref={ref}>
|
||||
<Text
|
||||
as="time"
|
||||
style={{ flexShrink: 0 }}
|
||||
size="T200"
|
||||
priority="300"
|
||||
title={title}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
{time}
|
||||
</Text>
|
||||
);
|
||||
|
||||
@@ -28,6 +28,10 @@ export const UsernameBold = as<'b'>(({ as: AsUsernameBold = 'b', className, ...p
|
||||
<AsUsernameBold className={classNames(css.UsernameBold, className)} {...props} ref={ref} />
|
||||
));
|
||||
|
||||
export const PronounPill = as<'span'>(({ as: AsPronounPill = 'span', className, ...props }, ref) => (
|
||||
<AsPronounPill className={classNames(css.PronounPill, className)} {...props} ref={ref} />
|
||||
));
|
||||
|
||||
export const MessageTextBody = as<'div', css.MessageTextBodyVariants & { notice?: boolean }>(
|
||||
({ as: asComp = 'div', className, preWrap, jumboEmoji, emote, notice, ...props }, ref) => (
|
||||
<Text
|
||||
|
||||
@@ -181,6 +181,16 @@ export const UsernameBold = style({
|
||||
fontWeight: 550,
|
||||
});
|
||||
|
||||
export const PronounPill = style({
|
||||
borderRadius: config.radii.Pill,
|
||||
backgroundColor: 'var(--sable-surface-var-container)',
|
||||
paddingInline: toRem(5),
|
||||
opacity: 0.8,
|
||||
fontSize: '0.7rem',
|
||||
whiteSpace: 'nowrap',
|
||||
textTransform: 'lowercase',
|
||||
});
|
||||
|
||||
export const MessageTextBody = recipe({
|
||||
base: {
|
||||
wordBreak: 'break-word',
|
||||
|
||||
@@ -60,10 +60,20 @@ function UserExtendedSection({
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
}: UserExtendedSectionProps) {
|
||||
const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str);
|
||||
const clamp = (str: any, len: number) => {
|
||||
const stringified = String(str ?? '');
|
||||
return stringified.length > len ? `${stringified.slice(0, len)}...` : stringified;
|
||||
};
|
||||
const [showMore, setShowMore] = useState(false);
|
||||
|
||||
const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 20)).join('/');
|
||||
const renderValue = (val: any) => {
|
||||
if (val === null || val === undefined) return 'n/a';
|
||||
if (typeof val === 'boolean') return val ? 'Yes' : 'No';
|
||||
if (typeof val === 'object') return JSON.stringify(val);
|
||||
return String(val);
|
||||
};
|
||||
|
||||
const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 16)).join(', ');
|
||||
const timezone = profile.timezone ? clamp(profile.timezone, 64) : null;
|
||||
const localTime = timezone
|
||||
? new Intl.DateTimeFormat([], {
|
||||
@@ -102,8 +112,7 @@ function UserExtendedSection({
|
||||
}, [profile]);
|
||||
|
||||
const unknownFields = Object.entries(profile.extended || {}).filter(
|
||||
([key, value]) =>
|
||||
!KNOWN_KEYS.includes(key) && (typeof value === 'string' || typeof value === 'number')
|
||||
([key]) => !KNOWN_KEYS.includes(key)
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -182,10 +191,10 @@ function UserExtendedSection({
|
||||
{unknownFields.map(([key, value]) => (
|
||||
<Box key={key} direction="Column" style={{ marginBottom: config.space.S100 }}>
|
||||
<Text size="T200" priority="400" style={{ letterSpacing: '0.05em' }}>
|
||||
{clamp(key, 64).split('.').pop()?.replace(/_/g, ' ')}
|
||||
{key}
|
||||
</Text>
|
||||
<Text size="T200" priority="300">
|
||||
{String(clamp(value, 64))}
|
||||
{clamp(renderValue(value), 128)}
|
||||
</Text>
|
||||
</Box>
|
||||
))}
|
||||
|
||||
@@ -69,11 +69,17 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) {
|
||||
const [iconFile, setIconFile] = useState<File>();
|
||||
const pickFile = useFilePicker(setIconFile, false);
|
||||
|
||||
const [tagColor, setTagColor] = useState<string | undefined>(tag?.color);
|
||||
const [tagColor, setTagColor] = useState<string>(tag?.color || '#FFFFFF');
|
||||
const [tagIcon, setTagIcon] = useState<MemberPowerTagIcon | undefined>(tag?.icon);
|
||||
|
||||
const uploadingIcon = iconFile && !tagIcon;
|
||||
const tagIconSrc = tagIcon && getPowerTagIconSrc(mx, useAuthentication, tagIcon);
|
||||
|
||||
const handleUpdateColor = (newColor: string) => {
|
||||
const sanitized = newColor.startsWith('#') ? newColor : `#${newColor}`;
|
||||
setTagColor(sanitized);
|
||||
};
|
||||
|
||||
const iconUploadAtom = useMemo(() => {
|
||||
if (iconFile) return createUploadAtom(iconFile);
|
||||
return undefined;
|
||||
@@ -84,9 +90,7 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) {
|
||||
}, []);
|
||||
|
||||
const handleIconUploaded = useCallback((upload: UploadSuccess) => {
|
||||
setTagIcon({
|
||||
key: upload.mxc,
|
||||
});
|
||||
setTagIcon({ key: upload.mxc });
|
||||
setIconFile(undefined);
|
||||
}, []);
|
||||
|
||||
@@ -105,9 +109,11 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) {
|
||||
const tagName = nameInput.value.trim();
|
||||
if (!tagName) return;
|
||||
|
||||
const finalColor = /^#[0-9A-F]{6}$/i.test(tagColor) ? tagColor : undefined;
|
||||
|
||||
const editedTag: MemberPowerTag = {
|
||||
name: tagName,
|
||||
color: tagColor,
|
||||
color: finalColor,
|
||||
icon: tagIcon,
|
||||
};
|
||||
|
||||
@@ -121,10 +127,10 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) {
|
||||
<Box gap="200">
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<Text size="L400">Color</Text>
|
||||
<Box gap="200">
|
||||
<Box gap="200" alignItems="Center">
|
||||
<HexColorPickerPopOut
|
||||
picker={<HexColorPicker color={tagColor} onChange={setTagColor} />}
|
||||
onRemove={() => setTagColor(undefined)}
|
||||
picker={<HexColorPicker color={tagColor} onChange={handleUpdateColor} />}
|
||||
onRemove={() => setTagColor('#FFFFFF')}
|
||||
>
|
||||
{(openPicker, opened) => (
|
||||
<Button
|
||||
@@ -141,6 +147,19 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) {
|
||||
</Button>
|
||||
)}
|
||||
</HexColorPickerPopOut>
|
||||
<Input
|
||||
value={tagColor}
|
||||
onChange={(e) => handleUpdateColor(e.currentTarget.value)}
|
||||
placeholder="#FFFFFF"
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
radii="300"
|
||||
style={{
|
||||
width: toRem(100),
|
||||
fontFamily: 'monospace',
|
||||
textTransform: 'uppercase',
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="100">
|
||||
|
||||
@@ -257,6 +257,7 @@ type RoomTimelineProps = {
|
||||
eventId?: string;
|
||||
roomInputRef: RefObject<HTMLElement>;
|
||||
editor: Editor;
|
||||
onEditorReset?: () => void;
|
||||
};
|
||||
|
||||
const PAGINATION_LIMIT = 60;
|
||||
@@ -459,7 +460,13 @@ const getRoomUnreadInfo = (room: Room, scrollTo = false) => {
|
||||
};
|
||||
};
|
||||
|
||||
export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimelineProps) {
|
||||
export function RoomTimeline({
|
||||
room,
|
||||
eventId,
|
||||
roomInputRef,
|
||||
editor,
|
||||
onEditorReset,
|
||||
}: RoomTimelineProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
@@ -1136,9 +1143,15 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
return;
|
||||
}
|
||||
setEditId(undefined);
|
||||
ReactEditor.focus(editor);
|
||||
onEditorReset?.();
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
if (!alive()) return;
|
||||
ReactEditor.focus(editor);
|
||||
moveCursor(editor);
|
||||
});
|
||||
},
|
||||
[editor]
|
||||
[editor, alive, onEditorReset]
|
||||
);
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import React, { useCallback, useRef, useState } from 'react';
|
||||
import { Box, Text, config, toRem } from 'folds';
|
||||
import { EventType, Room } from '$types/matrix-sdk';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
@@ -79,6 +79,9 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
const canMessage = permissions.event(EventType.RoomMessage, mx.getSafeUserId());
|
||||
|
||||
const [editorResetKey, setEditorResetKey] = useState(0);
|
||||
const handleResetEditor = useCallback(() => setEditorResetKey((prev) => prev + 1), []);
|
||||
|
||||
useKeyDown(
|
||||
window,
|
||||
useCallback(
|
||||
@@ -124,6 +127,7 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
||||
eventId={eventId}
|
||||
roomInputRef={roomInputRef}
|
||||
editor={editor}
|
||||
onEditorReset={handleResetEditor}
|
||||
/>
|
||||
<RoomViewTyping room={room} />
|
||||
<GlobalModalManager />
|
||||
@@ -140,6 +144,7 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
||||
<>
|
||||
{canMessage && (
|
||||
<RoomInput
|
||||
key={`${roomId}-${editorResetKey}`}
|
||||
room={room}
|
||||
editor={editor}
|
||||
roomId={roomId}
|
||||
|
||||
@@ -82,7 +82,7 @@ async function getPinsHash(pinnedIds: string[]): Promise<string> {
|
||||
return hashHex.slice(0, 10);
|
||||
}
|
||||
|
||||
interface PinReadMarker {
|
||||
export interface PinReadMarker {
|
||||
hash: string;
|
||||
count: number;
|
||||
last_seen_id: string;
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
CompactLayout,
|
||||
MessageBase,
|
||||
ModernLayout,
|
||||
PronounPill,
|
||||
Time,
|
||||
Username,
|
||||
UsernameBold,
|
||||
@@ -249,46 +250,33 @@ function useMobileDoubleTap(callback: () => void, delay = 300) {
|
||||
);
|
||||
}
|
||||
|
||||
function PronounTag({ pronouns, tagColor }: { pronouns?: any[]; tagColor: string }) {
|
||||
const Pronouns = as<
|
||||
'div',
|
||||
{
|
||||
pronouns?: any[];
|
||||
tagColor: string;
|
||||
}
|
||||
>(({ pronouns, tagColor, ...props }, ref) => {
|
||||
if (!pronouns || pronouns.length === 0) return null;
|
||||
|
||||
const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str);
|
||||
const limit = mobileOrTablet() ? 1 : 3;
|
||||
|
||||
const display = clamp(
|
||||
pronouns
|
||||
.slice(0, 2)
|
||||
.map((p) => clamp(p.summary, 48))
|
||||
.join('/'),
|
||||
128
|
||||
);
|
||||
const hasMore = pronouns.length > 2;
|
||||
const display = pronouns.slice(0, limit).map((p) => (
|
||||
<PronounPill style={{ color: tagColor }} {...props} ref={ref}>
|
||||
{clamp(p.summary, 16)}
|
||||
</PronounPill>
|
||||
));
|
||||
|
||||
return (
|
||||
<Box
|
||||
alignItems="Center"
|
||||
style={{
|
||||
backgroundColor: 'var(--sable-surface-var-container)',
|
||||
padding: '0 5px',
|
||||
borderRadius: config.radii.Pill,
|
||||
height: '16px',
|
||||
display: 'inline-flex',
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
color: tagColor,
|
||||
fontSize: '0.7rem',
|
||||
lineHeight: '1',
|
||||
textTransform: 'lowercase',
|
||||
opacity: 0.8,
|
||||
}}
|
||||
>
|
||||
{display}
|
||||
{hasMore ? '...' : ''}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
if (pronouns.length > limit) {
|
||||
display.push(
|
||||
<PronounPill style={{ color: tagColor }} {...props} ref={ref}>
|
||||
...
|
||||
</PronounPill>
|
||||
);
|
||||
}
|
||||
return <>{display}</>;
|
||||
});
|
||||
|
||||
function MessageInternal(
|
||||
{
|
||||
@@ -404,7 +392,7 @@ function MessageInternal(
|
||||
</Text>
|
||||
</Username>
|
||||
{showPronouns && (
|
||||
<PronounTag pronouns={profile.pronouns} tagColor={usernameColor ?? 'currentColor'} />
|
||||
<Pronouns pronouns={profile.pronouns} tagColor={usernameColor ?? 'currentColor'} />
|
||||
)}
|
||||
{tagIconSrc && <PowerIcon size="100" iconSrc={tagIconSrc} />}
|
||||
</Box>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable react/destructuring-assignment */
|
||||
import React, { forwardRef, MouseEventHandler, useCallback, useMemo, useRef } from 'react';
|
||||
import { MatrixEvent, Room } from '$types/matrix-sdk';
|
||||
import { RoomPinnedEventsEventContent } from '$types/matrix-sdk';
|
||||
@@ -76,8 +75,6 @@ import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
import { usePowerLevelTags } from '$hooks/usePowerLevelTags';
|
||||
import { useTheme } from '$hooks/useTheme';
|
||||
import { PowerIcon } from '$components/power';
|
||||
import colorMXID from '$util/colorMXID';
|
||||
import { useIsDirectRoom } from '$hooks/useRoom';
|
||||
import { useRoomCreators } from '$hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '$hooks/useRoomPermissions';
|
||||
import {
|
||||
@@ -89,6 +86,8 @@ import {
|
||||
import { useRoomCreatorsTag } from '$hooks/useRoomCreatorsTag';
|
||||
import { nicknamesAtom } from '$state/nicknames';
|
||||
import { AccountDataEvent } from '$types/matrix/accountData';
|
||||
import { useSableCosmetics } from '$hooks/useSableCosmetics';
|
||||
import { PinReadMarker } from '../RoomViewHeader';
|
||||
|
||||
type PinnedMessageProps = {
|
||||
room: Room;
|
||||
@@ -98,110 +97,46 @@ type PinnedMessageProps = {
|
||||
canPinEvent: boolean;
|
||||
getMemberPowerTag: GetMemberPowerTag;
|
||||
accessibleTagColors: Map<string, string>;
|
||||
legacyUsernameColor: boolean;
|
||||
hour24Clock: boolean;
|
||||
dateFormatString: string;
|
||||
isNew: boolean;
|
||||
};
|
||||
function PinnedMessage({
|
||||
room,
|
||||
eventId,
|
||||
renderContent,
|
||||
onOpen,
|
||||
canPinEvent,
|
||||
getMemberPowerTag,
|
||||
accessibleTagColors,
|
||||
legacyUsernameColor,
|
||||
hour24Clock,
|
||||
dateFormatString,
|
||||
isNew,
|
||||
}: PinnedMessageProps) {
|
||||
const pinnedEvent = useRoomEvent(room, eventId);
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
|
||||
const PinnedMessageActiveContent = (
|
||||
props: PinnedMessageProps & {
|
||||
pinnedEvent: MatrixEvent;
|
||||
renderOptions: () => React.ReactNode;
|
||||
handleOpenClick: MouseEventHandler;
|
||||
}
|
||||
) => {
|
||||
const {
|
||||
pinnedEvent,
|
||||
room,
|
||||
renderContent,
|
||||
hour24Clock,
|
||||
dateFormatString,
|
||||
getMemberPowerTag,
|
||||
renderOptions,
|
||||
handleOpenClick,
|
||||
} = props;
|
||||
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const nicknames = useAtomValue(nicknamesAtom);
|
||||
|
||||
const [unpinState, unpin] = useAsyncCallback(
|
||||
useCallback(() => {
|
||||
const pinEvent = getStateEvent(room, StateEvent.RoomPinnedEvents);
|
||||
const content = pinEvent?.getContent<RoomPinnedEventsEventContent>() ?? { pinned: [] };
|
||||
const newContent: RoomPinnedEventsEventContent = {
|
||||
pinned: content.pinned.filter((id: string) => id !== eventId),
|
||||
};
|
||||
|
||||
return mx.sendStateEvent(room.roomId, StateEvent.RoomPinnedEvents as any, newContent);
|
||||
}, [room, eventId, mx])
|
||||
);
|
||||
|
||||
const handleOpenClick: MouseEventHandler = (evt) => {
|
||||
evt.stopPropagation();
|
||||
const evtId = evt.currentTarget.getAttribute('data-event-id');
|
||||
if (!evtId) return;
|
||||
onOpen(room.roomId, evtId);
|
||||
};
|
||||
|
||||
const handleUnpinClick: MouseEventHandler = (evt) => {
|
||||
evt.stopPropagation();
|
||||
unpin();
|
||||
};
|
||||
|
||||
const renderOptions = () => (
|
||||
<Box shrink="No" gap="200" alignItems="Center">
|
||||
<Chip
|
||||
data-event-id={eventId}
|
||||
onClick={handleOpenClick}
|
||||
// Maybe change colors later. design not finalized
|
||||
//variant={isNew ? "Primary" : "Secondary"}
|
||||
radii="Pill"
|
||||
>
|
||||
<Text size="T200">Jump</Text>
|
||||
</Chip>
|
||||
{canPinEvent && (
|
||||
<IconButton
|
||||
data-event-id={eventId}
|
||||
//variant={isNew ? "Primary" : "Secondary"}
|
||||
size="300"
|
||||
radii="Pill"
|
||||
onClick={unpinState.status === AsyncStatus.Loading ? undefined : handleUnpinClick}
|
||||
aria-disabled={unpinState.status === AsyncStatus.Loading}
|
||||
>
|
||||
{unpinState.status === AsyncStatus.Loading ? (
|
||||
<Spinner size="100" />
|
||||
) : (
|
||||
<Icon src={Icons.Cross} size="100" />
|
||||
)}
|
||||
</IconButton>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
|
||||
if (pinnedEvent === undefined) return <DefaultPlaceholder variant="Secondary" />;
|
||||
if (pinnedEvent === null)
|
||||
return (
|
||||
<Box gap="300" justifyContent="SpaceBetween" alignItems="Center">
|
||||
<Box>
|
||||
<Text style={{ color: color.Critical.Main }}>Failed to load message!</Text>
|
||||
</Box>
|
||||
{renderOptions()}
|
||||
</Box>
|
||||
);
|
||||
|
||||
const sender = pinnedEvent.getSender()!;
|
||||
const { color: usernameColor, font: usernameFont } = useSableCosmetics(sender, room);
|
||||
|
||||
const displayName =
|
||||
getMemberDisplayName(room, sender, nicknames) ?? getMxIdLocalPart(sender) ?? sender;
|
||||
const senderAvatarMxc = getMemberAvatarMxc(room, sender);
|
||||
const getContent = (() => pinnedEvent.getContent()) as GetContentCallback;
|
||||
|
||||
const memberPowerTag = getMemberPowerTag(sender);
|
||||
const tagColor = memberPowerTag?.color
|
||||
? accessibleTagColors?.get(memberPowerTag.color)
|
||||
: undefined;
|
||||
const tagIconSrc = memberPowerTag?.icon
|
||||
? getPowerTagIconSrc(mx, useAuthentication, memberPowerTag.icon)
|
||||
: undefined;
|
||||
|
||||
const usernameColor = legacyUsernameColor ? colorMXID(sender) : tagColor;
|
||||
|
||||
return (
|
||||
<ModernLayout
|
||||
before={
|
||||
@@ -225,7 +160,7 @@ function PinnedMessage({
|
||||
<Box gap="300" justifyContent="SpaceBetween" alignItems="Center" grow="Yes">
|
||||
<Box gap="200" alignItems="Baseline">
|
||||
<Box alignItems="Center" gap="200">
|
||||
<Username style={{ color: usernameColor }}>
|
||||
<Username style={{ color: usernameColor, font: usernameFont }}>
|
||||
<Text as="span" truncate>
|
||||
<UsernameBold>{displayName}</UsernameBold>
|
||||
</Text>
|
||||
@@ -251,6 +186,85 @@ function PinnedMessage({
|
||||
{renderContent(pinnedEvent.getType(), false, pinnedEvent, displayName, getContent)}
|
||||
</ModernLayout>
|
||||
);
|
||||
};
|
||||
|
||||
function PinnedMessage(props: PinnedMessageProps) {
|
||||
const { room, eventId, onOpen, canPinEvent } = props;
|
||||
const pinnedEvent = useRoomEvent(room, eventId);
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [unpinState, unpin] = useAsyncCallback(
|
||||
useCallback(() => {
|
||||
const pinEvent = getStateEvent(room, StateEvent.RoomPinnedEvents);
|
||||
const content = pinEvent?.getContent<RoomPinnedEventsEventContent>() ?? { pinned: [] };
|
||||
const newContent: RoomPinnedEventsEventContent = {
|
||||
pinned: content.pinned.filter((id: string) => id !== eventId),
|
||||
};
|
||||
|
||||
return mx.sendStateEvent(room.roomId, StateEvent.RoomPinnedEvents as any, newContent);
|
||||
}, [room, eventId, mx])
|
||||
);
|
||||
|
||||
const handleOpenClick: MouseEventHandler = useCallback(
|
||||
(evt) => {
|
||||
evt.stopPropagation();
|
||||
onOpen(room.roomId, eventId);
|
||||
},
|
||||
[onOpen, room.roomId, eventId]
|
||||
);
|
||||
|
||||
const handleUnpinClick: MouseEventHandler = useCallback(
|
||||
(evt) => {
|
||||
evt.stopPropagation();
|
||||
void unpin();
|
||||
},
|
||||
[unpin]
|
||||
);
|
||||
|
||||
const renderOptions = () => (
|
||||
<Box shrink="No" gap="200" alignItems="Center">
|
||||
<Chip data-event-id={eventId} onClick={handleOpenClick} radii="Pill">
|
||||
<Text size="T200">Jump</Text>
|
||||
</Chip>
|
||||
{canPinEvent && (
|
||||
<IconButton
|
||||
data-event-id={eventId}
|
||||
size="300"
|
||||
radii="Pill"
|
||||
onClick={unpinState.status === AsyncStatus.Loading ? undefined : handleUnpinClick}
|
||||
aria-disabled={unpinState.status === AsyncStatus.Loading}
|
||||
>
|
||||
{unpinState.status === AsyncStatus.Loading ? (
|
||||
<Spinner size="100" />
|
||||
) : (
|
||||
<Icon src={Icons.Cross} size="100" />
|
||||
)}
|
||||
</IconButton>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
|
||||
if (pinnedEvent === undefined) return <DefaultPlaceholder variant="Secondary" />;
|
||||
|
||||
if (pinnedEvent === null) {
|
||||
return (
|
||||
<Box gap="300" justifyContent="SpaceBetween" alignItems="Center">
|
||||
<Box>
|
||||
<Text style={{ color: color.Critical.Main }}>Failed to load message!</Text>
|
||||
</Box>
|
||||
{renderOptions()}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PinnedMessageActiveContent
|
||||
{...props}
|
||||
pinnedEvent={pinnedEvent}
|
||||
renderOptions={renderOptions}
|
||||
handleOpenClick={handleOpenClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
type RoomPinMenuProps = {
|
||||
@@ -258,6 +272,7 @@ type RoomPinMenuProps = {
|
||||
requestClose: () => void;
|
||||
currentHash: string;
|
||||
};
|
||||
|
||||
export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
({ room, requestClose, currentHash }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
@@ -286,26 +301,22 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||
const [urlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||
|
||||
const direct = useIsDirectRoom();
|
||||
const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor');
|
||||
|
||||
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
||||
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
|
||||
|
||||
const { navigateRoom } = useRoomNavigate();
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const pinMarker = useMemo(() =>
|
||||
room.getAccountData(AccountDataEvent.SablePinStatus)?.getContent(),
|
||||
[room]);
|
||||
const pinMarker = useMemo(
|
||||
() => room.getAccountData(AccountDataEvent.SablePinStatus)?.getContent() as PinReadMarker,
|
||||
[room]
|
||||
);
|
||||
|
||||
const lastSeenIndex = useMemo(() => {
|
||||
if (!pinMarker?.last_seen_id) return -1;
|
||||
return pinnedEvents.indexOf(pinMarker.last_seen_id);
|
||||
}, [pinnedEvents, pinMarker]);
|
||||
|
||||
const hasNewContent = pinMarker?.hash !== currentHash;
|
||||
|
||||
const virtualizer = useVirtualizer({
|
||||
count: sortedPinnedEvent.length,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
@@ -355,9 +366,11 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
{
|
||||
[MessageEvent.RoomMessage]: (event, displayName, getContent) => {
|
||||
if (event.isRedacted()) {
|
||||
return (
|
||||
<RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />
|
||||
);
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| { reason?: string }
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason} />;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -396,7 +409,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
<EncryptedContent mEvent={mEvent}>
|
||||
{() => {
|
||||
if (mEvent.isRedacted()) return <RedactedContent />;
|
||||
if (mEvent.getType() === MessageEvent.Sticker)
|
||||
if ((mEvent.getType() as MessageEvent) === MessageEvent.Sticker)
|
||||
return (
|
||||
<MSticker
|
||||
content={mEvent.getContent()}
|
||||
@@ -410,11 +423,16 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
)}
|
||||
/>
|
||||
);
|
||||
if (mEvent.getType() === MessageEvent.RoomMessage) {
|
||||
if ((mEvent.getType() as MessageEvent) === MessageEvent.RoomMessage) {
|
||||
const editedEvent = getEditedEvent(eventId, mEvent, evtTimeline.getTimelineSet());
|
||||
const getContent = (() =>
|
||||
editedEvent?.getContent()['m.new_content'] ??
|
||||
mEvent.getContent()) as GetContentCallback;
|
||||
const getContent = (() => {
|
||||
const eventContent = mEvent.getContent();
|
||||
const editContent = editedEvent?.getContent();
|
||||
return (editContent?.['m.new_content'] ?? eventContent) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
}) as GetContentCallback;
|
||||
|
||||
return (
|
||||
<RenderMessageContent
|
||||
@@ -430,7 +448,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (mEvent.getType() === MessageEvent.RoomMessageEncrypted)
|
||||
if ((mEvent.getType() as MessageEvent) === MessageEvent.RoomMessageEncrypted)
|
||||
return (
|
||||
<Text>
|
||||
<MessageNotDecryptedContent />
|
||||
@@ -445,11 +463,14 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
</EncryptedContent>
|
||||
);
|
||||
},
|
||||
[MessageEvent.Sticker]: (event, displayName, getContent) => {
|
||||
[MessageEvent.Sticker]: (event, _displayName, getContent) => {
|
||||
if (event.isRedacted()) {
|
||||
return (
|
||||
<RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />
|
||||
);
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<MSticker
|
||||
@@ -469,7 +490,11 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
undefined,
|
||||
(event) => {
|
||||
if (event.isRedacted()) {
|
||||
return <RedactedContent reason={event.getUnsigned().redacted_because?.content.reason} />;
|
||||
const unsigned = event.getUnsigned();
|
||||
const redactionContent = unsigned.redacted_because?.content as
|
||||
| Record<string, unknown>
|
||||
| undefined;
|
||||
return <RedactedContent reason={redactionContent?.reason as string | undefined} />;
|
||||
}
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
@@ -521,7 +546,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
isNew = originalIndex > lastSeenIndex;
|
||||
} else {
|
||||
const oldCount = pinMarker?.count ?? 0;
|
||||
isNew = originalIndex >= (oldCount - 1);
|
||||
isNew = originalIndex >= oldCount - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,12 +558,14 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
key={vItem.index}
|
||||
>
|
||||
<SequenceCard
|
||||
style={{
|
||||
padding: config.space.S400,
|
||||
style={{
|
||||
padding: config.space.S400,
|
||||
borderRadius: config.radii.R300,
|
||||
border: isNew ? `${config.borderWidth.B700} solid ${color.Secondary.ContainerActive}` : undefined,
|
||||
border: isNew
|
||||
? `${config.borderWidth.B700} solid ${color.Secondary.ContainerActive}`
|
||||
: undefined,
|
||||
}}
|
||||
variant={"Background"}
|
||||
variant={'Background'}
|
||||
direction="Column"
|
||||
>
|
||||
<PinnedMessage
|
||||
@@ -549,7 +576,6 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
canPinEvent={canPinEvent}
|
||||
getMemberPowerTag={getMemberPowerTag}
|
||||
accessibleTagColors={accessibleTagColors}
|
||||
legacyUsernameColor={legacyUsernameColor || direct}
|
||||
hour24Clock={hour24Clock}
|
||||
isNew={isNew}
|
||||
dateFormatString={dateFormatString}
|
||||
@@ -584,7 +610,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
No Pinned Messages
|
||||
</Text>
|
||||
<Text size="T400" align="Center">
|
||||
Users with sufficient power level can pin a messages from its context menu.
|
||||
Users with sufficient power level can pin messages from the context menu.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -597,3 +623,5 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
RoomPinMenu.displayName = 'RoomPinMenu';
|
||||
@@ -46,7 +46,7 @@ export function About({ requestClose }: AboutProps) {
|
||||
<Box direction="Column" gap="100">
|
||||
<Box gap="100" alignItems="End">
|
||||
<Text size="H3">Sable</Text>
|
||||
<Text size="T200">v1.2.0</Text>
|
||||
<Text size="T200">v1.2.1</Text>
|
||||
</Box>
|
||||
<Text>Yet another matrix client fork(ed from cinny).</Text>
|
||||
</Box>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { SettingTile } from '$components/setting-tile';
|
||||
type PronounSet = {
|
||||
summary: string;
|
||||
language?: string;
|
||||
grammatical_gender?: string;
|
||||
};
|
||||
|
||||
type PronounEditorProps = {
|
||||
@@ -13,7 +14,7 @@ type PronounEditorProps = {
|
||||
};
|
||||
|
||||
export function PronounEditor({ current, onSave }: PronounEditorProps) {
|
||||
const initialString = current.map((p) => p.summary).join('/');
|
||||
const initialString = current.map((p) => p.summary).join(', ');
|
||||
const [val, setVal] = useState(initialString);
|
||||
|
||||
useEffect(() => setVal(initialString), [initialString]);
|
||||
@@ -22,10 +23,10 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) {
|
||||
if (val === initialString) return;
|
||||
const safeVal = val.slice(0, 128);
|
||||
const next = safeVal
|
||||
.split('/')
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
.map((s) => ({ summary: s.slice(0, 16) }));
|
||||
.map((s) => ({ summary: s.slice(0, 16), language: "en" }));
|
||||
onSave(next);
|
||||
};
|
||||
|
||||
@@ -36,7 +37,7 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) {
|
||||
return (
|
||||
<SettingTile
|
||||
title="Pronouns"
|
||||
description="Separate with slashes (e.g. they/them)."
|
||||
description="Separate sets with commas (e.g. 'they/them, it/its')."
|
||||
after={
|
||||
<Input
|
||||
value={val}
|
||||
|
||||
@@ -9,6 +9,8 @@ import { useSetting } from '../state/hooks/settings';
|
||||
import { settingsAtom } from '../state/settings';
|
||||
import colorMXID from '$util/colorMXID';
|
||||
|
||||
const inFlightProfiles = new Map<string, Promise<any>>();
|
||||
|
||||
export type UserProfile = {
|
||||
avatarUrl?: string;
|
||||
displayName?: string;
|
||||
@@ -21,17 +23,38 @@ export type UserProfile = {
|
||||
_fetched?: boolean;
|
||||
};
|
||||
|
||||
const normalizeInfo = (info: any): UserProfile => ({
|
||||
avatarUrl: info.avatar_url,
|
||||
displayName: info.displayname,
|
||||
pronouns: info['io.fsky.nyx.pronouns'],
|
||||
timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
|
||||
bio: info['moe.sable.app.bio'] || info['chat.commet.profile_bio'],
|
||||
bannerUrl: info['chat.commet.profile_banner'],
|
||||
nameColor: info['moe.sable.app.name_color'],
|
||||
extended: {},
|
||||
_fetched: true,
|
||||
});
|
||||
const normalizeInfo = (info: any): UserProfile => {
|
||||
const knownKeys = [
|
||||
'avatar_url',
|
||||
'displayname',
|
||||
'io.fsky.nyx.pronouns',
|
||||
'us.cloke.msc4175.tz',
|
||||
'm.tz',
|
||||
'moe.sable.app.bio',
|
||||
'chat.commet.profile_bio',
|
||||
'chat.commet.profile_banner',
|
||||
'moe.sable.app.name_color',
|
||||
];
|
||||
|
||||
const extended: Record<string, any> = {};
|
||||
Object.entries(info).forEach(([key, value]) => {
|
||||
if (!knownKeys.includes(key)) {
|
||||
extended[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
avatarUrl: info.avatar_url,
|
||||
displayName: info.displayname,
|
||||
pronouns: info['io.fsky.nyx.pronouns'],
|
||||
timezone: info['us.cloke.msc4175.tz'] || info['m.tz'],
|
||||
bio: info['moe.sable.app.bio'] || info['chat.commet.profile_bio'],
|
||||
bannerUrl: info['chat.commet.profile_banner'],
|
||||
nameColor: info['moe.sable.app.name_color'],
|
||||
extended,
|
||||
_fetched: true,
|
||||
};
|
||||
};
|
||||
|
||||
const isValidHex = (c: string) => /^#[0-9A-F]{6}$/i.test(c);
|
||||
const sanitizeFont = (f: string) => f.replace(/[;{}<>]/g, '').slice(0, 32);
|
||||
@@ -54,9 +77,19 @@ export const useUserProfile = (
|
||||
|
||||
useEffect(() => {
|
||||
if (!needsFetch) return;
|
||||
|
||||
let fetchPromise = inFlightProfiles.get(userId);
|
||||
|
||||
if (!fetchPromise) {
|
||||
fetchPromise = mx.getProfileInfo(userId).finally(() => {
|
||||
inFlightProfiles.delete(userId);
|
||||
});
|
||||
inFlightProfiles.set(userId, fetchPromise);
|
||||
}
|
||||
|
||||
let isMounted = true;
|
||||
|
||||
mx.getProfileInfo(userId)
|
||||
fetchPromise
|
||||
.then((info: any) => {
|
||||
if (!isMounted) return;
|
||||
const normalized = normalizeInfo(info);
|
||||
@@ -66,11 +99,13 @@ export const useUserProfile = (
|
||||
}));
|
||||
})
|
||||
.catch(() => {
|
||||
if (!isMounted) return;
|
||||
setGlobalProfiles((prev) => ({
|
||||
...prev,
|
||||
[userId]: { ...prev[userId], _fetched: true },
|
||||
}));
|
||||
});
|
||||
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ export function ConfigConfigLoading() {
|
||||
<SplashScreen>
|
||||
<Box grow="Yes" direction="Column" gap="400" alignItems="Center" justifyContent="Center">
|
||||
<Spinner variant="Secondary" size="600" />
|
||||
<Text>Heating up</Text>
|
||||
<Text>Petting cats</Text>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ export function AuthFooter() {
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
v1.2.0
|
||||
v1.2.1
|
||||
</Text>
|
||||
<Text as="a" size="T300" href="https://twitter.com/cinnyapp" target="_blank" rel="noreferrer">
|
||||
Twitter
|
||||
|
||||
@@ -50,7 +50,7 @@ function ClientRootLoading() {
|
||||
<SplashScreen>
|
||||
<Box direction="Column" grow="Yes" alignItems="Center" justifyContent="Center" gap="400">
|
||||
<Spinner variant="Secondary" size="600" />
|
||||
<Text>Heating up</Text>
|
||||
<Text>Petting cats</Text>
|
||||
</Box>
|
||||
</SplashScreen>
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export function WelcomePage() {
|
||||
<span>
|
||||
Yet another matrix client fork.{' '}
|
||||
<a href="https://github.com/7w1/sable" target="_blank" rel="noreferrer noopener">
|
||||
v1.2.0
|
||||
v1.2.1
|
||||
</a>
|
||||
</span>
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
HeadingRule,
|
||||
OrderedListRule,
|
||||
UnorderedListRule,
|
||||
SmallRule,
|
||||
HorizontalRuleRule,
|
||||
} from './rules';
|
||||
import { runBlockRule } from './runner';
|
||||
import { BlockMDParser } from './type';
|
||||
@@ -22,9 +24,11 @@ export const parseBlockMD: BlockMDParser = (text, parseInline) => {
|
||||
let result: string | undefined;
|
||||
|
||||
if (!result) result = runBlockRule(text, CodeBlockRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, HorizontalRuleRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, BlockQuoteRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, OrderedListRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, UnorderedListRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, SmallRule, parseBlockMD, parseInline);
|
||||
if (!result) result = runBlockRule(text, HeadingRule, parseBlockMD, parseInline);
|
||||
|
||||
// replace \n with <br/> because want to preserve empty lines
|
||||
|
||||
@@ -43,12 +43,12 @@ export const BlockQuoteRule: BlockMDRule = {
|
||||
},
|
||||
};
|
||||
|
||||
const ORDERED_LIST_MD_1 = '-';
|
||||
const O_LIST_ITEM_PREFIX = /^(-|[\da-zA-Z]\.) */;
|
||||
const ORDERED_LIST_MD_1 = '1.';
|
||||
const O_LIST_ITEM_PREFIX = /^([\da-zA-Z]\.) */;
|
||||
const O_LIST_START = /^([\d])\./;
|
||||
const O_LIST_TYPE = /^([aAiI])\./;
|
||||
const O_LIST_TRAILING_NEWLINE = /\n$/;
|
||||
const ORDERED_LIST_REG_1 = /(^(?:-|[\da-zA-Z]\.) +.+\n?)+/m;
|
||||
const ORDERED_LIST_REG_1 = /(^(?:[\da-zA-Z]\.) +.+\n?)+/m;
|
||||
export const OrderedListRule: BlockMDRule = {
|
||||
match: (text) => text.match(ORDERED_LIST_REG_1),
|
||||
html: (match, parseInline) => {
|
||||
@@ -73,10 +73,10 @@ export const OrderedListRule: BlockMDRule = {
|
||||
},
|
||||
};
|
||||
|
||||
const UNORDERED_LIST_MD_1 = '*';
|
||||
const U_LIST_ITEM_PREFIX = /^\* */;
|
||||
const UNORDERED_LIST_MD_1 = '-';
|
||||
const U_LIST_ITEM_PREFIX = /^[*-] */;
|
||||
const U_LIST_TRAILING_NEWLINE = /\n$/;
|
||||
const UNORDERED_LIST_REG_1 = /(^\* +.+\n?)+/m;
|
||||
const UNORDERED_LIST_REG_1 = /(^[*-] +.+\n?)+/m;
|
||||
export const UnorderedListRule: BlockMDRule = {
|
||||
match: (text) => text.match(UNORDERED_LIST_REG_1),
|
||||
html: (match, parseInline) => {
|
||||
@@ -96,5 +96,23 @@ export const UnorderedListRule: BlockMDRule = {
|
||||
},
|
||||
};
|
||||
|
||||
export const UN_ESC_BLOCK_SEQ = /^\\*(#{1,6} +|```|>|(-|[\da-zA-Z]\.) +|\* +)/;
|
||||
export const ESC_BLOCK_SEQ = /^\\(\\*(#{1,6} +|```|>|(-|[\da-zA-Z]\.) +|\* +))/;
|
||||
const HR_MD = '---';
|
||||
const HR_REG = /^--- *(?:\n|$)/m;
|
||||
export const HorizontalRuleRule: BlockMDRule = {
|
||||
match: (text) => text.match(HR_REG),
|
||||
html: () => `<hr data-md="${HR_MD}"/>`,
|
||||
};
|
||||
|
||||
const SMALL_MD = '-#';
|
||||
const SMALL_REG = /^-# +(.+)\n?/m;
|
||||
export const SmallRule: BlockMDRule = {
|
||||
match: (text) => text.match(SMALL_REG),
|
||||
html: (match, parseInline) => {
|
||||
const [, g1] = match;
|
||||
const content = parseInline ? parseInline(g1) : g1;
|
||||
return `<small data-md="${SMALL_MD}">${content}</small>`;
|
||||
},
|
||||
};
|
||||
|
||||
export const UN_ESC_BLOCK_SEQ = /^\\*(#{1,6} +|```|>|([\da-zA-Z]\.) +|[*-] +|-# +|--- *)/;
|
||||
export const ESC_BLOCK_SEQ = /^\\(\\*(#{1,6} +|```|>|([\da-zA-Z]\.) +|[*-] +|-# +|--- *))/;
|
||||
@@ -391,6 +391,18 @@ export const getReactCustomHtmlParser = (
|
||||
);
|
||||
}
|
||||
|
||||
if (name === 'small') {
|
||||
return (
|
||||
<Text {...props} className={css.Small} size="Inherit">
|
||||
{renderChildren()}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
if (name === 'hr') {
|
||||
return <hr {...props} className={css.HorizontalRule} />;
|
||||
}
|
||||
|
||||
if (name === 'pre') {
|
||||
return <CodeBlock opts={opts}>{children}</CodeBlock>;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ const defaultSettings: Settings = {
|
||||
monochromeMode: false,
|
||||
isMarkdown: true,
|
||||
editorToolbar: false,
|
||||
twitterEmoji: false,
|
||||
twitterEmoji: true,
|
||||
pageZoom: 100,
|
||||
hideActivity: false,
|
||||
|
||||
|
||||
@@ -248,3 +248,23 @@ export const highlightText = style([
|
||||
color: 'black',
|
||||
},
|
||||
]);
|
||||
|
||||
export const Small = style([
|
||||
DefaultReset,
|
||||
{
|
||||
fontSize: '0.85rem',
|
||||
opacity: config.opacity.Placeholder,
|
||||
},
|
||||
]);
|
||||
|
||||
export const HorizontalRule = style([
|
||||
DefaultReset,
|
||||
MarginSpaced,
|
||||
{
|
||||
border: 'none',
|
||||
borderBottom: `${config.borderWidth.B300} solid ${color.SurfaceVariant.ContainerLine}`,
|
||||
height: 0,
|
||||
margin: `${config.space.S400} 0`,
|
||||
userSelect: 'none',
|
||||
},
|
||||
]);
|
||||
@@ -4,6 +4,10 @@ export const floatingEditor = style({
|
||||
minWidth: '100%',
|
||||
});
|
||||
|
||||
export const floatingToolbar = style({
|
||||
minWidth: '100%',
|
||||
});
|
||||
|
||||
globalStyle(
|
||||
`
|
||||
${floatingEditor} > div,
|
||||
@@ -18,7 +22,7 @@ globalStyle(
|
||||
}
|
||||
);
|
||||
|
||||
globalStyle(`${floatingEditor} button`, {
|
||||
globalStyle(`${floatingEditor} ${floatingToolbar} button`, {
|
||||
borderRadius: '20px',
|
||||
backgroundColor: 'transparent',
|
||||
border: 'none',
|
||||
@@ -27,11 +31,11 @@ globalStyle(`${floatingEditor} button`, {
|
||||
cursor: 'pointer',
|
||||
});
|
||||
|
||||
globalStyle(`${floatingEditor} button *`, {
|
||||
globalStyle(`${floatingEditor} ${floatingToolbar} button *`, {
|
||||
color: 'inherit',
|
||||
});
|
||||
|
||||
globalStyle(`${floatingEditor} button:hover`, {
|
||||
globalStyle(`${floatingEditor} ${floatingToolbar} button:hover`, {
|
||||
backgroundColor: 'var(--sable-surface-container-hover)',
|
||||
color: 'var(--sable-primary-main)',
|
||||
});
|
||||
@@ -5,6 +5,7 @@ const MAX_TAG_NESTING = 100;
|
||||
const permittedHtmlTags = [
|
||||
'font',
|
||||
'del',
|
||||
'small',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
@@ -78,6 +79,8 @@ const permittedTagToAttributes = {
|
||||
u: ['data-md'],
|
||||
s: ['data-md'],
|
||||
del: ['data-md'],
|
||||
small: ['data-md'],
|
||||
hr: ['data-md'],
|
||||
};
|
||||
|
||||
const transformFontTag: Transformer = (tagName, attribs) => ({
|
||||
|
||||
@@ -21,6 +21,9 @@ export const timeYear = (ts: number): string => dayjs(ts).format('YYYY');
|
||||
export const timeHourMinute = (ts: number, hour24Clock: boolean): string =>
|
||||
dayjs(ts).format(hour24Clock ? 'HH:mm' : 'hh:mm A');
|
||||
|
||||
export const timeHourMinuteSecond = (ts: number, hour24Clock: boolean): string =>
|
||||
dayjs(ts).format(hour24Clock ? 'HH:mm:ss' : 'hh:mm:ss A');
|
||||
|
||||
export const timeDayMonYear = (ts: number, dateFormatString: string): string =>
|
||||
dayjs(ts).format(dateFormatString);
|
||||
|
||||
|
||||
Reference in new issue
Block a user