@bnsights/bbsf-utilities 1.0.34 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +10 -0
- package/package.json +20 -28
- package/src/lib/bbsf-utilities.module.ts +52 -0
- package/src/lib/shared/authentication/auth.service.ts +242 -0
- package/src/lib/shared/config/environment.ts +16 -0
- package/src/lib/shared/config/word/constants.js +133 -0
- package/src/lib/shared/config/word/docx-document.js +482 -0
- package/src/lib/shared/config/word/helpers/index.js +3 -0
- package/src/lib/shared/config/word/helpers/render-document-file.js +334 -0
- package/src/lib/shared/config/word/helpers/xml-builder.js +2165 -0
- package/src/lib/shared/config/word/html-to-docx.js +259 -0
- package/src/lib/shared/config/word/index.js +63 -0
- package/src/lib/shared/config/word/namespaces.js +40 -0
- package/src/lib/shared/config/word/schemas/content-types.js +26 -0
- package/src/lib/shared/config/word/schemas/core.js +44 -0
- package/src/lib/shared/config/word/schemas/document-rels.js +17 -0
- package/src/lib/shared/config/word/schemas/document.template.js +119 -0
- package/src/lib/shared/config/word/schemas/font-table.js +41 -0
- package/src/lib/shared/config/word/schemas/generic-rels.js +11 -0
- package/src/lib/shared/config/word/schemas/index.js +12 -0
- package/src/lib/shared/config/word/schemas/numbering.js +18 -0
- package/src/lib/shared/config/word/schemas/rels.js +12 -0
- package/src/lib/shared/config/word/schemas/settings.js +14 -0
- package/src/lib/shared/config/word/schemas/styles.js +152 -0
- package/src/lib/shared/config/word/schemas/theme.js +199 -0
- package/src/lib/shared/config/word/schemas/web-settings.js +10 -0
- package/src/lib/shared/config/word/utils/color-conversion.js +60 -0
- package/src/lib/shared/config/word/utils/list.js +55 -0
- package/src/lib/shared/config/word/utils/unit-conversion.js +53 -0
- package/src/lib/shared/config/word/utils/url.js +8 -0
- package/src/lib/shared/config/word/utils/vnode.js +3 -0
- package/src/lib/shared/config/word/word-work/assets/contentTypesXml.ts +1 -0
- package/src/lib/shared/config/word/word-work/assets/documentXmlRels.ts +1 -0
- package/src/lib/shared/config/word/word-work/assets/index.ts +3 -0
- package/src/lib/shared/config/word/word-work/assets/relsXml.ts +1 -0
- package/src/lib/shared/config/word/word-work/index.ts +8 -0
- package/src/lib/shared/config/word/word-work/internal.ts +69 -0
- package/src/lib/shared/config/word/word-work/templates/documentTemplate.ts +58 -0
- package/src/lib/shared/config/word/word-work/templates/index.ts +3 -0
- package/src/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.ts +21 -0
- package/src/lib/shared/config/word/word-work/templates/mhtPartTemplate.ts +14 -0
- package/src/lib/shared/config/word/word-work/utils.ts +27 -0
- package/src/lib/shared/models/AreaModel.ts +5 -0
- package/{lib/shared/models/ErrorModel.d.ts → src/lib/shared/models/ErrorModel.ts} +5 -2
- package/src/lib/shared/models/RequestOptionsModel.ts +13 -0
- package/src/lib/shared/models/WordDocumentModel.ts +19 -0
- package/src/lib/shared/services/AppearanceConfiguration.service.ts +30 -0
- package/src/lib/shared/services/configuration.service.ts +18 -0
- package/src/lib/shared/services/controlvalidation.service.ts +194 -0
- package/src/lib/shared/services/environment.service.ts +56 -0
- package/src/lib/shared/services/masterlayout.service.ts +89 -0
- package/src/lib/shared/services/requesthandler.service.ts +241 -0
- package/src/lib/shared/services/stylesbundle.service.ts +52 -0
- package/src/lib/shared/services/translate.service.ts +8 -0
- package/src/lib/shared/services/translationresolver.service.ts +16 -0
- package/src/lib/shared/services/utility.service.ts +94 -0
- package/src/lib/shared/services/word-document.service.ts +36 -0
- package/src/public-api.ts +27 -0
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +39 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +17 -0
- package/tslint.json +17 -0
- package/bnsights-bbsf-utilities-1.0.34.tgz +0 -0
- package/bnsights-bbsf-utilities.d.ts +0 -4
- package/bnsights-bbsf-utilities.metadata.json +0 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +0 -4865
- package/bundles/bnsights-bbsf-utilities.umd.js.map +0 -1
- package/esm2015/bnsights-bbsf-utilities.js +0 -5
- package/esm2015/lib/bbsf-utilities.module.js +0 -52
- package/esm2015/lib/shared/authentication/auth.service.js +0 -236
- package/esm2015/lib/shared/config/environment.js +0 -12
- package/esm2015/lib/shared/config/word/constants.js +0 -105
- package/esm2015/lib/shared/config/word/docx-document.js +0 -351
- package/esm2015/lib/shared/config/word/helpers/index.js +0 -4
- package/esm2015/lib/shared/config/word/helpers/render-document-file.js +0 -278
- package/esm2015/lib/shared/config/word/helpers/xml-builder.js +0 -1765
- package/esm2015/lib/shared/config/word/html-to-docx.js +0 -195
- package/esm2015/lib/shared/config/word/index.js +0 -55
- package/esm2015/lib/shared/config/word/namespaces.js +0 -37
- package/esm2015/lib/shared/config/word/schemas/content-types.js +0 -26
- package/esm2015/lib/shared/config/word/schemas/core.js +0 -29
- package/esm2015/lib/shared/config/word/schemas/document-rels.js +0 -16
- package/esm2015/lib/shared/config/word/schemas/document.template.js +0 -109
- package/esm2015/lib/shared/config/word/schemas/font-table.js +0 -40
- package/esm2015/lib/shared/config/word/schemas/generic-rels.js +0 -11
- package/esm2015/lib/shared/config/word/schemas/index.js +0 -13
- package/esm2015/lib/shared/config/word/schemas/numbering.js +0 -19
- package/esm2015/lib/shared/config/word/schemas/rels.js +0 -11
- package/esm2015/lib/shared/config/word/schemas/settings.js +0 -13
- package/esm2015/lib/shared/config/word/schemas/styles.js +0 -149
- package/esm2015/lib/shared/config/word/schemas/theme.js +0 -200
- package/esm2015/lib/shared/config/word/schemas/web-settings.js +0 -9
- package/esm2015/lib/shared/config/word/utils/color-conversion.js +0 -60
- package/esm2015/lib/shared/config/word/utils/list.js +0 -51
- package/esm2015/lib/shared/config/word/utils/unit-conversion.js +0 -30
- package/esm2015/lib/shared/config/word/utils/url.js +0 -9
- package/esm2015/lib/shared/config/word/utils/vnode.js +0 -3
- package/esm2015/lib/shared/config/word/word-work/templates/documentTemplate.js +0 -54
- package/esm2015/lib/shared/config/word/word-work/templates/index.js +0 -4
- package/esm2015/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.js +0 -22
- package/esm2015/lib/shared/config/word/word-work/templates/mhtPartTemplate.js +0 -10
- package/esm2015/lib/shared/config/word/word-work/utils.js +0 -26
- package/esm2015/lib/shared/models/AreaModel.js +0 -3
- package/esm2015/lib/shared/models/ErrorModel.js +0 -3
- package/esm2015/lib/shared/models/RequestOptionsModel.js +0 -11
- package/esm2015/lib/shared/models/WordDocumentModel.js +0 -8
- package/esm2015/lib/shared/services/AppearanceConfiguration.service.js +0 -37
- package/esm2015/lib/shared/services/configuration.service.js +0 -26
- package/esm2015/lib/shared/services/controlvalidation.service.js +0 -168
- package/esm2015/lib/shared/services/environment.service.js +0 -48
- package/esm2015/lib/shared/services/masterlayout.service.js +0 -96
- package/esm2015/lib/shared/services/requesthandler.service.js +0 -206
- package/esm2015/lib/shared/services/stylesbundle.service.js +0 -56
- package/esm2015/lib/shared/services/translate.service.js +0 -13
- package/esm2015/lib/shared/services/translationresolver.service.js +0 -20
- package/esm2015/lib/shared/services/utility.service.js +0 -96
- package/esm2015/lib/shared/services/word-document.service.js +0 -39
- package/esm2015/public-api.js +0 -20
- package/fesm2015/bnsights-bbsf-utilities.js +0 -4634
- package/fesm2015/bnsights-bbsf-utilities.js.map +0 -1
- package/lib/bbsf-utilities.module.d.ts +0 -6
- package/lib/shared/authentication/auth.service.d.ts +0 -41
- package/lib/shared/config/environment.d.ts +0 -1
- package/lib/shared/config/word/constants.d.ts +0 -124
- package/lib/shared/config/word/docx-document.d.ts +0 -73
- package/lib/shared/config/word/helpers/index.d.ts +0 -1
- package/lib/shared/config/word/helpers/render-document-file.d.ts +0 -4
- package/lib/shared/config/word/helpers/xml-builder.d.ts +0 -14
- package/lib/shared/config/word/html-to-docx.d.ts +0 -1
- package/lib/shared/config/word/index.d.ts +0 -1
- package/lib/shared/config/word/namespaces.d.ts +0 -36
- package/lib/shared/config/word/schemas/content-types.d.ts +0 -1
- package/lib/shared/config/word/schemas/core.d.ts +0 -1
- package/lib/shared/config/word/schemas/document-rels.d.ts +0 -1
- package/lib/shared/config/word/schemas/document.template.d.ts +0 -4
- package/lib/shared/config/word/schemas/font-table.d.ts +0 -1
- package/lib/shared/config/word/schemas/generic-rels.d.ts +0 -1
- package/lib/shared/config/word/schemas/index.d.ts +0 -12
- package/lib/shared/config/word/schemas/numbering.d.ts +0 -1
- package/lib/shared/config/word/schemas/rels.d.ts +0 -1
- package/lib/shared/config/word/schemas/settings.d.ts +0 -1
- package/lib/shared/config/word/schemas/styles.d.ts +0 -1
- package/lib/shared/config/word/schemas/theme.d.ts +0 -1
- package/lib/shared/config/word/schemas/web-settings.d.ts +0 -1
- package/lib/shared/config/word/utils/color-conversion.d.ts +0 -7
- package/lib/shared/config/word/utils/list.d.ts +0 -6
- package/lib/shared/config/word/utils/unit-conversion.d.ts +0 -29
- package/lib/shared/config/word/utils/url.d.ts +0 -1
- package/lib/shared/config/word/utils/vnode.d.ts +0 -1
- package/lib/shared/config/word/word-work/templates/documentTemplate.d.ts +0 -12
- package/lib/shared/config/word/word-work/templates/index.d.ts +0 -3
- package/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.d.ts +0 -1
- package/lib/shared/config/word/word-work/templates/mhtPartTemplate.d.ts +0 -1
- package/lib/shared/config/word/word-work/utils.d.ts +0 -1
- package/lib/shared/models/AreaModel.d.ts +0 -4
- package/lib/shared/models/RequestOptionsModel.d.ts +0 -11
- package/lib/shared/models/WordDocumentModel.d.ts +0 -16
- package/lib/shared/services/AppearanceConfiguration.service.d.ts +0 -11
- package/lib/shared/services/configuration.service.d.ts +0 -7
- package/lib/shared/services/controlvalidation.service.d.ts +0 -19
- package/lib/shared/services/environment.service.d.ts +0 -13
- package/lib/shared/services/masterlayout.service.d.ts +0 -24
- package/lib/shared/services/requesthandler.service.d.ts +0 -32
- package/lib/shared/services/stylesbundle.service.d.ts +0 -9
- package/lib/shared/services/translate.service.d.ts +0 -3
- package/lib/shared/services/translationresolver.service.d.ts +0 -8
- package/lib/shared/services/utility.service.d.ts +0 -21
- package/lib/shared/services/word-document.service.d.ts +0 -5
- package/public-api.d.ts +0 -16
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { create } from 'xmlbuilder2';
|
|
2
|
+
import VNode from 'virtual-dom/vnode/vnode';
|
|
3
|
+
import VText from 'virtual-dom/vnode/vtext';
|
|
4
|
+
// eslint-disable-next-line import/no-named-default
|
|
5
|
+
import { default as HTMLToVDOM } from 'html-to-vdom';
|
|
6
|
+
|
|
7
|
+
import { relsXML } from './schemas';
|
|
8
|
+
import {DocxDocument} from './docx-document';
|
|
9
|
+
import { renderDocumentFile } from './helpers';
|
|
10
|
+
import {getMHTdocument} from "./word-work/utils"
|
|
11
|
+
import {
|
|
12
|
+
pixelRegex,
|
|
13
|
+
pixelToTWIP,
|
|
14
|
+
cmRegex,
|
|
15
|
+
cmToTWIP,
|
|
16
|
+
inchRegex,
|
|
17
|
+
inchToTWIP,
|
|
18
|
+
pointRegex,
|
|
19
|
+
pointToHIP,
|
|
20
|
+
} from './utils/unit-conversion';
|
|
21
|
+
import {
|
|
22
|
+
defaultDocumentOptions,
|
|
23
|
+
defaultHTMLString,
|
|
24
|
+
relsFolderName,
|
|
25
|
+
headerFileName,
|
|
26
|
+
footerFileName,
|
|
27
|
+
themeFileName,
|
|
28
|
+
documentFileName,
|
|
29
|
+
headerType,
|
|
30
|
+
footerType,
|
|
31
|
+
internalRelationship,
|
|
32
|
+
wordFolder,
|
|
33
|
+
themeFolder,
|
|
34
|
+
themeType,
|
|
35
|
+
} from './constants';
|
|
36
|
+
import {generateDocumentTemplateHeader,generateDocumentTemplateFooter,generateDocumentTemplateFooterWithoutPaging }from './schemas/document.template';
|
|
37
|
+
const convertHTML = HTMLToVDOM({
|
|
38
|
+
VNode,
|
|
39
|
+
VText,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const mergeOptions = (options, patch) => ({ ...options, ...patch });
|
|
43
|
+
|
|
44
|
+
const fixupFontSize = (fontSize) => {
|
|
45
|
+
let normalizedFontSize;
|
|
46
|
+
if (pointRegex.test(fontSize)) {
|
|
47
|
+
const matchedParts = fontSize.match(pointRegex);
|
|
48
|
+
|
|
49
|
+
normalizedFontSize = pointToHIP(matchedParts[1]);
|
|
50
|
+
} else if (fontSize) {
|
|
51
|
+
// assuming it is already in HIP
|
|
52
|
+
normalizedFontSize = fontSize;
|
|
53
|
+
} else {
|
|
54
|
+
normalizedFontSize = null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return normalizedFontSize;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const normalizeUnits = (dimensioningObject, defaultDimensionsProperty) => {
|
|
61
|
+
let normalizedUnitResult = {};
|
|
62
|
+
if (typeof dimensioningObject === 'object' && dimensioningObject !== null) {
|
|
63
|
+
Object.keys(dimensioningObject).forEach((key) => {
|
|
64
|
+
if (pixelRegex.test(dimensioningObject[key])) {
|
|
65
|
+
const matchedParts = dimensioningObject[key].match(pixelRegex);
|
|
66
|
+
normalizedUnitResult[key] = pixelToTWIP(matchedParts[1]);
|
|
67
|
+
} else if (cmRegex.test(dimensioningObject[key])) {
|
|
68
|
+
const matchedParts = dimensioningObject[key].match(cmRegex);
|
|
69
|
+
normalizedUnitResult[key] = cmToTWIP(matchedParts[1]);
|
|
70
|
+
} else if (inchRegex.test(dimensioningObject[key])) {
|
|
71
|
+
const matchedParts = dimensioningObject[key].match(inchRegex);
|
|
72
|
+
normalizedUnitResult[key] = inchToTWIP(matchedParts[1]);
|
|
73
|
+
} else if (dimensioningObject[key]) {
|
|
74
|
+
normalizedUnitResult[key] = dimensioningObject[key];
|
|
75
|
+
} else {
|
|
76
|
+
// incase value is something like 0
|
|
77
|
+
normalizedUnitResult[key] = defaultDimensionsProperty[key];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
// eslint-disable-next-line no-param-reassign
|
|
82
|
+
normalizedUnitResult = null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return normalizedUnitResult;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const normalizeDocumentOptions = (documentOptions) => {
|
|
89
|
+
const normalizedDocumentOptions = { ...documentOptions };
|
|
90
|
+
Object.keys(documentOptions).forEach((key) => {
|
|
91
|
+
// eslint-disable-next-line default-case
|
|
92
|
+
switch (key) {
|
|
93
|
+
case 'pageSize':
|
|
94
|
+
case 'margins':
|
|
95
|
+
normalizedDocumentOptions[key] = normalizeUnits(
|
|
96
|
+
documentOptions[key],
|
|
97
|
+
defaultDocumentOptions[key]
|
|
98
|
+
);
|
|
99
|
+
break;
|
|
100
|
+
case 'fontSize':
|
|
101
|
+
case 'complexScriptFontSize':
|
|
102
|
+
normalizedDocumentOptions[key] = fixupFontSize(documentOptions[key]);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return normalizedDocumentOptions;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Ref: https://en.wikipedia.org/wiki/Office_Open_XML_file_formats
|
|
111
|
+
// http://officeopenxml.com/anatomyofOOXML.php
|
|
112
|
+
async function addFilesToContainer(
|
|
113
|
+
zip,
|
|
114
|
+
htmlString,
|
|
115
|
+
suppliedDocumentOptions,
|
|
116
|
+
headerHTMLString,
|
|
117
|
+
footerHTMLString
|
|
118
|
+
) {
|
|
119
|
+
debugger;
|
|
120
|
+
const normalizedDocumentOptions = normalizeDocumentOptions(suppliedDocumentOptions);
|
|
121
|
+
const documentOptions = mergeOptions(defaultDocumentOptions, normalizedDocumentOptions);
|
|
122
|
+
|
|
123
|
+
if (documentOptions.header && !headerHTMLString) {
|
|
124
|
+
// eslint-disable-next-line no-param-reassign
|
|
125
|
+
headerHTMLString = defaultHTMLString;
|
|
126
|
+
}
|
|
127
|
+
if (documentOptions.footer && !footerHTMLString) {
|
|
128
|
+
// eslint-disable-next-line no-param-reassign
|
|
129
|
+
footerHTMLString = defaultHTMLString;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const docxDocument = new DocxDocument({ zip, htmlString, ...documentOptions });
|
|
133
|
+
// Conversion to Word XML happens here
|
|
134
|
+
docxDocument.documentXML = await renderDocumentFile(docxDocument);
|
|
135
|
+
debugger;
|
|
136
|
+
zip
|
|
137
|
+
.folder(relsFolderName)
|
|
138
|
+
.file(
|
|
139
|
+
'.rels',
|
|
140
|
+
create({ encoding: 'UTF-8', standalone: true }, relsXML).toString({ prettyPrint: true }),
|
|
141
|
+
{ createFolders: false }
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
zip.folder('docProps').file('core.xml', docxDocument.generateCoreXML(), {
|
|
145
|
+
createFolders: false,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
if (docxDocument.header && headerHTMLString) {
|
|
149
|
+
const vTree = convertHTML(headerHTMLString);
|
|
150
|
+
|
|
151
|
+
docxDocument.relationshipFilename = headerFileName;
|
|
152
|
+
const { headerId, headerXML } = await docxDocument.generateHeaderXML(vTree);
|
|
153
|
+
docxDocument.relationshipFilename = documentFileName;
|
|
154
|
+
const fileNameWithExt = `${headerType}${headerId}.xml`;
|
|
155
|
+
|
|
156
|
+
const relationshipId = docxDocument.createDocumentRelationships(
|
|
157
|
+
docxDocument.relationshipFilename,
|
|
158
|
+
headerType,
|
|
159
|
+
fileNameWithExt,
|
|
160
|
+
internalRelationship
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateHeader.toString({ prettyPrint: true }), {
|
|
164
|
+
createFolders: false,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
docxDocument.headerObjects.push({ headerId, relationshipId, type: docxDocument.headerType });
|
|
168
|
+
}
|
|
169
|
+
if (docxDocument.footer && footerHTMLString) {
|
|
170
|
+
const vTree = convertHTML(footerHTMLString);
|
|
171
|
+
|
|
172
|
+
docxDocument.relationshipFilename = footerFileName;
|
|
173
|
+
const { footerId, footerXML } = await docxDocument.generateFooterXML(vTree);
|
|
174
|
+
docxDocument.relationshipFilename = documentFileName;
|
|
175
|
+
const fileNameWithExt = `${footerType}${footerId}.xml`;
|
|
176
|
+
|
|
177
|
+
const relationshipId = docxDocument.createDocumentRelationships(
|
|
178
|
+
docxDocument.relationshipFilename,
|
|
179
|
+
footerType,
|
|
180
|
+
fileNameWithExt,
|
|
181
|
+
internalRelationship
|
|
182
|
+
);
|
|
183
|
+
console.log(footerXML.toString({ prettyPrint: true }))
|
|
184
|
+
|
|
185
|
+
if(suppliedDocumentOptions.pageNumber)
|
|
186
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateFooter.toString({ prettyPrint: true }), {
|
|
187
|
+
createFolders: false,
|
|
188
|
+
});
|
|
189
|
+
else
|
|
190
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateFooterWithoutPaging.toString({ prettyPrint: true }), {
|
|
191
|
+
createFolders: false,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
docxDocument.footerObjects.push({ footerId, relationshipId, type: docxDocument.footerType });
|
|
195
|
+
}
|
|
196
|
+
const themeFileNameWithExt = `${themeFileName}.xml`;
|
|
197
|
+
docxDocument.createDocumentRelationships(
|
|
198
|
+
docxDocument.relationshipFilename,
|
|
199
|
+
themeType,
|
|
200
|
+
`${themeFolder}/${themeFileNameWithExt}`,
|
|
201
|
+
internalRelationship
|
|
202
|
+
);
|
|
203
|
+
zip
|
|
204
|
+
.folder(wordFolder)
|
|
205
|
+
.folder(themeFolder)
|
|
206
|
+
.file(themeFileNameWithExt, docxDocument.generateThemeXML(), {
|
|
207
|
+
createFolders: false,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
zip
|
|
211
|
+
.folder(wordFolder)
|
|
212
|
+
.file('document.xml', docxDocument.generateDocumentXML(), { createFolders: false })
|
|
213
|
+
.file('afchunk.mht', getMHTdocument(htmlString), {
|
|
214
|
+
createFolders: false,
|
|
215
|
+
})
|
|
216
|
+
.file('afchunkheader.mht', getMHTdocument(headerHTMLString), {
|
|
217
|
+
createFolders: false,
|
|
218
|
+
})
|
|
219
|
+
.file('afchunkfooter.mht', getMHTdocument(footerHTMLString), {
|
|
220
|
+
createFolders: false,
|
|
221
|
+
})
|
|
222
|
+
.file('fontTable.xml', docxDocument.generateFontTableXML(), { createFolders: false })
|
|
223
|
+
.file('styles.xml', docxDocument.generateStylesXML(), { createFolders: false })
|
|
224
|
+
.file('numbering.xml', docxDocument.generateNumberingXML(), { createFolders: false })
|
|
225
|
+
.file('settings.xml', docxDocument.generateSettingsXML(), { createFolders: false })
|
|
226
|
+
.file('webSettings.xml', docxDocument.generateWebSettingsXML(), { createFolders: false });
|
|
227
|
+
|
|
228
|
+
const relationshipXMLs = docxDocument.generateRelsXML();
|
|
229
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
230
|
+
relationshipXMLs.forEach(({ fileName, xmlString }) => {
|
|
231
|
+
console.log(xmlString)
|
|
232
|
+
zip.folder(wordFolder).folder(relsFolderName).file(`${fileName}.xml.rels`, xmlString, {
|
|
233
|
+
createFolders: false,
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
239
|
+
relationshipXMLs.forEach(({ fileName, xmlString }) => {
|
|
240
|
+
zip.folder(wordFolder).folder(relsFolderName).file(`header1.xml.rels`, xmlString, {
|
|
241
|
+
createFolders: false,
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
246
|
+
relationshipXMLs.forEach(({ fileName, xmlString }) => {
|
|
247
|
+
zip.folder(wordFolder).folder(relsFolderName).file(`footer1.xml.rels`, xmlString, {
|
|
248
|
+
createFolders: false,
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
zip.file('[Content_Types].xml', docxDocument.generateContentTypesXML(), { createFolders: false });
|
|
255
|
+
|
|
256
|
+
return zip;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export { addFilesToContainer};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable no-useless-escape */
|
|
2
|
+
import JSZip from 'jszip';
|
|
3
|
+
import {addFilesToContainer} from './html-to-docx';
|
|
4
|
+
|
|
5
|
+
const minifyHTMLString = (htmlString) => {
|
|
6
|
+
try {
|
|
7
|
+
if (typeof htmlString === 'string' || htmlString instanceof String) {
|
|
8
|
+
const minifiedHTMLString = htmlString
|
|
9
|
+
.replace(/\n/g, ' ')
|
|
10
|
+
.replace(/\r/g, ' ')
|
|
11
|
+
.replace(/\r\n/g, ' ')
|
|
12
|
+
.replace(/[\t]+\</g, '<')
|
|
13
|
+
.replace(/\>[\t ]+\</g, '><')
|
|
14
|
+
.replace(/\>[\t ]+$/g, '>');
|
|
15
|
+
|
|
16
|
+
return minifiedHTMLString;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
throw new Error('invalid html string');
|
|
20
|
+
} catch (error) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
async function generateContainer(
|
|
26
|
+
htmlString,
|
|
27
|
+
headerHTMLString,
|
|
28
|
+
documentOptions = {},
|
|
29
|
+
footerHTMLString
|
|
30
|
+
) {
|
|
31
|
+
const zip = new JSZip();
|
|
32
|
+
|
|
33
|
+
let contentHTML = htmlString;
|
|
34
|
+
let headerHTML = headerHTMLString;
|
|
35
|
+
let footerHTML = footerHTMLString;
|
|
36
|
+
if (htmlString) {
|
|
37
|
+
contentHTML = minifyHTMLString(contentHTML);
|
|
38
|
+
}
|
|
39
|
+
if (headerHTMLString) {
|
|
40
|
+
headerHTML = minifyHTMLString(headerHTML);
|
|
41
|
+
}
|
|
42
|
+
if (footerHTMLString) {
|
|
43
|
+
footerHTML = minifyHTMLString(footerHTML);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await addFilesToContainer(zip, contentHTML, documentOptions, headerHTML, footerHTML);
|
|
47
|
+
|
|
48
|
+
const buffer = await zip.generateAsync({ type: 'arraybuffer' });
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(global, 'Buffer')) {
|
|
50
|
+
return Buffer.from(new Uint8Array(buffer));
|
|
51
|
+
}
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(global, 'Blob')) {
|
|
53
|
+
// eslint-disable-next-line no-undef
|
|
54
|
+
return new Blob([buffer], {
|
|
55
|
+
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
throw new Error(
|
|
59
|
+
'Add blob support using a polyfill eg https://github.com/bjornstar/blob-polyfill'
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {generateContainer};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const namespaces = {
|
|
2
|
+
a: 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
|
3
|
+
b: 'http://schemas.openxmlformats.org/officeDocument/2006/bibliography',
|
|
4
|
+
cdr: 'http://schemas.openxmlformats.org/drawingml/2006/chartDrawing',
|
|
5
|
+
dc: 'http://purl.org/dc/elements/1.1/',
|
|
6
|
+
dcmitype: 'http://purl.org/dc/dcmitype/',
|
|
7
|
+
dcterms: 'http://purl.org/dc/terms/',
|
|
8
|
+
o: 'urn:schemas-microsoft-com:office:office',
|
|
9
|
+
pic: 'http://schemas.openxmlformats.org/drawingml/2006/picture',
|
|
10
|
+
r: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
11
|
+
v: 'urn:schemas-microsoft-com:vml',
|
|
12
|
+
ve: 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
|
13
|
+
vt: 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes',
|
|
14
|
+
w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
|
15
|
+
w10: 'urn:schemas-microsoft-com:office:word',
|
|
16
|
+
wp: 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing',
|
|
17
|
+
wne: 'http://schemas.microsoft.com/office/word/2006/wordml',
|
|
18
|
+
xsd: 'http://www.w3.org/2001/XMLSchema',
|
|
19
|
+
xsi: 'http://www.w3.org/2001/XMLSchema-instance',
|
|
20
|
+
numbering: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
|
21
|
+
hyperlinks: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
|
22
|
+
images: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
|
23
|
+
styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
|
24
|
+
headers: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header',
|
|
25
|
+
footers: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer',
|
|
26
|
+
themes: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
|
27
|
+
coreProperties: 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
|
|
28
|
+
officeDocumentRelation:
|
|
29
|
+
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
|
30
|
+
corePropertiesRelation:
|
|
31
|
+
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
|
32
|
+
settingsRelation: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
|
33
|
+
webSettingsRelation:
|
|
34
|
+
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
|
35
|
+
sl: 'http://schemas.openxmlformats.org/schemaLibrary/2006/main',
|
|
36
|
+
contentTypes: 'http://schemas.openxmlformats.org/package/2006/content-types',
|
|
37
|
+
relationship: 'http://schemas.openxmlformats.org/package/2006/relationships',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default namespaces;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const contentTypesXML = `
|
|
2
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
+
|
|
4
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
5
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
|
|
6
|
+
<Default Extension="jpeg" ContentType="image/jpeg"/>
|
|
7
|
+
<Default Extension="png" ContentType="image/png"/>
|
|
8
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
9
|
+
<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
10
|
+
<Override PartName="/word/_rels/document.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
11
|
+
<Override PartName="/word/_rels/footer1.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
12
|
+
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
13
|
+
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
|
|
14
|
+
<Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/>
|
|
15
|
+
<Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
|
|
16
|
+
<Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>
|
|
17
|
+
<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
|
|
18
|
+
<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>
|
|
19
|
+
<Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/>
|
|
20
|
+
<Override PartName="/word/afchunk.mht" ContentType="message/rfc822"/>
|
|
21
|
+
<Override PartName="/word/afchunkheader.mht" ContentType="message/rfc822"/>
|
|
22
|
+
<Override PartName="/word/afchunkfooter.mht" ContentType="message/rfc822"/>
|
|
23
|
+
</Types>
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export { contentTypesXML};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import namespaces from '../namespaces';
|
|
2
|
+
import { applicationName } from '../constants';
|
|
3
|
+
|
|
4
|
+
const generateCoreXML = (
|
|
5
|
+
title = '',
|
|
6
|
+
subject = '',
|
|
7
|
+
creator = applicationName,
|
|
8
|
+
keywords = [applicationName],
|
|
9
|
+
description = '',
|
|
10
|
+
lastModifiedBy = applicationName,
|
|
11
|
+
revision = 1,
|
|
12
|
+
createdAt = new Date(),
|
|
13
|
+
modifiedAt = new Date()
|
|
14
|
+
) => `
|
|
15
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
16
|
+
|
|
17
|
+
<cp:coreProperties
|
|
18
|
+
xmlns:cp="${namespaces.coreProperties}"
|
|
19
|
+
xmlns:dc="${namespaces.dc}"
|
|
20
|
+
xmlns:dcterms="${namespaces.dcterms}"
|
|
21
|
+
xmlns:dcmitype="${namespaces.dcmitype}"
|
|
22
|
+
xmlns:xsi="${namespaces.xsi}"
|
|
23
|
+
>
|
|
24
|
+
<dc:title>${title}</dc:title>
|
|
25
|
+
<dc:subject>${subject}</dc:subject>
|
|
26
|
+
<dc:creator>${creator}</dc:creator>
|
|
27
|
+
${
|
|
28
|
+
keywords && Array.isArray(keywords)
|
|
29
|
+
? `<cp:keywords>${keywords.join(', ')}</cp:keywords>`
|
|
30
|
+
: ''
|
|
31
|
+
}
|
|
32
|
+
<dc:description>${description}</dc:description>
|
|
33
|
+
<cp:lastModifiedBy>${lastModifiedBy}</cp:lastModifiedBy>
|
|
34
|
+
<cp:revision>${revision}</cp:revision>
|
|
35
|
+
<dcterms:created xsi:type="dcterms:W3CDTF">${
|
|
36
|
+
createdAt instanceof Date ? createdAt.toISOString() : new Date().toISOString()
|
|
37
|
+
}</dcterms:created>
|
|
38
|
+
<dcterms:modified xsi:type="dcterms:W3CDTF">${
|
|
39
|
+
modifiedAt instanceof Date ? modifiedAt.toISOString() : new Date().toISOString()
|
|
40
|
+
}</dcterms:modified>
|
|
41
|
+
</cp:coreProperties>
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export { generateCoreXML};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import namespaces from '../namespaces';
|
|
2
|
+
|
|
3
|
+
const documentRelsXML = `
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5
|
+
|
|
6
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
7
|
+
<Relationship Id="rId1" Type="${namespaces.numbering}" Target="numbering.xml"/>
|
|
8
|
+
<Relationship Id="rId2" Type="${namespaces.styles}" Target="styles.xml"/>
|
|
9
|
+
<Relationship Id="rId3" Type="${namespaces.settingsRelation}" Target="settings.xml"/>
|
|
10
|
+
<Relationship Id="rId4" Type="${namespaces.webSettingsRelation}" Target="webSettings.xml"/>
|
|
11
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunk.mht" Id="htmlChunk" />
|
|
12
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunkheader.mht" Id="htmlChunkHeader" />
|
|
13
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunkfooter.mht" Id="htmlChunkFooter" />
|
|
14
|
+
</Relationships>
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export {documentRelsXML};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import namespaces from "../namespaces";
|
|
2
|
+
|
|
3
|
+
const generateDocumentTemplate = (width, height, orientation, margins) => `
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5
|
+
<w:document
|
|
6
|
+
xmlns:a="${namespaces.a}"
|
|
7
|
+
xmlns:cdr="${namespaces.cdr}"
|
|
8
|
+
xmlns:o="${namespaces.o}"
|
|
9
|
+
xmlns:pic="${namespaces.pic}"
|
|
10
|
+
xmlns:r="${namespaces.r}"
|
|
11
|
+
xmlns:v="${namespaces.v}"
|
|
12
|
+
xmlns:ve="${namespaces.ve}"
|
|
13
|
+
xmlns:vt="${namespaces.vt}"
|
|
14
|
+
xmlns:w="${namespaces.w}"
|
|
15
|
+
xmlns:w10="${namespaces.w10}"
|
|
16
|
+
xmlns:wp="${namespaces.wp}"
|
|
17
|
+
xmlns:wne="${namespaces.wne}"
|
|
18
|
+
>
|
|
19
|
+
<w:body>
|
|
20
|
+
|
|
21
|
+
<w:altChunk r:id="htmlChunk" />
|
|
22
|
+
<w:sectPr>
|
|
23
|
+
<w:pgSz w:w="${width}" w:h="${height}" w:orient="${orientation}" />
|
|
24
|
+
<w:pgMar w:top="${margins.top}"
|
|
25
|
+
w:right="${margins.right}"
|
|
26
|
+
w:bottom="${margins.bottom}"
|
|
27
|
+
w:left="${margins.left}"
|
|
28
|
+
w:header="${margins.header}"
|
|
29
|
+
w:footer="${margins.footer}"
|
|
30
|
+
w:gutter="${margins.gutter}"/>
|
|
31
|
+
</w:sectPr>
|
|
32
|
+
</w:body>
|
|
33
|
+
</w:document>
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
const generateDocumentTemplateHeader = `
|
|
37
|
+
<w:hdr
|
|
38
|
+
xmlns:a="${namespaces.a}"
|
|
39
|
+
xmlns:cdr="${namespaces.cdr}"
|
|
40
|
+
xmlns:o="${namespaces.o}"
|
|
41
|
+
xmlns:pic="${namespaces.pic}"
|
|
42
|
+
xmlns:r="${namespaces.r}"
|
|
43
|
+
xmlns:v="${namespaces.v}"
|
|
44
|
+
xmlns:ve="${namespaces.ve}"
|
|
45
|
+
xmlns:vt="${namespaces.vt}"
|
|
46
|
+
xmlns:w="${namespaces.w}"
|
|
47
|
+
xmlns:w10="${namespaces.w10}"
|
|
48
|
+
xmlns:wp="${namespaces.wp}"
|
|
49
|
+
xmlns:wne="${namespaces.wne}"
|
|
50
|
+
>
|
|
51
|
+
<w:altChunk r:id="htmlChunkHeader" />
|
|
52
|
+
</w:hdr>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
const generateDocumentTemplateFooter = `
|
|
56
|
+
<w:ftr
|
|
57
|
+
xmlns:a="${namespaces.a}"
|
|
58
|
+
xmlns:cdr="${namespaces.cdr}"
|
|
59
|
+
xmlns:o="${namespaces.o}"
|
|
60
|
+
xmlns:pic="${namespaces.pic}"
|
|
61
|
+
xmlns:r="${namespaces.r}"
|
|
62
|
+
xmlns:v="${namespaces.v}"
|
|
63
|
+
xmlns:ve="${namespaces.ve}"
|
|
64
|
+
xmlns:vt="${namespaces.vt}"
|
|
65
|
+
xmlns:w="${namespaces.w}"
|
|
66
|
+
xmlns:w10="${namespaces.w10}"
|
|
67
|
+
xmlns:wp="${namespaces.wp}"
|
|
68
|
+
>
|
|
69
|
+
<w:altChunk r:id="htmlChunkFooter" />
|
|
70
|
+
<w:p w:rsidR="0014021C" w:rsidRDefault="0014021C" w:rsidP="0014021C">
|
|
71
|
+
<w:pPr>
|
|
72
|
+
<w:pStyle w:val="Footer"/>
|
|
73
|
+
<w:jc w:val="center"/>
|
|
74
|
+
</w:pPr>
|
|
75
|
+
<w:fldSimple xmlns:ns2="http://schemas.openxmlformats.org/wordprocessingml/2006/main" ns2:instr="PAGE">
|
|
76
|
+
<w:r/>
|
|
77
|
+
</w:fldSimple>
|
|
78
|
+
</w:p>
|
|
79
|
+
</w:ftr>
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
const generateDocumentTemplateFooterWithoutPaging = `
|
|
83
|
+
<w:ftr
|
|
84
|
+
xmlns:a="${namespaces.a}"
|
|
85
|
+
xmlns:cdr="${namespaces.cdr}"
|
|
86
|
+
xmlns:o="${namespaces.o}"
|
|
87
|
+
xmlns:pic="${namespaces.pic}"
|
|
88
|
+
xmlns:r="${namespaces.r}"
|
|
89
|
+
xmlns:v="${namespaces.v}"
|
|
90
|
+
xmlns:ve="${namespaces.ve}"
|
|
91
|
+
xmlns:vt="${namespaces.vt}"
|
|
92
|
+
xmlns:w="${namespaces.w}"
|
|
93
|
+
xmlns:w10="${namespaces.w10}"
|
|
94
|
+
xmlns:wp="${namespaces.wp}"
|
|
95
|
+
>
|
|
96
|
+
<w:altChunk r:id="htmlChunkFooter" />
|
|
97
|
+
</w:ftr>
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
generateDocumentTemplate,
|
|
102
|
+
generateDocumentTemplateHeader,
|
|
103
|
+
generateDocumentTemplateFooter,
|
|
104
|
+
generateDocumentTemplateFooterWithoutPaging
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
{/* <w:altChunk r:id="htmlChunkFooter" /> */}
|
|
108
|
+
|
|
109
|
+
{
|
|
110
|
+
/* <w:altChunk r:id="htmlChunkFooter" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" /> */
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
{
|
|
114
|
+
/* <w:ftr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
115
|
+
<fldSimple xmlns:ns2="http://schemas.openxmlformats.org/wordprocessingml/2006/main" ns2:instr="PAGE">
|
|
116
|
+
</fldSimple>
|
|
117
|
+
<w:altChunk r:id="htmlChunkFooter" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
|
|
118
|
+
</w:ftr> */
|
|
119
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import namespaces from '../namespaces';
|
|
2
|
+
|
|
3
|
+
const fontTableXML = `
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5
|
+
|
|
6
|
+
<w:fonts
|
|
7
|
+
xmlns:r="${namespaces.r}"
|
|
8
|
+
xmlns:w="${namespaces.w}"
|
|
9
|
+
>
|
|
10
|
+
<w:font w:name="Symbol">
|
|
11
|
+
<w:panose1 w:val="05050102010706020507"/>
|
|
12
|
+
<w:charset w:val="02"/>
|
|
13
|
+
<w:family w:val="decorative"/>
|
|
14
|
+
<w:pitch w:val="variable"/>
|
|
15
|
+
<w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/>
|
|
16
|
+
</w:font>
|
|
17
|
+
<w:font w:name="Calibri">
|
|
18
|
+
<w:panose1 w:val="020F0502020204030204"/>
|
|
19
|
+
<w:charset w:val="00"/>
|
|
20
|
+
<w:family w:val="swiss"/>
|
|
21
|
+
<w:pitch w:val="variable"/>
|
|
22
|
+
<w:sig w:usb0="E4002EFF" w:usb1="C000247B" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
|
|
23
|
+
</w:font>
|
|
24
|
+
<w:font w:name="Times New Roman">
|
|
25
|
+
<w:panose1 w:val="02020603050405020304"/>
|
|
26
|
+
<w:charset w:val="00"/>
|
|
27
|
+
<w:family w:val="roman"/>
|
|
28
|
+
<w:pitch w:val="variable"/>
|
|
29
|
+
<w:sig w:usb0="E0002EFF" w:usb1="C000785B" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
|
|
30
|
+
</w:font>
|
|
31
|
+
<w:font w:name="Calibri Light">
|
|
32
|
+
<w:panose1 w:val="020F0302020204030204"/>
|
|
33
|
+
<w:charset w:val="00"/>
|
|
34
|
+
<w:family w:val="swiss"/>
|
|
35
|
+
<w:pitch w:val="variable"/>
|
|
36
|
+
<w:sig w:usb0="E4002EFF" w:usb1="C000247B" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
|
|
37
|
+
</w:font>
|
|
38
|
+
</w:fonts>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export {fontTableXML};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const genericRelsXML = `
|
|
2
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3
|
+
|
|
4
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
5
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunk.mht" Id="htmlChunk" />
|
|
6
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunkheader.mht" Id="htmlChunkHeader" />
|
|
7
|
+
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" Target="/word/afchunkfooter.mht" Id="htmlChunkFooter" />
|
|
8
|
+
</Relationships>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export {genericRelsXML};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { contentTypesXML } from './content-types';
|
|
2
|
+
export { generateCoreXML } from './core';
|
|
3
|
+
export { documentRelsXML } from './document-rels';
|
|
4
|
+
export { relsXML } from './rels';
|
|
5
|
+
export { generateNumberingXMLTemplate } from './numbering';
|
|
6
|
+
export { generateStylesXML } from './styles';
|
|
7
|
+
export { fontTableXML } from './font-table';
|
|
8
|
+
export { generateThemeXML } from './theme';
|
|
9
|
+
export { settingsXML } from './settings';
|
|
10
|
+
export { webSettingsXML } from './web-settings';
|
|
11
|
+
export { genericRelsXML } from './generic-rels';
|
|
12
|
+
export { generateDocumentTemplate } from './document.template';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import namespaces from '../namespaces';
|
|
2
|
+
|
|
3
|
+
const generateNumberingXMLTemplate = () => `
|
|
4
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5
|
+
|
|
6
|
+
<w:numbering
|
|
7
|
+
xmlns:w="${namespaces.w}"
|
|
8
|
+
xmlns:ve="${namespaces.ve}"
|
|
9
|
+
xmlns:o="${namespaces.o}"
|
|
10
|
+
xmlns:r="${namespaces.r}"
|
|
11
|
+
xmlns:v="${namespaces.v}"
|
|
12
|
+
xmlns:wp="${namespaces.wp}"
|
|
13
|
+
xmlns:w10="${namespaces.w10}"
|
|
14
|
+
xmlns:wne="${namespaces.wne}">
|
|
15
|
+
</w:numbering>
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export {generateNumberingXMLTemplate};
|