Load prompt: support JSON and TXT metadata

Also, allow prompt files (one line per prompt) to be dnd'ed
This commit is contained in:
JeLuF 2023-03-19 16:21:17 +01:00
parent 8aead029a8
commit 7917ac8ebc
2 changed files with 4 additions and 3 deletions

View File

@ -490,6 +490,7 @@ async function parseContent(text) {
return true
} else {
console.warn(`Raw text content couldn't be parsed.`)
promptField.value = text
return false
}
}

View File

@ -1582,7 +1582,7 @@ promptsFromFileBtn.addEventListener('click', function() {
promptsFromFileSelector.click()
})
promptsFromFileSelector.addEventListener('change', function() {
promptsFromFileSelector.addEventListener('change', async function() {
if (promptsFromFileSelector.files.length === 0) {
return
}
@ -1590,8 +1590,8 @@ promptsFromFileSelector.addEventListener('change', function() {
let reader = new FileReader()
let file = promptsFromFileSelector.files[0]
reader.addEventListener('load', function() {
promptField.value = reader.result
reader.addEventListener('load', async function() {
await parseContent(reader.result)
})
if (file) {