From a58fa7b83bfd4532ab6aee99e701d480b1b7411b Mon Sep 17 00:00:00 2001 From: king Date: Wed, 19 Aug 2026 22:22:17 +0900 Subject: [PATCH] =?UTF-8?q?feat(cafe24):=20HTML=20=ED=8E=B8=EC=A7=91?= =?UTF-8?q?=EA=B8=B0=20Shift+Delete=20=EC=A4=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 커서가 있는 줄(선택이 있으면 그 줄들)을 통째로 지운다. 윈도우 기본 동작인 "잘라내기"를 대신한다. - 줄바꿈까지 함께 지워 빈 줄이 남지 않게 한다. 마지막 줄이면 대신 앞의 줄바꿈을 지운다(문서 끝에 빈 줄이 생기지 않게). - 커서는 지운 자리로 올라온 줄의 같은 칸에 둔다(칸이 모자라면 줄 끝). - 빈 문자열은 insertText 가 브라우저에 따라 무시되므로 applyEdit 이 execCommand("delete") 로 갈라진다. Ctrl+Z 는 그대로 동작한다. Co-Authored-By: Claude Opus 5 --- .../cafe24/templates/cafe24/_editor.html | 4 +-- .../cafe24/templates/cafe24/products.html | 33 ++++++++++++++++++- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/modules/cafe24/templates/cafe24/_editor.html b/app/modules/cafe24/templates/cafe24/_editor.html index 4a64c40..19a53f1 100644 --- a/app/modules/cafe24/templates/cafe24/_editor.html +++ b/app/modules/cafe24/templates/cafe24/_editor.html @@ -78,7 +78,7 @@
- 상세설명 HTML · {{ desc.description | length }}자 · PC/모바일 공통 · Ctrl+/ 주석 · Alt+↑↓ 줄 이동 + 상세설명 HTML · {{ desc.description | length }}자 · PC/모바일 공통 · Ctrl+/ 주석 · Alt+↑↓ 줄 이동 · Shift+Del 줄 삭제 @@ -100,7 +100,7 @@ + title="Tab 들여쓰기 · Ctrl+/ 주석 토글 · Alt+↑/↓ 줄 이동 · Alt+Shift+↑/↓ 줄 복사 · Shift+Delete 줄 삭제 (선택이 없으면 커서가 있는 줄)">{{ html_pc }}
diff --git a/app/modules/cafe24/templates/cafe24/products.html b/app/modules/cafe24/templates/cafe24/products.html index 712fdbc..161bf86 100644 --- a/app/modules/cafe24/templates/cafe24/products.html +++ b/app/modules/cafe24/templates/cafe24/products.html @@ -209,7 +209,12 @@ ta.selectionStart = from; ta.selectionEnd = to; var inserted = false; - try { inserted = document.execCommand("insertText", false, text); } catch (err) { inserted = false; } + try { + // 빈 문자열은 insertText 가 브라우저에 따라 무시된다 — 삭제는 delete 로. + inserted = text === "" + ? document.execCommand("delete") + : document.execCommand("insertText", false, text); + } catch (err) { inserted = false; } if (!inserted) ta.value = value.slice(0, from) + text + value.slice(to); ta.selectionStart = selStart; ta.selectionEnd = selEnd; @@ -288,6 +293,25 @@ applyEdit(r.from, r.to, text, r.start + shift, r.end + shift); } + /* Shift+Delete — 커서가 있는 줄(선택이 있으면 그 줄들)을 통째로 지운다. + 줄바꿈까지 같이 지워야 빈 줄이 남지 않는다. 마지막 줄이면 대신 앞의 + 줄바꿈을 지운다(문서 끝에 빈 줄이 생기지 않게). */ + function deleteLines() { + var r = lineRange(); + var from = r.from, to = r.to; + if (to < r.value.length) to += 1; + else if (from > 0) from -= 1; + if (from === to) return; // 빈 문서 — 지울 것이 없다 + + var rest = r.value.slice(0, from) + r.value.slice(to); + // 커서는 지운 자리로 올라온 줄의 같은 칸에 둔다(칸이 모자라면 줄 끝). + var lineFrom = rest.lastIndexOf("\n", from - 1) + 1; + var lineTo = rest.indexOf("\n", lineFrom); + if (lineTo === -1) lineTo = rest.length; + var col = Math.min(Math.max(0, r.start - r.from), lineTo - lineFrom); + applyEdit(from, to, "", lineFrom + col, lineFrom + col); + } + ta.addEventListener("scroll", sync); ta.addEventListener("input", function () { dirty = true; refresh(); }); ta.addEventListener("keydown", function (e) { @@ -307,6 +331,13 @@ else moveLines(isDown); return; } + // Shift+Delete — 줄 삭제. (윈도우 기본 동작인 "잘라내기"를 대신한다) + if (e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey && + (e.key === "Delete" || e.code === "Delete")) { + e.preventDefault(); + deleteLines(); + return; + } // Tab 은 포커스 이동이 아니라 들여쓰기로 쓴다. if (e.key !== "Tab") return; e.preventDefault();