@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
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"
|
|
@@ -2217,6 +2212,10 @@ function inlineChildren(children, resources = /* @__PURE__ */ new Map()) {
|
|
|
2217
2212
|
throw new Error(
|
|
2218
2213
|
"the docxjs renderer has no emitter for a drawing group; this document should have been refused by the capability check"
|
|
2219
2214
|
);
|
|
2215
|
+
case "chart":
|
|
2216
|
+
throw new Error(
|
|
2217
|
+
"the docxjs renderer has no emitter for a chart; this document should have been refused by the capability check"
|
|
2218
|
+
);
|
|
2220
2219
|
case "noteReference":
|
|
2221
2220
|
out.push(
|
|
2222
2221
|
child.noteKind === "endnote" ? new EndnoteReferenceRun(child.id) : new FootnoteReferenceRun(child.id)
|
|
@@ -2775,88 +2774,6 @@ var init_styles2 = __esm({
|
|
|
2775
2774
|
}
|
|
2776
2775
|
});
|
|
2777
2776
|
|
|
2778
|
-
// src/ir/features.ts
|
|
2779
|
-
var DOCX_FEATURES, ALL_DOCX_FEATURES;
|
|
2780
|
-
var init_features = __esm({
|
|
2781
|
-
"src/ir/features.ts"() {
|
|
2782
|
-
"use strict";
|
|
2783
|
-
DOCX_FEATURES = [
|
|
2784
|
-
/** Paragraphs and text runs — the floor of the format. */
|
|
2785
|
-
"paragraphs",
|
|
2786
|
-
/** Named paragraph and character styles in `styles.xml`. */
|
|
2787
|
-
"styles",
|
|
2788
|
-
/** Numbering definitions and numbered paragraphs. */
|
|
2789
|
-
"numbering",
|
|
2790
|
-
/** Multiple sections with their own page setup. */
|
|
2791
|
-
"sections",
|
|
2792
|
-
/** Multi-column section layout. */
|
|
2793
|
-
"columns",
|
|
2794
|
-
/** Header and footer parts, including first/even variants. */
|
|
2795
|
-
"headers-footers",
|
|
2796
|
-
"tables",
|
|
2797
|
-
/** Merged table cells — column span or vertical merge. */
|
|
2798
|
-
"table-merged-cells",
|
|
2799
|
-
/** A table positioned out of the text flow. */
|
|
2800
|
-
"floating-tables",
|
|
2801
|
-
/** Inline images. */
|
|
2802
|
-
"images",
|
|
2803
|
-
/** Anchored images with text wrapping. */
|
|
2804
|
-
"floating-images",
|
|
2805
|
-
/** SVG images with a raster fallback. */
|
|
2806
|
-
"svg-images",
|
|
2807
|
-
/** A paragraph positioned as a floating frame. */
|
|
2808
|
-
"text-frames",
|
|
2809
|
-
/** Native shape text boxes. */
|
|
2810
|
-
"text-boxes",
|
|
2811
|
-
/**
|
|
2812
|
-
* A DrawingML group: shapes, text boxes and pictures sharing one child
|
|
2813
|
-
* coordinate space, drawn as a single anchored or inline object.
|
|
2814
|
-
*
|
|
2815
|
-
* Separate from `text-boxes` because a lone `wps:wsp` run is a far smaller
|
|
2816
|
-
* ask than `wpg:wgp` with child transforms, preset geometry and grouped
|
|
2817
|
-
* pictures — a backend can plausibly have the first and not the second.
|
|
2818
|
-
*/
|
|
2819
|
-
"drawing-groups",
|
|
2820
|
-
/** A table-of-contents field. */
|
|
2821
|
-
"toc",
|
|
2822
|
-
/** TOC entries baked in so an unrefreshed reader still shows them. */
|
|
2823
|
-
"cached-toc",
|
|
2824
|
-
/** Arbitrary Word fields, e.g. PAGE, NUMPAGES, REF. */
|
|
2825
|
-
"fields",
|
|
2826
|
-
/** Field results cached for readers that never refresh. */
|
|
2827
|
-
"cached-fields",
|
|
2828
|
-
"hyperlinks",
|
|
2829
|
-
"bookmarks",
|
|
2830
|
-
/** Links and REF fields that target a bookmark. */
|
|
2831
|
-
"cross-references",
|
|
2832
|
-
"comments",
|
|
2833
|
-
/** Threaded and resolvable comments. */
|
|
2834
|
-
"comment-threads",
|
|
2835
|
-
"footnotes",
|
|
2836
|
-
"endnotes",
|
|
2837
|
-
/** Inserted and deleted content. */
|
|
2838
|
-
"revisions",
|
|
2839
|
-
/** Page, column and line breaks. */
|
|
2840
|
-
"breaks",
|
|
2841
|
-
/** Paragraph and table shading. */
|
|
2842
|
-
"shading",
|
|
2843
|
-
/** Paragraph, table and page borders. */
|
|
2844
|
-
"borders",
|
|
2845
|
-
/** Tab stops. */
|
|
2846
|
-
"tab-stops",
|
|
2847
|
-
/** Per-run proofing language and no-proof. */
|
|
2848
|
-
"proofing-language",
|
|
2849
|
-
/** Custom document properties. */
|
|
2850
|
-
"custom-properties",
|
|
2851
|
-
/** Right-to-left paragraph direction. */
|
|
2852
|
-
"rtl"
|
|
2853
|
-
];
|
|
2854
|
-
ALL_DOCX_FEATURES = new Set(
|
|
2855
|
-
DOCX_FEATURES
|
|
2856
|
-
);
|
|
2857
|
-
}
|
|
2858
|
-
});
|
|
2859
|
-
|
|
2860
2777
|
// src/utils/packageDocument.ts
|
|
2861
2778
|
import AdmZip from "adm-zip";
|
|
2862
2779
|
function resolveGenerationDate(options) {
|
|
@@ -3264,41 +3181,149 @@ function coreProperties(ir) {
|
|
|
3264
3181
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
3265
3182
|
};
|
|
3266
3183
|
}
|
|
3267
|
-
var DOCXJS_RENDERER_ID,
|
|
3184
|
+
var DOCXJS_RENDERER_ID, DOCXJS_CAPABILITIES;
|
|
3268
3185
|
var init_docxjs = __esm({
|
|
3269
3186
|
"src/renderers/docxjs/index.ts"() {
|
|
3270
3187
|
"use strict";
|
|
3271
3188
|
init_styles2();
|
|
3272
3189
|
init_imageUtils();
|
|
3273
|
-
init_features();
|
|
3274
3190
|
init_packageDocument();
|
|
3275
3191
|
init_fixFloatingImageIds();
|
|
3276
3192
|
init_emit();
|
|
3277
3193
|
init_units();
|
|
3278
3194
|
DOCXJS_RENDERER_ID = "docxjs";
|
|
3279
|
-
|
|
3280
|
-
"
|
|
3281
|
-
"
|
|
3282
|
-
"
|
|
3283
|
-
"
|
|
3284
|
-
"
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
"
|
|
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"
|
|
3290
3224
|
]);
|
|
3291
|
-
|
|
3292
|
-
|
|
3225
|
+
}
|
|
3226
|
+
});
|
|
3227
|
+
|
|
3228
|
+
// src/utils/chartWorkbook.ts
|
|
3229
|
+
import AdmZip3 from "adm-zip";
|
|
3230
|
+
import { chartWorkbookParts } from "@json-to-office/shared/rendering";
|
|
3231
|
+
import {
|
|
3232
|
+
CHART_WORKBOOK_SHEET_NAME,
|
|
3233
|
+
categoryReference,
|
|
3234
|
+
columnLetter,
|
|
3235
|
+
seriesNameReference,
|
|
3236
|
+
seriesValueReference
|
|
3237
|
+
} from "@json-to-office/shared/rendering";
|
|
3238
|
+
function buildChartWorkbook(series) {
|
|
3239
|
+
const zip = new AdmZip3();
|
|
3240
|
+
for (const [name, content] of chartWorkbookParts(series)) {
|
|
3241
|
+
zip.addFile(name, Buffer.from(content, "utf8"));
|
|
3242
|
+
}
|
|
3243
|
+
for (const entry of zip.getEntries()) {
|
|
3244
|
+
entry.header.timeval = WORKBOOK_TIMESTAMP;
|
|
3245
|
+
}
|
|
3246
|
+
return new Uint8Array(zip.toBuffer());
|
|
3247
|
+
}
|
|
3248
|
+
var WORKBOOK_TIMESTAMP;
|
|
3249
|
+
var init_chartWorkbook = __esm({
|
|
3250
|
+
"src/utils/chartWorkbook.ts"() {
|
|
3251
|
+
"use strict";
|
|
3252
|
+
init_packageDocument();
|
|
3253
|
+
WORKBOOK_TIMESTAMP = toDosTime(DEFAULT_GENERATION_DATE);
|
|
3254
|
+
}
|
|
3255
|
+
});
|
|
3256
|
+
|
|
3257
|
+
// src/renderers/office-open/chartParts.ts
|
|
3258
|
+
import {
|
|
3259
|
+
CHART_WORKBOOK_CONTENT_TYPE,
|
|
3260
|
+
chartWorkbookRelsXml,
|
|
3261
|
+
matchChartParts,
|
|
3262
|
+
spliceChartXml
|
|
3263
|
+
} from "@json-to-office/shared/rendering";
|
|
3264
|
+
function spliceInput(chart) {
|
|
3265
|
+
return {
|
|
3266
|
+
chartType: chart.chartType,
|
|
3267
|
+
series: chart.series,
|
|
3268
|
+
colors: chart.colors,
|
|
3269
|
+
...chart.legendPosition ? { legendPosition: chart.legendPosition } : {},
|
|
3270
|
+
...chart.categoryAxisTitle ? { categoryAxis: { title: chart.categoryAxisTitle } } : {},
|
|
3271
|
+
...chart.valueAxisTitle ? { valueAxis: { title: chart.valueAxisTitle } } : {}
|
|
3272
|
+
};
|
|
3273
|
+
}
|
|
3274
|
+
function declareWorkbookContentType(zip) {
|
|
3275
|
+
const entry = zip.getEntry("[Content_Types].xml");
|
|
3276
|
+
if (!entry) return;
|
|
3277
|
+
const xml = entry.getData().toString("utf8");
|
|
3278
|
+
if (xml.includes(`Extension="xlsx"`)) return;
|
|
3279
|
+
zip.updateFile(
|
|
3280
|
+
entry,
|
|
3281
|
+
Buffer.from(
|
|
3282
|
+
xml.replace(
|
|
3283
|
+
'<Default Extension="xml"',
|
|
3284
|
+
`<Default Extension="xlsx" ContentType="${CHART_WORKBOOK_CONTENT_TYPE}"/><Default Extension="xml"`
|
|
3285
|
+
),
|
|
3286
|
+
"utf8"
|
|
3287
|
+
)
|
|
3288
|
+
);
|
|
3289
|
+
}
|
|
3290
|
+
function spliceChartParts(zip, charts) {
|
|
3291
|
+
if (charts.length === 0) return;
|
|
3292
|
+
const parts = zip.getEntries().map((entry) => entry.entryName).map((name) => name.match(/^word\/charts\/chart(\d+)\.xml$/)).filter((match) => match !== null).map(
|
|
3293
|
+
(match) => [
|
|
3294
|
+
Number(match[1]),
|
|
3295
|
+
zip.getEntry(match[0]).getData().toString("utf8")
|
|
3296
|
+
]
|
|
3297
|
+
);
|
|
3298
|
+
for (const { ordinal, xml, chart } of matchChartParts(parts, charts)) {
|
|
3299
|
+
const workbookName = `chart${ordinal}.xlsx`;
|
|
3300
|
+
zip.updateFile(
|
|
3301
|
+
zip.getEntry(`word/charts/chart${ordinal}.xml`),
|
|
3302
|
+
Buffer.from(spliceChartXml(xml, spliceInput(chart)), "utf8")
|
|
3303
|
+
);
|
|
3304
|
+
zip.addFile(
|
|
3305
|
+
`word/embeddings/${workbookName}`,
|
|
3306
|
+
Buffer.from(buildChartWorkbook(chart.series))
|
|
3307
|
+
);
|
|
3308
|
+
zip.addFile(
|
|
3309
|
+
`word/charts/_rels/chart${ordinal}.xml.rels`,
|
|
3310
|
+
Buffer.from(chartWorkbookRelsXml(workbookName), "utf8")
|
|
3293
3311
|
);
|
|
3294
3312
|
}
|
|
3313
|
+
declareWorkbookContentType(zip);
|
|
3314
|
+
}
|
|
3315
|
+
var init_chartParts = __esm({
|
|
3316
|
+
"src/renderers/office-open/chartParts.ts"() {
|
|
3317
|
+
"use strict";
|
|
3318
|
+
init_chartWorkbook();
|
|
3319
|
+
}
|
|
3295
3320
|
});
|
|
3296
3321
|
|
|
3297
3322
|
// src/renderers/office-open/emit.ts
|
|
3298
3323
|
import { assertNever as assertNever2 } from "@json-to-office/shared/rendering";
|
|
3299
3324
|
function emptyContext() {
|
|
3300
3325
|
let next = 1;
|
|
3301
|
-
return { pictures: /* @__PURE__ */ new Map(), nextDrawingId: () => next
|
|
3326
|
+
return { pictures: /* @__PURE__ */ new Map(), nextDrawingId: () => next++, charts: [] };
|
|
3302
3327
|
}
|
|
3303
3328
|
function simpleField(instruction, cachedText) {
|
|
3304
3329
|
return {
|
|
@@ -3434,6 +3459,10 @@ function inlineChildren2(children, ctx = emptyContext()) {
|
|
|
3434
3459
|
case "shape":
|
|
3435
3460
|
out.push({ wpsShape: shapeOptions(child, ctx) });
|
|
3436
3461
|
break;
|
|
3462
|
+
case "chart":
|
|
3463
|
+
ctx.charts?.push(child);
|
|
3464
|
+
out.push({ chart: chartOptions(child, ctx) });
|
|
3465
|
+
break;
|
|
3437
3466
|
case "noteReference":
|
|
3438
3467
|
out.push(
|
|
3439
3468
|
child.noteKind === "endnote" ? { endnoteReference: child.id } : { footnoteReference: child.id }
|
|
@@ -3542,6 +3571,25 @@ function drawingGroupOptions(group, ctx) {
|
|
|
3542
3571
|
...group.floating ? { floating: floatingOptions2(group.floating) } : {}
|
|
3543
3572
|
};
|
|
3544
3573
|
}
|
|
3574
|
+
function chartOptions(chart, ctx) {
|
|
3575
|
+
const id = ctx.nextDrawingId();
|
|
3576
|
+
return {
|
|
3577
|
+
type: chart.chartType,
|
|
3578
|
+
categories: chart.series[0]?.labels ?? [],
|
|
3579
|
+
series: chart.series.map((entry, index) => ({
|
|
3580
|
+
name: entry.name ?? `Series ${index + 1}`,
|
|
3581
|
+
values: entry.values
|
|
3582
|
+
})),
|
|
3583
|
+
...chart.title && chart.showTitle !== false ? { title: chart.title } : {},
|
|
3584
|
+
...chart.showLegend !== void 0 ? { showLegend: chart.showLegend } : {},
|
|
3585
|
+
transformation: { width: chart.widthEmu, height: chart.heightEmu },
|
|
3586
|
+
altText: {
|
|
3587
|
+
id: String(id),
|
|
3588
|
+
...chart.altText ? { description: chart.altText } : {}
|
|
3589
|
+
},
|
|
3590
|
+
...chart.floating ? { floating: floatingOptions2(chart.floating) } : {}
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3545
3593
|
function groupChild(child, ctx) {
|
|
3546
3594
|
return child.kind === "shape" ? groupShape(child, ctx) : groupPicture(child, ctx);
|
|
3547
3595
|
}
|
|
@@ -4114,6 +4162,7 @@ __export(office_open_exports, {
|
|
|
4114
4162
|
buildDocumentOptions: () => buildDocumentOptions,
|
|
4115
4163
|
createOfficeOpenDocxRenderer: () => createOfficeOpenDocxRenderer
|
|
4116
4164
|
});
|
|
4165
|
+
import AdmZip4 from "adm-zip";
|
|
4117
4166
|
async function createOfficeOpenDocxRenderer() {
|
|
4118
4167
|
const backend = await import(
|
|
4119
4168
|
/* @vite-ignore */
|
|
@@ -4129,13 +4178,19 @@ async function createOfficeOpenDocxRenderer() {
|
|
|
4129
4178
|
format: "docx",
|
|
4130
4179
|
capabilities: OFFICE_OPEN_CAPABILITIES,
|
|
4131
4180
|
async render(ir, options) {
|
|
4132
|
-
const
|
|
4181
|
+
const charts = [];
|
|
4182
|
+
const document = await buildDocumentOptions(ir, charts);
|
|
4133
4183
|
const bytes = await backend.generateDocument(document, {
|
|
4134
4184
|
type: "uint8array"
|
|
4135
4185
|
});
|
|
4136
|
-
|
|
4186
|
+
let raw = Buffer.from(
|
|
4137
4187
|
bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)
|
|
4138
4188
|
);
|
|
4189
|
+
if (charts.length > 0) {
|
|
4190
|
+
const zip = new AdmZip4(raw);
|
|
4191
|
+
spliceChartParts(zip, charts);
|
|
4192
|
+
raw = zip.toBuffer();
|
|
4193
|
+
}
|
|
4139
4194
|
if (options?.deterministic === false) return new Uint8Array(raw);
|
|
4140
4195
|
return new Uint8Array(
|
|
4141
4196
|
canonicalizeDocxBuffer(
|
|
@@ -4149,11 +4204,12 @@ async function createOfficeOpenDocxRenderer() {
|
|
|
4149
4204
|
}
|
|
4150
4205
|
};
|
|
4151
4206
|
}
|
|
4152
|
-
async function buildDocumentOptions(ir) {
|
|
4207
|
+
async function buildDocumentOptions(ir, charts = []) {
|
|
4153
4208
|
let nextDrawingId = 1;
|
|
4154
4209
|
const ctx = {
|
|
4155
4210
|
pictures: await prepareImages2(ir),
|
|
4156
|
-
nextDrawingId: () => nextDrawingId
|
|
4211
|
+
nextDrawingId: () => nextDrawingId++,
|
|
4212
|
+
charts
|
|
4157
4213
|
};
|
|
4158
4214
|
return {
|
|
4159
4215
|
styles: emitStyles2(ir.styles),
|
|
@@ -4423,28 +4479,48 @@ function coreProperties2(ir) {
|
|
|
4423
4479
|
...metadata.custom?.length ? { customProperties: metadata.custom } : {}
|
|
4424
4480
|
};
|
|
4425
4481
|
}
|
|
4426
|
-
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX,
|
|
4482
|
+
var OFFICE_OPEN_DOCX_RENDERER_ID, OFFICE_OPEN_DOCX, OFFICE_OPEN_CAPABILITIES;
|
|
4427
4483
|
var init_office_open = __esm({
|
|
4428
4484
|
"src/renderers/office-open/index.ts"() {
|
|
4429
4485
|
"use strict";
|
|
4430
|
-
|
|
4486
|
+
init_chartParts();
|
|
4431
4487
|
init_imageUtils();
|
|
4432
4488
|
init_packageDocument();
|
|
4433
4489
|
init_emit2();
|
|
4434
4490
|
init_styles3();
|
|
4435
4491
|
OFFICE_OPEN_DOCX_RENDERER_ID = "office-open";
|
|
4436
4492
|
OFFICE_OPEN_DOCX = "@office-open/docx";
|
|
4437
|
-
|
|
4438
|
-
"
|
|
4439
|
-
"
|
|
4440
|
-
"
|
|
4441
|
-
"
|
|
4442
|
-
"
|
|
4443
|
-
"
|
|
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"
|
|
4444
4523
|
]);
|
|
4445
|
-
OFFICE_OPEN_CAPABILITIES = new Set(
|
|
4446
|
-
[...ALL_DOCX_FEATURES].filter((feature) => !UNSUPPORTED.has(feature))
|
|
4447
|
-
);
|
|
4448
4524
|
}
|
|
4449
4525
|
});
|
|
4450
4526
|
|
|
@@ -5358,7 +5434,10 @@ init_colorUtils();
|
|
|
5358
5434
|
import {
|
|
5359
5435
|
FeatureRequirementCollector
|
|
5360
5436
|
} from "@json-to-office/shared/rendering";
|
|
5361
|
-
import {
|
|
5437
|
+
import {
|
|
5438
|
+
synthesizeFamilyName,
|
|
5439
|
+
DEFAULT_CHART_THEME_COLORS as DEFAULT_CHART_THEME_COLORS2
|
|
5440
|
+
} from "@json-to-office/shared";
|
|
5362
5441
|
import {
|
|
5363
5442
|
isNativeVisualProps as isNativeVisualProps4
|
|
5364
5443
|
} from "@json-to-office/shared-docx";
|
|
@@ -5875,6 +5954,13 @@ init_themes();
|
|
|
5875
5954
|
init_colorUtils();
|
|
5876
5955
|
init_styleHelpers();
|
|
5877
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
|
+
};
|
|
5878
5964
|
function isValidStyleName(name) {
|
|
5879
5965
|
return [
|
|
5880
5966
|
"normal",
|
|
@@ -6513,6 +6599,67 @@ function createDocumentStyles(themeNameOrObject = "minimal", language) {
|
|
|
6513
6599
|
}
|
|
6514
6600
|
};
|
|
6515
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
|
+
}
|
|
6516
6663
|
|
|
6517
6664
|
// src/ir/compiler.ts
|
|
6518
6665
|
init_styleHelpers();
|
|
@@ -7823,6 +7970,7 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
7823
7970
|
resourcesByHash: /* @__PURE__ */ new Map(),
|
|
7824
7971
|
nextBookmarkId: CONTENT_BOOKMARK_ID_BASE + 1,
|
|
7825
7972
|
bookmarkNames: /* @__PURE__ */ new Set(),
|
|
7973
|
+
usesStatistic: false,
|
|
7826
7974
|
styleIds: /* @__PURE__ */ new Set([
|
|
7827
7975
|
...styles.paragraph.map((s) => s.id),
|
|
7828
7976
|
...styles.character.map((s) => s.id)
|
|
@@ -7871,7 +8019,17 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
7871
8019
|
trackRevisions: structure.trackRevisions === true,
|
|
7872
8020
|
...noProofWords(structure.theme) ? { noProofWords: noProofWords(structure.theme) } : {}
|
|
7873
8021
|
},
|
|
7874
|
-
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,
|
|
7875
8033
|
numbering: ctx.numbering,
|
|
7876
8034
|
resources: ctx.resources,
|
|
7877
8035
|
sections,
|
|
@@ -7886,6 +8044,21 @@ function compileDocument(structure, layout, warnings = [], images = /* @__PURE__
|
|
|
7886
8044
|
unsupported: ctx.unsupported
|
|
7887
8045
|
};
|
|
7888
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
|
+
}
|
|
7889
8062
|
function collectOutline(layout, warnings) {
|
|
7890
8063
|
try {
|
|
7891
8064
|
return collectDocumentOutline(layout.sections);
|
|
@@ -7962,6 +8135,7 @@ function compileSection(section2, index, ordinal, chrome, ctx) {
|
|
|
7962
8135
|
})
|
|
7963
8136
|
);
|
|
7964
8137
|
});
|
|
8138
|
+
separateFromTables(children);
|
|
7965
8139
|
const compiled = {
|
|
7966
8140
|
id: `s${index}`,
|
|
7967
8141
|
path: path4,
|
|
@@ -8164,6 +8338,8 @@ function compileComponent(component, scope) {
|
|
|
8164
8338
|
return compileImage2(component, scope);
|
|
8165
8339
|
case "visual":
|
|
8166
8340
|
return compileVisual(component, scope);
|
|
8341
|
+
case "chart":
|
|
8342
|
+
return compileChart(component, scope);
|
|
8167
8343
|
case "table":
|
|
8168
8344
|
return compileTable(component, scope);
|
|
8169
8345
|
default:
|
|
@@ -8730,35 +8906,83 @@ function compileToc(component, scope) {
|
|
|
8730
8906
|
});
|
|
8731
8907
|
return blocks;
|
|
8732
8908
|
}
|
|
8909
|
+
var TREND_GLYPHS = {
|
|
8910
|
+
up: "\u25B2",
|
|
8911
|
+
down: "\u25BC",
|
|
8912
|
+
neutral: "\u2013"
|
|
8913
|
+
};
|
|
8733
8914
|
function compileStatistic(component, scope) {
|
|
8734
|
-
const { path: path4 } = scope;
|
|
8915
|
+
const { ctx, path: path4 } = scope;
|
|
8735
8916
|
const props = component.props ?? {};
|
|
8736
8917
|
const alignment2 = compileAlignment(props.alignment) ?? "center";
|
|
8918
|
+
ctx.usesStatistic = true;
|
|
8737
8919
|
const spacing = props.spacing ? {
|
|
8738
8920
|
...props.spacing.before !== void 0 ? { beforeTwips: props.spacing.before } : {},
|
|
8739
8921
|
...props.spacing.after !== void 0 ? { afterTwips: props.spacing.after } : {}
|
|
8740
8922
|
} : void 0;
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
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);
|
|
8754
8975
|
return [
|
|
8755
|
-
line(
|
|
8976
|
+
line(numberRuns, STATISTIC_NUMBER_STYLE_ID, "number", {
|
|
8756
8977
|
alignment: alignment2,
|
|
8757
8978
|
...spacing ? { spacing } : {}
|
|
8758
8979
|
}),
|
|
8759
|
-
line(
|
|
8760
|
-
|
|
8761
|
-
|
|
8980
|
+
line(
|
|
8981
|
+
descriptionText ? [{ kind: "text", text: descriptionText }] : [],
|
|
8982
|
+
STATISTIC_DESCRIPTION_STYLE_ID,
|
|
8983
|
+
"description",
|
|
8984
|
+
{ alignment: alignment2 }
|
|
8985
|
+
)
|
|
8762
8986
|
];
|
|
8763
8987
|
}
|
|
8764
8988
|
function compileList(component, scope, referencePrefix = "list", explicitLevels) {
|
|
@@ -8831,12 +9055,12 @@ function compileList(component, scope, referencePrefix = "list", explicitLevels)
|
|
|
8831
9055
|
}
|
|
8832
9056
|
function itemSpacing(spacing, index, count) {
|
|
8833
9057
|
const out = {};
|
|
8834
|
-
if (index === 0 && spacing?.before) {
|
|
9058
|
+
if (index === 0 && spacing?.before !== void 0) {
|
|
8835
9059
|
out.beforeTwips = pointsToTwips2(spacing.before);
|
|
8836
9060
|
}
|
|
8837
|
-
if (index === count - 1 && spacing?.after) {
|
|
9061
|
+
if (index === count - 1 && spacing?.after !== void 0) {
|
|
8838
9062
|
out.afterTwips = pointsToTwips2(spacing.after);
|
|
8839
|
-
} else if (spacing?.item) {
|
|
9063
|
+
} else if (spacing?.item !== void 0) {
|
|
8840
9064
|
out.afterTwips = pointsToTwips2(spacing.item);
|
|
8841
9065
|
}
|
|
8842
9066
|
return out;
|
|
@@ -9554,6 +9778,111 @@ function compileImage2(component, scope) {
|
|
|
9554
9778
|
if (caption) blocks.push(caption);
|
|
9555
9779
|
return blocks;
|
|
9556
9780
|
}
|
|
9781
|
+
var DEFAULT_CHART_HEIGHT_INCHES = 3;
|
|
9782
|
+
function compileChart(component, scope) {
|
|
9783
|
+
const { ctx, path: path4 } = scope;
|
|
9784
|
+
const props = component.props ?? {};
|
|
9785
|
+
if (props.type === "bubble") {
|
|
9786
|
+
throw new Error(
|
|
9787
|
+
`Chart at ${path4} is a bubble chart, which no docx renderer draws; use the pptx \`chart\` component on the pptxgenjs renderer for one.`
|
|
9788
|
+
);
|
|
9789
|
+
}
|
|
9790
|
+
const rawSeries = Array.isArray(props.data) ? props.data : [];
|
|
9791
|
+
if (rawSeries.length === 0) {
|
|
9792
|
+
throw new Error(`Chart at ${path4} has no data series.`);
|
|
9793
|
+
}
|
|
9794
|
+
const series = rawSeries.map((entry, index) => {
|
|
9795
|
+
const raw = entry ?? {};
|
|
9796
|
+
const label = typeof raw.name === "string" ? raw.name : `series ${index}`;
|
|
9797
|
+
const labels = raw.labels;
|
|
9798
|
+
const values = raw.values;
|
|
9799
|
+
if (!Array.isArray(labels) || !Array.isArray(values)) {
|
|
9800
|
+
throw new Error(
|
|
9801
|
+
`Chart series "${label}" at ${path4} needs both "labels" and "values"; every series carries its own, not just the first.`
|
|
9802
|
+
);
|
|
9803
|
+
}
|
|
9804
|
+
if (labels.length !== values.length) {
|
|
9805
|
+
throw new Error(
|
|
9806
|
+
`Chart series "${label}" at ${path4} has ${labels.length} labels and ${values.length} values; they must be the same length.`
|
|
9807
|
+
);
|
|
9808
|
+
}
|
|
9809
|
+
return {
|
|
9810
|
+
...typeof raw.name === "string" ? { name: raw.name } : {},
|
|
9811
|
+
labels: labels.map((value) => String(value)),
|
|
9812
|
+
values: values.map((value) => Number(value))
|
|
9813
|
+
};
|
|
9814
|
+
});
|
|
9815
|
+
const categories = series[0].labels;
|
|
9816
|
+
for (const [index, entry] of series.entries()) {
|
|
9817
|
+
if (index === 0) continue;
|
|
9818
|
+
if (entry.labels.length !== categories.length || entry.labels.some((label, i) => label !== categories[i])) {
|
|
9819
|
+
throw new Error(
|
|
9820
|
+
`Chart series "${entry.name ?? `series ${index}`}" at ${path4} 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.`
|
|
9821
|
+
);
|
|
9822
|
+
}
|
|
9823
|
+
}
|
|
9824
|
+
const colors = Array.isArray(props.chartColors) ? props.chartColors.map(
|
|
9825
|
+
(color) => resolveColor(String(color), ctx.theme)
|
|
9826
|
+
) : DEFAULT_CHART_THEME_COLORS2.map((token) => {
|
|
9827
|
+
const value = ctx.theme?.colors?.[token];
|
|
9828
|
+
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
9829
|
+
try {
|
|
9830
|
+
return resolveColor(token, ctx.theme);
|
|
9831
|
+
} catch {
|
|
9832
|
+
return void 0;
|
|
9833
|
+
}
|
|
9834
|
+
}).filter((color) => color !== void 0);
|
|
9835
|
+
const page = getPageSetup(ctx.theme);
|
|
9836
|
+
const contentWidthInches = (page.size.width - page.margin.left - page.margin.right) / 1440;
|
|
9837
|
+
const widthInches = typeof props.width === "number" ? props.width : contentWidthInches;
|
|
9838
|
+
const heightInches = typeof props.height === "number" ? props.height : DEFAULT_CHART_HEIGHT_INCHES;
|
|
9839
|
+
const chart = {
|
|
9840
|
+
kind: "chart",
|
|
9841
|
+
chartType: props.type,
|
|
9842
|
+
series,
|
|
9843
|
+
colors,
|
|
9844
|
+
widthEmu: inchesToEmu(widthInches),
|
|
9845
|
+
heightEmu: inchesToEmu(heightInches),
|
|
9846
|
+
...typeof props.title === "string" ? { title: props.title } : {},
|
|
9847
|
+
...props.showTitle !== void 0 ? { showTitle: props.showTitle } : {},
|
|
9848
|
+
...props.showLegend !== void 0 ? { showLegend: props.showLegend } : {},
|
|
9849
|
+
...props.legendPos ? { legendPosition: props.legendPos } : {},
|
|
9850
|
+
...typeof props.catAxisTitle === "string" ? { categoryAxisTitle: props.catAxisTitle } : {},
|
|
9851
|
+
...typeof props.valAxisTitle === "string" ? { valueAxisTitle: props.valAxisTitle } : {},
|
|
9852
|
+
...typeof props.alt === "string" && props.alt ? { altText: props.alt } : {},
|
|
9853
|
+
...props.floating ? { floating: compileFloating(props.floating, ctx, path4) } : {}
|
|
9854
|
+
};
|
|
9855
|
+
ctx.features.require("charts", path4);
|
|
9856
|
+
if (props.floating) ctx.features.require("floating-images", path4);
|
|
9857
|
+
const spacing = {};
|
|
9858
|
+
if (props.spacing?.before !== void 0) {
|
|
9859
|
+
spacing.beforeTwips = pointsToTwips2(props.spacing.before);
|
|
9860
|
+
}
|
|
9861
|
+
if (props.spacing?.after !== void 0) {
|
|
9862
|
+
spacing.afterTwips = pointsToTwips2(props.spacing.after);
|
|
9863
|
+
}
|
|
9864
|
+
const blocks = [
|
|
9865
|
+
{
|
|
9866
|
+
kind: "paragraph",
|
|
9867
|
+
id: scope.id,
|
|
9868
|
+
path: path4,
|
|
9869
|
+
children: [chart],
|
|
9870
|
+
formatting: {
|
|
9871
|
+
// An anchored chart moves with its anchor, so aligning the paragraph
|
|
9872
|
+
// would move the anchor rather than the chart — the same reasoning as
|
|
9873
|
+
// a floating image.
|
|
9874
|
+
...props.floating ? {} : { alignment: compileAlignment(props.alignment) ?? "center" },
|
|
9875
|
+
...Object.keys(spacing).length > 0 ? { spacing } : {},
|
|
9876
|
+
...props.keepNext !== void 0 ? { keepNext: props.keepNext } : {},
|
|
9877
|
+
...props.keepLines !== void 0 ? { keepLines: props.keepLines } : {}
|
|
9878
|
+
}
|
|
9879
|
+
}
|
|
9880
|
+
];
|
|
9881
|
+
const caption = captionBlock(props.caption, scope, "chart");
|
|
9882
|
+
if (caption === void 0) return [];
|
|
9883
|
+
if (caption) blocks.push(caption);
|
|
9884
|
+
return blocks;
|
|
9885
|
+
}
|
|
9557
9886
|
function captionBlock(value, scope, componentName) {
|
|
9558
9887
|
if (!value) return null;
|
|
9559
9888
|
const { ctx, path: path4 } = scope;
|
|
@@ -10202,7 +10531,9 @@ function warnOnce(ctx, component, message, code) {
|
|
|
10202
10531
|
}
|
|
10203
10532
|
|
|
10204
10533
|
// src/renderers/registry.ts
|
|
10205
|
-
import {
|
|
10534
|
+
import {
|
|
10535
|
+
RendererRegistry
|
|
10536
|
+
} from "@json-to-office/shared/rendering";
|
|
10206
10537
|
|
|
10207
10538
|
// src/renderers/types.ts
|
|
10208
10539
|
import {
|
|
@@ -10228,6 +10559,9 @@ function resolveDocxRenderer(id) {
|
|
|
10228
10559
|
function docxRendererIds() {
|
|
10229
10560
|
return registry.ids();
|
|
10230
10561
|
}
|
|
10562
|
+
function docxRendererStatuses() {
|
|
10563
|
+
return registry.statuses();
|
|
10564
|
+
}
|
|
10231
10565
|
function isDocxRendererId(value) {
|
|
10232
10566
|
return registry.has(value);
|
|
10233
10567
|
}
|
|
@@ -12204,6 +12538,7 @@ export {
|
|
|
12204
12538
|
createMinimalTheme,
|
|
12205
12539
|
createVersion,
|
|
12206
12540
|
docxRendererIds,
|
|
12541
|
+
docxRendererStatuses,
|
|
12207
12542
|
examples,
|
|
12208
12543
|
exportPluginSchema,
|
|
12209
12544
|
exportThemeToJson,
|