feat(project): remove drag-to-move for annual goal cells

Goal text cells no longer get move borders or drag handling; clicking a
cell still highlights it. The weekly meeting table keeps its move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-07 14:02:51 +09:00
parent fbb6c648a5
commit b7c24c07e7
11 changed files with 26 additions and 194 deletions
+3 -99
View File
@@ -9182,12 +9182,6 @@
if (ta.dataset.bound) return;
ta.dataset.bound = "1";
if (ta.tagName !== "TEXTAREA") window.PJGoalText.attach(ta);
["top", "right", "bottom", "left"].forEach(function (edge) {
const handle = document.createElement("span");
handle.className = "pj-goal-move-edge"; handle.dataset.edge = edge;
handle.title = "끌어서 내용과 서식 이동"; handle.setAttribute("aria-hidden", "true");
ta.closest("td").appendChild(handle);
});
const r = textSaver.track(ta, ta.value);
if (r === "restored") restored++;
else if (r === "conflict") conflict++;
@@ -9200,109 +9194,19 @@
}
bindTexts(table);
window.PJGoalText.init(table, el("pj-goal-format"));
let moveBusy = false, moveClickUntil = 0;
function goalCellTd(node) {
const td = node && node.closest && node.closest("tbody.pj-goal-area td.pj-goal-texttd");
return td && table.contains(td) && td.querySelector(".pj-goal-text") ? td : null;
}
// 누른 글 칸 표시(테두리). 셀 테두리를 끌어 내용·서식 옮기기는 2026-10-07 요청으로 없앴다(회의록 표는 그대로).
function setMoveActive(td) {
table.querySelectorAll(".is-goal-active").forEach(function (cell) { cell.classList.remove("is-goal-active"); });
if (td) td.classList.add("is-goal-active");
}
function moveBody(editor) {
// 열의 기본 서식도 현재 표시값으로 명시해 연간·분기의 굵기가 이동 뒤 달라지지 않게 한다.
const cs = getComputedStyle(editor), rgb = cs.color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
const defaults = { bold: Number(cs.fontWeight) >= 600 || cs.fontWeight === "bold", italic: cs.fontStyle === "italic",
underline: (cs.textDecorationLine || "").includes("underline") };
const size = Math.round(parseFloat(cs.fontSize)); if (size >= 10 && size <= 32) defaults.size = size;
if (rgb) defaults.color = "#" + rgb.slice(1).map(function (v) { return Number(v).toString(16).padStart(2, "0"); }).join("");
return window.PJGoalText.encode(window.PJGoalText.readRuns(editor).map(function (run) { return Object.assign({}, defaults, run); }));
}
function moveCell(sourceTd, targetTd) {
if (moveBusy || sourceTd === targetTd) return;
moveBusy = true;
return withStruct(async function () {
const source = sourceTd.querySelector(".pj-goal-text"), target = targetTd.querySelector(".pj-goal-text");
const fields = [source, target], attrs = fields.map(function (n) { return n.getAttribute("contenteditable"); });
try {
if (!document.contains(sourceTd) || !document.contains(targetTd) || !source.value) return;
fields.forEach(function (n) { n.setAttribute("contenteditable", "false"); n.closest("td").classList.add("is-goal-move-saving"); });
await flushTexts();
const sourceBody = source.value, targetBody = target.value;
if (targetBody && !await confirm("대상 셀의 내용을 덮어쓸까요? 원본의 내용과 서식으로 바뀝니다.", { okText: "덮어쓰기", cancelText: "취소" })) return;
const res = await api("POST", "/project/api/goals/cells/move", {
source_row: source.dataset.row, source_month: source.dataset.month,
target_row: target.dataset.row, target_month: target.dataset.month,
source_body: sourceBody, target_body: targetBody, body: moveBody(source),
});
source.value = ""; target.value = res.body;
textSaver.acceptSaved(source, ""); textSaver.acceptSaved(target, target.value);
fit(source); fit(target); clearMergeSel(); setMoveActive(targetTd); flashSaved(targetTd);
showToast("내용과 서식을 이동했습니다.");
} catch (err) {
showToast("셀 이동 실패: " + err.message + " — 두 칸의 화면 내용은 유지됩니다. 다시 시도하거나 새로고침해 저장 상태를 확인해 주세요.", "error");
} finally {
fields.forEach(function (n, i) {
if (attrs[i] == null) n.removeAttribute("contenteditable"); else n.setAttribute("contenteditable", attrs[i]);
n.closest("td").classList.remove("is-goal-move-saving");
});
moveBusy = false;
}
});
}
// 선택한 셀의 테두리는 이동, 일반 본문 드래그는 기존 글/병합 범위 선택을 유지한다.
table.addEventListener("mousedown", function (e) {
if (e.button !== 0 || e.shiftKey) return;
const source = goalCellTd(e.target), handle = e.target.closest(".pj-goal-move-edge");
if (!source) return;
if (!handle) { if (!moveBusy) setMoveActive(source); return; }
e.preventDefault(); e.stopImmediatePropagation();
if (moveBusy || !source.querySelector(".pj-goal-text").value) return;
const startX = e.clientX, startY = e.clientY;
let moving = false, target = null, frame = null, x = startX, y = startY;
function updateTarget() {
table.querySelectorAll(".is-goal-move-target").forEach(function (n) { n.classList.remove("is-goal-move-target"); });
target = goalCellTd(document.elementFromPoint(x, y));
if (target === source) target = null;
if (target) target.classList.add("is-goal-move-target");
}
function scroll() {
const r = pane.getBoundingClientRect();
if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) {
if (x < r.left + 24) pane.scrollLeft -= 16; else if (x > r.right - 24) pane.scrollLeft += 16;
if (y < r.top + 24) pane.scrollTop -= 16; else if (y > r.bottom - 24) pane.scrollTop += 16;
}
updateTarget(); frame = requestAnimationFrame(scroll);
}
function move(ev) {
x = ev.clientX; y = ev.clientY;
if (!moving && Math.hypot(x - startX, y - startY) < 4) return;
if (!moving) {
moving = true; source.classList.add("is-goal-moving");
document.documentElement.classList.add("pj-goal-moving");
const selection = window.getSelection(); if (selection) selection.removeAllRanges();
frame = requestAnimationFrame(scroll);
}
updateTarget();
}
function end(ev) {
if (frame !== null) cancelAnimationFrame(frame);
document.removeEventListener("mousemove", move); document.removeEventListener("mouseup", end);
document.removeEventListener("keydown", key, true); window.removeEventListener("blur", cancel);
source.classList.remove("is-goal-moving"); document.documentElement.classList.remove("pj-goal-moving");
table.querySelectorAll(".is-goal-move-target").forEach(function (n) { n.classList.remove("is-goal-move-target"); });
if (moving) moveClickUntil = Date.now() + 300;
if (ev && moving && target) moveCell(source, target);
}
function cancel() { end(null); }
function key(ev) { if (ev.key === "Escape") { ev.preventDefault(); ev.stopImmediatePropagation(); cancel(); } }
document.addEventListener("mousemove", move); document.addEventListener("mouseup", end);
document.addEventListener("keydown", key, true); window.addEventListener("blur", cancel);
}, true);
table.addEventListener("click", function (e) {
if ((Date.now() < moveClickUntil && e.detail !== 0 && goalCellTd(e.target)) || e.target.closest(".pj-goal-move-edge")) {
e.preventDefault(); e.stopImmediatePropagation();
}
const td = goalCellTd(e.target);
if (td) setMoveActive(td);
}, true);
// 칸이 세로로 길어도(옆 칸 글이 길거나 세로 병합) 칸 아무 곳이나 누르면 그 칸 입력 — 커서는 글 끝(엑셀처럼).
// 입력칸(textarea)은 글 높이만큼이라 그 아래를 누르면 아무것도 안 되던 것. Shift+클릭(범위 고르기)·끌기는 그대로.