@json-to-office/core-docx 7.0.0 → 7.0.1
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/core/desugarExternals.d.ts.map +1 -1
- package/dist/core/imageResources.d.ts.map +1 -1
- package/dist/core/layout.d.ts +7 -0
- package/dist/core/layout.d.ts.map +1 -1
- package/dist/index.js +128 -18
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/ir/types.d.ts +14 -0
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/plugin/example/index.js +128 -18
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts.map +1 -1
- package/dist/renderers/office-open/chartParts.d.ts.map +1 -1
- package/dist/renderers/office-open/emit.d.ts.map +1 -1
- package/dist/styles/index.d.ts +2 -1
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/utils/layoutUtils.d.ts +41 -0
- package/dist/styles/utils/layoutUtils.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"desugarExternals.d.ts","sourceRoot":"","sources":["../../src/core/desugarExternals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAuB7C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC3C,2EAA2E;IAC3E,UAAU,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1C,kEAAkE;IAClE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,CAAC,CAAC,CA8EZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResources.d.ts","sourceRoot":"","sources":["../../src/core/imageResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;
|
|
1
|
+
{"version":3,"file":"imageResources.d.ts","sourceRoot":"","sources":["../../src/core/imageResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;AAOH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAOpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC;IACtE,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClD;AAED,yEAAyE;AACzE,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,QAAQ,CAAC,mBAAmB,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,cAAc,CAAC,CAgCzB"}
|
package/dist/core/layout.d.ts
CHANGED
|
@@ -71,6 +71,13 @@ export interface SectionLayout {
|
|
|
71
71
|
gutter?: number;
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Set when the section asked to continue on the page but its paper size or
|
|
76
|
+
* orientation differs from the section before it. A continuous break cannot
|
|
77
|
+
* change either, so the layout started it on a new page instead; the
|
|
78
|
+
* compiler reports that the author's request was overridden.
|
|
79
|
+
*/
|
|
80
|
+
forcedPageBreak?: boolean;
|
|
74
81
|
}
|
|
75
82
|
export interface LayoutGroup {
|
|
76
83
|
layout: 'single' | 'multi-column';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/core/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,cAAc,EAMf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/core/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,mBAAmB,EACnB,cAAc,EAMf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAQxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM,CAAC;YACd,MAAM,EAAE,MAAM,CAAC;YACf;;;eAGG;YACH,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,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AAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,GACA,qBAAqB,CAwDvB;AA0GD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,mBAAmB,EAAE,EACjC,WAAW,EAAE,MAAM,GAClB,mBAAmB,EAAE,EAAE,CAiBzB"}
|
package/dist/index.js
CHANGED
|
@@ -1847,6 +1847,21 @@ function getPageDimensions(size) {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
return { width: size.width, height: size.height };
|
|
1849
1849
|
}
|
|
1850
|
+
function themeForSectionPage(theme, page) {
|
|
1851
|
+
if (!page || !page.size && !page.margins) return theme;
|
|
1852
|
+
const base = getPageSetup(theme);
|
|
1853
|
+
return {
|
|
1854
|
+
...theme,
|
|
1855
|
+
page: {
|
|
1856
|
+
...theme.page,
|
|
1857
|
+
size: page.size ?? theme.page?.size ?? "A4",
|
|
1858
|
+
margins: { ...theme.page?.margins, ...base.margin, ...page.margins }
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
function pageSizeDiffers(a, b) {
|
|
1863
|
+
return a.width !== b.width || a.height !== b.height;
|
|
1864
|
+
}
|
|
1850
1865
|
var resolveTableParagraphSpacing, PAGE_SIZES, getTableStyle, getDocumentMargins, getPageSetup;
|
|
1851
1866
|
var init_layoutUtils = __esm({
|
|
1852
1867
|
"src/styles/utils/layoutUtils.ts"() {
|
|
@@ -3232,7 +3247,7 @@ function emitBlock(block2, resources = /* @__PURE__ */ new Map()) {
|
|
|
3232
3247
|
}
|
|
3233
3248
|
}
|
|
3234
3249
|
function emitToc(block2) {
|
|
3235
|
-
return new
|
|
3250
|
+
return new ThemedTableOfContents(block2.alias ?? "Table of Contents", {
|
|
3236
3251
|
...block2.hyperlink !== void 0 ? { hyperlink: block2.hyperlink } : {},
|
|
3237
3252
|
...block2.headingRange ? {
|
|
3238
3253
|
headingStyleRange: `${block2.headingRange.from}-${block2.headingRange.to}`
|
|
@@ -3364,7 +3379,7 @@ function emitBorder(border3) {
|
|
|
3364
3379
|
...border3.spacePoints !== void 0 ? { space: border3.spacePoints } : {}
|
|
3365
3380
|
};
|
|
3366
3381
|
}
|
|
3367
|
-
var ALIGNMENT2, PAGE_FIELDS, isSequenceField, WRAP_TYPE, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
|
|
3382
|
+
var ALIGNMENT2, PAGE_FIELDS, isSequenceField, WRAP_TYPE, ThemedTableOfContents, VERTICAL_ALIGN, TABLE_ANCHOR, HORIZONTAL_POSITION, VERTICAL_POSITION, BORDER_STYLE;
|
|
3368
3383
|
var init_emit = __esm({
|
|
3369
3384
|
"src/renderers/docxjs/emit.ts"() {
|
|
3370
3385
|
"use strict";
|
|
@@ -3384,6 +3399,11 @@ var init_emit = __esm({
|
|
|
3384
3399
|
tight: TextWrappingType.TIGHT,
|
|
3385
3400
|
topAndBottom: TextWrappingType.TOP_AND_BOTTOM
|
|
3386
3401
|
};
|
|
3402
|
+
ThemedTableOfContents = class extends TableOfContents {
|
|
3403
|
+
};
|
|
3404
|
+
Object.defineProperty(ThemedTableOfContents.prototype, "getTabStopsForLevel", {
|
|
3405
|
+
value: () => []
|
|
3406
|
+
});
|
|
3387
3407
|
VERTICAL_ALIGN = {
|
|
3388
3408
|
top: VerticalAlign.TOP,
|
|
3389
3409
|
center: VerticalAlign.CENTER,
|
|
@@ -4144,13 +4164,30 @@ import {
|
|
|
4144
4164
|
spliceChartXml
|
|
4145
4165
|
} from "@json-to-office/shared/rendering";
|
|
4146
4166
|
function spliceInput(chart) {
|
|
4167
|
+
const { bold, ...rest } = chart.textFont;
|
|
4168
|
+
const textFont = rest;
|
|
4169
|
+
const axisTitleFont = { ...rest, bold };
|
|
4170
|
+
const chartTitleFont = {
|
|
4171
|
+
...rest,
|
|
4172
|
+
fontSize: Math.round(rest.fontSize * CHART_TITLE_SCALE),
|
|
4173
|
+
bold: true
|
|
4174
|
+
};
|
|
4147
4175
|
return {
|
|
4148
4176
|
chartType: chart.chartType,
|
|
4149
4177
|
series: chart.series,
|
|
4150
4178
|
colors: chart.colors,
|
|
4179
|
+
textFont,
|
|
4180
|
+
titleFont: chartTitleFont,
|
|
4151
4181
|
...chart.legendPosition ? { legendPosition: chart.legendPosition } : {},
|
|
4152
|
-
...chart.categoryAxisTitle ? {
|
|
4153
|
-
|
|
4182
|
+
...chart.categoryAxisTitle ? {
|
|
4183
|
+
categoryAxis: {
|
|
4184
|
+
title: chart.categoryAxisTitle,
|
|
4185
|
+
titleFont: axisTitleFont
|
|
4186
|
+
}
|
|
4187
|
+
} : {},
|
|
4188
|
+
...chart.valueAxisTitle ? {
|
|
4189
|
+
valueAxis: { title: chart.valueAxisTitle, titleFont: axisTitleFont }
|
|
4190
|
+
} : {}
|
|
4154
4191
|
};
|
|
4155
4192
|
}
|
|
4156
4193
|
function declareWorkbookContentType(zip) {
|
|
@@ -4194,10 +4231,12 @@ function spliceChartParts(zip, charts) {
|
|
|
4194
4231
|
}
|
|
4195
4232
|
declareWorkbookContentType(zip);
|
|
4196
4233
|
}
|
|
4234
|
+
var CHART_TITLE_SCALE;
|
|
4197
4235
|
var init_chartParts = __esm({
|
|
4198
4236
|
"src/renderers/office-open/chartParts.ts"() {
|
|
4199
4237
|
"use strict";
|
|
4200
4238
|
init_chartWorkbook();
|
|
4239
|
+
CHART_TITLE_SCALE = 1.4;
|
|
4201
4240
|
}
|
|
4202
4241
|
});
|
|
4203
4242
|
|
|
@@ -4743,9 +4782,6 @@ function tocEntry(entry) {
|
|
|
4743
4782
|
return {
|
|
4744
4783
|
paragraph: {
|
|
4745
4784
|
style: `TOC${entry.level}`,
|
|
4746
|
-
tabStops: [
|
|
4747
|
-
{ type: "right", position: TOC_PAGE_TAB_TWIPS, leader: "dot" }
|
|
4748
|
-
],
|
|
4749
4785
|
children: [{ text: entry.text }, { children: [{ tab: true }] }]
|
|
4750
4786
|
}
|
|
4751
4787
|
};
|
|
@@ -4775,13 +4811,18 @@ function table(value, ctx) {
|
|
|
4775
4811
|
return {
|
|
4776
4812
|
rows: value.rows.map((row) => tableRow(row, ctx)),
|
|
4777
4813
|
width: {
|
|
4778
|
-
|
|
4814
|
+
// `w:w` is an integer in OOXML. A grid that splits a remainder between
|
|
4815
|
+
// unstated columns comes out fractional, and the XML would carry it
|
|
4816
|
+
// verbatim; floored here, as the docxjs backend floors it.
|
|
4817
|
+
size: value.width.kind === "auto" ? 0 : value.width.kind === "twips" ? Math.floor(value.width.value) : value.width.value,
|
|
4779
4818
|
type: value.width.kind === "twips" ? "dxa" : value.width.kind === "percent" ? "pct" : "auto"
|
|
4780
4819
|
},
|
|
4781
4820
|
layout: value.layout,
|
|
4782
4821
|
// An empty grid is a table with nothing to say about its columns, which is
|
|
4783
4822
|
// not the same as one whose columns are all zero wide.
|
|
4784
|
-
...value.columnGrid.values.length > 0 ? {
|
|
4823
|
+
...value.columnGrid.values.length > 0 ? {
|
|
4824
|
+
columnWidths: value.columnGrid.unit === "twips" ? value.columnGrid.values.map(Math.floor) : value.columnGrid.values
|
|
4825
|
+
} : {},
|
|
4785
4826
|
...value.alignment ? { alignment: alignment(value.alignment) } : {},
|
|
4786
4827
|
...value.borders ? { borders: borders2(value.borders) } : {},
|
|
4787
4828
|
...value.cellMargins ? { margins: cellMargins(value.cellMargins) } : {},
|
|
@@ -4973,7 +5014,7 @@ function numberingConfig2(numbering) {
|
|
|
4973
5014
|
}))
|
|
4974
5015
|
};
|
|
4975
5016
|
}
|
|
4976
|
-
var WRAP_TYPE2, BODY_ANCHOR
|
|
5017
|
+
var WRAP_TYPE2, BODY_ANCHOR;
|
|
4977
5018
|
var init_emit2 = __esm({
|
|
4978
5019
|
"src/renderers/office-open/emit.ts"() {
|
|
4979
5020
|
"use strict";
|
|
@@ -4989,7 +5030,6 @@ var init_emit2 = __esm({
|
|
|
4989
5030
|
middle: "ctr",
|
|
4990
5031
|
bottom: "b"
|
|
4991
5032
|
};
|
|
4992
|
-
TOC_PAGE_TAB_TWIPS = 9025;
|
|
4993
5033
|
}
|
|
4994
5034
|
});
|
|
4995
5035
|
|
|
@@ -5270,7 +5310,9 @@ function addPngTextChunk(data, marker) {
|
|
|
5270
5310
|
}
|
|
5271
5311
|
offset = chunkEnd;
|
|
5272
5312
|
}
|
|
5273
|
-
|
|
5313
|
+
throw new Error(
|
|
5314
|
+
"Cannot mark a PNG that has no intact IEND chunk; its bytes were not checked to decode before rendering"
|
|
5315
|
+
);
|
|
5274
5316
|
}
|
|
5275
5317
|
function addJpegComment(data, marker) {
|
|
5276
5318
|
if (data.length < 2 || data[0] !== 255 || data[1] !== 216) {
|
|
@@ -5969,6 +6011,7 @@ function containsComponent(root, name) {
|
|
|
5969
6011
|
}
|
|
5970
6012
|
|
|
5971
6013
|
// src/core/desugarExternals.ts
|
|
6014
|
+
init_layoutUtils();
|
|
5972
6015
|
import {
|
|
5973
6016
|
clampVisualDpi as clampVisualDpi2,
|
|
5974
6017
|
DEFAULT_VISUAL_DPI as DEFAULT_VISUAL_DPI2,
|
|
@@ -6172,8 +6215,18 @@ async function desugarExternals(document, options) {
|
|
|
6172
6215
|
}
|
|
6173
6216
|
).catch(() => /* @__PURE__ */ new Map());
|
|
6174
6217
|
const chartCache = /* @__PURE__ */ new Map();
|
|
6175
|
-
|
|
6218
|
+
const replace = (theme, inSection) => async function replaceNode(node) {
|
|
6176
6219
|
if (node.enabled === false) return void 0;
|
|
6220
|
+
if (node.name === "section" && !inSection) {
|
|
6221
|
+
const page = node.props.page;
|
|
6222
|
+
return transformComponents(
|
|
6223
|
+
node,
|
|
6224
|
+
replace(themeForSectionPage(theme, page), true)
|
|
6225
|
+
);
|
|
6226
|
+
}
|
|
6227
|
+
return replaceExternal(node, theme);
|
|
6228
|
+
};
|
|
6229
|
+
const replaceExternal = async (node, theme) => {
|
|
6177
6230
|
if (node.name === "visual") {
|
|
6178
6231
|
if (isNativeVisualProps2(node.props)) return void 0;
|
|
6179
6232
|
return withNodeIdentity(node, {
|
|
@@ -6191,7 +6244,7 @@ async function desugarExternals(document, options) {
|
|
|
6191
6244
|
name: "image",
|
|
6192
6245
|
props: await renderChartToImageProps(
|
|
6193
6246
|
node.props,
|
|
6194
|
-
|
|
6247
|
+
theme,
|
|
6195
6248
|
options.services?.highcharts,
|
|
6196
6249
|
options.chartFonts,
|
|
6197
6250
|
options.warnings,
|
|
@@ -6200,7 +6253,8 @@ async function desugarExternals(document, options) {
|
|
|
6200
6253
|
});
|
|
6201
6254
|
}
|
|
6202
6255
|
return void 0;
|
|
6203
|
-
}
|
|
6256
|
+
};
|
|
6257
|
+
return transformComponents(document, replace(options.theme, false));
|
|
6204
6258
|
}
|
|
6205
6259
|
async function visualImageProps(props, prerastered, options) {
|
|
6206
6260
|
const serviceConfig = options.services?.pptx;
|
|
@@ -6235,6 +6289,7 @@ init_imageUtils();
|
|
|
6235
6289
|
import {
|
|
6236
6290
|
isNativeVisualProps as isNativeVisualProps3
|
|
6237
6291
|
} from "@json-to-office/shared-docx";
|
|
6292
|
+
import { imageIntegrityDefect } from "@json-to-office/shared/images/node";
|
|
6238
6293
|
async function loadImageResources(components) {
|
|
6239
6294
|
const sources = /* @__PURE__ */ new Set();
|
|
6240
6295
|
for (const component of components) collectSources(component, sources);
|
|
@@ -6244,6 +6299,8 @@ async function loadImageResources(components) {
|
|
|
6244
6299
|
[...sources].map(async (source) => {
|
|
6245
6300
|
try {
|
|
6246
6301
|
const result = await getImageBuffer(source);
|
|
6302
|
+
const defect = imageIntegrityDefect(result.buffer);
|
|
6303
|
+
if (defect) throw new Error(defect);
|
|
6247
6304
|
const intrinsic = readIntrinsic(result.buffer, source);
|
|
6248
6305
|
loaded.set(source, {
|
|
6249
6306
|
bytes: result.buffer,
|
|
@@ -9170,8 +9227,25 @@ function resolveSectionChrome(sections) {
|
|
|
9170
9227
|
});
|
|
9171
9228
|
}
|
|
9172
9229
|
function compileSection(section2, index, ordinal, chrome, ctx) {
|
|
9230
|
+
const documentTheme = ctx.theme;
|
|
9231
|
+
ctx.theme = themeForSectionPage(documentTheme, section2.pageOverride);
|
|
9232
|
+
try {
|
|
9233
|
+
return compileSectionBody(section2, index, ordinal, chrome, ctx);
|
|
9234
|
+
} finally {
|
|
9235
|
+
ctx.theme = documentTheme;
|
|
9236
|
+
}
|
|
9237
|
+
}
|
|
9238
|
+
function compileSectionBody(section2, index, ordinal, chrome, ctx) {
|
|
9173
9239
|
const path4 = `sections[${index}]`;
|
|
9174
9240
|
const { page, column } = section2.properties;
|
|
9241
|
+
if (section2.forcedPageBreak) {
|
|
9242
|
+
warnOnce(
|
|
9243
|
+
ctx,
|
|
9244
|
+
"section",
|
|
9245
|
+
`${path4} is set to continue on the page but changes the paper size or orientation, which a continuous section break cannot do, so it starts on a new page instead. Set pageBreak: true on the section to say so, or keep the page size of the section before it.`,
|
|
9246
|
+
"W_SECTION_PAGE_BREAK_FORCED"
|
|
9247
|
+
);
|
|
9248
|
+
}
|
|
9175
9249
|
if (column && column.count > 1) {
|
|
9176
9250
|
ctx.features.require("columns", `${path4}.properties.columns`);
|
|
9177
9251
|
}
|
|
@@ -11026,6 +11100,24 @@ function compileImage2(component, scope) {
|
|
|
11026
11100
|
return blocks;
|
|
11027
11101
|
}
|
|
11028
11102
|
var DEFAULT_CHART_HEIGHT_INCHES = 3;
|
|
11103
|
+
var MAX_CHART_TEXT_POINTS = 10;
|
|
11104
|
+
function chartTextFont(theme) {
|
|
11105
|
+
const bodySize = getThemeFonts(theme).body?.size;
|
|
11106
|
+
let color = "000000";
|
|
11107
|
+
try {
|
|
11108
|
+
color = resolveColor("textPrimary", theme);
|
|
11109
|
+
} catch {
|
|
11110
|
+
}
|
|
11111
|
+
return {
|
|
11112
|
+
fontFamily: resolveFontFamily(theme, "body"),
|
|
11113
|
+
fontSize: Math.min(
|
|
11114
|
+
typeof bodySize === "number" && bodySize > 0 ? bodySize : 11,
|
|
11115
|
+
MAX_CHART_TEXT_POINTS
|
|
11116
|
+
),
|
|
11117
|
+
bold: false,
|
|
11118
|
+
color
|
|
11119
|
+
};
|
|
11120
|
+
}
|
|
11029
11121
|
function compileChart(component, scope) {
|
|
11030
11122
|
const { ctx, path: path4 } = scope;
|
|
11031
11123
|
const props = component.props ?? {};
|
|
@@ -11094,6 +11186,7 @@ function compileChart(component, scope) {
|
|
|
11094
11186
|
...props.legendPos ? { legendPosition: props.legendPos } : {},
|
|
11095
11187
|
...typeof props.catAxisTitle === "string" ? { categoryAxisTitle: props.catAxisTitle } : {},
|
|
11096
11188
|
...typeof props.valAxisTitle === "string" ? { valueAxisTitle: props.valAxisTitle } : {},
|
|
11189
|
+
textFont: chartTextFont(ctx.theme),
|
|
11097
11190
|
...typeof props.alt === "string" && props.alt ? { altText: props.alt } : {},
|
|
11098
11191
|
...props.floating ? { floating: compileFloating(props.floating, ctx, path4) } : {}
|
|
11099
11192
|
};
|
|
@@ -11832,6 +11925,18 @@ init_styles();
|
|
|
11832
11925
|
init_widthUtils();
|
|
11833
11926
|
function applyLayout(sections, theme, themeName) {
|
|
11834
11927
|
const layoutSections = [];
|
|
11928
|
+
const push = (layoutSection) => {
|
|
11929
|
+
const previous = layoutSections[layoutSections.length - 1];
|
|
11930
|
+
if (previous && layoutSection.properties.type === "continuous" && pageSizeDiffers(
|
|
11931
|
+
previous.properties.page.size,
|
|
11932
|
+
layoutSection.properties.page.size
|
|
11933
|
+
)) {
|
|
11934
|
+
layoutSection.properties.type = "nextPage";
|
|
11935
|
+
layoutSection.breakBefore = true;
|
|
11936
|
+
layoutSection.forcedPageBreak = true;
|
|
11937
|
+
}
|
|
11938
|
+
layoutSections.push(layoutSection);
|
|
11939
|
+
};
|
|
11835
11940
|
for (let i = 0; i < sections.length; i++) {
|
|
11836
11941
|
const section2 = sections[i];
|
|
11837
11942
|
const layoutGroups = analyzeLayoutGroups(section2.components);
|
|
@@ -11840,7 +11945,7 @@ function applyLayout(sections, theme, themeName) {
|
|
|
11840
11945
|
const isFirstSection = i === 0;
|
|
11841
11946
|
const breakBefore = isFirstSection || Boolean(section2.pageBreak);
|
|
11842
11947
|
const sectionType2 = breakBefore ? "nextPage" : "continuous";
|
|
11843
|
-
|
|
11948
|
+
push({
|
|
11844
11949
|
properties: createSectionProperties(
|
|
11845
11950
|
getColumnSettings("single"),
|
|
11846
11951
|
theme,
|
|
@@ -11862,7 +11967,12 @@ function applyLayout(sections, theme, themeName) {
|
|
|
11862
11967
|
for (let j = 0; j < layoutGroups.length; j++) {
|
|
11863
11968
|
const group = layoutGroups[j];
|
|
11864
11969
|
const isSingleColumnsGroup = group.components.length === 1 && isColumnsComponent(group.components[0]);
|
|
11865
|
-
const columnSettings = isSingleColumnsGroup ? createColumnSettingsFromConfig(
|
|
11970
|
+
const columnSettings = isSingleColumnsGroup ? createColumnSettingsFromConfig(
|
|
11971
|
+
group.components[0],
|
|
11972
|
+
// Percentages are of this section's text measure, not the theme's.
|
|
11973
|
+
theme ? themeForSectionPage(theme, section2.page) : theme,
|
|
11974
|
+
themeName
|
|
11975
|
+
) : getColumnSettings(group.layout);
|
|
11866
11976
|
const isFirstSection = i === 0 && j === 0;
|
|
11867
11977
|
const titlelessSectionBreak = Boolean(section2.pageBreak && j === 0);
|
|
11868
11978
|
const breakBefore = group.breakBefore || isFirstSection || titlelessSectionBreak;
|
|
@@ -11870,7 +11980,7 @@ function applyLayout(sections, theme, themeName) {
|
|
|
11870
11980
|
const contentComponents = isSingleColumnsGroup ? processLayoutComponents(
|
|
11871
11981
|
group.components[0].children || []
|
|
11872
11982
|
) : processLayoutComponents(group.components);
|
|
11873
|
-
|
|
11983
|
+
push({
|
|
11874
11984
|
properties: createSectionProperties(
|
|
11875
11985
|
columnSettings,
|
|
11876
11986
|
theme,
|