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:
16
src/ipc/utils/replacePromptReference.ts
Normal file
16
src/ipc/utils/replacePromptReference.ts
Normal 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;
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user