feat(chat): enhance ChatMessage component with context-aware film interaction

- Updated ChatMessage component to support click interactions for film context.
- Added computed property to determine if a message has associated films.
- Refactored film ID extraction to normalize film IDs for consistency.

Made-with: Cursor
This commit is contained in:
Dorian
2026-03-02 16:49:47 +00:00
parent 464069b2f2
commit 6f79f0860d
2 changed files with 16 additions and 4 deletions
@@ -7,15 +7,20 @@ const panelFilms = ref<Film[]>([])
const selectedFilm = ref<Film | null>(null)
const panelTitle = ref('Recommended Films')
const FILM_TAG_RE = /\[\[film:(f\d+)\]\]/g
const FILM_TAG_RE = /\[\[film:(f?\d+)\]\]/gi
export function useContentPanel() {
function normalizeFilmId(raw: string): string {
return raw.startsWith('f') ? raw : `f${raw}`
}
function extractFilmIds(text: string): string[] {
const ids: string[] = []
let match: RegExpExecArray | null
const re = new RegExp(FILM_TAG_RE.source, 'g')
const re = new RegExp(FILM_TAG_RE.source, 'gi')
while ((match = re.exec(text)) !== null) {
if (!ids.includes(match[1])) ids.push(match[1])
const id = normalizeFilmId(match[1])
if (!ids.includes(id)) ids.push(id)
}
return ids
}