@bnsights/bbsf-utilities 1.0.34 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +8 -0
  2. package/karma.conf.js +44 -0
  3. package/ng-package.json +10 -0
  4. package/package.json +20 -28
  5. package/src/lib/bbsf-utilities.module.ts +52 -0
  6. package/src/lib/shared/authentication/auth.service.ts +242 -0
  7. package/src/lib/shared/config/environment.ts +16 -0
  8. package/src/lib/shared/config/word/constants.js +133 -0
  9. package/src/lib/shared/config/word/docx-document.js +482 -0
  10. package/src/lib/shared/config/word/helpers/index.js +3 -0
  11. package/src/lib/shared/config/word/helpers/render-document-file.js +334 -0
  12. package/src/lib/shared/config/word/helpers/xml-builder.js +2165 -0
  13. package/src/lib/shared/config/word/html-to-docx.js +259 -0
  14. package/src/lib/shared/config/word/index.js +63 -0
  15. package/src/lib/shared/config/word/namespaces.js +40 -0
  16. package/src/lib/shared/config/word/schemas/content-types.js +26 -0
  17. package/src/lib/shared/config/word/schemas/core.js +44 -0
  18. package/src/lib/shared/config/word/schemas/document-rels.js +17 -0
  19. package/src/lib/shared/config/word/schemas/document.template.js +119 -0
  20. package/src/lib/shared/config/word/schemas/font-table.js +41 -0
  21. package/src/lib/shared/config/word/schemas/generic-rels.js +11 -0
  22. package/src/lib/shared/config/word/schemas/index.js +12 -0
  23. package/src/lib/shared/config/word/schemas/numbering.js +18 -0
  24. package/src/lib/shared/config/word/schemas/rels.js +12 -0
  25. package/src/lib/shared/config/word/schemas/settings.js +14 -0
  26. package/src/lib/shared/config/word/schemas/styles.js +152 -0
  27. package/src/lib/shared/config/word/schemas/theme.js +199 -0
  28. package/src/lib/shared/config/word/schemas/web-settings.js +10 -0
  29. package/src/lib/shared/config/word/utils/color-conversion.js +60 -0
  30. package/src/lib/shared/config/word/utils/list.js +55 -0
  31. package/src/lib/shared/config/word/utils/unit-conversion.js +53 -0
  32. package/src/lib/shared/config/word/utils/url.js +8 -0
  33. package/src/lib/shared/config/word/utils/vnode.js +3 -0
  34. package/src/lib/shared/config/word/word-work/assets/contentTypesXml.ts +1 -0
  35. package/src/lib/shared/config/word/word-work/assets/documentXmlRels.ts +1 -0
  36. package/src/lib/shared/config/word/word-work/assets/index.ts +3 -0
  37. package/src/lib/shared/config/word/word-work/assets/relsXml.ts +1 -0
  38. package/src/lib/shared/config/word/word-work/index.ts +8 -0
  39. package/src/lib/shared/config/word/word-work/internal.ts +69 -0
  40. package/src/lib/shared/config/word/word-work/templates/documentTemplate.ts +58 -0
  41. package/src/lib/shared/config/word/word-work/templates/index.ts +3 -0
  42. package/src/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.ts +21 -0
  43. package/src/lib/shared/config/word/word-work/templates/mhtPartTemplate.ts +14 -0
  44. package/src/lib/shared/config/word/word-work/utils.ts +27 -0
  45. package/src/lib/shared/models/AreaModel.ts +5 -0
  46. package/{lib/shared/models/ErrorModel.d.ts → src/lib/shared/models/ErrorModel.ts} +5 -2
  47. package/src/lib/shared/models/RequestOptionsModel.ts +13 -0
  48. package/src/lib/shared/models/WordDocumentModel.ts +19 -0
  49. package/src/lib/shared/services/AppearanceConfiguration.service.ts +30 -0
  50. package/src/lib/shared/services/configuration.service.ts +18 -0
  51. package/src/lib/shared/services/controlvalidation.service.ts +194 -0
  52. package/src/lib/shared/services/environment.service.ts +56 -0
  53. package/src/lib/shared/services/masterlayout.service.ts +89 -0
  54. package/src/lib/shared/services/requesthandler.service.ts +241 -0
  55. package/src/lib/shared/services/stylesbundle.service.ts +52 -0
  56. package/src/lib/shared/services/translate.service.ts +8 -0
  57. package/src/lib/shared/services/translationresolver.service.ts +16 -0
  58. package/src/lib/shared/services/utility.service.ts +94 -0
  59. package/src/lib/shared/services/word-document.service.ts +36 -0
  60. package/src/public-api.ts +27 -0
  61. package/src/test.ts +26 -0
  62. package/tsconfig.lib.json +39 -0
  63. package/tsconfig.lib.prod.json +11 -0
  64. package/tsconfig.spec.json +17 -0
  65. package/tslint.json +17 -0
  66. package/bnsights-bbsf-utilities-1.0.34.tgz +0 -0
  67. package/bnsights-bbsf-utilities.d.ts +0 -4
  68. package/bnsights-bbsf-utilities.metadata.json +0 -1
  69. package/bundles/bnsights-bbsf-utilities.umd.js +0 -4865
  70. package/bundles/bnsights-bbsf-utilities.umd.js.map +0 -1
  71. package/esm2015/bnsights-bbsf-utilities.js +0 -5
  72. package/esm2015/lib/bbsf-utilities.module.js +0 -52
  73. package/esm2015/lib/shared/authentication/auth.service.js +0 -236
  74. package/esm2015/lib/shared/config/environment.js +0 -12
  75. package/esm2015/lib/shared/config/word/constants.js +0 -105
  76. package/esm2015/lib/shared/config/word/docx-document.js +0 -351
  77. package/esm2015/lib/shared/config/word/helpers/index.js +0 -4
  78. package/esm2015/lib/shared/config/word/helpers/render-document-file.js +0 -278
  79. package/esm2015/lib/shared/config/word/helpers/xml-builder.js +0 -1765
  80. package/esm2015/lib/shared/config/word/html-to-docx.js +0 -195
  81. package/esm2015/lib/shared/config/word/index.js +0 -55
  82. package/esm2015/lib/shared/config/word/namespaces.js +0 -37
  83. package/esm2015/lib/shared/config/word/schemas/content-types.js +0 -26
  84. package/esm2015/lib/shared/config/word/schemas/core.js +0 -29
  85. package/esm2015/lib/shared/config/word/schemas/document-rels.js +0 -16
  86. package/esm2015/lib/shared/config/word/schemas/document.template.js +0 -109
  87. package/esm2015/lib/shared/config/word/schemas/font-table.js +0 -40
  88. package/esm2015/lib/shared/config/word/schemas/generic-rels.js +0 -11
  89. package/esm2015/lib/shared/config/word/schemas/index.js +0 -13
  90. package/esm2015/lib/shared/config/word/schemas/numbering.js +0 -19
  91. package/esm2015/lib/shared/config/word/schemas/rels.js +0 -11
  92. package/esm2015/lib/shared/config/word/schemas/settings.js +0 -13
  93. package/esm2015/lib/shared/config/word/schemas/styles.js +0 -149
  94. package/esm2015/lib/shared/config/word/schemas/theme.js +0 -200
  95. package/esm2015/lib/shared/config/word/schemas/web-settings.js +0 -9
  96. package/esm2015/lib/shared/config/word/utils/color-conversion.js +0 -60
  97. package/esm2015/lib/shared/config/word/utils/list.js +0 -51
  98. package/esm2015/lib/shared/config/word/utils/unit-conversion.js +0 -30
  99. package/esm2015/lib/shared/config/word/utils/url.js +0 -9
  100. package/esm2015/lib/shared/config/word/utils/vnode.js +0 -3
  101. package/esm2015/lib/shared/config/word/word-work/templates/documentTemplate.js +0 -54
  102. package/esm2015/lib/shared/config/word/word-work/templates/index.js +0 -4
  103. package/esm2015/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.js +0 -22
  104. package/esm2015/lib/shared/config/word/word-work/templates/mhtPartTemplate.js +0 -10
  105. package/esm2015/lib/shared/config/word/word-work/utils.js +0 -26
  106. package/esm2015/lib/shared/models/AreaModel.js +0 -3
  107. package/esm2015/lib/shared/models/ErrorModel.js +0 -3
  108. package/esm2015/lib/shared/models/RequestOptionsModel.js +0 -11
  109. package/esm2015/lib/shared/models/WordDocumentModel.js +0 -8
  110. package/esm2015/lib/shared/services/AppearanceConfiguration.service.js +0 -37
  111. package/esm2015/lib/shared/services/configuration.service.js +0 -26
  112. package/esm2015/lib/shared/services/controlvalidation.service.js +0 -168
  113. package/esm2015/lib/shared/services/environment.service.js +0 -48
  114. package/esm2015/lib/shared/services/masterlayout.service.js +0 -96
  115. package/esm2015/lib/shared/services/requesthandler.service.js +0 -206
  116. package/esm2015/lib/shared/services/stylesbundle.service.js +0 -56
  117. package/esm2015/lib/shared/services/translate.service.js +0 -13
  118. package/esm2015/lib/shared/services/translationresolver.service.js +0 -20
  119. package/esm2015/lib/shared/services/utility.service.js +0 -96
  120. package/esm2015/lib/shared/services/word-document.service.js +0 -39
  121. package/esm2015/public-api.js +0 -20
  122. package/fesm2015/bnsights-bbsf-utilities.js +0 -4634
  123. package/fesm2015/bnsights-bbsf-utilities.js.map +0 -1
  124. package/lib/bbsf-utilities.module.d.ts +0 -6
  125. package/lib/shared/authentication/auth.service.d.ts +0 -41
  126. package/lib/shared/config/environment.d.ts +0 -1
  127. package/lib/shared/config/word/constants.d.ts +0 -124
  128. package/lib/shared/config/word/docx-document.d.ts +0 -73
  129. package/lib/shared/config/word/helpers/index.d.ts +0 -1
  130. package/lib/shared/config/word/helpers/render-document-file.d.ts +0 -4
  131. package/lib/shared/config/word/helpers/xml-builder.d.ts +0 -14
  132. package/lib/shared/config/word/html-to-docx.d.ts +0 -1
  133. package/lib/shared/config/word/index.d.ts +0 -1
  134. package/lib/shared/config/word/namespaces.d.ts +0 -36
  135. package/lib/shared/config/word/schemas/content-types.d.ts +0 -1
  136. package/lib/shared/config/word/schemas/core.d.ts +0 -1
  137. package/lib/shared/config/word/schemas/document-rels.d.ts +0 -1
  138. package/lib/shared/config/word/schemas/document.template.d.ts +0 -4
  139. package/lib/shared/config/word/schemas/font-table.d.ts +0 -1
  140. package/lib/shared/config/word/schemas/generic-rels.d.ts +0 -1
  141. package/lib/shared/config/word/schemas/index.d.ts +0 -12
  142. package/lib/shared/config/word/schemas/numbering.d.ts +0 -1
  143. package/lib/shared/config/word/schemas/rels.d.ts +0 -1
  144. package/lib/shared/config/word/schemas/settings.d.ts +0 -1
  145. package/lib/shared/config/word/schemas/styles.d.ts +0 -1
  146. package/lib/shared/config/word/schemas/theme.d.ts +0 -1
  147. package/lib/shared/config/word/schemas/web-settings.d.ts +0 -1
  148. package/lib/shared/config/word/utils/color-conversion.d.ts +0 -7
  149. package/lib/shared/config/word/utils/list.d.ts +0 -6
  150. package/lib/shared/config/word/utils/unit-conversion.d.ts +0 -29
  151. package/lib/shared/config/word/utils/url.d.ts +0 -1
  152. package/lib/shared/config/word/utils/vnode.d.ts +0 -1
  153. package/lib/shared/config/word/word-work/templates/documentTemplate.d.ts +0 -12
  154. package/lib/shared/config/word/word-work/templates/index.d.ts +0 -3
  155. package/lib/shared/config/word/word-work/templates/mhtDocumentTemplate.d.ts +0 -1
  156. package/lib/shared/config/word/word-work/templates/mhtPartTemplate.d.ts +0 -1
  157. package/lib/shared/config/word/word-work/utils.d.ts +0 -1
  158. package/lib/shared/models/AreaModel.d.ts +0 -4
  159. package/lib/shared/models/RequestOptionsModel.d.ts +0 -11
  160. package/lib/shared/models/WordDocumentModel.d.ts +0 -16
  161. package/lib/shared/services/AppearanceConfiguration.service.d.ts +0 -11
  162. package/lib/shared/services/configuration.service.d.ts +0 -7
  163. package/lib/shared/services/controlvalidation.service.d.ts +0 -19
  164. package/lib/shared/services/environment.service.d.ts +0 -13
  165. package/lib/shared/services/masterlayout.service.d.ts +0 -24
  166. package/lib/shared/services/requesthandler.service.d.ts +0 -32
  167. package/lib/shared/services/stylesbundle.service.d.ts +0 -9
  168. package/lib/shared/services/translate.service.d.ts +0 -3
  169. package/lib/shared/services/translationresolver.service.d.ts +0 -8
  170. package/lib/shared/services/utility.service.d.ts +0 -21
  171. package/lib/shared/services/word-document.service.d.ts +0 -5
  172. package/public-api.d.ts +0 -16
@@ -0,0 +1,12 @@
1
+ import namespaces from '../namespaces';
2
+
3
+ const relsXML = `
4
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+
6
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
7
+ <Relationship Id="rId1" Type="${namespaces.officeDocumentRelation}" Target="word/document.xml"/>
8
+ <Relationship Id="rId2" Type="${namespaces.corePropertiesRelation}" Target="docProps/core.xml"/>
9
+ </Relationships>
10
+ `;
11
+
12
+ export {relsXML};
@@ -0,0 +1,14 @@
1
+ import namespaces from '../namespaces';
2
+
3
+ const settingsXML = `
4
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+
6
+ <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}">
7
+ <w:zoom w:percent="100"/>
8
+ <w:defaultTabStop w:val="720"/>
9
+ <w:decimalSymbol w:val="."/>
10
+ <w:listSeparator w:val=","/>
11
+ </w:settings>
12
+ `;
13
+
14
+ export {settingsXML};
@@ -0,0 +1,152 @@
1
+ import { defaultFont, defaultFontSize } from '../constants';
2
+ import namespaces from '../namespaces';
3
+
4
+ const generateStylesXML = (
5
+ font = defaultFont,
6
+ fontSize = defaultFontSize,
7
+ complexScriptFontSize = defaultFontSize
8
+ ) => `
9
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
10
+
11
+ <w:styles xmlns:w="${namespaces.w}" xmlns:r="${namespaces.r}">
12
+ <w:docDefaults>
13
+ <w:rPrDefault>
14
+ <w:rPr>
15
+ <w:rFonts w:ascii="${font}" w:eastAsiaTheme="minorHAnsi" w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi" />
16
+ <w:sz w:val="${fontSize}" />
17
+ <w:szCs w:val="${complexScriptFontSize}" />
18
+ <w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA" />
19
+ </w:rPr>
20
+ </w:rPrDefault>
21
+ <w:pPrDefault>
22
+ <w:pPr>
23
+ <w:spacing w:after="120" w:line="240" w:lineRule="atLeast" />
24
+ </w:pPr>
25
+ </w:pPrDefault>
26
+ </w:docDefaults>
27
+ <w:style w:type="character" w:styleId="Hyperlink">
28
+ <w:name w:val="Hyperlink" />
29
+ <w:rPr>
30
+ <w:color w:val="0000FF" />
31
+ <w:u w:val="single" />
32
+ </w:rPr>
33
+ </w:style>
34
+ <w:style w:type="paragraph" w:styleId="Heading1">
35
+ <w:name w:val="heading 1" />
36
+ <w:basedOn w:val="Normal" />
37
+ <w:next w:val="Normal" />
38
+ <w:uiPriority w:val="9" />
39
+ <w:qFormat />
40
+ <w:pPr>
41
+ <w:keepNext />
42
+ <w:keepLines />
43
+ <w:spacing w:before="480" />
44
+ <w:outlineLvl w:val="0" />
45
+ </w:pPr>
46
+ <w:rPr>
47
+ <w:b />
48
+ <w:sz w:val="48" />
49
+ <w:szCs w:val="48" />
50
+ </w:rPr>
51
+ </w:style>
52
+ <w:style w:type="paragraph" w:styleId="Heading2">
53
+ <w:name w:val="heading 2" />
54
+ <w:basedOn w:val="Normal" />
55
+ <w:next w:val="Normal" />
56
+ <w:uiPriority w:val="9" />
57
+ <w:unhideWhenUsed />
58
+ <w:qFormat />
59
+ <w:pPr>
60
+ <w:keepNext />
61
+ <w:keepLines />
62
+ <w:spacing w:before="360" w:after="80" />
63
+ <w:outlineLvl w:val="1" />
64
+ </w:pPr>
65
+ <w:rPr>
66
+ <w:b />
67
+ <w:sz w:val="36" />
68
+ <w:szCs w:val="36" />
69
+ </w:rPr>
70
+ </w:style>
71
+ <w:style w:type="paragraph" w:styleId="Heading3">
72
+ <w:name w:val="heading 3" />
73
+ <w:basedOn w:val="Normal" />
74
+ <w:next w:val="Normal" />
75
+ <w:uiPriority w:val="9" />
76
+ <w:semiHidden />
77
+ <w:unhideWhenUsed />
78
+ <w:qFormat />
79
+ <w:pPr>
80
+ <w:keepNext />
81
+ <w:keepLines />
82
+ <w:spacing w:before="280" w:after="80" />
83
+ <w:outlineLvl w:val="2" />
84
+ </w:pPr>
85
+ <w:rPr>
86
+ <w:b />
87
+ <w:sz w:val="28" />
88
+ <w:szCs w:val="28" />
89
+ </w:rPr>
90
+ </w:style>
91
+ <w:style w:type="paragraph" w:styleId="Heading4">
92
+ <w:name w:val="heading 4" />
93
+ <w:basedOn w:val="Normal" />
94
+ <w:next w:val="Normal" />
95
+ <w:uiPriority w:val="9" />
96
+ <w:semiHidden />
97
+ <w:unhideWhenUsed />
98
+ <w:qFormat />
99
+ <w:pPr>
100
+ <w:keepNext />
101
+ <w:keepLines />
102
+ <w:spacing w:before="240" w:after="40" />
103
+ <w:outlineLvl w:val="3" />
104
+ </w:pPr>
105
+ <w:rPr>
106
+ <w:b />
107
+ <w:sz w:val="24" />
108
+ <w:szCs w:val="24" />
109
+ </w:rPr>
110
+ </w:style>
111
+ <w:style w:type="paragraph" w:styleId="Heading5">
112
+ <w:name w:val="heading 5" />
113
+ <w:basedOn w:val="Normal" />
114
+ <w:next w:val="Normal" />
115
+ <w:uiPriority w:val="9" />
116
+ <w:semiHidden />
117
+ <w:unhideWhenUsed />
118
+ <w:qFormat />
119
+ <w:pPr>
120
+ <w:keepNext />
121
+ <w:keepLines />
122
+ <w:spacing w:before="220" w:after="40" />
123
+ <w:outlineLvl w:val="4" />
124
+ </w:pPr>
125
+ <w:rPr>
126
+ <w:b />
127
+ </w:rPr>
128
+ </w:style>
129
+ <w:style w:type="paragraph" w:styleId="Heading6">
130
+ <w:name w:val="heading 6" />
131
+ <w:basedOn w:val="Normal" />
132
+ <w:next w:val="Normal" />
133
+ <w:uiPriority w:val="9" />
134
+ <w:semiHidden />
135
+ <w:unhideWhenUsed />
136
+ <w:qFormat />
137
+ <w:pPr>
138
+ <w:keepNext />
139
+ <w:keepLines />
140
+ <w:spacing w:before="200" w:after="40" />
141
+ <w:outlineLvl w:val="5" />
142
+ </w:pPr>
143
+ <w:rPr>
144
+ <w:b />
145
+ <w:sz w:val="20" />
146
+ <w:szCs w:val="20" />
147
+ </w:rPr>
148
+ </w:style>
149
+ </w:styles>
150
+ `;
151
+
152
+ export {generateStylesXML};
@@ -0,0 +1,199 @@
1
+ import { defaultFont } from '../constants';
2
+
3
+ const generateThemeXML = (font = defaultFont) => `
4
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+
6
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
7
+ <a:themeElements>
8
+ <a:clrScheme name="Office">
9
+ <a:dk1>
10
+ <a:sysClr val="windowText" lastClr="000000"/>
11
+ </a:dk1>
12
+ <a:lt1>
13
+ <a:sysClr val="window" lastClr="FFFFFF"/>
14
+ </a:lt1>
15
+ <a:dk2>
16
+ <a:srgbClr val="44546A"/>
17
+ </a:dk2>
18
+ <a:lt2>
19
+ <a:srgbClr val="E7E6E6"/>
20
+ </a:lt2>
21
+ <a:accent1>
22
+ <a:srgbClr val="4472C4"/>
23
+ </a:accent1>
24
+ <a:accent2>
25
+ <a:srgbClr val="ED7D31"/>
26
+ </a:accent2>
27
+ <a:accent3>
28
+ <a:srgbClr val="A5A5A5"/>
29
+ </a:accent3>
30
+ <a:accent4>
31
+ <a:srgbClr val="FFC000"/>
32
+ </a:accent4>
33
+ <a:accent5>
34
+ <a:srgbClr val="5B9BD5"/>
35
+ </a:accent5>
36
+ <a:accent6>
37
+ <a:srgbClr val="70AD47"/>
38
+ </a:accent6>
39
+ <a:hlink>
40
+ <a:srgbClr val="0563C1"/>
41
+ </a:hlink>
42
+ <a:folHlink>
43
+ <a:srgbClr val="954F72"/>
44
+ </a:folHlink>
45
+ </a:clrScheme>
46
+ <a:fontScheme name="Office">
47
+ <a:majorFont>
48
+ <a:latin typeface="${font}"/>
49
+ <a:ea typeface="${font}"/>
50
+ <a:cs typeface=""/>
51
+ </a:majorFont>
52
+ <a:minorFont>
53
+ <a:latin typeface="${font}"/>
54
+ <a:ea typeface="${font}"/>
55
+ <a:cs typeface=""/>
56
+ </a:minorFont>
57
+ </a:fontScheme>
58
+ <a:fmtScheme name="Office">
59
+ <a:fillStyleLst>
60
+ <a:solidFill>
61
+ <a:schemeClr val="phClr"/>
62
+ </a:solidFill>
63
+ <a:gradFill rotWithShape="1">
64
+ <a:gsLst>
65
+ <a:gs pos="0">
66
+ <a:schemeClr val="phClr">
67
+ <a:lumMod val="110000"/>
68
+ <a:satMod val="105000"/>
69
+ <a:tint val="67000"/>
70
+ </a:schemeClr>
71
+ </a:gs>
72
+ <a:gs pos="50000">
73
+ <a:schemeClr val="phClr">
74
+ <a:lumMod val="105000"/>
75
+ <a:satMod val="103000"/>
76
+ <a:tint val="73000"/>
77
+ </a:schemeClr>
78
+ </a:gs>
79
+ <a:gs pos="100000">
80
+ <a:schemeClr val="phClr">
81
+ <a:lumMod val="105000"/>
82
+ <a:satMod val="109000"/>
83
+ <a:tint val="81000"/>
84
+ </a:schemeClr>
85
+ </a:gs>
86
+ </a:gsLst>
87
+ <a:lin ang="5400000" scaled="0"/>
88
+ </a:gradFill>
89
+ <a:gradFill rotWithShape="1">
90
+ <a:gsLst>
91
+ <a:gs pos="0">
92
+ <a:schemeClr val="phClr">
93
+ <a:satMod val="103000"/>
94
+ <a:lumMod val="102000"/>
95
+ <a:tint val="94000"/>
96
+ </a:schemeClr>
97
+ </a:gs>
98
+ <a:gs pos="50000">
99
+ <a:schemeClr val="phClr">
100
+ <a:satMod val="110000"/>
101
+ <a:lumMod val="100000"/>
102
+ <a:shade val="100000"/>
103
+ </a:schemeClr>
104
+ </a:gs>
105
+ <a:gs pos="100000">
106
+ <a:schemeClr val="phClr">
107
+ <a:lumMod val="99000"/>
108
+ <a:satMod val="120000"/>
109
+ <a:shade val="78000"/>
110
+ </a:schemeClr>
111
+ </a:gs>
112
+ </a:gsLst>
113
+ <a:lin ang="5400000" scaled="0"/>
114
+ </a:gradFill>
115
+ </a:fillStyleLst>
116
+ <a:lnStyleLst>
117
+ <a:ln w="6350" cap="flat" cmpd="sng" algn="ctr">
118
+ <a:solidFill>
119
+ <a:schemeClr val="phClr"/>
120
+ </a:solidFill>
121
+ <a:prstDash val="solid"/>
122
+ <a:miter lim="800000"/>
123
+ </a:ln>
124
+ <a:ln w="12700" cap="flat" cmpd="sng" algn="ctr">
125
+ <a:solidFill>
126
+ <a:schemeClr val="phClr"/>
127
+ </a:solidFill>
128
+ <a:prstDash val="solid"/>
129
+ <a:miter lim="800000"/>
130
+ </a:ln>
131
+ <a:ln w="19050" cap="flat" cmpd="sng" algn="ctr">
132
+ <a:solidFill>
133
+ <a:schemeClr val="phClr"/>
134
+ </a:solidFill>
135
+ <a:prstDash val="solid"/>
136
+ <a:miter lim="800000"/>
137
+ </a:ln>
138
+ </a:lnStyleLst>
139
+ <a:effectStyleLst>
140
+ <a:effectStyle>
141
+ <a:effectLst/>
142
+ </a:effectStyle>
143
+ <a:effectStyle>
144
+ <a:effectLst/>
145
+ </a:effectStyle>
146
+ <a:effectStyle>
147
+ <a:effectLst>
148
+ <a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0">
149
+ <a:srgbClr val="000000">
150
+ <a:alpha val="63000"/>
151
+ </a:srgbClr>
152
+ </a:outerShdw>
153
+ </a:effectLst>
154
+ </a:effectStyle>
155
+ </a:effectStyleLst>
156
+ <a:bgFillStyleLst>
157
+ <a:solidFill>
158
+ <a:schemeClr val="phClr"/>
159
+ </a:solidFill>
160
+ <a:solidFill>
161
+ <a:schemeClr val="phClr">
162
+ <a:tint val="95000"/>
163
+ <a:satMod val="170000"/>
164
+ </a:schemeClr>
165
+ </a:solidFill>
166
+ <a:gradFill rotWithShape="1">
167
+ <a:gsLst>
168
+ <a:gs pos="0">
169
+ <a:schemeClr val="phClr">
170
+ <a:tint val="93000"/>
171
+ <a:satMod val="150000"/>
172
+ <a:shade val="98000"/>
173
+ <a:lumMod val="102000"/>
174
+ </a:schemeClr>
175
+ </a:gs>
176
+ <a:gs pos="50000">
177
+ <a:schemeClr val="phClr">
178
+ <a:tint val="98000"/>
179
+ <a:satMod val="130000"/>
180
+ <a:shade val="90000"/>
181
+ <a:lumMod val="103000"/>
182
+ </a:schemeClr>
183
+ </a:gs>
184
+ <a:gs pos="100000">
185
+ <a:schemeClr val="phClr">
186
+ <a:shade val="63000"/>
187
+ <a:satMod val="120000"/>
188
+ </a:schemeClr>
189
+ </a:gs>
190
+ </a:gsLst>
191
+ <a:lin ang="5400000" scaled="0"/>
192
+ </a:gradFill>
193
+ </a:bgFillStyleLst>
194
+ </a:fmtScheme>
195
+ </a:themeElements>
196
+ </a:theme>
197
+ `;
198
+
199
+ export {generateThemeXML};
@@ -0,0 +1,10 @@
1
+ import namespaces from '../namespaces';
2
+
3
+ const webSettingsXML = `
4
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+
6
+ <w:webSettings xmlns:w="${namespaces.w}" xmlns:r="${namespaces.r}">
7
+ </w:webSettings>
8
+ `;
9
+
10
+ export {webSettingsXML};
@@ -0,0 +1,60 @@
1
+ /* eslint-disable no-param-reassign */
2
+
3
+ export const rgbRegex = /rgb\((\d+),\s*([\d.]+),\s*([\d.]+)\)/i;
4
+ export const hslRegex = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/i;
5
+ export const hexRegex = /#([0-9A-F]{6})/i;
6
+ export const hex3Regex = /#([0-9A-F])([0-9A-F])([0-9A-F])/i;
7
+
8
+ // eslint-disable-next-line import/prefer-default-export
9
+ export const rgbToHex = (red, green, blue) => {
10
+ const hexColorCode = [red, green, blue]
11
+ .map((x) => {
12
+ // eslint-disable-next-line radix, no-param-reassign
13
+ x = parseInt(x).toString(16);
14
+ return x.length === 1 ? `0${x}` : x;
15
+ })
16
+ .join('');
17
+
18
+ return hexColorCode;
19
+ };
20
+
21
+ export const hslToHex = (hue, saturation, luminosity) => {
22
+ hue /= 360;
23
+ saturation /= 100;
24
+ luminosity /= 100;
25
+ // eslint-disable-next-line one-var
26
+ let red, green, blue;
27
+ if (saturation === 0) {
28
+ // eslint-disable-next-line no-multi-assign
29
+ red = green = blue = luminosity; // achromatic
30
+ } else {
31
+ const hue2rgb = (p, q, t) => {
32
+ if (t < 0) t += 1;
33
+ if (t > 1) t -= 1;
34
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
35
+ if (t < 1 / 2) return q;
36
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
37
+ return p;
38
+ };
39
+ const q =
40
+ luminosity < 0.5
41
+ ? luminosity * (1 + saturation)
42
+ : luminosity + saturation - luminosity * saturation;
43
+ const p = 2 * luminosity - q;
44
+ red = hue2rgb(p, q, hue + 1 / 3);
45
+ green = hue2rgb(p, q, hue);
46
+ blue = hue2rgb(p, q, hue - 1 / 3);
47
+ }
48
+ return [red, green, blue]
49
+ .map((x) => {
50
+ const hex = Math.round(x * 255).toString(16);
51
+ return hex.length === 1 ? `0${hex}` : hex;
52
+ })
53
+ .join('');
54
+ };
55
+
56
+ export const hex3ToHex = (red, green, blue) => {
57
+ const hexColorCode = [red, green, blue].map((x) => `${x}${x}`).join('');
58
+
59
+ return hexColorCode;
60
+ };
@@ -0,0 +1,55 @@
1
+ class ListStyleBuilder {
2
+ // defaults is an object passed in from constants.js / numbering with the following properties:
3
+ // defaultOrderedListStyleType: 'decimal' (unless otherwise specified)
4
+ constructor(defaults) {
5
+ this.defaults = defaults || { defaultOrderedListStyleType: 'decimal' };
6
+ }
7
+
8
+ // eslint-disable-next-line class-methods-use-this
9
+ getListStyleType(listType) {
10
+ switch (listType) {
11
+ case 'upper-roman':
12
+ return 'upperRoman';
13
+ case 'lower-roman':
14
+ return 'lowerRoman';
15
+ case 'upper-alpha':
16
+ case 'upper-alpha-bracket-end':
17
+ return 'upperLetter';
18
+ case 'lower-alpha':
19
+ case 'lower-alpha-bracket-end':
20
+ return 'lowerLetter';
21
+ case 'decimal':
22
+ case 'decimal-bracket':
23
+ return 'decimal';
24
+ default:
25
+ return this.defaults.defaultOrderedListStyleType;
26
+ }
27
+ }
28
+
29
+ getListPrefixSuffix(style, lvl) {
30
+ let listType = this.defaults.defaultOrderedListStyleType;
31
+
32
+ if (style && style['list-style-type']) {
33
+ listType = style['list-style-type'];
34
+ }
35
+
36
+ switch (listType) {
37
+ case 'upper-roman':
38
+ case 'lower-roman':
39
+ case 'upper-alpha':
40
+ case 'lower-alpha':
41
+ return `%${lvl + 1}.`;
42
+ case 'upper-alpha-bracket-end':
43
+ case 'lower-alpha-bracket-end':
44
+ case 'decimal-bracket-end':
45
+ return `%${lvl + 1})`;
46
+ case 'decimal-bracket':
47
+ return `(%${lvl + 1})`;
48
+ case 'decimal':
49
+ default:
50
+ return `%${lvl + 1}.`;
51
+ }
52
+ }
53
+ }
54
+
55
+ export {ListStyleBuilder};
@@ -0,0 +1,53 @@
1
+ export const pixelRegex = /([\d.]+)px/i;
2
+ export const percentageRegex = /([\d.]+)%/i;
3
+ export const pointRegex = /([\d.]+)pt/i;
4
+ export const cmRegex = /([\d.]+)cm/i;
5
+ export const inchRegex = /([\d.]+)in/i;
6
+
7
+ export const pixelToEMU = (pixelValue) => Math.round(pixelValue * 9525);
8
+
9
+ export const EMUToPixel = (EMUValue) => Math.round(EMUValue / 9525);
10
+
11
+ export const TWIPToEMU = (TWIPValue) => Math.round(TWIPValue * 635);
12
+
13
+ export const EMUToTWIP = (EMUValue) => Math.round(EMUValue / 635);
14
+
15
+ export const pointToTWIP = (pointValue) => Math.round(pointValue * 20);
16
+
17
+ export const TWIPToPoint = (TWIPValue) => Math.round(TWIPValue / 20);
18
+
19
+ export const pointToHIP = (pointValue) => Math.round(pointValue * 2);
20
+
21
+ export const HIPToPoint = (HIPValue) => Math.round(HIPValue / 2);
22
+
23
+ export const HIPToTWIP = (HIPValue) => Math.round(HIPValue * 10);
24
+
25
+ export const TWIPToHIP = (TWIPValue) => Math.round(TWIPValue / 10);
26
+
27
+ export const pixelToTWIP = (pixelValue) => EMUToTWIP(pixelToEMU(pixelValue));
28
+
29
+ export const TWIPToPixel = (TWIPValue) => EMUToPixel(TWIPToEMU(TWIPValue));
30
+
31
+ export const pixelToHIP = (pixelValue) => TWIPToHIP(EMUToTWIP(pixelToEMU(pixelValue)));
32
+
33
+ export const HIPToPixel = (HIPValue) => EMUToPixel(TWIPToEMU(HIPToTWIP(HIPValue)));
34
+
35
+ export const inchToPoint = (inchValue) => Math.round(inchValue * 72);
36
+
37
+ export const inchToTWIP = (inchValue) => pointToTWIP(inchToPoint(inchValue));
38
+
39
+ export const cmToInch = (cmValue) => cmValue * 0.3937008;
40
+
41
+ export const cmToTWIP = (cmValue) => inchToTWIP(cmToInch(cmValue));
42
+
43
+ export const pixelToPoint = (pixelValue) => HIPToPoint(pixelToHIP(pixelValue));
44
+
45
+ export const pointToPixel = (pointValue) => HIPToPixel(pointToHIP(pointValue));
46
+
47
+ export const EIPToPoint = (EIPValue) => Math.round(EIPValue / 8);
48
+
49
+ export const pointToEIP = (PointValue) => Math.round(PointValue * 8);
50
+
51
+ export const pixelToEIP = (pixelValue) => pointToEIP(pixelToPoint(pixelValue));
52
+
53
+ export const EIPToPixel = (EIPValue) => pointToPixel(EIPToPoint(EIPValue));
@@ -0,0 +1,8 @@
1
+ const isValidUrl = (urlString) => {
2
+ const urlRegex = /http(s)?:\/\/(\w+:?\w*@)?(\S+)(:\d+)?((?<=\.)\w+)+(\/([\w#!:.?+=&%@!\-/])*)?/gi;
3
+
4
+ return Boolean(urlRegex.test(urlString));
5
+ };
6
+
7
+ // eslint-disable-next-line import/prefer-default-export
8
+ export { isValidUrl };
@@ -0,0 +1,3 @@
1
+ // eslint-disable-next-line import/prefer-default-export
2
+ export const vNodeHasChildren = (vNode) =>
3
+ vNode && vNode.children && Array.isArray(vNode.children) && vNode.children.length;
@@ -0,0 +1 @@
1
+ export const contentTypesXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\n <Default Extension="rels" ContentType=\n "application/vnd.openxmlformats-package.relationships+xml" />\n <Override PartName="/word/document.xml" ContentType=\n "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>\n <Override PartName="/word/afchunk.mht" ContentType="message/rfc822"/>\n</Types>\n`
@@ -0,0 +1 @@
1
+ export const documentXmlRels = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"\n Target="/word/afchunk.mht" Id="htmlChunk" />\n</Relationships>\n`;
@@ -0,0 +1,3 @@
1
+ export * from './contentTypesXml'
2
+ export * from './documentXmlRels'
3
+ export * from './relsXml'
@@ -0,0 +1 @@
1
+ export const relsXml = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n <Relationship\n Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"\n Target="/word/document.xml" Id="R09c83fafc067488e" />\n</Relationships>\n`
@@ -0,0 +1,8 @@
1
+ import { addFiles, generateDocument, DocumentOptions } from './internal'
2
+ import JSZip from 'jszip';
3
+
4
+ export async function asBlob(html: string, options: Partial<DocumentOptions> = {}) {
5
+ const zip = new JSZip()
6
+ addFiles(zip, html, options)
7
+ return await generateDocument(zip)
8
+ }
@@ -0,0 +1,69 @@
1
+ import JSZip from 'jszip';
2
+ import { getMHTdocument } from './utils'
3
+ import { contentTypesXml, documentXmlRels, relsXml } from './assets'
4
+ import { documentTemplate, Orient, Margins, defaultMargins } from './templates'
5
+ import { isBrowser } from 'browser-or-node'
6
+
7
+ export type DocumentOptions = typeof defaultDocumentOptions
8
+
9
+ const defaultDocumentOptions = {
10
+ orientation: 'portrait' as Orient,
11
+ margins: {} as Partial<Margins>,
12
+ paperWidth: 11905.511 as number,
13
+ paperHeight: 16837.795 as number,
14
+ }
15
+
16
+ function mergeOptions<T>(options: T, patch: Partial<T>) {
17
+ return { ...options, ...patch } as T
18
+ }
19
+
20
+ export async function generateDocument(zip: JSZip) {
21
+ const buffer = await zip.generateAsync({ type: 'arraybuffer' })
22
+ if (isBrowser) {
23
+ return new Blob([buffer], {
24
+ type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
25
+ })
26
+ } else {
27
+ return new Buffer(new Uint8Array(buffer))
28
+ }
29
+ }
30
+
31
+ function getBinaryData(str: string) {
32
+ return isBrowser ? new Blob([str]) : new Buffer(str, 'utf-8')
33
+ }
34
+
35
+ function renderDocumentFile(documentOptions: DocumentOptions) {
36
+ const { orientation, margins, paperWidth, paperHeight } = documentOptions
37
+ const marginsOptions = mergeOptions(defaultMargins, margins)
38
+ let width = 0
39
+ let height = 0
40
+
41
+ if (orientation === 'landscape') {
42
+ height = paperWidth
43
+ width = paperHeight
44
+ } else {
45
+ width = paperWidth
46
+ height = paperHeight
47
+ }
48
+ return documentTemplate(width, height, orientation, marginsOptions)
49
+ }
50
+
51
+ export function addFiles(zip: JSZip, htmlSource: string, options: Partial<DocumentOptions>) {
52
+ const documentOptions = mergeOptions(defaultDocumentOptions, options)
53
+ zip.file('[Content_Types].xml', getBinaryData(contentTypesXml), {
54
+ createFolders: false,
55
+ })
56
+ zip.folder('_rels').file('.rels', getBinaryData(relsXml), { createFolders: false })
57
+ return zip
58
+ .folder('word')
59
+ .file('document.xml', renderDocumentFile(documentOptions), {
60
+ createFolders: false,
61
+ })
62
+ .file('afchunk.mht', getMHTdocument(htmlSource), {
63
+ createFolders: false,
64
+ })
65
+ .folder('_rels')
66
+ .file('document.xml.rels', getBinaryData(documentXmlRels), {
67
+ createFolders: false,
68
+ })
69
+ }