fix(capture): date input 캡쳐 시 빈 표시 → 같은 값의 span 프록시로 대체
Deploy momo-erp / deploy (push) Successful in 2m12s

This commit is contained in:
chpark
2026-05-15 09:35:01 +09:00
parent d36d256f27
commit 86b90e2d5a
+32 -1
View File
@@ -40,7 +40,31 @@ export async function captureAndShare({ node, filename, shareTitle, shareText, f
}
});
// 2) 거래처에 보낼 이미지에서 내부 정보(.js-no-export)는 잠시 숨긴다.
// 2) input[type="date"] 는 html-to-image 가 native control 의 value 텍스트를
// 캔버스에 못 그리는 경우가 있어, 캡쳐 직전 옆에 같은 값을 가진 <span> 을 삽입하고
// 원본 input 은 visibility:hidden + width:0 으로 자리만 비킴.
const dateInputs = node.querySelectorAll<HTMLInputElement>('input[type="date"]');
const dateProxies: { el: HTMLInputElement; span: HTMLSpanElement; vis: string; w: string }[] = [];
dateInputs.forEach((el) => {
const v = el.value || el.getAttribute("value") || "";
if (!v) return;
const span = document.createElement("span");
span.textContent = v;
span.style.display = "inline-block";
const cs = getComputedStyle(el);
span.style.fontSize = cs.fontSize;
span.style.fontFamily = cs.fontFamily;
span.style.color = cs.color;
span.style.fontWeight = cs.fontWeight;
span.style.padding = "0 2px";
el.parentNode?.insertBefore(span, el);
dateProxies.push({ el, span, vis: el.style.visibility, w: el.style.width });
el.style.visibility = "hidden";
el.style.width = "0";
el.style.position = "absolute";
});
// 3) 거래처에 보낼 이미지에서 내부 정보(.js-no-export)는 잠시 숨긴다.
const hideEls = node.querySelectorAll<HTMLElement>(".js-no-export");
const prev: { el: HTMLElement; display: string }[] = [];
hideEls.forEach((el) => { prev.push({ el, display: el.style.display }); el.style.display = "none"; });
@@ -104,6 +128,13 @@ export async function captureAndShare({ node, filename, shareTitle, shareText, f
// 순서 역순 — cssText 가 hideEls 의 display:none 덮어쓰지 않도록.
fieldPrev.forEach((f) => { f.el.style.cssText = f.cssText; });
prev.forEach((p) => { p.el.style.display = p.display; });
// date 프록시 span 제거 + 원본 input 복원
dateProxies.forEach((d) => {
d.span.remove();
d.el.style.visibility = d.vis;
d.el.style.width = d.w;
d.el.style.position = "";
});
if (widthPrev) {
node.style.width = widthPrev.width;
node.style.minWidth = widthPrev.minWidth;