Remove invalid 'w:shdCs' element

This commit is contained in:
Tom Hunkapiller
2021-05-20 03:02:48 +03:00
parent 30912e7aaf
commit 06da596ffb
6 changed files with 6 additions and 67 deletions

View File

@ -625,7 +625,6 @@ describe("AbstractNumbering", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -636,7 +635,6 @@ describe("AbstractNumbering", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -645,10 +643,8 @@ describe("AbstractNumbering", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: true,
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -657,7 +653,6 @@ describe("AbstractNumbering", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: false,
expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }], expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
}, },
{ {
@ -666,18 +661,12 @@ describe("AbstractNumbering", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: {
type: ShadingType.PERCENT_10,
fill: "00FFFF",
color: "00FF00",
},
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "00FF00" } } },
], ],
}, },
]; ];
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => { shadingTests.forEach(({ shadow, shading, expected }) => {
it("#shadow correctly", () => { it("#shadow correctly", () => {
const abstractNumbering = new AbstractNumbering(1, [ const abstractNumbering = new AbstractNumbering(1, [
{ {
@ -685,7 +674,7 @@ describe("AbstractNumbering", () => {
format: LevelFormat.LOWER_ROMAN, format: LevelFormat.LOWER_ROMAN,
text: "%0.", text: "%0.",
style: { style: {
run: { shadow, shading, shadingComplexScript }, run: { shadow, shading },
}, },
}, },
]); ]);

View File

@ -200,15 +200,3 @@ export class Shading extends XmlComponent {
} }
} }
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,
}),
);
}
}

View File

@ -16,7 +16,6 @@ import {
ItalicsComplexScript, ItalicsComplexScript,
RightToLeft, RightToLeft,
Shading, Shading,
ShadowComplexScript,
Size, Size,
SizeComplexScript, SizeComplexScript,
SmallCaps, SmallCaps,
@ -63,7 +62,6 @@ export interface IRunStylePropertiesOptions {
readonly fill: string; readonly fill: string;
readonly color: string; readonly color: string;
}; };
readonly shadingComplexScript?: boolean | IRunStylePropertiesOptions["shading"];
readonly shadow?: IRunStylePropertiesOptions["shading"]; readonly shadow?: IRunStylePropertiesOptions["shading"];
readonly emboss?: boolean; readonly emboss?: boolean;
readonly imprint?: boolean; readonly imprint?: boolean;
@ -185,11 +183,6 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent {
if (shading) { if (shading) {
this.push(new Shading(shading.type, shading.fill, shading.color)); this.push(new Shading(shading.type, shading.fill, shading.color));
} }
const shdCs =
options.shadingComplexScript === undefined || options.shadingComplexScript === true ? shading : options.shadingComplexScript;
if (shdCs) {
this.push(new ShadowComplexScript(shdCs.type, shdCs.fill, shdCs.color));
}
} }
public push(item: XmlComponent): void { public push(item: XmlComponent): void {

View File

@ -245,15 +245,6 @@ describe("Run", () => {
{ {
"w:rPr": [ "w:rPr": [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{
"w:shdCs": {
_attr: {
"w:val": "pct10",
"w:fill": "00FFFF",
"w:color": "FF0000",
},
},
},
], ],
}, },
], ],

View File

@ -784,7 +784,6 @@ describe("CharacterStyle", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -795,7 +794,6 @@ describe("CharacterStyle", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -804,10 +802,8 @@ describe("CharacterStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: true,
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -816,7 +812,6 @@ describe("CharacterStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: false,
expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }], expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
}, },
{ {
@ -825,22 +820,16 @@ describe("CharacterStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: {
type: ShadingType.PERCENT_10,
fill: "00FFFF",
color: "00FF00",
},
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "00FF00" } } },
], ],
}, },
]; ];
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => { shadingTests.forEach(({ shadow, shading, expected }) => {
it("#shadow correctly", () => { it("#shadow correctly", () => {
const style = new StyleForCharacter({ const style = new StyleForCharacter({
id: "myStyleId", id: "myStyleId",
run: { shadow, shading, shadingComplexScript }, run: { shadow, shading },
}); });
const tree = new Formatter().format(style); const tree = new Formatter().format(style);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -660,7 +660,6 @@ describe("ParagraphStyle", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -671,7 +670,6 @@ describe("ParagraphStyle", () => {
}, },
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -680,10 +678,8 @@ describe("ParagraphStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: true,
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
], ],
}, },
{ {
@ -692,7 +688,6 @@ describe("ParagraphStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: false,
expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }], expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
}, },
{ {
@ -701,22 +696,16 @@ describe("ParagraphStyle", () => {
fill: "00FFFF", fill: "00FFFF",
color: "FF0000", color: "FF0000",
}, },
shadingComplexScript: {
type: ShadingType.PERCENT_10,
fill: "00FFFF",
color: "00FF00",
},
expected: [ expected: [
{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }, { "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } },
{ "w:shdCs": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "00FF00" } } },
], ],
}, },
]; ];
shadingTests.forEach(({ shadow, shading, shadingComplexScript, expected }) => { shadingTests.forEach(({ shadow, shading, expected }) => {
it("#shadow correctly", () => { it("#shadow correctly", () => {
const style = new StyleForParagraph({ const style = new StyleForParagraph({
id: "myStyleId", id: "myStyleId",
run: { shadow, shading, shadingComplexScript }, run: { shadow, shading },
}); });
const tree = new Formatter().format(style); const tree = new Formatter().format(style);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({