Files
docx-js/src/file/drawing/text-wrap/wrap-square.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

// http://officeopenxml.com/drwPicFloating-textWrap.php
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
2022-08-31 08:59:27 +01:00
2018-06-09 23:49:01 +01:00
import { IDistance } from "../drawing";
2019-01-10 02:10:20 +00:00
import { IMargins } from "../floating";
2022-08-31 08:59:27 +01:00
import { ITextWrapping, TextWrappingSide } from "./text-wrapping";
2018-06-09 23:49:01 +01:00
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 {
2022-08-31 07:52:27 +01:00
public constructor(
2019-01-10 02:10:20 +00:00
textWrapping: ITextWrapping,
margins: IMargins = {
top: 0,
bottom: 0,
left: 0,
right: 0,
},
) {
super("wp:wrapSquare");
this.root.push(
new WrapSquareAttributes({
2019-01-10 02:10:20 +00:00
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,
distT: margins.top,
distB: margins.bottom,
distL: margins.left,
distR: margins.right,
}),
);
}
}