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 @@
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();