Clipboard-related buttons are now grouped in a styled .painter-clipboard-group container for improved UI clarity. New CSS styles were added for the group, and the DOM structure was updated to wrap the 'Paste Image' and clipboard toggle buttons together.
Adds robust clipboard and drag & drop support for images, including ComfyUI Clipspace integration, system clipboard fallback, and improved user feedback. Clipboard and paste logic is centralized and clarified, with priority handling for internal clipboard, ComfyUI Clipspace, and system clipboard. Drag & drop is now handled at the canvas level, and tooltips and notifications provide clearer guidance for users.
Updated isValidImagePath to recognize and validate image URLs in addition to local file paths. The function now checks for valid URL formats and logs debug information for both URLs and local paths.
Moved all system clipboard paste and image path handling logic from CanvasLayers.js into a new ClipboardManager utility class. This improves code organization and separation of concerns, making clipboard-related functionality easier to maintain and extend.
Introduces a backend API endpoint to load images from local file paths and return them as base64-encoded PNGs. Updates CanvasLayers.js to detect image file paths in the clipboard, validate them, and attempt to load images using multiple strategies, including the new backend endpoint, ComfyUI view endpoints, and a file picker fallback. Also updates canvas context creation to use the 'willReadFrequently' option for improved performance.
Updated all calls to getContext('2d') to include the { willReadFrequently: true } option. This change improves performance for frequent pixel read operations, particularly for mask and image processing tasks.
Refactored Canvas.js to use the 'log' object for debug, info, and warn messages instead of console.log, console.warn, and console.error. Added more detailed and structured logging throughout the file to improve traceability and debugging, including context information for key operations such as state changes, layer management, mask editor interactions, and image processing.
Deleted the unused handleMaskEditorClose method and removed excessive console logging from widget visibility and mask application logic. Increased the default timeout for waitForWidget to 20000ms for improved reliability.
This commit applies consistent code style changes (mainly spacing and formatting) across multiple JS files for improved readability and maintainability. Additionally, it removes the unused 'js/examples/mask_editor_examples.js' file.
Deleted documentation files related to automatic mask loading. Cleaned up and streamlined comments across Canvas.js, CanvasInteractions.js, CanvasLayers.js, CanvasView.js, MaskTool.js, mask_utils.js, and example scripts for improved clarity and maintainability. No functional changes to core logic.
Refactored Canvas.js to use an async waitForWidget method for reliably finding widgets before manipulating them. The setPreviewVisibility method is now async and simplified, with excessive debug logging removed. CanvasState.js now triggers a render after saving state. In CanvasView.js, initial state loading is deferred and preview visibility is managed in the Canvas constructor, removing redundant calls.
Introduces a new 'show_preview' boolean option to CanvasNode and UI, allowing users to toggle the visibility of the canvas image preview widget. Updates Canvas.js with a setPreviewVisibility method to control the preview's display and size, and hooks this logic into CanvasView.js to respond to the new option. Adds detailed debug logging for widget state and size changes.
Implemented logic in Canvas.js to save and restore mask state when the mask editor is cancelled. Added robust detection and event listener setup for the cancel button in mask_utils.js, including multiple selector strategies and fallback mechanisms. This improves user experience by allowing users to revert changes if they cancel out of the mask editor.
Introduces functionality for automatically applying predefined masks in the ComfyUI mask editor. Adds new API methods and utilities in Canvas.js and mask_utils.js, including support for sending a clean image, handling both new and old mask editors, and flexible mask formats. Includes documentation, usage examples, and helper functions for mask processing and error handling.
Removes the default 'Open in MaskEditor' option from the menu and adds a new custom option with improved error handling and logging. This ensures the MaskEditor is opened through a controlled callback, providing better user feedback in case of errors.
Introduces a clipboardPreference setting to choose between system clipboard and ComfyUI Clipspace as the source for paste operations in CanvasLayers. Adds a UI button in CanvasView to toggle the clipboard source, improving user control over paste behavior.
Improves the paste operation in CanvasLayers to prioritize internal clipboard, then ComfyUI Clipspace, and finally the system clipboard, pasting images at the mouse position. Also clears the internal clipboard when the mouse leaves the canvas in CanvasInteractions.
Replaces the mask editor's image preparation to use a new method that combines the full image with the current mask, ensuring the editor starts with the correct state. Updates mask application logic to fully replace the mask area instead of blending, and refactors mask extraction and application in CanvasLayers for consistency and correctness, including a new getFlattenedCanvasForMaskEditor method.
Introduces a new method to export the flattened canvas with the mask applied as the alpha channel. Updates UI actions to allow previewing, copying, and saving the image with mask alpha, and ensures node previews use the new export method. This enhances workflows that require the mask to be embedded as transparency in the output image.
Replaces manual image layer creation with calls to canvas.addLayer, passing options and addMode. This streamlines image addition logic and ensures consistent handling of layer properties.
Removed all remaining delegating methods from Canvas.js, including handleMouseMove and garbage collection helpers, as part of finalizing the refactor to a pure facade. Updated REFACTORING_GUIDE.md to reflect the completion of this refactor and clarify the new architecture.
Eliminated 14 delegation methods to CanvasLayers from Canvas.js. Updated all relevant calls in CanvasRenderer.js, CanvasIO.js, and CanvasInteractions.js to use canvas.canvasLayers directly. This streamlines the Canvas class to only expose core facade operations and necessary helpers.
Removed delegating methods to CanvasState from Canvas.js and updated all references to use canvas.canvasState directly for state operations (undo, redo, saveStateToDB). Updated CanvasInteractions.js, CanvasIO.js, CanvasLayers.js, and CanvasView.js accordingly. Updated REFACTORING_GUIDE.md to reflect the completion of this refactor.
Renamed the CanvasLayers constructor parameter from 'canvasLayers' to 'canvas' and updated all internal references accordingly for clarity and consistency. Adjusted CanvasView.js to call layer operations via canvas.canvasLayers. Updated REFACTORING_GUIDE.md to document these architectural changes and ensure all modules follow a unified naming convention.
Moved the resizeLayer and rotateLayer logic from Canvas.js to CanvasLayers.js, improving modularity and consistency. Updated REFACTORING_GUIDE.md to reflect these changes and document the current architecture and status.
Updated all CanvasView.js method calls to use the new modular structure (canvasIO, canvasLayers, imageReferenceManager) as part of the Canvas facade refactor. Updated REFACTORING_GUIDE.md to reflect completed migration, document new usage patterns, and outline next steps. This improves code clarity and modularity while maintaining backward compatibility.
Changed the default log level from NONE to DEBUG in both canvas_node.py and LoggerUtils.js to improve logging visibility during development. Added js/REFACTORING_GUIDE.md with detailed documentation on the recent Canvas module refactor, outlining architectural changes, migration instructions, and developer notes.
Refactored the Canvas class to act as a facade, providing a simplified high-level interface and delegating detailed operations to internal modules. Added Polish documentation, grouped and clarified main operations, and moved legacy/delegation methods to the end for backward compatibility. Removed unused or redundant methods from CanvasLayers.js, such as removeLayer, moveLayer, addMattedLayer, isRotationHandle, getResizeHandle, handleBlendModeSelection, and getFlattenedCanvasAsDataURL, to streamline the codebase.
Introduces the ability to open the current canvas in a mask editor, upload and retrieve mask edits, and apply them to the mask layer. Adds utility functions for mask editor state detection and control, a new 'Edit Mask' button in the UI, and methods for handling mask updates and preview refresh. Also adds a setMask method to MaskTool for precise mask placement.
Added originalWidth and originalHeight properties to layers in CanvasLayers.js. Updated CanvasRenderer.js to display the original image dimensions in the layer info overlay if available, and improved overlay rendering to support multiline text.
Introduces a 'fit_on_add' boolean option to control whether images are fit to the canvas when added or pasted. Updates image addition and paste logic in Canvas, CanvasLayers, and CanvasView to support new placement modes ('fit', 'center', 'mouse', 'default').
The handlePaste method now accepts a pasteMode parameter to control image placement, allowing images to be pasted either at the mouse position or centered on the canvas. This improves user control when pasting images via keyboard shortcuts or UI buttons.
Eliminated unnecessary code that filled temporary canvases with a white background in two methods. This streamlines canvas creation and avoids redundant operations.
Changed the default log level for both Python and JavaScript module loggers from DEBUG to NONE to disable logging by default. Removed the README_LOGGER.md documentation file, and updated README.md to remove a reference to seamless integration.
Replaces direct calls to canvas.render() and node.onResize() with setTimeout to defer execution, ensuring UI updates occur after DOM changes. This helps prevent rendering issues and improves responsiveness when toggling mask controls and editor view.
Replaces all references to 'softness' with 'hardness' for brush controls in both CanvasView.js and MaskTool.js. Updates UI labels, slider IDs, and internal logic to use 'hardness' terminology, clarifying that a higher value means a harder brush edge.
Introduces a brush preview overlay using a separate preview canvas in MaskTool. Mouse event handlers in CanvasInteractions and MaskTool are updated to support passing both world and view coordinates, enabling accurate brush preview rendering. The preview is shown or hidden appropriately on mouse enter/leave and while drawing.
Set logging level to DEBUG in both Python and JavaScript loggers for improved debugging. Updated MaskTool to accept an onStateChange callback and trigger it after mask state changes, allowing Canvas to respond to mask updates.
Changed the default log level to LogLevel.NONE in both Python and JavaScript logger utilities. Updated LayerForgeLogger to fully disable logging when the effective level is NONE, ensuring no logs are emitted for disabled modules.
Refactors the .painter-tooltip CSS for better appearance, responsiveness, and usability, including new scaling classes, table-based layout, and improved scrollbar styling. Updates shortcut help content to use tables instead of lists for clarity. Enhances tooltip positioning logic to prevent overflow outside the viewport and ensures proper display near screen edges.
Split help tooltip content into standard and mask mode shortcuts. Tooltip now dynamically displays relevant shortcuts based on whether the mask tool is active, improving user guidance during mask editing.
Added 'title' attributes to various canvas control buttons to provide tooltips with descriptive information about each button's function. This improves accessibility and user experience by clarifying the purpose of each control.
Replaces direct DOM removal with a dedicated closeBlendModeMenu method for consistency. Increases menu z-index for better stacking, and appends the menu to the canvas container if available instead of always using document.body.
Replaces the onInteractionEnd callback with onStateChange for more consistent state change notifications. Adds a removeSelectedLayers method to Canvas for cleaner layer removal logic. Updates UI event handlers to use the new methods and callbacks, and ensures state is saved after relevant operations. Cleans up redundant updateOutput calls and streamlines output update logic.
Introduces an optional onInteractionEnd callback to the Canvas class, which is triggered at the end of user interactions. CanvasView now uses this callback to update output after interactions, improving responsiveness to user actions.
This commit applies consistent code formatting across multiple files, including spacing, indentation, and object destructuring. No functional changes were made; the update improves code readability and maintainability.
Removed redundant comments and streamlined logic across canvas-related modules, including mask positioning, garbage collection, and WebSocket communication. Improved code readability and maintainability by eliminating unnecessary explanations and clarifying intent in both Python and JavaScript files. No functional changes were made; this is a cleanup and refactor for better developer experience.