Merge branch 'master' of https://github.com/h4buli/docx into feat/h4-update

# Conflicts:
#	package.json
#	src/file/drawing/drawing.ts
#	src/file/media/media.ts
#	src/file/paragraph/run/picture-run.ts
#	src/file/styles/external-styles-factory.ts
#	src/file/xml-components/imported-xml-component.ts
This commit is contained in:
Dolan Miu
2018-06-09 23:29:59 +01:00
74 changed files with 896 additions and 82 deletions

View File

@ -1,13 +1,6 @@
import * as fastXmlParser from "fast-xml-parser";
import { Styles } from "./";
import { ImportedRootElementAttributes, ImportedXmlComponent } from "./../../file/xml-components";
const parseOptions = {
ignoreAttributes: false,
attributeNamePrefix: "",
attrNodeName: "_attr",
};
import * as fastXmlParser from "fast-xml-parser";
import { ImportedXmlComponent, ImportedRootElementAttributes, parseOptions, convertToXmlComponent } from "./../../file/xml-components";
export class ExternalStylesFactory {
/**
@ -45,20 +38,7 @@ export class ExternalStylesFactory {
});
// convert the styles one by one
xmlStyles["w:style"].map((style) => this.convertElement("w:style", style)).forEach(importedStyle.push.bind(importedStyle));
xmlStyles["w:style"].map((style) => convertToXmlComponent("w:style", style)).forEach(importedStyle.push.bind(importedStyle));
return importedStyle;
}
// tslint:disable-next-line:no-any
public convertElement(elementName: string, element: any): ImportedXmlComponent {
const xmlElement = new ImportedXmlComponent(elementName, element._attr);
if (typeof element === "object") {
Object.keys(element)
.filter((key) => key !== "_attr")
.map((item) => this.convertElement(item, element[item]))
.forEach(xmlElement.push.bind(xmlElement));
}
return xmlElement;
}
}