mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 22:37:32 +00:00
* [refactor] Improve renderer architecture organization Building on PR #5388, this refines the renderer domain structure: **Key improvements:** - Group all transform utilities in `transform/` subdirectory for better cohesion - Move canvas state to dedicated `renderer/core/canvas/` domain - Consolidate coordinate system logic (TransformPane, useTransformState, sync utilities) **File organization:** - `renderer/core/canvas/canvasStore.ts` (was `stores/graphStore.ts`) - `renderer/core/layout/transform/` contains all coordinate system utilities - Transform sync utilities co-located with core transform logic This creates clearer domain boundaries and groups related functionality while building on the foundation established in PR #5388. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Clean up linter-modified files * Fix import paths and clean up unused imports after rebase - Update all remaining @/stores/graphStore references to @/renderer/core/canvas/canvasStore - Remove unused imports from selection toolbox components - All tests pass, only reka-ui upstream issue remains in typecheck 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * [auto-fix] Apply ESLint and Prettier fixes --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: GitHub Action <action@github.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { useEventListener } from '@vueuse/core'
|
|
|
|
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
|
|
|
/**
|
|
* Adds a handler on copy that serializes selected nodes to JSON
|
|
*/
|
|
export const useCopy = () => {
|
|
const canvasStore = useCanvasStore()
|
|
|
|
useEventListener(document, 'copy', (e) => {
|
|
if (!(e.target instanceof Element)) {
|
|
return
|
|
}
|
|
if (
|
|
(e.target instanceof HTMLTextAreaElement &&
|
|
e.target.type === 'textarea') ||
|
|
(e.target instanceof HTMLInputElement && e.target.type === 'text')
|
|
) {
|
|
// Default system copy
|
|
return
|
|
}
|
|
const isTargetInGraph =
|
|
e.target.classList.contains('litegraph') ||
|
|
e.target.classList.contains('graph-canvas-container') ||
|
|
e.target.id === 'graph-canvas'
|
|
|
|
// copy nodes and clear clipboard
|
|
const canvas = canvasStore.canvas
|
|
if (isTargetInGraph && canvas?.selectedItems) {
|
|
canvas.copyToClipboard()
|
|
// clearData doesn't remove images from clipboard
|
|
e.clipboardData?.setData('text', ' ')
|
|
e.preventDefault()
|
|
e.stopImmediatePropagation()
|
|
return false
|
|
}
|
|
})
|
|
}
|