Merge pull request #276 from filippomuscolino/feat/cell-properties
Cell borders on Google Docs + set cell width
This commit is contained in:
@ -66,6 +66,22 @@ export class TableCellBorders extends XmlComponent {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addLeftBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||||
|
const left = new BaseTableCellBorder("w:left");
|
||||||
|
left.setProperties(style, size, color);
|
||||||
|
this.root.push(left);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public addRightBorder(style: BorderStyle, size: number, color: string): TableCellBorders {
|
||||||
|
const right = new BaseTableCellBorder("w:right");
|
||||||
|
right.setProperties(style, size, color);
|
||||||
|
this.root.push(right);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,12 +102,58 @@ describe("TableCellBorders", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should add left border", () => {
|
||||||
|
const tb = new TableCellBorders();
|
||||||
|
tb.addLeftBorder(BorderStyle.THICK, 3, "FF00FF");
|
||||||
|
|
||||||
|
const tree = new Formatter().format(tb);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:tcBorders": [
|
||||||
|
{
|
||||||
|
"w:left": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FF00FF",
|
||||||
|
"w:sz": 3,
|
||||||
|
"w:val": "thick",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should add right border", () => {
|
||||||
|
const tb = new TableCellBorders();
|
||||||
|
tb.addRightBorder(BorderStyle.THICK, 3, "FF00FF");
|
||||||
|
|
||||||
|
const tree = new Formatter().format(tb);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:tcBorders": [
|
||||||
|
{
|
||||||
|
"w:right": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FF00FF",
|
||||||
|
"w:sz": 3,
|
||||||
|
"w:val": "thick",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should add multiple borders", () => {
|
it("should add multiple borders", () => {
|
||||||
const tb = new TableCellBorders();
|
const tb = new TableCellBorders();
|
||||||
tb.addTopBorder(BorderStyle.DOTTED, 1, "FF00FF");
|
tb.addTopBorder(BorderStyle.DOTTED, 1, "FF00FF");
|
||||||
tb.addEndBorder(BorderStyle.THICK, 3, "FF00FF");
|
tb.addEndBorder(BorderStyle.THICK, 3, "FF00FF");
|
||||||
tb.addBottomBorder(BorderStyle.DOUBLE, 1, "FF00FF");
|
tb.addBottomBorder(BorderStyle.DOUBLE, 1, "FF00FF");
|
||||||
tb.addStartBorder(BorderStyle.SINGLE, 2, "FF00FF");
|
tb.addStartBorder(BorderStyle.SINGLE, 2, "FF00FF");
|
||||||
|
tb.addLeftBorder(BorderStyle.SINGLE, 2, "FF00FF");
|
||||||
|
tb.addRightBorder(BorderStyle.SINGLE, 2, "FF00FF");
|
||||||
|
|
||||||
const tree = new Formatter().format(tb);
|
const tree = new Formatter().format(tb);
|
||||||
expect(tree).to.deep.equal({
|
expect(tree).to.deep.equal({
|
||||||
@ -156,6 +202,28 @@ describe("TableCellBorders", () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"w:left": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FF00FF",
|
||||||
|
"w:sz": 2,
|
||||||
|
"w:val": "single",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"w:right": [
|
||||||
|
{
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FF00FF",
|
||||||
|
"w:sz": 2,
|
||||||
|
"w:val": "single",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -61,4 +61,8 @@ export class TableCell extends XmlComponent {
|
|||||||
public get Borders(): TableCellBorders {
|
public get Borders(): TableCellBorders {
|
||||||
return this.properties.Borders;
|
return this.properties.Borders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get Properties(): TableCellProperties {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user