feat(프로젝트): 설명란 하이퍼링크 글자 크기·굵기 변경
- 링크는 한 글자처럼 잠겨(contenteditable=false) execCommand 서식이 안 들어갔다 - 고른 범위의 링크는 링크 안쪽 span style 로 크기(글자 크기 도구)·굵기(굵게 버튼·Ctrl+B) - 링크 기본이 굵게라 보통 = font-weight: 400, 서버 desc_inline_style 이 400 만 허용 - 글자와 같이 고르면 글자에 적용된 굵기를 따름 - project.js 캐시 버전 20261030b, 브라우저·sanitize 테스트 추가 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -183,6 +183,46 @@ async function dropFile(page, selector, name) {
|
||||
await page.waitForTimeout(1600);
|
||||
const saved = puts.filter(p => p.id === 102 && p.body.description != null).pop();
|
||||
check("저장 HTML 에 잠금 표시(contenteditable) 없음", !!saved && !saved.body.description.includes("contenteditable"), saved);
|
||||
|
||||
// ── 6) 링크 서식(2026-10-30) — 링크만 고르고 크기·굵기 바꾸기(잠긴 링크라 예전엔 안 바뀌었다), 글자와 같이 고르면 같은 굵기
|
||||
function selectLink(i, withBefore) {
|
||||
return page.evaluate((a) => {
|
||||
const box = document.getElementById("pj-t-desc"); box.focus();
|
||||
const link = box.querySelectorAll("a")[a.i], r = document.createRange();
|
||||
if (a.withBefore) r.setStart(link.previousSibling, 0); else r.setStartBefore(link);
|
||||
r.setEndAfter(link);
|
||||
const s = getSelection(); s.removeAllRanges(); s.addRange(r);
|
||||
}, { i: i, withBefore: withBefore });
|
||||
}
|
||||
const linkSt = (i) => page.evaluate((n) => {
|
||||
const a = document.querySelectorAll("#pj-t-desc a")[n], t = a.querySelector("span[style]") || a, cs = getComputedStyle(t);
|
||||
return { size: cs.fontSize, w: +cs.fontWeight, ce: a.getAttribute("contenteditable"), html: a.innerHTML };
|
||||
}, i);
|
||||
await selectLink(0, false);
|
||||
await page.click('.pj-desc-fmtbtn[data-cmd="textSize"]');
|
||||
await page.click('.pj-desc-stylepop button[data-v="18px"]');
|
||||
let ls = await linkSt(0);
|
||||
check("링크만 골라 크기 크게(18px), 링크는 그대로 잠김", ls.size === "18px" && ls.ce === "false" && ls.html.includes("링크 글자"), ls);
|
||||
await selectLink(0, false);
|
||||
await page.click('.pj-desc-fmtbtn[data-cmd="bold"]');
|
||||
ls = await linkSt(0);
|
||||
check("링크 굵게 버튼 → 보통(기본이 굵게라 끔), 크기는 그대로", ls.w === 400 && ls.size === "18px", ls);
|
||||
await selectLink(0, false);
|
||||
await page.keyboard.press("Control+b");
|
||||
ls = await linkSt(0);
|
||||
check("Ctrl+B → 다시 굵게", ls.w >= 700 && ls.size === "18px", ls);
|
||||
await selectLink(0, true); // "앞 " 글자 + 링크 — 글자가 굵게 되면 링크도 굵게(그대로)
|
||||
await page.click('.pj-desc-fmtbtn[data-cmd="bold"]');
|
||||
const mix = await page.evaluate(() => {
|
||||
const a = document.querySelector("#pj-t-desc a"), t = a.querySelector("span[style]") || a;
|
||||
// 글자 굵기는 실제 계산값으로(잠긴 링크가 낀 선택에선 queryCommandState 가 틀린다)
|
||||
const head = a.previousSibling && a.previousSibling.nodeType === 3 ? a.parentElement : a.previousElementSibling;
|
||||
return { link: +getComputedStyle(t).fontWeight, text: +getComputedStyle(head).fontWeight >= 700 };
|
||||
});
|
||||
check("글자와 같이 고르면 링크도 글자와 같은 굵기", (mix.link >= 700) === mix.text, mix);
|
||||
await page.waitForTimeout(1600);
|
||||
const saved2 = puts.filter(p => p.id === 102 && p.body.description != null).pop();
|
||||
check("링크 서식 저장 — 링크 안쪽 span 의 font-size", !!saved2 && /<a [^>]*><span style="font-size: 18px;?">링크 글자<\/span><\/a>/.test(saved2.body.description), saved2 && saved2.body.description);
|
||||
} finally { await browser.close(); server.close(); }
|
||||
console.log(fails.length ? "\n" + fails.length + " FAILED" : "\nALL PASS");
|
||||
process.exit(fails.length ? 1 : 0);
|
||||
|
||||
@@ -23,6 +23,13 @@ class DescStyleTests(unittest.TestCase):
|
||||
out = self.clean('<span style="color: rgb(224, 62, 62); font-size: 22px">a</span><span style="color:#ABC">b</span>')
|
||||
self.assertEqual(out, '<span style="color: rgb(224, 62, 62); font-size: 22px">a</span><span style="color: #abc">b</span>')
|
||||
|
||||
def test_link_inner_size_and_normal_weight_kept(self):
|
||||
# 링크 서식(2026-10-30) — 링크 안쪽 span 의 크기·굵기 "보통"(400)만, 다른 굵기는 버림
|
||||
out = self.clean('<a href="https://x.y"><span style="font-size: 18px; font-weight: 400">l</span></a>'
|
||||
'<span style="font-weight: normal">a</span><span style="font-weight: 900">b</span>')
|
||||
self.assertEqual(out, '<a href="https://x.y"><span style="font-size: 18px; font-weight: 400">l</span></a>'
|
||||
'<span style="font-weight: 400">a</span><span>b</span>')
|
||||
|
||||
def test_other_declarations_and_sizes_dropped(self):
|
||||
out = self.clean('<span style="background:url(javascript:x); font-size: 99px; color: red; position:fixed">a</span>')
|
||||
self.assertEqual(out, "<span>a</span>")
|
||||
|
||||
Reference in New Issue
Block a user