From df619ffe49054a6007d039b3595b84afa51b37b5 Mon Sep 17 00:00:00 2001 From: Pulpgrinder Dev Team Date: Tue, 9 May 2023 11:01:54 -0800 Subject: [PATCH 1/5] Added style support for noProof option. Useful for blocks of source code, and possibly other things that cause the grammar and spelling checkers to go nuts. Example usage: run: { font:"Consolas", color: "0000AA", break:1, noProof:true, }, Also added section to .gitignore to exclude Mac .DS_Store files. These are useless on anything other than a Mac. --- .gitignore | 3 +++ src/file/paragraph/run/properties.ts | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 287fdb8f83..2ec3d77b21 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,6 @@ My Document.docx # Temporary folder tmp + +# Exclude Mac .DS_Store files +.DS_Store diff --git a/src/file/paragraph/run/properties.ts b/src/file/paragraph/run/properties.ts index 41ca650995..93ab96cfa4 100644 --- a/src/file/paragraph/run/properties.ts +++ b/src/file/paragraph/run/properties.ts @@ -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 { IShadingAttributesProperties, Shading } from "@file/shading"; import { ChangeAttributes, IChangedAttributesProperties } from "@file/track-revision/track-revision"; @@ -34,6 +35,7 @@ export enum TextEffect { } export interface IRunStylePropertiesOptions { + readonly noProof?: boolean; readonly bold?: boolean; readonly boldComplexScript?: boolean; readonly italics?: boolean; @@ -131,7 +133,9 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent { if (!options) { return; } - + if (options.noProof !== undefined) { + this.push(new OnOffElement("w:noProof", options.noProof)); + } if (options.bold !== undefined) { this.push(new OnOffElement("w:b", options.bold)); } From 36e9ac1179a4cd3197b7f0d1fb1538668bf27730 Mon Sep 17 00:00:00 2001 From: Pulpgrinder Dev Team Date: Thu, 11 May 2023 20:49:09 -0800 Subject: [PATCH 2/5] Adding tests for noProof option --- src/file/paragraph/run/run.spec.ts | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index b2027c2cfb..d065181fb4 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -8,8 +8,38 @@ import { EmphasisMarkType } from "./emphasis-mark"; import { PageNumber, Run } from "./run"; import { UnderlineType } from "./underline"; import { TextEffect } from "./properties"; - 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": {} }, + ], + }, + ], + }); + }); + const run = new Run({ + noProof: false, + }); + const tree = new Formatter().format(run); + expect(tree).to.deep.equal({ + "w:r": [ + { + "w:rPr": [ + { "w:noProof": { _attr: { "w:val": false } } }, + ], + }, + ], + }); + }); + describe("#bold()", () => { it("it should add bold to the properties", () => { const run = new Run({ From 99dee460ae8a720ac8216c4f8e6e54554f2df2e5 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Tue, 13 Jun 2023 20:55:20 +0100 Subject: [PATCH 3/5] Fix prettier --- src/file/paragraph/run/run.spec.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index d065181fb4..12a46c4ba6 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -18,9 +18,7 @@ describe("Run", () => { expect(tree).to.deep.equal({ "w:r": [ { - "w:rPr": [ - { "w:noProof": {} }, - ], + "w:rPr": [{ "w:noProof": {} }], }, ], }); @@ -32,9 +30,7 @@ describe("Run", () => { expect(tree).to.deep.equal({ "w:r": [ { - "w:rPr": [ - { "w:noProof": { _attr: { "w:val": false } } }, - ], + "w:rPr": [{ "w:noProof": { _attr: { "w:val": false } } }], }, ], }); From a168dc1c158dc22395f58e06077769f4b5740895 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Wed, 14 Jun 2023 01:17:44 +0100 Subject: [PATCH 4/5] Remove redundant code --- src/file/paragraph/run/run.spec.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 12a46c4ba6..5d5650ce31 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -23,17 +23,6 @@ describe("Run", () => { ], }); }); - const run = new Run({ - noProof: false, - }); - const tree = new Formatter().format(run); - expect(tree).to.deep.equal({ - "w:r": [ - { - "w:rPr": [{ "w:noProof": { _attr: { "w:val": false } } }], - }, - ], - }); }); describe("#bold()", () => { From e4eeb3f87fbda64a6a3066791d1af4f645ff7693 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Wed, 14 Jun 2023 01:55:47 +0100 Subject: [PATCH 5/5] Fix spelling --- src/file/paragraph/run/run.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 5d5650ce31..162804b5ba 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -9,7 +9,7 @@ import { PageNumber, Run } from "./run"; import { UnderlineType } from "./underline"; import { TextEffect } from "./properties"; describe("Run", () => { - describe("#noproof()", () => { + describe("#noProof()", () => { it("turns off spelling and grammar checkers for a run", () => { const run = new Run({ noProof: true,