abstract-document 20.0.4 → 20.1.0
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/CHANGELOG.md +4 -0
- package/lib/abstract-document/abstract-doc.d.ts.map +1 -1
- package/lib/abstract-document/abstract-doc.js +2 -2
- package/lib/abstract-document/atoms/atom.d.ts +3 -3
- package/lib/abstract-document/atoms/atom.d.ts.map +1 -1
- package/lib/abstract-document/default-styles.d.ts.map +1 -1
- package/lib/abstract-document/default-styles.js.map +1 -1
- package/lib/abstract-document/markdown/markdown.d.ts.map +1 -1
- package/lib/abstract-document/markdown/markdown.js +4 -4
- package/lib/abstract-document/markdown/markdown.js.map +1 -1
- package/lib/abstract-document/numberings/numbering-definition.d.ts +2 -2
- package/lib/abstract-document/numberings/numbering-definition.d.ts.map +1 -1
- package/lib/abstract-document/numberings/numbering-level-definition.js +2 -2
- package/lib/abstract-document/page/master-page.d.ts +1 -1
- package/lib/abstract-document/page/master-page.d.ts.map +1 -1
- package/lib/abstract-document/page/master-page.js +1 -1
- package/lib/abstract-document/page/master-page.js.map +1 -1
- package/lib/abstract-document/page/section.d.ts +1 -1
- package/lib/abstract-document/page/section.d.ts.map +1 -1
- package/lib/abstract-document/page/section.js +2 -2
- package/lib/abstract-document/page/section.js.map +1 -1
- package/lib/abstract-document/primitives/font.d.ts +1 -1
- package/lib/abstract-document/primitives/font.d.ts.map +1 -1
- package/lib/abstract-document/primitives/font.js +1 -1
- package/lib/abstract-document/primitives/font.js.map +1 -1
- package/lib/abstract-document/primitives/layout-foundation-color.d.ts.map +1 -1
- package/lib/abstract-document/primitives/layout-foundation-color.js.map +1 -1
- package/lib/abstract-document/primitives/layout-foundation.d.ts.map +1 -1
- package/lib/abstract-document/primitives/layout-foundation.js.map +1 -1
- package/lib/abstract-document/resources.d.ts +4 -3
- package/lib/abstract-document/resources.d.ts.map +1 -1
- package/lib/abstract-document/resources.js +4 -4
- package/lib/abstract-document/resources.js.map +1 -1
- package/lib/abstract-document/section-elements/group.d.ts +1 -1
- package/lib/abstract-document/section-elements/group.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/group.js +2 -2
- package/lib/abstract-document/section-elements/group.js.map +1 -1
- package/lib/abstract-document/section-elements/page-break.d.ts +2 -2
- package/lib/abstract-document/section-elements/page-break.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/page-break.js +1 -2
- package/lib/abstract-document/section-elements/page-break.js.map +1 -1
- package/lib/abstract-document/section-elements/paragraph.d.ts +2 -2
- package/lib/abstract-document/section-elements/paragraph.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/paragraph.js +2 -2
- package/lib/abstract-document/section-elements/paragraph.js.map +1 -1
- package/lib/abstract-document/section-elements/section-element.d.ts +1 -1
- package/lib/abstract-document/section-elements/section-element.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/section-element.js.map +1 -1
- package/lib/abstract-document/section-elements/table.d.ts +1 -1
- package/lib/abstract-document/section-elements/table.d.ts.map +1 -1
- package/lib/abstract-document/section-elements/table.js +2 -2
- package/lib/abstract-document/section-elements/table.js.map +1 -1
- package/lib/abstract-document/styles/group-style.js +3 -3
- package/lib/abstract-document/styles/page-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/page-style.js +3 -7
- package/lib/abstract-document/styles/page-style.js.map +1 -1
- package/lib/abstract-document/styles/paragraph-style.d.ts +1 -1
- package/lib/abstract-document/styles/paragraph-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/paragraph-style.js +5 -5
- package/lib/abstract-document/styles/paragraph-style.js.map +1 -1
- package/lib/abstract-document/styles/style.d.ts.map +1 -1
- package/lib/abstract-document/styles/style.js.map +1 -1
- package/lib/abstract-document/styles/table-cell-style.d.ts +1 -1
- package/lib/abstract-document/styles/table-cell-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/table-cell-style.js +7 -7
- package/lib/abstract-document/styles/table-cell-style.js.map +1 -1
- package/lib/abstract-document/styles/table-style.d.ts +1 -1
- package/lib/abstract-document/styles/table-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/table-style.js +2 -2
- package/lib/abstract-document/styles/table-style.js.map +1 -1
- package/lib/abstract-document/styles/text-style.d.ts.map +1 -1
- package/lib/abstract-document/styles/text-style.js +16 -21
- package/lib/abstract-document/styles/text-style.js.map +1 -1
- package/lib/abstract-document/table/table-cell.js +2 -2
- package/lib/abstract-document/table/table-row.d.ts +2 -3
- package/lib/abstract-document/table/table-row.d.ts.map +1 -1
- package/lib/abstract-document/table/table-row.js +2 -3
- package/lib/abstract-document/table/table-row.js.map +1 -1
- package/lib/abstract-document/types.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/document-container.d.ts +5 -5
- package/lib/abstract-document-exporters/docx/document-container.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/document-container.js +14 -13
- package/lib/abstract-document-exporters/docx/document-container.js.map +1 -1
- package/lib/abstract-document-exporters/docx/docx-constants.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/docx-constants.js +1 -4
- package/lib/abstract-document-exporters/docx/docx-constants.js.map +1 -1
- package/lib/abstract-document-exporters/docx/ref-container.d.ts +8 -10
- package/lib/abstract-document-exporters/docx/ref-container.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/ref-container.js +34 -35
- package/lib/abstract-document-exporters/docx/ref-container.js.map +1 -1
- package/lib/abstract-document-exporters/docx/string-utils.d.ts +2 -1
- package/lib/abstract-document-exporters/docx/string-utils.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/string-utils.js +6 -4
- package/lib/abstract-document-exporters/docx/string-utils.js.map +1 -1
- package/lib/abstract-document-exporters/docx/xml-writer.d.ts +12 -33
- package/lib/abstract-document-exporters/docx/xml-writer.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx/xml-writer.js +243 -249
- package/lib/abstract-document-exporters/docx/xml-writer.js.map +1 -1
- package/lib/abstract-document-exporters/docx2/render-image.d.ts +1 -1
- package/lib/abstract-document-exporters/docx2/render-image.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx2/render-image.js +4 -16
- package/lib/abstract-document-exporters/docx2/render-image.js.map +1 -1
- package/lib/abstract-document-exporters/docx2/render.d.ts.map +1 -1
- package/lib/abstract-document-exporters/docx2/render.js +28 -38
- package/lib/abstract-document-exporters/docx2/render.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/font.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/font.js +13 -14
- package/lib/abstract-document-exporters/pdf/font.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/header-footer.d.ts +8 -0
- package/lib/abstract-document-exporters/pdf/header-footer.d.ts.map +1 -0
- package/lib/abstract-document-exporters/pdf/header-footer.js +31 -0
- package/lib/abstract-document-exporters/pdf/header-footer.js.map +1 -0
- package/lib/abstract-document-exporters/pdf/measure.d.ts +4 -4
- package/lib/abstract-document-exporters/pdf/measure.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/measure.js +29 -31
- package/lib/abstract-document-exporters/pdf/measure.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/page.d.ts +15 -0
- package/lib/abstract-document-exporters/pdf/page.d.ts.map +1 -0
- package/lib/abstract-document-exporters/pdf/page.js +2 -0
- package/lib/abstract-document-exporters/pdf/page.js.map +1 -0
- package/lib/abstract-document-exporters/pdf/paginate.d.ts +2 -20
- package/lib/abstract-document-exporters/pdf/paginate.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/paginate.js +8 -45
- package/lib/abstract-document-exporters/pdf/paginate.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/pre-process.js +8 -35
- package/lib/abstract-document-exporters/pdf/pre-process.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/render-image.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/render-image.js +24 -34
- package/lib/abstract-document-exporters/pdf/render-image.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/render.d.ts +4 -3
- package/lib/abstract-document-exporters/pdf/render.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/render.js +60 -50
- package/lib/abstract-document-exporters/pdf/render.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/std-fonts.js +1 -1
- package/lib/abstract-document-exporters/pdf/std-fonts.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/textRunRow.d.ts +3 -3
- package/lib/abstract-document-exporters/pdf/textRunRow.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/textRunRow.js +6 -6
- package/lib/abstract-document-exporters/pdf/textRunRow.js.map +1 -1
- package/lib/abstract-document-exporters/pdf/update-refs.d.ts +1 -1
- package/lib/abstract-document-exporters/pdf/update-refs.d.ts.map +1 -1
- package/lib/abstract-document-exporters/pdf/update-refs.js +3 -2
- package/lib/abstract-document-exporters/pdf/update-refs.js.map +1 -1
- package/lib/abstract-document-exporters/shared/get_resources.d.ts.map +1 -1
- package/lib/abstract-document-exporters/shared/get_resources.js.map +1 -1
- package/lib/abstract-document-jsx/index.d.ts +2 -3
- package/lib/abstract-document-jsx/index.d.ts.map +1 -1
- package/lib/abstract-document-jsx/index.js +10 -6
- package/lib/abstract-document-jsx/index.js.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts +3 -7
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js +5 -3
- package/lib/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.js.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js +1 -3
- package/lib/abstract-document-xml/abstract-doc-of-xml/creator.js.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.d.ts.map +1 -1
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js +4 -8
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js.map +1 -1
- package/lib/abstract-document-xml/xsd-template/xsd-template.js +2 -2
- package/lib/abstract-document-xml/xsd-template/xsd-template.js.map +1 -1
- package/package.json +21 -21
- package/src/abstract-document/abstract-doc.ts +6 -6
- package/src/abstract-document/atoms/atom.ts +3 -3
- package/src/abstract-document/default-styles.ts +1 -1
- package/src/abstract-document/markdown/markdown.ts +5 -5
- package/src/abstract-document/numberings/numbering-definition.ts +2 -2
- package/src/abstract-document/numberings/numbering-level-definition.ts +2 -2
- package/src/abstract-document/page/master-page.ts +2 -2
- package/src/abstract-document/page/section.ts +3 -3
- package/src/abstract-document/primitives/font.ts +1 -12
- package/src/abstract-document/primitives/layout-foundation-color.ts +1 -4
- package/src/abstract-document/primitives/layout-foundation.ts +1 -4
- package/src/abstract-document/resources.ts +9 -14
- package/src/abstract-document/section-elements/group.ts +3 -3
- package/src/abstract-document/section-elements/page-break.ts +2 -3
- package/src/abstract-document/section-elements/paragraph.ts +4 -4
- package/src/abstract-document/section-elements/section-element.ts +1 -1
- package/src/abstract-document/section-elements/table.ts +3 -3
- package/src/abstract-document/styles/group-style.ts +3 -3
- package/src/abstract-document/styles/page-style.ts +3 -7
- package/src/abstract-document/styles/paragraph-style.ts +6 -14
- package/src/abstract-document/styles/style.ts +1 -5
- package/src/abstract-document/styles/table-cell-style.ts +8 -11
- package/src/abstract-document/styles/table-style.ts +3 -8
- package/src/abstract-document/styles/text-style.ts +16 -21
- package/src/abstract-document/table/table-cell.ts +2 -2
- package/src/abstract-document/table/table-row.ts +3 -4
- package/src/abstract-document/types.ts +0 -1
- package/src/abstract-document-exporters/docx/document-container.ts +24 -13
- package/src/abstract-document-exporters/docx/docx-constants.ts +2 -6
- package/src/abstract-document-exporters/docx/ref-container.ts +48 -41
- package/src/abstract-document-exporters/docx/string-utils.ts +6 -6
- package/src/abstract-document-exporters/docx/xml-writer.ts +261 -266
- package/src/abstract-document-exporters/docx2/render-image.ts +15 -49
- package/src/abstract-document-exporters/docx2/render.ts +64 -139
- package/src/abstract-document-exporters/pdf/font.ts +17 -23
- package/src/abstract-document-exporters/pdf/header-footer.ts +43 -0
- package/src/abstract-document-exporters/pdf/measure.ts +50 -103
- package/src/abstract-document-exporters/pdf/page.ts +16 -0
- package/src/abstract-document-exporters/pdf/paginate.ts +29 -125
- package/src/abstract-document-exporters/pdf/pre-process.ts +11 -47
- package/src/abstract-document-exporters/pdf/render-image.ts +29 -46
- package/src/abstract-document-exporters/pdf/render.ts +84 -129
- package/src/abstract-document-exporters/pdf/std-fonts.ts +1 -1
- package/src/abstract-document-exporters/pdf/textRunRow.ts +12 -23
- package/src/abstract-document-exporters/pdf/update-refs.ts +10 -33
- package/src/abstract-document-exporters/shared/get_resources.ts +4 -4
- package/src/abstract-document-jsx/index.ts +38 -26
- package/src/abstract-document-xml/abstract-doc-of-xml/abstract-doc-of-xml.ts +14 -26
- package/src/abstract-document-xml/abstract-doc-of-xml/creator.ts +10 -28
- package/src/abstract-document-xml/abstract-doc-of-xml/custom-elements.tsx +8 -30
- package/src/abstract-document-xml/xsd-template/xsd-template.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as AD from "../../abstract-document/index.js";
|
|
2
|
-
import type { Page } from "./
|
|
2
|
+
import type { Page } from "./page.js";
|
|
3
3
|
|
|
4
4
|
export function updatePageRefs(pages: ReadonlyArray<Page>): Array<Page> {
|
|
5
5
|
return pages.map((page) => updateRefsOnPage(page, pages));
|
|
@@ -23,18 +23,14 @@ function updateRefsInElements(
|
|
|
23
23
|
pages: ReadonlyArray<Page>
|
|
24
24
|
): ReadonlyArray<AD.SectionElement.SectionElement> {
|
|
25
25
|
const updatedElements = new Array<AD.SectionElement.SectionElement>();
|
|
26
|
-
for (
|
|
26
|
+
for (const element of elements) {
|
|
27
27
|
const updatedElement = updateRefsInElement(element, page, pages);
|
|
28
28
|
updatedElements.push(updatedElement);
|
|
29
29
|
}
|
|
30
30
|
return updatedElements;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function updateRefsInElement(
|
|
34
|
-
element: AD.SectionElement.SectionElement,
|
|
35
|
-
page: Page,
|
|
36
|
-
pages: ReadonlyArray<Page>
|
|
37
|
-
): AD.SectionElement.SectionElement {
|
|
33
|
+
function updateRefsInElement(element: AD.SectionElement.SectionElement, page: Page, pages: ReadonlyArray<Page>): AD.SectionElement.SectionElement {
|
|
38
34
|
switch (element.type) {
|
|
39
35
|
case "Paragraph":
|
|
40
36
|
return updateRefsInParagraph(element, page, pages);
|
|
@@ -47,11 +43,7 @@ function updateRefsInElement(
|
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
function updateRefsInParagraph(
|
|
51
|
-
paragraph: AD.Paragraph.Paragraph,
|
|
52
|
-
page: Page,
|
|
53
|
-
pages: ReadonlyArray<Page>
|
|
54
|
-
): AD.SectionElement.SectionElement {
|
|
46
|
+
function updateRefsInParagraph(paragraph: AD.Paragraph.Paragraph, page: Page, pages: ReadonlyArray<Page>): AD.SectionElement.SectionElement {
|
|
55
47
|
const updatedChildren = paragraph.children.map((atom) => updateRefInAtom(atom, page, pages));
|
|
56
48
|
return {
|
|
57
49
|
...paragraph,
|
|
@@ -59,11 +51,7 @@ function updateRefsInParagraph(
|
|
|
59
51
|
};
|
|
60
52
|
}
|
|
61
53
|
|
|
62
|
-
function updateRefsInTable(
|
|
63
|
-
table: AD.Table.Table,
|
|
64
|
-
page: Page,
|
|
65
|
-
pages: ReadonlyArray<Page>
|
|
66
|
-
): AD.SectionElement.SectionElement {
|
|
54
|
+
function updateRefsInTable(table: AD.Table.Table, page: Page, pages: ReadonlyArray<Page>): AD.SectionElement.SectionElement {
|
|
67
55
|
const updatedChildren = table.children.map((row) => updateRefsInTableRow(row, page, pages));
|
|
68
56
|
return {
|
|
69
57
|
...table,
|
|
@@ -79,11 +67,7 @@ function updateRefsInTableRow(row: AD.TableRow.TableRow, page: Page, pages: Read
|
|
|
79
67
|
};
|
|
80
68
|
}
|
|
81
69
|
|
|
82
|
-
function updateRefsInTableCell(
|
|
83
|
-
cell: AD.TableCell.TableCell,
|
|
84
|
-
page: Page,
|
|
85
|
-
pages: ReadonlyArray<Page>
|
|
86
|
-
): AD.TableCell.TableCell {
|
|
70
|
+
function updateRefsInTableCell(cell: AD.TableCell.TableCell, page: Page, pages: ReadonlyArray<Page>): AD.TableCell.TableCell {
|
|
87
71
|
const updatedChildren = cell.children.map((element) => updateRefsInElement(element, page, pages));
|
|
88
72
|
return {
|
|
89
73
|
...cell,
|
|
@@ -91,11 +75,7 @@ function updateRefsInTableCell(
|
|
|
91
75
|
};
|
|
92
76
|
}
|
|
93
77
|
|
|
94
|
-
function updateRefsInGroup(
|
|
95
|
-
group: AD.Group.Group,
|
|
96
|
-
page: Page,
|
|
97
|
-
pages: ReadonlyArray<Page>
|
|
98
|
-
): AD.SectionElement.SectionElement {
|
|
78
|
+
function updateRefsInGroup(group: AD.Group.Group, page: Page, pages: ReadonlyArray<Page>): AD.SectionElement.SectionElement {
|
|
99
79
|
const updatedChildren = group.children.map((element) => updateRefsInElement(element, page, pages));
|
|
100
80
|
return {
|
|
101
81
|
...group,
|
|
@@ -111,11 +91,7 @@ function updateRefInAtom(atom: AD.Atom.Atom, page: Page, pages: ReadonlyArray<Pa
|
|
|
111
91
|
}
|
|
112
92
|
}
|
|
113
93
|
|
|
114
|
-
function updateRefInTextField(
|
|
115
|
-
textField: AD.TextField.TextField,
|
|
116
|
-
page: Page,
|
|
117
|
-
pages: ReadonlyArray<Page>
|
|
118
|
-
): AD.TextField.TextField {
|
|
94
|
+
function updateRefInTextField(textField: AD.TextField.TextField, page: Page, pages: ReadonlyArray<Page>): AD.TextField.TextField {
|
|
119
95
|
switch (textField.fieldType) {
|
|
120
96
|
case "PageNumber":
|
|
121
97
|
return {
|
|
@@ -127,7 +103,7 @@ function updateRefInTextField(
|
|
|
127
103
|
...textField,
|
|
128
104
|
text: pages.length.toString(),
|
|
129
105
|
};
|
|
130
|
-
case "PageNumberOf":
|
|
106
|
+
case "PageNumberOf": {
|
|
131
107
|
const targetPage = pages.find((p) => p.namedDestionations.some((dest) => dest === textField.target));
|
|
132
108
|
if (targetPage) {
|
|
133
109
|
return {
|
|
@@ -137,6 +113,7 @@ function updateRefInTextField(
|
|
|
137
113
|
} else {
|
|
138
114
|
return textField;
|
|
139
115
|
}
|
|
116
|
+
}
|
|
140
117
|
default:
|
|
141
118
|
return textField;
|
|
142
119
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { exhaustiveCheck } from "ts-exhaustive-check";
|
|
2
2
|
import type { AbstractDoc } from "../../abstract-document/abstract-doc.js";
|
|
3
|
+
import type { Section } from "../../abstract-document/page/section.js";
|
|
3
4
|
import type { Resources } from "../../abstract-document/resources.js";
|
|
4
5
|
import { mergeResources } from "../../abstract-document/resources.js";
|
|
5
6
|
import type { Group } from "../../abstract-document/section-elements/group.js";
|
|
6
|
-
import type { Table } from "../../abstract-document/section-elements/table.js";
|
|
7
|
-
import type { SectionElement } from "../../abstract-document/section-elements/section-element.js";
|
|
8
7
|
import type { Paragraph } from "../../abstract-document/section-elements/paragraph.js";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
8
|
+
import type { SectionElement } from "../../abstract-document/section-elements/section-element.js";
|
|
9
|
+
import type { Table } from "../../abstract-document/section-elements/table.js";
|
|
11
10
|
import type { TableCell } from "../../abstract-document/table/table-cell.js";
|
|
11
|
+
import type { TableRow } from "../../abstract-document/table/table-row.js";
|
|
12
12
|
|
|
13
13
|
export function getResources(doc: AbstractDoc): Resources {
|
|
14
14
|
const resources = doc.children.map((s) => getResourcesSection(s));
|
|
@@ -17,52 +17,64 @@ import {
|
|
|
17
17
|
PageBreak as PageBreak1,
|
|
18
18
|
LineBreak as LineBreak1,
|
|
19
19
|
} from "../abstract-document/index.js";
|
|
20
|
+
import type { SectionElement as SectionElement1, Atom as Atom1 } from "../abstract-document/index.js";
|
|
20
21
|
|
|
21
22
|
export interface ChildrenProp {
|
|
22
23
|
readonly children?: Child;
|
|
23
24
|
}
|
|
24
25
|
export type Child = React.JSX.Element | Children;
|
|
25
|
-
export
|
|
26
|
+
export type Children = ReadonlyArray<Child>;
|
|
26
27
|
|
|
28
|
+
// These factories build a real AD tree, structurally incompatible with React.JSX.Element (the fake
|
|
29
|
+
// type this JSX pragma requires). Every cast below just bridges the two via `unknown`; there's no real type fix.
|
|
27
30
|
export const AbstractDoc = (props?: AbstractDoc1.AbstractDocProps & ChildrenProp): React.JSX.Element =>
|
|
28
|
-
AbstractDoc1.create(props, props && (props.children as
|
|
31
|
+
AbstractDoc1.create(props, props && (props.children as unknown as ReadonlyArray<Section1.Section>)) as unknown as React.JSX.Element;
|
|
29
32
|
export const Section = (props?: Section1.SectionProps & ChildrenProp): React.JSX.Element =>
|
|
30
|
-
Section1.create(props, props && (props.children as
|
|
33
|
+
Section1.create(props, props && (props.children as unknown as ReadonlyArray<SectionElement1.SectionElement>)) as unknown as React.JSX.Element;
|
|
31
34
|
export const Group = (props: Group1.GroupProps & ChildrenProp): React.JSX.Element =>
|
|
32
|
-
Group1.create(props, props && (props.children as
|
|
35
|
+
Group1.create(props, props && (props.children as unknown as ReadonlyArray<SectionElement1.SectionElement>)) as unknown as React.JSX.Element;
|
|
33
36
|
export const Paragraph = (props: Paragraph1.ParagraphProps & ChildrenProp): React.JSX.Element =>
|
|
34
|
-
Paragraph1.create(props, props && (props.children as
|
|
37
|
+
Paragraph1.create(props, props && (props.children as unknown as ReadonlyArray<Atom1.Atom>)) as unknown as React.JSX.Element;
|
|
35
38
|
export const Table = (props: Table1.TableProps & ChildrenProp): React.JSX.Element =>
|
|
36
|
-
Table1.create(props, props && (props.children as
|
|
39
|
+
Table1.create(props, props && (props.children as unknown as ReadonlyArray<TableRow1.TableRow>)) as unknown as React.JSX.Element;
|
|
37
40
|
export const TableRow = (props: TableRow1.TableRowProps & ChildrenProp): React.JSX.Element =>
|
|
38
|
-
TableRow1.create(props, props && (props.children as
|
|
41
|
+
TableRow1.create(props, props && (props.children as unknown as ReadonlyArray<TableCell1.TableCell>)) as unknown as React.JSX.Element;
|
|
39
42
|
export const TableCell = (props: TableCell1.TableCellProps & ChildrenProp): React.JSX.Element =>
|
|
40
|
-
TableCell1.create(props, props && (props.children as
|
|
41
|
-
export const HyperLink = (props: HyperLink1.HyperLinkProps): React.JSX.Element => HyperLink1.create(props) as
|
|
42
|
-
export const LinkTarget = (props: LinkTarget1.LinkTargetProps): React.JSX.Element => LinkTarget1.create(props) as
|
|
43
|
-
export const Image = (props: Image1.ImageProps): React.JSX.Element => Image1.create(props) as
|
|
43
|
+
TableCell1.create(props, props && (props.children as unknown as ReadonlyArray<SectionElement1.SectionElement>)) as unknown as React.JSX.Element;
|
|
44
|
+
export const HyperLink = (props: HyperLink1.HyperLinkProps): React.JSX.Element => HyperLink1.create(props) as unknown as React.JSX.Element;
|
|
45
|
+
export const LinkTarget = (props: LinkTarget1.LinkTargetProps): React.JSX.Element => LinkTarget1.create(props) as unknown as React.JSX.Element;
|
|
46
|
+
export const Image = (props: Image1.ImageProps): React.JSX.Element => Image1.create(props) as unknown as React.JSX.Element;
|
|
44
47
|
export const TocSeparator = (props: TocSeparator1.TocSeparatorProps): React.JSX.Element =>
|
|
45
|
-
TocSeparator1.create(props) as
|
|
46
|
-
export const Markdown = (props: Markdown1.MarkdownProps): React.JSX.Element => Markdown1.create(props) as
|
|
47
|
-
export const TextField = (props: TextField1.TextFieldProps): React.JSX.Element => TextField1.create(props) as
|
|
48
|
-
export const TextRun = (props: TextRun1.TextRunProps): React.JSX.Element => TextRun1.create(props) as
|
|
49
|
-
export const PageBreak = (props: PageBreak1.PageBreakProps): React.JSX.Element => PageBreak1.create(props) as
|
|
50
|
-
export const LineBreak = (props: LineBreak1.LineBreakProps): React.JSX.Element => LineBreak1.create(props) as
|
|
48
|
+
TocSeparator1.create(props) as unknown as React.JSX.Element;
|
|
49
|
+
export const Markdown = (props: Markdown1.MarkdownProps): React.JSX.Element => Markdown1.create(props) as unknown as React.JSX.Element;
|
|
50
|
+
export const TextField = (props: TextField1.TextFieldProps): React.JSX.Element => TextField1.create(props) as unknown as React.JSX.Element;
|
|
51
|
+
export const TextRun = (props: TextRun1.TextRunProps): React.JSX.Element => TextRun1.create(props) as unknown as React.JSX.Element;
|
|
52
|
+
export const PageBreak = (props: PageBreak1.PageBreakProps): React.JSX.Element => PageBreak1.create(props) as unknown as React.JSX.Element;
|
|
53
|
+
export const LineBreak = (props: LineBreak1.LineBreakProps): React.JSX.Element => LineBreak1.create(props) as unknown as React.JSX.Element;
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
// Shape actually accessed when walking the fake element tree at runtime; `type`'s props param and
|
|
56
|
+
// `props` itself are a genuinely arbitrary bag of component props, not a fixed structural type.
|
|
57
|
+
interface FakeElement {
|
|
58
|
+
readonly type: string | ((props: Record<string, unknown>) => unknown);
|
|
59
|
+
readonly props?: { readonly children?: unknown; readonly [key: string]: unknown };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- callers assign the result to whichever AD model type they expect at that call site; narrowing this would break every caller
|
|
63
|
+
export function render(element: unknown): any {
|
|
64
|
+
const el = element as FakeElement;
|
|
65
|
+
if (typeof el.type !== "function") {
|
|
66
|
+
return el;
|
|
55
67
|
}
|
|
56
|
-
const props =
|
|
57
|
-
const children = renderChildren(
|
|
58
|
-
return
|
|
68
|
+
const props = el.props ?? {};
|
|
69
|
+
const children = renderChildren(el);
|
|
70
|
+
return el.type({ ...props, children });
|
|
59
71
|
}
|
|
60
72
|
|
|
61
|
-
function renderChildren(element:
|
|
62
|
-
if (!element.props
|
|
73
|
+
function renderChildren(element: FakeElement): Array<unknown> {
|
|
74
|
+
if (!element.props?.children) {
|
|
63
75
|
return [];
|
|
64
76
|
} else if (Array.isArray(element.props.children)) {
|
|
65
|
-
return element.props.children.flatMap((c:
|
|
77
|
+
return element.props.children.flatMap((c: unknown) => {
|
|
66
78
|
if (!c) {
|
|
67
79
|
return [];
|
|
68
80
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { parseHandlebarsXml, type XmlElement } from "handlebars-xml";
|
|
2
|
+
import { getFontStyleName } from "../../abstract-document-exporters/pdf/font.js";
|
|
1
3
|
import { addResources, merge } from "../../abstract-document/abstract-doc.js";
|
|
2
4
|
import type { AbstractDoc } from "../../abstract-document/index.js";
|
|
3
|
-
import
|
|
5
|
+
import type { Font } from "../../abstract-document/primitives/font.js";
|
|
4
6
|
import type { Resources } from "../../abstract-document/resources.js";
|
|
7
|
+
import * as StyleKey from "../../abstract-document/styles/style-key.js";
|
|
5
8
|
import type { ADCreatorFn } from "./creator.js";
|
|
6
9
|
import { creators, propsCreators } from "./creator.js";
|
|
7
|
-
import { parseHandlebarsXml, type XmlElement } from "handlebars-xml";
|
|
8
|
-
import { getFontStyleName } from "../../abstract-document-exporters/pdf/font.js";
|
|
9
|
-
import type { Font } from "../../abstract-document/primitives/font.js";
|
|
10
10
|
|
|
11
11
|
export type TemplateInput = {
|
|
12
12
|
readonly template: string;
|
|
13
|
-
readonly data:
|
|
13
|
+
readonly data: unknown;
|
|
14
14
|
readonly partials: Record<string, string>;
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -22,10 +22,7 @@ export type Format = "PDF" | "DOCX";
|
|
|
22
22
|
|
|
23
23
|
export async function abstractDocsXml(
|
|
24
24
|
templateInputs: ReadonlyArray<TemplateInput>,
|
|
25
|
-
getResources: (
|
|
26
|
-
imageUrls: Record<string, true>,
|
|
27
|
-
fontFamilies: Record<string, Partial<Record<keyof Font, boolean>>>
|
|
28
|
-
) => Promise<Resources>
|
|
25
|
+
getResources: (imageUrls: Record<string, true>, fontFamilies: Record<string, Partial<Record<keyof Font, boolean>>>) => Promise<Resources>
|
|
29
26
|
): Promise<AbstractDoxXmlsResult> {
|
|
30
27
|
try {
|
|
31
28
|
const abstractDocs = Array<AbstractDoc.AbstractDoc>();
|
|
@@ -35,9 +32,7 @@ export async function abstractDocsXml(
|
|
|
35
32
|
const [ad, newImageUrls, newFontFamilies] = abstractDocXml(r.template, r.data, r.partials);
|
|
36
33
|
abstractDocs.push(ad);
|
|
37
34
|
imageUrls = { ...imageUrls, ...newImageUrls };
|
|
38
|
-
Object.entries(newFontFamilies).forEach(
|
|
39
|
-
([font, types]) => (fontFamilies[font] = { ...fontFamilies[font], ...types })
|
|
40
|
-
);
|
|
35
|
+
Object.entries(newFontFamilies).forEach(([font, types]) => (fontFamilies[font] = { ...fontFamilies[font], ...types }));
|
|
41
36
|
}
|
|
42
37
|
const resources = await getResources(imageUrls, fontFamilies);
|
|
43
38
|
const combinedReport = addResources(merge(...abstractDocs), resources);
|
|
@@ -49,24 +44,17 @@ export async function abstractDocsXml(
|
|
|
49
44
|
|
|
50
45
|
export function abstractDocXml(
|
|
51
46
|
template: string,
|
|
52
|
-
data:
|
|
47
|
+
data: unknown,
|
|
53
48
|
partials: Record<string, string>
|
|
54
|
-
): readonly [
|
|
55
|
-
AbstractDoc.AbstractDoc,
|
|
56
|
-
imageUrls: Record<string, true>,
|
|
57
|
-
fontFamilies: Record<string, Partial<Record<keyof Font, boolean>>>,
|
|
58
|
-
] {
|
|
49
|
+
): readonly [AbstractDoc.AbstractDoc, imageUrls: Record<string, true>, fontFamilies: Record<string, Partial<Record<keyof Font, boolean>>>] {
|
|
59
50
|
const xml = parseHandlebarsXml(template, data, partials);
|
|
60
51
|
const [imageUrls, fontFamilies, styleNames] = extractImageFontsStyleNames(xml);
|
|
61
52
|
const doc = abstractDocXmlRecursive(creators(styleNames), xml[0]);
|
|
62
53
|
return [doc, imageUrls, fontFamilies];
|
|
63
54
|
}
|
|
64
55
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
xmlElement: XmlElement,
|
|
68
|
-
onlyChildren: boolean = false
|
|
69
|
-
): any {
|
|
56
|
+
// oxlint-disable-next-line typescript/no-explicit-any -- produces whichever AD model type (or a children array) the caller expects at that recursion site; see the single external call site's tuple return, which assigns this straight to AbstractDoc.AbstractDoc
|
|
57
|
+
function abstractDocXmlRecursive(creators: Record<string, ADCreatorFn>, xmlElement: XmlElement, onlyChildren: boolean = false): any {
|
|
70
58
|
const children = [];
|
|
71
59
|
const props: Record<string, unknown> = {};
|
|
72
60
|
for (const childElement of xmlElement.children ?? []) {
|
|
@@ -74,7 +62,7 @@ function abstractDocXmlRecursive(
|
|
|
74
62
|
if (childName !== undefined) {
|
|
75
63
|
if (childName === "StyleNames") {
|
|
76
64
|
props["styles"] = abstractDocXmlRecursive(creators, childElement);
|
|
77
|
-
} else if (childName === "StyleName" && childElement.attributes
|
|
65
|
+
} else if (childName === "StyleName" && childElement.attributes?.["name"]) {
|
|
78
66
|
const styleName = StyleKey.create(childElement.attributes["type"], childElement.attributes["name"]);
|
|
79
67
|
const style = abstractDocXmlRecursive(creators, childElement);
|
|
80
68
|
props[styleName] = style;
|
|
@@ -110,9 +98,9 @@ function abstractDocXmlRecursive(
|
|
|
110
98
|
//
|
|
111
99
|
const obj = creator(allProps, children) as { [k: string]: unknown };
|
|
112
100
|
|
|
101
|
+
// oxlint-disable-next-line unicorn/no-array-sort
|
|
113
102
|
for (const propName of Object.keys(allProps).sort((a, b) => a.length - b.length)) {
|
|
114
|
-
const propsCreator =
|
|
115
|
-
allProps[propName] !== undefined && propsCreators[propName] ? propsCreators[propName] : undefined;
|
|
103
|
+
const propsCreator = allProps[propName] !== undefined && propsCreators[propName] ? propsCreators[propName] : undefined;
|
|
116
104
|
if (propsCreator) {
|
|
117
105
|
const attributeName = getSuffixedAttributeBaseName(propsCreator.name) ?? propsCreator.name;
|
|
118
106
|
obj[attributeName] = propsCreator(allProps, children);
|
|
@@ -17,14 +17,7 @@ import {
|
|
|
17
17
|
TocSeparator,
|
|
18
18
|
ImageResource,
|
|
19
19
|
} from "../../abstract-document/index.js";
|
|
20
|
-
import type {
|
|
21
|
-
TextRowProps,
|
|
22
|
-
TextCellProps,
|
|
23
|
-
TextParagraphProps,
|
|
24
|
-
ImageCellProps,
|
|
25
|
-
ImageParagraphProps,
|
|
26
|
-
ImageRowProps,
|
|
27
|
-
} from "./custom-elements.js";
|
|
20
|
+
import type { TextRowProps, TextCellProps, TextParagraphProps, ImageCellProps, ImageParagraphProps, ImageRowProps } from "./custom-elements.js";
|
|
28
21
|
import { TextRow, TextCell, TextParagraph, ImageCell, ImageParagraph, ImageRow } from "./custom-elements.js";
|
|
29
22
|
|
|
30
23
|
export type ADCreatorFn = (props?: Record<string, unknown>, children?: ReadonlyArray<unknown>) => unknown;
|
|
@@ -39,13 +32,10 @@ export const creators: (styleNames: Record<string, string>) => Record<string, AD
|
|
|
39
32
|
TextParagraph: (props: TextParagraphProps) => TextParagraph(props, styleNames),
|
|
40
33
|
TextRun: (props) => TextRun.create(props as unknown as TextRun.TextRunProps),
|
|
41
34
|
ImageRow: (props: Record<string, unknown>) => ImageRow(imageProps(props) as unknown as ImageRowProps, styleNames),
|
|
42
|
-
ImageCell: (props: Record<string, unknown>) =>
|
|
43
|
-
|
|
44
|
-
ImageParagraph: (props: Record<string, unknown>) =>
|
|
45
|
-
ImageParagraph(imageProps(props) as unknown as ImageParagraphProps, styleNames),
|
|
35
|
+
ImageCell: (props: Record<string, unknown>) => ImageCell(imageProps(props) as unknown as ImageCellProps, styleNames),
|
|
36
|
+
ImageParagraph: (props: Record<string, unknown>) => ImageParagraph(imageProps(props) as unknown as ImageParagraphProps, styleNames),
|
|
46
37
|
Image: (props: Record<string, unknown>) => Image.create(imageProps(props) as unknown as Image.ImageProps),
|
|
47
|
-
Table: (props, children: ReadonlyArray<TableRow.TableRow>) =>
|
|
48
|
-
Table.create(props as unknown as Table.TableProps, children),
|
|
38
|
+
Table: (props, children: ReadonlyArray<TableRow.TableRow>) => Table.create(props as unknown as Table.TableProps, children),
|
|
49
39
|
TableRow: (props, children: ReadonlyArray<TableCell.TableCell>) => TableRow.create(props, children),
|
|
50
40
|
TableCell: (props, children: ReadonlyArray<SectionElement.SectionElement>) => TableCell.create(props, children),
|
|
51
41
|
TextField: (props) => TextField.create(props as unknown as TextField.TextFieldProps),
|
|
@@ -57,9 +47,7 @@ export const creators: (styleNames: Record<string, string>) => Record<string, AD
|
|
|
57
47
|
};
|
|
58
48
|
|
|
59
49
|
export const propsCreators: Record<string, ADCreatorFn> = {
|
|
60
|
-
styles: (props: {
|
|
61
|
-
readonly styles: Record<string, Record<string, string | number> & { readonly type: string }>;
|
|
62
|
-
}): unknown => {
|
|
50
|
+
styles: (props: { readonly styles: Record<string, Record<string, string | number> & { readonly type: string }> }): unknown => {
|
|
63
51
|
const fixedStyles: Record<string, Record<string, string | number>> = {};
|
|
64
52
|
if (props.styles) {
|
|
65
53
|
Object.keys(props.styles).forEach((key: string) => {
|
|
@@ -320,22 +308,19 @@ export const propsCreators: Record<string, ADCreatorFn> = {
|
|
|
320
308
|
},
|
|
321
309
|
borderColorBottom: (props: { readonly borderColorBottom: string }): unknown => {
|
|
322
310
|
const allProps = props as Record<string, unknown>;
|
|
323
|
-
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } =
|
|
324
|
-
allProps["borderColors"] ?? {};
|
|
311
|
+
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } = allProps["borderColors"] ?? {};
|
|
325
312
|
boderColors.bottom = props.borderColorBottom;
|
|
326
313
|
return boderColors;
|
|
327
314
|
},
|
|
328
315
|
borderColorLeft: (props: { readonly borderColorLeft: string }): unknown => {
|
|
329
316
|
const allProps = props as Record<string, unknown>;
|
|
330
|
-
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } =
|
|
331
|
-
allProps["borderColors"] ?? {};
|
|
317
|
+
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } = allProps["borderColors"] ?? {};
|
|
332
318
|
boderColors.left = props.borderColorLeft;
|
|
333
319
|
return boderColors;
|
|
334
320
|
},
|
|
335
321
|
borderColorRight: (props: { readonly borderColorRight: string }): unknown => {
|
|
336
322
|
const allProps = props as Record<string, unknown>;
|
|
337
|
-
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } =
|
|
338
|
-
allProps["borderColors"] ?? {};
|
|
323
|
+
const boderColors: { top?: string; bottom?: string; left?: string; right?: string } = allProps["borderColors"] ?? {};
|
|
339
324
|
boderColors.right = props.borderColorRight;
|
|
340
325
|
return boderColors;
|
|
341
326
|
},
|
|
@@ -367,8 +352,7 @@ export const propsCreators: Record<string, ADCreatorFn> = {
|
|
|
367
352
|
lineBreak: (props: { readonly lineBreak: string }): unknown => strToBool(props.lineBreak),
|
|
368
353
|
mediumBold: (props: { readonly mediumBold: string }): unknown => strToBool(props.mediumBold),
|
|
369
354
|
noTopBottomMargin: (props: { readonly noTopBottomMargin: string }): unknown => strToBool(props.noTopBottomMargin),
|
|
370
|
-
keepTogetherSections: (props: { readonly keepTogetherSections: string }): unknown =>
|
|
371
|
-
strToBool(props.keepTogetherSections),
|
|
355
|
+
keepTogetherSections: (props: { readonly keepTogetherSections: string }): unknown => strToBool(props.keepTogetherSections),
|
|
372
356
|
keepTogether: (props: { readonly keepTogether: string }): unknown => strToBool(props.keepTogether),
|
|
373
357
|
differentFirstPage: (props: { readonly differentFirstPage: string }): unknown => strToBool(props.differentFirstPage),
|
|
374
358
|
};
|
|
@@ -382,9 +366,7 @@ function imageProps(props: Record<string, unknown>): Record<string, unknown> {
|
|
|
382
366
|
height: Number(props["height"]),
|
|
383
367
|
imageResource: ImageResource.create({
|
|
384
368
|
id: props["src"] as string,
|
|
385
|
-
abstractImage: createAbstractImage(zero, size, white, [
|
|
386
|
-
createBinaryImage(zero, zero, "png", { type: "url", url: props["src"] as string }),
|
|
387
|
-
]),
|
|
369
|
+
abstractImage: createAbstractImage(zero, size, white, [createBinaryImage(zero, zero, "png", { type: "url", url: props["src"] as string })]),
|
|
388
370
|
renderScale: 1,
|
|
389
371
|
}),
|
|
390
372
|
};
|
|
@@ -20,11 +20,8 @@ const stylePropsKeys: Record<string, boolean> = {
|
|
|
20
20
|
GroupStyle: true,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export function extractStyleNames(
|
|
24
|
-
styleNames
|
|
25
|
-
styleNameTypes: Record<string, string>
|
|
26
|
-
): Partial<StyleProps> {
|
|
27
|
-
const names = (styleNames || "").split(",");
|
|
23
|
+
export function extractStyleNames(styleNames: string | undefined, styleNameTypes: Record<string, string>): Partial<StyleProps> {
|
|
24
|
+
const names = (styleNames ?? "").split(",");
|
|
28
25
|
|
|
29
26
|
let styleNameProps = {};
|
|
30
27
|
|
|
@@ -102,27 +99,14 @@ export type ImageCellProps = Omit<ImageParagraphProps, "style"> & {
|
|
|
102
99
|
};
|
|
103
100
|
|
|
104
101
|
export function ImageCell(props: ImageCellProps, styleNameTypes: Record<string, string>): TableCell.TableCell {
|
|
105
|
-
const {
|
|
106
|
-
imageResource,
|
|
107
|
-
width,
|
|
108
|
-
height,
|
|
109
|
-
horizontalAlignment,
|
|
110
|
-
verticalAlignment,
|
|
111
|
-
paragraphStyle,
|
|
112
|
-
style,
|
|
113
|
-
columnSpan,
|
|
114
|
-
rowSpan,
|
|
115
|
-
} = props;
|
|
102
|
+
const { imageResource, width, height, horizontalAlignment, verticalAlignment, paragraphStyle, style, columnSpan, rowSpan } = props;
|
|
116
103
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
117
|
-
const imageElement =
|
|
118
|
-
imageResource && Image.create({ imageResource, width, height, horizontalAlignment, verticalAlignment });
|
|
104
|
+
const imageElement = imageResource && Image.create({ imageResource, width, height, horizontalAlignment, verticalAlignment });
|
|
119
105
|
const pararaphProps = {
|
|
120
106
|
style: paragraphStyle ? { ...paragraphStyle, type: "ParagraphStyle" } : undefined,
|
|
121
107
|
styleName: styleNames.ParagraphStyle,
|
|
122
108
|
} as ParagraphProps;
|
|
123
|
-
const paragraph = imageElement
|
|
124
|
-
? Paragraph.create(pararaphProps, [imageElement])
|
|
125
|
-
: Paragraph.create(pararaphProps, [ImageMissing]);
|
|
109
|
+
const paragraph = imageElement ? Paragraph.create(pararaphProps, [imageElement]) : Paragraph.create(pararaphProps, [ImageMissing]);
|
|
126
110
|
return TableCell.create({ columnSpan, rowSpan, style, styleName: styleNames.TableCellStyle }, [paragraph]);
|
|
127
111
|
}
|
|
128
112
|
|
|
@@ -131,18 +115,12 @@ export type ImageParagraphProps = ImageProps & {
|
|
|
131
115
|
readonly styleNames?: string;
|
|
132
116
|
};
|
|
133
117
|
|
|
134
|
-
export function ImageParagraph(
|
|
135
|
-
props: ImageParagraphProps,
|
|
136
|
-
styleNameTypes: Record<string, string>
|
|
137
|
-
): Paragraph.Paragraph | undefined {
|
|
118
|
+
export function ImageParagraph(props: ImageParagraphProps, styleNameTypes: Record<string, string>): Paragraph.Paragraph | undefined {
|
|
138
119
|
const { imageResource, width, height, style, horizontalAlignment, verticalAlignment } = props;
|
|
139
120
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
140
|
-
const imageElement =
|
|
141
|
-
imageResource && Image.create({ imageResource, width, height, horizontalAlignment, verticalAlignment });
|
|
121
|
+
const imageElement = imageResource && Image.create({ imageResource, width, height, horizontalAlignment, verticalAlignment });
|
|
142
122
|
const pararaphProps = { style, styleName: styleNames.ParagraphStyle };
|
|
143
|
-
return imageElement
|
|
144
|
-
? Paragraph.create(pararaphProps, [imageElement])
|
|
145
|
-
: Paragraph.create(pararaphProps, [ImageMissing]);
|
|
123
|
+
return imageElement ? Paragraph.create(pararaphProps, [imageElement]) : Paragraph.create(pararaphProps, [ImageMissing]);
|
|
146
124
|
}
|
|
147
125
|
|
|
148
126
|
const ImageMissing = TextRun.create({ text: "Image missing" });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { parseXsd } from "handlebars-xml";
|
|
2
|
+
import * as CustomElements from "./custom-elements.js";
|
|
1
3
|
import * as Elements from "./elements.js";
|
|
2
4
|
import * as Styles from "./styles.js";
|
|
3
|
-
import * as CustomElements from "./custom-elements.js";
|
|
4
|
-
import { parseXsd } from "handlebars-xml";
|
|
5
5
|
|
|
6
6
|
const commonParts = `${Styles.layoutFoundation}
|
|
7
7
|
${Styles.pageColumnLayout}
|