Compare commits
89 Commits
Author | SHA1 | Date | |
---|---|---|---|
82bdb301f9 | |||
c7ea26e422 | |||
34b2029efe | |||
37e610d2b3 | |||
4882235d20 | |||
1552ebde11 | |||
d263d0c8a5 | |||
610b2388bb | |||
bcb16cef9b | |||
0f3afd94f3 | |||
60eb686d05 | |||
7f5e43fba9 | |||
ed52ef358b | |||
214afab711 | |||
18a1677588 | |||
cae372e9ad | |||
ea5f9a48ab | |||
dcf755e756 | |||
d445c21ea1 | |||
6db0449ed0 | |||
ae37b1980f | |||
96f76906c4 | |||
19d9619785 | |||
5be195fd91 | |||
e36e9e1cf4 | |||
102d6aa55c | |||
daea8d2868 | |||
700a74fd4c | |||
32a84a5ad0 | |||
3c9f9474ce | |||
1e10686315 | |||
cae6405d9a | |||
a884ce94e5 | |||
065c17de74 | |||
09db2c528a | |||
2adfe532dd | |||
6cbe40cecb | |||
6b9467393e | |||
5125e77431 | |||
ab68ae0092 | |||
38079b6171 | |||
d584290f3d | |||
9b9baa9b4a | |||
c258310560 | |||
af0bf5ced5 | |||
57c480a6c6 | |||
25f7423533 | |||
0c068bb03b | |||
1822473abc | |||
93a7d607b2 | |||
d45213636c | |||
e196d9d917 | |||
cf88e50afd | |||
64e5814c31 | |||
37251c84f8 | |||
a576098639 | |||
2450fe83ce | |||
e1004440d2 | |||
491c7abd1c | |||
364ce6d856 | |||
ffb6b73bb7 | |||
6041c39a26 | |||
c54f0a52f6 | |||
6b87d9c038 | |||
1285304f97 | |||
58fae6b201 | |||
dc1f3aebe9 | |||
8a189161f2 | |||
6667595627 | |||
33befaab09 | |||
c91f135c28 | |||
08f9926e60 | |||
f323b293fb | |||
adc91929b0 | |||
c63cba5a0c | |||
7a48da440b | |||
05dda37b71 | |||
ee43585210 | |||
a6eb8e01df | |||
8c45c30753 | |||
d18cfbc26f | |||
f4af5f9e33 | |||
69adbbc1c1 | |||
4f6a9f734c | |||
8b78f2d200 | |||
f955a18936 | |||
9aab68a8f8 | |||
4f8d435e16 | |||
a1b9be453b |
@ -1,6 +1,6 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- 9
|
- 10
|
||||||
install:
|
install:
|
||||||
- npm install
|
- npm install
|
||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
|
@ -67,7 +67,7 @@ Please refer to the [documentation at https://docx.js.org/](https://docx.js.org/
|
|||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
Check the `examples` section in the [documentation](https://docx.js.org/#/examples) and the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
Check the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
|
||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
|
@ -28,6 +28,18 @@ doc.addSection({
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
shading: {
|
||||||
|
type: ShadingType.DIAGONAL_CROSS,
|
||||||
|
color: "00FFFF",
|
||||||
|
fill: "FF0000",
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
new TextRun({
|
||||||
|
text: "Hello World for entire paragraph",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
145
demo/54-track-revisions.ts
Normal file
145
demo/54-track-revisions.ts
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
// Track Revisions aka. "Track Changes"
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
AlignmentType,
|
||||||
|
DeletedTextRun,
|
||||||
|
Document,
|
||||||
|
Footer,
|
||||||
|
FootnoteReferenceRun,
|
||||||
|
InsertedTextRun,
|
||||||
|
Packer,
|
||||||
|
PageNumber,
|
||||||
|
Paragraph,
|
||||||
|
ShadingType,
|
||||||
|
TextRun,
|
||||||
|
} from "../build";
|
||||||
|
|
||||||
|
/*
|
||||||
|
For reference, see
|
||||||
|
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.insertedrun
|
||||||
|
- https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.deletedrun
|
||||||
|
|
||||||
|
The method `addTrackRevisions()` adds an element `<w:trackRevisions />` to the `settings.xml` file. This specifies that the application shall track *new* revisions made to the existing document.
|
||||||
|
See also https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.trackrevisions
|
||||||
|
|
||||||
|
Note that this setting enables to track *new changes* after teh file is generated, so this example will still show inserted and deleted text runs when you remove it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
footnotes: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("This is a footnote"),
|
||||||
|
new DeletedTextRun({
|
||||||
|
text: " with some extra text which was deleted",
|
||||||
|
id: 0,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
}),
|
||||||
|
new InsertedTextRun({
|
||||||
|
text: " and new content",
|
||||||
|
id: 1,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
features: {
|
||||||
|
trackRevisions: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("This is a simple demo "),
|
||||||
|
new TextRun({
|
||||||
|
text: "on how to ",
|
||||||
|
}),
|
||||||
|
new InsertedTextRun({
|
||||||
|
text: "mark a text as an insertion ",
|
||||||
|
id: 0,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
}),
|
||||||
|
new DeletedTextRun({
|
||||||
|
text: "or a deletion.",
|
||||||
|
id: 1,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
doc.addSection({
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
paragraph,
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("This is a demo "),
|
||||||
|
new DeletedTextRun({
|
||||||
|
text: "in order",
|
||||||
|
color: "red",
|
||||||
|
bold: true,
|
||||||
|
size: 24,
|
||||||
|
font: {
|
||||||
|
name: "Garamond",
|
||||||
|
},
|
||||||
|
shading: {
|
||||||
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
|
color: "00FFFF",
|
||||||
|
fill: "FF0000",
|
||||||
|
},
|
||||||
|
id: 2,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
}).break(),
|
||||||
|
new InsertedTextRun({
|
||||||
|
text: "to show how to ",
|
||||||
|
bold: false,
|
||||||
|
id: 3,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
bold: true,
|
||||||
|
children: ["\tuse Inserted and Deleted TextRuns.", new FootnoteReferenceRun(1)],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
footers: {
|
||||||
|
default: new Footer({
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
alignment: AlignmentType.CENTER,
|
||||||
|
children: [
|
||||||
|
new TextRun("Awesome LLC"),
|
||||||
|
new TextRun({
|
||||||
|
children: ["Page Number: ", PageNumber.CURRENT],
|
||||||
|
}),
|
||||||
|
new DeletedTextRun({
|
||||||
|
children: [" to ", PageNumber.TOTAL_PAGES],
|
||||||
|
id: 4,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
}),
|
||||||
|
new InsertedTextRun({
|
||||||
|
children: [" from ", PageNumber.TOTAL_PAGES],
|
||||||
|
bold: true,
|
||||||
|
id: 5,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:05:00Z",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
294
demo/55-math.ts
Normal file
294
demo/55-math.ts
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
// Simple example to add text to a document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
|
import * as fs from "fs";
|
||||||
|
import {
|
||||||
|
Document,
|
||||||
|
Math,
|
||||||
|
MathAngledBrackets,
|
||||||
|
MathCurlyBrackets,
|
||||||
|
MathFraction,
|
||||||
|
MathFunction,
|
||||||
|
MathPreSubSuperScript,
|
||||||
|
MathRadical,
|
||||||
|
MathRoundBrackets,
|
||||||
|
MathRun,
|
||||||
|
MathSquareBrackets,
|
||||||
|
MathSubScript,
|
||||||
|
MathSubSuperScript,
|
||||||
|
MathSum,
|
||||||
|
MathSuperScript,
|
||||||
|
Packer,
|
||||||
|
Paragraph,
|
||||||
|
TextRun,
|
||||||
|
} from "../build";
|
||||||
|
|
||||||
|
const doc = new Document();
|
||||||
|
|
||||||
|
doc.addSection({
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathRun("2+2"),
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("hi")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
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({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
}),
|
||||||
|
new MathSum({
|
||||||
|
children: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("e")],
|
||||||
|
superScript: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
subScript: [new MathRun("i")],
|
||||||
|
}),
|
||||||
|
new MathSum({
|
||||||
|
children: [
|
||||||
|
new MathRadical({
|
||||||
|
children: [new MathRun("i")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
subScript: [new MathRun("i")],
|
||||||
|
superScript: [new MathRun("10")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
superScript: [new MathRun("hello")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathSubScript({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
subScript: [new MathRun("hello")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathSubScript({
|
||||||
|
children: [new MathRun("x")],
|
||||||
|
subScript: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("y")],
|
||||||
|
superScript: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathSubSuperScript({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
superScript: [new MathRun("hello")],
|
||||||
|
subScript: [new MathRun("world")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathPreSubSuperScript({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
superScript: [new MathRun("hello")],
|
||||||
|
subScript: [new MathRun("world")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathSubScript({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
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")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathRadical({
|
||||||
|
children: [new MathRun("4")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathFunction({
|
||||||
|
name: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("cos")],
|
||||||
|
superScript: [new MathRun("-1")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
children: [new MathRun("100")],
|
||||||
|
}),
|
||||||
|
new MathRun("×"),
|
||||||
|
new MathFunction({
|
||||||
|
name: [new MathRun("sin")],
|
||||||
|
children: [new MathRun("360")],
|
||||||
|
}),
|
||||||
|
new MathRun("= x"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathRoundBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new MathSquareBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new MathCurlyBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new MathAngledBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [
|
||||||
|
new MathRadical({
|
||||||
|
children: [new MathRun("4")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
denominator: [new MathRun("2a")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
33
demo/56-background-color.ts
Normal file
33
demo/56-background-color.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Change background colour of whole document
|
||||||
|
// Import from 'docx' rather than '../build' if you install from npm
|
||||||
|
import * as fs from "fs";
|
||||||
|
import { Document, Packer, Paragraph, TextRun } from "../build";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
background: {
|
||||||
|
color: "C45911",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
doc.addSection({
|
||||||
|
properties: {},
|
||||||
|
children: [
|
||||||
|
new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("Hello World"),
|
||||||
|
new TextRun({
|
||||||
|
text: "Foo Bar",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
new TextRun({
|
||||||
|
text: "\tGithub is the best",
|
||||||
|
bold: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
Packer.toBuffer(doc).then((buffer) => {
|
||||||
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
|
});
|
@ -53,11 +53,11 @@ Packer.toBuffer(doc).then((buffer) => {
|
|||||||
fs.writeFileSync("My Document.docx", buffer);
|
fs.writeFileSync("My Document.docx", buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Done! A file called 'My First Document.docx' will be in your file system.
|
// Done! A file called 'My Document.docx' will be in your file system.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="clippy the assistant" src="http://i60.tinypic.com/339pvtt.png">
|
<img alt="clippy the assistant" src="./clippy.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
* [Tab Stops](usage/tab-stops.md)
|
* [Tab Stops](usage/tab-stops.md)
|
||||||
* [Table of Contents](usage/table-of-contents.md)
|
* [Table of Contents](usage/table-of-contents.md)
|
||||||
* [Page Numbers](usage/page-numbers.md)
|
* [Page Numbers](usage/page-numbers.md)
|
||||||
|
* [Change Tracking](usage/change-tracking.md)
|
||||||
|
* [Math](usage/math.md)
|
||||||
* Styling
|
* Styling
|
||||||
* [Styling with JS](usage/styling-with-js.md)
|
* [Styling with JS](usage/styling-with-js.md)
|
||||||
* [Styling with XML](usage/styling-with-xml.md)
|
* [Styling with XML](usage/styling-with-xml.md)
|
||||||
@ -28,4 +30,3 @@
|
|||||||
* [Packers](usage/packers.md)
|
* [Packers](usage/packers.md)
|
||||||
|
|
||||||
* [Contribution Guidelines](contribution-guidelines.md)
|
* [Contribution Guidelines](contribution-guidelines.md)
|
||||||
|
|
||||||
|
BIN
docs/clippy.png
Normal file
BIN
docs/clippy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
BIN
docs/clippy.psd
Normal file
BIN
docs/clippy.psd
Normal file
Binary file not shown.
BIN
docs/images/math-example.png
Normal file
BIN
docs/images/math-example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
61
docs/usage/change-tracking.md
Normal file
61
docs/usage/change-tracking.md
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Change Tracking
|
||||||
|
|
||||||
|
> Instead of adding a `TextRun` into a `Paragraph`, you can also add an `InsertedTextRun` or `DeletedTextRun` where you need to supply an `id`, `author` and `date` for the change.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Paragraph, TextRun, InsertedTextRun, DeletedTextRun } from "docx";
|
||||||
|
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("This is a simple demo "),
|
||||||
|
new TextRun({
|
||||||
|
text: "on how to "
|
||||||
|
}),
|
||||||
|
new InsertedTextRun({
|
||||||
|
text: "mark a text as an insertion ",
|
||||||
|
id: 0,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
}),
|
||||||
|
new DeletedTextRun({
|
||||||
|
text: "or a deletion.",
|
||||||
|
id: 1,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
})
|
||||||
|
],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that for a `InsertedTextRun` and `DeletedTextRun`, it is not possible to simply call it with only a text as in `new TextRun("some text")`, since the additonal fields for change tracking need to be provided. Similar to a normal `TextRun` you can add additional text properties.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Paragraph, TextRun, InsertedTextRun, DeletedTextRun } from "docx";
|
||||||
|
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
children: [
|
||||||
|
new TextRun("This is a simple demo"),
|
||||||
|
new DeletedTextRun({
|
||||||
|
text: "with a deletion.",
|
||||||
|
color: "red",
|
||||||
|
bold: true,
|
||||||
|
size: 24,
|
||||||
|
id: 0,
|
||||||
|
author: "Firstname Lastname",
|
||||||
|
date: "2020-10-06T09:00:00Z",
|
||||||
|
})
|
||||||
|
],
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
In addtion to marking text as inserted or deleted, change tracking can also be added via the document settings. This will enable new changes to be tracked as well.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { Document } from "docx";
|
||||||
|
|
||||||
|
const doc = new Document({
|
||||||
|
features: {
|
||||||
|
trackRevisions: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
@ -30,6 +30,24 @@ const doc = new docx.Document({
|
|||||||
* keywords
|
* keywords
|
||||||
* lastModifiedBy
|
* lastModifiedBy
|
||||||
* revision
|
* revision
|
||||||
|
* externalStyles
|
||||||
|
* styles
|
||||||
|
* numbering
|
||||||
|
* footnotes
|
||||||
|
* hyperlinks
|
||||||
|
* background
|
||||||
|
|
||||||
|
### Change background color of Document
|
||||||
|
|
||||||
|
Set the hex value in the document like so:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const doc = new docx.Document({
|
||||||
|
background: {
|
||||||
|
color: "C45911",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
You can mix and match whatever properties you want, or provide no properties.
|
You can mix and match whatever properties you want, or provide no properties.
|
||||||
|
|
||||||
|
265
docs/usage/math.md
Normal file
265
docs/usage/math.md
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
# Math
|
||||||
|
|
||||||
|
!> Math requires an understanding of [Sections](usage/sections.md) and [Paragraphs](usage/paragraph.md).
|
||||||
|
|
||||||
|
## Intro
|
||||||
|
|
||||||
|
1. To add math, create a `Math` object
|
||||||
|
2. Add `MathComponents` inside `Math`
|
||||||
|
3. `MathComponents` can have nested `MathComponents` inside. e.g. A fraction where the numerator is a square root, and the demoninator as another fraction. More on `MathComponents` below
|
||||||
|
4. Make sure to add the `Math` object inside a `Paragraph`
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathRun("2+2"),
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("hi")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
This will produce:
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img alt="clippy the assistant" src="images/math-example.png" width="200">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Math Components
|
||||||
|
|
||||||
|
`MathComponents` are the unit sized building blocks of an equation in `docx`. A `MathComponent` takes in more nested `MathComponents` until you reach `MathRun`, which has no children. `MathRun` is similar to a [TextRun](usage/text.md).
|
||||||
|
|
||||||
|
### Math Run
|
||||||
|
|
||||||
|
`MathRun` is the most basic `MathComponent`.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathRun("2+2");
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathRun("hello");
|
||||||
|
```
|
||||||
|
|
||||||
|
An example of it being used inside `Math`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathRun("2"),
|
||||||
|
new MathRun("+"),
|
||||||
|
new MathRun("2"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Math Fraction
|
||||||
|
|
||||||
|
`MathFractions` require a `numerator` and a `demoninator`, which are both a list of `MathComponents`
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [
|
||||||
|
new MathRun("1"),
|
||||||
|
new MathRadical({
|
||||||
|
children: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
An example of it being used inside `Math`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new Math({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
new MathText("+"),
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
new MathText("= 1"),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sum
|
||||||
|
|
||||||
|
A `MathComponent` for `Σ`. It can take a `superScript` and/or `subScript` as arguments to add `MathComponents` (usually limits) on the top and bottom
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSum({
|
||||||
|
children: [new MathRun("i")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSum({
|
||||||
|
children: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("e")],
|
||||||
|
superScript: [new MathRun("2")],
|
||||||
|
})
|
||||||
|
],
|
||||||
|
subScript: [new MathRun("i")],
|
||||||
|
superScript: [new MathRun("10")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Radicals
|
||||||
|
|
||||||
|
A `MathComponent` for the `√` symbol. Examples include, square root, cube root etc. There is an optional `degree` parameter to specify the number of times the radicand is multiplied by itself. For example, `3` for cube root.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathRadical({
|
||||||
|
children: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
Cube root example:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathRadical({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
new MathRun('+ 1'),
|
||||||
|
],
|
||||||
|
degree: [new MathRun("3")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Super Script
|
||||||
|
|
||||||
|
`MathSuperScripts` are the little numbers written to the top right of numbers or variables. It means the exponent or power if written by itself with the number or variable.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("x")],
|
||||||
|
superScript: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
An example with cosine:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("cos")],
|
||||||
|
superScript: [new MathRun("-1")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sub Script
|
||||||
|
|
||||||
|
`MathSubScripts` are similar to `MathSuperScripts`, except the little number is written below.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSubScript({
|
||||||
|
children: [new MathRun("F")],
|
||||||
|
subScript: [new MathRun("n-1")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sub-Super Script
|
||||||
|
|
||||||
|
`MathSubSuperScripts` are a combination of both `MathSuperScript` and `MathSubScript`.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSubSuperScript({
|
||||||
|
children: [new MathRun("test")],
|
||||||
|
superScript: [new MathRun("hello")],
|
||||||
|
subScript: [new MathRun("world")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Function
|
||||||
|
|
||||||
|
`MathFunctions` are a way of describing what happens to an input variable, in order to get the output result. It takes a `name` parameter to specify the name of the function.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathFunction({
|
||||||
|
name: [
|
||||||
|
new MathSuperScript({
|
||||||
|
children: [new MathRun("cos")],
|
||||||
|
superScript: [new MathRun("-1")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
children: [new MathRun("100")],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
### Brackets
|
||||||
|
|
||||||
|
#### Square brackets
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathSquareBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Round brackets
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathRoundBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Curly brackets
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathCurlyBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Angled brackets
|
||||||
|
|
||||||
|
```ts
|
||||||
|
new MathAngledBrackets({
|
||||||
|
children: [
|
||||||
|
new MathFraction({
|
||||||
|
numerator: [new MathRun("1")],
|
||||||
|
denominator: [new MathRun("2")],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
```
|
@ -142,6 +142,21 @@ const paragraph = new Paragraph({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Shading
|
||||||
|
|
||||||
|
Add color to an entire paragraph block
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const paragraph = new Paragraph({
|
||||||
|
text: "shading",
|
||||||
|
shading: {
|
||||||
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
|
color: "00FFFF",
|
||||||
|
fill: "FF0000",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Spacing
|
## Spacing
|
||||||
|
|
||||||
Adding spacing between paragraphs
|
Adding spacing between paragraphs
|
||||||
|
@ -51,19 +51,6 @@ const table = new Table({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pagination
|
|
||||||
|
|
||||||
#### Prevent row pagination
|
|
||||||
|
|
||||||
To prevent breaking contents of a row across multiple pages, call `cantSplit`:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const table = new Table({
|
|
||||||
rows: [],
|
|
||||||
cantSplit: true,
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Table Row
|
## Table Row
|
||||||
|
|
||||||
A table consists of multiple `table rows`. Table rows have a list of `children` which accepts a list of `table cells` explained below. You can create a simple `table row` like so:
|
A table consists of multiple `table rows`. Table rows have a list of `children` which accepts a list of `table cells` explained below. You can create a simple `table row` like so:
|
||||||
@ -103,7 +90,7 @@ Here is a list of options you can add to the `table row`:
|
|||||||
| children | `Array<TableCell>` | Required |
|
| children | `Array<TableCell>` | Required |
|
||||||
| cantSplit | `boolean` | Optional |
|
| cantSplit | `boolean` | Optional |
|
||||||
| tableHeader | `boolean` | Optional |
|
| tableHeader | `boolean` | Optional |
|
||||||
| height | `{ value: number, rule: HeightRule }` | Optional |
|
| height | `{ height: number, rule: HeightRule }` | Optional |
|
||||||
|
|
||||||
### Repeat row
|
### Repeat row
|
||||||
|
|
||||||
@ -116,6 +103,19 @@ const row = new TableRow({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Pagination
|
||||||
|
|
||||||
|
#### Prevent row pagination
|
||||||
|
|
||||||
|
To prevent breaking contents of a row across multiple pages, call `cantSplit`:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const row = new Row({
|
||||||
|
...,
|
||||||
|
cantSplit: true,
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Table Cells
|
## Table Cells
|
||||||
|
|
||||||
Cells need to be added in the `table row`, you can create a table cell like:
|
Cells need to be added in the `table row`, you can create a table cell like:
|
||||||
|
@ -77,40 +77,78 @@ const text = new TextRun({
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Shading and Highlighting
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const text = new TextRun({
|
||||||
|
text: "shading",
|
||||||
|
shading: {
|
||||||
|
type: ShadingType.REVERSE_DIAGONAL_STRIPE,
|
||||||
|
color: "00FFFF",
|
||||||
|
fill: "FF0000",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const text = new TextRun({
|
||||||
|
text: "highlighting",
|
||||||
|
highlight: "yellow",
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Strike through
|
### Strike through
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.strike();
|
const text = new TextRun({
|
||||||
|
text: "strike",
|
||||||
|
strike: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Double strike through
|
### Double strike through
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.doubleStrike();
|
const text = new TextRun({
|
||||||
|
text: "doubleStrike",
|
||||||
|
doubleStrike: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Superscript
|
### Superscript
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.superScript();
|
const text = new TextRun({
|
||||||
|
text: "superScript",
|
||||||
|
superScript: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Subscript
|
### Subscript
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.subScript();
|
const text = new TextRun({
|
||||||
|
text: "subScript",
|
||||||
|
subScript: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### All Capitals
|
### All Capitals
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.allCaps();
|
const text = new TextRun({
|
||||||
|
text: "allCaps",
|
||||||
|
allCaps: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
### Small Capitals
|
### Small Capitals
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.smallCaps();
|
const text = new TextRun({
|
||||||
|
text: "smallCaps",
|
||||||
|
smallCaps: true,
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## Break
|
## Break
|
||||||
@ -118,13 +156,8 @@ text.smallCaps();
|
|||||||
Sometimes you would want to put text underneath another line of text but inside the same paragraph.
|
Sometimes you would want to put text underneath another line of text but inside the same paragraph.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
text.break();
|
const text = new TextRun({
|
||||||
```
|
text: "break",
|
||||||
|
break: true,
|
||||||
## Chaining
|
});
|
||||||
|
|
||||||
What if you want to create a paragraph which is **_bold_** and **_italic_**?
|
|
||||||
|
|
||||||
```ts
|
|
||||||
paragraph.bold().italics();
|
|
||||||
```
|
```
|
||||||
|
209
package-lock.json
generated
209
package-lock.json
generated
@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.2.2",
|
"version": "5.3.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": {
|
"@babel/code-frame": {
|
||||||
"version": "7.0.0",
|
"version": "7.10.4",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
|
||||||
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
|
"integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/highlight": "^7.0.0"
|
"@babel/highlight": "^7.10.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/core": {
|
"@babel/core": {
|
||||||
@ -246,13 +246,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@babel/highlight": {
|
"@babel/highlight": {
|
||||||
"version": "7.5.0",
|
"version": "7.10.4",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
|
||||||
"integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
|
"integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
"@babel/helper-validator-identifier": "^7.10.4",
|
||||||
"chalk": "^2.0.0",
|
"chalk": "^2.0.0",
|
||||||
"esutils": "^2.0.2",
|
|
||||||
"js-tokens": "^4.0.0"
|
"js-tokens": "^4.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -498,9 +498,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@sinonjs/samsam": {
|
"@sinonjs/samsam": {
|
||||||
"version": "5.0.3",
|
"version": "5.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-5.2.0.tgz",
|
||||||
"integrity": "sha512-QucHkc2uMJ0pFGjJUDP3F9dq5dx8QIaqISl9QgwLOh6P9yv877uONPGXh/OH/0zmM3tW1JjuJltAZV2l7zU+uQ==",
|
"integrity": "sha512-CaIcyX5cDsjcW/ab7HposFWzV1kC++4HNsfnEdFJa7cP1QIuILAKV+BgfeqRXhcnSAc76r/Rh/O5C+300BwUIw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@sinonjs/commons": "^1.6.0",
|
"@sinonjs/commons": "^1.6.0",
|
||||||
@ -576,15 +576,15 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/mocha": {
|
"@types/mocha": {
|
||||||
"version": "8.0.0",
|
"version": "8.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.0.3.tgz",
|
||||||
"integrity": "sha512-jWeYcTo3sCH/rMgsdYXDTO85GNRyTCII5dayMIu/ZO4zbEot1E3iNGaOwpLReLUHjeNQFkgeNNVYlY4dX6azQQ==",
|
"integrity": "sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "14.0.27",
|
"version": "14.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.2.tgz",
|
||||||
"integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g=="
|
"integrity": "sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A=="
|
||||||
},
|
},
|
||||||
"@types/request": {
|
"@types/request": {
|
||||||
"version": "2.48.5",
|
"version": "2.48.5",
|
||||||
@ -661,18 +661,18 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/uglify-js": {
|
"@types/uglify-js": {
|
||||||
"version": "3.9.3",
|
"version": "3.11.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.11.1.tgz",
|
||||||
"integrity": "sha512-KswB5C7Kwduwjj04Ykz+AjvPcfgv/37Za24O2EDzYNbwyzOo8+ydtvzUfZ5UMguiVu29Gx44l1A6VsPPcmYu9w==",
|
"integrity": "sha512-7npvPKV+jINLu1SpSYVWG8KvyJBhBa8tmzMMdDoVc2pWUYHN8KIXlPJhjJ4LT97c4dXJA2SHL/q6ADbDriZN+Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"source-map": "^0.6.1"
|
"source-map": "^0.6.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/webpack": {
|
"@types/webpack": {
|
||||||
"version": "4.41.21",
|
"version": "4.41.24",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.21.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.41.24.tgz",
|
||||||
"integrity": "sha512-2j9WVnNrr/8PLAB5csW44xzQSJwS26aOnICsP3pSGCEdsu6KYtfQ6QJsVUKHWRnm1bL7HziJsfh5fHqth87yKA==",
|
"integrity": "sha512-1A0MXPwZiMOD3DPMuOKUKcpkdPo8Lq33UGggZ7xio6wJ/jV1dAu5cXDrOfGDnldUroPIRLsr/DT43/GqOA4RFQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/anymatch": "*",
|
"@types/anymatch": "*",
|
||||||
@ -684,9 +684,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/webpack-sources": {
|
"@types/webpack-sources": {
|
||||||
"version": "1.4.2",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-1.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-2.0.0.tgz",
|
||||||
"integrity": "sha512-77T++JyKow4BQB/m9O96n9d/UUHWLQHlcqXb9Vsf4F1+wKNrrlWNFPDLKNT92RJnCSL6CieTc+NDXtCVZswdTw==",
|
"integrity": "sha512-a5kPx98CNFRKQ+wqawroFunvFqv7GHm/3KOI52NY9xWADgc8smu4R6prt4EU/M4QfVjvgBkMqU4fBhw3QfMVkg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
@ -1088,7 +1088,7 @@
|
|||||||
},
|
},
|
||||||
"awesome-typescript-loader": {
|
"awesome-typescript-loader": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "http://registry.npmjs.org/awesome-typescript-loader/-/awesome-typescript-loader-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/awesome-typescript-loader/-/awesome-typescript-loader-3.5.0.tgz",
|
||||||
"integrity": "sha512-qzgm9SEvodVkSi9QY7Me1/rujg+YBNMjayNSAyzNghwTEez++gXoPCwMvpbHRG7wrOkDCiF6dquvv9ESmUBAuw==",
|
"integrity": "sha512-qzgm9SEvodVkSi9QY7Me1/rujg+YBNMjayNSAyzNghwTEez++gXoPCwMvpbHRG7wrOkDCiF6dquvv9ESmUBAuw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -1665,7 +1665,7 @@
|
|||||||
},
|
},
|
||||||
"chai": {
|
"chai": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.0",
|
||||||
"resolved": "http://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz",
|
||||||
"integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=",
|
"integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -2153,7 +2153,7 @@
|
|||||||
},
|
},
|
||||||
"deep-eql": {
|
"deep-eql": {
|
||||||
"version": "0.1.3",
|
"version": "0.1.3",
|
||||||
"resolved": "http://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
||||||
"integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=",
|
"integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -2531,9 +2531,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"dot-prop": {
|
"dot-prop": {
|
||||||
"version": "4.2.0",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.1.tgz",
|
||||||
"integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==",
|
"integrity": "sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"is-obj": "^1.0.0"
|
"is-obj": "^1.0.0"
|
||||||
@ -4373,7 +4373,7 @@
|
|||||||
"is-buffer": {
|
"is-buffer": {
|
||||||
"version": "1.1.6",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"is-ci": {
|
"is-ci": {
|
||||||
@ -4919,9 +4919,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"just-extend": {
|
"just-extend": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.1.1.tgz",
|
||||||
"integrity": "sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==",
|
"integrity": "sha512-aWgeGFW67BP3e5181Ep1Fv2v8z//iBJfrvyTnq8wG86vEESwmonn1zPBJ0VfmT9CJq2FIT0VsETtrNFm2a+SHA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"keyv": {
|
"keyv": {
|
||||||
@ -5395,7 +5395,7 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
@ -5560,9 +5560,9 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"nanoid": {
|
"nanoid": {
|
||||||
"version": "2.1.6",
|
"version": "2.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
|
||||||
"integrity": "sha512-2NDzpiuEy3+H0AVtdt8LoFi7PnqkOnIzYmJQp7xsEU6VexLluHQwKREuiz57XaQC5006seIadPrIZJhyS2n7aw=="
|
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
|
||||||
},
|
},
|
||||||
"nanomatch": {
|
"nanomatch": {
|
||||||
"version": "1.2.13",
|
"version": "1.2.13",
|
||||||
@ -5585,7 +5585,7 @@
|
|||||||
},
|
},
|
||||||
"ncp": {
|
"ncp": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "http://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ncp/-/ncp-1.0.1.tgz",
|
||||||
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=",
|
"integrity": "sha1-0VNn5cuHQyuhF9K/gP30Wuz7QkY=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -5603,7 +5603,7 @@
|
|||||||
},
|
},
|
||||||
"next-tick": {
|
"next-tick": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
||||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -5627,9 +5627,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-fetch": {
|
"node-fetch": {
|
||||||
"version": "2.6.0",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||||
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==",
|
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node-libs-browser": {
|
"node-libs-browser": {
|
||||||
@ -6492,15 +6492,15 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"version": "1.18.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz",
|
||||||
"integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==",
|
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"prismjs": {
|
"prismjs": {
|
||||||
"version": "1.20.0",
|
"version": "1.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.21.0.tgz",
|
||||||
"integrity": "sha512-AEDjSrVNkynnw6A+B1DsFkd6AVdTnp+/WoUixFRULlCLZVRZlVQMVWio/16jv7G1FscUxQxOQhWwApgbnxr6kQ==",
|
"integrity": "sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"clipboard": "^2.0.0"
|
"clipboard": "^2.0.0"
|
||||||
@ -7091,9 +7091,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rimraf": {
|
"rimraf": {
|
||||||
"version": "2.6.3",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||||
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
|
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"glob": "^7.1.3"
|
"glob": "^7.1.3"
|
||||||
@ -7116,7 +7116,7 @@
|
|||||||
},
|
},
|
||||||
"safe-regex": {
|
"safe-regex": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
|
||||||
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
|
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
@ -7289,9 +7289,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"shortid": {
|
"shortid": {
|
||||||
"version": "2.2.15",
|
"version": "2.2.16",
|
||||||
"resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.15.tgz",
|
"resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.16.tgz",
|
||||||
"integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==",
|
"integrity": "sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"nanoid": "^2.1.0"
|
"nanoid": "^2.1.0"
|
||||||
}
|
}
|
||||||
@ -7303,17 +7303,17 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"sinon": {
|
"sinon": {
|
||||||
"version": "9.0.2",
|
"version": "9.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/sinon/-/sinon-9.2.1.tgz",
|
||||||
"integrity": "sha512-0uF8Q/QHkizNUmbK3LRFqx5cpTttEVXudywY9Uwzy8bTfZUhljZ7ARzSxnRHWYWtVTeh4Cw+tTb3iU21FQVO9A==",
|
"integrity": "sha512-naPfsamB5KEE1aiioaoqJ6MEhdUs/2vtI5w1hPAXX/UwvoPjXcwh1m5HiKx0HGgKR8lQSoFIgY5jM6KK8VrS9w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@sinonjs/commons": "^1.7.2",
|
"@sinonjs/commons": "^1.8.1",
|
||||||
"@sinonjs/fake-timers": "^6.0.1",
|
"@sinonjs/fake-timers": "^6.0.1",
|
||||||
"@sinonjs/formatio": "^5.0.1",
|
"@sinonjs/formatio": "^5.0.1",
|
||||||
"@sinonjs/samsam": "^5.0.3",
|
"@sinonjs/samsam": "^5.2.0",
|
||||||
"diff": "^4.0.2",
|
"diff": "^4.0.2",
|
||||||
"nise": "^4.0.1",
|
"nise": "^4.0.4",
|
||||||
"supports-color": "^7.1.0"
|
"supports-color": "^7.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -7330,9 +7330,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"supports-color": {
|
"supports-color": {
|
||||||
"version": "7.1.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
"integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
|
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"has-flag": "^4.0.0"
|
"has-flag": "^4.0.0"
|
||||||
@ -7719,7 +7719,7 @@
|
|||||||
},
|
},
|
||||||
"strip-eof": {
|
"strip-eof": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||||
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
|
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
@ -7915,9 +7915,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"version": "8.10.2",
|
"version": "9.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz",
|
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz",
|
||||||
"integrity": "sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==",
|
"integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"arg": "^4.1.0",
|
"arg": "^4.1.0",
|
||||||
@ -7946,37 +7946,63 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslib": {
|
"tslib": {
|
||||||
"version": "1.10.0",
|
"version": "1.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
|
||||||
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
|
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"tslint": {
|
"tslint": {
|
||||||
"version": "5.18.0",
|
"version": "6.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.18.0.tgz",
|
"resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz",
|
||||||
"integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==",
|
"integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.0.0",
|
"@babel/code-frame": "^7.0.0",
|
||||||
"builtin-modules": "^1.1.1",
|
"builtin-modules": "^1.1.1",
|
||||||
"chalk": "^2.3.0",
|
"chalk": "^2.3.0",
|
||||||
"commander": "^2.12.1",
|
"commander": "^2.12.1",
|
||||||
"diff": "^3.2.0",
|
"diff": "^4.0.1",
|
||||||
"glob": "^7.1.1",
|
"glob": "^7.1.1",
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"minimatch": "^3.0.4",
|
"minimatch": "^3.0.4",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.3",
|
||||||
"resolve": "^1.3.2",
|
"resolve": "^1.3.2",
|
||||||
"semver": "^5.3.0",
|
"semver": "^5.3.0",
|
||||||
"tslib": "^1.8.0",
|
"tslib": "^1.13.0",
|
||||||
"tsutils": "^2.29.0"
|
"tsutils": "^2.29.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"diff": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"minimist": {
|
||||||
|
"version": "1.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
|
||||||
|
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"mkdirp": {
|
||||||
|
"version": "0.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||||
|
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"minimist": "^1.2.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslint-immutable": {
|
"tslint-immutable": {
|
||||||
"version": "4.9.1",
|
"version": "6.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/tslint-immutable/-/tslint-immutable-4.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/tslint-immutable/-/tslint-immutable-6.0.1.tgz",
|
||||||
"integrity": "sha512-iIFCq08H4YyNIX0bV5N6fGQtAmjc4OQZKQCgBP5WHgQaITyGAHPVmAw+Yf7qe0zbRCvCDZdrdEC/191fLGFiww==",
|
"integrity": "sha512-3GQ6HffN64gLmT/N1YzyVMqyf6uBjMvhNaevK8B0K01/QC0OU5AQZrH4TjMHo1IdG3JpqsZvuRy9IW1LA3zjwA==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"tsutils": "^2.28.0 || ^3.0.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"tsutils": {
|
"tsutils": {
|
||||||
"version": "2.29.0",
|
"version": "2.29.0",
|
||||||
@ -8394,6 +8420,17 @@
|
|||||||
"mkdirp": "0.x.x",
|
"mkdirp": "0.x.x",
|
||||||
"ncp": "1.0.x",
|
"ncp": "1.0.x",
|
||||||
"rimraf": "2.x.x"
|
"rimraf": "2.x.x"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||||
|
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"glob": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"utils-merge": {
|
"utils-merge": {
|
||||||
@ -8821,7 +8858,7 @@
|
|||||||
},
|
},
|
||||||
"winston": {
|
"winston": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "http://registry.npmjs.org/winston/-/winston-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/winston/-/winston-2.1.1.tgz",
|
||||||
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
|
"integrity": "sha1-PJNJ0ZYgf9G9/51LxD73JRDjoS4=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
14
package.json
14
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "5.2.2",
|
"version": "5.4.0",
|
||||||
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -79,22 +79,22 @@
|
|||||||
"mocha-webpack": "^1.0.1",
|
"mocha-webpack": "^1.0.1",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"prettier": "^1.15.2",
|
"prettier": "^2.1.2",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"replace-in-file": "^3.1.0",
|
"replace-in-file": "^3.1.0",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
"request-promise": "^4.2.2",
|
"request-promise": "^4.2.2",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^3.0.2",
|
||||||
"shelljs": "^0.8.4",
|
"shelljs": "^0.8.4",
|
||||||
"sinon": "^9.0.2",
|
"sinon": "^9.0.2",
|
||||||
"ts-node": "^8.10.2",
|
"ts-node": "^9.0.0",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-immutable": "^4.9.0",
|
"tslint-immutable": "^6.0.1",
|
||||||
"typedoc": "^0.16.11",
|
"typedoc": "^0.16.11",
|
||||||
"typescript": "2.9.2",
|
"typescript": "2.9.2",
|
||||||
"webpack": "^3.10.0"
|
"webpack": "^3.10.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ describe("Compiler", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#compile()", () => {
|
describe("#compile()", () => {
|
||||||
it("should pack all the content", async function() {
|
it("should pack all the content", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
const zipFile = compiler.compile(file);
|
const zipFile = compiler.compile(file);
|
||||||
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
|
const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name);
|
||||||
@ -35,7 +35,7 @@ describe("Compiler", () => {
|
|||||||
expect(fileNames).to.include("_rels/.rels");
|
expect(fileNames).to.include("_rels/.rels");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should pack all additional headers and footers", async function() {
|
it("should pack all additional headers and footers", async function () {
|
||||||
file.addSection({
|
file.addSection({
|
||||||
headers: {
|
headers: {
|
||||||
default: new Header(),
|
default: new Header(),
|
||||||
|
@ -36,7 +36,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#toBuffer()", () => {
|
describe("#toBuffer()", () => {
|
||||||
it("should create a standard docx file", async function() {
|
it("should create a standard docx file", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
const buffer = await Packer.toBuffer(file);
|
const buffer = await Packer.toBuffer(file);
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ describe("Packer", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("#toBase64String()", () => {
|
describe("#toBase64String()", () => {
|
||||||
it("should create a standard docx file", async function() {
|
it("should create a standard docx file", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
const str = await Packer.toBase64String(file);
|
const str = await Packer.toBase64String(file);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
import { IDocumentBackgroundOptions } from "../document";
|
||||||
|
|
||||||
import { DocumentAttributes } from "../document/document-attributes";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
import { INumberingOptions } from "../numbering";
|
import { INumberingOptions } from "../numbering";
|
||||||
@ -32,6 +33,10 @@ export interface IPropertiesOptions {
|
|||||||
readonly hyperlinks?: {
|
readonly hyperlinks?: {
|
||||||
readonly [key: string]: IInternalHyperlinkDefinition | IExternalHyperlinkDefinition;
|
readonly [key: string]: IInternalHyperlinkDefinition | IExternalHyperlinkDefinition;
|
||||||
};
|
};
|
||||||
|
readonly background?: IDocumentBackgroundOptions;
|
||||||
|
readonly features?: {
|
||||||
|
readonly trackRevisions?: boolean;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CoreProperties extends XmlComponent {
|
export class CoreProperties extends XmlComponent {
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { DocumentBackground } from "./document-background";
|
||||||
|
|
||||||
|
describe("DocumentBackground", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a DocumentBackground with no options and set color to auto", () => {
|
||||||
|
const documentBackground = new DocumentBackground({});
|
||||||
|
const tree = new Formatter().format(documentBackground);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:background": {
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FFFFFF",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create a DocumentBackground with no options and set color to value", () => {
|
||||||
|
const documentBackground = new DocumentBackground({ color: "ffff00" });
|
||||||
|
const tree = new Formatter().format(documentBackground);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:background": {
|
||||||
|
_attr: {
|
||||||
|
"w:color": "ffff00",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create a DocumentBackground with no options and set other values", () => {
|
||||||
|
const documentBackground = new DocumentBackground({
|
||||||
|
color: "ffff00",
|
||||||
|
themeColor: "test",
|
||||||
|
themeShade: "test",
|
||||||
|
themeTint: "test",
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(documentBackground);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:background": {
|
||||||
|
_attr: {
|
||||||
|
"w:color": "ffff00",
|
||||||
|
"w:themeColor": "test",
|
||||||
|
"w:themeShade": "test",
|
||||||
|
"w:themeTint": "test",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
39
src/file/document/document-background/document-background.ts
Normal file
39
src/file/document/document-background/document-background.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// http://officeopenxml.com/WPdocument.php
|
||||||
|
// http://www.datypic.com/sc/ooxml/e-w_background-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
export class DocumentBackgroundAttributes extends XmlAttributeComponent<{
|
||||||
|
readonly color: string;
|
||||||
|
readonly themeColor?: string;
|
||||||
|
readonly themeShade?: string;
|
||||||
|
readonly themeTint?: string;
|
||||||
|
}> {
|
||||||
|
protected readonly xmlKeys = {
|
||||||
|
color: "w:color",
|
||||||
|
themeColor: "w:themeColor",
|
||||||
|
themeShade: "w:themeShade",
|
||||||
|
themeTint: "w:themeTint",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDocumentBackgroundOptions {
|
||||||
|
readonly color?: string;
|
||||||
|
readonly themeColor?: string;
|
||||||
|
readonly themeShade?: string;
|
||||||
|
readonly themeTint?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DocumentBackground extends XmlComponent {
|
||||||
|
constructor(options: IDocumentBackgroundOptions) {
|
||||||
|
super("w:background");
|
||||||
|
|
||||||
|
this.root.push(
|
||||||
|
new DocumentBackgroundAttributes({
|
||||||
|
color: options.color ? options.color : "FFFFFF",
|
||||||
|
themeColor: options.themeColor,
|
||||||
|
themeShade: options.themeShade,
|
||||||
|
themeTint: options.themeTint,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
1
src/file/document/document-background/index.ts
Normal file
1
src/file/document/document-background/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./document-background";
|
@ -8,7 +8,7 @@ describe("Document", () => {
|
|||||||
let document: Document;
|
let document: Document;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
document = new Document();
|
document = new Document({ background: {} });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
@ -38,6 +38,13 @@ describe("Document", () => {
|
|||||||
"mc:Ignorable": "w14 w15 wp14",
|
"mc:Ignorable": "w14 w15 wp14",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"w:background": {
|
||||||
|
_attr: {
|
||||||
|
"w:color": "FFFFFF",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{ "w:body": {} },
|
{ "w:body": {} },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -5,11 +5,16 @@ import { Table } from "../table";
|
|||||||
import { TableOfContents } from "../table-of-contents";
|
import { TableOfContents } from "../table-of-contents";
|
||||||
import { Body } from "./body";
|
import { Body } from "./body";
|
||||||
import { DocumentAttributes } from "./document-attributes";
|
import { DocumentAttributes } from "./document-attributes";
|
||||||
|
import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background";
|
||||||
|
|
||||||
|
interface IDocumentOptions {
|
||||||
|
readonly background: IDocumentBackgroundOptions;
|
||||||
|
}
|
||||||
|
|
||||||
export class Document extends XmlComponent {
|
export class Document extends XmlComponent {
|
||||||
private readonly body: Body;
|
private readonly body: Body;
|
||||||
|
|
||||||
constructor() {
|
constructor(options: IDocumentOptions) {
|
||||||
super("w:document");
|
super("w:document");
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new DocumentAttributes({
|
new DocumentAttributes({
|
||||||
@ -33,6 +38,7 @@ export class Document extends XmlComponent {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
this.body = new Body();
|
this.body = new Body();
|
||||||
|
this.root.push(new DocumentBackground(options.background));
|
||||||
this.root.push(this.body);
|
this.root.push(this.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export * from "./document";
|
export * from "./document";
|
||||||
export * from "./document-attributes";
|
export * from "./document-attributes";
|
||||||
export * from "./body";
|
export * from "./body";
|
||||||
|
export * from "./document-background";
|
||||||
|
@ -12,7 +12,7 @@ export class Inline extends XmlComponent {
|
|||||||
private readonly extent: Extent;
|
private readonly extent: Extent;
|
||||||
private readonly graphic: Graphic;
|
private readonly graphic: Graphic;
|
||||||
|
|
||||||
constructor(readonly mediaData: IMediaData, private readonly dimensions: IMediaDataDimensions) {
|
constructor(mediaData: IMediaData, private readonly dimensions: IMediaDataDimensions) {
|
||||||
super("wp:inline");
|
super("wp:inline");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
|
@ -5,7 +5,7 @@ import { Formatter } from "export/formatter";
|
|||||||
|
|
||||||
import { File } from "./file";
|
import { File } from "./file";
|
||||||
import { Footer, Header } from "./header";
|
import { Footer, Header } from "./header";
|
||||||
import { HyperlinkRef, Paragraph } from "./paragraph";
|
import { HyperlinkRef, HyperlinkType, Paragraph } from "./paragraph";
|
||||||
import { Table, TableCell, TableRow } from "./table";
|
import { Table, TableCell, TableRow } from "./table";
|
||||||
import { TableOfContents } from "./table-of-contents";
|
import { TableOfContents } from "./table-of-contents";
|
||||||
|
|
||||||
@ -243,12 +243,40 @@ describe("File", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("#addTrackRevisionsFeature", () => {
|
||||||
|
it("should call the underlying document's add", () => {
|
||||||
|
const file = new File({
|
||||||
|
features: {
|
||||||
|
trackRevisions: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// tslint:disable-next-line: no-unused-expression no-string-literal
|
||||||
|
expect(file.Settings["trackRevisions"]).to.exist;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("#HyperlinkCache", () => {
|
describe("#HyperlinkCache", () => {
|
||||||
it("should initially have empty hyperlink cache", () => {
|
it("should initially have empty hyperlink cache", () => {
|
||||||
const file = new File();
|
const file = new File();
|
||||||
|
|
||||||
expect(file.HyperlinkCache).to.deep.equal({});
|
expect(file.HyperlinkCache).to.deep.equal({});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should have hyperlink cache when option is added", () => {
|
||||||
|
const file = new File({
|
||||||
|
hyperlinks: {
|
||||||
|
myCoolLink: {
|
||||||
|
link: "http://www.example.com",
|
||||||
|
text: "Hyperlink",
|
||||||
|
type: HyperlinkType.EXTERNAL,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// tslint:disable-next-line: no-unused-expression no-string-literal
|
||||||
|
expect(file.HyperlinkCache["myCoolLink"]).to.exist;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#createFootnote", () => {
|
describe("#createFootnote", () => {
|
||||||
|
@ -41,7 +41,7 @@ export interface ISectionOptions {
|
|||||||
readonly size?: IPageSizeAttributes;
|
readonly size?: IPageSizeAttributes;
|
||||||
readonly margins?: IPageMarginAttributes;
|
readonly margins?: IPageMarginAttributes;
|
||||||
readonly properties?: SectionPropertiesOptions;
|
readonly properties?: SectionPropertiesOptions;
|
||||||
readonly children: Array<Paragraph | Table | TableOfContents | HyperlinkRef>;
|
readonly children: (Paragraph | Table | TableOfContents | HyperlinkRef)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class File {
|
export class File {
|
||||||
@ -85,7 +85,7 @@ export class File {
|
|||||||
this.appProperties = new AppProperties();
|
this.appProperties = new AppProperties();
|
||||||
this.footNotes = new FootNotes();
|
this.footNotes = new FootNotes();
|
||||||
this.contentTypes = new ContentTypes();
|
this.contentTypes = new ContentTypes();
|
||||||
this.document = new Document();
|
this.document = new Document({ background: options.background || {} });
|
||||||
this.settings = new Settings();
|
this.settings = new Settings();
|
||||||
|
|
||||||
this.media = fileProperties.template && fileProperties.template.media ? fileProperties.template.media : new Media();
|
this.media = fileProperties.template && fileProperties.template.media ? fileProperties.template.media : new Media();
|
||||||
@ -170,6 +170,12 @@ export class File {
|
|||||||
|
|
||||||
this.hyperlinkCache = cache;
|
this.hyperlinkCache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.features) {
|
||||||
|
if (options.features.trackRevisions) {
|
||||||
|
this.settings.addTrackRevisions();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addSection({
|
public addSection({
|
||||||
|
@ -2,7 +2,7 @@ import { Paragraph } from "./paragraph";
|
|||||||
import { Table } from "./table";
|
import { Table } from "./table";
|
||||||
|
|
||||||
export interface IHeaderOptions {
|
export interface IHeaderOptions {
|
||||||
readonly children: Array<Paragraph | Table>;
|
readonly children: (Paragraph | Table)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Header {
|
export class Header {
|
||||||
|
@ -13,3 +13,4 @@ export * from "./header-wrapper";
|
|||||||
export * from "./footer-wrapper";
|
export * from "./footer-wrapper";
|
||||||
export * from "./header";
|
export * from "./header";
|
||||||
export * from "./footnotes";
|
export * from "./footnotes";
|
||||||
|
export * from "./track-revision";
|
||||||
|
@ -21,14 +21,7 @@ export class Media {
|
|||||||
|
|
||||||
private static generateId(): string {
|
private static generateId(): string {
|
||||||
// https://gist.github.com/6174/6062387
|
// https://gist.github.com/6174/6062387
|
||||||
return (
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.substring(2, 15) +
|
|
||||||
Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.substring(2, 15)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly map: Map<string, IMediaData>;
|
private readonly map: Map<string, IMediaData>;
|
||||||
|
@ -8,10 +8,10 @@ import { ILevelsOptions } from "./level";
|
|||||||
import { ConcreteNumbering } from "./num";
|
import { ConcreteNumbering } from "./num";
|
||||||
|
|
||||||
export interface INumberingOptions {
|
export interface INumberingOptions {
|
||||||
readonly config: Array<{
|
readonly config: {
|
||||||
readonly levels: ILevelsOptions[];
|
readonly levels: ILevelsOptions[];
|
||||||
readonly reference: string;
|
readonly reference: string;
|
||||||
}>;
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Numbering extends XmlComponent {
|
export class Numbering extends XmlComponent {
|
||||||
|
@ -3,3 +3,4 @@ export * from "./paragraph";
|
|||||||
export * from "./properties";
|
export * from "./properties";
|
||||||
export * from "./run";
|
export * from "./run";
|
||||||
export * from "./links";
|
export * from "./links";
|
||||||
|
export * from "./math";
|
||||||
|
4
src/file/paragraph/math/brackets/index.ts
Normal file
4
src/file/paragraph/math/brackets/index.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export * from "./math-round-brackets";
|
||||||
|
export * from "./math-square-brackets";
|
||||||
|
export * from "./math-curly-brackets";
|
||||||
|
export * from "./math-angled-brackets";
|
@ -0,0 +1,51 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathAngledBrackets } from "./math-angled-brackets";
|
||||||
|
|
||||||
|
describe("MathAngledBrackets", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathAngledBrackets with correct root key", () => {
|
||||||
|
const mathAngledBrackets = new MathAngledBrackets({
|
||||||
|
children: [new MathRun("60")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathAngledBrackets);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:d": [
|
||||||
|
{
|
||||||
|
"m:dPr": [
|
||||||
|
{
|
||||||
|
"m:begChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "〈",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:endChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "〉",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["60"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
20
src/file/paragraph/math/brackets/math-angled-brackets.ts
Normal file
20
src/file/paragraph/math/brackets/math-angled-brackets.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_d-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "../n-ary";
|
||||||
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
|
export class MathAngledBrackets extends XmlComponent {
|
||||||
|
constructor(options: { readonly children: MathComponent[] }) {
|
||||||
|
super("m:d");
|
||||||
|
|
||||||
|
this.root.push(
|
||||||
|
new MathBracketProperties({
|
||||||
|
beginningCharacter: "〈",
|
||||||
|
endingCharacter: "〉",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathBeginningCharacter } from "./math-beginning-character";
|
||||||
|
|
||||||
|
describe("MathBeginningCharacter", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathBeginningCharacter with correct root key", () => {
|
||||||
|
const mathBeginningCharacter = new MathBeginningCharacter("[");
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathBeginningCharacter);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:begChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "[",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/brackets/math-beginning-character.ts
Normal file
14
src/file/paragraph/math/brackets/math-beginning-character.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_begChr-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathBeginningCharacterAttributes extends XmlAttributeComponent<{ readonly character: string }> {
|
||||||
|
protected readonly xmlKeys = { character: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathBeginningCharacter extends XmlComponent {
|
||||||
|
constructor(character: string) {
|
||||||
|
super("m:begChr");
|
||||||
|
|
||||||
|
this.root.push(new MathBeginningCharacterAttributes({ character }));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
|
describe("MathBracketProperties", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathBracketProperties with correct root key", () => {
|
||||||
|
const mathBracketProperties = new MathBracketProperties();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathBracketProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:dPr": {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create a MathBracketProperties with correct root key and add brackets", () => {
|
||||||
|
const mathBracketProperties = new MathBracketProperties({
|
||||||
|
beginningCharacter: "[",
|
||||||
|
endingCharacter: "]",
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathBracketProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:dPr": [
|
||||||
|
{
|
||||||
|
"m:begChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "[",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:endChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
16
src/file/paragraph/math/brackets/math-bracket-properties.ts
Normal file
16
src/file/paragraph/math/brackets/math-bracket-properties.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_dPr-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathBeginningCharacter } from "./math-beginning-character";
|
||||||
|
import { MathEndingCharacter } from "./math-ending-char";
|
||||||
|
|
||||||
|
export class MathBracketProperties extends XmlComponent {
|
||||||
|
constructor(options?: { readonly beginningCharacter: string; readonly endingCharacter: string }) {
|
||||||
|
super("m:dPr");
|
||||||
|
|
||||||
|
if (!!options) {
|
||||||
|
this.root.push(new MathBeginningCharacter(options.beginningCharacter));
|
||||||
|
this.root.push(new MathEndingCharacter(options.endingCharacter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
src/file/paragraph/math/brackets/math-curly-brackets.spec.ts
Normal file
51
src/file/paragraph/math/brackets/math-curly-brackets.spec.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathCurlyBrackets } from "./math-curly-brackets";
|
||||||
|
|
||||||
|
describe("MathCurlyBrackets", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathCurlyBrackets with correct root key", () => {
|
||||||
|
const mathCurlyBrackets = new MathCurlyBrackets({
|
||||||
|
children: [new MathRun("60")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathCurlyBrackets);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:d": [
|
||||||
|
{
|
||||||
|
"m:dPr": [
|
||||||
|
{
|
||||||
|
"m:begChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "{",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:endChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["60"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
20
src/file/paragraph/math/brackets/math-curly-brackets.ts
Normal file
20
src/file/paragraph/math/brackets/math-curly-brackets.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_d-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "../n-ary";
|
||||||
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
|
export class MathCurlyBrackets extends XmlComponent {
|
||||||
|
constructor(options: { readonly children: MathComponent[] }) {
|
||||||
|
super("m:d");
|
||||||
|
|
||||||
|
this.root.push(
|
||||||
|
new MathBracketProperties({
|
||||||
|
beginningCharacter: "{",
|
||||||
|
endingCharacter: "}",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
14
src/file/paragraph/math/brackets/math-ending-char.ts
Normal file
14
src/file/paragraph/math/brackets/math-ending-char.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_endChr-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathEndingCharacterAttributes extends XmlAttributeComponent<{ readonly character: string }> {
|
||||||
|
protected readonly xmlKeys = { character: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathEndingCharacter extends XmlComponent {
|
||||||
|
constructor(character: string) {
|
||||||
|
super("m:endChr");
|
||||||
|
|
||||||
|
this.root.push(new MathEndingCharacterAttributes({ character }));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathEndingCharacter } from "./math-ending-char";
|
||||||
|
|
||||||
|
describe("MathEndingCharacter", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathEndingCharacter with correct root key", () => {
|
||||||
|
const mathEndingCharacter = new MathEndingCharacter("]");
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathEndingCharacter);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:endChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
36
src/file/paragraph/math/brackets/math-round-brackets.spec.ts
Normal file
36
src/file/paragraph/math/brackets/math-round-brackets.spec.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathRoundBrackets } from "./math-round-brackets";
|
||||||
|
|
||||||
|
describe("MathRoundBrackets", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathRoundBrackets with correct root key", () => {
|
||||||
|
const mathRoundBrackets = new MathRoundBrackets({
|
||||||
|
children: [new MathRun("60")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathRoundBrackets);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:d": [
|
||||||
|
{
|
||||||
|
"m:dPr": {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["60"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
15
src/file/paragraph/math/brackets/math-round-brackets.ts
Normal file
15
src/file/paragraph/math/brackets/math-round-brackets.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_d-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "../n-ary";
|
||||||
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
|
export class MathRoundBrackets extends XmlComponent {
|
||||||
|
constructor(options: { readonly children: MathComponent[] }) {
|
||||||
|
super("m:d");
|
||||||
|
|
||||||
|
this.root.push(new MathBracketProperties());
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathSquareBrackets } from "./math-square-brackets";
|
||||||
|
|
||||||
|
describe("MathSquareBrackets", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathSquareBrackets with correct root key", () => {
|
||||||
|
const mathSquareBrackets = new MathSquareBrackets({
|
||||||
|
children: [new MathRun("60")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathSquareBrackets);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:d": [
|
||||||
|
{
|
||||||
|
"m:dPr": [
|
||||||
|
{
|
||||||
|
"m:begChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "[",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:endChr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["60"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
20
src/file/paragraph/math/brackets/math-square-brackets.ts
Normal file
20
src/file/paragraph/math/brackets/math-square-brackets.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_d-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "../n-ary";
|
||||||
|
import { MathBracketProperties } from "./math-bracket-properties";
|
||||||
|
|
||||||
|
export class MathSquareBrackets extends XmlComponent {
|
||||||
|
constructor(options: { readonly children: MathComponent[] }) {
|
||||||
|
super("m:d");
|
||||||
|
|
||||||
|
this.root.push(
|
||||||
|
new MathBracketProperties({
|
||||||
|
beginningCharacter: "[",
|
||||||
|
endingCharacter: "]",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
3
src/file/paragraph/math/fraction/index.ts
Normal file
3
src/file/paragraph/math/fraction/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./math-fraction";
|
||||||
|
export * from "./math-denominator";
|
||||||
|
export * from "./math-numerator";
|
26
src/file/paragraph/math/fraction/math-denominator.spec.ts
Normal file
26
src/file/paragraph/math/fraction/math-denominator.spec.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathDenominator);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:den": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
13
src/file/paragraph/math/fraction/math-denominator.ts
Normal file
13
src/file/paragraph/math/fraction/math-denominator.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathDenominator extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:den");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/file/paragraph/math/fraction/math-fraction.spec.ts
Normal file
44
src/file/paragraph/math/fraction/math-fraction.spec.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathFraction } from "./math-fraction";
|
||||||
|
|
||||||
|
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")],
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(mathFraction);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:f": [
|
||||||
|
{
|
||||||
|
"m:num": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:den": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
19
src/file/paragraph/math/fraction/math-fraction.ts
Normal file
19
src/file/paragraph/math/fraction/math-fraction.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathDenominator } from "./math-denominator";
|
||||||
|
import { MathNumerator } from "./math-numerator";
|
||||||
|
|
||||||
|
export interface IMathFractionOptions {
|
||||||
|
readonly numerator: MathComponent[];
|
||||||
|
readonly denominator: MathComponent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathFraction extends XmlComponent {
|
||||||
|
constructor(options: IMathFractionOptions) {
|
||||||
|
super("m:f");
|
||||||
|
|
||||||
|
this.root.push(new MathNumerator(options.numerator));
|
||||||
|
this.root.push(new MathDenominator(options.denominator));
|
||||||
|
}
|
||||||
|
}
|
26
src/file/paragraph/math/fraction/math-numerator.spec.ts
Normal file
26
src/file/paragraph/math/fraction/math-numerator.spec.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathNumerator);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:num": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
13
src/file/paragraph/math/fraction/math-numerator.ts
Normal file
13
src/file/paragraph/math/fraction/math-numerator.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathNumerator extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:num");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
src/file/paragraph/math/function/index.ts
Normal file
3
src/file/paragraph/math/function/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./math-function";
|
||||||
|
export * from "./math-function-name";
|
||||||
|
export * from "./math-function-properties";
|
27
src/file/paragraph/math/function/math-function-name.spec.ts
Normal file
27
src/file/paragraph/math/function/math-function-name.spec.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathFunctionName);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:fName": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
13
src/file/paragraph/math/function/math-function-name.ts
Normal file
13
src/file/paragraph/math/function/math-function-name.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_fName-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathFunctionName extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:fName");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathFunctionProperties } from "./math-function-properties";
|
||||||
|
|
||||||
|
describe("MathFunctionProperties", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathFunctionProperties with correct root key", () => {
|
||||||
|
const mathFunctionProperties = new MathFunctionProperties();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathFunctionProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:funcPr": {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_radPr-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
export class MathFunctionProperties extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("m:funcPr");
|
||||||
|
}
|
||||||
|
}
|
48
src/file/paragraph/math/function/math-function.spec.ts
Normal file
48
src/file/paragraph/math/function/math-function.spec.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathFunction } from "./math-function";
|
||||||
|
|
||||||
|
describe("MathFunction", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathFunction with correct root key", () => {
|
||||||
|
const mathFunction = new MathFunction({
|
||||||
|
name: [new MathRun("sin")],
|
||||||
|
children: [new MathRun("60")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathFunction);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:func": [
|
||||||
|
{
|
||||||
|
"m:funcPr": {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:fName": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["sin"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["60"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
22
src/file/paragraph/math/function/math-function.ts
Normal file
22
src/file/paragraph/math/function/math-function.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_func-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "../n-ary";
|
||||||
|
import { MathFunctionName } from "./math-function-name";
|
||||||
|
import { MathFunctionProperties } from "./math-function-properties";
|
||||||
|
|
||||||
|
export interface IMathFunctionOptions {
|
||||||
|
readonly children: MathComponent[];
|
||||||
|
readonly name: MathComponent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathFunction extends XmlComponent {
|
||||||
|
constructor(options: IMathFunctionOptions) {
|
||||||
|
super("m:func");
|
||||||
|
|
||||||
|
this.root.push(new MathFunctionProperties());
|
||||||
|
this.root.push(new MathFunctionName(options.name));
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
9
src/file/paragraph/math/index.ts
Normal file
9
src/file/paragraph/math/index.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export * from "./math";
|
||||||
|
export * from "./math-run";
|
||||||
|
export * from "./fraction";
|
||||||
|
export * from "./n-ary";
|
||||||
|
export * from "./script";
|
||||||
|
export * from "./math-component";
|
||||||
|
export * from "./radical";
|
||||||
|
export * from "./function";
|
||||||
|
export * from "./brackets";
|
21
src/file/paragraph/math/math-component.ts
Normal file
21
src/file/paragraph/math/math-component.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { MathAngledBrackets, MathCurlyBrackets, MathRoundBrackets, MathSquareBrackets } from "./brackets";
|
||||||
|
import { MathFraction } from "./fraction";
|
||||||
|
import { MathFunction } from "./function";
|
||||||
|
import { MathRun } from "./math-run";
|
||||||
|
import { MathSum } from "./n-ary";
|
||||||
|
import { MathRadical } from "./radical";
|
||||||
|
import { MathSubScript, MathSubSuperScript, MathSuperScript } from "./script";
|
||||||
|
|
||||||
|
export type MathComponent =
|
||||||
|
| MathRun
|
||||||
|
| MathFraction
|
||||||
|
| MathSum
|
||||||
|
| MathSuperScript
|
||||||
|
| MathSubScript
|
||||||
|
| MathSubSuperScript
|
||||||
|
| MathRadical
|
||||||
|
| MathFunction
|
||||||
|
| MathRoundBrackets
|
||||||
|
| MathCurlyBrackets
|
||||||
|
| MathAngledBrackets
|
||||||
|
| MathSquareBrackets;
|
21
src/file/paragraph/math/math-run.spec.ts
Normal file
21
src/file/paragraph/math/math-run.spec.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "./math-run";
|
||||||
|
|
||||||
|
describe("MathRun", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathRun with correct root key", () => {
|
||||||
|
const mathRun = new MathRun("2+2");
|
||||||
|
const tree = new Formatter().format(mathRun);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
12
src/file/paragraph/math/math-run.ts
Normal file
12
src/file/paragraph/math/math-run.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_r-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathText } from "./math-text";
|
||||||
|
|
||||||
|
export class MathRun extends XmlComponent {
|
||||||
|
constructor(text: string) {
|
||||||
|
super("m:r");
|
||||||
|
|
||||||
|
this.root.push(new MathText(text));
|
||||||
|
}
|
||||||
|
}
|
17
src/file/paragraph/math/math-text.spec.ts
Normal file
17
src/file/paragraph/math/math-text.spec.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathText } from "./math-text";
|
||||||
|
|
||||||
|
describe("MathText", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathText with correct root key", () => {
|
||||||
|
const mathText = new MathText("2+2");
|
||||||
|
const tree = new Formatter().format(mathText);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
9
src/file/paragraph/math/math-text.ts
Normal file
9
src/file/paragraph/math/math-text.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
export class MathText extends XmlComponent {
|
||||||
|
constructor(text: string) {
|
||||||
|
super("m:t");
|
||||||
|
|
||||||
|
this.root.push(text);
|
||||||
|
}
|
||||||
|
}
|
38
src/file/paragraph/math/math.spec.ts
Normal file
38
src/file/paragraph/math/math.spec.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { Math } from "./math";
|
||||||
|
import { MathRun } from "./math-run";
|
||||||
|
|
||||||
|
describe("Math", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a Math with correct root key", () => {
|
||||||
|
const math = new Math({
|
||||||
|
children: [],
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(math);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:oMath": {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be able to add children", () => {
|
||||||
|
const math = new Math({
|
||||||
|
children: [new MathRun("2+2")],
|
||||||
|
});
|
||||||
|
const tree = new Formatter().format(math);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:oMath": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
18
src/file/paragraph/math/math.ts
Normal file
18
src/file/paragraph/math/math.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_oMath-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "./math-component";
|
||||||
|
|
||||||
|
export interface IMathOptions {
|
||||||
|
readonly children: MathComponent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Math extends XmlComponent {
|
||||||
|
constructor(options: IMathOptions) {
|
||||||
|
super("m:oMath");
|
||||||
|
|
||||||
|
for (const child of options.children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/file/paragraph/math/n-ary/index.ts
Normal file
7
src/file/paragraph/math/n-ary/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export * from "./math-accent-character";
|
||||||
|
export * from "./math-base";
|
||||||
|
export * from "./math-limit-location";
|
||||||
|
export * from "./math-naray-properties";
|
||||||
|
export * from "./math-sub-script";
|
||||||
|
export * from "./math-sum";
|
||||||
|
export * from "./math-super-script";
|
22
src/file/paragraph/math/n-ary/math-accent-character.spec.ts
Normal file
22
src/file/paragraph/math/n-ary/math-accent-character.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathAccentCharacter } from "./math-accent-character";
|
||||||
|
|
||||||
|
describe("MathAccentCharacter", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathAccentCharacter with correct root key", () => {
|
||||||
|
const mathAccentCharacter = new MathAccentCharacter("∑");
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathAccentCharacter);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-accent-character.ts
Normal file
14
src/file/paragraph/math/n-ary/math-accent-character.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_chr-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathAccentCharacterAttributes extends XmlAttributeComponent<{ readonly accent: string }> {
|
||||||
|
protected readonly xmlKeys = { accent: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathAccentCharacter extends XmlComponent {
|
||||||
|
constructor(accent: string) {
|
||||||
|
super("m:chr");
|
||||||
|
|
||||||
|
this.root.push(new MathAccentCharacterAttributes({ accent }));
|
||||||
|
}
|
||||||
|
}
|
27
src/file/paragraph/math/n-ary/math-base.spec.ts
Normal file
27
src/file/paragraph/math/n-ary/math-base.spec.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathBase);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-base.ts
Normal file
14
src/file/paragraph/math/n-ary/math-base.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_e-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathBase extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:e");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/file/paragraph/math/n-ary/math-limit-location.spec.ts
Normal file
22
src/file/paragraph/math/n-ary/math-limit-location.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathLimitLocation } from "./math-limit-location";
|
||||||
|
|
||||||
|
describe("MathLimitLocation", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathLimitLocation with correct root key", () => {
|
||||||
|
const mathLimitLocation = new MathLimitLocation();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathLimitLocation);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-limit-location.ts
Normal file
14
src/file/paragraph/math/n-ary/math-limit-location.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_limLoc-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathLimitLocationAttributes extends XmlAttributeComponent<{ readonly value: string }> {
|
||||||
|
protected readonly xmlKeys = { value: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathLimitLocation extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("m:limLoc");
|
||||||
|
|
||||||
|
this.root.push(new MathLimitLocationAttributes({ value: "undOvr" }));
|
||||||
|
}
|
||||||
|
}
|
133
src/file/paragraph/math/n-ary/math-naray-properties.spec.ts
Normal file
133
src/file/paragraph/math/n-ary/math-naray-properties.spec.ts
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathNArayProperties } from "./math-naray-properties";
|
||||||
|
|
||||||
|
describe("MathNArayProperties", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathNArayProperties with correct root key", () => {
|
||||||
|
const mathNArayProperties = new MathNArayProperties("∑", true, true);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathNArayProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:naryPr": [
|
||||||
|
{
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should add super-script hide attributes", () => {
|
||||||
|
const mathNArayProperties = new MathNArayProperties("∑", false, true);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathNArayProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:naryPr": [
|
||||||
|
{
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:supHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should add sub-script hide attributes", () => {
|
||||||
|
const mathNArayProperties = new MathNArayProperties("∑", true, false);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathNArayProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:naryPr": [
|
||||||
|
{
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:subHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should add both super-script and sub-script hide attributes", () => {
|
||||||
|
const mathNArayProperties = new MathNArayProperties("∑", false, false);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathNArayProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:naryPr": [
|
||||||
|
{
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:supHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:subHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
24
src/file/paragraph/math/n-ary/math-naray-properties.ts
Normal file
24
src/file/paragraph/math/n-ary/math-naray-properties.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_naryPr-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathAccentCharacter } from "./math-accent-character";
|
||||||
|
import { MathLimitLocation } from "./math-limit-location";
|
||||||
|
import { MathSubScriptHide } from "./math-sub-script-hide";
|
||||||
|
import { MathSuperScriptHide } from "./math-super-script-hide";
|
||||||
|
|
||||||
|
export class MathNArayProperties extends XmlComponent {
|
||||||
|
constructor(accent: string, hasSuperScript: boolean, hasSubScript: boolean) {
|
||||||
|
super("m:naryPr");
|
||||||
|
|
||||||
|
this.root.push(new MathAccentCharacter(accent));
|
||||||
|
this.root.push(new MathLimitLocation());
|
||||||
|
|
||||||
|
if (!hasSuperScript) {
|
||||||
|
this.root.push(new MathSuperScriptHide());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasSubScript) {
|
||||||
|
this.root.push(new MathSubScriptHide());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
src/file/paragraph/math/n-ary/math-sub-script-hide.spec.ts
Normal file
22
src/file/paragraph/math/n-ary/math-sub-script-hide.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathSubScriptHide } from "./math-sub-script-hide";
|
||||||
|
|
||||||
|
describe("MathSubScriptHide", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathSubScriptHide with correct root key", () => {
|
||||||
|
const mathSubScriptHide = new MathSubScriptHide();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathSubScriptHide);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:subHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-sub-script-hide.ts
Normal file
14
src/file/paragraph/math/n-ary/math-sub-script-hide.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_subHide-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathSubScriptHideAttributes extends XmlAttributeComponent<{ readonly hide: number }> {
|
||||||
|
protected readonly xmlKeys = { hide: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathSubScriptHide extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("m:subHide");
|
||||||
|
|
||||||
|
this.root.push(new MathSubScriptHideAttributes({ hide: 1 }));
|
||||||
|
}
|
||||||
|
}
|
27
src/file/paragraph/math/n-ary/math-sub-script.spec.ts
Normal file
27
src/file/paragraph/math/n-ary/math-sub-script.spec.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathSubScriptElement);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:sub": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-sub-script.ts
Normal file
14
src/file/paragraph/math/n-ary/math-sub-script.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_sub-3.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathSubScriptElement extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:sub");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
src/file/paragraph/math/n-ary/math-sum.spec.ts
Normal file
75
src/file/paragraph/math/n-ary/math-sum.spec.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathSum } from "./math-sum";
|
||||||
|
|
||||||
|
describe("MathSum", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathSum with correct root key", () => {
|
||||||
|
const mathSum = new MathSum({
|
||||||
|
children: [new MathRun("1")],
|
||||||
|
subScript: [new MathRun("2")],
|
||||||
|
superScript: [new MathRun("3")],
|
||||||
|
});
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathSum);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:nary": [
|
||||||
|
{
|
||||||
|
"m:naryPr": [
|
||||||
|
{
|
||||||
|
"m:chr": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "∑",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:limLoc": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": "undOvr",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:sub": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:sup": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["3"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m:e": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["1"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
32
src/file/paragraph/math/n-ary/math-sum.ts
Normal file
32
src/file/paragraph/math/n-ary/math-sum.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_nary-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
import { MathBase } from "./math-base";
|
||||||
|
import { MathNArayProperties } from "./math-naray-properties";
|
||||||
|
import { MathSubScriptElement } from "./math-sub-script";
|
||||||
|
import { MathSuperScriptElement } from "./math-super-script";
|
||||||
|
|
||||||
|
export interface IMathSumOptions {
|
||||||
|
readonly children: MathComponent[];
|
||||||
|
readonly subScript?: MathComponent[];
|
||||||
|
readonly superScript?: MathComponent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathSum extends XmlComponent {
|
||||||
|
constructor(options: IMathSumOptions) {
|
||||||
|
super("m:nary");
|
||||||
|
|
||||||
|
this.root.push(new MathNArayProperties("∑", !!options.superScript, !!options.subScript));
|
||||||
|
|
||||||
|
if (!!options.subScript) {
|
||||||
|
this.root.push(new MathSubScriptElement(options.subScript));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!!options.superScript) {
|
||||||
|
this.root.push(new MathSuperScriptElement(options.superScript));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.root.push(new MathBase(options.children));
|
||||||
|
}
|
||||||
|
}
|
22
src/file/paragraph/math/n-ary/math-super-script-hide.spec.ts
Normal file
22
src/file/paragraph/math/n-ary/math-super-script-hide.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathSuperScriptHide } from "./math-super-script-hide";
|
||||||
|
|
||||||
|
describe("MathSuperScriptHide", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathSuperScriptHide with correct root key", () => {
|
||||||
|
const mathSuperScriptHide = new MathSuperScriptHide();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathSuperScriptHide);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:supHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-super-script-hide.ts
Normal file
14
src/file/paragraph/math/n-ary/math-super-script-hide.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_subHide-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathSuperScriptHideAttributes extends XmlAttributeComponent<{ readonly hide: number }> {
|
||||||
|
protected readonly xmlKeys = { hide: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathSuperScriptHide extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("m:supHide");
|
||||||
|
|
||||||
|
this.root.push(new MathSuperScriptHideAttributes({ hide: 1 }));
|
||||||
|
}
|
||||||
|
}
|
27
src/file/paragraph/math/n-ary/math-super-script.spec.ts
Normal file
27
src/file/paragraph/math/n-ary/math-super-script.spec.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
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 tree = new Formatter().format(mathSuperScriptElement);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:sup": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2+2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/n-ary/math-super-script.ts
Normal file
14
src/file/paragraph/math/n-ary/math-super-script.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_sup-3.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathSuperScriptElement extends XmlComponent {
|
||||||
|
constructor(children: MathComponent[]) {
|
||||||
|
super("m:sup");
|
||||||
|
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
src/file/paragraph/math/radical/index.ts
Normal file
3
src/file/paragraph/math/radical/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from "./math-degree";
|
||||||
|
export * from "./math-radical";
|
||||||
|
export * from "./math-radical-properties";
|
22
src/file/paragraph/math/radical/math-degree-hide.spec.ts
Normal file
22
src/file/paragraph/math/radical/math-degree-hide.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathDegreeHide } from "./math-degree-hide";
|
||||||
|
|
||||||
|
describe("MathDegreeHide", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathDegreeHide with correct root key", () => {
|
||||||
|
const mathDegreeHide = new MathDegreeHide();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathDegreeHide);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:degHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
14
src/file/paragraph/math/radical/math-degree-hide.ts
Normal file
14
src/file/paragraph/math/radical/math-degree-hide.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_degHide-1.html
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
class MathDegreeHideAttributes extends XmlAttributeComponent<{ readonly hide: number }> {
|
||||||
|
protected readonly xmlKeys = { hide: "m:val" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MathDegreeHide extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("m:degHide");
|
||||||
|
|
||||||
|
this.root.push(new MathDegreeHideAttributes({ hide: 1 }));
|
||||||
|
}
|
||||||
|
}
|
36
src/file/paragraph/math/radical/math-degree.spec.ts
Normal file
36
src/file/paragraph/math/radical/math-degree.spec.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRun } from "../math-run";
|
||||||
|
import { MathDegree } from "./math-degree";
|
||||||
|
|
||||||
|
describe("MathDegree", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathDegree with correct root key", () => {
|
||||||
|
const mathDegree = new MathDegree();
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathDegree);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:deg": {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create a MathDegree with correct root key with child", () => {
|
||||||
|
const mathDegree = new MathDegree([new MathRun("2")]);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathDegree);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:deg": [
|
||||||
|
{
|
||||||
|
"m:r": [
|
||||||
|
{
|
||||||
|
"m:t": ["2"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
15
src/file/paragraph/math/radical/math-degree.ts
Normal file
15
src/file/paragraph/math/radical/math-degree.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_deg-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
import { MathComponent } from "../math-component";
|
||||||
|
|
||||||
|
export class MathDegree extends XmlComponent {
|
||||||
|
constructor(children?: MathComponent[]) {
|
||||||
|
super("m:deg");
|
||||||
|
|
||||||
|
if (!!children) {
|
||||||
|
for (const child of children) {
|
||||||
|
this.root.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
|
||||||
|
import { Formatter } from "export/formatter";
|
||||||
|
|
||||||
|
import { MathRadicalProperties } from "./math-radical-properties";
|
||||||
|
|
||||||
|
describe("MathRadicalProperties", () => {
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("should create a MathRadicalProperties with correct root key", () => {
|
||||||
|
const mathRadicalProperties = new MathRadicalProperties(true);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathRadicalProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:radPr": {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create a MathRadicalProperties with correct root key with degree hide", () => {
|
||||||
|
const mathRadicalProperties = new MathRadicalProperties(false);
|
||||||
|
|
||||||
|
const tree = new Formatter().format(mathRadicalProperties);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"m:radPr": [
|
||||||
|
{
|
||||||
|
"m:degHide": {
|
||||||
|
_attr: {
|
||||||
|
"m:val": 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
13
src/file/paragraph/math/radical/math-radical-properties.ts
Normal file
13
src/file/paragraph/math/radical/math-radical-properties.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// http://www.datypic.com/sc/ooxml/e-m_radPr-1.html
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
import { MathDegreeHide } from "./math-degree-hide";
|
||||||
|
|
||||||
|
export class MathRadicalProperties extends XmlComponent {
|
||||||
|
constructor(hasDegree: boolean) {
|
||||||
|
super("m:radPr");
|
||||||
|
|
||||||
|
if (!hasDegree) {
|
||||||
|
this.root.push(new MathDegreeHide());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user