From e87aa1873f6a01148898b41dc3498ca6f82410d8 Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Wed, 12 Apr 2023 19:36:35 -0600 Subject: [PATCH 1/5] Add slider setting type --- web/scripts/ui.js | 24 ++++++++++++++++++++++++ web/style.css | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 09861c440..1c7fdc8a1 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -270,6 +270,30 @@ class ComfySettingsDialog extends ComfyDialog { ]), ]); break; + case "slider": + element = $el("div", [ + $el("label", { textContent: name }, [ + $el("input", { + type: "range", + value, + oninput: (e) => { + setter(e.target.value); + e.target.nextElementSibling.value = e.target.value; + }, + ...attrs + }), + $el("input", { + type: "number", + value, + oninput: (e) => { + setter(e.target.value); + e.target.previousElementSibling.value = e.target.value; + }, + ...attrs + }), + ]), + ]); + break; default: console.warn("Unsupported setting type, defaulting to text"); element = $el("div", [ diff --git a/web/style.css b/web/style.css index 34e31726c..e3b445762 100644 --- a/web/style.css +++ b/web/style.css @@ -217,6 +217,14 @@ button.comfy-queue-btn { z-index: 99; } +.comfy-modal.comfy-settings input[type="range"] { + vertical-align: middle; +} + +.comfy-modal.comfy-settings input[type="range"] + input[type="number"] { + width: 3.5em; +} + .comfy-modal input, .comfy-modal select { color: var(--input-text); From 8810e1b4b9e2c14860800a2bdc97d50d1aa2f904 Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Wed, 12 Apr 2023 21:15:21 -0600 Subject: [PATCH 2/5] Fix indentation --- web/scripts/ui.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 1c7fdc8a1..6cbc9383e 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -270,7 +270,7 @@ class ComfySettingsDialog extends ComfyDialog { ]), ]); break; - case "slider": + case "slider": element = $el("div", [ $el("label", { textContent: name }, [ $el("input", { @@ -278,16 +278,16 @@ class ComfySettingsDialog extends ComfyDialog { value, oninput: (e) => { setter(e.target.value); - e.target.nextElementSibling.value = e.target.value; + e.target.nextElementSibling.value = e.target.value; }, ...attrs }), - $el("input", { + $el("input", { type: "number", value, oninput: (e) => { setter(e.target.value); - e.target.previousElementSibling.value = e.target.value; + e.target.previousElementSibling.value = e.target.value; }, ...attrs }), From 307ef543bf66e5ffd718b3a0b148c72287b65a89 Mon Sep 17 00:00:00 2001 From: missionfloyd Date: Thu, 13 Apr 2023 10:04:06 -0600 Subject: [PATCH 3/5] Change grid size to slider --- web/extensions/core/snapToGrid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/extensions/core/snapToGrid.js b/web/extensions/core/snapToGrid.js index 20b245e18..cb5fc154b 100644 --- a/web/extensions/core/snapToGrid.js +++ b/web/extensions/core/snapToGrid.js @@ -9,7 +9,7 @@ app.registerExtension({ app.ui.settings.addSetting({ id: "Comfy.SnapToGrid.GridSize", name: "Grid Size", - type: "number", + type: "slider", attrs: { min: 1, max: 500, From 79ba0399d8d70bc655269fc3318455a70d14e180 Mon Sep 17 00:00:00 2001 From: EllangoK Date: Mon, 17 Apr 2023 19:02:08 -0400 Subject: [PATCH 4/5] selects current word automatically --- web/extensions/core/editAttention.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/web/extensions/core/editAttention.js b/web/extensions/core/editAttention.js index fe395c3ca..55201953b 100644 --- a/web/extensions/core/editAttention.js +++ b/web/extensions/core/editAttention.js @@ -70,7 +70,7 @@ name:id, let end = inputField.selectionEnd; let selectedText = inputField.value.substring(start, end); - // If there is no selection, attempt to find the nearest enclosure + // If there is no selection, attempt to find the nearest enclosure, or select the current word if (!selectedText) { const nearestEnclosure = findNearestEnclosure(inputField.value, start); if (nearestEnclosure) { @@ -78,7 +78,18 @@ name:id, end = nearestEnclosure.end; selectedText = inputField.value.substring(start, end); } else { - return; + // Select the current word, find the start and end of the word (first space before and after) + start = inputField.value.substring(0, start).lastIndexOf(" ") + 1; + end = inputField.value.substring(end).indexOf(" ") + end; + // Remove all punctuation at the end and beginning of the word + while (inputField.value[start].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) { + start++; + } + while (inputField.value[end - 1].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) { + end--; + } + selectedText = inputField.value.substring(start, end); + if (!selectedText) return; } } @@ -97,7 +108,6 @@ name:id, // If the selection is not enclosed in parentheses, add them if (selectedText[0] !== "(" || selectedText[selectedText.length - 1] !== ")") { - console.log("adding parentheses", inputField.value[start], inputField.value[end], selectedText); selectedText = `(${selectedText})`; } From a962222992479057b104cdd06bf399d2a2cae2fa Mon Sep 17 00:00:00 2001 From: EllangoK Date: Mon, 17 Apr 2023 23:40:44 -0400 Subject: [PATCH 5/5] correctly checks end of the text --- web/extensions/core/editAttention.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/extensions/core/editAttention.js b/web/extensions/core/editAttention.js index 55201953b..206d0830a 100644 --- a/web/extensions/core/editAttention.js +++ b/web/extensions/core/editAttention.js @@ -79,8 +79,16 @@ name:id, selectedText = inputField.value.substring(start, end); } else { // Select the current word, find the start and end of the word (first space before and after) - start = inputField.value.substring(0, start).lastIndexOf(" ") + 1; - end = inputField.value.substring(end).indexOf(" ") + end; + const wordStart = inputField.value.substring(0, start).lastIndexOf(" ") + 1; + const wordEnd = inputField.value.substring(end).indexOf(" "); + // If there is no space after the word, select to the end of the string + if (wordEnd === -1) { + end = inputField.value.length; + } else { + end += wordEnd; + } + start = wordStart; + // Remove all punctuation at the end and beginning of the word while (inputField.value[start].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) { start++;