@json-to-office/core-docx 7.2.0 → 7.3.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/index.js +1539 -471
- package/dist/index.js.map +1 -1
- package/dist/ir/chartValues.d.ts +16 -0
- package/dist/ir/chartValues.d.ts.map +1 -0
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/ir/features.d.ts.map +1 -1
- package/dist/ir/theme.d.ts +43 -0
- package/dist/ir/theme.d.ts.map +1 -0
- package/dist/ir/types.d.ts +39 -3
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/validation.d.ts +2 -1
- package/dist/ir/validation.d.ts.map +1 -1
- package/dist/plugin/example/index.js +1536 -468
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/renderers/chartText.d.ts +43 -0
- package/dist/renderers/chartText.d.ts.map +1 -0
- package/dist/renderers/docxjs/charts.d.ts +45 -0
- package/dist/renderers/docxjs/charts.d.ts.map +1 -0
- package/dist/renderers/docxjs/docxSubpath.d.ts +34 -0
- package/dist/renderers/docxjs/docxSubpath.d.ts.map +1 -0
- package/dist/renderers/docxjs/drawingGroup.d.ts +79 -0
- package/dist/renderers/docxjs/drawingGroup.d.ts.map +1 -0
- package/dist/renderers/docxjs/drawingGroupRepair.d.ts +36 -0
- package/dist/renderers/docxjs/drawingGroupRepair.d.ts.map +1 -0
- package/dist/renderers/docxjs/emit.d.ts +10 -2
- package/dist/renderers/docxjs/emit.d.ts.map +1 -1
- package/dist/renderers/docxjs/index.d.ts +2 -1
- package/dist/renderers/docxjs/index.d.ts.map +1 -1
- package/dist/renderers/docxjs/presetShapes.d.ts +233 -0
- package/dist/renderers/docxjs/presetShapes.d.ts.map +1 -0
- package/dist/renderers/office-open/chartLook.d.ts +45 -0
- package/dist/renderers/office-open/chartLook.d.ts.map +1 -0
- package/dist/renderers/office-open/chartParts.d.ts +29 -15
- package/dist/renderers/office-open/chartParts.d.ts.map +1 -1
- package/dist/renderers/office-open/emit.d.ts +25 -39
- package/dist/renderers/office-open/emit.d.ts.map +1 -1
- package/dist/renderers/office-open/index.d.ts +16 -4
- package/dist/renderers/office-open/index.d.ts.map +1 -1
- package/dist/renderers/office-open/themePart.d.ts +28 -0
- package/dist/renderers/office-open/themePart.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/chartWorkbook.d.ts +2 -1
- package/dist/utils/chartWorkbook.d.ts.map +1 -1
- package/dist/utils/fixFloatingImageIds.d.ts +17 -9
- package/dist/utils/fixFloatingImageIds.d.ts.map +1 -1
- package/dist/utils/packageDocument.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/renderers/office-open/cellTocs.d.ts +0 -26
- package/dist/renderers/office-open/cellTocs.d.ts.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native chart's text roles, shared by both DOCX renderers.
|
|
3
|
+
*
|
|
4
|
+
* The IR carries one chart text style, resolved from the theme. A chart part
|
|
5
|
+
* has more text than that: tick labels, the legend, axis titles and the chart
|
|
6
|
+
* title. Which of them takes the style as is, and which adjusts it, is decided
|
|
7
|
+
* here once, so the two backends cannot drift apart on a chart's type — each
|
|
8
|
+
* only spells the roles in its own vocabulary.
|
|
9
|
+
*
|
|
10
|
+
* No `docx` or `@office-open` import: this sits outside both renderer
|
|
11
|
+
* directories, and the import boundary forbids either here.
|
|
12
|
+
*/
|
|
13
|
+
import type { DocxIrChartTextFont } from '../ir/types';
|
|
14
|
+
/** Word's chart title size over its chart text size: 14pt over 10pt. */
|
|
15
|
+
export declare const CHART_TITLE_SCALE = 1.4;
|
|
16
|
+
/** One chart text role: face, size in points, colour and weight. */
|
|
17
|
+
export interface ChartTextRole {
|
|
18
|
+
fontFamily: string;
|
|
19
|
+
fontSize: number;
|
|
20
|
+
color: string;
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ChartTextRoles {
|
|
24
|
+
/**
|
|
25
|
+
* Tick labels and the legend. No weight: as a chart-wide default, a `b`
|
|
26
|
+
* would also unbold the chart title.
|
|
27
|
+
*/
|
|
28
|
+
text: ChartTextRole;
|
|
29
|
+
/**
|
|
30
|
+
* Axis titles: the chart text at its own weight, which Word would otherwise
|
|
31
|
+
* draw at its large bold default.
|
|
32
|
+
*/
|
|
33
|
+
axisTitle: ChartTextRole;
|
|
34
|
+
/**
|
|
35
|
+
* The chart title. Once the chart text states a size the title has to state
|
|
36
|
+
* its own: Word scales an unsized title up from that default, LibreOffice
|
|
37
|
+
* draws it at the default itself — a title no bigger than a tick label. So
|
|
38
|
+
* it is written at Word's own ratio, bold as Word draws it.
|
|
39
|
+
*/
|
|
40
|
+
title: ChartTextRole;
|
|
41
|
+
}
|
|
42
|
+
export declare function chartTextRoles(font: DocxIrChartTextFont): ChartTextRoles;
|
|
43
|
+
//# sourceMappingURL=chartText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartText.d.ts","sourceRoot":"","sources":["../../src/renderers/chartText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC;IACpB;;;OAGG;IACH,SAAS,EAAE,aAAa,CAAC;IACzB;;;;;OAKG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,cAAc,CAYxE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A native chart on the docx.js renderer: `DocxIrChartRun` → docx 9.8's
|
|
3
|
+
* `ChartRun`.
|
|
4
|
+
*
|
|
5
|
+
* `ChartRun` writes the whole of a chart — the `c:chartSpace` part, its
|
|
6
|
+
* relationship and the workbook "Edit Data" opens — so this layer only
|
|
7
|
+
* translates vocabulary. Parity with office-open is on content and placement:
|
|
8
|
+
* data, series order and names, series colours, every text element's face,
|
|
9
|
+
* size, colour and weight, the title and axis titles, the legend, the extent
|
|
10
|
+
* and the anchor, and a chart area with no fill and no border. The plot's
|
|
11
|
+
* internals — gridlines, tick marks, axis lines, bar gaps — follow what Word
|
|
12
|
+
* writes for a chart made with Insert Chart, which is what `ChartRun`
|
|
13
|
+
* defaults to, and office-open writes the same (`../office-open/chartLook.ts`);
|
|
14
|
+
* a `ChartRun` default that changes has to change there too, or the
|
|
15
|
+
* cross-backend chart test fails.
|
|
16
|
+
*
|
|
17
|
+
* The chart-wide font carries no size in `ChartRun` (`Omit<ChartFont,
|
|
18
|
+
* "size">`), so every text element states its own. A new text element — data
|
|
19
|
+
* labels, a data table — has to do the same, or Word draws it at 9pt.
|
|
20
|
+
*
|
|
21
|
+
* `docx/charts` is loaded when `render()` starts rather than with the package:
|
|
22
|
+
* see `docxSubpath.ts`. Only types come from it statically.
|
|
23
|
+
*/
|
|
24
|
+
import type { IFloating, ParagraphChild } from 'docx';
|
|
25
|
+
import type { ChartRunOptions } from 'docx/charts';
|
|
26
|
+
import type { DocxIrChartRun } from '../../ir/types';
|
|
27
|
+
/**
|
|
28
|
+
* Load `docx/charts`, once per process. Never rejects: a docx without the
|
|
29
|
+
* entry fails only a document that draws a chart, when it is emitted.
|
|
30
|
+
* `render()` awaits it; a caller of `buildDocument` with charts must too.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadDocxCharts(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* `DocxIrChartRun` → `ChartRunOptions`.
|
|
35
|
+
*
|
|
36
|
+
* Pure, and exported for tests: asserting on options is far cheaper than
|
|
37
|
+
* unzipping a chart part.
|
|
38
|
+
*/
|
|
39
|
+
export declare function chartRunOptions(chart: DocxIrChartRun, floating?: IFloating): ChartRunOptions;
|
|
40
|
+
/**
|
|
41
|
+
* A chart run. Throws a named error when `docx/charts` was never loaded, or
|
|
42
|
+
* could not be — a docx older than 9.8.0.
|
|
43
|
+
*/
|
|
44
|
+
export declare function emitChart(chart: DocxIrChartRun, floating?: IFloating): ParagraphChild;
|
|
45
|
+
//# sourceMappingURL=charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/charts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,KAAK,EAIV,eAAe,EAEhB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAA6B,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhF;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9C;AAuBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,EACrB,QAAQ,CAAC,EAAE,SAAS,GACnB,eAAe,CAsIjB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,cAAc,EACrB,QAAQ,CAAC,EAAE,SAAS,GACnB,cAAc,CAMhB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `docx` subpath entry — `docx/charts`, `docx/shapes` — loaded when a
|
|
3
|
+
* render first asks for it.
|
|
4
|
+
*
|
|
5
|
+
* Dynamic rather than static on purpose. `docx` is a peer dependency and those
|
|
6
|
+
* entries exist from 9.8.0 on: a static import would make the whole package
|
|
7
|
+
* fail to load (`ERR_PACKAGE_PATH_NOT_EXPORTED`) for a consumer on an older
|
|
8
|
+
* docx, including one that never draws a chart or a drawing group. tsup keeps
|
|
9
|
+
* `import('docx/…')` external (`external: ['docx']`), so nothing is inlined
|
|
10
|
+
* either way; what changes is when the module is evaluated.
|
|
11
|
+
*
|
|
12
|
+
* `load()` never rejects. A failed import is kept, and `get()` reports it —
|
|
13
|
+
* naming the component that needed the entry — only when a document actually
|
|
14
|
+
* needs it, so a document without one renders on any docx the peer range
|
|
15
|
+
* allows.
|
|
16
|
+
*
|
|
17
|
+
* The importer must be a literal `() => import('docx/…')` at the call site:
|
|
18
|
+
* that is what tsup keeps external and what `vi.mock('docx/…')` intercepts.
|
|
19
|
+
*/
|
|
20
|
+
export interface DocxSubpath<T> {
|
|
21
|
+
/** The entry, e.g. `docx/charts`. */
|
|
22
|
+
readonly specifier: string;
|
|
23
|
+
/** Start the import (once per process) and wait for it. Never rejects. */
|
|
24
|
+
load(): Promise<void>;
|
|
25
|
+
/** Whether the entry loaded. */
|
|
26
|
+
loaded(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The loaded module. Throws a named error when `load()` was never awaited
|
|
29
|
+
* or the import failed.
|
|
30
|
+
*/
|
|
31
|
+
get(): T;
|
|
32
|
+
}
|
|
33
|
+
export declare function docxSubpath<T>(specifier: `docx/${string}`, component: string, importer: () => Promise<T>): DocxSubpath<T>;
|
|
34
|
+
//# sourceMappingURL=docxSubpath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docxSubpath.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/docxSubpath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,qCAAqC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,0EAA0E;IAC1E,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,gCAAgC;IAChC,MAAM,IAAI,OAAO,CAAC;IAClB;;;OAGG;IACH,GAAG,IAAI,CAAC,CAAC;CACV;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,SAAS,EAAE,QAAQ,MAAM,EAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,WAAW,CAAC,CAAC,CAAC,CAoChB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A drawing group (`wpg:wgp`), as a `docx/shapes` `ShapeGroupRun`.
|
|
3
|
+
*
|
|
4
|
+
* **A group, not a canvas.** `docx/shapes` also has `ShapeCanvasRun`, but a
|
|
5
|
+
* canvas's children keep their own size, so a canvas authored at one size and
|
|
6
|
+
* placed at another cannot be expressed; it also writes the whole diagram
|
|
7
|
+
* twice (`wpc:wpc` plus a `wpg:wgp` fallback in `mc:AlternateContent`). A
|
|
8
|
+
* group scales its children onto its extent and writes one bare `wpg:wgp`,
|
|
9
|
+
* which is exactly what the office-open adapter writes.
|
|
10
|
+
*
|
|
11
|
+
* **The pad.** `ShapeGroupRun` has no child-space option: it sets `a:chOff`
|
|
12
|
+
* and `a:chExt` to the union of the children's unrotated boxes. The IR's child
|
|
13
|
+
* space is the whole canvas, so when the children do not already reach every
|
|
14
|
+
* edge — any visual without a background — the first (bottom-most) child is an
|
|
15
|
+
* invisible, decorative rectangle the size of the canvas, the same pad
|
|
16
|
+
* upstream's own canvas-to-group fallback uses. With a background the union
|
|
17
|
+
* already is the canvas and no pad is written, so the child list matches
|
|
18
|
+
* office-open's.
|
|
19
|
+
*
|
|
20
|
+
* **The tolerance.** The compiler rounds each offset and extent on its own, so
|
|
21
|
+
* an element meant to end on the canvas edge can overshoot it by an EMU or
|
|
22
|
+
* two. Within `OVERFLOW_TOLERANCE_EMU` that counts as reaching the edge: no
|
|
23
|
+
* pad, and the placed size is kept. Beyond it the children really overflow,
|
|
24
|
+
* and the group keeps the authored scale — the extent grows by the overflow —
|
|
25
|
+
* where office-open draws the overflow outside a frame of the placed size.
|
|
26
|
+
*
|
|
27
|
+
* **The markers.** docx.js writes two things this adapter must not keep, and
|
|
28
|
+
* offers no option to leave them out, so each is replaced by a marker the
|
|
29
|
+
* post-pack repair (`drawingGroupRepair.ts`) removes:
|
|
30
|
+
* - With no truthy alt text, docx.js describes the group from its children's
|
|
31
|
+
* names (`descr="Canvas background. Shape elements[0]."`). A marker
|
|
32
|
+
* description suppresses that, and the repair drops the attribute.
|
|
33
|
+
* - It never writes `wps:cNvSpPr txBox="1"`, which is how Word tells a text box
|
|
34
|
+
* from a shape holding text. A marker title on the text box's `wps:cNvPr`
|
|
35
|
+
* says where it belongs, and the repair moves it there.
|
|
36
|
+
* The markers are chosen per IR (`chooseMarkers`) so that no string an author
|
|
37
|
+
* wrote can contain one: nothing authored is ever stripped, and the repair's
|
|
38
|
+
* check that no marker survived cannot be tripped by content.
|
|
39
|
+
*
|
|
40
|
+
* **Stated defaults.** Where `docx/shapes` defaults differ from OOXML's, the
|
|
41
|
+
* OOXML default is stated: text anchored at the top rather than centred, no
|
|
42
|
+
* fill, and no line rather than a black 1pt one.
|
|
43
|
+
*
|
|
44
|
+
* **Partial outlines**, as office-open draws them: an outline with no colour
|
|
45
|
+
* strokes nothing (office-open writes an `a:ln` with no fill), and one with a
|
|
46
|
+
* colour but no width is a hairline (`w="0"`, office-open's omitted `w`).
|
|
47
|
+
*
|
|
48
|
+
* **Clamps.** docx throws for a line width or text inset outside 0–1584pt,
|
|
49
|
+
* which is also the most `ST_LineWidth` and Word allow; the schema has no
|
|
50
|
+
* maximum for either, so they are clamped rather than refused. Transparency is
|
|
51
|
+
* clamped to 0–100 for the same reason.
|
|
52
|
+
*/
|
|
53
|
+
import type { IShapeGroupOptions, ImageSource } from 'docx/shapes';
|
|
54
|
+
import type { DocxIR, DocxIrDrawingGroupRun } from '../../ir/types';
|
|
55
|
+
import { type DrawingGroupFactory, type EmitResources } from './emit';
|
|
56
|
+
export type ShapesModule = typeof import('docx/shapes');
|
|
57
|
+
/** The picture a group child draws, for one resource at one size. */
|
|
58
|
+
export type GroupPictureSource = (resourceId: string, placement: {
|
|
59
|
+
widthEmu: number;
|
|
60
|
+
heightEmu: number;
|
|
61
|
+
}) => ImageSource;
|
|
62
|
+
export interface DrawingGroupMarkers {
|
|
63
|
+
/** A `wp:docPr` description standing for "no alt text". */
|
|
64
|
+
readonly noAltText: string;
|
|
65
|
+
/** A `wps:cNvPr` title standing for `wps:cNvSpPr txBox="1"`. */
|
|
66
|
+
readonly textBox: string;
|
|
67
|
+
}
|
|
68
|
+
export declare const DEFAULT_MARKERS: DrawingGroupMarkers;
|
|
69
|
+
/** Two independent `Math.round` calls in `ir/nativeVisual.ts`: 1 EMU each. */
|
|
70
|
+
export declare const OVERFLOW_TOLERANCE_EMU = 2;
|
|
71
|
+
/**
|
|
72
|
+
* Markers no string in this IR contains, so the repair can never strip or
|
|
73
|
+
* trip on authored content.
|
|
74
|
+
*/
|
|
75
|
+
export declare function chooseMarkers(ir: DocxIR): DrawingGroupMarkers;
|
|
76
|
+
export declare function createDrawingGroupFactory(shapes: ShapesModule, pictures: GroupPictureSource, markers: DrawingGroupMarkers): DrawingGroupFactory;
|
|
77
|
+
/** Exported for tests: asserting on the option bag needs no `docx/shapes`. */
|
|
78
|
+
export declare function drawingGroupOptions(group: DocxIrDrawingGroupRun, resources: EmitResources, pictures: GroupPictureSource, markers?: DrawingGroupMarkers): IShapeGroupOptions;
|
|
79
|
+
//# sourceMappingURL=drawingGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawingGroup.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/drawingGroup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAGH,OAAO,KAAK,EAEV,kBAAkB,EAClB,WAAW,EAIZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,MAAM,EAIN,qBAAqB,EAKtB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AAGhB,MAAM,MAAM,YAAY,GAAG,cAAc,aAAa,CAAC,CAAC;AAExD,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,CAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAC/C,WAAW,CAAC;AAEjB,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,EAAE,mBAG7B,CAAC;AAKF,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAa7D;AA+BD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAKrB;AAED,8EAA8E;AAC9E,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,qBAAqB,EAC5B,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,mBAAqC,GAC7C,kBAAkB,CAkDpB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-pack repair for drawing groups written by `docx/shapes`.
|
|
3
|
+
*
|
|
4
|
+
* Runs after `fixFloatingImageIdsInBuffer`, and only for a package whose IR
|
|
5
|
+
* holds a drawing group. Three things `docx/shapes` writes cannot be stated
|
|
6
|
+
* through its options, so they are put right here:
|
|
7
|
+
*
|
|
8
|
+
* - **Child ids.** Every `wps:cNvPr`/`pic:cNvPr`/`wpg:cNvPr` inside a group is
|
|
9
|
+
* drawn from docx's process-wide drawing counter, so the same document came
|
|
10
|
+
* out with different ids depending on what the process built before. They
|
|
11
|
+
* are renumbered in one sequence that starts after the highest drawing id
|
|
12
|
+
* anywhere else in the package, walking the parts in the order
|
|
13
|
+
* `fixFloatingImageIds` numbers `wp:docPr` in. Taking the maximum rather
|
|
14
|
+
* than assuming a count keeps this pass independent of how that one
|
|
15
|
+
* numbers. No connector (`a:stCxn`/`a:endCxn`) is ever emitted, so nothing
|
|
16
|
+
* refers to these ids.
|
|
17
|
+
* - **Rotation.** docx writes `rot` as degrees × 60000 without rounding, and
|
|
18
|
+
* `7.123456°` becomes `rot="427407.36"`, which `ST_Angle` (an int) forbids.
|
|
19
|
+
* It is rounded — and not wrapped into [0, 360°), exactly as office-open's
|
|
20
|
+
* `emitAngle` writes it, so `-30°` stays `rot="-1800000"`.
|
|
21
|
+
* - **Markers** (see `drawingGroup.ts`): the `wp:docPr` description that stood
|
|
22
|
+
* for "no alt text" is dropped, and the `wps:cNvPr` title that stood for a
|
|
23
|
+
* text box becomes `wps:cNvSpPr txBox="1"`. A marker that survives means
|
|
24
|
+
* docx changed how it serialises one of them; that is a pipeline bug and
|
|
25
|
+
* throws, naming the part, rather than shipping a stray attribute.
|
|
26
|
+
*
|
|
27
|
+
* Every part holding a group is rewritten unconditionally, for the reason
|
|
28
|
+
* `fixFloatingImageIds` gives: whether an id "changed" depends on the process
|
|
29
|
+
* counter, and a rewritten entry is deflated differently from one left alone,
|
|
30
|
+
* so a changed-only rule would leak the counter into the package bytes.
|
|
31
|
+
*/
|
|
32
|
+
/// <reference types="node" />
|
|
33
|
+
/// <reference types="node" />
|
|
34
|
+
import type { DrawingGroupMarkers } from './drawingGroup';
|
|
35
|
+
export declare function repairDrawingGroupsInBuffer(buffer: Buffer, markers: DrawingGroupMarkers): Buffer;
|
|
36
|
+
//# sourceMappingURL=drawingGroupRepair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawingGroupRepair.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/drawingGroupRepair.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAOH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAe1D,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CA0DR"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* is dropped by Word and paragraph tab stops only bind to real tab runs.
|
|
13
13
|
*/
|
|
14
14
|
import { AlignmentType, Paragraph, Table, TableOfContents, type IParagraphOptions, type IRunOptions, type ParagraphChild } from 'docx';
|
|
15
|
-
import type { DocxIrBlock, DocxIrFloating, DocxIrImageRun, DocxIrInline, DocxIrParagraph, DocxIrParagraphFormatting, DocxIrRunFormatting, DocxIrTable } from '../../ir/types';
|
|
15
|
+
import type { DocxIrBlock, DocxIrDrawingGroupRun, DocxIrFloating, DocxIrImageRun, DocxIrInline, DocxIrParagraph, DocxIrParagraphFormatting, DocxIrRunFormatting, DocxIrTable } from '../../ir/types';
|
|
16
16
|
export declare const ALIGNMENT: Readonly<Record<string, (typeof AlignmentType)[keyof typeof AlignmentType]>>;
|
|
17
17
|
/**
|
|
18
18
|
* Image runs, keyed by IR resource id.
|
|
@@ -21,7 +21,15 @@ export declare const ALIGNMENT: Readonly<Record<string, (typeof AlignmentType)[k
|
|
|
21
21
|
* asynchronous — it rasterises a fallback. So the renderer builds them all
|
|
22
22
|
* before the document, and this layer only places them.
|
|
23
23
|
*/
|
|
24
|
-
export
|
|
24
|
+
export interface EmitResources extends ReadonlyMap<string, ImageRunFactory> {
|
|
25
|
+
/**
|
|
26
|
+
* Builds a drawing group's run. Present only when the IR holds one, because
|
|
27
|
+
* `docx/shapes` is loaded on demand (`drawingGroup.ts`).
|
|
28
|
+
*/
|
|
29
|
+
readonly drawingGroup?: DrawingGroupFactory;
|
|
30
|
+
}
|
|
31
|
+
/** Builds the run for one drawing group, placed and anchored. */
|
|
32
|
+
export type DrawingGroupFactory = (group: DocxIrDrawingGroupRun, resources: EmitResources) => ParagraphChild;
|
|
25
33
|
/** Builds the run for one placement, which carries its own size and anchor. */
|
|
26
34
|
export type ImageRunFactory = (image: DocxIrImageRun) => ParagraphChild;
|
|
27
35
|
export declare function runOptions(formatting: DocxIrRunFormatting | undefined): IRunOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EAeb,SAAS,EAMT,KAAK,EAIL,eAAe,
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EAeb,SAAS,EAMT,KAAK,EAIL,eAAe,EASf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,KAAK,cAAc,EACpB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EACV,WAAW,EAEX,qBAAqB,EACrB,cAAc,EAEd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,yBAAyB,EAGzB,mBAAmB,EAEnB,WAAW,EAKZ,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,SAAS,EAAE,QAAQ,CAC9B,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC,CAQnE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC;IACzE;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CAC7C;AAED,iEAAiE;AACjE,MAAM,MAAM,mBAAmB,GAAG,CAChC,KAAK,EAAE,qBAAqB,EAC5B,SAAS,EAAE,aAAa,KACrB,cAAc,CAAC;AAEpB,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,CAAC;AA2ExE,wBAAgB,UAAU,CACxB,UAAU,EAAE,mBAAmB,GAAG,SAAS,GAC1C,WAAW,CAqCb;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,SAAS,GAAE,aAAyB,GACnC,cAAc,EAAE,CAqLlB;AAyDD,gDAAgD;AAChD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwEzB;AA4CD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,yBAAyB,GAAG,SAAS,GAChD,OAAO,CAAC,iBAAiB,CAAC,CAoE5B;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,EACtB,SAAS,GAAE,aAAyB,GACnC,SAAS,CAsBX;AAqCD,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,SAAS,GAAE,aAAyB,GACnC,SAAS,GAAG,KAAK,GAAG,eAAe,CAWrC;AA4ED,wBAAgB,SAAS,CACvB,KAAK,EAAE,WAAW,EAClB,SAAS,GAAE,aAAyB,GACnC,KAAK,CA+BP"}
|
|
@@ -16,7 +16,8 @@ export declare function createDocxJsRenderer(): DocxRenderer;
|
|
|
16
16
|
* Build the docx.js object graph for an IR document.
|
|
17
17
|
*
|
|
18
18
|
* Exported for tests: asserting on the object graph is far cheaper, and far
|
|
19
|
-
* more legible, than unzipping a package.
|
|
19
|
+
* more legible, than unzipping a package. An IR with charts needs
|
|
20
|
+
* `await loadDocxCharts()` first; `render()` does it.
|
|
20
21
|
*/
|
|
21
22
|
export declare function buildDocument(ir: DocxIR, resources?: EmitResources): Document;
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,QAAQ,EAcT,MAAM,MAAM,CAAC;AAOd,OAAO,KAAK,EACV,MAAM,EAQP,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAKL,KAAK,aAAa,EAEnB,MAAM,QAAQ,CAAC;AAUhB,eAAO,MAAM,kBAAkB,EAAE,cAAyB,CAAC;AAwD3D,wBAAgB,oBAAoB,IAAI,YAAY,CAkDnD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,SAAS,GAAE,aAAyB,GACnC,QAAQ,CA8CV"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OOXML preset names → the names `docx/shapes` takes.
|
|
3
|
+
*
|
|
4
|
+
* The IR speaks OOXML — `a:prstGeom/@prst`, `a:prstDash/@val` — because that
|
|
5
|
+
* is what a DOCX stores and what the office-open backend writes verbatim.
|
|
6
|
+
* `docx/shapes` takes readable names instead (`roundRect` is
|
|
7
|
+
* `"roundedRectangle"`, `sysDot` is `"shortDot"`) and translates them back on
|
|
8
|
+
* the way out. Its own OOXML tables are declared but not exported, so the
|
|
9
|
+
* mapping lives here.
|
|
10
|
+
*
|
|
11
|
+
* Both maps are total over what docx 9.8.0 accepts, and a compile-time guard
|
|
12
|
+
* breaks the build when an upgrade adds a name the map lacks. Both lookups
|
|
13
|
+
* throw on a name they do not know rather than passing it through: docx throws
|
|
14
|
+
* for an unknown preset, but it writes an empty `<a:prstDash/>` for an unknown
|
|
15
|
+
* dash, which Word reads as solid — a silent change of look.
|
|
16
|
+
*/
|
|
17
|
+
import type { LineDash, PresetShapeType } from 'docx/shapes';
|
|
18
|
+
/**
|
|
19
|
+
* OOXML `a:prstGeom/@prst` → `docx/shapes` preset name, total over the 187
|
|
20
|
+
* `ST_ShapeType` values. Generated from `PRESET_SHAPE_OOXML_NAMES` in
|
|
21
|
+
* `docx/dist/shapes.d.ts`, in upstream order.
|
|
22
|
+
*/
|
|
23
|
+
export declare const OOXML_PRESET_TO_DOCX: {
|
|
24
|
+
readonly line: "line";
|
|
25
|
+
readonly lineInv: "inverseLine";
|
|
26
|
+
readonly straightConnector1: "straightConnector";
|
|
27
|
+
readonly bentConnector2: "elbowConnectorOneBend";
|
|
28
|
+
readonly bentConnector3: "elbowConnector";
|
|
29
|
+
readonly bentConnector4: "elbowConnectorThreeBends";
|
|
30
|
+
readonly bentConnector5: "elbowConnectorFourBends";
|
|
31
|
+
readonly curvedConnector2: "curvedConnectorOneBend";
|
|
32
|
+
readonly curvedConnector3: "curvedConnector";
|
|
33
|
+
readonly curvedConnector4: "curvedConnectorThreeBends";
|
|
34
|
+
readonly curvedConnector5: "curvedConnectorFourBends";
|
|
35
|
+
readonly triangle: "triangle";
|
|
36
|
+
readonly rtTriangle: "rightTriangle";
|
|
37
|
+
readonly diamond: "diamond";
|
|
38
|
+
readonly parallelogram: "parallelogram";
|
|
39
|
+
readonly trapezoid: "trapezoid";
|
|
40
|
+
readonly nonIsoscelesTrapezoid: "nonIsoscelesTrapezoid";
|
|
41
|
+
readonly pentagon: "pentagon";
|
|
42
|
+
readonly hexagon: "hexagon";
|
|
43
|
+
readonly heptagon: "heptagon";
|
|
44
|
+
readonly octagon: "octagon";
|
|
45
|
+
readonly decagon: "decagon";
|
|
46
|
+
readonly dodecagon: "dodecagon";
|
|
47
|
+
readonly ellipse: "ellipse";
|
|
48
|
+
readonly teardrop: "teardrop";
|
|
49
|
+
readonly pieWedge: "pieWedge";
|
|
50
|
+
readonly pie: "pie";
|
|
51
|
+
readonly blockArc: "blockArc";
|
|
52
|
+
readonly donut: "donut";
|
|
53
|
+
readonly noSmoking: "noSymbol";
|
|
54
|
+
readonly chord: "chord";
|
|
55
|
+
readonly arc: "arc";
|
|
56
|
+
readonly frame: "frame";
|
|
57
|
+
readonly halfFrame: "halfFrame";
|
|
58
|
+
readonly corner: "lShape";
|
|
59
|
+
readonly diagStripe: "diagonalStripe";
|
|
60
|
+
readonly plus: "cross";
|
|
61
|
+
readonly plaque: "plaque";
|
|
62
|
+
readonly can: "cylinder";
|
|
63
|
+
readonly cube: "cube";
|
|
64
|
+
readonly bevel: "beveledRectangle";
|
|
65
|
+
readonly foldedCorner: "foldedCorner";
|
|
66
|
+
readonly smileyFace: "smileyFace";
|
|
67
|
+
readonly heart: "heart";
|
|
68
|
+
readonly lightningBolt: "lightningBolt";
|
|
69
|
+
readonly sun: "sun";
|
|
70
|
+
readonly moon: "moon";
|
|
71
|
+
readonly cloud: "cloud";
|
|
72
|
+
readonly leftBracket: "leftBracket";
|
|
73
|
+
readonly rightBracket: "rightBracket";
|
|
74
|
+
readonly leftBrace: "leftBrace";
|
|
75
|
+
readonly rightBrace: "rightBrace";
|
|
76
|
+
readonly bracketPair: "bracketPair";
|
|
77
|
+
readonly bracePair: "bracePair";
|
|
78
|
+
readonly rect: "rectangle";
|
|
79
|
+
readonly roundRect: "roundedRectangle";
|
|
80
|
+
readonly round1Rect: "roundedCornerRectangle";
|
|
81
|
+
readonly round2SameRect: "topRoundedCornersRectangle";
|
|
82
|
+
readonly round2DiagRect: "diagonalRoundedCornersRectangle";
|
|
83
|
+
readonly snip1Rect: "snippedCornerRectangle";
|
|
84
|
+
readonly snip2SameRect: "topSnippedCornersRectangle";
|
|
85
|
+
readonly snip2DiagRect: "diagonalSnippedCornersRectangle";
|
|
86
|
+
readonly snipRoundRect: "roundedAndSnippedCornersRectangle";
|
|
87
|
+
readonly rightArrow: "rightArrow";
|
|
88
|
+
readonly leftArrow: "leftArrow";
|
|
89
|
+
readonly upArrow: "upArrow";
|
|
90
|
+
readonly downArrow: "downArrow";
|
|
91
|
+
readonly leftRightArrow: "leftRightArrow";
|
|
92
|
+
readonly upDownArrow: "upDownArrow";
|
|
93
|
+
readonly quadArrow: "quadArrow";
|
|
94
|
+
readonly leftRightUpArrow: "leftRightUpArrow";
|
|
95
|
+
readonly bentArrow: "bentArrow";
|
|
96
|
+
readonly uturnArrow: "uTurnArrow";
|
|
97
|
+
readonly leftUpArrow: "leftUpArrow";
|
|
98
|
+
readonly bentUpArrow: "bentUpArrow";
|
|
99
|
+
readonly curvedRightArrow: "curvedRightArrow";
|
|
100
|
+
readonly curvedLeftArrow: "curvedLeftArrow";
|
|
101
|
+
readonly curvedUpArrow: "curvedUpArrow";
|
|
102
|
+
readonly curvedDownArrow: "curvedDownArrow";
|
|
103
|
+
readonly stripedRightArrow: "stripedRightArrow";
|
|
104
|
+
readonly notchedRightArrow: "notchedRightArrow";
|
|
105
|
+
readonly homePlate: "pentagonArrow";
|
|
106
|
+
readonly chevron: "chevron";
|
|
107
|
+
readonly rightArrowCallout: "rightArrowCallout";
|
|
108
|
+
readonly downArrowCallout: "downArrowCallout";
|
|
109
|
+
readonly leftArrowCallout: "leftArrowCallout";
|
|
110
|
+
readonly upArrowCallout: "upArrowCallout";
|
|
111
|
+
readonly leftRightArrowCallout: "leftRightArrowCallout";
|
|
112
|
+
readonly upDownArrowCallout: "upDownArrowCallout";
|
|
113
|
+
readonly quadArrowCallout: "quadArrowCallout";
|
|
114
|
+
readonly circularArrow: "circularArrow";
|
|
115
|
+
readonly leftCircularArrow: "leftCircularArrow";
|
|
116
|
+
readonly leftRightCircularArrow: "leftRightCircularArrow";
|
|
117
|
+
readonly swooshArrow: "swooshArrow";
|
|
118
|
+
readonly mathPlus: "mathPlus";
|
|
119
|
+
readonly mathMinus: "mathMinus";
|
|
120
|
+
readonly mathMultiply: "mathMultiply";
|
|
121
|
+
readonly mathDivide: "mathDivide";
|
|
122
|
+
readonly mathEqual: "mathEqual";
|
|
123
|
+
readonly mathNotEqual: "mathNotEqual";
|
|
124
|
+
readonly flowChartProcess: "flowChartProcess";
|
|
125
|
+
readonly flowChartAlternateProcess: "flowChartAlternateProcess";
|
|
126
|
+
readonly flowChartDecision: "flowChartDecision";
|
|
127
|
+
readonly flowChartInputOutput: "flowChartInputOutput";
|
|
128
|
+
readonly flowChartPredefinedProcess: "flowChartPredefinedProcess";
|
|
129
|
+
readonly flowChartInternalStorage: "flowChartInternalStorage";
|
|
130
|
+
readonly flowChartDocument: "flowChartDocument";
|
|
131
|
+
readonly flowChartMultidocument: "flowChartMultidocument";
|
|
132
|
+
readonly flowChartTerminator: "flowChartTerminator";
|
|
133
|
+
readonly flowChartPreparation: "flowChartPreparation";
|
|
134
|
+
readonly flowChartManualInput: "flowChartManualInput";
|
|
135
|
+
readonly flowChartManualOperation: "flowChartManualOperation";
|
|
136
|
+
readonly flowChartConnector: "flowChartConnector";
|
|
137
|
+
readonly flowChartOffpageConnector: "flowChartOffpageConnector";
|
|
138
|
+
readonly flowChartPunchedCard: "flowChartPunchedCard";
|
|
139
|
+
readonly flowChartPunchedTape: "flowChartPunchedTape";
|
|
140
|
+
readonly flowChartSummingJunction: "flowChartSummingJunction";
|
|
141
|
+
readonly flowChartOr: "flowChartOr";
|
|
142
|
+
readonly flowChartCollate: "flowChartCollate";
|
|
143
|
+
readonly flowChartSort: "flowChartSort";
|
|
144
|
+
readonly flowChartExtract: "flowChartExtract";
|
|
145
|
+
readonly flowChartMerge: "flowChartMerge";
|
|
146
|
+
readonly flowChartOfflineStorage: "flowChartOfflineStorage";
|
|
147
|
+
readonly flowChartOnlineStorage: "flowChartOnlineStorage";
|
|
148
|
+
readonly flowChartDelay: "flowChartDelay";
|
|
149
|
+
readonly flowChartMagneticTape: "flowChartMagneticTape";
|
|
150
|
+
readonly flowChartMagneticDisk: "flowChartMagneticDisk";
|
|
151
|
+
readonly flowChartMagneticDrum: "flowChartMagneticDrum";
|
|
152
|
+
readonly flowChartDisplay: "flowChartDisplay";
|
|
153
|
+
readonly irregularSeal1: "explosion12";
|
|
154
|
+
readonly irregularSeal2: "explosion14";
|
|
155
|
+
readonly star4: "star4";
|
|
156
|
+
readonly star5: "star5";
|
|
157
|
+
readonly star6: "star6";
|
|
158
|
+
readonly star7: "star7";
|
|
159
|
+
readonly star8: "star8";
|
|
160
|
+
readonly star10: "star10";
|
|
161
|
+
readonly star12: "star12";
|
|
162
|
+
readonly star16: "star16";
|
|
163
|
+
readonly star24: "star24";
|
|
164
|
+
readonly star32: "star32";
|
|
165
|
+
readonly ribbon2: "ribbonUp";
|
|
166
|
+
readonly ribbon: "ribbonDown";
|
|
167
|
+
readonly ellipseRibbon2: "curvedRibbonUp";
|
|
168
|
+
readonly ellipseRibbon: "curvedRibbonDown";
|
|
169
|
+
readonly leftRightRibbon: "leftRightRibbon";
|
|
170
|
+
readonly verticalScroll: "verticalScroll";
|
|
171
|
+
readonly horizontalScroll: "horizontalScroll";
|
|
172
|
+
readonly wave: "wave";
|
|
173
|
+
readonly doubleWave: "doubleWave";
|
|
174
|
+
readonly wedgeRectCallout: "rectangularCallout";
|
|
175
|
+
readonly wedgeRoundRectCallout: "roundedRectangularCallout";
|
|
176
|
+
readonly wedgeEllipseCallout: "ellipticalCallout";
|
|
177
|
+
readonly cloudCallout: "cloudCallout";
|
|
178
|
+
readonly borderCallout1: "lineCallout";
|
|
179
|
+
readonly borderCallout2: "bentLineCallout";
|
|
180
|
+
readonly borderCallout3: "doubleBentLineCallout";
|
|
181
|
+
readonly accentCallout1: "lineCalloutWithAccentBar";
|
|
182
|
+
readonly accentCallout2: "bentLineCalloutWithAccentBar";
|
|
183
|
+
readonly accentCallout3: "doubleBentLineCalloutWithAccentBar";
|
|
184
|
+
readonly callout1: "lineCalloutWithNoBorder";
|
|
185
|
+
readonly callout2: "bentLineCalloutWithNoBorder";
|
|
186
|
+
readonly callout3: "doubleBentLineCalloutWithNoBorder";
|
|
187
|
+
readonly accentBorderCallout1: "lineCalloutWithBorderAndAccentBar";
|
|
188
|
+
readonly accentBorderCallout2: "bentLineCalloutWithBorderAndAccentBar";
|
|
189
|
+
readonly accentBorderCallout3: "doubleBentLineCalloutWithBorderAndAccentBar";
|
|
190
|
+
readonly actionButtonBlank: "actionButtonBlank";
|
|
191
|
+
readonly actionButtonHome: "actionButtonHome";
|
|
192
|
+
readonly actionButtonHelp: "actionButtonHelp";
|
|
193
|
+
readonly actionButtonInformation: "actionButtonInformation";
|
|
194
|
+
readonly actionButtonForwardNext: "actionButtonForwardNext";
|
|
195
|
+
readonly actionButtonBackPrevious: "actionButtonBackPrevious";
|
|
196
|
+
readonly actionButtonEnd: "actionButtonEnd";
|
|
197
|
+
readonly actionButtonBeginning: "actionButtonBeginning";
|
|
198
|
+
readonly actionButtonReturn: "actionButtonReturn";
|
|
199
|
+
readonly actionButtonDocument: "actionButtonDocument";
|
|
200
|
+
readonly actionButtonSound: "actionButtonSound";
|
|
201
|
+
readonly actionButtonMovie: "actionButtonMovie";
|
|
202
|
+
readonly gear6: "gear6";
|
|
203
|
+
readonly gear9: "gear9";
|
|
204
|
+
readonly funnel: "funnel";
|
|
205
|
+
readonly cornerTabs: "cornerTabs";
|
|
206
|
+
readonly squareTabs: "squareTabs";
|
|
207
|
+
readonly plaqueTabs: "plaqueTabs";
|
|
208
|
+
readonly chartX: "chartX";
|
|
209
|
+
readonly chartStar: "chartStar";
|
|
210
|
+
readonly chartPlus: "chartPlus";
|
|
211
|
+
};
|
|
212
|
+
/** The `docx/shapes` name for an OOXML preset geometry. */
|
|
213
|
+
export declare function docxPresetShape(geometry: string): PresetShapeType;
|
|
214
|
+
/** OOXML `a:prstDash/@val` → `docx/shapes` dash name, total over `ST_PresetLineDashVal`. */
|
|
215
|
+
export declare const OOXML_DASH_TO_DOCX: {
|
|
216
|
+
readonly solid: "solid";
|
|
217
|
+
readonly dot: "dot";
|
|
218
|
+
readonly dash: "dash";
|
|
219
|
+
readonly lgDash: "longDash";
|
|
220
|
+
readonly dashDot: "dashDot";
|
|
221
|
+
readonly lgDashDot: "longDashDot";
|
|
222
|
+
readonly lgDashDotDot: "longDashDotDot";
|
|
223
|
+
readonly sysDash: "shortDash";
|
|
224
|
+
readonly sysDot: "shortDot";
|
|
225
|
+
readonly sysDashDot: "shortDashDot";
|
|
226
|
+
readonly sysDashDotDot: "shortDashDotDot";
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* The `docx/shapes` name for an OOXML dash. Throws on an unknown one, which
|
|
230
|
+
* docx itself would write as an empty `<a:prstDash/>` without a word.
|
|
231
|
+
*/
|
|
232
|
+
export declare function docxLineDash(dash: string): LineDash;
|
|
233
|
+
//# sourceMappingURL=presetShapes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presetShapes.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/presetShapes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4LmB,CAAC;AAWrD,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAUjE;AAED,4FAA4F;AAC5F,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAYc,CAAC;AAS9C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAUnD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Word's Insert Chart look, stated for office-open's charts.
|
|
3
|
+
*
|
|
4
|
+
* On the docx.js renderer `ChartRun` writes a chart the way Word's Insert
|
|
5
|
+
* Chart does: value gridlines and a category axis line in a tint of Text 1,
|
|
6
|
+
* no tick marks, Word's bar gaps, straight lines with round markers, slice
|
|
7
|
+
* borders in Background 1, a doughnut with a hole. `@office-open/docx` states
|
|
8
|
+
* none of it, and each reader fills the gap its own way — cross ticks, dark
|
|
9
|
+
* axis lines, no gridlines, curved lines, a doughnut with no hole — while two
|
|
10
|
+
* of the gaps misdraw the data: a scatter chart's x values go in as text, so a
|
|
11
|
+
* reader plots them at 1, 2, 3…, and an untitled chart gets a title invented
|
|
12
|
+
* from its lone series' name, which also rescales its value axis.
|
|
13
|
+
*
|
|
14
|
+
* So office-open writes the look docx.js writes, and a chart draws the same on
|
|
15
|
+
* either renderer; `__tests__/chart-cross-backend.test.ts` holds the two to
|
|
16
|
+
* it, element by element. The look lives here, in one place, in two halves:
|
|
17
|
+
* what each series object states on its own (`seriesLook`) and the rest, in
|
|
18
|
+
* the shared look's vocabulary (`plotLook`), which `chartLook` in
|
|
19
|
+
* `@json-to-office/shared/rendering` turns into backend options.
|
|
20
|
+
*
|
|
21
|
+
* The tints are theme references, as Word writes them, not colours: the
|
|
22
|
+
* gridlines follow the document theme's Text 1 on both renderers.
|
|
23
|
+
*/
|
|
24
|
+
import type { ChartOptions } from '@office-open/docx';
|
|
25
|
+
import type { ChartPartInput } from '@json-to-office/shared/rendering';
|
|
26
|
+
import type { DocxIrChartRun, DocxIrChartType } from '../../ir/types';
|
|
27
|
+
/** The fields of a series the look sets on its own. */
|
|
28
|
+
export type SeriesLookFields = Pick<ChartOptions['series'][number], 'marker' | 'smooth' | 'invertIfNegative'>;
|
|
29
|
+
/**
|
|
30
|
+
* What each series object carries to the backend, which passes it through
|
|
31
|
+
* whole: the marker, a line that is not smoothed, and bars that keep their
|
|
32
|
+
* colour below zero.
|
|
33
|
+
*
|
|
34
|
+
* `c:smooth` has to be stated: with none, Word and LibreOffice both draw a
|
|
35
|
+
* line chart's series as a curve through its points.
|
|
36
|
+
*/
|
|
37
|
+
export declare function seriesLook(chartType: DocxIrChartType): SeriesLookFields;
|
|
38
|
+
/**
|
|
39
|
+
* Everything of the look but the series' own fields, for one chart.
|
|
40
|
+
*
|
|
41
|
+
* Axis edits come back whole, for `chartParts.ts` to merge its axis titles
|
|
42
|
+
* into.
|
|
43
|
+
*/
|
|
44
|
+
export declare function plotLook(chart: DocxIrChartRun): Partial<ChartPartInput>;
|
|
45
|
+
//# sourceMappingURL=chartLook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chartLook.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/chartLook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA+CtE,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAC9B,QAAQ,GAAG,QAAQ,GAAG,kBAAkB,CACzC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,eAAe,GAAG,gBAAgB,CAavE;AAwED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAuCvE"}
|