/
wrap-square.ts
44 lines (39 loc) · 1.24 KB
/
wrap-square.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// http://officeopenxml.com/drwPicFloating-textWrap.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { IDistance } from "../drawing";
import { IMargins } from "../floating";
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
interface IWrapSquareAttributes extends IDistance {
readonly wrapText?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide];
}
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
protected readonly xmlKeys = {
distT: "distT",
distB: "distB",
distL: "distL",
distR: "distR",
wrapText: "wrapText",
};
}
export class WrapSquare extends XmlComponent {
public constructor(
textWrapping: ITextWrapping,
margins: IMargins = {
top: 0,
bottom: 0,
left: 0,
right: 0,
},
) {
super("wp:wrapSquare");
this.root.push(
new WrapSquareAttributes({
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,
distT: margins.top,
distB: margins.bottom,
distL: margins.left,
distR: margins.right,
}),
);
}
}