데스크탑 앱 전략편집기 수정
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type { ReactFlowInstance } from '@xyflow/react';
|
||||
|
||||
type FlowProjector = Pick<ReactFlowInstance, 'screenToFlowPosition' | 'getViewport'>;
|
||||
|
||||
/** screen(client) → React Flow 좌표 (Tauri WebView screenToFlowPosition 보정) */
|
||||
export function projectScreenToFlowPosition(
|
||||
clientX: number,
|
||||
clientY: number,
|
||||
rf: FlowProjector | null,
|
||||
containerEl: HTMLElement | null,
|
||||
): { x: number; y: number } {
|
||||
if (rf) {
|
||||
try {
|
||||
const pos = rf.screenToFlowPosition({ x: clientX, y: clientY });
|
||||
if (Number.isFinite(pos.x) && Number.isFinite(pos.y)) {
|
||||
return pos;
|
||||
}
|
||||
} catch {
|
||||
/* manual fallback */
|
||||
}
|
||||
}
|
||||
|
||||
const host = (containerEl?.querySelector('.react-flow') as HTMLElement | null) ?? containerEl;
|
||||
if (!host || !rf) {
|
||||
return { x: clientX, y: clientY };
|
||||
}
|
||||
|
||||
const rect = host.getBoundingClientRect();
|
||||
const { x: vx, y: vy, zoom } = rf.getViewport();
|
||||
const z = zoom || 1;
|
||||
return {
|
||||
x: (clientX - rect.left - vx) / z,
|
||||
y: (clientY - rect.top - vy) / z,
|
||||
};
|
||||
}
|
||||
|
||||
/** 팔레트 드롭 — 전략 빌더 캔버스 위인지 (우측 팔레트 위 release 무시) */
|
||||
export function isOverStrategyBuilder(clientX: number, clientY: number): boolean {
|
||||
const el = document.elementFromPoint(clientX, clientY);
|
||||
if (!el) return false;
|
||||
if (el.closest('.se-palette-panel, .se-side-wrap--right')) return false;
|
||||
return el.closest('.se-canvas-wrap') != null;
|
||||
}
|
||||
Reference in New Issue
Block a user