From 022a161ddab007308e97d6e7ad703f92c084736e Mon Sep 17 00:00:00 2001 From: king Date: Tue, 15 Sep 2026 22:34:45 +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=EC=82=BD=EC=9E=85=20=EC=8B=9C=20?= =?UTF-8?q?=EC=9B=90=EB=B3=B8=EC=9D=B4=20=EB=84=88=EB=B9=84=20=EC=B4=88?= =?UTF-8?q?=EA=B3=BC=ED=95=98=EB=A9=B4=2090%=EB=A1=9C=20=EC=B6=95=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이미지가 설명란 너비와 같거나 넓게 삽입되면 크기조절 핸들(이미지 우하단 바깥쪽 -6px 오프셋)이 설명란 테두리 밖으로 삐져나갔다. 붙여넣기/업로드로 삽입하기 전 원본 크기를 확인해, 설명란보다 넓은 경우 width 속성을 설명란 너비의 90%로 지정해서 넣는다. Co-Authored-By: Claude Sonnet 5 --- .../project/templates/project/inbox.html | 2 +- .../project/templates/project/index.html | 2 +- .../project/templates/project/project.html | 2 +- app/static/project.js | 23 +++++++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/modules/project/templates/project/inbox.html b/app/modules/project/templates/project/inbox.html index 2e71266..81acc30 100644 --- a/app/modules/project/templates/project/inbox.html +++ b/app/modules/project/templates/project/inbox.html @@ -45,5 +45,5 @@ {% endif %} - + {% endblock %} diff --git a/app/modules/project/templates/project/index.html b/app/modules/project/templates/project/index.html index 30360e9..7d6203e 100644 --- a/app/modules/project/templates/project/index.html +++ b/app/modules/project/templates/project/index.html @@ -376,5 +376,5 @@ - + {% endblock %} diff --git a/app/modules/project/templates/project/project.html b/app/modules/project/templates/project/project.html index a4b77ea..87b0deb 100644 --- a/app/modules/project/templates/project/project.html +++ b/app/modules/project/templates/project/project.html @@ -379,5 +379,5 @@ - + {% endblock %} diff --git a/app/static/project.js b/app/static/project.js index bcd1a53..b786432 100644 --- a/app/static/project.js +++ b/app/static/project.js @@ -2079,15 +2079,34 @@ } } + // 삽입 전 원본 크기를 확인해, 설명란보다 넓으면 90%로 줄여서 넣는다 + // (그대로 넣으면 크기조절 핸들이 설명란 밖으로 삐져나간다). + function naturalImageSize(file) { + return new Promise(function (resolve) { + const url = URL.createObjectURL(file); + const img = new Image(); + img.onload = function () { URL.revokeObjectURL(url); resolve({ width: img.naturalWidth }); }; + img.onerror = function () { URL.revokeObjectURL(url); resolve(null); }; + img.src = url; + }); + } + async function insertImageFile(file) { if (!taskId) { alert("먼저 저장한 뒤 이미지를 추가할 수 있습니다."); return; } const fd = new FormData(); fd.append("file", file); try { - const res = await fetch("/project/api/tasks/" + taskId + "/attachments", { method: "POST", body: fd }); + const results = await Promise.all([ + naturalImageSize(file), + fetch("/project/api/tasks/" + taskId + "/attachments", { method: "POST", body: fd }), + ]); + const dims = results[0], res = results[1]; if (!res.ok) { let m = res.statusText; try { m = (await res.json()).detail; } catch (_) {} throw new Error(m); } const data = await res.json(); - insertHtmlAtCursor(''); + const boxW = box.clientWidth || 0; + const widthAttr = (dims && dims.width && boxW && dims.width > boxW) + ? ' width="' + Math.round(boxW * 0.9) + '"' : ""; + insertHtmlAtCursor(''); } catch (e) { alert("이미지 업로드 실패: " + e.message); } }