feat: architectural grid editor fullPage + slash commands + doc info panel + AI title
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
import type { Note } from '@/lib/types'
|
||||
|
||||
const MD_IMG = /!\[[^\]]*\]\(([^)\s]+)\)/g
|
||||
const HTML_IMG = /<img[^>]+src=["']([^"']+)["'][^>]*>/gi
|
||||
|
||||
/**
|
||||
* Plain-text preview for list view (light markdown stripping).
|
||||
*/
|
||||
@@ -31,3 +36,27 @@ export function getNoteDisplayTitle(note: { title: string | null; content: strin
|
||||
const preview = stripMarkdownPreview(note.content || '', 100)
|
||||
return preview || untitled
|
||||
}
|
||||
|
||||
export function getNoteFeedImage(note: Note): string | null {
|
||||
const first = note.images?.[0]?.trim()
|
||||
if (first) return first
|
||||
|
||||
const content = note.content || ''
|
||||
MD_IMG.lastIndex = 0
|
||||
const md = MD_IMG.exec(content)
|
||||
if (md?.[1]) return md[1]
|
||||
|
||||
HTML_IMG.lastIndex = 0
|
||||
const html = HTML_IMG.exec(content)
|
||||
if (html?.[1]) return html[1]
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/** Plain excerpt for collection cards (HTML + markdown noise stripped). */
|
||||
export function getNotePlainExcerpt(note: Note, maxLen = 240): string {
|
||||
let raw = note.content || ''
|
||||
raw = raw.replace(/!\[[^\]]*\]\([^)]+\)/g, ' ')
|
||||
raw = raw.replace(/<[^>]+>/g, ' ')
|
||||
return stripMarkdownPreview(raw, maxLen)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user