#751 Add bidi visual - Visual Right to Left
This commit is contained in:
15
src/file/paragraph/formatting/bidirectional.spec.ts
Normal file
15
src/file/paragraph/formatting/bidirectional.spec.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { Bidirectional } from "./bidirectional";
|
||||
|
||||
describe("Bidirectional", () => {
|
||||
it("should create", () => {
|
||||
const bidirectional = new Bidirectional();
|
||||
const tree = new Formatter().format(bidirectional);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:bidi": {},
|
||||
});
|
||||
});
|
||||
});
|
@ -141,4 +141,20 @@ describe("TableProperties", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#Set Virtual Right to Left", () => {
|
||||
it("sets the alignment of the table", () => {
|
||||
const tp = new TableProperties({
|
||||
visuallyRightToLeft: true,
|
||||
});
|
||||
const tree = new Formatter().format(tp);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:tblPr": [
|
||||
{
|
||||
"w:bidiVisual": {},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -9,6 +9,7 @@ import { ITableCellMarginOptions, TableCellMargin } from "./table-cell-margin";
|
||||
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
|
||||
import { TableLayout, TableLayoutType } from "./table-layout";
|
||||
import { PreferredTableWidth } from "./table-width";
|
||||
import { VisuallyRightToLeft } from "./visually-right-to-left";
|
||||
|
||||
export interface ITablePropertiesOptions {
|
||||
readonly width?: {
|
||||
@ -21,6 +22,7 @@ export interface ITablePropertiesOptions {
|
||||
readonly shading?: ITableShadingAttributesProperties;
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly cellMargin?: ITableCellMarginOptions;
|
||||
readonly visuallyRightToLeft?: boolean;
|
||||
}
|
||||
|
||||
export class TableProperties extends IgnoreIfEmptyXmlComponent {
|
||||
@ -52,5 +54,9 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent {
|
||||
if (options.shading) {
|
||||
this.root.push(new TableShading(options.shading));
|
||||
}
|
||||
|
||||
if (options.visuallyRightToLeft) {
|
||||
this.root.push(new VisuallyRightToLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { VisuallyRightToLeft } from "./visually-right-to-left";
|
||||
|
||||
describe("VisuallyRightToLeft", () => {
|
||||
it("should create", () => {
|
||||
const visuallyRightToLeft = new VisuallyRightToLeft();
|
||||
const tree = new Formatter().format(visuallyRightToLeft);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:bidiVisual": {},
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_bidiVisual_topic_ID0EOXIQ.html
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class VisuallyRightToLeft extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:bidiVisual");
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ export interface ITableOptions {
|
||||
readonly layout?: TableLayoutType;
|
||||
readonly borders?: ITableBordersOptions;
|
||||
readonly alignment?: AlignmentType;
|
||||
readonly visuallyRightToLeft?: boolean;
|
||||
}
|
||||
|
||||
export class Table extends XmlComponent {
|
||||
@ -48,6 +49,7 @@ export class Table extends XmlComponent {
|
||||
layout,
|
||||
borders,
|
||||
alignment,
|
||||
visuallyRightToLeft,
|
||||
}: ITableOptions) {
|
||||
super("w:tbl");
|
||||
|
||||
@ -76,6 +78,7 @@ export class Table extends XmlComponent {
|
||||
type: marginUnitType,
|
||||
},
|
||||
},
|
||||
visuallyRightToLeft,
|
||||
}),
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user