feat(project): add Excel font controls and reflow

This commit is contained in:
2026-10-03 05:47:57 +09:00
parent 494d84f7c2
commit dc2008c5b3
13 changed files with 146 additions and 42 deletions
+27 -6
View File
@@ -2,12 +2,19 @@
(function () {
"use strict";
const PREFIX = "pj-rich:v1:";
const STYLE_KEYS = ["bold", "italic", "underline", "color", "size"];
const TOGGLES = ["bold", "italic", "underline"];
function styles(node, inherited) {
const s = Object.assign({}, inherited);
if (node.nodeType !== 1) return s;
const css = node.style;
if (node.tagName === "B" || node.tagName === "STRONG") s.bold = true;
if (css.fontWeight) s.bold = css.fontWeight === "bold" || Number(css.fontWeight) >= 600;
if (node.tagName === "I" || node.tagName === "EM") s.italic = true;
if (css.fontStyle) s.italic = css.fontStyle === "italic" || css.fontStyle === "oblique";
if (node.tagName === "U") s.underline = true;
const decoration = css.textDecorationLine || css.textDecoration;
if (decoration) s.underline = decoration.includes("underline");
const size = parseInt(css.fontSize, 10);
if (size >= 10 && size <= 32) s.size = size;
if (css.color) {
@@ -38,7 +45,7 @@
runs.forEach(function (run) {
if (!run.text) return;
const prev = out[out.length - 1];
if (prev && prev.bold === run.bold && prev.color === run.color && prev.size === run.size) prev.text += run.text;
if (prev && STYLE_KEYS.every(function (key) { return prev[key] === run[key]; })) prev.text += run.text;
else out.push(Object.assign({}, run));
});
return out;
@@ -60,6 +67,8 @@
const span = document.createElement("span");
span.textContent = r.text;
if (typeof r.bold === "boolean") span.style.fontWeight = r.bold ? "700" : "400";
if (typeof r.italic === "boolean") span.style.fontStyle = r.italic ? "italic" : "normal";
if (typeof r.underline === "boolean") span.style.textDecoration = r.underline ? "underline" : "none";
if (/^#[\da-f]{6}$/i.test(r.color || "")) span.style.color = r.color;
if (Number.isInteger(r.size) && r.size >= 10 && r.size <= 32) span.style.fontSize = r.size + "px";
editor.appendChild(span.style.cssText ? span : document.createTextNode(r.text));
@@ -159,9 +168,16 @@
const value = chosen[0] && chosen[0][key];
return chosen.every(function (r) { return r[key] === value; }) && value !== undefined ? value : fallback;
}
toolbar.querySelector("[data-goal-format='bold']").value = uniform("bold", false) ? "700" : "400";
TOGGLES.forEach(function (key) {
const all = chosen.every(function (r) { return r[key] === true; });
const some = chosen.some(function (r) { return r[key] === true; });
toolbar.querySelector("[data-goal-format='" + key + "']").setAttribute("aria-pressed", all ? "true" : some ? "mixed" : "false");
});
showColor(uniform("color", "#000000"));
toolbar.querySelector("[data-goal-format='size']").value = String(uniform("size", 14));
const sizes = chosen.map(function (r) { return r.size || 14; });
toolbar.querySelector("[data-goal-format='size']").textContent = sizes.every(function (n) { return n === sizes[0]; }) ? sizes[0] + "px" : "혼합";
toolbar.querySelector("[data-goal-format='size-up']").disabled = sizes.every(function (n) { return n >= 32; });
toolbar.querySelector("[data-goal-format='size-down']").disabled = sizes.every(function (n) { return n <= 10; });
toolbar.hidden = false;
place();
}
@@ -179,7 +195,8 @@
else {
if (a > pos) out.push(Object.assign({}, run, { text: run.text.slice(0, a - pos) }));
const middle = Object.assign({}, run, { text: run.text.slice(a - pos, b - pos) });
if (key === "reset") { delete middle.color; delete middle.bold; delete middle.size; }
if (key === "reset") STYLE_KEYS.forEach(function (style) { delete middle[style]; });
else if (key === "size-delta") middle.size = Math.max(10, Math.min(32, (middle.size || 14) + value));
else middle[key] = value;
out.push(middle);
if (b < end) out.push(Object.assign({}, run, { text: run.text.slice(b - pos) }));
@@ -199,8 +216,12 @@
if (!btn) return;
apply("color", btn.dataset.goalColor.toLowerCase()); closeColors();
});
toolbar.querySelector("[data-goal-format='bold']").addEventListener("change", function (e) { apply("bold", e.target.value === "700"); });
toolbar.querySelector("[data-goal-format='size']").addEventListener("change", function (e) { apply("size", Number(e.target.value)); });
TOGGLES.forEach(function (key) {
const btn = toolbar.querySelector("[data-goal-format='" + key + "']");
btn.addEventListener("click", function () { apply(key, btn.getAttribute("aria-pressed") !== "true"); });
});
toolbar.querySelector("[data-goal-format='size-up']").addEventListener("click", function () { apply("size-delta", 2); });
toolbar.querySelector("[data-goal-format='size-down']").addEventListener("click", function () { apply("size-delta", -2); });
toolbar.querySelector("[data-goal-format='reset']").addEventListener("click", function () { apply("reset"); });
document.addEventListener("mousedown", function (e) {
if (toolbar.contains(e.target) || (saved && saved.editor.contains(e.target))) return;
+28 -10
View File
@@ -113,7 +113,7 @@
.pj-side-resizer { position: absolute; top: 0; bottom: 0; left: var(--pj-side-w, 250px); width: 8px; padding: 0; border: 0; background: transparent; cursor: col-resize; z-index: 12; }
.pj-side-resizer:hover, .pj-side-resizer:focus-visible, .pj-side-resizer.is-dragging { background: var(--pj-accent-tint); outline: none; }
html.pj-side-resizing, html.pj-side-resizing * { cursor: col-resize !important; user-select: none !important; }
.pj-side { min-width: 0; min-height: 0; height: 100%; overflow-y: auto; padding-right: 14px; }
.pj-side { min-width: 0; min-height: 0; height: 100%; overflow-y: auto; padding-right: 14px; container: pj-side / inline-size; }
.pj-main { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; }
/* ── 자체 스크롤 패널(내 업무/좌측 목록/홈 프로젝트 목록/보드)의 스크롤 막대 ──
@@ -1007,13 +1007,16 @@ html.pj-ui-scale #pj-timeline { zoom: calc(1 / var(--pj-z)); --tz: var(--pj-z);
.pj-member-pick-avatar img.pj-member-pick-icon { width: 36px; height: 36px; }
.pj-member-pick-stacked .pj-member-pick-name { font-size: 12.5px; }
/* ── 좌측 사이드바 "전체 멤버" — 4열 그리드, 아이콘 아래 이름(새 프로젝트
/* ── 좌측 사이드바 "전체 멤버" — 메뉴의 실제 내부 폭에 따라 4열↔3열, 아이콘 아래 이름(새 프로젝트
모달의 pj-member-pick-stacked 와 같은 아이콘 크기 재사용). ── */
.pj-allmembers-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 4px; }
.pj-allmembers-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 4px; }
@container pj-side (max-width: 207px) {
.pj-allmembers-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.pj-allmember-item {
display: flex; flex-direction: column; align-items: center; gap: 4px;
padding: 6px 2px; border: none; background: none; border-radius: 8px; cursor: pointer;
font: inherit; width: 100%;
font: inherit; width: 100%; min-width: 0; box-sizing: border-box;
}
.pj-allmember-item:hover { background: #f5f6f8; }
.pj-allmember-item .pj-member-pick-icon.material-symbols-outlined { font-size: 40px; }
@@ -2719,13 +2722,28 @@ html[data-pj-font="nanum-square-round"] { --pj-font: "NanumSquareRound", var(--p
.pj-options-dialog p { font-size: 12px; color: var(--pj-ink-soft); }
.pj-options-dialog .pj-options-error { color: #c22b10; }
.pj-options-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.pj-goal-format { position: fixed; z-index: 1200; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 8px 10px; max-width: calc(100vw - 16px); box-sizing: border-box; border: 1px solid var(--pj-border); border-radius: 8px; box-shadow: 0 4px 16px #0002; background: #fff; color: var(--pj-ink); font-family: var(--pj-font); font-size: 12px; }
.pj-goal-format { position: fixed; z-index: 1200; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 8px; max-width: calc(100vw - 16px); box-sizing: border-box; border: 1px solid var(--pj-border); border-radius: 8px; box-shadow: 0 4px 16px #0002; background: #fff; color: var(--pj-ink); font-family: var(--pj-font); font-size: 12px; }
.pj-goal-format[hidden], .pj-goal-color-grid[hidden] { display: none; }
.pj-goal-format label { display: flex; align-items: center; gap: 6px; }
.pj-goal-format select { padding: 4px; border: 1px solid #d8dce2; border-radius: 4px; font: inherit; }
.pj-goal-color-picker { position: relative; display: flex; align-items: center; gap: 6px; }
.pj-goal-color-toggle { width: 30px; height: 28px; padding: 4px; border: 1px solid #d8dce2; border-radius: 4px; background: #fff; cursor: pointer; }
.pj-goal-color-preview { display: block; width: 100%; height: 100%; background: #000; box-shadow: inset 0 0 0 1px #0002; }
.pj-goal-format-group { display: inline-flex; align-items: center; gap: 2px; }
.pj-goal-format-group + .pj-goal-format-group { border-left: 1px solid var(--pj-border); padding-left: 6px; }
.pj-goal-format .pj-goal-format-btn, .pj-goal-format [data-goal-format="reset"] { display: inline-flex; align-items: center; justify-content: center; height: 32px; box-sizing: border-box; border: 1px solid transparent; border-radius: 4px; padding: 0 8px; background: #fff; color: inherit; font: inherit; line-height: 1; cursor: pointer; }
.pj-goal-format .pj-goal-format-btn { min-width: 32px; }
.pj-goal-format .pj-goal-format-btn:hover, .pj-goal-format [data-goal-format="reset"]:hover { background: #f3f4f6; }
.pj-goal-format .pj-goal-format-btn[aria-pressed="true"] { border-color: #b5b9c0; background: #e8eaed; }
.pj-goal-format .pj-goal-format-btn[aria-pressed="mixed"] { background: #f3f4f6; box-shadow: inset 0 -2px #9ca3af; }
.pj-goal-format .pj-goal-format-btn:focus-visible { outline: 2px solid var(--pj-accent); outline-offset: 1px; }
.pj-goal-format [data-goal-format="reset"] { border-color: #d8dce2; margin-left: 4px; }
.pj-goal-color-picker { position: relative; display: flex; align-items: center; }
.pj-goal-color-toggle { gap: 5px; }
.pj-goal-color-letter { display: flex; flex-direction: column; align-items: stretch; font-size: 17px; line-height: 18px; }
.pj-goal-color-preview { display: block; width: 18px; height: 3px; background: #000; box-shadow: inset 0 0 0 1px #0002; }
.pj-goal-format-chevron { width: 8px; height: 8px; }
.pj-goal-font-letter { font-size: 16px; }
.pj-goal-font-arrow { width: 10px; height: 14px; align-self: flex-start; margin-top: 4px; color: #2563eb; }
.pj-goal-size-value { min-width: 36px; text-align: center; color: var(--pj-ink-soft); font-variant-numeric: tabular-nums; }
.pj-goal-format [data-goal-format="bold"] .pj-goal-font-letter { font-weight: 700; }
.pj-goal-format [data-goal-format="italic"] .pj-goal-font-letter { font-style: italic; }
.pj-goal-format [data-goal-format="underline"] .pj-goal-font-letter { text-decoration: underline; text-underline-offset: 3px; }
.pj-goal-color-grid { position: absolute; bottom: calc(100% + 8px); left: 0; display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 8px; background: #fff; border: 1px solid var(--pj-border); border-radius: 6px; box-shadow: 0 4px 12px #0002; }
.pj-goal-color-grid.is-below { bottom: auto; top: calc(100% + 8px); }
.pj-goal-text-swatch { width: 26px; height: 26px; border: 1px solid #0003; border-radius: 3px; background: var(--swatch); cursor: pointer; padding: 0; }