mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
## Summary Backport of #7166 to core/1.33 branch. - Fixes copy not working when text is selected in dialogs - Also includes workflow priority fix (workflow checked before parameters) ## Conflicts Resolved - `src/scripts/app.ts`: Accepted incoming changes for workflow priority logic ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7269-backport-core-1-33-Fix-copy-not-working-when-text-is-selected-in-dialogs-2c46d73d365081b690bfc9dc1548618e) by [Unito](https://www.unito.io) Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
|
/**
|
|
* Utility functions for handling workbench events
|
|
*/
|
|
|
|
/**
|
|
* Check if there is selected text in the document.
|
|
*/
|
|
function hasTextSelection(): boolean {
|
|
const selection = window.getSelection()
|
|
return selection !== null && selection.toString().trim().length > 0
|
|
}
|
|
|
|
/**
|
|
* Used by clipboard handlers to determine if copy/paste events should be
|
|
* intercepted for graph operations vs. allowing default browser behavior
|
|
* for text inputs and other UI elements.
|
|
*
|
|
* @param target - The event target to check
|
|
* @returns true if copy paste events will be handled by target
|
|
*/
|
|
export function shouldIgnoreCopyPaste(target: EventTarget | null): boolean {
|
|
const isTextInput =
|
|
target instanceof HTMLTextAreaElement ||
|
|
(target instanceof HTMLInputElement &&
|
|
![
|
|
'button',
|
|
'checkbox',
|
|
'file',
|
|
'hidden',
|
|
'image',
|
|
'radio',
|
|
'range',
|
|
'reset',
|
|
'search',
|
|
'submit'
|
|
].includes(target.type))
|
|
return isTextInput || useCanvasStore().linearMode || hasTextSelection()
|
|
}
|