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:
@@ -1,12 +1,19 @@
|
||||
// 긴급 공지 관리(/notice/, 수퍼관리자) — 만들기·고치기·취소·이미지·미리 보기·확인 현황.
|
||||
// 긴급 공지 관리(/notice/, 수퍼관리자) — 만들기·고치기·취소·미리 보기·확인 현황.
|
||||
// 내용 편집기·날짜 팝업·받는 사람 고르기는 프로젝트 화면 부품 그대로(window.PJLib — project.js, PJ_LIB_ONLY):
|
||||
// · 내용 = 작업 설명란과 같은 편집기(굵게·기울임·밑줄·취소선·글자 색/크기·목록·체크리스트·인용·링크·서식 지우기·이미지
|
||||
// 붙여넣기/버튼·크기 조절), 이미지는 /notice/api/images 로 올린다.
|
||||
// · 띄울 날짜 = 아사나식 날짜 팝업(공휴일·오늘·지우기), 시각은 옆 칸.
|
||||
// · 받는 사람 = 프로젝트 멤버 고르기와 같은 아이콘 + 이름 + 체크.
|
||||
(function () {
|
||||
"use strict";
|
||||
const root = document.getElementById("ntc-root");
|
||||
if (!root) return;
|
||||
if (!root || !window.PJLib) return;
|
||||
const L = window.PJLib;
|
||||
const $ = function (id) { return document.getElementById(id); };
|
||||
const people = {};
|
||||
(window.NTC_PEOPLE || []).forEach(function (p) { people[String(p.email).toLowerCase()] = p.name; });
|
||||
const nameOf = function (e) { return people[String(e).toLowerCase()] || String(e).split("@")[0]; };
|
||||
const people = window.NTC_PEOPLE || [];
|
||||
const byEmail = {};
|
||||
people.forEach(function (p) { byEmail[String(p.email).toLowerCase()] = p; });
|
||||
const nameOf = function (e) { const p = byEmail[String(e).toLowerCase()]; return p ? p.name : String(e).split("@")[0]; };
|
||||
const esc = function (s) {
|
||||
return String(s == null ? "" : s).replace(/[&<>"']/g, function (c) {
|
||||
return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c];
|
||||
@@ -32,94 +39,65 @@
|
||||
return data || {};
|
||||
}
|
||||
|
||||
const title = $("ntc-title"), body = $("ntc-body"), showAt = $("ntc-show-at"), idEl = $("ntc-id");
|
||||
const title = $("ntc-title"), dateEl = $("ntc-date"), timeEl = $("ntc-time"), idEl = $("ntc-id");
|
||||
const peopleBox = $("ntc-people"), msg = $("ntc-msg"), save = $("ntc-save");
|
||||
const say = function (text, ok) { msg.textContent = text || ""; msg.hidden = !text; msg.style.color = ok ? "#1f7a3a" : ""; };
|
||||
const say = function (text, ok) { msg.textContent = text || ""; msg.hidden = !text; msg.classList.toggle("is-ok", !!ok); };
|
||||
|
||||
// ── 내용 — 작업 설명란 편집기 ──
|
||||
const editor = L.createDescEditor({
|
||||
box: $("ntc-body"), fmtbar: $("ntc-fmtbar"), imgInput: $("ntc-img-input"), hint: $("ntc-hint"), mentions: false,
|
||||
uploadImage: async function (file) {
|
||||
const fd = new FormData();
|
||||
fd.append("file", file, file.name || "image");
|
||||
return (await api("POST", "/notice/api/images", fd, true)).image.url;
|
||||
},
|
||||
});
|
||||
// ── 날짜 — 프로젝트 날짜 팝업 ──
|
||||
L.enhanceDateInput(dateEl, { placeholder: "날짜(비우면 바로)" });
|
||||
// ── 받는 사람 — 프로젝트 멤버 고르기 모양 ──
|
||||
peopleBox.innerHTML = people.map(L.memberPickHtml).join("") || '<span class="pj-empty-sm">등록된 사람이 없습니다.</span>';
|
||||
function toAll() { return root.querySelector('input[name="ntc-to"]:checked').value === "all"; }
|
||||
root.querySelectorAll('input[name="ntc-to"]').forEach(function (r) {
|
||||
r.addEventListener("change", function () { peopleBox.hidden = toAll(); });
|
||||
});
|
||||
|
||||
// ── 본문 편집 — 굵게, 이미지(버튼·붙여넣기·끌어 놓기 → 서버에 올리고 주소로 넣는다) ──
|
||||
root.querySelector('[data-cmd="bold"]').addEventListener("click", function () { body.focus(); document.execCommand("bold"); });
|
||||
let savedRange = null;
|
||||
body.addEventListener("keyup", keepRange);
|
||||
body.addEventListener("mouseup", keepRange);
|
||||
body.addEventListener("blur", keepRange);
|
||||
function keepRange() {
|
||||
const s = window.getSelection();
|
||||
if (s.rangeCount && body.contains(s.getRangeAt(0).commonAncestorContainer)) savedRange = s.getRangeAt(0).cloneRange();
|
||||
function picked() {
|
||||
return Array.from(peopleBox.querySelectorAll("input[type=checkbox]:checked")).map(function (c) { return c.value; });
|
||||
}
|
||||
function insertNode(node) {
|
||||
body.focus();
|
||||
const s = window.getSelection();
|
||||
let r = savedRange && body.contains(savedRange.commonAncestorContainer) ? savedRange : null;
|
||||
if (!r) { r = document.createRange(); r.selectNodeContents(body); r.collapse(false); }
|
||||
r.deleteContents();
|
||||
r.insertNode(node);
|
||||
r.setStartAfter(node); r.collapse(true);
|
||||
s.removeAllRanges(); s.addRange(r);
|
||||
savedRange = r.cloneRange();
|
||||
function setPicked(emails) {
|
||||
const want = (emails || []).map(function (e) { return String(e).toLowerCase(); });
|
||||
peopleBox.querySelectorAll("input[type=checkbox]").forEach(function (c) { c.checked = want.indexOf(c.value.toLowerCase()) >= 0; });
|
||||
}
|
||||
let uploading = 0;
|
||||
async function uploadImages(files) {
|
||||
for (const f of files) {
|
||||
if (!/^image\/(png|jpeg|gif|webp)$/.test(f.type)) { say("이미지(png·jpg·gif·webp)만 넣을 수 있습니다: " + f.name); continue; }
|
||||
uploading++;
|
||||
save.disabled = true;
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append("file", f, f.name || "image");
|
||||
const res = await api("POST", "/notice/api/images", fd, true);
|
||||
const img = document.createElement("img");
|
||||
img.src = res.image.url;
|
||||
img.alt = f.name || "";
|
||||
insertNode(img);
|
||||
say("");
|
||||
} catch (e) { say("이미지를 올리지 못했습니다: " + e.message); }
|
||||
finally { uploading--; if (!uploading) save.disabled = false; }
|
||||
}
|
||||
}
|
||||
$("ntc-image-btn").addEventListener("click", function () { keepRange(); $("ntc-image-file").click(); });
|
||||
$("ntc-image-file").addEventListener("change", function (e) { uploadImages(Array.from(e.target.files || [])); e.target.value = ""; });
|
||||
body.addEventListener("paste", function (e) {
|
||||
const files = Array.from((e.clipboardData && e.clipboardData.files) || []).filter(function (f) { return /^image\//.test(f.type); });
|
||||
if (files.length) { e.preventDefault(); keepRange(); uploadImages(files); }
|
||||
});
|
||||
body.addEventListener("dragover", function (e) { e.preventDefault(); });
|
||||
body.addEventListener("drop", function (e) {
|
||||
const files = Array.from((e.dataTransfer && e.dataTransfer.files) || []).filter(function (f) { return /^image\//.test(f.type); });
|
||||
if (files.length) { e.preventDefault(); keepRange(); uploadImages(files); }
|
||||
});
|
||||
|
||||
// ── 저장(만들기·고치기) ──
|
||||
function showAtValue() {
|
||||
// 날짜를 비우면 바로(서버가 지금으로), 날짜만 있으면 그날 00:00, 시각까지 있으면 그 시각 — 모두 한국시간
|
||||
return dateEl.value ? dateEl.value + "T" + (timeEl.value || "00:00") : "";
|
||||
}
|
||||
function payload() {
|
||||
return {
|
||||
title: title.value.trim(), body_html: body.innerHTML, show_at: showAt.value || "",
|
||||
to_all: toAll(),
|
||||
targets: Array.from(peopleBox.querySelectorAll("input:checked")).map(function (c) { return c.value; }),
|
||||
reshow: $("ntc-reshow").checked,
|
||||
title: title.value.trim(), body_html: editor.getHtml(), show_at: showAtValue(),
|
||||
to_all: toAll(), targets: picked(), reshow: $("ntc-reshow").checked,
|
||||
};
|
||||
}
|
||||
function resetForm() {
|
||||
idEl.value = ""; title.value = ""; body.innerHTML = ""; showAt.value = "";
|
||||
idEl.value = ""; title.value = ""; editor.setHtml(""); dateEl.value = ""; timeEl.value = "";
|
||||
root.querySelector('input[name="ntc-to"][value="all"]').checked = true;
|
||||
peopleBox.hidden = true;
|
||||
peopleBox.querySelectorAll("input").forEach(function (c) { c.checked = false; });
|
||||
setPicked([]);
|
||||
$("ntc-reshow").checked = false; $("ntc-reshow-row").hidden = true;
|
||||
$("ntc-form-title").textContent = "새 긴급 공지";
|
||||
save.textContent = "공지 만들기";
|
||||
savedRange = null;
|
||||
}
|
||||
$("ntc-reset").addEventListener("click", function () { resetForm(); say(""); });
|
||||
let saving = false;
|
||||
save.addEventListener("click", async function () {
|
||||
if (saving || uploading) return;
|
||||
const p = payload();
|
||||
if (!p.title) { say("제목을 입력하세요."); title.focus(); return; }
|
||||
if (!p.to_all && !p.targets.length) { say("받는 사람을 한 명 이상 고르거나 '전체'를 고르세요."); return; }
|
||||
if (saving) return;
|
||||
saving = true; save.disabled = true;
|
||||
try {
|
||||
await editor.whenIdle(); // 이미지 올리는 중이면 끝난 뒤 저장(빠진 채 저장되지 않게)
|
||||
const p = payload();
|
||||
if (!p.title) { say("제목을 입력하세요."); title.focus(); return; }
|
||||
if (!p.to_all && !p.targets.length) { say("받는 사람을 한 명 이상 고르거나 '전체'를 고르세요."); return; }
|
||||
const id = idEl.value;
|
||||
if (id) await api("PUT", "/notice/api/notices/" + id, p);
|
||||
else await api("POST", "/notice/api/notices", p);
|
||||
@@ -131,7 +109,7 @@
|
||||
});
|
||||
|
||||
// ── 미리 보기 — 받는 사람 화면과 같은 모양 ──
|
||||
$("ntc-preview").addEventListener("click", function () { preview(title.value.trim() || "(제목 없음)", body.innerHTML); });
|
||||
$("ntc-preview").addEventListener("click", function () { preview(title.value.trim() || "(제목 없음)", editor.getHtml()); });
|
||||
function preview(t, html) {
|
||||
const box = document.createElement("div");
|
||||
box.className = "erp-notice-backdrop";
|
||||
@@ -173,9 +151,9 @@
|
||||
'<div class="ntc-item-head"><span class="ntc-state ' + st[0] + '">' + esc(st[1]) + "</span>" +
|
||||
'<span class="ntc-item-title">' + esc(n.title) + "</span>" +
|
||||
'<span class="ntc-item-acts">' +
|
||||
'<button type="button" class="erp-btn erp-btn-outline" data-act="preview">미리 보기</button>' +
|
||||
'<button type="button" class="erp-btn erp-btn-outline" data-act="edit">고치기</button>' +
|
||||
'<button type="button" class="erp-btn erp-btn-outline" data-act="cancel">' + (n.cancelled_at ? "취소 되돌리기" : "취소") + "</button>" +
|
||||
'<button type="button" class="pj-btn pj-btn-sm" data-act="preview">미리 보기</button>' +
|
||||
'<button type="button" class="pj-btn pj-btn-sm" data-act="edit">고치기</button>' +
|
||||
'<button type="button" class="pj-btn pj-btn-sm" data-act="cancel">' + (n.cancelled_at ? "취소 되돌리기" : "취소") + "</button>" +
|
||||
"</span></div>" +
|
||||
'<div class="ntc-item-meta">띄울 시각 ' + esc(shortWhen(n.show_at)) + " · 받는 사람 " + esc(who) +
|
||||
" · 만든 사람 " + esc(nameOf(n.created_by)) + "</div>" +
|
||||
@@ -194,10 +172,11 @@
|
||||
if (!n) return;
|
||||
if (b.dataset.act === "preview") { preview(n.title, n.body_html); return; }
|
||||
if (b.dataset.act === "edit") {
|
||||
idEl.value = n.id; title.value = n.title; body.innerHTML = n.body_html; showAt.value = (n.show_at || "").slice(0, 16);
|
||||
idEl.value = n.id; title.value = n.title; editor.setHtml(n.body_html);
|
||||
dateEl.value = (n.show_at || "").slice(0, 10); timeEl.value = (n.show_at || "").slice(11, 16);
|
||||
root.querySelector('input[name="ntc-to"][value="' + (n.to_all ? "all" : "some") + '"]').checked = true;
|
||||
peopleBox.hidden = n.to_all;
|
||||
peopleBox.querySelectorAll("input").forEach(function (c) { c.checked = n.targets.indexOf(c.value.toLowerCase()) >= 0; });
|
||||
setPicked(n.targets);
|
||||
$("ntc-reshow-row").hidden = false; $("ntc-reshow").checked = false;
|
||||
$("ntc-form-title").textContent = "공지 고치기";
|
||||
save.textContent = "고친 내용 저장";
|
||||
|
||||
+31
-16
@@ -27,7 +27,22 @@
|
||||
}
|
||||
.erp-notice-body p { margin: 0 0 .6em; }
|
||||
.erp-notice-body img { display: block; max-width: 100%; height: auto; margin: 8px 0; border-radius: 8px; }
|
||||
.erp-notice-body a { color: #3b6fd8; }
|
||||
.erp-notice-body a { color: #3b6fd8; text-decoration: underline; }
|
||||
/* 작업 설명란 편집기와 같은 서식(project.css .pj-desc-editor) — 프로젝트 밖 화면에서도 같게 보이게 */
|
||||
.erp-notice-body blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid #d5d9de; color: #565c66; }
|
||||
.erp-notice-body ul, .erp-notice-body ol { margin: 4px 0; padding-left: 22px; }
|
||||
.erp-notice-body ul.pj-checklist { list-style: none; padding-left: 24px; }
|
||||
.erp-notice-body ul.pj-checklist > li { position: relative; }
|
||||
.erp-notice-body ul.pj-checklist > li::before {
|
||||
content: ""; position: absolute; left: -22px; top: .3em; width: 14px; height: 14px;
|
||||
box-sizing: border-box; border: 1.5px solid #8f959d; border-radius: 3px; background: #fff;
|
||||
}
|
||||
.erp-notice-body ul.pj-checklist > li[data-checked="true"]::before {
|
||||
border-color: #7b68ee; background: #7b68ee center / 10px 10px no-repeat
|
||||
url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.3l2.6 2.6L10 3.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
}
|
||||
.erp-notice-body ul.pj-checklist > li[data-checked="true"] { color: #9aa1a9; text-decoration: line-through; }
|
||||
.erp-notice-body img[width] { height: auto; }
|
||||
.erp-notice-error { margin: 0; padding: 6px 10px; border-radius: 6px; background: #fdecec; color: #b42318; font-size: 13px; }
|
||||
.erp-notice-error[hidden] { display: none; }
|
||||
.erp-notice-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 1px solid #eceef1; }
|
||||
@@ -41,31 +56,31 @@
|
||||
.erp-notice-ok:disabled { opacity: .6; cursor: default; }
|
||||
|
||||
/* 관리 화면(/notice/) */
|
||||
.ntc-wrap { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; gap: 18px; align-items: start; }
|
||||
.ntc-wrap { display: grid; grid-template-columns: minmax(420px, 640px) 1fr; gap: 18px; align-items: start; }
|
||||
@media (max-width: 1100px) { .ntc-wrap { grid-template-columns: 1fr; } }
|
||||
.ntc-card { background: #fff; border: 1px solid #e6e8eb; border-radius: 12px; padding: 18px; }
|
||||
.ntc-card h2 { margin: 0 0 12px; font-size: 16px; }
|
||||
.ntc-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; font-weight: 700; color: #3b4048; }
|
||||
.ntc-field input[type=text], .ntc-field input[type=datetime-local] {
|
||||
.ntc-field input[type=text], .ntc-time {
|
||||
font: inherit; font-weight: 500; padding: 8px 10px; border: 1px solid #d5d9de; border-radius: 8px;
|
||||
}
|
||||
.ntc-editor-bar { display: flex; gap: 4px; }
|
||||
.ntc-editor-bar button { padding: 4px 10px; border: 1px solid #d5d9de; border-radius: 6px; background: #fff; cursor: pointer; font: inherit; font-size: 12.5px; }
|
||||
.ntc-editor {
|
||||
min-height: 160px; max-height: 420px; overflow: auto; padding: 10px 12px; border: 1px solid #d5d9de; border-radius: 8px;
|
||||
font-weight: 400; font-size: 14px; line-height: 1.6; color: #2b2f36; outline: none;
|
||||
}
|
||||
.ntc-editor:focus { border-color: #7b68ee; box-shadow: 0 0 0 3px rgba(123, 104, 238, .15); }
|
||||
.ntc-editor:empty::before { content: attr(data-placeholder); color: #a0a5ad; }
|
||||
.ntc-editor img { max-width: 100%; height: auto; border-radius: 6px; }
|
||||
.ntc-targets { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
|
||||
.ntc-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; max-height: 220px; overflow: auto;
|
||||
padding: 8px; border: 1px solid #e6e8eb; border-radius: 8px; }
|
||||
.ntc-sub { font-weight: 500; color: #8a9099; }
|
||||
.ntc-desc .pj-desc-toolbar { display: flex; align-items: center; gap: 8px; }
|
||||
.ntc-desc .pj-desc-wrap { position: relative; }
|
||||
.ntc-desc .pj-desc-editor { min-height: 180px; max-height: 460px; overflow: auto; font-weight: 400;
|
||||
padding: 10px 12px; border: 1px solid #d5d9de; border-radius: 8px; }
|
||||
.ntc-desc .pj-desc-editor:focus { border-color: #7b68ee; box-shadow: 0 0 0 3px rgba(123, 104, 238, .15); outline: none; }
|
||||
.ntc-when { display: flex; align-items: center; gap: 8px; font-weight: 500; }
|
||||
.ntc-time { padding: 6px 8px; }
|
||||
.ntc-targets { display: flex; flex-direction: column; gap: 8px; font-weight: 500; }
|
||||
.ntc-to { display: flex; gap: 16px; flex-wrap: wrap; }
|
||||
.ntc-people { max-height: 260px; }
|
||||
.ntc-people[hidden] { display: none; }
|
||||
.ntc-people label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
|
||||
.ntc-inline { flex-direction: row; align-items: center; font-weight: 500; }
|
||||
.ntc-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
|
||||
.ntc-msg { margin: 8px 0 0; font-size: 13px; color: #b42318; }
|
||||
.ntc-msg[hidden] { display: none; }
|
||||
.ntc-msg.is-ok { color: #1f7a3a; }
|
||||
.ntc-list { display: flex; flex-direction: column; gap: 10px; }
|
||||
.ntc-item { border: 1px solid #e6e8eb; border-radius: 10px; padding: 12px 14px; }
|
||||
.ntc-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
|
||||
+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