@bnsights/bbsf-utilities 1.0.31 → 1.0.33
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 +3 -0
- package/bnsights-bbsf-utilities-1.0.33.tgz +0 -0
- package/bnsights-bbsf-utilities.metadata.json +1 -1
- package/bundles/bnsights-bbsf-utilities.umd.js +3384 -4
- package/bundles/bnsights-bbsf-utilities.umd.js.map +1 -1
- package/esm2015/lib/shared/config/word/constants.js +105 -0
- package/esm2015/lib/shared/config/word/docx-document.js +351 -0
- package/esm2015/lib/shared/config/word/helpers/index.js +4 -0
- package/esm2015/lib/shared/config/word/helpers/render-document-file.js +278 -0
- package/esm2015/lib/shared/config/word/helpers/xml-builder.js +1765 -0
- package/esm2015/lib/shared/config/word/html-to-docx.js +195 -0
- package/esm2015/lib/shared/config/word/index.js +55 -0
- package/esm2015/lib/shared/config/word/namespaces.js +37 -0
- package/esm2015/lib/shared/config/word/schemas/content-types.js +26 -0
- package/esm2015/lib/shared/config/word/schemas/core.js +29 -0
- package/esm2015/lib/shared/config/word/schemas/document-rels.js +16 -0
- package/esm2015/lib/shared/config/word/schemas/document.template.js +109 -0
- package/esm2015/lib/shared/config/word/schemas/font-table.js +40 -0
- package/esm2015/lib/shared/config/word/schemas/generic-rels.js +11 -0
- package/esm2015/lib/shared/config/word/schemas/index.js +13 -0
- package/esm2015/lib/shared/config/word/schemas/numbering.js +19 -0
- package/esm2015/lib/shared/config/word/schemas/rels.js +11 -0
- package/esm2015/lib/shared/config/word/schemas/settings.js +13 -0
- package/esm2015/lib/shared/config/word/schemas/styles.js +149 -0
- package/esm2015/lib/shared/config/word/schemas/theme.js +200 -0
- package/esm2015/lib/shared/config/word/schemas/web-settings.js +9 -0
- package/esm2015/lib/shared/config/word/utils/color-conversion.js +60 -0
- package/esm2015/lib/shared/config/word/utils/list.js +51 -0
- package/esm2015/lib/shared/config/word/utils/unit-conversion.js +30 -0
- package/esm2015/lib/shared/config/word/utils/url.js +9 -0
- package/esm2015/lib/shared/config/word/utils/vnode.js +3 -0
- package/esm2015/lib/shared/config/word/word-work/templates/documentTemplate.js +54 -0
- package/esm2015/lib/shared/config/word/word-work/templates/index.js +4 -0
- package/esm2015/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.js +22 -0
- package/esm2015/lib/shared/config/word/word-work/templates/mhtPartTemplate.js +10 -0
- package/esm2015/lib/shared/config/word/word-work/utils.js +26 -0
- package/esm2015/lib/shared/models/WordDocumentModel.js +8 -0
- package/esm2015/lib/shared/services/word-document.service.js +39 -0
- package/esm2015/public-api.js +3 -1
- package/fesm2015/bnsights-bbsf-utilities.js +3630 -2
- package/fesm2015/bnsights-bbsf-utilities.js.map +1 -1
- package/lib/shared/config/word/constants.d.ts +124 -0
- package/lib/shared/config/word/docx-document.d.ts +73 -0
- package/lib/shared/config/word/helpers/index.d.ts +1 -0
- package/lib/shared/config/word/helpers/render-document-file.d.ts +4 -0
- package/lib/shared/config/word/helpers/xml-builder.d.ts +14 -0
- package/lib/shared/config/word/html-to-docx.d.ts +1 -0
- package/lib/shared/config/word/index.d.ts +1 -0
- package/lib/shared/config/word/namespaces.d.ts +36 -0
- package/lib/shared/config/word/schemas/content-types.d.ts +1 -0
- package/lib/shared/config/word/schemas/core.d.ts +1 -0
- package/lib/shared/config/word/schemas/document-rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/document.template.d.ts +4 -0
- package/lib/shared/config/word/schemas/font-table.d.ts +1 -0
- package/lib/shared/config/word/schemas/generic-rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/index.d.ts +12 -0
- package/lib/shared/config/word/schemas/numbering.d.ts +1 -0
- package/lib/shared/config/word/schemas/rels.d.ts +1 -0
- package/lib/shared/config/word/schemas/settings.d.ts +1 -0
- package/lib/shared/config/word/schemas/styles.d.ts +1 -0
- package/lib/shared/config/word/schemas/theme.d.ts +1 -0
- package/lib/shared/config/word/schemas/web-settings.d.ts +1 -0
- package/lib/shared/config/word/utils/color-conversion.d.ts +7 -0
- package/lib/shared/config/word/utils/list.d.ts +6 -0
- package/lib/shared/config/word/utils/unit-conversion.d.ts +29 -0
- package/lib/shared/config/word/utils/url.d.ts +1 -0
- package/lib/shared/config/word/utils/vnode.d.ts +1 -0
- package/lib/shared/config/word/word-work/templates/documentTemplate.d.ts +12 -0
- package/lib/shared/config/word/word-work/templates/index.d.ts +3 -0
- package/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.d.ts +1 -0
- package/lib/shared/config/word/word-work/templates/mhtPartTemplate.d.ts +1 -0
- package/lib/shared/config/word/word-work/utils.d.ts +1 -0
- package/lib/shared/models/WordDocumentModel.d.ts +16 -0
- package/lib/shared/services/word-document.service.d.ts +5 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
- package/bnsights-bbsf-utilities-1.0.31.tgz +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/router'), require('@ngx-translate/core'), require('ng-block-ui'), require('ngx-toastr'), require('@angular/http'), require('@angular/common/http'), require('oidc-client'), require('rxjs'), require('rxjs/operators'), require('class-transformer')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@bnsights/bbsf-utilities', ['exports', '@angular/common', '@angular/core', '@angular/router', '@ngx-translate/core', 'ng-block-ui', 'ngx-toastr', '@angular/http', '@angular/common/http', 'oidc-client', 'rxjs', 'rxjs/operators', 'class-transformer'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bnsights = global.bnsights || {}, global.bnsights["bbsf-utilities"] = {}), global.ng.common, global.ng.core, global.ng.router, global.i1, global.ngBlockUi, global.ngxToastr, global.ng.http, global.ng.common.http, global.oidcClient, global.rxjs, global.rxjs.operators, global.classTransformer));
|
|
5
|
-
})(this, (function (exports, i1$3, i0, i1$2, i1, ngBlockUi, ngxToastr, http, i1$1, oidcClient, rxjs, operators, classTransformer) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/router'), require('@ngx-translate/core'), require('ng-block-ui'), require('ngx-toastr'), require('@angular/http'), require('@angular/common/http'), require('oidc-client'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('jszip'), require('xmlbuilder2'), require('virtual-dom/vnode/vnode'), require('virtual-dom/vnode/vtext'), require('html-to-vdom'), require('lodash'), require('nanoid'), require('virtual-dom/vnode/is-vnode'), require('virtual-dom/vnode/is-vtext'), require('escape-html'), require('image-size'), require('image-to-base64'), require('mime-types'), require('color-name')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@bnsights/bbsf-utilities', ['exports', '@angular/common', '@angular/core', '@angular/router', '@ngx-translate/core', 'ng-block-ui', 'ngx-toastr', '@angular/http', '@angular/common/http', 'oidc-client', 'rxjs', 'rxjs/operators', 'class-transformer', 'jszip', 'xmlbuilder2', 'virtual-dom/vnode/vnode', 'virtual-dom/vnode/vtext', 'html-to-vdom', 'lodash', 'nanoid', 'virtual-dom/vnode/is-vnode', 'virtual-dom/vnode/is-vtext', 'escape-html', 'image-size', 'image-to-base64', 'mime-types', 'color-name'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.bnsights = global.bnsights || {}, global.bnsights["bbsf-utilities"] = {}), global.ng.common, global.ng.core, global.ng.router, global.i1, global.ngBlockUi, global.ngxToastr, global.ng.http, global.ng.common.http, global.oidcClient, global.rxjs, global.rxjs.operators, global.classTransformer, global.JSZip, global.xmlbuilder2, global.VNode, global.VText, global.HTMLToVDOM, global.lodash, global.nanoid, global.isVNode, global.isVText, global.escape, global.sizeOf, global.imageToBase64, global.mimeTypes, global.colorNames));
|
|
5
|
+
})(this, (function (exports, i1$3, i0, i1$2, i1, ngBlockUi, ngxToastr, http, i1$1, oidcClient, rxjs, operators, classTransformer, JSZip, xmlbuilder2, VNode, VText, HTMLToVDOM, lodash, nanoid, isVNode, isVText, escape, sizeOf, imageToBase64, mimeTypes, colorNames) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
8
|
|
|
7
9
|
function _interopNamespace(e) {
|
|
8
10
|
if (e && e.__esModule) return e;
|
|
@@ -27,6 +29,17 @@
|
|
|
27
29
|
var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
|
|
28
30
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
31
|
var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$1);
|
|
32
|
+
var JSZip__default = /*#__PURE__*/_interopDefaultLegacy(JSZip);
|
|
33
|
+
var VNode__default = /*#__PURE__*/_interopDefaultLegacy(VNode);
|
|
34
|
+
var VText__default = /*#__PURE__*/_interopDefaultLegacy(VText);
|
|
35
|
+
var HTMLToVDOM__default = /*#__PURE__*/_interopDefaultLegacy(HTMLToVDOM);
|
|
36
|
+
var isVNode__default = /*#__PURE__*/_interopDefaultLegacy(isVNode);
|
|
37
|
+
var isVText__default = /*#__PURE__*/_interopDefaultLegacy(isVText);
|
|
38
|
+
var escape__default = /*#__PURE__*/_interopDefaultLegacy(escape);
|
|
39
|
+
var sizeOf__default = /*#__PURE__*/_interopDefaultLegacy(sizeOf);
|
|
40
|
+
var imageToBase64__default = /*#__PURE__*/_interopDefaultLegacy(imageToBase64);
|
|
41
|
+
var mimeTypes__default = /*#__PURE__*/_interopDefaultLegacy(mimeTypes);
|
|
42
|
+
var colorNames__default = /*#__PURE__*/_interopDefaultLegacy(colorNames);
|
|
30
43
|
|
|
31
44
|
/*! *****************************************************************************
|
|
32
45
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1456,6 +1469,3370 @@
|
|
|
1456
1469
|
{ type: ConfigurationService }
|
|
1457
1470
|
]; };
|
|
1458
1471
|
|
|
1472
|
+
var contentTypesXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">\n <Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\" />\n <Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/>\n <Default Extension=\"png\" ContentType=\"image/png\"/>\n <Default Extension=\"xml\" ContentType=\"application/xml\"/>\n <Override PartName=\"/_rels/.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n <Override PartName=\"/word/_rels/document.xml.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n <Override PartName=\"/word/_rels/footer1.xml.rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/>\n <Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/>\n <Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/>\n <Override PartName=\"/word/numbering.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\"/>\n <Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/>\n <Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/>\n <Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/>\n <Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/>\n <Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/>\n <Override PartName=\"/word/afchunk.mht\" ContentType=\"message/rfc822\"/>\n <Override PartName=\"/word/afchunkheader.mht\" ContentType=\"message/rfc822\"/>\n <Override PartName=\"/word/afchunkfooter.mht\" ContentType=\"message/rfc822\"/>\n </Types>\n";
|
|
1473
|
+
|
|
1474
|
+
var namespaces = {
|
|
1475
|
+
a: 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
|
1476
|
+
b: 'http://schemas.openxmlformats.org/officeDocument/2006/bibliography',
|
|
1477
|
+
cdr: 'http://schemas.openxmlformats.org/drawingml/2006/chartDrawing',
|
|
1478
|
+
dc: 'http://purl.org/dc/elements/1.1/',
|
|
1479
|
+
dcmitype: 'http://purl.org/dc/dcmitype/',
|
|
1480
|
+
dcterms: 'http://purl.org/dc/terms/',
|
|
1481
|
+
o: 'urn:schemas-microsoft-com:office:office',
|
|
1482
|
+
pic: 'http://schemas.openxmlformats.org/drawingml/2006/picture',
|
|
1483
|
+
r: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
|
1484
|
+
v: 'urn:schemas-microsoft-com:vml',
|
|
1485
|
+
ve: 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
|
1486
|
+
vt: 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes',
|
|
1487
|
+
w: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
|
1488
|
+
w10: 'urn:schemas-microsoft-com:office:word',
|
|
1489
|
+
wp: 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing',
|
|
1490
|
+
wne: 'http://schemas.microsoft.com/office/word/2006/wordml',
|
|
1491
|
+
xsd: 'http://www.w3.org/2001/XMLSchema',
|
|
1492
|
+
xsi: 'http://www.w3.org/2001/XMLSchema-instance',
|
|
1493
|
+
numbering: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
|
1494
|
+
hyperlinks: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
|
1495
|
+
images: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
|
1496
|
+
styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
|
1497
|
+
headers: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header',
|
|
1498
|
+
footers: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer',
|
|
1499
|
+
themes: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
|
1500
|
+
coreProperties: 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
|
|
1501
|
+
officeDocumentRelation: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
|
1502
|
+
corePropertiesRelation: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
|
1503
|
+
settingsRelation: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
|
1504
|
+
webSettingsRelation: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
|
1505
|
+
sl: 'http://schemas.openxmlformats.org/schemaLibrary/2006/main',
|
|
1506
|
+
contentTypes: 'http://schemas.openxmlformats.org/package/2006/content-types',
|
|
1507
|
+
relationship: 'http://schemas.openxmlformats.org/package/2006/relationships',
|
|
1508
|
+
};
|
|
1509
|
+
|
|
1510
|
+
var applicationName = 'html-to-docx';
|
|
1511
|
+
var defaultOrientation = 'portrait';
|
|
1512
|
+
var landscapeWidth = 15840;
|
|
1513
|
+
var landscapeHeight = 12240;
|
|
1514
|
+
var landscapeMargins = {
|
|
1515
|
+
top: 1800,
|
|
1516
|
+
right: 1440,
|
|
1517
|
+
bottom: 1800,
|
|
1518
|
+
left: 1440,
|
|
1519
|
+
header: 720,
|
|
1520
|
+
footer: 720,
|
|
1521
|
+
gutter: 0,
|
|
1522
|
+
};
|
|
1523
|
+
var portraitMargins = {
|
|
1524
|
+
top: 1440,
|
|
1525
|
+
right: 1800,
|
|
1526
|
+
bottom: 1440,
|
|
1527
|
+
left: 1800,
|
|
1528
|
+
header: 720,
|
|
1529
|
+
footer: 720,
|
|
1530
|
+
gutter: 0,
|
|
1531
|
+
};
|
|
1532
|
+
var defaultFont = 'Times New Roman';
|
|
1533
|
+
var defaultFontSize = 22;
|
|
1534
|
+
var defaultDocumentOptions = {
|
|
1535
|
+
orientation: defaultOrientation,
|
|
1536
|
+
margins: lodash.cloneDeep(portraitMargins),
|
|
1537
|
+
title: '',
|
|
1538
|
+
subject: '',
|
|
1539
|
+
creator: applicationName,
|
|
1540
|
+
keywords: [applicationName],
|
|
1541
|
+
description: '',
|
|
1542
|
+
lastModifiedBy: applicationName,
|
|
1543
|
+
revision: 1,
|
|
1544
|
+
createdAt: new Date(),
|
|
1545
|
+
modifiedAt: new Date(),
|
|
1546
|
+
headerType: 'default',
|
|
1547
|
+
header: false,
|
|
1548
|
+
footerType: 'default',
|
|
1549
|
+
footer: false,
|
|
1550
|
+
font: defaultFont,
|
|
1551
|
+
fontSize: defaultFontSize,
|
|
1552
|
+
complexScriptFontSize: defaultFontSize,
|
|
1553
|
+
table: {
|
|
1554
|
+
row: {
|
|
1555
|
+
cantSplit: false,
|
|
1556
|
+
},
|
|
1557
|
+
},
|
|
1558
|
+
pageSize: {
|
|
1559
|
+
width: landscapeHeight,
|
|
1560
|
+
height: landscapeWidth,
|
|
1561
|
+
},
|
|
1562
|
+
pageNumber: false,
|
|
1563
|
+
skipFirstHeaderFooter: false,
|
|
1564
|
+
lineNumber: false,
|
|
1565
|
+
lineNumberOptions: {
|
|
1566
|
+
countBy: 1,
|
|
1567
|
+
start: 0,
|
|
1568
|
+
restart: 'continuous',
|
|
1569
|
+
},
|
|
1570
|
+
numbering: {
|
|
1571
|
+
defaultOrderedListStyleType: 'decimal',
|
|
1572
|
+
},
|
|
1573
|
+
};
|
|
1574
|
+
var defaultHTMLString = '<p></p>';
|
|
1575
|
+
var relsFolderName = '_rels';
|
|
1576
|
+
var headerFileName = 'header1';
|
|
1577
|
+
var footerFileName = 'footer1';
|
|
1578
|
+
var themeFileName = 'theme1';
|
|
1579
|
+
var documentFileName = 'document';
|
|
1580
|
+
var headerType = 'header';
|
|
1581
|
+
var footerType = 'footer';
|
|
1582
|
+
var themeType = 'theme';
|
|
1583
|
+
var hyperlinkType = 'hyperlink';
|
|
1584
|
+
var imageType = 'image';
|
|
1585
|
+
var internalRelationship = 'Internal';
|
|
1586
|
+
var wordFolder = 'word';
|
|
1587
|
+
var themeFolder = 'theme';
|
|
1588
|
+
var paragraphBordersObject = {
|
|
1589
|
+
top: {
|
|
1590
|
+
size: 0,
|
|
1591
|
+
spacing: 3,
|
|
1592
|
+
color: 'FFFFFF',
|
|
1593
|
+
},
|
|
1594
|
+
left: {
|
|
1595
|
+
size: 0,
|
|
1596
|
+
spacing: 3,
|
|
1597
|
+
color: 'FFFFFF',
|
|
1598
|
+
},
|
|
1599
|
+
bottom: {
|
|
1600
|
+
size: 0,
|
|
1601
|
+
spacing: 3,
|
|
1602
|
+
color: 'FFFFFF',
|
|
1603
|
+
},
|
|
1604
|
+
right: {
|
|
1605
|
+
size: 0,
|
|
1606
|
+
spacing: 3,
|
|
1607
|
+
color: 'FFFFFF',
|
|
1608
|
+
},
|
|
1609
|
+
};
|
|
1610
|
+
var colorlessColors = ['transparent', 'auto'];
|
|
1611
|
+
var verticalAlignValues = ['top', 'middle', 'bottom'];
|
|
1612
|
+
|
|
1613
|
+
var generateCoreXML = function (title, subject, creator, keywords, description, lastModifiedBy, revision, createdAt, modifiedAt) {
|
|
1614
|
+
if (title === void 0) { title = ''; }
|
|
1615
|
+
if (subject === void 0) { subject = ''; }
|
|
1616
|
+
if (creator === void 0) { creator = applicationName; }
|
|
1617
|
+
if (keywords === void 0) { keywords = [applicationName]; }
|
|
1618
|
+
if (description === void 0) { description = ''; }
|
|
1619
|
+
if (lastModifiedBy === void 0) { lastModifiedBy = applicationName; }
|
|
1620
|
+
if (revision === void 0) { revision = 1; }
|
|
1621
|
+
if (createdAt === void 0) { createdAt = new Date(); }
|
|
1622
|
+
if (modifiedAt === void 0) { modifiedAt = new Date(); }
|
|
1623
|
+
return "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <cp:coreProperties\n xmlns:cp=\"" + namespaces.coreProperties + "\"\n xmlns:dc=\"" + namespaces.dc + "\"\n xmlns:dcterms=\"" + namespaces.dcterms + "\"\n xmlns:dcmitype=\"" + namespaces.dcmitype + "\"\n xmlns:xsi=\"" + namespaces.xsi + "\"\n >\n <dc:title>" + title + "</dc:title>\n <dc:subject>" + subject + "</dc:subject>\n <dc:creator>" + creator + "</dc:creator>\n " + (keywords && Array.isArray(keywords)
|
|
1624
|
+
? "<cp:keywords>" + keywords.join(', ') + "</cp:keywords>"
|
|
1625
|
+
: '') + "\n <dc:description>" + description + "</dc:description>\n <cp:lastModifiedBy>" + lastModifiedBy + "</cp:lastModifiedBy>\n <cp:revision>" + revision + "</cp:revision>\n <dcterms:created xsi:type=\"dcterms:W3CDTF\">" + (createdAt instanceof Date ? createdAt.toISOString() : new Date().toISOString()) + "</dcterms:created>\n <dcterms:modified xsi:type=\"dcterms:W3CDTF\">" + (modifiedAt instanceof Date ? modifiedAt.toISOString() : new Date().toISOString()) + "</dcterms:modified>\n </cp:coreProperties>\n ";
|
|
1626
|
+
};
|
|
1627
|
+
var ɵ0$8 = generateCoreXML;
|
|
1628
|
+
|
|
1629
|
+
var documentRelsXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"" + namespaces.numbering + "\" Target=\"numbering.xml\"/>\n <Relationship Id=\"rId2\" Type=\"" + namespaces.styles + "\" Target=\"styles.xml\"/>\n <Relationship Id=\"rId3\" Type=\"" + namespaces.settingsRelation + "\" Target=\"settings.xml\"/>\n <Relationship Id=\"rId4\" Type=\"" + namespaces.webSettingsRelation + "\" Target=\"webSettings.xml\"/>\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunk.mht\" Id=\"htmlChunk\" />\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunkheader.mht\" Id=\"htmlChunkHeader\" />\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunkfooter.mht\" Id=\"htmlChunkFooter\" />\n </Relationships>\n";
|
|
1630
|
+
|
|
1631
|
+
var relsXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Id=\"rId1\" Type=\"" + namespaces.officeDocumentRelation + "\" Target=\"word/document.xml\"/>\n <Relationship Id=\"rId2\" Type=\"" + namespaces.corePropertiesRelation + "\" Target=\"docProps/core.xml\"/>\n </Relationships>\n";
|
|
1632
|
+
|
|
1633
|
+
var generateNumberingXMLTemplate = function () { return "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <w:numbering\n xmlns:w=\"" + namespaces.w + "\"\n xmlns:ve=\"" + namespaces.ve + "\"\n xmlns:o=\"" + namespaces.o + "\"\n xmlns:r=\"" + namespaces.r + "\"\n xmlns:v=\"" + namespaces.v + "\"\n xmlns:wp=\"" + namespaces.wp + "\"\n xmlns:w10=\"" + namespaces.w10 + "\"\n xmlns:wne=\"" + namespaces.wne + "\">\n </w:numbering>\n "; };
|
|
1634
|
+
var ɵ0$7 = generateNumberingXMLTemplate;
|
|
1635
|
+
|
|
1636
|
+
var generateStylesXML = function (font, fontSize, complexScriptFontSize) {
|
|
1637
|
+
if (font === void 0) { font = defaultFont; }
|
|
1638
|
+
if (fontSize === void 0) { fontSize = defaultFontSize; }
|
|
1639
|
+
if (complexScriptFontSize === void 0) { complexScriptFontSize = defaultFontSize; }
|
|
1640
|
+
return "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <w:styles xmlns:w=\"" + namespaces.w + "\" xmlns:r=\"" + namespaces.r + "\">\n\t<w:docDefaults>\n\t <w:rPrDefault>\n\t\t<w:rPr>\n\t\t <w:rFonts w:ascii=\"" + font + "\" w:eastAsiaTheme=\"minorHAnsi\" w:hAnsiTheme=\"minorHAnsi\" w:cstheme=\"minorBidi\" />\n\t\t <w:sz w:val=\"" + fontSize + "\" />\n\t\t <w:szCs w:val=\"" + complexScriptFontSize + "\" />\n\t\t <w:lang w:val=\"en-US\" w:eastAsia=\"en-US\" w:bidi=\"ar-SA\" />\n\t\t</w:rPr>\n\t </w:rPrDefault>\n\t <w:pPrDefault>\n\t\t<w:pPr>\n\t\t <w:spacing w:after=\"120\" w:line=\"240\" w:lineRule=\"atLeast\" />\n\t\t</w:pPr>\n\t </w:pPrDefault>\n\t</w:docDefaults>\n\t<w:style w:type=\"character\" w:styleId=\"Hyperlink\">\n\t <w:name w:val=\"Hyperlink\" />\n\t <w:rPr>\n\t\t<w:color w:val=\"0000FF\" />\n\t\t<w:u w:val=\"single\" />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading1\">\n\t <w:name w:val=\"heading 1\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"480\" />\n\t\t<w:outlineLvl w:val=\"0\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t\t<w:sz w:val=\"48\" />\n\t\t<w:szCs w:val=\"48\" />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading2\">\n\t <w:name w:val=\"heading 2\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:unhideWhenUsed />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"360\" w:after=\"80\" />\n\t\t<w:outlineLvl w:val=\"1\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t\t<w:sz w:val=\"36\" />\n\t\t<w:szCs w:val=\"36\" />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading3\">\n\t <w:name w:val=\"heading 3\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:semiHidden />\n\t <w:unhideWhenUsed />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"280\" w:after=\"80\" />\n\t\t<w:outlineLvl w:val=\"2\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t\t<w:sz w:val=\"28\" />\n\t\t<w:szCs w:val=\"28\" />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading4\">\n\t <w:name w:val=\"heading 4\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:semiHidden />\n\t <w:unhideWhenUsed />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"240\" w:after=\"40\" />\n\t\t<w:outlineLvl w:val=\"3\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t\t<w:sz w:val=\"24\" />\n\t\t<w:szCs w:val=\"24\" />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading5\">\n\t <w:name w:val=\"heading 5\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:semiHidden />\n\t <w:unhideWhenUsed />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"220\" w:after=\"40\" />\n\t\t<w:outlineLvl w:val=\"4\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t </w:rPr>\n\t</w:style>\n\t<w:style w:type=\"paragraph\" w:styleId=\"Heading6\">\n\t <w:name w:val=\"heading 6\" />\n\t <w:basedOn w:val=\"Normal\" />\n\t <w:next w:val=\"Normal\" />\n\t <w:uiPriority w:val=\"9\" />\n\t <w:semiHidden />\n\t <w:unhideWhenUsed />\n\t <w:qFormat />\n\t <w:pPr>\n\t\t<w:keepNext />\n\t\t<w:keepLines />\n\t\t<w:spacing w:before=\"200\" w:after=\"40\" />\n\t\t<w:outlineLvl w:val=\"5\" />\n\t </w:pPr>\n\t <w:rPr>\n\t\t<w:b />\n\t\t<w:sz w:val=\"20\" />\n\t\t<w:szCs w:val=\"20\" />\n\t </w:rPr>\n\t</w:style>\n </w:styles>\n ";
|
|
1641
|
+
};
|
|
1642
|
+
var ɵ0$6 = generateStylesXML;
|
|
1643
|
+
|
|
1644
|
+
var fontTableXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <w:fonts\n xmlns:r=\"" + namespaces.r + "\"\n xmlns:w=\"" + namespaces.w + "\"\n >\n <w:font w:name=\"Symbol\">\n <w:panose1 w:val=\"05050102010706020507\"/>\n <w:charset w:val=\"02\"/>\n <w:family w:val=\"decorative\"/>\n <w:pitch w:val=\"variable\"/>\n <w:sig w:usb0=\"00000000\" w:usb1=\"10000000\" w:usb2=\"00000000\" w:usb3=\"00000000\" w:csb0=\"80000000\" w:csb1=\"00000000\"/>\n </w:font>\n <w:font w:name=\"Calibri\">\n <w:panose1 w:val=\"020F0502020204030204\"/>\n <w:charset w:val=\"00\"/>\n <w:family w:val=\"swiss\"/>\n <w:pitch w:val=\"variable\"/>\n <w:sig w:usb0=\"E4002EFF\" w:usb1=\"C000247B\" w:usb2=\"00000009\" w:usb3=\"00000000\" w:csb0=\"000001FF\" w:csb1=\"00000000\"/>\n </w:font>\n <w:font w:name=\"Times New Roman\">\n <w:panose1 w:val=\"02020603050405020304\"/>\n <w:charset w:val=\"00\"/>\n <w:family w:val=\"roman\"/>\n <w:pitch w:val=\"variable\"/>\n <w:sig w:usb0=\"E0002EFF\" w:usb1=\"C000785B\" w:usb2=\"00000009\" w:usb3=\"00000000\" w:csb0=\"000001FF\" w:csb1=\"00000000\"/>\n </w:font>\n <w:font w:name=\"Calibri Light\">\n <w:panose1 w:val=\"020F0302020204030204\"/>\n <w:charset w:val=\"00\"/>\n <w:family w:val=\"swiss\"/>\n <w:pitch w:val=\"variable\"/>\n <w:sig w:usb0=\"E4002EFF\" w:usb1=\"C000247B\" w:usb2=\"00000009\" w:usb3=\"00000000\" w:csb0=\"000001FF\" w:csb1=\"00000000\"/>\n </w:font>\n </w:fonts>\n";
|
|
1645
|
+
|
|
1646
|
+
var generateThemeXML = function (font) {
|
|
1647
|
+
if (font === void 0) { font = defaultFont; }
|
|
1648
|
+
return "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\">\n <a:themeElements>\n <a:clrScheme name=\"Office\">\n <a:dk1>\n <a:sysClr val=\"windowText\" lastClr=\"000000\"/>\n </a:dk1>\n <a:lt1>\n <a:sysClr val=\"window\" lastClr=\"FFFFFF\"/>\n </a:lt1>\n <a:dk2>\n <a:srgbClr val=\"44546A\"/>\n </a:dk2>\n <a:lt2>\n <a:srgbClr val=\"E7E6E6\"/>\n </a:lt2>\n <a:accent1>\n <a:srgbClr val=\"4472C4\"/>\n </a:accent1>\n <a:accent2>\n <a:srgbClr val=\"ED7D31\"/>\n </a:accent2>\n <a:accent3>\n <a:srgbClr val=\"A5A5A5\"/>\n </a:accent3>\n <a:accent4>\n <a:srgbClr val=\"FFC000\"/>\n </a:accent4>\n <a:accent5>\n <a:srgbClr val=\"5B9BD5\"/>\n </a:accent5>\n <a:accent6>\n <a:srgbClr val=\"70AD47\"/>\n </a:accent6>\n <a:hlink>\n <a:srgbClr val=\"0563C1\"/>\n </a:hlink>\n <a:folHlink>\n <a:srgbClr val=\"954F72\"/>\n </a:folHlink>\n </a:clrScheme>\n <a:fontScheme name=\"Office\">\n <a:majorFont>\n <a:latin typeface=\"" + font + "\"/>\n <a:ea typeface=\"" + font + "\"/>\n <a:cs typeface=\"\"/>\n </a:majorFont>\n <a:minorFont>\n <a:latin typeface=\"" + font + "\"/>\n <a:ea typeface=\"" + font + "\"/>\n <a:cs typeface=\"\"/>\n </a:minorFont>\n </a:fontScheme>\n <a:fmtScheme name=\"Office\">\n <a:fillStyleLst>\n <a:solidFill>\n <a:schemeClr val=\"phClr\"/>\n </a:solidFill>\n <a:gradFill rotWithShape=\"1\">\n <a:gsLst>\n <a:gs pos=\"0\">\n <a:schemeClr val=\"phClr\">\n <a:lumMod val=\"110000\"/>\n <a:satMod val=\"105000\"/>\n <a:tint val=\"67000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"50000\">\n <a:schemeClr val=\"phClr\">\n <a:lumMod val=\"105000\"/>\n <a:satMod val=\"103000\"/>\n <a:tint val=\"73000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"100000\">\n <a:schemeClr val=\"phClr\">\n <a:lumMod val=\"105000\"/>\n <a:satMod val=\"109000\"/>\n <a:tint val=\"81000\"/>\n </a:schemeClr>\n </a:gs>\n </a:gsLst>\n <a:lin ang=\"5400000\" scaled=\"0\"/>\n </a:gradFill>\n <a:gradFill rotWithShape=\"1\">\n <a:gsLst>\n <a:gs pos=\"0\">\n <a:schemeClr val=\"phClr\">\n <a:satMod val=\"103000\"/>\n <a:lumMod val=\"102000\"/>\n <a:tint val=\"94000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"50000\">\n <a:schemeClr val=\"phClr\">\n <a:satMod val=\"110000\"/>\n <a:lumMod val=\"100000\"/>\n <a:shade val=\"100000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"100000\">\n <a:schemeClr val=\"phClr\">\n <a:lumMod val=\"99000\"/>\n <a:satMod val=\"120000\"/>\n <a:shade val=\"78000\"/>\n </a:schemeClr>\n </a:gs>\n </a:gsLst>\n <a:lin ang=\"5400000\" scaled=\"0\"/>\n </a:gradFill>\n </a:fillStyleLst>\n <a:lnStyleLst>\n <a:ln w=\"6350\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\n <a:solidFill>\n <a:schemeClr val=\"phClr\"/>\n </a:solidFill>\n <a:prstDash val=\"solid\"/>\n <a:miter lim=\"800000\"/>\n </a:ln>\n <a:ln w=\"12700\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\n <a:solidFill>\n <a:schemeClr val=\"phClr\"/>\n </a:solidFill>\n <a:prstDash val=\"solid\"/>\n <a:miter lim=\"800000\"/>\n </a:ln>\n <a:ln w=\"19050\" cap=\"flat\" cmpd=\"sng\" algn=\"ctr\">\n <a:solidFill>\n <a:schemeClr val=\"phClr\"/>\n </a:solidFill>\n <a:prstDash val=\"solid\"/>\n <a:miter lim=\"800000\"/>\n </a:ln>\n </a:lnStyleLst>\n <a:effectStyleLst>\n <a:effectStyle>\n <a:effectLst/>\n </a:effectStyle>\n <a:effectStyle>\n <a:effectLst/>\n </a:effectStyle>\n <a:effectStyle>\n <a:effectLst>\n <a:outerShdw blurRad=\"57150\" dist=\"19050\" dir=\"5400000\" algn=\"ctr\" rotWithShape=\"0\">\n <a:srgbClr val=\"000000\">\n <a:alpha val=\"63000\"/>\n </a:srgbClr>\n </a:outerShdw>\n </a:effectLst>\n </a:effectStyle>\n </a:effectStyleLst>\n <a:bgFillStyleLst>\n <a:solidFill>\n <a:schemeClr val=\"phClr\"/>\n </a:solidFill>\n <a:solidFill>\n <a:schemeClr val=\"phClr\">\n <a:tint val=\"95000\"/>\n <a:satMod val=\"170000\"/>\n </a:schemeClr>\n </a:solidFill>\n <a:gradFill rotWithShape=\"1\">\n <a:gsLst>\n <a:gs pos=\"0\">\n <a:schemeClr val=\"phClr\">\n <a:tint val=\"93000\"/>\n <a:satMod val=\"150000\"/>\n <a:shade val=\"98000\"/>\n <a:lumMod val=\"102000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"50000\">\n <a:schemeClr val=\"phClr\">\n <a:tint val=\"98000\"/>\n <a:satMod val=\"130000\"/>\n <a:shade val=\"90000\"/>\n <a:lumMod val=\"103000\"/>\n </a:schemeClr>\n </a:gs>\n <a:gs pos=\"100000\">\n <a:schemeClr val=\"phClr\">\n <a:shade val=\"63000\"/>\n <a:satMod val=\"120000\"/>\n </a:schemeClr>\n </a:gs>\n </a:gsLst>\n <a:lin ang=\"5400000\" scaled=\"0\"/>\n </a:gradFill>\n </a:bgFillStyleLst>\n </a:fmtScheme>\n </a:themeElements>\n </a:theme>\n";
|
|
1649
|
+
};
|
|
1650
|
+
var ɵ0$5 = generateThemeXML;
|
|
1651
|
+
|
|
1652
|
+
var settingsXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <w:settings xmlns:w=\"" + namespaces.w + "\" xmlns:o=\"" + namespaces.o + "\" xmlns:r=\"" + namespaces.r + "\" xmlns:v=\"" + namespaces.v + "\" xmlns:w10=\"" + namespaces.w10 + "\" xmlns:sl=\"" + namespaces.sl + "\">\n <w:zoom w:percent=\"100\"/>\n <w:defaultTabStop w:val=\"720\"/>\n <w:decimalSymbol w:val=\".\"/>\n <w:listSeparator w:val=\",\"/>\n </w:settings>\n";
|
|
1653
|
+
|
|
1654
|
+
var webSettingsXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <w:webSettings xmlns:w=\"" + namespaces.w + "\" xmlns:r=\"" + namespaces.r + "\">\n </w:webSettings>\n";
|
|
1655
|
+
|
|
1656
|
+
var genericRelsXML = "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunk.mht\" Id=\"htmlChunk\" />\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunkheader.mht\" Id=\"htmlChunkHeader\" />\n <Relationship Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\" Target=\"/word/afchunkfooter.mht\" Id=\"htmlChunkFooter\" />\n </Relationships>\n";
|
|
1657
|
+
|
|
1658
|
+
var generateDocumentTemplate = function (width, height, orientation, margins) { return "\n <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n <w:document\n xmlns:a=\"" + namespaces.a + "\"\n xmlns:cdr=\"" + namespaces.cdr + "\"\n xmlns:o=\"" + namespaces.o + "\"\n xmlns:pic=\"" + namespaces.pic + "\"\n xmlns:r=\"" + namespaces.r + "\"\n xmlns:v=\"" + namespaces.v + "\"\n xmlns:ve=\"" + namespaces.ve + "\"\n xmlns:vt=\"" + namespaces.vt + "\"\n xmlns:w=\"" + namespaces.w + "\"\n xmlns:w10=\"" + namespaces.w10 + "\"\n xmlns:wp=\"" + namespaces.wp + "\"\n xmlns:wne=\"" + namespaces.wne + "\"\n >\n <w:body>\n\n <w:altChunk r:id=\"htmlChunk\" />\n <w:sectPr>\n <w:pgSz w:w=\"" + width + "\" w:h=\"" + height + "\" w:orient=\"" + orientation + "\" />\n <w:pgMar w:top=\"" + margins.top + "\"\n w:right=\"" + margins.right + "\"\n w:bottom=\"" + margins.bottom + "\"\n w:left=\"" + margins.left + "\"\n w:header=\"" + margins.header + "\"\n w:footer=\"" + margins.footer + "\"\n w:gutter=\"" + margins.gutter + "\"/>\n </w:sectPr>\n </w:body>\n </w:document>\n "; };
|
|
1659
|
+
var ɵ0$4 = generateDocumentTemplate;
|
|
1660
|
+
var generateDocumentTemplateHeader = "\n<w:hdr\nxmlns:a=\"" + namespaces.a + "\"\nxmlns:cdr=\"" + namespaces.cdr + "\"\nxmlns:o=\"" + namespaces.o + "\"\nxmlns:pic=\"" + namespaces.pic + "\"\nxmlns:r=\"" + namespaces.r + "\"\nxmlns:v=\"" + namespaces.v + "\"\nxmlns:ve=\"" + namespaces.ve + "\"\nxmlns:vt=\"" + namespaces.vt + "\"\nxmlns:w=\"" + namespaces.w + "\"\nxmlns:w10=\"" + namespaces.w10 + "\"\nxmlns:wp=\"" + namespaces.wp + "\"\nxmlns:wne=\"" + namespaces.wne + "\"\n>\n<w:altChunk r:id=\"htmlChunkHeader\" />\n</w:hdr>\n ";
|
|
1661
|
+
var generateDocumentTemplateFooter = "\n <w:ftr\n xmlns:a=\"" + namespaces.a + "\"\n xmlns:cdr=\"" + namespaces.cdr + "\"\n xmlns:o=\"" + namespaces.o + "\"\n xmlns:pic=\"" + namespaces.pic + "\"\n xmlns:r=\"" + namespaces.r + "\"\n xmlns:v=\"" + namespaces.v + "\"\n xmlns:ve=\"" + namespaces.ve + "\"\n xmlns:vt=\"" + namespaces.vt + "\"\n xmlns:w=\"" + namespaces.w + "\"\n xmlns:w10=\"" + namespaces.w10 + "\"\n xmlns:wp=\"" + namespaces.wp + "\"\n >\n <w:altChunk r:id=\"htmlChunkFooter\" />\n\t<w:p w:rsidR=\"0014021C\" w:rsidRDefault=\"0014021C\" w:rsidP=\"0014021C\">\n\t\t\t<w:pPr>\n\t\t\t\t<w:pStyle w:val=\"Footer\"/>\n\t\t\t\t<w:jc w:val=\"center\"/>\n\t\t\t</w:pPr>\n <w:fldSimple xmlns:ns2=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ns2:instr=\"PAGE\">\n <w:r/>\n </w:fldSimple>\n\t\t</w:p>\n\t</w:ftr>\n ";
|
|
1662
|
+
var generateDocumentTemplateFooterWithoutPaging = "\n <w:ftr\n xmlns:a=\"" + namespaces.a + "\"\n xmlns:cdr=\"" + namespaces.cdr + "\"\n xmlns:o=\"" + namespaces.o + "\"\n xmlns:pic=\"" + namespaces.pic + "\"\n xmlns:r=\"" + namespaces.r + "\"\n xmlns:v=\"" + namespaces.v + "\"\n xmlns:ve=\"" + namespaces.ve + "\"\n xmlns:vt=\"" + namespaces.vt + "\"\n xmlns:w=\"" + namespaces.w + "\"\n xmlns:w10=\"" + namespaces.w10 + "\"\n xmlns:wp=\"" + namespaces.wp + "\"\n >\n <w:altChunk r:id=\"htmlChunkFooter\" />\n\t</w:ftr>\n ";
|
|
1663
|
+
{ /* <w:altChunk r:id="htmlChunkFooter" /> */ }
|
|
1664
|
+
{
|
|
1665
|
+
/* <w:altChunk r:id="htmlChunkFooter" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" /> */
|
|
1666
|
+
}
|
|
1667
|
+
{
|
|
1668
|
+
/* <w:ftr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
1669
|
+
<fldSimple xmlns:ns2="http://schemas.openxmlformats.org/wordprocessingml/2006/main" ns2:instr="PAGE">
|
|
1670
|
+
</fldSimple>
|
|
1671
|
+
<w:altChunk r:id="htmlChunkFooter" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" />
|
|
1672
|
+
</w:ftr> */
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/* eslint-disable no-param-reassign */
|
|
1676
|
+
var rgbRegex = /rgb\((\d+),\s*([\d.]+),\s*([\d.]+)\)/i;
|
|
1677
|
+
var hslRegex = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/i;
|
|
1678
|
+
var hexRegex = /#([0-9A-F]{6})/i;
|
|
1679
|
+
var hex3Regex = /#([0-9A-F])([0-9A-F])([0-9A-F])/i;
|
|
1680
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1681
|
+
var rgbToHex = function (red, green, blue) {
|
|
1682
|
+
var hexColorCode = [red, green, blue]
|
|
1683
|
+
.map(function (x) {
|
|
1684
|
+
// eslint-disable-next-line radix, no-param-reassign
|
|
1685
|
+
x = parseInt(x).toString(16);
|
|
1686
|
+
return x.length === 1 ? "0" + x : x;
|
|
1687
|
+
})
|
|
1688
|
+
.join('');
|
|
1689
|
+
return hexColorCode;
|
|
1690
|
+
};
|
|
1691
|
+
var hslToHex = function (hue, saturation, luminosity) {
|
|
1692
|
+
hue /= 360;
|
|
1693
|
+
saturation /= 100;
|
|
1694
|
+
luminosity /= 100;
|
|
1695
|
+
// eslint-disable-next-line one-var
|
|
1696
|
+
var red, green, blue;
|
|
1697
|
+
if (saturation === 0) {
|
|
1698
|
+
// eslint-disable-next-line no-multi-assign
|
|
1699
|
+
red = green = blue = luminosity; // achromatic
|
|
1700
|
+
}
|
|
1701
|
+
else {
|
|
1702
|
+
var hue2rgb = function (p, q, t) {
|
|
1703
|
+
if (t < 0)
|
|
1704
|
+
t += 1;
|
|
1705
|
+
if (t > 1)
|
|
1706
|
+
t -= 1;
|
|
1707
|
+
if (t < 1 / 6)
|
|
1708
|
+
return p + (q - p) * 6 * t;
|
|
1709
|
+
if (t < 1 / 2)
|
|
1710
|
+
return q;
|
|
1711
|
+
if (t < 2 / 3)
|
|
1712
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
1713
|
+
return p;
|
|
1714
|
+
};
|
|
1715
|
+
var q = luminosity < 0.5
|
|
1716
|
+
? luminosity * (1 + saturation)
|
|
1717
|
+
: luminosity + saturation - luminosity * saturation;
|
|
1718
|
+
var p = 2 * luminosity - q;
|
|
1719
|
+
red = hue2rgb(p, q, hue + 1 / 3);
|
|
1720
|
+
green = hue2rgb(p, q, hue);
|
|
1721
|
+
blue = hue2rgb(p, q, hue - 1 / 3);
|
|
1722
|
+
}
|
|
1723
|
+
return [red, green, blue]
|
|
1724
|
+
.map(function (x) {
|
|
1725
|
+
var hex = Math.round(x * 255).toString(16);
|
|
1726
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
1727
|
+
})
|
|
1728
|
+
.join('');
|
|
1729
|
+
};
|
|
1730
|
+
var hex3ToHex = function (red, green, blue) {
|
|
1731
|
+
var hexColorCode = [red, green, blue].map(function (x) { return "" + x + x; }).join('');
|
|
1732
|
+
return hexColorCode;
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
var pixelRegex = /([\d.]+)px/i;
|
|
1736
|
+
var percentageRegex = /([\d.]+)%/i;
|
|
1737
|
+
var pointRegex = /([\d.]+)pt/i;
|
|
1738
|
+
var cmRegex = /([\d.]+)cm/i;
|
|
1739
|
+
var inchRegex = /([\d.]+)in/i;
|
|
1740
|
+
var pixelToEMU = function (pixelValue) { return Math.round(pixelValue * 9525); };
|
|
1741
|
+
var EMUToPixel = function (EMUValue) { return Math.round(EMUValue / 9525); };
|
|
1742
|
+
var TWIPToEMU = function (TWIPValue) { return Math.round(TWIPValue * 635); };
|
|
1743
|
+
var EMUToTWIP = function (EMUValue) { return Math.round(EMUValue / 635); };
|
|
1744
|
+
var pointToTWIP = function (pointValue) { return Math.round(pointValue * 20); };
|
|
1745
|
+
var TWIPToPoint = function (TWIPValue) { return Math.round(TWIPValue / 20); };
|
|
1746
|
+
var pointToHIP = function (pointValue) { return Math.round(pointValue * 2); };
|
|
1747
|
+
var HIPToPoint = function (HIPValue) { return Math.round(HIPValue / 2); };
|
|
1748
|
+
var HIPToTWIP = function (HIPValue) { return Math.round(HIPValue * 10); };
|
|
1749
|
+
var TWIPToHIP = function (TWIPValue) { return Math.round(TWIPValue / 10); };
|
|
1750
|
+
var pixelToTWIP = function (pixelValue) { return EMUToTWIP(pixelToEMU(pixelValue)); };
|
|
1751
|
+
var TWIPToPixel = function (TWIPValue) { return EMUToPixel(TWIPToEMU(TWIPValue)); };
|
|
1752
|
+
var pixelToHIP = function (pixelValue) { return TWIPToHIP(EMUToTWIP(pixelToEMU(pixelValue))); };
|
|
1753
|
+
var HIPToPixel = function (HIPValue) { return EMUToPixel(TWIPToEMU(HIPToTWIP(HIPValue))); };
|
|
1754
|
+
var inchToPoint = function (inchValue) { return Math.round(inchValue * 72); };
|
|
1755
|
+
var inchToTWIP = function (inchValue) { return pointToTWIP(inchToPoint(inchValue)); };
|
|
1756
|
+
var cmToInch = function (cmValue) { return cmValue * 0.3937008; };
|
|
1757
|
+
var cmToTWIP = function (cmValue) { return inchToTWIP(cmToInch(cmValue)); };
|
|
1758
|
+
var pixelToPoint = function (pixelValue) { return HIPToPoint(pixelToHIP(pixelValue)); };
|
|
1759
|
+
var pointToPixel = function (pointValue) { return HIPToPixel(pointToHIP(pointValue)); };
|
|
1760
|
+
var EIPToPoint = function (EIPValue) { return Math.round(EIPValue / 8); };
|
|
1761
|
+
var pointToEIP = function (PointValue) { return Math.round(PointValue * 8); };
|
|
1762
|
+
var pixelToEIP = function (pixelValue) { return pointToEIP(pixelToPoint(pixelValue)); };
|
|
1763
|
+
var EIPToPixel = function (EIPValue) { return pointToPixel(EIPToPoint(EIPValue)); };
|
|
1764
|
+
|
|
1765
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
1766
|
+
var vNodeHasChildren = function (vNode) { return vNode && vNode.children && Array.isArray(vNode.children) && vNode.children.length; };
|
|
1767
|
+
|
|
1768
|
+
var isValidUrl = function (urlString) {
|
|
1769
|
+
var urlRegex = /http(s)?:\/\/(\w+:?\w*@)?(\S+)(:\d+)?((?<=\.)\w+)+(\/([\w#!:.?+=&%@!\-/])*)?/gi;
|
|
1770
|
+
return Boolean(urlRegex.test(urlString));
|
|
1771
|
+
};
|
|
1772
|
+
var ɵ0$3 = isValidUrl;
|
|
1773
|
+
|
|
1774
|
+
// eslint-disable-next-line consistent-return
|
|
1775
|
+
var fixupColorCode = function (colorCodeString) {
|
|
1776
|
+
if (Object.prototype.hasOwnProperty.call(colorNames__default["default"], colorCodeString.toLowerCase())) {
|
|
1777
|
+
var _a = __read(colorNames__default["default"][colorCodeString.toLowerCase()], 3), red = _a[0], green = _a[1], blue = _a[2];
|
|
1778
|
+
return rgbToHex(red, green, blue);
|
|
1779
|
+
}
|
|
1780
|
+
else if (rgbRegex.test(colorCodeString)) {
|
|
1781
|
+
var matchedParts = colorCodeString.match(rgbRegex);
|
|
1782
|
+
var red = matchedParts[1];
|
|
1783
|
+
var green = matchedParts[2];
|
|
1784
|
+
var blue = matchedParts[3];
|
|
1785
|
+
return rgbToHex(red, green, blue);
|
|
1786
|
+
}
|
|
1787
|
+
else if (hslRegex.test(colorCodeString)) {
|
|
1788
|
+
var matchedParts = colorCodeString.match(hslRegex);
|
|
1789
|
+
var hue = matchedParts[1];
|
|
1790
|
+
var saturation = matchedParts[2];
|
|
1791
|
+
var luminosity = matchedParts[3];
|
|
1792
|
+
return hslToHex(hue, saturation, luminosity);
|
|
1793
|
+
}
|
|
1794
|
+
else if (hexRegex.test(colorCodeString)) {
|
|
1795
|
+
var matchedParts = colorCodeString.match(hexRegex);
|
|
1796
|
+
return matchedParts[1];
|
|
1797
|
+
}
|
|
1798
|
+
else if (hex3Regex.test(colorCodeString)) {
|
|
1799
|
+
var matchedParts = colorCodeString.match(hex3Regex);
|
|
1800
|
+
var red = matchedParts[1];
|
|
1801
|
+
var green = matchedParts[2];
|
|
1802
|
+
var blue = matchedParts[3];
|
|
1803
|
+
return hex3ToHex(red, green, blue);
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
return '000000';
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
var ɵ0$2 = fixupColorCode;
|
|
1810
|
+
var buildRunFontFragment = function (fontName) {
|
|
1811
|
+
if (fontName === void 0) { fontName = defaultFont; }
|
|
1812
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1813
|
+
.ele('@w', 'rFonts')
|
|
1814
|
+
.att('@w', 'ascii', fontName)
|
|
1815
|
+
.att('@w', 'hAnsi', fontName)
|
|
1816
|
+
.up();
|
|
1817
|
+
};
|
|
1818
|
+
var ɵ1$1 = buildRunFontFragment;
|
|
1819
|
+
var buildRunStyleFragment = function (type) {
|
|
1820
|
+
if (type === void 0) { type = 'Hyperlink'; }
|
|
1821
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1822
|
+
.ele('@w', 'rStyle')
|
|
1823
|
+
.att('@w', 'val', type)
|
|
1824
|
+
.up();
|
|
1825
|
+
};
|
|
1826
|
+
var ɵ2$1 = buildRunStyleFragment;
|
|
1827
|
+
var buildTableRowHeight = function (tableRowHeight) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1828
|
+
.ele('@w', 'trHeight')
|
|
1829
|
+
.att('@w', 'val', tableRowHeight)
|
|
1830
|
+
.att('@w', 'hRule', 'atLeast')
|
|
1831
|
+
.up(); };
|
|
1832
|
+
var ɵ3$1 = buildTableRowHeight;
|
|
1833
|
+
var buildVerticalAlignment = function (verticalAlignment) {
|
|
1834
|
+
if (verticalAlignment.toLowerCase() === 'middle') {
|
|
1835
|
+
verticalAlignment = 'center';
|
|
1836
|
+
}
|
|
1837
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1838
|
+
.ele('@w', 'vAlign')
|
|
1839
|
+
.att('@w', 'val', verticalAlignment)
|
|
1840
|
+
.up();
|
|
1841
|
+
};
|
|
1842
|
+
var ɵ4 = buildVerticalAlignment;
|
|
1843
|
+
var buildVerticalMerge = function (verticalMerge) {
|
|
1844
|
+
if (verticalMerge === void 0) { verticalMerge = 'continue'; }
|
|
1845
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1846
|
+
.ele('@w', 'vMerge')
|
|
1847
|
+
.att('@w', 'val', verticalMerge)
|
|
1848
|
+
.up();
|
|
1849
|
+
};
|
|
1850
|
+
var ɵ5 = buildVerticalMerge;
|
|
1851
|
+
var buildColor = function (colorCode) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1852
|
+
.ele('@w', 'color')
|
|
1853
|
+
.att('@w', 'val', colorCode)
|
|
1854
|
+
.up(); };
|
|
1855
|
+
var ɵ6 = buildColor;
|
|
1856
|
+
var buildFontSize = function (fontSize) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1857
|
+
.ele('@w', 'sz')
|
|
1858
|
+
.att('@w', 'val', fontSize)
|
|
1859
|
+
.up(); };
|
|
1860
|
+
var ɵ7 = buildFontSize;
|
|
1861
|
+
var buildShading = function (colorCode) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1862
|
+
.ele('@w', 'shd')
|
|
1863
|
+
.att('@w', 'val', 'clear')
|
|
1864
|
+
.att('@w', 'fill', colorCode)
|
|
1865
|
+
.up(); };
|
|
1866
|
+
var ɵ8 = buildShading;
|
|
1867
|
+
var buildHighlight = function (color) {
|
|
1868
|
+
if (color === void 0) { color = 'yellow'; }
|
|
1869
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1870
|
+
.ele('@w', 'highlight')
|
|
1871
|
+
.att('@w', 'val', color)
|
|
1872
|
+
.up();
|
|
1873
|
+
};
|
|
1874
|
+
var ɵ9 = buildHighlight;
|
|
1875
|
+
var buildVertAlign = function (type) {
|
|
1876
|
+
if (type === void 0) { type = 'baseline'; }
|
|
1877
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1878
|
+
.ele('@w', 'vertAlign')
|
|
1879
|
+
.att('@w', 'val', type)
|
|
1880
|
+
.up();
|
|
1881
|
+
};
|
|
1882
|
+
var ɵ10 = buildVertAlign;
|
|
1883
|
+
var buildStrike = function () { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1884
|
+
.ele('@w', 'strike')
|
|
1885
|
+
.att('@w', 'val', true)
|
|
1886
|
+
.up(); };
|
|
1887
|
+
var ɵ11 = buildStrike;
|
|
1888
|
+
var buildBold = function () { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1889
|
+
.ele('@w', 'b')
|
|
1890
|
+
.up(); };
|
|
1891
|
+
var ɵ12 = buildBold;
|
|
1892
|
+
var buildItalics = function () { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1893
|
+
.ele('@w', 'i')
|
|
1894
|
+
.up(); };
|
|
1895
|
+
var ɵ13 = buildItalics;
|
|
1896
|
+
var buildUnderline = function (type) {
|
|
1897
|
+
if (type === void 0) { type = 'single'; }
|
|
1898
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1899
|
+
.ele('@w', 'u')
|
|
1900
|
+
.att('@w', 'val', type)
|
|
1901
|
+
.up();
|
|
1902
|
+
};
|
|
1903
|
+
var ɵ14 = buildUnderline;
|
|
1904
|
+
var buildLineBreak = function (type) {
|
|
1905
|
+
if (type === void 0) { type = 'textWrapping'; }
|
|
1906
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1907
|
+
.ele('@w', 'br')
|
|
1908
|
+
.att('@w', 'type', type)
|
|
1909
|
+
.up();
|
|
1910
|
+
};
|
|
1911
|
+
var ɵ15 = buildLineBreak;
|
|
1912
|
+
var buildBorder = function (borderSide, borderSize, borderSpacing, borderColor, borderStroke) {
|
|
1913
|
+
if (borderSide === void 0) { borderSide = 'top'; }
|
|
1914
|
+
if (borderSize === void 0) { borderSize = 0; }
|
|
1915
|
+
if (borderSpacing === void 0) { borderSpacing = 0; }
|
|
1916
|
+
if (borderColor === void 0) { borderColor = fixupColorCode('black'); }
|
|
1917
|
+
if (borderStroke === void 0) { borderStroke = 'single'; }
|
|
1918
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1919
|
+
.ele('@w', borderSide)
|
|
1920
|
+
.att('@w', 'val', borderStroke)
|
|
1921
|
+
.att('@w', 'sz', borderSize)
|
|
1922
|
+
.att('@w', 'space', borderSpacing)
|
|
1923
|
+
.att('@w', 'color', borderColor)
|
|
1924
|
+
.up();
|
|
1925
|
+
};
|
|
1926
|
+
var ɵ16 = buildBorder;
|
|
1927
|
+
var buildTextElement = function (text) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
1928
|
+
.ele('@w', 't')
|
|
1929
|
+
.att('@xml', 'space', 'preserve')
|
|
1930
|
+
.txt(text)
|
|
1931
|
+
.up(); };
|
|
1932
|
+
var ɵ17 = buildTextElement;
|
|
1933
|
+
// eslint-disable-next-line consistent-return
|
|
1934
|
+
var fixupLineHeight = function (lineHeight, fontSize) {
|
|
1935
|
+
// FIXME: If line height is anything other than a number
|
|
1936
|
+
// eslint-disable-next-line no-restricted-globals
|
|
1937
|
+
if (!isNaN(lineHeight)) {
|
|
1938
|
+
if (fontSize) {
|
|
1939
|
+
var actualLineHeight = +lineHeight * fontSize;
|
|
1940
|
+
return HIPToTWIP(actualLineHeight);
|
|
1941
|
+
}
|
|
1942
|
+
else {
|
|
1943
|
+
// 240 TWIP or 12 point is default line height
|
|
1944
|
+
return +lineHeight * 240;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
else {
|
|
1948
|
+
// 240 TWIP or 12 point is default line height
|
|
1949
|
+
return 240;
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
var ɵ18 = fixupLineHeight;
|
|
1953
|
+
// eslint-disable-next-line consistent-return
|
|
1954
|
+
var fixupFontSize$1 = function (fontSizeString) {
|
|
1955
|
+
if (pointRegex.test(fontSizeString)) {
|
|
1956
|
+
var matchedParts = fontSizeString.match(pointRegex);
|
|
1957
|
+
// convert point to half point
|
|
1958
|
+
return pointToHIP(matchedParts[1]);
|
|
1959
|
+
}
|
|
1960
|
+
else if (pixelRegex.test(fontSizeString)) {
|
|
1961
|
+
var matchedParts = fontSizeString.match(pixelRegex);
|
|
1962
|
+
// convert pixels to half point
|
|
1963
|
+
return pixelToHIP(matchedParts[1]);
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
var ɵ19 = fixupFontSize$1;
|
|
1967
|
+
// eslint-disable-next-line consistent-return
|
|
1968
|
+
var fixupRowHeight = function (rowHeightString) {
|
|
1969
|
+
if (pointRegex.test(rowHeightString)) {
|
|
1970
|
+
var matchedParts = rowHeightString.match(pointRegex);
|
|
1971
|
+
// convert point to half point
|
|
1972
|
+
return pointToTWIP(matchedParts[1]);
|
|
1973
|
+
}
|
|
1974
|
+
else if (pixelRegex.test(rowHeightString)) {
|
|
1975
|
+
var matchedParts = rowHeightString.match(pixelRegex);
|
|
1976
|
+
// convert pixels to half point
|
|
1977
|
+
return pixelToTWIP(matchedParts[1]);
|
|
1978
|
+
}
|
|
1979
|
+
else if (cmRegex.test(rowHeightString)) {
|
|
1980
|
+
var matchedParts = rowHeightString.match(cmRegex);
|
|
1981
|
+
return cmToTWIP(matchedParts[1]);
|
|
1982
|
+
}
|
|
1983
|
+
else if (inchRegex.test(rowHeightString)) {
|
|
1984
|
+
var matchedParts = rowHeightString.match(inchRegex);
|
|
1985
|
+
return inchToTWIP(matchedParts[1]);
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
var ɵ20 = fixupRowHeight;
|
|
1989
|
+
// eslint-disable-next-line consistent-return
|
|
1990
|
+
var fixupColumnWidth = function (columnWidthString) {
|
|
1991
|
+
if (pointRegex.test(columnWidthString)) {
|
|
1992
|
+
var matchedParts = columnWidthString.match(pointRegex);
|
|
1993
|
+
return pointToTWIP(matchedParts[1]);
|
|
1994
|
+
}
|
|
1995
|
+
else if (pixelRegex.test(columnWidthString)) {
|
|
1996
|
+
var matchedParts = columnWidthString.match(pixelRegex);
|
|
1997
|
+
return pixelToTWIP(matchedParts[1]);
|
|
1998
|
+
}
|
|
1999
|
+
else if (cmRegex.test(columnWidthString)) {
|
|
2000
|
+
var matchedParts = columnWidthString.match(cmRegex);
|
|
2001
|
+
return cmToTWIP(matchedParts[1]);
|
|
2002
|
+
}
|
|
2003
|
+
else if (inchRegex.test(columnWidthString)) {
|
|
2004
|
+
var matchedParts = columnWidthString.match(inchRegex);
|
|
2005
|
+
return inchToTWIP(matchedParts[1]);
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
var ɵ21 = fixupColumnWidth;
|
|
2009
|
+
// eslint-disable-next-line consistent-return
|
|
2010
|
+
var fixupMargin = function (marginString) {
|
|
2011
|
+
if (pointRegex.test(marginString)) {
|
|
2012
|
+
var matchedParts = marginString.match(pointRegex);
|
|
2013
|
+
// convert point to half point
|
|
2014
|
+
return pointToTWIP(matchedParts[1]);
|
|
2015
|
+
}
|
|
2016
|
+
else if (pixelRegex.test(marginString)) {
|
|
2017
|
+
var matchedParts = marginString.match(pixelRegex);
|
|
2018
|
+
// convert pixels to half point
|
|
2019
|
+
return pixelToTWIP(matchedParts[1]);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
var ɵ22 = fixupMargin;
|
|
2023
|
+
var modifiedStyleAttributesBuilder = function (vNode, attributes, options) {
|
|
2024
|
+
var modifiedAttributes = Object.assign({}, attributes);
|
|
2025
|
+
// styles
|
|
2026
|
+
if (isVNode__default["default"](vNode) && vNode.properties && vNode.properties.style) {
|
|
2027
|
+
if (vNode.properties.style.color && !colorlessColors.includes(vNode.properties.style.color)) {
|
|
2028
|
+
modifiedAttributes.color = fixupColorCode(vNode.properties.style.color);
|
|
2029
|
+
}
|
|
2030
|
+
if (vNode.properties.style['background-color'] &&
|
|
2031
|
+
!colorlessColors.includes(vNode.properties.style['background-color'])) {
|
|
2032
|
+
modifiedAttributes.backgroundColor = fixupColorCode(vNode.properties.style['background-color']);
|
|
2033
|
+
}
|
|
2034
|
+
if (vNode.properties.style['vertical-align'] &&
|
|
2035
|
+
verticalAlignValues.includes(vNode.properties.style['vertical-align'])) {
|
|
2036
|
+
modifiedAttributes.verticalAlign = vNode.properties.style['vertical-align'];
|
|
2037
|
+
}
|
|
2038
|
+
if (vNode.properties.style['text-align'] &&
|
|
2039
|
+
['left', 'right', 'center', 'justify'].includes(vNode.properties.style['text-align'])) {
|
|
2040
|
+
modifiedAttributes.textAlign = vNode.properties.style['text-align'];
|
|
2041
|
+
}
|
|
2042
|
+
// FIXME: remove bold check when other font weights are handled.
|
|
2043
|
+
if (vNode.properties.style['font-weight'] && vNode.properties.style['font-weight'] === 'bold') {
|
|
2044
|
+
modifiedAttributes.strong = vNode.properties.style['font-weight'];
|
|
2045
|
+
}
|
|
2046
|
+
if (vNode.properties.style['font-size']) {
|
|
2047
|
+
modifiedAttributes.fontSize = fixupFontSize$1(vNode.properties.style['font-size']);
|
|
2048
|
+
}
|
|
2049
|
+
if (vNode.properties.style['line-height']) {
|
|
2050
|
+
modifiedAttributes.lineHeight = fixupLineHeight(vNode.properties.style['line-height'], vNode.properties.style['font-size']
|
|
2051
|
+
? fixupFontSize$1(vNode.properties.style['font-size'])
|
|
2052
|
+
: null);
|
|
2053
|
+
}
|
|
2054
|
+
if (vNode.properties.style['margin-left'] || vNode.properties.style['margin-right']) {
|
|
2055
|
+
var leftMargin = fixupMargin(vNode.properties.style['margin-left']);
|
|
2056
|
+
var rightMargin = fixupMargin(vNode.properties.style['margin-right']);
|
|
2057
|
+
var indentation = {};
|
|
2058
|
+
if (leftMargin) {
|
|
2059
|
+
indentation.left = leftMargin;
|
|
2060
|
+
}
|
|
2061
|
+
if (rightMargin) {
|
|
2062
|
+
indentation.right = rightMargin;
|
|
2063
|
+
}
|
|
2064
|
+
if (leftMargin || rightMargin) {
|
|
2065
|
+
modifiedAttributes.indentation = indentation;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
if (vNode.properties.style.display) {
|
|
2069
|
+
modifiedAttributes.display = vNode.properties.style.display;
|
|
2070
|
+
}
|
|
2071
|
+
if (vNode.properties.style.width) {
|
|
2072
|
+
modifiedAttributes.width = vNode.properties.style.width;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
// paragraph only
|
|
2076
|
+
if (options && options.isParagraph) {
|
|
2077
|
+
if (isVNode__default["default"](vNode) && vNode.tagName === 'blockquote') {
|
|
2078
|
+
modifiedAttributes.indentation = { left: 284 };
|
|
2079
|
+
modifiedAttributes.textAlign = 'justify';
|
|
2080
|
+
}
|
|
2081
|
+
else if (isVNode__default["default"](vNode) && vNode.tagName === 'code') {
|
|
2082
|
+
modifiedAttributes.highlightColor = 'lightGray';
|
|
2083
|
+
}
|
|
2084
|
+
else if (isVNode__default["default"](vNode) && vNode.tagName === 'pre') {
|
|
2085
|
+
modifiedAttributes.font = 'Courier';
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
return modifiedAttributes;
|
|
2089
|
+
};
|
|
2090
|
+
var ɵ23 = modifiedStyleAttributesBuilder;
|
|
2091
|
+
// html tag to formatting function
|
|
2092
|
+
// options are passed to the formatting function if needed
|
|
2093
|
+
var buildFormatting = function (htmlTag, options) {
|
|
2094
|
+
switch (htmlTag) {
|
|
2095
|
+
case 'strong':
|
|
2096
|
+
case 'b':
|
|
2097
|
+
return buildBold();
|
|
2098
|
+
case 'em':
|
|
2099
|
+
case 'i':
|
|
2100
|
+
return buildItalics();
|
|
2101
|
+
case 'ins':
|
|
2102
|
+
case 'u':
|
|
2103
|
+
return buildUnderline();
|
|
2104
|
+
case 'strike':
|
|
2105
|
+
case 'del':
|
|
2106
|
+
case 's':
|
|
2107
|
+
return buildStrike();
|
|
2108
|
+
case 'sub':
|
|
2109
|
+
return buildVertAlign('subscript');
|
|
2110
|
+
case 'sup':
|
|
2111
|
+
return buildVertAlign('superscript');
|
|
2112
|
+
case 'mark':
|
|
2113
|
+
return buildHighlight();
|
|
2114
|
+
case 'code':
|
|
2115
|
+
return buildHighlight('lightGray');
|
|
2116
|
+
case 'highlightColor':
|
|
2117
|
+
return buildHighlight(options && options.color ? options.color : 'lightGray');
|
|
2118
|
+
case 'font':
|
|
2119
|
+
case 'pre':
|
|
2120
|
+
return buildRunFontFragment('Courier');
|
|
2121
|
+
case 'color':
|
|
2122
|
+
return buildColor(options && options.color ? options.color : 'black');
|
|
2123
|
+
case 'backgroundColor':
|
|
2124
|
+
return buildShading(options && options.color ? options.color : 'black');
|
|
2125
|
+
case 'fontSize':
|
|
2126
|
+
// does this need a unit of measure?
|
|
2127
|
+
return buildFontSize(options && options.fontSize ? options.fontSize : 10);
|
|
2128
|
+
case 'hyperlink':
|
|
2129
|
+
return buildRunStyleFragment('Hyperlink');
|
|
2130
|
+
}
|
|
2131
|
+
return null;
|
|
2132
|
+
};
|
|
2133
|
+
var ɵ24 = buildFormatting;
|
|
2134
|
+
var buildRunProperties = function (attributes) {
|
|
2135
|
+
var runPropertiesFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'rPr');
|
|
2136
|
+
if (attributes && attributes.constructor === Object) {
|
|
2137
|
+
Object.keys(attributes).forEach(function (key) {
|
|
2138
|
+
var options = {};
|
|
2139
|
+
if (key === 'color' || key === 'backgroundColor' || key === 'highlightColor') {
|
|
2140
|
+
options.color = attributes[key];
|
|
2141
|
+
}
|
|
2142
|
+
if (key === 'fontSize') {
|
|
2143
|
+
options.fontSize = attributes[key];
|
|
2144
|
+
}
|
|
2145
|
+
var formattingFragment = buildFormatting(key, options);
|
|
2146
|
+
if (formattingFragment) {
|
|
2147
|
+
runPropertiesFragment.import(formattingFragment);
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
runPropertiesFragment.up();
|
|
2152
|
+
return runPropertiesFragment;
|
|
2153
|
+
};
|
|
2154
|
+
var ɵ25 = buildRunProperties;
|
|
2155
|
+
var buildRun = function (vNode, attributes, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2156
|
+
var runFragment, runPropertiesFragment, runFragmentsArray, vNodes, tempAttributes, tempRunFragment, tempVNode, textFragment, tempRunPropertiesFragment, formattingFragment, spanFragment, textFragment, response, base64Uri, documentRelsId, type, inlineOrAnchored, otherAttributes, imageFragment, lineBreakFragment;
|
|
2157
|
+
return __generator(this, function (_a) {
|
|
2158
|
+
switch (_a.label) {
|
|
2159
|
+
case 0:
|
|
2160
|
+
runFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'r');
|
|
2161
|
+
runPropertiesFragment = buildRunProperties(lodash.cloneDeep(attributes));
|
|
2162
|
+
// case where we have recursive spans representing font changes
|
|
2163
|
+
if (isVNode__default["default"](vNode) && vNode.tagName === 'span') {
|
|
2164
|
+
// eslint-disable-next-line no-use-before-define
|
|
2165
|
+
return [2 /*return*/, buildRunOrRuns(vNode, attributes, docxDocumentInstance)];
|
|
2166
|
+
}
|
|
2167
|
+
if (!(isVNode__default["default"](vNode) &&
|
|
2168
|
+
[
|
|
2169
|
+
'strong',
|
|
2170
|
+
'b',
|
|
2171
|
+
'em',
|
|
2172
|
+
'i',
|
|
2173
|
+
'u',
|
|
2174
|
+
'ins',
|
|
2175
|
+
'strike',
|
|
2176
|
+
'del',
|
|
2177
|
+
's',
|
|
2178
|
+
'sub',
|
|
2179
|
+
'sup',
|
|
2180
|
+
'mark',
|
|
2181
|
+
'blockquote',
|
|
2182
|
+
'code',
|
|
2183
|
+
'pre',
|
|
2184
|
+
].includes(vNode.tagName))) return [3 /*break*/, 7];
|
|
2185
|
+
runFragmentsArray = [];
|
|
2186
|
+
vNodes = [vNode];
|
|
2187
|
+
tempAttributes = lodash.cloneDeep(attributes);
|
|
2188
|
+
tempRunFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'r');
|
|
2189
|
+
_a.label = 1;
|
|
2190
|
+
case 1:
|
|
2191
|
+
if (!vNodes.length) return [3 /*break*/, 6];
|
|
2192
|
+
tempVNode = vNodes.shift();
|
|
2193
|
+
if (!isVText__default["default"](tempVNode)) return [3 /*break*/, 2];
|
|
2194
|
+
textFragment = buildTextElement(tempVNode.text);
|
|
2195
|
+
tempRunPropertiesFragment = buildRunProperties(Object.assign(Object.assign({}, attributes), tempAttributes));
|
|
2196
|
+
tempRunFragment.import(tempRunPropertiesFragment);
|
|
2197
|
+
tempRunFragment.import(textFragment);
|
|
2198
|
+
runFragmentsArray.push(tempRunFragment);
|
|
2199
|
+
// re initialize temp run fragments with new fragment
|
|
2200
|
+
tempAttributes = lodash.cloneDeep(attributes);
|
|
2201
|
+
tempRunFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'r');
|
|
2202
|
+
return [3 /*break*/, 5];
|
|
2203
|
+
case 2:
|
|
2204
|
+
if (!isVNode__default["default"](tempVNode)) return [3 /*break*/, 5];
|
|
2205
|
+
if (![
|
|
2206
|
+
'strong',
|
|
2207
|
+
'b',
|
|
2208
|
+
'em',
|
|
2209
|
+
'i',
|
|
2210
|
+
'u',
|
|
2211
|
+
'ins',
|
|
2212
|
+
'strike',
|
|
2213
|
+
'del',
|
|
2214
|
+
's',
|
|
2215
|
+
'sub',
|
|
2216
|
+
'sup',
|
|
2217
|
+
'mark',
|
|
2218
|
+
'code',
|
|
2219
|
+
'pre',
|
|
2220
|
+
].includes(tempVNode.tagName)) return [3 /*break*/, 3];
|
|
2221
|
+
tempAttributes = {};
|
|
2222
|
+
switch (tempVNode.tagName) {
|
|
2223
|
+
case 'strong':
|
|
2224
|
+
case 'b':
|
|
2225
|
+
tempAttributes.strong = true;
|
|
2226
|
+
break;
|
|
2227
|
+
case 'i':
|
|
2228
|
+
tempAttributes.i = true;
|
|
2229
|
+
break;
|
|
2230
|
+
case 'u':
|
|
2231
|
+
tempAttributes.u = true;
|
|
2232
|
+
break;
|
|
2233
|
+
case 'sub':
|
|
2234
|
+
tempAttributes.sub = true;
|
|
2235
|
+
break;
|
|
2236
|
+
case 'sup':
|
|
2237
|
+
tempAttributes.sup = true;
|
|
2238
|
+
break;
|
|
2239
|
+
}
|
|
2240
|
+
formattingFragment = buildFormatting(tempVNode);
|
|
2241
|
+
if (formattingFragment) {
|
|
2242
|
+
runPropertiesFragment.import(formattingFragment);
|
|
2243
|
+
}
|
|
2244
|
+
return [3 /*break*/, 5];
|
|
2245
|
+
case 3:
|
|
2246
|
+
if (!(tempVNode.tagName === 'span')) return [3 /*break*/, 5];
|
|
2247
|
+
return [4 /*yield*/, buildRunOrRuns(tempVNode, Object.assign(Object.assign({}, attributes), tempAttributes), docxDocumentInstance)];
|
|
2248
|
+
case 4:
|
|
2249
|
+
spanFragment = _a.sent();
|
|
2250
|
+
// if spanFragment is an array, we need to add each fragment to the runFragmentsArray. If the fragment is an array, perform a depth first search on the array to add each fragment to the runFragmentsArray
|
|
2251
|
+
if (Array.isArray(spanFragment)) {
|
|
2252
|
+
spanFragment.flat(Infinity);
|
|
2253
|
+
runFragmentsArray.push.apply(runFragmentsArray, __spreadArray([], __read(spanFragment)));
|
|
2254
|
+
}
|
|
2255
|
+
else {
|
|
2256
|
+
runFragmentsArray.push(spanFragment);
|
|
2257
|
+
}
|
|
2258
|
+
// do not slice and concat children since this is already accounted for in the buildRunOrRuns function
|
|
2259
|
+
// eslint-disable-next-line no-continue
|
|
2260
|
+
return [3 /*break*/, 1];
|
|
2261
|
+
case 5:
|
|
2262
|
+
if (tempVNode.children && tempVNode.children.length) {
|
|
2263
|
+
if (tempVNode.children.length > 1) {
|
|
2264
|
+
attributes = Object.assign(Object.assign({}, attributes), tempAttributes);
|
|
2265
|
+
}
|
|
2266
|
+
vNodes = tempVNode.children.slice().concat(vNodes);
|
|
2267
|
+
}
|
|
2268
|
+
return [3 /*break*/, 1];
|
|
2269
|
+
case 6:
|
|
2270
|
+
if (runFragmentsArray.length) {
|
|
2271
|
+
return [2 /*return*/, runFragmentsArray];
|
|
2272
|
+
}
|
|
2273
|
+
_a.label = 7;
|
|
2274
|
+
case 7:
|
|
2275
|
+
runFragment.import(runPropertiesFragment);
|
|
2276
|
+
if (isVText__default["default"](vNode)) {
|
|
2277
|
+
textFragment = buildTextElement(vNode.text);
|
|
2278
|
+
runFragment.import(textFragment);
|
|
2279
|
+
}
|
|
2280
|
+
else if (attributes && attributes.type === 'picture') {
|
|
2281
|
+
response = null;
|
|
2282
|
+
base64Uri = decodeURIComponent(vNode.properties.src);
|
|
2283
|
+
if (base64Uri) {
|
|
2284
|
+
response = docxDocumentInstance.createMediaFile(base64Uri);
|
|
2285
|
+
}
|
|
2286
|
+
if (response) {
|
|
2287
|
+
docxDocumentInstance.zip
|
|
2288
|
+
.folder('word')
|
|
2289
|
+
.folder('media')
|
|
2290
|
+
.file(response.fileNameWithExtension, Buffer.from(response.fileContent, 'base64'), {
|
|
2291
|
+
createFolders: false,
|
|
2292
|
+
});
|
|
2293
|
+
documentRelsId = docxDocumentInstance.createDocumentRelationships(docxDocumentInstance.relationshipFilename, imageType, "media/" + response.fileNameWithExtension, internalRelationship);
|
|
2294
|
+
attributes.inlineOrAnchored = true;
|
|
2295
|
+
attributes.relationshipId = documentRelsId;
|
|
2296
|
+
attributes.id = response.id;
|
|
2297
|
+
attributes.fileContent = response.fileContent;
|
|
2298
|
+
attributes.fileNameWithExtension = response.fileNameWithExtension;
|
|
2299
|
+
}
|
|
2300
|
+
type = attributes.type, inlineOrAnchored = attributes.inlineOrAnchored, otherAttributes = __rest(attributes, ["type", "inlineOrAnchored"]);
|
|
2301
|
+
imageFragment = buildDrawing(inlineOrAnchored, type, otherAttributes);
|
|
2302
|
+
runFragment.import(imageFragment);
|
|
2303
|
+
}
|
|
2304
|
+
else if (isVNode__default["default"](vNode) && vNode.tagName === 'br') {
|
|
2305
|
+
lineBreakFragment = buildLineBreak();
|
|
2306
|
+
runFragment.import(lineBreakFragment);
|
|
2307
|
+
}
|
|
2308
|
+
runFragment.up();
|
|
2309
|
+
return [2 /*return*/, runFragment];
|
|
2310
|
+
}
|
|
2311
|
+
});
|
|
2312
|
+
}); };
|
|
2313
|
+
var ɵ26 = buildRun;
|
|
2314
|
+
var buildRunOrRuns = function (vNode, attributes, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2315
|
+
var runFragments, index, childVNode, modifiedAttributes, tempRunFragments, tempRunFragments;
|
|
2316
|
+
return __generator(this, function (_a) {
|
|
2317
|
+
switch (_a.label) {
|
|
2318
|
+
case 0:
|
|
2319
|
+
if (!(isVNode__default["default"](vNode) && vNode.tagName === 'span')) return [3 /*break*/, 5];
|
|
2320
|
+
runFragments = [];
|
|
2321
|
+
index = 0;
|
|
2322
|
+
_a.label = 1;
|
|
2323
|
+
case 1:
|
|
2324
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 4];
|
|
2325
|
+
childVNode = vNode.children[index];
|
|
2326
|
+
modifiedAttributes = modifiedStyleAttributesBuilder(vNode, attributes);
|
|
2327
|
+
return [4 /*yield*/, buildRun(childVNode, modifiedAttributes, docxDocumentInstance)];
|
|
2328
|
+
case 2:
|
|
2329
|
+
tempRunFragments = _a.sent();
|
|
2330
|
+
runFragments = runFragments.concat(Array.isArray(tempRunFragments) ? tempRunFragments : [tempRunFragments]);
|
|
2331
|
+
_a.label = 3;
|
|
2332
|
+
case 3:
|
|
2333
|
+
index++;
|
|
2334
|
+
return [3 /*break*/, 1];
|
|
2335
|
+
case 4: return [2 /*return*/, runFragments];
|
|
2336
|
+
case 5: return [4 /*yield*/, buildRun(vNode, attributes, docxDocumentInstance)];
|
|
2337
|
+
case 6:
|
|
2338
|
+
tempRunFragments = _a.sent();
|
|
2339
|
+
return [2 /*return*/, tempRunFragments];
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2342
|
+
}); };
|
|
2343
|
+
var ɵ27 = buildRunOrRuns;
|
|
2344
|
+
var buildRunOrHyperLink = function (vNode, attributes, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2345
|
+
var relationshipId, hyperlinkFragment, modifiedAttributes, runFragments_1, index, runFragment, runFragments;
|
|
2346
|
+
return __generator(this, function (_a) {
|
|
2347
|
+
switch (_a.label) {
|
|
2348
|
+
case 0:
|
|
2349
|
+
if (!(isVNode__default["default"](vNode) && vNode.tagName === 'a')) return [3 /*break*/, 2];
|
|
2350
|
+
relationshipId = docxDocumentInstance.createDocumentRelationships(docxDocumentInstance.relationshipFilename, hyperlinkType, vNode.properties && vNode.properties.href ? vNode.properties.href : '');
|
|
2351
|
+
hyperlinkFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w, r: namespaces.r } })
|
|
2352
|
+
.ele('@w', 'hyperlink')
|
|
2353
|
+
.att('@r', 'id', "rId" + relationshipId);
|
|
2354
|
+
modifiedAttributes = Object.assign({}, attributes);
|
|
2355
|
+
modifiedAttributes.hyperlink = true;
|
|
2356
|
+
return [4 /*yield*/, buildRunOrRuns(vNode.children[0], modifiedAttributes, docxDocumentInstance)];
|
|
2357
|
+
case 1:
|
|
2358
|
+
runFragments_1 = _a.sent();
|
|
2359
|
+
if (Array.isArray(runFragments_1)) {
|
|
2360
|
+
for (index = 0; index < runFragments_1.length; index++) {
|
|
2361
|
+
runFragment = runFragments_1[index];
|
|
2362
|
+
hyperlinkFragment.import(runFragment);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
else {
|
|
2366
|
+
hyperlinkFragment.import(runFragments_1);
|
|
2367
|
+
}
|
|
2368
|
+
hyperlinkFragment.up();
|
|
2369
|
+
return [2 /*return*/, hyperlinkFragment];
|
|
2370
|
+
case 2: return [4 /*yield*/, buildRunOrRuns(vNode, attributes, docxDocumentInstance)];
|
|
2371
|
+
case 3:
|
|
2372
|
+
runFragments = _a.sent();
|
|
2373
|
+
return [2 /*return*/, runFragments];
|
|
2374
|
+
}
|
|
2375
|
+
});
|
|
2376
|
+
}); };
|
|
2377
|
+
var ɵ28 = buildRunOrHyperLink;
|
|
2378
|
+
var buildNumberingProperties = function (levelId, numberingId) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2379
|
+
.ele('@w', 'numPr')
|
|
2380
|
+
.ele('@w', 'ilvl')
|
|
2381
|
+
.att('@w', 'val', String(levelId))
|
|
2382
|
+
.up()
|
|
2383
|
+
.ele('@w', 'numId')
|
|
2384
|
+
.att('@w', 'val', String(numberingId))
|
|
2385
|
+
.up()
|
|
2386
|
+
.up(); };
|
|
2387
|
+
var ɵ29 = buildNumberingProperties;
|
|
2388
|
+
var buildNumberingInstances = function () { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2389
|
+
.ele('@w', 'num')
|
|
2390
|
+
.ele('@w', 'abstractNumId')
|
|
2391
|
+
.up()
|
|
2392
|
+
.up(); };
|
|
2393
|
+
var ɵ30 = buildNumberingInstances;
|
|
2394
|
+
var buildSpacing = function (lineSpacing, beforeSpacing, afterSpacing) {
|
|
2395
|
+
var spacingFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'spacing');
|
|
2396
|
+
if (lineSpacing) {
|
|
2397
|
+
spacingFragment.att('@w', 'line', lineSpacing);
|
|
2398
|
+
}
|
|
2399
|
+
if (beforeSpacing) {
|
|
2400
|
+
spacingFragment.att('@w', 'before', beforeSpacing);
|
|
2401
|
+
}
|
|
2402
|
+
if (afterSpacing) {
|
|
2403
|
+
spacingFragment.att('@w', 'after', afterSpacing);
|
|
2404
|
+
}
|
|
2405
|
+
spacingFragment.att('@w', 'lineRule', 'auto').up();
|
|
2406
|
+
return spacingFragment;
|
|
2407
|
+
};
|
|
2408
|
+
var ɵ31 = buildSpacing;
|
|
2409
|
+
var buildIndentation = function (_a) {
|
|
2410
|
+
var left = _a.left, right = _a.right;
|
|
2411
|
+
var indentationFragment = xmlbuilder2.fragment({
|
|
2412
|
+
namespaceAlias: { w: namespaces.w },
|
|
2413
|
+
}).ele('@w', 'ind');
|
|
2414
|
+
if (left) {
|
|
2415
|
+
indentationFragment.att('@w', 'left', left);
|
|
2416
|
+
}
|
|
2417
|
+
if (right) {
|
|
2418
|
+
indentationFragment.att('@w', 'right', right);
|
|
2419
|
+
}
|
|
2420
|
+
indentationFragment.up();
|
|
2421
|
+
return indentationFragment;
|
|
2422
|
+
};
|
|
2423
|
+
var ɵ32 = buildIndentation;
|
|
2424
|
+
var buildPStyle = function (style) {
|
|
2425
|
+
if (style === void 0) { style = 'Normal'; }
|
|
2426
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2427
|
+
.ele('@w', 'pStyle')
|
|
2428
|
+
.att('@w', 'val', style)
|
|
2429
|
+
.up();
|
|
2430
|
+
};
|
|
2431
|
+
var ɵ33 = buildPStyle;
|
|
2432
|
+
var buildHorizontalAlignment = function (horizontalAlignment) {
|
|
2433
|
+
if (horizontalAlignment === 'justify') {
|
|
2434
|
+
horizontalAlignment = 'both';
|
|
2435
|
+
}
|
|
2436
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2437
|
+
.ele('@w', 'jc')
|
|
2438
|
+
.att('@w', 'val', horizontalAlignment)
|
|
2439
|
+
.up();
|
|
2440
|
+
};
|
|
2441
|
+
var ɵ34 = buildHorizontalAlignment;
|
|
2442
|
+
var buildParagraphBorder = function () {
|
|
2443
|
+
var paragraphBorderFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'pBdr');
|
|
2444
|
+
var bordersObject = lodash.cloneDeep(paragraphBordersObject);
|
|
2445
|
+
Object.keys(bordersObject).forEach(function (borderName) {
|
|
2446
|
+
if (bordersObject[borderName]) {
|
|
2447
|
+
var _a = bordersObject[borderName], size = _a.size, spacing = _a.spacing, color = _a.color;
|
|
2448
|
+
var borderFragment = buildBorder(borderName, size, spacing, color);
|
|
2449
|
+
paragraphBorderFragment.import(borderFragment);
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
paragraphBorderFragment.up();
|
|
2453
|
+
return paragraphBorderFragment;
|
|
2454
|
+
};
|
|
2455
|
+
var ɵ35 = buildParagraphBorder;
|
|
2456
|
+
var buildParagraphProperties = function (attributes) {
|
|
2457
|
+
var paragraphPropertiesFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'pPr');
|
|
2458
|
+
if (attributes && attributes.constructor === Object) {
|
|
2459
|
+
Object.keys(attributes).forEach(function (key) {
|
|
2460
|
+
switch (key) {
|
|
2461
|
+
case 'numbering':
|
|
2462
|
+
var _a = attributes[key], levelId = _a.levelId, numberingId = _a.numberingId;
|
|
2463
|
+
var numberingPropertiesFragment = buildNumberingProperties(levelId, numberingId);
|
|
2464
|
+
paragraphPropertiesFragment.import(numberingPropertiesFragment);
|
|
2465
|
+
// eslint-disable-next-line no-param-reassign
|
|
2466
|
+
delete attributes.numbering;
|
|
2467
|
+
break;
|
|
2468
|
+
case 'textAlign':
|
|
2469
|
+
var horizontalAlignmentFragment = buildHorizontalAlignment(attributes[key]);
|
|
2470
|
+
paragraphPropertiesFragment.import(horizontalAlignmentFragment);
|
|
2471
|
+
// eslint-disable-next-line no-param-reassign
|
|
2472
|
+
delete attributes.textAlign;
|
|
2473
|
+
break;
|
|
2474
|
+
case 'backgroundColor':
|
|
2475
|
+
// Add shading to Paragraph Properties only if display is block
|
|
2476
|
+
// Essentially if background color needs to be across the row
|
|
2477
|
+
if (attributes.display === 'block') {
|
|
2478
|
+
var shadingFragment = buildShading(attributes[key]);
|
|
2479
|
+
paragraphPropertiesFragment.import(shadingFragment);
|
|
2480
|
+
// FIXME: Inner padding in case of shaded paragraphs.
|
|
2481
|
+
var paragraphBorderFragment = buildParagraphBorder();
|
|
2482
|
+
paragraphPropertiesFragment.import(paragraphBorderFragment);
|
|
2483
|
+
// eslint-disable-next-line no-param-reassign
|
|
2484
|
+
delete attributes.backgroundColor;
|
|
2485
|
+
}
|
|
2486
|
+
break;
|
|
2487
|
+
case 'paragraphStyle':
|
|
2488
|
+
var pStyleFragment = buildPStyle(attributes.paragraphStyle);
|
|
2489
|
+
paragraphPropertiesFragment.import(pStyleFragment);
|
|
2490
|
+
delete attributes.paragraphStyle;
|
|
2491
|
+
break;
|
|
2492
|
+
case 'indentation':
|
|
2493
|
+
var indentationFragment = buildIndentation(attributes[key]);
|
|
2494
|
+
paragraphPropertiesFragment.import(indentationFragment);
|
|
2495
|
+
// eslint-disable-next-line no-param-reassign
|
|
2496
|
+
delete attributes.indentation;
|
|
2497
|
+
break;
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
var spacingFragment = buildSpacing(attributes.lineHeight, attributes.beforeSpacing, attributes.afterSpacing);
|
|
2501
|
+
// eslint-disable-next-line no-param-reassign
|
|
2502
|
+
delete attributes.lineHeight;
|
|
2503
|
+
// eslint-disable-next-line no-param-reassign
|
|
2504
|
+
delete attributes.beforeSpacing;
|
|
2505
|
+
// eslint-disable-next-line no-param-reassign
|
|
2506
|
+
delete attributes.afterSpacing;
|
|
2507
|
+
paragraphPropertiesFragment.import(spacingFragment);
|
|
2508
|
+
}
|
|
2509
|
+
paragraphPropertiesFragment.up();
|
|
2510
|
+
return paragraphPropertiesFragment;
|
|
2511
|
+
};
|
|
2512
|
+
var ɵ36 = buildParagraphProperties;
|
|
2513
|
+
var computeImageDimensions = function (vNode, attributes) {
|
|
2514
|
+
var maximumWidth = attributes.maximumWidth, originalWidth = attributes.originalWidth, originalHeight = attributes.originalHeight;
|
|
2515
|
+
var aspectRatio = originalWidth / originalHeight;
|
|
2516
|
+
var maximumWidthInEMU = TWIPToEMU(maximumWidth);
|
|
2517
|
+
var originalWidthInEMU = pixelToEMU(originalWidth);
|
|
2518
|
+
var originalHeightInEMU = pixelToEMU(originalHeight);
|
|
2519
|
+
if (originalWidthInEMU > maximumWidthInEMU) {
|
|
2520
|
+
originalWidthInEMU = maximumWidthInEMU;
|
|
2521
|
+
originalHeightInEMU = Math.round(originalWidthInEMU / aspectRatio);
|
|
2522
|
+
}
|
|
2523
|
+
var modifiedHeight;
|
|
2524
|
+
var modifiedWidth;
|
|
2525
|
+
if (vNode.properties && vNode.properties.style) {
|
|
2526
|
+
if (vNode.properties.style.width) {
|
|
2527
|
+
if (vNode.properties.style.width !== 'auto') {
|
|
2528
|
+
if (pixelRegex.test(vNode.properties.style.width)) {
|
|
2529
|
+
modifiedWidth = pixelToEMU(vNode.properties.style.width.match(pixelRegex)[1]);
|
|
2530
|
+
}
|
|
2531
|
+
else if (percentageRegex.test(vNode.properties.style.width)) {
|
|
2532
|
+
var percentageValue = vNode.properties.style.width.match(percentageRegex)[1];
|
|
2533
|
+
modifiedWidth = Math.round((percentageValue / 100) * originalWidthInEMU);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
else {
|
|
2537
|
+
// eslint-disable-next-line no-lonely-if
|
|
2538
|
+
if (vNode.properties.style.height && vNode.properties.style.height === 'auto') {
|
|
2539
|
+
modifiedWidth = originalWidthInEMU;
|
|
2540
|
+
modifiedHeight = originalHeightInEMU;
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
if (vNode.properties.style.height) {
|
|
2545
|
+
if (vNode.properties.style.height !== 'auto') {
|
|
2546
|
+
if (pixelRegex.test(vNode.properties.style.height)) {
|
|
2547
|
+
modifiedHeight = pixelToEMU(vNode.properties.style.height.match(pixelRegex)[1]);
|
|
2548
|
+
}
|
|
2549
|
+
else if (percentageRegex.test(vNode.properties.style.height)) {
|
|
2550
|
+
var percentageValue = vNode.properties.style.width.match(percentageRegex)[1];
|
|
2551
|
+
modifiedHeight = Math.round((percentageValue / 100) * originalHeightInEMU);
|
|
2552
|
+
if (!modifiedWidth) {
|
|
2553
|
+
modifiedWidth = Math.round(modifiedHeight * aspectRatio);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
else {
|
|
2558
|
+
// eslint-disable-next-line no-lonely-if
|
|
2559
|
+
if (modifiedWidth) {
|
|
2560
|
+
if (!modifiedHeight) {
|
|
2561
|
+
modifiedHeight = Math.round(modifiedWidth / aspectRatio);
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
else {
|
|
2565
|
+
modifiedHeight = originalHeightInEMU;
|
|
2566
|
+
modifiedWidth = originalWidthInEMU;
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
if (modifiedWidth && !modifiedHeight) {
|
|
2571
|
+
modifiedHeight = Math.round(modifiedWidth / aspectRatio);
|
|
2572
|
+
}
|
|
2573
|
+
else if (modifiedHeight && !modifiedWidth) {
|
|
2574
|
+
modifiedWidth = Math.round(modifiedHeight * aspectRatio);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
else {
|
|
2578
|
+
modifiedWidth = originalWidthInEMU;
|
|
2579
|
+
modifiedHeight = originalHeightInEMU;
|
|
2580
|
+
}
|
|
2581
|
+
// eslint-disable-next-line no-param-reassign
|
|
2582
|
+
attributes.width = modifiedWidth;
|
|
2583
|
+
// eslint-disable-next-line no-param-reassign
|
|
2584
|
+
attributes.height = modifiedHeight;
|
|
2585
|
+
};
|
|
2586
|
+
var ɵ37 = computeImageDimensions;
|
|
2587
|
+
var buildParagraph = function (vNode, attributes, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2588
|
+
var paragraphFragment, modifiedAttributes, paragraphPropertiesFragment, runOrHyperlinkFragments, iteratorIndex, runOrHyperlinkFragment, runFragmentOrFragments, index, index, childVNode, base64String, imageSource, imageBuffer, imageProperties, runOrHyperlinkFragments, iteratorIndex, runOrHyperlinkFragment, imageSource, base64String, imageBuffer, imageProperties, runFragments, index, runFragment;
|
|
2589
|
+
return __generator(this, function (_a) {
|
|
2590
|
+
switch (_a.label) {
|
|
2591
|
+
case 0:
|
|
2592
|
+
paragraphFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'p');
|
|
2593
|
+
modifiedAttributes = modifiedStyleAttributesBuilder(vNode, attributes, {
|
|
2594
|
+
isParagraph: true,
|
|
2595
|
+
});
|
|
2596
|
+
paragraphPropertiesFragment = buildParagraphProperties(modifiedAttributes);
|
|
2597
|
+
paragraphFragment.import(paragraphPropertiesFragment);
|
|
2598
|
+
if (!(isVNode__default["default"](vNode) && vNodeHasChildren(vNode))) return [3 /*break*/, 13];
|
|
2599
|
+
if (![
|
|
2600
|
+
'span',
|
|
2601
|
+
'strong',
|
|
2602
|
+
'b',
|
|
2603
|
+
'em',
|
|
2604
|
+
'i',
|
|
2605
|
+
'u',
|
|
2606
|
+
'ins',
|
|
2607
|
+
'strike',
|
|
2608
|
+
'del',
|
|
2609
|
+
's',
|
|
2610
|
+
'sub',
|
|
2611
|
+
'sup',
|
|
2612
|
+
'mark',
|
|
2613
|
+
'a',
|
|
2614
|
+
'code',
|
|
2615
|
+
'pre',
|
|
2616
|
+
].includes(vNode.tagName)) return [3 /*break*/, 2];
|
|
2617
|
+
return [4 /*yield*/, buildRunOrHyperLink(vNode, modifiedAttributes, docxDocumentInstance)];
|
|
2618
|
+
case 1:
|
|
2619
|
+
runOrHyperlinkFragments = _a.sent();
|
|
2620
|
+
if (Array.isArray(runOrHyperlinkFragments)) {
|
|
2621
|
+
for (iteratorIndex = 0; iteratorIndex < runOrHyperlinkFragments.length; iteratorIndex++) {
|
|
2622
|
+
runOrHyperlinkFragment = runOrHyperlinkFragments[iteratorIndex];
|
|
2623
|
+
paragraphFragment.import(runOrHyperlinkFragment);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
else {
|
|
2627
|
+
paragraphFragment.import(runOrHyperlinkFragments);
|
|
2628
|
+
}
|
|
2629
|
+
return [3 /*break*/, 12];
|
|
2630
|
+
case 2:
|
|
2631
|
+
if (!(vNode.tagName === 'blockquote')) return [3 /*break*/, 4];
|
|
2632
|
+
return [4 /*yield*/, buildRun(vNode, attributes)];
|
|
2633
|
+
case 3:
|
|
2634
|
+
runFragmentOrFragments = _a.sent();
|
|
2635
|
+
if (Array.isArray(runFragmentOrFragments)) {
|
|
2636
|
+
for (index = 0; index < runFragmentOrFragments.length; index++) {
|
|
2637
|
+
paragraphFragment.import(runFragmentOrFragments[index]);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
else {
|
|
2641
|
+
paragraphFragment.import(runFragmentOrFragments);
|
|
2642
|
+
}
|
|
2643
|
+
return [3 /*break*/, 12];
|
|
2644
|
+
case 4:
|
|
2645
|
+
index = 0;
|
|
2646
|
+
_a.label = 5;
|
|
2647
|
+
case 5:
|
|
2648
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 12];
|
|
2649
|
+
childVNode = vNode.children[index];
|
|
2650
|
+
if (!(childVNode.tagName === 'img')) return [3 /*break*/, 9];
|
|
2651
|
+
base64String = void 0;
|
|
2652
|
+
imageSource = childVNode.properties.src;
|
|
2653
|
+
if (!isValidUrl(imageSource)) return [3 /*break*/, 7];
|
|
2654
|
+
return [4 /*yield*/, imageToBase64__default["default"](imageSource).catch(function (error) {
|
|
2655
|
+
// eslint-disable-next-line no-console
|
|
2656
|
+
console.warning("skipping image download and conversion due to " + error);
|
|
2657
|
+
})];
|
|
2658
|
+
case 6:
|
|
2659
|
+
base64String = _a.sent();
|
|
2660
|
+
if (base64String && mimeTypes__default["default"].lookup(imageSource)) {
|
|
2661
|
+
childVNode.properties.src = "data:" + mimeTypes__default["default"].lookup(imageSource) + ";base64, " + base64String;
|
|
2662
|
+
}
|
|
2663
|
+
else {
|
|
2664
|
+
return [3 /*break*/, 12];
|
|
2665
|
+
}
|
|
2666
|
+
return [3 /*break*/, 8];
|
|
2667
|
+
case 7:
|
|
2668
|
+
// eslint-disable-next-line no-useless-escape, prefer-destructuring
|
|
2669
|
+
base64String = imageSource.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/)[2];
|
|
2670
|
+
_a.label = 8;
|
|
2671
|
+
case 8:
|
|
2672
|
+
imageBuffer = Buffer.from(decodeURIComponent(base64String), 'base64');
|
|
2673
|
+
imageProperties = sizeOf__default["default"](imageBuffer);
|
|
2674
|
+
modifiedAttributes.maximumWidth =
|
|
2675
|
+
modifiedAttributes.maximumWidth || docxDocumentInstance.availableDocumentSpace;
|
|
2676
|
+
modifiedAttributes.originalWidth = imageProperties.width;
|
|
2677
|
+
modifiedAttributes.originalHeight = imageProperties.height;
|
|
2678
|
+
computeImageDimensions(childVNode, modifiedAttributes);
|
|
2679
|
+
_a.label = 9;
|
|
2680
|
+
case 9: return [4 /*yield*/, buildRunOrHyperLink(childVNode, isVNode__default["default"](childVNode) && childVNode.tagName === 'img'
|
|
2681
|
+
? Object.assign(Object.assign({}, modifiedAttributes), { type: 'picture' }) : modifiedAttributes, docxDocumentInstance)];
|
|
2682
|
+
case 10:
|
|
2683
|
+
runOrHyperlinkFragments = _a.sent();
|
|
2684
|
+
if (Array.isArray(runOrHyperlinkFragments)) {
|
|
2685
|
+
for (iteratorIndex = 0; iteratorIndex < runOrHyperlinkFragments.length; iteratorIndex++) {
|
|
2686
|
+
runOrHyperlinkFragment = runOrHyperlinkFragments[iteratorIndex];
|
|
2687
|
+
paragraphFragment.import(runOrHyperlinkFragment);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
else {
|
|
2691
|
+
paragraphFragment.import(runOrHyperlinkFragments);
|
|
2692
|
+
}
|
|
2693
|
+
_a.label = 11;
|
|
2694
|
+
case 11:
|
|
2695
|
+
index++;
|
|
2696
|
+
return [3 /*break*/, 5];
|
|
2697
|
+
case 12: return [3 /*break*/, 19];
|
|
2698
|
+
case 13:
|
|
2699
|
+
if (!(isVNode__default["default"](vNode) && vNode.tagName === 'img')) return [3 /*break*/, 17];
|
|
2700
|
+
imageSource = vNode.properties.src;
|
|
2701
|
+
base64String = imageSource;
|
|
2702
|
+
if (!isValidUrl(imageSource)) return [3 /*break*/, 15];
|
|
2703
|
+
return [4 /*yield*/, imageToBase64__default["default"](imageSource).catch(function (error) {
|
|
2704
|
+
// eslint-disable-next-line no-console
|
|
2705
|
+
console.warning("skipping image download and conversion due to " + error);
|
|
2706
|
+
})];
|
|
2707
|
+
case 14:
|
|
2708
|
+
base64String = _a.sent();
|
|
2709
|
+
if (base64String && mimeTypes__default["default"].lookup(imageSource)) {
|
|
2710
|
+
vNode.properties.src = "data:" + mimeTypes__default["default"].lookup(imageSource) + ";base64, " + base64String;
|
|
2711
|
+
}
|
|
2712
|
+
else {
|
|
2713
|
+
paragraphFragment.up();
|
|
2714
|
+
return [2 /*return*/, paragraphFragment];
|
|
2715
|
+
}
|
|
2716
|
+
return [3 /*break*/, 16];
|
|
2717
|
+
case 15:
|
|
2718
|
+
// eslint-disable-next-line no-useless-escape, prefer-destructuring
|
|
2719
|
+
base64String = base64String.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/)[2];
|
|
2720
|
+
_a.label = 16;
|
|
2721
|
+
case 16:
|
|
2722
|
+
imageBuffer = Buffer.from(decodeURIComponent(base64String), 'base64');
|
|
2723
|
+
imageProperties = sizeOf__default["default"](imageBuffer);
|
|
2724
|
+
modifiedAttributes.maximumWidth =
|
|
2725
|
+
modifiedAttributes.maximumWidth || docxDocumentInstance.availableDocumentSpace;
|
|
2726
|
+
modifiedAttributes.originalWidth = imageProperties.width;
|
|
2727
|
+
modifiedAttributes.originalHeight = imageProperties.height;
|
|
2728
|
+
computeImageDimensions(vNode, modifiedAttributes);
|
|
2729
|
+
_a.label = 17;
|
|
2730
|
+
case 17: return [4 /*yield*/, buildRunOrRuns(vNode, modifiedAttributes, docxDocumentInstance)];
|
|
2731
|
+
case 18:
|
|
2732
|
+
runFragments = _a.sent();
|
|
2733
|
+
if (Array.isArray(runFragments)) {
|
|
2734
|
+
for (index = 0; index < runFragments.length; index++) {
|
|
2735
|
+
runFragment = runFragments[index];
|
|
2736
|
+
paragraphFragment.import(runFragment);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
else {
|
|
2740
|
+
paragraphFragment.import(runFragments);
|
|
2741
|
+
}
|
|
2742
|
+
_a.label = 19;
|
|
2743
|
+
case 19:
|
|
2744
|
+
paragraphFragment.up();
|
|
2745
|
+
return [2 /*return*/, paragraphFragment];
|
|
2746
|
+
}
|
|
2747
|
+
});
|
|
2748
|
+
}); };
|
|
2749
|
+
var ɵ38 = buildParagraph;
|
|
2750
|
+
var buildGridSpanFragment = function (spanValue) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2751
|
+
.ele('@w', 'gridSpan')
|
|
2752
|
+
.att('@w', 'val', spanValue)
|
|
2753
|
+
.up(); };
|
|
2754
|
+
var ɵ39 = buildGridSpanFragment;
|
|
2755
|
+
var buildTableCellSpacing = function (cellSpacing) {
|
|
2756
|
+
if (cellSpacing === void 0) { cellSpacing = 0; }
|
|
2757
|
+
return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2758
|
+
.ele('@w', 'tblCellSpacing')
|
|
2759
|
+
.att('@w', 'w', cellSpacing)
|
|
2760
|
+
.att('@w', 'type', 'dxa')
|
|
2761
|
+
.up();
|
|
2762
|
+
};
|
|
2763
|
+
var ɵ40 = buildTableCellSpacing;
|
|
2764
|
+
var buildTableCellBorders = function (tableCellBorder) {
|
|
2765
|
+
var tableCellBordersFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tcBorders');
|
|
2766
|
+
var color = tableCellBorder.color, stroke = tableCellBorder.stroke, borders = __rest(tableCellBorder, ["color", "stroke"]);
|
|
2767
|
+
Object.keys(borders).forEach(function (border) {
|
|
2768
|
+
if (tableCellBorder[border]) {
|
|
2769
|
+
var borderFragment = buildBorder(border, tableCellBorder[border], 0, color, stroke);
|
|
2770
|
+
tableCellBordersFragment.import(borderFragment);
|
|
2771
|
+
}
|
|
2772
|
+
});
|
|
2773
|
+
tableCellBordersFragment.up();
|
|
2774
|
+
return tableCellBordersFragment;
|
|
2775
|
+
};
|
|
2776
|
+
var ɵ41 = buildTableCellBorders;
|
|
2777
|
+
var buildTableCellWidth = function (tableCellWidth) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2778
|
+
.ele('@w', 'tcW')
|
|
2779
|
+
.att('@w', 'w', fixupColumnWidth(tableCellWidth))
|
|
2780
|
+
.att('@w', 'type', 'dxa')
|
|
2781
|
+
.up(); };
|
|
2782
|
+
var ɵ42 = buildTableCellWidth;
|
|
2783
|
+
var buildTableCellProperties = function (attributes) {
|
|
2784
|
+
var tableCellPropertiesFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tcPr');
|
|
2785
|
+
if (attributes && attributes.constructor === Object) {
|
|
2786
|
+
Object.keys(attributes).forEach(function (key) {
|
|
2787
|
+
switch (key) {
|
|
2788
|
+
case 'backgroundColor':
|
|
2789
|
+
var shadingFragment = buildShading(attributes[key]);
|
|
2790
|
+
tableCellPropertiesFragment.import(shadingFragment);
|
|
2791
|
+
// eslint-disable-next-line no-param-reassign
|
|
2792
|
+
delete attributes.backgroundColor;
|
|
2793
|
+
break;
|
|
2794
|
+
case 'verticalAlign':
|
|
2795
|
+
var verticalAlignmentFragment = buildVerticalAlignment(attributes[key]);
|
|
2796
|
+
tableCellPropertiesFragment.import(verticalAlignmentFragment);
|
|
2797
|
+
// eslint-disable-next-line no-param-reassign
|
|
2798
|
+
delete attributes.verticalAlign;
|
|
2799
|
+
break;
|
|
2800
|
+
case 'colSpan':
|
|
2801
|
+
var gridSpanFragment = buildGridSpanFragment(attributes[key]);
|
|
2802
|
+
tableCellPropertiesFragment.import(gridSpanFragment);
|
|
2803
|
+
// eslint-disable-next-line no-param-reassign
|
|
2804
|
+
delete attributes.colSpan;
|
|
2805
|
+
break;
|
|
2806
|
+
case 'tableCellBorder':
|
|
2807
|
+
var tableCellBorderFragment = buildTableCellBorders(attributes[key]);
|
|
2808
|
+
tableCellPropertiesFragment.import(tableCellBorderFragment);
|
|
2809
|
+
// eslint-disable-next-line no-param-reassign
|
|
2810
|
+
delete attributes.tableCellBorder;
|
|
2811
|
+
break;
|
|
2812
|
+
case 'rowSpan':
|
|
2813
|
+
var verticalMergeFragment = buildVerticalMerge(attributes[key]);
|
|
2814
|
+
tableCellPropertiesFragment.import(verticalMergeFragment);
|
|
2815
|
+
delete attributes.rowSpan;
|
|
2816
|
+
break;
|
|
2817
|
+
case 'width':
|
|
2818
|
+
var widthFragment = buildTableCellWidth(attributes[key]);
|
|
2819
|
+
tableCellPropertiesFragment.import(widthFragment);
|
|
2820
|
+
delete attributes.width;
|
|
2821
|
+
break;
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
tableCellPropertiesFragment.up();
|
|
2826
|
+
return tableCellPropertiesFragment;
|
|
2827
|
+
};
|
|
2828
|
+
var ɵ43 = buildTableCellProperties;
|
|
2829
|
+
var fixupTableCellBorder = function (vNode, attributes) {
|
|
2830
|
+
if (Object.prototype.hasOwnProperty.call(vNode.properties.style, 'border')) {
|
|
2831
|
+
if (vNode.properties.style.border === 'none' || vNode.properties.style.border === 0) {
|
|
2832
|
+
attributes.tableCellBorder = {};
|
|
2833
|
+
}
|
|
2834
|
+
else {
|
|
2835
|
+
// eslint-disable-next-line no-use-before-define
|
|
2836
|
+
var _a = __read(cssBorderParser(vNode.properties.style.border), 3), borderSize = _a[0], borderStroke = _a[1], borderColor = _a[2];
|
|
2837
|
+
attributes.tableCellBorder = {
|
|
2838
|
+
top: borderSize,
|
|
2839
|
+
left: borderSize,
|
|
2840
|
+
bottom: borderSize,
|
|
2841
|
+
right: borderSize,
|
|
2842
|
+
color: borderColor,
|
|
2843
|
+
stroke: borderStroke,
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
if (vNode.properties.style['border-top'] && vNode.properties.style['border-top'] === '0') {
|
|
2848
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { top: 0 });
|
|
2849
|
+
}
|
|
2850
|
+
else if (vNode.properties.style['border-top'] && vNode.properties.style['border-top'] !== '0') {
|
|
2851
|
+
// eslint-disable-next-line no-use-before-define
|
|
2852
|
+
var _b = __read(cssBorderParser(vNode.properties.style['border-top']), 3), borderSize = _b[0], borderStroke = _b[1], borderColor = _b[2];
|
|
2853
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { top: borderSize, color: borderColor, stroke: borderStroke });
|
|
2854
|
+
}
|
|
2855
|
+
if (vNode.properties.style['border-left'] && vNode.properties.style['border-left'] === '0') {
|
|
2856
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { left: 0 });
|
|
2857
|
+
}
|
|
2858
|
+
else if (vNode.properties.style['border-left'] &&
|
|
2859
|
+
vNode.properties.style['border-left'] !== '0') {
|
|
2860
|
+
// eslint-disable-next-line no-use-before-define
|
|
2861
|
+
var _c = __read(cssBorderParser(vNode.properties.style['border-left']), 3), borderSize = _c[0], borderStroke = _c[1], borderColor = _c[2];
|
|
2862
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { left: borderSize, color: borderColor, stroke: borderStroke });
|
|
2863
|
+
}
|
|
2864
|
+
if (vNode.properties.style['border-bottom'] && vNode.properties.style['border-bottom'] === '0') {
|
|
2865
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { bottom: 0 });
|
|
2866
|
+
}
|
|
2867
|
+
else if (vNode.properties.style['border-bottom'] &&
|
|
2868
|
+
vNode.properties.style['border-bottom'] !== '0') {
|
|
2869
|
+
// eslint-disable-next-line no-use-before-define
|
|
2870
|
+
var _d = __read(cssBorderParser(vNode.properties.style['border-bottom']), 3), borderSize = _d[0], borderStroke = _d[1], borderColor = _d[2];
|
|
2871
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { bottom: borderSize, color: borderColor, stroke: borderStroke });
|
|
2872
|
+
}
|
|
2873
|
+
if (vNode.properties.style['border-right'] && vNode.properties.style['border-right'] === '0') {
|
|
2874
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { right: 0 });
|
|
2875
|
+
}
|
|
2876
|
+
else if (vNode.properties.style['border-right'] &&
|
|
2877
|
+
vNode.properties.style['border-right'] !== '0') {
|
|
2878
|
+
// eslint-disable-next-line no-use-before-define
|
|
2879
|
+
var _e = __read(cssBorderParser(vNode.properties.style['border-right']), 3), borderSize = _e[0], borderStroke = _e[1], borderColor = _e[2];
|
|
2880
|
+
attributes.tableCellBorder = Object.assign(Object.assign({}, attributes.tableCellBorder), { right: borderSize, color: borderColor, stroke: borderStroke });
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2883
|
+
var ɵ44 = fixupTableCellBorder;
|
|
2884
|
+
var buildTableCell = function (vNode, attributes, rowSpanMap, columnIndex, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2885
|
+
var tableCellFragment, modifiedAttributes, previousSpanObject, previousSpanObject, tableCellPropertiesFragment, index, childVNode, imageFragment, iteratorIndex, grandChildVNode, imageFragment, paragraphFragment, paragraphFragment;
|
|
2886
|
+
return __generator(this, function (_a) {
|
|
2887
|
+
switch (_a.label) {
|
|
2888
|
+
case 0:
|
|
2889
|
+
tableCellFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tc');
|
|
2890
|
+
modifiedAttributes = Object.assign({}, attributes);
|
|
2891
|
+
if (isVNode__default["default"](vNode) && vNode.properties) {
|
|
2892
|
+
if (vNode.properties.rowSpan) {
|
|
2893
|
+
rowSpanMap.set(columnIndex.index, { rowSpan: vNode.properties.rowSpan - 1, colSpan: 0 });
|
|
2894
|
+
modifiedAttributes.rowSpan = 'restart';
|
|
2895
|
+
}
|
|
2896
|
+
else {
|
|
2897
|
+
previousSpanObject = rowSpanMap.get(columnIndex.index);
|
|
2898
|
+
rowSpanMap.set(columnIndex.index,
|
|
2899
|
+
// eslint-disable-next-line prefer-object-spread
|
|
2900
|
+
Object.assign({}, previousSpanObject, {
|
|
2901
|
+
rowSpan: 0,
|
|
2902
|
+
colSpan: (previousSpanObject && previousSpanObject.colSpan) || 0,
|
|
2903
|
+
}));
|
|
2904
|
+
}
|
|
2905
|
+
if (vNode.properties.colSpan ||
|
|
2906
|
+
(vNode.properties.style && vNode.properties.style['column-span'])) {
|
|
2907
|
+
modifiedAttributes.colSpan =
|
|
2908
|
+
vNode.properties.colSpan ||
|
|
2909
|
+
(vNode.properties.style && vNode.properties.style['column-span']);
|
|
2910
|
+
previousSpanObject = rowSpanMap.get(columnIndex.index);
|
|
2911
|
+
rowSpanMap.set(columnIndex.index,
|
|
2912
|
+
// eslint-disable-next-line prefer-object-spread
|
|
2913
|
+
Object.assign({}, previousSpanObject, {
|
|
2914
|
+
colSpan: parseInt(modifiedAttributes.colSpan) || 0,
|
|
2915
|
+
}));
|
|
2916
|
+
columnIndex.index += parseInt(modifiedAttributes.colSpan) - 1;
|
|
2917
|
+
}
|
|
2918
|
+
if (vNode.properties.style) {
|
|
2919
|
+
modifiedAttributes = Object.assign(Object.assign({}, modifiedAttributes), modifiedStyleAttributesBuilder(vNode, attributes));
|
|
2920
|
+
fixupTableCellBorder(vNode, modifiedAttributes);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
tableCellPropertiesFragment = buildTableCellProperties(modifiedAttributes);
|
|
2924
|
+
tableCellFragment.import(tableCellPropertiesFragment);
|
|
2925
|
+
if (!vNodeHasChildren(vNode)) return [3 /*break*/, 15];
|
|
2926
|
+
index = 0;
|
|
2927
|
+
_a.label = 1;
|
|
2928
|
+
case 1:
|
|
2929
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 14];
|
|
2930
|
+
childVNode = vNode.children[index];
|
|
2931
|
+
if (!(isVNode__default["default"](childVNode) && childVNode.tagName === 'img')) return [3 /*break*/, 3];
|
|
2932
|
+
return [4 /*yield*/, buildImage(docxDocumentInstance, childVNode, modifiedAttributes.maximumWidth)];
|
|
2933
|
+
case 2:
|
|
2934
|
+
imageFragment = _a.sent();
|
|
2935
|
+
if (imageFragment) {
|
|
2936
|
+
tableCellFragment.import(imageFragment);
|
|
2937
|
+
}
|
|
2938
|
+
return [3 /*break*/, 13];
|
|
2939
|
+
case 3:
|
|
2940
|
+
if (!(isVNode__default["default"](childVNode) && childVNode.tagName === 'figure')) return [3 /*break*/, 8];
|
|
2941
|
+
if (!vNodeHasChildren(childVNode)) return [3 /*break*/, 7];
|
|
2942
|
+
iteratorIndex = 0;
|
|
2943
|
+
_a.label = 4;
|
|
2944
|
+
case 4:
|
|
2945
|
+
if (!(iteratorIndex < childVNode.children.length)) return [3 /*break*/, 7];
|
|
2946
|
+
grandChildVNode = childVNode.children[iteratorIndex];
|
|
2947
|
+
if (!(grandChildVNode.tagName === 'img')) return [3 /*break*/, 6];
|
|
2948
|
+
return [4 /*yield*/, buildImage(docxDocumentInstance, grandChildVNode, modifiedAttributes.maximumWidth)];
|
|
2949
|
+
case 5:
|
|
2950
|
+
imageFragment = _a.sent();
|
|
2951
|
+
if (imageFragment) {
|
|
2952
|
+
tableCellFragment.import(imageFragment);
|
|
2953
|
+
}
|
|
2954
|
+
_a.label = 6;
|
|
2955
|
+
case 6:
|
|
2956
|
+
iteratorIndex++;
|
|
2957
|
+
return [3 /*break*/, 4];
|
|
2958
|
+
case 7: return [3 /*break*/, 13];
|
|
2959
|
+
case 8:
|
|
2960
|
+
if (!(isVNode__default["default"](childVNode) && ['ul', 'ol'].includes(childVNode.tagName))) return [3 /*break*/, 11];
|
|
2961
|
+
if (!vNodeHasChildren(childVNode)) return [3 /*break*/, 10];
|
|
2962
|
+
return [4 /*yield*/, buildList(childVNode, docxDocumentInstance, tableCellFragment)];
|
|
2963
|
+
case 9:
|
|
2964
|
+
_a.sent();
|
|
2965
|
+
_a.label = 10;
|
|
2966
|
+
case 10: return [3 /*break*/, 13];
|
|
2967
|
+
case 11: return [4 /*yield*/, buildParagraph(childVNode, modifiedAttributes, docxDocumentInstance)];
|
|
2968
|
+
case 12:
|
|
2969
|
+
paragraphFragment = _a.sent();
|
|
2970
|
+
tableCellFragment.import(paragraphFragment);
|
|
2971
|
+
_a.label = 13;
|
|
2972
|
+
case 13:
|
|
2973
|
+
index++;
|
|
2974
|
+
return [3 /*break*/, 1];
|
|
2975
|
+
case 14: return [3 /*break*/, 16];
|
|
2976
|
+
case 15:
|
|
2977
|
+
paragraphFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2978
|
+
.ele('@w', 'p')
|
|
2979
|
+
.up();
|
|
2980
|
+
tableCellFragment.import(paragraphFragment);
|
|
2981
|
+
_a.label = 16;
|
|
2982
|
+
case 16:
|
|
2983
|
+
tableCellFragment.up();
|
|
2984
|
+
return [2 /*return*/, tableCellFragment];
|
|
2985
|
+
}
|
|
2986
|
+
});
|
|
2987
|
+
}); };
|
|
2988
|
+
var ɵ45 = buildTableCell;
|
|
2989
|
+
var buildRowSpanCell = function (rowSpanMap, columnIndex, attributes) {
|
|
2990
|
+
var rowSpanCellFragments = [];
|
|
2991
|
+
var spanObject = rowSpanMap.get(columnIndex.index);
|
|
2992
|
+
while (spanObject && spanObject.rowSpan) {
|
|
2993
|
+
var rowSpanCellFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tc');
|
|
2994
|
+
var tableCellPropertiesFragment = buildTableCellProperties(Object.assign(Object.assign({}, attributes), { rowSpan: 'continue', colSpan: spanObject.colSpan ? spanObject.colSpan : 0 }));
|
|
2995
|
+
rowSpanCellFragment.import(tableCellPropertiesFragment);
|
|
2996
|
+
var paragraphFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
2997
|
+
.ele('@w', 'p')
|
|
2998
|
+
.up();
|
|
2999
|
+
rowSpanCellFragment.import(paragraphFragment);
|
|
3000
|
+
rowSpanCellFragment.up();
|
|
3001
|
+
rowSpanCellFragments.push(rowSpanCellFragment);
|
|
3002
|
+
if (spanObject.rowSpan - 1 === 0) {
|
|
3003
|
+
rowSpanMap.delete(columnIndex.index);
|
|
3004
|
+
}
|
|
3005
|
+
else {
|
|
3006
|
+
rowSpanMap.set(columnIndex.index, {
|
|
3007
|
+
rowSpan: spanObject.rowSpan - 1,
|
|
3008
|
+
colSpan: spanObject.colSpan || 0,
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
columnIndex.index += spanObject.colSpan || 1;
|
|
3012
|
+
spanObject = rowSpanMap.get(columnIndex.index);
|
|
3013
|
+
}
|
|
3014
|
+
return rowSpanCellFragments;
|
|
3015
|
+
};
|
|
3016
|
+
var ɵ46 = buildRowSpanCell;
|
|
3017
|
+
var buildTableRowProperties = function (attributes) {
|
|
3018
|
+
var tableRowPropertiesFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'trPr');
|
|
3019
|
+
if (attributes && attributes.constructor === Object) {
|
|
3020
|
+
Object.keys(attributes).forEach(function (key) {
|
|
3021
|
+
switch (key) {
|
|
3022
|
+
case 'tableRowHeight':
|
|
3023
|
+
var tableRowHeightFragment = buildTableRowHeight(attributes[key]);
|
|
3024
|
+
tableRowPropertiesFragment.import(tableRowHeightFragment);
|
|
3025
|
+
// eslint-disable-next-line no-param-reassign
|
|
3026
|
+
delete attributes.tableRowHeight;
|
|
3027
|
+
break;
|
|
3028
|
+
case 'rowCantSplit':
|
|
3029
|
+
if (attributes.rowCantSplit) {
|
|
3030
|
+
var cantSplitFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
3031
|
+
.ele('@w', 'cantSplit')
|
|
3032
|
+
.up();
|
|
3033
|
+
tableRowPropertiesFragment.import(cantSplitFragment);
|
|
3034
|
+
// eslint-disable-next-line no-param-reassign
|
|
3035
|
+
delete attributes.rowCantSplit;
|
|
3036
|
+
}
|
|
3037
|
+
break;
|
|
3038
|
+
}
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
tableRowPropertiesFragment.up();
|
|
3042
|
+
return tableRowPropertiesFragment;
|
|
3043
|
+
};
|
|
3044
|
+
var ɵ47 = buildTableRowProperties;
|
|
3045
|
+
var buildTableRow = function (vNode, attributes, rowSpanMap, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3046
|
+
var tableRowFragment, modifiedAttributes, tableRowPropertiesFragment, columnIndex, tableColumns, maximumColumnWidth, tableColumns_1, tableColumns_1_1, column, rowSpanCellFragments, iteratorIndex, rowSpanCellFragment, tableCellFragment, e_1_1, rowSpanCellFragments, iteratorIndex, rowSpanCellFragment;
|
|
3047
|
+
var e_1, _a;
|
|
3048
|
+
return __generator(this, function (_b) {
|
|
3049
|
+
switch (_b.label) {
|
|
3050
|
+
case 0:
|
|
3051
|
+
tableRowFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tr');
|
|
3052
|
+
modifiedAttributes = Object.assign({}, attributes);
|
|
3053
|
+
if (isVNode__default["default"](vNode) && vNode.properties) {
|
|
3054
|
+
// FIXME: find a better way to get row height from cell style
|
|
3055
|
+
if ((vNode.properties.style && vNode.properties.style.height) ||
|
|
3056
|
+
(vNode.children[0] &&
|
|
3057
|
+
isVNode__default["default"](vNode.children[0]) &&
|
|
3058
|
+
vNode.children[0].properties.style &&
|
|
3059
|
+
vNode.children[0].properties.style.height)) {
|
|
3060
|
+
modifiedAttributes.tableRowHeight = fixupRowHeight((vNode.properties.style && vNode.properties.style.height) ||
|
|
3061
|
+
(vNode.children[0] &&
|
|
3062
|
+
isVNode__default["default"](vNode.children[0]) &&
|
|
3063
|
+
vNode.children[0].properties.style &&
|
|
3064
|
+
vNode.children[0].properties.style.height
|
|
3065
|
+
? vNode.children[0].properties.style.height
|
|
3066
|
+
: undefined));
|
|
3067
|
+
}
|
|
3068
|
+
if (vNode.properties.style) {
|
|
3069
|
+
fixupTableCellBorder(vNode, modifiedAttributes);
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
tableRowPropertiesFragment = buildTableRowProperties(modifiedAttributes);
|
|
3073
|
+
tableRowFragment.import(tableRowPropertiesFragment);
|
|
3074
|
+
columnIndex = { index: 0 };
|
|
3075
|
+
if (!vNodeHasChildren(vNode)) return [3 /*break*/, 8];
|
|
3076
|
+
tableColumns = vNode.children.filter(function (childVNode) { return ['td', 'th'].includes(childVNode.tagName); });
|
|
3077
|
+
maximumColumnWidth = docxDocumentInstance.availableDocumentSpace / tableColumns.length;
|
|
3078
|
+
_b.label = 1;
|
|
3079
|
+
case 1:
|
|
3080
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
3081
|
+
tableColumns_1 = __values(tableColumns), tableColumns_1_1 = tableColumns_1.next();
|
|
3082
|
+
_b.label = 2;
|
|
3083
|
+
case 2:
|
|
3084
|
+
if (!!tableColumns_1_1.done) return [3 /*break*/, 5];
|
|
3085
|
+
column = tableColumns_1_1.value;
|
|
3086
|
+
rowSpanCellFragments = buildRowSpanCell(rowSpanMap, columnIndex, modifiedAttributes);
|
|
3087
|
+
if (Array.isArray(rowSpanCellFragments)) {
|
|
3088
|
+
for (iteratorIndex = 0; iteratorIndex < rowSpanCellFragments.length; iteratorIndex++) {
|
|
3089
|
+
rowSpanCellFragment = rowSpanCellFragments[iteratorIndex];
|
|
3090
|
+
tableRowFragment.import(rowSpanCellFragment);
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
return [4 /*yield*/, buildTableCell(column, Object.assign(Object.assign({}, modifiedAttributes), { maximumWidth: maximumColumnWidth }), rowSpanMap, columnIndex, docxDocumentInstance)];
|
|
3094
|
+
case 3:
|
|
3095
|
+
tableCellFragment = _b.sent();
|
|
3096
|
+
columnIndex.index++;
|
|
3097
|
+
tableRowFragment.import(tableCellFragment);
|
|
3098
|
+
_b.label = 4;
|
|
3099
|
+
case 4:
|
|
3100
|
+
tableColumns_1_1 = tableColumns_1.next();
|
|
3101
|
+
return [3 /*break*/, 2];
|
|
3102
|
+
case 5: return [3 /*break*/, 8];
|
|
3103
|
+
case 6:
|
|
3104
|
+
e_1_1 = _b.sent();
|
|
3105
|
+
e_1 = { error: e_1_1 };
|
|
3106
|
+
return [3 /*break*/, 8];
|
|
3107
|
+
case 7:
|
|
3108
|
+
try {
|
|
3109
|
+
if (tableColumns_1_1 && !tableColumns_1_1.done && (_a = tableColumns_1.return)) _a.call(tableColumns_1);
|
|
3110
|
+
}
|
|
3111
|
+
finally { if (e_1) throw e_1.error; }
|
|
3112
|
+
return [7 /*endfinally*/];
|
|
3113
|
+
case 8:
|
|
3114
|
+
if (columnIndex.index < rowSpanMap.size) {
|
|
3115
|
+
rowSpanCellFragments = buildRowSpanCell(rowSpanMap, columnIndex, modifiedAttributes);
|
|
3116
|
+
if (Array.isArray(rowSpanCellFragments)) {
|
|
3117
|
+
for (iteratorIndex = 0; iteratorIndex < rowSpanCellFragments.length; iteratorIndex++) {
|
|
3118
|
+
rowSpanCellFragment = rowSpanCellFragments[iteratorIndex];
|
|
3119
|
+
tableRowFragment.import(rowSpanCellFragment);
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
tableRowFragment.up();
|
|
3124
|
+
return [2 /*return*/, tableRowFragment];
|
|
3125
|
+
}
|
|
3126
|
+
});
|
|
3127
|
+
}); };
|
|
3128
|
+
var ɵ48 = buildTableRow;
|
|
3129
|
+
var buildTableGridCol = function (gridWidth) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
3130
|
+
.ele('@w', 'gridCol')
|
|
3131
|
+
.att('@w', 'w', String(gridWidth)); };
|
|
3132
|
+
var ɵ49 = buildTableGridCol;
|
|
3133
|
+
var buildTableGrid = function (vNode, attributes) {
|
|
3134
|
+
var tableGridFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tblGrid');
|
|
3135
|
+
if (vNodeHasChildren(vNode)) {
|
|
3136
|
+
var gridColumns = vNode.children.filter(function (childVNode) { return childVNode.tagName === 'col'; });
|
|
3137
|
+
var gridWidth = attributes.maximumWidth / gridColumns.length;
|
|
3138
|
+
for (var index = 0; index < gridColumns.length; index++) {
|
|
3139
|
+
var tableGridColFragment = buildTableGridCol(gridWidth);
|
|
3140
|
+
tableGridFragment.import(tableGridColFragment);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
tableGridFragment.up();
|
|
3144
|
+
return tableGridFragment;
|
|
3145
|
+
};
|
|
3146
|
+
var ɵ50 = buildTableGrid;
|
|
3147
|
+
var buildTableGridFromTableRow = function (vNode, attributes) {
|
|
3148
|
+
var tableGridFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tblGrid');
|
|
3149
|
+
if (vNodeHasChildren(vNode)) {
|
|
3150
|
+
var numberOfGridColumns = vNode.children.reduce(function (accumulator, childVNode) {
|
|
3151
|
+
var colSpan = childVNode.properties.colSpan ||
|
|
3152
|
+
(childVNode.properties.style && childVNode.properties.style['column-span']);
|
|
3153
|
+
return accumulator + (colSpan ? parseInt(colSpan) : 1);
|
|
3154
|
+
}, 0);
|
|
3155
|
+
var gridWidth = attributes.maximumWidth / numberOfGridColumns;
|
|
3156
|
+
for (var index = 0; index < numberOfGridColumns; index++) {
|
|
3157
|
+
var tableGridColFragment = buildTableGridCol(gridWidth);
|
|
3158
|
+
tableGridFragment.import(tableGridColFragment);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
tableGridFragment.up();
|
|
3162
|
+
return tableGridFragment;
|
|
3163
|
+
};
|
|
3164
|
+
var ɵ51 = buildTableGridFromTableRow;
|
|
3165
|
+
var buildTableBorders = function (tableBorder) {
|
|
3166
|
+
var tableBordersFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tblBorders');
|
|
3167
|
+
var color = tableBorder.color, stroke = tableBorder.stroke, borders = __rest(tableBorder, ["color", "stroke"]);
|
|
3168
|
+
Object.keys(borders).forEach(function (border) {
|
|
3169
|
+
if (borders[border]) {
|
|
3170
|
+
var borderFragment = buildBorder(border, borders[border], 0, color, stroke);
|
|
3171
|
+
tableBordersFragment.import(borderFragment);
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
tableBordersFragment.up();
|
|
3175
|
+
return tableBordersFragment;
|
|
3176
|
+
};
|
|
3177
|
+
var ɵ52 = buildTableBorders;
|
|
3178
|
+
var buildTableWidth = function (tableWidth) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
3179
|
+
.ele('@w', 'tblW')
|
|
3180
|
+
.att('@w', 'type', 'dxa')
|
|
3181
|
+
.att('@w', 'w', String(tableWidth))
|
|
3182
|
+
.up(); };
|
|
3183
|
+
var ɵ53 = buildTableWidth;
|
|
3184
|
+
var buildCellMargin = function (side, margin) { return xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
3185
|
+
.ele('@w', side)
|
|
3186
|
+
.att('@w', 'type', 'dxa')
|
|
3187
|
+
.att('@w', 'w', String(margin))
|
|
3188
|
+
.up(); };
|
|
3189
|
+
var ɵ54 = buildCellMargin;
|
|
3190
|
+
var buildTableCellMargins = function (margin) {
|
|
3191
|
+
var tableCellMarFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tblCellMar');
|
|
3192
|
+
['top', 'bottom'].forEach(function (side) {
|
|
3193
|
+
var marginFragment = buildCellMargin(side, margin / 2);
|
|
3194
|
+
tableCellMarFragment.import(marginFragment);
|
|
3195
|
+
});
|
|
3196
|
+
['left', 'right'].forEach(function (side) {
|
|
3197
|
+
var marginFragment = buildCellMargin(side, margin);
|
|
3198
|
+
tableCellMarFragment.import(marginFragment);
|
|
3199
|
+
});
|
|
3200
|
+
return tableCellMarFragment;
|
|
3201
|
+
};
|
|
3202
|
+
var ɵ55 = buildTableCellMargins;
|
|
3203
|
+
var buildTableProperties = function (attributes) {
|
|
3204
|
+
var tablePropertiesFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tblPr');
|
|
3205
|
+
if (attributes && attributes.constructor === Object) {
|
|
3206
|
+
Object.keys(attributes).forEach(function (key) {
|
|
3207
|
+
switch (key) {
|
|
3208
|
+
case 'tableBorder':
|
|
3209
|
+
var tableBordersFragment = buildTableBorders(attributes[key]);
|
|
3210
|
+
tablePropertiesFragment.import(tableBordersFragment);
|
|
3211
|
+
// eslint-disable-next-line no-param-reassign
|
|
3212
|
+
delete attributes.tableBorder;
|
|
3213
|
+
break;
|
|
3214
|
+
case 'tableCellSpacing':
|
|
3215
|
+
var tableCellSpacingFragment = buildTableCellSpacing(attributes[key]);
|
|
3216
|
+
tablePropertiesFragment.import(tableCellSpacingFragment);
|
|
3217
|
+
// eslint-disable-next-line no-param-reassign
|
|
3218
|
+
delete attributes.tableCellSpacing;
|
|
3219
|
+
break;
|
|
3220
|
+
case 'width':
|
|
3221
|
+
if (attributes[key]) {
|
|
3222
|
+
var tableWidthFragment = buildTableWidth(attributes[key]);
|
|
3223
|
+
tablePropertiesFragment.import(tableWidthFragment);
|
|
3224
|
+
}
|
|
3225
|
+
// eslint-disable-next-line no-param-reassign
|
|
3226
|
+
delete attributes.width;
|
|
3227
|
+
break;
|
|
3228
|
+
}
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
var tableCellMarginFragment = buildTableCellMargins(160);
|
|
3232
|
+
tablePropertiesFragment.import(tableCellMarginFragment);
|
|
3233
|
+
// by default, all tables are center aligned.
|
|
3234
|
+
var alignmentFragment = buildHorizontalAlignment('center');
|
|
3235
|
+
tablePropertiesFragment.import(alignmentFragment);
|
|
3236
|
+
tablePropertiesFragment.up();
|
|
3237
|
+
return tablePropertiesFragment;
|
|
3238
|
+
};
|
|
3239
|
+
var ɵ56 = buildTableProperties;
|
|
3240
|
+
var cssBorderParser = function (borderString) {
|
|
3241
|
+
var _a = __read(borderString.split(' '), 3), size = _a[0], stroke = _a[1], color = _a[2];
|
|
3242
|
+
if (pointRegex.test(size)) {
|
|
3243
|
+
var matchedParts = size.match(pointRegex);
|
|
3244
|
+
// convert point to eighth of a point
|
|
3245
|
+
size = pointToEIP(matchedParts[1]);
|
|
3246
|
+
}
|
|
3247
|
+
else if (pixelRegex.test(size)) {
|
|
3248
|
+
var matchedParts = size.match(pixelRegex);
|
|
3249
|
+
// convert pixels to eighth of a point
|
|
3250
|
+
size = pixelToEIP(matchedParts[1]);
|
|
3251
|
+
}
|
|
3252
|
+
stroke = stroke && ['dashed', 'dotted', 'double'].includes(stroke) ? stroke : 'single';
|
|
3253
|
+
color = color && fixupColorCode(color).toUpperCase();
|
|
3254
|
+
return [size, stroke, color];
|
|
3255
|
+
};
|
|
3256
|
+
var ɵ57 = cssBorderParser;
|
|
3257
|
+
var buildTable = function (vNode, attributes, docxDocumentInstance) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3258
|
+
var tableFragment, modifiedAttributes, tableAttributes, tableStyles, tableBorders, tableCellBorders, _a, borderSize, borderStrike, borderColor, _b, cssSize, cssStroke, cssColor, minimumWidth, maximumWidth, width, percentageValue, percentageValue, percentageValue, tablePropertiesFragment, rowSpanMap, index, childVNode, tableGridFragment, iteratorIndex, grandChildVNode, tableGridFragment, tableRowFragment, iteratorIndex, grandChildVNode, tableGridFragment, tableRowFragment, tableGridFragment, tableRowFragment;
|
|
3259
|
+
return __generator(this, function (_c) {
|
|
3260
|
+
switch (_c.label) {
|
|
3261
|
+
case 0:
|
|
3262
|
+
tableFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'tbl');
|
|
3263
|
+
modifiedAttributes = Object.assign({}, attributes);
|
|
3264
|
+
if (isVNode__default["default"](vNode) && vNode.properties) {
|
|
3265
|
+
tableAttributes = vNode.properties.attributes || {};
|
|
3266
|
+
tableStyles = vNode.properties.style || {};
|
|
3267
|
+
tableBorders = {};
|
|
3268
|
+
tableCellBorders = {};
|
|
3269
|
+
_a = __read([2, 'single', '000000'], 3), borderSize = _a[0], borderStrike = _a[1], borderColor = _a[2];
|
|
3270
|
+
// eslint-disable-next-line no-restricted-globals
|
|
3271
|
+
if (!isNaN(tableAttributes.border)) {
|
|
3272
|
+
borderSize = parseInt(tableAttributes.border, 10);
|
|
3273
|
+
}
|
|
3274
|
+
// css style overrides table border properties
|
|
3275
|
+
if (tableStyles.border) {
|
|
3276
|
+
_b = __read(cssBorderParser(tableStyles.border), 3), cssSize = _b[0], cssStroke = _b[1], cssColor = _b[2];
|
|
3277
|
+
borderSize = cssSize || borderSize;
|
|
3278
|
+
borderColor = cssColor || borderColor;
|
|
3279
|
+
borderStrike = cssStroke || borderStrike;
|
|
3280
|
+
}
|
|
3281
|
+
tableBorders.top = borderSize;
|
|
3282
|
+
tableBorders.bottom = borderSize;
|
|
3283
|
+
tableBorders.left = borderSize;
|
|
3284
|
+
tableBorders.right = borderSize;
|
|
3285
|
+
tableBorders.stroke = borderStrike;
|
|
3286
|
+
tableBorders.color = borderColor;
|
|
3287
|
+
if (tableStyles['border-collapse'] === 'collapse') {
|
|
3288
|
+
tableBorders.insideV = borderSize;
|
|
3289
|
+
tableBorders.insideH = borderSize;
|
|
3290
|
+
}
|
|
3291
|
+
else {
|
|
3292
|
+
tableBorders.insideV = 0;
|
|
3293
|
+
tableBorders.insideH = 0;
|
|
3294
|
+
tableCellBorders.top = 1;
|
|
3295
|
+
tableCellBorders.bottom = 1;
|
|
3296
|
+
tableCellBorders.left = 1;
|
|
3297
|
+
tableCellBorders.right = 1;
|
|
3298
|
+
}
|
|
3299
|
+
modifiedAttributes.tableBorder = tableBorders;
|
|
3300
|
+
modifiedAttributes.tableCellSpacing = 0;
|
|
3301
|
+
if (Object.keys(tableCellBorders).length) {
|
|
3302
|
+
modifiedAttributes.tableCellBorder = tableCellBorders;
|
|
3303
|
+
}
|
|
3304
|
+
minimumWidth = void 0;
|
|
3305
|
+
maximumWidth = void 0;
|
|
3306
|
+
width = void 0;
|
|
3307
|
+
// Calculate minimum width of table
|
|
3308
|
+
if (pixelRegex.test(tableStyles['min-width'])) {
|
|
3309
|
+
minimumWidth = pixelToTWIP(tableStyles['min-width'].match(pixelRegex)[1]);
|
|
3310
|
+
}
|
|
3311
|
+
else if (percentageRegex.test(tableStyles['min-width'])) {
|
|
3312
|
+
percentageValue = tableStyles['min-width'].match(percentageRegex)[1];
|
|
3313
|
+
minimumWidth = Math.round((percentageValue / 100) * attributes.maximumWidth);
|
|
3314
|
+
}
|
|
3315
|
+
// Calculate maximum width of table
|
|
3316
|
+
if (pixelRegex.test(tableStyles['max-width'])) {
|
|
3317
|
+
pixelRegex.lastIndex = 0;
|
|
3318
|
+
maximumWidth = pixelToTWIP(tableStyles['max-width'].match(pixelRegex)[1]);
|
|
3319
|
+
}
|
|
3320
|
+
else if (percentageRegex.test(tableStyles['max-width'])) {
|
|
3321
|
+
percentageRegex.lastIndex = 0;
|
|
3322
|
+
percentageValue = tableStyles['max-width'].match(percentageRegex)[1];
|
|
3323
|
+
maximumWidth = Math.round((percentageValue / 100) * attributes.maximumWidth);
|
|
3324
|
+
}
|
|
3325
|
+
// Calculate specified width of table
|
|
3326
|
+
if (pixelRegex.test(tableStyles.width)) {
|
|
3327
|
+
pixelRegex.lastIndex = 0;
|
|
3328
|
+
width = pixelToTWIP(tableStyles.width.match(pixelRegex)[1]);
|
|
3329
|
+
}
|
|
3330
|
+
else if (percentageRegex.test(tableStyles.width)) {
|
|
3331
|
+
percentageRegex.lastIndex = 0;
|
|
3332
|
+
percentageValue = tableStyles.width.match(percentageRegex)[1];
|
|
3333
|
+
width = Math.round((percentageValue / 100) * attributes.maximumWidth);
|
|
3334
|
+
}
|
|
3335
|
+
// If width isn't supplied, we should have min-width as the width.
|
|
3336
|
+
if (width) {
|
|
3337
|
+
modifiedAttributes.width = width;
|
|
3338
|
+
if (maximumWidth) {
|
|
3339
|
+
modifiedAttributes.width = Math.min(modifiedAttributes.width, maximumWidth);
|
|
3340
|
+
}
|
|
3341
|
+
if (minimumWidth) {
|
|
3342
|
+
modifiedAttributes.width = Math.max(modifiedAttributes.width, minimumWidth);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
else if (minimumWidth) {
|
|
3346
|
+
modifiedAttributes.width = minimumWidth;
|
|
3347
|
+
}
|
|
3348
|
+
if (modifiedAttributes.width) {
|
|
3349
|
+
modifiedAttributes.width = Math.min(modifiedAttributes.width, attributes.maximumWidth);
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
tablePropertiesFragment = buildTableProperties(modifiedAttributes);
|
|
3353
|
+
tableFragment.import(tablePropertiesFragment);
|
|
3354
|
+
rowSpanMap = new Map();
|
|
3355
|
+
if (!vNodeHasChildren(vNode)) return [3 /*break*/, 15];
|
|
3356
|
+
index = 0;
|
|
3357
|
+
_c.label = 1;
|
|
3358
|
+
case 1:
|
|
3359
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 15];
|
|
3360
|
+
childVNode = vNode.children[index];
|
|
3361
|
+
if (!(childVNode.tagName === 'colgroup')) return [3 /*break*/, 2];
|
|
3362
|
+
tableGridFragment = buildTableGrid(childVNode, modifiedAttributes);
|
|
3363
|
+
tableFragment.import(tableGridFragment);
|
|
3364
|
+
return [3 /*break*/, 14];
|
|
3365
|
+
case 2:
|
|
3366
|
+
if (!(childVNode.tagName === 'thead')) return [3 /*break*/, 7];
|
|
3367
|
+
iteratorIndex = 0;
|
|
3368
|
+
_c.label = 3;
|
|
3369
|
+
case 3:
|
|
3370
|
+
if (!(iteratorIndex < childVNode.children.length)) return [3 /*break*/, 6];
|
|
3371
|
+
grandChildVNode = childVNode.children[iteratorIndex];
|
|
3372
|
+
if (!(grandChildVNode.tagName === 'tr')) return [3 /*break*/, 5];
|
|
3373
|
+
if (iteratorIndex === 0) {
|
|
3374
|
+
tableGridFragment = buildTableGridFromTableRow(grandChildVNode, modifiedAttributes);
|
|
3375
|
+
tableFragment.import(tableGridFragment);
|
|
3376
|
+
}
|
|
3377
|
+
return [4 /*yield*/, buildTableRow(grandChildVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance)];
|
|
3378
|
+
case 4:
|
|
3379
|
+
tableRowFragment = _c.sent();
|
|
3380
|
+
tableFragment.import(tableRowFragment);
|
|
3381
|
+
_c.label = 5;
|
|
3382
|
+
case 5:
|
|
3383
|
+
iteratorIndex++;
|
|
3384
|
+
return [3 /*break*/, 3];
|
|
3385
|
+
case 6: return [3 /*break*/, 14];
|
|
3386
|
+
case 7:
|
|
3387
|
+
if (!(childVNode.tagName === 'tbody')) return [3 /*break*/, 12];
|
|
3388
|
+
iteratorIndex = 0;
|
|
3389
|
+
_c.label = 8;
|
|
3390
|
+
case 8:
|
|
3391
|
+
if (!(iteratorIndex < childVNode.children.length)) return [3 /*break*/, 11];
|
|
3392
|
+
grandChildVNode = childVNode.children[iteratorIndex];
|
|
3393
|
+
if (!(grandChildVNode.tagName === 'tr')) return [3 /*break*/, 10];
|
|
3394
|
+
if (iteratorIndex === 0) {
|
|
3395
|
+
tableGridFragment = buildTableGridFromTableRow(grandChildVNode, modifiedAttributes);
|
|
3396
|
+
tableFragment.import(tableGridFragment);
|
|
3397
|
+
}
|
|
3398
|
+
return [4 /*yield*/, buildTableRow(grandChildVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance)];
|
|
3399
|
+
case 9:
|
|
3400
|
+
tableRowFragment = _c.sent();
|
|
3401
|
+
tableFragment.import(tableRowFragment);
|
|
3402
|
+
_c.label = 10;
|
|
3403
|
+
case 10:
|
|
3404
|
+
iteratorIndex++;
|
|
3405
|
+
return [3 /*break*/, 8];
|
|
3406
|
+
case 11: return [3 /*break*/, 14];
|
|
3407
|
+
case 12:
|
|
3408
|
+
if (!(childVNode.tagName === 'tr')) return [3 /*break*/, 14];
|
|
3409
|
+
if (index === 0) {
|
|
3410
|
+
tableGridFragment = buildTableGridFromTableRow(childVNode, modifiedAttributes);
|
|
3411
|
+
tableFragment.import(tableGridFragment);
|
|
3412
|
+
}
|
|
3413
|
+
return [4 /*yield*/, buildTableRow(childVNode, modifiedAttributes, rowSpanMap, docxDocumentInstance)];
|
|
3414
|
+
case 13:
|
|
3415
|
+
tableRowFragment = _c.sent();
|
|
3416
|
+
tableFragment.import(tableRowFragment);
|
|
3417
|
+
_c.label = 14;
|
|
3418
|
+
case 14:
|
|
3419
|
+
index++;
|
|
3420
|
+
return [3 /*break*/, 1];
|
|
3421
|
+
case 15:
|
|
3422
|
+
tableFragment.up();
|
|
3423
|
+
return [2 /*return*/, tableFragment];
|
|
3424
|
+
}
|
|
3425
|
+
});
|
|
3426
|
+
}); };
|
|
3427
|
+
var ɵ58 = buildTable;
|
|
3428
|
+
var buildPresetGeometry = function () { return xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3429
|
+
.ele('@a', 'prstGeom')
|
|
3430
|
+
.att('prst', 'rect')
|
|
3431
|
+
.up(); };
|
|
3432
|
+
var ɵ59 = buildPresetGeometry;
|
|
3433
|
+
var buildExtents = function (_a) {
|
|
3434
|
+
var width = _a.width, height = _a.height;
|
|
3435
|
+
return xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3436
|
+
.ele('@a', 'ext')
|
|
3437
|
+
.att('cx', width)
|
|
3438
|
+
.att('cy', height)
|
|
3439
|
+
.up();
|
|
3440
|
+
};
|
|
3441
|
+
var ɵ60 = buildExtents;
|
|
3442
|
+
var buildOffset = function () { return xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3443
|
+
.ele('@a', 'off')
|
|
3444
|
+
.att('x', '0')
|
|
3445
|
+
.att('y', '0')
|
|
3446
|
+
.up(); };
|
|
3447
|
+
var ɵ61 = buildOffset;
|
|
3448
|
+
var buildGraphicFrameTransform = function (attributes) {
|
|
3449
|
+
var graphicFrameTransformFragment = xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } }).ele('@a', 'xfrm');
|
|
3450
|
+
var offsetFragment = buildOffset();
|
|
3451
|
+
graphicFrameTransformFragment.import(offsetFragment);
|
|
3452
|
+
var extentsFragment = buildExtents(attributes);
|
|
3453
|
+
graphicFrameTransformFragment.import(extentsFragment);
|
|
3454
|
+
graphicFrameTransformFragment.up();
|
|
3455
|
+
return graphicFrameTransformFragment;
|
|
3456
|
+
};
|
|
3457
|
+
var ɵ62 = buildGraphicFrameTransform;
|
|
3458
|
+
var buildShapeProperties = function (attributes) {
|
|
3459
|
+
var shapeProperties = xmlbuilder2.fragment({ namespaceAlias: { pic: namespaces.pic } }).ele('@pic', 'spPr');
|
|
3460
|
+
var graphicFrameTransformFragment = buildGraphicFrameTransform(attributes);
|
|
3461
|
+
shapeProperties.import(graphicFrameTransformFragment);
|
|
3462
|
+
var presetGeometryFragment = buildPresetGeometry();
|
|
3463
|
+
shapeProperties.import(presetGeometryFragment);
|
|
3464
|
+
shapeProperties.up();
|
|
3465
|
+
return shapeProperties;
|
|
3466
|
+
};
|
|
3467
|
+
var ɵ63 = buildShapeProperties;
|
|
3468
|
+
var buildFillRect = function () { return xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3469
|
+
.ele('@a', 'fillRect')
|
|
3470
|
+
.up(); };
|
|
3471
|
+
var ɵ64 = buildFillRect;
|
|
3472
|
+
var buildStretch = function () {
|
|
3473
|
+
var stretchFragment = xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } }).ele('@a', 'stretch');
|
|
3474
|
+
var fillRectFragment = buildFillRect();
|
|
3475
|
+
stretchFragment.import(fillRectFragment);
|
|
3476
|
+
stretchFragment.up();
|
|
3477
|
+
return stretchFragment;
|
|
3478
|
+
};
|
|
3479
|
+
var ɵ65 = buildStretch;
|
|
3480
|
+
var buildSrcRectFragment = function () { return xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3481
|
+
.ele('@a', 'srcRect')
|
|
3482
|
+
.att('b', '0')
|
|
3483
|
+
.att('l', '0')
|
|
3484
|
+
.att('r', '0')
|
|
3485
|
+
.att('t', '0')
|
|
3486
|
+
.up(); };
|
|
3487
|
+
var ɵ66 = buildSrcRectFragment;
|
|
3488
|
+
var buildBinaryLargeImageOrPicture = function (relationshipId) { return xmlbuilder2.fragment({
|
|
3489
|
+
namespaceAlias: { a: namespaces.a, r: namespaces.r },
|
|
3490
|
+
})
|
|
3491
|
+
.ele('@a', 'blip')
|
|
3492
|
+
.att('@r', 'embed', "rId" + relationshipId)
|
|
3493
|
+
// FIXME: possible values 'email', 'none', 'print', 'hqprint', 'screen'
|
|
3494
|
+
.att('cstate', 'print')
|
|
3495
|
+
.up(); };
|
|
3496
|
+
var ɵ67 = buildBinaryLargeImageOrPicture;
|
|
3497
|
+
var buildBinaryLargeImageOrPictureFill = function (relationshipId) {
|
|
3498
|
+
var binaryLargeImageOrPictureFillFragment = xmlbuilder2.fragment({
|
|
3499
|
+
namespaceAlias: { pic: namespaces.pic },
|
|
3500
|
+
}).ele('@pic', 'blipFill');
|
|
3501
|
+
var binaryLargeImageOrPictureFragment = buildBinaryLargeImageOrPicture(relationshipId);
|
|
3502
|
+
binaryLargeImageOrPictureFillFragment.import(binaryLargeImageOrPictureFragment);
|
|
3503
|
+
var srcRectFragment = buildSrcRectFragment();
|
|
3504
|
+
binaryLargeImageOrPictureFillFragment.import(srcRectFragment);
|
|
3505
|
+
var stretchFragment = buildStretch();
|
|
3506
|
+
binaryLargeImageOrPictureFillFragment.import(stretchFragment);
|
|
3507
|
+
binaryLargeImageOrPictureFillFragment.up();
|
|
3508
|
+
return binaryLargeImageOrPictureFillFragment;
|
|
3509
|
+
};
|
|
3510
|
+
var ɵ68 = buildBinaryLargeImageOrPictureFill;
|
|
3511
|
+
var buildNonVisualPictureDrawingProperties = function () { return xmlbuilder2.fragment({ namespaceAlias: { pic: namespaces.pic } })
|
|
3512
|
+
.ele('@pic', 'cNvPicPr')
|
|
3513
|
+
.up(); };
|
|
3514
|
+
var ɵ69 = buildNonVisualPictureDrawingProperties;
|
|
3515
|
+
var buildNonVisualDrawingProperties = function (pictureId, pictureNameWithExtension, pictureDescription) {
|
|
3516
|
+
if (pictureDescription === void 0) { pictureDescription = ''; }
|
|
3517
|
+
return xmlbuilder2.fragment({ namespaceAlias: { pic: namespaces.pic } })
|
|
3518
|
+
.ele('@pic', 'cNvPr')
|
|
3519
|
+
.att('id', pictureId)
|
|
3520
|
+
.att('name', pictureNameWithExtension)
|
|
3521
|
+
.att('descr', pictureDescription)
|
|
3522
|
+
.up();
|
|
3523
|
+
};
|
|
3524
|
+
var ɵ70 = buildNonVisualDrawingProperties;
|
|
3525
|
+
var buildNonVisualPictureProperties = function (pictureId, pictureNameWithExtension, pictureDescription) {
|
|
3526
|
+
var nonVisualPicturePropertiesFragment = xmlbuilder2.fragment({
|
|
3527
|
+
namespaceAlias: { pic: namespaces.pic },
|
|
3528
|
+
}).ele('@pic', 'nvPicPr');
|
|
3529
|
+
// TODO: Handle picture attributes
|
|
3530
|
+
var nonVisualDrawingPropertiesFragment = buildNonVisualDrawingProperties(pictureId, pictureNameWithExtension, pictureDescription);
|
|
3531
|
+
nonVisualPicturePropertiesFragment.import(nonVisualDrawingPropertiesFragment);
|
|
3532
|
+
var nonVisualPictureDrawingPropertiesFragment = buildNonVisualPictureDrawingProperties();
|
|
3533
|
+
nonVisualPicturePropertiesFragment.import(nonVisualPictureDrawingPropertiesFragment);
|
|
3534
|
+
nonVisualPicturePropertiesFragment.up();
|
|
3535
|
+
return nonVisualPicturePropertiesFragment;
|
|
3536
|
+
};
|
|
3537
|
+
var ɵ71 = buildNonVisualPictureProperties;
|
|
3538
|
+
var buildPicture = function (_a) {
|
|
3539
|
+
var id = _a.id, fileNameWithExtension = _a.fileNameWithExtension, description = _a.description, relationshipId = _a.relationshipId, width = _a.width, height = _a.height;
|
|
3540
|
+
var pictureFragment = xmlbuilder2.fragment({ namespaceAlias: { pic: namespaces.pic } }).ele('@pic', 'pic');
|
|
3541
|
+
var nonVisualPicturePropertiesFragment = buildNonVisualPictureProperties(id, fileNameWithExtension, description);
|
|
3542
|
+
pictureFragment.import(nonVisualPicturePropertiesFragment);
|
|
3543
|
+
var binaryLargeImageOrPictureFill = buildBinaryLargeImageOrPictureFill(relationshipId);
|
|
3544
|
+
pictureFragment.import(binaryLargeImageOrPictureFill);
|
|
3545
|
+
var shapeProperties = buildShapeProperties({ width: width, height: height });
|
|
3546
|
+
pictureFragment.import(shapeProperties);
|
|
3547
|
+
pictureFragment.up();
|
|
3548
|
+
return pictureFragment;
|
|
3549
|
+
};
|
|
3550
|
+
var ɵ72 = buildPicture;
|
|
3551
|
+
var buildGraphicData = function (graphicType, attributes) {
|
|
3552
|
+
var graphicDataFragment = xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } })
|
|
3553
|
+
.ele('@a', 'graphicData')
|
|
3554
|
+
.att('uri', 'http://schemas.openxmlformats.org/drawingml/2006/picture');
|
|
3555
|
+
if (graphicType === 'picture') {
|
|
3556
|
+
var pictureFragment = buildPicture(attributes);
|
|
3557
|
+
graphicDataFragment.import(pictureFragment);
|
|
3558
|
+
}
|
|
3559
|
+
graphicDataFragment.up();
|
|
3560
|
+
return graphicDataFragment;
|
|
3561
|
+
};
|
|
3562
|
+
var ɵ73 = buildGraphicData;
|
|
3563
|
+
var buildGraphic = function (graphicType, attributes) {
|
|
3564
|
+
var graphicFragment = xmlbuilder2.fragment({ namespaceAlias: { a: namespaces.a } }).ele('@a', 'graphic');
|
|
3565
|
+
// TODO: Handle drawing type
|
|
3566
|
+
var graphicDataFragment = buildGraphicData(graphicType, attributes);
|
|
3567
|
+
graphicFragment.import(graphicDataFragment);
|
|
3568
|
+
graphicFragment.up();
|
|
3569
|
+
return graphicFragment;
|
|
3570
|
+
};
|
|
3571
|
+
var ɵ74 = buildGraphic;
|
|
3572
|
+
var buildDrawingObjectNonVisualProperties = function (pictureId, pictureName) { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3573
|
+
.ele('@wp', 'docPr')
|
|
3574
|
+
.att('id', pictureId)
|
|
3575
|
+
.att('name', pictureName)
|
|
3576
|
+
.up(); };
|
|
3577
|
+
var ɵ75 = buildDrawingObjectNonVisualProperties;
|
|
3578
|
+
var buildWrapSquare = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3579
|
+
.ele('@wp', 'wrapSquare')
|
|
3580
|
+
.att('wrapText', 'bothSides')
|
|
3581
|
+
.att('distB', '228600')
|
|
3582
|
+
.att('distT', '228600')
|
|
3583
|
+
.att('distL', '228600')
|
|
3584
|
+
.att('distR', '228600')
|
|
3585
|
+
.up(); };
|
|
3586
|
+
var ɵ76 = buildWrapSquare;
|
|
3587
|
+
// eslint-disable-next-line no-unused-vars
|
|
3588
|
+
var buildWrapNone = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3589
|
+
.ele('@wp', 'wrapNone')
|
|
3590
|
+
.up(); };
|
|
3591
|
+
var ɵ77 = buildWrapNone;
|
|
3592
|
+
var buildEffectExtentFragment = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3593
|
+
.ele('@wp', 'effectExtent')
|
|
3594
|
+
.att('b', '0')
|
|
3595
|
+
.att('l', '0')
|
|
3596
|
+
.att('r', '0')
|
|
3597
|
+
.att('t', '0')
|
|
3598
|
+
.up(); };
|
|
3599
|
+
var ɵ78 = buildEffectExtentFragment;
|
|
3600
|
+
var buildExtent = function (_a) {
|
|
3601
|
+
var width = _a.width, height = _a.height;
|
|
3602
|
+
return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3603
|
+
.ele('@wp', 'extent')
|
|
3604
|
+
.att('cx', width)
|
|
3605
|
+
.att('cy', height)
|
|
3606
|
+
.up();
|
|
3607
|
+
};
|
|
3608
|
+
var ɵ79 = buildExtent;
|
|
3609
|
+
var buildPositionV = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3610
|
+
.ele('@wp', 'positionV')
|
|
3611
|
+
.att('relativeFrom', 'paragraph')
|
|
3612
|
+
.ele('@wp', 'posOffset')
|
|
3613
|
+
.txt('19050')
|
|
3614
|
+
.up()
|
|
3615
|
+
.up(); };
|
|
3616
|
+
var ɵ80 = buildPositionV;
|
|
3617
|
+
var buildPositionH = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3618
|
+
.ele('@wp', 'positionH')
|
|
3619
|
+
.att('relativeFrom', 'column')
|
|
3620
|
+
.ele('@wp', 'posOffset')
|
|
3621
|
+
.txt('19050')
|
|
3622
|
+
.up()
|
|
3623
|
+
.up(); };
|
|
3624
|
+
var ɵ81 = buildPositionH;
|
|
3625
|
+
var buildSimplePos = function () { return xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3626
|
+
.ele('@wp', 'simplePos')
|
|
3627
|
+
.att('x', '0')
|
|
3628
|
+
.att('y', '0')
|
|
3629
|
+
.up(); };
|
|
3630
|
+
var ɵ82 = buildSimplePos;
|
|
3631
|
+
var buildAnchoredDrawing = function (graphicType, attributes) {
|
|
3632
|
+
var anchoredDrawingFragment = xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3633
|
+
.ele('@wp', 'anchor')
|
|
3634
|
+
.att('distB', '0')
|
|
3635
|
+
.att('distL', '0')
|
|
3636
|
+
.att('distR', '0')
|
|
3637
|
+
.att('distT', '0')
|
|
3638
|
+
.att('relativeHeight', '0')
|
|
3639
|
+
.att('behindDoc', 'false')
|
|
3640
|
+
.att('locked', 'true')
|
|
3641
|
+
.att('layoutInCell', 'true')
|
|
3642
|
+
.att('allowOverlap', 'false')
|
|
3643
|
+
.att('simplePos', 'false');
|
|
3644
|
+
// Even though simplePos isnt supported by Word 2007 simplePos is required.
|
|
3645
|
+
var simplePosFragment = buildSimplePos();
|
|
3646
|
+
anchoredDrawingFragment.import(simplePosFragment);
|
|
3647
|
+
var positionHFragment = buildPositionH();
|
|
3648
|
+
anchoredDrawingFragment.import(positionHFragment);
|
|
3649
|
+
var positionVFragment = buildPositionV();
|
|
3650
|
+
anchoredDrawingFragment.import(positionVFragment);
|
|
3651
|
+
var extentFragment = buildExtent({ width: attributes.width, height: attributes.height });
|
|
3652
|
+
anchoredDrawingFragment.import(extentFragment);
|
|
3653
|
+
var effectExtentFragment = buildEffectExtentFragment();
|
|
3654
|
+
anchoredDrawingFragment.import(effectExtentFragment);
|
|
3655
|
+
var wrapSquareFragment = buildWrapSquare();
|
|
3656
|
+
anchoredDrawingFragment.import(wrapSquareFragment);
|
|
3657
|
+
var drawingObjectNonVisualPropertiesFragment = buildDrawingObjectNonVisualProperties(attributes.id, attributes.fileNameWithExtension);
|
|
3658
|
+
anchoredDrawingFragment.import(drawingObjectNonVisualPropertiesFragment);
|
|
3659
|
+
var graphicFragment = buildGraphic(graphicType, attributes);
|
|
3660
|
+
anchoredDrawingFragment.import(graphicFragment);
|
|
3661
|
+
anchoredDrawingFragment.up();
|
|
3662
|
+
return anchoredDrawingFragment;
|
|
3663
|
+
};
|
|
3664
|
+
var ɵ83 = buildAnchoredDrawing;
|
|
3665
|
+
var buildInlineDrawing = function (graphicType, attributes) {
|
|
3666
|
+
var inlineDrawingFragment = xmlbuilder2.fragment({ namespaceAlias: { wp: namespaces.wp } })
|
|
3667
|
+
.ele('@wp', 'inline')
|
|
3668
|
+
.att('distB', '0')
|
|
3669
|
+
.att('distL', '0')
|
|
3670
|
+
.att('distR', '0')
|
|
3671
|
+
.att('distT', '0');
|
|
3672
|
+
var extentFragment = buildExtent({ width: attributes.width, height: attributes.height });
|
|
3673
|
+
inlineDrawingFragment.import(extentFragment);
|
|
3674
|
+
var effectExtentFragment = buildEffectExtentFragment();
|
|
3675
|
+
inlineDrawingFragment.import(effectExtentFragment);
|
|
3676
|
+
var drawingObjectNonVisualPropertiesFragment = buildDrawingObjectNonVisualProperties(attributes.id, attributes.fileNameWithExtension);
|
|
3677
|
+
inlineDrawingFragment.import(drawingObjectNonVisualPropertiesFragment);
|
|
3678
|
+
var graphicFragment = buildGraphic(graphicType, attributes);
|
|
3679
|
+
inlineDrawingFragment.import(graphicFragment);
|
|
3680
|
+
inlineDrawingFragment.up();
|
|
3681
|
+
return inlineDrawingFragment;
|
|
3682
|
+
};
|
|
3683
|
+
var ɵ84 = buildInlineDrawing;
|
|
3684
|
+
var buildDrawing = function (inlineOrAnchored, graphicType, attributes) {
|
|
3685
|
+
if (inlineOrAnchored === void 0) { inlineOrAnchored = false; }
|
|
3686
|
+
var drawingFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'drawing');
|
|
3687
|
+
var inlineOrAnchoredDrawingFragment = inlineOrAnchored
|
|
3688
|
+
? buildInlineDrawing(graphicType, attributes)
|
|
3689
|
+
: buildAnchoredDrawing(graphicType, attributes);
|
|
3690
|
+
drawingFragment.import(inlineOrAnchoredDrawingFragment);
|
|
3691
|
+
drawingFragment.up();
|
|
3692
|
+
return drawingFragment;
|
|
3693
|
+
};
|
|
3694
|
+
var ɵ85 = buildDrawing;
|
|
3695
|
+
|
|
3696
|
+
var convertHTML$1 = HTMLToVDOM__default["default"]({
|
|
3697
|
+
VNode: VNode__default["default"],
|
|
3698
|
+
VText: VText__default["default"],
|
|
3699
|
+
});
|
|
3700
|
+
// eslint-disable-next-line consistent-return, no-shadow
|
|
3701
|
+
var buildImage = function (docxDocumentInstance, vNode, maximumWidth) {
|
|
3702
|
+
if (maximumWidth === void 0) { maximumWidth = null; }
|
|
3703
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
3704
|
+
var response, base64Uri, imageSource, base64String, error_1, documentRelsId, imageBuffer, imageProperties, imageFragment;
|
|
3705
|
+
return __generator(this, function (_a) {
|
|
3706
|
+
switch (_a.label) {
|
|
3707
|
+
case 0:
|
|
3708
|
+
response = null;
|
|
3709
|
+
base64Uri = null;
|
|
3710
|
+
_a.label = 1;
|
|
3711
|
+
case 1:
|
|
3712
|
+
_a.trys.push([1, 5, , 6]);
|
|
3713
|
+
imageSource = vNode.properties.src;
|
|
3714
|
+
if (!isValidUrl(imageSource)) return [3 /*break*/, 3];
|
|
3715
|
+
return [4 /*yield*/, imageToBase64__default["default"](imageSource).catch(function (error) {
|
|
3716
|
+
// eslint-disable-next-line no-console
|
|
3717
|
+
console.warning("skipping image download and conversion due to " + error);
|
|
3718
|
+
})];
|
|
3719
|
+
case 2:
|
|
3720
|
+
base64String = _a.sent();
|
|
3721
|
+
if (base64String) {
|
|
3722
|
+
base64Uri = "data:" + mimeTypes__default["default"].lookup(imageSource) + ";base64, " + base64String;
|
|
3723
|
+
}
|
|
3724
|
+
return [3 /*break*/, 4];
|
|
3725
|
+
case 3:
|
|
3726
|
+
base64Uri = decodeURIComponent(vNode.properties.src);
|
|
3727
|
+
_a.label = 4;
|
|
3728
|
+
case 4:
|
|
3729
|
+
if (base64Uri) {
|
|
3730
|
+
response = docxDocumentInstance.createMediaFile(base64Uri);
|
|
3731
|
+
}
|
|
3732
|
+
return [3 /*break*/, 6];
|
|
3733
|
+
case 5:
|
|
3734
|
+
error_1 = _a.sent();
|
|
3735
|
+
return [3 /*break*/, 6];
|
|
3736
|
+
case 6:
|
|
3737
|
+
if (!response) return [3 /*break*/, 8];
|
|
3738
|
+
docxDocumentInstance.zip
|
|
3739
|
+
.folder('word')
|
|
3740
|
+
.folder('media')
|
|
3741
|
+
.file(response.fileNameWithExtension, Buffer.from(response.fileContent, 'base64'), {
|
|
3742
|
+
createFolders: false,
|
|
3743
|
+
});
|
|
3744
|
+
documentRelsId = docxDocumentInstance.createDocumentRelationships(docxDocumentInstance.relationshipFilename, imageType, "media/" + response.fileNameWithExtension, internalRelationship);
|
|
3745
|
+
imageBuffer = Buffer.from(response.fileContent, 'base64');
|
|
3746
|
+
imageProperties = sizeOf__default["default"](imageBuffer);
|
|
3747
|
+
return [4 /*yield*/, buildParagraph(vNode, Object.assign(Object.assign({ type: 'picture', inlineOrAnchored: true, relationshipId: documentRelsId }, response), { maximumWidth: maximumWidth || docxDocumentInstance.availableDocumentSpace, originalWidth: imageProperties.width, originalHeight: imageProperties.height }), docxDocumentInstance)];
|
|
3748
|
+
case 7:
|
|
3749
|
+
imageFragment = _a.sent();
|
|
3750
|
+
return [2 /*return*/, imageFragment];
|
|
3751
|
+
case 8: return [2 /*return*/];
|
|
3752
|
+
}
|
|
3753
|
+
});
|
|
3754
|
+
});
|
|
3755
|
+
};
|
|
3756
|
+
var buildList = function (vNode, docxDocumentInstance, xmlFragment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3757
|
+
var listElements, vNodeObjects, _loop_1;
|
|
3758
|
+
return __generator(this, function (_a) {
|
|
3759
|
+
switch (_a.label) {
|
|
3760
|
+
case 0:
|
|
3761
|
+
listElements = [];
|
|
3762
|
+
vNodeObjects = [
|
|
3763
|
+
{
|
|
3764
|
+
node: vNode,
|
|
3765
|
+
level: 0,
|
|
3766
|
+
type: vNode.tagName,
|
|
3767
|
+
numberingId: docxDocumentInstance.createNumbering(vNode.tagName, vNode.properties),
|
|
3768
|
+
},
|
|
3769
|
+
];
|
|
3770
|
+
_loop_1 = function () {
|
|
3771
|
+
var tempVNodeObject, paragraphFragment, tempVNodeObjects;
|
|
3772
|
+
return __generator(this, function (_b) {
|
|
3773
|
+
switch (_b.label) {
|
|
3774
|
+
case 0:
|
|
3775
|
+
tempVNodeObject = vNodeObjects.shift();
|
|
3776
|
+
if (!(isVText__default["default"](tempVNodeObject.node) ||
|
|
3777
|
+
(isVNode__default["default"](tempVNodeObject.node) && !['ul', 'ol', 'li'].includes(tempVNodeObject.node.tagName)))) return [3 /*break*/, 2];
|
|
3778
|
+
return [4 /*yield*/, buildParagraph(tempVNodeObject.node, {
|
|
3779
|
+
numbering: { levelId: tempVNodeObject.level, numberingId: tempVNodeObject.numberingId },
|
|
3780
|
+
}, docxDocumentInstance)];
|
|
3781
|
+
case 1:
|
|
3782
|
+
paragraphFragment = _b.sent();
|
|
3783
|
+
xmlFragment.import(paragraphFragment);
|
|
3784
|
+
_b.label = 2;
|
|
3785
|
+
case 2:
|
|
3786
|
+
if (tempVNodeObject.node.children &&
|
|
3787
|
+
tempVNodeObject.node.children.length &&
|
|
3788
|
+
['ul', 'ol', 'li'].includes(tempVNodeObject.node.tagName)) {
|
|
3789
|
+
tempVNodeObjects = tempVNodeObject.node.children.reduce(function (accumulator, childVNode) {
|
|
3790
|
+
if (['ul', 'ol'].includes(childVNode.tagName)) {
|
|
3791
|
+
accumulator.push({
|
|
3792
|
+
node: childVNode,
|
|
3793
|
+
level: tempVNodeObject.level + 1,
|
|
3794
|
+
type: childVNode.tagName,
|
|
3795
|
+
numberingId: docxDocumentInstance.createNumbering(childVNode.tagName, childVNode.properties),
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
else {
|
|
3799
|
+
// eslint-disable-next-line no-lonely-if
|
|
3800
|
+
if (accumulator.length > 0 &&
|
|
3801
|
+
isVNode__default["default"](accumulator[accumulator.length - 1].node) &&
|
|
3802
|
+
accumulator[accumulator.length - 1].node.tagName.toLowerCase() === 'p') {
|
|
3803
|
+
accumulator[accumulator.length - 1].node.children.push(childVNode);
|
|
3804
|
+
}
|
|
3805
|
+
else {
|
|
3806
|
+
var paragraphVNode = new VNode__default["default"]('p', null,
|
|
3807
|
+
// eslint-disable-next-line no-nested-ternary
|
|
3808
|
+
isVText__default["default"](childVNode)
|
|
3809
|
+
? [childVNode]
|
|
3810
|
+
: // eslint-disable-next-line no-nested-ternary
|
|
3811
|
+
isVNode__default["default"](childVNode)
|
|
3812
|
+
? childVNode.tagName.toLowerCase() === 'li'
|
|
3813
|
+
? __spreadArray([], __read(childVNode.children)) : [childVNode]
|
|
3814
|
+
: []);
|
|
3815
|
+
accumulator.push({
|
|
3816
|
+
// eslint-disable-next-line prettier/prettier, no-nested-ternary
|
|
3817
|
+
node: isVNode__default["default"](childVNode)
|
|
3818
|
+
? // eslint-disable-next-line prettier/prettier, no-nested-ternary
|
|
3819
|
+
childVNode.tagName.toLowerCase() === 'li'
|
|
3820
|
+
? childVNode
|
|
3821
|
+
: childVNode.tagName.toLowerCase() !== 'p'
|
|
3822
|
+
? paragraphVNode
|
|
3823
|
+
: childVNode
|
|
3824
|
+
: // eslint-disable-next-line prettier/prettier
|
|
3825
|
+
paragraphVNode,
|
|
3826
|
+
level: tempVNodeObject.level,
|
|
3827
|
+
type: tempVNodeObject.type,
|
|
3828
|
+
numberingId: tempVNodeObject.numberingId,
|
|
3829
|
+
});
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
return accumulator;
|
|
3833
|
+
}, []);
|
|
3834
|
+
vNodeObjects = tempVNodeObjects.concat(vNodeObjects);
|
|
3835
|
+
}
|
|
3836
|
+
return [2 /*return*/];
|
|
3837
|
+
}
|
|
3838
|
+
});
|
|
3839
|
+
};
|
|
3840
|
+
_a.label = 1;
|
|
3841
|
+
case 1:
|
|
3842
|
+
if (!vNodeObjects.length) return [3 /*break*/, 3];
|
|
3843
|
+
return [5 /*yield**/, _loop_1()];
|
|
3844
|
+
case 2:
|
|
3845
|
+
_a.sent();
|
|
3846
|
+
return [3 /*break*/, 1];
|
|
3847
|
+
case 3: return [2 /*return*/, listElements];
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
}); };
|
|
3851
|
+
function findXMLEquivalent(docxDocumentInstance, vNode, xmlFragment) {
|
|
3852
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3853
|
+
var paragraphFragment, _a, headingFragment, paragraphFragment, index, childVNode, tableFragment_1, emptyParagraphFragment_1, imageFragment_1, tableFragment, emptyParagraphFragment, imageFragment, linebreakFragment, index, childVNode;
|
|
3854
|
+
return __generator(this, function (_b) {
|
|
3855
|
+
switch (_b.label) {
|
|
3856
|
+
case 0:
|
|
3857
|
+
if (vNode.tagName === 'div' &&
|
|
3858
|
+
(vNode.properties.attributes.class === 'page-break' ||
|
|
3859
|
+
(vNode.properties.style && vNode.properties.style['page-break-after']))) {
|
|
3860
|
+
paragraphFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
3861
|
+
.ele('@w', 'p')
|
|
3862
|
+
.ele('@w', 'r')
|
|
3863
|
+
.ele('@w', 'br')
|
|
3864
|
+
.att('@w', 'type', 'page')
|
|
3865
|
+
.up()
|
|
3866
|
+
.up()
|
|
3867
|
+
.up();
|
|
3868
|
+
xmlFragment.import(paragraphFragment);
|
|
3869
|
+
return [2 /*return*/];
|
|
3870
|
+
}
|
|
3871
|
+
_a = vNode.tagName;
|
|
3872
|
+
switch (_a) {
|
|
3873
|
+
case 'h1': return [3 /*break*/, 1];
|
|
3874
|
+
case 'h2': return [3 /*break*/, 1];
|
|
3875
|
+
case 'h3': return [3 /*break*/, 1];
|
|
3876
|
+
case 'h4': return [3 /*break*/, 1];
|
|
3877
|
+
case 'h5': return [3 /*break*/, 1];
|
|
3878
|
+
case 'h6': return [3 /*break*/, 1];
|
|
3879
|
+
case 'span': return [3 /*break*/, 3];
|
|
3880
|
+
case 'strong': return [3 /*break*/, 3];
|
|
3881
|
+
case 'b': return [3 /*break*/, 3];
|
|
3882
|
+
case 'em': return [3 /*break*/, 3];
|
|
3883
|
+
case 'i': return [3 /*break*/, 3];
|
|
3884
|
+
case 'u': return [3 /*break*/, 3];
|
|
3885
|
+
case 'ins': return [3 /*break*/, 3];
|
|
3886
|
+
case 'strike': return [3 /*break*/, 3];
|
|
3887
|
+
case 'del': return [3 /*break*/, 3];
|
|
3888
|
+
case 's': return [3 /*break*/, 3];
|
|
3889
|
+
case 'sub': return [3 /*break*/, 3];
|
|
3890
|
+
case 'sup': return [3 /*break*/, 3];
|
|
3891
|
+
case 'mark': return [3 /*break*/, 3];
|
|
3892
|
+
case 'p': return [3 /*break*/, 3];
|
|
3893
|
+
case 'a': return [3 /*break*/, 3];
|
|
3894
|
+
case 'blockquote': return [3 /*break*/, 3];
|
|
3895
|
+
case 'code': return [3 /*break*/, 3];
|
|
3896
|
+
case 'pre': return [3 /*break*/, 3];
|
|
3897
|
+
case 'figure': return [3 /*break*/, 5];
|
|
3898
|
+
case 'table': return [3 /*break*/, 13];
|
|
3899
|
+
case 'ol': return [3 /*break*/, 16];
|
|
3900
|
+
case 'ul': return [3 /*break*/, 16];
|
|
3901
|
+
case 'img': return [3 /*break*/, 18];
|
|
3902
|
+
case 'br': return [3 /*break*/, 20];
|
|
3903
|
+
}
|
|
3904
|
+
return [3 /*break*/, 22];
|
|
3905
|
+
case 1: return [4 /*yield*/, buildParagraph(vNode, {
|
|
3906
|
+
paragraphStyle: "Heading" + vNode.tagName[1],
|
|
3907
|
+
}, docxDocumentInstance)];
|
|
3908
|
+
case 2:
|
|
3909
|
+
headingFragment = _b.sent();
|
|
3910
|
+
xmlFragment.import(headingFragment);
|
|
3911
|
+
return [2 /*return*/];
|
|
3912
|
+
case 3: return [4 /*yield*/, buildParagraph(vNode, {}, docxDocumentInstance)];
|
|
3913
|
+
case 4:
|
|
3914
|
+
paragraphFragment = _b.sent();
|
|
3915
|
+
xmlFragment.import(paragraphFragment);
|
|
3916
|
+
return [2 /*return*/];
|
|
3917
|
+
case 5:
|
|
3918
|
+
if (!vNodeHasChildren(vNode)) return [3 /*break*/, 12];
|
|
3919
|
+
index = 0;
|
|
3920
|
+
_b.label = 6;
|
|
3921
|
+
case 6:
|
|
3922
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 12];
|
|
3923
|
+
childVNode = vNode.children[index];
|
|
3924
|
+
if (!(childVNode.tagName === 'table')) return [3 /*break*/, 9];
|
|
3925
|
+
return [4 /*yield*/, buildTable(childVNode, {
|
|
3926
|
+
maximumWidth: docxDocumentInstance.availableDocumentSpace,
|
|
3927
|
+
rowCantSplit: docxDocumentInstance.tableRowCantSplit,
|
|
3928
|
+
}, docxDocumentInstance)];
|
|
3929
|
+
case 7:
|
|
3930
|
+
tableFragment_1 = _b.sent();
|
|
3931
|
+
xmlFragment.import(tableFragment_1);
|
|
3932
|
+
return [4 /*yield*/, buildParagraph(null, {})];
|
|
3933
|
+
case 8:
|
|
3934
|
+
emptyParagraphFragment_1 = _b.sent();
|
|
3935
|
+
xmlFragment.import(emptyParagraphFragment_1);
|
|
3936
|
+
return [3 /*break*/, 11];
|
|
3937
|
+
case 9:
|
|
3938
|
+
if (!(childVNode.tagName === 'img')) return [3 /*break*/, 11];
|
|
3939
|
+
return [4 /*yield*/, buildImage(docxDocumentInstance, childVNode)];
|
|
3940
|
+
case 10:
|
|
3941
|
+
imageFragment_1 = _b.sent();
|
|
3942
|
+
if (imageFragment_1) {
|
|
3943
|
+
xmlFragment.import(imageFragment_1);
|
|
3944
|
+
}
|
|
3945
|
+
_b.label = 11;
|
|
3946
|
+
case 11:
|
|
3947
|
+
index++;
|
|
3948
|
+
return [3 /*break*/, 6];
|
|
3949
|
+
case 12: return [2 /*return*/];
|
|
3950
|
+
case 13: return [4 /*yield*/, buildTable(vNode, {
|
|
3951
|
+
maximumWidth: docxDocumentInstance.availableDocumentSpace,
|
|
3952
|
+
rowCantSplit: docxDocumentInstance.tableRowCantSplit,
|
|
3953
|
+
}, docxDocumentInstance)];
|
|
3954
|
+
case 14:
|
|
3955
|
+
tableFragment = _b.sent();
|
|
3956
|
+
xmlFragment.import(tableFragment);
|
|
3957
|
+
return [4 /*yield*/, buildParagraph(null, {})];
|
|
3958
|
+
case 15:
|
|
3959
|
+
emptyParagraphFragment = _b.sent();
|
|
3960
|
+
xmlFragment.import(emptyParagraphFragment);
|
|
3961
|
+
return [2 /*return*/];
|
|
3962
|
+
case 16: return [4 /*yield*/, buildList(vNode, docxDocumentInstance, xmlFragment)];
|
|
3963
|
+
case 17:
|
|
3964
|
+
_b.sent();
|
|
3965
|
+
return [2 /*return*/];
|
|
3966
|
+
case 18: return [4 /*yield*/, buildImage(docxDocumentInstance, vNode)];
|
|
3967
|
+
case 19:
|
|
3968
|
+
imageFragment = _b.sent();
|
|
3969
|
+
if (imageFragment) {
|
|
3970
|
+
xmlFragment.import(imageFragment);
|
|
3971
|
+
}
|
|
3972
|
+
return [2 /*return*/];
|
|
3973
|
+
case 20: return [4 /*yield*/, buildParagraph(null, {})];
|
|
3974
|
+
case 21:
|
|
3975
|
+
linebreakFragment = _b.sent();
|
|
3976
|
+
xmlFragment.import(linebreakFragment);
|
|
3977
|
+
return [2 /*return*/];
|
|
3978
|
+
case 22:
|
|
3979
|
+
if (!vNodeHasChildren(vNode)) return [3 /*break*/, 26];
|
|
3980
|
+
index = 0;
|
|
3981
|
+
_b.label = 23;
|
|
3982
|
+
case 23:
|
|
3983
|
+
if (!(index < vNode.children.length)) return [3 /*break*/, 26];
|
|
3984
|
+
childVNode = vNode.children[index];
|
|
3985
|
+
// eslint-disable-next-line no-use-before-define
|
|
3986
|
+
return [4 /*yield*/, convertVTreeToXML(docxDocumentInstance, childVNode, xmlFragment)];
|
|
3987
|
+
case 24:
|
|
3988
|
+
// eslint-disable-next-line no-use-before-define
|
|
3989
|
+
_b.sent();
|
|
3990
|
+
_b.label = 25;
|
|
3991
|
+
case 25:
|
|
3992
|
+
index++;
|
|
3993
|
+
return [3 /*break*/, 23];
|
|
3994
|
+
case 26: return [2 /*return*/];
|
|
3995
|
+
}
|
|
3996
|
+
});
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3999
|
+
// eslint-disable-next-line consistent-return
|
|
4000
|
+
function convertVTreeToXML(docxDocumentInstance, vTree, xmlFragment) {
|
|
4001
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4002
|
+
var index, vNode;
|
|
4003
|
+
return __generator(this, function (_a) {
|
|
4004
|
+
switch (_a.label) {
|
|
4005
|
+
case 0:
|
|
4006
|
+
if (!vTree) {
|
|
4007
|
+
// eslint-disable-next-line no-useless-return
|
|
4008
|
+
return [2 /*return*/, ''];
|
|
4009
|
+
}
|
|
4010
|
+
if (!(Array.isArray(vTree) && vTree.length)) return [3 /*break*/, 5];
|
|
4011
|
+
index = 0;
|
|
4012
|
+
_a.label = 1;
|
|
4013
|
+
case 1:
|
|
4014
|
+
if (!(index < vTree.length)) return [3 /*break*/, 4];
|
|
4015
|
+
vNode = vTree[index];
|
|
4016
|
+
return [4 /*yield*/, convertVTreeToXML(docxDocumentInstance, vNode, xmlFragment)];
|
|
4017
|
+
case 2:
|
|
4018
|
+
_a.sent();
|
|
4019
|
+
_a.label = 3;
|
|
4020
|
+
case 3:
|
|
4021
|
+
index++;
|
|
4022
|
+
return [3 /*break*/, 1];
|
|
4023
|
+
case 4: return [3 /*break*/, 8];
|
|
4024
|
+
case 5:
|
|
4025
|
+
if (!isVNode__default["default"](vTree)) return [3 /*break*/, 7];
|
|
4026
|
+
return [4 /*yield*/, findXMLEquivalent(docxDocumentInstance, vTree, xmlFragment)];
|
|
4027
|
+
case 6:
|
|
4028
|
+
_a.sent();
|
|
4029
|
+
return [3 /*break*/, 8];
|
|
4030
|
+
case 7:
|
|
4031
|
+
if (isVText__default["default"](vTree)) {
|
|
4032
|
+
buildTextElement(xmlFragment, escape__default["default"](String(vTree.text)));
|
|
4033
|
+
}
|
|
4034
|
+
_a.label = 8;
|
|
4035
|
+
case 8: return [2 /*return*/, xmlFragment];
|
|
4036
|
+
}
|
|
4037
|
+
});
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
function renderDocumentFile(docxDocumentInstance) {
|
|
4041
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4042
|
+
var vTree, xmlFragment, populatedXmlFragment;
|
|
4043
|
+
return __generator(this, function (_a) {
|
|
4044
|
+
switch (_a.label) {
|
|
4045
|
+
case 0:
|
|
4046
|
+
vTree = convertHTML$1(docxDocumentInstance.htmlString);
|
|
4047
|
+
xmlFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } });
|
|
4048
|
+
return [4 /*yield*/, convertVTreeToXML(docxDocumentInstance, vTree, xmlFragment)];
|
|
4049
|
+
case 1:
|
|
4050
|
+
populatedXmlFragment = _a.sent();
|
|
4051
|
+
return [2 /*return*/, populatedXmlFragment];
|
|
4052
|
+
}
|
|
4053
|
+
});
|
|
4054
|
+
});
|
|
4055
|
+
}
|
|
4056
|
+
|
|
4057
|
+
/* eslint-disable import/prefer-default-export */
|
|
4058
|
+
|
|
4059
|
+
var ListStyleBuilder = /** @class */ (function () {
|
|
4060
|
+
// defaults is an object passed in from constants.js / numbering with the following properties:
|
|
4061
|
+
// defaultOrderedListStyleType: 'decimal' (unless otherwise specified)
|
|
4062
|
+
function ListStyleBuilder(defaults) {
|
|
4063
|
+
this.defaults = defaults || { defaultOrderedListStyleType: 'decimal' };
|
|
4064
|
+
}
|
|
4065
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4066
|
+
ListStyleBuilder.prototype.getListStyleType = function (listType) {
|
|
4067
|
+
switch (listType) {
|
|
4068
|
+
case 'upper-roman':
|
|
4069
|
+
return 'upperRoman';
|
|
4070
|
+
case 'lower-roman':
|
|
4071
|
+
return 'lowerRoman';
|
|
4072
|
+
case 'upper-alpha':
|
|
4073
|
+
case 'upper-alpha-bracket-end':
|
|
4074
|
+
return 'upperLetter';
|
|
4075
|
+
case 'lower-alpha':
|
|
4076
|
+
case 'lower-alpha-bracket-end':
|
|
4077
|
+
return 'lowerLetter';
|
|
4078
|
+
case 'decimal':
|
|
4079
|
+
case 'decimal-bracket':
|
|
4080
|
+
return 'decimal';
|
|
4081
|
+
default:
|
|
4082
|
+
return this.defaults.defaultOrderedListStyleType;
|
|
4083
|
+
}
|
|
4084
|
+
};
|
|
4085
|
+
ListStyleBuilder.prototype.getListPrefixSuffix = function (style, lvl) {
|
|
4086
|
+
var listType = this.defaults.defaultOrderedListStyleType;
|
|
4087
|
+
if (style && style['list-style-type']) {
|
|
4088
|
+
listType = style['list-style-type'];
|
|
4089
|
+
}
|
|
4090
|
+
switch (listType) {
|
|
4091
|
+
case 'upper-roman':
|
|
4092
|
+
case 'lower-roman':
|
|
4093
|
+
case 'upper-alpha':
|
|
4094
|
+
case 'lower-alpha':
|
|
4095
|
+
return "%" + (lvl + 1) + ".";
|
|
4096
|
+
case 'upper-alpha-bracket-end':
|
|
4097
|
+
case 'lower-alpha-bracket-end':
|
|
4098
|
+
case 'decimal-bracket-end':
|
|
4099
|
+
return "%" + (lvl + 1) + ")";
|
|
4100
|
+
case 'decimal-bracket':
|
|
4101
|
+
return "(%" + (lvl + 1) + ")";
|
|
4102
|
+
case 'decimal':
|
|
4103
|
+
default:
|
|
4104
|
+
return "%" + (lvl + 1) + ".";
|
|
4105
|
+
}
|
|
4106
|
+
};
|
|
4107
|
+
return ListStyleBuilder;
|
|
4108
|
+
}());
|
|
4109
|
+
|
|
4110
|
+
function generateContentTypesFragments(contentTypesXML, type, objects) {
|
|
4111
|
+
if (objects && Array.isArray(objects)) {
|
|
4112
|
+
objects.forEach(function (object) {
|
|
4113
|
+
var contentTypesFragment = xmlbuilder2.fragment({ defaultNamespace: { ele: namespaces.contentTypes } })
|
|
4114
|
+
.ele('Override')
|
|
4115
|
+
.att('PartName', "/word/" + type + object[type + "Id"] + ".xml")
|
|
4116
|
+
.att('ContentType', "application/vnd.openxmlformats-officedocument.wordprocessingml." + type + "+xml")
|
|
4117
|
+
.up();
|
|
4118
|
+
contentTypesXML.root().import(contentTypesFragment);
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
4121
|
+
}
|
|
4122
|
+
function generateSectionReferenceXML(documentXML, documentSectionType, objects, isEnabled) {
|
|
4123
|
+
if (isEnabled && objects && Array.isArray(objects) && objects.length) {
|
|
4124
|
+
var xmlFragment_1 = xmlbuilder2.fragment();
|
|
4125
|
+
objects.forEach(function (_a) {
|
|
4126
|
+
var relationshipId = _a.relationshipId, type = _a.type;
|
|
4127
|
+
var objectFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w, r: namespaces.r } })
|
|
4128
|
+
.ele('@w', documentSectionType + "Reference")
|
|
4129
|
+
.att('@r', 'id', "rId" + relationshipId)
|
|
4130
|
+
.att('@w', 'type', type)
|
|
4131
|
+
.up();
|
|
4132
|
+
xmlFragment_1.import(objectFragment);
|
|
4133
|
+
});
|
|
4134
|
+
documentXML.root().first().first().import(xmlFragment_1);
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
function generateXMLString(xmlString) {
|
|
4138
|
+
var xmlDocumentString = xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, xmlString);
|
|
4139
|
+
return xmlDocumentString.toString({ prettyPrint: true });
|
|
4140
|
+
}
|
|
4141
|
+
function generateSectionXML(vTree, type) {
|
|
4142
|
+
if (type === void 0) { type = 'header'; }
|
|
4143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4144
|
+
var sectionXML, XMLFragment, referenceName;
|
|
4145
|
+
var _a;
|
|
4146
|
+
return __generator(this, function (_b) {
|
|
4147
|
+
switch (_b.label) {
|
|
4148
|
+
case 0:
|
|
4149
|
+
debugger;
|
|
4150
|
+
sectionXML = xmlbuilder2.create({
|
|
4151
|
+
encoding: 'UTF-8',
|
|
4152
|
+
standalone: true,
|
|
4153
|
+
namespaceAlias: {
|
|
4154
|
+
a: namespaces.a,
|
|
4155
|
+
cdr: namespaces.cdr,
|
|
4156
|
+
o: namespaces.o,
|
|
4157
|
+
pic: namespaces.pic,
|
|
4158
|
+
r: namespaces.r,
|
|
4159
|
+
v: namespaces.v,
|
|
4160
|
+
ve: namespaces.ve,
|
|
4161
|
+
vt: namespaces.vt,
|
|
4162
|
+
w: namespaces.w,
|
|
4163
|
+
w10: namespaces.w10,
|
|
4164
|
+
wp: namespaces.wp,
|
|
4165
|
+
wne: namespaces.wne
|
|
4166
|
+
},
|
|
4167
|
+
}).ele('@w', type === 'header' ? 'hdr' : 'ftr');
|
|
4168
|
+
XMLFragment = xmlbuilder2.fragment();
|
|
4169
|
+
return [4 /*yield*/, convertVTreeToXML(this, vTree, XMLFragment)];
|
|
4170
|
+
case 1:
|
|
4171
|
+
_b.sent();
|
|
4172
|
+
if (type === 'footer' && XMLFragment.first().node.tagName === 'p' && this.pageNumber) {
|
|
4173
|
+
XMLFragment.first().import(xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4174
|
+
.ele('@w', 'fldSimple')
|
|
4175
|
+
.att('@w', 'instr', 'PAGE')
|
|
4176
|
+
.ele('@w', 'r')
|
|
4177
|
+
.up()
|
|
4178
|
+
.up());
|
|
4179
|
+
}
|
|
4180
|
+
sectionXML.root().import(XMLFragment);
|
|
4181
|
+
referenceName = type === 'header' ? 'Header' : 'Footer';
|
|
4182
|
+
this["last" + referenceName + "Id"] += 1;
|
|
4183
|
+
return [2 /*return*/, (_a = {}, _a[type + "Id"] = this["last" + referenceName + "Id"], _a[type + "XML"] = sectionXML, _a)];
|
|
4184
|
+
}
|
|
4185
|
+
});
|
|
4186
|
+
});
|
|
4187
|
+
}
|
|
4188
|
+
var DocxDocument = /** @class */ (function () {
|
|
4189
|
+
function DocxDocument(properties) {
|
|
4190
|
+
this.zip = properties.zip;
|
|
4191
|
+
this.htmlString = properties.htmlString;
|
|
4192
|
+
this.orientation = properties.orientation;
|
|
4193
|
+
this.pageSize = properties.pageSize || defaultDocumentOptions.pageSize;
|
|
4194
|
+
var isPortraitOrientation = this.orientation === defaultOrientation;
|
|
4195
|
+
var height = this.pageSize.height ? this.pageSize.height : landscapeHeight;
|
|
4196
|
+
var width = this.pageSize.width ? this.pageSize.width : landscapeWidth;
|
|
4197
|
+
this.width = isPortraitOrientation ? width : height;
|
|
4198
|
+
this.height = isPortraitOrientation ? height : width;
|
|
4199
|
+
var marginsObject = properties.margins;
|
|
4200
|
+
this.margins =
|
|
4201
|
+
// eslint-disable-next-line no-nested-ternary
|
|
4202
|
+
marginsObject && Object.keys(marginsObject).length
|
|
4203
|
+
? marginsObject
|
|
4204
|
+
: isPortraitOrientation
|
|
4205
|
+
? portraitMargins
|
|
4206
|
+
: landscapeMargins;
|
|
4207
|
+
this.availableDocumentSpace = this.width - this.margins.left - this.margins.right;
|
|
4208
|
+
this.title = properties.title || '';
|
|
4209
|
+
this.subject = properties.subject || '';
|
|
4210
|
+
this.creator = properties.creator || applicationName;
|
|
4211
|
+
this.keywords = properties.keywords || [applicationName];
|
|
4212
|
+
this.description = properties.description || '';
|
|
4213
|
+
this.lastModifiedBy = properties.lastModifiedBy || applicationName;
|
|
4214
|
+
this.revision = properties.revision || 1;
|
|
4215
|
+
this.createdAt = properties.createdAt || new Date();
|
|
4216
|
+
this.modifiedAt = properties.modifiedAt || new Date();
|
|
4217
|
+
this.headerType = properties.headerType || 'default';
|
|
4218
|
+
this.header = properties.header || false;
|
|
4219
|
+
this.footerType = properties.footerType || 'default';
|
|
4220
|
+
this.footer = properties.footer || false;
|
|
4221
|
+
this.font = properties.font || defaultFont;
|
|
4222
|
+
this.fontSize = properties.fontSize || defaultFontSize;
|
|
4223
|
+
this.complexScriptFontSize = properties.complexScriptFontSize || defaultFontSize;
|
|
4224
|
+
this.tableRowCantSplit =
|
|
4225
|
+
(properties.table && properties.table.row && properties.table.row.cantSplit) || false;
|
|
4226
|
+
this.pageNumber = properties.pageNumber || false;
|
|
4227
|
+
this.skipFirstHeaderFooter = properties.skipFirstHeaderFooter || false;
|
|
4228
|
+
this.lineNumber = properties.lineNumber ? properties.lineNumberOptions : null;
|
|
4229
|
+
this.lastNumberingId = 0;
|
|
4230
|
+
this.lastMediaId = 0;
|
|
4231
|
+
this.lastHeaderId = 0;
|
|
4232
|
+
this.lastFooterId = 0;
|
|
4233
|
+
this.stylesObjects = [];
|
|
4234
|
+
this.numberingObjects = [];
|
|
4235
|
+
this.relationshipFilename = documentFileName;
|
|
4236
|
+
this.relationships = [{ fileName: documentFileName, lastRelsId: 4, rels: [] }];
|
|
4237
|
+
this.mediaFiles = [];
|
|
4238
|
+
this.headerObjects = [];
|
|
4239
|
+
this.footerObjects = [];
|
|
4240
|
+
this.documentXML = null;
|
|
4241
|
+
this.generateContentTypesXML = this.generateContentTypesXML.bind(this);
|
|
4242
|
+
this.generateDocumentXML = this.generateDocumentXML.bind(this);
|
|
4243
|
+
this.generateCoreXML = this.generateCoreXML.bind(this);
|
|
4244
|
+
this.generateSettingsXML = this.generateSettingsXML.bind(this);
|
|
4245
|
+
this.generateWebSettingsXML = this.generateWebSettingsXML.bind(this);
|
|
4246
|
+
this.generateStylesXML = this.generateStylesXML.bind(this);
|
|
4247
|
+
this.generateFontTableXML = this.generateFontTableXML.bind(this);
|
|
4248
|
+
this.generateThemeXML = this.generateThemeXML.bind(this);
|
|
4249
|
+
this.generateNumberingXML = this.generateNumberingXML.bind(this);
|
|
4250
|
+
this.generateRelsXML = this.generateRelsXML.bind(this);
|
|
4251
|
+
this.createMediaFile = this.createMediaFile.bind(this);
|
|
4252
|
+
this.createDocumentRelationships = this.createDocumentRelationships.bind(this);
|
|
4253
|
+
this.generateHeaderXML = this.generateHeaderXML.bind(this);
|
|
4254
|
+
this.generateFooterXML = this.generateFooterXML.bind(this);
|
|
4255
|
+
this.generateSectionXML = generateSectionXML.bind(this);
|
|
4256
|
+
this.ListStyleBuilder = new ListStyleBuilder(properties.numbering);
|
|
4257
|
+
}
|
|
4258
|
+
DocxDocument.prototype.generateContentTypesXML = function () {
|
|
4259
|
+
var contentTypesXML$1 = xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, contentTypesXML);
|
|
4260
|
+
generateContentTypesFragments(contentTypesXML$1, 'header', this.headerObjects);
|
|
4261
|
+
generateContentTypesFragments(contentTypesXML$1, 'footer', this.footerObjects);
|
|
4262
|
+
return contentTypesXML$1.toString({ prettyPrint: true });
|
|
4263
|
+
};
|
|
4264
|
+
DocxDocument.prototype.generateDocumentXML = function () {
|
|
4265
|
+
var documentXML = xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, generateDocumentTemplate(this.width, this.height, this.orientation, this.margins));
|
|
4266
|
+
// documentXML.root().first().import(this.documentXML);
|
|
4267
|
+
generateSectionReferenceXML(documentXML, 'header', this.headerObjects, this.header);
|
|
4268
|
+
generateSectionReferenceXML(documentXML, 'footer', this.footerObjects, this.footer);
|
|
4269
|
+
if ((this.header || this.footer) && this.skipFirstHeaderFooter) {
|
|
4270
|
+
documentXML
|
|
4271
|
+
.root()
|
|
4272
|
+
.first()
|
|
4273
|
+
.first()
|
|
4274
|
+
.import(xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } }).ele('@w', 'titlePg'));
|
|
4275
|
+
}
|
|
4276
|
+
if (this.lineNumber) {
|
|
4277
|
+
var _a = this.lineNumber, countBy = _a.countBy, start = _a.start, restart = _a.restart;
|
|
4278
|
+
documentXML
|
|
4279
|
+
.root()
|
|
4280
|
+
.first()
|
|
4281
|
+
.first()
|
|
4282
|
+
.import(xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4283
|
+
.ele('@w', 'lnNumType')
|
|
4284
|
+
.att('@w', 'countBy', countBy)
|
|
4285
|
+
.att('@w', 'start', start)
|
|
4286
|
+
.att('@w', 'restart', restart));
|
|
4287
|
+
}
|
|
4288
|
+
return documentXML.toString({ prettyPrint: true });
|
|
4289
|
+
};
|
|
4290
|
+
DocxDocument.prototype.generateCoreXML = function () {
|
|
4291
|
+
return generateXMLString(generateCoreXML(this.title, this.subject, this.creator, this.keywords, this.description, this.lastModifiedBy, this.revision, this.createdAt, this.modifiedAt));
|
|
4292
|
+
};
|
|
4293
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4294
|
+
DocxDocument.prototype.generateSettingsXML = function () {
|
|
4295
|
+
return generateXMLString(settingsXML);
|
|
4296
|
+
};
|
|
4297
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4298
|
+
DocxDocument.prototype.generateWebSettingsXML = function () {
|
|
4299
|
+
return generateXMLString(webSettingsXML);
|
|
4300
|
+
};
|
|
4301
|
+
DocxDocument.prototype.generateStylesXML = function () {
|
|
4302
|
+
return generateXMLString(generateStylesXML(this.font, this.fontSize, this.complexScriptFontSize));
|
|
4303
|
+
};
|
|
4304
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4305
|
+
DocxDocument.prototype.generateFontTableXML = function () {
|
|
4306
|
+
return generateXMLString(fontTableXML);
|
|
4307
|
+
};
|
|
4308
|
+
DocxDocument.prototype.generateThemeXML = function () {
|
|
4309
|
+
return generateXMLString(generateThemeXML(this.font));
|
|
4310
|
+
};
|
|
4311
|
+
DocxDocument.prototype.generateNumberingXML = function () {
|
|
4312
|
+
var _this = this;
|
|
4313
|
+
var numberingXML = xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, generateNumberingXMLTemplate());
|
|
4314
|
+
var abstractNumberingFragments = xmlbuilder2.fragment();
|
|
4315
|
+
var numberingFragments = xmlbuilder2.fragment();
|
|
4316
|
+
this.numberingObjects.forEach(function (_a) {
|
|
4317
|
+
var numberingId = _a.numberingId, type = _a.type, properties = _a.properties;
|
|
4318
|
+
var abstractNumberingFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4319
|
+
.ele('@w', 'abstractNum')
|
|
4320
|
+
.att('@w', 'abstractNumId', String(numberingId));
|
|
4321
|
+
__spreadArray([], __read(Array(8).keys())).forEach(function (level) {
|
|
4322
|
+
var levelFragment = xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4323
|
+
.ele('@w', 'lvl')
|
|
4324
|
+
.att('@w', 'ilvl', level)
|
|
4325
|
+
.ele('@w', 'start')
|
|
4326
|
+
.att('@w', 'val', type === 'ol'
|
|
4327
|
+
? (properties.attributes && properties.attributes['data-start']) || 1
|
|
4328
|
+
: '1')
|
|
4329
|
+
.up()
|
|
4330
|
+
.ele('@w', 'numFmt')
|
|
4331
|
+
.att('@w', 'val', type === 'ol'
|
|
4332
|
+
? _this.ListStyleBuilder.getListStyleType(properties.style && properties.style['list-style-type'])
|
|
4333
|
+
: 'bullet')
|
|
4334
|
+
.up()
|
|
4335
|
+
.ele('@w', 'lvlText')
|
|
4336
|
+
.att('@w', 'val', type === 'ol' ? _this.ListStyleBuilder.getListPrefixSuffix(properties.style, level) : '')
|
|
4337
|
+
.up()
|
|
4338
|
+
.ele('@w', 'lvlJc')
|
|
4339
|
+
.att('@w', 'val', 'left')
|
|
4340
|
+
.up()
|
|
4341
|
+
.ele('@w', 'pPr')
|
|
4342
|
+
.ele('@w', 'tabs')
|
|
4343
|
+
.ele('@w', 'tab')
|
|
4344
|
+
.att('@w', 'val', 'num')
|
|
4345
|
+
.att('@w', 'pos', (level + 1) * 720)
|
|
4346
|
+
.up()
|
|
4347
|
+
.up()
|
|
4348
|
+
.ele('@w', 'ind')
|
|
4349
|
+
.att('@w', 'left', (level + 1) * 720)
|
|
4350
|
+
.att('@w', 'hanging', 360)
|
|
4351
|
+
.up()
|
|
4352
|
+
.up()
|
|
4353
|
+
.up();
|
|
4354
|
+
if (type === 'ul') {
|
|
4355
|
+
levelFragment.last().import(xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4356
|
+
.ele('@w', 'rPr')
|
|
4357
|
+
.ele('@w', 'rFonts')
|
|
4358
|
+
.att('@w', 'ascii', 'Symbol')
|
|
4359
|
+
.att('@w', 'hAnsi', 'Symbol')
|
|
4360
|
+
.att('@w', 'hint', 'default')
|
|
4361
|
+
.up()
|
|
4362
|
+
.up());
|
|
4363
|
+
}
|
|
4364
|
+
abstractNumberingFragment.import(levelFragment);
|
|
4365
|
+
});
|
|
4366
|
+
abstractNumberingFragment.up();
|
|
4367
|
+
abstractNumberingFragments.import(abstractNumberingFragment);
|
|
4368
|
+
numberingFragments.import(xmlbuilder2.fragment({ namespaceAlias: { w: namespaces.w } })
|
|
4369
|
+
.ele('@w', 'num')
|
|
4370
|
+
.att('@w', 'numId', String(numberingId))
|
|
4371
|
+
.ele('@w', 'abstractNumId')
|
|
4372
|
+
.att('@w', 'val', String(numberingId))
|
|
4373
|
+
.up()
|
|
4374
|
+
.up());
|
|
4375
|
+
});
|
|
4376
|
+
numberingXML.root().import(abstractNumberingFragments);
|
|
4377
|
+
numberingXML.root().import(numberingFragments);
|
|
4378
|
+
return numberingXML.toString({ prettyPrint: true });
|
|
4379
|
+
};
|
|
4380
|
+
// eslint-disable-next-line class-methods-use-this
|
|
4381
|
+
DocxDocument.prototype.appendRelationships = function (xmlFragment, relationships) {
|
|
4382
|
+
relationships.forEach(function (_a) {
|
|
4383
|
+
var relationshipId = _a.relationshipId, type = _a.type, target = _a.target, targetMode = _a.targetMode;
|
|
4384
|
+
xmlFragment.import(xmlbuilder2.fragment({ defaultNamespace: { ele: namespaces.relationship } })
|
|
4385
|
+
.ele('Relationship')
|
|
4386
|
+
.att('Id', "rId" + relationshipId)
|
|
4387
|
+
.att('Type', type)
|
|
4388
|
+
.att('Target', target)
|
|
4389
|
+
.att('TargetMode', targetMode)
|
|
4390
|
+
.up());
|
|
4391
|
+
});
|
|
4392
|
+
};
|
|
4393
|
+
DocxDocument.prototype.generateRelsXML = function () {
|
|
4394
|
+
var _this = this;
|
|
4395
|
+
var relationshipXMLStrings = this.relationships.map(function (_a) {
|
|
4396
|
+
var fileName = _a.fileName, rels = _a.rels;
|
|
4397
|
+
var xmlFragment = xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, fileName === documentFileName ? documentRelsXML : genericRelsXML);
|
|
4398
|
+
_this.appendRelationships(xmlFragment.root(), rels);
|
|
4399
|
+
return { fileName: fileName, xmlString: xmlFragment.toString({ prettyPrint: true }) };
|
|
4400
|
+
});
|
|
4401
|
+
return relationshipXMLStrings;
|
|
4402
|
+
};
|
|
4403
|
+
DocxDocument.prototype.createNumbering = function (type, properties) {
|
|
4404
|
+
this.lastNumberingId += 1;
|
|
4405
|
+
this.numberingObjects.push({ numberingId: this.lastNumberingId, type: type, properties: properties });
|
|
4406
|
+
return this.lastNumberingId;
|
|
4407
|
+
};
|
|
4408
|
+
DocxDocument.prototype.createMediaFile = function (base64String) {
|
|
4409
|
+
// eslint-disable-next-line no-useless-escape
|
|
4410
|
+
var matches = base64String.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/);
|
|
4411
|
+
if (matches.length !== 3) {
|
|
4412
|
+
throw new Error('Invalid base64 string');
|
|
4413
|
+
}
|
|
4414
|
+
var base64FileContent = matches[2];
|
|
4415
|
+
// matches array contains file type in base64 format - image/jpeg and base64 stringified data
|
|
4416
|
+
var fileExtension = matches[1].match(/\/(.*?)$/)[1] === 'octet-stream' ? 'png' : matches[1].match(/\/(.*?)$/)[1];
|
|
4417
|
+
var fileNameWithExtension = "image-" + nanoid.nanoid() + "." + fileExtension;
|
|
4418
|
+
this.lastMediaId += 1;
|
|
4419
|
+
return { id: this.lastMediaId, fileContent: base64FileContent, fileNameWithExtension: fileNameWithExtension };
|
|
4420
|
+
};
|
|
4421
|
+
DocxDocument.prototype.createDocumentRelationships = function (fileName, type, target, targetMode) {
|
|
4422
|
+
if (fileName === void 0) { fileName = 'document'; }
|
|
4423
|
+
if (targetMode === void 0) { targetMode = 'External'; }
|
|
4424
|
+
debugger;
|
|
4425
|
+
var relationshipObject = this.relationships.find(function (relationship) { return relationship.fileName === fileName; });
|
|
4426
|
+
var lastRelsId = 1;
|
|
4427
|
+
if (relationshipObject) {
|
|
4428
|
+
lastRelsId = relationshipObject.lastRelsId + 1;
|
|
4429
|
+
relationshipObject.lastRelsId = lastRelsId;
|
|
4430
|
+
}
|
|
4431
|
+
else {
|
|
4432
|
+
relationshipObject = { fileName: fileName, lastRelsId: lastRelsId, rels: [] };
|
|
4433
|
+
this.relationships.push(relationshipObject);
|
|
4434
|
+
}
|
|
4435
|
+
var relationshipType;
|
|
4436
|
+
switch (type) {
|
|
4437
|
+
case hyperlinkType:
|
|
4438
|
+
relationshipType = namespaces.hyperlinks;
|
|
4439
|
+
break;
|
|
4440
|
+
case imageType:
|
|
4441
|
+
relationshipType = namespaces.images;
|
|
4442
|
+
break;
|
|
4443
|
+
case headerType:
|
|
4444
|
+
relationshipType = namespaces.headers;
|
|
4445
|
+
break;
|
|
4446
|
+
case footerType:
|
|
4447
|
+
relationshipType = namespaces.footers;
|
|
4448
|
+
break;
|
|
4449
|
+
case themeType:
|
|
4450
|
+
relationshipType = namespaces.themes;
|
|
4451
|
+
break;
|
|
4452
|
+
}
|
|
4453
|
+
relationshipObject.rels.push({
|
|
4454
|
+
relationshipId: lastRelsId,
|
|
4455
|
+
type: relationshipType,
|
|
4456
|
+
target: target,
|
|
4457
|
+
targetMode: targetMode,
|
|
4458
|
+
});
|
|
4459
|
+
console.log(fileName);
|
|
4460
|
+
console.log(relationshipObject.rels);
|
|
4461
|
+
return lastRelsId;
|
|
4462
|
+
};
|
|
4463
|
+
DocxDocument.prototype.generateHeaderXML = function (vTree) {
|
|
4464
|
+
return this.generateSectionXML(vTree, 'header');
|
|
4465
|
+
};
|
|
4466
|
+
DocxDocument.prototype.generateFooterXML = function (vTree) {
|
|
4467
|
+
return this.generateSectionXML(vTree, 'footer');
|
|
4468
|
+
};
|
|
4469
|
+
return DocxDocument;
|
|
4470
|
+
}());
|
|
4471
|
+
|
|
4472
|
+
var defaultMargins = {
|
|
4473
|
+
top: 1440,
|
|
4474
|
+
right: 1440,
|
|
4475
|
+
bottom: 1440,
|
|
4476
|
+
left: 1440,
|
|
4477
|
+
header: 720,
|
|
4478
|
+
footer: 720,
|
|
4479
|
+
gutter: 0,
|
|
4480
|
+
};
|
|
4481
|
+
var documentTemplate = function (width, height, orient, margins) {
|
|
4482
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:document\n xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"\n xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\"\n xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"\n xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\"\n xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"\n xmlns:ns6=\"http://schemas.openxmlformats.org/schemaLibrary/2006/main\"\n xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"\n xmlns:ns8=\"http://schemas.openxmlformats.org/drawingml/2006/chartDrawing\"\n xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\"\n xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"\n xmlns:ns11=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\"\n xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\"\n xmlns:ns13=\"urn:schemas-microsoft-com:office:excel\"\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n xmlns:v=\"urn:schemas-microsoft-com:vml\"\n xmlns:w10=\"urn:schemas-microsoft-com:office:word\"\n xmlns:ns17=\"urn:schemas-microsoft-com:office:powerpoint\"\n xmlns:odx=\"http://opendope.org/xpaths\"\n xmlns:odc=\"http://opendope.org/conditions\"\n xmlns:odq=\"http://opendope.org/questions\"\n xmlns:odi=\"http://opendope.org/components\"\n xmlns:odgm=\"http://opendope.org/SmartArt/DataHierarchy\"\n xmlns:ns24=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"\n xmlns:ns25=\"http://schemas.openxmlformats.org/drawingml/2006/compatibility\"\n xmlns:ns26=\"http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas\">\n <w:body>\n <w:altChunk r:id=\"htmlChunk\" />\n <w:sectPr>\n <w:pgSz w:w=\"" + width + "\" w:h=\"" + height + "\" w:orient=\"" + orient + "\" />\n <w:pgMar w:top=\"" + margins.top + "\"\n w:right=\"" + margins.right + "\"\n w:bottom=\"" + margins.bottom + "\"\n w:left=\"" + margins.left + "\"\n w:header=\"" + margins.header + "\"\n w:footer=\"" + margins.footer + "\"\n w:gutter=\"" + margins.gutter + "\"/>\n </w:sectPr>\n </w:body>\n</w:document>\n";
|
|
4483
|
+
};
|
|
4484
|
+
|
|
4485
|
+
var mhtDocumentTemplate = function (htmlSource, contentParts) {
|
|
4486
|
+
debugger;
|
|
4487
|
+
return "MIME-Version: 1.0\nContent-Type: multipart/related;\n type=\"text/html\";\n boundary=\"----=mhtDocumentPart\"\n\n\n------=mhtDocumentPart\nContent-Type: text/html;\n charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\nContent-Location: file:///C:/fake/document.html\n\n" + htmlSource + "\n\n" + contentParts + "\n\n------=mhtDocumentPart--\n";
|
|
4488
|
+
};
|
|
4489
|
+
|
|
4490
|
+
var mhtPartTemplate = function (contentType, contentEncoding, contentLocation, encodedContent) {
|
|
4491
|
+
return "------=mhtDocumentPart\nContent-Type: " + contentType + "\nContent-Transfer-Encoding: " + contentEncoding + "\nContent-Location: " + contentLocation + "\n\n" + encodedContent + "\n";
|
|
4492
|
+
};
|
|
4493
|
+
|
|
4494
|
+
function getMHTdocument(htmlSource) {
|
|
4495
|
+
debugger;
|
|
4496
|
+
var ref = _prepareImageParts(htmlSource);
|
|
4497
|
+
var imageContentPartsString = ref.imageContentParts.join('\n');
|
|
4498
|
+
htmlSource = ref.htmlSource.replace(/\=/g, '=3D');
|
|
4499
|
+
return mhtDocumentTemplate(htmlSource, imageContentPartsString);
|
|
4500
|
+
}
|
|
4501
|
+
function _prepareImageParts(htmlSource) {
|
|
4502
|
+
debugger;
|
|
4503
|
+
var imageContentParts = [];
|
|
4504
|
+
var inlinedSrcPattern = /"data:(\w+\/\w+);(\w+),(\S+)"/g;
|
|
4505
|
+
var inlinedReplacer = function (match, contentType, contentEncoding, encodedContent) {
|
|
4506
|
+
var index = imageContentParts.length;
|
|
4507
|
+
var extension = contentType.split('/')[1];
|
|
4508
|
+
var contentLocation = "file:///C:/fake/image" + index + "." + extension;
|
|
4509
|
+
imageContentParts.push(mhtPartTemplate(contentType, contentEncoding, contentLocation, encodedContent));
|
|
4510
|
+
return "\"" + contentLocation + "\"";
|
|
4511
|
+
};
|
|
4512
|
+
if (!/<img/g.test(htmlSource)) {
|
|
4513
|
+
return { htmlSource: htmlSource, imageContentParts: imageContentParts };
|
|
4514
|
+
}
|
|
4515
|
+
htmlSource = htmlSource.replace(inlinedSrcPattern, inlinedReplacer);
|
|
4516
|
+
return { htmlSource: htmlSource, imageContentParts: imageContentParts };
|
|
4517
|
+
}
|
|
4518
|
+
|
|
4519
|
+
var convertHTML = HTMLToVDOM__default["default"]({
|
|
4520
|
+
VNode: VNode__default["default"],
|
|
4521
|
+
VText: VText__default["default"],
|
|
4522
|
+
});
|
|
4523
|
+
var mergeOptions = function (options, patch) { return (Object.assign(Object.assign({}, options), patch)); };
|
|
4524
|
+
var ɵ0$1 = mergeOptions;
|
|
4525
|
+
var fixupFontSize = function (fontSize) {
|
|
4526
|
+
var normalizedFontSize;
|
|
4527
|
+
if (pointRegex.test(fontSize)) {
|
|
4528
|
+
var matchedParts = fontSize.match(pointRegex);
|
|
4529
|
+
normalizedFontSize = pointToHIP(matchedParts[1]);
|
|
4530
|
+
}
|
|
4531
|
+
else if (fontSize) {
|
|
4532
|
+
// assuming it is already in HIP
|
|
4533
|
+
normalizedFontSize = fontSize;
|
|
4534
|
+
}
|
|
4535
|
+
else {
|
|
4536
|
+
normalizedFontSize = null;
|
|
4537
|
+
}
|
|
4538
|
+
return normalizedFontSize;
|
|
4539
|
+
};
|
|
4540
|
+
var ɵ1 = fixupFontSize;
|
|
4541
|
+
var normalizeUnits = function (dimensioningObject, defaultDimensionsProperty) {
|
|
4542
|
+
var normalizedUnitResult = {};
|
|
4543
|
+
if (typeof dimensioningObject === 'object' && dimensioningObject !== null) {
|
|
4544
|
+
Object.keys(dimensioningObject).forEach(function (key) {
|
|
4545
|
+
if (pixelRegex.test(dimensioningObject[key])) {
|
|
4546
|
+
var matchedParts = dimensioningObject[key].match(pixelRegex);
|
|
4547
|
+
normalizedUnitResult[key] = pixelToTWIP(matchedParts[1]);
|
|
4548
|
+
}
|
|
4549
|
+
else if (cmRegex.test(dimensioningObject[key])) {
|
|
4550
|
+
var matchedParts = dimensioningObject[key].match(cmRegex);
|
|
4551
|
+
normalizedUnitResult[key] = cmToTWIP(matchedParts[1]);
|
|
4552
|
+
}
|
|
4553
|
+
else if (inchRegex.test(dimensioningObject[key])) {
|
|
4554
|
+
var matchedParts = dimensioningObject[key].match(inchRegex);
|
|
4555
|
+
normalizedUnitResult[key] = inchToTWIP(matchedParts[1]);
|
|
4556
|
+
}
|
|
4557
|
+
else if (dimensioningObject[key]) {
|
|
4558
|
+
normalizedUnitResult[key] = dimensioningObject[key];
|
|
4559
|
+
}
|
|
4560
|
+
else {
|
|
4561
|
+
// incase value is something like 0
|
|
4562
|
+
normalizedUnitResult[key] = defaultDimensionsProperty[key];
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
}
|
|
4566
|
+
else {
|
|
4567
|
+
// eslint-disable-next-line no-param-reassign
|
|
4568
|
+
normalizedUnitResult = null;
|
|
4569
|
+
}
|
|
4570
|
+
return normalizedUnitResult;
|
|
4571
|
+
};
|
|
4572
|
+
var ɵ2 = normalizeUnits;
|
|
4573
|
+
var normalizeDocumentOptions = function (documentOptions) {
|
|
4574
|
+
var normalizedDocumentOptions = Object.assign({}, documentOptions);
|
|
4575
|
+
Object.keys(documentOptions).forEach(function (key) {
|
|
4576
|
+
// eslint-disable-next-line default-case
|
|
4577
|
+
switch (key) {
|
|
4578
|
+
case 'pageSize':
|
|
4579
|
+
case 'margins':
|
|
4580
|
+
normalizedDocumentOptions[key] = normalizeUnits(documentOptions[key], defaultDocumentOptions[key]);
|
|
4581
|
+
break;
|
|
4582
|
+
case 'fontSize':
|
|
4583
|
+
case 'complexScriptFontSize':
|
|
4584
|
+
normalizedDocumentOptions[key] = fixupFontSize(documentOptions[key]);
|
|
4585
|
+
break;
|
|
4586
|
+
}
|
|
4587
|
+
});
|
|
4588
|
+
return normalizedDocumentOptions;
|
|
4589
|
+
};
|
|
4590
|
+
var ɵ3 = normalizeDocumentOptions;
|
|
4591
|
+
// Ref: https://en.wikipedia.org/wiki/Office_Open_XML_file_formats
|
|
4592
|
+
// http://officeopenxml.com/anatomyofOOXML.php
|
|
4593
|
+
function addFilesToContainer(zip, htmlString, suppliedDocumentOptions, headerHTMLString, footerHTMLString) {
|
|
4594
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4595
|
+
var normalizedDocumentOptions, documentOptions, docxDocument, _a, vTree, _b, headerId, headerXML, fileNameWithExt, relationshipId, vTree, _c, footerId, footerXML, fileNameWithExt, relationshipId, themeFileNameWithExt, relationshipXMLs;
|
|
4596
|
+
return __generator(this, function (_d) {
|
|
4597
|
+
switch (_d.label) {
|
|
4598
|
+
case 0:
|
|
4599
|
+
debugger;
|
|
4600
|
+
normalizedDocumentOptions = normalizeDocumentOptions(suppliedDocumentOptions);
|
|
4601
|
+
documentOptions = mergeOptions(defaultDocumentOptions, normalizedDocumentOptions);
|
|
4602
|
+
if (documentOptions.header && !headerHTMLString) {
|
|
4603
|
+
// eslint-disable-next-line no-param-reassign
|
|
4604
|
+
headerHTMLString = defaultHTMLString;
|
|
4605
|
+
}
|
|
4606
|
+
if (documentOptions.footer && !footerHTMLString) {
|
|
4607
|
+
// eslint-disable-next-line no-param-reassign
|
|
4608
|
+
footerHTMLString = defaultHTMLString;
|
|
4609
|
+
}
|
|
4610
|
+
docxDocument = new DocxDocument(Object.assign({ zip: zip, htmlString: htmlString }, documentOptions));
|
|
4611
|
+
// Conversion to Word XML happens here
|
|
4612
|
+
_a = docxDocument;
|
|
4613
|
+
return [4 /*yield*/, renderDocumentFile(docxDocument)];
|
|
4614
|
+
case 1:
|
|
4615
|
+
// Conversion to Word XML happens here
|
|
4616
|
+
_a.documentXML = _d.sent();
|
|
4617
|
+
debugger;
|
|
4618
|
+
zip
|
|
4619
|
+
.folder(relsFolderName)
|
|
4620
|
+
.file('.rels', xmlbuilder2.create({ encoding: 'UTF-8', standalone: true }, relsXML).toString({ prettyPrint: true }), { createFolders: false });
|
|
4621
|
+
zip.folder('docProps').file('core.xml', docxDocument.generateCoreXML(), {
|
|
4622
|
+
createFolders: false,
|
|
4623
|
+
});
|
|
4624
|
+
if (!(docxDocument.header && headerHTMLString)) return [3 /*break*/, 3];
|
|
4625
|
+
vTree = convertHTML(headerHTMLString);
|
|
4626
|
+
docxDocument.relationshipFilename = headerFileName;
|
|
4627
|
+
return [4 /*yield*/, docxDocument.generateHeaderXML(vTree)];
|
|
4628
|
+
case 2:
|
|
4629
|
+
_b = _d.sent(), headerId = _b.headerId, headerXML = _b.headerXML;
|
|
4630
|
+
docxDocument.relationshipFilename = documentFileName;
|
|
4631
|
+
fileNameWithExt = "" + headerType + headerId + ".xml";
|
|
4632
|
+
relationshipId = docxDocument.createDocumentRelationships(docxDocument.relationshipFilename, headerType, fileNameWithExt, internalRelationship);
|
|
4633
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateHeader.toString({ prettyPrint: true }), {
|
|
4634
|
+
createFolders: false,
|
|
4635
|
+
});
|
|
4636
|
+
docxDocument.headerObjects.push({ headerId: headerId, relationshipId: relationshipId, type: docxDocument.headerType });
|
|
4637
|
+
_d.label = 3;
|
|
4638
|
+
case 3:
|
|
4639
|
+
if (!(docxDocument.footer && footerHTMLString)) return [3 /*break*/, 5];
|
|
4640
|
+
vTree = convertHTML(footerHTMLString);
|
|
4641
|
+
docxDocument.relationshipFilename = footerFileName;
|
|
4642
|
+
return [4 /*yield*/, docxDocument.generateFooterXML(vTree)];
|
|
4643
|
+
case 4:
|
|
4644
|
+
_c = _d.sent(), footerId = _c.footerId, footerXML = _c.footerXML;
|
|
4645
|
+
docxDocument.relationshipFilename = documentFileName;
|
|
4646
|
+
fileNameWithExt = "" + footerType + footerId + ".xml";
|
|
4647
|
+
relationshipId = docxDocument.createDocumentRelationships(docxDocument.relationshipFilename, footerType, fileNameWithExt, internalRelationship);
|
|
4648
|
+
console.log(footerXML.toString({ prettyPrint: true }));
|
|
4649
|
+
if (suppliedDocumentOptions.pageNumber)
|
|
4650
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateFooter.toString({ prettyPrint: true }), {
|
|
4651
|
+
createFolders: false,
|
|
4652
|
+
});
|
|
4653
|
+
else
|
|
4654
|
+
zip.folder(wordFolder).file(fileNameWithExt, generateDocumentTemplateFooterWithoutPaging.toString({ prettyPrint: true }), {
|
|
4655
|
+
createFolders: false,
|
|
4656
|
+
});
|
|
4657
|
+
docxDocument.footerObjects.push({ footerId: footerId, relationshipId: relationshipId, type: docxDocument.footerType });
|
|
4658
|
+
_d.label = 5;
|
|
4659
|
+
case 5:
|
|
4660
|
+
themeFileNameWithExt = themeFileName + ".xml";
|
|
4661
|
+
docxDocument.createDocumentRelationships(docxDocument.relationshipFilename, themeType, themeFolder + "/" + themeFileNameWithExt, internalRelationship);
|
|
4662
|
+
zip
|
|
4663
|
+
.folder(wordFolder)
|
|
4664
|
+
.folder(themeFolder)
|
|
4665
|
+
.file(themeFileNameWithExt, docxDocument.generateThemeXML(), {
|
|
4666
|
+
createFolders: false,
|
|
4667
|
+
});
|
|
4668
|
+
zip
|
|
4669
|
+
.folder(wordFolder)
|
|
4670
|
+
.file('document.xml', docxDocument.generateDocumentXML(), { createFolders: false })
|
|
4671
|
+
.file('afchunk.mht', getMHTdocument(htmlString), {
|
|
4672
|
+
createFolders: false,
|
|
4673
|
+
})
|
|
4674
|
+
.file('afchunkheader.mht', getMHTdocument(headerHTMLString), {
|
|
4675
|
+
createFolders: false,
|
|
4676
|
+
})
|
|
4677
|
+
.file('afchunkfooter.mht', getMHTdocument(footerHTMLString), {
|
|
4678
|
+
createFolders: false,
|
|
4679
|
+
})
|
|
4680
|
+
.file('fontTable.xml', docxDocument.generateFontTableXML(), { createFolders: false })
|
|
4681
|
+
.file('styles.xml', docxDocument.generateStylesXML(), { createFolders: false })
|
|
4682
|
+
.file('numbering.xml', docxDocument.generateNumberingXML(), { createFolders: false })
|
|
4683
|
+
.file('settings.xml', docxDocument.generateSettingsXML(), { createFolders: false })
|
|
4684
|
+
.file('webSettings.xml', docxDocument.generateWebSettingsXML(), { createFolders: false });
|
|
4685
|
+
relationshipXMLs = docxDocument.generateRelsXML();
|
|
4686
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
4687
|
+
relationshipXMLs.forEach(function (_a) {
|
|
4688
|
+
var fileName = _a.fileName, xmlString = _a.xmlString;
|
|
4689
|
+
console.log(xmlString);
|
|
4690
|
+
zip.folder(wordFolder).folder(relsFolderName).file(fileName + ".xml.rels", xmlString, {
|
|
4691
|
+
createFolders: false,
|
|
4692
|
+
});
|
|
4693
|
+
});
|
|
4694
|
+
}
|
|
4695
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
4696
|
+
relationshipXMLs.forEach(function (_a) {
|
|
4697
|
+
var fileName = _a.fileName, xmlString = _a.xmlString;
|
|
4698
|
+
zip.folder(wordFolder).folder(relsFolderName).file("header1.xml.rels", xmlString, {
|
|
4699
|
+
createFolders: false,
|
|
4700
|
+
});
|
|
4701
|
+
});
|
|
4702
|
+
}
|
|
4703
|
+
if (relationshipXMLs && Array.isArray(relationshipXMLs)) {
|
|
4704
|
+
relationshipXMLs.forEach(function (_a) {
|
|
4705
|
+
var fileName = _a.fileName, xmlString = _a.xmlString;
|
|
4706
|
+
zip.folder(wordFolder).folder(relsFolderName).file("footer1.xml.rels", xmlString, {
|
|
4707
|
+
createFolders: false,
|
|
4708
|
+
});
|
|
4709
|
+
});
|
|
4710
|
+
}
|
|
4711
|
+
zip.file('[Content_Types].xml', docxDocument.generateContentTypesXML(), { createFolders: false });
|
|
4712
|
+
return [2 /*return*/, zip];
|
|
4713
|
+
}
|
|
4714
|
+
});
|
|
4715
|
+
});
|
|
4716
|
+
}
|
|
4717
|
+
|
|
4718
|
+
var minifyHTMLString = function (htmlString) {
|
|
4719
|
+
try {
|
|
4720
|
+
if (typeof htmlString === 'string' || htmlString instanceof String) {
|
|
4721
|
+
var minifiedHTMLString = htmlString
|
|
4722
|
+
.replace(/\n/g, ' ')
|
|
4723
|
+
.replace(/\r/g, ' ')
|
|
4724
|
+
.replace(/\r\n/g, ' ')
|
|
4725
|
+
.replace(/[\t]+\</g, '<')
|
|
4726
|
+
.replace(/\>[\t ]+\</g, '><')
|
|
4727
|
+
.replace(/\>[\t ]+$/g, '>');
|
|
4728
|
+
return minifiedHTMLString;
|
|
4729
|
+
}
|
|
4730
|
+
throw new Error('invalid html string');
|
|
4731
|
+
}
|
|
4732
|
+
catch (error) {
|
|
4733
|
+
return null;
|
|
4734
|
+
}
|
|
4735
|
+
};
|
|
4736
|
+
var ɵ0 = minifyHTMLString;
|
|
4737
|
+
function generateContainer(htmlString, headerHTMLString, documentOptions, footerHTMLString) {
|
|
4738
|
+
if (documentOptions === void 0) { documentOptions = {}; }
|
|
4739
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4740
|
+
var zip, contentHTML, headerHTML, footerHTML, buffer;
|
|
4741
|
+
return __generator(this, function (_a) {
|
|
4742
|
+
switch (_a.label) {
|
|
4743
|
+
case 0:
|
|
4744
|
+
zip = new JSZip__default["default"]();
|
|
4745
|
+
contentHTML = htmlString;
|
|
4746
|
+
headerHTML = headerHTMLString;
|
|
4747
|
+
footerHTML = footerHTMLString;
|
|
4748
|
+
if (htmlString) {
|
|
4749
|
+
contentHTML = minifyHTMLString(contentHTML);
|
|
4750
|
+
}
|
|
4751
|
+
if (headerHTMLString) {
|
|
4752
|
+
headerHTML = minifyHTMLString(headerHTML);
|
|
4753
|
+
}
|
|
4754
|
+
if (footerHTMLString) {
|
|
4755
|
+
footerHTML = minifyHTMLString(footerHTML);
|
|
4756
|
+
}
|
|
4757
|
+
return [4 /*yield*/, addFilesToContainer(zip, contentHTML, documentOptions, headerHTML, footerHTML)];
|
|
4758
|
+
case 1:
|
|
4759
|
+
_a.sent();
|
|
4760
|
+
return [4 /*yield*/, zip.generateAsync({ type: 'arraybuffer' })];
|
|
4761
|
+
case 2:
|
|
4762
|
+
buffer = _a.sent();
|
|
4763
|
+
if (Object.prototype.hasOwnProperty.call(global, 'Buffer')) {
|
|
4764
|
+
return [2 /*return*/, Buffer.from(new Uint8Array(buffer))];
|
|
4765
|
+
}
|
|
4766
|
+
if (Object.prototype.hasOwnProperty.call(global, 'Blob')) {
|
|
4767
|
+
// eslint-disable-next-line no-undef
|
|
4768
|
+
return [2 /*return*/, new Blob([buffer], {
|
|
4769
|
+
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
4770
|
+
})];
|
|
4771
|
+
}
|
|
4772
|
+
throw new Error('Add blob support using a polyfill eg https://github.com/bjornstar/blob-polyfill');
|
|
4773
|
+
}
|
|
4774
|
+
});
|
|
4775
|
+
});
|
|
4776
|
+
}
|
|
4777
|
+
|
|
4778
|
+
var WordDocumentService = /** @class */ (function () {
|
|
4779
|
+
function WordDocumentService() {
|
|
4780
|
+
}
|
|
4781
|
+
WordDocumentService.prototype.generateWordByteFile = function (model) {
|
|
4782
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4783
|
+
var documentOptions, fileBuffer;
|
|
4784
|
+
return __generator(this, function (_a) {
|
|
4785
|
+
switch (_a.label) {
|
|
4786
|
+
case 0:
|
|
4787
|
+
documentOptions = {};
|
|
4788
|
+
if (model.options.isLandscape)
|
|
4789
|
+
documentOptions.orientation = 'landscape';
|
|
4790
|
+
documentOptions.pageSize = {
|
|
4791
|
+
width: model.options.pageWidth * 15,
|
|
4792
|
+
height: model.options.pageHeight * 15,
|
|
4793
|
+
};
|
|
4794
|
+
documentOptions.margins = {
|
|
4795
|
+
top: model.options.top * 15,
|
|
4796
|
+
right: model.options.right * 15,
|
|
4797
|
+
bottom: model.options.bottom * 15,
|
|
4798
|
+
left: model.options.left * 15,
|
|
4799
|
+
header: model.options.top * 15 * 2,
|
|
4800
|
+
footer: model.options.bottom * 15 * 2,
|
|
4801
|
+
gutter: 0,
|
|
4802
|
+
};
|
|
4803
|
+
documentOptions.footer = true;
|
|
4804
|
+
documentOptions.header = true;
|
|
4805
|
+
documentOptions.pageNumber = model.options.showPaging;
|
|
4806
|
+
documentOptions.table = { row: { cantSplit: true } };
|
|
4807
|
+
return [4 /*yield*/, generateContainer(model.body, model.header, documentOptions, model.footer)];
|
|
4808
|
+
case 1:
|
|
4809
|
+
fileBuffer = _a.sent();
|
|
4810
|
+
return [2 /*return*/, fileBuffer];
|
|
4811
|
+
}
|
|
4812
|
+
});
|
|
4813
|
+
});
|
|
4814
|
+
};
|
|
4815
|
+
return WordDocumentService;
|
|
4816
|
+
}());
|
|
4817
|
+
WordDocumentService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WordDocumentService_Factory() { return new WordDocumentService(); }, token: WordDocumentService, providedIn: "root" });
|
|
4818
|
+
WordDocumentService.decorators = [
|
|
4819
|
+
{ type: i0.Injectable, args: [{
|
|
4820
|
+
providedIn: 'root',
|
|
4821
|
+
},] }
|
|
4822
|
+
];
|
|
4823
|
+
|
|
4824
|
+
var WordDocumentModel = /** @class */ (function () {
|
|
4825
|
+
function WordDocumentModel() {
|
|
4826
|
+
this.options = new DocumentOptionsModel();
|
|
4827
|
+
}
|
|
4828
|
+
return WordDocumentModel;
|
|
4829
|
+
}());
|
|
4830
|
+
var DocumentOptionsModel = /** @class */ (function () {
|
|
4831
|
+
function DocumentOptionsModel() {
|
|
4832
|
+
}
|
|
4833
|
+
return DocumentOptionsModel;
|
|
4834
|
+
}());
|
|
4835
|
+
|
|
1459
4836
|
/*
|
|
1460
4837
|
* Public API Surface of @bnsights/bbsf-utilities
|
|
1461
4838
|
*/
|
|
@@ -1470,6 +4847,7 @@
|
|
|
1470
4847
|
exports.BBSFUtilitiesModule = BBSFUtilitiesModule;
|
|
1471
4848
|
exports.ConfigurationService = ConfigurationService;
|
|
1472
4849
|
exports.ControlValidationService = ControlValidationService;
|
|
4850
|
+
exports.DocumentOptionsModel = DocumentOptionsModel;
|
|
1473
4851
|
exports.EnvironmentService = EnvironmentService;
|
|
1474
4852
|
exports.MasterLayoutService = MasterLayoutService;
|
|
1475
4853
|
exports.RequestHandlerService = RequestHandlerService;
|
|
@@ -1477,6 +4855,8 @@
|
|
|
1477
4855
|
exports.StylesBundleService = StylesBundleService;
|
|
1478
4856
|
exports.TranslationResolverService = TranslationResolverService;
|
|
1479
4857
|
exports.UtilityService = UtilityService;
|
|
4858
|
+
exports.WordDocumentModel = WordDocumentModel;
|
|
4859
|
+
exports.WordDocumentService = WordDocumentService;
|
|
1480
4860
|
exports.environment = environment;
|
|
1481
4861
|
|
|
1482
4862
|
Object.defineProperty(exports, '__esModule', { value: true });
|