Merge pull request #371 from mforman1/Highlighting
Add Highlight and Shading to the properties
This commit is contained in:
@ -113,7 +113,7 @@ export class Imprint extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class Shadow extends XmlComponent {
|
||||
/* export class Shadow extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:shadow");
|
||||
this.root.push(
|
||||
@ -122,7 +122,7 @@ export class Shadow extends XmlComponent {
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
export class SmallCaps extends XmlComponent {
|
||||
constructor() {
|
||||
@ -178,3 +178,51 @@ export class RightToLeft extends XmlComponent {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class Highlight extends XmlComponent {
|
||||
constructor(color: string) {
|
||||
super("w:highlight");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
val: color,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class HighlightComplexScript extends XmlComponent {
|
||||
constructor(color: string) {
|
||||
super("w:highlightCs");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
val: color,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class Shadow extends XmlComponent {
|
||||
constructor(value: string, fill: string, color: string) {
|
||||
super("w:shd");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
val: value,
|
||||
fill: fill,
|
||||
color: color,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ShadowComplexScript extends XmlComponent {
|
||||
constructor(value: string, fill: string, color: string) {
|
||||
super("w:shdCs");
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
val: value,
|
||||
fill: fill,
|
||||
color: color,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,54 @@ describe("Run", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#highlight()", () => {
|
||||
it("it should add highlight to the properties", () => {
|
||||
run.highlight("005599");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{ "w:highlight": { _attr: { "w:val": "005599" } } },
|
||||
{
|
||||
"w:highlightCs": {
|
||||
_attr: {
|
||||
"w:val": "005599",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#shadow()", () => {
|
||||
it("it should add shadow to the properties", () => {
|
||||
run.shadow("pct10", "00FFFF", "FF0000");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
|
||||
{
|
||||
"w:shdCs": {
|
||||
_attr: {
|
||||
"w:val": "pct10",
|
||||
"w:fill": "00FFFF",
|
||||
"w:color": "FF0000",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#break()", () => {
|
||||
it("it should add break to the run", () => {
|
||||
run.break();
|
||||
|
@ -7,9 +7,13 @@ import {
|
||||
BoldComplexScript,
|
||||
Color,
|
||||
DoubleStrike,
|
||||
Highlight,
|
||||
HighlightComplexScript,
|
||||
Italics,
|
||||
ItalicsComplexScript,
|
||||
RightToLeft,
|
||||
Shadow,
|
||||
ShadowComplexScript,
|
||||
Size,
|
||||
SizeComplexScript,
|
||||
Strike,
|
||||
@ -131,4 +135,16 @@ export class Run extends XmlComponent {
|
||||
this.properties.push(new Style(styleId));
|
||||
return this;
|
||||
}
|
||||
|
||||
public highlight(color: string): Run {
|
||||
this.properties.push(new Highlight(color));
|
||||
this.properties.push(new HighlightComplexScript(color));
|
||||
return this;
|
||||
}
|
||||
|
||||
public shadow(value: string, fill: string, color: string): Run {
|
||||
this.properties.push(new Shadow(value, fill, color));
|
||||
this.properties.push(new ShadowComplexScript(value, fill, color));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user