feat(notice): reuse project editor, date popup and member picker on the notice page
- Notice body uses the task description editor (createDescEditor, shared toolbar partial project/_desc_fmtbar.html): bold/italic/underline/strike, text color/size, lists, checklist, quote, link, clear format, image button/paste with resize; images upload to /notice/api/images - Show date uses the project date popup (enhanceDateInput) plus a time field - Recipients rendered like the project member picker (icon + name + check) - project.js exposes window.PJLib; PJ_LIB_ONLY runs only shared tooltips on non-project pages - Centered notice renders checklist/quote/list styles outside project pages too - Task window editor behavior unchanged (jsdom + Chrome regressions pass) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+34
-15
@@ -7511,14 +7511,23 @@
|
||||
|
||||
// ── 설명(contenteditable) — 붙여넣기/업로드로 이미지를 끼워 넣는다 ──
|
||||
function initDescEditor() {
|
||||
const box = el("pj-t-desc");
|
||||
return createDescEditor({
|
||||
box: el("pj-t-desc"), fmtbar: el("pj-desc-fmtbar"), imgInput: el("pj-desc-img-input"),
|
||||
hint: el("pj-desc-hint"), mentions: true,
|
||||
});
|
||||
}
|
||||
// 설명 편집기 본체 — 작업 창(initDescEditor)과 긴급 공지 관리 화면(window.PJLib)이 같이 쓴다.
|
||||
// cfg.box·fmtbar·imgInput·hint — 요소, cfg.mentions — @태그(작업 설명란만),
|
||||
// cfg.uploadImage(file) → Promise<이미지 주소> — 주면 그걸로 올린다(없으면 작업 첨부로, setTaskId 필요).
|
||||
function createDescEditor(cfg) {
|
||||
const box = cfg.box;
|
||||
if (!box) return null;
|
||||
// @ 를 누르면 멤버 목록 → 고르면 멘션 칩이 들어간다(수신함에 쌓인다).
|
||||
attachMentionEditor(box);
|
||||
if (cfg.mentions) attachMentionEditor(box);
|
||||
const wrap = box.parentElement;
|
||||
const imgInput = el("pj-desc-img-input");
|
||||
const hint = el("pj-desc-hint");
|
||||
let taskId = null;
|
||||
const imgInput = cfg.imgInput || null;
|
||||
const hint = cfg.hint || null;
|
||||
let taskId = cfg.uploadImage ? "custom" : null; // 자체 업로드면 늘 이미지 추가 가능
|
||||
|
||||
// ── 서식 도구 모음(간단 워드프로세서) — execCommand 는 구식 API지만
|
||||
// 크롬/엣지는 여전히 지원하고, 이미 같은 파일의 이미지 삽입에서도 쓰고
|
||||
@@ -7608,7 +7617,7 @@
|
||||
box.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
});
|
||||
|
||||
const fmtbar = el("pj-desc-fmtbar");
|
||||
const fmtbar = cfg.fmtbar || null;
|
||||
if (fmtbar) {
|
||||
fmtbar.addEventListener("mousedown", function (e) { e.preventDefault(); });
|
||||
fmtbar.addEventListener("click", function (e) {
|
||||
@@ -7964,16 +7973,18 @@
|
||||
saveSelection();
|
||||
const insertAt = lastRange ? lastRange.cloneRange() : null;
|
||||
beginUpload();
|
||||
const fd = new FormData();
|
||||
fd.append("file", file);
|
||||
try {
|
||||
const results = await Promise.all([
|
||||
naturalImageSize(file),
|
||||
fetch("/project/api/tasks/" + myTaskId + "/attachments", { method: "POST", body: fd }),
|
||||
]);
|
||||
const dims = results[0], res = results[1];
|
||||
// 작업 설명란 = 그 작업 첨부로 올린다. 다른 화면(긴급 공지)은 cfg.uploadImage 가 주소를 돌려준다.
|
||||
const upload = cfg.uploadImage || async function (f) {
|
||||
const fd = new FormData();
|
||||
fd.append("file", f);
|
||||
const res = await fetch("/project/api/tasks/" + myTaskId + "/attachments", { method: "POST", body: fd });
|
||||
if (!res.ok) { let m = res.statusText; try { m = (await res.json()).detail; } catch (_) {} throw new Error(m); }
|
||||
const data = await res.json();
|
||||
return "/project/api/attachments/" + data.attachment.id + "/inline";
|
||||
};
|
||||
try {
|
||||
const results = await Promise.all([naturalImageSize(file), upload(file)]);
|
||||
const dims = results[0], imgSrc = results[1];
|
||||
if (myGen !== editorGen || myTaskId !== taskId) {
|
||||
showToast("이미지는 원래 작업의 첨부 파일로 저장됐습니다(작업 창이 바뀌어 설명에는 넣지 않았습니다).");
|
||||
return;
|
||||
@@ -7985,7 +7996,7 @@
|
||||
if (insertAt) {
|
||||
try { const sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(insertAt); } catch (_) {}
|
||||
}
|
||||
insertHtmlAtCursor('<img src="/project/api/attachments/' + data.attachment.id + '/inline" alt=""' + widthAttr + '>');
|
||||
insertHtmlAtCursor('<img src="' + escapeHtml(imgSrc) + '" alt=""' + widthAttr + '>');
|
||||
} catch (e) { alert("이미지 업로드 실패: " + e.message); }
|
||||
finally { endUpload(); }
|
||||
}
|
||||
@@ -11410,7 +11421,15 @@
|
||||
poll();
|
||||
}
|
||||
|
||||
// 다른 화면이 프로젝트 부품을 같이 쓴다(긴급 공지 관리 — app/modules/notice): 설명 편집기(서식 도구 전체·이미지)·
|
||||
// 아사나식 날짜 팝업·멤버 고르기(아이콘 + 이름)·알림. window.PJ_LIB_ONLY 면 프로젝트 화면 초기화는 하지 않고
|
||||
// 공용 말풍선만 켠다(프로젝트 알림 팝업 확인·실시간 동기화 등이 그 화면에서 돌지 않게).
|
||||
window.PJLib = {
|
||||
createDescEditor: createDescEditor, enhanceDateInput: enhanceDateInput,
|
||||
memberPickHtml: memberPickHtml, showToast: showToast,
|
||||
};
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
if (window.PJ_LIB_ONLY) { initHoverTips(); return; }
|
||||
// 좌측 프로젝트 목록 — 프로젝트 화면은 initProject 가 자기 데이터로 직접 연다.
|
||||
if (!document.querySelector(".pj-project-view")) initSideTree();
|
||||
initTrash();
|
||||
|
||||
Reference in New Issue
Block a user