Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/nodes/base/BaseNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ export function createNodeClass(
// Add resize handler with constraint enforcement (unless overridden by image preview)
if (!config.showImagePreview) {
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed - let LiteGraph handle collapse sizing
if (this.flags?.collapsed) return

// Prevent circular updates
if (this._isResizing) return
this._isResizing = true
Expand Down Expand Up @@ -694,6 +697,9 @@ export function createNodeClass(

// Add onResize handler to sync widgets when manual resizing happens
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed - let LiteGraph handle collapse sizing
if (this.flags?.collapsed) return

// Prevent circular updates
if (this._isResizing) return
this._isResizing = true
Expand Down
16 changes: 16 additions & 0 deletions src/nodes/input/ImageSourceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { extractWorkflowFromPngFile, type WorkflowMetadata } from '../../lib/png
// Extend LGraphNode type for our custom properties
interface ImageSourceNodeType extends LGraphNode {
resizable?: boolean
onResize?: (size: [number, number]) => void
_dropZoneRect?: { x: number; y: number; width: number; height: number }
_isDragOver?: boolean
_imageLoaded?: HTMLImageElement | null
Expand Down Expand Up @@ -36,6 +37,18 @@ export function ImageSourceNode(this: ImageSourceNodeType) {
this.color = NODE_TYPE_COLOURS.imageSource
this.bgcolor = adjustBrightness(NODE_TYPE_COLOURS.imageSource, -40)

// Handle resize - skip constraints when collapsed to allow LiteGraph collapse
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed
if (this.flags?.collapsed) return

// Enforce minimum size for usability
const minWidth = 200
const minHeight = 150
if (size[0] < minWidth) size[0] = minWidth
if (size[1] < minHeight) size[1] = minHeight
}

// Store reference for callbacks
// eslint-disable-next-line @typescript-eslint/no-this-alias
const nodeRef = this
Expand Down Expand Up @@ -131,6 +144,9 @@ export function ImageSourceNode(this: ImageSourceNodeType) {

// Custom foreground drawing - draws image preview and drop zone
this.onDrawForeground = function (ctx: CanvasRenderingContext2D) {
// Don't draw content when node is collapsed
if (this.flags?.collapsed) return

const titleHeight = 26
const slotHeight = 20
const widgetHeight = 30
Expand Down
16 changes: 16 additions & 0 deletions src/nodes/input/PromptNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface PromptNodeType extends LGraphNode {
_textarea?: HTMLTextAreaElement
_editing: boolean
resizable?: boolean
onResize?: (size: [number, number]) => void
}

/**
Expand All @@ -30,6 +31,18 @@ export function PromptNode(this: PromptNodeType) {
this.size = [280, 180]
this.resizable = true

// Handle resize - skip constraints when collapsed to allow LiteGraph collapse
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed
if (this.flags?.collapsed) return

// Enforce minimum size for usability
const minWidth = 180
const minHeight = 100
if (size[0] < minWidth) size[0] = minWidth
if (size[1] < minHeight) size[1] = minHeight
}

// Store reference for callbacks
// eslint-disable-next-line @typescript-eslint/no-this-alias
const nodeRef = this
Expand All @@ -51,6 +64,9 @@ export function PromptNode(this: PromptNodeType) {

// Custom foreground drawing - draws the textarea that fills the node
this.onDrawForeground = function (ctx: CanvasRenderingContext2D) {
// Don't draw content when node is collapsed
if (this.flags?.collapsed) return

const bounds = getTextareaBounds()

if (bounds.height < 20) return
Expand Down
16 changes: 16 additions & 0 deletions src/nodes/input/SeedNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NODE_TYPE_COLOURS } from '../../types/nodes'
// Extend LGraphNode type for our custom properties
interface SeedNodeType extends LGraphNode {
resizable?: boolean
onResize?: (size: [number, number]) => void
_randomizeRect?: { x: number; y: number; width: number; height: number }
}

Expand Down Expand Up @@ -33,6 +34,18 @@ export function SeedNode(this: SeedNodeType) {
this.color = NODE_TYPE_COLOURS.seed
this.bgcolor = adjustBrightness(NODE_TYPE_COLOURS.seed, -40)

// Handle resize - skip constraints when collapsed to allow LiteGraph collapse
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed
if (this.flags?.collapsed) return

// Enforce minimum size for usability
const minWidth = 150
const minHeight = 100
if (size[0] < minWidth) size[0] = minWidth
if (size[1] < minHeight) size[1] = minHeight
}

// Store reference for callbacks
// eslint-disable-next-line @typescript-eslint/no-this-alias
const nodeRef = this
Expand All @@ -50,6 +63,9 @@ export function SeedNode(this: SeedNodeType) {

// Custom foreground drawing - draws Randomize button
this.onDrawForeground = function (ctx: CanvasRenderingContext2D) {
// Don't draw content when node is collapsed
if (this.flags?.collapsed) return

// Calculate button position (below widgets)
const titleHeight = 26
const widgetHeight = 30
Expand Down
16 changes: 16 additions & 0 deletions src/nodes/processing/NegativePromptNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const COMMON_NEGATIVES: Record<string, string> = {
// Extend LGraphNode type for our custom properties
interface NegativePromptNodeType extends LGraphNode {
resizable?: boolean
onResize?: (size: [number, number]) => void
_buttonRects: Array<{ x: number; y: number; width: number; height: number; label: string }>
}

Expand All @@ -42,6 +43,18 @@ export function NegativePromptNode(this: NegativePromptNodeType) {
this.color = NODE_TYPE_COLOURS.negativePrompt
this.bgcolor = adjustBrightness(NODE_TYPE_COLOURS.negativePrompt, -40)

// Handle resize - skip constraints when collapsed to allow LiteGraph collapse
this.onResize = function (size: [number, number]) {
// Don't enforce constraints when node is collapsed
if (this.flags?.collapsed) return

// Enforce minimum size for usability
const minWidth = 180
const minHeight = 150
if (size[0] < minWidth) size[0] = minWidth
if (size[1] < minHeight) size[1] = minHeight
}

// Store button rectangles for click detection
this._buttonRects = []

Expand All @@ -51,6 +64,9 @@ export function NegativePromptNode(this: NegativePromptNodeType) {

// Custom foreground drawing - draws quick-add buttons
this.onDrawForeground = function (ctx: CanvasRenderingContext2D) {
// Don't draw content when node is collapsed
if (this.flags?.collapsed) return

// Calculate button area (below the widget)
const widgetHeight = 60 // Approximate height of textarea widget
const titleHeight = 26
Expand Down