* build(deps-dev): bump eslint from 8.57.1 to 9.13.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.57.1 to 9.13.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.57.1...v9.13.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Upgrade EsLint * Fix all new lint errors --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
108 lines
3.7 KiB
TypeScript
108 lines
3.7 KiB
TypeScript
// http://officeopenxml.com/WPsectionBorders.php
|
|
import { BorderElement, IBorderOptions } from "@file/border";
|
|
import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent } from "@file/xml-components";
|
|
|
|
// <xsd:simpleType name="ST_PageBorderDisplay">
|
|
// <xsd:restriction base="xsd:string">
|
|
// <xsd:enumeration value="allPages"/>
|
|
// <xsd:enumeration value="firstPage"/>
|
|
// <xsd:enumeration value="notFirstPage"/>
|
|
// </xsd:restriction>
|
|
// </xsd:simpleType>
|
|
|
|
export const PageBorderDisplay = {
|
|
ALL_PAGES: "allPages",
|
|
FIRST_PAGE: "firstPage",
|
|
NOT_FIRST_PAGE: "notFirstPage",
|
|
} as const;
|
|
|
|
// <xsd:simpleType name="ST_PageBorderOffset">
|
|
// <xsd:restriction base="xsd:string">
|
|
// <xsd:enumeration value="page"/>
|
|
// <xsd:enumeration value="text"/>
|
|
// </xsd:restriction>
|
|
// </xsd:simpleType>
|
|
export const PageBorderOffsetFrom = {
|
|
PAGE: "page",
|
|
TEXT: "text",
|
|
} as const;
|
|
|
|
// <xsd:simpleType name="ST_PageBorderZOrder">
|
|
// <xsd:restriction base="xsd:string">
|
|
// <xsd:enumeration value="front"/>
|
|
// <xsd:enumeration value="back"/>
|
|
// </xsd:restriction>
|
|
// </xsd:simpleType>
|
|
export const PageBorderZOrder = {
|
|
BACK: "back",
|
|
FRONT: "front",
|
|
} as const;
|
|
|
|
export type IPageBorderAttributes = {
|
|
readonly display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay];
|
|
readonly offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom];
|
|
readonly zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder];
|
|
};
|
|
|
|
export type IPageBordersOptions = {
|
|
readonly pageBorders?: IPageBorderAttributes;
|
|
readonly pageBorderTop?: IBorderOptions;
|
|
readonly pageBorderRight?: IBorderOptions;
|
|
readonly pageBorderBottom?: IBorderOptions;
|
|
readonly pageBorderLeft?: IBorderOptions;
|
|
};
|
|
|
|
class PageBordersAttributes extends XmlAttributeComponent<IPageBorderAttributes> {
|
|
protected readonly xmlKeys = {
|
|
display: "w:display",
|
|
offsetFrom: "w:offsetFrom",
|
|
zOrder: "w:zOrder",
|
|
};
|
|
}
|
|
|
|
// <xsd:complexType name="CT_PageBorders">
|
|
// <xsd:sequence>
|
|
// <xsd:element name="top" type="CT_TopPageBorder" minOccurs="0"/>
|
|
// <xsd:element name="left" type="CT_PageBorder" minOccurs="0"/>
|
|
// <xsd:element name="bottom" type="CT_BottomPageBorder" minOccurs="0"/>
|
|
// <xsd:element name="right" type="CT_PageBorder" minOccurs="0"/>
|
|
// </xsd:sequence>
|
|
// <xsd:attribute name="zOrder" type="ST_PageBorderZOrder" use="optional" default="front"/>
|
|
// <xsd:attribute name="display" type="ST_PageBorderDisplay" use="optional"/>
|
|
// <xsd:attribute name="offsetFrom" type="ST_PageBorderOffset" use="optional" default="text"/>
|
|
// </xsd:complexType>
|
|
export class PageBorders extends IgnoreIfEmptyXmlComponent {
|
|
public constructor(options?: IPageBordersOptions) {
|
|
super("w:pgBorders");
|
|
|
|
if (!options) {
|
|
return this;
|
|
}
|
|
|
|
if (options.pageBorders) {
|
|
this.root.push(
|
|
new PageBordersAttributes({
|
|
display: options.pageBorders.display,
|
|
offsetFrom: options.pageBorders.offsetFrom,
|
|
zOrder: options.pageBorders.zOrder,
|
|
}),
|
|
);
|
|
} else {
|
|
this.root.push(new PageBordersAttributes({}));
|
|
}
|
|
|
|
if (options.pageBorderTop) {
|
|
this.root.push(new BorderElement("w:top", options.pageBorderTop));
|
|
}
|
|
if (options.pageBorderLeft) {
|
|
this.root.push(new BorderElement("w:left", options.pageBorderLeft));
|
|
}
|
|
if (options.pageBorderBottom) {
|
|
this.root.push(new BorderElement("w:bottom", options.pageBorderBottom));
|
|
}
|
|
if (options.pageBorderRight) {
|
|
this.root.push(new BorderElement("w:right", options.pageBorderRight));
|
|
}
|
|
}
|
|
}
|