Merge pull request #2119 from pulpgrinder/master

Added style support for noProof option.
This commit is contained in:
Dolan
2023-06-14 02:25:36 +01:00
committed by GitHub
3 changed files with 24 additions and 2 deletions

3
.gitignore vendored
View File

@ -59,3 +59,6 @@ My Document.docx
# Temporary folder # Temporary folder
tmp tmp
# Exclude Mac .DS_Store files
.DS_Store

View File

@ -1,3 +1,4 @@
// https://www.ecma-international.org/wp-content/uploads/ECMA-376-1_5th_edition_december_2016.zip page 297, section 17.3.2.21
import { BorderElement, IBorderOptions } from "@file/border"; import { BorderElement, IBorderOptions } from "@file/border";
import { IShadingAttributesProperties, Shading } from "@file/shading"; import { IShadingAttributesProperties, Shading } from "@file/shading";
import { ChangeAttributes, IChangedAttributesProperties } from "@file/track-revision/track-revision"; import { ChangeAttributes, IChangedAttributesProperties } from "@file/track-revision/track-revision";
@ -34,6 +35,7 @@ export enum TextEffect {
} }
export interface IRunStylePropertiesOptions { export interface IRunStylePropertiesOptions {
readonly noProof?: boolean;
readonly bold?: boolean; readonly bold?: boolean;
readonly boldComplexScript?: boolean; readonly boldComplexScript?: boolean;
readonly italics?: boolean; readonly italics?: boolean;
@ -131,7 +133,9 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent {
if (!options) { if (!options) {
return; return;
} }
if (options.noProof !== undefined) {
this.push(new OnOffElement("w:noProof", options.noProof));
}
if (options.bold !== undefined) { if (options.bold !== undefined) {
this.push(new OnOffElement("w:b", options.bold)); this.push(new OnOffElement("w:b", options.bold));
} }

View File

@ -8,8 +8,23 @@ import { EmphasisMarkType } from "./emphasis-mark";
import { PageNumber, Run } from "./run"; import { PageNumber, Run } from "./run";
import { UnderlineType } from "./underline"; import { UnderlineType } from "./underline";
import { TextEffect } from "./properties"; import { TextEffect } from "./properties";
describe("Run", () => { describe("Run", () => {
describe("#noProof()", () => {
it("turns off spelling and grammar checkers for a run", () => {
const run = new Run({
noProof: true,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{
"w:rPr": [{ "w:noProof": {} }],
},
],
});
});
});
describe("#bold()", () => { describe("#bold()", () => {
it("it should add bold to the properties", () => { it("it should add bold to the properties", () => {
const run = new Run({ const run = new Run({