Merge remote-tracking branch 'origin/sub_laptop_7' into main_laptop_1
This commit is contained in:
@@ -51,6 +51,8 @@ export interface SpreadsheetOptions {
|
||||
onChange?: (book: Workbook) => void;
|
||||
/** 고름이 바뀜 — 시트 id · 활성 칸 A1 · 범위 A1 */
|
||||
onSelect?: (selection: { 시트: string; 칸: string; 범위: string }) => void;
|
||||
/** 아래 시트 탭 줄 — false 면 안 그림(산출근거 = 시트 하나) · 시트 오가기 · 새 시트 단축키 · 시트 메뉴도 끔 */
|
||||
tabs?: boolean;
|
||||
}
|
||||
|
||||
export interface SpreadsheetHandle {
|
||||
@@ -88,7 +90,10 @@ export function createSpreadsheet(
|
||||
opts: SpreadsheetOptions = {},
|
||||
): SpreadsheetHandle {
|
||||
const readOnly = !!opts.readOnly;
|
||||
const root = el("div", { className: readOnly ? "ss ss--readonly" : "ss" });
|
||||
const noTabs = opts.tabs === false;
|
||||
const root = el("div", {
|
||||
className: `ss${readOnly ? " ss--readonly" : ""}${noTabs ? " ss--notabs" : ""}`,
|
||||
});
|
||||
host.append(root);
|
||||
const firstSheet = (b: Workbook) => b.시트.find((s) => s.id === b.활성) ?? b.시트[0];
|
||||
/** 시트마다 마지막 고름(탭을 오가도 그대로) */
|
||||
@@ -116,14 +121,14 @@ export function createSpreadsheet(
|
||||
const ed = createEditor(ctx);
|
||||
ctx.editor = ed;
|
||||
const toolbar: PartHandle | null = readOnly ? null : mountToolbar(ctx);
|
||||
const tabs = mountTabs(ctx);
|
||||
const tabs: PartHandle | null = noTabs ? null : mountTabs(ctx);
|
||||
const menu: PartHandle | null = readOnly ? null : attachMenu(ctx);
|
||||
const clip = attachClipboard(ctx);
|
||||
const status = createStatusBar(ctx);
|
||||
const others = [toolbar, tabs, menu, clip, status].filter((p): p is PartHandle => !!p);
|
||||
|
||||
grid.root.classList.add("ss-grid-host");
|
||||
for (const node of [toolbar?.root, ed.bar, grid.root, tabs.root, status.root])
|
||||
for (const node of [toolbar?.root, ed.bar, grid.root, tabs?.root, status.root])
|
||||
if (node) root.append(node);
|
||||
const extras = attachExtras(ctx, ed, toolbar?.root ?? null);
|
||||
others.push(...extras.parts);
|
||||
|
||||
@@ -81,6 +81,8 @@ const CTRL_SHIFT: Record<string, Act> = {
|
||||
PageUp: "prev",
|
||||
};
|
||||
|
||||
const SHEET_ACTS = new Set<Act>(["next", "prev", "newSheet"]);
|
||||
|
||||
/** body 에 뜬 창(.ui-confirm)이 다 닫히면 초점을 격자로 — 창을 연 바로 뒤에 부름 */
|
||||
export function watchClose(back: () => void): void {
|
||||
const w = new MutationObserver(() => {
|
||||
@@ -114,8 +116,10 @@ export function mountActions(ctx: SpreadsheetContext, back: () => void): Actions
|
||||
return {
|
||||
key(e) {
|
||||
const act = pick(e);
|
||||
if (act) go(act);
|
||||
return !!act;
|
||||
// 시트 탭이 없으면(산출근거) 시트 오가기 · 새 시트를 받지 않음 — 브라우저 몫으로 둠
|
||||
if (!act || (SHEET_ACTS.has(act) && ctx.root.classList.contains("ss--notabs"))) return false;
|
||||
go(act);
|
||||
return true;
|
||||
},
|
||||
items: [
|
||||
item(TEXT.goTo, "goTo"),
|
||||
|
||||
@@ -181,7 +181,14 @@ export function mountDataMenu(ctx: SpreadsheetContext, back: () => void): DataMe
|
||||
async () => (await import("./spreadsheet_names")).createNameManagerPanel,
|
||||
),
|
||||
],
|
||||
[TEXT.sheets, () => void openPanel(TEXT.sheets, async () => createSheetExtraPanel)],
|
||||
...(ctx.root.classList.contains("ss--notabs") // 시트 탭 없음(산출근거) — 시트 창도 없음
|
||||
? []
|
||||
: [
|
||||
[
|
||||
TEXT.sheets,
|
||||
() => void openPanel(TEXT.sheets, async () => createSheetExtraPanel),
|
||||
] as MapContextMenuItem,
|
||||
]),
|
||||
[TEXT.grid, () => (toggleGridlines(), back())],
|
||||
...act.items,
|
||||
{
|
||||
|
||||
@@ -162,7 +162,7 @@ export function createStructurePanel(opts: StructurePanelOptions): StructurePane
|
||||
try {
|
||||
const { createSpreadsheet } = await loadSpreadsheet();
|
||||
if (mine !== seq || !basisDoc) return;
|
||||
basis = createSpreadsheet(basisHost, basisDoc, { readOnly: true });
|
||||
basis = createSpreadsheet(basisHost, basisDoc, { readOnly: true, tabs: false });
|
||||
} catch (error) {
|
||||
if (mine === seq) basisHost.replaceChildren(note(fill(TEXT.noSheet, why(error))));
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ export function createMain(isAdmin: boolean, onSaved?: () => void): MainHandle {
|
||||
const { createSpreadsheet } = await import("../A00_Common/spreadsheet/spreadsheet");
|
||||
editor = createSpreadsheet(host, doc as Parameters<typeof createSpreadsheet>[1], {
|
||||
readOnly,
|
||||
tabs: false, // 산출근거 = 시트 하나 · 탭 줄 없음
|
||||
onChange: () => (dirty = !readOnly),
|
||||
});
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user