feat(project): 설명 편집 서식 도구에 취소선·체크박스 추가
- 취소선: 서식 도구 S 버튼 + Ctrl+Shift+X (execCommand strikeThrough) - 체크박스: ☑ 버튼으로 커서 자리에 넣고, 누를 때마다 checked 속성을 직접 바꿔 저장·다시 열기에도 체크 상태 유지 - 서버 설명 정리기: s/strike/del 허용, input 은 type="checkbox" 만(checked 외 속성 없음, 다른 종류는 태그째 버림) - 도움말 8장 서식 도구 설명 갱신, 정적 파일 버전 20260926m Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+29
-1
@@ -4990,6 +4990,12 @@
|
||||
arg = prompt("연결할 주소(URL)를 입력하세요", "https://");
|
||||
if (!arg) return;
|
||||
}
|
||||
// 체크박스 — 커서 자리에 체크박스 하나 + 공백. 누르면 체크/해제(아래 클릭 처리).
|
||||
if (cmd === "insertCheckbox") {
|
||||
try { document.execCommand("insertHTML", false, '<input type="checkbox"> '); } catch (_) {}
|
||||
box.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
return;
|
||||
}
|
||||
try { document.execCommand(cmd, false, arg); } catch (_) {}
|
||||
if (cmd === "createLink") normalizeEditorLinks(box);
|
||||
updateFmtState();
|
||||
@@ -4997,7 +5003,7 @@
|
||||
function updateFmtState() {
|
||||
fmtbar.querySelectorAll(".pj-desc-fmtbtn[data-cmd]").forEach(function (btn) {
|
||||
const cmd = btn.dataset.cmd;
|
||||
if (cmd === "createLink" || cmd === "removeFormat") return;
|
||||
if (cmd === "createLink" || cmd === "removeFormat" || cmd === "insertCheckbox") return;
|
||||
let active = false;
|
||||
try { active = document.queryCommandState(cmd); } catch (_) { active = false; }
|
||||
btn.classList.toggle("is-active", active);
|
||||
@@ -5006,8 +5012,29 @@
|
||||
box.addEventListener("keyup", updateFmtState);
|
||||
box.addEventListener("mouseup", updateFmtState);
|
||||
box.addEventListener("focus", updateFmtState);
|
||||
// Ctrl+Shift+X = 취소선(구글 문서·아사나와 같은 단축키)
|
||||
box.addEventListener("keydown", function (e) {
|
||||
if ((e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === "x" || e.key === "X")) {
|
||||
e.preventDefault();
|
||||
try { document.execCommand("strikeThrough"); } catch (_) {}
|
||||
updateFmtState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── 체크박스 누르기 — 편집칸 안의 체크박스는 브라우저마다 눌림 동작이 달라
|
||||
// 직접 바꾼다. 저장되는 건 HTML 이라 화면 상태(.checked)가 아니라 checked
|
||||
// 속성을 바꿔야 저장·다시 열기에도 남는다(서버 정리기는 checked 속성만 남긴다).
|
||||
box.addEventListener("click", function (e) {
|
||||
const cb = e.target;
|
||||
if (!cb || cb.tagName !== "INPUT" || cb.type !== "checkbox") return;
|
||||
e.preventDefault(); // 브라우저 기본 토글은 막고(취소되면 원래 값으로 되돌려 놓는다) 아래에서 직접
|
||||
const next = !cb.hasAttribute("checked");
|
||||
if (next) cb.setAttribute("checked", ""); else cb.removeAttribute("checked");
|
||||
setTimeout(function () { cb.checked = next; }, 0);
|
||||
box.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}, true);
|
||||
|
||||
// ── 설명란 이미지 선택 → 크기 조절 핸들 + 삭제 버튼 오버레이 ──
|
||||
// 크기는 style이 아니라 width 속성으로 저장한다(서버 sanitize가 style은
|
||||
// 버리지만 img width/height 속성은 허용 목록에 있어 저장 후에도 유지된다).
|
||||
@@ -5221,6 +5248,7 @@
|
||||
return {
|
||||
setTaskId: setTaskId,
|
||||
setHtml: function (html) {
|
||||
// (체크박스는 checked 속성이 그대로 화면 상태가 된다 — 새 HTML 이라 따로 맞출 필요 없음)
|
||||
selectImg(null); lastRange = null;
|
||||
box.innerHTML = html || "";
|
||||
normalizeEditorLinks(box);
|
||||
|
||||
Reference in New Issue
Block a user