From 8ad8242c4135c94588fb7a0bf4b84fc984f4abce Mon Sep 17 00:00:00 2001 From: king Date: Thu, 15 Oct 2026 13:04:00 +0900 Subject: [PATCH] =?UTF-8?q?fix(project):=20=EC=84=A4=EB=AA=85=EB=9E=80=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B3=B5=EC=82=AC=20=E2=80=94=20?= =?UTF-8?q?Ctrl+C=C2=B7=EB=B3=B4=EA=B8=B0=20=EC=B0=BD=20[=EB=B3=B5?= =?UTF-8?q?=EC=82=AC]=20=EB=A1=9C=20PNG=20=EA=B7=B8=EB=A6=BC=EB=A7=8C=20?= =?UTF-8?q?=ED=81=B4=EB=A6=BD=EB=B3=B4=EB=93=9C=EC=97=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 원인: 설명란 이미지 "선택"은 편집기 표시라 기본 Ctrl+C 로는 아무것도 복사되지 않았고, 브라우저 "이미지 복사"는 HTML 을 같이 넣어 로그인 없는 프로그램(카카오톡·한글 등)엔 빈칸 - copyImageToClipboard: 캔버스로 PNG 변환 → navigator.clipboard.write(ClipboardItem, Promise) - 설명란 고른 이미지 Ctrl+C(한글 입력 상태 e.code), 글자를 골라 둔 상태면 기본 복사 그대로 - 이미지 보기 창: 아래 막대 [복사] 버튼 + Ctrl+C, 위쪽 알림 - tests/js/image_copy.browser.test.js (Edge 로 9항목 통과), project.js 버전 20261015a, 도움말·문서 Co-Authored-By: Claude Opus 5.5 --- .../notice/templates/notice/admin.html | 2 +- .../templates/project/goal_meeting.html | 2 +- .../project/templates/project/goals.html | 2 +- .../project/templates/project/help.html | 3 +- .../project/templates/project/inbox.html | 2 +- .../project/templates/project/mytasks.html | 2 +- .../project/templates/project/notifier.html | 2 +- .../project/templates/project/project.html | 2 +- .../project/templates/project/trash.html | 2 +- app/static/project.js | 63 ++++++++- docs/PROJECT_MODULE.md | 4 + tests/js/README.md | 10 ++ tests/js/image_copy.browser.test.js | 126 ++++++++++++++++++ 13 files changed, 210 insertions(+), 12 deletions(-) create mode 100644 tests/js/image_copy.browser.test.js diff --git a/app/modules/notice/templates/notice/admin.html b/app/modules/notice/templates/notice/admin.html index e23c5dc..5539f36 100644 --- a/app/modules/notice/templates/notice/admin.html +++ b/app/modules/notice/templates/notice/admin.html @@ -64,7 +64,7 @@ - + {% endif %} {% endblock %} diff --git a/app/modules/project/templates/project/goal_meeting.html b/app/modules/project/templates/project/goal_meeting.html index 39bf97c..3e2daf4 100644 --- a/app/modules/project/templates/project/goal_meeting.html +++ b/app/modules/project/templates/project/goal_meeting.html @@ -298,5 +298,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/goals.html b/app/modules/project/templates/project/goals.html index 70c5ff2..95e6553 100644 --- a/app/modules/project/templates/project/goals.html +++ b/app/modules/project/templates/project/goals.html @@ -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 2d0ada6..306d970 100644 --- a/app/modules/project/templates/project/help.html +++ b/app/modules/project/templates/project/help.html @@ -342,7 +342,8 @@ diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index e140ebf..a2da9c4 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -109,7 +109,7 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + - + {% endblock %} diff --git a/app/modules/project/templates/project/notifier.html b/app/modules/project/templates/project/notifier.html index 651f21a..b67f2de 100644 --- a/app/modules/project/templates/project/notifier.html +++ b/app/modules/project/templates/project/notifier.html @@ -108,5 +108,5 @@ }); })(); - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index 51ac10c..c75d0c5 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -470,5 +470,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/trash.html b/app/modules/project/templates/project/trash.html index 20f60de..18f762f 100644 --- a/app/modules/project/templates/project/trash.html +++ b/app/modules/project/templates/project/trash.html @@ -70,5 +70,5 @@ {% include "project/_side_modals.html" %} {% include "project/_member_tasks_modal.html" %} - + {% endblock %} diff --git a/app/static/project.js b/app/static/project.js index 645c444..0cb804a 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -2305,6 +2305,35 @@ return false; } + // ── 이미지 → 클립보드(PNG 그림만, 2026-10-15) — 브라우저 기본 복사는 `` HTML 을 같이(또는 그것만) 넣는데, + // 첨부 주소는 로그인해야 받을 수 있어서 카카오톡·한글·워드처럼 HTML 을 먼저 쓰는 프로그램에선 빈칸이 된다. + // 그래서 화면의 이미지를 캔버스로 PNG 로 만들어 그림만 넣는다(같은 서버 이미지라 캔버스가 오염되지 않음). + // ClipboardItem 에 Promise 를 넘겨야 변환을 기다리는 동안에도 키·클릭 직후 권한이 유지된다. + function imagePngBlob(img) { + return new Promise(function (resolve, reject) { + function draw() { + try { + const c = document.createElement("canvas"); + c.width = img.naturalWidth; c.height = img.naturalHeight; + c.getContext("2d").drawImage(img, 0, 0); + c.toBlob(function (b) { if (b) resolve(b); else reject(new Error("변환 실패")); }, "image/png"); + } catch (e) { reject(e); } + } + if (img.complete && img.naturalWidth) { draw(); return; } + img.addEventListener("load", draw, { once: true }); + img.addEventListener("error", function () { reject(new Error("이미지를 불러오지 못했습니다.")); }, { once: true }); + }); + } + function copyImageToClipboard(img) { + if (!navigator.clipboard || !navigator.clipboard.write || !window.ClipboardItem) { + showToast("이 브라우저는 이미지 복사를 지원하지 않습니다. 이미지를 더블클릭해 연 창에서 복사해 주세요.", "error"); + return Promise.resolve(false); + } + return navigator.clipboard.write([new ClipboardItem({ "image/png": imagePngBlob(img) })]) + .then(function () { showToast("이미지를 복사했습니다."); return true; }) + .catch(function (e) { showToast("이미지 복사 실패: " + ((e && e.message) || e), "error"); return false; }); + } + // ── 이미지 보기 창 — 설명란 이미지를 더블클릭하면 별도 브라우저 창(팝업 창, 페이지 안 팝업 아님)으로 연다. // 창 크기 = 이미지 원본 크기(+ 여백·도구 막대), 화면보다 크면 화면 95% 까지. 처음엔 원본(100%), 창보다 크면 창에 맞춤. // 창 안: 휠 = 마우스 위치 기준 확대·축소, 끌기 = 이동, 아래 막대 − / % / + · 1:1(원본) · 맞춤, @@ -2337,12 +2366,19 @@ '#pct{min-width:56px;text-align:center;font-size:13px;font-variant-numeric:tabular-nums}' + '.sep{width:1px;height:18px;background:rgba(255,255,255,.18);margin:0 4px}' + '#err{position:fixed;inset:0;display:none;align-items:center;justify-content:center;color:#cfd3da;font-size:14px}' + + '#msg{position:fixed;left:50%;top:14px;transform:translate(-50%,-8px);padding:7px 14px;border-radius:8px;background:rgba(40,42,47,.95);' + + 'border:1px solid rgba(255,255,255,.1);font-size:13px;opacity:0;pointer-events:none;transition:opacity .18s,transform .18s;z-index:3}' + + '#msg.show{opacity:1;transform:translate(-50%,0)}#msg.bad{color:#ffb4a8}' + '
이미지를 불러오지 못했습니다.
' + + '
' + '
' + '" + '100%' + '" + - '
' + + '' + + '' + "