2018-06-08 16:03:04 +02:00
|
|
|
// http://officeopenxml.com/drwPicFloating-position.php
|
2025-04-14 16:43:15 +05:30
|
|
|
import { BuilderElement, XmlComponent } from "@file/xml-components";
|
2024-10-21 03:57:15 +01:00
|
|
|
|
2025-04-14 16:43:15 +05:30
|
|
|
import { createAlign } from "./align";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floating-position";
|
2025-04-14 16:43:15 +05:30
|
|
|
import { createPositionOffset } from "./position-offset";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2025-04-14 16:43:15 +05:30
|
|
|
/**
|
|
|
|
* Vertical Positioning
|
|
|
|
*
|
|
|
|
* This simple type specifies the possible values for the base from which the relative vertical positioning of an object shall be calculated.
|
|
|
|
*
|
|
|
|
* Reference: https://www.datypic.com/sc/ooxml/e-wp_positionV-1.html
|
|
|
|
*/
|
|
|
|
export const createVerticalPosition = ({ relative, align, offset }: IVerticalPositionOptions): XmlComponent =>
|
|
|
|
new BuilderElement<{
|
|
|
|
/** Vertical Position Relative Base */
|
|
|
|
readonly relativeFrom: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom];
|
|
|
|
}>({
|
|
|
|
name: "wp:positionV",
|
|
|
|
attributes: {
|
|
|
|
relativeFrom: { key: "relativeFrom", value: relative ?? VerticalPositionRelativeFrom.PAGE },
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
(() => {
|
|
|
|
if (align) {
|
|
|
|
return createAlign(align);
|
|
|
|
} else if (offset !== undefined) {
|
|
|
|
return createPositionOffset(offset);
|
|
|
|
} else {
|
|
|
|
throw new Error("There is no configuration provided for floating position (Align or offset)");
|
|
|
|
}
|
|
|
|
})(),
|
|
|
|
],
|
|
|
|
});
|