#1487 Create union type for IFrameOptions
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@ -3571,7 +3571,7 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
|
@ -24,15 +24,11 @@ export enum FrameWrap {
|
|||||||
TIGHT = "tight",
|
TIGHT = "tight",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFrameOptions {
|
interface IBaseFrameOptions {
|
||||||
readonly anchorLock?: boolean;
|
readonly anchorLock?: boolean;
|
||||||
readonly dropCap?: DropCapType;
|
readonly dropCap?: DropCapType;
|
||||||
readonly width: number;
|
readonly width: number;
|
||||||
readonly height: number;
|
readonly height: number;
|
||||||
readonly position: {
|
|
||||||
readonly x: number;
|
|
||||||
readonly y: number;
|
|
||||||
};
|
|
||||||
readonly wrap?: FrameWrap;
|
readonly wrap?: FrameWrap;
|
||||||
readonly lines?: number;
|
readonly lines?: number;
|
||||||
readonly anchor: {
|
readonly anchor: {
|
||||||
@ -44,19 +40,33 @@ export interface IFrameOptions {
|
|||||||
readonly vertical: number;
|
readonly vertical: number;
|
||||||
};
|
};
|
||||||
readonly rule?: HeightRule;
|
readonly rule?: HeightRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IXYFrameOptions extends IBaseFrameOptions {
|
||||||
|
readonly position: {
|
||||||
|
readonly x: number;
|
||||||
|
readonly y: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IAlignmentFrameOptions extends IBaseFrameOptions {
|
||||||
readonly alignment: {
|
readonly alignment: {
|
||||||
readonly x: HorizontalPositionAlign;
|
readonly x: HorizontalPositionAlign;
|
||||||
readonly y: VerticalPositionAlign;
|
readonly y: VerticalPositionAlign;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Be wary of Typescript's Open types:
|
||||||
|
// https://stackoverflow.com/q/46370222/3481582
|
||||||
|
export type IFrameOptions = IXYFrameOptions | IAlignmentFrameOptions;
|
||||||
|
|
||||||
export class FramePropertiesAttributes extends XmlAttributeComponent<{
|
export class FramePropertiesAttributes extends XmlAttributeComponent<{
|
||||||
readonly anchorLock?: boolean;
|
readonly anchorLock?: boolean;
|
||||||
readonly dropCap?: DropCapType;
|
readonly dropCap?: DropCapType;
|
||||||
readonly width: number;
|
readonly width: number;
|
||||||
readonly height: number;
|
readonly height: number;
|
||||||
readonly x: number;
|
readonly x?: number;
|
||||||
readonly y: number;
|
readonly y?: number;
|
||||||
readonly wrap?: FrameWrap;
|
readonly wrap?: FrameWrap;
|
||||||
readonly lines?: number;
|
readonly lines?: number;
|
||||||
readonly anchorHorizontal?: FrameAnchorType;
|
readonly anchorHorizontal?: FrameAnchorType;
|
||||||
@ -95,15 +105,15 @@ export class FrameProperties extends XmlComponent {
|
|||||||
dropCap: options.dropCap,
|
dropCap: options.dropCap,
|
||||||
width: options.width,
|
width: options.width,
|
||||||
height: options.height,
|
height: options.height,
|
||||||
x: options.position.x,
|
x: (options as IXYFrameOptions).position ? (options as IXYFrameOptions).position.x : undefined,
|
||||||
y: options.position.y,
|
y: (options as IXYFrameOptions).position ? (options as IXYFrameOptions).position.y : undefined,
|
||||||
anchorHorizontal: options.anchor.horizontal,
|
anchorHorizontal: options.anchor.horizontal,
|
||||||
anchorVertical: options.anchor.vertical,
|
anchorVertical: options.anchor.vertical,
|
||||||
spaceHorizontal: options.space?.horizontal,
|
spaceHorizontal: options.space?.horizontal,
|
||||||
spaceVertical: options.space?.vertical,
|
spaceVertical: options.space?.vertical,
|
||||||
rule: options.rule,
|
rule: options.rule,
|
||||||
alignmentX: options.alignment.x,
|
alignmentX: (options as IAlignmentFrameOptions).alignment.x ? (options as IAlignmentFrameOptions).alignment.x : undefined,
|
||||||
alignmentY: options.alignment.y,
|
alignmentY: (options as IAlignmentFrameOptions).alignment.x ? (options as IAlignmentFrameOptions).alignment.y : undefined,
|
||||||
lines: options.lines,
|
lines: options.lines,
|
||||||
wrap: options.wrap,
|
wrap: options.wrap,
|
||||||
}),
|
}),
|
||||||
|
Reference in New Issue
Block a user