Prompt gallery (#957)

- [x] show prompt instead of app in autocomplete
- [x] use proper array/list for db (tags)
- [x] don't do <dyad-prompt> - replace inline
This commit is contained in:
Will Chen
2025-08-18 13:25:11 -07:00
committed by GitHub
parent a547735714
commit 573642ae5f
26 changed files with 1540 additions and 42 deletions

View File

@@ -0,0 +1,16 @@
export function replacePromptReference(
userPrompt: string,
promptsById: Record<number | string, string>,
): string {
if (typeof userPrompt !== "string" || userPrompt.length === 0)
return userPrompt;
return userPrompt.replace(
/@prompt:(\d+)/g,
(_match: string, idStr: string) => {
const idNum = Number(idStr);
const replacement = promptsById[idNum] ?? promptsById[idStr];
return replacement !== undefined ? replacement : _match;
},
);
}