fix: text compose papercuts (#270)

* make fixes

* cleanup
This commit was merged in pull request #270.
This commit is contained in:
Arjun Patel
2026-06-11 12:08:34 -07:00
committed by GitHub
parent 66d53497c5
commit ca3bbf204e
12 changed files with 220 additions and 60 deletions
+7
View File
@@ -0,0 +1,7 @@
/** Font scale for short messages shown as large centered text. Shared by the
* composer and the posted view so editing matches the final render. */
export function getImmersiveTextStyle(length: number) {
if (length < 30) return { size: 'text-5xl', weight: 'font-semibold' };
if (length < 70) return { size: 'text-3xl', weight: 'font-semibold' };
return { size: 'text-2xl', weight: 'font-normal' };
}
+8
View File
@@ -14,3 +14,11 @@ export function extractUrls(text: string): string[] {
// should only yield a single preview card.
return Array.from(new Set(Array.from(text.matchAll(URL_REGEX), (m) => m[0])));
}
export function domainFromUrl(url: string): string {
try {
return new URL(url).hostname.replace(/^www\./, '');
} catch {
return url;
}
}
+5
View File
@@ -0,0 +1,5 @@
export function hasMarkdownFormatting(content: string): boolean {
return /^#{1,6} |^\s*[-*+] |^\s*\d+\. |^```|`[^`]+`|\*\*|__|\*\S[^*]*\*|\b_\S[^_]*_\b|^>/m.test(
content,
);
}