fix: append (Clone) to cloned prompt title and clone to prompt id
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
import ChevronRight from '../icons/ChevronRight.svelte';
|
||||
import Spinner from '../common/Spinner.svelte';
|
||||
import Tooltip from '../common/Tooltip.svelte';
|
||||
import { capitalizeFirstLetter } from '$lib/utils';
|
||||
import { capitalizeFirstLetter, slugify } from '$lib/utils';
|
||||
import XMark from '../icons/XMark.svelte';
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
@@ -68,7 +68,15 @@
|
||||
};
|
||||
|
||||
const cloneHandler = async (prompt) => {
|
||||
sessionStorage.prompt = JSON.stringify(prompt);
|
||||
const clonedPrompt = { ...prompt };
|
||||
|
||||
clonedPrompt.title = `${clonedPrompt.title} (Clone)`;
|
||||
const baseCommand = clonedPrompt.command.startsWith('/')
|
||||
? clonedPrompt.command.substring(1)
|
||||
: clonedPrompt.command;
|
||||
clonedPrompt.command = slugify(`${baseCommand} clone`);
|
||||
|
||||
sessionStorage.prompt = JSON.stringify(clonedPrompt);
|
||||
goto('/workspace/prompts/create');
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
export let onSubmit: Function;
|
||||
export let edit = false;
|
||||
export let prompt = null;
|
||||
export let clone = false;
|
||||
|
||||
const i18n = getContext('i18n');
|
||||
|
||||
@@ -68,8 +69,8 @@
|
||||
if (prompt) {
|
||||
title = prompt.title;
|
||||
await tick();
|
||||
|
||||
command = prompt.command.at(0) === '/' ? prompt.command.slice(1) : prompt.command;
|
||||
hasManualEdit = true;
|
||||
content = prompt.content;
|
||||
|
||||
accessControl = prompt?.access_control === undefined ? {} : prompt?.access_control;
|
||||
|
||||
Reference in New Issue
Block a user