diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e968fe5..02388b05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff80e4c1..b9812722 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index de883fff..a893884f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package-lock.json b/package-lock.json index f71748f4..c9df2f0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index f6c37ced..ed3a15a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sable", - "version": "1.2.0", + "version": "1.2.1", "description": "Yet another matrix client fork", "type": "module", "packageManager": "npm@11.11.0", diff --git a/src/app/components/editor/Elements.tsx b/src/app/components/editor/Elements.tsx index 938e38f8..ce24872d 100644 --- a/src/app/components/editor/Elements.tsx +++ b/src/app/components/editor/Elements.tsx @@ -226,6 +226,19 @@ export function RenderElement({ attributes, element, children }: RenderElementPr {children} ); + case BlockType.Small: + return ( + + {children} + + ); + case BlockType.HorizontalRule: + return ( +
+
+ {children} +
+ ); default: return ( + <> diff --git a/src/app/components/editor/input.ts b/src/app/components/editor/input.ts index c0d5b03f..af686a9e 100644 --- a/src/app/components/editor/input.ts +++ b/src/app/components/editor/input.ts @@ -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({ diff --git a/src/app/components/editor/output.ts b/src/app/components/editor/output.ts index c9683dc3..1e827a92 100644 --- a/src/app/components/editor/output.ts +++ b/src/app/components/editor/output.ts @@ -57,6 +57,10 @@ const elementToCustomHtml = (node: CustomElement, children: string): string => { return `
    ${children}
`; case BlockType.UnorderedList: return `
    ${children}
`; + case BlockType.Small: + return `${children}`; + case BlockType.HorizontalRule: + return `
`; 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; } diff --git a/src/app/components/editor/slate.d.ts b/src/app/components/editor/slate.d.ts index da1460e5..81d690fb 100644 --- a/src/app/components/editor/slate.d.ts +++ b/src/app/components/editor/slate.d.ts @@ -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 { diff --git a/src/app/components/editor/types.ts b/src/app/components/editor/types.ts index 9a108ec7..7eb1cfb8 100644 --- a/src/app/components/editor/types.ts +++ b/src/app/components/editor/types.ts @@ -21,4 +21,6 @@ export enum BlockType { Emoticon = 'emoticon', Link = 'link', Command = 'command', + Small = 'small', + HorizontalRule = 'hr', } diff --git a/src/app/components/editor/utils.ts b/src/app/components/editor/utils.ts index d1f1c421..851bc30d 100644 --- a/src/app/components/editor/utils.ts +++ b/src/app/components/editor/utils.ts @@ -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, }); diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index fc9acd6e..a3bc3cf4 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -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 ; + 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(/]*>/g); - if (imageTags) { - safeCustomBody = imageTags.join(' '); - } else { - safeCustomBody = undefined; + const safeCustomBody = useMemo(() => { + if (!customBody) return undefined; + if (customBody.length > 8000) { + const imageTags = customBody.match(/]*>/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 && /]*>/i.test(safeCustomBody); + if (!hasImage) return false; + } + + return true; + }, [trimmedBody, safeCustomBody]); + + if (!body) return ; - const isJumbo = trimmedBody.length < 500 && JUMBO_EMOJI_REG.test(trimmedBody); const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG); const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined; diff --git a/src/app/components/message/Time.tsx b/src/app/components/message/Time.tsx index b1ba7571..37572a2a 100644 --- a/src/app/components/message/Time.tsx +++ b/src/app/components/message/Time.tsx @@ -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>( } else { time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`; } + const title = `${timeDayMonYear(ts, dateFormatString)} ${timeHourMinuteSecond(ts, hour24Clock)}`; return ( - + {time} ); diff --git a/src/app/components/message/layout/Base.tsx b/src/app/components/message/layout/Base.tsx index ac196a5b..922e704a 100644 --- a/src/app/components/message/layout/Base.tsx +++ b/src/app/components/message/layout/Base.tsx @@ -28,6 +28,10 @@ export const UsernameBold = as<'b'>(({ as: AsUsernameBold = 'b', className, ...p )); +export const PronounPill = as<'span'>(({ as: AsPronounPill = 'span', className, ...props }, ref) => ( + +)); + export const MessageTextBody = as<'div', css.MessageTextBodyVariants & { notice?: boolean }>( ({ as: asComp = 'div', className, preWrap, jumboEmoji, emote, notice, ...props }, ref) => ( (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]) => ( - {clamp(key, 64).split('.').pop()?.replace(/_/g, ' ')} + {key} - {String(clamp(value, 64))} + {clamp(renderValue(value), 128)} ))} diff --git a/src/app/features/common-settings/permissions/PowersEditor.tsx b/src/app/features/common-settings/permissions/PowersEditor.tsx index 1ed122a6..68cfba60 100644 --- a/src/app/features/common-settings/permissions/PowersEditor.tsx +++ b/src/app/features/common-settings/permissions/PowersEditor.tsx @@ -69,11 +69,17 @@ function EditPower({ maxPower, power, tag, onSave, onClose }: EditPowerProps) { const [iconFile, setIconFile] = useState(); const pickFile = useFilePicker(setIconFile, false); - const [tagColor, setTagColor] = useState(tag?.color); + const [tagColor, setTagColor] = useState(tag?.color || '#FFFFFF'); const [tagIcon, setTagIcon] = useState(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) { Color - + } - onRemove={() => setTagColor(undefined)} + picker={} + onRemove={() => setTagColor('#FFFFFF')} > {(openPicker, opened) => (