Compare commits
53 Commits
Author | SHA1 | Date | |
---|---|---|---|
e10b8889f7 | |||
744b16b753 | |||
77824ce1d2 | |||
d2f777c4e5 | |||
946a222d37 | |||
279a5a93f1 | |||
0e89606ec9 | |||
72683ea990 | |||
88cf5f5065 | |||
540518bd54 | |||
03b34915c6 | |||
f6eb412357 | |||
ca769cc849 | |||
727471b7e3 | |||
1a37242a3d | |||
81e0d56918 | |||
237be76d33 | |||
a454ff9643 | |||
f7b90d4ff3 | |||
cee515e43f | |||
0e9532d835 | |||
4b300e4def | |||
1fe7ab90f2 | |||
a3d2323254 | |||
0b2de737de | |||
0a70d932a0 | |||
6b702c4bd6 | |||
709ff25702 | |||
82998d4f6b | |||
6e6a06eba4 | |||
ae70c2dfde | |||
28e11a9b08 | |||
f5e81f1dfc | |||
38138049fe | |||
5511024ca6 | |||
ef1407e640 | |||
f822bbb26f | |||
52c4e3cabd | |||
9ced196678 | |||
ef6e195e89 | |||
a77d520f41 | |||
8eb11bca29 | |||
660a81633f | |||
a917247b60 | |||
f492b3fe04 | |||
96a8942455 | |||
bca478bb81 | |||
f5de5fef4d | |||
0e9301c0b5 | |||
b0869567c6 | |||
0585a25a5a | |||
9804091f6a | |||
9c3023019f |
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,4 +37,4 @@ build
|
|||||||
build-tests
|
build-tests
|
||||||
|
|
||||||
# vscode
|
# vscode
|
||||||
ts/.vscode
|
.vscode
|
||||||
|
40
.npmignore
Normal file
40
.npmignore
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directory
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# build
|
||||||
|
# build <-- we want this in the package
|
||||||
|
build-tests
|
||||||
|
|
||||||
|
# vscode
|
||||||
|
.vscode
|
18
README.md
18
README.md
@ -1,11 +1,19 @@
|
|||||||
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
|
<p align="center">
|
||||||
|
<img alt="clippy the assistant" src="http://i60.tinypic.com/339pvtt.png">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
Generate .docx files with JS/TS very easily
|
||||||
|
</p>
|
||||||
|
---
|
||||||
|
|
||||||
|
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Known Vulnerabilities][snky-image]][snky-url]
|
||||||
|
|
||||||
|
# docx
|
||||||
> A tool to create Word Documents (.docx) with JS or TS, written in TS.
|
> A tool to create Word Documents (.docx) with JS or TS, written in TS.
|
||||||
|
|
||||||
[](https://nodei.co/npm/docx/)
|
[](https://nodei.co/npm/docx/)
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
# Table of Contents
|
# Table of Contents
|
||||||
- [Install](#)
|
- [Install](#)
|
||||||
- [Usage](#)
|
- [Usage](#)
|
||||||
@ -379,4 +387,6 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|||||||
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
|
[travis-image]: https://travis-ci.org/dolanmiu/docx.svg?branch=master
|
||||||
[travis-url]: https://travis-ci.org/dolanmiu/docx
|
[travis-url]: https://travis-ci.org/dolanmiu/docx
|
||||||
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
|
[daviddm-image]: https://david-dm.org/dolanmiu/docx.svg?theme=shields.io
|
||||||
[daviddm-url]: https://david-dm.org/dolanmiu/docx
|
[daviddm-url]: https://david-dm.org/dolanmiu/docx
|
||||||
|
[snky-image]: https://snyk.io/test/github/dolanmiu/docx/badge.svg
|
||||||
|
[snky-url]: https://snyk.io/test/github/dolanmiu/docx
|
24
package.json
24
package.json
@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "1.0.1",
|
"version": "1.2.0",
|
||||||
"description": "Generate .docx documents with JavaScript (formerly Office-Clippy)",
|
"description": "Generate .docx documents with JavaScript (formerly Office-Clippy)",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pretest": "rimraf ./build-tests && tsc -p ts/test-tsconfig.json",
|
"pretest": "rimraf ./build-tests && tsc -p ts/test-tsconfig.json",
|
||||||
"test": "mocha ./build-tests --recursive",
|
"test": "mocha ./build-tests --recursive",
|
||||||
"prepublish": "tsc -p ts"
|
"prepublishOnly": "tsc -p ts",
|
||||||
|
"lint": "tslint --project ./ts"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"ts",
|
||||||
|
"build"
|
||||||
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/dolanmiu/docx.git"
|
"url": "git+https://github.com/dolanmiu/docx.git"
|
||||||
@ -16,17 +21,21 @@
|
|||||||
"office",
|
"office",
|
||||||
"generate",
|
"generate",
|
||||||
"document",
|
"document",
|
||||||
"doc"
|
"doc",
|
||||||
|
"officegen",
|
||||||
|
"clippy"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/archiver": "^0.15.37",
|
||||||
|
"@types/express": "^4.0.35",
|
||||||
|
"@types/lodash": "^4.14.54",
|
||||||
"app-root-path": "^2.0.1",
|
"app-root-path": "^2.0.1",
|
||||||
"archiver": "^1.3.0",
|
"archiver": "^1.3.0",
|
||||||
|
"install": "^0.8.7",
|
||||||
"lodash": "^4.6.1",
|
"lodash": "^4.6.1",
|
||||||
|
"npm": "^4.3.0",
|
||||||
"xml": "^1.0.1"
|
"xml": "^1.0.1"
|
||||||
},
|
},
|
||||||
"typescript": {
|
|
||||||
"definition": "ts/typings/index.d.ts"
|
|
||||||
},
|
|
||||||
"author": "Dolan Miu",
|
"author": "Dolan Miu",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@ -34,9 +43,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/dolanmiu/docx#readme",
|
"homepage": "https://github.com/dolanmiu/docx#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/chai": "^3.4.35",
|
||||||
|
"@types/mocha": "^2.2.39",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^3.2.0",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
|
"tslint": "^4.5.1",
|
||||||
"typescript": "^2.2.1"
|
"typescript": "^2.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
|
|
||||||
export class Columns extends XmlComponent {
|
export class Columns extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:cols");
|
super("w:cols");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
space: "708"
|
space: "708",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
|
|
||||||
export class DocumentGrid extends XmlComponent {
|
export class DocumentGrid extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:docGrid");
|
super("w:docGrid");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
linePitch: "360"
|
linePitch: "360",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
import {SectionProperties} from "./section-properties";
|
import { SectionProperties } from "./section-properties";
|
||||||
|
|
||||||
export class Body extends XmlComponent {
|
export class Body extends XmlComponent {
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ export class Body extends XmlComponent {
|
|||||||
// this.root.push(new SectionProperties()); not actually needed
|
// this.root.push(new SectionProperties()); not actually needed
|
||||||
}
|
}
|
||||||
|
|
||||||
push(component: XmlComponent) {
|
public push(component: XmlComponent): void {
|
||||||
// this.root.splice(this.body.length - 1, 0, component);
|
// this.root.splice(this.body.length - 1, 0, component);
|
||||||
this.root.push(component);
|
this.root.push(component);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
|
|
||||||
export class PageMargin extends XmlComponent {
|
export class PageMargin extends XmlComponent {
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export class PageMargin extends XmlComponent {
|
|||||||
left: "1440",
|
left: "1440",
|
||||||
header: "708",
|
header: "708",
|
||||||
footer: "708",
|
footer: "708",
|
||||||
gutter: "0"
|
gutter: "0",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
|
|
||||||
export class PageSize extends XmlComponent {
|
export class PageSize extends XmlComponent {
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ export class PageSize extends XmlComponent {
|
|||||||
super("w:pgSz");
|
super("w:pgSz");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
w: "11906",
|
w: "11906",
|
||||||
h: "16838"
|
h: "16838",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {XmlComponent, Attributes} from "../../xml-components";
|
import { Attributes, XmlComponent } from "../../xml-components";
|
||||||
import {PageSize} from "./page-size";
|
import { Columns } from "./columns";
|
||||||
import {PageMargin} from "./page-margin";
|
import { DocumentGrid } from "./doc-grid";
|
||||||
import {Columns} from "./columns";
|
import { PageMargin } from "./page-margin";
|
||||||
import {DocumentGrid} from "./doc-grid";
|
import { PageSize } from "./page-size";
|
||||||
|
|
||||||
export class SectionProperties extends XmlComponent {
|
export class SectionProperties extends XmlComponent {
|
||||||
|
|
||||||
@ -11,11 +11,11 @@ export class SectionProperties extends XmlComponent {
|
|||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
rsidR: "00B64E8F",
|
rsidR: "00B64E8F",
|
||||||
rsidRPr: "00D842E4",
|
rsidRPr: "00D842E4",
|
||||||
rsidSect: "000A6AD0"
|
rsidSect: "000A6AD0",
|
||||||
}));
|
}));
|
||||||
this.root.push(new PageSize());
|
this.root.push(new PageSize());
|
||||||
this.root.push(new PageMargin());
|
this.root.push(new PageMargin());
|
||||||
this.root.push(new Columns());
|
this.root.push(new Columns());
|
||||||
this.root.push(new DocumentGrid());
|
this.root.push(new DocumentGrid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {XmlAttributeComponent} from "../xml-components";
|
import { XmlAttributeComponent } from "../xml-components";
|
||||||
|
|
||||||
interface DocumentAttributesProperties {
|
interface IDocumentAttributesProperties {
|
||||||
wpc?: string;
|
wpc?: string;
|
||||||
mc?: string;
|
mc?: string;
|
||||||
o?: string;
|
o?: string;
|
||||||
@ -28,7 +28,7 @@ interface DocumentAttributesProperties {
|
|||||||
|
|
||||||
export class DocumentAttributes extends XmlAttributeComponent {
|
export class DocumentAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
constructor(properties?: DocumentAttributesProperties) {
|
constructor(properties?: IDocumentAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
wpc: "xmlns:wpc",
|
wpc: "xmlns:wpc",
|
||||||
mc: "xmlns:mc",
|
mc: "xmlns:mc",
|
||||||
@ -52,7 +52,7 @@ export class DocumentAttributes extends XmlAttributeComponent {
|
|||||||
dcterms: "xmlns:dcterms",
|
dcterms: "xmlns:dcterms",
|
||||||
dcmitype: "xmlns:dcmitype",
|
dcmitype: "xmlns:dcmitype",
|
||||||
xsi: "xmlns:xsi",
|
xsi: "xmlns:xsi",
|
||||||
type: "xsi:type"
|
type: "xsi:type",
|
||||||
}, properties);
|
}, properties);
|
||||||
|
|
||||||
this.root = properties;
|
this.root = properties;
|
||||||
@ -61,4 +61,4 @@ export class DocumentAttributes extends XmlAttributeComponent {
|
|||||||
this.root = {};
|
this.root = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { Paragraph } from "../paragraph";
|
||||||
import {DocumentAttributes} from "./document-attributes";
|
import { XmlComponent } from "../xml-components";
|
||||||
import {Body} from "./body";
|
import { Body } from "./body";
|
||||||
import {Paragraph} from "../paragraph";
|
import { DocumentAttributes } from "./document-attributes";
|
||||||
|
|
||||||
export class Document extends XmlComponent {
|
export class Document extends XmlComponent {
|
||||||
private body: Body;
|
private body: Body;
|
||||||
|
|
||||||
@ -25,18 +24,18 @@ export class Document extends XmlComponent {
|
|||||||
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
Ignorable: "w14 w15 wp14"
|
Ignorable: "w14 w15 wp14",
|
||||||
}));
|
}));
|
||||||
this.body = new Body();
|
this.body = new Body();
|
||||||
this.root.push(this.body);
|
this.root.push(this.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
addParagraph(paragraph: Paragraph): void {
|
public addParagraph(paragraph: Paragraph): void {
|
||||||
this.body.push(paragraph);
|
this.body.push(paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.body.clearVariables();
|
this.body.clearVariables();
|
||||||
delete this.body;
|
delete this.body;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export {Document} from "./document";
|
export { Document } from "./document";
|
||||||
export {Paragraph} from "./paragraph";
|
export { Paragraph } from "./paragraph";
|
||||||
export {Run} from "./run"
|
export { Run } from "./run";
|
||||||
export {TextRun} from "./run/text-run"
|
export { TextRun } from "./run/text-run";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
class Border extends XmlComponent {
|
class Border extends XmlComponent {
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ class Border extends XmlComponent {
|
|||||||
color: "auto",
|
color: "auto",
|
||||||
space: "1",
|
space: "1",
|
||||||
val: "single",
|
val: "single",
|
||||||
sz: "6"
|
sz: "6",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -19,4 +19,4 @@ export class ThematicBreak extends XmlComponent {
|
|||||||
super("w:pBdr");
|
super("w:pBdr");
|
||||||
this.root.push(new Border());
|
this.root.push(new Border());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Num } from "../../numbering/num";
|
||||||
import {ThematicBreak} from "./border";
|
import { TextRun } from "../run/text-run";
|
||||||
import {PageBreak} from "./page-break";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
import {TextRun} from "../run/text-run";
|
import { ThematicBreak } from "./border";
|
||||||
import {ParagraphProperties} from "./properties";
|
import { PageBreak } from "./page-break";
|
||||||
import {MaxRightTabStop, LeftTabStop} from "./tab-stop";
|
import { ParagraphProperties } from "./properties";
|
||||||
import {Style} from "./style";
|
import { Style } from "./style";
|
||||||
import {NumberProperties} from "./unordered-list";
|
import { LeftTabStop, MaxRightTabStop } from "./tab-stop";
|
||||||
|
import { NumberProperties } from "./unordered-list";
|
||||||
|
|
||||||
class Alignment extends XmlComponent {
|
class Alignment extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super("w:jc");
|
super("w:jc");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: type
|
val: type,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,84 +30,90 @@ export class Paragraph extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addText(run: TextRun): Paragraph {
|
public addText(run: TextRun): Paragraph {
|
||||||
this.root.push(run);
|
this.root.push(run);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
heading1(): Paragraph {
|
public heading1(): Paragraph {
|
||||||
this.properties.push(new Style("Heading1"));
|
this.properties.push(new Style("Heading1"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
heading2(): Paragraph {
|
public heading2(): Paragraph {
|
||||||
this.properties.push(new Style("Heading2"));
|
this.properties.push(new Style("Heading2"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
heading3(): Paragraph {
|
public heading3(): Paragraph {
|
||||||
this.properties.push(new Style("Heading3"));
|
this.properties.push(new Style("Heading3"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
heading4(): Paragraph {
|
public heading4(): Paragraph {
|
||||||
this.properties.push(new Style("Heading4"));
|
this.properties.push(new Style("Heading4"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
heading5(): Paragraph {
|
public heading5(): Paragraph {
|
||||||
this.properties.push(new Style("Heading5"));
|
this.properties.push(new Style("Heading5"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
title(): Paragraph {
|
public title(): Paragraph {
|
||||||
this.properties.push(new Style("Title"));
|
this.properties.push(new Style("Title"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
center(): Paragraph {
|
public center(): Paragraph {
|
||||||
this.properties.push(new Alignment("center"));
|
this.properties.push(new Alignment("center"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
left(): Paragraph {
|
public left(): Paragraph {
|
||||||
this.properties.push(new Alignment("left"));
|
this.properties.push(new Alignment("left"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
right(): Paragraph {
|
public right(): Paragraph {
|
||||||
this.properties.push(new Alignment("right"));
|
this.properties.push(new Alignment("right"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
justified(): Paragraph {
|
public justified(): Paragraph {
|
||||||
this.properties.push(new Alignment("both"));
|
this.properties.push(new Alignment("both"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
thematicBreak(): Paragraph {
|
public thematicBreak(): Paragraph {
|
||||||
this.properties.push(new ThematicBreak());
|
this.properties.push(new ThematicBreak());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
pageBreak(): Paragraph {
|
public pageBreak(): Paragraph {
|
||||||
this.properties.push(new PageBreak());
|
this.properties.push(new PageBreak());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
maxRightTabStop(): Paragraph {
|
public maxRightTabStop(): Paragraph {
|
||||||
this.properties.push(new MaxRightTabStop());
|
this.properties.push(new MaxRightTabStop());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
leftTabStop(position: number): Paragraph {
|
public leftTabStop(position: number): Paragraph {
|
||||||
this.properties.push(new LeftTabStop(position));
|
this.properties.push(new LeftTabStop(position));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bullet(): Paragraph {
|
public bullet(): Paragraph {
|
||||||
this.properties.push(new Style("ListParagraph"));
|
this.properties.push(new Style("ListParagraph"));
|
||||||
this.properties.push(new NumberProperties());
|
this.properties.push(new NumberProperties(1, 0));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public setNumbering(numbering: Num, indentLevel: number): Paragraph {
|
||||||
|
this.properties.push(new Style("ListParagraph"));
|
||||||
|
this.properties.push(new NumberProperties(numbering.id, indentLevel));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Run } from "../run";
|
||||||
import {Run} from "../run";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
class Break extends XmlComponent {
|
class Break extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:br");
|
super("w:br");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
type: "page"
|
type: "page",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,4 +17,4 @@ export class PageBreak extends Run {
|
|||||||
super();
|
super();
|
||||||
this.root.push(new Break());
|
this.root.push(new Break());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class ParagraphProperties extends XmlComponent {
|
export class ParagraphProperties extends XmlComponent {
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ export class ParagraphProperties extends XmlComponent {
|
|||||||
this.root.push(new Attributes());
|
this.root.push(new Attributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
push(item: XmlComponent): void {
|
public push(item: XmlComponent): void {
|
||||||
this.root.push(item);
|
this.root.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super("w:pStyle");
|
super("w:pStyle");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: type
|
val: type,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
class TabStop extends XmlComponent {
|
class TabStop extends XmlComponent {
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ class Tab extends XmlComponent {
|
|||||||
super("w:tab");
|
super("w:tab");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value,
|
val: value,
|
||||||
pos: position
|
pos: position,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
import {Style} from "./style";
|
import { Style } from "./style";
|
||||||
|
|
||||||
export class NumberProperties extends XmlComponent {
|
export class NumberProperties extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor(numberId: number, indentLevel: number) {
|
||||||
super("w:numPr");
|
super("w:numPr");
|
||||||
this.root.push(new IndentLevel(0));
|
this.root.push(new IndentLevel(indentLevel));
|
||||||
this.root.push(new NumberId(1));
|
this.root.push(new NumberId(numberId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class IndentLevel extends XmlComponent {
|
|||||||
constructor(level: number) {
|
constructor(level: number) {
|
||||||
super("w:ilvl");
|
super("w:ilvl");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: level
|
val: level,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ class NumberId extends XmlComponent {
|
|||||||
constructor(id: number) {
|
constructor(id: number) {
|
||||||
super("w:numId");
|
super("w:numId");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: id
|
val: id,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Break extends XmlComponent {
|
export class Break extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:br");
|
super("w:br");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class SmallCaps extends XmlComponent {
|
export class SmallCaps extends XmlComponent {
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Bold extends XmlComponent {
|
export class Bold extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:b");
|
super("w:b");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ export class Italics extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:i");
|
super("w:i");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ export class Caps extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:caps");
|
super("w:caps");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export class Color extends XmlComponent {
|
|||||||
constructor(color: string) {
|
constructor(color: string) {
|
||||||
super("w:color");
|
super("w:color");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: color
|
val: color,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ export class DoubleStrike extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:dstrike");
|
super("w:dstrike");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ export class Emboss extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:emboss");
|
super("w:emboss");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ export class Imprint extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:imprint");
|
super("w:imprint");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ export class Shadow extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:shadow");
|
super("w:shadow");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ export class SmallCaps extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:smallCaps");
|
super("w:smallCaps");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ export class Strike extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:strike");
|
super("w:strike");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: true
|
val: true,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ export class Size extends XmlComponent {
|
|||||||
constructor(size: number) {
|
constructor(size: number) {
|
||||||
super("w:sz");
|
super("w:sz");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: size
|
val: size,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,75 +1,81 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Break } from "./break";
|
||||||
import {RunProperties} from "./properties";
|
import { Caps, SmallCaps } from "./caps";
|
||||||
import {Bold, Italics} from "./formatting";
|
import { Bold, Italics } from "./formatting";
|
||||||
import {Tab} from "./tab";
|
import { RunProperties } from "./properties";
|
||||||
import {Break} from "./break";
|
import { RunFonts } from "./run-fonts";
|
||||||
import {SmallCaps, Caps} from "./caps";
|
import { SubScript, SuperScript } from "./script";
|
||||||
import {Strike, DoubleStrike} from "./strike";
|
import { DoubleStrike, Strike } from "./strike";
|
||||||
import {SubScript, SuperScript} from "./script";
|
import { Tab } from "./tab";
|
||||||
import {Underline} from "./underline"
|
import { Underline } from "./underline";
|
||||||
|
|
||||||
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Run extends XmlComponent {
|
export class Run extends XmlComponent {
|
||||||
private properties: RunProperties;
|
private properties: RunProperties;
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:r");
|
super("w:r");
|
||||||
this.properties = new RunProperties();
|
this.properties = new RunProperties();
|
||||||
this.root.push(this.properties);
|
this.root.push(this.properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
bold(): Run {
|
public bold(): Run {
|
||||||
this.properties.push(new Bold());
|
this.properties.push(new Bold());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
italic(): Run {
|
public italic(): Run {
|
||||||
this.properties.push(new Italics());
|
this.properties.push(new Italics());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
underline(): Run {
|
public underline(): Run {
|
||||||
this.properties.push(new Underline());
|
this.properties.push(new Underline());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
break(): Run {
|
public break(): Run {
|
||||||
this.root.splice(1, 0, new Break());
|
this.root.splice(1, 0, new Break());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
tab(): Run {
|
public tab(): Run {
|
||||||
this.root.splice(1, 0, new Tab());
|
this.root.splice(1, 0, new Tab());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
smallCaps(): Run {
|
public smallCaps(): Run {
|
||||||
this.properties.push(new SmallCaps());
|
this.properties.push(new SmallCaps());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
allCaps(): Run {
|
public allCaps(): Run {
|
||||||
this.properties.push(new Caps());
|
this.properties.push(new Caps());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
strike(): Run {
|
public strike(): Run {
|
||||||
this.properties.push(new Strike());
|
this.properties.push(new Strike());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
doubleStrike(): Run {
|
public doubleStrike(): Run {
|
||||||
this.properties.push(new DoubleStrike());
|
this.properties.push(new DoubleStrike());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
subScript(): Run {
|
public subScript(): Run {
|
||||||
this.properties.push(new SubScript());
|
this.properties.push(new SubScript());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
superScript(): Run {
|
public superScript(): Run {
|
||||||
this.properties.push(new SuperScript());
|
this.properties.push(new SuperScript());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public font(fontName: string): Run {
|
||||||
|
this.properties.push(new RunFonts(fontName));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class RunProperties extends XmlComponent {
|
export class RunProperties extends XmlComponent {
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ export class RunProperties extends XmlComponent {
|
|||||||
super("w:rPr");
|
super("w:rPr");
|
||||||
}
|
}
|
||||||
|
|
||||||
push(item: XmlComponent): void {
|
public push(item: XmlComponent): void {
|
||||||
this.root.push(item);
|
this.root.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
ts/docx/run/run-fonts.ts
Normal file
30
ts/docx/run/run-fonts.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
|
interface IRunFontAttributesProperties {
|
||||||
|
ascii: string;
|
||||||
|
hAnsi: string;
|
||||||
|
hint?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunFontAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
|
constructor(properties: IRunFontAttributesProperties) {
|
||||||
|
super({
|
||||||
|
ascii: "w:ascii",
|
||||||
|
hAnsi: "w:hAnsi",
|
||||||
|
hint: "w:hint",
|
||||||
|
}, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RunFonts extends XmlComponent {
|
||||||
|
|
||||||
|
constructor(ascii: string, hint?: string) {
|
||||||
|
super("w:rFonts");
|
||||||
|
this.root.push(new RunFontAttributes({
|
||||||
|
ascii: ascii,
|
||||||
|
hAnsi: ascii,
|
||||||
|
hint: hint,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
abstract class VerticalAlign extends XmlComponent {
|
abstract class VerticalAlign extends XmlComponent {
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super("w:vertAlign");
|
super("w:vertAlign");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: type
|
val: type,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,4 +22,4 @@ export class SubScript extends VerticalAlign {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("subscript");
|
super("subscript");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Strike extends XmlComponent {
|
export class Strike extends XmlComponent {
|
||||||
|
|
||||||
@ -12,4 +12,4 @@ export class DoubleStrike extends XmlComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("w:dstrike");
|
super("w:dstrike");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {XmlComponent} from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Tab extends XmlComponent {
|
export class Tab extends XmlComponent {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:tab");
|
super("w:tab");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Text} from "./text";
|
import { Run } from "../run";
|
||||||
import {Run} from "../run";
|
import { Text } from "./text";
|
||||||
|
|
||||||
export class TextRun extends Run {
|
export class TextRun extends Run {
|
||||||
|
|
||||||
@ -7,4 +7,4 @@ export class TextRun extends Run {
|
|||||||
super();
|
super();
|
||||||
this.root.push(new Text(text));
|
this.root.push(new Text(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlUnitComponent} from "../xml-components"
|
import { XmlUnitComponent } from "../xml-components";
|
||||||
|
|
||||||
export class Text extends XmlUnitComponent {
|
export class Text extends XmlUnitComponent {
|
||||||
|
|
||||||
@ -6,4 +6,4 @@ export class Text extends XmlUnitComponent {
|
|||||||
super("w:t");
|
super("w:t");
|
||||||
this.root = text;
|
this.root = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, Attributes} from "../xml-components";
|
import { Attributes, XmlComponent } from "../xml-components";
|
||||||
|
|
||||||
abstract class BaseUnderline extends XmlComponent {
|
abstract class BaseUnderline extends XmlComponent {
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ abstract class BaseUnderline extends XmlComponent {
|
|||||||
super("w:u");
|
super("w:u");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: underlineType,
|
val: underlineType,
|
||||||
color: color
|
color: color,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,6 @@ export class DoubleUnderline extends BaseUnderline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class SingleUnderline extends BaseUnderline {
|
export class SingleUnderline extends BaseUnderline {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -129,4 +128,4 @@ export class WordsUnderline extends BaseUnderline {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("words");
|
super("words");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {XmlAttributeComponent} from "./default-attributes";
|
import { XmlAttributeComponent } from "./default-attributes";
|
||||||
|
|
||||||
interface AttributesProperties {
|
interface IAttributesProperties {
|
||||||
val?: any;
|
val?: string | number | boolean;
|
||||||
color?: string;
|
color?: string;
|
||||||
space?: string;
|
space?: string;
|
||||||
sz?: string;
|
sz?: string;
|
||||||
@ -24,7 +24,7 @@ interface AttributesProperties {
|
|||||||
|
|
||||||
export class Attributes extends XmlAttributeComponent {
|
export class Attributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
constructor(properties?: AttributesProperties) {
|
constructor(properties?: IAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
val: "w:val",
|
val: "w:val",
|
||||||
color: "w:color",
|
color: "w:color",
|
||||||
@ -44,7 +44,7 @@ export class Attributes extends XmlAttributeComponent {
|
|||||||
footer: "w:footer",
|
footer: "w:footer",
|
||||||
gutter: "w:gutter",
|
gutter: "w:gutter",
|
||||||
linePitch: "w:linePitch",
|
linePitch: "w:linePitch",
|
||||||
pos: "w:pos"
|
pos: "w:pos",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@ export abstract class BaseXmlComponent {
|
|||||||
this.rootKey = rootKey;
|
this.rootKey = rootKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract replaceKey(): void;
|
public abstract replaceKey(): void;
|
||||||
clearVariables(): void {
|
|
||||||
};
|
public clearVariables(): void {
|
||||||
}
|
// Do Nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {BaseXmlComponent} from "./base";
|
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
|
import { BaseXmlComponent } from "./base";
|
||||||
|
|
||||||
export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
||||||
protected root: Object;
|
protected root: Object;
|
||||||
@ -16,10 +16,10 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceKey(): void {
|
public replaceKey(): void {
|
||||||
if (this.root !== undefined) {
|
if (this.root !== undefined) {
|
||||||
_.forOwn(this.root, (value, key) => {
|
_.forOwn(this.root, (value, key) => {
|
||||||
let newKey = this.xmlKeys[key];
|
const newKey = this.xmlKeys[key];
|
||||||
this.root[newKey] = value;
|
this.root[newKey] = value;
|
||||||
delete this.root[key];
|
delete this.root[key];
|
||||||
});
|
});
|
||||||
@ -27,4 +27,4 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
|||||||
delete this.root;
|
delete this.root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
import {BaseXmlComponent} from "./base";
|
import { BaseXmlComponent } from "./base";
|
||||||
|
|
||||||
export abstract class XmlComponent extends BaseXmlComponent {
|
export abstract class XmlComponent extends BaseXmlComponent {
|
||||||
protected root: Array<BaseXmlComponent>;
|
protected root: BaseXmlComponent[];
|
||||||
|
|
||||||
constructor(rootKey: string) {
|
constructor(rootKey: string) {
|
||||||
super(rootKey);
|
super(rootKey);
|
||||||
this.root = new Array<BaseXmlComponent>();
|
this.root = new Array<BaseXmlComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceKey(): void {
|
public replaceKey(): void {
|
||||||
// console.log(this.rootKey);
|
// console.log(this.rootKey);
|
||||||
// console.log(this.root);
|
// console.log(this.root);
|
||||||
if (this.root !== undefined) {
|
if (this.root !== undefined) {
|
||||||
this.root.forEach(root => {
|
this.root.forEach((root) => {
|
||||||
if (root && root instanceof BaseXmlComponent) {
|
if (root && root instanceof BaseXmlComponent) {
|
||||||
root.replaceKey();
|
root.replaceKey();
|
||||||
}
|
}
|
||||||
@ -27,4 +27,4 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
|||||||
export * from "./attributes"
|
export * from "./attributes"
|
||||||
export * from "./default-attributes";
|
export * from "./default-attributes";
|
||||||
export * from "./unit";
|
export * from "./unit";
|
||||||
export * from "./property";
|
export * from "./property";
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import {XmlComponent} from "./";
|
import { ParagraphProperties } from "../paragraph/properties";
|
||||||
import {ParagraphProperties} from "../paragraph/properties";
|
import { RunProperties } from "../run/properties";
|
||||||
import {RunProperties} from "../run/properties";
|
import { XmlComponent } from "./";
|
||||||
|
|
||||||
export class ParagraphPropertyXmlComponent extends XmlComponent {
|
export class ParagraphPropertyXmlComponent extends XmlComponent {
|
||||||
private paragraphProperties: ParagraphProperties;
|
private paragraphProperties: ParagraphProperties;
|
||||||
|
|
||||||
constructor(rootKey) {
|
constructor(rootKey: string) {
|
||||||
super(rootKey);
|
super(rootKey);
|
||||||
this.paragraphProperties = new ParagraphProperties();
|
this.paragraphProperties = new ParagraphProperties();
|
||||||
this.root.push(this.paragraphProperties);
|
this.root.push(this.paragraphProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.paragraphProperties.clearVariables();
|
this.paragraphProperties.clearVariables();
|
||||||
|
|
||||||
delete this.paragraphProperties;
|
delete this.paragraphProperties;
|
||||||
@ -21,13 +21,13 @@ export class ParagraphPropertyXmlComponent extends XmlComponent {
|
|||||||
export class RunPropertyXmlComponent extends XmlComponent {
|
export class RunPropertyXmlComponent extends XmlComponent {
|
||||||
private runProperties: RunProperties;
|
private runProperties: RunProperties;
|
||||||
|
|
||||||
constructor(rootKey) {
|
constructor(rootKey: string) {
|
||||||
super(rootKey);
|
super(rootKey);
|
||||||
this.runProperties = new RunProperties();
|
this.runProperties = new RunProperties();
|
||||||
this.root.push(this.runProperties);
|
this.root.push(this.runProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.runProperties.clearVariables();
|
this.runProperties.clearVariables();
|
||||||
|
|
||||||
delete this.runProperties;
|
delete this.runProperties;
|
||||||
@ -38,7 +38,7 @@ export class MultiPropertyXmlComponent extends XmlComponent {
|
|||||||
private runProperties: RunProperties;
|
private runProperties: RunProperties;
|
||||||
private paragraphProperties: ParagraphProperties;
|
private paragraphProperties: ParagraphProperties;
|
||||||
|
|
||||||
constructor(rootKey) {
|
constructor(rootKey: string) {
|
||||||
super(rootKey);
|
super(rootKey);
|
||||||
this.runProperties = new RunProperties();
|
this.runProperties = new RunProperties();
|
||||||
this.root.push(this.runProperties);
|
this.root.push(this.runProperties);
|
||||||
@ -47,11 +47,11 @@ export class MultiPropertyXmlComponent extends XmlComponent {
|
|||||||
this.root.push(this.paragraphProperties);
|
this.root.push(this.paragraphProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.runProperties.clearVariables();
|
this.runProperties.clearVariables();
|
||||||
this.paragraphProperties.clearVariables();
|
this.paragraphProperties.clearVariables();
|
||||||
|
|
||||||
delete this.runProperties;
|
delete this.runProperties;
|
||||||
delete this.paragraphProperties;
|
delete this.paragraphProperties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ export abstract class XmlUnitComponent extends BaseXmlComponent {
|
|||||||
super(rootKey);
|
super(rootKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceKey(): void {
|
public replaceKey(): void {
|
||||||
if (this.root !== undefined) {
|
if (this.root !== undefined) {
|
||||||
this[this.rootKey] = this.root;
|
this[this.rootKey] = this.root;
|
||||||
delete this.root;
|
delete this.root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,10 @@ import {XmlComponent} from "../docx/xml-components";
|
|||||||
|
|
||||||
export class Formatter {
|
export class Formatter {
|
||||||
|
|
||||||
format(input: any): Object {
|
public format(input: any): Object {
|
||||||
input.clearVariables();
|
input.clearVariables();
|
||||||
this.replaceKeys(input);
|
this.replaceKeys(input);
|
||||||
let newJson = this.clense(input);
|
const newJson = this.clense(input);
|
||||||
// console.log(JSON.stringify(newJson, null, " "));
|
// console.log(JSON.stringify(newJson, null, " "));
|
||||||
return newJson;
|
return newJson;
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ export class Formatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private clense(input: any): Object {
|
private clense(input: any): Object {
|
||||||
let newJson = this.jsonify(input);
|
const newJson = this.jsonify(input);
|
||||||
|
|
||||||
this.deepTraverseJson(newJson, (parent, value, key) => {
|
this.deepTraverseJson(newJson, (parent, value, key) => {
|
||||||
if (key === "properties") {
|
if (key === "properties") {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
export {LocalPacker} from "./packer/local";
|
export { LocalPacker } from "./packer/local";
|
||||||
export {ExpressPacker} from "./packer/express";
|
export { ExpressPacker } from "./packer/express";
|
@ -1,9 +1,10 @@
|
|||||||
import {Packer} from "./packer";
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import {Document} from "../../docx/document";
|
import * as fs from "fs";
|
||||||
import {Properties} from "../../properties";
|
import { Document } from "../../docx/document";
|
||||||
import {Numbering} from "../../numbering";
|
import { Numbering } from "../../numbering";
|
||||||
|
import { Properties } from "../../properties";
|
||||||
|
import { Packer } from "./packer";
|
||||||
|
|
||||||
|
|
||||||
export class ExpressPacker extends Packer {
|
export class ExpressPacker extends Packer {
|
||||||
private res: express.Response;
|
private res: express.Response;
|
||||||
@ -17,8 +18,8 @@ export class ExpressPacker extends Packer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pack(name: string): void {
|
public pack(name: string): void {
|
||||||
this.res.attachment(name + ".docx");
|
this.res.attachment(name + ".docx");
|
||||||
super.pack(this.res);
|
super.pack(this.res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import {Packer} from "./packer";
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {Document} from "../../docx/document";
|
import { Document } from "../../docx/document";
|
||||||
import {Properties} from "../../properties";
|
import { Numbering } from "../../numbering";
|
||||||
import {Numbering} from "../../numbering";
|
import { Properties } from "../../properties";
|
||||||
|
import { Packer } from "./packer";
|
||||||
|
|
||||||
|
|
||||||
export class LocalPacker extends Packer {
|
export class LocalPacker extends Packer {
|
||||||
private stream: fs.WriteStream;
|
private stream: fs.WriteStream;
|
||||||
@ -11,8 +12,8 @@ export class LocalPacker extends Packer {
|
|||||||
super(document, styles, properties, numbering);
|
super(document, styles, properties, numbering);
|
||||||
}
|
}
|
||||||
|
|
||||||
pack(path: string): void {
|
public pack(path: string): void {
|
||||||
this.stream = fs.createWriteStream(path);
|
this.stream = fs.createWriteStream(path);
|
||||||
super.pack(this.stream);
|
super.pack(this.stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import * as archiver from "archiver";
|
import * as archiver from "archiver";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as xml from "xml";
|
import * as xml from "xml";
|
||||||
import {Formatter} from "../formatter";
|
import { Document } from "../../docx";
|
||||||
import {Document} from "../../docx";
|
import { Numbering } from "../../numbering";
|
||||||
import {Styles} from "../../styles";
|
import { Properties } from "../../properties";
|
||||||
import {Properties} from "../../properties";
|
import { Styles } from "../../styles";
|
||||||
import {Numbering} from "../../numbering";
|
import { DefaultStylesFactory } from "../../styles/factory";
|
||||||
import {DefaultStylesFactory} from "../../styles/factory";
|
import { Formatter } from "../formatter";
|
||||||
|
|
||||||
let appRoot = require("app-root-path");
|
const appRoot = require("app-root-path");
|
||||||
|
|
||||||
export abstract class Packer {
|
export abstract class Packer {
|
||||||
protected archive: any;
|
protected archive: any;
|
||||||
private formatter: Formatter;
|
|
||||||
protected document: Document;
|
protected document: Document;
|
||||||
|
private formatter: Formatter;
|
||||||
private style: Styles;
|
private style: Styles;
|
||||||
private properties: Properties;
|
private properties: Properties;
|
||||||
private numbering: Numbering;
|
private numbering: Numbering;
|
||||||
@ -27,7 +27,7 @@ export abstract class Packer {
|
|||||||
this.archive = archiver.create("zip", {});
|
this.archive = archiver.create("zip", {});
|
||||||
|
|
||||||
if (!style) {
|
if (!style) {
|
||||||
let stylesFactory = new DefaultStylesFactory();
|
const stylesFactory = new DefaultStylesFactory();
|
||||||
this.style = stylesFactory.newInstance();
|
this.style = stylesFactory.newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ export abstract class Packer {
|
|||||||
this.properties = new Properties({
|
this.properties = new Properties({
|
||||||
creator: "Un-named",
|
creator: "Un-named",
|
||||||
revision: "1",
|
revision: "1",
|
||||||
lastModifiedBy: "Un-named"
|
lastModifiedBy: "Un-named",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ export abstract class Packer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pack(output: any): void {
|
public pack(output: any): void {
|
||||||
this.archive.pipe(output);
|
this.archive.pipe(output);
|
||||||
console.log(appRoot.path + "/template");
|
console.log(appRoot.path + "/template");
|
||||||
this.archive.glob("**", {
|
this.archive.glob("**", {
|
||||||
@ -69,28 +69,28 @@ export abstract class Packer {
|
|||||||
name: "/root/g.txt",
|
name: "/root/g.txt",
|
||||||
prefix: "root"
|
prefix: "root"
|
||||||
});*/
|
});*/
|
||||||
let xmlDocument = xml(this.formatter.format(this.document));
|
const xmlDocument = xml(this.formatter.format(this.document));
|
||||||
let xmlStyles = xml(this.formatter.format(this.style));
|
const xmlStyles = xml(this.formatter.format(this.style));
|
||||||
let xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: "yes", encoding: "UTF-8" } });
|
const xmlProperties = xml(this.formatter.format(this.properties), { declaration: { standalone: "yes", encoding: "UTF-8" } });
|
||||||
let xmlNumbering = xml(this.formatter.format(this.numbering));
|
const xmlNumbering = xml(this.formatter.format(this.numbering));
|
||||||
// console.log(JSON.stringify(this.numbering, null, " "));
|
// console.log(JSON.stringify(this.numbering, null, " "));
|
||||||
console.log(xmlNumbering);
|
console.log(xmlNumbering);
|
||||||
this.archive.append(xmlDocument, {
|
this.archive.append(xmlDocument, {
|
||||||
name: "word/document.xml"
|
name: "word/document.xml",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.archive.append(xmlStyles, {
|
this.archive.append(xmlStyles, {
|
||||||
name: "word/styles.xml"
|
name: "word/styles.xml",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.archive.append(xmlProperties, {
|
this.archive.append(xmlProperties, {
|
||||||
name: "docProps/core.xml"
|
name: "docProps/core.xml",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.archive.append(xmlNumbering, {
|
this.archive.append(xmlNumbering, {
|
||||||
name: "word/numbering.xml"
|
name: "word/numbering.xml",
|
||||||
});
|
});
|
||||||
|
|
||||||
this.archive.finalize();
|
this.archive.finalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from "./docx";
|
export * from "./docx";
|
||||||
export * from "./export";
|
export * from "./export";
|
||||||
|
export { Numbering } from "./numbering";
|
||||||
|
@ -1,42 +1,50 @@
|
|||||||
import {XmlComponent} from "../docx/xml-components";
|
|
||||||
import {XmlAttributeComponent} from "../docx/xml-components";
|
|
||||||
import {Level} from "./level";
|
|
||||||
import {MultiLevelType} from "./multi-level-type";
|
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
|
import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
||||||
|
import { Level } from "./level";
|
||||||
|
import { MultiLevelType } from "./multi-level-type";
|
||||||
|
|
||||||
interface AbstractNumberingAttributesProperties {
|
interface IAbstractNumberingAttributesProperties {
|
||||||
abstractNumId?: number;
|
abstractNumId?: number;
|
||||||
restartNumberingAfterBreak?: number;
|
restartNumberingAfterBreak?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AbstractNumberingAttributes extends XmlAttributeComponent {
|
class AbstractNumberingAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
constructor(properties: AbstractNumberingAttributesProperties) {
|
constructor(properties: IAbstractNumberingAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
abstractNumId: "w:abstractNumId",
|
abstractNumId: "w:abstractNumId",
|
||||||
restartNumberingAfterBreak: "w15:restartNumberingAfterBreak"
|
restartNumberingAfterBreak: "w15:restartNumberingAfterBreak",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AbstractNumbering extends XmlComponent {
|
export class AbstractNumbering extends XmlComponent {
|
||||||
|
public id: number;
|
||||||
|
|
||||||
constructor(id: number) {
|
constructor(id: number) {
|
||||||
super("w:abstractNum");
|
super("w:abstractNum");
|
||||||
this.root.push(new AbstractNumberingAttributes({
|
this.root.push(new AbstractNumberingAttributes({
|
||||||
abstractNumId: id,
|
abstractNumId: id,
|
||||||
restartNumberingAfterBreak: 0
|
restartNumberingAfterBreak: 0,
|
||||||
}));
|
}));
|
||||||
this.root.push(new MultiLevelType("hybridMultilevel"));
|
this.root.push(new MultiLevelType("hybridMultilevel"));
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
addLevel(level: Level): void {
|
public addLevel(level: Level): void {
|
||||||
this.root.push(level);
|
this.root.push(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables() {
|
public createLevel(num: number, format: string, text: string, align: string = "start"): Level {
|
||||||
_.forEach(this.root, element => {
|
const level = new Level(num, format, text, align);
|
||||||
|
this.addLevel(level);
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearVariables(): void {
|
||||||
|
_.forEach(this.root, (element) => {
|
||||||
element.clearVariables();
|
element.clearVariables();
|
||||||
});
|
});
|
||||||
|
delete this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
||||||
|
|
||||||
interface IndentAttributesProperties {
|
interface IndentAttributesProperties {
|
||||||
left: number;
|
left: number;
|
||||||
@ -10,7 +10,7 @@ class IndentAttributes extends XmlAttributeComponent {
|
|||||||
constructor(properties: IndentAttributesProperties) {
|
constructor(properties: IndentAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
left: "w:left",
|
left: "w:left",
|
||||||
hanging: "w:hanging"
|
hanging: "w:hanging",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ export class Indent extends XmlComponent {
|
|||||||
super("w:ind");
|
super("w:ind");
|
||||||
this.root.push(new IndentAttributes({
|
this.root.push(new IndentAttributes({
|
||||||
left: left,
|
left: left,
|
||||||
hanging: hanging
|
hanging: hanging,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import {MultiPropertyXmlComponent} from "../docx/xml-components";
|
|
||||||
import {DocumentAttributes} from "../docx/document/document-attributes";
|
|
||||||
import {AbstractNumbering} from "./abstract-numbering";
|
|
||||||
import {Level} from "./level";
|
|
||||||
import {Indent} from "./indent";
|
|
||||||
import {RunFonts} from "./run-fonts";
|
|
||||||
import {Num} from "./num";
|
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
|
import { DocumentAttributes } from "../docx/document/document-attributes";
|
||||||
|
import { RunFonts } from "../docx/run/run-fonts";
|
||||||
|
import { MultiPropertyXmlComponent } from "../docx/xml-components";
|
||||||
|
import { AbstractNumbering } from "./abstract-numbering";
|
||||||
|
import { Indent } from "./indent";
|
||||||
|
import { Level } from "./level";
|
||||||
|
import { Num } from "./num";
|
||||||
|
|
||||||
export class Numbering extends MultiPropertyXmlComponent {
|
export class Numbering extends MultiPropertyXmlComponent {
|
||||||
|
private nextId: number;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:numbering");
|
super("w:numbering");
|
||||||
@ -28,65 +29,69 @@ export class Numbering extends MultiPropertyXmlComponent {
|
|||||||
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
wpi: "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
||||||
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
wne: "http://schemas.microsoft.com/office/word/2006/wordml",
|
||||||
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
||||||
Ignorable: "w14 w15 wp14"
|
Ignorable: "w14 w15 wp14",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let abstractNumbering = new AbstractNumbering(0);
|
this.nextId = 0;
|
||||||
|
|
||||||
let level0 = new Level(0, "bullet", "•", "left");
|
const abstractNumbering = this.createAbstractNumbering();
|
||||||
level0.addParagraphProperty(new Indent(720, 360));
|
|
||||||
level0.addRunProperty(new RunFonts("Symbol", "default"));
|
|
||||||
abstractNumbering.addLevel(level0);
|
|
||||||
|
|
||||||
let level1 = new Level(1, "bullet", "o", "left");
|
abstractNumbering.createLevel(0, "bullet", "•", "left")
|
||||||
level1.addParagraphProperty(new Indent(1440, 360));
|
.addParagraphProperty(new Indent(720, 360))
|
||||||
level1.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
abstractNumbering.addLevel(level1);
|
|
||||||
|
|
||||||
let level2 = new Level(2, "bullet", "•", "left");
|
abstractNumbering.createLevel(1, "bullet", "o", "left")
|
||||||
level2.addParagraphProperty(new Indent(2160, 360));
|
.addParagraphProperty(new Indent(1440, 360))
|
||||||
level2.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
abstractNumbering.addLevel(level2);
|
|
||||||
|
|
||||||
let level3 = new Level(3, "bullet", "•", "left");
|
abstractNumbering.createLevel(2, "bullet", "•", "left")
|
||||||
level3.addParagraphProperty(new Indent(2880, 360));
|
.addParagraphProperty(new Indent(2160, 360))
|
||||||
level3.addRunProperty(new RunFonts("Symbol", "default"));
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
abstractNumbering.addLevel(level3);
|
|
||||||
|
|
||||||
let level4 = new Level(4, "bullet", "o", "left");
|
abstractNumbering.createLevel(3, "bullet", "•", "left")
|
||||||
level4.addParagraphProperty(new Indent(3600, 360));
|
.addParagraphProperty(new Indent(2880, 360))
|
||||||
level4.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
abstractNumbering.addLevel(level4);
|
|
||||||
|
|
||||||
let level5 = new Level(5, "bullet", "•", "left");
|
abstractNumbering.createLevel(4, "bullet", "o", "left")
|
||||||
level5.addParagraphProperty(new Indent(4320, 360));
|
.addParagraphProperty(new Indent(3600, 360))
|
||||||
level5.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
abstractNumbering.addLevel(level5);
|
|
||||||
|
|
||||||
let level6 = new Level(6, "bullet", "•", "left");
|
abstractNumbering.createLevel(5, "bullet", "•", "left")
|
||||||
level6.addParagraphProperty(new Indent(5040, 360));
|
.addParagraphProperty(new Indent(4320, 360))
|
||||||
level6.addRunProperty(new RunFonts("Symbol", "default"));
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
abstractNumbering.addLevel(level6);
|
|
||||||
|
|
||||||
let level7 = new Level(4, "bullet", "o", "left");
|
abstractNumbering.createLevel(6, "bullet", "•", "left")
|
||||||
level7.addParagraphProperty(new Indent(5760, 360));
|
.addParagraphProperty(new Indent(5040, 360))
|
||||||
level7.addRunProperty(new RunFonts("Courier New", "default"));
|
.addRunProperty(new RunFonts("Symbol", "default"));
|
||||||
abstractNumbering.addLevel(level7);
|
|
||||||
|
|
||||||
let level8 = new Level(5, "bullet", "•", "left");
|
abstractNumbering.createLevel(7, "bullet", "o", "left")
|
||||||
level8.addParagraphProperty(new Indent(6480, 360));
|
.addParagraphProperty(new Indent(5760, 360))
|
||||||
level8.addRunProperty(new RunFonts("Wingdings", "default"));
|
.addRunProperty(new RunFonts("Courier New", "default"));
|
||||||
abstractNumbering.addLevel(level8);
|
|
||||||
|
|
||||||
this.root.push(abstractNumbering);
|
abstractNumbering.createLevel(8, "bullet", "•", "left")
|
||||||
this.root.push(new Num(1, 0));
|
.addParagraphProperty(new Indent(6480, 360))
|
||||||
|
.addRunProperty(new RunFonts("Wingdings", "default"));
|
||||||
|
|
||||||
|
this.createConcreteNumbering(abstractNumbering);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables() {
|
public createAbstractNumbering(): AbstractNumbering {
|
||||||
|
const num = new AbstractNumbering(this.nextId++);
|
||||||
|
this.root.push(num);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public createConcreteNumbering(abstractNumbering: AbstractNumbering): Num {
|
||||||
|
const num = new Num(this.nextId++, abstractNumbering.id);
|
||||||
|
this.root.push(num);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearVariables(): void {
|
||||||
super.clearVariables();
|
super.clearVariables();
|
||||||
_.forEach(this.root, element => {
|
_.forEach(this.root, (element) => {
|
||||||
console.log(element);
|
|
||||||
element.clearVariables();
|
element.clearVariables();
|
||||||
});
|
});
|
||||||
|
delete this.nextId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
import {XmlComponent, Attributes, MultiPropertyXmlComponent} from "../docx/xml-components";
|
import { ParagraphProperties } from "../docx/paragraph/properties";
|
||||||
import {XmlAttributeComponent} from "../docx/xml-components";
|
import { RunProperties } from "../docx/run/properties";
|
||||||
import {RunProperties} from "../docx/run/properties";
|
import { Attributes, MultiPropertyXmlComponent, XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
||||||
import {ParagraphProperties} from "../docx/paragraph/properties";
|
|
||||||
|
|
||||||
interface LevelAttributesProperties {
|
interface ILevelAttributesProperties {
|
||||||
ilvl?: number;
|
ilvl?: number;
|
||||||
tentative?: number;
|
tentative?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LevelAttributes extends XmlAttributeComponent {
|
class LevelAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
constructor(properties: LevelAttributesProperties) {
|
constructor(properties: ILevelAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
ilvl: "w:ilvl",
|
ilvl: "w:ilvl",
|
||||||
tentative: "w15:tentative"
|
tentative: "w15:tentative",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,7 +22,7 @@ class Start extends XmlComponent {
|
|||||||
constructor(value: number) {
|
constructor(value: number) {
|
||||||
super("w:start");
|
super("w:start");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +32,7 @@ class NumberFormat extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:numFmt");
|
super("w:numFmt");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +42,7 @@ class LevelText extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:lvlText");
|
super("w:lvlText");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ class LevelJc extends XmlComponent {
|
|||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:lvlJc");
|
super("w:lvlJc");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +65,7 @@ export class Level extends XmlComponent {
|
|||||||
super("w:lvl");
|
super("w:lvl");
|
||||||
this.root.push(new LevelAttributes({
|
this.root.push(new LevelAttributes({
|
||||||
ilvl: level,
|
ilvl: level,
|
||||||
tentative: 1
|
tentative: 1,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.root.push(new Start(1));
|
this.root.push(new Start(1));
|
||||||
@ -81,7 +80,7 @@ export class Level extends XmlComponent {
|
|||||||
this.root.push(this.runProperties);
|
this.root.push(this.runProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearVariables(): void {
|
public clearVariables(): void {
|
||||||
this.paragraphProperties.clearVariables();
|
this.paragraphProperties.clearVariables();
|
||||||
this.runProperties.clearVariables();
|
this.runProperties.clearVariables();
|
||||||
|
|
||||||
@ -89,11 +88,13 @@ export class Level extends XmlComponent {
|
|||||||
delete this.runProperties;
|
delete this.runProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
addParagraphProperty(property: XmlComponent): void {
|
public addParagraphProperty(property: XmlComponent): Level {
|
||||||
this.paragraphProperties.push(property);
|
this.paragraphProperties.push(property);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
addRunProperty(property: XmlComponent): void {
|
public addRunProperty(property: XmlComponent): Level {
|
||||||
this.runProperties.push(property);
|
this.runProperties.push(property);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {XmlComponent, Attributes} from "../docx/xml-components";
|
import { Attributes, XmlComponent } from "../docx/xml-components";
|
||||||
|
|
||||||
export class MultiLevelType extends XmlComponent {
|
export class MultiLevelType extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:multiLevelType");
|
super("w:multiLevelType");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,42 @@
|
|||||||
import {XmlComponent, Attributes, XmlAttributeComponent} from "../docx/xml-components";
|
import { Attributes, XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
||||||
|
|
||||||
class AbstractNumId extends XmlComponent {
|
class AbstractNumId extends XmlComponent {
|
||||||
|
|
||||||
constructor(value: number) {
|
constructor(value: number) {
|
||||||
super("w:abstractNumId");
|
super("w:abstractNumId");
|
||||||
this.root.push(new Attributes({
|
this.root.push(new Attributes({
|
||||||
val: value
|
val: value,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface NumAttributesProperties {
|
interface INumAttributesProperties {
|
||||||
numId: number;
|
numId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NumAttributes extends XmlAttributeComponent {
|
class NumAttributes extends XmlAttributeComponent {
|
||||||
|
|
||||||
constructor(properties: NumAttributesProperties) {
|
constructor(properties: INumAttributesProperties) {
|
||||||
super({
|
super({
|
||||||
numId: "w:numId"
|
numId: "w:numId",
|
||||||
}, properties);
|
}, properties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Num extends XmlComponent {
|
export class Num extends XmlComponent {
|
||||||
|
public id: number;
|
||||||
|
|
||||||
constructor(numId: number, abstractNumId: number) {
|
constructor(numId: number, abstractNumId: number) {
|
||||||
super("w:num");
|
super("w:num");
|
||||||
this.root.push(new NumAttributes({
|
this.root.push(new NumAttributes({
|
||||||
numId: numId
|
numId: numId,
|
||||||
}));
|
}));
|
||||||
this.root.push(new AbstractNumId(abstractNumId));
|
this.root.push(new AbstractNumId(abstractNumId));
|
||||||
|
this.id = numId;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public clearVariables(): void {
|
||||||
|
super.clearVariables();
|
||||||
|
delete this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
import {XmlComponent, XmlAttributeComponent} from "../docx/xml-components";
|
|
||||||
|
|
||||||
interface RunFontAttributesProperties {
|
|
||||||
ascii: string;
|
|
||||||
hAnsi: string;
|
|
||||||
hint: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RunFontAttributes extends XmlAttributeComponent {
|
|
||||||
|
|
||||||
constructor(properties: RunFontAttributesProperties) {
|
|
||||||
super({
|
|
||||||
left: "w:left",
|
|
||||||
hanging: "w:hanging"
|
|
||||||
}, properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RunFonts extends XmlComponent {
|
|
||||||
|
|
||||||
constructor(ascii: string, hint: string) {
|
|
||||||
super("w:ind");
|
|
||||||
this.root.push(new RunFontAttributes({
|
|
||||||
ascii: ascii,
|
|
||||||
hAnsi: ascii,
|
|
||||||
hint: hint
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
import {XmlUnitComponent} from "../docx/xml-components";
|
import { DocumentAttributes } from "../docx/document/document-attributes";
|
||||||
import {XmlComponent} from "../docx/xml-components";
|
import { XmlUnitComponent } from "../docx/xml-components";
|
||||||
import {DocumentAttributes} from "../docx/document/document-attributes";
|
import { XmlComponent } from "../docx/xml-components";
|
||||||
|
|
||||||
export class Title extends XmlUnitComponent {
|
export class Title extends XmlUnitComponent {
|
||||||
|
|
||||||
@ -54,20 +54,20 @@ export class Revision extends XmlUnitComponent {
|
|||||||
|
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("cp:revision");
|
super("cp:revision");
|
||||||
let revision = value;
|
const revision = value;
|
||||||
this.root = value;
|
this.root = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class DateComponent extends XmlComponent {
|
abstract class DateComponent extends XmlComponent {
|
||||||
protected getCurrentDate(): any {
|
protected getCurrentDate(): any {
|
||||||
let date = new Date(),
|
const date = new Date();
|
||||||
year = date.getFullYear(),
|
const year = date.getFullYear();
|
||||||
month = ("0" + (date.getMonth() + 1)).slice(-2),
|
const month = ("0" + (date.getMonth() + 1)).slice(-2);
|
||||||
day = ("0" + date.getDate()).slice(-2),
|
const day = ("0" + date.getDate()).slice(-2);
|
||||||
hours = ("0" + date.getHours()).slice(-2),
|
const hours = ("0" + date.getHours()).slice(-2);
|
||||||
minutes = ("0" + date.getMinutes()).slice(-2),
|
const minutes = ("0" + date.getMinutes()).slice(-2);
|
||||||
seconds = ("0" + date.getSeconds()).slice(-2);
|
const seconds = ("0" + date.getSeconds()).slice(-2);
|
||||||
|
|
||||||
return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z";
|
return year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "Z";
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ export class Created extends DateComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("dcterms:created");
|
super("dcterms:created");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(new DocumentAttributes({
|
||||||
type: "dcterms:W3CDTF"
|
type: "dcterms:W3CDTF",
|
||||||
}));
|
}));
|
||||||
this.root.push(this.getCurrentDate());
|
this.root.push(this.getCurrentDate());
|
||||||
}
|
}
|
||||||
@ -89,8 +89,8 @@ export class Modified extends DateComponent {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super("dcterms:modified");
|
super("dcterms:modified");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(new DocumentAttributes({
|
||||||
type: "dcterms:W3CDTF"
|
type: "dcterms:W3CDTF",
|
||||||
}));
|
}));
|
||||||
this.root.push(this.getCurrentDate());
|
this.root.push(this.getCurrentDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {XmlComponent} from "../docx/xml-components";
|
import { DocumentAttributes } from "../docx/document/document-attributes";
|
||||||
import {DocumentAttributes} from "../docx/document/document-attributes";
|
import { XmlComponent } from "../docx/xml-components";
|
||||||
import {Title, Subject, Creator, Keywords, Description, LastModifiedBy, Revision, Created, Modified} from "./components";
|
import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";
|
||||||
|
|
||||||
interface PropertiesOptions {
|
interface IPropertiesOptions {
|
||||||
title?: string;
|
title?: string;
|
||||||
subject?: string;
|
subject?: string;
|
||||||
creator?: string;
|
creator?: string;
|
||||||
@ -14,14 +14,14 @@ interface PropertiesOptions {
|
|||||||
|
|
||||||
export class Properties extends XmlComponent {
|
export class Properties extends XmlComponent {
|
||||||
|
|
||||||
constructor(options: PropertiesOptions) {
|
constructor(options: IPropertiesOptions) {
|
||||||
super("cp:coreProperties");
|
super("cp:coreProperties");
|
||||||
this.root.push(new DocumentAttributes({
|
this.root.push(new DocumentAttributes({
|
||||||
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
||||||
dc: "http://purl.org/dc/elements/1.1/",
|
dc: "http://purl.org/dc/elements/1.1/",
|
||||||
dcterms: "http://purl.org/dc/terms/",
|
dcterms: "http://purl.org/dc/terms/",
|
||||||
dcmitype: "http://purl.org/dc/dcmitype/",
|
dcmitype: "http://purl.org/dc/dcmitype/",
|
||||||
xsi: "http://www.w3.org/2001/XMLSchema-instance"
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
}));
|
}));
|
||||||
this.root.push(new Title(options.title));
|
this.root.push(new Title(options.title));
|
||||||
this.root.push(new Subject(options.subject));
|
this.root.push(new Subject(options.subject));
|
||||||
@ -33,4 +33,4 @@ export class Properties extends XmlComponent {
|
|||||||
this.root.push(new Created());
|
this.root.push(new Created());
|
||||||
this.root.push(new Modified());
|
this.root.push(new Modified());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* tslint:disable */
|
||||||
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
function createLsdException(name, uiPriority, qFormat?, semiHidden?, unhideWhenUsed?) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
/// <reference path="../typings/mocha/mocha.d.ts" />
|
import { assert } from "chai";
|
||||||
/// <reference path="../typings/chai/chai.d.ts" />
|
|
||||||
|
|
||||||
import {assert} from "chai";
|
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
@ -11,7 +8,7 @@ function jsonify(obj: Object) {
|
|||||||
describe("", () => {
|
describe("", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#methodName()", () => {
|
describe("#methodName()", () => {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
import { Body } from "../../../docx/document/body";
|
||||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
import { assert } from "chai";
|
||||||
import {Body} from "../../../docx/document/body";
|
import { SectionProperties } from "../../../docx/document/body/section-properties";
|
||||||
import {assert} from "chai";
|
import { PageSize } from "../../../docx/document/body/page-size";
|
||||||
import {SectionProperties} from "../../../docx/document/body/section-properties";
|
import { PageMargin } from "../../../docx/document/body/page-margin";
|
||||||
import {PageSize} from "../../../docx/document/body/page-size";
|
import { Columns } from "../../../docx/document/body/columns";
|
||||||
import {PageMargin} from "../../../docx/document/body/page-margin";
|
import { DocumentGrid } from "../../../docx/document/body/doc-grid";
|
||||||
import {Columns} from "../../../docx/document/body/columns";
|
|
||||||
import {DocumentGrid} from "../../../docx/document/body/doc-grid";
|
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
|
||||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
|
||||||
|
|
||||||
import * as docx from "../../../docx";
|
import * as docx from "../../../docx";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
describe("Document", () => {
|
describe("Document", () => {
|
||||||
let document: docx.Document;
|
let document: docx.Document;
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
import { ThematicBreak } from "../../../docx/paragraph/border";
|
||||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
import { assert } from "chai";
|
||||||
|
|
||||||
import {ThematicBreak} from "../../../docx/paragraph/border";
|
|
||||||
import {assert} from "chai";
|
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {PageBreak} from "../../../docx/paragraph/page-break";
|
import { PageBreak } from "../../../docx/paragraph/page-break";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
@ -26,7 +26,7 @@ describe("PageBreak", () => {
|
|||||||
let newJson = jsonify(pageBreak);
|
let newJson = jsonify(pageBreak);
|
||||||
assert.equal(newJson.rootKey, "w:r");
|
assert.equal(newJson.rootKey, "w:r");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a Page Break with a Break inside", () => {
|
it("should create a Page Break with a Break inside", () => {
|
||||||
let newJson = jsonify(pageBreak);
|
let newJson = jsonify(pageBreak);
|
||||||
assert.equal(newJson.root[1].rootKey, "w:br");
|
assert.equal(newJson.root[1].rootKey, "w:br");
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
import { Style } from "../../../docx/paragraph/style";
|
||||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
import { assert } from "chai";
|
||||||
|
|
||||||
import {Style} from "../../../docx/paragraph/style";
|
|
||||||
import {assert} from "chai";
|
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
|
||||||
/// <reference path="../../../typings/chai/chai.d.ts" />
|
|
||||||
|
|
||||||
import * as docx from "../../../docx";
|
import * as docx from "../../../docx";
|
||||||
import {assert} from "chai";
|
import { Formatter } from "../../../export/formatter";
|
||||||
|
import { Numbering } from "../../../numbering";
|
||||||
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
@ -116,4 +115,44 @@ describe("Paragraph", () => {
|
|||||||
assert.isDefined(newJson.root[0].root[2]);
|
assert.isDefined(newJson.root[0].root[2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
describe("#setNumbering", () => {
|
||||||
|
it("should add list paragraph style to JSON", () => {
|
||||||
|
const numbering = new Numbering();
|
||||||
|
const numberedAbstract = numbering.createAbstractNumbering();
|
||||||
|
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "start");
|
||||||
|
const letterNumbering = numbering.createConcreteNumbering(numberedAbstract);
|
||||||
|
|
||||||
|
paragraph.setNumbering(letterNumbering, 0);
|
||||||
|
let newJson = jsonify(paragraph);
|
||||||
|
assert.equal(newJson.root[0].root[1].root[0].root.val, "ListParagraph");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("it should add numbered properties", () => {
|
||||||
|
const numbering = new Numbering();
|
||||||
|
const numberedAbstract = numbering.createAbstractNumbering();
|
||||||
|
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "start");
|
||||||
|
const letterNumbering = numbering.createConcreteNumbering(numberedAbstract);
|
||||||
|
|
||||||
|
paragraph.setNumbering(letterNumbering, 0);
|
||||||
|
const tree = new Formatter().format(paragraph);
|
||||||
|
console.log(JSON.stringify(tree, null, 2));
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:p": [
|
||||||
|
{
|
||||||
|
"w:pPr": [
|
||||||
|
{"_attr": {}},
|
||||||
|
{"w:pStyle": [{"_attr": {"w:val": "ListParagraph"}}]},
|
||||||
|
{
|
||||||
|
"w:numPr": [
|
||||||
|
{"w:ilvl": [{"_attr": {"w:val": 0}}]},
|
||||||
|
{"w:numId": [{"_attr": {"w:val": letterNumbering.id}}]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {LeftTabStop, MaxRightTabStop} from "../../../docx/paragraph/tab-stop";
|
import { LeftTabStop, MaxRightTabStop } from "../../../docx/paragraph/tab-stop";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {NumberProperties} from "../../../docx/paragraph/unordered-list";
|
import { NumberProperties } from "../../../docx/paragraph/unordered-list";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
@ -10,7 +10,7 @@ describe("NumberProperties", () => {
|
|||||||
let numberProperties: NumberProperties;
|
let numberProperties: NumberProperties;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
numberProperties = new NumberProperties();
|
numberProperties = new NumberProperties(5, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
@ -22,11 +22,13 @@ describe("NumberProperties", () => {
|
|||||||
it("should create a Page Break with a Indent Level inside", () => {
|
it("should create a Page Break with a Indent Level inside", () => {
|
||||||
let newJson = jsonify(numberProperties);
|
let newJson = jsonify(numberProperties);
|
||||||
assert.equal(newJson.root[0].rootKey, "w:ilvl");
|
assert.equal(newJson.root[0].rootKey, "w:ilvl");
|
||||||
|
assert.equal(newJson.root[0].root[0].root.val, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a Page Break with a Number Id inside", () => {
|
it("should create a Page Break with a Number Id inside", () => {
|
||||||
let newJson = jsonify(numberProperties);
|
let newJson = jsonify(numberProperties);
|
||||||
assert.equal(newJson.root[1].rootKey, "w:numId");
|
assert.equal(newJson.root[1].rootKey, "w:numId");
|
||||||
|
assert.equal(newJson.root[1].root[0].root.val, 5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,5 +1,5 @@
|
|||||||
import {Break} from "../../../docx/run/break";
|
import { Break } from "../../../docx/run/break";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
22
ts/tests/docx/run/fontTests.ts
Normal file
22
ts/tests/docx/run/fontTests.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { expect } from "chai";
|
||||||
|
import { RunFonts } from "../../../docx/run/run-fonts";
|
||||||
|
import { Formatter } from "../../../export/formatter";
|
||||||
|
|
||||||
|
describe("RunFonts", () => {
|
||||||
|
|
||||||
|
describe("#constructor()", () => {
|
||||||
|
it("uses the font name for both ascii and hAnsi", () => {
|
||||||
|
const tree = new Formatter().format(new RunFonts("Times"));
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses hint if given", () => {
|
||||||
|
const tree = new Formatter().format(new RunFonts("Times", "default"));
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times", "w:hint": "default"}}],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,10 +1,10 @@
|
|||||||
import {Run} from "../../../docx/run";
|
import { assert, expect } from "chai";
|
||||||
import {TextRun} from "../../../docx/run/text-run";
|
import { Run } from "../../../docx/run";
|
||||||
import {assert} from "chai";
|
import { TextRun } from "../../../docx/run/text-run";
|
||||||
|
import { Formatter } from "../../../export/formatter";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
return JSON.parse(JSON.stringify(obj));
|
||||||
return JSON.parse(stringifiedJson);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("Run", () => {
|
describe("Run", () => {
|
||||||
@ -17,7 +17,7 @@ describe("Run", () => {
|
|||||||
describe("#bold()", () => {
|
describe("#bold()", () => {
|
||||||
it("it should add bold to the properties", () => {
|
it("it should add bold to the properties", () => {
|
||||||
run.bold();
|
run.bold();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -25,7 +25,7 @@ describe("Run", () => {
|
|||||||
describe("#italic()", () => {
|
describe("#italic()", () => {
|
||||||
it("it should add italics to the properties", () => {
|
it("it should add italics to the properties", () => {
|
||||||
run.italic();
|
run.italic();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -33,7 +33,7 @@ describe("Run", () => {
|
|||||||
describe("#underline()", () => {
|
describe("#underline()", () => {
|
||||||
it("it should add underline to the properties", () => {
|
it("it should add underline to the properties", () => {
|
||||||
run.underline();
|
run.underline();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:u");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:u");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -41,7 +41,7 @@ describe("Run", () => {
|
|||||||
describe("#smallCaps()", () => {
|
describe("#smallCaps()", () => {
|
||||||
it("it should add smallCaps to the properties", () => {
|
it("it should add smallCaps to the properties", () => {
|
||||||
run.smallCaps();
|
run.smallCaps();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:smallCaps");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:smallCaps");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -49,7 +49,7 @@ describe("Run", () => {
|
|||||||
describe("#caps()", () => {
|
describe("#caps()", () => {
|
||||||
it("it should add caps to the properties", () => {
|
it("it should add caps to the properties", () => {
|
||||||
run.allCaps();
|
run.allCaps();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:caps");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:caps");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -57,7 +57,7 @@ describe("Run", () => {
|
|||||||
describe("#strike()", () => {
|
describe("#strike()", () => {
|
||||||
it("it should add strike to the properties", () => {
|
it("it should add strike to the properties", () => {
|
||||||
run.strike();
|
run.strike();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:strike");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:strike");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -65,26 +65,40 @@ describe("Run", () => {
|
|||||||
describe("#doubleStrike()", () => {
|
describe("#doubleStrike()", () => {
|
||||||
it("it should add caps to the properties", () => {
|
it("it should add caps to the properties", () => {
|
||||||
run.doubleStrike();
|
run.doubleStrike();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:dstrike");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:dstrike");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#break()", () => {
|
describe("#break()", () => {
|
||||||
it("it should add break to the run", () => {
|
it("it should add break to the run", () => {
|
||||||
let run = new Run();
|
|
||||||
run.break();
|
run.break();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[1].rootKey, "w:br");
|
assert.equal(newJson.root[1].rootKey, "w:br");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#tab()", () => {
|
describe("#tab()", () => {
|
||||||
it("it should add break to the run", () => {
|
it("it should add break to the run", () => {
|
||||||
let run = new Run();
|
|
||||||
run.tab();
|
run.tab();
|
||||||
let newJson = jsonify(run);
|
const newJson = jsonify(run);
|
||||||
assert.equal(newJson.root[1].rootKey, "w:tab");
|
assert.equal(newJson.root[1].rootKey, "w:tab");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
describe("#font()", () => {
|
||||||
|
it("should allow chaining calls", () => {
|
||||||
|
expect(run.font("Times")).to.equal(run);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should set the font as named", () => {
|
||||||
|
run.font("Times");
|
||||||
|
const tree = new Formatter().format(run);
|
||||||
|
expect(tree).to.deep.equal({
|
||||||
|
"w:r": [
|
||||||
|
{"w:rPr": [{"w:rFonts": [{_attr: {"w:ascii": "Times", "w:hAnsi": "Times"}}]}]},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {SubScript, SuperScript} from "../../../docx/run/script";
|
import { SubScript, SuperScript } from "../../../docx/run/script";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Strike, DoubleStrike} from "../../../docx/run/strike";
|
import { Strike, DoubleStrike } from "../../../docx/run/strike";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Tab} from "../../../docx/run/tab";
|
import { Tab } from "../../../docx/run/tab";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {TextRun} from "../../../docx/run/text-run";
|
import { TextRun } from "../../../docx/run/text-run";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as u from "../../../docx/run/underline";
|
import * as u from "../../../docx/run/underline";
|
||||||
import {TextRun} from "../../../docx/run/text-run";
|
import { TextRun } from "../../../docx/run/text-run";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {Attributes} from "../../../docx/xml-components";
|
import { Attributes } from "../../../docx/xml-components";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
describe("Attribute", () => {
|
describe("Attribute", () => {
|
||||||
let attributes: Attributes;
|
let attributes: Attributes;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlComponent} from "../../../docx/xml-components";
|
import { XmlComponent } from "../../../docx/xml-components";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {XmlUnitComponent} from "../../../docx/xml-components";
|
import { XmlUnitComponent } from "../../../docx/xml-components";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
/// <reference path="../../typings/mocha/mocha.d.ts" />
|
import { Formatter } from "../../export/formatter";
|
||||||
/// <reference path="../../typings/lodash/lodash.d.ts" />
|
|
||||||
/// <reference path="../../typings/chai/chai.d.ts" />
|
|
||||||
|
|
||||||
import {Formatter} from "../../export/formatter";
|
|
||||||
import * as docx from "../../docx";
|
import * as docx from "../../docx";
|
||||||
import {Attributes} from "../../docx/xml-components";
|
import { Attributes } from "../../docx/xml-components";
|
||||||
import {Properties} from "../../properties";
|
import { Properties } from "../../properties";
|
||||||
import {assert} from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
/// <reference path="../../typings/mocha/mocha.d.ts" />
|
|
||||||
/// <reference path="../../typings/chai/chai.d.ts" />
|
|
||||||
/// <reference path="../../typings/archiver/archiver.d.ts" />
|
|
||||||
/// <reference path="../../typings/xml/xml.d.ts" />
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import {LocalPacker} from "../../export/packer/local";
|
import { LocalPacker } from "../../export/packer/local";
|
||||||
import {assert} from "chai";
|
import { Document } from "../../docx/document";
|
||||||
import {Document} from "../../docx/document";
|
import { Properties } from "../../properties";
|
||||||
import {Properties} from "../../properties";
|
import { DefaultStyle } from "../../styles/sample";
|
||||||
import {DefaultStyle} from "../../styles/sample";
|
import { Paragraph } from "../../docx/paragraph";
|
||||||
import {Paragraph} from "../../docx/paragraph";
|
import { DefaultStylesFactory } from "../../styles/factory";
|
||||||
import {DefaultStylesFactory} from "../../styles/factory";
|
import { assert } from "chai";
|
||||||
|
|
||||||
describe("Packer", () => {
|
describe("Packer", () => {
|
||||||
let packer: LocalPacker;
|
let packer: LocalPacker;
|
||||||
@ -49,7 +44,7 @@ describe("Packer", () => {
|
|||||||
clearInterval(int);
|
clearInterval(int);
|
||||||
try {
|
try {
|
||||||
assert(false, 'did not create a file within the alloted time');
|
assert(false, 'did not create a file within the alloted time');
|
||||||
} catch (e){
|
} catch (e) {
|
||||||
done(e);
|
done(e);
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
@ -1,24 +1,109 @@
|
|||||||
/// <reference path="../typings/mocha/mocha.d.ts" />
|
import { expect } from "chai";
|
||||||
/// <reference path="../typings/chai/chai.d.ts" />
|
import { Formatter } from "../export/formatter";
|
||||||
|
import { Numbering } from "../numbering";
|
||||||
|
import { AbstractNumbering } from "../numbering/abstract-numbering";
|
||||||
|
import { Num } from "../numbering/num";
|
||||||
|
|
||||||
import {assert} from "chai";
|
function jsonify(obj: object) {
|
||||||
import {Numbering} from "../numbering";
|
return JSON.parse(JSON.stringify(obj));
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
|
||||||
return JSON.parse(stringifiedJson);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("", () => {
|
describe("Numbering", () => {
|
||||||
|
|
||||||
let numbering = new Numbering;
|
let numbering: Numbering;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
numbering = new Numbering();
|
numbering = new Numbering();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#methodName()", () => {
|
describe("#constructor", () => {
|
||||||
it("should ", () => {
|
it("creates a default numbering with one abstract and one concrete instance", () => {
|
||||||
|
const tree = new Formatter().format(numbering);
|
||||||
|
expect(Object.keys(tree)).to.deep.equal(["w:numbering"]);
|
||||||
|
const abstractNums = tree["w:numbering"].filter((el) => el["w:abstractNum"]);
|
||||||
|
expect(abstractNums).to.have.lengthOf(1);
|
||||||
|
expect(abstractNums[0]["w:abstractNum"]).to.deep.include.members([
|
||||||
|
{_attr: {"w:abstractNumId": 0, "w15:restartNumberingAfterBreak": 0}},
|
||||||
|
{"w:multiLevelType": [{_attr: {"w:val": "hybridMultilevel"}}]},
|
||||||
|
]);
|
||||||
|
|
||||||
|
abstractNums.filter((el) => el["w:lvl"]).forEach((el, ix) => {
|
||||||
|
expect(Object.keys(el)).to.have.lengthOf(1);
|
||||||
|
expect(Object.keys(el["w:lvl"]).sort()).to.deep.equal([
|
||||||
|
"_attr", "w:start", "w:lvlJc", "w:numFmt", "w:pPr", "w:rPr",
|
||||||
|
]);
|
||||||
|
expect(el["w:lvl"]).to.have.deep.members([
|
||||||
|
{_attr: {"w:ilvl": ix, "w15:tentative": 1}},
|
||||||
|
{"w:start": [{_attr: {"w:val": 1}}]},
|
||||||
|
{"w:lvlJc": [{_attr: {"w:val": "left"}}]},
|
||||||
|
{"w:numFmt": [{_attr: {"w:val": "bullet"}}]},
|
||||||
|
]);
|
||||||
|
// Once chai 4.0.0 lands and #644 is resolved, we can add the following to the test:
|
||||||
|
// {"w:lvlText": [{"_attr": {"w:val": "•"}}]},
|
||||||
|
// {"w:rPr": [{"w:rFonts": [{"_attr": {"w:ascii": "Symbol", "w:hAnsi": "Symbol", "w:hint": "default"}}]}]},
|
||||||
|
// {"w:pPr": [{"_attr": {}},
|
||||||
|
// {"w:ind": [{"_attr": {"w:left": 720, "w:hanging": 360}}]}]},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
describe("#createAbstractNumbering", () => {
|
||||||
|
it("returns a new AbstractNumbering instance", () => {
|
||||||
|
const a2 = numbering.createAbstractNumbering();
|
||||||
|
expect(a2).to.be.instanceof(AbstractNumbering);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("assigns a unique ID to each abstract numbering it creates", () => {
|
||||||
|
const a2 = numbering.createAbstractNumbering();
|
||||||
|
const a3 = numbering.createAbstractNumbering();
|
||||||
|
expect(a2.id).not.to.equal(a3.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#createConcreteNumbering", () => {
|
||||||
|
it("returns a new Num instance with its abstract ID set to the AbstractNumbering's ID", () => {
|
||||||
|
const a2 = numbering.createAbstractNumbering();
|
||||||
|
const n = numbering.createConcreteNumbering(a2);
|
||||||
|
expect(n).to.be.instanceof(Num);
|
||||||
|
const tree = new Formatter().format(numbering);
|
||||||
|
expect(n.id).to.equal(a2.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("assigns a unique ID to each concrete numbering it creates", () => {
|
||||||
|
const a2 = numbering.createAbstractNumbering();
|
||||||
|
const n = numbering.createConcreteNumbering(a2);
|
||||||
|
const n2 = numbering.createConcreteNumbering(a2);
|
||||||
|
expect(n.id).not.to.equal(n2.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("AbstractNumbering", () => {
|
||||||
|
it("stores its ID at its .id property", () => {
|
||||||
|
const abstractNumbering = new AbstractNumbering(5);
|
||||||
|
expect(abstractNumbering.id).to.equal(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("#createLevel", () => {
|
||||||
|
it("creates a level with the given characteristics", () => {
|
||||||
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
|
const level = abstractNumbering.createLevel(3, "lowerLetter", "%1)", "end");
|
||||||
|
const tree = new Formatter().format(level);
|
||||||
|
expect(tree['w:lvl']).to.include({_attr: {"w:ilvl": 3, "w15:tentative": 1}})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:start": [{_attr: {"w:val": 1}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:lvlJc": [{_attr: {"w:val": "end"}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:numFmt": [{_attr: {"w:val": "lowerLetter"}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:lvlText": [{"_attr": {"w:val": "%1)"}}]})
|
||||||
|
});
|
||||||
|
|
||||||
|
it("uses 'start' as the default alignment", () => {
|
||||||
|
const abstractNumbering = new AbstractNumbering(1);
|
||||||
|
const level = abstractNumbering.createLevel(3, "lowerLetter", "%1)");
|
||||||
|
const tree = new Formatter().format(level);
|
||||||
|
expect(tree['w:lvl']).to.include({_attr: {"w:ilvl": 3, "w15:tentative": 1}})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:start": [{_attr: {"w:val": 1}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:lvlJc": [{_attr: {"w:val": "start"}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:numFmt": [{_attr: {"w:val": "lowerLetter"}}]})
|
||||||
|
expect(tree['w:lvl']).to.include({"w:lvlText": [{"_attr": {"w:val": "%1)"}}]})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
/// <reference path="../typings/mocha/mocha.d.ts" />
|
import { Properties } from "../properties";
|
||||||
/// <reference path="../typings/chai/chai.d.ts" />
|
import { assert } from "chai";
|
||||||
import {Properties} from "../properties";
|
|
||||||
import {assert} from "chai";
|
|
||||||
|
|
||||||
function jsonify(obj: Object) {
|
function jsonify(obj: Object) {
|
||||||
let stringifiedJson = JSON.stringify(obj);
|
let stringifiedJson = JSON.stringify(obj);
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
/// <reference path="../typings/mocha/mocha.d.ts" />
|
import { Styles } from "../styles";
|
||||||
/// <reference path="../typings/chai/chai.d.ts" />
|
import { assert } from "chai";
|
||||||
|
|
||||||
import {Styles} from "../styles";
|
|
||||||
import {assert} from "chai";
|
|
||||||
|
|
||||||
describe("Styles", () => {
|
describe("Styles", () => {
|
||||||
let styles: Styles;
|
let styles: Styles;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"preserveConstEnums": true,
|
"preserveConstEnums": true,
|
||||||
//"outFile": "../build/build.js",
|
|
||||||
"outDir": "../build",
|
"outDir": "../build",
|
||||||
"sourceRoot": "./",
|
"sourceRoot": "./",
|
||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
|
39
ts/tsd.json
39
ts/tsd.json
@ -1,39 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"mocha/mocha.d.ts": {
|
|
||||||
"commit": "299b5caa22876ef27dc8e9a5b7fd7bf93457b6f4"
|
|
||||||
},
|
|
||||||
"lodash/lodash.d.ts": {
|
|
||||||
"commit": "299b5caa22876ef27dc8e9a5b7fd7bf93457b6f4"
|
|
||||||
},
|
|
||||||
"chai/chai.d.ts": {
|
|
||||||
"commit": "80057d687aefa736511e434cd2a6c0e9a6bb02bc"
|
|
||||||
},
|
|
||||||
"assertion-error/assertion-error.d.ts": {
|
|
||||||
"commit": "80057d687aefa736511e434cd2a6c0e9a6bb02bc"
|
|
||||||
},
|
|
||||||
"archiver/archiver.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
},
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
},
|
|
||||||
"express/express.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
},
|
|
||||||
"express-serve-static-core/express-serve-static-core.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
},
|
|
||||||
"serve-static/serve-static.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
},
|
|
||||||
"mime/mime.d.ts": {
|
|
||||||
"commit": "e937b3e64af586d19f2ea29fdf771e9dc4feecc8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
35
ts/tslint.json
Normal file
35
ts/tslint.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"extends": "tslint:latest",
|
||||||
|
"rules": {
|
||||||
|
"curly": true,
|
||||||
|
"one-variable-per-declaration": [
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"no-any": true,
|
||||||
|
"no-consecutive-blank-lines": [
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"no-require-imports": true,
|
||||||
|
"member-access": [
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"object-literal-shorthand": false,
|
||||||
|
"typedef": [
|
||||||
|
true,
|
||||||
|
"call-signature",
|
||||||
|
"parameter",
|
||||||
|
"property-declaration"
|
||||||
|
],
|
||||||
|
"max-line-length": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"max-classes-per-file": [
|
||||||
|
false
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
42
ts/typings/archiver/archiver.d.ts
vendored
42
ts/typings/archiver/archiver.d.ts
vendored
@ -1,42 +0,0 @@
|
|||||||
// Type definitions for archiver v0.15.0
|
|
||||||
// Project: https://github.com/archiverjs/node-archiver
|
|
||||||
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
/* =================== USAGE ===================
|
|
||||||
|
|
||||||
import Archiver = require('archiver);
|
|
||||||
var archiver = Archiver.create('zip');
|
|
||||||
archiver.pipe(FS.createWriteStream('xxx'));
|
|
||||||
archiver.append(FS.createReadStream('xxx'));
|
|
||||||
archiver.finalize();
|
|
||||||
|
|
||||||
=============================================== */
|
|
||||||
|
|
||||||
/// <reference path="../node/node.d.ts" />
|
|
||||||
declare module "archiver" {
|
|
||||||
import * as FS from 'fs';
|
|
||||||
import * as STREAM from 'stream';
|
|
||||||
|
|
||||||
interface nameInterface {
|
|
||||||
name?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Archiver extends STREAM.Transform {
|
|
||||||
pipe(writeStream: FS.WriteStream): void;
|
|
||||||
append(readStream: FS.ReadStream, name: nameInterface): void;
|
|
||||||
finalize(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Options {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function archiver(format: string, options?: Options): Archiver;
|
|
||||||
|
|
||||||
namespace archiver {
|
|
||||||
function create(format: string, options?: Options): Archiver;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = archiver;
|
|
||||||
}
|
|
15
ts/typings/assertion-error/assertion-error.d.ts
vendored
15
ts/typings/assertion-error/assertion-error.d.ts
vendored
@ -1,15 +0,0 @@
|
|||||||
// Type definitions for assertion-error 1.0.0
|
|
||||||
// Project: https://github.com/chaijs/assertion-error
|
|
||||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
declare module 'assertion-error' {
|
|
||||||
class AssertionError implements Error {
|
|
||||||
constructor(message: string, props?: any, ssf?: Function);
|
|
||||||
name: string;
|
|
||||||
message: string;
|
|
||||||
showDiff: boolean;
|
|
||||||
stack: string;
|
|
||||||
}
|
|
||||||
export = AssertionError;
|
|
||||||
}
|
|
401
ts/typings/chai/chai.d.ts
vendored
401
ts/typings/chai/chai.d.ts
vendored
@ -1,401 +0,0 @@
|
|||||||
// Type definitions for chai 3.4.0
|
|
||||||
// Project: http://chaijs.com/
|
|
||||||
// Definitions by: Jed Mao <https://github.com/jedmao/>,
|
|
||||||
// Bart van der Schoor <https://github.com/Bartvds>,
|
|
||||||
// Andrew Brown <https://github.com/AGBrown>,
|
|
||||||
// Olivier Chevet <https://github.com/olivr70>,
|
|
||||||
// Matt Wistrand <https://github.com/mwistrand>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
// <reference path="../assertion-error/assertion-error.d.ts"/>
|
|
||||||
|
|
||||||
declare namespace Chai {
|
|
||||||
|
|
||||||
interface ChaiStatic {
|
|
||||||
expect: ExpectStatic;
|
|
||||||
should(): Should;
|
|
||||||
/**
|
|
||||||
* Provides a way to extend the internals of Chai
|
|
||||||
*/
|
|
||||||
use(fn: (chai: any, utils: any) => void): ChaiStatic;
|
|
||||||
assert: AssertStatic;
|
|
||||||
config: Config;
|
|
||||||
AssertionError: typeof AssertionError;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExpectStatic extends AssertionStatic {
|
|
||||||
fail(actual?: any, expected?: any, message?: string, operator?: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AssertStatic extends Assert {
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AssertionStatic {
|
|
||||||
(target: any, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ShouldAssertion {
|
|
||||||
equal(value1: any, value2: any, message?: string): void;
|
|
||||||
Throw: ShouldThrow;
|
|
||||||
throw: ShouldThrow;
|
|
||||||
exist(value: any, message?: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Should extends ShouldAssertion {
|
|
||||||
not: ShouldAssertion;
|
|
||||||
fail(actual: any, expected: any, message?: string, operator?: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ShouldThrow {
|
|
||||||
(actual: Function): void;
|
|
||||||
(actual: Function, expected: string|RegExp, message?: string): void;
|
|
||||||
(actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
|
||||||
not: Assertion;
|
|
||||||
deep: Deep;
|
|
||||||
any: KeyFilter;
|
|
||||||
all: KeyFilter;
|
|
||||||
a: TypeComparison;
|
|
||||||
an: TypeComparison;
|
|
||||||
include: Include;
|
|
||||||
includes: Include;
|
|
||||||
contain: Include;
|
|
||||||
contains: Include;
|
|
||||||
ok: Assertion;
|
|
||||||
true: Assertion;
|
|
||||||
false: Assertion;
|
|
||||||
null: Assertion;
|
|
||||||
undefined: Assertion;
|
|
||||||
NaN: Assertion;
|
|
||||||
exist: Assertion;
|
|
||||||
empty: Assertion;
|
|
||||||
arguments: Assertion;
|
|
||||||
Arguments: Assertion;
|
|
||||||
equal: Equal;
|
|
||||||
equals: Equal;
|
|
||||||
eq: Equal;
|
|
||||||
eql: Equal;
|
|
||||||
eqls: Equal;
|
|
||||||
property: Property;
|
|
||||||
ownProperty: OwnProperty;
|
|
||||||
haveOwnProperty: OwnProperty;
|
|
||||||
ownPropertyDescriptor: OwnPropertyDescriptor;
|
|
||||||
haveOwnPropertyDescriptor: OwnPropertyDescriptor;
|
|
||||||
length: Length;
|
|
||||||
lengthOf: Length;
|
|
||||||
match: Match;
|
|
||||||
matches: Match;
|
|
||||||
string(string: string, message?: string): Assertion;
|
|
||||||
keys: Keys;
|
|
||||||
key(string: string): Assertion;
|
|
||||||
throw: Throw;
|
|
||||||
throws: Throw;
|
|
||||||
Throw: Throw;
|
|
||||||
respondTo: RespondTo;
|
|
||||||
respondsTo: RespondTo;
|
|
||||||
itself: Assertion;
|
|
||||||
satisfy: Satisfy;
|
|
||||||
satisfies: Satisfy;
|
|
||||||
closeTo: CloseTo;
|
|
||||||
approximately: CloseTo;
|
|
||||||
members: Members;
|
|
||||||
increase: PropertyChange;
|
|
||||||
increases: PropertyChange;
|
|
||||||
decrease: PropertyChange;
|
|
||||||
decreases: PropertyChange;
|
|
||||||
change: PropertyChange;
|
|
||||||
changes: PropertyChange;
|
|
||||||
extensible: Assertion;
|
|
||||||
sealed: Assertion;
|
|
||||||
frozen: Assertion;
|
|
||||||
oneOf(list: any[], message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LanguageChains {
|
|
||||||
to: Assertion;
|
|
||||||
be: Assertion;
|
|
||||||
been: Assertion;
|
|
||||||
is: Assertion;
|
|
||||||
that: Assertion;
|
|
||||||
which: Assertion;
|
|
||||||
and: Assertion;
|
|
||||||
has: Assertion;
|
|
||||||
have: Assertion;
|
|
||||||
with: Assertion;
|
|
||||||
at: Assertion;
|
|
||||||
of: Assertion;
|
|
||||||
same: Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NumericComparison {
|
|
||||||
above: NumberComparer;
|
|
||||||
gt: NumberComparer;
|
|
||||||
greaterThan: NumberComparer;
|
|
||||||
least: NumberComparer;
|
|
||||||
gte: NumberComparer;
|
|
||||||
below: NumberComparer;
|
|
||||||
lt: NumberComparer;
|
|
||||||
lessThan: NumberComparer;
|
|
||||||
most: NumberComparer;
|
|
||||||
lte: NumberComparer;
|
|
||||||
within(start: number, finish: number, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NumberComparer {
|
|
||||||
(value: number, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeComparison {
|
|
||||||
(type: string, message?: string): Assertion;
|
|
||||||
instanceof: InstanceOf;
|
|
||||||
instanceOf: InstanceOf;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InstanceOf {
|
|
||||||
(constructor: Object, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CloseTo {
|
|
||||||
(expected: number, delta: number, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Deep {
|
|
||||||
equal: Equal;
|
|
||||||
include: Include;
|
|
||||||
property: Property;
|
|
||||||
members: Members;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface KeyFilter {
|
|
||||||
keys: Keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Equal {
|
|
||||||
(value: any, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Property {
|
|
||||||
(name: string, value?: any, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OwnProperty {
|
|
||||||
(name: string, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OwnPropertyDescriptor {
|
|
||||||
(name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
|
|
||||||
(name: string, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Length extends LanguageChains, NumericComparison {
|
|
||||||
(length: number, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Include {
|
|
||||||
(value: Object, message?: string): Assertion;
|
|
||||||
(value: string, message?: string): Assertion;
|
|
||||||
(value: number, message?: string): Assertion;
|
|
||||||
keys: Keys;
|
|
||||||
members: Members;
|
|
||||||
any: KeyFilter;
|
|
||||||
all: KeyFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Match {
|
|
||||||
(regexp: RegExp|string, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Keys {
|
|
||||||
(...keys: string[]): Assertion;
|
|
||||||
(keys: any[]): Assertion;
|
|
||||||
(keys: Object): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Throw {
|
|
||||||
(): Assertion;
|
|
||||||
(expected: string, message?: string): Assertion;
|
|
||||||
(expected: RegExp, message?: string): Assertion;
|
|
||||||
(constructor: Error, expected?: string, message?: string): Assertion;
|
|
||||||
(constructor: Error, expected?: RegExp, message?: string): Assertion;
|
|
||||||
(constructor: Function, expected?: string, message?: string): Assertion;
|
|
||||||
(constructor: Function, expected?: RegExp, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RespondTo {
|
|
||||||
(method: string, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Satisfy {
|
|
||||||
(matcher: Function, message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Members {
|
|
||||||
(set: any[], message?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PropertyChange {
|
|
||||||
(object: Object, prop: string, msg?: string): Assertion;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Assert {
|
|
||||||
/**
|
|
||||||
* @param expression Expression to test for truthiness.
|
|
||||||
* @param message Message to display on error.
|
|
||||||
*/
|
|
||||||
(expression: any, message?: string): void;
|
|
||||||
|
|
||||||
fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
|
|
||||||
|
|
||||||
ok(val: any, msg?: string): void;
|
|
||||||
isOk(val: any, msg?: string): void;
|
|
||||||
notOk(val: any, msg?: string): void;
|
|
||||||
isNotOk(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
equal(act: any, exp: any, msg?: string): void;
|
|
||||||
notEqual(act: any, exp: any, msg?: string): void;
|
|
||||||
|
|
||||||
strictEqual(act: any, exp: any, msg?: string): void;
|
|
||||||
notStrictEqual(act: any, exp: any, msg?: string): void;
|
|
||||||
|
|
||||||
deepEqual(act: any, exp: any, msg?: string): void;
|
|
||||||
notDeepEqual(act: any, exp: any, msg?: string): void;
|
|
||||||
|
|
||||||
isTrue(val: any, msg?: string): void;
|
|
||||||
isFalse(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isNotTrue(val: any, msg?: string): void;
|
|
||||||
isNotFalse(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isNull(val: any, msg?: string): void;
|
|
||||||
isNotNull(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isUndefined(val: any, msg?: string): void;
|
|
||||||
isDefined(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isNaN(val: any, msg?: string): void;
|
|
||||||
isNotNaN(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isAbove(val: number, abv: number, msg?: string): void;
|
|
||||||
isBelow(val: number, blw: number, msg?: string): void;
|
|
||||||
|
|
||||||
isAtLeast(val: number, atlst: number, msg?: string): void;
|
|
||||||
isAtMost(val: number, atmst: number, msg?: string): void;
|
|
||||||
|
|
||||||
isFunction(val: any, msg?: string): void;
|
|
||||||
isNotFunction(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isObject(val: any, msg?: string): void;
|
|
||||||
isNotObject(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isArray(val: any, msg?: string): void;
|
|
||||||
isNotArray(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isString(val: any, msg?: string): void;
|
|
||||||
isNotString(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isNumber(val: any, msg?: string): void;
|
|
||||||
isNotNumber(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isBoolean(val: any, msg?: string): void;
|
|
||||||
isNotBoolean(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
typeOf(val: any, type: string, msg?: string): void;
|
|
||||||
notTypeOf(val: any, type: string, msg?: string): void;
|
|
||||||
|
|
||||||
instanceOf(val: any, type: Function, msg?: string): void;
|
|
||||||
notInstanceOf(val: any, type: Function, msg?: string): void;
|
|
||||||
|
|
||||||
include(exp: string, inc: any, msg?: string): void;
|
|
||||||
include(exp: any[], inc: any, msg?: string): void;
|
|
||||||
|
|
||||||
notInclude(exp: string, inc: any, msg?: string): void;
|
|
||||||
notInclude(exp: any[], inc: any, msg?: string): void;
|
|
||||||
|
|
||||||
match(exp: any, re: RegExp, msg?: string): void;
|
|
||||||
notMatch(exp: any, re: RegExp, msg?: string): void;
|
|
||||||
|
|
||||||
property(obj: Object, prop: string, msg?: string): void;
|
|
||||||
notProperty(obj: Object, prop: string, msg?: string): void;
|
|
||||||
deepProperty(obj: Object, prop: string, msg?: string): void;
|
|
||||||
notDeepProperty(obj: Object, prop: string, msg?: string): void;
|
|
||||||
|
|
||||||
propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
|
|
||||||
propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
|
|
||||||
|
|
||||||
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
|
|
||||||
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
|
|
||||||
|
|
||||||
lengthOf(exp: any, len: number, msg?: string): void;
|
|
||||||
//alias frenzy
|
|
||||||
throw(fn: Function, msg?: string): void;
|
|
||||||
throw(fn: Function, regExp: RegExp): void;
|
|
||||||
throw(fn: Function, errType: Function, msg?: string): void;
|
|
||||||
throw(fn: Function, errType: Function, regExp: RegExp): void;
|
|
||||||
|
|
||||||
throws(fn: Function, msg?: string): void;
|
|
||||||
throws(fn: Function, regExp: RegExp): void;
|
|
||||||
throws(fn: Function, errType: Function, msg?: string): void;
|
|
||||||
throws(fn: Function, errType: Function, regExp: RegExp): void;
|
|
||||||
|
|
||||||
Throw(fn: Function, msg?: string): void;
|
|
||||||
Throw(fn: Function, regExp: RegExp): void;
|
|
||||||
Throw(fn: Function, errType: Function, msg?: string): void;
|
|
||||||
Throw(fn: Function, errType: Function, regExp: RegExp): void;
|
|
||||||
|
|
||||||
doesNotThrow(fn: Function, msg?: string): void;
|
|
||||||
doesNotThrow(fn: Function, regExp: RegExp): void;
|
|
||||||
doesNotThrow(fn: Function, errType: Function, msg?: string): void;
|
|
||||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
|
|
||||||
|
|
||||||
operator(val: any, operator: string, val2: any, msg?: string): void;
|
|
||||||
closeTo(act: number, exp: number, delta: number, msg?: string): void;
|
|
||||||
approximately(act: number, exp: number, delta: number, msg?: string): void;
|
|
||||||
|
|
||||||
sameMembers(set1: any[], set2: any[], msg?: string): void;
|
|
||||||
sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
|
|
||||||
includeMembers(superset: any[], subset: any[], msg?: string): void;
|
|
||||||
|
|
||||||
ifError(val: any, msg?: string): void;
|
|
||||||
|
|
||||||
isExtensible(obj: {}, msg?: string): void;
|
|
||||||
extensible(obj: {}, msg?: string): void;
|
|
||||||
isNotExtensible(obj: {}, msg?: string): void;
|
|
||||||
notExtensible(obj: {}, msg?: string): void;
|
|
||||||
|
|
||||||
isSealed(obj: {}, msg?: string): void;
|
|
||||||
sealed(obj: {}, msg?: string): void;
|
|
||||||
isNotSealed(obj: {}, msg?: string): void;
|
|
||||||
notSealed(obj: {}, msg?: string): void;
|
|
||||||
|
|
||||||
isFrozen(obj: Object, msg?: string): void;
|
|
||||||
frozen(obj: Object, msg?: string): void;
|
|
||||||
isNotFrozen(obj: Object, msg?: string): void;
|
|
||||||
notFrozen(obj: Object, msg?: string): void;
|
|
||||||
|
|
||||||
oneOf(inList: any, list: any[], msg?: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Config {
|
|
||||||
includeStack: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AssertionError {
|
|
||||||
constructor(message: string, _props?: any, ssf?: Function);
|
|
||||||
name: string;
|
|
||||||
message: string;
|
|
||||||
showDiff: boolean;
|
|
||||||
stack: string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var chai: Chai.ChaiStatic;
|
|
||||||
|
|
||||||
declare module "chai" {
|
|
||||||
export = chai;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Object {
|
|
||||||
should: Chai.Assertion;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
54
ts/typings/express/express.d.ts
vendored
54
ts/typings/express/express.d.ts
vendored
@ -1,54 +0,0 @@
|
|||||||
// Type definitions for Express 4.x
|
|
||||||
// Project: http://expressjs.com
|
|
||||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
/* =================== USAGE ===================
|
|
||||||
|
|
||||||
import * as express from "express";
|
|
||||||
var app = express();
|
|
||||||
|
|
||||||
=============================================== */
|
|
||||||
|
|
||||||
/// <reference path="../serve-static/serve-static.d.ts" />
|
|
||||||
/// <reference path="../express-serve-static-core/express-serve-static-core.d.ts" />
|
|
||||||
|
|
||||||
declare module "express" {
|
|
||||||
import * as serveStatic from "serve-static";
|
|
||||||
import * as core from "express-serve-static-core";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an Express application. The express() function is a top-level function exported by the express module.
|
|
||||||
*/
|
|
||||||
function e(): core.Express;
|
|
||||||
|
|
||||||
namespace e {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the only built-in middleware function in Express. It serves static files and is based on serve-static.
|
|
||||||
*/
|
|
||||||
var static: typeof serveStatic;
|
|
||||||
|
|
||||||
export function Router(options?: any): core.Router;
|
|
||||||
|
|
||||||
interface Application extends core.Application { }
|
|
||||||
interface CookieOptions extends core.CookieOptions { }
|
|
||||||
interface Errback extends core.Errback { }
|
|
||||||
interface ErrorRequestHandler extends core.ErrorRequestHandler { }
|
|
||||||
interface Express extends core.Express { }
|
|
||||||
interface Handler extends core.Handler { }
|
|
||||||
interface IRoute extends core.IRoute { }
|
|
||||||
interface IRouter<T> extends core.IRouter<T> { }
|
|
||||||
interface IRouterMatcher<T> extends core.IRouterMatcher<T> { }
|
|
||||||
interface MediaType extends core.MediaType { }
|
|
||||||
interface NextFunction extends core.NextFunction { }
|
|
||||||
interface Request extends core.Request { }
|
|
||||||
interface RequestHandler extends core.RequestHandler { }
|
|
||||||
interface RequestParamHandler extends core.RequestParamHandler { }
|
|
||||||
export interface Response extends core.Response { }
|
|
||||||
interface Router extends core.Router { }
|
|
||||||
interface Send extends core.Send { }
|
|
||||||
}
|
|
||||||
|
|
||||||
export = e;
|
|
||||||
}
|
|
19172
ts/typings/lodash/lodash.d.ts
vendored
19172
ts/typings/lodash/lodash.d.ts
vendored
File diff suppressed because it is too large
Load Diff
20
ts/typings/mime/mime.d.ts
vendored
20
ts/typings/mime/mime.d.ts
vendored
@ -1,20 +0,0 @@
|
|||||||
// Type definitions for mime
|
|
||||||
// Project: https://github.com/broofa/node-mime
|
|
||||||
// Definitions by: Jeff Goddard <https://github.com/jedigo>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts
|
|
||||||
|
|
||||||
declare module "mime" {
|
|
||||||
export function lookup(path: string): string;
|
|
||||||
export function extension(mime: string): string;
|
|
||||||
export function load(filepath: string): void;
|
|
||||||
export function define(mimes: Object): void;
|
|
||||||
|
|
||||||
interface Charsets {
|
|
||||||
lookup(mime: string): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export var charsets: Charsets;
|
|
||||||
export var default_type: string;
|
|
||||||
}
|
|
236
ts/typings/mocha/mocha.d.ts
vendored
236
ts/typings/mocha/mocha.d.ts
vendored
@ -1,236 +0,0 @@
|
|||||||
// Type definitions for mocha 2.2.5
|
|
||||||
// Project: http://mochajs.org/
|
|
||||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
interface MochaSetupOptions {
|
|
||||||
//milliseconds to wait before considering a test slow
|
|
||||||
slow?: number;
|
|
||||||
|
|
||||||
// timeout in milliseconds
|
|
||||||
timeout?: number;
|
|
||||||
|
|
||||||
// ui name "bdd", "tdd", "exports" etc
|
|
||||||
ui?: string;
|
|
||||||
|
|
||||||
//array of accepted globals
|
|
||||||
globals?: any[];
|
|
||||||
|
|
||||||
// reporter instance (function or string), defaults to `mocha.reporters.Spec`
|
|
||||||
reporter?: any;
|
|
||||||
|
|
||||||
// bail on the first test failure
|
|
||||||
bail?: boolean;
|
|
||||||
|
|
||||||
// ignore global leaks
|
|
||||||
ignoreLeaks?: boolean;
|
|
||||||
|
|
||||||
// grep string or regexp to filter tests with
|
|
||||||
grep?: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MochaDone {
|
|
||||||
(error?: Error): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var mocha: Mocha;
|
|
||||||
declare var describe: Mocha.IContextDefinition;
|
|
||||||
declare var xdescribe: Mocha.IContextDefinition;
|
|
||||||
// alias for `describe`
|
|
||||||
declare var context: Mocha.IContextDefinition;
|
|
||||||
// alias for `describe`
|
|
||||||
declare var suite: Mocha.IContextDefinition;
|
|
||||||
declare var it: Mocha.ITestDefinition;
|
|
||||||
declare var xit: Mocha.ITestDefinition;
|
|
||||||
// alias for `it`
|
|
||||||
declare var test: Mocha.ITestDefinition;
|
|
||||||
|
|
||||||
declare function before(action: () => void): void;
|
|
||||||
|
|
||||||
declare function before(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function before(description: string, action: () => void): void;
|
|
||||||
|
|
||||||
declare function before(description: string, action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function setup(action: () => void): void;
|
|
||||||
|
|
||||||
declare function setup(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function after(action: () => void): void;
|
|
||||||
|
|
||||||
declare function after(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function after(description: string, action: () => void): void;
|
|
||||||
|
|
||||||
declare function after(description: string, action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function teardown(action: () => void): void;
|
|
||||||
|
|
||||||
declare function teardown(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(description: string, action: () => void): void;
|
|
||||||
|
|
||||||
declare function beforeEach(description: string, action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function suiteSetup(action: () => void): void;
|
|
||||||
|
|
||||||
declare function suiteSetup(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: () => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(description: string, action: () => void): void;
|
|
||||||
|
|
||||||
declare function afterEach(description: string, action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare function suiteTeardown(action: () => void): void;
|
|
||||||
|
|
||||||
declare function suiteTeardown(action: (done: MochaDone) => void): void;
|
|
||||||
|
|
||||||
declare class Mocha {
|
|
||||||
constructor(options?: {
|
|
||||||
grep?: RegExp;
|
|
||||||
ui?: string;
|
|
||||||
reporter?: string;
|
|
||||||
timeout?: number;
|
|
||||||
bail?: boolean;
|
|
||||||
});
|
|
||||||
|
|
||||||
/** Setup mocha with the given options. */
|
|
||||||
setup(options: MochaSetupOptions): Mocha;
|
|
||||||
bail(value?: boolean): Mocha;
|
|
||||||
addFile(file: string): Mocha;
|
|
||||||
/** Sets reporter by name, defaults to "spec". */
|
|
||||||
reporter(name: string): Mocha;
|
|
||||||
/** Sets reporter constructor, defaults to mocha.reporters.Spec. */
|
|
||||||
reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha;
|
|
||||||
ui(value: string): Mocha;
|
|
||||||
grep(value: string): Mocha;
|
|
||||||
grep(value: RegExp): Mocha;
|
|
||||||
invert(): Mocha;
|
|
||||||
ignoreLeaks(value: boolean): Mocha;
|
|
||||||
checkLeaks(): Mocha;
|
|
||||||
/**
|
|
||||||
* Function to allow assertion libraries to throw errors directly into mocha.
|
|
||||||
* This is useful when running tests in a browser because window.onerror will
|
|
||||||
* only receive the 'message' attribute of the Error.
|
|
||||||
*/
|
|
||||||
throwError(error: Error): void;
|
|
||||||
/** Enables growl support. */
|
|
||||||
growl(): Mocha;
|
|
||||||
globals(value: string): Mocha;
|
|
||||||
globals(values: string[]): Mocha;
|
|
||||||
useColors(value: boolean): Mocha;
|
|
||||||
useInlineDiffs(value: boolean): Mocha;
|
|
||||||
timeout(value: number): Mocha;
|
|
||||||
slow(value: number): Mocha;
|
|
||||||
enableTimeouts(value: boolean): Mocha;
|
|
||||||
asyncOnly(value: boolean): Mocha;
|
|
||||||
noHighlighting(value: boolean): Mocha;
|
|
||||||
/** Runs tests and invokes `onComplete()` when finished. */
|
|
||||||
run(onComplete?: (failures: number) => void): Mocha.IRunner;
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge the Mocha class declaration with a module
|
|
||||||
declare namespace Mocha {
|
|
||||||
/** Partial interface for Mocha's `Runnable` class. */
|
|
||||||
interface IRunnable {
|
|
||||||
title: string;
|
|
||||||
fn: Function;
|
|
||||||
async: boolean;
|
|
||||||
sync: boolean;
|
|
||||||
timedOut: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Partial interface for Mocha's `Suite` class. */
|
|
||||||
interface ISuite {
|
|
||||||
parent: ISuite;
|
|
||||||
title: string;
|
|
||||||
|
|
||||||
fullTitle(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Partial interface for Mocha's `Test` class. */
|
|
||||||
interface ITest extends IRunnable {
|
|
||||||
parent: ISuite;
|
|
||||||
pending: boolean;
|
|
||||||
|
|
||||||
fullTitle(): string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Partial interface for Mocha's `Runner` class. */
|
|
||||||
interface IRunner {}
|
|
||||||
|
|
||||||
interface IContextDefinition {
|
|
||||||
(description: string, spec: () => void): ISuite;
|
|
||||||
only(description: string, spec: () => void): ISuite;
|
|
||||||
skip(description: string, spec: () => void): void;
|
|
||||||
timeout(ms: number): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ITestDefinition {
|
|
||||||
(expectation: string, assertion?: () => void): ITest;
|
|
||||||
(expectation: string, assertion?: (done: MochaDone) => void): ITest;
|
|
||||||
only(expectation: string, assertion?: () => void): ITest;
|
|
||||||
only(expectation: string, assertion?: (done: MochaDone) => void): ITest;
|
|
||||||
skip(expectation: string, assertion?: () => void): void;
|
|
||||||
skip(expectation: string, assertion?: (done: MochaDone) => void): void;
|
|
||||||
timeout(ms: number): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export module reporters {
|
|
||||||
export class Base {
|
|
||||||
stats: {
|
|
||||||
suites: number;
|
|
||||||
tests: number;
|
|
||||||
passes: number;
|
|
||||||
pending: number;
|
|
||||||
failures: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(runner: IRunner);
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Doc extends Base {}
|
|
||||||
export class Dot extends Base {}
|
|
||||||
export class HTML extends Base {}
|
|
||||||
export class HTMLCov extends Base {}
|
|
||||||
export class JSON extends Base {}
|
|
||||||
export class JSONCov extends Base {}
|
|
||||||
export class JSONStream extends Base {}
|
|
||||||
export class Landing extends Base {}
|
|
||||||
export class List extends Base {}
|
|
||||||
export class Markdown extends Base {}
|
|
||||||
export class Min extends Base {}
|
|
||||||
export class Nyan extends Base {}
|
|
||||||
export class Progress extends Base {
|
|
||||||
/**
|
|
||||||
* @param options.open String used to indicate the start of the progress bar.
|
|
||||||
* @param options.complete String used to indicate a complete test on the progress bar.
|
|
||||||
* @param options.incomplete String used to indicate an incomplete test on the progress bar.
|
|
||||||
* @param options.close String used to indicate the end of the progress bar.
|
|
||||||
*/
|
|
||||||
constructor(runner: IRunner, options?: {
|
|
||||||
open?: string;
|
|
||||||
complete?: string;
|
|
||||||
incomplete?: string;
|
|
||||||
close?: string;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export class Spec extends Base {}
|
|
||||||
export class TAP extends Base {}
|
|
||||||
export class XUnit extends Base {
|
|
||||||
constructor(runner: IRunner, options?: any);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "mocha" {
|
|
||||||
export = Mocha;
|
|
||||||
}
|
|
2329
ts/typings/node/node.d.ts
vendored
2329
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
86
ts/typings/serve-static/serve-static.d.ts
vendored
86
ts/typings/serve-static/serve-static.d.ts
vendored
@ -1,86 +0,0 @@
|
|||||||
// Type definitions for serve-static 1.7.1
|
|
||||||
// Project: https://github.com/expressjs/serve-static
|
|
||||||
// Definitions by: Uros Smolnik <https://github.com/urossmolnik/>
|
|
||||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
||||||
|
|
||||||
/* =================== USAGE ===================
|
|
||||||
|
|
||||||
import * as serveStatic from "serve-static";
|
|
||||||
app.use(serveStatic("public/ftp", {"index": ["default.html", "default.htm"]}))
|
|
||||||
|
|
||||||
=============================================== */
|
|
||||||
|
|
||||||
/// <reference path="../express-serve-static-core/express-serve-static-core.d.ts" />
|
|
||||||
/// <reference path="../mime/mime.d.ts" />
|
|
||||||
|
|
||||||
declare module "serve-static" {
|
|
||||||
import * as express from "express-serve-static-core";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new middleware function to serve files from within a given root directory.
|
|
||||||
* The file to serve will be determined by combining req.url with the provided root directory.
|
|
||||||
* When a file is not found, instead of sending a 404 response, this module will instead call next() to move on to the next middleware, allowing for stacking and fall-backs.
|
|
||||||
*/
|
|
||||||
function serveStatic(root: string, options?: {
|
|
||||||
/**
|
|
||||||
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
|
|
||||||
* Note this check is done on the path itself without checking if the path actually exists on the disk.
|
|
||||||
* If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
|
|
||||||
* The default value is 'ignore'.
|
|
||||||
* 'allow' No special treatment for dotfiles
|
|
||||||
* 'deny' Send a 403 for any request for a dotfile
|
|
||||||
* 'ignore' Pretend like the dotfile does not exist and call next()
|
|
||||||
*/
|
|
||||||
dotfiles?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable etag generation, defaults to true.
|
|
||||||
*/
|
|
||||||
etag?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
|
|
||||||
* The first that exists will be served. Example: ['html', 'htm'].
|
|
||||||
* The default value is false.
|
|
||||||
*/
|
|
||||||
extensions?: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* By default this module will send "index.html" files in response to a request on a directory.
|
|
||||||
* To disable this set false or to supply a new index pass a string or an array in preferred order.
|
|
||||||
*/
|
|
||||||
index?: boolean|string|string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
|
|
||||||
*/
|
|
||||||
lastModified?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
|
|
||||||
*/
|
|
||||||
maxAge?: number|string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
|
|
||||||
*/
|
|
||||||
redirect?: boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
|
|
||||||
* The function is called as fn(res, path, stat), where the arguments are:
|
|
||||||
* res the response object
|
|
||||||
* path the file path that is being sent
|
|
||||||
* stat the stat object of the file that is being sent
|
|
||||||
*/
|
|
||||||
setHeaders?: (res: express.Response, path: string, stat: any) => any;
|
|
||||||
}): express.Handler;
|
|
||||||
|
|
||||||
import * as m from "mime";
|
|
||||||
|
|
||||||
namespace serveStatic {
|
|
||||||
var mime: typeof m;
|
|
||||||
}
|
|
||||||
|
|
||||||
export = serveStatic;
|
|
||||||
}
|
|
12
ts/typings/tsd.d.ts
vendored
12
ts/typings/tsd.d.ts
vendored
@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
/// <reference path="mocha/mocha.d.ts" />
|
|
||||||
/// <reference path="lodash/lodash.d.ts" />
|
|
||||||
/// <reference path="assertion-error/assertion-error.d.ts" />
|
|
||||||
/// <reference path="chai/chai.d.ts" />
|
|
||||||
/// <reference path="archiver/archiver.d.ts" />
|
|
||||||
/// <reference path="node/node.d.ts" />
|
|
||||||
/// <reference path="express-serve-static-core/express-serve-static-core.d.ts" />
|
|
||||||
/// <reference path="express/express.d.ts" />
|
|
||||||
/// <reference path="mime/mime.d.ts" />
|
|
||||||
/// <reference path="serve-static/serve-static.d.ts" />
|
|
||||||
/// <reference path="xml/xml.d.ts" />
|
|
8
ts/typings/xml/xml.d.ts
vendored
8
ts/typings/xml/xml.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
declare module "xml" {
|
|
||||||
function xml(xmlObject: any, options?: any): string;
|
|
||||||
|
|
||||||
namespace xml {
|
|
||||||
|
|
||||||
}
|
|
||||||
export = xml;
|
|
||||||
}
|
|
Reference in New Issue
Block a user