Merge pull request #52 from dolanmiu/feat/file-wrapper
Feat/file wrapper
This commit is contained in:
13
.editorconfig
Normal file
13
.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -38,3 +38,6 @@ build-tests
|
|||||||
|
|
||||||
# vscode
|
# vscode
|
||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
|
# Lock files
|
||||||
|
package-lock.json
|
@ -1,6 +1,6 @@
|
|||||||
const docx = require('../build');
|
const docx = require('../build');
|
||||||
|
|
||||||
var doc = new docx.Document();
|
var doc = new docx.File();
|
||||||
|
|
||||||
var paragraph = new docx.Paragraph("Hello World");
|
var paragraph = new docx.Paragraph("Hello World");
|
||||||
var institutionText = new docx.TextRun("University College London").bold();
|
var institutionText = new docx.TextRun("University College London").bold();
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
const docx = require('../build');
|
const docx = require('../build');
|
||||||
|
|
||||||
const styles = new docx.Styles();
|
const doc = new docx.File({
|
||||||
styles.createParagraphStyle('Heading1', 'Heading 1')
|
creator: 'Clippy',
|
||||||
|
title: 'Sample Document',
|
||||||
|
description: 'A brief example of using docx',
|
||||||
|
});
|
||||||
|
|
||||||
|
doc.Styles.createParagraphStyle('Heading1', 'Heading 1')
|
||||||
.basedOn("Normal")
|
.basedOn("Normal")
|
||||||
.next("Normal")
|
.next("Normal")
|
||||||
.quickFormat()
|
.quickFormat()
|
||||||
@ -10,7 +15,7 @@ styles.createParagraphStyle('Heading1', 'Heading 1')
|
|||||||
.italics()
|
.italics()
|
||||||
.spacing({after: 120});
|
.spacing({after: 120});
|
||||||
|
|
||||||
styles.createParagraphStyle('Heading2', 'Heading 2')
|
doc.Styles.createParagraphStyle('Heading2', 'Heading 2')
|
||||||
.basedOn("Normal")
|
.basedOn("Normal")
|
||||||
.next("Normal")
|
.next("Normal")
|
||||||
.quickFormat()
|
.quickFormat()
|
||||||
@ -19,7 +24,7 @@ styles.createParagraphStyle('Heading2', 'Heading 2')
|
|||||||
.underline('double', 'FF0000')
|
.underline('double', 'FF0000')
|
||||||
.spacing({before: 240, after: 120});
|
.spacing({before: 240, after: 120});
|
||||||
|
|
||||||
styles.createParagraphStyle('aside', 'Aside')
|
doc.Styles.createParagraphStyle('aside', 'Aside')
|
||||||
.basedOn('Normal')
|
.basedOn('Normal')
|
||||||
.next('Normal')
|
.next('Normal')
|
||||||
.color('999999')
|
.color('999999')
|
||||||
@ -27,31 +32,24 @@ styles.createParagraphStyle('aside', 'Aside')
|
|||||||
.indent(720)
|
.indent(720)
|
||||||
.spacing({line: 276});
|
.spacing({line: 276});
|
||||||
|
|
||||||
styles.createParagraphStyle('wellSpaced', 'Well Spaced')
|
doc.Styles.createParagraphStyle('wellSpaced', 'Well Spaced')
|
||||||
.basedOn('Normal')
|
.basedOn('Normal')
|
||||||
.spacing({line: 276, before: 20 * 72 * .1, after: 20 * 72 * .05});
|
.spacing({line: 276, before: 20 * 72 * .1, after: 20 * 72 * .05});
|
||||||
|
|
||||||
styles.createParagraphStyle('ListParagraph', 'List Paragraph')
|
doc.Styles.createParagraphStyle('ListParagraph', 'List Paragraph')
|
||||||
.quickFormat()
|
.quickFormat()
|
||||||
.basedOn('Normal');
|
.basedOn('Normal');
|
||||||
|
|
||||||
|
|
||||||
const numbering = new docx.Numbering();
|
const numberedAbstract = doc.Numbering.createAbstractNumbering();
|
||||||
const numberedAbstract = numbering.createAbstractNumbering();
|
|
||||||
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "left");
|
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "left");
|
||||||
|
|
||||||
const doc = new docx.Document({
|
|
||||||
creator: 'Clippy',
|
|
||||||
title: 'Sample Document',
|
|
||||||
description: 'A brief example of using docx',
|
|
||||||
});
|
|
||||||
|
|
||||||
doc.createParagraph('Test heading1, bold and italicized').heading1();
|
doc.createParagraph('Test heading1, bold and italicized').heading1();
|
||||||
doc.createParagraph('Some simple content');
|
doc.createParagraph('Some simple content');
|
||||||
doc.createParagraph('Test heading2 with double red underline').heading2();
|
doc.createParagraph('Test heading2 with double red underline').heading2();
|
||||||
|
|
||||||
const letterNumbering = numbering.createConcreteNumbering(numberedAbstract);
|
const letterNumbering = doc.Numbering.createConcreteNumbering(numberedAbstract);
|
||||||
const letterNumbering5 = numbering.createConcreteNumbering(numberedAbstract);
|
const letterNumbering5 = doc.Numbering.createConcreteNumbering(numberedAbstract);
|
||||||
letterNumbering5.overrideLevel(0, 5);
|
letterNumbering5.overrideLevel(0, 5);
|
||||||
|
|
||||||
doc.createParagraph('Option1').setNumbering(letterNumbering, 0);
|
doc.createParagraph('Option1').setNumbering(letterNumbering, 0);
|
||||||
@ -70,5 +68,5 @@ para.createTextRun(' switching to normal ');
|
|||||||
para.createTextRun('and then underlined ').underline();
|
para.createTextRun('and then underlined ').underline();
|
||||||
para.createTextRun('and back to normal.');
|
para.createTextRun('and back to normal.');
|
||||||
|
|
||||||
const exporter = new docx.LocalPacker(doc, styles, undefined, numbering);
|
const exporter = new docx.LocalPacker(doc);
|
||||||
exporter.pack('test.docx');
|
exporter.pack('My Document');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const docx = require('../build');
|
const docx = require('../build');
|
||||||
|
|
||||||
var doc = new docx.Document();
|
var doc = new docx.File();
|
||||||
|
|
||||||
const numbering = new docx.Numbering();
|
const numbering = new docx.Numbering();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const docx = require('../build');
|
const docx = require('../build');
|
||||||
|
|
||||||
var doc = new docx.Document();
|
var doc = new docx.File();
|
||||||
|
|
||||||
const table = doc.createTable(4, 4);
|
const table = doc.createTable(4, 4);
|
||||||
table.getCell(2, 2).addContent(new docx.Paragraph('Hello'));
|
table.getCell(2, 2).addContent(new docx.Paragraph('Hello'));
|
||||||
|
19
package.json
19
package.json
@ -4,13 +4,15 @@
|
|||||||
"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 src/test-tsconfig.json",
|
"pretest": "rimraf ./build",
|
||||||
"test": "mocha ./build-tests --recursive",
|
"test": "mocha-webpack \"src/**/*.ts\"",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"lint": "tslint --project ./src",
|
"lint": "tslint --project .",
|
||||||
"build": "rimraf ./build && tsc -p src",
|
"build": "npm run webpack",
|
||||||
|
"tsc": "rimraf ./build && tsc -p .",
|
||||||
|
"webpack": "rimraf ./build && webpack",
|
||||||
"demo": "npm run build && node ./demo",
|
"demo": "npm run build && node ./demo",
|
||||||
"typedoc": "typedoc --out docs/ src/ --module commonjs --target ES6 --disableOutputCheck"
|
"typedoc": "npm run build && typedoc --out docs/ src/ --module commonjs --target ES6 --disableOutputCheck"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src",
|
"src",
|
||||||
@ -53,13 +55,16 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "^3.4.35",
|
"@types/chai": "^3.4.35",
|
||||||
"@types/mocha": "^2.2.39",
|
"@types/mocha": "^2.2.39",
|
||||||
|
"awesome-typescript-loader": "^3.4.1",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"mocha": "^3.2.0",
|
"mocha": "^3.2.0",
|
||||||
|
"mocha-webpack": "^1.0.1",
|
||||||
"prompt": "^1.0.0",
|
"prompt": "^1.0.0",
|
||||||
"rimraf": "^2.5.2",
|
"rimraf": "^2.5.2",
|
||||||
"shelljs": "^0.7.7",
|
"shelljs": "^0.7.7",
|
||||||
"tslint": "^5.1.0",
|
"tslint": "^5.1.0",
|
||||||
"typedoc": "^0.5.10",
|
"typedoc": "^0.9.0",
|
||||||
"typescript": "2.4.1"
|
"typescript": "2.4.1",
|
||||||
|
"webpack": "^3.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
export * from "./document";
|
|
||||||
export * from "./paragraph";
|
|
||||||
export * from "./run";
|
|
||||||
export { Table } from "./table";
|
|
@ -1,9 +1,9 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import * as docx from "../docx";
|
|
||||||
import { Attributes } from "../docx/xml-components";
|
|
||||||
import { Formatter } from "../export/formatter";
|
import { Formatter } from "../export/formatter";
|
||||||
import { Properties } from "../properties";
|
import * as file from "../file";
|
||||||
|
import { Properties } from "../file/properties";
|
||||||
|
import { Attributes } from "../file/xml-components";
|
||||||
import { Utility } from "../tests/utility";
|
import { Utility } from "../tests/utility";
|
||||||
|
|
||||||
describe("Formatter", () => {
|
describe("Formatter", () => {
|
||||||
@ -15,21 +15,21 @@ describe("Formatter", () => {
|
|||||||
|
|
||||||
describe("#format()", () => {
|
describe("#format()", () => {
|
||||||
it("should format simple paragraph", () => {
|
it("should format simple paragraph", () => {
|
||||||
const paragraph = new docx.Paragraph();
|
const paragraph = new file.Paragraph();
|
||||||
const newJson = formatter.format(paragraph);
|
const newJson = formatter.format(paragraph);
|
||||||
assert.isDefined(newJson["w:p"]);
|
assert.isDefined(newJson["w:p"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove xmlKeys", () => {
|
it("should remove xmlKeys", () => {
|
||||||
const paragraph = new docx.Paragraph();
|
const paragraph = new file.Paragraph();
|
||||||
const newJson = formatter.format(paragraph);
|
const newJson = formatter.format(paragraph);
|
||||||
const stringifiedJson = JSON.stringify(newJson);
|
const stringifiedJson = JSON.stringify(newJson);
|
||||||
assert(stringifiedJson.indexOf("xmlKeys") < 0);
|
assert(stringifiedJson.indexOf("xmlKeys") < 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should format simple paragraph with bold text", () => {
|
it("should format simple paragraph with bold text", () => {
|
||||||
const paragraph = new docx.Paragraph();
|
const paragraph = new file.Paragraph();
|
||||||
paragraph.addRun(new docx.TextRun("test").bold());
|
paragraph.addRun(new file.TextRun("test").bold());
|
||||||
const newJson = formatter.format(paragraph);
|
const newJson = formatter.format(paragraph);
|
||||||
assert.isDefined(newJson["w:p"][1]["w:r"][0]["w:rPr"][0]["w:b"][0]._attr["w:val"]);
|
assert.isDefined(newJson["w:p"][1]["w:r"][0]["w:rPr"][0]["w:b"][0]._attr["w:val"]);
|
||||||
});
|
});
|
||||||
@ -61,7 +61,7 @@ describe("Formatter", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should should change 'p' tag into 'w:p' tag", () => {
|
it("should should change 'p' tag into 'w:p' tag", () => {
|
||||||
const paragraph = new docx.Paragraph();
|
const paragraph = new file.Paragraph();
|
||||||
const newJson = formatter.format(paragraph);
|
const newJson = formatter.format(paragraph);
|
||||||
assert.isDefined(newJson["w:p"]);
|
assert.isDefined(newJson["w:p"]);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { BaseXmlComponent } from "../docx/xml-components";
|
import { BaseXmlComponent } from "file/xml-components";
|
||||||
import { IXmlableObject } from "../docx/xml-components/xmlable-object";
|
import { IXmlableObject } from "file/xml-components/xmlable-object";
|
||||||
|
|
||||||
export class Formatter {
|
export class Formatter {
|
||||||
public format(input: BaseXmlComponent): IXmlableObject {
|
public format(input: BaseXmlComponent): IXmlableObject {
|
||||||
|
@ -4,12 +4,7 @@ import * as fs from "fs";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as xml from "xml";
|
import * as xml from "xml";
|
||||||
|
|
||||||
import { Document } from "../../docx";
|
import { File } from "file";
|
||||||
import { Media } from "../../media";
|
|
||||||
import { Numbering } from "../../numbering";
|
|
||||||
import { Properties } from "../../properties";
|
|
||||||
import { Styles } from "../../styles";
|
|
||||||
import { DefaultStylesFactory } from "../../styles/factory";
|
|
||||||
import { Formatter } from "../formatter";
|
import { Formatter } from "../formatter";
|
||||||
|
|
||||||
const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
|
const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
|
||||||
@ -17,29 +12,11 @@ const TEMPLATE_PATH = path.resolve(__dirname, "../../../template");
|
|||||||
export class Compiler {
|
export class Compiler {
|
||||||
protected archive: archiver.Archiver;
|
protected archive: archiver.Archiver;
|
||||||
private formatter: Formatter;
|
private formatter: Formatter;
|
||||||
private style: Styles;
|
|
||||||
|
|
||||||
constructor(
|
constructor(private file: File) {
|
||||||
protected document: Document,
|
|
||||||
style?: Styles,
|
|
||||||
private properties: Properties = new Properties({
|
|
||||||
creator: "Un-named",
|
|
||||||
revision: "1",
|
|
||||||
lastModifiedBy: "Un-named",
|
|
||||||
}),
|
|
||||||
private numbering: Numbering = new Numbering(),
|
|
||||||
private media: Media = new Media(),
|
|
||||||
) {
|
|
||||||
this.formatter = new Formatter();
|
this.formatter = new Formatter();
|
||||||
this.archive = archiver.create("zip", {});
|
this.archive = archiver.create("zip", {});
|
||||||
|
|
||||||
if (style) {
|
|
||||||
this.style = style;
|
|
||||||
} else {
|
|
||||||
const stylesFactory = new DefaultStylesFactory();
|
|
||||||
this.style = stylesFactory.newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.archive.on("error", (err) => {
|
this.archive.on("error", (err) => {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
@ -55,15 +32,15 @@ export class Compiler {
|
|||||||
cwd: TEMPLATE_PATH,
|
cwd: TEMPLATE_PATH,
|
||||||
});
|
});
|
||||||
|
|
||||||
const xmlDocument = xml(this.formatter.format(this.document));
|
const xmlDocument = xml(this.formatter.format(this.file.Document));
|
||||||
const xmlStyles = xml(this.formatter.format(this.style));
|
const xmlStyles = xml(this.formatter.format(this.file.Styles));
|
||||||
const xmlProperties = xml(this.formatter.format(this.properties), {
|
const xmlProperties = xml(this.formatter.format(this.file.Properties), {
|
||||||
declaration: {
|
declaration: {
|
||||||
standalone: "yes",
|
standalone: "yes",
|
||||||
encoding: "UTF-8",
|
encoding: "UTF-8",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const xmlNumbering = xml(this.formatter.format(this.numbering));
|
const xmlNumbering = xml(this.formatter.format(this.file.Numbering));
|
||||||
|
|
||||||
this.archive.append(xmlDocument, {
|
this.archive.append(xmlDocument, {
|
||||||
name: "word/document.xml",
|
name: "word/document.xml",
|
||||||
@ -81,7 +58,7 @@ export class Compiler {
|
|||||||
name: "word/numbering.xml",
|
name: "word/numbering.xml",
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const data of this.media.array) {
|
for (const data of this.file.Media.array) {
|
||||||
this.archive.append(data.stream, {
|
this.archive.append(data.stream, {
|
||||||
name: `media/${data.fileName}`,
|
name: `media/${data.fileName}`,
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
|
|
||||||
import { Document } from "../../docx/document";
|
import { File } from "file";
|
||||||
import { Media } from "../../media";
|
|
||||||
import { Numbering } from "../../numbering";
|
|
||||||
import { Properties } from "../../properties";
|
|
||||||
import { Styles } from "../../styles";
|
|
||||||
import { Compiler } from "./compiler";
|
import { Compiler } from "./compiler";
|
||||||
import { IPacker } from "./packer";
|
import { IPacker } from "./packer";
|
||||||
|
|
||||||
@ -12,8 +8,8 @@ export class ExpressPacker implements IPacker {
|
|||||||
private res: express.Response;
|
private res: express.Response;
|
||||||
private packer: Compiler;
|
private packer: Compiler;
|
||||||
|
|
||||||
constructor(document: Document, res: express.Response, styles?: Styles, properties?: Properties, numbering?: Numbering, media?: Media) {
|
constructor(file: File, res: express.Response) {
|
||||||
this.packer = new Compiler(document, styles, properties, numbering, media);
|
this.packer = new Compiler(file);
|
||||||
|
|
||||||
this.res = res;
|
this.res = res;
|
||||||
|
|
||||||
|
@ -1,38 +1,33 @@
|
|||||||
/* tslint:disable:typedef space-before-function-paren */
|
/* tslint:disable:typedef space-before-function-paren */
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
import { Document } from "../../docx/document";
|
|
||||||
import { Paragraph } from "../../docx/paragraph";
|
|
||||||
import { LocalPacker } from "../../export/packer/local";
|
import { LocalPacker } from "../../export/packer/local";
|
||||||
import { Properties } from "../../properties";
|
import { File, Paragraph } from "../../file";
|
||||||
import { DefaultStylesFactory } from "../../styles/factory";
|
|
||||||
|
|
||||||
describe("LocalPacker", () => {
|
describe("LocalPacker", () => {
|
||||||
let packer: LocalPacker;
|
let packer: LocalPacker;
|
||||||
let stylesFactory: DefaultStylesFactory;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const document = new Document();
|
const file = new File({
|
||||||
const paragraph = new Paragraph("test text");
|
|
||||||
const heading = new Paragraph("Hello world").heading1();
|
|
||||||
document.addParagraph(new Paragraph("title").title());
|
|
||||||
document.addParagraph(heading);
|
|
||||||
document.addParagraph(new Paragraph("heading 2").heading2());
|
|
||||||
document.addParagraph(paragraph);
|
|
||||||
const properties = new Properties({
|
|
||||||
creator: "Dolan Miu",
|
creator: "Dolan Miu",
|
||||||
revision: "1",
|
revision: "1",
|
||||||
lastModifiedBy: "Dolan Miu",
|
lastModifiedBy: "Dolan Miu",
|
||||||
});
|
});
|
||||||
stylesFactory = new DefaultStylesFactory();
|
const paragraph = new Paragraph("test text");
|
||||||
packer = new LocalPacker(document, stylesFactory.newInstance(), properties);
|
const heading = new Paragraph("Hello world").heading1();
|
||||||
|
file.addParagraph(new Paragraph("title").title());
|
||||||
|
file.addParagraph(heading);
|
||||||
|
file.addParagraph(new Paragraph("heading 2").heading2());
|
||||||
|
file.addParagraph(paragraph);
|
||||||
|
|
||||||
|
packer = new LocalPacker(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#pack()", () => {
|
describe("#pack()", () => {
|
||||||
it("should create a standard docx file", async function () {
|
it("should create a standard docx file", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
await packer.pack("build-tests/tests/test");
|
await packer.pack("build/tests/test");
|
||||||
fs.statSync("build-tests/tests/test.docx");
|
fs.statSync("build/tests/test.docx");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -40,8 +35,8 @@ describe("LocalPacker", () => {
|
|||||||
it("should create a standard PDF file", async function () {
|
it("should create a standard PDF file", async function () {
|
||||||
this.timeout(99999999);
|
this.timeout(99999999);
|
||||||
|
|
||||||
await packer.packPdf("build-tests/tests/pdf-test");
|
await packer.packPdf("build/tests/pdf-test");
|
||||||
fs.statSync("build-tests/tests/pdf-test.pdf");
|
fs.statSync("build/tests/pdf-test.pdf");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,11 +2,7 @@ import * as fs from "fs";
|
|||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import { Document } from "../../docx/document";
|
import { File } from "../../file";
|
||||||
import { Media } from "../../media";
|
|
||||||
import { Numbering } from "../../numbering";
|
|
||||||
import { Properties } from "../../properties";
|
|
||||||
import { Styles } from "../../styles";
|
|
||||||
import { Compiler } from "./compiler";
|
import { Compiler } from "./compiler";
|
||||||
import { IPacker } from "./packer";
|
import { IPacker } from "./packer";
|
||||||
import { PdfConvertWrapper } from "./pdf-convert-wrapper";
|
import { PdfConvertWrapper } from "./pdf-convert-wrapper";
|
||||||
@ -16,9 +12,9 @@ export class LocalPacker implements IPacker {
|
|||||||
private pdfConverter: PdfConvertWrapper;
|
private pdfConverter: PdfConvertWrapper;
|
||||||
private packer: Compiler;
|
private packer: Compiler;
|
||||||
|
|
||||||
constructor(document: Document, styles?: Styles, properties?: Properties, numbering?: Numbering, media?: Media) {
|
constructor(file: File) {
|
||||||
this.pdfConverter = new PdfConvertWrapper();
|
this.pdfConverter = new PdfConvertWrapper();
|
||||||
this.packer = new Compiler(document, styles, properties, numbering, media);
|
this.packer = new Compiler(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pack(filePath: string): Promise<void> {
|
public async pack(filePath: string): Promise<void> {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Body extends XmlComponent {
|
export class Body extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Columns extends XmlComponent {
|
export class Columns extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class DocumentGrid extends XmlComponent {
|
export class DocumentGrid extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class PageMargin extends XmlComponent {
|
export class PageMargin extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class PageSize extends XmlComponent {
|
export class PageSize extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
import { Columns } from "./columns";
|
import { Columns } from "./columns";
|
||||||
import { DocumentGrid } from "./doc-grid";
|
import { DocumentGrid } from "./doc-grid";
|
||||||
import { PageMargin } from "./page-margin";
|
import { PageMargin } from "./page-margin";
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent } from "../xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IDocumentAttributesProperties {
|
export interface IDocumentAttributesProperties {
|
||||||
wpc?: string;
|
wpc?: string;
|
@ -1,7 +1,7 @@
|
|||||||
// http://officeopenxml.com/WPdocument.php
|
// http://officeopenxml.com/WPdocument.php
|
||||||
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Paragraph } from "../paragraph";
|
import { Paragraph } from "../paragraph";
|
||||||
import { Table } from "../table";
|
import { Table } from "../table";
|
||||||
import { XmlComponent } from "../xml-components";
|
|
||||||
import { Body } from "./body";
|
import { Body } from "./body";
|
||||||
import { DocumentAttributes } from "./document-attributes";
|
import { DocumentAttributes } from "./document-attributes";
|
||||||
|
|
||||||
@ -52,5 +52,4 @@ export class Document extends XmlComponent {
|
|||||||
this.addTable(table);
|
this.addTable(table);
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
|
||||||
import { Utility } from "../../../../tests/utility";
|
import { Utility } from "../../tests/utility";
|
||||||
import { Drawing } from "./";
|
import { Drawing } from "./";
|
||||||
|
|
||||||
describe("Drawing", () => {
|
describe("Drawing", () => {
|
@ -1,5 +1,5 @@
|
|||||||
import { IData } from "../../../../media/data";
|
import { IData } from "file/media";
|
||||||
import { XmlComponent } from "../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Inline } from "./inline";
|
import { Inline } from "./inline";
|
||||||
|
|
||||||
export class Drawing extends XmlComponent {
|
export class Drawing extends XmlComponent {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Pic } from "./pic";
|
import { Pic } from "./pic";
|
||||||
|
|
||||||
export class GraphicData extends XmlComponent {
|
export class GraphicData extends XmlComponent {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Blip } from "./blip";
|
import { Blip } from "./blip";
|
||||||
import { SourceRectangle } from "./source-rectangle";
|
import { SourceRectangle } from "./source-rectangle";
|
||||||
import { Stretch } from "./stretch";
|
import { Stretch } from "./stretch";
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../../../../../../../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
interface IBlipProperties {
|
interface IBlipProperties {
|
||||||
embed: string;
|
embed: string;
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class SourceRectangle extends XmlComponent {
|
export class SourceRectangle extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class FillRectangle extends XmlComponent {
|
class FillRectangle extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { BlipFill } from "./blip/blip-fill";
|
import { BlipFill } from "./blip/blip-fill";
|
||||||
|
|
||||||
export class Pic extends XmlComponent {
|
export class Pic extends XmlComponent {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../../../../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
import { GraphicData } from "./graphic-data";
|
import { GraphicData } from "./graphic-data";
|
||||||
|
|
||||||
interface IGraphicProperties {
|
interface IGraphicProperties {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Graphic } from "./graphic";
|
import { Graphic } from "./graphic";
|
||||||
|
|
||||||
export class Inline extends XmlComponent {
|
export class Inline extends XmlComponent {
|
71
src/file/file.ts
Normal file
71
src/file/file.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { Document } from "./document";
|
||||||
|
import { Media } from "./media";
|
||||||
|
import { Numbering } from "./numbering";
|
||||||
|
import { Paragraph } from "./paragraph";
|
||||||
|
import { IPropertiesOptions, Properties } from "./properties";
|
||||||
|
import { Styles } from "./styles";
|
||||||
|
import { DefaultStylesFactory } from "./styles/factory";
|
||||||
|
import { Table } from "./table";
|
||||||
|
|
||||||
|
export class File {
|
||||||
|
|
||||||
|
private document: Document;
|
||||||
|
private styles: Styles;
|
||||||
|
private properties: Properties;
|
||||||
|
private numbering: Numbering;
|
||||||
|
private media: Media;
|
||||||
|
|
||||||
|
constructor(options?: IPropertiesOptions) {
|
||||||
|
this.document = new Document();
|
||||||
|
const stylesFactory = new DefaultStylesFactory();
|
||||||
|
this.styles = stylesFactory.newInstance();
|
||||||
|
|
||||||
|
if (!options) {
|
||||||
|
options = {
|
||||||
|
creator: "Un-named",
|
||||||
|
revision: "1",
|
||||||
|
lastModifiedBy: "Un-named",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.properties = new Properties(options);
|
||||||
|
this.numbering = new Numbering();
|
||||||
|
this.media = new Media();
|
||||||
|
}
|
||||||
|
|
||||||
|
public addParagraph(paragraph: Paragraph): void {
|
||||||
|
this.document.addParagraph(paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
public createParagraph(text?: string): Paragraph {
|
||||||
|
return this.document.createParagraph();
|
||||||
|
}
|
||||||
|
|
||||||
|
public addTable(table: Table): void {
|
||||||
|
return this.document.addTable(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public createTable(rows: number, cols: number): Table {
|
||||||
|
return this.document.createTable(rows, cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Document(): Document {
|
||||||
|
return this.document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Styles(): Styles {
|
||||||
|
return this.styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Properties(): Properties {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Numbering(): Numbering {
|
||||||
|
return this.numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Media(): Media {
|
||||||
|
return this.media;
|
||||||
|
}
|
||||||
|
}
|
8
src/file/index.ts
Normal file
8
src/file/index.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export * from "./document";
|
||||||
|
export * from "./paragraph";
|
||||||
|
export * from "./table";
|
||||||
|
export * from "./file";
|
||||||
|
export * from "./numbering";
|
||||||
|
export * from "./media";
|
||||||
|
export * from "./drawing";
|
||||||
|
export * from "./styles";
|
2
src/file/media/index.ts
Normal file
2
src/file/media/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from "./media";
|
||||||
|
export * from "./data";
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
import { Level } from "./level";
|
import { Level } from "./level";
|
||||||
import { MultiLevelType } from "./multi-level-type";
|
import { MultiLevelType } from "./multi-level-type";
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
import * as paragraph from "../docx/paragraph/formatting";
|
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
import { ParagraphProperties } from "../docx/paragraph/properties";
|
import * as paragraph from "../paragraph/formatting";
|
||||||
import * as formatting from "../docx/run/formatting";
|
import { ParagraphProperties } from "../paragraph/properties";
|
||||||
import { RunProperties } from "../docx/run/properties";
|
import * as formatting from "../paragraph/run/formatting";
|
||||||
import { Attributes, XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
import { RunProperties } from "../paragraph/run/properties";
|
||||||
|
|
||||||
interface ILevelAttributesProperties {
|
interface ILevelAttributesProperties {
|
||||||
ilvl?: number;
|
ilvl?: number;
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../docx/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class MultiLevelType extends XmlComponent {
|
export class MultiLevelType extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlAttributeComponent, XmlComponent } from "../docx/xml-components";
|
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
import { LevelForOverride } from "./level";
|
import { LevelForOverride } from "./level";
|
||||||
|
|
||||||
class AbstractNumId extends XmlComponent {
|
class AbstractNumId extends XmlComponent {
|
@ -1,5 +1,5 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
import { Formatter } from "../export/formatter";
|
import { Formatter } from "../../export/formatter";
|
||||||
import { Numbering } from "./";
|
import { Numbering } from "./";
|
||||||
import { AbstractNumbering } from "./abstract-numbering";
|
import { AbstractNumbering } from "./abstract-numbering";
|
||||||
import { LevelForOverride } from "./level";
|
import { LevelForOverride } from "./level";
|
@ -1,7 +1,7 @@
|
|||||||
import { DocumentAttributes } from "../docx/document/document-attributes";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Indent } from "../docx/paragraph/formatting";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
import { RunFonts } from "../docx/run/run-fonts";
|
import { Indent } from "../paragraph/formatting";
|
||||||
import { XmlComponent } from "../docx/xml-components";
|
import { RunFonts } from "../paragraph/run/run-fonts";
|
||||||
import { AbstractNumbering } from "./abstract-numbering";
|
import { AbstractNumbering } from "./abstract-numbering";
|
||||||
import { Num } from "./num";
|
import { Num } from "./num";
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPalignment.php
|
// http://officeopenxml.com/WPalignment.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export type AlignmentOptions = "left" | "center" | "right" | "both";
|
export type AlignmentOptions = "left" | "center" | "right" | "both";
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPborders.php
|
// http://officeopenxml.com/WPborders.php
|
||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class Border extends XmlComponent {
|
class Border extends XmlComponent {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPindentation.php
|
// http://officeopenxml.com/WPindentation.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
interface IIndentAttributesProperties {
|
interface IIndentAttributesProperties {
|
||||||
left?: number;
|
left?: number;
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class KeepLines extends XmlComponent {
|
export class KeepLines extends XmlComponent {
|
||||||
constructor() {
|
constructor() {
|
@ -1,6 +1,6 @@
|
|||||||
// http://officeopenxml.com/WPtextSpecialContent-break.php
|
// http://officeopenxml.com/WPtextSpecialContent-break.php
|
||||||
import { Run } from "../../run";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Run } from "../run";
|
||||||
|
|
||||||
class Break extends XmlComponent {
|
class Break extends XmlComponent {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPspacing.php
|
// http://officeopenxml.com/WPspacing.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface ISpacingProperties {
|
export interface ISpacingProperties {
|
||||||
after?: number;
|
after?: number;
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Style extends XmlComponent {
|
export class Style extends XmlComponent {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPtab.php
|
// http://officeopenxml.com/WPtab.php
|
||||||
import { XmlAttributeComponent, XmlComponent } from "../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class TabStop extends XmlComponent {
|
export class TabStop extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class NumberProperties extends XmlComponent {
|
export class NumberProperties extends XmlComponent {
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
export * from "./formatting";
|
export * from "./formatting";
|
||||||
export * from "./paragraph";
|
export * from "./paragraph";
|
||||||
export * from "./properties";
|
export * from "./properties";
|
||||||
|
export * from "./run";
|
@ -1,14 +1,14 @@
|
|||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
import * as docx from "../../docx";
|
|
||||||
import { Formatter } from "../../export/formatter";
|
import { Formatter } from "../../export/formatter";
|
||||||
import { Numbering } from "../../numbering";
|
import * as file from "../../file";
|
||||||
|
import { Numbering } from "../numbering";
|
||||||
|
|
||||||
describe("Paragraph", () => {
|
describe("Paragraph", () => {
|
||||||
let paragraph: docx.Paragraph;
|
let paragraph: file.Paragraph;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
paragraph = new docx.Paragraph();
|
paragraph = new file.Paragraph();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#constructor()", () => {
|
describe("#constructor()", () => {
|
||||||
@ -35,7 +35,7 @@ describe("Paragraph", () => {
|
|||||||
describe("#createTextRun", () => {
|
describe("#createTextRun", () => {
|
||||||
it("should add a new run to the paragraph and return it", () => {
|
it("should add a new run to the paragraph and return it", () => {
|
||||||
const run = paragraph.createTextRun("this is a test run");
|
const run = paragraph.createTextRun("this is a test run");
|
||||||
expect(run).to.be.instanceof(docx.TextRun);
|
expect(run).to.be.instanceof(file.TextRun);
|
||||||
const tree = new Formatter().format(paragraph)["w:p"];
|
const tree = new Formatter().format(paragraph)["w:p"];
|
||||||
expect(tree).to.be.an("array").which.includes({
|
expect(tree).to.be.an("array").which.includes({
|
||||||
"w:r": [
|
"w:r": [
|
@ -1,10 +1,8 @@
|
|||||||
// http://officeopenxml.com/WPparagraph.php
|
// http://officeopenxml.com/WPparagraph.php
|
||||||
import { IData } from "../../media/data";
|
import { IData } from "file/media";
|
||||||
import { Num } from "../../numbering/num";
|
import { Num } from "file/numbering/num";
|
||||||
import { Run } from "../run";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { PictureRun } from "../run/picture-run";
|
import { PictureRun, Run, TextRun } from "./run";
|
||||||
import { TextRun } from "../run/text-run";
|
|
||||||
import { XmlComponent } from "../xml-components";
|
|
||||||
|
|
||||||
import { Alignment } from "./formatting/alignment";
|
import { Alignment } from "./formatting/alignment";
|
||||||
import { ThematicBreak } from "./formatting/border";
|
import { ThematicBreak } from "./formatting/border";
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPparagraphProperties.php
|
// http://officeopenxml.com/WPparagraphProperties.php
|
||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class ParagraphProperties extends XmlComponent {
|
export class ParagraphProperties extends XmlComponent {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import { Break } from "./break";
|
import { Break } from "./break";
|
||||||
|
|
||||||
describe("Break", () => {
|
describe("Break", () => {
|
@ -1,5 +1,5 @@
|
|||||||
// http://officeopenxml.com/WPtextSpecialContent-break.php
|
// http://officeopenxml.com/WPtextSpecialContent-break.php
|
||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Break extends XmlComponent {
|
export class Break extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class SmallCaps extends XmlComponent {
|
export class SmallCaps extends XmlComponent {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
export { Underline } from "./underline";
|
export { Underline } from "./underline";
|
||||||
export { SubScript, SuperScript } from "./script";
|
export { SubScript, SuperScript } from "./script";
|
||||||
export { RunFonts } from "./run-fonts";
|
export { RunFonts } from "./run-fonts";
|
@ -1,6 +1,6 @@
|
|||||||
|
import { Drawing } from "../../drawing";
|
||||||
import { IData } from "../../media/data";
|
import { IData } from "../../media/data";
|
||||||
import { Run } from "../run";
|
import { Run } from "../run";
|
||||||
import { Drawing } from "./run-components/drawing";
|
|
||||||
|
|
||||||
export class PictureRun extends Run {
|
export class PictureRun extends Run {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class RunProperties extends XmlComponent {
|
export class RunProperties extends XmlComponent {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../../../export/formatter";
|
import { Formatter } from "../../../../export/formatter";
|
||||||
import { Text } from "./text";
|
import { Text } from "./text";
|
||||||
|
|
||||||
describe("Text", () => {
|
describe("Text", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class TextAttributes extends XmlAttributeComponent<{space: "default" | "preserve"}> {
|
class TextAttributes extends XmlAttributeComponent<{space: "default" | "preserve"}> {
|
||||||
protected xmlKeys = {space: "xml:space"};
|
protected xmlKeys = {space: "xml:space"};
|
@ -1,6 +1,6 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../../export/formatter";
|
import { Formatter } from "../../../export/formatter";
|
||||||
import { RunFonts } from "./run-fonts";
|
import { RunFonts } from "./run-fonts";
|
||||||
|
|
||||||
describe("RunFonts", () => {
|
describe("RunFonts", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
interface IRunFontAttributesProperties {
|
interface IRunFontAttributesProperties {
|
||||||
ascii: string;
|
ascii: string;
|
@ -1,7 +1,7 @@
|
|||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../../export/formatter";
|
import { Formatter } from "../../../export/formatter";
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import { Run } from "./";
|
import { Run } from "./";
|
||||||
|
|
||||||
describe("Run", () => {
|
describe("Run", () => {
|
@ -9,7 +9,7 @@ import { Style } from "./style";
|
|||||||
import { Tab } from "./tab";
|
import { Tab } from "./tab";
|
||||||
import { Underline } from "./underline";
|
import { Underline } from "./underline";
|
||||||
|
|
||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Run extends XmlComponent {
|
export class Run extends XmlComponent {
|
||||||
private properties: RunProperties;
|
private properties: RunProperties;
|
@ -1,6 +1,6 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import { SubScript, SuperScript } from "./script";
|
import { SubScript, SuperScript } from "./script";
|
||||||
|
|
||||||
describe("SubScript", () => {
|
describe("SubScript", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export abstract class VerticalAlign extends XmlComponent {
|
export abstract class VerticalAlign extends XmlComponent {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import { DoubleStrike, Strike } from "./formatting";
|
import { DoubleStrike, Strike } from "./formatting";
|
||||||
|
|
||||||
describe("Strike", () => {
|
describe("Strike", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent, XmlComponent } from "../xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class StyleAttributes extends XmlAttributeComponent<{val: string}> {
|
class StyleAttributes extends XmlAttributeComponent<{val: string}> {
|
||||||
protected xmlKeys = {val: "w:val"};
|
protected xmlKeys = {val: "w:val"};
|
@ -1,6 +1,6 @@
|
|||||||
import { assert } from "chai";
|
import { assert } from "chai";
|
||||||
|
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import { Tab } from "./tab";
|
import { Tab } from "./tab";
|
||||||
|
|
||||||
describe("Tab", () => {
|
describe("Tab", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export class Tab extends XmlComponent {
|
export class Tab extends XmlComponent {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../../export/formatter";
|
import { Formatter } from "../../../export/formatter";
|
||||||
import { TextRun } from "./text-run";
|
import { TextRun } from "./text-run";
|
||||||
|
|
||||||
describe("TextRun", () => {
|
describe("TextRun", () => {
|
@ -1,7 +1,7 @@
|
|||||||
import { assert, expect } from "chai";
|
import { assert, expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../../export/formatter";
|
import { Formatter } from "../../../export/formatter";
|
||||||
import { Utility } from "../../tests/utility";
|
import { Utility } from "../../../tests/utility";
|
||||||
import * as u from "./underline";
|
import * as u from "./underline";
|
||||||
|
|
||||||
describe("Underline", () => {
|
describe("Underline", () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { Attributes, XmlComponent } from "../xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export abstract class BaseUnderline extends XmlComponent {
|
export abstract class BaseUnderline extends XmlComponent {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import { DocumentAttributes } from "../docx/document/document-attributes";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { XmlComponent } from "../docx/xml-components";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
|
|
||||||
export class Title extends XmlComponent {
|
export class Title extends XmlComponent {
|
||||||
|
|
1
src/file/properties/index.ts
Normal file
1
src/file/properties/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./properties";
|
@ -1,7 +1,7 @@
|
|||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
|
||||||
import { Formatter } from "../export/formatter";
|
import { Formatter } from "../../export/formatter";
|
||||||
import { Properties } from "./";
|
import { Properties } from "./properties";
|
||||||
|
|
||||||
describe("Properties", () => {
|
describe("Properties", () => {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import { DocumentAttributes } from "../docx/document/document-attributes";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { XmlComponent } from "../docx/xml-components";
|
import { DocumentAttributes } from "../document/document-attributes";
|
||||||
import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";
|
import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components";
|
||||||
|
|
||||||
export interface IPropertiesOptions {
|
export interface IPropertiesOptions {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlAttributeComponent } from "../docx/xml-components";
|
import { XmlAttributeComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IRelationshipsAttributesProperties {
|
export interface IRelationshipsAttributesProperties {
|
||||||
xmlns: string;
|
xmlns: string;
|
1
src/file/relationships/index.ts
Normal file
1
src/file/relationships/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "./relationships";
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../docx/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { RelationshipsAttributes } from "./attributes";
|
import { RelationshipsAttributes } from "./attributes";
|
||||||
|
|
||||||
export class Relationships extends XmlComponent {
|
export class Relationships extends XmlComponent {
|
@ -1,4 +1,4 @@
|
|||||||
import { XmlComponent } from "../../docx/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { ParagraphPropertiesDefaults } from "./paragraph-properties";
|
import { ParagraphPropertiesDefaults } from "./paragraph-properties";
|
||||||
import { RunPropertiesDefaults } from "./run-properties";
|
import { RunPropertiesDefaults } from "./run-properties";
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import { ParagraphProperties } from "../../docx/paragraph/properties";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { XmlComponent } from "../../docx/xml-components";
|
import { ParagraphProperties } from "../../paragraph/properties";
|
||||||
|
|
||||||
export class ParagraphPropertiesDefaults extends XmlComponent {
|
export class ParagraphPropertiesDefaults extends XmlComponent {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user