feat(theme-3): sync inbox/announcements/presence/deposit/search from main
This commit is contained in:
12
apps/admin/src/utils/html.ts
Normal file
12
apps/admin/src/utils/html.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/** 去除 HTML 标签,用于列表摘要与跑马灯纯文本 */
|
||||
export function stripHtml(html: string): string {
|
||||
if (!html) return '';
|
||||
if (!/[<>]/.test(html)) return html.trim();
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return (doc.body.textContent ?? '').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
/** 判断富文本是否实质为空 */
|
||||
export function isHtmlEmpty(html: string): boolean {
|
||||
return !stripHtml(html);
|
||||
}
|
||||
Reference in New Issue
Block a user