change shading val -> type

This commit is contained in:
Tom Hunkapiller
2021-05-29 05:51:06 +03:00
parent 730e33b164
commit 034cd187ab
14 changed files with 24 additions and 24 deletions

View File

@ -98,7 +98,7 @@ const table3 = new Table({
children: [new Paragraph("Bar1")], children: [new Paragraph("Bar1")],
shading: { shading: {
fill: "b79c2f", fill: "b79c2f",
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "auto", color: "auto",
}, },
}), }),
@ -106,7 +106,7 @@ const table3 = new Table({
children: [new Paragraph("Bar2")], children: [new Paragraph("Bar2")],
shading: { shading: {
fill: "42c5f4", fill: "42c5f4",
val: ShadingType.PERCENT_95, type: ShadingType.PERCENT_95,
color: "auto", color: "auto",
}, },
}), }),
@ -114,7 +114,7 @@ const table3 = new Table({
children: [new Paragraph("Bar3")], children: [new Paragraph("Bar3")],
shading: { shading: {
fill: "880aa8", fill: "880aa8",
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
color: "e2df0b", color: "e2df0b",
}, },
}), }),
@ -122,7 +122,7 @@ const table3 = new Table({
children: [new Paragraph("Bar4")], children: [new Paragraph("Bar4")],
shading: { shading: {
fill: "FF0000", fill: "FF0000",
val: ShadingType.CLEAR, type: ShadingType.CLEAR,
color: "auto", color: "auto",
}, },
}), }),

View File

@ -21,7 +21,7 @@ const doc = new Document({
name: "Garamond", name: "Garamond",
}, },
shading: { shading: {
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },
@ -30,7 +30,7 @@ const doc = new Document({
}), }),
new Paragraph({ new Paragraph({
shading: { shading: {
val: ShadingType.DIAGONAL_CROSS, type: ShadingType.DIAGONAL_CROSS,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },

View File

@ -94,7 +94,7 @@ const doc = new Document({
name: "Garamond", name: "Garamond",
}, },
shading: { shading: {
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },

View File

@ -156,7 +156,7 @@ Add color to an entire paragraph block
const paragraph = new Paragraph({ const paragraph = new Paragraph({
text: "shading", text: "shading",
shading: { shading: {
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },

View File

@ -83,7 +83,7 @@ const text = new TextRun({
const text = new TextRun({ const text = new TextRun({
text: "shading", text: "shading",
shading: { shading: {
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },

View File

@ -619,7 +619,7 @@ describe("AbstractNumbering", () => {
const shadingTests = [ const shadingTests = [
{ {
shading: { shading: {
val: ShadingType.DIAGONAL_STRIPE, type: ShadingType.DIAGONAL_STRIPE,
fill: "006622", fill: "006622",
color: "0000FF", color: "0000FF",
}, },
@ -627,7 +627,7 @@ describe("AbstractNumbering", () => {
}, },
{ {
shading: { shading: {
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },

View File

@ -850,7 +850,7 @@ describe("Paragraph", () => {
it("should set shading to the given value", () => { it("should set shading to the given value", () => {
const paragraph = new Paragraph({ const paragraph = new Paragraph({
shading: { shading: {
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "00FFFF", color: "00FFFF",
fill: "FF0000", fill: "FF0000",
}, },

View File

@ -226,7 +226,7 @@ describe("Run", () => {
it("it should add shadow to the properties", () => { it("it should add shadow to the properties", () => {
const run = new Run({ const run = new Run({
shading: { shading: {
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },

View File

@ -17,7 +17,7 @@ describe("Shading", () => {
}); });
it("should create with params", () => { it("should create with params", () => {
const shading = new Shading({ val: ShadingType.PERCENT_40, color: "FF0000", fill: "555555" }); const shading = new Shading({ type: ShadingType.PERCENT_40, color: "FF0000", fill: "555555" });
const tree = new Formatter().format(shading); const tree = new Formatter().format(shading);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({
"w:shd": { "w:shd": {

View File

@ -23,25 +23,25 @@ import { hexColorValue } from "../values";
export interface IShadingAttributesProperties { export interface IShadingAttributesProperties {
readonly fill?: string; readonly fill?: string;
readonly color?: string; readonly color?: string;
readonly val?: ShadingType; readonly type?: ShadingType;
} }
class ShadingAttributes extends XmlAttributeComponent<IShadingAttributesProperties> { class ShadingAttributes extends XmlAttributeComponent<IShadingAttributesProperties> {
protected readonly xmlKeys = { protected readonly xmlKeys = {
fill: "w:fill", fill: "w:fill",
color: "w:color", color: "w:color",
val: "w:val", type: "w:val",
}; };
} }
export class Shading extends XmlComponent { export class Shading extends XmlComponent {
constructor({ fill, color, val }: IShadingAttributesProperties) { constructor({ fill, color, type }: IShadingAttributesProperties) {
super("w:shd"); super("w:shd");
this.root.push( this.root.push(
new ShadingAttributes({ new ShadingAttributes({
fill: fill === undefined ? undefined : hexColorValue(fill), fill: fill === undefined ? undefined : hexColorValue(fill),
color: color === undefined ? undefined : hexColorValue(color), color: color === undefined ? undefined : hexColorValue(color),
val, type,
}), }),
); );
} }

View File

@ -778,7 +778,7 @@ describe("CharacterStyle", () => {
const shadingTests = [ const shadingTests = [
{ {
shading: { shading: {
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
@ -786,7 +786,7 @@ describe("CharacterStyle", () => {
}, },
{ {
shading: { shading: {
val: ShadingType.SOLID, type: ShadingType.SOLID,
fill: "AA0000", fill: "AA0000",
color: "DD0000", color: "DD0000",
}, },

View File

@ -650,7 +650,7 @@ describe("ParagraphStyle", () => {
const shadingTests = [ const shadingTests = [
{ {
shading: { shading: {
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
@ -658,7 +658,7 @@ describe("ParagraphStyle", () => {
}, },
{ {
shading: { shading: {
val: ShadingType.DIAGONAL_CROSS, type: ShadingType.DIAGONAL_CROSS,
fill: "0066FF", fill: "0066FF",
color: "0000FF", color: "0000FF",
}, },

View File

@ -435,7 +435,7 @@ describe("TableCell", () => {
shading: { shading: {
fill: "FF0000", fill: "FF0000",
color: "0000ff", color: "0000ff",
val: ShadingType.PERCENT_10, type: ShadingType.PERCENT_10,
}, },
}); });

View File

@ -129,7 +129,7 @@ describe("TableProperties", () => {
const tp = new TableProperties({ const tp = new TableProperties({
shading: { shading: {
fill: "b79c2f", fill: "b79c2f",
val: ShadingType.REVERSE_DIAGONAL_STRIPE, type: ShadingType.REVERSE_DIAGONAL_STRIPE,
color: "auto", color: "auto",
}, },
}); });