diff --git a/src/file/table/table-properties/table-float-properties.spec.ts b/src/file/table/table-properties/table-float-properties.spec.ts index ccc8cb77ef..c64e1be446 100644 --- a/src/file/table/table-properties/table-float-properties.spec.ts +++ b/src/file/table/table-properties/table-float-properties.spec.ts @@ -38,9 +38,7 @@ describe("Table Float Properties", () => { expect(tree).to.deep.equal({ "w:tblpPr": [ { - _attr: { - overlap: "never", - }, + _attr: {}, }, { "w:tblOverlap": { diff --git a/src/file/table/table-properties/table-float-properties.ts b/src/file/table/table-properties/table-float-properties.ts index e7f32dc572..38595e3e98 100644 --- a/src/file/table/table-properties/table-float-properties.ts +++ b/src/file/table/table-properties/table-float-properties.ts @@ -1,4 +1,4 @@ -import { StringEnumValueElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components"; +import { NextAttributeComponent, StringEnumValueElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components"; import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values"; export enum TableAnchorType { @@ -35,7 +35,7 @@ export enum OverlapType { OVERLAP = "overlap", } -export interface ITableFloatOptions { +export type ITableFloatOptions = { /* cSpell:disable */ /** * Specifies the horizontal anchor or the base object from which the horizontal positioning in the @@ -124,7 +124,7 @@ export interface ITableFloatOptions { */ readonly rightFromText?: number | PositiveUniversalMeasure; readonly overlap?: OverlapType; -} +}; // // @@ -156,34 +156,63 @@ export class TableFloatOptionsAttributes extends XmlAttributeComponent>({ + leftFromText: { key: "w:leftFromText", value: leftFromText === undefined ? undefined : twipsMeasureValue(leftFromText) }, + rightFromText: { + key: "w:rightFromText", + value: rightFromText === undefined ? undefined : twipsMeasureValue(rightFromText), + }, + topFromText: { key: "w:topFromText", value: topFromText === undefined ? undefined : twipsMeasureValue(topFromText) }, + bottomFromText: { + key: "w:bottomFromText", + value: bottomFromText === undefined ? undefined : twipsMeasureValue(bottomFromText), + }, + absoluteHorizontalPosition: { + key: "w:tblpX", + value: absoluteHorizontalPosition === undefined ? undefined : signedTwipsMeasureValue(absoluteHorizontalPosition), + }, + absoluteVerticalPosition: { + key: "w:tblpY", + value: absoluteVerticalPosition === undefined ? undefined : signedTwipsMeasureValue(absoluteVerticalPosition), + }, + horizontalAnchor: { + key: "w:horzAnchor", + value: horizontalAnchor === undefined ? undefined : horizontalAnchor, + }, + relativeHorizontalPosition: { + key: "w:tblpXSpec", + value: relativeHorizontalPosition, + }, + relativeVerticalPosition: { + key: "w:tblpYSpec", + value: relativeVerticalPosition, + }, + verticalAnchor: { + key: "w:vertAnchor", + value: verticalAnchor, + }, }), ); - if (options.overlap) { + if (overlap) { // // // - this.root.push(new StringEnumValueElement("w:tblOverlap", options.overlap)); + this.root.push(new StringEnumValueElement("w:tblOverlap", overlap)); } } }