From 5e5586a25c3e9f0c680bd2cfa2ced1597d58f4a3 Mon Sep 17 00:00:00 2001 From: king Date: Tue, 3 Nov 2026 15:29:55 +0900 Subject: [PATCH] =?UTF-8?q?feat(=EC=B9=B4=ED=8E=9824):=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=86=8C=EC=8A=A4=EC=9D=98=20img=20=ED=83=9C?= =?UTF-8?q?=EA=B7=B8=20hover=20=EC=8B=9C=20=EC=98=A4=EB=A5=B8=EC=AA=BD?= =?UTF-8?q?=EC=97=90=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=AF=B8=EB=A6=AC?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/modules/cafe24/CLAUDE.md | 1 + .../cafe24/templates/cafe24/products.html | 43 ++++++++++++++++--- app/static/cafe24.css | 22 ++++++++++ 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/app/modules/cafe24/CLAUDE.md b/app/modules/cafe24/CLAUDE.md index c597d9d..66053c0 100644 --- a/app/modules/cafe24/CLAUDE.md +++ b/app/modules/cafe24/CLAUDE.md @@ -9,6 +9,7 @@ - 카페24 관리자에 들어가지 않고 상품 상세페이지(description HTML) 조회·편집·즉시적용·예약적용·버전 이력. - 3분할 화면(목록 | HTML 편집기 | 상품 정보 패널). +- HTML 편집기에서 `` 태그에 마우스를 올리면 화면 오른쪽에 창 높이로 미리보기(상대 경로는 `CAFE24_SHOP_URL` 루트 기준, 색칠 한도 `HL_LIMIT` 초과 소스는 미동작). - 정보 패널(`routes_product_info.py`, `_side.html`)에서 상품명·판매가·공급가·소비자가, 대표이미지, 옵션(생성/이름·썸네일·표시방식 수정/삭제)·품목(자체코드·추가금액·진열·판매) 수정. - 대표이미지는 `POST /admin/products/{no}/images` 에 base64 data URI + `image_upload_type=A`. NNEditor 업로드 경로를 PUT `detail_image` 에 넣는 방식은 적용 안 됨. diff --git a/app/modules/cafe24/templates/cafe24/products.html b/app/modules/cafe24/templates/cafe24/products.html index 14147f7..3f2a435 100644 --- a/app/modules/cafe24/templates/cafe24/products.html +++ b/app/modules/cafe24/templates/cafe24/products.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {% block head_extra %} - + {% endblock %} {% block content %} @@ -122,6 +122,9 @@
+ +{# 소스의 위에 마우스를 올리면 화면 오른쪽에 뜨는 미리보기 — setupCodeEditor 가 켜고 끈다. #} + {% endblock %} {% block scripts %} @@ -164,14 +167,32 @@ last = TOKEN_RE.lastIndex; if (m[1]) { out += '' + esc(m[1]) + ""; continue; } if (m[2]) { out += '' + esc(m[2]) + ""; continue; } - out += '' + esc(m[3]) + "" + - '' + esc(m[4]) + "" + - paintAttrs(m[5]) + - '' + esc(m[6]) + ""; + var tag = '' + esc(m[3]) + "" + + '' + esc(m[4]) + "" + + paintAttrs(m[5]) + + '' + esc(m[6]) + ""; + out += /^img$/i.test(m[4]) ? '' + tag + "" : tag; } return out + esc(src.slice(last)); } + // 상대 경로는 쇼핑몰 루트 기준이다: ../img/a.jpg → https://쇼핑몰/img/a.jpg + function imgPreviewUrl(tag) { + var m = tag.match(/\ssrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i); + var src = m && (m[1] || m[2] || m[3]); + var shop = document.getElementById("cf24-url"); + if (!src || !shop) return ""; + try { return new URL(src, new URL("/", shop.value)).href; } + catch (err) { return ""; } + } + + function showImgPreview(url) { + var box = document.getElementById("cf24-img-preview"); + var img = box.firstElementChild; + if (url && img.getAttribute("src") !== url) img.src = url; + box.hidden = !url; + } + function setupCodeEditor() { var ta = document.getElementById("cf24-html-pc"); var hl = document.getElementById("cf24-hl-pc"); @@ -337,6 +358,18 @@ applyEdit(from, to, "", lineFrom + col, lineFrom + col); } + /* 이미지 미리보기 — 맨 위 textarea 를 판정에서 잠깐 빼고 색칠 층의 를 찾는다. + 글자 폭을 계산하지 않아 한글·탭·여러 줄 태그에서도 위치가 어긋나지 않는다. + shortcut: HL_LIMIT 초과 소스는 색칠을 안 해 미리보기도 안 뜬다, 그런 상품이 나오면 글자 위치 계산으로 교체. */ + ta.addEventListener("mousemove", function (e) { + ta.style.pointerEvents = "none"; + var el = document.elementFromPoint(e.clientX, e.clientY); + ta.style.pointerEvents = ""; + var tag = el && el.closest(".cf24-t-img"); + showImgPreview(tag ? imgPreviewUrl(tag.textContent) : ""); + }); + ta.addEventListener("mouseleave", function () { showImgPreview(""); }); + ta.addEventListener("scroll", sync); ta.addEventListener("input", function () { dirty = true; refresh(); }); ta.addEventListener("keydown", function (e) { diff --git a/app/static/cafe24.css b/app/static/cafe24.css index 1b35ede..f3c8b74 100644 --- a/app/static/cafe24.css +++ b/app/static/cafe24.css @@ -467,6 +467,28 @@ .cf24-t-com { color: #6e7781; font-style: italic; } /* 주석 */ .cf24-t-doc { color: #6639ba; } /* DOCTYPE 등 선언 */ +/* 색칠 층 안에서 태그만 마우스 판정을 받는다(미리보기용). 평소에는 위의 textarea 가 가린다. */ +.cf24-t-img { pointer-events: auto; } + +/* 마우스를 통과시킨다 — 미리보기가 소스를 덮어도 hover 가 끊기지 않게. */ +.cf24-img-preview { + position: fixed; + top: 0; + right: 0; + z-index: 1100; + border-left: 1px solid var(--color-subtle-ash, #e5e5e5); + background: var(--color-canvas-white, #fff); + pointer-events: none; +} + +.cf24-img-preview img { + display: block; + height: 100vh; + width: auto; + max-width: 100vw; + object-fit: contain; +} + .cf24-code-hint { font-size: var(--text-caption, 12px); color: var(--color-midtone-gray, #737373);