mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 10:57:03 +08:00
Merge branch 'comfyanonymous:master' into feature/blockweights
This commit is contained in:
commit
346d74f212
@ -70,7 +70,7 @@ name:id,
|
|||||||
let end = inputField.selectionEnd;
|
let end = inputField.selectionEnd;
|
||||||
let selectedText = inputField.value.substring(start, end);
|
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) {
|
if (!selectedText) {
|
||||||
const nearestEnclosure = findNearestEnclosure(inputField.value, start);
|
const nearestEnclosure = findNearestEnclosure(inputField.value, start);
|
||||||
if (nearestEnclosure) {
|
if (nearestEnclosure) {
|
||||||
@ -78,7 +78,26 @@ name:id,
|
|||||||
end = nearestEnclosure.end;
|
end = nearestEnclosure.end;
|
||||||
selectedText = inputField.value.substring(start, end);
|
selectedText = inputField.value.substring(start, end);
|
||||||
} else {
|
} else {
|
||||||
return;
|
// Select the current word, find the start and end of the word (first space before and after)
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
while (inputField.value[end - 1].match(/[.,\/#!$%\^&\*;:{}=\-_`~()]/)) {
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
selectedText = inputField.value.substring(start, end);
|
||||||
|
if (!selectedText) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +116,6 @@ name:id,
|
|||||||
|
|
||||||
// If the selection is not enclosed in parentheses, add them
|
// If the selection is not enclosed in parentheses, add them
|
||||||
if (selectedText[0] !== "(" || selectedText[selectedText.length - 1] !== ")") {
|
if (selectedText[0] !== "(" || selectedText[selectedText.length - 1] !== ")") {
|
||||||
console.log("adding parentheses", inputField.value[start], inputField.value[end], selectedText);
|
|
||||||
selectedText = `(${selectedText})`;
|
selectedText = `(${selectedText})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ app.registerExtension({
|
|||||||
app.ui.settings.addSetting({
|
app.ui.settings.addSetting({
|
||||||
id: "Comfy.SnapToGrid.GridSize",
|
id: "Comfy.SnapToGrid.GridSize",
|
||||||
name: "Grid Size",
|
name: "Grid Size",
|
||||||
type: "number",
|
type: "slider",
|
||||||
attrs: {
|
attrs: {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 500,
|
max: 500,
|
||||||
|
|||||||
@ -270,6 +270,30 @@ class ComfySettingsDialog extends ComfyDialog {
|
|||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
break;
|
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:
|
default:
|
||||||
console.warn("Unsupported setting type, defaulting to text");
|
console.warn("Unsupported setting type, defaulting to text");
|
||||||
element = $el("div", [
|
element = $el("div", [
|
||||||
|
|||||||
@ -217,6 +217,14 @@ button.comfy-queue-btn {
|
|||||||
z-index: 99;
|
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 input,
|
||||||
.comfy-modal select {
|
.comfy-modal select {
|
||||||
color: var(--input-text);
|
color: var(--input-text);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user