@json-to-office/core-docx 1.3.0 → 1.4.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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +238 -158
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/plugin/example/index.js +234 -158
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/renderers/docxjs/index.d.ts.map +1 -1
- package/dist/renderers/office-open/index.d.ts.map +1 -1
- package/dist/renderers/registry.d.ts +18 -4
- package/dist/renderers/registry.d.ts.map +1 -1
- package/dist/styles/themeToStyles.d.ts +35 -1
- package/dist/styles/themeToStyles.d.ts.map +1 -1
- package/dist/templates/themes/apex.docx.theme.json +1 -2
- package/dist/templates/themes/corporate.docx.theme.json +1 -2
- package/dist/templates/themes/devportal.docx.theme.json +1 -2
- package/dist/templates/themes/minimal.docx.theme.json +1 -2
- package/dist/templates/themes/modern.docx.theme.json +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -14
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare function getCoreVersion(): string;
|
|
|
2
2
|
export { generateBufferFromJson, generateBufferWithWarnings, generateBufferFromConfig, generateBufferFromFile, generateAndSaveFromJson, generateAndSaveFromFile, validateJsonSchema, isReportComponentDefinition, DocumentGenerator as CoreDocumentGenerator, type DocxGenerationResult, } from './core/generator';
|
|
3
3
|
export type { DocxRendererId } from './renderers/types';
|
|
4
4
|
export { DEFAULT_DOCX_RENDERER_ID } from './renderers/types';
|
|
5
|
-
export { docxRendererIds, isDocxRendererId } from './renderers/registry';
|
|
5
|
+
export { docxRendererIds, docxRendererStatuses, isDocxRendererId, } from './renderers/registry';
|
|
6
6
|
export { UncompiledComponentError } from './core/generateFromIr';
|
|
7
7
|
export { flattenVisuals, type FlattenVisualsOptions, } from './core/flattenVisuals';
|
|
8
8
|
export { getVisualPrepassStats, resetVisualPrepassStats, type VisualPrepassStats, } from './core/prerasterizeVisuals';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAID,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,IAAI,qBAAqB,EAC1C,KAAK,oBAAoB,GAC1B,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -428,8 +428,7 @@ var init_minimal_docx_theme = __esm({
|
|
|
428
428
|
},
|
|
429
429
|
list: {
|
|
430
430
|
format: "bullet",
|
|
431
|
-
bullet: "\u2022"
|
|
432
|
-
indent: 3
|
|
431
|
+
bullet: "\u2022"
|
|
433
432
|
},
|
|
434
433
|
image: {
|
|
435
434
|
alignment: "left"
|
|
@@ -553,8 +552,7 @@ var init_corporate_docx_theme = __esm({
|
|
|
553
552
|
},
|
|
554
553
|
list: {
|
|
555
554
|
format: "bullet",
|
|
556
|
-
bullet: "\u2022"
|
|
557
|
-
indent: 3
|
|
555
|
+
bullet: "\u2022"
|
|
558
556
|
},
|
|
559
557
|
statistic: {
|
|
560
558
|
alignment: "center"
|
|
@@ -667,8 +665,7 @@ var init_modern_docx_theme = __esm({
|
|
|
667
665
|
},
|
|
668
666
|
list: {
|
|
669
667
|
format: "bullet",
|
|
670
|
-
bullet: "\u2013"
|
|
671
|
-
indent: 3
|
|
668
|
+
bullet: "\u2013"
|
|
672
669
|
},
|
|
673
670
|
image: {
|
|
674
671
|
alignment: "center"
|
|
@@ -792,8 +789,7 @@ var init_apex_docx_theme = __esm({
|
|
|
792
789
|
},
|
|
793
790
|
list: {
|
|
794
791
|
format: "bullet",
|
|
795
|
-
bullet: "\u2022"
|
|
796
|
-
indent: 3
|
|
792
|
+
bullet: "\u2022"
|
|
797
793
|
},
|
|
798
794
|
image: {
|
|
799
795
|
alignment: "center"
|
|
@@ -925,8 +921,7 @@ var init_devportal_docx_theme = __esm({
|
|
|
925
921
|
},
|
|
926
922
|
list: {
|
|
927
923
|
format: "bullet",
|
|
928
|
-
bullet: "\u2013"
|
|
929
|
-
indent: 3
|
|
924
|
+
bullet: "\u2013"
|
|
930
925
|
},
|
|
931
926
|
image: {
|
|
932
927
|
alignment: "center"
|
|
@@ -2779,99 +2774,6 @@ var init_styles2 = __esm({
|
|
|
2779
2774
|
}
|
|
2780
2775
|
});
|
|
2781
2776
|
|
|
2782
|
-
// src/ir/features.ts
|
|
2783
|
-
var DOCX_FEATURES, ALL_DOCX_FEATURES;
|
|
2784
|
-
var init_features = __esm({
|
|
2785
|
-
"src/ir/features.ts"() {
|
|
2786
|
-
"use strict";
|
|
2787
|
-
DOCX_FEATURES = [
|
|
2788
|
-
/** Paragraphs and text runs — the floor of the format. */
|
|
2789
|
-
"paragraphs",
|
|
2790
|
-
/** Named paragraph and character styles in `styles.xml`. */
|
|
2791
|
-
"styles",
|
|
2792
|
-
/** Numbering definitions and numbered paragraphs. */
|
|
2793
|
-
"numbering",
|
|
2794
|
-
/** Multiple sections with their own page setup. */
|
|
2795
|
-
"sections",
|
|
2796
|
-
/** Multi-column section layout. */
|
|
2797
|
-
"columns",
|
|
2798
|
-
/** Header and footer parts, including first/even variants. */
|
|
2799
|
-
"headers-footers",
|
|
2800
|
-
"tables",
|
|
2801
|
-
/** Merged table cells — column span or vertical merge. */
|
|
2802
|
-
"table-merged-cells",
|
|
2803
|
-
/** A table positioned out of the text flow. */
|
|
2804
|
-
"floating-tables",
|
|
2805
|
-
/** Inline images. */
|
|
2806
|
-
"images",
|
|
2807
|
-
/** Anchored images with text wrapping. */
|
|
2808
|
-
"floating-images",
|
|
2809
|
-
/** SVG images with a raster fallback. */
|
|
2810
|
-
"svg-images",
|
|
2811
|
-
/** A paragraph positioned as a floating frame. */
|
|
2812
|
-
"text-frames",
|
|
2813
|
-
/** Native shape text boxes. */
|
|
2814
|
-
"text-boxes",
|
|
2815
|
-
/**
|
|
2816
|
-
* A DrawingML group: shapes, text boxes and pictures sharing one child
|
|
2817
|
-
* coordinate space, drawn as a single anchored or inline object.
|
|
2818
|
-
*
|
|
2819
|
-
* Separate from `text-boxes` because a lone `wps:wsp` run is a far smaller
|
|
2820
|
-
* ask than `wpg:wgp` with child transforms, preset geometry and grouped
|
|
2821
|
-
* pictures — a backend can plausibly have the first and not the second.
|
|
2822
|
-
*/
|
|
2823
|
-
"drawing-groups",
|
|
2824
|
-
/**
|
|
2825
|
-
* A native chart part: a `c:chartSpace` with its own embedded workbook.
|
|
2826
|
-
*
|
|
2827
|
-
* Separate from `images` because a chart is not a picture with extra data —
|
|
2828
|
-
* it is its own part, its own relationship and its own workbook, and a
|
|
2829
|
-
* backend either writes all three or writes none. docx.js has no chart
|
|
2830
|
-
* primitive at all, which is what turns a `chart` component sent to that
|
|
2831
|
-
* backend into a named capability error rather than a document missing a
|
|
2832
|
-
* figure.
|
|
2833
|
-
*/
|
|
2834
|
-
"charts",
|
|
2835
|
-
/** A table-of-contents field. */
|
|
2836
|
-
"toc",
|
|
2837
|
-
/** TOC entries baked in so an unrefreshed reader still shows them. */
|
|
2838
|
-
"cached-toc",
|
|
2839
|
-
/** Arbitrary Word fields, e.g. PAGE, NUMPAGES, REF. */
|
|
2840
|
-
"fields",
|
|
2841
|
-
/** Field results cached for readers that never refresh. */
|
|
2842
|
-
"cached-fields",
|
|
2843
|
-
"hyperlinks",
|
|
2844
|
-
"bookmarks",
|
|
2845
|
-
/** Links and REF fields that target a bookmark. */
|
|
2846
|
-
"cross-references",
|
|
2847
|
-
"comments",
|
|
2848
|
-
/** Threaded and resolvable comments. */
|
|
2849
|
-
"comment-threads",
|
|
2850
|
-
"footnotes",
|
|
2851
|
-
"endnotes",
|
|
2852
|
-
/** Inserted and deleted content. */
|
|
2853
|
-
"revisions",
|
|
2854
|
-
/** Page, column and line breaks. */
|
|
2855
|
-
"breaks",
|
|
2856
|
-
/** Paragraph and table shading. */
|
|
2857
|
-
"shading",
|
|
2858
|
-
/** Paragraph, table and page borders. */
|
|
2859
|
-
"borders",
|
|
2860
|
-
/** Tab stops. */
|
|
2861
|
-
"tab-stops",
|
|
2862
|
-
/** Per-run proofing language and no-proof. */
|
|
2863
|
-
"proofing-language",
|
|
2864
|
-
/** Custom document properties. */
|
|
2865
|
-
"custom-properties",
|
|
2866
|
-
/** Right-to-left paragraph direction. */
|
|
2867
|
-
"rtl"
|
|
2868
|
-
];
|
|
2869
|
-
ALL_DOCX_FEATURES = new Set(
|
|
2870
|
-
DOCX_FEATURES
|
|
2871
|
-
);
|
|
2872
|
-
}
|
|
2873
|
-
});
|
|
2874
|
-
|
|
2875
2777
|
// src/utils/packageDocument.ts
|
|
2876
2778
|
import AdmZip from "adm-zip";
|
|
2877
2779
|
function resolveGenerationDate(options) {
|
|
@@ -3279,37 +3181,47 @@ function coreProperties(ir) {
|
|
|
3279
3181
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
3280
3182
|
};
|
|
3281
3183
|
}
|
|
3282
|
-
var DOCXJS_RENDERER_ID,
|
|
3184
|
+
var DOCXJS_RENDERER_ID, DOCXJS_CAPABILITIES;
|
|
3283
3185
|
var init_docxjs = __esm({
|
|
3284
3186
|
"src/renderers/docxjs/index.ts"() {
|
|
3285
3187
|
"use strict";
|
|
3286
3188
|
init_styles2();
|
|
3287
3189
|
init_imageUtils();
|
|
3288
|
-
init_features();
|
|
3289
3190
|
init_packageDocument();
|
|
3290
3191
|
init_fixFloatingImageIds();
|
|
3291
3192
|
init_emit();
|
|
3292
3193
|
init_units();
|
|
3293
3194
|
DOCXJS_RENDERER_ID = "docxjs";
|
|
3294
|
-
|
|
3295
|
-
"
|
|
3296
|
-
"
|
|
3297
|
-
"
|
|
3298
|
-
"
|
|
3299
|
-
"
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
"
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
"
|
|
3195
|
+
DOCXJS_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
3196
|
+
"paragraphs",
|
|
3197
|
+
"styles",
|
|
3198
|
+
"numbering",
|
|
3199
|
+
"sections",
|
|
3200
|
+
"columns",
|
|
3201
|
+
"headers-footers",
|
|
3202
|
+
"tables",
|
|
3203
|
+
"floating-tables",
|
|
3204
|
+
"images",
|
|
3205
|
+
"floating-images",
|
|
3206
|
+
"svg-images",
|
|
3207
|
+
"text-frames",
|
|
3208
|
+
"text-boxes",
|
|
3209
|
+
"toc",
|
|
3210
|
+
"cached-toc",
|
|
3211
|
+
"fields",
|
|
3212
|
+
"hyperlinks",
|
|
3213
|
+
"bookmarks",
|
|
3214
|
+
"cross-references",
|
|
3215
|
+
"comments",
|
|
3216
|
+
"comment-threads",
|
|
3217
|
+
"footnotes",
|
|
3218
|
+
"endnotes",
|
|
3219
|
+
"revisions",
|
|
3220
|
+
"breaks",
|
|
3221
|
+
"tab-stops",
|
|
3222
|
+
"proofing-language",
|
|
3223
|
+
"custom-properties"
|
|
3309
3224
|
]);
|
|
3310
|
-
DOCXJS_CAPABILITIES = new Set(
|
|
3311
|
-
[...ALL_DOCX_FEATURES].filter((feature) => !NOT_YET_EMITTED.has(feature))
|
|
3312
|
-
);
|
|
3313
3225
|
}
|
|
3314
3226
|
});
|
|
3315
3227
|
|
|
@@ -4567,11 +4479,10 @@ function coreProperties2(ir) {
|
|
|
4567
4479
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
4568
4480
|
};
|
|
4569
4481
|
}
|
|
4570
|
-
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX,
|
|
4482
|
+
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX, OFFICE_OPEN_CAPABILITIES;
|
|
4571
4483
|
var init_office_open = __esm({
|
|
4572
4484
|
"src/renderers/office-open/index.ts"() {
|
|
4573
4485
|
"use strict";
|
|
4574
|
-
init_features();
|
|
4575
4486
|
init_chartParts();
|
|
4576
4487
|
init_imageUtils();
|
|
4577
4488
|
init_packageDocument();
|
|
@@ -4579,17 +4490,37 @@ var init_office_open = __esm({
|
|
|
4579
4490
|
init_styles3();
|
|
4580
4491
|
OFFICE_OPEN_DOCX_RENDERER_ID = "office-open";
|
|
4581
4492
|
OFFICE_OPEN_DOCX = "@office-open/docx";
|
|
4582
|
-
|
|
4583
|
-
"
|
|
4584
|
-
"
|
|
4585
|
-
"
|
|
4586
|
-
"
|
|
4587
|
-
"
|
|
4588
|
-
"
|
|
4493
|
+
OFFICE_OPEN_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
4494
|
+
"paragraphs",
|
|
4495
|
+
"styles",
|
|
4496
|
+
"numbering",
|
|
4497
|
+
"sections",
|
|
4498
|
+
"columns",
|
|
4499
|
+
"headers-footers",
|
|
4500
|
+
"tables",
|
|
4501
|
+
"floating-tables",
|
|
4502
|
+
"images",
|
|
4503
|
+
"floating-images",
|
|
4504
|
+
"svg-images",
|
|
4505
|
+
"text-frames",
|
|
4506
|
+
"text-boxes",
|
|
4507
|
+
"drawing-groups",
|
|
4508
|
+
"charts",
|
|
4509
|
+
"toc",
|
|
4510
|
+
"cached-toc",
|
|
4511
|
+
"fields",
|
|
4512
|
+
"hyperlinks",
|
|
4513
|
+
"bookmarks",
|
|
4514
|
+
"cross-references",
|
|
4515
|
+
"comments",
|
|
4516
|
+
"footnotes",
|
|
4517
|
+
"endnotes",
|
|
4518
|
+
"revisions",
|
|
4519
|
+
"breaks",
|
|
4520
|
+
"tab-stops",
|
|
4521
|
+
"proofing-language",
|
|
4522
|
+
"custom-properties"
|
|
4589
4523
|
]);
|
|
4590
|
-
OFFICE_OPEN_CAPABILITIES = new Set(
|
|
4591
|
-
[...ALL_DOCX_FEATURES].filter((feature) => !UNSUPPORTED.has(feature))
|
|
4592
|
-
);
|
|
4593
4524
|
}
|
|
4594
4525
|
});
|
|
4595
4526
|
|
|
@@ -6023,6 +5954,13 @@ init_themes();
|
|
|
6023
5954
|
init_colorUtils();
|
|
6024
5955
|
init_styleHelpers();
|
|
6025
5956
|
var RIGHT_MARGIN_TAB_TWIPS = 9026 * 2;
|
|
5957
|
+
var STATISTIC_NUMBER_STYLE_ID = "StatisticNumber";
|
|
5958
|
+
var STATISTIC_DESCRIPTION_STYLE_ID = "StatisticDescription";
|
|
5959
|
+
var STATISTIC_SIZE_POINTS = {
|
|
5960
|
+
small: 20,
|
|
5961
|
+
medium: 28,
|
|
5962
|
+
large: 40
|
|
5963
|
+
};
|
|
6026
5964
|
function isValidStyleName(name) {
|
|
6027
5965
|
return [
|
|
6028
5966
|
"normal",
|
|
@@ -6661,6 +6599,67 @@ function createDocumentStyles(themeNameOrObject = "minimal", language) {
|
|
|
6661
6599
|
}
|
|
6662
6600
|
};
|
|
6663
6601
|
}
|
|
6602
|
+
function createStatisticStyles(theme) {
|
|
6603
|
+
const definitions = [
|
|
6604
|
+
{
|
|
6605
|
+
id: STATISTIC_NUMBER_STYLE_ID,
|
|
6606
|
+
name: "Statistic Number",
|
|
6607
|
+
font: "heading",
|
|
6608
|
+
sizePoints: STATISTIC_SIZE_POINTS.medium,
|
|
6609
|
+
color: theme.colors.primary,
|
|
6610
|
+
bold: true,
|
|
6611
|
+
// Space above separates the figure from whatever preceded it; none below,
|
|
6612
|
+
// because the description is the other half of the same block.
|
|
6613
|
+
spacing: { before: 12, after: 0 },
|
|
6614
|
+
next: STATISTIC_DESCRIPTION_STYLE_ID,
|
|
6615
|
+
// The figure and its caption are one unit; a page break between them
|
|
6616
|
+
// reads as a number with no label.
|
|
6617
|
+
keepNext: true
|
|
6618
|
+
},
|
|
6619
|
+
{
|
|
6620
|
+
id: STATISTIC_DESCRIPTION_STYLE_ID,
|
|
6621
|
+
name: "Statistic Description",
|
|
6622
|
+
font: "body",
|
|
6623
|
+
sizePoints: 10,
|
|
6624
|
+
color: theme.colors.textMuted,
|
|
6625
|
+
bold: false,
|
|
6626
|
+
spacing: { before: 0, after: 12 },
|
|
6627
|
+
next: "Normal",
|
|
6628
|
+
keepNext: false
|
|
6629
|
+
}
|
|
6630
|
+
];
|
|
6631
|
+
return definitions.filter(
|
|
6632
|
+
(definition) => !(theme.styles && Object.prototype.hasOwnProperty.call(theme.styles, definition.id))
|
|
6633
|
+
).map((definition) => {
|
|
6634
|
+
const fontProps = resolveFontProperties(theme, definition.font);
|
|
6635
|
+
return {
|
|
6636
|
+
id: definition.id,
|
|
6637
|
+
name: definition.name,
|
|
6638
|
+
basedOn: "Normal",
|
|
6639
|
+
next: definition.next,
|
|
6640
|
+
quickFormat: true,
|
|
6641
|
+
run: {
|
|
6642
|
+
fontFamily: fontProps.family || "Arial",
|
|
6643
|
+
// Pinned, not inherited: the whole point of the style is that the
|
|
6644
|
+
// figure is not body text, so a theme's body size must not decide it.
|
|
6645
|
+
sizeHalfPoints: definition.sizePoints * 2,
|
|
6646
|
+
color: { hex: resolveColor(definition.color, theme) },
|
|
6647
|
+
bold: definition.bold
|
|
6648
|
+
},
|
|
6649
|
+
paragraph: {
|
|
6650
|
+
spacing: {
|
|
6651
|
+
...resolveSpacing(definition.spacing),
|
|
6652
|
+
...irLineSpacing(fontProps.lineSpacing)
|
|
6653
|
+
},
|
|
6654
|
+
// Centred, matching the compiler's own alignment default — a KPI
|
|
6655
|
+
// reads as a block, and an author who wants otherwise says so on the
|
|
6656
|
+
// component, which overrides this on the paragraph.
|
|
6657
|
+
alignment: convertAlignment("center"),
|
|
6658
|
+
keepNext: definition.keepNext
|
|
6659
|
+
}
|
|
6660
|
+
};
|
|
6661
|
+
});
|
|
6662
|
+
}
|
|
6664
6663
|
|
|
6665
6664
|
// src/ir/compiler.ts
|
|
6666
6665
|
init_styleHelpers();
|
|
@@ -7971,6 +7970,7 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
7971
7970
|
resourcesByHash: /* @__PURE__ */ new Map(),
|
|
7972
7971
|
nextBookmarkId: CONTENT_BOOKMARK_ID_BASE + 1,
|
|
7973
7972
|
bookmarkNames: /* @__PURE__ */ new Set(),
|
|
7973
|
+
usesStatistic: false,
|
|
7974
7974
|
styleIds: /* @__PURE__ */ new Set([
|
|
7975
7975
|
...styles.paragraph.map((s) => s.id),
|
|
7976
7976
|
...styles.character.map((s) => s.id)
|
|
@@ -8019,7 +8019,17 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
8019
8019
|
trackRevisions: structure.trackRevisions === true,
|
|
8020
8020
|
...noProofWords(structure.theme) ? { noProofWords: noProofWords(structure.theme) } : {}
|
|
8021
8021
|
},
|
|
8022
|
-
styles
|
|
8022
|
+
// The statistic styles are appended rather than built with the rest: a
|
|
8023
|
+
// document that uses no statistic must keep the exact style set it had
|
|
8024
|
+
// before the component had styles, or every recorded golden moves for a
|
|
8025
|
+
// component the document does not contain.
|
|
8026
|
+
styles: ctx.usesStatistic ? {
|
|
8027
|
+
...styles,
|
|
8028
|
+
paragraph: [
|
|
8029
|
+
...styles.paragraph,
|
|
8030
|
+
...createStatisticStyles(structure.theme)
|
|
8031
|
+
]
|
|
8032
|
+
} : styles,
|
|
8023
8033
|
numbering: ctx.numbering,
|
|
8024
8034
|
resources: ctx.resources,
|
|
8025
8035
|
sections,
|
|
@@ -8034,6 +8044,21 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
8034
8044
|
unsupported: ctx.unsupported
|
|
8035
8045
|
};
|
|
8036
8046
|
}
|
|
8047
|
+
var AFTER_TABLE_TWIPS = 120;
|
|
8048
|
+
var BODY_STYLE_IDS = /* @__PURE__ */ new Set([void 0, "Normal"]);
|
|
8049
|
+
function separateFromTables(blocks) {
|
|
8050
|
+
for (let i = 1; i < blocks.length; i += 1) {
|
|
8051
|
+
const block2 = blocks[i];
|
|
8052
|
+
if (blocks[i - 1].kind !== "table") continue;
|
|
8053
|
+
if (block2.kind !== "paragraph") continue;
|
|
8054
|
+
if (!BODY_STYLE_IDS.has(block2.styleId)) continue;
|
|
8055
|
+
if (block2.formatting?.spacing?.beforeTwips !== void 0) continue;
|
|
8056
|
+
block2.formatting = {
|
|
8057
|
+
...block2.formatting,
|
|
8058
|
+
spacing: { ...block2.formatting?.spacing, beforeTwips: AFTER_TABLE_TWIPS }
|
|
8059
|
+
};
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8037
8062
|
function collectOutline(layout, warnings) {
|
|
8038
8063
|
try {
|
|
8039
8064
|
return collectDocumentOutline(layout.sections);
|
|
@@ -8110,6 +8135,7 @@ function compileSection(section2, index, ordinal, chrome, ctx) {
|
|
|
8110
8135
|
})
|
|
8111
8136
|
);
|
|
8112
8137
|
});
|
|
8138
|
+
separateFromTables(children);
|
|
8113
8139
|
const compiled = {
|
|
8114
8140
|
id: `s${index}`,
|
|
8115
8141
|
path: path4,
|
|
@@ -8880,35 +8906,83 @@ function compileToc(component, scope) {
|
|
|
8880
8906
|
});
|
|
8881
8907
|
return blocks;
|
|
8882
8908
|
}
|
|
8909
|
+
var TREND_GLYPHS = {
|
|
8910
|
+
up: "\u25B2",
|
|
8911
|
+
down: "\u25BC",
|
|
8912
|
+
neutral: "\u2013"
|
|
8913
|
+
};
|
|
8883
8914
|
function compileStatistic(component, scope) {
|
|
8884
|
-
const { path: path4 } = scope;
|
|
8915
|
+
const { ctx, path: path4 } = scope;
|
|
8885
8916
|
const props = component.props ?? {};
|
|
8886
8917
|
const alignment2 = compileAlignment(props.alignment) ?? "center";
|
|
8918
|
+
ctx.usesStatistic = true;
|
|
8887
8919
|
const spacing = props.spacing ? {
|
|
8888
8920
|
...props.spacing.before !== void 0 ? { beforeTwips: props.spacing.before } : {},
|
|
8889
8921
|
...props.spacing.after !== void 0 ? { afterTwips: props.spacing.after } : {}
|
|
8890
8922
|
} : void 0;
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8923
|
+
if (props.format !== void 0) {
|
|
8924
|
+
warnOnce(
|
|
8925
|
+
ctx,
|
|
8926
|
+
"statistic",
|
|
8927
|
+
'statistic "format" is not implemented and was ignored \u2014 format the value yourself and pass the result as "number".',
|
|
8928
|
+
"W_STATISTIC_FORMAT_IGNORED"
|
|
8929
|
+
);
|
|
8930
|
+
}
|
|
8931
|
+
const text = (value) => normalizeUnicodeText(String(value ?? ""));
|
|
8932
|
+
const numberPoints = STATISTIC_SIZE_POINTS[String(props.size)] ?? STATISTIC_SIZE_POINTS.medium;
|
|
8933
|
+
const resized = numberPoints !== STATISTIC_SIZE_POINTS.medium;
|
|
8934
|
+
const suffixHalfPoints = Math.max(12, Math.round(numberPoints));
|
|
8935
|
+
const numberRuns = [];
|
|
8936
|
+
const numberText = text(props.number);
|
|
8937
|
+
if (numberText) {
|
|
8938
|
+
numberRuns.push({
|
|
8939
|
+
kind: "text",
|
|
8940
|
+
text: numberText,
|
|
8941
|
+
...resized ? { formatting: { sizeHalfPoints: numberPoints * 2 } } : {}
|
|
8942
|
+
});
|
|
8943
|
+
}
|
|
8944
|
+
const unitText = text(props.unit);
|
|
8945
|
+
if (unitText) {
|
|
8946
|
+
numberRuns.push({
|
|
8947
|
+
kind: "text",
|
|
8948
|
+
text: unitText,
|
|
8949
|
+
formatting: { sizeHalfPoints: suffixHalfPoints }
|
|
8950
|
+
});
|
|
8951
|
+
}
|
|
8952
|
+
const glyph = typeof props.trend === "string" ? TREND_GLYPHS[props.trend] : void 0;
|
|
8953
|
+
const trendValue = text(props.trendValue);
|
|
8954
|
+
if (glyph || trendValue) {
|
|
8955
|
+
numberRuns.push({
|
|
8956
|
+
kind: "text",
|
|
8957
|
+
text: `${numberRuns.length > 0 ? " " : ""}${[glyph, trendValue].filter(Boolean).join(" ")}`,
|
|
8958
|
+
formatting: {
|
|
8959
|
+
sizeHalfPoints: suffixHalfPoints,
|
|
8960
|
+
color: irColor(resolveColor(ctx.theme.colors.textMuted, ctx.theme))
|
|
8961
|
+
}
|
|
8962
|
+
});
|
|
8963
|
+
}
|
|
8964
|
+
const line = (children, styleId, suffix, formatting) => ({
|
|
8965
|
+
kind: "paragraph",
|
|
8966
|
+
id: `${scope.id}:${suffix}`,
|
|
8967
|
+
path: `${path4}.${suffix}`,
|
|
8968
|
+
styleId,
|
|
8969
|
+
formatting,
|
|
8970
|
+
// Nothing to say is not the same as saying nothing: an empty statistic
|
|
8971
|
+
// line is a styled blank paragraph, with no run inside it at all.
|
|
8972
|
+
children
|
|
8973
|
+
});
|
|
8974
|
+
const descriptionText = text(props.description);
|
|
8904
8975
|
return [
|
|
8905
|
-
line(
|
|
8976
|
+
line(numberRuns, STATISTIC_NUMBER_STYLE_ID, "number", {
|
|
8906
8977
|
alignment: alignment2,
|
|
8907
8978
|
...spacing ? { spacing } : {}
|
|
8908
8979
|
}),
|
|
8909
|
-
line(
|
|
8910
|
-
|
|
8911
|
-
|
|
8980
|
+
line(
|
|
8981
|
+
descriptionText ? [{ kind: "text", text: descriptionText }] : [],
|
|
8982
|
+
STATISTIC_DESCRIPTION_STYLE_ID,
|
|
8983
|
+
"description",
|
|
8984
|
+
{ alignment: alignment2 }
|
|
8985
|
+
)
|
|
8912
8986
|
];
|
|
8913
8987
|
}
|
|
8914
8988
|
function compileList(component, scope, referencePrefix = "list", explicitLevels) {
|
|
@@ -8981,12 +9055,12 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
|
|
|
8981
9055
|
}
|
|
8982
9056
|
function itemSpacing(spacing, index, count) {
|
|
8983
9057
|
const out = {};
|
|
8984
|
-
if (index === 0 && spacing?.before) {
|
|
9058
|
+
if (index === 0 && spacing?.before !== void 0) {
|
|
8985
9059
|
out.beforeTwips = pointsToTwips2(spacing.before);
|
|
8986
9060
|
}
|
|
8987
|
-
if (index === count - 1 && spacing?.after) {
|
|
9061
|
+
if (index === count - 1 && spacing?.after !== void 0) {
|
|
8988
9062
|
out.afterTwips = pointsToTwips2(spacing.after);
|
|
8989
|
-
} else if (spacing?.item) {
|
|
9063
|
+
} else if (spacing?.item !== void 0) {
|
|
8990
9064
|
out.afterTwips = pointsToTwips2(spacing.item);
|
|
8991
9065
|
}
|
|
8992
9066
|
return out;
|
|
@@ -10457,7 +10531,9 @@ function warnOnce(ctx, component, message, code) {
|
|
|
10457
10531
|
}
|
|
10458
10532
|
|
|
10459
10533
|
// src/renderers/registry.ts
|
|
10460
|
-
import {
|
|
10534
|
+
import {
|
|
10535
|
+
RendererRegistry
|
|
10536
|
+
} from "@json-to-office/shared/rendering";
|
|
10461
10537
|
|
|
10462
10538
|
// src/renderers/types.ts
|
|
10463
10539
|
import {
|
|
@@ -10483,6 +10559,9 @@ function resolveDocxRenderer(id) {
|
|
|
10483
10559
|
function docxRendererIds() {
|
|
10484
10560
|
return registry.ids();
|
|
10485
10561
|
}
|
|
10562
|
+
function docxRendererStatuses() {
|
|
10563
|
+
return registry.statuses();
|
|
10564
|
+
}
|
|
10486
10565
|
function isDocxRendererId(value) {
|
|
10487
10566
|
return registry.has(value);
|
|
10488
10567
|
}
|
|
@@ -12459,6 +12538,7 @@ export {
|
|
|
12459
12538
|
createMinimalTheme,
|
|
12460
12539
|
createVersion,
|
|
12461
12540
|
docxRendererIds,
|
|
12541
|
+
docxRendererStatuses,
|
|
12462
12542
|
examples,
|
|
12463
12543
|
exportPluginSchema,
|
|
12464
12544
|
exportThemeToJson,
|