@json-to-office/core-docx 7.0.1 → 7.1.2

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.
@@ -1,6 +1,7 @@
1
1
  import { ThemeConfig } from '../styles';
2
2
  /**
3
- * Compute available page width in twips (page width minus left/right margins)
3
+ * Compute available page width in twips (page width minus left/right margins
4
+ * and the gutter, which Word adds to the inside margin)
4
5
  */
5
6
  export declare function getAvailableWidthTwips(theme?: ThemeConfig, themeName?: string): number;
6
7
  /**
@@ -24,6 +25,13 @@ export declare function parsePercentageStringToFraction(value: string): number |
24
25
  * Numbers pass through unchanged; percentage strings are resolved against referenceTwips.
25
26
  */
26
27
  export declare function resolveOffsetTwips(value: number | string, referenceTwips: number): number;
28
+ /**
29
+ * `count` whole-twip widths that split `totalTwips` evenly and add up to it
30
+ * exactly. Rounded at the edges between them rather than one by one, so none
31
+ * strays a twip from its share: four across 9602 twips are 2401, 2400, 2401,
32
+ * 2400.
33
+ */
34
+ export declare function splitTwips(count: number, totalTwips: number): number[];
27
35
  /**
28
36
  * Convert a numeric (points) or percentage string to twips using available width
29
37
  */
@@ -1 +1 @@
1
- {"version":3,"file":"widthUtils.d.ts","sourceRoot":"","sources":["../../src/utils/widthUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,CAAC,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK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AAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAMtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAOR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-to-office/core-docx",
3
- "version": "7.0.1",
3
+ "version": "7.1.2",
4
4
  "description": "Core DOCX document generation engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "date-fns": "3.6.0",
26
26
  "probe-image-size": "7.2.3",
27
27
  "@json-to-office/quality": "^7.0.0",
28
- "@json-to-office/shared": "^7.0.1",
29
- "@json-to-office/shared-docx": "^7.0.0"
28
+ "@json-to-office/shared-docx": "^7.1.2",
29
+ "@json-to-office/shared": "^7.0.1"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "docx": "9.7.1"
@@ -1,95 +0,0 @@
1
- /**
2
- * Border utilities for consistent border styling across modules
3
- */
4
- /**
5
- * OOXML border styles, by name.
6
- *
7
- * The literal values rather than a backend's enum: `w:val` on a border is a
8
- * plain OOXML token, and this module is read by the compiler, which imports no
9
- * renderer.
10
- */
11
- export type BorderStyleName = 'none' | 'single' | 'double' | 'dashed' | 'dotted' | 'thick';
12
- import { ThemeConfig } from '../index';
13
- /**
14
- * Standard "no borders" configuration for tables
15
- * Used when borders should be invisible/disabled
16
- */
17
- export declare const NONE_BORDERS: {
18
- readonly top: {
19
- readonly style: "none";
20
- readonly size: 0;
21
- readonly color: "000000";
22
- };
23
- readonly right: {
24
- readonly style: "none";
25
- readonly size: 0;
26
- readonly color: "000000";
27
- };
28
- readonly bottom: {
29
- readonly style: "none";
30
- readonly size: 0;
31
- readonly color: "000000";
32
- };
33
- readonly left: {
34
- readonly style: "none";
35
- readonly size: 0;
36
- readonly color: "000000";
37
- };
38
- readonly insideHorizontal: {
39
- readonly style: "none";
40
- readonly size: 0;
41
- readonly color: "000000";
42
- };
43
- readonly insideVertical: {
44
- readonly style: "none";
45
- readonly size: 0;
46
- readonly color: "000000";
47
- };
48
- };
49
- /**
50
- * Maps a theme border style name to its OOXML token
51
- * @param s - Border style string ('dashed', 'dotted', 'double', 'none', 'single')
52
- * @returns The `w:val` OOXML writes for it
53
- */
54
- export declare function mapBorderStyle(s?: string): BorderStyleName;
55
- /**
56
- * Border configuration object
57
- */
58
- export interface BorderConfig {
59
- style?: string;
60
- width?: number;
61
- color?: string;
62
- }
63
- /**
64
- * Converts border configuration to docx border format
65
- * @param b - Border configuration object
66
- * @param theme - Theme configuration for color resolution
67
- * @returns Docx border object or undefined if no border
68
- */
69
- export declare function convertBorder(b: BorderConfig | undefined, theme: ThemeConfig): {
70
- style: BorderStyleName;
71
- size: number;
72
- color: string;
73
- } | undefined;
74
- /**
75
- * Borders configuration for all four sides
76
- */
77
- export interface BordersConfig {
78
- top?: BorderConfig;
79
- right?: BorderConfig;
80
- bottom?: BorderConfig;
81
- left?: BorderConfig;
82
- }
83
- /**
84
- * Converts borders configuration object to docx borders format
85
- * Returns undefined if no borders are defined
86
- * @param bordersConfig - Configuration for all four borders
87
- * @param theme - Theme configuration for color resolution
88
- * @returns Docx borders object or undefined
89
- */
90
- export declare function convertBorders(bordersConfig: BordersConfig | undefined, theme: ThemeConfig): Record<string, {
91
- style: BorderStyleName;
92
- size: number;
93
- color: string;
94
- }> | undefined;
95
- //# sourceMappingURL=borderUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"borderUtils.d.ts","sourceRoot":"","sources":["../../../src/styles/utils/borderUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,OAAO,CAAC;AAEZ,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,Y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