@open-document/core 0.8.0 → 0.9.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/dist/{build-CFL7nhz0.js → build-B0GJXy8I.js} +1 -1
- package/dist/{check-pEQh4jJE.js → check-CuDIWsPT.js} +3 -3
- package/dist/cli/bin.js +8 -12
- package/dist/{config-4nz5NnxW.js → config-CAZ7Z_va.js} +1 -1
- package/dist/{context-BH8C-dSW.js → context-PWAh9qbf.js} +1 -1
- package/dist/{dev-BCSUczXW.js → dev-CYqppXDI.js} +1 -1
- package/dist/{diagram-xlVDekYk.js → diagram-CCaUUnRe.js} +85 -12
- package/dist/{export-BQ-GvMsb.js → export-1JtO2OMC.js} +5 -8
- package/dist/{import-Daat3L2J.js → import-CsrdBOZ8.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -2
- package/dist/ops/index.d.ts +2 -3
- package/dist/ops/index.js +4 -4
- package/dist/{ops-DQfckiyp.js → ops-B2y9BMpk.js} +5 -4
- package/dist/{preview-CwCrw-i3.js → preview-DW3PM-JV.js} +1 -1
- package/dist/{sdk-C9nl30dW.d.ts → sdk-BqU6mwD_.d.ts} +8 -1
- package/dist/{sdk-DhcqZdAw.js → sdk-CqNZzbkz.js} +12 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/skills/doc-authoring/SKILL.md +6 -3
- package/src/app/components/footnote.tsx +6 -1
- package/src/app/components/numbering.tsx +1 -0
- package/src/app/lib/agent-bridge.ts +13 -0
- package/src/app/lib/docx/from-dom.ts +889 -0
- package/src/app/lib/docx/ooxml.test.ts +299 -0
- package/src/app/lib/docx/ooxml.ts +755 -0
- package/src/app/lib/export-docx.ts +225 -0
- package/src/app/lib/export-dom.ts +23 -3
- package/src/app/lib/export-image.ts +47 -2
- package/src/app/lib/export-pdf.ts +6 -0
- package/src/app/lib/flow-measure.ts +3 -0
- package/src/app/lib/sdk.ts +8 -0
- package/src/app/lib/svg-ids.ts +37 -0
- package/src/app/routes/doc.tsx +12 -1
- package/src/app/styles.css +20 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as listDocIds } from "./config-
|
|
2
|
-
import { d as closeRenderSession, u as checkLayout } from "./ops-
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { _ as listDocIds } from "./config-CAZ7Z_va.js";
|
|
2
|
+
import { d as closeRenderSession, u as checkLayout } from "./ops-B2y9BMpk.js";
|
|
3
|
+
import { t as cliContext } from "./context-PWAh9qbf.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/check.ts
|
|
6
6
|
function line(finding) {
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { i as ORIENTATIONS, o as PAGE_SIZE_NAMES, r as EXPORT_FORMATS } from "../sdk-CqNZzbkz.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import * as readline from "node:readline/promises";
|
|
@@ -165,31 +165,27 @@ async function run(argv) {
|
|
|
165
165
|
program.name("open-doc").description("Author documents — we handle the Vite/React stack, pagination, and export.").version(version, "-v, --version", "print version").helpOption("-h, --help", "show help").showHelpAfterError(chalk.dim("(run `open-doc --help` for usage)"));
|
|
166
166
|
program.command("dev").description("Start the dev server").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").option("--no-skills-check", "skip the built-in skills drift check").option("--mcp", "serve an MCP endpoint at /mcp (requires @open-document/mcp)").action(async (flags) => {
|
|
167
167
|
if (flags.skillsCheck !== false) await runSkillsDriftCheck(resolveBuiltinSkillsDir());
|
|
168
|
-
const { dev } = await import("../dev-
|
|
168
|
+
const { dev } = await import("../dev-CYqppXDI.js");
|
|
169
169
|
await dev(flags);
|
|
170
170
|
});
|
|
171
171
|
program.command("build").description("Build a static site").option("--out-dir <dir>", "output directory (defaults to `dist`)").action(async (flags) => {
|
|
172
|
-
const { build } = await import("../build-
|
|
172
|
+
const { build } = await import("../build-B0GJXy8I.js");
|
|
173
173
|
await build(flags);
|
|
174
174
|
});
|
|
175
175
|
program.command("preview").description("Preview the production build").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).addOption(new Option("--host [host]", "expose on the network (optional host)")).option("--open", "open the browser on start").action(async (flags) => {
|
|
176
|
-
const { preview } = await import("../preview-
|
|
176
|
+
const { preview } = await import("../preview-DW3PM-JV.js");
|
|
177
177
|
await preview(flags);
|
|
178
178
|
});
|
|
179
|
-
program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, or
|
|
180
|
-
"
|
|
181
|
-
"html",
|
|
182
|
-
"png"
|
|
183
|
-
])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
|
|
184
|
-
const { exportDocs } = await import("../export-BQ-GvMsb.js");
|
|
179
|
+
program.command("export [docIds...]").description("Render documents headlessly to PDF, HTML, PNG, or DOCX").addOption(new Option("-f, --format <format>", "output format").choices([...EXPORT_FORMATS])).option("-o, --out-dir <dir>", "directory to write into (defaults to `out`)").option("--all", "export every document under docs/").action(async (docIds, flags) => {
|
|
180
|
+
const { exportDocs } = await import("../export-1JtO2OMC.js");
|
|
185
181
|
await exportDocs(docIds, flags);
|
|
186
182
|
});
|
|
187
183
|
program.command("check [docIds...]").description("Report layout faults — clipped content, blank sheets, stranded headings").option("--json", "print the full report as JSON").action(async (docIds, flags) => {
|
|
188
|
-
const { checkDocs } = await import("../check-
|
|
184
|
+
const { checkDocs } = await import("../check-CuDIWsPT.js");
|
|
189
185
|
await checkDocs(docIds, flags);
|
|
190
186
|
});
|
|
191
187
|
program.command("import <file>").description("Turn a Markdown file into a document under docs/").option("--id <id>", "document id (defaults to a slug of the title)").option("--title <title>", "override the title").option("--subtitle <subtitle>", "subtitle, also used as the cover eyebrow").option("--author <author>", "author line on the cover").option("--theme <theme>", "theme id to back-link from meta.theme").addOption(new Option("--page-size <size>", "page size").choices(PAGE_SIZE_NAMES)).addOption(new Option("--orientation <orientation>", "page orientation").choices(ORIENTATIONS)).option("--no-cover", "skip the title page").option("--contents", "add a self-filling contents page").action(async (file, flags) => {
|
|
192
|
-
const { importDoc } = await import("../import-
|
|
188
|
+
const { importDoc } = await import("../import-CsrdBOZ8.js");
|
|
193
189
|
await importDoc(file, flags);
|
|
194
190
|
});
|
|
195
191
|
program.command("sync:skills").description("Sync built-in skills from @open-document/core into this workspace").option("--dry-run", "show what would change without writing").action(async (flags) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defaultDesign, n as DiagramSyntaxError, r as parseDelimited, t as compileDiagram } from "./diagram-
|
|
1
|
+
import { a as defaultDesign, n as DiagramSyntaxError, r as parseDelimited, t as compileDiagram } from "./diagram-CCaUUnRe.js";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as readCoreVersion } from "./cli/bin.js";
|
|
2
|
-
import { A as loadUserConfig, O as makeContext } from "./config-
|
|
2
|
+
import { A as loadUserConfig, O as makeContext } from "./config-CAZ7Z_va.js";
|
|
3
3
|
//#region src/cli/context.ts
|
|
4
4
|
/** The same context the dev API and the MCP server run on, for commands that call `ops/`. */
|
|
5
5
|
async function cliContext(userCwd = process.cwd()) {
|
|
@@ -196,6 +196,7 @@ function sizeOf(node, lines, fontSize) {
|
|
|
196
196
|
const textHeight = lines.length * fontSize * LINE_HEIGHT$1;
|
|
197
197
|
let width = Math.max(MIN_WIDTH, textWidth + 28);
|
|
198
198
|
let height = textHeight + 20;
|
|
199
|
+
if (node.shape === "cylinder") height += 12;
|
|
199
200
|
if (node.shape === "diamond") {
|
|
200
201
|
width = textWidth * 2 + 28;
|
|
201
202
|
height = textHeight * 2 + 20;
|
|
@@ -359,6 +360,66 @@ function placeLabels(edges, fontSize) {
|
|
|
359
360
|
edge.labelAt = chosen;
|
|
360
361
|
}
|
|
361
362
|
}
|
|
363
|
+
const CHANNEL_GAP = 18;
|
|
364
|
+
/**
|
|
365
|
+
* A link that runs against the flow — a feedback arrow back to an earlier
|
|
366
|
+
* step. Drawn straight, it would cut through every box between the two ends
|
|
367
|
+
* and park its label on one of them; it goes round the side instead (the
|
|
368
|
+
* right in a column, underneath in a row), clear of everything it passes, and
|
|
369
|
+
* each such link a step further out than the last.
|
|
370
|
+
*/
|
|
371
|
+
function routeBack(from, to, nodes, horizontal, lane) {
|
|
372
|
+
if (horizontal) {
|
|
373
|
+
const left = Math.min(from.x, to.x);
|
|
374
|
+
const right = Math.max(from.x + from.width, to.x + to.width);
|
|
375
|
+
const passed = nodes.filter((n) => n.x < right && n.x + n.width > left);
|
|
376
|
+
const channel = Math.max(...passed.map((n) => n.y + n.height)) + CHANNEL_GAP * (lane + 1);
|
|
377
|
+
const start = {
|
|
378
|
+
x: from.x + from.width / 2,
|
|
379
|
+
y: from.y + from.height
|
|
380
|
+
};
|
|
381
|
+
const end = {
|
|
382
|
+
x: to.x + to.width / 2,
|
|
383
|
+
y: to.y + to.height
|
|
384
|
+
};
|
|
385
|
+
return [
|
|
386
|
+
start,
|
|
387
|
+
{
|
|
388
|
+
x: start.x,
|
|
389
|
+
y: channel
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
x: end.x,
|
|
393
|
+
y: channel
|
|
394
|
+
},
|
|
395
|
+
end
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
const top = Math.min(from.y, to.y);
|
|
399
|
+
const bottom = Math.max(from.y + from.height, to.y + to.height);
|
|
400
|
+
const passed = nodes.filter((n) => n.y < bottom && n.y + n.height > top);
|
|
401
|
+
const channel = Math.max(...passed.map((n) => n.x + n.width)) + CHANNEL_GAP * (lane + 1);
|
|
402
|
+
const start = {
|
|
403
|
+
x: from.x + from.width,
|
|
404
|
+
y: from.y + from.height / 2
|
|
405
|
+
};
|
|
406
|
+
const end = {
|
|
407
|
+
x: to.x + to.width,
|
|
408
|
+
y: to.y + to.height / 2
|
|
409
|
+
};
|
|
410
|
+
return [
|
|
411
|
+
start,
|
|
412
|
+
{
|
|
413
|
+
x: channel,
|
|
414
|
+
y: start.y
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
x: channel,
|
|
418
|
+
y: end.y
|
|
419
|
+
},
|
|
420
|
+
end
|
|
421
|
+
];
|
|
422
|
+
}
|
|
362
423
|
/** Straight where the two boxes line up, a single elbow where they do not. */
|
|
363
424
|
function route(from, to, horizontal) {
|
|
364
425
|
const fromCentre = {
|
|
@@ -480,11 +541,12 @@ function layoutDiagram(diagram, options = {}) {
|
|
|
480
541
|
});
|
|
481
542
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
482
543
|
const edges = [];
|
|
544
|
+
let lanes = 0;
|
|
483
545
|
for (const edge of diagram.edges) {
|
|
484
546
|
const from = byId.get(edge.from);
|
|
485
547
|
const to = byId.get(edge.to);
|
|
486
548
|
if (!from || !to) continue;
|
|
487
|
-
const points = route(from, to, horizontal);
|
|
549
|
+
const points = (rankOf.get(edge.to) ?? 0) < (rankOf.get(edge.from) ?? 0) ? routeBack(from, to, nodes, horizontal, lanes++) : route(from, to, horizontal);
|
|
488
550
|
edges.push({
|
|
489
551
|
...edge,
|
|
490
552
|
points,
|
|
@@ -492,8 +554,13 @@ function layoutDiagram(diagram, options = {}) {
|
|
|
492
554
|
});
|
|
493
555
|
}
|
|
494
556
|
placeLabels(edges, opts.fontSize);
|
|
495
|
-
const
|
|
496
|
-
const
|
|
557
|
+
const labelSize = opts.fontSize * .85;
|
|
558
|
+
const reach = edges.flatMap((edge) => [...edge.points, ...edge.labelAt && edge.label ? [{
|
|
559
|
+
x: edge.labelAt.x + (measureText(edge.label, labelSize) + 10) / 2,
|
|
560
|
+
y: edge.labelAt.y + labelSize * .8
|
|
561
|
+
}] : []]);
|
|
562
|
+
const width = Math.max(...nodes.map((n) => n.x + n.width), ...reach.map((p) => p.x)) + opts.padding;
|
|
563
|
+
const height = Math.max(...nodes.map((n) => n.y + n.height), ...reach.map((p) => p.y)) + opts.padding;
|
|
497
564
|
return {
|
|
498
565
|
direction: diagram.direction,
|
|
499
566
|
nodes,
|
|
@@ -513,14 +580,15 @@ var DiagramSyntaxError = class extends Error {
|
|
|
513
580
|
}
|
|
514
581
|
};
|
|
515
582
|
const HEADER_RE = /^(?:flowchart|graph)(?:\s+(TB|TD|BT|LR|RL))?$/i;
|
|
516
|
-
/** `A[Label]`, `A(Label)`, `A([Label])`, `A{Label}`, `A((Label))`, or a bare `A`. */
|
|
517
|
-
const NODE_RE = /^([A-Za-z0-9_.-]+)(?:(\(\(|\(\[|\[|\(|\{)([\s\S]*?)(\)\)|\]\)|\]|\)|\}))?$/;
|
|
583
|
+
/** `A[Label]`, `A(Label)`, `A([Label])`, `A[(Label)]`, `A{Label}`, `A((Label))`, or a bare `A`. */
|
|
584
|
+
const NODE_RE = /^([A-Za-z0-9_.-]+)(?:(\(\(|\(\[|\[\(|\[|\(|\{)([\s\S]*?)(\)\)|\]\)|\)\]|\]|\)|\}))?$/;
|
|
518
585
|
const SHAPES = {
|
|
519
586
|
"[": "rect",
|
|
520
587
|
"(": "round",
|
|
521
588
|
"([": "stadium",
|
|
522
589
|
"{": "diamond",
|
|
523
|
-
"((": "circle"
|
|
590
|
+
"((": "circle",
|
|
591
|
+
"[(": "cylinder"
|
|
524
592
|
};
|
|
525
593
|
/**
|
|
526
594
|
* Links, longest first: `-.->` must be tried before `-->` or the dash prefix
|
|
@@ -695,11 +763,12 @@ function escapeXml(text) {
|
|
|
695
763
|
* Every colour and face is a `--od-*` variable rather than a literal, which is
|
|
696
764
|
* the entire reason this renderer exists: the drawing inherits the document's
|
|
697
765
|
* theme, in the viewer and in the PDF, instead of arriving with a palette of
|
|
698
|
-
* its own.
|
|
766
|
+
* its own. Each carries a fallback, since a document without a `design` sets
|
|
767
|
+
* none of them and an unset `fill` paints the shapes solid black.
|
|
699
768
|
*/
|
|
700
769
|
function shapePath(node) {
|
|
701
770
|
const { x, y, width: w, height: h } = node;
|
|
702
|
-
const common = "fill=\"var(--od-bg)\" stroke=\"var(--od-text)\" stroke-width=\"1.25\"";
|
|
771
|
+
const common = "fill=\"var(--od-bg, #ffffff)\" stroke=\"var(--od-text, #16181d)\" stroke-width=\"1.25\"";
|
|
703
772
|
switch (node.shape) {
|
|
704
773
|
case "diamond": return `<polygon points="${[
|
|
705
774
|
`${x + w / 2},${y}`,
|
|
@@ -709,6 +778,10 @@ function shapePath(node) {
|
|
|
709
778
|
].join(" ")}" ${common} />`;
|
|
710
779
|
case "circle": return `<ellipse cx="${x + w / 2}" cy="${y + h / 2}" rx="${w / 2}" ry="${h / 2}" ${common} />`;
|
|
711
780
|
case "stadium": return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${h / 2}" ry="${h / 2}" ${common} />`;
|
|
781
|
+
case "cylinder": {
|
|
782
|
+
const ry = Math.min(8, h / 6);
|
|
783
|
+
return `<path d="${`M${x},${y + ry} A${w / 2},${ry} 0 0 1 ${x + w},${y + ry} L${x + w},${y + h - ry} A${w / 2},${ry} 0 0 1 ${x},${y + h - ry} Z`}" ${common} /><path d="${`M${x},${y + ry} A${w / 2},${ry} 0 0 0 ${x + w},${y + ry}`}" fill="none" stroke="var(--od-text, #16181d)" stroke-width="1.25" />`;
|
|
784
|
+
}
|
|
712
785
|
case "round": return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="10" ry="10" ${common} />`;
|
|
713
786
|
default: return `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="var(--od-radius, 2)" ${common} />`;
|
|
714
787
|
}
|
|
@@ -717,19 +790,19 @@ function nodeText(node, fontSize) {
|
|
|
717
790
|
const firstBaseline = node.y + node.height / 2 - node.lines.length * fontSize * LINE_HEIGHT / 2 + fontSize * .98;
|
|
718
791
|
return node.lines.map((line, i) => {
|
|
719
792
|
const y = firstBaseline + i * fontSize * LINE_HEIGHT;
|
|
720
|
-
return `<text x="${node.x + node.width / 2}" y="${y}" text-anchor="middle" font-family="var(--od-font-body)" font-size="${fontSize}" fill="var(--od-text)">${escapeXml(line)}</text>`;
|
|
793
|
+
return `<text x="${node.x + node.width / 2}" y="${y}" text-anchor="middle" font-family="var(--od-font-body, sans-serif)" font-size="${fontSize}" fill="var(--od-text, #16181d)">${escapeXml(line)}</text>`;
|
|
721
794
|
}).join("");
|
|
722
795
|
}
|
|
723
796
|
function edgePath(edge, marker) {
|
|
724
797
|
const d = edge.points.map((point, i) => `${i === 0 ? "M" : "L"}${round(point.x)},${round(point.y)}`).join(" ");
|
|
725
798
|
const dash = edge.style === "dashed" ? " stroke-dasharray=\"5 4\"" : "";
|
|
726
|
-
return `<path d="${d}" fill="none" stroke="var(--od-text)" stroke-width="${edge.style === "thick" ? 2.25 : 1.25}"${dash} stroke-linejoin="round"${edge.arrow ? ` marker-end="url(#${marker})"` : ""} />`;
|
|
799
|
+
return `<path d="${d}" fill="none" stroke="var(--od-text, #16181d)" stroke-width="${edge.style === "thick" ? 2.25 : 1.25}"${dash} stroke-linejoin="round"${edge.arrow ? ` marker-end="url(#${marker})"` : ""} />`;
|
|
727
800
|
}
|
|
728
801
|
function edgeLabel(edge, fontSize) {
|
|
729
802
|
if (!edge.labelAt || !edge.label) return "";
|
|
730
803
|
const size = fontSize * .85;
|
|
731
804
|
const width = measureText(edge.label, size) + 10;
|
|
732
|
-
return `<rect x="${round(edge.labelAt.x - width / 2)}" y="${round(edge.labelAt.y - size * .8)}" width="${round(width)}" height="${round(size * 1.6)}" fill="var(--od-bg)" /><text x="${round(edge.labelAt.x)}" y="${round(edge.labelAt.y + size * .34)}" text-anchor="middle" font-family="var(--od-font-body)" font-size="${size}" fill="var(--od-muted)">${escapeXml(edge.label)}</text>`;
|
|
805
|
+
return `<rect x="${round(edge.labelAt.x - width / 2)}" y="${round(edge.labelAt.y - size * .8)}" width="${round(width)}" height="${round(size * 1.6)}" fill="var(--od-bg, #ffffff)" /><text x="${round(edge.labelAt.x)}" y="${round(edge.labelAt.y + size * .34)}" text-anchor="middle" font-family="var(--od-font-body, sans-serif)" font-size="${size}" fill="var(--od-muted, #6b7280)">${escapeXml(edge.label)}</text>`;
|
|
733
806
|
}
|
|
734
807
|
function round(value) {
|
|
735
808
|
return Math.round(value * 100) / 100;
|
|
@@ -737,7 +810,7 @@ function round(value) {
|
|
|
737
810
|
function renderDiagram(diagram, options = {}) {
|
|
738
811
|
const fontSize = options.fontSize ?? 13;
|
|
739
812
|
const marker = `od-arrow${options.idSuffix ? `-${options.idSuffix}` : ""}`;
|
|
740
|
-
const defs = `<defs><marker id="${marker}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,1 L10,5 L0,9 z" fill="var(--od-text)" /></marker></defs>`;
|
|
813
|
+
const defs = `<defs><marker id="${marker}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,1 L10,5 L0,9 z" fill="var(--od-text, #16181d)" /></marker></defs>`;
|
|
741
814
|
const body = [
|
|
742
815
|
...diagram.edges.map((edge) => edgePath(edge, marker)),
|
|
743
816
|
...diagram.nodes.map((node) => shapePath(node)),
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { r as EXPORT_FORMATS } from "./sdk-CqNZzbkz.js";
|
|
2
|
+
import { _ as listDocIds } from "./config-CAZ7Z_va.js";
|
|
3
|
+
import { d as closeRenderSession, f as exportDocument } from "./ops-B2y9BMpk.js";
|
|
4
|
+
import { t as cliContext } from "./context-PWAh9qbf.js";
|
|
4
5
|
import chalk from "chalk";
|
|
5
6
|
//#region src/cli/export.ts
|
|
6
|
-
const FORMATS =
|
|
7
|
-
"pdf",
|
|
8
|
-
"html",
|
|
9
|
-
"png"
|
|
10
|
-
];
|
|
7
|
+
const FORMATS = EXPORT_FORMATS;
|
|
11
8
|
/**
|
|
12
9
|
* The Download menu without a browser window — the same render pipeline, driven
|
|
13
10
|
* from a script. This is what makes a document something CI can produce on a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { m as importMarkdown } from "./ops-
|
|
2
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { m as importMarkdown } from "./ops-B2y9BMpk.js";
|
|
2
|
+
import { t as cliContext } from "./context-PWAh9qbf.js";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region src/cli/import.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as useDocLabels, C as cssVarsToString, D as LabelKind, E as LabelEntry, O as LabelVocabulary, S as DesignTypeScale, T as designToCssVars, _ as isPageSizeName, a as DocModule, b as DesignPalette, d as Orientation, f as PAGE_SIZES, g as isOrientation, h as PageSizeName, i as DocMeta, k as useDocLabel, l as FlowSection, m as PageGeometry, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PAGE_SIZE_NAMES, r as DocEntry, t as DEFAULT_ORIENTATION, u as ORIENTATIONS, v as resolvePageGeometry, w as defaultDesign, x as DesignSystem, y as DesignFonts } from "./sdk-BqU6mwD_.js";
|
|
2
2
|
import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-P61niZMf.js";
|
|
3
3
|
import { CSSProperties, ComponentType, ReactNode } from "react";
|
|
4
4
|
//#region src/app/lib/source-loc.d.ts
|
|
@@ -287,7 +287,7 @@ declare function parseDelimited(text: string, opts?: ParseOptions): DelimitedTab
|
|
|
287
287
|
//#endregion
|
|
288
288
|
//#region src/diagram/parse.d.ts
|
|
289
289
|
type Direction = 'TD' | 'LR';
|
|
290
|
-
type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle';
|
|
290
|
+
type NodeShape = 'rect' | 'round' | 'stadium' | 'diamond' | 'circle' | 'cylinder';
|
|
291
291
|
type DiagramNode = {
|
|
292
292
|
id: string;
|
|
293
293
|
label: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as defaultDesign, i as cssVarsToString, n as DiagramSyntaxError, o as designToCssVars, r as parseDelimited, t as compileDiagram } from "./diagram-
|
|
2
|
-
import { a as
|
|
1
|
+
import { a as defaultDesign, i as cssVarsToString, n as DiagramSyntaxError, o as designToCssVars, r as parseDelimited, t as compileDiagram } from "./diagram-CCaUUnRe.js";
|
|
2
|
+
import { a as PAGE_SIZES, c as isPageSizeName, i as ORIENTATIONS, l as resolvePageGeometry, n as DEFAULT_PAGE_SIZE, o as PAGE_SIZE_NAMES, s as isOrientation, t as DEFAULT_ORIENTATION } from "./sdk-CqNZzbkz.js";
|
|
3
3
|
import { Children, Fragment, createContext, isValidElement, useContext, useEffect, useId, useRef, useSyncExternalStore } from "react";
|
|
4
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region src/app/lib/source-loc.ts
|
|
@@ -145,6 +145,8 @@ function Footnote({ id, children, [LOC_PROP]: loc }) {
|
|
|
145
145
|
}
|
|
146
146
|
Footnote[FOOTNOTE_MARKER_FLAG] = true;
|
|
147
147
|
const FOOTNOTE_ROW_ATTR = "data-od-footnote-row";
|
|
148
|
+
/** The note's id on its row, so an exporter can pair a marker with its text. */
|
|
149
|
+
const FOOTNOTE_ID_ATTR = "data-od-footnote-id";
|
|
148
150
|
function footnoteAreaStyle() {
|
|
149
151
|
return {
|
|
150
152
|
borderTop: "1px solid var(--od-rule)",
|
|
@@ -160,6 +162,7 @@ function FootnoteRow({ id, content, loc }) {
|
|
|
160
162
|
const entry = useDocLabel(id);
|
|
161
163
|
return /* @__PURE__ */ jsxs("div", {
|
|
162
164
|
[FOOTNOTE_ROW_ATTR]: "",
|
|
165
|
+
[FOOTNOTE_ID_ATTR]: id,
|
|
163
166
|
style: {
|
|
164
167
|
display: "flex",
|
|
165
168
|
gap: 5,
|
|
@@ -337,6 +340,7 @@ function ListOf({ kind = "figure", showPageNumbers = true, style, className }) {
|
|
|
337
340
|
...style
|
|
338
341
|
},
|
|
339
342
|
children: entries.map((entry) => /* @__PURE__ */ jsxs("div", {
|
|
343
|
+
"data-od-list-entry": entry.id,
|
|
340
344
|
style: {
|
|
341
345
|
display: "flex",
|
|
342
346
|
alignItems: "baseline",
|
package/dist/ops/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as ExportFormat, d as Orientation, h as PageSizeName, p as PAGE_SIZE_NAMES, s as EXPORT_FORMATS, u as ORIENTATIONS } from "../sdk-BqU6mwD_.js";
|
|
2
2
|
import "vite";
|
|
3
3
|
//#region src/vite/routes/context.d.ts
|
|
4
4
|
type ApiContext = {
|
|
@@ -135,7 +135,6 @@ type LayoutReport = {
|
|
|
135
135
|
warnings: number;
|
|
136
136
|
findings: LayoutFinding[];
|
|
137
137
|
};
|
|
138
|
-
type ExportFormat = 'pdf' | 'html' | 'png';
|
|
139
138
|
type ExportResult = {
|
|
140
139
|
docId: string;
|
|
141
140
|
format: ExportFormat;
|
|
@@ -291,4 +290,4 @@ declare function addComment(ctx: ApiContext, docId: string, loc: Loc, note: stri
|
|
|
291
290
|
id: string;
|
|
292
291
|
}>;
|
|
293
292
|
//#endregion
|
|
294
|
-
export { type ApiContext, type AssetSummary, type DocumentSummary, type ExportFormat, type ExportResult, type ImportMarkdownOptions, type ImportResult, type LayoutFinding, type LayoutReport, type Loc, ORIENTATIONS, OpsError, type Orientation, PAGE_SIZE_NAMES, type PageSizeName, type ThemeSummary, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
|
|
293
|
+
export { type ApiContext, type AssetSummary, type DocumentSummary, EXPORT_FORMATS, type ExportFormat, type ExportResult, type ImportMarkdownOptions, type ImportResult, type LayoutFinding, type LayoutReport, type Loc, ORIENTATIONS, OpsError, type Orientation, PAGE_SIZE_NAMES, type PageSizeName, type ThemeSummary, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
|
package/dist/ops/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { O as makeContext, S as writeDocument, _ as listDocIds, a as writeText, b as renameDocument, f as OpsError, g as duplicateDocument, h as docDir, i as readText, m as deleteDocument, o as writeTexts, p as createDocument, r as addComment, v as listDocuments, x as resolveEntry, y as readDocument } from "../config-
|
|
3
|
-
import { a as listAssets, c as readTheme, d as closeRenderSession, f as exportDocument, h as slugify, i as findAssetUsages, l as writeAsset, m as importMarkdown, n as deleteAsset, o as listFolders, p as renderDocPage, r as fileDocument, s as listThemes, t as createFolder, u as checkLayout } from "../ops-
|
|
4
|
-
export { ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
|
|
1
|
+
import { i as ORIENTATIONS, o as PAGE_SIZE_NAMES, r as EXPORT_FORMATS } from "../sdk-CqNZzbkz.js";
|
|
2
|
+
import { O as makeContext, S as writeDocument, _ as listDocIds, a as writeText, b as renameDocument, f as OpsError, g as duplicateDocument, h as docDir, i as readText, m as deleteDocument, o as writeTexts, p as createDocument, r as addComment, v as listDocuments, x as resolveEntry, y as readDocument } from "../config-CAZ7Z_va.js";
|
|
3
|
+
import { a as listAssets, c as readTheme, d as closeRenderSession, f as exportDocument, h as slugify, i as findAssetUsages, l as writeAsset, m as importMarkdown, n as deleteAsset, o as listFolders, p as renderDocPage, r as fileDocument, s as listThemes, t as createFolder, u as checkLayout } from "../ops-B2y9BMpk.js";
|
|
4
|
+
export { EXPORT_FORMATS, ORIENTATIONS, OpsError, PAGE_SIZE_NAMES, addComment, checkLayout, closeRenderSession, createDocument, createFolder, deleteAsset, deleteDocument, docDir, duplicateDocument, exportDocument, fileDocument, findAssetUsages, importMarkdown, listAssets, listDocIds, listDocuments, listFolders, listThemes, makeContext, readDocument, readText, readTheme, renameDocument, renderDocPage, resolveEntry, slugify, writeAsset, writeDocument, writeText, writeTexts };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as newFolderId, D as writeManifest, E as validateName, T as validateIcon, _ as listDocIds, c as countAssetUsages, d as validateAssetName, f as OpsError, k as DOC_ID_RE, l as resolveScopedAssetFile, n as parseFrontmatter$1, p as createDocument, s as assetImportPath, t as createViteConfig, u as resolveScopedAssetsDir, w as readManifest, x as resolveEntry } from "./config-
|
|
1
|
+
import { c as isPageSizeName, i as ORIENTATIONS, o as PAGE_SIZE_NAMES, s as isOrientation } from "./sdk-CqNZzbkz.js";
|
|
2
|
+
import { C as newFolderId, D as writeManifest, E as validateName, T as validateIcon, _ as listDocIds, c as countAssetUsages, d as validateAssetName, f as OpsError, k as DOC_ID_RE, l as resolveScopedAssetFile, n as parseFrontmatter$1, p as createDocument, s as assetImportPath, t as createViteConfig, u as resolveScopedAssetsDir, w as readManifest, x as resolveEntry } from "./config-CAZ7Z_va.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -933,6 +933,7 @@ async function createRenderSession(opts) {
|
|
|
933
933
|
}
|
|
934
934
|
},
|
|
935
935
|
html: () => page.evaluate("globalThis.__openDoc.htmlBundle()"),
|
|
936
|
+
docx: () => page.evaluate("globalThis.__openDoc.docxBundle()"),
|
|
936
937
|
close: () => page.close()
|
|
937
938
|
};
|
|
938
939
|
},
|
|
@@ -1062,8 +1063,8 @@ async function exportDocument(ctx, docId, opts = {}) {
|
|
|
1062
1063
|
written.push(path.relative(ctx.userCwd, file));
|
|
1063
1064
|
};
|
|
1064
1065
|
if (format === "pdf") await write(`${docId}.pdf`, await renderer.pdf());
|
|
1065
|
-
else if (format === "html") {
|
|
1066
|
-
const bundle = await renderer.html();
|
|
1066
|
+
else if (format === "html" || format === "docx") {
|
|
1067
|
+
const bundle = format === "html" ? await renderer.html() : await renderer.docx();
|
|
1067
1068
|
if (!bundle) throw new OpsError(422, `document has no pages: ${docId}`);
|
|
1068
1069
|
await write(bundle.filename, Buffer.from(bundle.base64, "base64"));
|
|
1069
1070
|
} else {
|
|
@@ -106,6 +106,13 @@ type FlowSection = {
|
|
|
106
106
|
};
|
|
107
107
|
/** What a document's default export may contain: fixed pages, flow sections, or both. */
|
|
108
108
|
type DocEntry = DocPage | FlowSection;
|
|
109
|
+
/**
|
|
110
|
+
* Every format `open-doc export` can write. The CLI's `--format`, the MCP
|
|
111
|
+
* `export_document` schema and `ops/layout.ts` all read this tuple, so adding a
|
|
112
|
+
* format is one edit here and its branch in `exportDocument`.
|
|
113
|
+
*/
|
|
114
|
+
declare const EXPORT_FORMATS: readonly ["pdf", "html", "png", "docx"];
|
|
115
|
+
type ExportFormat = (typeof EXPORT_FORMATS)[number];
|
|
109
116
|
type DocMeta = {
|
|
110
117
|
title?: string;
|
|
111
118
|
subtitle?: string;
|
|
@@ -126,4 +133,4 @@ type DocModule = {
|
|
|
126
133
|
};
|
|
127
134
|
declare function resolvePageGeometry(meta?: DocMeta): PageGeometry;
|
|
128
135
|
//#endregion
|
|
129
|
-
export {
|
|
136
|
+
export { useDocLabels as A, cssVarsToString as C, LabelKind as D, LabelEntry as E, LabelVocabulary as O, DesignTypeScale as S, designToCssVars as T, isPageSizeName as _, DocModule as a, DesignPalette as b, ExportFormat as c, Orientation as d, PAGE_SIZES as f, isOrientation as g, PageSizeName as h, DocMeta as i, useDocLabel as k, FlowSection as l, PageGeometry as m, DEFAULT_PAGE_SIZE as n, DocPage as o, PAGE_SIZE_NAMES as p, DocEntry as r, EXPORT_FORMATS as s, DEFAULT_ORIENTATION as t, ORIENTATIONS as u, resolvePageGeometry as v, defaultDesign as w, DesignSystem as x, DesignFonts as y };
|
|
@@ -36,6 +36,17 @@ function isPageSizeName(value) {
|
|
|
36
36
|
function isOrientation(value) {
|
|
37
37
|
return value === "portrait" || value === "landscape";
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Every format `open-doc export` can write. The CLI's `--format`, the MCP
|
|
41
|
+
* `export_document` schema and `ops/layout.ts` all read this tuple, so adding a
|
|
42
|
+
* format is one edit here and its branch in `exportDocument`.
|
|
43
|
+
*/
|
|
44
|
+
const EXPORT_FORMATS = [
|
|
45
|
+
"pdf",
|
|
46
|
+
"html",
|
|
47
|
+
"png",
|
|
48
|
+
"docx"
|
|
49
|
+
];
|
|
39
50
|
function resolvePageGeometry(meta) {
|
|
40
51
|
const size = PAGE_SIZES[meta?.pageSize ?? "A4"] ?? PAGE_SIZES["A4"];
|
|
41
52
|
const landscape = meta?.orientation === "landscape";
|
|
@@ -47,4 +58,4 @@ function resolvePageGeometry(meta) {
|
|
|
47
58
|
};
|
|
48
59
|
}
|
|
49
60
|
//#endregion
|
|
50
|
-
export {
|
|
61
|
+
export { PAGE_SIZES as a, isPageSizeName as c, ORIENTATIONS as i, resolvePageGeometry as l, DEFAULT_PAGE_SIZE as n, PAGE_SIZE_NAMES as o, EXPORT_FORMATS as r, isOrientation as s, DEFAULT_ORIENTATION as t };
|
package/dist/vite/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { j as openDocPlugin, t as createViteConfig } from "../config-
|
|
1
|
+
import { j as openDocPlugin, t as createViteConfig } from "../config-CAZ7Z_va.js";
|
|
2
2
|
export { createViteConfig, openDocPlugin };
|
package/package.json
CHANGED
|
@@ -183,8 +183,10 @@ variables, so it prints with the same ink and faces as the prose around it.
|
|
|
183
183
|
Never reach for an image of a diagram when the diagram can be written.
|
|
184
184
|
|
|
185
185
|
Supported: `flowchart`/`graph` with `TD` or `LR`; nodes as `A[box]`, `A(round)`,
|
|
186
|
-
`A([stadium])`, `A{decision}`, `A((circle))`; links `-->`,
|
|
187
|
-
with optional `|labels|`; chains `A --> B --> C`; `%%`
|
|
186
|
+
`A([stadium])`, `A[(database)]`, `A{decision}`, `A((circle))`; links `-->`,
|
|
187
|
+
`---`, `-.->`, `==>` with optional `|labels|`; chains `A --> B --> C`; `%%`
|
|
188
|
+
comments. A link back to an earlier step is drawn round the side, clear of the
|
|
189
|
+
steps in between. Anything else
|
|
188
190
|
in Mermaid's syntax — subgraphs, class diagrams, sequence diagrams — is not
|
|
189
191
|
supported, and a bad diagram fails the build with the line to fix.
|
|
190
192
|
|
|
@@ -358,7 +360,8 @@ A document is not a slide deck. Long-form copy is the point — but it still has
|
|
|
358
360
|
- **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.
|
|
359
361
|
- **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.
|
|
360
362
|
- **Download menu** — PDF (true page size) and self-contained HTML.
|
|
361
|
-
- **Headless render** — `open-doc export <id> --format pdf|html|png` 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.
|
|
363
|
+
- **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.
|
|
364
|
+
- **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()` footer a Word 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.
|
|
362
365
|
- **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.
|
|
363
366
|
|
|
364
367
|
### Writing for the inspector
|
|
@@ -154,6 +154,8 @@ export type FootnotesProps = {
|
|
|
154
154
|
export const FOOTNOTE_AREA_MARGIN_TOP = 12;
|
|
155
155
|
|
|
156
156
|
export const FOOTNOTE_ROW_ATTR = 'data-od-footnote-row';
|
|
157
|
+
/** The note's id on its row, so an exporter can pair a marker with its text. */
|
|
158
|
+
export const FOOTNOTE_ID_ATTR = 'data-od-footnote-id';
|
|
157
159
|
|
|
158
160
|
export function footnoteAreaStyle(): CSSProperties {
|
|
159
161
|
return {
|
|
@@ -170,7 +172,10 @@ export function footnoteAreaStyle(): CSSProperties {
|
|
|
170
172
|
export function FootnoteRow({ id, content, loc }: CollectedNote) {
|
|
171
173
|
const entry = useDocLabel(id);
|
|
172
174
|
return (
|
|
173
|
-
<div
|
|
175
|
+
<div
|
|
176
|
+
{...{ [FOOTNOTE_ROW_ATTR]: '', [FOOTNOTE_ID_ATTR]: id }}
|
|
177
|
+
style={{ display: 'flex', gap: 5, marginBottom: 3 }}
|
|
178
|
+
>
|
|
174
179
|
<span
|
|
175
180
|
style={{
|
|
176
181
|
flex: 'none',
|
|
@@ -186,6 +186,7 @@ export function ListOf({ kind = 'figure', showPageNumbers = true, style, classNa
|
|
|
186
186
|
{entries.map((entry) => (
|
|
187
187
|
<div
|
|
188
188
|
key={entry.id}
|
|
189
|
+
data-od-list-entry={entry.id}
|
|
189
190
|
style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 6 }}
|
|
190
191
|
>
|
|
191
192
|
<span style={{ flex: 'none', color: 'var(--od-muted)' }}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { diagnosePages, type LayoutFinding } from './diagnostics';
|
|
3
|
+
import { buildDocDocx } from './export-docx';
|
|
3
4
|
import { buildDocHtmlBundle } from './export-html';
|
|
4
5
|
import { mountPrintCopy } from './export-pdf';
|
|
5
6
|
import type { DocModule, PageGeometry } from './sdk';
|
|
@@ -29,6 +30,7 @@ export type OpenDocBridge = {
|
|
|
29
30
|
preparePrint(): Promise<{ pageCount: number }>;
|
|
30
31
|
releasePrint(): void;
|
|
31
32
|
htmlBundle(): Promise<BridgeBundle | null>;
|
|
33
|
+
docxBundle(): Promise<BridgeBundle | null>;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
type BridgeInput = {
|
|
@@ -118,6 +120,17 @@ export function useAgentBridge(input: BridgeInput): void {
|
|
|
118
120
|
base64: toBase64(bundle.bytes),
|
|
119
121
|
};
|
|
120
122
|
},
|
|
123
|
+
async docxBundle() {
|
|
124
|
+
const { docId, doc, pages } = latest.current;
|
|
125
|
+
if (!doc || pages.length === 0) return null;
|
|
126
|
+
const bundle = await buildDocDocx(doc, docId, pages);
|
|
127
|
+
if (!bundle) return null;
|
|
128
|
+
return {
|
|
129
|
+
filename: bundle.filename,
|
|
130
|
+
mimeType: bundle.mimeType,
|
|
131
|
+
base64: toBase64(bundle.bytes),
|
|
132
|
+
};
|
|
133
|
+
},
|
|
121
134
|
};
|
|
122
135
|
|
|
123
136
|
return () => {
|