@open-document/core 0.16.0 → 0.17.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-BS_CoazO.js → build-BzNZnIhF.js} +1 -1
- package/dist/{check-tTjyMCrU.js → check-C7kxlAFW.js} +11 -4
- package/dist/cli/bin.js +24 -11
- package/dist/{context-Cli81dhF.js → context-CFPnmNCR.js} +1 -1
- package/dist/{dev-n222xdoE.js → dev-BUo7OESU.js} +1 -1
- package/dist/{diff-DB_qruzT.js → diff-B950T0O6.js} +2 -2
- package/dist/{export-CCFtdscQ.js → export-CHN1CiGv.js} +3 -3
- package/dist/{flow-CS5apebG.d.ts → flow-DlV3t5ML.d.ts} +24 -4
- package/dist/{import-D7k0yYZh.js → import-CLSnIxvN.js} +11 -7
- package/dist/index.d.ts +26 -2
- package/dist/index.js +55 -1
- package/dist/ops/index.d.ts +138 -4
- package/dist/ops/index.js +3 -3
- package/dist/{ops-CouYBa1O.js → ops-BgbM5Irm.js} +197 -9
- package/dist/{preview-DV0GDIsj.js → preview-BVwVqS-I.js} +1 -1
- package/dist/proofread-BpR_3GZz.js +35 -0
- package/dist/{session-Cx7Msl_F.js → session-DmbXf3u7.js} +5135 -67
- package/dist/{templates-C-7VcMMV.js → templates-BsWxs7oo.js} +3 -3
- package/dist/translations-CW5OVM0L.js +42 -0
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/skills/doc-authoring/references/pagination.md +1 -1
- package/skills/fill-form/SKILL.md +42 -0
- package/skills/fit-pages/SKILL.md +48 -0
- package/skills/import-document/SKILL.md +58 -0
- package/skills/proofread/SKILL.md +44 -0
- package/skills/refresh-report/SKILL.md +48 -0
- package/skills/sync-translation/SKILL.md +55 -0
- package/src/agent/prompt.ts +1 -1
- package/src/app/components/checkbox.tsx +68 -0
- package/src/app/components/doc-sidebar.tsx +5 -3
- package/src/app/components/flow-page.tsx +7 -2
- package/src/app/components/panel/edit-save-card.tsx +3 -0
- package/src/app/lib/agent-bridge.ts +37 -4
- package/src/app/lib/diagnostics.ts +46 -5
- package/src/app/lib/export-docx.ts +5 -2
- package/src/app/lib/export-dom.ts +13 -0
- package/src/app/lib/export-html.ts +6 -1
- package/src/app/lib/export-image.ts +9 -4
- package/src/app/lib/export-pdf.ts +17 -4
- package/src/app/lib/flow-measure.ts +9 -5
- package/src/app/lib/flow.ts +3 -2
- package/src/app/lib/i18n-ja/browser.ts +1 -0
- package/src/app/lib/i18n-ko/browser.ts +1 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +1 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +1 -0
- package/src/app/lib/page-budget.ts +81 -0
- package/src/app/lib/proofread-script.ts +61 -0
- package/src/app/lib/proofread.ts +399 -0
- package/src/app/lib/recent-docs.ts +27 -0
- package/src/app/lib/sdk.ts +44 -2
- package/src/app/lib/text-runs.ts +83 -0
- package/src/app/lib/use-doc-pages.ts +10 -3
- package/src/app/routes/doc-preview.tsx +1 -1
- package/src/app/routes/doc.tsx +26 -2
- package/src/app/routes/home.tsx +39 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as createFromTemplate, u as listTemplates } from "./session-
|
|
2
|
-
import "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { l as createFromTemplate, u as listTemplates } from "./session-DmbXf3u7.js";
|
|
2
|
+
import "./ops-BgbM5Irm.js";
|
|
3
|
+
import { t as cliContext } from "./context-CFPnmNCR.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/templates.ts
|
|
6
6
|
/**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as translationStatus, t as markTranslated } from "./ops-BgbM5Irm.js";
|
|
2
|
+
import { t as cliContext } from "./context-CFPnmNCR.js";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
//#region src/cli/translations.ts
|
|
5
|
+
const STATE = {
|
|
6
|
+
current: chalk.green("up to date"),
|
|
7
|
+
stale: chalk.yellow("behind its source"),
|
|
8
|
+
unsynced: chalk.yellow("never marked — run with --mark once it matches"),
|
|
9
|
+
"missing-source": chalk.red("source document not found"),
|
|
10
|
+
"unknown-revision": chalk.red("translatedAt is not a known commit"),
|
|
11
|
+
"no-git": chalk.dim("not a git repository — changes cannot be traced")
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Lists translations (`meta.translationOf`) and whether their source changed
|
|
15
|
+
* since the commit they were translated from; `--mark <id>` records that one
|
|
16
|
+
* has caught up. Exits non-zero when any is behind, so it works as a CI gate.
|
|
17
|
+
*/
|
|
18
|
+
async function translations(docId, opts = {}) {
|
|
19
|
+
const ctx = await cliContext();
|
|
20
|
+
if (opts.mark) {
|
|
21
|
+
const done = await markTranslated(ctx, opts.mark, opts.at);
|
|
22
|
+
if (opts.json) process.stdout.write(`${JSON.stringify(done, null, 2)}\n`);
|
|
23
|
+
else process.stdout.write(`${chalk.bold(done.id)} matches ${done.of} @ ${chalk.dim(done.translatedAt.slice(0, 7))}\n`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const list = await translationStatus(ctx, {
|
|
27
|
+
docId,
|
|
28
|
+
diff: opts.diff
|
|
29
|
+
});
|
|
30
|
+
if (opts.json) process.stdout.write(`${JSON.stringify(list, null, 2)}\n`);
|
|
31
|
+
else if (list.length === 0) process.stdout.write("No translations: no document declares meta.translationOf.\n");
|
|
32
|
+
else for (const t of list) {
|
|
33
|
+
const langs = [t.sourceLang, t.lang].filter(Boolean).join(" → ");
|
|
34
|
+
process.stdout.write(`${chalk.bold(t.id)} ${chalk.dim(`of ${t.of}${langs ? ` (${langs})` : ""}`)} — ${STATE[t.state]}\n`);
|
|
35
|
+
for (const c of t.commits) process.stdout.write(` ${chalk.dim(c.short)} ${c.subject}\n`);
|
|
36
|
+
for (const f of t.changedFiles) process.stdout.write(` ${chalk.yellow("M")} ${f}\n`);
|
|
37
|
+
if (t.diff) process.stdout.write(`${t.diff}${t.diffTruncated ? "\n… (cut)\n" : ""}\n`);
|
|
38
|
+
}
|
|
39
|
+
if (list.some((t) => t.state !== "current" && t.state !== "no-git")) process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { translations };
|
package/dist/vite/index.js
CHANGED
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ export default [Cover, Contents, Body] satisfies DocEntry[];
|
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
- **Each direct child of the fragment is one block.** Blocks are atomic: a block never splits across a page, so a table either fits whole or moves to the next page.
|
|
33
|
-
- The framework owns the page shell for flow pages — margin, background, and base typography come from the `design` const. Your blocks keep their own styles. `flow(node, { padding })` overrides the margin for that section.
|
|
33
|
+
- The framework owns the page shell for flow pages — margin, background, and base typography come from the `design` const. Your blocks keep their own styles. `flow(node, { padding })` overrides the margin for that section — one number for all four sides, or `{ top, right, bottom, left }` when they differ. `flow(node, { orientation: 'landscape' })` prints that section on landscape sheets inside a portrait document — for a wide table — and back.
|
|
34
34
|
- `header` and `footer` are components rendered on **every** page the section expands into. `useDocPageNumber()` works inside them, so a running header or footer needs no extra wiring. Position each absolutely in its margin band (`top: 32` / `bottom: 40`); neither takes anything from the block budget.
|
|
35
35
|
- Blocks are measured in the real DOM at the real page width after fonts settle, then packed greedily. Change a paragraph and the pagination re-runs on hot reload.
|
|
36
36
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fill-form
|
|
3
|
+
description: Use this skill to fill in a form in an open-doc document — usually one imported from Word — with someone's details, without disturbing its layout. "Fill in this form", "幫我填這份申請表", "complete the application with these details", "tick 已婚", "fill the blanks from this data", "/fill-form". It finds the blanks, boxes and empty cells, fills them in the form's own type, ticks checkboxes, and checks the page still prints the same. Do NOT use to write a new document (create-doc) or to change the form's wording or design (doc-authoring).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fill in a form
|
|
7
|
+
|
|
8
|
+
A form imported from Word keeps Word's look: every label, rule and box is where Word put it. Filling it in means adding the applicant's words **into the spaces the form leaves** and changing nothing else.
|
|
9
|
+
|
|
10
|
+
## Step 1 — Gather the details
|
|
11
|
+
|
|
12
|
+
Ask for what you do not have; never invent a person's real details. If the user asks for sample data, make it plainly fictional. Read the form's own instructions (勾選此項者無需填寫…, 「無案號者免填」): some spaces are meant to stay empty, and a signature line is for a hand unless the user says to type a name there.
|
|
13
|
+
|
|
14
|
+
## Step 2 — Find the spaces
|
|
15
|
+
|
|
16
|
+
Work on a copy if the user wants the blank form kept (MCP `duplicate_document`, or copy `docs/<id>/` to a new folder). Then read `docs/<id>/index.tsx`. Every blank the import recognised is a `data-od-blank` span named by the label printed before it — `data-od-field="姓名"`, `data-od-field="填表日期.月"` — so search for those first; the same label in two tables appears twice, in document order.
|
|
17
|
+
|
|
18
|
+
| Space | How it looks in the source | How to fill it |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| Underlined blank (`姓名:____`) | `<span data-od-blank="" data-od-field="姓名" style={{ display: 'inline-block', minWidth: '4em', borderBottom: … }} />` | Put the text inside: `<span … >王小明</span>`. Keep the style; `minWidth` lets a long name widen the line instead of wrapping. When a label follows straight after (`姓名:___服務機關:`), end the value with a space so the two do not run together. |
|
|
21
|
+
| Date or count left as spaces (`日期: 年 月 日`) | `<span data-od-blank="" data-od-field="日期.年" style={{ whiteSpace: 'pre' }}>{' '}</span>年` — the form's own spaces, marked | Replace the spaces inside with the value (`>115</span>年`); keep a space either side if the form spaced it out. The 年/月/日 stay where they are. |
|
|
22
|
+
| Checkbox | `<Checkbox />` | `<Checkbox checked />` (`mark="cross"` for ☒). It is drawn, so it keeps its size in any font. Never type ☑ — CJK fonts lack it and it prints smaller than the box beside it. |
|
|
23
|
+
| Empty table cell | `<td … />` or `<td …><p …><br /></p></td>` | Write the text into the cell's own `<p>` (or add one with the style of a filled cell in the same row). An empty paragraph's `fontSize` is only the size of Word's paragraph mark — set the value in the size of the labels in the same row. Keep a cell's value on one line where you can: a `textAlign: 'justify'` cell spreads a wrapped first line, and an extra line grows the row. |
|
|
24
|
+
| Other run of spaces | Plain spaces in a `whiteSpace: 'pre-wrap'` paragraph | Replace spaces with the value, removing about as many spaces as characters you add (a CJK character is two half-width spaces wide) so the line keeps its length. |
|
|
25
|
+
| Space after a label (`此致機關:`) | The label, then the end of the paragraph | Type the value after the label in the same span. |
|
|
26
|
+
|
|
27
|
+
The same label can appear in several tables (表1 and 表2 both have 姓名:); edit by a string that is unique in the file, and check each edit landed in the cell you meant.
|
|
28
|
+
|
|
29
|
+
## Step 3 — Fill without moving anything
|
|
30
|
+
|
|
31
|
+
- Text you add inherits the paragraph's font and size — do not set new ones.
|
|
32
|
+
- Paragraphs in Word forms often carry a hanging indent (`textIndent: -21`). Anything you add as an inline-block or positioned element should carry `textIndent: 0`, or it is pulled left over the label.
|
|
33
|
+
- Do not add rows, delete labels, or change widths, borders or line heights. If a value does not fit its space, ask before shrinking the type.
|
|
34
|
+
|
|
35
|
+
## Step 4 — Check it prints the same
|
|
36
|
+
|
|
37
|
+
1. `open-doc check <id>` — must stay clean, same page count as before.
|
|
38
|
+
2. Render the filled pages (`open-doc export <id> -f png` or MCP `render_page`) and compare with the blank form: same rows, same table rules, filled text sitting on its lines and inside its cells. The check does not see a row grown by 2 px or a tick outside its box — only the picture does.
|
|
39
|
+
|
|
40
|
+
## Hand off
|
|
41
|
+
|
|
42
|
+
Say what was filled and what was left empty on purpose (and why), and point at anything the user must still do by hand — a signature, a seal (用印), an attachment the form asks for.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fit-pages
|
|
3
|
+
description: Use this skill when a document must fit a page limit — "keep the proposal to 10 pages", "this has to be two pages", "cut it down to fit", "it runs one page over", "/fit-pages". It measures where the length is with `open-doc check --max-pages`, cuts by priority (slack and repetition first, substance last), re-checks after every pass, and reports exactly what was removed. Do NOT use for making a document longer, or for layout faults unrelated to length — that is `doc-authoring`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fit a document to a page limit
|
|
7
|
+
|
|
8
|
+
People hate this job because every cut moves a page break somewhere else. You can see the whole document and re-measure in seconds, so do it in small, measured passes.
|
|
9
|
+
|
|
10
|
+
## Step 1 — Measure
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
open-doc check <id> --max-pages <N>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
(MCP: `check_layout` with `maxPages`.) Over the limit, the report has a `page-budget` error and a **Where the pages go** list: every top-level section with the pages it fills (fractions count — `0.46` is under half a sheet), plus `toCut`, roughly how many pages of body must go once the last sheet's slack is counted, and `lastPageFill`. With `--json`, read `budget.sections` and `budget.toCut`.
|
|
17
|
+
|
|
18
|
+
Under the limit already? Say so and stop. Never pad a document to reach a limit.
|
|
19
|
+
|
|
20
|
+
## Step 2 — Agree what may not change
|
|
21
|
+
|
|
22
|
+
Before cutting, settle with the user (or from the brief) what is fixed: required sections of a call for proposals, legal wording, numbers, quotes, figures someone asked for. If you were not told, assume **facts, numbers, names, dates and headings required by the brief are fixed**; prose is not.
|
|
23
|
+
|
|
24
|
+
## Step 3 — Cut in this order, cheapest first
|
|
25
|
+
|
|
26
|
+
Stop as soon as the check passes.
|
|
27
|
+
|
|
28
|
+
1. **Layout slack** (no words lost): a nearly empty last sheet (`lastPageFill` under ~0.25) often goes by tightening a figure's height, dropping a stray `pageBreak`, or letting a short fixed page join the `flow()` section. Keep type at or above the `doc-authoring` minimums and margins as designed — shrinking the type scale to win a page is not a fix unless the user asks for it.
|
|
29
|
+
2. **Repetition**: a summary that restates the introduction, a conclusion that repeats every section, the same point in a table and in prose — keep one.
|
|
30
|
+
3. **Wordiness**: shorten long sentences, merge paragraphs that make one point, turn a run of parallel sentences into a list or a table (often shorter).
|
|
31
|
+
4. **Low-value detail** in the longest sections first (the budget list tells you which): background the reader already knows, second and third examples, hedges.
|
|
32
|
+
5. **Move, don't delete**: detail a reviewer may still want can go to an appendix only if appendices don't count toward the limit — ask.
|
|
33
|
+
6. **Substance** — whole paragraphs, findings, figures: only with the user's agreement. Propose the specific cuts and the pages each would save.
|
|
34
|
+
|
|
35
|
+
Work section by section, largest first, aiming each pass at roughly the section's share of `toCut`. Edit with the usual tools (`read_text`/`write_text`, or the source), never by rewriting the whole file.
|
|
36
|
+
|
|
37
|
+
## Step 4 — Re-check after every pass
|
|
38
|
+
|
|
39
|
+
Run the same `open-doc check <id> --max-pages <N>` after each section you cut. Page breaks move non-linearly: a two-line cut can free a page, a big one can free nothing if a figure was what pushed the break. Also fix any new layout fault the check reports (an orphan heading where a section now ends, an overflow).
|
|
40
|
+
|
|
41
|
+
## Step 5 — Hand off
|
|
42
|
+
|
|
43
|
+
Report:
|
|
44
|
+
|
|
45
|
+
- before → after page count, and the limit;
|
|
46
|
+
- what you cut, per section, in one line each (e.g. "Method: merged the two tool paragraphs, dropped the second example — 0.4 p");
|
|
47
|
+
- anything you left that a person must decide (the Step 3.6 list), with the pages each would save;
|
|
48
|
+
- that `open-doc check` is clean.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: import-document
|
|
3
|
+
description: Use this skill to bring an existing Word, PDF or Markdown document into open-doc — "import this .docx", "convert our old report PDF", "move this Word template into open-doc", "rebuild this PDF as a document", "/import-document". Word and Markdown go through `open-doc import`; a PDF is read and rebuilt as Markdown first. It then applies a theme, fixes what the conversion lost and runs the layout check until clean. Do NOT use for writing new content — that is `create-doc`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Import an existing document
|
|
7
|
+
|
|
8
|
+
## Word (`.docx`) and Markdown (`.md`)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
open-doc import <file> --lang zh-Hant-TW --theme <theme> --contents
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Over MCP: `import_docx` for Word, `import_markdown` for Markdown. Useful CLI flags: `--id`, `--title`, `--subtitle`, `--author`, `--page-size`, `--orientation`, `--no-cover`, `--contents` (`open-doc import --help`). The language is detected for Chinese, Japanese and Korean text when `--lang` is omitted — pass it anyway when you know it. Images are copied into `docs/<id>/assets/`. An old binary `.doc` is refused: ask for it saved as `.docx`.
|
|
15
|
+
|
|
16
|
+
The command prints what it could not carry over (for Word: text boxes, comments, tracked changes, anything without structure). Read that list — every item is something you must fix or report in Step 3.
|
|
17
|
+
|
|
18
|
+
## PDF
|
|
19
|
+
|
|
20
|
+
A PDF has no structure to import, only positioned text. Rebuild it:
|
|
21
|
+
|
|
22
|
+
1. Read the PDF. If you can read PDF files directly, do. Otherwise extract text with `pdftotext -layout <file.pdf> -` (poppler) when it is installed. A scanned PDF has no text layer: say so and ask for the original file or an OCR'd copy rather than retyping it from images.
|
|
23
|
+
2. Write the content as Markdown in a scratch file: headings by their visual rank (`#`, `##`, `###`), paragraphs re-joined across line and page breaks, lists, tables as GFM tables, footnotes as plain text. Drop running headers, footers and page numbers — open-doc makes its own.
|
|
24
|
+
3. Keep **every word and number exactly as in the PDF**. Do not summarise, correct or "improve" — this is a conversion. Note what you could not read.
|
|
25
|
+
4. Pictures: if you can extract them (`pdfimages -png`), reference them from the Markdown; otherwise leave an `<ImagePlaceholder>` with what the picture showed, and list it.
|
|
26
|
+
5. `open-doc import <scratch.md> …` as above, then delete the scratch file.
|
|
27
|
+
|
|
28
|
+
## Word keeps its look
|
|
29
|
+
|
|
30
|
+
A `.docx` imports with Word's page look by default: page size and margins, fonts, alignment, colours, table grid with merged cells, borders and shading, fill-in blanks. That is usually what the user wants — a form must still look like the form. So for a Word import, **skip the theme and restyle steps below** unless the user asks for a restyle; then re-import with `--plain` (MCP `plain: true`), which keeps only the structure, and continue with the steps below. Still run the check and the proofread. To fill an imported form in, use the `fill-form` skill.
|
|
31
|
+
|
|
32
|
+
## Changing a document imported from Word
|
|
33
|
+
|
|
34
|
+
A Word import is written in Word's idiom, not the house style: inline styles on every element, captions as plain `<p>` ("Figure 2: …"), a hand-made contents list. **Keep that idiom when you edit it** — the `doc-authoring` rules about `design` tokens, `<Figure>`/`<Ref>` and generated contents are for documents written in open-doc, and applying them here changes the look the user imported for. Then:
|
|
35
|
+
|
|
36
|
+
- **Find by the words printed on the page.** Large files are easiest searched (`rg`) for a phrase near the change.
|
|
37
|
+
- **Tables.** A Word table may be written as several `<table>`s with the same `data-od-source-table`, cut between merged rows; the second and later pieces have `marginTop: -1`. Rows inside `<Rows>` split across pages by themselves. To add a row, copy a neighbouring row of the same kind whole — its cells' borders, padding and paragraph styles — and change only the words; a new row needs no `data-od-source-row` (that only maps rows back to Word's). Word's grid can hold a hair-thin column (`<col style={{ width: 0.87 }} />`), so count cells by `colSpan`, not by position.
|
|
38
|
+
- **Totals are text.** Word tables hold no formulas: a sum, subtotal or total is a number typed in a cell. When you change a figure, recompute every cell that depends on it — the row's total, the subtotal, the grand total, and any summary table elsewhere that repeats it — and say which you changed.
|
|
39
|
+
- **Charts** are `<Chart data={[…]} … />` with the values inline: change `data` (and `labels`, which may still carry Excel's "Series1"). The axis follows the data.
|
|
40
|
+
- **Captions and contents lists** do not renumber or update themselves in an imported document; change them by hand, and tell the user a page number in a typed contents list may be stale.
|
|
41
|
+
- **Check nothing else moved:** export PNGs before and after (`open-doc export <id> -f png`) and compare — only the pages you changed should differ — and run `open-doc check <id>`.
|
|
42
|
+
|
|
43
|
+
## After a Markdown, PDF or `--plain` import
|
|
44
|
+
|
|
45
|
+
1. **Theme and design**: apply the house theme (`--theme`, or follow `themes/<id>.md` for the components it offers) instead of restyling by hand.
|
|
46
|
+
2. **Restore what conversion flattens**, following `doc-authoring`: a table of numbers that came from a spreadsheet becomes a `.csv` with `<DataTable>`; numbered figures and tables get `<Figure>` and `<Ref>`; a chart that arrived as a picture can stay a picture unless its data is available.
|
|
47
|
+
3. **Check until clean**:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
open-doc check <id>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Fix overflowing tables (fewer columns, `splittable`), oversized images, stranded headings.
|
|
54
|
+
4. **Proofread** with the `proofread` skill — converted documents often carry full-width digits, mixed punctuation and stray double spaces.
|
|
55
|
+
|
|
56
|
+
## Hand off
|
|
57
|
+
|
|
58
|
+
The new document id, what came across cleanly, everything that did not (the import's warnings, unreadable passages, placeholders standing in for pictures), and that the check is clean. Do not delete or modify the original file.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: proofread
|
|
3
|
+
description: Use this skill to proofread an open-doc document for consistency — "proofread this", "check the wording is consistent", "fix punctuation and spacing", "are the terms consistent", "check for simplified characters", "/proofread". It runs `open-doc proofread` for the mechanical faults (full/half-width characters, punctuation width next to CJK, Simplified characters in a Traditional document and vice versa, doubled words, inconsistent capitalisation of terms), then reads for what only judgement finds (the same thing called two names, inconsistent number and date styles), and fixes after the user agrees. Do NOT use for layout faults — that is `open-doc check`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Proofread a document
|
|
7
|
+
|
|
8
|
+
## Step 1 — Mechanical pass
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
open-doc proofread <id>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
(MCP: `proofread_document`.) Each finding has a page, a rule, the text it found and a `loc` (line:column) in the source. Rules:
|
|
15
|
+
|
|
16
|
+
| Rule | Finds |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `fullwidth-alnum` | Full-width letters and digits (`2026`, `AI`) |
|
|
19
|
+
| `punctuation-width` | Half-width `, ; : ? ! ( )` against Chinese or Japanese text, full-width punctuation in Latin text |
|
|
20
|
+
| `script-mix` | Simplified-only characters in a Traditional Chinese document, and the reverse |
|
|
21
|
+
| `repeated-word` | Accidental doubles (`the the`, `的的`) |
|
|
22
|
+
| `term-casing` | One term spelled with different capitals (`GitHub` / `Github`) |
|
|
23
|
+
|
|
24
|
+
They are warnings, not errors: a quotation, a product name or a code sample may be right as written. Decide each one; never fix blindly.
|
|
25
|
+
|
|
26
|
+
## Step 2 — Judgement pass
|
|
27
|
+
|
|
28
|
+
Read the document (`read_text`, or the rendered pages) for what rules cannot decide:
|
|
29
|
+
|
|
30
|
+
- **One name per thing.** The same concept, product or role named two ways (`用戶`/`使用者`, `sign in`/`log in`, an abbreviation used before it is introduced). Prefer the form used most often, or the brief's glossary.
|
|
31
|
+
- **Numbers, dates, units**: one style per document — thousands separators, `%` vs `percent`, `2026/11/22` vs `2026-11-22` vs `2026 年 11 月 22 日`, currency placement.
|
|
32
|
+
- **Spacing between Chinese and Latin text**: open-doc adds the gap automatically inside one run of text, so manual spaces are optional — but be consistent within the document, and don't fight the house style.
|
|
33
|
+
- **Headings and lists**: parallel phrasing within one list, consistent punctuation at item ends.
|
|
34
|
+
- Typos and wrong characters (`的`/`得`/`地`, `在`/`再`).
|
|
35
|
+
|
|
36
|
+
Don't rewrite for style, tone or length — that is not proofreading.
|
|
37
|
+
|
|
38
|
+
## Step 3 — Propose, then fix
|
|
39
|
+
|
|
40
|
+
Group what you found by kind and show it as a short table: where, what it says, what it should say. For a long list, ask once whether to apply all of a kind ("make every `Github` `GitHub`?"). Then edit the source in place — text runs only — and re-run `open-doc proofread <id>` and `open-doc check <id>` (changed text can move page breaks).
|
|
41
|
+
|
|
42
|
+
## Hand off
|
|
43
|
+
|
|
44
|
+
What you changed (counts per kind, plus anything notable), findings you deliberately left (and why — a quote, a product name), and choices a person should confirm (which of two terms to keep).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: refresh-report
|
|
3
|
+
description: Use this skill when a recurring document needs this period's numbers — "update the monthly report with October's data", "refresh the Q3 figures", "here is the new CSV, update the report", "roll the report forward", "/refresh-report". It swaps the data files, updates every table and chart that reads them, rewrites the prose that states or describes numbers (totals, growth rates, rankings, "up 12%"), leaves everything else alone, and hands back a list of every number that changed. Do NOT use for writing a new report — that is `create-doc`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Refresh a recurring report
|
|
7
|
+
|
|
8
|
+
A recurring report is mostly the same document with new numbers. The risk is not the tables — they read their data files — but the sentences: "revenue rose 12% to $4.2M", "the North region led again". Miss one and the report contradicts itself.
|
|
9
|
+
|
|
10
|
+
## Step 1 — Find the period's moving parts
|
|
11
|
+
|
|
12
|
+
1. Open `docs/<id>/index.tsx` and list every data import (`import sales from './data/sales.csv'`) and what reads it (`<DataTable rows>`, `<Chart rows>`, `<Sparkline>`, computed values).
|
|
13
|
+
2. Find every **number in prose and in hand-written tables** — anything not computed from a data file: amounts, percentages, counts, ranks, dates, the period name ("October", "Q3 2026", "this quarter"). Search the source (`search_document` over MCP, or grep for digits, `%`, currency signs and month names) and read each hit in context.
|
|
14
|
+
3. Ask for — or locate — the new data. **Never invent or estimate a number.** If a number in the prose cannot be derived from the new data you have, list it as unresolved instead of guessing.
|
|
15
|
+
|
|
16
|
+
## Step 2 — Replace the data
|
|
17
|
+
|
|
18
|
+
- Replace each data file with the new period's file, keeping the **same columns and header names**. If the columns changed, adapt the `columns` / `x` / `y` props that read them rather than renaming in the data.
|
|
19
|
+
- If the report keeps history (last period alongside this one), append the new rows instead of replacing — check how the old version did it.
|
|
20
|
+
|
|
21
|
+
## Step 3 — Update the prose, sentence by sentence
|
|
22
|
+
|
|
23
|
+
For each number found in Step 1.2:
|
|
24
|
+
|
|
25
|
+
- **Recompute it from the new data** (sum, average, growth vs. the previous period, share, rank). Show your arithmetic to yourself; round the way the document already rounds.
|
|
26
|
+
- **Update the words around it**: "rose" vs "fell", "highest" vs "second-highest", "again", "for the third month running", adjectives like "sharp" or "slight". A number that changed sign changes the sentence.
|
|
27
|
+
- Update the period name, report date, `meta.subtitle` and anything like "data as of".
|
|
28
|
+
- Leave sentences without numbers or period words untouched — this is a refresh, not a rewrite. If an analytical paragraph no longer holds (it explained a trend that reversed), flag it rather than rewriting the analysis yourself, unless the user asked you to.
|
|
29
|
+
|
|
30
|
+
Prefer making a repeated number computed once in the source (`const total = sum(sales, 'amount')`) and printed from there, so next period's refresh is smaller — but only where the document is already written that way or the user agrees.
|
|
31
|
+
|
|
32
|
+
## Step 4 — Check
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
open-doc check <id>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
New data changes lengths: a table that grew splits differently, a longer name widens a column. Fix what the check reports. Then read the rendered pages (`render_page`, or the preview) for the sections you touched.
|
|
39
|
+
|
|
40
|
+
## Step 5 — Hand off a change list
|
|
41
|
+
|
|
42
|
+
The user will be asked "where did this number come from?" — give them the answer. One line per changed number:
|
|
43
|
+
|
|
44
|
+
| Where | Before | After | From |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| p.2 summary | 12% growth | 8% growth | sales.csv: Oct vs Sep total |
|
|
47
|
+
|
|
48
|
+
Then list: data files replaced, sentences whose meaning changed (not just the number), numbers you could not derive (left as they were, marked), and that the check is clean.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sync-translation
|
|
3
|
+
description: Use this skill to create or update a translated copy of an open-doc document — "translate this report into English", "the Chinese version changed, update the English one", "sync the translations", "which translations are out of date", "/sync-translation". A translation is its own document with `meta.translationOf` naming the source and `meta.translatedAt` naming the source commit it matches; `open-doc translations` shows which ones fell behind and exactly what changed, so only those passages are retranslated. Do NOT use for writing a document in one language from scratch — that is `create-doc`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Keep translations in step with their source
|
|
7
|
+
|
|
8
|
+
## How a translation is linked
|
|
9
|
+
|
|
10
|
+
A translation is an ordinary document under `docs/`, usually `<source-id>-<lang>` (`annual-report-en`), whose meta says what it translates:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
export const meta = {
|
|
14
|
+
title: 'Annual Report 2026',
|
|
15
|
+
lang: 'en',
|
|
16
|
+
translationOf: 'annual-report', // the source document's id
|
|
17
|
+
translatedAt: '3f9c2e1…', // the source commit it matches — written by --mark
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Changes are traced through git, so the workspace must be a git repository and the source committed.
|
|
22
|
+
|
|
23
|
+
## See where things stand
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
open-doc translations # every translation and its state
|
|
27
|
+
open-doc translations <id> --diff # what changed in the source since <id> was synced
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
(MCP: `translation_status`, with `docId` and `diff: true`.) States: `current`, `stale` (lists the source's commits and changed files since), `unsynced` (never marked), `missing-source`, `unknown-revision`. The command exits non-zero when any translation is behind, so it can gate CI.
|
|
31
|
+
|
|
32
|
+
## A new translation
|
|
33
|
+
|
|
34
|
+
1. Commit the source if it has uncommitted changes (ask first if it is not your change).
|
|
35
|
+
2. Duplicate it (`duplicate_document`, or copy the folder) to `<id>-<lang>`; set `title`, `lang` (a BCP 47 tag — it changes line breaking and glyphs), `translationOf`, and `meta.labels` for the target language (`圖`/`表` ↔ `Figure`/`Table`).
|
|
36
|
+
3. Translate **text only**: headings, prose, captions, table headers, alt text. Keep structure, components, ids (`<Figure id>`, `<Ref to>`), styles, data files and numbers exactly as they are. Shared data files stay shared — import them from the source's folder rather than copying, so a data refresh reaches both.
|
|
37
|
+
4. Mark it: `open-doc translations --mark <id>-<lang>` (MCP: `mark_translated`).
|
|
38
|
+
|
|
39
|
+
## Catching up a stale translation
|
|
40
|
+
|
|
41
|
+
1. `open-doc translations <id> --diff`. Read the diff of the source's `index.tsx`: each hunk is a passage that changed.
|
|
42
|
+
2. Find the matching passage in the translation — same component, same position, same ids — and retranslate **only that passage**. Leave the rest of the translation alone: it may have been reviewed and polished by a person.
|
|
43
|
+
3. Structural changes (a section added, a figure moved, a table column added) are made the same way in the translation. Data file changes need nothing unless the translation copied the file.
|
|
44
|
+
4. Check the layout of the translation — languages differ in length, and English text is often 20–40% longer than Chinese, so pages can overflow or run over a page limit:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
open-doc check <id>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If the translation must match the source's page count, use the `fit-pages` skill.
|
|
51
|
+
5. Mark it current: `open-doc translations --mark <id>`. It records the source's last commit; it refuses while the source has uncommitted changes.
|
|
52
|
+
|
|
53
|
+
## Hand off
|
|
54
|
+
|
|
55
|
+
Per translation: which source changes you carried over (one line each), anything you could not translate confidently (names, terms with no settled translation — list them for a person), and that `open-doc check` is clean. Term choices should follow what the translation already uses; when the document has a glossary, use it.
|
package/src/agent/prompt.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function systemPromptAppend(askInstruction: string, opts: PromptOptions):
|
|
|
24
24
|
return [
|
|
25
25
|
'You are running inside the open-doc dev server, driven from its in-app agent panel in the browser rather than a terminal.',
|
|
26
26
|
`The workspace is an open-doc project: documents live under ${opts.docsDir}/<id>/index.tsx and the dev server hot-reloads every edit, so the user sees changes immediately.`,
|
|
27
|
-
'Use the project skills: create-doc to draft a new document, apply-comments to resolve @doc-comment markers left by the inspector, create-theme for themes, and doc-authoring as the technical reference before writing a page.',
|
|
27
|
+
'Use the project skills: create-doc to draft a new document, apply-comments to resolve @doc-comment markers left by the inspector, create-theme for themes, fit-pages to bring a document under a page limit, refresh-report to roll a recurring report onto new data, proofread for consistency, sync-translation for translated copies, import-document for Word, PDF or Markdown files, fill-form to fill in a form, and doc-authoring as the technical reference before writing a page.',
|
|
28
28
|
SECTION_BY_SECTION,
|
|
29
29
|
opts.canOpenBrowser === false
|
|
30
30
|
? 'Your sandbox cannot start a browser, so `open-doc check` and the page preview fail here: do not run them. open-doc runs the check itself once your turn ends and shows the user what it finds, so keep the file compiling after every write.'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export type CheckboxProps = {
|
|
4
|
+
/** Ticked. Toggle this to fill in a form. */
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
/** The mark a ticked box shows: a tick (default) or a cross, as ☑ and ☒. */
|
|
7
|
+
mark?: 'tick' | 'cross';
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A box on a form to tick: ☐, or ☑ when `checked`. Drawn rather than typed,
|
|
14
|
+
* so it keeps one size and look in any font — ☑ is missing from most CJK
|
|
15
|
+
* faces, and the fallback a browser picks draws it smaller than the □ beside
|
|
16
|
+
* it. It takes a character's width in the text it sits in.
|
|
17
|
+
*/
|
|
18
|
+
export function Checkbox({ checked = false, mark = 'tick', style, className }: CheckboxProps) {
|
|
19
|
+
return (
|
|
20
|
+
<span
|
|
21
|
+
role="img"
|
|
22
|
+
aria-label={checked ? (mark === 'cross' ? '☒' : '☑') : '☐'}
|
|
23
|
+
data-od-checkbox={checked ? 'checked' : ''}
|
|
24
|
+
className={className}
|
|
25
|
+
style={{
|
|
26
|
+
display: 'inline-block',
|
|
27
|
+
position: 'relative',
|
|
28
|
+
boxSizing: 'border-box',
|
|
29
|
+
width: '0.8em',
|
|
30
|
+
height: '0.8em',
|
|
31
|
+
margin: '0 0.1em',
|
|
32
|
+
border: '0.07em solid currentColor',
|
|
33
|
+
verticalAlign: '-0.1em',
|
|
34
|
+
textIndent: 0,
|
|
35
|
+
lineHeight: 1,
|
|
36
|
+
...style,
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
{checked && (
|
|
40
|
+
<svg
|
|
41
|
+
viewBox="0 0 10 10"
|
|
42
|
+
aria-hidden
|
|
43
|
+
style={{
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
left: 0,
|
|
46
|
+
top: 0,
|
|
47
|
+
width: '100%',
|
|
48
|
+
height: '100%',
|
|
49
|
+
overflow: 'visible',
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{mark === 'cross' ? (
|
|
53
|
+
<path d="M2 2 L8 8 M8 2 L2 8" stroke="currentColor" strokeWidth="1.2" fill="none" />
|
|
54
|
+
) : (
|
|
55
|
+
<path
|
|
56
|
+
d="M1.8 5.2 L4.1 7.6 L8.6 2.2"
|
|
57
|
+
stroke="currentColor"
|
|
58
|
+
strokeWidth="1.3"
|
|
59
|
+
fill="none"
|
|
60
|
+
strokeLinecap="round"
|
|
61
|
+
strokeLinejoin="round"
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
</svg>
|
|
65
|
+
)}
|
|
66
|
+
</span>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -144,14 +144,16 @@ export function DocSidebar({
|
|
|
144
144
|
)}
|
|
145
145
|
style={{
|
|
146
146
|
width: THUMB_WIDTH,
|
|
147
|
-
height:
|
|
147
|
+
height:
|
|
148
|
+
(entry.geometry ?? geometry).height *
|
|
149
|
+
(THUMB_WIDTH / (entry.geometry ?? geometry).width),
|
|
148
150
|
}}
|
|
149
151
|
>
|
|
150
152
|
<PageFrame
|
|
151
153
|
index={index}
|
|
152
154
|
total={pages.length}
|
|
153
|
-
geometry={geometry}
|
|
154
|
-
scale={THUMB_WIDTH / geometry.width}
|
|
155
|
+
geometry={entry.geometry ?? geometry}
|
|
156
|
+
scale={THUMB_WIDTH / (entry.geometry ?? geometry).width}
|
|
155
157
|
design={design}
|
|
156
158
|
lang={lang}
|
|
157
159
|
flat
|
|
@@ -2,6 +2,7 @@ import { type CSSProperties, createContext, type ReactNode, useContext } from 'r
|
|
|
2
2
|
import type { DesignSystem } from '../lib/design';
|
|
3
3
|
import type { BlockSlice, FlowSection } from '../lib/flow';
|
|
4
4
|
import type { ExtractedNote } from '../lib/footnotes';
|
|
5
|
+
import { type FlowPadding, paddingSides } from '../lib/sdk';
|
|
5
6
|
import { Footnotes } from './footnote';
|
|
6
7
|
|
|
7
8
|
export const FLOW_BLOCK_ATTR = 'data-od-flow-block';
|
|
@@ -31,12 +32,16 @@ export function useTableSlice(): TableSliceRange | null {
|
|
|
31
32
|
* than immediately under the last paragraph. The blocks stay inside one block
|
|
32
33
|
* container, so their margins collapse exactly as they did when measured.
|
|
33
34
|
*/
|
|
34
|
-
export function flowShellStyle(
|
|
35
|
+
export function flowShellStyle(
|
|
36
|
+
design: DesignSystem | undefined,
|
|
37
|
+
padding?: FlowPadding,
|
|
38
|
+
): CSSProperties {
|
|
39
|
+
const sides = paddingSides(padding, design?.margin ?? 76);
|
|
35
40
|
return {
|
|
36
41
|
width: '100%',
|
|
37
42
|
height: '100%',
|
|
38
43
|
boxSizing: 'border-box',
|
|
39
|
-
padding:
|
|
44
|
+
padding: `${sides.top}px ${sides.right}px ${sides.bottom}px ${sides.left}px`,
|
|
40
45
|
background: 'var(--od-bg)',
|
|
41
46
|
color: 'var(--od-text)',
|
|
42
47
|
fontFamily: 'var(--od-font-body)',
|
|
@@ -27,10 +27,12 @@ export function EditSaveCard({
|
|
|
27
27
|
textCount,
|
|
28
28
|
controlsRef,
|
|
29
29
|
onShownChange,
|
|
30
|
+
onUnsavedChange,
|
|
30
31
|
}: {
|
|
31
32
|
textCount: number;
|
|
32
33
|
controlsRef: MutableRefObject<InspectorControls | null>;
|
|
33
34
|
onShownChange: (shown: boolean) => void;
|
|
35
|
+
onUnsavedChange?: (unsaved: boolean) => void;
|
|
34
36
|
}) {
|
|
35
37
|
const design = useDesignPanelState();
|
|
36
38
|
const history = useHistory();
|
|
@@ -116,6 +118,7 @@ export function EditSaveCard({
|
|
|
116
118
|
|
|
117
119
|
const shown = count > 0 || committing || history.canUndo || history.canRedo || error !== null;
|
|
118
120
|
useEffect(() => onShownChange(shown), [shown, onShownChange]);
|
|
121
|
+
useEffect(() => onUnsavedChange?.(count > 0), [count, onUnsavedChange]);
|
|
119
122
|
|
|
120
123
|
return (
|
|
121
124
|
<SaveCard
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { diagnosePages, type LayoutFinding } from './diagnostics';
|
|
2
|
+
import { diagnosePages, headingOffsets, type LayoutFinding, pageFills } from './diagnostics';
|
|
3
3
|
import { buildDocDocx } from './export-docx';
|
|
4
4
|
import { buildDocHtmlBundle } from './export-html';
|
|
5
5
|
import { mountPrintCopy, type PrintCopy } from './export-pdf';
|
|
6
|
-
import { exposeOutline } from './outline';
|
|
6
|
+
import { collectOutline, exposeOutline, type OutlineEntry } from './outline';
|
|
7
|
+
import { type ProofreadFinding, proofreadRuns } from './proofread';
|
|
7
8
|
import { recordFileName, setRecordIndex } from './records';
|
|
8
|
-
import type
|
|
9
|
+
import { type DocModule, type PageGeometry, pageLang } from './sdk';
|
|
10
|
+
import { collectTextRuns } from './text-runs';
|
|
9
11
|
import type { ExpandedPage } from './use-doc-pages';
|
|
10
12
|
|
|
11
13
|
export const BRIDGE_KEY = '__openDoc';
|
|
@@ -23,7 +25,21 @@ export type BridgeStatus = {
|
|
|
23
25
|
record: number;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
export type BridgeReport = BridgeStatus & {
|
|
28
|
+
export type BridgeReport = BridgeStatus & {
|
|
29
|
+
findings: LayoutFinding[];
|
|
30
|
+
/** How full each sheet is, 0–1, footer band excluded. */
|
|
31
|
+
fills?: number[];
|
|
32
|
+
outline?: OutlineEntry[];
|
|
33
|
+
/** Heading id → how far down its sheet it starts, 0–1. */
|
|
34
|
+
offsets?: Record<string, number>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type BridgeProofread = BridgeStatus & {
|
|
38
|
+
lang: string;
|
|
39
|
+
findings: ProofreadFinding[];
|
|
40
|
+
/** Findings dropped by the per-page and per-rule caps. */
|
|
41
|
+
omitted: number;
|
|
42
|
+
};
|
|
27
43
|
|
|
28
44
|
export type BridgeBundle = { filename: string; mimeType: string; base64: string };
|
|
29
45
|
|
|
@@ -32,6 +48,8 @@ export type OpenDocBridge = {
|
|
|
32
48
|
status(): BridgeStatus;
|
|
33
49
|
/** Mounts the print copy and reads the layout back from it. */
|
|
34
50
|
diagnose(): Promise<BridgeReport>;
|
|
51
|
+
/** Mounts the print copy and proofreads the text printed on it. */
|
|
52
|
+
proofread(): Promise<BridgeProofread>;
|
|
35
53
|
/** Mounts the print copy and leaves it up, for `page.pdf()` or a screenshot. */
|
|
36
54
|
preparePrint(): Promise<{ pageCount: number }>;
|
|
37
55
|
releasePrint(): void;
|
|
@@ -112,11 +130,26 @@ export function useAgentBridge(input: BridgeInput): void {
|
|
|
112
130
|
return {
|
|
113
131
|
...snapshot,
|
|
114
132
|
findings: diagnosePages(copy.root, geometry, { oversized }),
|
|
133
|
+
fills: pageFills(copy.root, geometry),
|
|
134
|
+
outline: collectOutline(copy.root),
|
|
135
|
+
offsets: headingOffsets(copy.root, geometry),
|
|
115
136
|
};
|
|
116
137
|
} finally {
|
|
117
138
|
copy.dispose();
|
|
118
139
|
}
|
|
119
140
|
},
|
|
141
|
+
async proofread() {
|
|
142
|
+
const { docId, doc, pages } = latest.current;
|
|
143
|
+
const snapshot = status();
|
|
144
|
+
const lang = pageLang(doc?.meta);
|
|
145
|
+
if (!doc || pages.length === 0) return { ...snapshot, lang, findings: [], omitted: 0 };
|
|
146
|
+
const copy = await mountPrintCopy(doc, docId, pages);
|
|
147
|
+
try {
|
|
148
|
+
return { ...snapshot, lang, ...proofreadRuns(collectTextRuns(copy.root), lang) };
|
|
149
|
+
} finally {
|
|
150
|
+
copy.dispose();
|
|
151
|
+
}
|
|
152
|
+
},
|
|
120
153
|
async preparePrint() {
|
|
121
154
|
release();
|
|
122
155
|
const { docId, doc, pages } = latest.current;
|