diff --git a/public/index.html b/public/index.html index 53ebb56ab..9047c6892 100644 --- a/public/index.html +++ b/public/index.html @@ -2077,14 +2077,14 @@

Keywords

Seperate by commas
- +
- +
diff --git a/public/scripts/extensions/stable-diffusion/index.js b/public/scripts/extensions/stable-diffusion/index.js index d91a68829..d55a5ed05 100644 --- a/public/scripts/extensions/stable-diffusion/index.js +++ b/public/scripts/extensions/stable-diffusion/index.js @@ -6,7 +6,7 @@ import { showSwipeButtons } from "../../../script.js"; import { getApiUrl, getContext, extension_settings, defaultRequestArgs } from "../../extensions.js"; -import { stringFormat } from "../../utils.js"; +import { stringFormat, initScrollHeight, resetScrollHeight } from "../../utils.js"; // Wraps a string into monospace font-face span const m = x => `${x}`; @@ -88,7 +88,10 @@ async function loadSettings() { $('#sd_width').val(extension_settings.sd.width).trigger('input'); $('#sd_height').val(extension_settings.sd.height).trigger('input'); + await Promise.all([loadSamplers(), loadModels()]); + + } function onScaleInput() { @@ -105,11 +108,13 @@ function onStepsInput() { function onPromptPrefixInput() { extension_settings.sd.prompt_prefix = $('#sd_prompt_prefix').val(); + resetScrollHeight($(this)); saveSettingsDebounced(); } function onNegativePromptInput() { extension_settings.sd.negative_prompt = $('#sd_negative_prompt').val(); + resetScrollHeight($(this)); saveSettingsDebounced(); } @@ -321,7 +326,7 @@ jQuery(async () => { - + @@ -336,5 +341,12 @@ jQuery(async () => { $('#sd_negative_prompt').on('input', onNegativePromptInput); $('#sd_width').on('input', onWidthInput); $('#sd_height').on('input', onHeightInput); + + $('.sd_settings .inline-drawer-toggle').on('click', function () { + initScrollHeight($("#sd_prompt_prefix")); + initScrollHeight($("#sd_negative_prompt")); + }) + await loadSettings(); + }); \ No newline at end of file diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 06bdd5c32..82c7c6131 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -164,15 +164,22 @@ export function restoreCaretPosition(element, position) { } export async function resetScrollHeight(element) { - element.style.height = ''; - element.style.height = (element.scrollHeight) + 3 + 'px'; + $(element).css('height', '0px'); + $(element).css('height', $(element).prop('scrollHeight') + 3 + 'px'); } export async function initScrollHeight(element) { await delay(1); - const height = Number($(element).prop("scrollHeight") + 3); - console.log(`init height to ${height}`); - //console.log(element.style.height); + + const curHeight = Number($(element).css("height").replace('px', '')); + const curScrollHeight = Number($(element).prop("scrollHeight")); + const diff = curScrollHeight - curHeight; + + if (diff < 3) { return } //happens when the div isn't loaded yet + + const newHeight = curHeight + diff + 3; //the +3 here is to account for padding/line-height on text inputs + //console.log(`init height to ${newHeight}`); $(element).css("height", ""); - $(element).css("height", `${height}px`); + $(element).css("height", `${newHeight}px`); + //resetScrollHeight(element); } \ No newline at end of file diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 85da5f962..1ec51b112 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -188,6 +188,7 @@ function appendWorldEntry(entry) { .filter((x) => x); saveWorldInfo(); }); + keySecondaryInput.val(entry.keysecondary.join(",")).trigger("input"); initScrollHeight(keySecondaryInput); @@ -235,13 +236,17 @@ function appendWorldEntry(entry) { .closest(".world_entry") .find(".keysecondary"); - const keyPrimary = $(this) + const keysecondarytextpole = $(this) .closest(".world_entry") - .find(".key"); + .find(".keysecondarytextpole"); - const keyPrimaryHeight = $(keyPrimary).css('height'); + const keyprimarytextpole = $(this) + .closest(".world_entry") + .find(".keyprimarytextpole"); + + const keyprimaryHeight = keyprimarytextpole.outerHeight(); + keysecondarytextpole.css('height', keyprimaryHeight + 'px'); - keysecondary.css('height', keyPrimaryHeight) + 'px'; value ? keysecondary.show() : keysecondary.hide(); });