- mountRouteEditor(parent, host, …) — 덮개 · 전체 화면 · 닫기 걷음 · 이력 · 키 듣기 = host 보임 · 숨김 · 떠남 · 칸 크기 = ResizeObserver - [취소] → [반영 전으로](이력 처음으로 · 되돌리기로 다시 살림) · [확인] → [노선 반영] · 대기 막 = 화면 전체(노선 재탐색) - [노선 반영] 끝 = 초안 · 결과 · 옛 노선 · 종단면 캐시 비움 → remountRoute(location.reload 없앰) - R 라벨 = 칸 안 절대 위치 · 오른쪽 횡단 미리보기 = 접는 칸 · [3D] 단추 = 평면 머리 도구줄 - 새 _RouteEdit_UndoOwner(누른 판 기억) · 종단도 Ctrl+Z 줄이 물음 - 시험: test_345_3_route_body 5 · 칸 · 겉틀 시험 고쳐 씀 · 관련 411 통과(옛 3 실패 그대로) · typecheck 통과 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
/* =============================================================================
|
|
* B05_Profile_UI_RouteEdit_UndoOwner.ts
|
|
* 한 화면 두 이력(345-3) — 평면(노선 편집)과 종단도가 둘 다 창(window)에서 Ctrl+Z · Y 를 듣는다.
|
|
* **마지막에 만진 판 하나만** 받는다: 누른 자리(평면 `.b05-routeedit` · 종단 판 `.b05-route-profile`)를
|
|
* 기억해 두고, 각 듣는 쪽이 받기 전에 묻는다. 평면이 안 듣는 동안(보기 숨김 · 떠남)은 늘 종단도.
|
|
* 한 줄 되돌리기로 합치는 일은 346-4.
|
|
* ========================================================================== */
|
|
|
|
export type UndoPanel = "plan" | "profile";
|
|
|
|
let last: UndoPanel = "profile";
|
|
let planListening = false;
|
|
let bound = false;
|
|
|
|
function remember(event: Event): void {
|
|
const target = event.target as Element | null;
|
|
if (!target?.closest) return;
|
|
if (target.closest(".b05-routeedit")) last = "plan";
|
|
else if (target.closest(".b05-route-profile")) last = "profile";
|
|
}
|
|
|
|
/** 평면 이력이 듣기 시작 · 멈춤 — 보기가 보일 때 켜고 숨을 때 끈다. */
|
|
export function setPlanUndoListening(on: boolean): void {
|
|
planListening = on;
|
|
if (bound) return;
|
|
bound = true;
|
|
window.addEventListener("pointerdown", remember, true);
|
|
}
|
|
|
|
/** 지금 Ctrl+Z · Y 를 받을 판. */
|
|
export function undoOwner(): UndoPanel {
|
|
return planListening && last === "plan" ? "plan" : "profile";
|
|
}
|