From 566459ae7999c1261faec5a0f57ec2aac4de5a2a Mon Sep 17 00:00:00 2001
From: Firetheft <97147055+Firetheft@users.noreply.github.com>
Date: Tue, 2 Dec 2025 23:25:39 +0800
Subject: [PATCH] Quick fix for the damn nodes 2.0 mode.
---
js/Simple_Web_Browser.js | 75 ++++++++++++++++++++++++++++++++++++----
pyproject.toml | 2 +-
2 files changed, 70 insertions(+), 7 deletions(-)
diff --git a/js/Simple_Web_Browser.js b/js/Simple_Web_Browser.js
index 940a84b..bf23702 100644
--- a/js/Simple_Web_Browser.js
+++ b/js/Simple_Web_Browser.js
@@ -13,10 +13,15 @@ app.registerExtension({
widgetDiv.style.display = "flex";
widgetDiv.style.flexDirection = "column";
widgetDiv.style.width = "100%";
+
+ widgetDiv.dataset.captureWheel = "true";
+ widgetDiv.addEventListener("wheel", (e) => {
+ e.stopPropagation();
+ });
- const imageUrlWidget = this.addWidget("text", "image_url", "", () => {}, { multiline: true });
+ const imageUrlWidget = this.addWidget("hidden_text", "image_url", "", () => {}, { multiline: true });
imageUrlWidget.draw = function() {};
- imageUrlWidget.computeSize = function() { return [0, -4]; };
+ imageUrlWidget.computeSize = function() { return [0, 0]; };
this.addDOMWidget("browser", "div", widgetDiv);
@@ -64,13 +69,13 @@ app.registerExtension({
-
+
✓
✓
-
-
+
+
`;
const urlInput = widgetDiv.querySelector(".browser-url-input");
@@ -121,6 +126,50 @@ app.registerExtension({
}
});
+ imageUrlInput.addEventListener("paste", async (e) => {
+ if (!e.clipboardData || !e.clipboardData.files.length) {
+ return;
+ }
+
+ const file = e.clipboardData.files[0];
+
+ if (!file.type.startsWith("image/")) {
+ return;
+ }
+
+ e.preventDefault();
+
+ try {
+ imageUrlInput.value = "Pasting image...";
+ imageUrlInput.disabled = true;
+
+ const formData = new FormData();
+ const filename = `clipboard_paste_${Date.now()}.png`;
+ formData.append('image', file, filename);
+
+ const response = await api.fetchApi('/browser/upload_temp_image', { method: 'POST', body: formData });
+ const result = await response.json();
+
+ if (result.name) {
+ imageUrlWidget.value = result.name;
+
+ imageUrlInput.value = `Pasted: ${result.name}`;
+ imageUrlInput.disabled = false;
+
+ urlStatusIcon.style.display = "inline";
+ setTimeout(() => { urlStatusIcon.style.display = "none"; }, 2000);
+
+ } else {
+ throw new Error("Upload failed, no filename returned.");
+ }
+ } catch (err) {
+ console.error("Error pasting image:", err);
+ alert("Failed to paste image. See console for details.");
+ imageUrlInput.value = "";
+ imageUrlInput.disabled = false;
+ }
+ });
+
imageUrlInput.addEventListener("input", () => {
if(imageUrlInput.value.trim() === ""){
imageUrlWidget.value = "";
@@ -279,7 +328,15 @@ app.registerExtension({
const minWidth = 700;
if (size[1] < minHeight) size[1] = minHeight;
if (size[0] < minWidth) size[0] = minWidth;
- widgetDiv.style.height = `${size[1] - 70}px`;
+
+ let topOffset = widgetDiv.offsetTop;
+ const approximateHeaderHeight = 50;
+ if (topOffset < 20) {
+ topOffset += approximateHeaderHeight;
+ }
+ const bottomPadding = 20;
+ const targetHeight = size[1] - topOffset - bottomPadding;
+ widgetDiv.style.height = targetHeight + "px";
};
this.size = [900, 770];
@@ -292,6 +349,12 @@ app.registerExtension({
} catch (e) { console.error("Failed to load bookmarks:", e); }
setTimeout(() => { this.onResize(this.size); }, 1);
})();
+
+ requestAnimationFrame(() => {
+ if (this.onResize) {
+ this.onResize(this.size);
+ }
+ });
return r;
};
diff --git a/pyproject.toml b/pyproject.toml
index 784411a..039988c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,7 +1,7 @@
[project]
name = "ComfyUI_Simple_Web_Browser"
description = "This is a custom node for ComfyUI that embeds a simple web browser directly into the interface. It allows you to browse websites, find inspiration, and load images directly, which can help streamline your workflow."
-version = "1.0.0"
+version = "1.0.1"
license = {file = "LICENSE"}
# classifiers = [
# # For OS-independent nodes (works on all operating systems)