Modernise list create/edit dialog (#8223)

This commit is contained in:
Samuel Newman
2025-09-23 20:11:21 +03:00
committed by GitHub
parent 3bc906b911
commit e90cfdc849
11 changed files with 536 additions and 77 deletions
+9 -2
View File
@@ -1,6 +1,9 @@
import {useCallback, useMemo} from 'react'
import {type RichText} from '@atproto/api'
import Graphemer from 'graphemer'
import {shortenLinks} from './rich-text-manip'
export function enforceLen(
str: string,
len: number,
@@ -45,13 +48,17 @@ export function useWarnMaxGraphemeCount({
text,
maxCount,
}: {
text: string
text: string | RichText
maxCount: number
}) {
const splitter = useMemo(() => new Graphemer(), [])
return useMemo(() => {
return splitter.countGraphemes(text) > maxCount
if (typeof text === 'string') {
return splitter.countGraphemes(text) > maxCount
} else {
return shortenLinks(text).graphemeLength > maxCount
}
}, [splitter, maxCount, text])
}