@open-document/core 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-BHFGY8eF.js → build-CbgIk6bA.js} +1 -1
- package/dist/{check-UEBmDfT_.js → check-BTroj-5Z.js} +3 -3
- package/dist/cli/bin.js +58 -34
- package/dist/config-BWtOZ1jc.d.ts +45 -0
- package/dist/{config-B_pdNbYg.js → config-DKKNIbvO.js} +1458 -983
- package/dist/{context-BM9_-u9P.js → context-DXNP8v9I.js} +3 -2
- package/dist/deploy-gcp-BUiSuqz7.js +758 -0
- package/dist/{dev-DX3QMIRi.js → dev-YXumw5iX.js} +1 -1
- package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
- package/dist/{diff-DayvbXfX.js → diff-CTFfU4Tz.js} +2 -2
- package/dist/{export-BPsXj1i6.js → export-D2QLtF84.js} +11 -4
- package/dist/flow-CS5apebG.d.ts +252 -0
- package/dist/{import-71wlAsrd.js → import-CcmrFetU.js} +3 -2
- package/dist/index.d.ts +155 -59
- package/dist/index.js +945 -104
- package/dist/open-doc-plugin-DnX5usgI.js +320 -0
- package/dist/ops/index.d.ts +112 -3
- package/dist/ops/index.js +3 -3
- package/dist/{ops-BUo67DaP.js → ops-DmEecq1k.js} +86 -164
- package/dist/package-version-C89gtYSk.js +36 -0
- package/dist/{preview-D3m1-gUL.js → preview-_mHpBhMk.js} +1 -1
- package/dist/templates-MMblHwmT.js +34 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +2 -1
- package/package.json +2 -1
- package/skills/apply-comments/SKILL.md +3 -1
- package/skills/create-doc/SKILL.md +2 -0
- package/skills/doc-authoring/SKILL.md +17 -16
- package/skills/doc-authoring/references/long-form.md +43 -2
- package/skills/doc-authoring/references/pagination.md +14 -2
- package/skills/doc-authoring/references/tables-and-charts.md +21 -17
- package/src/app/components/browser/browser-ui.tsx +21 -0
- package/src/app/components/browser/new-document-dialog.tsx +208 -0
- package/src/app/components/callout.tsx +101 -0
- package/src/app/components/changes/changes-overlay.tsx +68 -0
- package/src/app/components/changes/changes-panel.tsx +341 -0
- package/src/app/components/changes/use-changes.ts +85 -0
- package/src/app/components/chart.tsx +191 -33
- package/src/app/components/code-block.tsx +249 -0
- package/src/app/components/comments/comments-overlay.tsx +50 -0
- package/src/app/components/comments/comments-panel.tsx +272 -0
- package/src/app/components/comments/use-comments.ts +61 -0
- package/src/app/components/data-table.tsx +146 -18
- package/src/app/components/doc-sidebar.tsx +32 -2
- package/src/app/components/flow-page.tsx +57 -8
- package/src/app/components/inspector/field-source.tsx +41 -0
- package/src/app/components/inspector/inspector.tsx +64 -65
- package/src/app/components/numbering.tsx +226 -12
- package/src/app/components/overlay-frame.tsx +79 -0
- package/src/app/components/page-frame.tsx +46 -0
- package/src/app/components/page-placement.ts +68 -0
- package/src/app/components/record-picker.tsx +79 -0
- package/src/app/components/themes/theme-preview.tsx +5 -4
- package/src/app/lib/agent-bridge.ts +29 -1
- package/src/app/lib/chart.test.ts +15 -0
- package/src/app/lib/chart.ts +134 -9
- package/src/app/lib/diagnostics.ts +45 -1
- package/src/app/lib/docx/ooxml.test.ts +24 -1
- package/src/app/lib/docx/ooxml.ts +27 -1
- package/src/app/lib/export-docx.ts +3 -1
- package/src/app/lib/export-dom.ts +17 -3
- package/src/app/lib/export-html.ts +4 -2
- package/src/app/lib/export-image.ts +2 -1
- package/src/app/lib/export-pdf.ts +9 -1
- package/src/app/lib/flow-measure.test.ts +30 -0
- package/src/app/lib/flow-measure.ts +68 -14
- package/src/app/lib/flow.test.ts +20 -1
- package/src/app/lib/flow.ts +120 -20
- package/src/app/lib/i18n-ja/browser.ts +10 -0
- package/src/app/lib/i18n-ja/doc.ts +4 -0
- package/src/app/lib/i18n-ja/panels.ts +40 -0
- package/src/app/lib/i18n-ko/browser.ts +10 -0
- package/src/app/lib/i18n-ko/doc.ts +4 -0
- package/src/app/lib/i18n-ko/panels.ts +39 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +10 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +4 -0
- package/src/app/lib/i18n-zh-cn/panels.ts +38 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +10 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +4 -0
- package/src/app/lib/i18n-zh-tw/panels.ts +38 -0
- package/src/app/lib/labels.ts +29 -10
- package/src/app/lib/records.test.ts +38 -0
- package/src/app/lib/records.ts +127 -0
- package/src/app/lib/sdk.ts +35 -0
- package/src/app/lib/use-doc-module.ts +7 -0
- package/src/app/lib/use-doc-pages.ts +38 -17
- package/src/app/routes/doc.tsx +275 -13
- package/src/app/routes/home.tsx +30 -5
- package/src/app/styles.css +23 -0
- package/templates/blank/index.tsx +63 -0
- package/templates/blank/template.json +6 -0
- package/templates/certificate/data/recipients.csv +4 -0
- package/templates/certificate/index.tsx +128 -0
- package/templates/certificate/template.json +6 -0
- package/templates/letter/index.tsx +106 -0
- package/templates/letter/template.json +5 -0
- package/templates/meeting-notes/index.tsx +194 -0
- package/templates/meeting-notes/template.json +6 -0
- package/templates/proposal/index.tsx +264 -0
- package/templates/proposal/template.json +6 -0
- package/templates/report/data/metrics.csv +5 -0
- package/templates/report/index.tsx +224 -0
- package/templates/report/template.json +6 -0
- package/dist/config-P61niZMf.d.ts +0 -24
- package/dist/sdk-CpDEGRIo.d.ts +0 -138
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createElement, type ReactNode } from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
2
3
|
import { createRoot } from 'react-dom/client';
|
|
3
4
|
import { FLOW_BLOCK_ATTR, FlowBlock } from '../components/flow-page';
|
|
4
5
|
import { FOOTNOTE_AREA_MARGIN_TOP, FOOTNOTE_ROW_ATTR, Footnotes } from '../components/footnote';
|
|
@@ -16,14 +17,40 @@ export type MeasurableSection = {
|
|
|
16
17
|
/** Index-aligned with `blocks`. */
|
|
17
18
|
notesByBlock: ExtractedNote[][];
|
|
18
19
|
padding?: number;
|
|
20
|
+
columns?: 1 | 2 | 3;
|
|
21
|
+
columnGap?: number;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
function metricsFor(el: HTMLElement, height: number, footnoteHeight: number): BlockMetrics {
|
|
24
|
+
export function metricsFor(el: HTMLElement, height: number, footnoteHeight: number): BlockMetrics {
|
|
22
25
|
const inner = el.firstElementChild;
|
|
23
26
|
const tag = inner?.tagName ?? '';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// `?? null`: a block that renders nothing has no child, and `undefined`
|
|
28
|
+
// would pass every `!== null` below — an empty block then broke the page
|
|
29
|
+
// before it and glued itself to the next.
|
|
30
|
+
const declaredKeepNext = inner?.getAttribute('data-od-keep-with-next') ?? null;
|
|
31
|
+
const declaredKeepPrev = inner?.getAttribute('data-od-keep-with-previous') ?? null;
|
|
32
|
+
const declaredBreak = inner?.getAttribute('data-od-break-before') ?? null;
|
|
33
|
+
|
|
34
|
+
let splittable: BlockMetrics['splittable'];
|
|
35
|
+
if (typeof el.querySelector === 'function') {
|
|
36
|
+
const splitTable = el.querySelector<HTMLTableElement>('table[data-od-splittable]');
|
|
37
|
+
if (splitTable) {
|
|
38
|
+
const tbodyRows = Array.from(splitTable.querySelectorAll<HTMLElement>('tbody > tr'));
|
|
39
|
+
if (tbodyRows.length > 1) {
|
|
40
|
+
const blockRect = el.getBoundingClientRect();
|
|
41
|
+
const firstRowRect = tbodyRows[0].getBoundingClientRect();
|
|
42
|
+
const lastRowRect = tbodyRows[tbodyRows.length - 1].getBoundingClientRect();
|
|
43
|
+
const headerHeight = Math.max(0, firstRowRect.top - blockRect.top);
|
|
44
|
+
const footerHeight = Math.max(0, height - (lastRowRect.bottom - blockRect.top));
|
|
45
|
+
const rowHeights = tbodyRows.map((row, idx) => {
|
|
46
|
+
const r = row.getBoundingClientRect();
|
|
47
|
+
const next = tbodyRows[idx + 1]?.getBoundingClientRect();
|
|
48
|
+
return Math.max(0, (next ? next.top : lastRowRect.bottom) - r.top);
|
|
49
|
+
});
|
|
50
|
+
splittable = { headerHeight, footerHeight, rowHeights };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
27
54
|
|
|
28
55
|
return {
|
|
29
56
|
height,
|
|
@@ -33,6 +60,7 @@ function metricsFor(el: HTMLElement, height: number, footnoteHeight: number): Bl
|
|
|
33
60
|
keepWithNext: declaredKeepNext !== null ? declaredKeepNext !== 'false' : HEADING_TAGS.has(tag),
|
|
34
61
|
keepWithPrevious: declaredKeepPrev !== null && declaredKeepPrev !== 'false',
|
|
35
62
|
breakBefore: declaredBreak !== null && declaredBreak !== 'false',
|
|
63
|
+
...(splittable ? { splittable } : {}),
|
|
36
64
|
};
|
|
37
65
|
}
|
|
38
66
|
|
|
@@ -73,7 +101,7 @@ function stackedHeights(container: HTMLElement, selector: string): number[] {
|
|
|
73
101
|
*/
|
|
74
102
|
export async function measureFlowSections(
|
|
75
103
|
sections: MeasurableSection[],
|
|
76
|
-
opts: { geometry: PageGeometry; design?: DesignSystem },
|
|
104
|
+
opts: { geometry: PageGeometry; design?: DesignSystem; lang?: string },
|
|
77
105
|
): Promise<FlowMeasurement[]> {
|
|
78
106
|
if (sections.length === 0) return [];
|
|
79
107
|
|
|
@@ -82,6 +110,9 @@ export async function measureFlowSections(
|
|
|
82
110
|
// The sheet's own element styles (styles.css) apply here too, so a block
|
|
83
111
|
// measures as it will print.
|
|
84
112
|
host.setAttribute('data-od-measure', '');
|
|
113
|
+
// Where a line breaks depends on the language, so it is measured in the one
|
|
114
|
+
// it prints in.
|
|
115
|
+
host.setAttribute('lang', opts.lang ?? 'en');
|
|
85
116
|
Object.assign(host.style, {
|
|
86
117
|
position: 'fixed',
|
|
87
118
|
left: '-99999px',
|
|
@@ -112,16 +143,26 @@ export async function measureFlowSections(
|
|
|
112
143
|
};
|
|
113
144
|
|
|
114
145
|
try {
|
|
146
|
+
// Out of the effect that called us, so `flushSync` below may commit.
|
|
147
|
+
await Promise.resolve();
|
|
115
148
|
for (const section of sections) {
|
|
116
|
-
const
|
|
149
|
+
const fullWidth = opts.geometry.width - paddingOf(section) * 2;
|
|
150
|
+
const cols = section.columns && section.columns > 1 ? section.columns : 1;
|
|
151
|
+
const gap = section.columnGap ?? 24;
|
|
152
|
+
const blockWidth = cols > 1 ? (fullWidth - gap * (cols - 1)) / cols : fullWidth;
|
|
117
153
|
|
|
118
|
-
const blocks = makeContainer(
|
|
154
|
+
const blocks = makeContainer(blockWidth);
|
|
119
155
|
blockContainers.push(blocks);
|
|
120
156
|
const blockRoot = createRoot(blocks);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
157
|
+
// Committed now, not on React's schedule: on a slow machine a render
|
|
158
|
+
// left to finish on its own was still empty when the frames below had
|
|
159
|
+
// passed, the section measured as no blocks, and it printed as no pages.
|
|
160
|
+
flushSync(() =>
|
|
161
|
+
blockRoot.render(
|
|
162
|
+
section.blocks.map((block, index) =>
|
|
163
|
+
createElement(FlowBlock, { key: index }, block),
|
|
164
|
+
) as unknown as Parameters<typeof blockRoot.render>[0],
|
|
165
|
+
),
|
|
125
166
|
);
|
|
126
167
|
roots.push(blockRoot);
|
|
127
168
|
|
|
@@ -130,19 +171,31 @@ export async function measureFlowSections(
|
|
|
130
171
|
noteContainers.push(null);
|
|
131
172
|
continue;
|
|
132
173
|
}
|
|
133
|
-
const notes = makeContainer(
|
|
174
|
+
const notes = makeContainer(fullWidth);
|
|
134
175
|
noteContainers.push(notes);
|
|
135
176
|
const noteRoot = createRoot(notes);
|
|
136
|
-
noteRoot.render(createElement(Footnotes, { notes: allNotes }));
|
|
177
|
+
flushSync(() => noteRoot.render(createElement(Footnotes, { notes: allNotes })));
|
|
137
178
|
roots.push(noteRoot);
|
|
138
179
|
}
|
|
139
180
|
|
|
140
181
|
await nextFrame();
|
|
141
182
|
await waitForFonts();
|
|
142
183
|
await nextFrame();
|
|
184
|
+
// Every block has its wrapper before anything is read: a short count would
|
|
185
|
+
// be packed as a short section.
|
|
186
|
+
for (let frame = 0; frame < 60; frame++) {
|
|
187
|
+
const complete = sections.every(
|
|
188
|
+
(section, index) =>
|
|
189
|
+
(blockContainers[index]?.querySelectorAll(`:scope > [${FLOW_BLOCK_ATTR}]`).length ?? 0) >=
|
|
190
|
+
section.blocks.length,
|
|
191
|
+
);
|
|
192
|
+
if (complete) break;
|
|
193
|
+
await nextFrame();
|
|
194
|
+
}
|
|
143
195
|
|
|
144
196
|
return sections.map((section, sectionIndex) => {
|
|
145
197
|
const padding = paddingOf(section);
|
|
198
|
+
const cols = section.columns && section.columns > 1 ? section.columns : 1;
|
|
146
199
|
const blocks = blockContainers[sectionIndex];
|
|
147
200
|
const blockHeights = stackedHeights(blocks, `:scope > [${FLOW_BLOCK_ATTR}]`);
|
|
148
201
|
|
|
@@ -165,7 +218,8 @@ export async function measureFlowSections(
|
|
|
165
218
|
let notesHeight = 0;
|
|
166
219
|
for (let i = 0; i < count; i++) notesHeight += rowHeights[noteCursor + i] ?? 0;
|
|
167
220
|
noteCursor += count;
|
|
168
|
-
|
|
221
|
+
const rawHeight = blockHeights[index] ?? 0;
|
|
222
|
+
return metricsFor(node, cols > 1 ? rawHeight / cols : rawHeight, notesHeight);
|
|
169
223
|
});
|
|
170
224
|
|
|
171
225
|
return {
|
package/src/app/lib/flow.test.ts
CHANGED
|
@@ -59,7 +59,26 @@ describe('paginateBlocks', () => {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('returns no pages for no blocks', () => {
|
|
62
|
-
expect(paginateBlocks([], 1000)).toEqual({ pages: [], overflowing: [] });
|
|
62
|
+
expect(paginateBlocks([], 1000)).toEqual({ pages: [], slices: [], overflowing: [] });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('splits a tall splittable table across pages with repeated header', () => {
|
|
66
|
+
const tableBlock = b(680, {
|
|
67
|
+
splittable: {
|
|
68
|
+
headerHeight: 40,
|
|
69
|
+
footerHeight: 40,
|
|
70
|
+
rowHeights: [100, 100, 100, 100, 100, 100],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
const result = paginateBlocks([b(500), tableBlock], 1000);
|
|
74
|
+
// Page 1 has 500px left: header(40) + 4 rows(400) = 440 <= 500.
|
|
75
|
+
// Page 2 gets the remaining 2 rows + header(40) + footer(40).
|
|
76
|
+
expect(result.pages).toEqual([[0, 1], [1]]);
|
|
77
|
+
expect(result.slices).toEqual([
|
|
78
|
+
[{ index: 0 }, { index: 1, rowStart: 0, rowEnd: 4 }],
|
|
79
|
+
[{ index: 1, rowStart: 4, rowEnd: 6 }],
|
|
80
|
+
]);
|
|
81
|
+
expect(result.overflowing).toEqual([]);
|
|
63
82
|
});
|
|
64
83
|
});
|
|
65
84
|
|
package/src/app/lib/flow.ts
CHANGED
|
@@ -27,7 +27,13 @@ function toBlocks(node: ReactNode): ReactNode[] {
|
|
|
27
27
|
*/
|
|
28
28
|
export function flow(
|
|
29
29
|
children: ReactNode,
|
|
30
|
-
opts: {
|
|
30
|
+
opts: {
|
|
31
|
+
header?: ComponentType;
|
|
32
|
+
footer?: ComponentType;
|
|
33
|
+
padding?: number;
|
|
34
|
+
columns?: 1 | 2 | 3;
|
|
35
|
+
columnGap?: number;
|
|
36
|
+
} = {},
|
|
31
37
|
): FlowSection {
|
|
32
38
|
return { __odFlow: true, blocks: toBlocks(children), ...opts };
|
|
33
39
|
}
|
|
@@ -36,6 +42,12 @@ export function isFlowSection(entry: DocEntry): entry is FlowSection {
|
|
|
36
42
|
return typeof entry === 'object' && entry !== null && (entry as FlowSection).__odFlow === true;
|
|
37
43
|
}
|
|
38
44
|
|
|
45
|
+
export type BlockSlice = {
|
|
46
|
+
index: number;
|
|
47
|
+
rowStart?: number;
|
|
48
|
+
rowEnd?: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
39
51
|
export type BlockMetrics = {
|
|
40
52
|
height: number;
|
|
41
53
|
/** Height this block's footnotes add to the foot of whatever page it lands on. */
|
|
@@ -46,11 +58,19 @@ export type BlockMetrics = {
|
|
|
46
58
|
keepWithPrevious?: boolean;
|
|
47
59
|
/** Always start a new page before this block. */
|
|
48
60
|
breakBefore?: boolean;
|
|
61
|
+
/** When present, this block is a table that can split between rows across page breaks. */
|
|
62
|
+
splittable?: {
|
|
63
|
+
headerHeight: number;
|
|
64
|
+
footerHeight: number;
|
|
65
|
+
rowHeights: number[];
|
|
66
|
+
};
|
|
49
67
|
};
|
|
50
68
|
|
|
51
69
|
export type PaginationResult = {
|
|
52
70
|
/** Block indices per page, in order. */
|
|
53
71
|
pages: number[][];
|
|
72
|
+
/** Detailed block slices per page, carrying row ranges when a table splits across pages. */
|
|
73
|
+
slices: BlockSlice[][];
|
|
54
74
|
/** Blocks taller than one page — they stay whole and overflow. */
|
|
55
75
|
overflowing: number[];
|
|
56
76
|
};
|
|
@@ -63,7 +83,9 @@ export type PaginateOptions = {
|
|
|
63
83
|
/**
|
|
64
84
|
* Greedy top-to-bottom packing: fill a page until the next block would cross
|
|
65
85
|
* the bottom edge, then push that block — plus anything glued to it — onto the
|
|
66
|
-
* next page. Blocks are atomic
|
|
86
|
+
* next page. Blocks are atomic unless marked `splittable`, in which case rows
|
|
87
|
+
* pack into the remaining space and continue on the next sheet with the header
|
|
88
|
+
* repeated.
|
|
67
89
|
*
|
|
68
90
|
* Footnotes are packed from the same budget: a block that carries notes brings
|
|
69
91
|
* their height with it, because those notes print at the foot of whichever page
|
|
@@ -75,22 +97,42 @@ export function paginateBlocks(
|
|
|
75
97
|
opts: PaginateOptions = {},
|
|
76
98
|
): PaginationResult {
|
|
77
99
|
const overhead = opts.footnoteOverhead ?? 0;
|
|
78
|
-
const
|
|
100
|
+
const slices: BlockSlice[][] = [];
|
|
79
101
|
const overflowing: number[] = [];
|
|
80
|
-
let current:
|
|
102
|
+
let current: BlockSlice[] = [];
|
|
81
103
|
let used = 0;
|
|
82
104
|
let notes = 0;
|
|
83
105
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
const sliceHeight = (slice: BlockSlice): number => {
|
|
107
|
+
const block = blocks[slice.index];
|
|
108
|
+
if (!block) return 0;
|
|
109
|
+
if (slice.rowStart !== undefined && slice.rowEnd !== undefined && block.splittable) {
|
|
110
|
+
let rows = 0;
|
|
111
|
+
for (let r = slice.rowStart; r < slice.rowEnd; r++) {
|
|
112
|
+
rows += block.splittable.rowHeights[r] ?? 0;
|
|
113
|
+
}
|
|
114
|
+
const isLast = slice.rowEnd >= block.splittable.rowHeights.length;
|
|
115
|
+
return block.splittable.headerHeight + rows + (isLast ? block.splittable.footerHeight : 0);
|
|
116
|
+
}
|
|
117
|
+
return block.height;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const heightOf = (items: BlockSlice[]) => items.reduce((sum, item) => sum + sliceHeight(item), 0);
|
|
121
|
+
const notesOf = (items: BlockSlice[]) =>
|
|
122
|
+
items.reduce(
|
|
123
|
+
(sum, item) =>
|
|
124
|
+
sum +
|
|
125
|
+
(item.rowStart === undefined || item.rowStart === 0
|
|
126
|
+
? (blocks[item.index]?.footnoteHeight ?? 0)
|
|
127
|
+
: 0),
|
|
128
|
+
0,
|
|
129
|
+
);
|
|
88
130
|
/** A page with no notes pays nothing; the first note also pays for the rule. */
|
|
89
131
|
const reserve = (total: number) => (total > 0 ? total + overhead : 0);
|
|
90
132
|
|
|
91
133
|
const closePage = () => {
|
|
92
134
|
if (current.length === 0) return;
|
|
93
|
-
|
|
135
|
+
slices.push(current);
|
|
94
136
|
current = [];
|
|
95
137
|
used = 0;
|
|
96
138
|
notes = 0;
|
|
@@ -98,35 +140,93 @@ export function paginateBlocks(
|
|
|
98
140
|
|
|
99
141
|
blocks.forEach((block, index) => {
|
|
100
142
|
const own = block.footnoteHeight ?? 0;
|
|
101
|
-
if (block.height + reserve(own) > available) overflowing.push(index);
|
|
102
143
|
|
|
103
144
|
if (block.breakBefore) closePage();
|
|
104
145
|
|
|
146
|
+
const split = block.splittable;
|
|
147
|
+
const canSplit = split && split.rowHeights.length > 1;
|
|
148
|
+
|
|
149
|
+
if (!canSplit && block.height + reserve(own) > available) {
|
|
150
|
+
overflowing.push(index);
|
|
151
|
+
}
|
|
152
|
+
|
|
105
153
|
if (current.length > 0 && used + block.height + reserve(notes + own) > available) {
|
|
106
154
|
// Everything glued to this block travels with it: trailing headings
|
|
107
155
|
// (keep-with-next) and, when this block is a caption, its figure.
|
|
108
156
|
let splitAt = current.length;
|
|
109
|
-
while (splitAt > 0 && blocks[current[splitAt - 1]]?.keepWithNext) splitAt--;
|
|
157
|
+
while (splitAt > 0 && blocks[current[splitAt - 1].index]?.keepWithNext) splitAt--;
|
|
110
158
|
if (block.keepWithPrevious && splitAt === current.length) splitAt--;
|
|
111
159
|
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
160
|
+
if (canSplit) {
|
|
161
|
+
const firstRowCost = split.headerHeight + (split.rowHeights[0] ?? 0);
|
|
162
|
+
if (used + firstRowCost + reserve(notes + own) > available) {
|
|
163
|
+
if (splitAt > 0 && splitAt < current.length) {
|
|
164
|
+
const moved = current.slice(splitAt);
|
|
165
|
+
slices.push(current.slice(0, splitAt));
|
|
166
|
+
current = moved;
|
|
167
|
+
used = heightOf(moved);
|
|
168
|
+
notes = notesOf(moved);
|
|
169
|
+
} else {
|
|
170
|
+
closePage();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
118
173
|
} else {
|
|
119
|
-
|
|
174
|
+
if (splitAt > 0 && splitAt < current.length) {
|
|
175
|
+
const moved = current.slice(splitAt);
|
|
176
|
+
slices.push(current.slice(0, splitAt));
|
|
177
|
+
current = moved;
|
|
178
|
+
used = heightOf(moved);
|
|
179
|
+
notes = notesOf(moved);
|
|
180
|
+
} else {
|
|
181
|
+
closePage();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (canSplit && used + block.height + reserve(notes + own) > available) {
|
|
187
|
+
let rowCursor = 0;
|
|
188
|
+
const totalRows = split.rowHeights.length;
|
|
189
|
+
let firstSlice = true;
|
|
190
|
+
while (rowCursor < totalRows) {
|
|
191
|
+
const sliceNotes = firstSlice ? own : 0;
|
|
192
|
+
const budget = available - used - reserve(notes + sliceNotes) - split.headerHeight;
|
|
193
|
+
let rowEnd = rowCursor;
|
|
194
|
+
let rowSum = 0;
|
|
195
|
+
while (rowEnd < totalRows) {
|
|
196
|
+
const rHeight = split.rowHeights[rowEnd] ?? 0;
|
|
197
|
+
const tail = rowEnd + 1 === totalRows ? split.footerHeight : 0;
|
|
198
|
+
if (rowSum + rHeight + tail <= budget || (rowEnd === rowCursor && current.length === 0)) {
|
|
199
|
+
rowSum += rHeight;
|
|
200
|
+
rowEnd++;
|
|
201
|
+
} else {
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (rowEnd === rowCursor) {
|
|
206
|
+
closePage();
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
const slice: BlockSlice = { index, rowStart: rowCursor, rowEnd };
|
|
210
|
+
current.push(slice);
|
|
211
|
+
used += sliceHeight(slice);
|
|
212
|
+
notes += sliceNotes;
|
|
213
|
+
firstSlice = false;
|
|
214
|
+
rowCursor = rowEnd;
|
|
215
|
+
if (rowCursor < totalRows) {
|
|
216
|
+
closePage();
|
|
217
|
+
}
|
|
120
218
|
}
|
|
219
|
+
return;
|
|
121
220
|
}
|
|
122
221
|
|
|
123
|
-
current.push(index);
|
|
222
|
+
current.push({ index });
|
|
124
223
|
used += block.height;
|
|
125
224
|
notes += own;
|
|
126
225
|
});
|
|
127
226
|
|
|
128
227
|
closePage();
|
|
129
|
-
|
|
228
|
+
const pages = slices.map((page) => page.map((s) => s.index));
|
|
229
|
+
return { pages, slices, overflowing };
|
|
130
230
|
}
|
|
131
231
|
|
|
132
232
|
/** Blocks of the first flow section, for thumbnails that skip measurement. */
|
|
@@ -85,4 +85,14 @@ export const BROWSER: Record<string, string> = {
|
|
|
85
85
|
'Light theme': 'ライトテーマ',
|
|
86
86
|
'Dark theme': 'ダークテーマ',
|
|
87
87
|
'System theme': 'システムテーマ',
|
|
88
|
+
'New document': '新しいドキュメント',
|
|
89
|
+
Template: 'テンプレート',
|
|
90
|
+
'This workspace': 'このワークスペース',
|
|
91
|
+
Create: '作成',
|
|
92
|
+
'Could not create the document': 'ドキュメントを作成できませんでした',
|
|
93
|
+
Blank: '白紙',
|
|
94
|
+
Report: 'レポート',
|
|
95
|
+
Proposal: '提案書',
|
|
96
|
+
'Meeting notes': '議事録',
|
|
97
|
+
Letter: 'レター',
|
|
88
98
|
};
|
|
@@ -148,4 +148,44 @@ export const PANELS: Record<string, string> = {
|
|
|
148
148
|
Done: '完了',
|
|
149
149
|
'{count} elements print from this line of source':
|
|
150
150
|
'このソース行から {count} 個の要素が出力されます',
|
|
151
|
+
Changes: '変更',
|
|
152
|
+
'Changes ({count})': '変更({count})',
|
|
153
|
+
'Changes since the last commit': '前回のコミット以降の変更',
|
|
154
|
+
'Close the changes panel': '変更パネルを閉じる',
|
|
155
|
+
'Show changes since the last commit': '前回のコミット以降の変更を表示',
|
|
156
|
+
'Previous change': '前の変更',
|
|
157
|
+
'Next change': '次の変更',
|
|
158
|
+
Since: '比較',
|
|
159
|
+
'Compare with': '比較対象',
|
|
160
|
+
'Last commit': '前回のコミット',
|
|
161
|
+
'git is not installed': 'git がインストールされていません',
|
|
162
|
+
'Not a git repository': 'git リポジトリではありません',
|
|
163
|
+
'No changes': '変更はありません',
|
|
164
|
+
'Page {page}, changed': '{page} ページ(変更あり)',
|
|
165
|
+
Files: 'ファイル',
|
|
166
|
+
'Revert this change': 'この変更を元に戻す',
|
|
167
|
+
'that change is no longer there — reload the changes':
|
|
168
|
+
'この変更はもうありません。変更を再読み込みしてください',
|
|
169
|
+
'the file changed since the diff was read': '差分を読んだ後にファイルが変更されました',
|
|
170
|
+
'reverting this change alone would break the source — revert the changes around it too':
|
|
171
|
+
'この変更だけを戻すとソースが壊れます。周辺の変更も一緒に戻してください',
|
|
172
|
+
'a binary file cannot be reverted here': 'バイナリファイルはここでは元に戻せません',
|
|
173
|
+
'this workspace is not under git': 'このワークスペースは git で管理されていません',
|
|
174
|
+
Comments: 'コメント',
|
|
175
|
+
'Comments ({count})': 'コメント({count})',
|
|
176
|
+
'Close the comments panel': 'コメントパネルを閉じる',
|
|
177
|
+
'Show comments': 'コメントを表示',
|
|
178
|
+
'New comment': '新しいコメント',
|
|
179
|
+
Resolve: '解決済みにする',
|
|
180
|
+
'Copy request for the agent': 'エージェントへの依頼をコピー',
|
|
181
|
+
'No comments': 'コメントはありません',
|
|
182
|
+
'p.{page}': '{page} ページ',
|
|
183
|
+
'Page {page}, with comments': '{page} ページ(コメントあり)',
|
|
184
|
+
'Could not resolve the comment': '解決済みにできませんでした',
|
|
185
|
+
'Pick an element on the page': 'ページ上の要素を選択',
|
|
186
|
+
'Click the element to comment on · Esc to cancel':
|
|
187
|
+
'コメントする要素をクリック · Esc でキャンセル',
|
|
188
|
+
Records: 'レコード',
|
|
189
|
+
'Row {row} of {count}': '{count} 行中 {row} 行目',
|
|
190
|
+
'Esc to deselect': 'Esc で選択解除',
|
|
151
191
|
};
|
|
@@ -84,4 +84,14 @@ export const BROWSER: Record<string, string> = {
|
|
|
84
84
|
'Light theme': '라이트 테마',
|
|
85
85
|
'Dark theme': '다크 테마',
|
|
86
86
|
'System theme': '시스템 테마',
|
|
87
|
+
'New document': '새 문서',
|
|
88
|
+
Template: '템플릿',
|
|
89
|
+
'This workspace': '이 작업 공간',
|
|
90
|
+
Create: '만들기',
|
|
91
|
+
'Could not create the document': '문서를 만들 수 없습니다',
|
|
92
|
+
Blank: '빈 문서',
|
|
93
|
+
Report: '보고서',
|
|
94
|
+
Proposal: '제안서',
|
|
95
|
+
'Meeting notes': '회의록',
|
|
96
|
+
Letter: '서신',
|
|
87
97
|
};
|
|
@@ -145,4 +145,43 @@ export const PANELS: Record<string, string> = {
|
|
|
145
145
|
'Custom font': '사용자 지정 글꼴',
|
|
146
146
|
Done: '완료',
|
|
147
147
|
'{count} elements print from this line of source': '이 소스 줄에서 {count}개의 요소가 출력됩니다',
|
|
148
|
+
Changes: '변경 사항',
|
|
149
|
+
'Changes ({count})': '변경 사항({count})',
|
|
150
|
+
'Changes since the last commit': '마지막 커밋 이후 변경 사항',
|
|
151
|
+
'Close the changes panel': '변경 사항 패널 닫기',
|
|
152
|
+
'Show changes since the last commit': '마지막 커밋 이후 변경 사항 표시',
|
|
153
|
+
'Previous change': '이전 변경',
|
|
154
|
+
'Next change': '다음 변경',
|
|
155
|
+
Since: '비교',
|
|
156
|
+
'Compare with': '비교 대상',
|
|
157
|
+
'Last commit': '마지막 커밋',
|
|
158
|
+
'git is not installed': 'git이 설치되어 있지 않습니다',
|
|
159
|
+
'Not a git repository': 'git 저장소가 아닙니다',
|
|
160
|
+
'No changes': '변경 사항 없음',
|
|
161
|
+
'Page {page}, changed': '{page}페이지, 변경됨',
|
|
162
|
+
Files: '파일',
|
|
163
|
+
'Revert this change': '이 변경 되돌리기',
|
|
164
|
+
'that change is no longer there — reload the changes':
|
|
165
|
+
'이 변경은 더 이상 없습니다. 변경 사항을 다시 불러오세요',
|
|
166
|
+
'the file changed since the diff was read': '차이를 읽은 뒤 파일이 변경되었습니다',
|
|
167
|
+
'reverting this change alone would break the source — revert the changes around it too':
|
|
168
|
+
'이 변경만 되돌리면 소스가 깨집니다. 주변 변경도 함께 되돌리세요',
|
|
169
|
+
'a binary file cannot be reverted here': '바이너리 파일은 여기서 되돌릴 수 없습니다',
|
|
170
|
+
'this workspace is not under git': '이 작업 공간은 git으로 관리되지 않습니다',
|
|
171
|
+
Comments: '댓글',
|
|
172
|
+
'Comments ({count})': '댓글({count})',
|
|
173
|
+
'Close the comments panel': '댓글 패널 닫기',
|
|
174
|
+
'Show comments': '댓글 표시',
|
|
175
|
+
'New comment': '새 댓글',
|
|
176
|
+
Resolve: '해결됨으로 표시',
|
|
177
|
+
'Copy request for the agent': '에이전트 요청 복사',
|
|
178
|
+
'No comments': '댓글 없음',
|
|
179
|
+
'p.{page}': '{page}쪽',
|
|
180
|
+
'Page {page}, with comments': '{page}페이지, 댓글 있음',
|
|
181
|
+
'Could not resolve the comment': '해결됨으로 표시할 수 없습니다',
|
|
182
|
+
'Pick an element on the page': '페이지에서 요소 선택',
|
|
183
|
+
'Click the element to comment on · Esc to cancel': '댓글을 남길 요소를 클릭 · Esc로 취소',
|
|
184
|
+
Records: '레코드',
|
|
185
|
+
'Row {row} of {count}': '{count}행 중 {row}행',
|
|
186
|
+
'Esc to deselect': 'Esc로 선택 해제',
|
|
148
187
|
};
|
|
@@ -81,4 +81,14 @@ export const BROWSER: Record<string, string> = {
|
|
|
81
81
|
'Light theme': '浅色主题',
|
|
82
82
|
'Dark theme': '深色主题',
|
|
83
83
|
'System theme': '跟随系统主题',
|
|
84
|
+
'New document': '新建文档',
|
|
85
|
+
Template: '模板',
|
|
86
|
+
'This workspace': '这个工作区',
|
|
87
|
+
Create: '创建',
|
|
88
|
+
'Could not create the document': '无法创建文档',
|
|
89
|
+
Blank: '空白',
|
|
90
|
+
Report: '报告',
|
|
91
|
+
Proposal: '提案',
|
|
92
|
+
'Meeting notes': '会议记录',
|
|
93
|
+
Letter: '信函',
|
|
84
94
|
};
|
|
@@ -140,4 +140,42 @@ export const PANELS: Record<string, string> = {
|
|
|
140
140
|
'Custom font': '自定义字体',
|
|
141
141
|
Done: '完成',
|
|
142
142
|
'{count} elements print from this line of source': '这一行源码输出 {count} 个元素',
|
|
143
|
+
Changes: '变更',
|
|
144
|
+
'Changes ({count})': '变更({count})',
|
|
145
|
+
'Changes since the last commit': '上次 commit 之后的变更',
|
|
146
|
+
'Close the changes panel': '关闭变更面板',
|
|
147
|
+
'Show changes since the last commit': '显示上次 commit 之后的变更',
|
|
148
|
+
'Previous change': '上一个变更',
|
|
149
|
+
'Next change': '下一个变更',
|
|
150
|
+
Since: '比较',
|
|
151
|
+
'Compare with': '比较对象',
|
|
152
|
+
'Last commit': '上次 commit',
|
|
153
|
+
'git is not installed': '没有安装 git',
|
|
154
|
+
'Not a git repository': '不是 git 仓库',
|
|
155
|
+
'No changes': '没有变更',
|
|
156
|
+
'Page {page}, changed': '第 {page} 页,有变更',
|
|
157
|
+
Files: '文件',
|
|
158
|
+
'Revert this change': '还原这个变更',
|
|
159
|
+
'that change is no longer there — reload the changes': '这个变更已经不在了,请重新加载变更',
|
|
160
|
+
'the file changed since the diff was read': '读取差异之后文件又被改过了',
|
|
161
|
+
'reverting this change alone would break the source — revert the changes around it too':
|
|
162
|
+
'单独还原这个变更会让源码出错,请连同周围的变更一起还原',
|
|
163
|
+
'a binary file cannot be reverted here': '二进制文件无法在这里还原',
|
|
164
|
+
'this workspace is not under git': '这个工作区没有使用 git',
|
|
165
|
+
Comments: '评论',
|
|
166
|
+
'Comments ({count})': '评论({count})',
|
|
167
|
+
'Close the comments panel': '关闭评论面板',
|
|
168
|
+
'Show comments': '显示评论',
|
|
169
|
+
'New comment': '新建评论',
|
|
170
|
+
Resolve: '标为已解决',
|
|
171
|
+
'Copy request for the agent': '复制给 Agent 的指令',
|
|
172
|
+
'No comments': '没有评论',
|
|
173
|
+
'p.{page}': '第 {page} 页',
|
|
174
|
+
'Page {page}, with comments': '第 {page} 页,有评论',
|
|
175
|
+
'Could not resolve the comment': '无法标为已解决',
|
|
176
|
+
'Pick an element on the page': '在页面上点选元素',
|
|
177
|
+
'Click the element to comment on · Esc to cancel': '点选要评论的元素 · Esc 取消',
|
|
178
|
+
Records: '数据',
|
|
179
|
+
'Row {row} of {count}': '第 {row} 行,共 {count} 行',
|
|
180
|
+
'Esc to deselect': 'Esc 取消选取',
|
|
143
181
|
};
|
|
@@ -81,4 +81,14 @@ export const BROWSER: Record<string, string> = {
|
|
|
81
81
|
'Light theme': '淺色主題',
|
|
82
82
|
'Dark theme': '深色主題',
|
|
83
83
|
'System theme': '系統主題',
|
|
84
|
+
'New document': '新增文件',
|
|
85
|
+
Template: '範本',
|
|
86
|
+
'This workspace': '這個工作區',
|
|
87
|
+
Create: '建立',
|
|
88
|
+
'Could not create the document': '無法建立文件',
|
|
89
|
+
Blank: '空白',
|
|
90
|
+
Report: '報告',
|
|
91
|
+
Proposal: '提案',
|
|
92
|
+
'Meeting notes': '會議紀錄',
|
|
93
|
+
Letter: '信函',
|
|
84
94
|
};
|