Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
70c4e89a65 | |||
8f632d4ecd | |||
6784dc1f3d | |||
fd63a30298 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docx",
|
"name": "docx",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"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": {
|
||||||
@ -34,7 +34,7 @@
|
|||||||
],
|
],
|
||||||
"types": "./build/index.d.ts",
|
"types": "./build/index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/archiver": "^1.3.2",
|
"@types/archiver": "^1.3.4",
|
||||||
"@types/express": "^4.0.35",
|
"@types/express": "^4.0.35",
|
||||||
"archiver": "^1.3.0",
|
"archiver": "^1.3.0",
|
||||||
"xml": "^1.0.1"
|
"xml": "^1.0.1"
|
||||||
@ -55,6 +55,6 @@
|
|||||||
"shelljs": "^0.7.7",
|
"shelljs": "^0.7.7",
|
||||||
"tslint": "^5.1.0",
|
"tslint": "^5.1.0",
|
||||||
"typedoc": "^0.5.10",
|
"typedoc": "^0.5.10",
|
||||||
"typescript": "^2.2.1"
|
"typescript": "^2.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Paragraph } from "../paragraph";
|
import { Paragraph } from "../paragraph";
|
||||||
import { XmlComponent } from "../xml-components";
|
import { XmlComponent } from "../xml-components";
|
||||||
|
import { IXmlableObject } from "../xml-components/xmlable-object";
|
||||||
import { TableGrid } from "./grid";
|
import { TableGrid } from "./grid";
|
||||||
import { TableProperties, WidthTypes } from "./properties";
|
import { TableProperties, WidthTypes } from "./properties";
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ export class TableCell extends XmlComponent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public prepForXml(): XmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
// Cells must end with a paragraph
|
// Cells must end with a paragraph
|
||||||
const retval = super.prepForXml();
|
const retval = super.prepForXml();
|
||||||
const content = retval["w:tc"];
|
const content = retval["w:tc"];
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { IXmlableObject } from "./xmlable-object";
|
||||||
|
|
||||||
export abstract class BaseXmlComponent {
|
export abstract class BaseXmlComponent {
|
||||||
protected rootKey: string;
|
protected rootKey: string;
|
||||||
|
|
||||||
@ -5,5 +7,5 @@ export abstract class BaseXmlComponent {
|
|||||||
this.rootKey = rootKey;
|
this.rootKey = rootKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract prepForXml(): XmlableObject;
|
public abstract prepForXml(): IXmlableObject;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { BaseXmlComponent } from "./base";
|
import { BaseXmlComponent } from "./base";
|
||||||
|
import { IXmlableObject } from "./xmlable-object";
|
||||||
|
|
||||||
export type AttributeMap<T> = {[P in keyof T]: string};
|
export type AttributeMap<T> = {[P in keyof T]: string};
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ export abstract class XmlAttributeComponent<T> extends BaseXmlComponent {
|
|||||||
this.root = properties;
|
this.root = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public prepForXml(): XmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
const attrs = {};
|
const attrs = {};
|
||||||
Object.keys(this.root).forEach((key) => {
|
Object.keys(this.root).forEach((key) => {
|
||||||
const value = this.root[key];
|
const value = this.root[key];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { BaseXmlComponent } from "./base";
|
import { BaseXmlComponent } from "./base";
|
||||||
|
import { IXmlableObject } from "./xmlable-object";
|
||||||
export { BaseXmlComponent };
|
export { BaseXmlComponent };
|
||||||
|
|
||||||
export abstract class XmlComponent extends BaseXmlComponent {
|
export abstract class XmlComponent extends BaseXmlComponent {
|
||||||
@ -9,7 +10,7 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
|||||||
this.root = new Array<BaseXmlComponent>();
|
this.root = new Array<BaseXmlComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public prepForXml(): XmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
const children = this.root.map((comp) => {
|
const children = this.root.map((comp) => {
|
||||||
if (comp instanceof BaseXmlComponent) {
|
if (comp instanceof BaseXmlComponent) {
|
||||||
return comp.prepForXml();
|
return comp.prepForXml();
|
||||||
|
3
ts/docx/xml-components/xmlable-object.d.ts
vendored
3
ts/docx/xml-components/xmlable-object.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
declare interface XmlableObject extends Object {
|
|
||||||
_attr?: { [key: string]: (string | number | boolean) }
|
|
||||||
}
|
|
3
ts/docx/xml-components/xmlable-object.ts
Normal file
3
ts/docx/xml-components/xmlable-object.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface IXmlableObject extends Object {
|
||||||
|
_attr?: { [key: string]: (string | number | boolean) };
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
import { BaseXmlComponent } from "../docx/xml-components";
|
import { BaseXmlComponent } from "../docx/xml-components";
|
||||||
|
import { IXmlableObject } from "../docx/xml-components/xmlable-object";
|
||||||
|
|
||||||
export class Formatter {
|
export class Formatter {
|
||||||
public format(input: BaseXmlComponent): XmlableObject {
|
public format(input: BaseXmlComponent): IXmlableObject {
|
||||||
return input.prepForXml();
|
return input.prepForXml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user