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:
@@ -333,8 +333,12 @@ def build_subject_project_done(*, project_name: str) -> str:
|
||||
_DESC_ALLOWED_TAGS: frozenset[str] = frozenset({
|
||||
"p", "br", "b", "strong", "i", "em", "u", "a", "img",
|
||||
"ul", "ol", "li", "blockquote", "code", "pre", "span", "div",
|
||||
# 취소선(서식 도구 "S" — 브라우저에 따라 strike/s/del 로 만든다)
|
||||
"s", "strike", "del",
|
||||
# 체크박스(서식 도구 "☑") — type="checkbox" 만, 속성은 checked 뿐(아래 _emit_start)
|
||||
"input",
|
||||
})
|
||||
_DESC_VOID_TAGS: frozenset[str] = frozenset({"br", "img"})
|
||||
_DESC_VOID_TAGS: frozenset[str] = frozenset({"br", "img", "input"})
|
||||
# a: target/rel 은 "새 탭에서 열기"용. 화면(설명란)에서 링크를 클릭하면
|
||||
# 새 탭으로 여는데, 저장했다 다시 열었을 때도 같은 동작이어야 해서 허용한다.
|
||||
# span: 멘션 칩(@이름) 전용 — class="pj-mention" + data-email 만 남긴다.
|
||||
@@ -342,6 +346,7 @@ _DESC_ALLOWED_ATTRS: dict[str, frozenset[str]] = {
|
||||
"a": frozenset({"href", "target", "rel"}),
|
||||
"img": frozenset({"src", "alt", "width", "height"}),
|
||||
"span": frozenset({"class", "data-email"}),
|
||||
"input": frozenset({"type", "checked"}),
|
||||
}
|
||||
# URL 은 금지 목록이 아니라 허용 목록으로 검사한다. 금지 목록(javascript: 등)은
|
||||
# "jav	ascript:" 처럼 중간에 탭/개행을 끼우면 통과하는데, 브라우저는 URL 을
|
||||
@@ -411,6 +416,14 @@ class _DescriptionSanitizer(HTMLParser):
|
||||
return
|
||||
if tag not in _DESC_ALLOWED_TAGS:
|
||||
return
|
||||
# input 은 체크박스만 — 다른 종류(text·file·hidden 등)는 태그째 버리고,
|
||||
# 체크 여부 말고는 아무 속성도 남기지 않는다.
|
||||
if tag == "input":
|
||||
if (dict(attrs).get("type") or "").strip().lower() != "checkbox":
|
||||
return
|
||||
checked = any(name == "checked" for name, _ in attrs)
|
||||
self.out.append('<input type="checkbox" checked>' if checked else '<input type="checkbox">')
|
||||
return
|
||||
allowed = _DESC_ALLOWED_ATTRS.get(tag, frozenset())
|
||||
# span 은 멘션 칩일 때만 속성을 갖는다 — class 가 pj-mention 이 아니면
|
||||
# data-email 까지 통째로 버린다(평범한 span 으로만 남는다).
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926m" />
|
||||
<link rel="stylesheet" href="/static/project-help.css?v=20260926m" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -274,7 +274,8 @@
|
||||
</ul>
|
||||
<h3>설명</h3>
|
||||
<ul>
|
||||
<li>서식 도구: <span class="pjh-ui">B</span> 굵게 · <span class="pjh-ui">I</span> 기울임 · <span class="pjh-ui">U</span> 밑줄 · 글머리 목록 · 번호 목록 · 인용 · 링크 · <span class="pjh-ui">×서식</span>(서식 지우기) · 이미지 넣기</li>
|
||||
<li>서식 도구: <span class="pjh-ui">B</span> 굵게 · <span class="pjh-ui">I</span> 기울임 · <span class="pjh-ui">U</span> 밑줄 · <span class="pjh-ui"><s>S</s></span> 취소선(<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>X</kbd>) · 글머리 목록 · 번호 목록 · <span class="pjh-ui"><span class="material-symbols-outlined">check_box</span></span> 체크박스 · 인용 · 링크 · <span class="pjh-ui">×서식</span>(서식 지우기) · 이미지 넣기</li>
|
||||
<li><b>체크박스</b> — 커서 자리에 체크박스가 들어갑니다. 누를 때마다 체크/해제되고, <b>저장</b>하면 체크 상태도 그대로 남습니다. 글머리 목록과 함께 쓰면 할 일 목록처럼 쓸 수 있어요.</li>
|
||||
<li><b>이미지</b> — 캡처한 그림을 <kbd>Ctrl</kbd>+<kbd>V</kbd>로 바로 붙여 넣을 수 있습니다. 그림을 누르면 모서리를 끌어 크기를 바꾸거나 지울 수 있습니다.</li>
|
||||
<li><b>링크</b> — 웹 주소를 붙여 넣으면 자동으로 링크가 되고, 누르면 새 탭에서 열립니다.</li>
|
||||
<li><b>@태그</b> — <kbd>@</kbd>를 누르면 사람 목록이 뜹니다. 고른 사람의 수신함에 이 작업이 쌓입니다.</li>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926m" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -101,5 +101,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260926l" defer></script>
|
||||
<script src="/static/project.js?v=20260926m" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926m" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -100,5 +100,5 @@
|
||||
"today": {{ today | tojson }}
|
||||
}
|
||||
</script>
|
||||
<script src="/static/project.js?v=20260926l" defer></script>
|
||||
<script src="/static/project.js?v=20260926m" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926m" />
|
||||
<!-- 구글 머티리얼 심볼(담당자 아이콘 등) — self-host -->
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
<!-- 타임라인 vis-timeline — self-host -->
|
||||
@@ -326,9 +326,11 @@
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="bold" title="굵게 (Ctrl+B)"><b>B</b></button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="italic" title="기울임 (Ctrl+I)"><i>I</i></button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="underline" title="밑줄 (Ctrl+U)"><u>U</u></button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="strikeThrough" title="취소선 (Ctrl+Shift+X)"><s>S</s></button>
|
||||
<span class="pj-desc-fmtsep"></span>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="insertUnorderedList" title="글머리 기호 목록">☰•</button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="insertOrderedList" title="번호 매기기 목록">☰1</button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="insertCheckbox" title="체크박스 넣기"><span class="material-symbols-outlined">check_box</span></button>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="formatBlock" data-arg="blockquote" title="인용구">❝</button>
|
||||
<span class="pj-desc-fmtsep"></span>
|
||||
<button type="button" class="pj-desc-fmtbtn" data-cmd="createLink" title="링크 삽입">🔗</button>
|
||||
@@ -468,5 +470,5 @@
|
||||
</script>
|
||||
|
||||
<script src="/static/vendor/vis-timeline/vis-timeline-graph2d.min.js"></script>
|
||||
<script src="/static/project.js?v=20260926l" defer></script>
|
||||
<script src="/static/project.js?v=20260926m" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% extends "erp_base.html" %}
|
||||
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926l" />
|
||||
<link rel="stylesheet" href="/static/project.css?v=20260926m" />
|
||||
<link rel="stylesheet" href="/static/vendor/material-symbols/material-symbols.css" />
|
||||
{% endblock %}
|
||||
|
||||
@@ -70,5 +70,5 @@
|
||||
{% include "project/_side_modals.html" %}
|
||||
{% include "project/_member_tasks_modal.html" %}
|
||||
|
||||
<script src="/static/project.js?v=20260926l" defer></script>
|
||||
<script src="/static/project.js?v=20260926m" defer></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -994,6 +994,11 @@
|
||||
기본 24px 아이콘을 그대로 두면 이 버튼만 커 보이고 줄도 어긋난다. */
|
||||
.pj-desc-fmtbtn .material-symbols-outlined { font-size: 19px; line-height: 1; position: relative; top: 4px; }
|
||||
label.pj-desc-fmtbtn { line-height: 26px; }
|
||||
/* 설명란 체크박스(서식 도구 ☑) — 누르면 체크/해제, 체크 여부는 저장된다 */
|
||||
.pj-desc-editor input[type="checkbox"] {
|
||||
width: 15px; height: 15px; margin: 0 4px 0 1px; vertical-align: -2px; cursor: pointer;
|
||||
accent-color: var(--pj-accent);
|
||||
}
|
||||
.pj-desc-fmtsep { width: 1px; height: 16px; background: #e2e4ea; margin: 0 4px; }
|
||||
.pj-desc-editor {
|
||||
min-height: 80px; max-height: 300px; overflow-y: auto; padding: 8px 10px;
|
||||
|
||||
+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