ts-visio 1.0.2 → 1.2.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 -3
- package/dist/Layer.d.ts +3 -1
- package/dist/Layer.js +6 -7
- package/dist/Page.d.ts +12 -0
- package/dist/Page.js +35 -12
- package/dist/Shape.d.ts +47 -2
- package/dist/Shape.js +119 -78
- package/dist/ShapeModifier.d.ts +53 -0
- package/dist/ShapeModifier.js +451 -267
- package/dist/ShapeReader.d.ts +12 -0
- package/dist/ShapeReader.js +59 -3
- package/dist/VisioDocument.d.ts +10 -0
- package/dist/VisioDocument.js +20 -1
- package/dist/VisioPackage.d.ts +1 -0
- package/dist/VisioPackage.js +7 -0
- package/dist/core/MasterManager.js +1 -1
- package/dist/core/MediaConstants.js +11 -2
- package/dist/core/MediaManager.js +8 -16
- package/dist/core/PageManager.d.ts +8 -1
- package/dist/core/PageManager.js +75 -16
- package/dist/core/RelsManager.js +4 -11
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/shapes/ConnectorBuilder.js +8 -9
- package/dist/shapes/ContainerBuilder.js +8 -6
- package/dist/shapes/ForeignShapeBuilder.js +9 -6
- package/dist/shapes/ShapeBuilder.js +15 -7
- package/dist/types/VisioTypes.d.ts +12 -0
- package/dist/utils/StyleHelpers.d.ts +21 -4
- package/dist/utils/StyleHelpers.js +52 -27
- package/dist/utils/XmlHelper.d.ts +39 -0
- package/dist/utils/XmlHelper.js +56 -0
- package/package.json +2 -2
package/dist/ShapeModifier.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { VisioPackage } from './VisioPackage';
|
|
2
|
+
import { HorzAlign, VertAlign } from './utils/StyleHelpers';
|
|
2
3
|
import { NewShapeProps } from './types/VisioTypes';
|
|
4
|
+
import type { ShapeData, ShapeHyperlink } from './Shape';
|
|
3
5
|
export declare class ShapeModifier {
|
|
4
6
|
private pkg;
|
|
5
7
|
addContainer(pageId: string, props: NewShapeProps): Promise<string>;
|
|
@@ -9,9 +11,18 @@ export declare class ShapeModifier {
|
|
|
9
11
|
private relsManager;
|
|
10
12
|
private pageCache;
|
|
11
13
|
private dirtyPages;
|
|
14
|
+
private shapeCache;
|
|
15
|
+
private pagePathRegistry;
|
|
12
16
|
autoSave: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Register the resolved OPC part path for a page ID.
|
|
19
|
+
* Must be called before any operation on a loaded file to ensure the
|
|
20
|
+
* correct file is targeted rather than the ID-derived fallback name.
|
|
21
|
+
*/
|
|
22
|
+
registerPage(pageId: string, xmlPath: string): void;
|
|
13
23
|
constructor(pkg: VisioPackage);
|
|
14
24
|
private getPagePath;
|
|
25
|
+
private getShapeMap;
|
|
15
26
|
private getAllShapes;
|
|
16
27
|
private getNextId;
|
|
17
28
|
private ensurePageSheet;
|
|
@@ -22,9 +33,28 @@ export declare class ShapeModifier {
|
|
|
22
33
|
flush(): void;
|
|
23
34
|
addConnector(pageId: string, fromShapeId: string, toShapeId: string, beginArrow?: string, endArrow?: string): Promise<string>;
|
|
24
35
|
addShape(pageId: string, props: NewShapeProps, parentId?: string): Promise<string>;
|
|
36
|
+
deleteShape(pageId: string, shapeId: string): Promise<void>;
|
|
37
|
+
private removeShapeFromTree;
|
|
25
38
|
updateShapeText(pageId: string, shapeId: string, newText: string): Promise<void>;
|
|
26
39
|
updateShapeStyle(pageId: string, shapeId: string, style: ShapeStyle): Promise<void>;
|
|
27
40
|
updateShapeDimensions(pageId: string, shapeId: string, w: number, h: number): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Set the rotation angle of a shape. Degrees are converted to radians
|
|
43
|
+
* for storage in the Angle cell (Visio's native unit).
|
|
44
|
+
*/
|
|
45
|
+
rotateShape(pageId: string, shapeId: string, degrees: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Set the flip state for a shape along the X or Y axis.
|
|
48
|
+
* FlipX mirrors left-to-right; FlipY mirrors top-to-bottom.
|
|
49
|
+
*/
|
|
50
|
+
setShapeFlip(pageId: string, shapeId: string, axis: 'x' | 'y', enabled: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Resize a shape, keeping it centred on its current PinX/PinY.
|
|
53
|
+
* Updates Width, Height, LocPinX, LocPinY, and the cached @_V on any
|
|
54
|
+
* Geometry cells whose @_F formula references Width or Height, so that
|
|
55
|
+
* non-Visio renderers see consistent values.
|
|
56
|
+
*/
|
|
57
|
+
resizeShape(pageId: string, shapeId: string, width: number, height: number): Promise<void>;
|
|
28
58
|
updateShapePosition(pageId: string, shapeId: string, x: number, y: number): Promise<void>;
|
|
29
59
|
addPropertyDefinition(pageId: string, shapeId: string, name: string, type: number, options?: {
|
|
30
60
|
label?: string;
|
|
@@ -58,9 +88,32 @@ export declare class ShapeModifier {
|
|
|
58
88
|
}>;
|
|
59
89
|
assignLayer(pageId: string, shapeId: string, layerIndex: number): Promise<void>;
|
|
60
90
|
updateLayerProperty(pageId: string, layerIndex: number, propName: string, value: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Read back all custom property (shape data) entries for a shape.
|
|
93
|
+
* Returns a map of property key → ShapeData, with values coerced to
|
|
94
|
+
* the declared type (Number, Boolean, Date, or String).
|
|
95
|
+
*/
|
|
96
|
+
getShapeProperties(pageId: string, shapeId: string): Record<string, ShapeData>;
|
|
97
|
+
/**
|
|
98
|
+
* Read back all hyperlinks attached to a shape.
|
|
99
|
+
*/
|
|
100
|
+
getShapeHyperlinks(pageId: string, shapeId: string): ShapeHyperlink[];
|
|
101
|
+
/**
|
|
102
|
+
* Read back the layer indices a shape is assigned to.
|
|
103
|
+
* Returns an empty array if the shape has no layer assignment.
|
|
104
|
+
*/
|
|
105
|
+
getShapeLayerIndices(pageId: string, shapeId: string): number[];
|
|
61
106
|
}
|
|
62
107
|
export interface ShapeStyle {
|
|
63
108
|
fillColor?: string;
|
|
64
109
|
fontColor?: string;
|
|
65
110
|
bold?: boolean;
|
|
111
|
+
/** Font size in points (e.g. 14 for 14pt). */
|
|
112
|
+
fontSize?: number;
|
|
113
|
+
/** Font family name (e.g. "Arial"). */
|
|
114
|
+
fontFamily?: string;
|
|
115
|
+
/** Horizontal text alignment. */
|
|
116
|
+
horzAlign?: HorzAlign;
|
|
117
|
+
/** Vertical text alignment. */
|
|
118
|
+
verticalAlign?: VertAlign;
|
|
66
119
|
}
|