ts-visio 1.2.0 → 1.3.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/README.md +76 -4
- package/dist/Page.d.ts +23 -2
- package/dist/Page.js +48 -2
- package/dist/Shape.d.ts +2 -2
- package/dist/Shape.js +2 -2
- package/dist/ShapeModifier.d.ts +15 -2
- package/dist/ShapeModifier.js +41 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -1
- package/dist/shapes/ConnectorBuilder.d.ts +2 -1
- package/dist/shapes/ConnectorBuilder.js +14 -4
- package/dist/shapes/GeometryBuilder.d.ts +42 -0
- package/dist/shapes/GeometryBuilder.js +177 -0
- package/dist/shapes/ShapeBuilder.js +2 -12
- package/dist/types/VisioTypes.d.ts +57 -0
- package/dist/types/VisioTypes.js +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
A Node.js library to strict-type interact with Visio (`.vsdx`) files.
|
|
9
9
|
Built using specific schema-level abstractions to handle the complex internal structure of Visio documents (ShapeSheets, Pages, Masters).
|
|
10
10
|
|
|
11
|
-
> **Status**: Work In Progress (TDD).
|
|
12
|
-
|
|
13
11
|
## Features
|
|
14
12
|
|
|
15
13
|
- **Read VSDX**: Open and parse `.vsdx` files (zipped XML).
|
|
@@ -18,13 +16,16 @@ Built using specific schema-level abstractions to handle the complex internal st
|
|
|
18
16
|
- **Connections**: Analyze connectivity between shapes.
|
|
19
17
|
- **Modular Architecture**: Use specialized components for loading, page management, shape reading, and modification.
|
|
20
18
|
- **Modify Content**: Update text content of shapes.
|
|
21
|
-
- **Create Shapes**:
|
|
22
|
-
- **Connect Shapes**:
|
|
19
|
+
- **Create Shapes**: Rectangles, ellipses, diamonds, rounded rectangles, triangles, parallelograms.
|
|
20
|
+
- **Connect Shapes**: Dynamic connectors with arrow styles, line styling, and routing (straight / orthogonal / curved).
|
|
23
21
|
- **Text Styling**: Font size, font family, bold, color, horizontal/vertical alignment.
|
|
24
22
|
- **Shape Transformations**: Rotate, flip (X/Y), and resize shapes via a fluent API.
|
|
25
23
|
- **Deletion**: Remove shapes and pages cleanly (including orphaned connectors and relationships).
|
|
26
24
|
- **Lookup API**: Find shapes by ID, predicate, or look up pages by name.
|
|
27
25
|
- **Read-Back API**: Read custom properties, hyperlinks, and layer assignments from existing shapes.
|
|
26
|
+
- **Page Size & Orientation**: Set canvas dimensions with named sizes (`Letter`, `A4`, …) or raw inches; rotate between portrait and landscape.
|
|
27
|
+
|
|
28
|
+
Feature gaps are being tracked in [FEATURES.md](./FEATURES.md).
|
|
28
29
|
|
|
29
30
|
## Installation
|
|
30
31
|
|
|
@@ -418,6 +419,77 @@ const links = shape.getHyperlinks();
|
|
|
418
419
|
const indices = shape.getLayerIndices(); // e.g. [0, 2]
|
|
419
420
|
```
|
|
420
421
|
|
|
422
|
+
#### 23. Non-Rectangular Geometry
|
|
423
|
+
Use the `geometry` prop on `addShape()` to create common flowchart primitives without touching XML.
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
// Ellipse / circle
|
|
427
|
+
await page.addShape({ text: "Start", x: 1, y: 5, width: 2, height: 2, geometry: 'ellipse' });
|
|
428
|
+
|
|
429
|
+
// Decision diamond
|
|
430
|
+
await page.addShape({ text: "Yes?", x: 4, y: 5, width: 2, height: 2, geometry: 'diamond' });
|
|
431
|
+
|
|
432
|
+
// Rounded rectangle (optional corner radius in inches)
|
|
433
|
+
await page.addShape({ text: "Process", x: 7, y: 5, width: 3, height: 2,
|
|
434
|
+
geometry: 'rounded-rectangle', cornerRadius: 0.2 });
|
|
435
|
+
|
|
436
|
+
// Right-pointing triangle
|
|
437
|
+
await page.addShape({ text: "Extract", x: 1, y: 2, width: 2, height: 2, geometry: 'triangle' });
|
|
438
|
+
|
|
439
|
+
// Parallelogram (Data / IO shape)
|
|
440
|
+
await page.addShape({ text: "Input", x: 4, y: 2, width: 3, height: 1.5, geometry: 'parallelogram' });
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Supported values: `'rectangle'` (default), `'ellipse'`, `'diamond'`, `'rounded-rectangle'`, `'triangle'`, `'parallelogram'`.
|
|
444
|
+
|
|
445
|
+
#### 24. Connector Styling
|
|
446
|
+
Control line appearance and routing algorithm on any connector.
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
import { ArrowHeads } from 'ts-visio/utils/StyleHelpers';
|
|
450
|
+
|
|
451
|
+
// Styled connector with crow's foot arrow and custom line
|
|
452
|
+
await shape1.connectTo(shape2, ArrowHeads.One, ArrowHeads.CrowsFoot, {
|
|
453
|
+
lineColor: '#cc0000', // Hex stroke color
|
|
454
|
+
lineWeight: 1.5, // Stroke width in points
|
|
455
|
+
linePattern: 2, // 1=solid, 2=dash, 3=dot, 4=dash-dot
|
|
456
|
+
routing: 'curved', // 'straight' | 'orthogonal' (default) | 'curved'
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// Via page.connectShapes()
|
|
460
|
+
await page.connectShapes(a, b, undefined, undefined, { routing: 'straight' });
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### 25. Page Size & Orientation
|
|
464
|
+
Control the canvas dimensions using named paper sizes or raw inch values.
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
import { PageSizes } from 'ts-visio';
|
|
468
|
+
|
|
469
|
+
// Use a named paper size (portrait by default)
|
|
470
|
+
page.setNamedSize('A4'); // 8.268" × 11.693"
|
|
471
|
+
page.setNamedSize('Letter', 'landscape'); // 11" × 8.5"
|
|
472
|
+
|
|
473
|
+
// Set arbitrary dimensions in inches
|
|
474
|
+
page.setSize(13.33, 7.5); // 13.33" × 7.5" widescreen
|
|
475
|
+
|
|
476
|
+
// Rotate the existing canvas without changing the paper size
|
|
477
|
+
page.setOrientation('landscape'); // swaps width and height if needed
|
|
478
|
+
page.setOrientation('portrait');
|
|
479
|
+
|
|
480
|
+
// Read current dimensions
|
|
481
|
+
console.log(page.pageWidth); // e.g. 11
|
|
482
|
+
console.log(page.pageHeight); // e.g. 8.5
|
|
483
|
+
console.log(page.orientation); // 'landscape' | 'portrait'
|
|
484
|
+
|
|
485
|
+
// All size methods are chainable
|
|
486
|
+
page.setNamedSize('A3').setOrientation('landscape');
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
Available named sizes in `PageSizes`: `Letter`, `Legal`, `Tabloid`, `A3`, `A4`, `A5`.
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
421
493
|
## Examples
|
|
422
494
|
|
|
423
495
|
Check out the [examples](./examples) directory for complete scripts.
|
package/dist/Page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VisioPage } from './types/VisioTypes';
|
|
1
|
+
import { VisioPage, ConnectorStyle, PageOrientation, PageSizeName } from './types/VisioTypes';
|
|
2
2
|
import { VisioPackage } from './VisioPackage';
|
|
3
3
|
import { ShapeModifier } from './ShapeModifier';
|
|
4
4
|
import { NewShapeProps } from './types/VisioTypes';
|
|
@@ -17,6 +17,27 @@ export declare class Page {
|
|
|
17
17
|
constructor(internalPage: VisioPage, pkg: VisioPackage, media?: MediaManager, rels?: RelsManager, modifier?: ShapeModifier);
|
|
18
18
|
get id(): string;
|
|
19
19
|
get name(): string;
|
|
20
|
+
/** Width of the page canvas in inches. */
|
|
21
|
+
get pageWidth(): number;
|
|
22
|
+
/** Height of the page canvas in inches. */
|
|
23
|
+
get pageHeight(): number;
|
|
24
|
+
/** Current page orientation derived from the canvas dimensions. */
|
|
25
|
+
get orientation(): PageOrientation;
|
|
26
|
+
/**
|
|
27
|
+
* Set the page canvas size in inches.
|
|
28
|
+
* @example page.setSize(11, 8.5) // landscape letter
|
|
29
|
+
*/
|
|
30
|
+
setSize(width: number, height: number): this;
|
|
31
|
+
/**
|
|
32
|
+
* Convenience: change the page to a named standard size (portrait by default).
|
|
33
|
+
* @example page.setNamedSize('A4')
|
|
34
|
+
*/
|
|
35
|
+
setNamedSize(sizeName: PageSizeName, orientation?: PageOrientation): this;
|
|
36
|
+
/**
|
|
37
|
+
* Rotate the canvas between portrait and landscape without changing the paper size.
|
|
38
|
+
* Swaps width and height when the current orientation does not match the requested one.
|
|
39
|
+
*/
|
|
40
|
+
setOrientation(orientation: PageOrientation): this;
|
|
20
41
|
getShapes(): Shape[];
|
|
21
42
|
/**
|
|
22
43
|
* Find a shape by its ID anywhere on the page, including shapes nested inside groups.
|
|
@@ -29,7 +50,7 @@ export declare class Page {
|
|
|
29
50
|
*/
|
|
30
51
|
findShapes(predicate: (shape: Shape) => boolean): Shape[];
|
|
31
52
|
addShape(props: NewShapeProps, parentId?: string): Promise<Shape>;
|
|
32
|
-
connectShapes(fromShape: Shape, toShape: Shape, beginArrow?: string, endArrow?: string): Promise<void>;
|
|
53
|
+
connectShapes(fromShape: Shape, toShape: Shape, beginArrow?: string, endArrow?: string, style?: ConnectorStyle): Promise<void>;
|
|
33
54
|
addImage(data: Buffer, name: string, x: number, y: number, width: number, height: number): Promise<Shape>;
|
|
34
55
|
addContainer(props: NewShapeProps): Promise<Shape>;
|
|
35
56
|
addList(props: NewShapeProps, direction?: 'vertical' | 'horizontal'): Promise<Shape>;
|
package/dist/Page.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Page = void 0;
|
|
4
|
+
const VisioTypes_1 = require("./types/VisioTypes");
|
|
4
5
|
const ShapeReader_1 = require("./ShapeReader");
|
|
5
6
|
const ShapeModifier_1 = require("./ShapeModifier");
|
|
6
7
|
const Shape_1 = require("./Shape");
|
|
@@ -26,6 +27,51 @@ class Page {
|
|
|
26
27
|
get name() {
|
|
27
28
|
return this.internalPage.Name;
|
|
28
29
|
}
|
|
30
|
+
/** Width of the page canvas in inches. */
|
|
31
|
+
get pageWidth() {
|
|
32
|
+
return this.modifier.getPageDimensions(this.id).width;
|
|
33
|
+
}
|
|
34
|
+
/** Height of the page canvas in inches. */
|
|
35
|
+
get pageHeight() {
|
|
36
|
+
return this.modifier.getPageDimensions(this.id).height;
|
|
37
|
+
}
|
|
38
|
+
/** Current page orientation derived from the canvas dimensions. */
|
|
39
|
+
get orientation() {
|
|
40
|
+
return this.pageWidth > this.pageHeight ? 'landscape' : 'portrait';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Set the page canvas size in inches.
|
|
44
|
+
* @example page.setSize(11, 8.5) // landscape letter
|
|
45
|
+
*/
|
|
46
|
+
setSize(width, height) {
|
|
47
|
+
this.modifier.setPageSize(this.id, width, height);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Convenience: change the page to a named standard size (portrait by default).
|
|
52
|
+
* @example page.setNamedSize('A4')
|
|
53
|
+
*/
|
|
54
|
+
setNamedSize(sizeName, orientation = 'portrait') {
|
|
55
|
+
const { width, height } = VisioTypes_1.PageSizes[sizeName];
|
|
56
|
+
return orientation === 'landscape'
|
|
57
|
+
? this.setSize(height, width)
|
|
58
|
+
: this.setSize(width, height);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Rotate the canvas between portrait and landscape without changing the paper size.
|
|
62
|
+
* Swaps width and height when the current orientation does not match the requested one.
|
|
63
|
+
*/
|
|
64
|
+
setOrientation(orientation) {
|
|
65
|
+
const w = this.pageWidth;
|
|
66
|
+
const h = this.pageHeight;
|
|
67
|
+
if (orientation === 'landscape' && h > w) {
|
|
68
|
+
this.modifier.setPageSize(this.id, h, w);
|
|
69
|
+
}
|
|
70
|
+
else if (orientation === 'portrait' && w > h) {
|
|
71
|
+
this.modifier.setPageSize(this.id, h, w);
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
29
75
|
getShapes() {
|
|
30
76
|
const reader = new ShapeReader_1.ShapeReader(this.pkg);
|
|
31
77
|
try {
|
|
@@ -78,8 +124,8 @@ class Page {
|
|
|
78
124
|
});
|
|
79
125
|
return new Shape_1.Shape(internalStub, this.id, this.pkg, this.modifier);
|
|
80
126
|
}
|
|
81
|
-
async connectShapes(fromShape, toShape, beginArrow, endArrow) {
|
|
82
|
-
await this.modifier.addConnector(this.id, fromShape.id, toShape.id, beginArrow, endArrow);
|
|
127
|
+
async connectShapes(fromShape, toShape, beginArrow, endArrow, style) {
|
|
128
|
+
await this.modifier.addConnector(this.id, fromShape.id, toShape.id, beginArrow, endArrow, style);
|
|
83
129
|
}
|
|
84
130
|
async addImage(data, name, x, y, width, height) {
|
|
85
131
|
// 1. Upload Media
|
package/dist/Shape.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VisioShape } from './types/VisioTypes';
|
|
1
|
+
import { VisioShape, ConnectorStyle } from './types/VisioTypes';
|
|
2
2
|
import { VisioPackage } from './VisioPackage';
|
|
3
3
|
import { ShapeModifier, ShapeStyle } from './ShapeModifier';
|
|
4
4
|
import { VisioPropType } from './types/VisioTypes';
|
|
@@ -30,7 +30,7 @@ export declare class Shape {
|
|
|
30
30
|
get x(): number;
|
|
31
31
|
get y(): number;
|
|
32
32
|
delete(): Promise<void>;
|
|
33
|
-
connectTo(targetShape: Shape, beginArrow?: string, endArrow?: string): Promise<this>;
|
|
33
|
+
connectTo(targetShape: Shape, beginArrow?: string, endArrow?: string, style?: ConnectorStyle): Promise<this>;
|
|
34
34
|
setStyle(style: ShapeStyle): Promise<this>;
|
|
35
35
|
placeRightOf(targetShape: Shape, options?: {
|
|
36
36
|
gap: number;
|
package/dist/Shape.js
CHANGED
|
@@ -42,8 +42,8 @@ class Shape {
|
|
|
42
42
|
async delete() {
|
|
43
43
|
await this.modifier.deleteShape(this.pageId, this.id);
|
|
44
44
|
}
|
|
45
|
-
async connectTo(targetShape, beginArrow, endArrow) {
|
|
46
|
-
await this.modifier.addConnector(this.pageId, this.id, targetShape.id, beginArrow, endArrow);
|
|
45
|
+
async connectTo(targetShape, beginArrow, endArrow, style) {
|
|
46
|
+
await this.modifier.addConnector(this.pageId, this.id, targetShape.id, beginArrow, endArrow, style);
|
|
47
47
|
return this;
|
|
48
48
|
}
|
|
49
49
|
async setStyle(style) {
|
package/dist/ShapeModifier.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VisioPackage } from './VisioPackage';
|
|
2
2
|
import { HorzAlign, VertAlign } from './utils/StyleHelpers';
|
|
3
|
-
import { NewShapeProps } from './types/VisioTypes';
|
|
3
|
+
import { NewShapeProps, ConnectorStyle } from './types/VisioTypes';
|
|
4
4
|
import type { ShapeData, ShapeHyperlink } from './Shape';
|
|
5
5
|
export declare class ShapeModifier {
|
|
6
6
|
private pkg;
|
|
@@ -31,7 +31,7 @@ export declare class ShapeModifier {
|
|
|
31
31
|
private saveParsed;
|
|
32
32
|
private performSave;
|
|
33
33
|
flush(): void;
|
|
34
|
-
addConnector(pageId: string, fromShapeId: string, toShapeId: string, beginArrow?: string, endArrow?: string): Promise<string>;
|
|
34
|
+
addConnector(pageId: string, fromShapeId: string, toShapeId: string, beginArrow?: string, endArrow?: string, style?: ConnectorStyle): Promise<string>;
|
|
35
35
|
addShape(pageId: string, props: NewShapeProps, parentId?: string): Promise<string>;
|
|
36
36
|
deleteShape(pageId: string, shapeId: string): Promise<void>;
|
|
37
37
|
private removeShapeFromTree;
|
|
@@ -94,6 +94,19 @@ export declare class ShapeModifier {
|
|
|
94
94
|
* the declared type (Number, Boolean, Date, or String).
|
|
95
95
|
*/
|
|
96
96
|
getShapeProperties(pageId: string, shapeId: string): Record<string, ShapeData>;
|
|
97
|
+
/**
|
|
98
|
+
* Set the page canvas size. Writes PageWidth / PageHeight into the PageSheet
|
|
99
|
+
* and sets DrawingSizeType=0 (Custom) so Visio does not override the values.
|
|
100
|
+
*/
|
|
101
|
+
setPageSize(pageId: string, width: number, height: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* Read the current page canvas dimensions.
|
|
104
|
+
* Returns 8.5 × 11 (US Letter) if no PageSheet cells are present.
|
|
105
|
+
*/
|
|
106
|
+
getPageDimensions(pageId: string): {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
};
|
|
97
110
|
/**
|
|
98
111
|
* Read back all hyperlinks attached to a shape.
|
|
99
112
|
*/
|
package/dist/ShapeModifier.js
CHANGED
|
@@ -184,7 +184,7 @@ class ShapeModifier {
|
|
|
184
184
|
}
|
|
185
185
|
this.dirtyPages.clear();
|
|
186
186
|
}
|
|
187
|
-
async addConnector(pageId, fromShapeId, toShapeId, beginArrow, endArrow) {
|
|
187
|
+
async addConnector(pageId, fromShapeId, toShapeId, beginArrow, endArrow, style) {
|
|
188
188
|
const parsed = this.getParsed(pageId);
|
|
189
189
|
// Ensure Shapes collection exists
|
|
190
190
|
if (!parsed.PageContents.Shapes) {
|
|
@@ -205,7 +205,7 @@ class ShapeModifier {
|
|
|
205
205
|
return val;
|
|
206
206
|
};
|
|
207
207
|
const layout = ConnectorBuilder_1.ConnectorBuilder.calculateConnectorLayout(fromShapeId, toShapeId, shapeHierarchy);
|
|
208
|
-
const connectorShape = ConnectorBuilder_1.ConnectorBuilder.createConnectorShapeObject(newId, layout, validateArrow(beginArrow), validateArrow(endArrow));
|
|
208
|
+
const connectorShape = ConnectorBuilder_1.ConnectorBuilder.createConnectorShapeObject(newId, layout, validateArrow(beginArrow), validateArrow(endArrow), style);
|
|
209
209
|
const topLevelShapes = parsed.PageContents.Shapes.Shape;
|
|
210
210
|
topLevelShapes.push(connectorShape);
|
|
211
211
|
this.getShapeMap(parsed).set(newId, connectorShape);
|
|
@@ -1012,6 +1012,45 @@ class ShapeModifier {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
return result;
|
|
1014
1014
|
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Set the page canvas size. Writes PageWidth / PageHeight into the PageSheet
|
|
1017
|
+
* and sets DrawingSizeType=0 (Custom) so Visio does not override the values.
|
|
1018
|
+
*/
|
|
1019
|
+
setPageSize(pageId, width, height) {
|
|
1020
|
+
if (width <= 0 || height <= 0)
|
|
1021
|
+
throw new Error('Page dimensions must be positive');
|
|
1022
|
+
const parsed = this.getParsed(pageId);
|
|
1023
|
+
this.ensurePageSheet(parsed);
|
|
1024
|
+
const ps = parsed.PageContents.PageSheet;
|
|
1025
|
+
const upsert = (name, value) => {
|
|
1026
|
+
const existing = ps.Cell.find((c) => c['@_N'] === name);
|
|
1027
|
+
if (existing)
|
|
1028
|
+
existing['@_V'] = value;
|
|
1029
|
+
else
|
|
1030
|
+
ps.Cell.push({ '@_N': name, '@_V': value });
|
|
1031
|
+
};
|
|
1032
|
+
upsert('PageWidth', width.toString());
|
|
1033
|
+
upsert('PageHeight', height.toString());
|
|
1034
|
+
upsert('DrawingSizeType', '0');
|
|
1035
|
+
upsert('PageDrawSizeType', '0');
|
|
1036
|
+
this.saveParsed(pageId, parsed);
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* Read the current page canvas dimensions.
|
|
1040
|
+
* Returns 8.5 × 11 (US Letter) if no PageSheet cells are present.
|
|
1041
|
+
*/
|
|
1042
|
+
getPageDimensions(pageId) {
|
|
1043
|
+
const parsed = this.getParsed(pageId);
|
|
1044
|
+
const ps = parsed.PageContents?.PageSheet;
|
|
1045
|
+
if (!ps?.Cell)
|
|
1046
|
+
return { width: 8.5, height: 11 };
|
|
1047
|
+
const cells = Array.isArray(ps.Cell) ? ps.Cell : [ps.Cell];
|
|
1048
|
+
const getVal = (name, def) => {
|
|
1049
|
+
const c = cells.find((cell) => cell['@_N'] === name);
|
|
1050
|
+
return c ? parseFloat(c['@_V']) : def;
|
|
1051
|
+
};
|
|
1052
|
+
return { width: getVal('PageWidth', 8.5), height: getVal('PageHeight', 11) };
|
|
1053
|
+
}
|
|
1015
1054
|
/**
|
|
1016
1055
|
* Read back all hyperlinks attached to a shape.
|
|
1017
1056
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,7 @@ export { VisioDocument } from './VisioDocument';
|
|
|
7
7
|
export { Page } from './Page';
|
|
8
8
|
export { Shape } from './Shape';
|
|
9
9
|
export type { ShapeData, ShapeHyperlink } from './Shape';
|
|
10
|
+
export { Layer } from './Layer';
|
|
11
|
+
export { SchemaDiagram } from './SchemaDiagram';
|
|
12
|
+
export { VisioValidator } from './core/VisioValidator';
|
|
10
13
|
export * from './types/VisioTypes';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Shape = exports.Page = exports.VisioDocument = exports.ShapeModifier = exports.ShapeReader = exports.PageManager = exports.VisioPackage = void 0;
|
|
17
|
+
exports.VisioValidator = exports.SchemaDiagram = exports.Layer = exports.Shape = exports.Page = exports.VisioDocument = exports.ShapeModifier = exports.ShapeReader = exports.PageManager = exports.VisioPackage = void 0;
|
|
18
18
|
var VisioPackage_1 = require("./VisioPackage");
|
|
19
19
|
Object.defineProperty(exports, "VisioPackage", { enumerable: true, get: function () { return VisioPackage_1.VisioPackage; } });
|
|
20
20
|
var PageManager_1 = require("./core/PageManager");
|
|
@@ -29,4 +29,10 @@ var Page_1 = require("./Page");
|
|
|
29
29
|
Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return Page_1.Page; } });
|
|
30
30
|
var Shape_1 = require("./Shape");
|
|
31
31
|
Object.defineProperty(exports, "Shape", { enumerable: true, get: function () { return Shape_1.Shape; } });
|
|
32
|
+
var Layer_1 = require("./Layer");
|
|
33
|
+
Object.defineProperty(exports, "Layer", { enumerable: true, get: function () { return Layer_1.Layer; } });
|
|
34
|
+
var SchemaDiagram_1 = require("./SchemaDiagram");
|
|
35
|
+
Object.defineProperty(exports, "SchemaDiagram", { enumerable: true, get: function () { return SchemaDiagram_1.SchemaDiagram; } });
|
|
36
|
+
var VisioValidator_1 = require("./core/VisioValidator");
|
|
37
|
+
Object.defineProperty(exports, "VisioValidator", { enumerable: true, get: function () { return VisioValidator_1.VisioValidator; } });
|
|
32
38
|
__exportStar(require("./types/VisioTypes"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConnectorStyle } from '../types/VisioTypes';
|
|
1
2
|
export declare class ConnectorBuilder {
|
|
2
3
|
private static getCellVal;
|
|
3
4
|
private static getAbsolutePos;
|
|
@@ -17,7 +18,7 @@ export declare class ConnectorBuilder {
|
|
|
17
18
|
width: number;
|
|
18
19
|
angle: number;
|
|
19
20
|
};
|
|
20
|
-
static createConnectorShapeObject(id: string, layout: any, beginArrow?: string, endArrow?: string): {
|
|
21
|
+
static createConnectorShapeObject(id: string, layout: any, beginArrow?: string, endArrow?: string, style?: ConnectorStyle): {
|
|
21
22
|
'@_ID': string;
|
|
22
23
|
'@_NameU': string;
|
|
23
24
|
'@_Name': string;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectorBuilder = void 0;
|
|
4
4
|
const StyleHelpers_1 = require("../utils/StyleHelpers");
|
|
5
|
+
const ROUTING_VALUES = {
|
|
6
|
+
straight: '2',
|
|
7
|
+
orthogonal: '1',
|
|
8
|
+
curved: '16',
|
|
9
|
+
};
|
|
5
10
|
class ConnectorBuilder {
|
|
6
11
|
static getCellVal(shape, name) {
|
|
7
12
|
if (!shape || !shape.Cell)
|
|
@@ -96,8 +101,12 @@ class ConnectorBuilder {
|
|
|
96
101
|
const angle = Math.atan2(dy, dx);
|
|
97
102
|
return { beginX, beginY, endX, endY, width, angle };
|
|
98
103
|
}
|
|
99
|
-
static createConnectorShapeObject(id, layout, beginArrow, endArrow) {
|
|
104
|
+
static createConnectorShapeObject(id, layout, beginArrow, endArrow, style) {
|
|
100
105
|
const { beginX, beginY, endX, endY, width, angle } = layout;
|
|
106
|
+
const routeStyle = style?.routing ? (ROUTING_VALUES[style.routing] ?? '1') : '1';
|
|
107
|
+
const lineWeightIn = style?.lineWeight != null
|
|
108
|
+
? (style.lineWeight / 72).toString() // convert pt → inches
|
|
109
|
+
: '0.01';
|
|
101
110
|
return {
|
|
102
111
|
'@_ID': id,
|
|
103
112
|
'@_NameU': 'Dynamic connector',
|
|
@@ -118,7 +127,7 @@ class ConnectorBuilder {
|
|
|
118
127
|
{ '@_N': 'ObjType', '@_V': '2' },
|
|
119
128
|
{ '@_N': 'ShapePermeableX', '@_V': '0' },
|
|
120
129
|
{ '@_N': 'ShapePermeableY', '@_V': '0' },
|
|
121
|
-
{ '@_N': 'ShapeRouteStyle', '@_V':
|
|
130
|
+
{ '@_N': 'ShapeRouteStyle', '@_V': routeStyle },
|
|
122
131
|
{ '@_N': 'ConFixedCode', '@_V': '0' },
|
|
123
132
|
{ '@_N': 'BeginArrow', '@_V': beginArrow || '0' },
|
|
124
133
|
{ '@_N': 'BeginArrowSize', '@_V': '2' },
|
|
@@ -127,8 +136,9 @@ class ConnectorBuilder {
|
|
|
127
136
|
],
|
|
128
137
|
Section: [
|
|
129
138
|
(0, StyleHelpers_1.createLineSection)({
|
|
130
|
-
color: '#000000',
|
|
131
|
-
weight:
|
|
139
|
+
color: style?.lineColor ?? '#000000',
|
|
140
|
+
weight: lineWeightIn,
|
|
141
|
+
pattern: style?.linePattern != null ? String(style.linePattern) : undefined,
|
|
132
142
|
}),
|
|
133
143
|
{
|
|
134
144
|
'@_N': 'Geometry',
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ShapeGeometry } from '../types/VisioTypes';
|
|
2
|
+
export declare class GeometryBuilder {
|
|
3
|
+
/**
|
|
4
|
+
* Build a Geometry section object for the given props.
|
|
5
|
+
* Defaults to 'rectangle' when geometry is omitted.
|
|
6
|
+
*/
|
|
7
|
+
static build(props: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
geometry?: ShapeGeometry;
|
|
11
|
+
cornerRadius?: number;
|
|
12
|
+
fillColor?: string;
|
|
13
|
+
}): any;
|
|
14
|
+
/** Standard rectangle: 4 LineTo rows starting at origin. */
|
|
15
|
+
static rectangle(W: number, H: number, noFill: string): any;
|
|
16
|
+
/**
|
|
17
|
+
* Ellipse: a single Ellipse row. No MoveTo required.
|
|
18
|
+
* X, Y = centre; A, B = rightmost point; C, D = topmost point.
|
|
19
|
+
*/
|
|
20
|
+
static ellipse(W: number, H: number, noFill: string): any;
|
|
21
|
+
/**
|
|
22
|
+
* Diamond: 4 LineTo rows, starting at top vertex and going clockwise
|
|
23
|
+
* (top → right → bottom → left → top), matching Visio's built-in Decision shape.
|
|
24
|
+
*/
|
|
25
|
+
static diamond(W: number, H: number, noFill: string): any;
|
|
26
|
+
/**
|
|
27
|
+
* Rounded rectangle with circular corner arcs of radius `r`.
|
|
28
|
+
* Uses EllipticalArcTo with C=0 (no rotation) and D=1 (circle).
|
|
29
|
+
* The A, B control cells are the arc midpoints: r*(1-√2/2) inset from each corner.
|
|
30
|
+
*/
|
|
31
|
+
static roundedRectangle(W: number, H: number, r: number, noFill: string): any;
|
|
32
|
+
/**
|
|
33
|
+
* Right-pointing triangle (standard Visio flowchart orientation).
|
|
34
|
+
* Vertices: bottom-left (0,0), apex-right (W, H/2), top-left (0, H).
|
|
35
|
+
*/
|
|
36
|
+
static triangle(W: number, H: number, noFill: string): any;
|
|
37
|
+
/**
|
|
38
|
+
* Parallelogram with a rightward skew of 20% of the width.
|
|
39
|
+
* Matches the proportions of Visio's built-in "Data" flowchart shape.
|
|
40
|
+
*/
|
|
41
|
+
static parallelogram(W: number, H: number, noFill: string): any;
|
|
42
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeometryBuilder = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* For a 90° circular arc of radius r, the midpoint on the arc sits at 45° from
|
|
6
|
+
* the corner. Its distance from each endpoint along the arc edge is:
|
|
7
|
+
* r * (1 - cos(45°)) = r * (1 - √2/2) ≈ r * 0.29289
|
|
8
|
+
* This offset is used to compute the A, B control-point cells of EllipticalArcTo.
|
|
9
|
+
*/
|
|
10
|
+
const ARC_OFFSET = 1 - Math.SQRT2 / 2; // ≈ 0.29289321881345254
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Internal helpers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
function cell(n, value, formula) {
|
|
15
|
+
const obj = { '@_N': n, '@_V': typeof value === 'number' ? value.toString() : value };
|
|
16
|
+
if (formula)
|
|
17
|
+
obj['@_F'] = formula;
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
function moveTo(ix, x, y, xF, yF) {
|
|
21
|
+
return {
|
|
22
|
+
'@_T': 'MoveTo',
|
|
23
|
+
'@_IX': String(ix),
|
|
24
|
+
Cell: [cell('X', x, xF), cell('Y', y, yF)],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function lineTo(ix, x, y, xF, yF) {
|
|
28
|
+
return {
|
|
29
|
+
'@_T': 'LineTo',
|
|
30
|
+
'@_IX': String(ix),
|
|
31
|
+
Cell: [cell('X', x, xF), cell('Y', y, yF)],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function arcTo(ix, endX, endY, midX, midY) {
|
|
35
|
+
return {
|
|
36
|
+
'@_T': 'EllipticalArcTo',
|
|
37
|
+
'@_IX': String(ix),
|
|
38
|
+
Cell: [
|
|
39
|
+
cell('X', endX), // arc endpoint X
|
|
40
|
+
cell('Y', endY), // arc endpoint Y
|
|
41
|
+
cell('A', midX), // midpoint-on-arc X
|
|
42
|
+
cell('B', midY), // midpoint-on-arc Y
|
|
43
|
+
cell('C', '0'), // major-axis angle (0 = no rotation)
|
|
44
|
+
cell('D', '1'), // eccentricity ratio (1 = circle)
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function section(rows, noFill) {
|
|
49
|
+
return {
|
|
50
|
+
'@_N': 'Geometry',
|
|
51
|
+
'@_IX': '0',
|
|
52
|
+
Cell: [{ '@_N': 'NoFill', '@_V': noFill }],
|
|
53
|
+
Row: rows,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// Public builder
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
class GeometryBuilder {
|
|
60
|
+
/**
|
|
61
|
+
* Build a Geometry section object for the given props.
|
|
62
|
+
* Defaults to 'rectangle' when geometry is omitted.
|
|
63
|
+
*/
|
|
64
|
+
static build(props) {
|
|
65
|
+
const { width: W, height: H, geometry, cornerRadius, fillColor } = props;
|
|
66
|
+
const noFill = fillColor ? '0' : '1';
|
|
67
|
+
switch (geometry) {
|
|
68
|
+
case 'ellipse':
|
|
69
|
+
return GeometryBuilder.ellipse(W, H, noFill);
|
|
70
|
+
case 'diamond':
|
|
71
|
+
return GeometryBuilder.diamond(W, H, noFill);
|
|
72
|
+
case 'rounded-rectangle': {
|
|
73
|
+
const r = cornerRadius ?? Math.min(W, H) * 0.1;
|
|
74
|
+
return GeometryBuilder.roundedRectangle(W, H, r, noFill);
|
|
75
|
+
}
|
|
76
|
+
case 'triangle':
|
|
77
|
+
return GeometryBuilder.triangle(W, H, noFill);
|
|
78
|
+
case 'parallelogram':
|
|
79
|
+
return GeometryBuilder.parallelogram(W, H, noFill);
|
|
80
|
+
case 'rectangle':
|
|
81
|
+
default:
|
|
82
|
+
return GeometryBuilder.rectangle(W, H, noFill);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// -----------------------------------------------------------------------
|
|
86
|
+
// Individual geometry factories (also exported for direct use / testing)
|
|
87
|
+
// -----------------------------------------------------------------------
|
|
88
|
+
/** Standard rectangle: 4 LineTo rows starting at origin. */
|
|
89
|
+
static rectangle(W, H, noFill) {
|
|
90
|
+
return section([
|
|
91
|
+
moveTo(1, 0, 0),
|
|
92
|
+
lineTo(2, W, 0, 'Width'),
|
|
93
|
+
lineTo(3, W, H, 'Width', 'Height'),
|
|
94
|
+
lineTo(4, 0, H, undefined, 'Height'),
|
|
95
|
+
lineTo(5, 0, 0),
|
|
96
|
+
], noFill);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Ellipse: a single Ellipse row. No MoveTo required.
|
|
100
|
+
* X, Y = centre; A, B = rightmost point; C, D = topmost point.
|
|
101
|
+
*/
|
|
102
|
+
static ellipse(W, H, noFill) {
|
|
103
|
+
return section([
|
|
104
|
+
{
|
|
105
|
+
'@_T': 'Ellipse',
|
|
106
|
+
'@_IX': '1',
|
|
107
|
+
Cell: [
|
|
108
|
+
cell('X', W / 2, 'Width*0.5'), // centre X
|
|
109
|
+
cell('Y', H / 2, 'Height*0.5'), // centre Y
|
|
110
|
+
cell('A', W, 'Width'), // right X
|
|
111
|
+
cell('B', H / 2, 'Height*0.5'), // right Y
|
|
112
|
+
cell('C', W / 2, 'Width*0.5'), // top X
|
|
113
|
+
cell('D', H, 'Height'), // top Y
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
], noFill);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Diamond: 4 LineTo rows, starting at top vertex and going clockwise
|
|
120
|
+
* (top → right → bottom → left → top), matching Visio's built-in Decision shape.
|
|
121
|
+
*/
|
|
122
|
+
static diamond(W, H, noFill) {
|
|
123
|
+
return section([
|
|
124
|
+
moveTo(1, W / 2, H, 'Width*0.5', 'Height'), // top
|
|
125
|
+
lineTo(2, W, H / 2, 'Width', 'Height*0.5'), // right
|
|
126
|
+
lineTo(3, W / 2, 0, 'Width*0.5'), // bottom
|
|
127
|
+
lineTo(4, 0, H / 2, undefined, 'Height*0.5'), // left
|
|
128
|
+
lineTo(5, W / 2, H, 'Width*0.5', 'Height'), // close
|
|
129
|
+
], noFill);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Rounded rectangle with circular corner arcs of radius `r`.
|
|
133
|
+
* Uses EllipticalArcTo with C=0 (no rotation) and D=1 (circle).
|
|
134
|
+
* The A, B control cells are the arc midpoints: r*(1-√2/2) inset from each corner.
|
|
135
|
+
*/
|
|
136
|
+
static roundedRectangle(W, H, r, noFill) {
|
|
137
|
+
const k = r * ARC_OFFSET; // midpoint inset ≈ r * 0.2929
|
|
138
|
+
return section([
|
|
139
|
+
moveTo(1, r, 0),
|
|
140
|
+
lineTo(2, W - r, 0),
|
|
141
|
+
arcTo(3, W, r, W - k, k), // bottom-right corner
|
|
142
|
+
lineTo(4, W, H - r),
|
|
143
|
+
arcTo(5, W - r, H, W - k, H - k), // top-right corner
|
|
144
|
+
lineTo(6, r, H),
|
|
145
|
+
arcTo(7, 0, H - r, k, H - k), // top-left corner
|
|
146
|
+
lineTo(8, 0, r),
|
|
147
|
+
arcTo(9, r, 0, k, k), // bottom-left corner (closes path)
|
|
148
|
+
], noFill);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Right-pointing triangle (standard Visio flowchart orientation).
|
|
152
|
+
* Vertices: bottom-left (0,0), apex-right (W, H/2), top-left (0, H).
|
|
153
|
+
*/
|
|
154
|
+
static triangle(W, H, noFill) {
|
|
155
|
+
return section([
|
|
156
|
+
moveTo(1, 0, 0),
|
|
157
|
+
lineTo(2, W, H / 2, 'Width', 'Height*0.5'),
|
|
158
|
+
lineTo(3, 0, H, undefined, 'Height'),
|
|
159
|
+
lineTo(4, 0, 0),
|
|
160
|
+
], noFill);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Parallelogram with a rightward skew of 20% of the width.
|
|
164
|
+
* Matches the proportions of Visio's built-in "Data" flowchart shape.
|
|
165
|
+
*/
|
|
166
|
+
static parallelogram(W, H, noFill) {
|
|
167
|
+
const s = W * 0.2; // horizontal skew offset
|
|
168
|
+
return section([
|
|
169
|
+
moveTo(1, s, 0),
|
|
170
|
+
lineTo(2, W, 0, 'Width'),
|
|
171
|
+
lineTo(3, W - s, H),
|
|
172
|
+
lineTo(4, 0, H, undefined, 'Height'),
|
|
173
|
+
lineTo(5, s, 0),
|
|
174
|
+
], noFill);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.GeometryBuilder = GeometryBuilder;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShapeBuilder = void 0;
|
|
4
4
|
const StyleHelpers_1 = require("../utils/StyleHelpers");
|
|
5
|
+
const GeometryBuilder_1 = require("./GeometryBuilder");
|
|
5
6
|
class ShapeBuilder {
|
|
6
7
|
static createStandardShape(id, props) {
|
|
7
8
|
// Validate dimensions
|
|
@@ -53,18 +54,7 @@ class ShapeBuilder {
|
|
|
53
54
|
// Add Geometry
|
|
54
55
|
// Only if NOT a Group AND NOT a Master Instance
|
|
55
56
|
if (props.type !== 'Group' && !props.masterId) {
|
|
56
|
-
shape.Section.push(
|
|
57
|
-
'@_N': 'Geometry',
|
|
58
|
-
'@_IX': '0',
|
|
59
|
-
Cell: [{ '@_N': 'NoFill', '@_V': props.fillColor ? '0' : '1' }],
|
|
60
|
-
Row: [
|
|
61
|
-
{ '@_T': 'MoveTo', '@_IX': '1', Cell: [{ '@_N': 'X', '@_V': '0' }, { '@_N': 'Y', '@_V': '0' }] },
|
|
62
|
-
{ '@_T': 'LineTo', '@_IX': '2', Cell: [{ '@_N': 'X', '@_V': props.width.toString(), '@_F': 'Width' }, { '@_N': 'Y', '@_V': '0' }] },
|
|
63
|
-
{ '@_T': 'LineTo', '@_IX': '3', Cell: [{ '@_N': 'X', '@_V': props.width.toString(), '@_F': 'Width' }, { '@_N': 'Y', '@_V': props.height.toString(), '@_F': 'Height' }] },
|
|
64
|
-
{ '@_T': 'LineTo', '@_IX': '4', Cell: [{ '@_N': 'X', '@_V': '0' }, { '@_N': 'Y', '@_V': props.height.toString(), '@_F': 'Height' }] },
|
|
65
|
-
{ '@_T': 'LineTo', '@_IX': '5', Cell: [{ '@_N': 'X', '@_V': '0' }, { '@_N': 'Y', '@_V': '0' }] }
|
|
66
|
-
]
|
|
67
|
-
});
|
|
57
|
+
shape.Section.push(GeometryBuilder_1.GeometryBuilder.build(props));
|
|
68
58
|
}
|
|
69
59
|
// Handle Text if provided
|
|
70
60
|
if (props.text !== undefined && props.text !== null) {
|
|
@@ -72,6 +72,59 @@ export declare enum VisioPropType {
|
|
|
72
72
|
Duration = 6,
|
|
73
73
|
Currency = 7
|
|
74
74
|
}
|
|
75
|
+
export type PageOrientation = 'portrait' | 'landscape';
|
|
76
|
+
/** Common paper sizes in inches (width × height in portrait orientation). */
|
|
77
|
+
export declare const PageSizes: {
|
|
78
|
+
readonly Letter: {
|
|
79
|
+
readonly width: 8.5;
|
|
80
|
+
readonly height: 11;
|
|
81
|
+
};
|
|
82
|
+
readonly Legal: {
|
|
83
|
+
readonly width: 8.5;
|
|
84
|
+
readonly height: 14;
|
|
85
|
+
};
|
|
86
|
+
readonly Tabloid: {
|
|
87
|
+
readonly width: 11;
|
|
88
|
+
readonly height: 17;
|
|
89
|
+
};
|
|
90
|
+
readonly A3: {
|
|
91
|
+
readonly width: 11.693;
|
|
92
|
+
readonly height: 16.535;
|
|
93
|
+
};
|
|
94
|
+
readonly A4: {
|
|
95
|
+
readonly width: 8.268;
|
|
96
|
+
readonly height: 11.693;
|
|
97
|
+
};
|
|
98
|
+
readonly A5: {
|
|
99
|
+
readonly width: 5.827;
|
|
100
|
+
readonly height: 8.268;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export type PageSizeName = keyof typeof PageSizes;
|
|
104
|
+
/** Connector line-routing algorithm. */
|
|
105
|
+
export type ConnectorRouting = 'straight' | 'orthogonal' | 'curved';
|
|
106
|
+
/**
|
|
107
|
+
* Style options for a connector (dynamic connector shape).
|
|
108
|
+
* All fields are optional; omitted fields retain their defaults.
|
|
109
|
+
*/
|
|
110
|
+
export interface ConnectorStyle {
|
|
111
|
+
/** Line stroke color as a CSS hex string (e.g. `'#ff0000'`). */
|
|
112
|
+
lineColor?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Stroke weight in **points** (e.g. `1` for a 1 pt line).
|
|
115
|
+
* Converted to inches internally (pt / 72).
|
|
116
|
+
*/
|
|
117
|
+
lineWeight?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Line pattern. 0 = no line, 1 = solid (default), 2 = dashed,
|
|
120
|
+
* 3 = dotted, 4 = dash-dot, etc. Matches Visio's LinePattern cell.
|
|
121
|
+
*/
|
|
122
|
+
linePattern?: number;
|
|
123
|
+
/** How Visio routes the connector between its endpoints. */
|
|
124
|
+
routing?: ConnectorRouting;
|
|
125
|
+
}
|
|
126
|
+
/** Non-rectangular geometry variants supported by ShapeBuilder. */
|
|
127
|
+
export type ShapeGeometry = 'rectangle' | 'ellipse' | 'diamond' | 'rounded-rectangle' | 'triangle' | 'parallelogram';
|
|
75
128
|
export interface NewShapeProps {
|
|
76
129
|
text: string;
|
|
77
130
|
x: number;
|
|
@@ -90,6 +143,10 @@ export interface NewShapeProps {
|
|
|
90
143
|
horzAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
91
144
|
/** Vertical text alignment within the shape. */
|
|
92
145
|
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
146
|
+
/** Shape geometry. Defaults to 'rectangle'. */
|
|
147
|
+
geometry?: ShapeGeometry;
|
|
148
|
+
/** Corner radius in inches for 'rounded-rectangle'. Defaults to 10% of the smaller dimension. */
|
|
149
|
+
cornerRadius?: number;
|
|
93
150
|
type?: string;
|
|
94
151
|
masterId?: string;
|
|
95
152
|
imgRelId?: string;
|
package/dist/types/VisioTypes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VisioPropType = void 0;
|
|
3
|
+
exports.PageSizes = exports.VisioPropType = void 0;
|
|
4
4
|
var VisioPropType;
|
|
5
5
|
(function (VisioPropType) {
|
|
6
6
|
VisioPropType[VisioPropType["String"] = 0] = "String";
|
|
@@ -12,3 +12,12 @@ var VisioPropType;
|
|
|
12
12
|
VisioPropType[VisioPropType["Duration"] = 6] = "Duration";
|
|
13
13
|
VisioPropType[VisioPropType["Currency"] = 7] = "Currency";
|
|
14
14
|
})(VisioPropType || (exports.VisioPropType = VisioPropType = {}));
|
|
15
|
+
/** Common paper sizes in inches (width × height in portrait orientation). */
|
|
16
|
+
exports.PageSizes = {
|
|
17
|
+
Letter: { width: 8.5, height: 11 },
|
|
18
|
+
Legal: { width: 8.5, height: 14 },
|
|
19
|
+
Tabloid: { width: 11, height: 17 },
|
|
20
|
+
A3: { width: 11.693, height: 16.535 },
|
|
21
|
+
A4: { width: 8.268, height: 11.693 },
|
|
22
|
+
A5: { width: 5.827, height: 8.268 },
|
|
23
|
+
};
|