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:
2026-11-04 21:24:18 +09:00
parent 677bf8f1d1
commit 4171d61db1
4 changed files with 26 additions and 2 deletions
+1
View File
@@ -10,6 +10,7 @@
- 카페24 관리자에 들어가지 않고 상품 상세페이지(description HTML) 조회·편집·즉시적용·예약적용·버전 이력.
- 3분할 화면(목록 | HTML 편집기 | 상품 정보 패널).
- HTML 편집기에서 `<img>` 태그에 마우스를 올리면 태그를 오렌지색으로 칠하고 화면 오른쪽에 폭 500px·창 높이로 파일명과 미리보기(상대 경로는 `CAFE24_SHOP_URL` 루트 기준, 색칠 한도 `HL_LIMIT` 초과 소스는 미동작).
- HTML 편집기 `<img>` 안에서 커서 바로 뒤가 `.jpg`/`.gif`/`.png` 일 때 Ctrl+↑/↓ 로 파일명 번호 변경(없음 → `_2` → `_3` …, 내리면 `_2` 다음은 원래 이름, `_2`~`_99` 만 번호로 인식).
- 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지, 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매) 수정.
- 대표이미지는 `POST /admin/products/{no}/images` 에 base64 data URI + `image_upload_type=A`.
NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨.
@@ -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")) {
-1
View File
@@ -278,7 +278,6 @@
.cf24-shortcuts {
font-size: var(--text-caption, 12px);
color: #79a6dd;
white-space: nowrap;
}
/* 편집 폼과 코드 칸은 **줄어들지 않는다.** 아래 「예약 적용」·「버전 이력」을 펼치면