fix: text compose papercuts (#270)
* make fixes * cleanup
This commit was merged in pull request #270.
This commit is contained in:
@@ -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' };
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export function hasMarkdownFormatting(content: string): boolean {
|
||||
return /^#{1,6} |^\s*[-*+] |^\s*\d+\. |^```|`[^`]+`|\*\*|__|\*\S[^*]*\*|\b_\S[^_]*_\b|^>/m.test(
|
||||
content,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user