Commit Graph

235 Commits

Author SHA1 Message Date
filtered
38bbf2fead Add reroute snap highlight (#813)
### Reroute snap highlight

When connecting links, a simple border now helps to indicate that a
connecting link can be dropped on a reroute below the pointer.

### Reroute ID badges

Optionally, intended for debugging purposes, drawing of ID badges can
also be manually enabled via console.
2025-03-21 19:05:09 +00:00
filtered
cdbc0fa5e5 Cancel link connection by pressing Esc (#811)
Cancels connecting links if the escape key is pressed.
2025-03-21 18:53:13 +00:00
filtered
4078e3ad8b Improve reroutes - prep for LinkConnector overhaul (#810)
- Fixes TS types
- Various bug fixes for reroute / link (re)connect
- Adds reroute snap circle when connecting links
- Validates reroutes on drop (part of larger work)
- Prevent nodes linking to themselves
2025-03-21 18:47:36 +00:00
filtered
3447ea1981 Remove unused code (#789)
'start' and 'finish' do not exist on canvas 2d context.
2025-03-16 04:37:34 +00:00
filtered
9b16144390 [CodeHealth] Standardise & remove deprecated code (#787)
- Removes event.keyCode use (i18n-safe)
- Prefer strict equality for readability
2025-03-15 03:15:38 +00:00
filtered
cd65c4bfea Fix regression in #782 undo fails via context menu (#785)
Only breaks when adding reroute via context menu.
2025-03-14 03:09:17 +00:00
filtered
bd17247b4f Centre reroutes spawned via link context menu (#782)
- Centre reroutes spawned via link context menu
- Fix changeTracker history for reroute context menu
2025-03-14 12:46:40 +11:00
filtered
b80e1744be Snap to reroute when connecting links (#778)
Add basic snap to reroute on hover; reuses existing slot visual.
2025-03-14 00:18:17 +00:00
filtered
034692120e [Refactor] Replace deprecated getConnectionPos (#776)
Uses `getInputPos` or `getOutputPos` where appropriate.
2025-03-13 22:19:28 +00:00
filtered
e6a914117b Add floating reroutes (#773)
### Floating reroutes

Native reroutes can now be kept in a disconnected state.

Link chains may be kept provided they are connected to _either_ an input
or an output. By design, reroutes will be automatically removed if both
sides are disconnected.
2025-03-13 19:56:57 +00:00
filtered
18811f50fc Add serialisation support for floating links (#771)
Adds the serialisation code to support the new floating links impl.
2025-03-13 15:20:14 +00:00
filtered
486c5ad6c0 [Refactor] Split link render code to private method (#765)
- Enables floating reroutes
- Allows rendering logic for a chain of reroutes to be called without a
real `LLink` connected to an input
- Deprecates unused `visible_links` array
2025-03-13 00:00:52 +00:00
filtered
6805643204 Snap to widget - fast widget conversion (#758)
- Initial basic impl.
- Tracking issue for proper impl. #757
2025-03-11 19:28:15 +00:00
filtered
27873d0351 [Cleanup] Remove duplicate code (#754)
- Removes null widget skip - this _should_ throw
- Removes widget locator that was on LGraphCanvas - canvas should not
functions that find things in graph space.
2025-03-11 16:41:37 +00:00
filtered
a7f2ff16a9 [TS] Remove optional from widget y and type (#752)
- Fixes widget `type` marked as optional - it is required
- Fixes widget `y` marked as optional - now initialised to 0
2025-03-11 15:46:10 +00:00
filtered
f6c605434b Fix fast widget connect indicator (#751)
Remains as visual artifact when pointer leaves widget.
2025-03-11 14:49:19 +00:00
filtered
314095a3c1 Enable reroutes globally (#747)
Removes the opt-in to enable flag for reroutes, which are now a
permanent feature.
2025-03-11 12:43:59 +00:00
filtered
35ec2a3fa1 [API] Remove unused drag & drop interface (#746)
Not maintained or functional.
2025-03-11 11:46:22 +00:00
filtered
35827b8494 [Refactor] Move animate code to DragAndScale (#745) 2025-03-11 11:31:21 +00:00
filtered
58011e77b6 [Refactor] Simplify & standardise canvas code (#744)
Various clean up & minor refactors / nits.
2025-03-11 10:21:11 +00:00
filtered
8ba671a5eb Fix animate to bounding rect interpolation (#743)
- Resolves #738
2025-03-11 09:41:28 +00:00
filtered
84dad03f4d Remove static circular dependency workaround (#734)
Workaround originally implemented when converting to ES modules, but is
now redundant.

`DEFAULT_EVENT_LINK_COLOR` confirmed unused in code search (litegraph
events).
2025-03-10 15:29:33 +00:00
filtered
c0bfe5489f [API] Add LinkConnector - replaces connecting_links (#726)
### LinkConnector

Replaces the minimal-change effort of `connecting_links` with a more
reliable implementation.

- Subscribable, event-based API
- Uses browser-standard `e.preventDefault()` to cancel `before-*` events
- Uses standard `state` POJO - can be proxied without issue
- Structures code and separates concerns out of `LGraphCanvas`
- Link creation calls can now be made from anywhere, without the need
for a rewrite
- New canvas sub-components now live in `src/canvas/`

### Rendering

- Skips link segments by setting a `_dragging` bool flag on the LLink or
Reroute
- Moves some previously nested code to event listeners, configured in
the `LGraphCanvas` constructor

### Deprecation

`LGraphCanvas.connecting_links` is now deprecated and will later be
removed.

Until it is removed, to prevent breaking extensions it will continue to
be set and cleared by a legacy callback. The contents of this property
are ignored; code search revealed no exentsions actually modifying the
array.
2025-03-08 23:48:45 +00:00
filtered
8e59fbfaa2 Prep link connector (#725)
Prepration for LinkConnector replacement

- Simplifies code
- Minor perf improvement
- nits and clean up
2025-03-08 20:43:27 +00:00
filtered
68945cb54d Remove getTime workaround and Node.js type bleeding (#723)
- Removes legacy timer workaround (redundant on Chrome v6 / Node.js v16)
- Removes old type workarounds
- Improves type inference speed
2025-03-08 13:27:49 +00:00
Chenlei Hu
c21510773e [Bug] Fix link drop on multi-line string dom widget (#718)
Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2905
2025-03-07 10:28:07 -05:00
filtered
3e44f6a0c1 [API] Add improved slot locator functions (#716)
- Returns object with slot, index, and pos
- Locate-by-type returns object with slot & index
- Uses standard `undefined` return for concise chaining & validation
- Free 10x perf increase over getConnectionPos (used basic random data
to test, out of curiosity)
2025-03-07 13:18:06 +00:00
filtered
84fad5b8a5 [Perf] Fix unnecessary canvas redraw (null vs undefined) (#715)
Fixes regression added in TS strict conversion. A fallback to `null`
added to match the TS type, however value being stored was actually
uncaught use of `undefined`.

`null` !== `undefined` -> redraw every frame the pointer moves
2025-03-07 11:50:53 +00:00
filtered
7e2009188d [Refactor] Split functions out to file (#713)
Splits code out from `LGraphCanvas`.
2025-03-07 09:07:38 +00:00
Chenlei Hu
54f96ca028 Add LGraphCanvas.isNodeVisible (#711)
Add LGraphCanvas.isNodeVisible or more efficient node visibility checks.
2025-03-06 15:20:51 -05:00
filtered
e62ef2e0aa [Refactor] Prefer undefined over explicit null (#709)
- Ref: #595
2025-03-05 10:22:51 +00:00
filtered
e4a41669f6 Fix moving output links loses subsequent reroutes
Now maintains any level of reroute chain complexity when moving links.
2025-03-04 07:25:10 +11:00
filtered
32b6b7eff9 Fix reroutes lost when moving links via outputs (#699)
- Resolves #309

https://github.com/user-attachments/assets/70c8b9ba-b4e6-4293-a254-6ae95930d1f1
2025-03-03 19:16:55 +00:00
filtered
aca81a99c8 Fix regression in legacy search (#698)
- Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2828
- Issue caused by earlier instantiation of `input` object
2025-03-03 17:42:00 +00:00
filtered
b227eefbdd Improve connecting link logic (#697)
### Current

- Connections are disconnected the moment a link starts being dragged
- Reseating a connection where it came from creates a new connection
- If the process is somehow interrupted, the links are already gone

### Proposed

- Connection is disconnected after a new connection is made
- Rendering is bypassed for the link segment being moved
- Does nothing if dropping a link exactly where it came from
- Adds early return when trying to connect a node to itself
2025-03-03 17:03:31 +00:00
filtered
cef6ab6ced Improve link drag & drop (#380)
- Resolves
https://github.com/Comfy-Org/litegraph.js/issues/309#issuecomment-2508726168
- Output issue still pending
- Splits connecting links `pointerup` handler to separate function,
which can now be called from `CanvasPointer` callbacks
  - Minor refactor; no functional changes

### Behaviour change

When moving existing links from an input slot, the link will not be
disconnected until the drop event occurs.

### Current

Shift + drag


https://github.com/user-attachments/assets/0b98f9bf-3d5f-467e-9a9b-e5695e5a0d0b

### Proposed

Shift + drag

https://github.com/user-attachments/assets/0bc36215-0247-41da-8050-e8df09addf23
2025-03-04 01:26:56 +11:00
bymyself
83fb246119 Fix Selection Marquee display is offset when DPI < 1 (#692)
Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/2481. The
canvas scaling behavior is not consistent with DPI which is the source
of many bugs. To verify, add console log somewhere:
2025-03-03 17:06:15 +11:00
Chenlei Hu
4cbf12849e [BugFix] Fix add node via context menu (2) (#689)
https://github.com/Comfy-Org/litegraph.js/pull/647 failed to convert
`return` to `continue` when converting forEach to for-lop.
2025-03-02 21:21:39 -05:00
Chenlei Hu
9af4ee120c Revert "[BugFix] Fix adding node via context menu" (#688)
Reverts Comfy-Org/litegraph.js#682

Reason: Revert improper fix.
2025-03-02 21:15:45 -05:00
Chenlei Hu
326670206d [BugFix] Fix adding node via context menu (#682)
Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/2814

Culprit: https://github.com/Comfy-Org/litegraph.js/pull/647
2025-03-02 18:38:31 -05:00
filtered
af7db40fce [chore] Clean up ignores after strict mode enabled (#680)
- Replaces all `ts-ignore` with `ts-expect-error`
- Resolves https://github.com/Comfy-Org/litegraph.js/issues/578
2025-03-02 14:56:15 +00:00
filtered
a815ce92a8 Add final refactoring to enable TS strict (#678)
- Removes long-deprecated onMenuNodePin
  - Code search empty
- Fixes TS types
- Minor refactors to ensure type-safety
- Adds explicit throws and null checks
2025-03-02 14:42:24 +00:00
filtered
972527de70 [Refactor] Use strict mode in Add Node menus (#677)
- Improves TS types
- Adds type guards / null checks
2025-03-02 14:17:25 +00:00
filtered
77b274f27f Add link context menu info to replace console error (#676)
Shows a single menu item with an error message when a link is corrupt.
2025-03-02 14:10:43 +00:00
filtered
b1885ebec8 Remove redundant code - onGetInputs / onGetOutputs (#674)
- Removes unused context menu for optional in/outputs
- At the top of the node context menu, greyed out `Inputs` and `Outputs`
- API does not fit with current design
- If required, rewrite would be simpler
2025-03-02 13:47:48 +00:00
filtered
6cb9131035 [TS] Use strict mode in LGraphCanvas (#673)
- Adds remaining TS nullable types
- Adds type guards to allow strict mode
  - Uses explicit throw in places that would throw regardless
- Adds ts-ignore that must be removed later
  * [ ] #578
2025-03-02 13:34:02 +00:00
filtered
02d991d669 [Refactor] Minor refactors to support strict mode (#671)
- Removes unnecessary `null`-init
- Deprecates unused drag / drop code
- Adds null checks
2025-03-02 09:02:29 +00:00
filtered
1aba15bbca Fix incorrect links highlighted (#670)
Fixes rare issue where incorrect links could be highlighted (and
seemingly remain highlighted).

Requires corrupt links & null coercion.
2025-03-02 08:49:13 +00:00
filtered
78175e2c1b [TS] Add strict nullability to LGraphCanvas (#669)
- Updates typing in copy & paste
- Clean up
2025-03-02 08:34:26 +00:00
filtered
d597271954 Add runtime type guards to search box (#668)
- Prevents unnecessary property access exceptions
- Adds TS strict types
- Removes inline polyfill for `Array.filter`
2025-03-02 08:12:15 +00:00