No reference image. Prompt only.
Prompt only what should change in the painted area.
@@ -2361,6 +2395,9 @@ const editLightbox = ref
(null)
const editLightboxUrl = ref('')
const file = ref(null)
const inputStillId = ref('')
+const renamingInputStill = ref(false)
+const inputStillNameDraft = ref('')
+const inputStillRenameEl = ref(null)
const preview = ref('')
const dragging = ref(false)
const prompt = ref('')
@@ -4591,6 +4628,7 @@ async function copyPrompt(text: string) {
}
function resetImage() {
+ cancelInputStillRename()
if (preview.value) URL.revokeObjectURL(preview.value)
file.value = null
inputStillId.value = ''
@@ -4623,7 +4661,59 @@ function stillIdFromLibraryUrl(url: string) {
return match ? decodeURIComponent(match[1]) : ''
}
+const inputStill = computed(() => stills.value.find(item => item.id === inputStillId.value) || null)
+
+const inputStillLabel = computed(() => {
+ if (inputStill.value) return stillTitle(inputStill.value)
+ const name = file.value?.name || ''
+ return name.replace(/\.[a-z0-9]+$/i, '') || 'Untitled still'
+})
+
+function startInputStillRename() {
+ renamingInputStill.value = true
+ inputStillNameDraft.value = inputStillLabel.value
+ nextTick(() => {
+ inputStillRenameEl.value?.focus()
+ inputStillRenameEl.value?.select()
+ })
+}
+
+function cancelInputStillRename() {
+ renamingInputStill.value = false
+}
+
+async function saveInputStillName() {
+ if (!renamingInputStill.value) return
+ const name = inputStillNameDraft.value.trim().slice(0, 80)
+ if (!name) {
+ toast('A name is required')
+ return
+ }
+ if (name === inputStillLabel.value) {
+ cancelInputStillRename()
+ return
+ }
+ if (file.value) {
+ const ext = (file.value.name.match(/\.[a-z0-9]+$/i) || ['.png'])[0]
+ file.value = new File([file.value], `${clipFileName(name)}${ext}`, { type: file.value.type || 'image/png' })
+ }
+ const id = inputStillId.value
+ if (id) {
+ try {
+ applyLibrary(await $fetch(`/api/library/stills/${id}`, {
+ method: 'PATCH',
+ body: { name }
+ }))
+ } catch (error: any) {
+ toast(error?.data?.statusMessage || 'Could not rename still')
+ return
+ }
+ }
+ cancelInputStillRename()
+}
+
function readFile(next: File, opts?: { keepThumbnailPref?: boolean; stillId?: string }) {
+ cancelInputStillRename()
if (preview.value) URL.revokeObjectURL(preview.value)
file.value = next
inputStillId.value = opts?.stillId || ''