From 5135e68569b8b13fe4eafd9373bddad61c7ad706 Mon Sep 17 00:00:00 2001 From: king Date: Mon, 19 Oct 2026 23:42:35 +0900 Subject: [PATCH] =?UTF-8?q?feat(project):=20=EC=84=A4=EB=AA=85=EB=9E=80=20?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EA=B5=B5=EA=B2=8C=C2=B7=EA=B8=B0=EC=9A=B8?= =?UTF-8?q?=EC=9E=84=C2=B7=EB=B0=91=EC=A4=84,=20=ED=95=9C=20=EA=B8=80?= =?UTF-8?q?=EC=9E=90=EC=B2=98=EB=9F=BC=20=ED=95=9C=20=EB=B2=88=EC=97=90=20?= =?UTF-8?q?=EC=A7=80=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 링크는 contenteditable=false 로 잠가 커서가 링크 글자 안으로 들어가지 않음 - 링크 바로 뒤 Backspace·바로 앞 Delete = 링크 통째로 삭제(execCommand, Ctrl+Z 가능) - 저장 HTML 에서는 잠금 표시를 뺀다(getHtml) Co-Authored-By: Claude Opus 5.5 --- .../notice/templates/notice/admin.html | 4 +- app/modules/project/CLAUDE.md | 2 +- .../templates/project/goal_meeting.html | 4 +- .../project/templates/project/goals.html | 4 +- .../project/templates/project/help.html | 4 +- .../project/templates/project/inbox.html | 4 +- .../project/templates/project/mytasks.html | 4 +- .../project/templates/project/notifier.html | 4 +- .../project/templates/project/project.html | 4 +- .../project/templates/project/trash.html | 4 +- app/static/project.css | 2 + app/static/project.js | 49 ++++++++++++++++++- tests/js/board_drive.browser.test.js | 43 ++++++++++++++++ 13 files changed, 112 insertions(+), 20 deletions(-) diff --git a/app/modules/notice/templates/notice/admin.html b/app/modules/notice/templates/notice/admin.html index 5447f80..8ddb458 100644 --- a/app/modules/notice/templates/notice/admin.html +++ b/app/modules/notice/templates/notice/admin.html @@ -2,7 +2,7 @@ {% block head_extra %} {# 프로젝트 화면 부품(설명 편집기·날짜 팝업·멤버 고르기)을 그대로 쓴다 — project.js 는 PJ_LIB_ONLY 로 부품만 #} - + {% endblock %} @@ -64,7 +64,7 @@ - + {% endif %} {% endblock %} diff --git a/app/modules/project/CLAUDE.md b/app/modules/project/CLAUDE.md index d1bf8a5..ee4309d 100644 --- a/app/modules/project/CLAUDE.md +++ b/app/modules/project/CLAUDE.md @@ -61,7 +61,7 @@ - **설명란·세부 업무 목록·보드 카드(펼친 세부 업무 줄) → 구글 드라이브**: `POST /project/api/tasks/{id}/drive-files`(`app/integrations/google_drive.py`, 최상위 `PROJECT_DRIVE_FOLDER_ID` 기본 `1Zdak2FtACRJ6peOnA9zD22hsbbsTixJG` 아래 `프로젝트/섹션/업무/세부 업무` 폴더 자동, 세부 업무 섹션 = 맨 위 업무 섹션). 링크 제목 = 파일 이름.확장자(새 탭). 설명란 = 놓은 자리(`descEditor.insertDriveFiles`, 올리는 중 표시·저장 미룸), 세부 업무 줄·카드 = `append=true` 로 서버가 설명 끝에 붙임 — 단 지금 업무 창에 열린 업무면 편집기 끝에(옛 설명 저장이 링크를 덮지 않게, `dropDriveFilesOnTask`). - **링크를 지우면 드라이브 휴지통**: `api_update_task` 가 설명 저장 전후 드라이브 링크 id 를 비교 → 백그라운드 `_sync_drive_links` — 우리가 올린 파일(appProperties `dbxTaskId`)만, 다른 업무 설명에 같은 링크가 있으면 그대로(`db.description_mentions`), 링크가 다시 생기면 휴지통에서 꺼냄. DB 변경 없음. - 그 밖의 업무 창 자리 → 예전처럼 첨부(`POST …/attachments`, `uploadTaskFiles`). -- 설명란 서식 도구에 글자 색·크기(서버는 span style 의 color·font-size 만 허용, `desc_inline_style`). 주소 붙여넣기 시 자동 링크. 설명란 이미지 더블클릭 = 별도 창 이미지 보기(확대·축소·끌어 이동). +- 설명란 서식 도구에 글자 색·크기(서버는 span style 의 color·font-size 만 허용, `desc_inline_style`). 주소 붙여넣기 시 자동 링크. 설명란 링크 = 굵게·기울임·밑줄 + 한 글자처럼(2026-10-19 — `normalizeEditorLinks` 가 `contenteditable=false`, 링크 바로 뒤 Backspace·앞 Delete = 링크 통째로 `execCommand delete`(Ctrl+Z 가능), 저장 HTML 에선 `getHtml` 이 잠금 표시를 뺀다). 설명란 이미지 더블클릭 = 별도 창 이미지 보기(확대·축소·끌어 이동). - 설명란·댓글에서 @로 멤버 태그(`task_mentions`, 마이그레이션 006) → 수신함에 그 작업이 쌓임. 댓글 `@아이디` 는 아이콘+이름 칩. - 댓글·답글 입력칸은 Enter 등록·Shift+Enter 줄바꿈(textarea). - 댓글 답글·이모티콘 반응(마이그레이션 012 `task_comments.parent_id`·`task_comment_reactions`, 미적용 시 버튼 숨김·API 503). 반응 = 댓글 쓴 사람에게 알림(`type=reaction`). diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html index e332d63..e2f3097 100644 --- a/app/modules/project/templates/project/goal_meeting.html +++ b/app/modules/project/templates/project/goal_meeting.html @@ -1,7 +1,7 @@ {% extends "project/_meeting_content_base.html" if meeting_embedded else "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -289,5 +289,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/goals.html b/app/modules/project/templates/project/goals.html index 9cb309b..a615ca0 100644 --- a/app/modules/project/templates/project/goals.html +++ b/app/modules/project/templates/project/goals.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -207,5 +207,5 @@ {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/help.html b/app/modules/project/templates/project/help.html index 6c9aa4e..7575e28 100644 --- a/app/modules/project/templates/project/help.html +++ b/app/modules/project/templates/project/help.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -351,7 +351,7 @@
  • 체크박스(체크리스트) — 글머리 목록처럼 씁니다. check_box를 누르면 지금 줄(또는 고른 줄들)이 체크리스트가 되어 줄마다 체크박스가 붙습니다. Enter로 새 줄을 만들면 체크박스도 함께 생기고, 빈 줄에서 Enter를 누르면 목록이 끝납니다. 체크박스를 누르면 체크되고 그 줄은 흐리게 취소선이 그어집니다. 다시 check_box를 누르면 평범한 글로, 글머리·번호 버튼을 누르면 그 목록으로 바뀝니다. 체크 상태도 바로 저장됩니다.
  • 이미지 — 캡처한 그림을 Ctrl+V로 바로 붙여 넣을 수 있습니다. 그림을 누르면 모서리를 끌어 크기를 바꾸거나 지울 수 있습니다. 그림을 누른 채 Ctrl+C를 누르면 그림이 복사되어 카카오톡·한글·그림판 등에 그대로 붙습니다. 그림을 더블클릭해 연 창에서는 아래 복사 버튼이나 Ctrl+C로 복사합니다(마우스 오른쪽 메뉴의 "이미지 복사"는 일부 프로그램에서 빈칸으로 붙을 수 있습니다).
  • -
  • 링크 — 웹 주소를 붙여 넣으면 자동으로 링크가 되고, 누르면 새 탭에서 열립니다.
  • +
  • 링크 — 웹 주소를 붙여 넣으면 자동으로 링크가 되고, 누르면 새 탭에서 열립니다. 링크는 굵게·기울임·밑줄로 보이고 한 글자처럼 다뤄집니다 — 링크 바로 뒤에서 Backspace, 바로 앞에서 Delete를 한 번 누르면 링크 전체가 지워집니다(Ctrl+Z로 되살림). 링크 글자를 고치려면 지우고 다시 넣습니다.
  • @태그 — @를 누르면 사람 목록이 뜹니다. 고른 사람의 수신함에 이 업무가 쌓입니다.
  • 첨부 파일

    diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index 23e486a..0673a4c 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -106,5 +106,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/modules/project/templates/project/mytasks.html b/app/modules/project/templates/project/mytasks.html index 4aa36cd..cf66089 100644 --- a/app/modules/project/templates/project/mytasks.html +++ b/app/modules/project/templates/project/mytasks.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -100,5 +100,5 @@ "today": {{ today | tojson }} } - + {% endblock %} diff --git a/app/modules/project/templates/project/notifier.html b/app/modules/project/templates/project/notifier.html index 4d7ea59..db8e974 100644 --- a/app/modules/project/templates/project/notifier.html +++ b/app/modules/project/templates/project/notifier.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -108,5 +108,5 @@ }); })(); - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index c148907..c192fd0 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + @@ -472,5 +472,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/trash.html b/app/modules/project/templates/project/trash.html index c756e32..47fd6c7 100644 --- a/app/modules/project/templates/project/trash.html +++ b/app/modules/project/templates/project/trash.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} @@ -70,5 +70,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/static/project.css b/app/static/project.css index ad19b40..e0a5293 100644 --- a/app/static/project.css +++ b/app/static/project.css @@ -2185,6 +2185,8 @@ html.pj-embed .pj-btn-goto-project { display: inline-flex; align-items: center; /* 설명란 링크 — 클릭하면 새 탭으로 열린다(JS 가 처리). */ .pj-desc-editor a { color: var(--pj-accent-dark, #2f5bb7); text-decoration: underline; cursor: pointer; } +/* 설명란 링크 서식 — 굵게·기울임·밑줄(2026-10-19). 링크는 한 글자처럼(contenteditable=false) 한 번에 지워진다 */ +.pj-desc-editor a { font-weight: 700; font-style: italic; text-decoration: underline; text-underline-offset: 2px; } /* ── 수신함 섹션 (알림 / 나를 태그한 업무) ── */ .pj-inbox-section { margin-bottom: 26px; } diff --git a/app/static/project.js b/app/static/project.js index a698aa4..f4fa126 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -2938,11 +2938,14 @@ return out.replace(/\n/g, "
    "); } // 에디터 안의 모든 가 새 탭으로 열리게 맞춘다(서식바 링크 버튼 포함). + // 설명란 링크 — 새 탭 + 글자 한 덩어리(contenteditable=false, 2026-10-19): 커서가 링크 글자 안으로 들어가지 않고 + // Backspace·Delete 한 번에 링크 전체가 지워진다(createDescEditor 의 keydown). 저장 HTML 에서는 빠진다(getHtml·서버 정리기). function normalizeEditorLinks(box) { if (!box) return; box.querySelectorAll("a").forEach(function (a) { a.setAttribute("target", "_blank"); a.setAttribute("rel", "noopener noreferrer"); + if (a.getAttribute("contenteditable") !== "false") a.setAttribute("contenteditable", "false"); }); } @@ -8855,6 +8858,49 @@ e.preventDefault(); openImageWindow(e.target); }); + // ── 링크 = 한 글자처럼(2026-10-19) — 붙여넣기·링크 버튼·드라이브 링크 등으로 새 링크가 생기면 바로 잠그고, + // 커서 바로 앞(Backspace)/뒤(Delete)가 링크면 링크 전체를 한 번에 지운다(execCommand 라 Ctrl+Z 로 되돌리기 가능). + box.addEventListener("input", function () { + if (box.querySelector("a:not([contenteditable])")) normalizeEditorLinks(box); + }); + function linkNear(range, backward) { + let node = range.startContainer, off = range.startOffset; + const inside = node.nodeType === 1 ? node.closest("a") : node.parentElement && node.parentElement.closest("a"); + if (inside && box.contains(inside)) return inside; + let cand = null; + if (node.nodeType === 3) { + // 지우는 방향에 글자가 남아 있으면(ZWSP 제외) 평소처럼 한 글자 + const rest = backward ? node.nodeValue.slice(0, off) : node.nodeValue.slice(off); + if (rest.replace(/\u200b/g, "")) return null; + cand = backward ? node.previousSibling : node.nextSibling; + } else { + cand = backward ? node.childNodes[off - 1] : node.childNodes[off]; + } + // 빈 글자 노드는 건너뛴다 + while (cand && cand.nodeType === 3 && !cand.nodeValue.replace(/\u200b/g, "")) cand = backward ? cand.previousSibling : cand.nextSibling; + if (!cand || cand.nodeType !== 1) return null; + if (cand.tagName === "A") return cand; + // .. 처럼 서식 안에 든 링크 — 맞닿은 쪽 끝이 링크면 + const edge = backward ? cand.lastElementChild : cand.firstElementChild; + const edgeText = backward ? cand.lastChild : cand.firstChild; + return edge && edge.tagName === "A" && edge === edgeText ? edge : null; + } + box.addEventListener("keydown", function (e) { + if ((e.key !== "Backspace" && e.key !== "Delete") || e.isComposing || e.altKey) return; + if (box.getAttribute("contenteditable") === "false") return; + const sel = window.getSelection(); + if (!sel || !sel.rangeCount || !sel.isCollapsed || !box.contains(sel.anchorNode)) return; + const a = linkNear(sel.getRangeAt(0), e.key === "Backspace"); + if (!a) return; + e.preventDefault(); + const r = document.createRange(); + r.selectNode(a); + sel.removeAllRanges(); + sel.addRange(r); + let ok = false; + try { ok = document.execCommand("delete"); } catch (_) { ok = false; } + if (!ok || a.isConnected) { a.remove(); box.dispatchEvent(new Event("input", { bubbles: true })); } + }); box.addEventListener("click", function (e) { if (e.target.tagName === "IMG") selectImg(e.target); else selectImg(null); @@ -9115,7 +9161,8 @@ normalizeEditorLinks(box); normalizeChecklists(); // 예전 방식() 체크리스트 → 글머리식 }, - getHtml: function () { return box.innerHTML; }, + // 링크 잠금 표시(contenteditable)는 화면 전용 — 저장·비교 값에서는 뺀다 + getHtml: function () { return box.innerHTML.replace(/(]*?) contenteditable="false"/g, "$1"); }, isUploading: function () { return pendingUploads > 0; }, whenIdle: whenIdle, setOnImageRemoved: function (fn) { onImageRemoved = fn; }, diff --git a/tests/js/board_drive.browser.test.js b/tests/js/board_drive.browser.test.js index 9b47874..892a9b3 100644 --- a/tests/js/board_drive.browser.test.js +++ b/tests/js/board_drive.browser.test.js @@ -19,6 +19,8 @@ function boardHtml() { const data = JSON.parse(json); const base = data.tasks.find(function (t) { return t.id === 101; }); base.description = "

    앞 글

    "; + const b = data.tasks.find(function (t) { return t.id === 102; }); + b.description = '

    앞 링크 글자 뒤

    끝 링크 마지막

    '; data.tasks.push(Object.assign({}, base, { description: "", id: 104, title: "작업 C(완료)", completed_at: "2026-10-01T00:00:00+09:00", sort_order: 104 })); data.tasks.push(Object.assign({}, base, { description: "", id: 105, title: "작업 D", sort_order: 105 })); return a + JSON.stringify(data) + c; @@ -140,6 +142,47 @@ async function dropFile(page, selector, name) { await page.waitForTimeout(500); const n = await page.$$eval('#pj-t-desc a[href*="drive.google.com"]', els => els.map(e => e.textContent)); check("열린 업무 카드 → 편집기에 링크(append 아님)", drives.length === 3 && !drives[2].append && n.indexOf("사진.jpg") >= 0, { drives: drives, n: n }); + + // ── 5) 설명란 링크 = 굵게·기울임·밑줄, 한 글자처럼(Backspace·Delete 한 번에 통째로, Ctrl+Z 로 되살림) + await page.keyboard.press("Escape"); + await page.waitForTimeout(300); + await page.evaluate(() => { const c = document.querySelector('.pj-card[data-task-id="102"] .pj-card-title'); c.click(); }); + await page.waitForFunction(() => document.getElementById("pj-t-desc").textContent.includes("링크 글자")); + const st = await page.evaluate(() => { + const a = document.querySelector("#pj-t-desc a"), cs = getComputedStyle(a); + return { ce: a.getAttribute("contenteditable"), w: cs.fontWeight, i: cs.fontStyle, u: cs.textDecorationLine }; + }); + check("링크 서식 굵게·기울임·밑줄 + 잠금", st.ce === "false" && +st.w >= 700 && st.i === "italic" && st.u.includes("underline"), st); + function caret(where) { // where: "after1" = 첫 링크 바로 뒤, "before2" = 둘째 링크 바로 앞 + return page.evaluate((w) => { + const box = document.getElementById("pj-t-desc"); box.focus(); + const as = box.querySelectorAll("a"), r = document.createRange(); + if (w === "after1") r.setStart(as[0].nextSibling, 0); + else { const t = as[as.length - 1].previousSibling; r.setStart(t, t.nodeValue.length); } + r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); + }, where); + } + await caret("after1"); + await page.keyboard.press("Backspace"); + let txt = await page.evaluate(() => ({ t: document.getElementById("pj-t-desc").textContent, n: document.querySelectorAll("#pj-t-desc a").length })); + check("링크 바로 뒤 Backspace 한 번 → 링크 통째로 지움", txt.n === 1 && !txt.t.includes("링크 글자") && txt.t.replace(/ /g, " ").includes("앞 뒤"), txt); + await page.keyboard.press("Control+z"); + txt = await page.evaluate(() => document.querySelectorAll("#pj-t-desc a").length); + check("Ctrl+Z 로 링크 되살림", txt === 2, txt); + await caret("before2"); + await page.keyboard.press("Delete"); + txt = await page.evaluate(() => ({ t: document.getElementById("pj-t-desc").textContent, n: document.querySelectorAll("#pj-t-desc a").length })); + check("링크 바로 앞 Delete 한 번 → 링크 통째로 지움", !txt.t.includes("마지막") && txt.t.includes("끝 링크"), txt); + await page.keyboard.press("Control+z"); + // 줄 끝 링크 오른쪽을 눌러 이어 쓰면 링크 밖에 써진다 + const last = await page.locator("#pj-t-desc a").last().boundingBox(); + await page.mouse.click(last.x + last.width + 40, last.y + last.height / 2); + await page.keyboard.type("추가"); + txt = await page.evaluate(() => { const a = [...document.querySelectorAll("#pj-t-desc a")].pop(); return { a: a.textContent, p: a.parentElement.textContent }; }); + check("줄 끝 링크 뒤에 이어 쓰기(링크 밖)", txt.a === "마지막" && /마지막추가$/.test(txt.p), txt); + await page.waitForTimeout(1600); + const saved = puts.filter(p => p.id === 102 && p.body.description != null).pop(); + check("저장 HTML 에 잠금 표시(contenteditable) 없음", !!saved && !saved.body.description.includes("contenteditable"), saved); } finally { await browser.close(); server.close(); } console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS"); process.exit(fails.length ? 1 : 0);