More math components
This commit is contained in:
@ -0,0 +1,2 @@
|
||||
export * from "./math-pre-sub-super-script-function";
|
||||
export * from "./math-pre-sub-super-script-function-properties";
|
@ -0,0 +1,17 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties";
|
||||
|
||||
describe("MathPreSubSuperScriptProperties", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should create a MathPreSubSuperScriptProperties with correct root key", () => {
|
||||
const mathPreSubSuperScriptProperties = new MathPreSubSuperScriptProperties();
|
||||
|
||||
const tree = new Formatter().format(mathPreSubSuperScriptProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"m:sPrePr": {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
// http://www.datypic.com/sc/ooxml/e-m_sPrePr-1.html
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class MathPreSubSuperScriptProperties extends XmlComponent {
|
||||
constructor() {
|
||||
super("m:sPrePr");
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { MathRun } from "../../math-run";
|
||||
import { MathPreSubSuperScript } from "./math-pre-sub-super-script-function";
|
||||
|
||||
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"),
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(mathPreSubScript);
|
||||
expect(tree).to.deep.equal({
|
||||
"m:sPre": [
|
||||
{
|
||||
"m:sPrePr": {},
|
||||
},
|
||||
{
|
||||
"m:e": [
|
||||
{
|
||||
"m:r": [
|
||||
{
|
||||
"m:t": ["e"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"m:sub": [
|
||||
{
|
||||
"m:r": [
|
||||
{
|
||||
"m:t": ["2"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"m:sup": [
|
||||
{
|
||||
"m:r": [
|
||||
{
|
||||
"m:t": ["5"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
// http://www.datypic.com/sc/ooxml/e-m_sPre-1.html
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
import { MathComponent } from "../../math-component";
|
||||
import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-ary";
|
||||
import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties";
|
||||
|
||||
export interface IMathPreSubSuperScriptOptions {
|
||||
readonly child: MathComponent;
|
||||
readonly subScript: MathComponent;
|
||||
readonly superScript: MathComponent;
|
||||
}
|
||||
|
||||
export class MathPreSubSuperScript extends XmlComponent {
|
||||
constructor(options: IMathPreSubSuperScriptOptions) {
|
||||
super("m:sPre");
|
||||
|
||||
this.root.push(new MathPreSubSuperScriptProperties());
|
||||
this.root.push(new MathBase(options.child));
|
||||
this.root.push(new MathSubScriptElement(options.subScript));
|
||||
this.root.push(new MathSuperScriptElement(options.superScript));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user