forked from extern/easydiffusion
Fix a bug in drag-and-drop where an empty Negative Prompt line would result in the next line getting assigned to negative prompts; Simplify the drag-and-drop text file parsing logic to use a single algorithm, the files are small enough that we don't need over-optimization and confuse new developers
This commit is contained in:
parent
fa080e380c
commit
1176ddcc85
@ -280,7 +280,7 @@
|
|||||||
<script src="media/js/auto-save.js?v=4"></script>
|
<script src="media/js/auto-save.js?v=4"></script>
|
||||||
<script src="media/js/main.js?v=8"></script>
|
<script src="media/js/main.js?v=8"></script>
|
||||||
<script src="media/js/themes.js?v=3"></script>
|
<script src="media/js/themes.js?v=3"></script>
|
||||||
<script src="media/js/dnd.js?v=5"></script>
|
<script src="media/js/dnd.js?v=6"></script>
|
||||||
<script>
|
<script>
|
||||||
async function init() {
|
async function init() {
|
||||||
await initSettings()
|
await initSettings()
|
||||||
|
@ -280,7 +280,6 @@ const TASK_TEXT_MAPPING = {
|
|||||||
use_stable_diffusion_model: 'Stable Diffusion model'
|
use_stable_diffusion_model: 'Stable Diffusion model'
|
||||||
}
|
}
|
||||||
const afterPromptRe = /^\s*Width\s*:\s*\d+\s*(?:\r\n|\r|\n)+\s*Height\s*:\s*\d+\s*(\r\n|\r|\n)+Seed\s*:\s*\d+\s*$/igm
|
const afterPromptRe = /^\s*Width\s*:\s*\d+\s*(?:\r\n|\r|\n)+\s*Height\s*:\s*\d+\s*(\r\n|\r|\n)+Seed\s*:\s*\d+\s*$/igm
|
||||||
const lineEndRe = /(?:\r\n|\r|\n)+/igm
|
|
||||||
function parseTaskFromText(str) {
|
function parseTaskFromText(str) {
|
||||||
const taskReqBody = {}
|
const taskReqBody = {}
|
||||||
|
|
||||||
@ -296,27 +295,15 @@ function parseTaskFromText(str) {
|
|||||||
for (const key in TASK_TEXT_MAPPING) {
|
for (const key in TASK_TEXT_MAPPING) {
|
||||||
const name = TASK_TEXT_MAPPING[key];
|
const name = TASK_TEXT_MAPPING[key];
|
||||||
let val = undefined
|
let val = undefined
|
||||||
if (str.startsWith(name + ':')) {
|
|
||||||
// Backend format, faster
|
const reName = new RegExp(`${name}\\ *:\\ *(.*)(?:\\r\\n|\\r|\\n)*`, 'igm')
|
||||||
lineEndRe.lastIndex = 0
|
const match = reName.exec(str);
|
||||||
const endMatch = lineEndRe.exec(str)
|
if (match) {
|
||||||
if (endMatch) {
|
console.log(match)
|
||||||
val = str.slice(name.length + 1, endMatch.index)
|
str = str.slice(0, match.index) + str.slice(match.index + match[0].length)
|
||||||
str = str.slice(endMatch.index + endMatch[0].length)
|
val = match[1]
|
||||||
} else {
|
|
||||||
val = str.slice(name.length + 1)
|
|
||||||
str = ""
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// User formatted, use regex to get all cases, but slower.
|
|
||||||
const reName = new RegExp(`${name}\\s*:\\s*(.*)(?:\\r\\n|\\r|\\n)*`, 'igm')
|
|
||||||
const match = reName.exec(str);
|
|
||||||
if (match) {
|
|
||||||
str = str.slice(0, match.index) + str.slice(match.index + match[0].length)
|
|
||||||
val = match[1]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (val) {
|
if (val !== undefined) {
|
||||||
taskReqBody[key] = TASK_MAPPING[key].parse(val.trim())
|
taskReqBody[key] = TASK_MAPPING[key].parse(val.trim())
|
||||||
console.log(TASK_MAPPING[key].name + ':', taskReqBody[key])
|
console.log(TASK_MAPPING[key].name + ':', taskReqBody[key])
|
||||||
if (!str) {
|
if (!str) {
|
||||||
|
Loading…
Reference in New Issue
Block a user