@json-to-office/core-docx 3.1.0 → 3.2.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/blocks/document.d.ts +18 -3
- package/dist/blocks/document.d.ts.map +1 -1
- package/dist/components/highcharts.d.ts +10 -1
- package/dist/components/highcharts.d.ts.map +1 -1
- package/dist/core/desugarExternals.d.ts +3 -1
- package/dist/core/desugarExternals.d.ts.map +1 -1
- package/dist/core/generateFromIr.d.ts.map +1 -1
- package/dist/index.js +159 -32
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/ir/inline.d.ts +1 -0
- package/dist/ir/inline.d.ts.map +1 -1
- package/dist/plugin/example/index.js +158 -31
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/quality/facts.d.ts +5 -0
- package/dist/quality/facts.d.ts.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { JsonBlockEvaluator, toAuthoredBlockPointer, type BlockEvaluatorOptions } from '@json-to-office/shared';
|
|
2
|
-
export { blockSlotBudgets } from '@json-to-office/shared';
|
|
2
|
+
export { blockSlotBudgets, blockSlotRoles } from '@json-to-office/shared';
|
|
3
3
|
export type { BlockSlotBudget, BlockSourceMap, ExpandedBlocks, } from '@json-to-office/shared';
|
|
4
4
|
import type { ExpandedBlocks } from '@json-to-office/shared';
|
|
5
5
|
import type { ThemeConfig } from '../styles';
|
|
6
6
|
type Rec = Record<string, unknown>;
|
|
7
7
|
export declare const toAuthoredPointer: typeof toAuthoredBlockPointer;
|
|
8
|
+
/** One source line the document cites, and the slot it was written in. */
|
|
9
|
+
export interface DocumentSourceLine {
|
|
10
|
+
text: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Every `source`-role slot value in document order, once per distinct text —
|
|
15
|
+
* what a "Notes and sources" block lists. Read from the authored invocations
|
|
16
|
+
* and their definitions; a block nested inside another's body is not in the
|
|
17
|
+
* authored document and so is not counted twice. One walk per expansion:
|
|
18
|
+
* callers compute it once and hand it to every context they build.
|
|
19
|
+
*/
|
|
20
|
+
export declare function documentSourceLines(document: unknown): DocumentSourceLine[];
|
|
8
21
|
/** General document state and page geometry. No report design is registered here. */
|
|
9
|
-
export declare function docxBlockContext(document: unknown, theme: ThemeConfig, path
|
|
10
|
-
|
|
22
|
+
export declare function docxBlockContext(document: unknown, theme: ThemeConfig, path: string, sources: readonly DocumentSourceLine[]): Rec;
|
|
23
|
+
/** Where each context value was authored, for findings that land on it. */
|
|
24
|
+
export declare function docxBlockContextSources(sources: readonly DocumentSourceLine[]): Record<string, string>;
|
|
25
|
+
export declare function createDocxBlockEvaluator(document: unknown, theme: ThemeConfig, extra?: Partial<BlockEvaluatorOptions>, sources?: readonly DocumentSourceLine[]): JsonBlockEvaluator;
|
|
11
26
|
export declare function expandBlocks<T>(document: T, theme: ThemeConfig): ExpandedBlocks<T>;
|
|
12
27
|
/** The plugin host supplies registered code; JSON itself never loads code. */
|
|
13
28
|
export declare function expandBlocksWithPlugins<T>(document: T, theme: ThemeConfig, plugins: ReadonlySet<string>, render: (component: Rec, path: string) => Promise<unknown[]>, preserve?: ReadonlySet<string>): Promise<ExpandedBlocks<T> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/blocks/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMlB,sBAAsB,EAEtB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/blocks/document.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMlB,sBAAsB,EAEtB,KAAK,qBAAqB,EAG3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EA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AC,MAAM,CAAC,EAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,EAC5D,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAa,GACxC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC,CA+C/C"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { ThemeConfig } from '../styles';
|
|
10
10
|
import type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
11
|
+
import type { GenerationWarning } from '@json-to-office/shared';
|
|
11
12
|
import { type HighchartsServiceConfig, type RasterizeFontFace } from '@json-to-office/shared';
|
|
12
13
|
export type { HighchartsProps } from '@json-to-office/shared-docx';
|
|
13
14
|
/**
|
|
@@ -18,6 +19,14 @@ export interface ChartGenerationResult {
|
|
|
18
19
|
width: number;
|
|
19
20
|
height: number;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Generate chart using Highcharts Export Server
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Refuse a public export server unless the caller opted in, and say so when
|
|
27
|
+
* it did: where the request goes is part of the document's confidentiality.
|
|
28
|
+
*/
|
|
29
|
+
export declare function assertExportServerAllowed(serverUrl: string, servicesConfig: HighchartsServiceConfig | undefined, warnings: GenerationWarning[] | undefined): void;
|
|
21
30
|
/**
|
|
22
31
|
* Map a chart's props to the `image` props it desugars to.
|
|
23
32
|
*
|
|
@@ -27,5 +36,5 @@ export interface ChartGenerationResult {
|
|
|
27
36
|
* rather than merging with it — stating one and inheriting the other would
|
|
28
37
|
* distort the chart.
|
|
29
38
|
*/
|
|
30
|
-
export declare function renderChartToImageProps(props: HighchartsProps, theme: ThemeConfig, servicesConfig?: HighchartsServiceConfig, chartFonts?: readonly RasterizeFontFace[]): Promise<Record<string, unknown>>;
|
|
39
|
+
export declare function renderChartToImageProps(props: HighchartsProps, theme: ThemeConfig, servicesConfig?: HighchartsServiceConfig, chartFonts?: readonly RasterizeFontFace[], warnings?: GenerationWarning[]): Promise<Record<string, unknown>>;
|
|
31
40
|
//# sourceMappingURL=highcharts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAOxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAOxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EASL,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;GAEG;AACH;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,uBAAuB,GAAG,SAAS,EACnD,QAAQ,EAAE,iBAAiB,EAAE,GAAG,SAAS,GACxC,IAAI,CASN;AA2ND;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,WAAW,EAClB,cAAc,CAAC,EAAE,uBAAuB,EACxC,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,EACzC,QAAQ,CAAC,EAAE,iBAAiB,EAAE,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiBlC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* fail, block on a network call or depend on a machine's LibreOffice happens in
|
|
13
13
|
* this pass; what comes out is a document that builds anywhere.
|
|
14
14
|
*/
|
|
15
|
-
import { type RasterizeFontFace, type ServicesConfig } from '@json-to-office/shared';
|
|
15
|
+
import { type RasterizeFontFace, type ServicesConfig, type GenerationWarning } from '@json-to-office/shared';
|
|
16
16
|
import type { ThemeConfig } from '../styles';
|
|
17
17
|
export interface DesugarExternalsOptions {
|
|
18
18
|
theme: ThemeConfig;
|
|
@@ -23,6 +23,8 @@ export interface DesugarExternalsOptions {
|
|
|
23
23
|
visualFonts?: readonly RasterizeFontFace[];
|
|
24
24
|
/** Font faces a chart's export server is handed as inline `@font-face`. */
|
|
25
25
|
chartFonts?: readonly RasterizeFontFace[];
|
|
26
|
+
/** Where a chart posted to a remote export server is reported. */
|
|
27
|
+
warnings?: GenerationWarning[];
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Replace every `visual` and `highcharts` in `document` with its image.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,WAAW,E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;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,SAAgB,IAAI,0BAA0B;IAC9C,SAAgB,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;gBAEhD,UAAU,EAAE,SAAS,oBAAoB,EAAE;CAiBxD;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;IACzD,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,EACrC,SAAS,CAAC,EAAE,iBAAiB,EAAE,GAC9B,OAAO,CAAC,YAAY,CAAC,CAOvB;AA0GD,0EAA0E;AAC1E,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAcjC"}
|
package/dist/index.js
CHANGED
|
@@ -2376,7 +2376,7 @@ import {
|
|
|
2376
2376
|
WpsShapeRun
|
|
2377
2377
|
} from "docx";
|
|
2378
2378
|
import { assertNever } from "@json-to-office/shared/rendering";
|
|
2379
|
-
function complexField(instruction, formatting, leading) {
|
|
2379
|
+
function complexField(instruction, formatting, leading, cachedText) {
|
|
2380
2380
|
const options = runOptions(formatting);
|
|
2381
2381
|
const fieldChar = (type, extra = {}) => new TextRun({
|
|
2382
2382
|
children: [
|
|
@@ -2395,6 +2395,9 @@ function complexField(instruction, formatting, leading) {
|
|
|
2395
2395
|
fieldChar("begin", leading),
|
|
2396
2396
|
new TextRun({ children: [instrText], ...options }),
|
|
2397
2397
|
fieldChar("separate"),
|
|
2398
|
+
// A sequence number is the one field this pipeline can compute, so its
|
|
2399
|
+
// result is written: a reader that never updates fields shows the count.
|
|
2400
|
+
...cachedText !== void 0 ? [new TextRun({ text: cachedText, ...options })] : [],
|
|
2398
2401
|
fieldChar("end")
|
|
2399
2402
|
];
|
|
2400
2403
|
}
|
|
@@ -2505,13 +2508,18 @@ function inlineChildren(children, resources = /* @__PURE__ */ new Map()) {
|
|
|
2505
2508
|
out.push(new SimpleField(child.instruction, child.cachedText));
|
|
2506
2509
|
break;
|
|
2507
2510
|
}
|
|
2508
|
-
if (!PAGE_FIELDS.has(child.instruction)) {
|
|
2511
|
+
if (!PAGE_FIELDS.has(child.instruction) && !isSequenceField(child.instruction)) {
|
|
2509
2512
|
throw new Error(
|
|
2510
2513
|
`the docxjs renderer has no emitter for the field "${child.instruction}"`
|
|
2511
2514
|
);
|
|
2512
2515
|
}
|
|
2513
2516
|
out.push(
|
|
2514
|
-
...complexField(
|
|
2517
|
+
...complexField(
|
|
2518
|
+
child.instruction,
|
|
2519
|
+
child.formatting,
|
|
2520
|
+
breakOption(),
|
|
2521
|
+
child.cachedText
|
|
2522
|
+
)
|
|
2515
2523
|
);
|
|
2516
2524
|
break;
|
|
2517
2525
|
}
|
|
@@ -2885,7 +2893,7 @@ function emitBorder(border3) {
|
|
|
2885
2893
|
...border3.spacePoints !== void 0 ? { space: border3.spacePoints } : {}
|
|
2886
2894
|
};
|
|
2887
2895
|
}
|
|
2888
|
-
var ALIGNMENT2, PAGE_FIELDS, WRAP_TYPE, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
|
|
2896
|
+
var ALIGNMENT2, PAGE_FIELDS, isSequenceField, WRAP_TYPE, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
|
|
2889
2897
|
var init_emit = __esm({
|
|
2890
2898
|
"src/renderers/docxjs/emit.ts"() {
|
|
2891
2899
|
"use strict";
|
|
@@ -2898,6 +2906,7 @@ var init_emit = __esm({
|
|
|
2898
2906
|
end: AlignmentType.END
|
|
2899
2907
|
};
|
|
2900
2908
|
PAGE_FIELDS = /* @__PURE__ */ new Set(["PAGE", "NUMPAGES"]);
|
|
2909
|
+
isSequenceField = (instruction) => /^SEQ [A-Za-z][\w-]* \\\* ARABIC$/.test(instruction);
|
|
2901
2910
|
WRAP_TYPE = {
|
|
2902
2911
|
none: TextWrappingType.NONE,
|
|
2903
2912
|
square: TextWrappingType.SQUARE,
|
|
@@ -5521,13 +5530,25 @@ init_colorUtils();
|
|
|
5521
5530
|
init_layoutUtils();
|
|
5522
5531
|
import {
|
|
5523
5532
|
chartFamilyResolver,
|
|
5533
|
+
remoteExportNotice,
|
|
5534
|
+
REMOTE_EXPORT_WARNING,
|
|
5524
5535
|
chartPointsPerPixel,
|
|
5525
5536
|
POINTS_PER_PIXEL_96DPI,
|
|
5526
5537
|
withChartFontFaceCss,
|
|
5527
5538
|
withChartTypography
|
|
5528
5539
|
} from "@json-to-office/shared";
|
|
5529
5540
|
var DEFAULT_EXPORT_SERVER_URL = "http://localhost:7801";
|
|
5530
|
-
|
|
5541
|
+
function assertExportServerAllowed(serverUrl, servicesConfig, warnings) {
|
|
5542
|
+
const notice = remoteExportNotice(serverUrl, servicesConfig?.allowRemote);
|
|
5543
|
+
if (notice)
|
|
5544
|
+
warnings?.push({
|
|
5545
|
+
component: "highcharts",
|
|
5546
|
+
severity: "warning",
|
|
5547
|
+
message: notice,
|
|
5548
|
+
context: { code: REMOTE_EXPORT_WARNING, serverUrl }
|
|
5549
|
+
});
|
|
5550
|
+
}
|
|
5551
|
+
async function generateChart(config, servicesConfig, warnings) {
|
|
5531
5552
|
if (!isNodeEnvironment()) {
|
|
5532
5553
|
throw new Error(
|
|
5533
5554
|
"Highcharts export server requires a Node.js environment. Chart generation is not available in browser environments."
|
|
@@ -5538,6 +5559,7 @@ async function generateChart(config, servicesConfig) {
|
|
|
5538
5559
|
servicesConfig?.serverUrl,
|
|
5539
5560
|
DEFAULT_EXPORT_SERVER_URL
|
|
5540
5561
|
);
|
|
5562
|
+
assertExportServerAllowed(serverUrl, servicesConfig, warnings);
|
|
5541
5563
|
const requestBody = {
|
|
5542
5564
|
infile: config.options,
|
|
5543
5565
|
type: "png",
|
|
@@ -5650,13 +5672,13 @@ function withChartFontFaces(config, theme, faces) {
|
|
|
5650
5672
|
theme.fonts.heading.family
|
|
5651
5673
|
]);
|
|
5652
5674
|
}
|
|
5653
|
-
async function renderChartToImageProps(props, theme, servicesConfig, chartFonts) {
|
|
5675
|
+
async function renderChartToImageProps(props, theme, servicesConfig, chartFonts, warnings) {
|
|
5654
5676
|
const config = withChartFontFaces(
|
|
5655
5677
|
withThemeTypography(withThemeColors(props, theme), theme),
|
|
5656
5678
|
theme,
|
|
5657
5679
|
chartFonts
|
|
5658
5680
|
);
|
|
5659
|
-
const chart = await generateChart(config, servicesConfig);
|
|
5681
|
+
const chart = await generateChart(config, servicesConfig, warnings);
|
|
5660
5682
|
const hasConfigDimensions = config.width !== void 0 || config.height !== void 0;
|
|
5661
5683
|
return {
|
|
5662
5684
|
base64: chart.base64DataUri,
|
|
@@ -5696,7 +5718,8 @@ async function desugarExternals(document, options) {
|
|
|
5696
5718
|
node.props,
|
|
5697
5719
|
options.theme,
|
|
5698
5720
|
options.services?.highcharts,
|
|
5699
|
-
options.chartFonts
|
|
5721
|
+
options.chartFonts,
|
|
5722
|
+
options.warnings
|
|
5700
5723
|
)
|
|
5701
5724
|
});
|
|
5702
5725
|
}
|
|
@@ -8247,6 +8270,9 @@ function parsePlaceholders(normalized, parseOptions) {
|
|
|
8247
8270
|
out.push({
|
|
8248
8271
|
kind: "field",
|
|
8249
8272
|
instruction: resolved.instruction,
|
|
8273
|
+
...resolved.cachedText !== void 0 && {
|
|
8274
|
+
cachedText: resolved.cachedText
|
|
8275
|
+
},
|
|
8250
8276
|
...formatting ? { formatting } : {}
|
|
8251
8277
|
});
|
|
8252
8278
|
}
|
|
@@ -8473,6 +8499,7 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
8473
8499
|
nextBookmarkId: CONTENT_BOOKMARK_ID_BASE + 1,
|
|
8474
8500
|
bookmarkNames: /* @__PURE__ */ new Set(),
|
|
8475
8501
|
usesStatistic: false,
|
|
8502
|
+
sequences: /* @__PURE__ */ new Map(),
|
|
8476
8503
|
styleIds: /* @__PURE__ */ new Set([
|
|
8477
8504
|
...styles.paragraph.map((s) => s.id),
|
|
8478
8505
|
...styles.character.map((s) => s.id)
|
|
@@ -9868,7 +9895,20 @@ function compileRuns(props, text, ctx, path4, mode = "inline") {
|
|
|
9868
9895
|
return children;
|
|
9869
9896
|
}
|
|
9870
9897
|
function placeholderResolver(ctx) {
|
|
9871
|
-
return (name) =>
|
|
9898
|
+
return (name) => {
|
|
9899
|
+
const sequence = /^SEQ:([A-Za-z][\w-]*)$/i.exec(name);
|
|
9900
|
+
if (sequence) {
|
|
9901
|
+
const key = sequence[1];
|
|
9902
|
+
const count = (ctx.sequences.get(key) ?? 0) + 1;
|
|
9903
|
+
ctx.sequences.set(key, count);
|
|
9904
|
+
return {
|
|
9905
|
+
kind: "field",
|
|
9906
|
+
instruction: `SEQ ${key} \\* ARABIC`,
|
|
9907
|
+
cachedText: String(count)
|
|
9908
|
+
};
|
|
9909
|
+
}
|
|
9910
|
+
return resolvePlaceholder(name, ctx.generatedAt);
|
|
9911
|
+
};
|
|
9872
9912
|
}
|
|
9873
9913
|
function crossReferenceResolver(ctx, path4) {
|
|
9874
9914
|
return (id, format2, token) => resolveCrossReference(id, format2, token, ctx, path4);
|
|
@@ -12094,12 +12134,41 @@ import {
|
|
|
12094
12134
|
readBlockDefinitions,
|
|
12095
12135
|
blockValueAt,
|
|
12096
12136
|
isBlockRecord,
|
|
12097
|
-
toAuthoredBlockPointer
|
|
12137
|
+
toAuthoredBlockPointer,
|
|
12138
|
+
blockPointerKey,
|
|
12139
|
+
blockSlotRoles
|
|
12098
12140
|
} from "@json-to-office/shared";
|
|
12099
|
-
import { blockSlotBudgets } from "@json-to-office/shared";
|
|
12141
|
+
import { blockSlotBudgets, blockSlotRoles as blockSlotRoles2 } from "@json-to-office/shared";
|
|
12100
12142
|
import { validateDocument } from "@json-to-office/shared-docx";
|
|
12101
12143
|
var toAuthoredPointer = toAuthoredBlockPointer;
|
|
12102
|
-
function
|
|
12144
|
+
function documentSourceLines(document) {
|
|
12145
|
+
if (!isBlockRecord(document)) return [];
|
|
12146
|
+
const invocations = [];
|
|
12147
|
+
const walk2 = (value, path4) => {
|
|
12148
|
+
if (Array.isArray(value)) {
|
|
12149
|
+
value.forEach((item, index) => walk2(item, `${path4}/${index}`));
|
|
12150
|
+
return;
|
|
12151
|
+
}
|
|
12152
|
+
if (!isBlockRecord(value) || value.enabled === false) return;
|
|
12153
|
+
if (value.name === "block") invocations.push(path4);
|
|
12154
|
+
for (const [key, item] of Object.entries(value)) {
|
|
12155
|
+
if (path4 === "/props" && key === "blocks") continue;
|
|
12156
|
+
walk2(item, `${path4}/${blockPointerKey(key)}`);
|
|
12157
|
+
}
|
|
12158
|
+
};
|
|
12159
|
+
walk2(document, "");
|
|
12160
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12161
|
+
const lines = [];
|
|
12162
|
+
for (const slot of blockSlotRoles(document, invocations)) {
|
|
12163
|
+
if (slot.role !== "source" || typeof slot.value !== "string") continue;
|
|
12164
|
+
const text = slot.value.trim();
|
|
12165
|
+
if (text === "" || seen.has(text)) continue;
|
|
12166
|
+
seen.add(text);
|
|
12167
|
+
lines.push({ text, path: slot.path });
|
|
12168
|
+
}
|
|
12169
|
+
return lines;
|
|
12170
|
+
}
|
|
12171
|
+
function docxBlockContext(document, theme, path4, sources) {
|
|
12103
12172
|
const index = /^\/children\/(\d+)/.exec(path4)?.[1];
|
|
12104
12173
|
const section2 = index === void 0 ? void 0 : blockValueAt(document, `/children/${index}`);
|
|
12105
12174
|
const page = isBlockRecord(section2) && isBlockRecord(section2.props) && isBlockRecord(section2.props.page) ? section2.props.page : {};
|
|
@@ -12119,26 +12188,46 @@ function docxBlockContext(document, theme, path4 = "") {
|
|
|
12119
12188
|
return {
|
|
12120
12189
|
document: blockValueAt(document, "/props/metadata") ?? {},
|
|
12121
12190
|
page: { width, height },
|
|
12122
|
-
section: {}
|
|
12191
|
+
section: {},
|
|
12192
|
+
sources: sources.map((line) => line.text)
|
|
12123
12193
|
};
|
|
12124
12194
|
}
|
|
12125
|
-
function
|
|
12195
|
+
function docxBlockContextSources(sources) {
|
|
12196
|
+
return {
|
|
12197
|
+
"/document": "/props/metadata",
|
|
12198
|
+
...Object.fromEntries(
|
|
12199
|
+
sources.map((line, index) => [`/sources/${index}`, line.path])
|
|
12200
|
+
)
|
|
12201
|
+
};
|
|
12202
|
+
}
|
|
12203
|
+
function createDocxBlockEvaluator(document, theme, extra = {}, sources = documentSourceLines(document)) {
|
|
12126
12204
|
return new JsonBlockEvaluator(readBlockDefinitions(document), {
|
|
12127
12205
|
format: "docx",
|
|
12128
12206
|
theme,
|
|
12129
|
-
contextAt: (path4) => docxBlockContext(document, theme, path4),
|
|
12130
|
-
contextSources:
|
|
12207
|
+
contextAt: (path4) => docxBlockContext(document, theme, path4, sources),
|
|
12208
|
+
contextSources: docxBlockContextSources(sources),
|
|
12131
12209
|
measure: (axis, unit, context) => Number(blockValueAt(context, `/page/${axis}`)) / (unit === "twip" ? 1 : unit === "in" ? 1440 : 20),
|
|
12132
12210
|
...extra
|
|
12133
12211
|
});
|
|
12134
12212
|
}
|
|
12135
12213
|
function expandBlocks(document, theme) {
|
|
12136
12214
|
const effects = [];
|
|
12137
|
-
const
|
|
12138
|
-
|
|
12139
|
-
|
|
12215
|
+
const sources = documentSourceLines(document);
|
|
12216
|
+
const evaluator = createDocxBlockEvaluator(
|
|
12217
|
+
document,
|
|
12218
|
+
theme,
|
|
12219
|
+
{ onSection: (effect) => effects.push(effect) },
|
|
12220
|
+
sources
|
|
12221
|
+
);
|
|
12140
12222
|
const expanded = evaluator.expand(document);
|
|
12141
|
-
return finishDocxBlocks(
|
|
12223
|
+
return finishDocxBlocks(
|
|
12224
|
+
expanded,
|
|
12225
|
+
document,
|
|
12226
|
+
theme,
|
|
12227
|
+
evaluator,
|
|
12228
|
+
effects,
|
|
12229
|
+
sources
|
|
12230
|
+
);
|
|
12142
12231
|
}
|
|
12143
12232
|
function validateEffects(document, effects) {
|
|
12144
12233
|
for (const effect of effects) {
|
|
@@ -12159,7 +12248,7 @@ function validateEffects(document, effects) {
|
|
|
12159
12248
|
]);
|
|
12160
12249
|
}
|
|
12161
12250
|
}
|
|
12162
|
-
function finishDocxBlocks(expanded, document, theme, evaluator, effects, validate = true) {
|
|
12251
|
+
function finishDocxBlocks(expanded, document, theme, evaluator, effects, sources, validate = true) {
|
|
12163
12252
|
if (isBlockRecord(expanded) && Array.isArray(expanded.children)) {
|
|
12164
12253
|
let inherited;
|
|
12165
12254
|
expanded.children.forEach((section2, index) => {
|
|
@@ -12197,11 +12286,11 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, validat
|
|
|
12197
12286
|
const environment = {
|
|
12198
12287
|
...chrome.environment,
|
|
12199
12288
|
context: {
|
|
12200
|
-
...docxBlockContext(document, theme, path4),
|
|
12289
|
+
...docxBlockContext(document, theme, path4, sources),
|
|
12201
12290
|
section: { tracker }
|
|
12202
12291
|
},
|
|
12203
12292
|
contextSources: {
|
|
12204
|
-
|
|
12293
|
+
...docxBlockContextSources(sources),
|
|
12205
12294
|
"/section/tracker": trackerSource
|
|
12206
12295
|
}
|
|
12207
12296
|
};
|
|
@@ -12245,10 +12334,16 @@ function finishDocxBlocks(expanded, document, theme, evaluator, effects, validat
|
|
|
12245
12334
|
}
|
|
12246
12335
|
async function expandBlocksWithPlugins(document, theme, plugins, render, preserve = /* @__PURE__ */ new Set()) {
|
|
12247
12336
|
const effects = [];
|
|
12248
|
-
const
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12337
|
+
const sources = documentSourceLines(document);
|
|
12338
|
+
const evaluator = createDocxBlockEvaluator(
|
|
12339
|
+
document,
|
|
12340
|
+
theme,
|
|
12341
|
+
{
|
|
12342
|
+
reservedNames: [...plugins],
|
|
12343
|
+
onSection: (effect) => effects.push(effect)
|
|
12344
|
+
},
|
|
12345
|
+
sources
|
|
12346
|
+
);
|
|
12252
12347
|
const walk2 = (value) => composeBlocksWithPlugins(evaluator, value, {
|
|
12253
12348
|
plugins,
|
|
12254
12349
|
render,
|
|
@@ -12261,6 +12356,7 @@ async function expandBlocksWithPlugins(document, theme, plugins, render, preserv
|
|
|
12261
12356
|
theme,
|
|
12262
12357
|
evaluator,
|
|
12263
12358
|
effects,
|
|
12359
|
+
sources,
|
|
12264
12360
|
false
|
|
12265
12361
|
);
|
|
12266
12362
|
const second = await walk2(finished.document);
|
|
@@ -12360,7 +12456,8 @@ function chartFact(node, props, path4, paletteTokens) {
|
|
|
12360
12456
|
kind: "docx/chart",
|
|
12361
12457
|
path: path4,
|
|
12362
12458
|
componentName: typeof node.name === "string" ? node.name : "",
|
|
12363
|
-
paletteTokens
|
|
12459
|
+
paletteTokens,
|
|
12460
|
+
generated: false
|
|
12364
12461
|
};
|
|
12365
12462
|
if (node.name === "highcharts") {
|
|
12366
12463
|
const shape = normalizeHighchartsChart(props.options);
|
|
@@ -12371,7 +12468,11 @@ function chartFact(node, props, path4, paletteTokens) {
|
|
|
12371
12468
|
threeD: shape.threeD,
|
|
12372
12469
|
seriesCount: shape.seriesCount,
|
|
12373
12470
|
categoryCount: shape.categoryCount,
|
|
12374
|
-
|
|
12471
|
+
// A config that names no `colors` is painted in the theme's chart
|
|
12472
|
+
// palette at render, so the series are the document's whenever the
|
|
12473
|
+
// theme has a palette to give; only a theme with none leaves them to
|
|
12474
|
+
// the export server's default.
|
|
12475
|
+
seriesColorsStated: shape.seriesColorsStated || paletteTokens.length > 0,
|
|
12375
12476
|
seriesColorsPath: `${path4}/props/options`,
|
|
12376
12477
|
...shape.valueAxisMin !== void 0 && {
|
|
12377
12478
|
valueAxisMin: shape.valueAxisMin
|
|
@@ -12743,6 +12844,11 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12743
12844
|
...fact.relatedPaths && { relatedPaths: fact.relatedPaths }
|
|
12744
12845
|
};
|
|
12745
12846
|
};
|
|
12847
|
+
const annotatedInvocations = new Set(
|
|
12848
|
+
blockSlotRoles2(themed.document, expanded.blocks).filter(
|
|
12849
|
+
(slot) => (slot.role === "takeaway" || slot.role === "source") && typeof slot.value === "string" && slot.value.trim() !== ""
|
|
12850
|
+
).map((slot) => slot.invocation)
|
|
12851
|
+
);
|
|
12746
12852
|
for (const budget of blockSlotBudgets(themed.document, expanded.blocks)) {
|
|
12747
12853
|
addFact({
|
|
12748
12854
|
id: `docx:block-slot:${budget.path}`,
|
|
@@ -12854,7 +12960,27 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
12854
12960
|
}
|
|
12855
12961
|
if (node.name === "chart" || node.name === "highcharts") {
|
|
12856
12962
|
const fact = chartFact(node, props, path4, paletteTokens);
|
|
12857
|
-
if (fact)
|
|
12963
|
+
if (fact) {
|
|
12964
|
+
const authored = authoredPath(path4);
|
|
12965
|
+
const invocation = expanded.blocks.filter(
|
|
12966
|
+
(pointer) => authored === pointer || authored.startsWith(`${pointer}/`)
|
|
12967
|
+
).sort((a, b) => b.length - a.length)[0];
|
|
12968
|
+
const annotated = invocation !== void 0 && annotatedInvocations.has(invocation);
|
|
12969
|
+
addFact({
|
|
12970
|
+
...fact,
|
|
12971
|
+
generated: !["chart", "highcharts"].includes(
|
|
12972
|
+
String(asRecord(nodeAtPointer(themed.document, authored))?.name)
|
|
12973
|
+
),
|
|
12974
|
+
seriesColorsPath: authoredPath(fact.seriesColorsPath),
|
|
12975
|
+
...fact.annotation && {
|
|
12976
|
+
annotation: {
|
|
12977
|
+
...fact.annotation,
|
|
12978
|
+
path: authoredPath(fact.annotation.path),
|
|
12979
|
+
stated: fact.annotation.stated || annotated
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
});
|
|
12983
|
+
}
|
|
12858
12984
|
}
|
|
12859
12985
|
if (node.name === "paragraph" || node.name === "text-box") {
|
|
12860
12986
|
const floating = asRecord(props.floating);
|
|
@@ -12976,7 +13102,8 @@ async function compileDocumentScoped(document, options, warnings) {
|
|
|
12976
13102
|
...options.services ? { services: options.services } : {},
|
|
12977
13103
|
...options.baseDir !== void 0 ? { baseDir: options.baseDir } : {},
|
|
12978
13104
|
...visualFonts.length > 0 ? { visualFonts } : {},
|
|
12979
|
-
...chartFonts.length > 0 ? { chartFonts } : {}
|
|
13105
|
+
...chartFonts.length > 0 ? { chartFonts } : {},
|
|
13106
|
+
warnings
|
|
12980
13107
|
});
|
|
12981
13108
|
const resolved = desugared === context.document ? prepared.model.document : resolveDocumentTree(desugared, context.theme);
|
|
12982
13109
|
const structure = await processResolvedDocument(
|
|
@@ -13909,7 +14036,7 @@ var docxChartRule = {
|
|
|
13909
14036
|
}
|
|
13910
14037
|
};
|
|
13911
14038
|
function seriesColorFix(fact) {
|
|
13912
|
-
if (fact.componentName !== "chart") return void 0;
|
|
14039
|
+
if (fact.componentName !== "chart" || fact.generated) return void 0;
|
|
13913
14040
|
if (fact.seriesCount < 1 || fact.paletteTokens.length === 0) return void 0;
|
|
13914
14041
|
const tokens = Array.from(
|
|
13915
14042
|
{ length: fact.seriesCount },
|