diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..9b7352176a --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore index 7c5b7bc2bd..83b42c1a11 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ build-tests # vscode .vscode + +# Lock files +package-lock.json \ No newline at end of file diff --git a/demo/demo1.js b/demo/demo1.js index 2a36bb1a83..1a550b5977 100644 --- a/demo/demo1.js +++ b/demo/demo1.js @@ -1,6 +1,6 @@ const docx = require('../build'); -var doc = new docx.Document(); +var doc = new docx.File(); var paragraph = new docx.Paragraph("Hello World"); var institutionText = new docx.TextRun("University College London").bold(); diff --git a/demo/demo2.js b/demo/demo2.js index ba880e2e30..9ae4ad8dc5 100644 --- a/demo/demo2.js +++ b/demo/demo2.js @@ -1,7 +1,12 @@ const docx = require('../build'); -const styles = new docx.Styles(); -styles.createParagraphStyle('Heading1', 'Heading 1') +const doc = new docx.File({ + creator: 'Clippy', + title: 'Sample Document', + description: 'A brief example of using docx', +}); + +doc.Styles.createParagraphStyle('Heading1', 'Heading 1') .basedOn("Normal") .next("Normal") .quickFormat() @@ -10,7 +15,7 @@ styles.createParagraphStyle('Heading1', 'Heading 1') .italics() .spacing({after: 120}); -styles.createParagraphStyle('Heading2', 'Heading 2') +doc.Styles.createParagraphStyle('Heading2', 'Heading 2') .basedOn("Normal") .next("Normal") .quickFormat() @@ -19,7 +24,7 @@ styles.createParagraphStyle('Heading2', 'Heading 2') .underline('double', 'FF0000') .spacing({before: 240, after: 120}); -styles.createParagraphStyle('aside', 'Aside') +doc.Styles.createParagraphStyle('aside', 'Aside') .basedOn('Normal') .next('Normal') .color('999999') @@ -27,31 +32,24 @@ styles.createParagraphStyle('aside', 'Aside') .indent(720) .spacing({line: 276}); -styles.createParagraphStyle('wellSpaced', 'Well Spaced') +doc.Styles.createParagraphStyle('wellSpaced', 'Well Spaced') .basedOn('Normal') .spacing({line: 276, before: 20 * 72 * .1, after: 20 * 72 * .05}); -styles.createParagraphStyle('ListParagraph', 'List Paragraph') +doc.Styles.createParagraphStyle('ListParagraph', 'List Paragraph') .quickFormat() .basedOn('Normal'); -const numbering = new docx.Numbering(); -const numberedAbstract = numbering.createAbstractNumbering(); +const numberedAbstract = doc.Numbering.createAbstractNumbering(); 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('Some simple content'); doc.createParagraph('Test heading2 with double red underline').heading2(); -const letterNumbering = numbering.createConcreteNumbering(numberedAbstract); -const letterNumbering5 = numbering.createConcreteNumbering(numberedAbstract); +const letterNumbering = doc.Numbering.createConcreteNumbering(numberedAbstract); +const letterNumbering5 = doc.Numbering.createConcreteNumbering(numberedAbstract); letterNumbering5.overrideLevel(0, 5); doc.createParagraph('Option1').setNumbering(letterNumbering, 0); @@ -70,5 +68,5 @@ para.createTextRun(' switching to normal '); para.createTextRun('and then underlined ').underline(); para.createTextRun('and back to normal.'); -const exporter = new docx.LocalPacker(doc, styles, undefined, numbering); -exporter.pack('test.docx'); +const exporter = new docx.LocalPacker(doc); +exporter.pack('My Document'); diff --git a/demo/demo3.js b/demo/demo3.js index 1cebd68076..e0606cad9c 100644 --- a/demo/demo3.js +++ b/demo/demo3.js @@ -1,6 +1,6 @@ const docx = require('../build'); -var doc = new docx.Document(); +var doc = new docx.File(); const numbering = new docx.Numbering(); diff --git a/demo/demo4.js b/demo/demo4.js index 4429895940..900e9a49c7 100644 --- a/demo/demo4.js +++ b/demo/demo4.js @@ -1,6 +1,6 @@ const docx = require('../build'); -var doc = new docx.Document(); +var doc = new docx.File(); const table = doc.createTable(4, 4); table.getCell(2, 2).addContent(new docx.Paragraph('Hello')); diff --git a/package.json b/package.json index f344126761..f08aeec4fe 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,15 @@ "description": "Generate .docx documents with JavaScript (formerly Office-Clippy)", "main": "build/index.js", "scripts": { - "pretest": "rimraf ./build-tests && tsc -p src/test-tsconfig.json", - "test": "mocha ./build-tests --recursive", + "pretest": "rimraf ./build", + "test": "mocha-webpack \"src/**/*.ts\"", "prepublishOnly": "npm run build", - "lint": "tslint --project ./src", - "build": "rimraf ./build && tsc -p src", + "lint": "tslint --project .", + "build": "npm run webpack", + "tsc": "rimraf ./build && tsc -p .", + "webpack": "rimraf ./build && webpack", "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": [ "src", @@ -53,13 +55,16 @@ "devDependencies": { "@types/chai": "^3.4.35", "@types/mocha": "^2.2.39", + "awesome-typescript-loader": "^3.4.1", "chai": "^3.5.0", "mocha": "^3.2.0", + "mocha-webpack": "^1.0.1", "prompt": "^1.0.0", "rimraf": "^2.5.2", "shelljs": "^0.7.7", "tslint": "^5.1.0", - "typedoc": "^0.5.10", - "typescript": "2.4.1" + "typedoc": "^0.9.0", + "typescript": "2.4.1", + "webpack": "^3.10.0" } } diff --git a/src/docx/index.ts b/src/docx/index.ts deleted file mode 100644 index 9e7f554a4e..0000000000 --- a/src/docx/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./document"; -export * from "./paragraph"; -export * from "./run"; -export { Table } from "./table"; diff --git a/src/export/formatter.spec.ts b/src/export/formatter.spec.ts index 5bab6ab24b..d6e29cee8e 100644 --- a/src/export/formatter.spec.ts +++ b/src/export/formatter.spec.ts @@ -1,9 +1,9 @@ import { assert } from "chai"; -import * as docx from "../docx"; -import { Attributes } from "../docx/xml-components"; 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"; describe("Formatter", () => { @@ -15,21 +15,21 @@ describe("Formatter", () => { describe("#format()", () => { it("should format simple paragraph", () => { - const paragraph = new docx.Paragraph(); + const paragraph = new file.Paragraph(); const newJson = formatter.format(paragraph); assert.isDefined(newJson["w:p"]); }); it("should remove xmlKeys", () => { - const paragraph = new docx.Paragraph(); + const paragraph = new file.Paragraph(); const newJson = formatter.format(paragraph); const stringifiedJson = JSON.stringify(newJson); assert(stringifiedJson.indexOf("xmlKeys") < 0); }); it("should format simple paragraph with bold text", () => { - const paragraph = new docx.Paragraph(); - paragraph.addRun(new docx.TextRun("test").bold()); + const paragraph = new file.Paragraph(); + paragraph.addRun(new file.TextRun("test").bold()); const newJson = formatter.format(paragraph); 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", () => { - const paragraph = new docx.Paragraph(); + const paragraph = new file.Paragraph(); const newJson = formatter.format(paragraph); assert.isDefined(newJson["w:p"]); }); diff --git a/src/export/formatter.ts b/src/export/formatter.ts index fe8d142c31..95c4e38e78 100644 --- a/src/export/formatter.ts +++ b/src/export/formatter.ts @@ -1,5 +1,5 @@ -import { BaseXmlComponent } from "../docx/xml-components"; -import { IXmlableObject } from "../docx/xml-components/xmlable-object"; +import { BaseXmlComponent } from "file/xml-components"; +import { IXmlableObject } from "file/xml-components/xmlable-object"; export class Formatter { public format(input: BaseXmlComponent): IXmlableObject { diff --git a/src/export/packer/compiler.ts b/src/export/packer/compiler.ts index b1e3f0a1d7..45be0d7a15 100644 --- a/src/export/packer/compiler.ts +++ b/src/export/packer/compiler.ts @@ -4,12 +4,7 @@ import * as fs from "fs"; import * as path from "path"; import * as xml from "xml"; -import { Document } from "../../docx"; -import { Media } from "../../media"; -import { Numbering } from "../../numbering"; -import { Properties } from "../../properties"; -import { Styles } from "../../styles"; -import { DefaultStylesFactory } from "../../styles/factory"; +import { File } from "file"; import { Formatter } from "../formatter"; const TEMPLATE_PATH = path.resolve(__dirname, "../../../template"); @@ -17,29 +12,11 @@ const TEMPLATE_PATH = path.resolve(__dirname, "../../../template"); export class Compiler { protected archive: archiver.Archiver; private formatter: Formatter; - private style: Styles; - constructor( - 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(), - ) { + constructor(private file: File) { this.formatter = new Formatter(); this.archive = archiver.create("zip", {}); - if (style) { - this.style = style; - } else { - const stylesFactory = new DefaultStylesFactory(); - this.style = stylesFactory.newInstance(); - } - this.archive.on("error", (err) => { throw err; }); @@ -55,15 +32,15 @@ export class Compiler { cwd: TEMPLATE_PATH, }); - const xmlDocument = xml(this.formatter.format(this.document)); - const xmlStyles = xml(this.formatter.format(this.style)); - const xmlProperties = xml(this.formatter.format(this.properties), { + const xmlDocument = xml(this.formatter.format(this.file.Document)); + const xmlStyles = xml(this.formatter.format(this.file.Styles)); + const xmlProperties = xml(this.formatter.format(this.file.Properties), { declaration: { standalone: "yes", encoding: "UTF-8", }, }); - const xmlNumbering = xml(this.formatter.format(this.numbering)); + const xmlNumbering = xml(this.formatter.format(this.file.Numbering)); this.archive.append(xmlDocument, { name: "word/document.xml", @@ -81,7 +58,7 @@ export class Compiler { name: "word/numbering.xml", }); - for (const data of this.media.array) { + for (const data of this.file.Media.array) { this.archive.append(data.stream, { name: `media/${data.fileName}`, }); diff --git a/src/export/packer/express.ts b/src/export/packer/express.ts index f5f2789f1d..4c6a573d4f 100644 --- a/src/export/packer/express.ts +++ b/src/export/packer/express.ts @@ -1,10 +1,6 @@ import * as express from "express"; -import { Document } from "../../docx/document"; -import { Media } from "../../media"; -import { Numbering } from "../../numbering"; -import { Properties } from "../../properties"; -import { Styles } from "../../styles"; +import { File } from "file"; import { Compiler } from "./compiler"; import { IPacker } from "./packer"; @@ -12,8 +8,8 @@ export class ExpressPacker implements IPacker { private res: express.Response; private packer: Compiler; - constructor(document: Document, res: express.Response, styles?: Styles, properties?: Properties, numbering?: Numbering, media?: Media) { - this.packer = new Compiler(document, styles, properties, numbering, media); + constructor(file: File, res: express.Response) { + this.packer = new Compiler(file); this.res = res; diff --git a/src/export/packer/local.spec.ts b/src/export/packer/local.spec.ts index 79caf6dd9c..39a721195d 100644 --- a/src/export/packer/local.spec.ts +++ b/src/export/packer/local.spec.ts @@ -1,38 +1,33 @@ /* tslint:disable:typedef space-before-function-paren */ import * as fs from "fs"; -import { Document } from "../../docx/document"; -import { Paragraph } from "../../docx/paragraph"; import { LocalPacker } from "../../export/packer/local"; -import { Properties } from "../../properties"; -import { DefaultStylesFactory } from "../../styles/factory"; +import { File, Paragraph } from "../../file"; describe("LocalPacker", () => { let packer: LocalPacker; - let stylesFactory: DefaultStylesFactory; beforeEach(() => { - const document = new Document(); - 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({ + const file = new File({ creator: "Dolan Miu", revision: "1", lastModifiedBy: "Dolan Miu", }); - stylesFactory = new DefaultStylesFactory(); - packer = new LocalPacker(document, stylesFactory.newInstance(), properties); + const paragraph = new Paragraph("test text"); + 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()", () => { it("should create a standard docx file", async function () { this.timeout(99999999); - await packer.pack("build-tests/tests/test"); - fs.statSync("build-tests/tests/test.docx"); + await packer.pack("build/tests/test"); + fs.statSync("build/tests/test.docx"); }); }); @@ -40,8 +35,8 @@ describe("LocalPacker", () => { it("should create a standard PDF file", async function () { this.timeout(99999999); - await packer.packPdf("build-tests/tests/pdf-test"); - fs.statSync("build-tests/tests/pdf-test.pdf"); + await packer.packPdf("build/tests/pdf-test"); + fs.statSync("build/tests/pdf-test.pdf"); }); }); }); diff --git a/src/export/packer/local.ts b/src/export/packer/local.ts index 1fefb6cb20..f59526bbc4 100644 --- a/src/export/packer/local.ts +++ b/src/export/packer/local.ts @@ -2,11 +2,7 @@ import * as fs from "fs"; import * as os from "os"; import * as path from "path"; -import { Document } from "../../docx/document"; -import { Media } from "../../media"; -import { Numbering } from "../../numbering"; -import { Properties } from "../../properties"; -import { Styles } from "../../styles"; +import { File } from "../../file"; import { Compiler } from "./compiler"; import { IPacker } from "./packer"; import { PdfConvertWrapper } from "./pdf-convert-wrapper"; @@ -16,9 +12,9 @@ export class LocalPacker implements IPacker { private pdfConverter: PdfConvertWrapper; private packer: Compiler; - constructor(document: Document, styles?: Styles, properties?: Properties, numbering?: Numbering, media?: Media) { + constructor(file: File) { this.pdfConverter = new PdfConvertWrapper(); - this.packer = new Compiler(document, styles, properties, numbering, media); + this.packer = new Compiler(file); } public async pack(filePath: string): Promise { diff --git a/src/docx/document/body/body.spec.ts b/src/file/document/body/body.spec.ts similarity index 100% rename from src/docx/document/body/body.spec.ts rename to src/file/document/body/body.spec.ts diff --git a/src/docx/document/body/body.ts b/src/file/document/body/body.ts similarity index 77% rename from src/docx/document/body/body.ts rename to src/file/document/body/body.ts index 993d353573..24cb1bf8bc 100644 --- a/src/docx/document/body/body.ts +++ b/src/file/document/body/body.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../xml-components"; +import { XmlComponent } from "file/xml-components"; export class Body extends XmlComponent { diff --git a/src/docx/document/body/columns.ts b/src/file/document/body/columns.ts similarity index 73% rename from src/docx/document/body/columns.ts rename to src/file/document/body/columns.ts index 3a1b3a1f60..0f66904faa 100644 --- a/src/docx/document/body/columns.ts +++ b/src/file/document/body/columns.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class Columns extends XmlComponent { diff --git a/src/docx/document/body/doc-grid.ts b/src/file/document/body/doc-grid.ts similarity index 74% rename from src/docx/document/body/doc-grid.ts rename to src/file/document/body/doc-grid.ts index ec10ef4830..5b2f280014 100644 --- a/src/docx/document/body/doc-grid.ts +++ b/src/file/document/body/doc-grid.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class DocumentGrid extends XmlComponent { diff --git a/src/docx/document/body/index.ts b/src/file/document/body/index.ts similarity index 100% rename from src/docx/document/body/index.ts rename to src/file/document/body/index.ts diff --git a/src/docx/document/body/page-margin.ts b/src/file/document/body/page-margin.ts similarity index 83% rename from src/docx/document/body/page-margin.ts rename to src/file/document/body/page-margin.ts index 6c98ecf8c2..b02c788c5f 100644 --- a/src/docx/document/body/page-margin.ts +++ b/src/file/document/body/page-margin.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class PageMargin extends XmlComponent { diff --git a/src/docx/document/body/page-size.ts b/src/file/document/body/page-size.ts similarity index 75% rename from src/docx/document/body/page-size.ts rename to src/file/document/body/page-size.ts index 8259326347..cda39d728e 100644 --- a/src/docx/document/body/page-size.ts +++ b/src/file/document/body/page-size.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class PageSize extends XmlComponent { diff --git a/src/docx/document/body/section-properties.ts b/src/file/document/body/section-properties.ts similarity index 90% rename from src/docx/document/body/section-properties.ts rename to src/file/document/body/section-properties.ts index c2d556de33..c112674f44 100644 --- a/src/docx/document/body/section-properties.ts +++ b/src/file/document/body/section-properties.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; import { Columns } from "./columns"; import { DocumentGrid } from "./doc-grid"; import { PageMargin } from "./page-margin"; diff --git a/src/docx/document/document-attributes.ts b/src/file/document/document-attributes.ts similarity index 95% rename from src/docx/document/document-attributes.ts rename to src/file/document/document-attributes.ts index 88031719e9..68df58ca61 100644 --- a/src/docx/document/document-attributes.ts +++ b/src/file/document/document-attributes.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent } from "../xml-components"; +import { XmlAttributeComponent } from "file/xml-components"; export interface IDocumentAttributesProperties { wpc?: string; diff --git a/src/docx/document/document.spec.ts b/src/file/document/document.spec.ts similarity index 100% rename from src/docx/document/document.spec.ts rename to src/file/document/document.spec.ts diff --git a/src/docx/document/document.ts b/src/file/document/document.ts similarity index 97% rename from src/docx/document/document.ts rename to src/file/document/document.ts index fa13145b94..23b73a97fd 100644 --- a/src/docx/document/document.ts +++ b/src/file/document/document.ts @@ -1,7 +1,7 @@ // http://officeopenxml.com/WPdocument.php +import { XmlComponent } from "file/xml-components"; import { Paragraph } from "../paragraph"; import { Table } from "../table"; -import { XmlComponent } from "../xml-components"; import { Body } from "./body"; import { DocumentAttributes } from "./document-attributes"; @@ -52,5 +52,4 @@ export class Document extends XmlComponent { this.addTable(table); return table; } - } diff --git a/src/docx/document/index.ts b/src/file/document/index.ts similarity index 100% rename from src/docx/document/index.ts rename to src/file/document/index.ts diff --git a/src/docx/run/run-components/drawing/drawing.spec.ts b/src/file/drawing/drawing.spec.ts similarity index 93% rename from src/docx/run/run-components/drawing/drawing.spec.ts rename to src/file/drawing/drawing.spec.ts index aa55535059..8bda6243e7 100644 --- a/src/docx/run/run-components/drawing/drawing.spec.ts +++ b/src/file/drawing/drawing.spec.ts @@ -1,7 +1,7 @@ import { assert } from "chai"; import * as fs from "fs"; -import { Utility } from "../../../../tests/utility"; +import { Utility } from "../../tests/utility"; import { Drawing } from "./"; describe("Drawing", () => { diff --git a/src/docx/run/run-components/drawing/index.ts b/src/file/drawing/index.ts similarity index 75% rename from src/docx/run/run-components/drawing/index.ts rename to src/file/drawing/index.ts index fab434e058..fe79f86673 100644 --- a/src/docx/run/run-components/drawing/index.ts +++ b/src/file/drawing/index.ts @@ -1,5 +1,5 @@ -import { IData } from "../../../../media/data"; -import { XmlComponent } from "../../../xml-components"; +import { IData } from "file/media"; +import { XmlComponent } from "file/xml-components"; import { Inline } from "./inline"; export class Drawing extends XmlComponent { diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts b/src/file/drawing/inline/graphic/graphic-data/index.ts similarity index 75% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts rename to src/file/drawing/inline/graphic/graphic-data/index.ts index c717a1098c..0f462b62ae 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/index.ts +++ b/src/file/drawing/inline/graphic/graphic-data/index.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; import { Pic } from "./pic"; export class GraphicData extends XmlComponent { diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts similarity index 84% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts rename to src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts index ac2ca1d580..69b6bf40a4 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-fill.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; import { Blip } from "./blip"; import { SourceRectangle } from "./source-rectangle"; import { Stretch } from "./stretch"; diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts similarity index 80% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts rename to src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts index 2926c52893..c4aca1f156 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/blip.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../../../../../../../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; interface IBlipProperties { embed: string; diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts similarity index 60% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts rename to src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts index 32df3eaaac..c944ebbc77 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/source-rectangle.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; export class SourceRectangle extends XmlComponent { diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts similarity index 77% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts rename to src/file/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts index c42fa04ff3..2de9775885 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/stretch.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; class FillRectangle extends XmlComponent { diff --git a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts b/src/file/drawing/inline/graphic/graphic-data/pic/index.ts similarity index 75% rename from src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts rename to src/file/drawing/inline/graphic/graphic-data/pic/index.ts index 54628facf8..b7907e20dc 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/graphic-data/pic/index.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/index.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; import { BlipFill } from "./blip/blip-fill"; export class Pic extends XmlComponent { diff --git a/src/docx/run/run-components/drawing/inline/graphic/index.ts b/src/file/drawing/inline/graphic/index.ts similarity index 86% rename from src/docx/run/run-components/drawing/inline/graphic/index.ts rename to src/file/drawing/inline/graphic/index.ts index 0ee4f17a88..81251fd41c 100644 --- a/src/docx/run/run-components/drawing/inline/graphic/index.ts +++ b/src/file/drawing/inline/graphic/index.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../../../../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { GraphicData } from "./graphic-data"; interface IGraphicProperties { diff --git a/src/docx/run/run-components/drawing/inline/index.ts b/src/file/drawing/inline/index.ts similarity index 77% rename from src/docx/run/run-components/drawing/inline/index.ts rename to src/file/drawing/inline/index.ts index 8f752edfcc..3e7ab22831 100644 --- a/src/docx/run/run-components/drawing/inline/index.ts +++ b/src/file/drawing/inline/index.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../../../xml-components"; +import { XmlComponent } from "file/xml-components"; import { Graphic } from "./graphic"; export class Inline extends XmlComponent { diff --git a/src/file/file.ts b/src/file/file.ts new file mode 100644 index 0000000000..59e913743f --- /dev/null +++ b/src/file/file.ts @@ -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; + } +} diff --git a/src/file/index.ts b/src/file/index.ts new file mode 100644 index 0000000000..544723257e --- /dev/null +++ b/src/file/index.ts @@ -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"; diff --git a/src/media/data.ts b/src/file/media/data.ts similarity index 100% rename from src/media/data.ts rename to src/file/media/data.ts diff --git a/src/file/media/index.ts b/src/file/media/index.ts new file mode 100644 index 0000000000..3575274e26 --- /dev/null +++ b/src/file/media/index.ts @@ -0,0 +1,2 @@ +export * from "./media"; +export * from "./data"; diff --git a/src/media/index.ts b/src/file/media/media.ts similarity index 100% rename from src/media/index.ts rename to src/file/media/media.ts diff --git a/src/numbering/abstract-numbering.ts b/src/file/numbering/abstract-numbering.ts similarity index 93% rename from src/numbering/abstract-numbering.ts rename to src/file/numbering/abstract-numbering.ts index 3491ec6426..eb64487cdc 100644 --- a/src/numbering/abstract-numbering.ts +++ b/src/file/numbering/abstract-numbering.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../docx/xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { Level } from "./level"; import { MultiLevelType } from "./multi-level-type"; diff --git a/src/numbering/index.ts b/src/file/numbering/index.ts similarity index 100% rename from src/numbering/index.ts rename to src/file/numbering/index.ts diff --git a/src/numbering/level.ts b/src/file/numbering/level.ts similarity index 95% rename from src/numbering/level.ts rename to src/file/numbering/level.ts index 15f3abaa8a..801746ca88 100644 --- a/src/numbering/level.ts +++ b/src/file/numbering/level.ts @@ -1,8 +1,8 @@ -import * as paragraph from "../docx/paragraph/formatting"; -import { ParagraphProperties } from "../docx/paragraph/properties"; -import * as formatting from "../docx/run/formatting"; -import { RunProperties } from "../docx/run/properties"; -import { Attributes, XmlAttributeComponent, XmlComponent } from "../docx/xml-components"; +import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components"; +import * as paragraph from "../paragraph/formatting"; +import { ParagraphProperties } from "../paragraph/properties"; +import * as formatting from "../paragraph/run/formatting"; +import { RunProperties } from "../paragraph/run/properties"; interface ILevelAttributesProperties { ilvl?: number; diff --git a/src/numbering/multi-level-type.ts b/src/file/numbering/multi-level-type.ts similarity index 75% rename from src/numbering/multi-level-type.ts rename to src/file/numbering/multi-level-type.ts index 9822b18c1a..4b688e35fb 100644 --- a/src/numbering/multi-level-type.ts +++ b/src/file/numbering/multi-level-type.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../docx/xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class MultiLevelType extends XmlComponent { diff --git a/src/numbering/num.ts b/src/file/numbering/num.ts similarity index 98% rename from src/numbering/num.ts rename to src/file/numbering/num.ts index 5e73441f8d..e9362a3c9e 100644 --- a/src/numbering/num.ts +++ b/src/file/numbering/num.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlAttributeComponent, XmlComponent } from "../docx/xml-components"; +import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components"; import { LevelForOverride } from "./level"; class AbstractNumId extends XmlComponent { diff --git a/src/numbering/numbering.spec.ts b/src/file/numbering/numbering.spec.ts similarity index 99% rename from src/numbering/numbering.spec.ts rename to src/file/numbering/numbering.spec.ts index 58483841af..a61d352c33 100644 --- a/src/numbering/numbering.spec.ts +++ b/src/file/numbering/numbering.spec.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { Formatter } from "../export/formatter"; +import { Formatter } from "../../export/formatter"; import { Numbering } from "./"; import { AbstractNumbering } from "./abstract-numbering"; import { LevelForOverride } from "./level"; diff --git a/src/numbering/numbering.ts b/src/file/numbering/numbering.ts similarity index 94% rename from src/numbering/numbering.ts rename to src/file/numbering/numbering.ts index b8a601e96c..59caa49951 100644 --- a/src/numbering/numbering.ts +++ b/src/file/numbering/numbering.ts @@ -1,7 +1,7 @@ -import { DocumentAttributes } from "../docx/document/document-attributes"; -import { Indent } from "../docx/paragraph/formatting"; -import { RunFonts } from "../docx/run/run-fonts"; -import { XmlComponent } from "../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { DocumentAttributes } from "../document/document-attributes"; +import { Indent } from "../paragraph/formatting"; +import { RunFonts } from "../paragraph/run/run-fonts"; import { AbstractNumbering } from "./abstract-numbering"; import { Num } from "./num"; diff --git a/src/docx/paragraph/formatting/alignment.ts b/src/file/paragraph/formatting/alignment.ts similarity index 84% rename from src/docx/paragraph/formatting/alignment.ts rename to src/file/paragraph/formatting/alignment.ts index 5923f0d623..a260aa18ff 100644 --- a/src/docx/paragraph/formatting/alignment.ts +++ b/src/file/paragraph/formatting/alignment.ts @@ -1,5 +1,5 @@ // 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"; diff --git a/src/docx/paragraph/formatting/border.spec.ts b/src/file/paragraph/formatting/border.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/border.spec.ts rename to src/file/paragraph/formatting/border.spec.ts diff --git a/src/docx/paragraph/formatting/border.ts b/src/file/paragraph/formatting/border.ts similarity index 86% rename from src/docx/paragraph/formatting/border.ts rename to src/file/paragraph/formatting/border.ts index 11eb7c45aa..b8c5142fde 100644 --- a/src/docx/paragraph/formatting/border.ts +++ b/src/file/paragraph/formatting/border.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPborders.php -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; class Border extends XmlComponent { diff --git a/src/docx/paragraph/formatting/indent.ts b/src/file/paragraph/formatting/indent.ts similarity index 88% rename from src/docx/paragraph/formatting/indent.ts rename to src/file/paragraph/formatting/indent.ts index 67ca37b905..98ab4e0212 100644 --- a/src/docx/paragraph/formatting/indent.ts +++ b/src/file/paragraph/formatting/indent.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPindentation.php -import { XmlAttributeComponent, XmlComponent } from "../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; interface IIndentAttributesProperties { left?: number; diff --git a/src/docx/paragraph/formatting/index.ts b/src/file/paragraph/formatting/index.ts similarity index 100% rename from src/docx/paragraph/formatting/index.ts rename to src/file/paragraph/formatting/index.ts diff --git a/src/docx/paragraph/formatting/keep.ts b/src/file/paragraph/formatting/keep.ts similarity index 79% rename from src/docx/paragraph/formatting/keep.ts rename to src/file/paragraph/formatting/keep.ts index 1e3e27c422..5f1abb53f8 100644 --- a/src/docx/paragraph/formatting/keep.ts +++ b/src/file/paragraph/formatting/keep.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../xml-components"; +import { XmlComponent } from "file/xml-components"; export class KeepLines extends XmlComponent { constructor() { diff --git a/src/docx/paragraph/formatting/page-break.spec.ts b/src/file/paragraph/formatting/page-break.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/page-break.spec.ts rename to src/file/paragraph/formatting/page-break.spec.ts diff --git a/src/docx/paragraph/formatting/page-break.ts b/src/file/paragraph/formatting/page-break.ts similarity index 77% rename from src/docx/paragraph/formatting/page-break.ts rename to src/file/paragraph/formatting/page-break.ts index 055b0a106c..c35d5f10af 100644 --- a/src/docx/paragraph/formatting/page-break.ts +++ b/src/file/paragraph/formatting/page-break.ts @@ -1,6 +1,6 @@ // http://officeopenxml.com/WPtextSpecialContent-break.php -import { Run } from "../../run"; -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; +import { Run } from "../run"; class Break extends XmlComponent { diff --git a/src/docx/paragraph/formatting/spacing.spec.ts b/src/file/paragraph/formatting/spacing.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/spacing.spec.ts rename to src/file/paragraph/formatting/spacing.spec.ts diff --git a/src/docx/paragraph/formatting/spacing.ts b/src/file/paragraph/formatting/spacing.ts similarity index 87% rename from src/docx/paragraph/formatting/spacing.ts rename to src/file/paragraph/formatting/spacing.ts index 23df8523ac..fceab8af8c 100644 --- a/src/docx/paragraph/formatting/spacing.ts +++ b/src/file/paragraph/formatting/spacing.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPspacing.php -import { XmlAttributeComponent, XmlComponent } from "../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; export interface ISpacingProperties { after?: number; diff --git a/src/docx/paragraph/formatting/style.spec.ts b/src/file/paragraph/formatting/style.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/style.spec.ts rename to src/file/paragraph/formatting/style.spec.ts diff --git a/src/docx/paragraph/formatting/style.ts b/src/file/paragraph/formatting/style.ts similarity index 74% rename from src/docx/paragraph/formatting/style.ts rename to src/file/paragraph/formatting/style.ts index 4f73e0f2b5..08d6500c34 100644 --- a/src/docx/paragraph/formatting/style.ts +++ b/src/file/paragraph/formatting/style.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class Style extends XmlComponent { diff --git a/src/docx/paragraph/formatting/tab-stop.spec.ts b/src/file/paragraph/formatting/tab-stop.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/tab-stop.spec.ts rename to src/file/paragraph/formatting/tab-stop.spec.ts diff --git a/src/docx/paragraph/formatting/tab-stop.ts b/src/file/paragraph/formatting/tab-stop.ts similarity index 94% rename from src/docx/paragraph/formatting/tab-stop.ts rename to src/file/paragraph/formatting/tab-stop.ts index 4042b7d47d..cd65ae76f5 100644 --- a/src/docx/paragraph/formatting/tab-stop.ts +++ b/src/file/paragraph/formatting/tab-stop.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPtab.php -import { XmlAttributeComponent, XmlComponent } from "../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; export class TabStop extends XmlComponent { diff --git a/src/docx/paragraph/formatting/unordered-list.spec.ts b/src/file/paragraph/formatting/unordered-list.spec.ts similarity index 100% rename from src/docx/paragraph/formatting/unordered-list.spec.ts rename to src/file/paragraph/formatting/unordered-list.spec.ts diff --git a/src/docx/paragraph/formatting/unordered-list.ts b/src/file/paragraph/formatting/unordered-list.ts similarity index 90% rename from src/docx/paragraph/formatting/unordered-list.ts rename to src/file/paragraph/formatting/unordered-list.ts index 50af69c20d..82a432603a 100644 --- a/src/docx/paragraph/formatting/unordered-list.ts +++ b/src/file/paragraph/formatting/unordered-list.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export class NumberProperties extends XmlComponent { diff --git a/src/docx/paragraph/index.ts b/src/file/paragraph/index.ts similarity index 79% rename from src/docx/paragraph/index.ts rename to src/file/paragraph/index.ts index 653e1a8e97..08d4e487cf 100644 --- a/src/docx/paragraph/index.ts +++ b/src/file/paragraph/index.ts @@ -1,3 +1,4 @@ export * from "./formatting"; export * from "./paragraph"; export * from "./properties"; +export * from "./run"; diff --git a/src/docx/paragraph/paragraph.spec.ts b/src/file/paragraph/paragraph.spec.ts similarity index 97% rename from src/docx/paragraph/paragraph.spec.ts rename to src/file/paragraph/paragraph.spec.ts index bc239fc298..7d9720ce1d 100644 --- a/src/docx/paragraph/paragraph.spec.ts +++ b/src/file/paragraph/paragraph.spec.ts @@ -1,14 +1,14 @@ import { assert, expect } from "chai"; -import * as docx from "../../docx"; import { Formatter } from "../../export/formatter"; -import { Numbering } from "../../numbering"; +import * as file from "../../file"; +import { Numbering } from "../numbering"; describe("Paragraph", () => { - let paragraph: docx.Paragraph; + let paragraph: file.Paragraph; beforeEach(() => { - paragraph = new docx.Paragraph(); + paragraph = new file.Paragraph(); }); describe("#constructor()", () => { @@ -35,7 +35,7 @@ describe("Paragraph", () => { describe("#createTextRun", () => { it("should add a new run to the paragraph and return it", () => { 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"]; expect(tree).to.be.an("array").which.includes({ "w:r": [ diff --git a/src/docx/paragraph/paragraph.ts b/src/file/paragraph/paragraph.ts similarity index 94% rename from src/docx/paragraph/paragraph.ts rename to src/file/paragraph/paragraph.ts index fcba366b8f..766b7d7d14 100644 --- a/src/docx/paragraph/paragraph.ts +++ b/src/file/paragraph/paragraph.ts @@ -1,10 +1,8 @@ // http://officeopenxml.com/WPparagraph.php -import { IData } from "../../media/data"; -import { Num } from "../../numbering/num"; -import { Run } from "../run"; -import { PictureRun } from "../run/picture-run"; -import { TextRun } from "../run/text-run"; -import { XmlComponent } from "../xml-components"; +import { IData } from "file/media"; +import { Num } from "file/numbering/num"; +import { XmlComponent } from "file/xml-components"; +import { PictureRun, Run, TextRun } from "./run"; import { Alignment } from "./formatting/alignment"; import { ThematicBreak } from "./formatting/border"; diff --git a/src/docx/paragraph/properties.ts b/src/file/paragraph/properties.ts similarity index 82% rename from src/docx/paragraph/properties.ts rename to src/file/paragraph/properties.ts index 16013986c0..7b54f23350 100644 --- a/src/docx/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPparagraphProperties.php -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class ParagraphProperties extends XmlComponent { diff --git a/src/docx/run/break.spec.ts b/src/file/paragraph/run/break.spec.ts similarity index 89% rename from src/docx/run/break.spec.ts rename to src/file/paragraph/run/break.spec.ts index f34f60bfbc..2a317dd8b2 100644 --- a/src/docx/run/break.spec.ts +++ b/src/file/paragraph/run/break.spec.ts @@ -1,6 +1,6 @@ import { assert } from "chai"; -import { Utility } from "../../tests/utility"; +import { Utility } from "../../../tests/utility"; import { Break } from "./break"; describe("Break", () => { diff --git a/src/docx/run/break.ts b/src/file/paragraph/run/break.ts similarity index 74% rename from src/docx/run/break.ts rename to src/file/paragraph/run/break.ts index 75254a09c6..a40abea558 100644 --- a/src/docx/run/break.ts +++ b/src/file/paragraph/run/break.ts @@ -1,5 +1,5 @@ // http://officeopenxml.com/WPtextSpecialContent-break.php -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class Break extends XmlComponent { diff --git a/src/docx/run/caps.ts b/src/file/paragraph/run/caps.ts similarity index 79% rename from src/docx/run/caps.ts rename to src/file/paragraph/run/caps.ts index d1e0f8f2cb..bc12d6e256 100644 --- a/src/docx/run/caps.ts +++ b/src/file/paragraph/run/caps.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class SmallCaps extends XmlComponent { diff --git a/src/docx/run/formatting.ts b/src/file/paragraph/run/formatting.ts similarity index 97% rename from src/docx/run/formatting.ts rename to src/file/paragraph/run/formatting.ts index 2685f07fda..f6abf1a770 100644 --- a/src/docx/run/formatting.ts +++ b/src/file/paragraph/run/formatting.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export { Underline } from "./underline"; export { SubScript, SuperScript } from "./script"; export { RunFonts } from "./run-fonts"; diff --git a/src/docx/run/index.ts b/src/file/paragraph/run/index.ts similarity index 100% rename from src/docx/run/index.ts rename to src/file/paragraph/run/index.ts diff --git a/src/docx/run/picture-run.ts b/src/file/paragraph/run/picture-run.ts similarity index 86% rename from src/docx/run/picture-run.ts rename to src/file/paragraph/run/picture-run.ts index 038d1fc7bf..f5d7f4e763 100644 --- a/src/docx/run/picture-run.ts +++ b/src/file/paragraph/run/picture-run.ts @@ -1,6 +1,6 @@ +import { Drawing } from "../../drawing"; import { IData } from "../../media/data"; import { Run } from "../run"; -import { Drawing } from "./run-components/drawing"; export class PictureRun extends Run { diff --git a/src/docx/run/properties.ts b/src/file/paragraph/run/properties.ts similarity index 78% rename from src/docx/run/properties.ts rename to src/file/paragraph/run/properties.ts index 7c781fe04c..191aaf715c 100644 --- a/src/docx/run/properties.ts +++ b/src/file/paragraph/run/properties.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class RunProperties extends XmlComponent { diff --git a/src/docx/run/run-components/text.spec.ts b/src/file/paragraph/run/run-components/text.spec.ts similarity index 92% rename from src/docx/run/run-components/text.spec.ts rename to src/file/paragraph/run/run-components/text.spec.ts index 046951ff93..56c6643adc 100644 --- a/src/docx/run/run-components/text.spec.ts +++ b/src/file/paragraph/run/run-components/text.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { Formatter } from "../../../export/formatter"; +import { Formatter } from "../../../../export/formatter"; import { Text } from "./text"; describe("Text", () => { diff --git a/src/docx/run/run-components/text.ts b/src/file/paragraph/run/run-components/text.ts similarity index 82% rename from src/docx/run/run-components/text.ts rename to src/file/paragraph/run/run-components/text.ts index a07cf8f618..36bd17c507 100644 --- a/src/docx/run/run-components/text.ts +++ b/src/file/paragraph/run/run-components/text.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; class TextAttributes extends XmlAttributeComponent<{space: "default" | "preserve"}> { protected xmlKeys = {space: "xml:space"}; diff --git a/src/docx/run/run-fonts.spec.ts b/src/file/paragraph/run/run-fonts.spec.ts similarity index 93% rename from src/docx/run/run-fonts.spec.ts rename to src/file/paragraph/run/run-fonts.spec.ts index cf419a4e18..359635d22b 100644 --- a/src/docx/run/run-fonts.spec.ts +++ b/src/file/paragraph/run/run-fonts.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { Formatter } from "../../export/formatter"; +import { Formatter } from "../../../export/formatter"; import { RunFonts } from "./run-fonts"; describe("RunFonts", () => { diff --git a/src/docx/run/run-fonts.ts b/src/file/paragraph/run/run-fonts.ts similarity index 88% rename from src/docx/run/run-fonts.ts rename to src/file/paragraph/run/run-fonts.ts index 674f1395b9..61f8e8758e 100644 --- a/src/docx/run/run-fonts.ts +++ b/src/file/paragraph/run/run-fonts.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; interface IRunFontAttributesProperties { ascii: string; diff --git a/src/docx/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts similarity index 97% rename from src/docx/run/run.spec.ts rename to src/file/paragraph/run/run.spec.ts index 32b277592e..d4b0236304 100644 --- a/src/docx/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -1,7 +1,7 @@ import { assert, expect } from "chai"; -import { Formatter } from "../../export/formatter"; -import { Utility } from "../../tests/utility"; +import { Formatter } from "../../../export/formatter"; +import { Utility } from "../../../tests/utility"; import { Run } from "./"; describe("Run", () => { diff --git a/src/docx/run/run.ts b/src/file/paragraph/run/run.ts similarity index 97% rename from src/docx/run/run.ts rename to src/file/paragraph/run/run.ts index a0b8584a58..243cea68d3 100644 --- a/src/docx/run/run.ts +++ b/src/file/paragraph/run/run.ts @@ -9,7 +9,7 @@ import { Style } from "./style"; import { Tab } from "./tab"; import { Underline } from "./underline"; -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class Run extends XmlComponent { private properties: RunProperties; diff --git a/src/docx/run/script.spec.ts b/src/file/paragraph/run/script.spec.ts similarity index 96% rename from src/docx/run/script.spec.ts rename to src/file/paragraph/run/script.spec.ts index 5f8cdb3aeb..df3d6fa01a 100644 --- a/src/docx/run/script.spec.ts +++ b/src/file/paragraph/run/script.spec.ts @@ -1,6 +1,6 @@ import { assert } from "chai"; -import { Utility } from "../../tests/utility"; +import { Utility } from "../../../tests/utility"; import { SubScript, SuperScript } from "./script"; describe("SubScript", () => { diff --git a/src/docx/run/script.ts b/src/file/paragraph/run/script.ts similarity index 86% rename from src/docx/run/script.ts rename to src/file/paragraph/run/script.ts index a39841709a..88f0dbddda 100644 --- a/src/docx/run/script.ts +++ b/src/file/paragraph/run/script.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export abstract class VerticalAlign extends XmlComponent { diff --git a/src/docx/run/strike.spec.ts b/src/file/paragraph/run/strike.spec.ts similarity index 94% rename from src/docx/run/strike.spec.ts rename to src/file/paragraph/run/strike.spec.ts index 4b07b308b9..4e266da540 100644 --- a/src/docx/run/strike.spec.ts +++ b/src/file/paragraph/run/strike.spec.ts @@ -1,6 +1,6 @@ import { assert } from "chai"; -import { Utility } from "../../tests/utility"; +import { Utility } from "../../../tests/utility"; import { DoubleStrike, Strike } from "./formatting"; describe("Strike", () => { diff --git a/src/docx/run/style.ts b/src/file/paragraph/run/style.ts similarity index 79% rename from src/docx/run/style.ts rename to src/file/paragraph/run/style.ts index 713752377e..5382724eb7 100644 --- a/src/docx/run/style.ts +++ b/src/file/paragraph/run/style.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; class StyleAttributes extends XmlAttributeComponent<{val: string}> { protected xmlKeys = {val: "w:val"}; diff --git a/src/docx/run/tab.spec.ts b/src/file/paragraph/run/tab.spec.ts similarity index 88% rename from src/docx/run/tab.spec.ts rename to src/file/paragraph/run/tab.spec.ts index b709eb88be..4ae84e5f2b 100644 --- a/src/docx/run/tab.spec.ts +++ b/src/file/paragraph/run/tab.spec.ts @@ -1,6 +1,6 @@ import { assert } from "chai"; -import { Utility } from "../../tests/utility"; +import { Utility } from "../../../tests/utility"; import { Tab } from "./tab"; describe("Tab", () => { diff --git a/src/docx/run/tab.ts b/src/file/paragraph/run/tab.ts similarity index 64% rename from src/docx/run/tab.ts rename to src/file/paragraph/run/tab.ts index 3e346b6062..c6c4a2f0d7 100644 --- a/src/docx/run/tab.ts +++ b/src/file/paragraph/run/tab.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../xml-components"; +import { XmlComponent } from "file/xml-components"; export class Tab extends XmlComponent { diff --git a/src/docx/run/text-run.spec.ts b/src/file/paragraph/run/text-run.spec.ts similarity index 89% rename from src/docx/run/text-run.spec.ts rename to src/file/paragraph/run/text-run.spec.ts index 9f52e9a402..7fe1b7c3d4 100644 --- a/src/docx/run/text-run.spec.ts +++ b/src/file/paragraph/run/text-run.spec.ts @@ -1,6 +1,6 @@ import { expect } from "chai"; -import { Formatter } from "../../export/formatter"; +import { Formatter } from "../../../export/formatter"; import { TextRun } from "./text-run"; describe("TextRun", () => { diff --git a/src/docx/run/text-run.ts b/src/file/paragraph/run/text-run.ts similarity index 100% rename from src/docx/run/text-run.ts rename to src/file/paragraph/run/text-run.ts diff --git a/src/docx/run/underline.spec.ts b/src/file/paragraph/run/underline.spec.ts similarity index 98% rename from src/docx/run/underline.spec.ts rename to src/file/paragraph/run/underline.spec.ts index 70c70d8cad..386892a750 100644 --- a/src/docx/run/underline.spec.ts +++ b/src/file/paragraph/run/underline.spec.ts @@ -1,7 +1,7 @@ import { assert, expect } from "chai"; -import { Formatter } from "../../export/formatter"; -import { Utility } from "../../tests/utility"; +import { Formatter } from "../../../export/formatter"; +import { Utility } from "../../../tests/utility"; import * as u from "./underline"; describe("Underline", () => { diff --git a/src/docx/run/underline.ts b/src/file/paragraph/run/underline.ts similarity index 97% rename from src/docx/run/underline.ts rename to src/file/paragraph/run/underline.ts index 096f72d29f..f83b5479f9 100644 --- a/src/docx/run/underline.ts +++ b/src/file/paragraph/run/underline.ts @@ -1,4 +1,4 @@ -import { Attributes, XmlComponent } from "../xml-components"; +import { Attributes, XmlComponent } from "file/xml-components"; export abstract class BaseUnderline extends XmlComponent { diff --git a/src/properties/components.ts b/src/file/properties/components.ts similarity index 94% rename from src/properties/components.ts rename to src/file/properties/components.ts index 387524a35b..f4dbd8fd9a 100644 --- a/src/properties/components.ts +++ b/src/file/properties/components.ts @@ -1,5 +1,5 @@ -import { DocumentAttributes } from "../docx/document/document-attributes"; -import { XmlComponent } from "../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { DocumentAttributes } from "../document/document-attributes"; export class Title extends XmlComponent { diff --git a/src/file/properties/index.ts b/src/file/properties/index.ts new file mode 100644 index 0000000000..99d40e003c --- /dev/null +++ b/src/file/properties/index.ts @@ -0,0 +1 @@ +export * from "./properties"; diff --git a/src/properties/properties.spec.ts b/src/file/properties/properties.spec.ts similarity index 97% rename from src/properties/properties.spec.ts rename to src/file/properties/properties.spec.ts index f28c0ae72f..d938873b56 100644 --- a/src/properties/properties.spec.ts +++ b/src/file/properties/properties.spec.ts @@ -1,7 +1,7 @@ import { expect } from "chai"; -import { Formatter } from "../export/formatter"; -import { Properties } from "./"; +import { Formatter } from "../../export/formatter"; +import { Properties } from "./properties"; describe("Properties", () => { diff --git a/src/properties/index.ts b/src/file/properties/properties.ts similarity index 92% rename from src/properties/index.ts rename to src/file/properties/properties.ts index 943a620677..ca01056fb2 100644 --- a/src/properties/index.ts +++ b/src/file/properties/properties.ts @@ -1,5 +1,5 @@ -import { DocumentAttributes } from "../docx/document/document-attributes"; -import { XmlComponent } from "../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { DocumentAttributes } from "../document/document-attributes"; import { Created, Creator, Description, Keywords, LastModifiedBy, Modified, Revision, Subject, Title } from "./components"; export interface IPropertiesOptions { diff --git a/src/relationships/attributes.ts b/src/file/relationships/attributes.ts similarity index 79% rename from src/relationships/attributes.ts rename to src/file/relationships/attributes.ts index 14d88b7a96..54cbd62472 100644 --- a/src/relationships/attributes.ts +++ b/src/file/relationships/attributes.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent } from "../docx/xml-components"; +import { XmlAttributeComponent } from "file/xml-components"; export interface IRelationshipsAttributesProperties { xmlns: string; diff --git a/src/file/relationships/index.ts b/src/file/relationships/index.ts new file mode 100644 index 0000000000..8233ccd5d7 --- /dev/null +++ b/src/file/relationships/index.ts @@ -0,0 +1 @@ +export * from "./relationships"; diff --git a/src/relationships/index.ts b/src/file/relationships/relationships.ts similarity index 86% rename from src/relationships/index.ts rename to src/file/relationships/relationships.ts index e2c27f36e8..d9c0562a74 100644 --- a/src/relationships/index.ts +++ b/src/file/relationships/relationships.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; import { RelationshipsAttributes } from "./attributes"; export class Relationships extends XmlComponent { diff --git a/src/styles/defaults/index.ts b/src/file/styles/defaults/index.ts similarity index 91% rename from src/styles/defaults/index.ts rename to src/file/styles/defaults/index.ts index 065ed785bd..93211ac5ec 100644 --- a/src/styles/defaults/index.ts +++ b/src/file/styles/defaults/index.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; import { ParagraphPropertiesDefaults } from "./paragraph-properties"; import { RunPropertiesDefaults } from "./run-properties"; diff --git a/src/styles/defaults/paragraph-properties.ts b/src/file/styles/defaults/paragraph-properties.ts similarity index 57% rename from src/styles/defaults/paragraph-properties.ts rename to src/file/styles/defaults/paragraph-properties.ts index bac85aa796..4fe9c341ce 100644 --- a/src/styles/defaults/paragraph-properties.ts +++ b/src/file/styles/defaults/paragraph-properties.ts @@ -1,5 +1,5 @@ -import { ParagraphProperties } from "../../docx/paragraph/properties"; -import { XmlComponent } from "../../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { ParagraphProperties } from "../../paragraph/properties"; export class ParagraphPropertiesDefaults extends XmlComponent { diff --git a/src/styles/defaults/run-properties.ts b/src/file/styles/defaults/run-properties.ts similarity index 69% rename from src/styles/defaults/run-properties.ts rename to src/file/styles/defaults/run-properties.ts index 898bc34ad1..242aa3e58d 100644 --- a/src/styles/defaults/run-properties.ts +++ b/src/file/styles/defaults/run-properties.ts @@ -1,7 +1,7 @@ -import { Size } from "../../docx/run/formatting"; -import { RunProperties } from "../../docx/run/properties"; -import { RunFonts } from "../../docx/run/run-fonts"; -import { XmlComponent } from "../../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { Size } from "../../paragraph/run/formatting"; +import { RunProperties } from "../../paragraph/run/properties"; +import { RunFonts } from "../../paragraph/run/run-fonts"; export class RunPropertiesDefaults extends XmlComponent { private properties: RunProperties; diff --git a/src/styles/factory.ts b/src/file/styles/factory.ts similarity index 96% rename from src/styles/factory.ts rename to src/file/styles/factory.ts index 3d65ca8d85..aeb06bedf6 100644 --- a/src/styles/factory.ts +++ b/src/file/styles/factory.ts @@ -1,4 +1,4 @@ -import { Color, Italics, Size } from "../docx/run/formatting"; +import { Color, Italics, Size } from "../paragraph/run/formatting"; import { Styles } from "./"; // import { DocumentDefaults } from "./defaults"; diff --git a/src/styles/index.ts b/src/file/styles/index.ts similarity index 89% rename from src/styles/index.ts rename to src/file/styles/index.ts index 4487d70083..9c54752998 100644 --- a/src/styles/index.ts +++ b/src/file/styles/index.ts @@ -1,5 +1,5 @@ -import { DocumentAttributes } from "../docx/document/document-attributes"; -import { XmlComponent } from "../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; +import { DocumentAttributes } from "../document/document-attributes"; import { DocumentDefaults } from "./defaults"; import { ParagraphStyle } from "./style"; diff --git a/src/styles/latent-styles/exceptions.ts b/src/file/styles/latent-styles/exceptions.ts similarity index 90% rename from src/styles/latent-styles/exceptions.ts rename to src/file/styles/latent-styles/exceptions.ts index ceaf5477fe..9bede8257f 100644 --- a/src/styles/latent-styles/exceptions.ts +++ b/src/file/styles/latent-styles/exceptions.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; export interface ILatentStyleExceptionAttributesProperties { name?: string; diff --git a/src/styles/latent-styles/index.ts b/src/file/styles/latent-styles/index.ts similarity index 82% rename from src/styles/latent-styles/index.ts rename to src/file/styles/latent-styles/index.ts index 583ab1e0e0..5ab51e1c4e 100644 --- a/src/styles/latent-styles/index.ts +++ b/src/file/styles/latent-styles/index.ts @@ -1,4 +1,4 @@ -import { XmlComponent } from "../../docx/xml-components"; +import { XmlComponent } from "file/xml-components"; import { LatentStyleException } from "./exceptions"; export class LatentStyles extends XmlComponent { diff --git a/src/styles/sample/index.ts b/src/file/styles/sample/index.ts similarity index 100% rename from src/styles/sample/index.ts rename to src/file/styles/sample/index.ts diff --git a/src/styles/style/components.ts b/src/file/styles/style/components.ts similarity index 94% rename from src/styles/style/components.ts rename to src/file/styles/style/components.ts index 8980ee8a58..199b1f064e 100644 --- a/src/styles/style/components.ts +++ b/src/file/styles/style/components.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; interface IComponentAttributes { val: string; diff --git a/src/styles/style/index.ts b/src/file/styles/style/index.ts similarity index 96% rename from src/styles/style/index.ts rename to src/file/styles/style/index.ts index 349565e0f6..3f45c5805c 100644 --- a/src/styles/style/index.ts +++ b/src/file/styles/style/index.ts @@ -1,7 +1,7 @@ -import * as paragraph from "../../docx/paragraph"; -import * as formatting from "../../docx/run/formatting"; -import { RunProperties } from "../../docx/run/properties"; -import { XmlAttributeComponent, XmlComponent } from "../../docx/xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; +import * as paragraph from "../../paragraph"; +import * as formatting from "../../paragraph/run/formatting"; +import { RunProperties } from "../../paragraph/run/properties"; import { BasedOn, Name, Next, QuickFormat } from "./components"; diff --git a/src/styles/styles.spec.ts b/src/file/styles/styles.spec.ts similarity index 99% rename from src/styles/styles.spec.ts rename to src/file/styles/styles.spec.ts index 090b48dffe..40e87b8d9b 100644 --- a/src/styles/styles.spec.ts +++ b/src/file/styles/styles.spec.ts @@ -1,5 +1,5 @@ import { assert, expect } from "chai"; -import { Formatter } from "../export/formatter"; +import { Formatter } from "../../export/formatter"; import { Styles } from "./"; import { ParagraphStyle, Style } from "./style"; import * as components from "./style/components"; diff --git a/src/docx/table/grid.spec.ts b/src/file/table/grid.spec.ts similarity index 100% rename from src/docx/table/grid.spec.ts rename to src/file/table/grid.spec.ts diff --git a/src/docx/table/grid.ts b/src/file/table/grid.ts similarity index 87% rename from src/docx/table/grid.ts rename to src/file/table/grid.ts index 3731891177..16bab3fa75 100644 --- a/src/docx/table/grid.ts +++ b/src/file/table/grid.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; export class TableGrid extends XmlComponent { constructor(cols: number[]) { diff --git a/src/docx/table/index.ts b/src/file/table/index.ts similarity index 100% rename from src/docx/table/index.ts rename to src/file/table/index.ts diff --git a/src/docx/table/properties.spec.ts b/src/file/table/properties.spec.ts similarity index 100% rename from src/docx/table/properties.spec.ts rename to src/file/table/properties.spec.ts diff --git a/src/docx/table/properties.ts b/src/file/table/properties.ts similarity index 94% rename from src/docx/table/properties.ts rename to src/file/table/properties.ts index 09ced45d00..c11797c1fd 100644 --- a/src/docx/table/properties.ts +++ b/src/file/table/properties.ts @@ -1,4 +1,4 @@ -import { XmlAttributeComponent, XmlComponent } from "../xml-components"; +import { XmlAttributeComponent, XmlComponent } from "file/xml-components"; export type WidthTypes = "dxa" | "pct" | "nil" | "auto"; diff --git a/src/docx/table/table.spec.ts b/src/file/table/table.spec.ts similarity index 100% rename from src/docx/table/table.spec.ts rename to src/file/table/table.spec.ts diff --git a/src/docx/table/table.ts b/src/file/table/table.ts similarity index 96% rename from src/docx/table/table.ts rename to src/file/table/table.ts index 9969926fb7..43a41cd78e 100644 --- a/src/docx/table/table.ts +++ b/src/file/table/table.ts @@ -1,6 +1,6 @@ +import { XmlComponent } from "file/xml-components"; +import { IXmlableObject } from "file/xml-components/xmlable-object"; import { Paragraph } from "../paragraph"; -import { XmlComponent } from "../xml-components"; -import { IXmlableObject } from "../xml-components/xmlable-object"; import { TableGrid } from "./grid"; import { TableProperties, WidthTypes } from "./properties"; diff --git a/src/docx/xml-components/attribute.spec.ts b/src/file/xml-components/attribute.spec.ts similarity index 100% rename from src/docx/xml-components/attribute.spec.ts rename to src/file/xml-components/attribute.spec.ts diff --git a/src/docx/xml-components/attributes.ts b/src/file/xml-components/attributes.ts similarity index 100% rename from src/docx/xml-components/attributes.ts rename to src/file/xml-components/attributes.ts diff --git a/src/docx/xml-components/base.ts b/src/file/xml-components/base.ts similarity index 100% rename from src/docx/xml-components/base.ts rename to src/file/xml-components/base.ts diff --git a/src/docx/xml-components/default-attributes.ts b/src/file/xml-components/default-attributes.ts similarity index 100% rename from src/docx/xml-components/default-attributes.ts rename to src/file/xml-components/default-attributes.ts diff --git a/src/docx/xml-components/index.ts b/src/file/xml-components/index.ts similarity index 100% rename from src/docx/xml-components/index.ts rename to src/file/xml-components/index.ts diff --git a/src/docx/xml-components/xml-component.spec.ts b/src/file/xml-components/xml-component.spec.ts similarity index 100% rename from src/docx/xml-components/xml-component.spec.ts rename to src/file/xml-components/xml-component.spec.ts diff --git a/src/docx/xml-components/xml-component.ts b/src/file/xml-components/xml-component.ts similarity index 100% rename from src/docx/xml-components/xml-component.ts rename to src/file/xml-components/xml-component.ts diff --git a/src/docx/xml-components/xmlable-object.ts b/src/file/xml-components/xmlable-object.ts similarity index 100% rename from src/docx/xml-components/xmlable-object.ts rename to src/file/xml-components/xmlable-object.ts diff --git a/src/index.ts b/src/index.ts index 7c5a2fda81..0116f99460 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,2 @@ -export * from "./docx"; -export * from "./export"; -export { Numbering } from "./numbering"; -export { Styles } from "./styles"; -export { Media } from "./media"; +export * from "./file"; export * from "./export"; diff --git a/src/relationships/relationship.ts b/src/relationships/relationship.ts deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/test-tsconfig.json b/src/test-tsconfig.json deleted file mode 100644 index b8c28cb188..0000000000 --- a/src/test-tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "target": "es6", - "strictNullChecks": true, - "sourceMap": true, - "removeComments": true, - "preserveConstEnums": true, - "outDir": "../build-tests", - "sourceRoot": "./", - "rootDir": "./", - "module": "commonjs", - "noUnusedLocals": true - }, - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/src/tests/utility.ts b/src/tests/utility.ts index f89701b726..c43d0f6cc3 100644 --- a/src/tests/utility.ts +++ b/src/tests/utility.ts @@ -1,4 +1,5 @@ export class Utility { + // tslint:disable-next-line:no-any public static jsonify(obj: object): any { const stringifiedJson = JSON.stringify(obj); return JSON.parse(stringifiedJson); diff --git a/src/tsconfig.json b/tsconfig.json similarity index 59% rename from src/tsconfig.json rename to tsconfig.json index fc3e28c1a2..2d46f20143 100644 --- a/src/tsconfig.json +++ b/tsconfig.json @@ -5,14 +5,20 @@ "sourceMap": true, "removeComments": true, "preserveConstEnums": true, - "outDir": "../build", - "sourceRoot": "./", - "rootDir": "./", + "outDir": "./build", + "rootDir": "./src", "module": "commonjs", "declaration": true, - "noUnusedLocals": true + "noUnusedLocals": true, + "baseUrl": "./src", + "paths" : { + "/*": [ + "./*" + ] + } }, "exclude": [ + "node_modules", "tests", "**/*.spec.ts", "**/_*" diff --git a/src/tslint.json b/tslint.json similarity index 90% rename from src/tslint.json rename to tslint.json index 48b5fbfc6a..66e44398fc 100644 --- a/src/tslint.json +++ b/tslint.json @@ -34,6 +34,7 @@ "no-unused-variable": [ true ], - "no-implicit-dependencies": false + "no-implicit-dependencies": false, + "no-submodule-imports": false } } \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000000..a8000404c1 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,31 @@ +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + + output: { + path: path.resolve('build'), + filename: 'index.js', + libraryTarget: 'umd' + }, + + resolve: { + extensions: ['.tsx', '.ts', '.js'], + modules: [path.resolve('./src'), "node_modules"] + }, + + module: { + rules: [ + { + test: /\.ts$/, + loaders: ["awesome-typescript-loader"], + } + ], + }, + + target: 'node', + + node: { + __dirname: true + } +};