@open-document/core 0.6.0 → 0.7.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-BvIHtePO.js → build-CFL7nhz0.js} +1 -1
- package/dist/{check-BqEdVH7G.js → check-pEQh4jJE.js} +3 -3
- package/dist/cli/bin.js +6 -6
- package/dist/{config-B7vFf9qZ.js → config-4nz5NnxW.js} +593 -137
- package/dist/{context-BaUE_aqU.js → context-BH8C-dSW.js} +1 -1
- package/dist/{dev-DXG-Dg-y.js → dev-BCSUczXW.js} +1 -1
- package/dist/{export-CT1Axnjv.js → export-BQ-GvMsb.js} +3 -3
- package/dist/{import-C8ZC4R6T.js → import-Daat3L2J.js} +2 -2
- package/dist/index.d.ts +21 -3
- package/dist/index.js +40 -9
- package/dist/ops/index.d.ts +47 -3
- package/dist/ops/index.js +3 -3
- package/dist/{ops-ByclxTfk.js → ops-DQfckiyp.js} +2 -45
- package/dist/{preview-CdmWbaHy.js → preview-CwCrw-i3.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
- package/src/app/components/data-table.tsx +17 -2
- package/src/app/components/design-panel/design-panel.tsx +149 -274
- package/src/app/components/design-panel/design-provider.tsx +35 -15
- package/src/app/components/footnote.tsx +27 -10
- package/src/app/components/history-provider.tsx +125 -0
- package/src/app/components/inspector/inspector.tsx +1145 -208
- package/src/app/components/numbering.tsx +13 -1
- package/src/app/components/panel/edit-save-card.tsx +112 -0
- package/src/app/components/panel/fields.tsx +247 -0
- package/src/app/components/panel/panel-shell.tsx +71 -0
- package/src/app/components/panel/save-card.tsx +146 -0
- package/src/app/lib/footnotes.ts +6 -3
- package/src/app/lib/href.ts +14 -0
- package/src/app/lib/inspector/inline-edit.test.ts +244 -0
- package/src/app/lib/inspector/inline-edit.ts +770 -0
- package/src/app/lib/source-loc.ts +15 -0
- package/src/app/routes/doc.tsx +109 -39
- package/src/app/styles.css +41 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as readCoreVersion } from "./cli/bin.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as loadUserConfig, O as makeContext } from "./config-4nz5NnxW.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()) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { _ as listDocIds } from "./config-4nz5NnxW.js";
|
|
2
|
+
import { d as closeRenderSession, f as exportDocument } from "./ops-DQfckiyp.js";
|
|
3
|
+
import { t as cliContext } from "./context-BH8C-dSW.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
//#region src/cli/export.ts
|
|
6
6
|
const FORMATS = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as cliContext } from "./context-
|
|
1
|
+
import { m as importMarkdown } from "./ops-DQfckiyp.js";
|
|
2
|
+
import { t as cliContext } from "./context-BH8C-dSW.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,6 +1,16 @@
|
|
|
1
1
|
import { C as designToCssVars, D as useDocLabel, E as LabelVocabulary, O as useDocLabels, S as defaultDesign, T as LabelKind, _ as DesignFonts, a as DocModule, b as DesignTypeScale, c as ORIENTATIONS, d as PAGE_SIZE_NAMES, f as PageGeometry, g as resolvePageGeometry, h as isPageSizeName, i as DocMeta, l as Orientation, m as isOrientation, n as DEFAULT_PAGE_SIZE, o as DocPage, p as PageSizeName, r as DocEntry, s as FlowSection, t as DEFAULT_ORIENTATION, u as PAGE_SIZES, v as DesignPalette, w as LabelEntry, x as cssVarsToString, y as DesignSystem } from "./sdk-C9nl30dW.js";
|
|
2
2
|
import { n as OpenDocConfig, t as OpenDocBuildConfig } from "./config-P61niZMf.js";
|
|
3
3
|
import { CSSProperties, ComponentType, ReactNode } from "react";
|
|
4
|
+
//#region src/app/lib/source-loc.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* In dev, `loc-tags-plugin` stamps `data-od-loc` onto the call site of a
|
|
7
|
+
* framework component that forwards it. The component puts it back on the
|
|
8
|
+
* host that prints the call site's words, so the inspector can select what it
|
|
9
|
+
* rendered — a table, a caption, a footnote — and find the source behind it.
|
|
10
|
+
* `data-od-prop` says which attribute of the call site those words come from.
|
|
11
|
+
*/
|
|
12
|
+
declare const LOC_PROP = "data-od-loc";
|
|
13
|
+
//#endregion
|
|
4
14
|
//#region src/app/components/data-table.d.ts
|
|
5
15
|
type DataAlign = 'left' | 'center' | 'right';
|
|
6
16
|
type DataFormat = 'text' | 'number' | 'integer' | 'percent' | ((value: unknown, row: Record<string, unknown>) => ReactNode);
|
|
@@ -29,13 +39,15 @@ type DataTableProps = {
|
|
|
29
39
|
emptyValue?: ReactNode;
|
|
30
40
|
style?: CSSProperties;
|
|
31
41
|
className?: string;
|
|
42
|
+
/** Stamped in dev by the loc-tags plugin; see `lib/source-loc.ts`. */
|
|
43
|
+
[LOC_PROP]?: string;
|
|
32
44
|
};
|
|
33
45
|
/**
|
|
34
46
|
* A print-shaped table from data, so the numbers in a report come from a file
|
|
35
47
|
* instead of being retyped into JSX. Alignment and grouping follow the column's
|
|
36
48
|
* contents, which is the part people get wrong by hand.
|
|
37
49
|
*/
|
|
38
|
-
declare function DataTable({ rows, columns, caption, id, limit, compact, emptyValue, style, className }: DataTableProps): import("react").JSX.Element;
|
|
50
|
+
declare function DataTable({ rows, columns, caption, id, limit, compact, emptyValue, style, className, [LOC_PROP]: loc }: DataTableProps): import("react").JSX.Element;
|
|
39
51
|
//#endregion
|
|
40
52
|
//#region src/app/components/diagram.d.ts
|
|
41
53
|
type DiagramSource = {
|
|
@@ -70,21 +82,25 @@ type DiagramProps = {
|
|
|
70
82
|
declare function Diagram({ chart, caption, captionText, kind, id, width, align, style, className }: DiagramProps): import("react").JSX.Element;
|
|
71
83
|
//#endregion
|
|
72
84
|
//#region src/app/components/footnote.d.ts
|
|
85
|
+
/** `loc` is the `<Footnote>` call site, so the printed note can be edited where it prints. */
|
|
73
86
|
type CollectedNote = {
|
|
74
87
|
id: string;
|
|
75
88
|
content: ReactNode;
|
|
89
|
+
loc?: string;
|
|
76
90
|
};
|
|
77
91
|
type FootnoteProps = {
|
|
78
92
|
/** Stable id, so `<Ref to>` can point at the note. Generated when omitted. */
|
|
79
93
|
id?: string;
|
|
80
94
|
children?: ReactNode;
|
|
95
|
+
/** Stamped in dev by the loc-tags plugin; see `lib/source-loc.ts`. */
|
|
96
|
+
[LOC_PROP]?: string;
|
|
81
97
|
};
|
|
82
98
|
/**
|
|
83
99
|
* A note anchored to this point in the text. Inside a `flow()` section the
|
|
84
100
|
* framework lifts it to the foot of whatever page the marker lands on; on a
|
|
85
101
|
* fixed page, put a `<Footnotes />` where you want them printed.
|
|
86
102
|
*/
|
|
87
|
-
declare function Footnote({ id, children }: FootnoteProps): import("react").JSX.Element;
|
|
103
|
+
declare function Footnote({ id, children, [LOC_PROP]: loc }: FootnoteProps): import("react").JSX.Element;
|
|
88
104
|
type FootnotesProps = {
|
|
89
105
|
/** Notes to print. Omitted on a fixed page, where they are collected from it. */
|
|
90
106
|
notes?: CollectedNote[];
|
|
@@ -125,6 +141,8 @@ type FigureProps = {
|
|
|
125
141
|
captionStyle?: CSSProperties;
|
|
126
142
|
className?: string;
|
|
127
143
|
children?: ReactNode;
|
|
144
|
+
/** Stamped in dev by the loc-tags plugin; see `lib/source-loc.ts`. */
|
|
145
|
+
[LOC_PROP]?: string;
|
|
128
146
|
};
|
|
129
147
|
/**
|
|
130
148
|
* A numbered figure or table. The number comes from a scan of the rendered
|
|
@@ -134,7 +152,7 @@ type FigureProps = {
|
|
|
134
152
|
*
|
|
135
153
|
* Caption and content are one block, so a `flow()` section never separates them.
|
|
136
154
|
*/
|
|
137
|
-
declare function Figure({ id, caption, kind, captionPosition, captionText, style, captionStyle, className, children }: FigureProps): import("react").JSX.Element;
|
|
155
|
+
declare function Figure({ id, caption, kind, captionPosition, captionText, style, captionStyle, className, children, [LOC_PROP]: loc }: FigureProps): import("react").JSX.Element;
|
|
138
156
|
type RefProps = {
|
|
139
157
|
/** The `id` of a `<Figure>` or `<Footnote>`. */
|
|
140
158
|
to: string;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,25 @@ import { a as defaultDesign, i as cssVarsToString, n as DiagramSyntaxError, o as
|
|
|
2
2
|
import { a as PAGE_SIZE_NAMES, c as resolvePageGeometry, i as PAGE_SIZES, n as DEFAULT_PAGE_SIZE, o as isOrientation, r as ORIENTATIONS, s as isPageSizeName, t as DEFAULT_ORIENTATION } from "./sdk-DhcqZdAw.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
|
+
//#region src/app/lib/source-loc.ts
|
|
6
|
+
/**
|
|
7
|
+
* In dev, `loc-tags-plugin` stamps `data-od-loc` onto the call site of a
|
|
8
|
+
* framework component that forwards it. The component puts it back on the
|
|
9
|
+
* host that prints the call site's words, so the inspector can select what it
|
|
10
|
+
* rendered — a table, a caption, a footnote — and find the source behind it.
|
|
11
|
+
* `data-od-prop` says which attribute of the call site those words come from.
|
|
12
|
+
*/
|
|
13
|
+
const LOC_PROP = "data-od-loc";
|
|
14
|
+
const PROP_ATTR = "data-od-prop";
|
|
15
|
+
/** The attributes pointing a host back at its call site; nothing outside dev. */
|
|
16
|
+
function sourceAttrs(loc, prop) {
|
|
17
|
+
if (!loc) return {};
|
|
18
|
+
return prop ? {
|
|
19
|
+
[LOC_PROP]: loc,
|
|
20
|
+
[PROP_ATTR]: prop
|
|
21
|
+
} : { [LOC_PROP]: loc };
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
5
24
|
//#region src/app/lib/outline.ts
|
|
6
25
|
const GLOBAL_KEY$3 = "__open_doc_outline_store__";
|
|
7
26
|
const g$3 = globalThis;
|
|
@@ -112,14 +131,14 @@ function FootnoteMarker({ id }) {
|
|
|
112
131
|
* framework lifts it to the foot of whatever page the marker lands on; on a
|
|
113
132
|
* fixed page, put a `<Footnotes />` where you want them printed.
|
|
114
133
|
*/
|
|
115
|
-
function Footnote({ id, children }) {
|
|
134
|
+
function Footnote({ id, children, [LOC_PROP]: loc }) {
|
|
116
135
|
const generated = useId();
|
|
117
136
|
const noteId = id ?? generated;
|
|
118
137
|
const collector = useContext(FootnoteContext);
|
|
119
138
|
const latest = useRef(null);
|
|
120
139
|
useEffect(() => {
|
|
121
140
|
latest.current = collector;
|
|
122
|
-
collector?.register(noteId, children);
|
|
141
|
+
collector?.register(noteId, children, loc);
|
|
123
142
|
});
|
|
124
143
|
useEffect(() => () => latest.current?.unregister(noteId), [noteId]);
|
|
125
144
|
return /* @__PURE__ */ jsx(FootnoteMarker, { id: noteId });
|
|
@@ -137,7 +156,7 @@ function footnoteAreaStyle() {
|
|
|
137
156
|
};
|
|
138
157
|
}
|
|
139
158
|
/** One note's row. Shared with the measurement pass so the reserved space is real. */
|
|
140
|
-
function FootnoteRow({ id, content }) {
|
|
159
|
+
function FootnoteRow({ id, content, loc }) {
|
|
141
160
|
const entry = useDocLabel(id);
|
|
142
161
|
return /* @__PURE__ */ jsxs("div", {
|
|
143
162
|
[FOOTNOTE_ROW_ATTR]: "",
|
|
@@ -154,6 +173,7 @@ function FootnoteRow({ id, content }) {
|
|
|
154
173
|
},
|
|
155
174
|
children: entry?.number ?? UNNUMBERED
|
|
156
175
|
}), /* @__PURE__ */ jsx("span", {
|
|
176
|
+
...sourceAttrs(loc),
|
|
157
177
|
style: { minWidth: 0 },
|
|
158
178
|
children: content
|
|
159
179
|
})]
|
|
@@ -164,7 +184,8 @@ function Footnotes({ notes, style, className }) {
|
|
|
164
184
|
const vocabulary = useLabelVocabulary();
|
|
165
185
|
const list = notes ?? collector?.ids.map((id) => ({
|
|
166
186
|
id,
|
|
167
|
-
content: collector.contents.get(id)
|
|
187
|
+
content: collector.contents.get(id),
|
|
188
|
+
loc: collector.locs.get(id)
|
|
168
189
|
})) ?? [];
|
|
169
190
|
if (list.length === 0) return null;
|
|
170
191
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -182,7 +203,8 @@ function Footnotes({ notes, style, className }) {
|
|
|
182
203
|
children: vocabulary.footnotes
|
|
183
204
|
}) : null, list.map((note) => /* @__PURE__ */ jsx(FootnoteRow, {
|
|
184
205
|
id: note.id,
|
|
185
|
-
content: note.content
|
|
206
|
+
content: note.content,
|
|
207
|
+
loc: note.loc
|
|
186
208
|
}, note.id))]
|
|
187
209
|
});
|
|
188
210
|
}
|
|
@@ -215,7 +237,7 @@ function nameFor(kind, vocabulary) {
|
|
|
215
237
|
*
|
|
216
238
|
* Caption and content are one block, so a `flow()` section never separates them.
|
|
217
239
|
*/
|
|
218
|
-
function Figure({ id, caption, kind = "figure", captionPosition, captionText, style, captionStyle, className, children }) {
|
|
240
|
+
function Figure({ id, caption, kind = "figure", captionPosition, captionText, style, captionStyle, className, children, [LOC_PROP]: loc }) {
|
|
219
241
|
const generated = useId();
|
|
220
242
|
const labelId = id ?? generated;
|
|
221
243
|
const entry = useDocLabel(labelId);
|
|
@@ -240,12 +262,16 @@ function Figure({ id, caption, kind = "figure", captionPosition, captionText, st
|
|
|
240
262
|
" ",
|
|
241
263
|
entry?.number ?? ""
|
|
242
264
|
]
|
|
243
|
-
}), caption ? /* @__PURE__ */ jsxs("span", { children: [" — ",
|
|
265
|
+
}), typeof caption === "string" || typeof caption === "number" ? /* @__PURE__ */ jsxs("span", { children: [" — ", /* @__PURE__ */ jsx("span", {
|
|
266
|
+
...sourceAttrs(loc, "caption"),
|
|
267
|
+
children: caption
|
|
268
|
+
})] }) : caption ? /* @__PURE__ */ jsxs("span", { children: [" — ", caption] }) : null]
|
|
244
269
|
}) : null;
|
|
245
270
|
return /* @__PURE__ */ jsxs("figure", {
|
|
246
271
|
[LABEL_ATTR]: kind,
|
|
247
272
|
[LABEL_ID_ATTR]: labelId,
|
|
248
273
|
[LABEL_TEXT_ATTR]: text,
|
|
274
|
+
...sourceAttrs(loc),
|
|
249
275
|
className,
|
|
250
276
|
style: {
|
|
251
277
|
margin: "0 0 16px",
|
|
@@ -392,12 +418,13 @@ function formatValue(value, format, row, emptyValue) {
|
|
|
392
418
|
* instead of being retyped into JSX. Alignment and grouping follow the column's
|
|
393
419
|
* contents, which is the part people get wrong by hand.
|
|
394
420
|
*/
|
|
395
|
-
function DataTable({ rows, columns, caption, id, limit, compact = false, emptyValue = "—", style, className }) {
|
|
421
|
+
function DataTable({ rows, columns, caption, id, limit, compact = false, emptyValue = "—", style, className, [LOC_PROP]: loc }) {
|
|
396
422
|
const resolved = (columns ?? Object.keys(rows[0] ?? {})).map(normalizeColumn);
|
|
397
423
|
const shown = limit !== void 0 ? rows.slice(0, limit) : rows;
|
|
398
424
|
const hidden = rows.length - shown.length;
|
|
399
425
|
const cellPadding = compact ? "4px 8px" : "7px 8px";
|
|
400
426
|
const table = /* @__PURE__ */ jsxs("table", {
|
|
427
|
+
...caption ? {} : sourceAttrs(loc),
|
|
401
428
|
className,
|
|
402
429
|
style: {
|
|
403
430
|
width: "100%",
|
|
@@ -407,9 +434,12 @@ function DataTable({ rows, columns, caption, id, limit, compact = false, emptyVa
|
|
|
407
434
|
...style
|
|
408
435
|
},
|
|
409
436
|
children: [
|
|
410
|
-
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: resolved.map((column) => {
|
|
437
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: resolved.map((column, index) => {
|
|
411
438
|
const align = column.align ?? inferAlign(rows, column.key);
|
|
439
|
+
const authored = columns?.[index];
|
|
440
|
+
const labelled = typeof authored === "object" && typeof authored.label === "string";
|
|
412
441
|
return /* @__PURE__ */ jsx("th", {
|
|
442
|
+
...labelled ? sourceAttrs(loc, `columns.${index}.label`) : {},
|
|
413
443
|
style: {
|
|
414
444
|
textAlign: align,
|
|
415
445
|
width: column.width,
|
|
@@ -460,6 +490,7 @@ function DataTable({ rows, columns, caption, id, limit, compact = false, emptyVa
|
|
|
460
490
|
kind: "table",
|
|
461
491
|
caption,
|
|
462
492
|
...id !== void 0 ? { id } : {},
|
|
493
|
+
...sourceAttrs(loc),
|
|
463
494
|
children: table
|
|
464
495
|
});
|
|
465
496
|
}
|
package/dist/ops/index.d.ts
CHANGED
|
@@ -220,6 +220,37 @@ declare function createFolder(ctx: ApiContext, rawName: unknown, rawIcon?: unkno
|
|
|
220
220
|
/** Filing only edits assignments — a document id never moves on disk. */
|
|
221
221
|
declare function fileDocument(ctx: ApiContext, docId: string, folderId: string | null): Promise<void>;
|
|
222
222
|
//#endregion
|
|
223
|
+
//#region src/editing/edit-ops.d.ts
|
|
224
|
+
type EditTarget = {
|
|
225
|
+
line: number;
|
|
226
|
+
column: number;
|
|
227
|
+
};
|
|
228
|
+
/** A stretch of a run and the inline formatting it carries. */
|
|
229
|
+
type TextSegment = {
|
|
230
|
+
text: string;
|
|
231
|
+
bold?: boolean;
|
|
232
|
+
italic?: boolean;
|
|
233
|
+
code?: boolean;
|
|
234
|
+
href?: string;
|
|
235
|
+
};
|
|
236
|
+
type TextEdit = EditTarget & {
|
|
237
|
+
text: string;
|
|
238
|
+
/** A path into the element's attributes, for words a component prints from a prop. */
|
|
239
|
+
prop?: string;
|
|
240
|
+
/** The run as formatted pieces; `text` is their concatenation. */
|
|
241
|
+
segments?: TextSegment[];
|
|
242
|
+
index?: number;
|
|
243
|
+
expected?: string;
|
|
244
|
+
shown?: string;
|
|
245
|
+
};
|
|
246
|
+
type TextEditOutcome = {
|
|
247
|
+
ok: true;
|
|
248
|
+
} | {
|
|
249
|
+
ok: false;
|
|
250
|
+
status: number;
|
|
251
|
+
error: string;
|
|
252
|
+
};
|
|
253
|
+
//#endregion
|
|
223
254
|
//#region src/ops/text.d.ts
|
|
224
255
|
type Loc = {
|
|
225
256
|
line: number;
|
|
@@ -230,21 +261,34 @@ type Loc = {
|
|
|
230
261
|
* that spot. `shown` is the rendered text — when a clicked element belongs to a
|
|
231
262
|
* local helper component, it is what decides which candidate was really meant.
|
|
232
263
|
*/
|
|
233
|
-
declare function readText(ctx: ApiContext, docId: string, locs: Loc[], shown?: string): Promise<unknown>;
|
|
264
|
+
declare function readText(ctx: ApiContext, docId: string, locs: Loc[], shown?: string, prop?: string): Promise<unknown>;
|
|
234
265
|
/**
|
|
235
266
|
* `expected` is the text the caller believes is there; when it no longer
|
|
236
267
|
* matches the write is refused rather than silently overwriting someone else's
|
|
237
|
-
* edit. `index` picks a run when the element mixes text and markup.
|
|
268
|
+
* edit. `index` picks a run when the element mixes text and markup. A run that
|
|
269
|
+
* carries code, emphasis or links must be written as `segments`, or the write
|
|
270
|
+
* is refused rather than dropping the formatting.
|
|
238
271
|
*/
|
|
239
272
|
declare function writeText(ctx: ApiContext, docId: string, loc: Loc, text: string, opts?: {
|
|
240
273
|
index?: number;
|
|
241
274
|
expected?: string;
|
|
275
|
+
segments?: TextSegment[];
|
|
276
|
+
prop?: string;
|
|
242
277
|
}): Promise<{
|
|
243
278
|
ok: true;
|
|
244
279
|
}>;
|
|
280
|
+
/**
|
|
281
|
+
* Several run replacements in one read and one write, so an editing session
|
|
282
|
+
* that touched five paragraphs lands as a single hot reload rather than five
|
|
283
|
+
* that each re-paginate the document. Per-edit failures are reported, not
|
|
284
|
+
* thrown: the edits that still apply are written.
|
|
285
|
+
*/
|
|
286
|
+
declare function writeTexts(ctx: ApiContext, docId: string, edits: TextEdit[]): Promise<{
|
|
287
|
+
results: TextEditOutcome[];
|
|
288
|
+
}>;
|
|
245
289
|
/** Leaves a `@doc-comment` marker in the source for a later agent pass to act on. */
|
|
246
290
|
declare function addComment(ctx: ApiContext, docId: string, loc: Loc, note: string, hint?: string): Promise<{
|
|
247
291
|
id: string;
|
|
248
292
|
}>;
|
|
249
293
|
//#endregion
|
|
250
|
-
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 };
|
|
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 };
|
package/dist/ops/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as PAGE_SIZE_NAMES, r as ORIENTATIONS } from "../sdk-DhcqZdAw.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 };
|
|
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-4nz5NnxW.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-DQfckiyp.js";
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { a as PAGE_SIZE_NAMES, o as isOrientation, r as ORIENTATIONS, s as isPageSizeName } from "./sdk-DhcqZdAw.js";
|
|
2
|
-
import { C as
|
|
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-4nz5NnxW.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
@@ -1229,47 +1229,4 @@ async function fileDocument(ctx, docId, folderId) {
|
|
|
1229
1229
|
await writeManifest(ctx.manifestPath, manifest);
|
|
1230
1230
|
}
|
|
1231
1231
|
//#endregion
|
|
1232
|
-
|
|
1233
|
-
async function sourceOf(ctx, docId) {
|
|
1234
|
-
const entry = resolveEntry(ctx, docId);
|
|
1235
|
-
if (!entry) throw new OpsError(404, `document not found: ${docId}`);
|
|
1236
|
-
return {
|
|
1237
|
-
entry,
|
|
1238
|
-
source: await fs.readFile(entry, "utf8")
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
/**
|
|
1242
|
-
* Resolves a `line:column` (or several candidates) to the editable text runs at
|
|
1243
|
-
* that spot. `shown` is the rendered text — when a clicked element belongs to a
|
|
1244
|
-
* local helper component, it is what decides which candidate was really meant.
|
|
1245
|
-
*/
|
|
1246
|
-
async function readText(ctx, docId, locs, shown) {
|
|
1247
|
-
if (locs.length === 0) throw new OpsError(400, "at least one loc is required");
|
|
1248
|
-
const { source } = await sourceOf(ctx, docId);
|
|
1249
|
-
const resolved = resolveTextTarget(source, locs, shown);
|
|
1250
|
-
if (!resolved) throw new OpsError(404, "no editable text at that location");
|
|
1251
|
-
return resolved;
|
|
1252
|
-
}
|
|
1253
|
-
/**
|
|
1254
|
-
* `expected` is the text the caller believes is there; when it no longer
|
|
1255
|
-
* matches the write is refused rather than silently overwriting someone else's
|
|
1256
|
-
* edit. `index` picks a run when the element mixes text and markup.
|
|
1257
|
-
*/
|
|
1258
|
-
async function writeText(ctx, docId, loc, text, opts = {}) {
|
|
1259
|
-
const { entry, source } = await sourceOf(ctx, docId);
|
|
1260
|
-
const result = replaceTextAt(source, loc, text, opts);
|
|
1261
|
-
if (!result.ok) throw new OpsError(result.status, result.error);
|
|
1262
|
-
if (result.source !== source) await fs.writeFile(entry, result.source, "utf8");
|
|
1263
|
-
return { ok: true };
|
|
1264
|
-
}
|
|
1265
|
-
/** Leaves a `@doc-comment` marker in the source for a later agent pass to act on. */
|
|
1266
|
-
async function addComment(ctx, docId, loc, note, hint) {
|
|
1267
|
-
if (note.trim() === "") throw new OpsError(400, "note is empty");
|
|
1268
|
-
const { entry, source } = await sourceOf(ctx, docId);
|
|
1269
|
-
const inserted = insertMarker(source, loc, note.trim(), hint);
|
|
1270
|
-
if (!inserted) throw new OpsError(422, "cannot anchor a comment here — pick the surrounding element");
|
|
1271
|
-
await fs.writeFile(entry, inserted.source, "utf8");
|
|
1272
|
-
return { id: inserted.id };
|
|
1273
|
-
}
|
|
1274
|
-
//#endregion
|
|
1275
|
-
export { importMarkdown as _, deleteAsset as a, listAssets as c, readTheme as d, writeAsset as f, renderDocPage as g, exportDocument as h, createFolder as i, listFolders as l, closeRenderSession as m, readText as n, fileDocument as o, checkLayout as p, writeText as r, findAssetUsages as s, addComment as t, listThemes as u, slugify as v };
|
|
1232
|
+
export { listAssets as a, readTheme as c, closeRenderSession as d, exportDocument as f, slugify as h, findAssetUsages as i, writeAsset as l, importMarkdown as m, deleteAsset as n, listFolders as o, renderDocPage as p, fileDocument as r, listThemes as s, createFolder as t, checkLayout as u };
|
package/dist/vite/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as openDocPlugin, t as createViteConfig } from "../config-4nz5NnxW.js";
|
|
2
2
|
export { createViteConfig, openDocPlugin };
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { LOC_PROP, sourceAttrs } from '../lib/source-loc';
|
|
2
3
|
import { Figure } from './numbering';
|
|
3
4
|
|
|
4
5
|
export type DataAlign = 'left' | 'center' | 'right';
|
|
@@ -36,6 +37,8 @@ export type DataTableProps = {
|
|
|
36
37
|
emptyValue?: ReactNode;
|
|
37
38
|
style?: CSSProperties;
|
|
38
39
|
className?: string;
|
|
40
|
+
/** Stamped in dev by the loc-tags plugin; see `lib/source-loc.ts`. */
|
|
41
|
+
[LOC_PROP]?: string;
|
|
39
42
|
};
|
|
40
43
|
|
|
41
44
|
function normalizeColumn(column: DataColumn | string): DataColumn {
|
|
@@ -95,6 +98,7 @@ export function DataTable({
|
|
|
95
98
|
emptyValue = '—',
|
|
96
99
|
style,
|
|
97
100
|
className,
|
|
101
|
+
[LOC_PROP]: loc,
|
|
98
102
|
}: DataTableProps) {
|
|
99
103
|
const resolved: DataColumn[] = (columns ?? Object.keys(rows[0] ?? {})).map(normalizeColumn);
|
|
100
104
|
|
|
@@ -105,6 +109,7 @@ export function DataTable({
|
|
|
105
109
|
|
|
106
110
|
const table = (
|
|
107
111
|
<table
|
|
112
|
+
{...(caption ? {} : sourceAttrs(loc))}
|
|
108
113
|
className={className}
|
|
109
114
|
style={{
|
|
110
115
|
width: '100%',
|
|
@@ -116,11 +121,16 @@ export function DataTable({
|
|
|
116
121
|
>
|
|
117
122
|
<thead>
|
|
118
123
|
<tr>
|
|
119
|
-
{resolved.map((column) => {
|
|
124
|
+
{resolved.map((column, index) => {
|
|
120
125
|
const align = column.align ?? inferAlign(rows, column.key);
|
|
126
|
+
const authored = columns?.[index];
|
|
127
|
+
// Only a label written as a string can be edited where it prints;
|
|
128
|
+
// a bare key would rename the column the data is read from.
|
|
129
|
+
const labelled = typeof authored === 'object' && typeof authored.label === 'string';
|
|
121
130
|
return (
|
|
122
131
|
<th
|
|
123
132
|
key={column.key}
|
|
133
|
+
{...(labelled ? sourceAttrs(loc, `columns.${index}.label`) : {})}
|
|
124
134
|
style={{
|
|
125
135
|
textAlign: align,
|
|
126
136
|
width: column.width,
|
|
@@ -189,7 +199,12 @@ export function DataTable({
|
|
|
189
199
|
if (!caption) return table;
|
|
190
200
|
|
|
191
201
|
return (
|
|
192
|
-
<Figure
|
|
202
|
+
<Figure
|
|
203
|
+
kind="table"
|
|
204
|
+
caption={caption}
|
|
205
|
+
{...(id !== undefined ? { id } : {})}
|
|
206
|
+
{...sourceAttrs(loc)}
|
|
207
|
+
>
|
|
193
208
|
{table}
|
|
194
209
|
</Figure>
|
|
195
210
|
);
|