@open-document/core 0.15.0 → 0.15.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-document/core",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Runtime and CLI for open-doc — write documents in docs/, we handle the pages, print layout, and export.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,6 +22,8 @@ Read the matching reference **before** using a primitive:
22
22
  | Tables, stat rows, `<Chart>`, `<Sparkline>`, `<Callout>` | rendering data or callouts | `references/tables-and-charts.md` |
23
23
  | Assets + `<ImagePlaceholder>` | importing images or leaving a placeholder | `references/assets.md` |
24
24
  | Footnotes, `<Figure>`, `<Ref>`, `<DataTable>`, `<Cite>`, `<Bibliography>`, `<CodeBlock>` | notes, figures, cross-references, citations, code blocks, or `.csv` | `references/long-form.md` |
25
+ | `<Diagram>` and `.mmd` diagrams | drawing a flow, architecture, or sequence | `references/diagrams.md` |
26
+ | Exports, `open-doc diff`, Word output, Inspect mode, Design panel | telling the user what they can do next, or an export / review step | `references/runtime.md` |
25
27
 
26
28
  ## Themes
27
29
 
@@ -145,59 +147,19 @@ Bare elements on the sheet start from a base drawn from the design, not from a b
145
147
 
146
148
  ## Footnotes, numbering, and data
147
149
 
148
- Four primitives resolve themselves from the rendered pages, the same way the
149
- contents list does. Read `references/long-form.md` before using any of them.
150
-
151
- - **`<Footnote>`** — numbered by position, printed at the foot of the page its
152
- marker landed on, and its height is taken out of that page's budget before the
153
- packer breaks. On a fixed page, add `<Footnotes />` where they should print.
154
- - **`<Figure caption id>`** — a numbered figure (or `kind="table"`), caption and
155
- content in one unbreakable block. `<ListOfFigures />` / `<ListOfTables />`
156
- build the lists.
157
- - **`<Ref to="id" />`** — "Figure 3", plus the page when the target is elsewhere.
158
- - **`<Cite id="…" source="…" />` & `<Bibliography />`** — academic/report citations numbered in order of first appearance (`[1]`), deduplicated by `id`, and listed by `<Bibliography />`.
159
- - **`<DataTable rows={…} splittable summaryRow>`** — a print-shaped table from an imported `.csv` (supports automatic multi-page splitting with repeated headers when `splittable` is set, plus `summaryRow`, `dataBar`, `'currency'`, and `'delta'` formats).
160
- - **`<CodeBlock code={…} lang="ts" lineNumbers highlightLines={[…]} caption="…" />`** — zero-dependency syntax-highlighted code block with optional line numbers, highlighted lines, and figure numbering when given `caption`.
161
- - **`<Callout type="note|tip|warning|danger" title="…">`** — semantic callout box styled with `--od-*` tokens.
162
- - **`<Diagram chart={…} caption>`** — an architecture, flow, or sequence drawing from an imported `.mmd`. Given a caption it numbers as a figure, like `<Figure>`.
163
- - **`<Chart data x y caption>` & `<Sparkline data={…} />`** — `bar`, `horizontal-bar`, `line`, `area`, or `pie` charts from rows, plus inline SVG `<Sparkline>` for tables and stat cards. See `references/tables-and-charts.md`.
150
+ These primitives resolve themselves from the rendered pages, the same way the
151
+ contents list does. Read the reference in brackets before using one.
152
+
153
+ - **`<Footnote>`** — numbered by position, printed at the foot of its page, its height taken out of that page's budget. On a fixed page, add `<Footnotes />` where they print. (`long-form.md`)
154
+ - **`<Figure caption id>`**, **`<Ref to="id" />`**, `<ListOfFigures />` / `<ListOfTables />` — numbered figures and tables, and references to them with the page. (`long-form.md`)
155
+ - **`<Cite id source />`** & **`<Bibliography />`** — citations numbered by first appearance. (`long-form.md`)
156
+ - **`<DataTable rows>`** from an imported `.csv`, splittable across pages; **`<CodeBlock code lang>`** with line numbers and highlights. (`long-form.md`)
157
+ - **`<Chart>`**, **`<Sparkline>`**, **`<Callout type>`** — charts from rows and semantic callouts. (`tables-and-charts.md`)
158
+ - **`<Diagram chart caption>`** — flowcharts and sequence diagrams written as `.mmd` text, compiled to SVG in the document's own ink. Never use an image of a diagram that can be written. (`diagrams.md`)
164
159
 
165
160
  `meta.labels` sets what they are called (`圖`, `表`) — the numbering itself is
166
161
  structural.
167
162
 
168
- ## Diagrams
169
-
170
- Write the drawing as Mermaid-flavoured text in `docs/<id>/<name>.mmd`, import
171
- it, and hand it to `<Diagram>`:
172
-
173
- ```mermaid
174
- %% docs/my-doc/architecture.mmd
175
- flowchart TD
176
- Client[使用者] -->|HTTPS| Gate{驗證}
177
- Gate -->|通過| App[應用伺服器]
178
- Gate -.->|拒絕| Deny([401])
179
- App --> DB[資料庫]
180
- ```
181
-
182
- ```tsx
183
- import { Diagram } from '@open-document/core';
184
- import architecture from './architecture.mmd';
185
-
186
- <Diagram chart={architecture} caption="請求路徑" width={420} />
187
- ```
188
-
189
- It is compiled to SVG at build time and drawn with the document's own theme
190
- variables, so it prints with the same ink and faces as the prose around it.
191
- Never reach for an image of a diagram when the diagram can be written.
192
-
193
- Supported:
194
- - `flowchart`/`graph` with `TD` or `LR`; nodes as `A[box]`, `A(round)`, `A([stadium])`, `A[(database)]`, `A{decision}`, `A((circle))`; links `-->`, `---`, `-.->`, `==>` with optional `|labels|`; chains `A --> B --> C`; `subgraph id [Title] ... end` clusters; `%%` comments. A link back to an earlier step is drawn round the side, clear of the steps in between.
195
- - `sequenceDiagram` with `participant Id as Label`, message arrows (`->>`, `-->>`, `->`, `-->`), and `Note over A,B: text` (or `Note left of` / `Note right of`).
196
- - Anything else in Mermaid's syntax is not supported, and a bad diagram fails the build with the line to fix.
197
-
198
- Keep `width` inside the text block: a drawing wider than the column is a layout
199
- fault, and `open-doc check` reports it as one.
200
-
201
163
  ## Table of contents
202
164
 
203
165
  ```tsx
@@ -356,19 +318,9 @@ A document is not a slide deck. Long-form copy is the point — but it still has
356
318
  - Cite numbers with their source and date inline (`Q3 billing export, 2026-08-01`) — a report that can't be traced gets ignored.
357
319
  - Don't invent data. If a number must come from the user, leave `<ImagePlaceholder>` for a chart or an explicit `TODO:` marker in the copy and tell them at hand-off.
358
320
 
359
- ## Runtime behavior you get for free
360
-
361
- - Home page lists every folder under `docs/` with a live thumbnail of page 1.
362
- - Document view: vertical scroll of real-size pages, a left rail that switches between page thumbnails, the outline, and the document's assets, zoom (actual size / fit width / fit page), page counter, and fullscreen reading (`F`).
363
- - Export PDF (print pipeline, correct `@page` size) and export HTML (self-contained, printable).
364
- - Hot reload: edit `index.tsx` and the pages update live.
365
- - **Assets panel** (`/assets` in the dev UI): upload, rename, and delete files in the global `assets/` folder or any document's `assets/` folder, with an "unused" badge and a copy-ready import line. Files you reference in source are what it scans, so an import you write by hand shows up there immediately.
366
- - **Inspect mode** (the "Inspect" button, dev only): click any element on a page to edit its text in place — the change is written straight back into `docs/<id>/index.tsx` — or leave a note for the agent, which is stored as a `@doc-comment` marker and processed by the `apply-comments` skill.
367
- - **Download menu** — PDF (true page size) and self-contained HTML.
368
- - **Headless render** — `open-doc export <id> --format pdf|html|png|docx` produces the same output from a script, and `open-doc check <id>` reports layout faults. Both drive the real viewer in a headless browser, so what they produce is what the Download menu produces. A PDF exported this way also carries the outline as bookmarks and is tagged for screen readers — the same headings the sidebar and `<TableOfContents />` list, so a heading marked `data-od-outline="skip"` stays out and `data-od-heading` sets the bookmark's text. (The Download menu prints through the browser's dialog, which writes no bookmarks.)
369
- - **What changed** — `open-doc diff <id> [--since <rev>]` (MCP: `diff_document`) renders the document as it is and as it was at a git revision (default `HEAD`), pairs the pages by content, and lists each page as same, changed, added or removed, with the lines of text that moved. It also writes `out/<id>-diff.html`, a self-contained before/after report with the changed regions outlined — hand that to a reviewer. Run it before handing back an edit, so your summary of what changed is what actually changed on the page.
370
- - **Word (DOCX)** — for review that runs in Word. It carries structure, not page breaks: headings become Word heading styles, `<TableOfContents />` a TOC field, `<Footnote>` real footnotes, a `flow()` header and footer a Word header and footer with page-number fields, and the theme's CJK font the East Asian font. Write headings as real `h1`–`h3` and tables as `<table>`/`<DataTable>` so they arrive as structure; anything drawn with boxes (a chart made of `div`s) arrives as a picture, and absolutely positioned layouts on fixed pages flow as plain paragraphs.
371
- - **Design panel** (the "Design" button in the document view, dev only): live-tweaks the `design` const — palette, fonts, type scale, margin, leading, radius — previewing on the real pages and writing the values back into `docs/<id>/index.tsx` on save.
321
+ ## Writing for the viewer's editors
322
+
323
+ The viewer, exports, `open-doc check` / `export` / `diff`, the Inspect mode and the Design panel come with the framework — `references/runtime.md` lists what each does. Two of them edit your source, so write it in the shape they can read.
372
324
 
373
325
  ### Writing for the inspector
374
326
 
@@ -0,0 +1,32 @@
1
+ # Diagrams
2
+
3
+ Write the drawing as Mermaid-flavoured text in `docs/<id>/<name>.mmd`, import
4
+ it, and hand it to `<Diagram>`:
5
+
6
+ ```mermaid
7
+ %% docs/my-doc/architecture.mmd
8
+ flowchart TD
9
+ Client[使用者] -->|HTTPS| Gate{驗證}
10
+ Gate -->|通過| App[應用伺服器]
11
+ Gate -.->|拒絕| Deny([401])
12
+ App --> DB[資料庫]
13
+ ```
14
+
15
+ ```tsx
16
+ import { Diagram } from '@open-document/core';
17
+ import architecture from './architecture.mmd';
18
+
19
+ <Diagram chart={architecture} caption="請求路徑" width={420} />
20
+ ```
21
+
22
+ It is compiled to SVG at build time and drawn with the document's own theme
23
+ variables, so it prints with the same ink and faces as the prose around it.
24
+ Never reach for an image of a diagram when the diagram can be written.
25
+
26
+ Supported:
27
+ - `flowchart`/`graph` with `TD` or `LR`; nodes as `A[box]`, `A(round)`, `A([stadium])`, `A[(database)]`, `A{decision}`, `A((circle))`; links `-->`, `---`, `-.->`, `==>` with optional `|labels|`; chains `A --> B --> C`; `subgraph id [Title] ... end` clusters; `%%` comments. A link back to an earlier step is drawn round the side, clear of the steps in between.
28
+ - `sequenceDiagram` with `participant Id as Label`, message arrows (`->>`, `-->>`, `->`, `-->`), and `Note over A,B: text` (or `Note left of` / `Note right of`).
29
+ - Anything else in Mermaid's syntax is not supported, and a bad diagram fails the build with the line to fix.
30
+
31
+ Keep `width` inside the text block: a drawing wider than the column is a layout
32
+ fault, and `open-doc check` reports it as one.
@@ -0,0 +1,15 @@
1
+ # Runtime behavior you get for free
2
+
3
+ What the framework and its viewer already do, so a document never re-implements it.
4
+
5
+ - Home page lists every folder under `docs/` with a live thumbnail of page 1.
6
+ - Document view: vertical scroll of real-size pages, a left rail that switches between page thumbnails, the outline, and the document's assets, zoom (actual size / fit width / fit page), page counter, and fullscreen reading (`F`).
7
+ - Export PDF (print pipeline, correct `@page` size) and export HTML (self-contained, printable).
8
+ - Hot reload: edit `index.tsx` and the pages update live.
9
+ - **Assets panel** (`/assets` in the dev UI): upload, rename, and delete files in the global `assets/` folder or any document's `assets/` folder, with an "unused" badge and a copy-ready import line. Files you reference in source are what it scans, so an import you write by hand shows up there immediately.
10
+ - **Inspect mode** (the "Inspect" button, dev only): click any element on a page to edit its text in place — the change is written straight back into `docs/<id>/index.tsx` — or leave a note for the agent, which is stored as a `@doc-comment` marker and processed by the `apply-comments` skill.
11
+ - **Download menu** — PDF (true page size) and self-contained HTML.
12
+ - **Headless render** — `open-doc export <id> --format pdf|html|png|docx` produces the same output from a script, and `open-doc check <id>` reports layout faults. Both drive the real viewer in a headless browser, so what they produce is what the Download menu produces. A PDF exported this way also carries the outline as bookmarks and is tagged for screen readers — the same headings the sidebar and `<TableOfContents />` list, so a heading marked `data-od-outline="skip"` stays out and `data-od-heading` sets the bookmark's text. (The Download menu prints through the browser's dialog, which writes no bookmarks.)
13
+ - **What changed** — `open-doc diff <id> [--since <rev>]` (MCP: `diff_document`) renders the document as it is and as it was at a git revision (default `HEAD`), pairs the pages by content, and lists each page as same, changed, added or removed, with the lines of text that moved. It also writes `out/<id>-diff.html`, a self-contained before/after report with the changed regions outlined — hand that to a reviewer. Run it before handing back an edit, so your summary of what changed is what actually changed on the page.
14
+ - **Word (DOCX)** — for review that runs in Word. It carries structure, not page breaks: headings become Word heading styles, `<TableOfContents />` a TOC field, `<Footnote>` real footnotes, a `flow()` header and footer a Word header and footer with page-number fields, and the theme's CJK font the East Asian font. Write headings as real `h1`–`h3` and tables as `<table>`/`<DataTable>` so they arrive as structure; anything drawn with boxes (a chart made of `div`s) arrives as a picture, and absolutely positioned layouts on fixed pages flow as plain paragraphs.
15
+ - **Design panel** (the "Design" button in the document view, dev only): live-tweaks the `design` const — palette, fonts, type scale, margin, leading, radius — previewing on the real pages and writing the values back into `docs/<id>/index.tsx` on save.