feat(카페24): 소스 편집기 이미지 파일명 번호 단축키
img 태그 안에서 커서 바로 뒤가 .jpg/.gif/.png 일 때 Ctrl+위/아래로 파일명 번호를 바꾼다(없음 → _2 → _3 …, 내리면 _2 다음은 원래 이름). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -122,7 +122,7 @@
|
||||
<input type="hidden" name="list_query" value="{{ list_query }}" />
|
||||
|
||||
<div class="cf24-editor-bar">
|
||||
<span class="cf24-shortcuts">단축키: 주석토글[Ctrl+/] · 줄 복사[Alt+Shift+↑↓] · 줄 이동[Alt+↑↓] · 줄 삭제[Shift+Del]</span>
|
||||
<span class="cf24-shortcuts">단축키: 주석토글[Ctrl+/] · 줄 복사[Alt+Shift+↑↓] · 줄 이동[Alt+↑↓] · 줄 삭제[Shift+Del] · 이미지 번호[Ctrl+↑↓]</span>
|
||||
<span class="cf24-editor-bar-right">
|
||||
<input class="cf24-memo" type="text" name="memo" maxlength="200"
|
||||
placeholder="변경 메모 (버전 이력에 남습니다)" />
|
||||
|
||||
@@ -368,6 +368,26 @@
|
||||
applyEdit(from, to, "", lineFrom + col, lineFrom + col);
|
||||
}
|
||||
|
||||
/* Ctrl+↑/↓ — <img> 안에서 커서 바로 뒤가 .jpg/.gif/.png 이면 파일명 번호를 바꾼다.
|
||||
a.jpg → a_2.jpg → a_3.jpg …, 내릴 때는 _2 다음이 원래 이름. 커서는 확장자 앞에 그대로 둔다.
|
||||
_2~_99 만 번호로 본다(product_2024.jpg 의 2024 는 번호가 아니다).
|
||||
조건이 안 맞으면 false — 브라우저 기본 동작을 막지 않는다. */
|
||||
function stepImgSuffix(up) {
|
||||
var at = ta.selectionStart, value = ta.value;
|
||||
if (at !== ta.selectionEnd || !/^\.(jpg|gif|png)/i.test(value.slice(at, at + 4))) return false;
|
||||
var head = value.slice(value.lastIndexOf("<", at - 1), at);
|
||||
if (!/^<img\s[^>]*$/i.test(head)) return false;
|
||||
|
||||
var m = head.match(/_([2-9]|[1-9]\d)$/);
|
||||
var n = m ? Number(m[1]) : 1;
|
||||
if (up ? n >= 99 : !m) return true; // 더 갈 곳이 없다
|
||||
var next = up ? n + 1 : n - 1;
|
||||
var text = next < 2 ? "" : "_" + next;
|
||||
var from = at - (m ? m[0].length : 0);
|
||||
applyEdit(from, at, text, from + text.length, from + text.length);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* 이미지 미리보기 — 맨 위 textarea 를 판정에서 잠깐 빼고 색칠 층의 <img> 를 찾는다.
|
||||
글자 폭을 계산하지 않아 한글·탭·여러 줄 태그에서도 위치가 어긋나지 않는다.
|
||||
shortcut: HL_LIMIT 초과 소스는 색칠을 안 해 미리보기도 안 뜬다, 그런 상품이 나오면 글자 위치 계산으로 교체. */
|
||||
@@ -408,6 +428,10 @@
|
||||
else moveLines(isDown);
|
||||
return;
|
||||
}
|
||||
if (e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey && (isUp || isDown) && stepImgSuffix(isUp)) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
// Shift+Delete — 줄 삭제. (윈도우 기본 동작인 "잘라내기"를 대신한다)
|
||||
if (e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey &&
|
||||
(e.key === "Delete" || e.code === "Delete")) {
|
||||
|
||||
Reference in New Issue
Block a user