diff --git a/demo/55-math.ts b/demo/55-math.ts index ad7473915c..3dc6c1a17c 100644 --- a/demo/55-math.ts +++ b/demo/55-math.ts @@ -33,8 +33,8 @@ doc.addSection({ children: [ new MathRun("2+2"), new MathFraction({ - numerator: new MathRun("hi"), - denominator: new MathRun("2"), + numerator: [new MathRun("hi")], + denominator: [new MathRun("2")], }), ], }), @@ -44,26 +44,43 @@ doc.addSection({ }), ], }), + // new Paragraph({ + // children: [ + // new MathFraction({ + // numerator: [ + // new MathRun("1"), + // new MathRadical({ + // children: [new MathRun("2")], + // }), + // ], + // denominator: [new MathRun("2")], + // }), + // ], + // }), new Paragraph({ children: [ new Math({ children: [ new MathSum({ - child: new MathRun("test"), + children: [new MathRun("test")], }), new MathSum({ - child: new MathSuperScript({ - child: new MathRun("e"), - superScript: new MathRun("2"), - }), - subScript: new MathRun("i"), + children: [ + new MathSuperScript({ + children: [new MathRun("e")], + superScript: [new MathRun("2")], + }), + ], + subScript: [new MathRun("i")], }), new MathSum({ - child: new MathRadical({ - child: new MathRun("i"), - }), - subScript: new MathRun("i"), - superScript: new MathRun("10"), + children: [ + new MathRadical({ + children: [new MathRun("i")], + }), + ], + subScript: [new MathRun("i")], + superScript: [new MathRun("10")], }), ], }), @@ -74,8 +91,8 @@ doc.addSection({ new Math({ children: [ new MathSuperScript({ - child: new MathRun("test"), - superScript: new MathRun("hello"), + children: [new MathRun("test")], + superScript: [new MathRun("hello")], }), ], }), @@ -86,8 +103,8 @@ doc.addSection({ new Math({ children: [ new MathSubScript({ - child: new MathRun("test"), - subScript: new MathRun("hello"), + children: [new MathRun("test")], + subScript: [new MathRun("hello")], }), ], }), @@ -98,11 +115,13 @@ doc.addSection({ new Math({ children: [ new MathSubScript({ - child: new MathRun("x"), - subScript: new MathSuperScript({ - child: new MathRun("y"), - superScript: new MathRun("2"), - }), + children: [new MathRun("x")], + subScript: [ + new MathSuperScript({ + children: [new MathRun("y")], + superScript: [new MathRun("2")], + }), + ], }), ], }), @@ -113,9 +132,9 @@ doc.addSection({ new Math({ children: [ new MathSubSuperScript({ - child: new MathRun("test"), - superScript: new MathRun("hello"), - subScript: new MathRun("world"), + children: [new MathRun("test")], + superScript: [new MathRun("hello")], + subScript: [new MathRun("world")], }), ], }), @@ -126,9 +145,9 @@ doc.addSection({ new Math({ children: [ new MathPreSubSuperScript({ - child: new MathRun("test"), - superScript: new MathRun("hello"), - subScript: new MathRun("world"), + children: [new MathRun("test")], + superScript: [new MathRun("hello")], + subScript: [new MathRun("world")], }), ], }), @@ -139,29 +158,35 @@ doc.addSection({ new Math({ children: [ new MathSubScript({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), - }), - subScript: new MathRun("4"), - }), - ], - }), - ], - }), - new Paragraph({ - children: [ - new Math({ - children: [ - new MathSubScript({ - child: new MathRadical({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], }), - degree: new MathRun("4"), - }), - subScript: new MathRun("x"), + ], + subScript: [new MathRun("4")], + }), + ], + }), + ], + }), + new Paragraph({ + children: [ + new Math({ + children: [ + new MathSubScript({ + children: [ + new MathRadical({ + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], + }), + ], + degree: [new MathRun("4")], + }), + ], + subScript: [new MathRun("x")], }), ], }), @@ -172,7 +197,7 @@ doc.addSection({ new Math({ children: [ new MathRadical({ - child: new MathRun("4"), + children: [new MathRun("4")], }), ], }), @@ -183,16 +208,18 @@ doc.addSection({ new Math({ children: [ new MathFunction({ - name: new MathSuperScript({ - child: new MathRun("cos"), - superScript: new MathRun("-1"), - }), - child: new MathRun("100"), + name: [ + new MathSuperScript({ + children: [new MathRun("cos")], + superScript: [new MathRun("-1")], + }), + ], + children: [new MathRun("100")], }), new MathRun("×"), new MathFunction({ - name: new MathRun("sin"), - child: new MathRun("360"), + name: [new MathRun("sin")], + children: [new MathRun("360")], }), new MathRun("= x"), ], @@ -204,28 +231,36 @@ doc.addSection({ new Math({ children: [ new MathRoundBrackets({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), - }), + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], + }), + ], }), new MathSquareBrackets({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), - }), + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], + }), + ], }), new MathCurlyBrackets({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), - }), + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], + }), + ], }), new MathAngledBrackets({ - child: new MathFraction({ - numerator: new MathRun("1"), - denominator: new MathRun("2"), - }), + children: [ + new MathFraction({ + numerator: [new MathRun("1")], + denominator: [new MathRun("2")], + }), + ], }), ], }), @@ -236,10 +271,12 @@ doc.addSection({ new Math({ children: [ new MathFraction({ - numerator: new MathRadical({ - child: new MathRun("4"), - }), - denominator: new MathRun("2a"), + numerator: [ + new MathRadical({ + children: [new MathRun("4")], + }), + ], + denominator: [new MathRun("2a")], }), ], }), diff --git a/src/file/paragraph/math/brackets/math-angled-brackets.spec.ts b/src/file/paragraph/math/brackets/math-angled-brackets.spec.ts index 735e0da272..ccd73b192b 100644 --- a/src/file/paragraph/math/brackets/math-angled-brackets.spec.ts +++ b/src/file/paragraph/math/brackets/math-angled-brackets.spec.ts @@ -9,7 +9,7 @@ describe("MathAngledBrackets", () => { describe("#constructor()", () => { it("should create a MathAngledBrackets with correct root key", () => { const mathAngledBrackets = new MathAngledBrackets({ - child: new MathRun("60"), + children: [new MathRun("60")], }); const tree = new Formatter().format(mathAngledBrackets); diff --git a/src/file/paragraph/math/brackets/math-angled-brackets.ts b/src/file/paragraph/math/brackets/math-angled-brackets.ts index fbafb7e738..48fe0d415d 100644 --- a/src/file/paragraph/math/brackets/math-angled-brackets.ts +++ b/src/file/paragraph/math/brackets/math-angled-brackets.ts @@ -6,7 +6,7 @@ import { MathBase } from "../n-ary"; import { MathBracketProperties } from "./math-bracket-properties"; export class MathAngledBrackets extends XmlComponent { - constructor(options: { readonly child: MathComponent }) { + constructor(options: { readonly children: MathComponent[] }) { super("m:d"); this.root.push( @@ -15,6 +15,6 @@ export class MathAngledBrackets extends XmlComponent { endingCharacter: "〉", }), ); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/brackets/math-curly-brackets.spec.ts b/src/file/paragraph/math/brackets/math-curly-brackets.spec.ts index 6e44621b21..d6defd57ef 100644 --- a/src/file/paragraph/math/brackets/math-curly-brackets.spec.ts +++ b/src/file/paragraph/math/brackets/math-curly-brackets.spec.ts @@ -9,7 +9,7 @@ describe("MathCurlyBrackets", () => { describe("#constructor()", () => { it("should create a MathCurlyBrackets with correct root key", () => { const mathCurlyBrackets = new MathCurlyBrackets({ - child: new MathRun("60"), + children: [new MathRun("60")], }); const tree = new Formatter().format(mathCurlyBrackets); diff --git a/src/file/paragraph/math/brackets/math-curly-brackets.ts b/src/file/paragraph/math/brackets/math-curly-brackets.ts index 4d540ec8bc..ccce71e6a7 100644 --- a/src/file/paragraph/math/brackets/math-curly-brackets.ts +++ b/src/file/paragraph/math/brackets/math-curly-brackets.ts @@ -6,7 +6,7 @@ import { MathBase } from "../n-ary"; import { MathBracketProperties } from "./math-bracket-properties"; export class MathCurlyBrackets extends XmlComponent { - constructor(options: { readonly child: MathComponent }) { + constructor(options: { readonly children: MathComponent[] }) { super("m:d"); this.root.push( @@ -15,6 +15,6 @@ export class MathCurlyBrackets extends XmlComponent { endingCharacter: "}", }), ); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/brackets/math-round-brackets.spec.ts b/src/file/paragraph/math/brackets/math-round-brackets.spec.ts index cb28126a20..5138e9d085 100644 --- a/src/file/paragraph/math/brackets/math-round-brackets.spec.ts +++ b/src/file/paragraph/math/brackets/math-round-brackets.spec.ts @@ -9,7 +9,7 @@ describe("MathRoundBrackets", () => { describe("#constructor()", () => { it("should create a MathRoundBrackets with correct root key", () => { const mathRoundBrackets = new MathRoundBrackets({ - child: new MathRun("60"), + children: [new MathRun("60")], }); const tree = new Formatter().format(mathRoundBrackets); diff --git a/src/file/paragraph/math/brackets/math-round-brackets.ts b/src/file/paragraph/math/brackets/math-round-brackets.ts index 2302fa30f1..6fe60318a4 100644 --- a/src/file/paragraph/math/brackets/math-round-brackets.ts +++ b/src/file/paragraph/math/brackets/math-round-brackets.ts @@ -6,10 +6,10 @@ import { MathBase } from "../n-ary"; import { MathBracketProperties } from "./math-bracket-properties"; export class MathRoundBrackets extends XmlComponent { - constructor(options: { readonly child: MathComponent }) { + constructor(options: { readonly children: MathComponent[] }) { super("m:d"); this.root.push(new MathBracketProperties()); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/brackets/math-square-brackets.spec.ts b/src/file/paragraph/math/brackets/math-square-brackets.spec.ts index 03b8aef03d..b0e2ec9e26 100644 --- a/src/file/paragraph/math/brackets/math-square-brackets.spec.ts +++ b/src/file/paragraph/math/brackets/math-square-brackets.spec.ts @@ -9,7 +9,7 @@ describe("MathSquareBrackets", () => { describe("#constructor()", () => { it("should create a MathSquareBrackets with correct root key", () => { const mathSquareBrackets = new MathSquareBrackets({ - child: new MathRun("60"), + children: [new MathRun("60")], }); const tree = new Formatter().format(mathSquareBrackets); diff --git a/src/file/paragraph/math/brackets/math-square-brackets.ts b/src/file/paragraph/math/brackets/math-square-brackets.ts index 3c3d385357..fdfe88a004 100644 --- a/src/file/paragraph/math/brackets/math-square-brackets.ts +++ b/src/file/paragraph/math/brackets/math-square-brackets.ts @@ -6,7 +6,7 @@ import { MathBase } from "../n-ary"; import { MathBracketProperties } from "./math-bracket-properties"; export class MathSquareBrackets extends XmlComponent { - constructor(options: { readonly child: MathComponent }) { + constructor(options: { readonly children: MathComponent[] }) { super("m:d"); this.root.push( @@ -15,6 +15,6 @@ export class MathSquareBrackets extends XmlComponent { endingCharacter: "]", }), ); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/fraction/math-denominator.spec.ts b/src/file/paragraph/math/fraction/math-denominator.spec.ts index a5f50ce1ad..f2e7459e1e 100644 --- a/src/file/paragraph/math/fraction/math-denominator.spec.ts +++ b/src/file/paragraph/math/fraction/math-denominator.spec.ts @@ -8,7 +8,7 @@ import { MathDenominator } from "./math-denominator"; describe("MathDenominator", () => { describe("#constructor()", () => { it("should create a MathDenominator with correct root key", () => { - const mathDenominator = new MathDenominator(new MathRun("2+2")); + const mathDenominator = new MathDenominator([new MathRun("2+2")]); const tree = new Formatter().format(mathDenominator); expect(tree).to.deep.equal({ "m:den": [ diff --git a/src/file/paragraph/math/fraction/math-denominator.ts b/src/file/paragraph/math/fraction/math-denominator.ts index db59eabc8c..8df68bf4b0 100644 --- a/src/file/paragraph/math/fraction/math-denominator.ts +++ b/src/file/paragraph/math/fraction/math-denominator.ts @@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathDenominator extends XmlComponent { - constructor(child: MathComponent) { + constructor(children: MathComponent[]) { super("m:den"); - this.root.push(child); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/fraction/math-fraction.spec.ts b/src/file/paragraph/math/fraction/math-fraction.spec.ts index 9ebd3c4bcd..51cac646bf 100644 --- a/src/file/paragraph/math/fraction/math-fraction.spec.ts +++ b/src/file/paragraph/math/fraction/math-fraction.spec.ts @@ -9,8 +9,8 @@ describe("MathFraction", () => { describe("#constructor()", () => { it("should create a MathFraction with correct root key", () => { const mathFraction = new MathFraction({ - numerator: new MathRun("2"), - denominator: new MathRun("2"), + numerator: [new MathRun("2")], + denominator: [new MathRun("2")], }); const tree = new Formatter().format(mathFraction); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/fraction/math-fraction.ts b/src/file/paragraph/math/fraction/math-fraction.ts index 65768a1fca..84a803a872 100644 --- a/src/file/paragraph/math/fraction/math-fraction.ts +++ b/src/file/paragraph/math/fraction/math-fraction.ts @@ -5,8 +5,8 @@ import { MathDenominator } from "./math-denominator"; import { MathNumerator } from "./math-numerator"; export interface IMathFractionOptions { - readonly numerator: MathComponent; - readonly denominator: MathComponent; + readonly numerator: MathComponent[]; + readonly denominator: MathComponent[]; } export class MathFraction extends XmlComponent { diff --git a/src/file/paragraph/math/fraction/math-numerator.spec.ts b/src/file/paragraph/math/fraction/math-numerator.spec.ts index 862dc18938..e3aaf35c0e 100644 --- a/src/file/paragraph/math/fraction/math-numerator.spec.ts +++ b/src/file/paragraph/math/fraction/math-numerator.spec.ts @@ -8,7 +8,7 @@ import { MathNumerator } from "./math-numerator"; describe("MathNumerator", () => { describe("#constructor()", () => { it("should create a MathNumerator with correct root key", () => { - const mathNumerator = new MathNumerator(new MathRun("2+2")); + const mathNumerator = new MathNumerator([new MathRun("2+2")]); const tree = new Formatter().format(mathNumerator); expect(tree).to.deep.equal({ "m:num": [ diff --git a/src/file/paragraph/math/fraction/math-numerator.ts b/src/file/paragraph/math/fraction/math-numerator.ts index bad0ace36f..b7a49d9a75 100644 --- a/src/file/paragraph/math/fraction/math-numerator.ts +++ b/src/file/paragraph/math/fraction/math-numerator.ts @@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathNumerator extends XmlComponent { - constructor(child: MathComponent) { + constructor(children: MathComponent[]) { super("m:num"); - this.root.push(child); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/function/math-function-name.spec.ts b/src/file/paragraph/math/function/math-function-name.spec.ts index bdb38d7596..8a37ee998e 100644 --- a/src/file/paragraph/math/function/math-function-name.spec.ts +++ b/src/file/paragraph/math/function/math-function-name.spec.ts @@ -8,7 +8,7 @@ import { MathFunctionName } from "./math-function-name"; describe("MathFunctionName", () => { describe("#constructor()", () => { it("should create a MathFunctionName with correct root key", () => { - const mathFunctionName = new MathFunctionName(new MathRun("2")); + const mathFunctionName = new MathFunctionName([new MathRun("2")]); const tree = new Formatter().format(mathFunctionName); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/function/math-function-name.ts b/src/file/paragraph/math/function/math-function-name.ts index 011e82133a..e58488dd28 100644 --- a/src/file/paragraph/math/function/math-function-name.ts +++ b/src/file/paragraph/math/function/math-function-name.ts @@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathFunctionName extends XmlComponent { - constructor(child: MathComponent) { + constructor(children: MathComponent[]) { super("m:fName"); - this.root.push(child); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/function/math-function.spec.ts b/src/file/paragraph/math/function/math-function.spec.ts index 4320a853c6..6ea02b6c9d 100644 --- a/src/file/paragraph/math/function/math-function.spec.ts +++ b/src/file/paragraph/math/function/math-function.spec.ts @@ -9,8 +9,8 @@ describe("MathFunction", () => { describe("#constructor()", () => { it("should create a MathFunction with correct root key", () => { const mathFunction = new MathFunction({ - name: new MathRun("sin"), - child: new MathRun("60"), + name: [new MathRun("sin")], + children: [new MathRun("60")], }); const tree = new Formatter().format(mathFunction); diff --git a/src/file/paragraph/math/function/math-function.ts b/src/file/paragraph/math/function/math-function.ts index b3de75ddb8..86b66392cc 100644 --- a/src/file/paragraph/math/function/math-function.ts +++ b/src/file/paragraph/math/function/math-function.ts @@ -7,8 +7,8 @@ import { MathFunctionName } from "./math-function-name"; import { MathFunctionProperties } from "./math-function-properties"; export interface IMathFunctionOptions { - readonly child: MathComponent; - readonly name: MathComponent; + readonly children: MathComponent[]; + readonly name: MathComponent[]; } export class MathFunction extends XmlComponent { @@ -17,6 +17,6 @@ export class MathFunction extends XmlComponent { this.root.push(new MathFunctionProperties()); this.root.push(new MathFunctionName(options.name)); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/n-ary/math-base.spec.ts b/src/file/paragraph/math/n-ary/math-base.spec.ts index 012147c4d9..c282537970 100644 --- a/src/file/paragraph/math/n-ary/math-base.spec.ts +++ b/src/file/paragraph/math/n-ary/math-base.spec.ts @@ -8,7 +8,7 @@ import { MathBase } from "./math-base"; describe("MathBase", () => { describe("#constructor()", () => { it("should create a MathBase with correct root key", () => { - const mathBase = new MathBase(new MathRun("2+2")); + const mathBase = new MathBase([new MathRun("2+2")]); const tree = new Formatter().format(mathBase); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/n-ary/math-base.ts b/src/file/paragraph/math/n-ary/math-base.ts index 7c06a67c23..6c2320439f 100644 --- a/src/file/paragraph/math/n-ary/math-base.ts +++ b/src/file/paragraph/math/n-ary/math-base.ts @@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathBase extends XmlComponent { - constructor(run: MathComponent) { + constructor(children: MathComponent[]) { super("m:e"); - this.root.push(run); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/n-ary/math-sub-script.spec.ts b/src/file/paragraph/math/n-ary/math-sub-script.spec.ts index 5a4009811e..d342946b74 100644 --- a/src/file/paragraph/math/n-ary/math-sub-script.spec.ts +++ b/src/file/paragraph/math/n-ary/math-sub-script.spec.ts @@ -8,7 +8,7 @@ import { MathSubScriptElement } from "./math-sub-script"; describe("MathSubScriptElement", () => { describe("#constructor()", () => { it("should create a MathSubScriptElement with correct root key", () => { - const mathSubScriptElement = new MathSubScriptElement(new MathRun("2+2")); + const mathSubScriptElement = new MathSubScriptElement([new MathRun("2+2")]); const tree = new Formatter().format(mathSubScriptElement); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/n-ary/math-sub-script.ts b/src/file/paragraph/math/n-ary/math-sub-script.ts index aaa8530e74..48268312cf 100644 --- a/src/file/paragraph/math/n-ary/math-sub-script.ts +++ b/src/file/paragraph/math/n-ary/math-sub-script.ts @@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathSubScriptElement extends XmlComponent { - constructor(child: MathComponent) { + constructor(children: MathComponent[]) { super("m:sub"); - this.root.push(child); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/n-ary/math-sum.spec.ts b/src/file/paragraph/math/n-ary/math-sum.spec.ts index 9f0d213aa4..1e76815147 100644 --- a/src/file/paragraph/math/n-ary/math-sum.spec.ts +++ b/src/file/paragraph/math/n-ary/math-sum.spec.ts @@ -9,9 +9,9 @@ describe("MathSum", () => { describe("#constructor()", () => { it("should create a MathSum with correct root key", () => { const mathSum = new MathSum({ - child: new MathRun("1"), - subScript: new MathRun("2"), - superScript: new MathRun("3"), + children: [new MathRun("1")], + subScript: [new MathRun("2")], + superScript: [new MathRun("3")], }); const tree = new Formatter().format(mathSum); diff --git a/src/file/paragraph/math/n-ary/math-sum.ts b/src/file/paragraph/math/n-ary/math-sum.ts index a16603982d..af14730bbf 100644 --- a/src/file/paragraph/math/n-ary/math-sum.ts +++ b/src/file/paragraph/math/n-ary/math-sum.ts @@ -8,9 +8,9 @@ import { MathSubScriptElement } from "./math-sub-script"; import { MathSuperScriptElement } from "./math-super-script"; export interface IMathSumOptions { - readonly child: MathComponent; - readonly subScript?: MathComponent; - readonly superScript?: MathComponent; + readonly children: MathComponent[]; + readonly subScript?: MathComponent[]; + readonly superScript?: MathComponent[]; } export class MathSum extends XmlComponent { @@ -27,6 +27,6 @@ export class MathSum extends XmlComponent { this.root.push(new MathSuperScriptElement(options.superScript)); } - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/n-ary/math-super-script.spec.ts b/src/file/paragraph/math/n-ary/math-super-script.spec.ts index 85a5195c0f..10e037eba3 100644 --- a/src/file/paragraph/math/n-ary/math-super-script.spec.ts +++ b/src/file/paragraph/math/n-ary/math-super-script.spec.ts @@ -8,7 +8,7 @@ import { MathSuperScriptElement } from "./math-super-script"; describe("MathSuperScriptElement", () => { describe("#constructor()", () => { it("should create a MathSuperScriptElement with correct root key", () => { - const mathSuperScriptElement = new MathSuperScriptElement(new MathRun("2+2")); + const mathSuperScriptElement = new MathSuperScriptElement([new MathRun("2+2")]); const tree = new Formatter().format(mathSuperScriptElement); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/n-ary/math-super-script.ts b/src/file/paragraph/math/n-ary/math-super-script.ts index 1d29bda52b..8d8386addc 100644 --- a/src/file/paragraph/math/n-ary/math-super-script.ts +++ b/src/file/paragraph/math/n-ary/math-super-script.ts @@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathSuperScriptElement extends XmlComponent { - constructor(child: MathComponent) { + constructor(children: MathComponent[]) { super("m:sup"); - this.root.push(child); + for (const child of children) { + this.root.push(child); + } } } diff --git a/src/file/paragraph/math/radical/math-degree.spec.ts b/src/file/paragraph/math/radical/math-degree.spec.ts index 6a1c28656b..3d1f17dfa8 100644 --- a/src/file/paragraph/math/radical/math-degree.spec.ts +++ b/src/file/paragraph/math/radical/math-degree.spec.ts @@ -17,7 +17,7 @@ describe("MathDegree", () => { }); it("should create a MathDegree with correct root key with child", () => { - const mathDegree = new MathDegree(new MathRun("2")); + const mathDegree = new MathDegree([new MathRun("2")]); const tree = new Formatter().format(mathDegree); expect(tree).to.deep.equal({ diff --git a/src/file/paragraph/math/radical/math-degree.ts b/src/file/paragraph/math/radical/math-degree.ts index 402ee8ffda..79923bbde8 100644 --- a/src/file/paragraph/math/radical/math-degree.ts +++ b/src/file/paragraph/math/radical/math-degree.ts @@ -3,11 +3,13 @@ import { XmlComponent } from "file/xml-components"; import { MathComponent } from "../math-component"; export class MathDegree extends XmlComponent { - constructor(child?: MathComponent) { + constructor(children?: MathComponent[]) { super("m:deg"); - if (!!child) { - this.root.push(child); + if (!!children) { + for (const child of children) { + this.root.push(child); + } } } } diff --git a/src/file/paragraph/math/radical/math-radical.spec.ts b/src/file/paragraph/math/radical/math-radical.spec.ts index 7d7d7c4225..e388edece4 100644 --- a/src/file/paragraph/math/radical/math-radical.spec.ts +++ b/src/file/paragraph/math/radical/math-radical.spec.ts @@ -9,8 +9,8 @@ describe("MathRadical", () => { describe("#constructor()", () => { it("should create a MathRadical with correct root key", () => { const mathRadical = new MathRadical({ - child: new MathRun("e"), - degree: new MathRun("2"), + children: [new MathRun("e")], + degree: [new MathRun("2")], }); const tree = new Formatter().format(mathRadical); diff --git a/src/file/paragraph/math/radical/math-radical.ts b/src/file/paragraph/math/radical/math-radical.ts index 76fc2dc7ca..1469867a5f 100644 --- a/src/file/paragraph/math/radical/math-radical.ts +++ b/src/file/paragraph/math/radical/math-radical.ts @@ -7,8 +7,8 @@ import { MathDegree } from "./math-degree"; import { MathRadicalProperties } from "./math-radical-properties"; export interface IMathRadicalOptions { - readonly child: MathComponent; - readonly degree?: MathComponent; + readonly children: MathComponent[]; + readonly degree?: MathComponent[]; } export class MathRadical extends XmlComponent { @@ -17,6 +17,6 @@ export class MathRadical extends XmlComponent { this.root.push(new MathRadicalProperties(!!options.degree)); this.root.push(new MathDegree(options.degree)); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); } } diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts index 956a2ff445..20d00a639d 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts @@ -9,9 +9,9 @@ describe("MathPreSubScript", () => { describe("#constructor()", () => { it("should create a MathPreSubScript with correct root key", () => { const mathPreSubScript = new MathPreSubSuperScript({ - child: new MathRun("e"), - subScript: new MathRun("2"), - superScript: new MathRun("5"), + children: [new MathRun("e")], + subScript: [new MathRun("2")], + superScript: [new MathRun("5")], }); const tree = new Formatter().format(mathPreSubScript); diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts index a0bdc321a0..3a58675b0f 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts @@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n- import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties"; export interface IMathPreSubSuperScriptOptions { - readonly child: MathComponent; - readonly subScript: MathComponent; - readonly superScript: MathComponent; + readonly children: MathComponent[]; + readonly subScript: MathComponent[]; + readonly superScript: MathComponent[]; } export class MathPreSubSuperScript extends XmlComponent { @@ -16,7 +16,7 @@ export class MathPreSubSuperScript extends XmlComponent { super("m:sPre"); this.root.push(new MathPreSubSuperScriptProperties()); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); this.root.push(new MathSubScriptElement(options.subScript)); this.root.push(new MathSuperScriptElement(options.superScript)); } diff --git a/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts b/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts index dd33598d81..a3ea8d680c 100644 --- a/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts +++ b/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts @@ -9,8 +9,8 @@ describe("MathSubScript", () => { describe("#constructor()", () => { it("should create a MathSubScript with correct root key", () => { const mathSubScript = new MathSubScript({ - child: new MathRun("e"), - subScript: new MathRun("2"), + children: [new MathRun("e")], + subScript: [new MathRun("2")], }); const tree = new Formatter().format(mathSubScript); diff --git a/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts b/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts index a5c26cd06c..319d4d1f1a 100644 --- a/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts +++ b/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts @@ -6,8 +6,8 @@ import { MathBase, MathSubScriptElement } from "../../n-ary"; import { MathSubScriptProperties } from "./math-sub-script-function-properties"; export interface IMathSubScriptOptions { - readonly child: MathComponent; - readonly subScript: MathComponent; + readonly children: MathComponent[]; + readonly subScript: MathComponent[]; } export class MathSubScript extends XmlComponent { @@ -15,7 +15,7 @@ export class MathSubScript extends XmlComponent { super("m:sSub"); this.root.push(new MathSubScriptProperties()); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); this.root.push(new MathSubScriptElement(options.subScript)); } } diff --git a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts index 5e7f976db7..68a86fb26b 100644 --- a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts @@ -9,9 +9,9 @@ describe("MathSubScript", () => { describe("#constructor()", () => { it("should create a MathSubScript with correct root key", () => { const mathSubScript = new MathSubSuperScript({ - child: new MathRun("e"), - subScript: new MathRun("2"), - superScript: new MathRun("5"), + children: [new MathRun("e")], + subScript: [new MathRun("2")], + superScript: [new MathRun("5")], }); const tree = new Formatter().format(mathSubScript); diff --git a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts index 91bdfe6781..c382c9ff4c 100644 --- a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts +++ b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts @@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n- import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties"; export interface IMathSubSuperScriptOptions { - readonly child: MathComponent; - readonly subScript: MathComponent; - readonly superScript: MathComponent; + readonly children: MathComponent[]; + readonly subScript: MathComponent[]; + readonly superScript: MathComponent[]; } export class MathSubSuperScript extends XmlComponent { @@ -16,7 +16,7 @@ export class MathSubSuperScript extends XmlComponent { super("m:sSubSup"); this.root.push(new MathSubSuperScriptProperties()); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); this.root.push(new MathSubScriptElement(options.subScript)); this.root.push(new MathSuperScriptElement(options.superScript)); } diff --git a/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts b/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts index 6e6beb5e04..ae3740360b 100644 --- a/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts @@ -9,8 +9,8 @@ describe("MathSuperScript", () => { describe("#constructor()", () => { it("should create a MathSuperScript with correct root key", () => { const mathSuperScript = new MathSuperScript({ - child: new MathRun("e"), - superScript: new MathRun("2"), + children: [new MathRun("e")], + superScript: [new MathRun("2")], }); const tree = new Formatter().format(mathSuperScript); diff --git a/src/file/paragraph/math/script/super-script/math-super-script-function.ts b/src/file/paragraph/math/script/super-script/math-super-script-function.ts index d48ece6985..eeffdf124a 100644 --- a/src/file/paragraph/math/script/super-script/math-super-script-function.ts +++ b/src/file/paragraph/math/script/super-script/math-super-script-function.ts @@ -6,8 +6,8 @@ import { MathBase, MathSuperScriptElement } from "../../n-ary"; import { MathSuperScriptProperties } from "./math-super-script-function-properties"; export interface IMathSuperScriptOptions { - readonly child: MathComponent; - readonly superScript: MathComponent; + readonly children: MathComponent[]; + readonly superScript: MathComponent[]; } export class MathSuperScript extends XmlComponent { @@ -15,7 +15,7 @@ export class MathSuperScript extends XmlComponent { super("m:sSup"); this.root.push(new MathSuperScriptProperties()); - this.root.push(new MathBase(options.child)); + this.root.push(new MathBase(options.children)); this.root.push(new MathSuperScriptElement(options.superScript)); } }