@json-to-office/core-docx 1.1.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 +483 -148
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/ir/features.d.ts +1 -1
- package/dist/ir/features.d.ts.map +1 -1
- package/dist/ir/types.d.ts +46 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/validation.d.ts.map +1 -1
- package/dist/plugin/example/index.js +479 -148
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts.map +1 -1
- package/dist/renderers/docxjs/index.d.ts.map +1 -1
- package/dist/renderers/office-open/chartParts.d.ts +28 -0
- package/dist/renderers/office-open/chartParts.d.ts.map +1 -0
- package/dist/renderers/office-open/emit.d.ts +10 -1
- package/dist/renderers/office-open/emit.d.ts.map +1 -1
- package/dist/renderers/office-open/index.d.ts +2 -2
- 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/dist/utils/chartWorkbook.d.ts +19 -0
- package/dist/utils/chartWorkbook.d.ts.map +1 -0
- package/dist/utils/packageDocument.d.ts +2 -0
- package/dist/utils/packageDocument.d.ts.map +1 -1
- package/package.json +8 -14
|
@@ -355,8 +355,7 @@ var init_minimal_docx_theme = __esm({
|
|
|
355
355
|
},
|
|
356
356
|
list: {
|
|
357
357
|
format: "bullet",
|
|
358
|
-
bullet: "\u2022"
|
|
359
|
-
indent: 3
|
|
358
|
+
bullet: "\u2022"
|
|
360
359
|
},
|
|
361
360
|
image: {
|
|
362
361
|
alignment: "left"
|
|
@@ -480,8 +479,7 @@ var init_corporate_docx_theme = __esm({
|
|
|
480
479
|
},
|
|
481
480
|
list: {
|
|
482
481
|
format: "bullet",
|
|
483
|
-
bullet: "\u2022"
|
|
484
|
-
indent: 3
|
|
482
|
+
bullet: "\u2022"
|
|
485
483
|
},
|
|
486
484
|
statistic: {
|
|
487
485
|
alignment: "center"
|
|
@@ -594,8 +592,7 @@ var init_modern_docx_theme = __esm({
|
|
|
594
592
|
},
|
|
595
593
|
list: {
|
|
596
594
|
format: "bullet",
|
|
597
|
-
bullet: "\u2013"
|
|
598
|
-
indent: 3
|
|
595
|
+
bullet: "\u2013"
|
|
599
596
|
},
|
|
600
597
|
image: {
|
|
601
598
|
alignment: "center"
|
|
@@ -719,8 +716,7 @@ var init_apex_docx_theme = __esm({
|
|
|
719
716
|
},
|
|
720
717
|
list: {
|
|
721
718
|
format: "bullet",
|
|
722
|
-
bullet: "\u2022"
|
|
723
|
-
indent: 3
|
|
719
|
+
bullet: "\u2022"
|
|
724
720
|
},
|
|
725
721
|
image: {
|
|
726
722
|
alignment: "center"
|
|
@@ -852,8 +848,7 @@ var init_devportal_docx_theme = __esm({
|
|
|
852
848
|
},
|
|
853
849
|
list: {
|
|
854
850
|
format: "bullet",
|
|
855
|
-
bullet: "\u2013"
|
|
856
|
-
indent: 3
|
|
851
|
+
bullet: "\u2013"
|
|
857
852
|
},
|
|
858
853
|
image: {
|
|
859
854
|
alignment: "center"
|
|
@@ -2189,6 +2184,10 @@ function inlineChildren(children, resources = /* @__PURE__ */ new Map()) {
|
|
|
2189
2184
|
throw new Error(
|
|
2190
2185
|
"the docxjs renderer has no emitter for a drawing group; this document should have been refused by the capability check"
|
|
2191
2186
|
);
|
|
2187
|
+
case "chart":
|
|
2188
|
+
throw new Error(
|
|
2189
|
+
"the docxjs renderer has no emitter for a chart; this document should have been refused by the capability check"
|
|
2190
|
+
);
|
|
2192
2191
|
case "noteReference":
|
|
2193
2192
|
out.push(
|
|
2194
2193
|
child.noteKind === "endnote" ? new EndnoteReferenceRun(child.id) : new FootnoteReferenceRun(child.id)
|
|
@@ -2747,88 +2746,6 @@ var init_styles2 = __esm({
|
|
|
2747
2746
|
}
|
|
2748
2747
|
});
|
|
2749
2748
|
|
|
2750
|
-
// src/ir/features.ts
|
|
2751
|
-
var DOCX_FEATURES, ALL_DOCX_FEATURES;
|
|
2752
|
-
var init_features = __esm({
|
|
2753
|
-
"src/ir/features.ts"() {
|
|
2754
|
-
"use strict";
|
|
2755
|
-
DOCX_FEATURES = [
|
|
2756
|
-
/** Paragraphs and text runs — the floor of the format. */
|
|
2757
|
-
"paragraphs",
|
|
2758
|
-
/** Named paragraph and character styles in `styles.xml`. */
|
|
2759
|
-
"styles",
|
|
2760
|
-
/** Numbering definitions and numbered paragraphs. */
|
|
2761
|
-
"numbering",
|
|
2762
|
-
/** Multiple sections with their own page setup. */
|
|
2763
|
-
"sections",
|
|
2764
|
-
/** Multi-column section layout. */
|
|
2765
|
-
"columns",
|
|
2766
|
-
/** Header and footer parts, including first/even variants. */
|
|
2767
|
-
"headers-footers",
|
|
2768
|
-
"tables",
|
|
2769
|
-
/** Merged table cells — column span or vertical merge. */
|
|
2770
|
-
"table-merged-cells",
|
|
2771
|
-
/** A table positioned out of the text flow. */
|
|
2772
|
-
"floating-tables",
|
|
2773
|
-
/** Inline images. */
|
|
2774
|
-
"images",
|
|
2775
|
-
/** Anchored images with text wrapping. */
|
|
2776
|
-
"floating-images",
|
|
2777
|
-
/** SVG images with a raster fallback. */
|
|
2778
|
-
"svg-images",
|
|
2779
|
-
/** A paragraph positioned as a floating frame. */
|
|
2780
|
-
"text-frames",
|
|
2781
|
-
/** Native shape text boxes. */
|
|
2782
|
-
"text-boxes",
|
|
2783
|
-
/**
|
|
2784
|
-
* A DrawingML group: shapes, text boxes and pictures sharing one child
|
|
2785
|
-
* coordinate space, drawn as a single anchored or inline object.
|
|
2786
|
-
*
|
|
2787
|
-
* Separate from `text-boxes` because a lone `wps:wsp` run is a far smaller
|
|
2788
|
-
* ask than `wpg:wgp` with child transforms, preset geometry and grouped
|
|
2789
|
-
* pictures — a backend can plausibly have the first and not the second.
|
|
2790
|
-
*/
|
|
2791
|
-
"drawing-groups",
|
|
2792
|
-
/** A table-of-contents field. */
|
|
2793
|
-
"toc",
|
|
2794
|
-
/** TOC entries baked in so an unrefreshed reader still shows them. */
|
|
2795
|
-
"cached-toc",
|
|
2796
|
-
/** Arbitrary Word fields, e.g. PAGE, NUMPAGES, REF. */
|
|
2797
|
-
"fields",
|
|
2798
|
-
/** Field results cached for readers that never refresh. */
|
|
2799
|
-
"cached-fields",
|
|
2800
|
-
"hyperlinks",
|
|
2801
|
-
"bookmarks",
|
|
2802
|
-
/** Links and REF fields that target a bookmark. */
|
|
2803
|
-
"cross-references",
|
|
2804
|
-
"comments",
|
|
2805
|
-
/** Threaded and resolvable comments. */
|
|
2806
|
-
"comment-threads",
|
|
2807
|
-
"footnotes",
|
|
2808
|
-
"endnotes",
|
|
2809
|
-
/** Inserted and deleted content. */
|
|
2810
|
-
"revisions",
|
|
2811
|
-
/** Page, column and line breaks. */
|
|
2812
|
-
"breaks",
|
|
2813
|
-
/** Paragraph and table shading. */
|
|
2814
|
-
"shading",
|
|
2815
|
-
/** Paragraph, table and page borders. */
|
|
2816
|
-
"borders",
|
|
2817
|
-
/** Tab stops. */
|
|
2818
|
-
"tab-stops",
|
|
2819
|
-
/** Per-run proofing language and no-proof. */
|
|
2820
|
-
"proofing-language",
|
|
2821
|
-
/** Custom document properties. */
|
|
2822
|
-
"custom-properties",
|
|
2823
|
-
/** Right-to-left paragraph direction. */
|
|
2824
|
-
"rtl"
|
|
2825
|
-
];
|
|
2826
|
-
ALL_DOCX_FEATURES = new Set(
|
|
2827
|
-
DOCX_FEATURES
|
|
2828
|
-
);
|
|
2829
|
-
}
|
|
2830
|
-
});
|
|
2831
|
-
|
|
2832
2749
|
// src/utils/packageDocument.ts
|
|
2833
2750
|
import AdmZip from "adm-zip";
|
|
2834
2751
|
function resolveGenerationDate(options) {
|
|
@@ -3236,41 +3153,149 @@ function coreProperties(ir) {
|
|
|
3236
3153
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
3237
3154
|
};
|
|
3238
3155
|
}
|
|
3239
|
-
var DOCXJS_RENDERER_ID,
|
|
3156
|
+
var DOCXJS_RENDERER_ID, DOCXJS_CAPABILITIES;
|
|
3240
3157
|
var init_docxjs = __esm({
|
|
3241
3158
|
"src/renderers/docxjs/index.ts"() {
|
|
3242
3159
|
"use strict";
|
|
3243
3160
|
init_styles2();
|
|
3244
3161
|
init_imageUtils();
|
|
3245
|
-
init_features();
|
|
3246
3162
|
init_packageDocument();
|
|
3247
3163
|
init_fixFloatingImageIds();
|
|
3248
3164
|
init_emit();
|
|
3249
3165
|
init_units();
|
|
3250
3166
|
DOCXJS_RENDERER_ID = "docxjs";
|
|
3251
|
-
|
|
3252
|
-
"
|
|
3253
|
-
"
|
|
3254
|
-
"
|
|
3255
|
-
"
|
|
3256
|
-
"
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
"
|
|
3167
|
+
DOCXJS_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
3168
|
+
"paragraphs",
|
|
3169
|
+
"styles",
|
|
3170
|
+
"numbering",
|
|
3171
|
+
"sections",
|
|
3172
|
+
"columns",
|
|
3173
|
+
"headers-footers",
|
|
3174
|
+
"tables",
|
|
3175
|
+
"floating-tables",
|
|
3176
|
+
"images",
|
|
3177
|
+
"floating-images",
|
|
3178
|
+
"svg-images",
|
|
3179
|
+
"text-frames",
|
|
3180
|
+
"text-boxes",
|
|
3181
|
+
"toc",
|
|
3182
|
+
"cached-toc",
|
|
3183
|
+
"fields",
|
|
3184
|
+
"hyperlinks",
|
|
3185
|
+
"bookmarks",
|
|
3186
|
+
"cross-references",
|
|
3187
|
+
"comments",
|
|
3188
|
+
"comment-threads",
|
|
3189
|
+
"footnotes",
|
|
3190
|
+
"endnotes",
|
|
3191
|
+
"revisions",
|
|
3192
|
+
"breaks",
|
|
3193
|
+
"tab-stops",
|
|
3194
|
+
"proofing-language",
|
|
3195
|
+
"custom-properties"
|
|
3262
3196
|
]);
|
|
3263
|
-
|
|
3264
|
-
|
|
3197
|
+
}
|
|
3198
|
+
});
|
|
3199
|
+
|
|
3200
|
+
// src/utils/chartWorkbook.ts
|
|
3201
|
+
import AdmZip3 from "adm-zip";
|
|
3202
|
+
import { chartWorkbookParts } from "@json-to-office/shared/rendering";
|
|
3203
|
+
import {
|
|
3204
|
+
CHART_WORKBOOK_SHEET_NAME,
|
|
3205
|
+
categoryReference,
|
|
3206
|
+
columnLetter,
|
|
3207
|
+
seriesNameReference,
|
|
3208
|
+
seriesValueReference
|
|
3209
|
+
} from "@json-to-office/shared/rendering";
|
|
3210
|
+
function buildChartWorkbook(series) {
|
|
3211
|
+
const zip = new AdmZip3();
|
|
3212
|
+
for (const [name, content] of chartWorkbookParts(series)) {
|
|
3213
|
+
zip.addFile(name, Buffer.from(content, "utf8"));
|
|
3214
|
+
}
|
|
3215
|
+
for (const entry of zip.getEntries()) {
|
|
3216
|
+
entry.header.timeval = WORKBOOK_TIMESTAMP;
|
|
3217
|
+
}
|
|
3218
|
+
return new Uint8Array(zip.toBuffer());
|
|
3219
|
+
}
|
|
3220
|
+
var WORKBOOK_TIMESTAMP;
|
|
3221
|
+
var init_chartWorkbook = __esm({
|
|
3222
|
+
"src/utils/chartWorkbook.ts"() {
|
|
3223
|
+
"use strict";
|
|
3224
|
+
init_packageDocument();
|
|
3225
|
+
WORKBOOK_TIMESTAMP = toDosTime(DEFAULT_GENERATION_DATE);
|
|
3226
|
+
}
|
|
3227
|
+
});
|
|
3228
|
+
|
|
3229
|
+
// src/renderers/office-open/chartParts.ts
|
|
3230
|
+
import {
|
|
3231
|
+
CHART_WORKBOOK_CONTENT_TYPE,
|
|
3232
|
+
chartWorkbookRelsXml,
|
|
3233
|
+
matchChartParts,
|
|
3234
|
+
spliceChartXml
|
|
3235
|
+
} from "@json-to-office/shared/rendering";
|
|
3236
|
+
function spliceInput(chart) {
|
|
3237
|
+
return {
|
|
3238
|
+
chartType: chart.chartType,
|
|
3239
|
+
series: chart.series,
|
|
3240
|
+
colors: chart.colors,
|
|
3241
|
+
...chart.legendPosition ? { legendPosition: chart.legendPosition } : {},
|
|
3242
|
+
...chart.categoryAxisTitle ? { categoryAxis: { title: chart.categoryAxisTitle } } : {},
|
|
3243
|
+
...chart.valueAxisTitle ? { valueAxis: { title: chart.valueAxisTitle } } : {}
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
function declareWorkbookContentType(zip) {
|
|
3247
|
+
const entry = zip.getEntry("[Content_Types].xml");
|
|
3248
|
+
if (!entry) return;
|
|
3249
|
+
const xml = entry.getData().toString("utf8");
|
|
3250
|
+
if (xml.includes(`Extension="xlsx"`)) return;
|
|
3251
|
+
zip.updateFile(
|
|
3252
|
+
entry,
|
|
3253
|
+
Buffer.from(
|
|
3254
|
+
xml.replace(
|
|
3255
|
+
'<Default Extension="xml"',
|
|
3256
|
+
`<Default Extension="xlsx" ContentType="${CHART_WORKBOOK_CONTENT_TYPE}"/><Default Extension="xml"`
|
|
3257
|
+
),
|
|
3258
|
+
"utf8"
|
|
3259
|
+
)
|
|
3260
|
+
);
|
|
3261
|
+
}
|
|
3262
|
+
function spliceChartParts(zip, charts) {
|
|
3263
|
+
if (charts.length === 0) return;
|
|
3264
|
+
const parts = zip.getEntries().map((entry) => entry.entryName).map((name) => name.match(/^word\/charts\/chart(\d+)\.xml$/)).filter((match) => match !== null).map(
|
|
3265
|
+
(match) => [
|
|
3266
|
+
Number(match[1]),
|
|
3267
|
+
zip.getEntry(match[0]).getData().toString("utf8")
|
|
3268
|
+
]
|
|
3269
|
+
);
|
|
3270
|
+
for (const { ordinal, xml, chart } of matchChartParts(parts, charts)) {
|
|
3271
|
+
const workbookName = `chart${ordinal}.xlsx`;
|
|
3272
|
+
zip.updateFile(
|
|
3273
|
+
zip.getEntry(`word/charts/chart${ordinal}.xml`),
|
|
3274
|
+
Buffer.from(spliceChartXml(xml, spliceInput(chart)), "utf8")
|
|
3275
|
+
);
|
|
3276
|
+
zip.addFile(
|
|
3277
|
+
`word/embeddings/${workbookName}`,
|
|
3278
|
+
Buffer.from(buildChartWorkbook(chart.series))
|
|
3279
|
+
);
|
|
3280
|
+
zip.addFile(
|
|
3281
|
+
`word/charts/_rels/chart${ordinal}.xml.rels`,
|
|
3282
|
+
Buffer.from(chartWorkbookRelsXml(workbookName), "utf8")
|
|
3265
3283
|
);
|
|
3266
3284
|
}
|
|
3285
|
+
declareWorkbookContentType(zip);
|
|
3286
|
+
}
|
|
3287
|
+
var init_chartParts = __esm({
|
|
3288
|
+
"src/renderers/office-open/chartParts.ts"() {
|
|
3289
|
+
"use strict";
|
|
3290
|
+
init_chartWorkbook();
|
|
3291
|
+
}
|
|
3267
3292
|
});
|
|
3268
3293
|
|
|
3269
3294
|
// src/renderers/office-open/emit.ts
|
|
3270
3295
|
import { assertNever as assertNever2 } from "@json-to-office/shared/rendering";
|
|
3271
3296
|
function emptyContext() {
|
|
3272
3297
|
let next = 1;
|
|
3273
|
-
return { pictures: /* @__PURE__ */ new Map(), nextDrawingId: () => next
|
|
3298
|
+
return { pictures: /* @__PURE__ */ new Map(), nextDrawingId: () => next++, charts: [] };
|
|
3274
3299
|
}
|
|
3275
3300
|
function simpleField(instruction, cachedText) {
|
|
3276
3301
|
return {
|
|
@@ -3406,6 +3431,10 @@ function inlineChildren2(children, ctx = emptyContext()) {
|
|
|
3406
3431
|
case "shape":
|
|
3407
3432
|
out.push({ wpsShape: shapeOptions(child, ctx) });
|
|
3408
3433
|
break;
|
|
3434
|
+
case "chart":
|
|
3435
|
+
ctx.charts?.push(child);
|
|
3436
|
+
out.push({ chart: chartOptions(child, ctx) });
|
|
3437
|
+
break;
|
|
3409
3438
|
case "noteReference":
|
|
3410
3439
|
out.push(
|
|
3411
3440
|
child.noteKind === "endnote" ? { endnoteReference: child.id } : { footnoteReference: child.id }
|
|
@@ -3514,6 +3543,25 @@ function drawingGroupOptions(group, ctx) {
|
|
|
3514
3543
|
...group.floating ? { floating: floatingOptions2(group.floating) } : {}
|
|
3515
3544
|
};
|
|
3516
3545
|
}
|
|
3546
|
+
function chartOptions(chart, ctx) {
|
|
3547
|
+
const id = ctx.nextDrawingId();
|
|
3548
|
+
return {
|
|
3549
|
+
type: chart.chartType,
|
|
3550
|
+
categories: chart.series[0]?.labels ?? [],
|
|
3551
|
+
series: chart.series.map((entry, index) => ({
|
|
3552
|
+
name: entry.name ?? `Series ${index + 1}`,
|
|
3553
|
+
values: entry.values
|
|
3554
|
+
})),
|
|
3555
|
+
...chart.title && chart.showTitle !== false ? { title: chart.title } : {},
|
|
3556
|
+
...chart.showLegend !== void 0 ? { showLegend: chart.showLegend } : {},
|
|
3557
|
+
transformation: { width: chart.widthEmu, height: chart.heightEmu },
|
|
3558
|
+
altText: {
|
|
3559
|
+
id: String(id),
|
|
3560
|
+
...chart.altText ? { description: chart.altText } : {}
|
|
3561
|
+
},
|
|
3562
|
+
...chart.floating ? { floating: floatingOptions2(chart.floating) } : {}
|
|
3563
|
+
};
|
|
3564
|
+
}
|
|
3517
3565
|
function groupChild(child, ctx) {
|
|
3518
3566
|
return child.kind === "shape" ? groupShape(child, ctx) : groupPicture(child, ctx);
|
|
3519
3567
|
}
|
|
@@ -4086,6 +4134,7 @@ __export(office_open_exports, {
|
|
|
4086
4134
|
buildDocumentOptions: () => buildDocumentOptions,
|
|
4087
4135
|
createOfficeOpenDocxRenderer: () => createOfficeOpenDocxRenderer
|
|
4088
4136
|
});
|
|
4137
|
+
import AdmZip4 from "adm-zip";
|
|
4089
4138
|
async function createOfficeOpenDocxRenderer() {
|
|
4090
4139
|
const backend = await import(
|
|
4091
4140
|
/* @vite-ignore */
|
|
@@ -4101,13 +4150,19 @@ async function createOfficeOpenDocxRenderer() {
|
|
|
4101
4150
|
format: "docx",
|
|
4102
4151
|
capabilities: OFFICE_OPEN_CAPABILITIES,
|
|
4103
4152
|
async render(ir, options) {
|
|
4104
|
-
const
|
|
4153
|
+
const charts = [];
|
|
4154
|
+
const document = await buildDocumentOptions(ir, charts);
|
|
4105
4155
|
const bytes = await backend.generateDocument(document, {
|
|
4106
4156
|
type: "uint8array"
|
|
4107
4157
|
});
|
|
4108
|
-
|
|
4158
|
+
let raw = Buffer.from(
|
|
4109
4159
|
bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)
|
|
4110
4160
|
);
|
|
4161
|
+
if (charts.length > 0) {
|
|
4162
|
+
const zip = new AdmZip4(raw);
|
|
4163
|
+
spliceChartParts(zip, charts);
|
|
4164
|
+
raw = zip.toBuffer();
|
|
4165
|
+
}
|
|
4111
4166
|
if (options?.deterministic === false) return new Uint8Array(raw);
|
|
4112
4167
|
return new Uint8Array(
|
|
4113
4168
|
canonicalizeDocxBuffer(
|
|
@@ -4121,11 +4176,12 @@ async function createOfficeOpenDocxRenderer() {
|
|
|
4121
4176
|
}
|
|
4122
4177
|
};
|
|
4123
4178
|
}
|
|
4124
|
-
async function buildDocumentOptions(ir) {
|
|
4179
|
+
async function buildDocumentOptions(ir, charts = []) {
|
|
4125
4180
|
let nextDrawingId = 1;
|
|
4126
4181
|
const ctx = {
|
|
4127
4182
|
pictures: await prepareImages2(ir),
|
|
4128
|
-
nextDrawingId: () => nextDrawingId
|
|
4183
|
+
nextDrawingId: () => nextDrawingId++,
|
|
4184
|
+
charts
|
|
4129
4185
|
};
|
|
4130
4186
|
return {
|
|
4131
4187
|
styles: emitStyles2(ir.styles),
|
|
@@ -4395,28 +4451,48 @@ function coreProperties2(ir) {
|
|
|
4395
4451
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
4396
4452
|
};
|
|
4397
4453
|
}
|
|
4398
|
-
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX,
|
|
4454
|
+
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX, OFFICE_OPEN_CAPABILITIES;
|
|
4399
4455
|
var init_office_open = __esm({
|
|
4400
4456
|
"src/renderers/office-open/index.ts"() {
|
|
4401
4457
|
"use strict";
|
|
4402
|
-
|
|
4458
|
+
init_chartParts();
|
|
4403
4459
|
init_imageUtils();
|
|
4404
4460
|
init_packageDocument();
|
|
4405
4461
|
init_emit2();
|
|
4406
4462
|
init_styles3();
|
|
4407
4463
|
OFFICE_OPEN_DOCX_RENDERER_ID = "office-open";
|
|
4408
4464
|
OFFICE_OPEN_DOCX = "@office-open/docx";
|
|
4409
|
-
|
|
4410
|
-
"
|
|
4411
|
-
"
|
|
4412
|
-
"
|
|
4413
|
-
"
|
|
4414
|
-
"
|
|
4415
|
-
"
|
|
4465
|
+
OFFICE_OPEN_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
4466
|
+
"paragraphs",
|
|
4467
|
+
"styles",
|
|
4468
|
+
"numbering",
|
|
4469
|
+
"sections",
|
|
4470
|
+
"columns",
|
|
4471
|
+
"headers-footers",
|
|
4472
|
+
"tables",
|
|
4473
|
+
"floating-tables",
|
|
4474
|
+
"images",
|
|
4475
|
+
"floating-images",
|
|
4476
|
+
"svg-images",
|
|
4477
|
+
"text-frames",
|
|
4478
|
+
"text-boxes",
|
|
4479
|
+
"drawing-groups",
|
|
4480
|
+
"charts",
|
|
4481
|
+
"toc",
|
|
4482
|
+
"cached-toc",
|
|
4483
|
+
"fields",
|
|
4484
|
+
"hyperlinks",
|
|
4485
|
+
"bookmarks",
|
|
4486
|
+
"cross-references",
|
|
4487
|
+
"comments",
|
|
4488
|
+
"footnotes",
|
|
4489
|
+
"endnotes",
|
|
4490
|
+
"revisions",
|
|
4491
|
+
"breaks",
|
|
4492
|
+
"tab-stops",
|
|
4493
|
+
"proofing-language",
|
|
4494
|
+
"custom-properties"
|
|
4416
4495
|
]);
|
|
4417
|
-
OFFICE_OPEN_CAPABILITIES = new Set(
|
|
4418
|
-
[...ALL_DOCX_FEATURES].filter((feature) => !UNSUPPORTED.has(feature))
|
|
4419
|
-
);
|
|
4420
4496
|
}
|
|
4421
4497
|
});
|
|
4422
4498
|
|
|
@@ -5527,7 +5603,10 @@ init_colorUtils();
|
|
|
5527
5603
|
import {
|
|
5528
5604
|
FeatureRequirementCollector
|
|
5529
5605
|
} from "@json-to-office/shared/rendering";
|
|
5530
|
-
import {
|
|
5606
|
+
import {
|
|
5607
|
+
synthesizeFamilyName,
|
|
5608
|
+
DEFAULT_CHART_THEME_COLORS as DEFAULT_CHART_THEME_COLORS2
|
|
5609
|
+
} from "@json-to-office/shared";
|
|
5531
5610
|
import {
|
|
5532
5611
|
isNativeVisualProps as isNativeVisualProps4
|
|
5533
5612
|
} from "@json-to-office/shared-docx";
|
|
@@ -6044,6 +6123,13 @@ init_themes();
|
|
|
6044
6123
|
init_colorUtils();
|
|
6045
6124
|
init_styleHelpers();
|
|
6046
6125
|
var RIGHT_MARGIN_TAB_TWIPS = 9026 * 2;
|
|
6126
|
+
var STATISTIC_NUMBER_STYLE_ID = "StatisticNumber";
|
|
6127
|
+
var STATISTIC_DESCRIPTION_STYLE_ID = "StatisticDescription";
|
|
6128
|
+
var STATISTIC_SIZE_POINTS = {
|
|
6129
|
+
small: 20,
|
|
6130
|
+
medium: 28,
|
|
6131
|
+
large: 40
|
|
6132
|
+
};
|
|
6047
6133
|
function isValidStyleName(name) {
|
|
6048
6134
|
return [
|
|
6049
6135
|
"normal",
|
|
@@ -6682,6 +6768,67 @@ function createDocumentStyles(themeNameOrObject = "minimal", language) {
|
|
|
6682
6768
|
}
|
|
6683
6769
|
};
|
|
6684
6770
|
}
|
|
6771
|
+
function createStatisticStyles(theme) {
|
|
6772
|
+
const definitions = [
|
|
6773
|
+
{
|
|
6774
|
+
id: STATISTIC_NUMBER_STYLE_ID,
|
|
6775
|
+
name: "Statistic Number",
|
|
6776
|
+
font: "heading",
|
|
6777
|
+
sizePoints: STATISTIC_SIZE_POINTS.medium,
|
|
6778
|
+
color: theme.colors.primary,
|
|
6779
|
+
bold: true,
|
|
6780
|
+
// Space above separates the figure from whatever preceded it; none below,
|
|
6781
|
+
// because the description is the other half of the same block.
|
|
6782
|
+
spacing: { before: 12, after: 0 },
|
|
6783
|
+
next: STATISTIC_DESCRIPTION_STYLE_ID,
|
|
6784
|
+
// The figure and its caption are one unit; a page break between them
|
|
6785
|
+
// reads as a number with no label.
|
|
6786
|
+
keepNext: true
|
|
6787
|
+
},
|
|
6788
|
+
{
|
|
6789
|
+
id: STATISTIC_DESCRIPTION_STYLE_ID,
|
|
6790
|
+
name: "Statistic Description",
|
|
6791
|
+
font: "body",
|
|
6792
|
+
sizePoints: 10,
|
|
6793
|
+
color: theme.colors.textMuted,
|
|
6794
|
+
bold: false,
|
|
6795
|
+
spacing: { before: 0, after: 12 },
|
|
6796
|
+
next: "Normal",
|
|
6797
|
+
keepNext: false
|
|
6798
|
+
}
|
|
6799
|
+
];
|
|
6800
|
+
return definitions.filter(
|
|
6801
|
+
(definition) => !(theme.styles && Object.prototype.hasOwnProperty.call(theme.styles, definition.id))
|
|
6802
|
+
).map((definition) => {
|
|
6803
|
+
const fontProps = resolveFontProperties(theme, definition.font);
|
|
6804
|
+
return {
|
|
6805
|
+
id: definition.id,
|
|
6806
|
+
name: definition.name,
|
|
6807
|
+
basedOn: "Normal",
|
|
6808
|
+
next: definition.next,
|
|
6809
|
+
quickFormat: true,
|
|
6810
|
+
run: {
|
|
6811
|
+
fontFamily: fontProps.family || "Arial",
|
|
6812
|
+
// Pinned, not inherited: the whole point of the style is that the
|
|
6813
|
+
// figure is not body text, so a theme's body size must not decide it.
|
|
6814
|
+
sizeHalfPoints: definition.sizePoints * 2,
|
|
6815
|
+
color: { hex: resolveColor(definition.color, theme) },
|
|
6816
|
+
bold: definition.bold
|
|
6817
|
+
},
|
|
6818
|
+
paragraph: {
|
|
6819
|
+
spacing: {
|
|
6820
|
+
...resolveSpacing(definition.spacing),
|
|
6821
|
+
...irLineSpacing(fontProps.lineSpacing)
|
|
6822
|
+
},
|
|
6823
|
+
// Centred, matching the compiler's own alignment default — a KPI
|
|
6824
|
+
// reads as a block, and an author who wants otherwise says so on the
|
|
6825
|
+
// component, which overrides this on the paragraph.
|
|
6826
|
+
alignment: convertAlignment("center"),
|
|
6827
|
+
keepNext: definition.keepNext
|
|
6828
|
+
}
|
|
6829
|
+
};
|
|
6830
|
+
});
|
|
6831
|
+
}
|
|
6685
6832
|
|
|
6686
6833
|
// src/ir/compiler.ts
|
|
6687
6834
|
init_styleHelpers();
|
|
@@ -7992,6 +8139,7 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
7992
8139
|
resourcesByHash: /* @__PURE__ */ new Map(),
|
|
7993
8140
|
nextBookmarkId: CONTENT_BOOKMARK_ID_BASE + 1,
|
|
7994
8141
|
bookmarkNames: /* @__PURE__ */ new Set(),
|
|
8142
|
+
usesStatistic: false,
|
|
7995
8143
|
styleIds: /* @__PURE__ */ new Set([
|
|
7996
8144
|
...styles.paragraph.map((s) => s.id),
|
|
7997
8145
|
...styles.character.map((s) => s.id)
|
|
@@ -8040,7 +8188,17 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
8040
8188
|
trackRevisions: structure.trackRevisions === true,
|
|
8041
8189
|
...noProofWords(structure.theme) ? { noProofWords: noProofWords(structure.theme) } : {}
|
|
8042
8190
|
},
|
|
8043
|
-
styles
|
|
8191
|
+
// The statistic styles are appended rather than built with the rest: a
|
|
8192
|
+
// document that uses no statistic must keep the exact style set it had
|
|
8193
|
+
// before the component had styles, or every recorded golden moves for a
|
|
8194
|
+
// component the document does not contain.
|
|
8195
|
+
styles: ctx.usesStatistic ? {
|
|
8196
|
+
...styles,
|
|
8197
|
+
paragraph: [
|
|
8198
|
+
...styles.paragraph,
|
|
8199
|
+
...createStatisticStyles(structure.theme)
|
|
8200
|
+
]
|
|
8201
|
+
} : styles,
|
|
8044
8202
|
numbering: ctx.numbering,
|
|
8045
8203
|
resources: ctx.resources,
|
|
8046
8204
|
sections,
|
|
@@ -8055,6 +8213,21 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
8055
8213
|
unsupported: ctx.unsupported
|
|
8056
8214
|
};
|
|
8057
8215
|
}
|
|
8216
|
+
var AFTER_TABLE_TWIPS = 120;
|
|
8217
|
+
var BODY_STYLE_IDS = /* @__PURE__ */ new Set([void 0, "Normal"]);
|
|
8218
|
+
function separateFromTables(blocks) {
|
|
8219
|
+
for (let i = 1; i < blocks.length; i += 1) {
|
|
8220
|
+
const block2 = blocks[i];
|
|
8221
|
+
if (blocks[i - 1].kind !== "table") continue;
|
|
8222
|
+
if (block2.kind !== "paragraph") continue;
|
|
8223
|
+
if (!BODY_STYLE_IDS.has(block2.styleId)) continue;
|
|
8224
|
+
if (block2.formatting?.spacing?.beforeTwips !== void 0) continue;
|
|
8225
|
+
block2.formatting = {
|
|
8226
|
+
...block2.formatting,
|
|
8227
|
+
spacing: { ...block2.formatting?.spacing, beforeTwips: AFTER_TABLE_TWIPS }
|
|
8228
|
+
};
|
|
8229
|
+
}
|
|
8230
|
+
}
|
|
8058
8231
|
function collectOutline(layout, warnings) {
|
|
8059
8232
|
try {
|
|
8060
8233
|
return collectDocumentOutline(layout.sections);
|
|
@@ -8131,6 +8304,7 @@ function compileSection(section2, index, ordinal, chrome, ctx) {
|
|
|
8131
8304
|
})
|
|
8132
8305
|
);
|
|
8133
8306
|
});
|
|
8307
|
+
separateFromTables(children);
|
|
8134
8308
|
const compiled = {
|
|
8135
8309
|
id: `s${index}`,
|
|
8136
8310
|
path: path3,
|
|
@@ -8333,6 +8507,8 @@ function compileComponent(component, scope) {
|
|
|
8333
8507
|
return compileImage2(component, scope);
|
|
8334
8508
|
case "visual":
|
|
8335
8509
|
return compileVisual(component, scope);
|
|
8510
|
+
case "chart":
|
|
8511
|
+
return compileChart(component, scope);
|
|
8336
8512
|
case "table":
|
|
8337
8513
|
return compileTable(component, scope);
|
|
8338
8514
|
default:
|
|
@@ -8899,35 +9075,83 @@ function compileToc(component, scope) {
|
|
|
8899
9075
|
});
|
|
8900
9076
|
return blocks;
|
|
8901
9077
|
}
|
|
9078
|
+
var TREND_GLYPHS = {
|
|
9079
|
+
up: "\u25B2",
|
|
9080
|
+
down: "\u25BC",
|
|
9081
|
+
neutral: "\u2013"
|
|
9082
|
+
};
|
|
8902
9083
|
function compileStatistic(component, scope) {
|
|
8903
|
-
const { path: path3 } = scope;
|
|
9084
|
+
const { ctx, path: path3 } = scope;
|
|
8904
9085
|
const props = component.props ?? {};
|
|
8905
9086
|
const alignment2 = compileAlignment(props.alignment) ?? "center";
|
|
9087
|
+
ctx.usesStatistic = true;
|
|
8906
9088
|
const spacing = props.spacing ? {
|
|
8907
9089
|
...props.spacing.before !== void 0 ? { beforeTwips: props.spacing.before } : {},
|
|
8908
9090
|
...props.spacing.after !== void 0 ? { afterTwips: props.spacing.after } : {}
|
|
8909
9091
|
} : void 0;
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
9092
|
+
if (props.format !== void 0) {
|
|
9093
|
+
warnOnce(
|
|
9094
|
+
ctx,
|
|
9095
|
+
"statistic",
|
|
9096
|
+
'statistic "format" is not implemented and was ignored \u2014 format the value yourself and pass the result as "number".',
|
|
9097
|
+
"W_STATISTIC_FORMAT_IGNORED"
|
|
9098
|
+
);
|
|
9099
|
+
}
|
|
9100
|
+
const text = (value) => normalizeUnicodeText(String(value ?? ""));
|
|
9101
|
+
const numberPoints = STATISTIC_SIZE_POINTS[String(props.size)] ?? STATISTIC_SIZE_POINTS.medium;
|
|
9102
|
+
const resized = numberPoints !== STATISTIC_SIZE_POINTS.medium;
|
|
9103
|
+
const suffixHalfPoints = Math.max(12, Math.round(numberPoints));
|
|
9104
|
+
const numberRuns = [];
|
|
9105
|
+
const numberText = text(props.number);
|
|
9106
|
+
if (numberText) {
|
|
9107
|
+
numberRuns.push({
|
|
9108
|
+
kind: "text",
|
|
9109
|
+
text: numberText,
|
|
9110
|
+
...resized ? { formatting: { sizeHalfPoints: numberPoints * 2 } } : {}
|
|
9111
|
+
});
|
|
9112
|
+
}
|
|
9113
|
+
const unitText = text(props.unit);
|
|
9114
|
+
if (unitText) {
|
|
9115
|
+
numberRuns.push({
|
|
9116
|
+
kind: "text",
|
|
9117
|
+
text: unitText,
|
|
9118
|
+
formatting: { sizeHalfPoints: suffixHalfPoints }
|
|
9119
|
+
});
|
|
9120
|
+
}
|
|
9121
|
+
const glyph = typeof props.trend === "string" ? TREND_GLYPHS[props.trend] : void 0;
|
|
9122
|
+
const trendValue = text(props.trendValue);
|
|
9123
|
+
if (glyph || trendValue) {
|
|
9124
|
+
numberRuns.push({
|
|
9125
|
+
kind: "text",
|
|
9126
|
+
text: `${numberRuns.length > 0 ? " " : ""}${[glyph, trendValue].filter(Boolean).join(" ")}`,
|
|
9127
|
+
formatting: {
|
|
9128
|
+
sizeHalfPoints: suffixHalfPoints,
|
|
9129
|
+
color: irColor(resolveColor(ctx.theme.colors.textMuted, ctx.theme))
|
|
9130
|
+
}
|
|
9131
|
+
});
|
|
9132
|
+
}
|
|
9133
|
+
const line = (children, styleId, suffix, formatting) => ({
|
|
9134
|
+
kind: "paragraph",
|
|
9135
|
+
id: `${scope.id}:${suffix}`,
|
|
9136
|
+
path: `${path3}.${suffix}`,
|
|
9137
|
+
styleId,
|
|
9138
|
+
formatting,
|
|
9139
|
+
// Nothing to say is not the same as saying nothing: an empty statistic
|
|
9140
|
+
// line is a styled blank paragraph, with no run inside it at all.
|
|
9141
|
+
children
|
|
9142
|
+
});
|
|
9143
|
+
const descriptionText = text(props.description);
|
|
8923
9144
|
return [
|
|
8924
|
-
line(
|
|
9145
|
+
line(numberRuns, STATISTIC_NUMBER_STYLE_ID, "number", {
|
|
8925
9146
|
alignment: alignment2,
|
|
8926
9147
|
...spacing ? { spacing } : {}
|
|
8927
9148
|
}),
|
|
8928
|
-
line(
|
|
8929
|
-
|
|
8930
|
-
|
|
9149
|
+
line(
|
|
9150
|
+
descriptionText ? [{ kind: "text", text: descriptionText }] : [],
|
|
9151
|
+
STATISTIC_DESCRIPTION_STYLE_ID,
|
|
9152
|
+
"description",
|
|
9153
|
+
{ alignment: alignment2 }
|
|
9154
|
+
)
|
|
8931
9155
|
];
|
|
8932
9156
|
}
|
|
8933
9157
|
function compileList(component, scope, referencePrefix = "list", explicitLevels) {
|
|
@@ -9000,12 +9224,12 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
|
|
|
9000
9224
|
}
|
|
9001
9225
|
function itemSpacing(spacing, index, count) {
|
|
9002
9226
|
const out = {};
|
|
9003
|
-
if (index === 0 && spacing?.before) {
|
|
9227
|
+
if (index === 0 && spacing?.before !== void 0) {
|
|
9004
9228
|
out.beforeTwips = pointsToTwips2(spacing.before);
|
|
9005
9229
|
}
|
|
9006
|
-
if (index === count - 1 && spacing?.after) {
|
|
9230
|
+
if (index === count - 1 && spacing?.after !== void 0) {
|
|
9007
9231
|
out.afterTwips = pointsToTwips2(spacing.after);
|
|
9008
|
-
} else if (spacing?.item) {
|
|
9232
|
+
} else if (spacing?.item !== void 0) {
|
|
9009
9233
|
out.afterTwips = pointsToTwips2(spacing.item);
|
|
9010
9234
|
}
|
|
9011
9235
|
return out;
|
|
@@ -9723,6 +9947,111 @@ function compileImage2(component, scope) {
|
|
|
9723
9947
|
if (caption) blocks.push(caption);
|
|
9724
9948
|
return blocks;
|
|
9725
9949
|
}
|
|
9950
|
+
var DEFAULT_CHART_HEIGHT_INCHES = 3;
|
|
9951
|
+
function compileChart(component, scope) {
|
|
9952
|
+
const { ctx, path: path3 } = scope;
|
|
9953
|
+
const props = component.props ?? {};
|
|
9954
|
+
if (props.type === "bubble") {
|
|
9955
|
+
throw new Error(
|
|
9956
|
+
`Chart at ${path3} is a bubble chart, which no docx renderer draws; use the pptx \`chart\` component on the pptxgenjs renderer for one.`
|
|
9957
|
+
);
|
|
9958
|
+
}
|
|
9959
|
+
const rawSeries = Array.isArray(props.data) ? props.data : [];
|
|
9960
|
+
if (rawSeries.length === 0) {
|
|
9961
|
+
throw new Error(`Chart at ${path3} has no data series.`);
|
|
9962
|
+
}
|
|
9963
|
+
const series = rawSeries.map((entry, index) => {
|
|
9964
|
+
const raw = entry ?? {};
|
|
9965
|
+
const label = typeof raw.name === "string" ? raw.name : `series ${index}`;
|
|
9966
|
+
const labels = raw.labels;
|
|
9967
|
+
const values = raw.values;
|
|
9968
|
+
if (!Array.isArray(labels) || !Array.isArray(values)) {
|
|
9969
|
+
throw new Error(
|
|
9970
|
+
`Chart series "${label}" at ${path3} needs both "labels" and "values"; every series carries its own, not just the first.`
|
|
9971
|
+
);
|
|
9972
|
+
}
|
|
9973
|
+
if (labels.length !== values.length) {
|
|
9974
|
+
throw new Error(
|
|
9975
|
+
`Chart series "${label}" at ${path3} has ${labels.length} labels and ${values.length} values; they must be the same length.`
|
|
9976
|
+
);
|
|
9977
|
+
}
|
|
9978
|
+
return {
|
|
9979
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
9980
|
+
labels: labels.map((value) => String(value)),
|
|
9981
|
+
values: values.map((value) => Number(value))
|
|
9982
|
+
};
|
|
9983
|
+
});
|
|
9984
|
+
const categories = series[0].labels;
|
|
9985
|
+
for (const [index, entry] of series.entries()) {
|
|
9986
|
+
if (index === 0) continue;
|
|
9987
|
+
if (entry.labels.length !== categories.length || entry.labels.some((label, i) => label !== categories[i])) {
|
|
9988
|
+
throw new Error(
|
|
9989
|
+
`Chart series "${entry.name ?? `series ${index}`}" at ${path3} has different labels from the first series. A chart has one category axis, so every series must name the same categories in the same order.`
|
|
9990
|
+
);
|
|
9991
|
+
}
|
|
9992
|
+
}
|
|
9993
|
+
const colors = Array.isArray(props.chartColors) ? props.chartColors.map(
|
|
9994
|
+
(color) => resolveColor(String(color), ctx.theme)
|
|
9995
|
+
) : DEFAULT_CHART_THEME_COLORS2.map((token) => {
|
|
9996
|
+
const value = ctx.theme?.colors?.[token];
|
|
9997
|
+
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
9998
|
+
try {
|
|
9999
|
+
return resolveColor(token, ctx.theme);
|
|
10000
|
+
} catch {
|
|
10001
|
+
return void 0;
|
|
10002
|
+
}
|
|
10003
|
+
}).filter((color) => color !== void 0);
|
|
10004
|
+
const page = getPageSetup(ctx.theme);
|
|
10005
|
+
const contentWidthInches = (page.size.width - page.margin.left - page.margin.right) / 1440;
|
|
10006
|
+
const widthInches = typeof props.width === "number" ? props.width : contentWidthInches;
|
|
10007
|
+
const heightInches = typeof props.height === "number" ? props.height : DEFAULT_CHART_HEIGHT_INCHES;
|
|
10008
|
+
const chart = {
|
|
10009
|
+
kind: "chart",
|
|
10010
|
+
chartType: props.type,
|
|
10011
|
+
series,
|
|
10012
|
+
colors,
|
|
10013
|
+
widthEmu: inchesToEmu(widthInches),
|
|
10014
|
+
heightEmu: inchesToEmu(heightInches),
|
|
10015
|
+
...typeof props.title === "string" ? { title: props.title } : {},
|
|
10016
|
+
...props.showTitle !== void 0 ? { showTitle: props.showTitle } : {},
|
|
10017
|
+
...props.showLegend !== void 0 ? { showLegend: props.showLegend } : {},
|
|
10018
|
+
...props.legendPos ? { legendPosition: props.legendPos } : {},
|
|
10019
|
+
...typeof props.catAxisTitle === "string" ? { categoryAxisTitle: props.catAxisTitle } : {},
|
|
10020
|
+
...typeof props.valAxisTitle === "string" ? { valueAxisTitle: props.valAxisTitle } : {},
|
|
10021
|
+
...typeof props.alt === "string" && props.alt ? { altText: props.alt } : {},
|
|
10022
|
+
...props.floating ? { floating: compileFloating(props.floating, ctx, path3) } : {}
|
|
10023
|
+
};
|
|
10024
|
+
ctx.features.require("charts", path3);
|
|
10025
|
+
if (props.floating) ctx.features.require("floating-images", path3);
|
|
10026
|
+
const spacing = {};
|
|
10027
|
+
if (props.spacing?.before !== void 0) {
|
|
10028
|
+
spacing.beforeTwips = pointsToTwips2(props.spacing.before);
|
|
10029
|
+
}
|
|
10030
|
+
if (props.spacing?.after !== void 0) {
|
|
10031
|
+
spacing.afterTwips = pointsToTwips2(props.spacing.after);
|
|
10032
|
+
}
|
|
10033
|
+
const blocks = [
|
|
10034
|
+
{
|
|
10035
|
+
kind: "paragraph",
|
|
10036
|
+
id: scope.id,
|
|
10037
|
+
path: path3,
|
|
10038
|
+
children: [chart],
|
|
10039
|
+
formatting: {
|
|
10040
|
+
// An anchored chart moves with its anchor, so aligning the paragraph
|
|
10041
|
+
// would move the anchor rather than the chart — the same reasoning as
|
|
10042
|
+
// a floating image.
|
|
10043
|
+
...props.floating ? {} : { alignment: compileAlignment(props.alignment) ?? "center" },
|
|
10044
|
+
...Object.keys(spacing).length > 0 ? { spacing } : {},
|
|
10045
|
+
...props.keepNext !== void 0 ? { keepNext: props.keepNext } : {},
|
|
10046
|
+
...props.keepLines !== void 0 ? { keepLines: props.keepLines } : {}
|
|
10047
|
+
}
|
|
10048
|
+
}
|
|
10049
|
+
];
|
|
10050
|
+
const caption = captionBlock(props.caption, scope, "chart");
|
|
10051
|
+
if (caption === void 0) return [];
|
|
10052
|
+
if (caption) blocks.push(caption);
|
|
10053
|
+
return blocks;
|
|
10054
|
+
}
|
|
9726
10055
|
function captionBlock(value, scope, componentName) {
|
|
9727
10056
|
if (!value) return null;
|
|
9728
10057
|
const { ctx, path: path3 } = scope;
|
|
@@ -10371,7 +10700,9 @@ function warnOnce(ctx, component, message, code) {
|
|
|
10371
10700
|
}
|
|
10372
10701
|
|
|
10373
10702
|
// src/renderers/registry.ts
|
|
10374
|
-
import {
|
|
10703
|
+
import {
|
|
10704
|
+
RendererRegistry
|
|
10705
|
+
} from "@json-to-office/shared/rendering";
|
|
10375
10706
|
|
|
10376
10707
|
// src/renderers/types.ts
|
|
10377
10708
|
import {
|