abstract-document 6.12.6 → 6.12.8
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/lib/abstract-document-xml/abstract-doc-of-xml/creator.d.ts +2 -5
- 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 +15 -25
- 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 +21 -11
- 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 +12 -12
- package/lib/abstract-document-xml/abstract-doc-of-xml/custom-elements.js.map +1 -1
- package/lib/abstract-document-xml/xsd-template/custom-elements.d.ts +5 -5
- package/lib/abstract-document-xml/xsd-template/custom-elements.d.ts.map +1 -1
- package/lib/abstract-document-xml/xsd-template/custom-elements.js +7 -7
- package/package.json +2 -2
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Group.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Header and footer.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Header → footer.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed hyperlink and textrun.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed hyperlink → textrun.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed textrun and images.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Mixed textrun → images.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple images.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple tables.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Center alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with End alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Start alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Multiple textrun with Start alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Page numbering.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table colSpan and rowSpan.docx and b/package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table colSpan → rowSpan.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table without rows.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Simple table.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single hyperlink.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single image.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Center alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Center alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with End alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with End alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Start alignment that linebreaks.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun with Start alignment.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/Single textrun.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/hello with Arial font.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/hello.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/letter-dimensions.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/page-orientation-landscape.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/page-orientation-portrait.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/tocSeparator.docx +0 -0
- package/src/abstract-document-exporters/__tests__/docx2/tmp/world.docx +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position group.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position header and footer.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position paragraph.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position section in group.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position section in table.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Absolute position table.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group Paragraphs.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group Tables.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group no keeptogether.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Group too big for one page.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Header and footer.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Hyperlink internal linktarget.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Hyperlink internal.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Manual line break.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Manual line breaks empty lines.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Margins header body footer.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed hyperlink and textrun no underline.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed hyperlink and textrun with underline.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed hyperlink and textrun.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed textrun and images.pdf and b/package/src/abstract-document-exporters/__tests__/pdf/tmp/Mixed textrun → images.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple images overflow.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple images.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with End alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Start alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Multiple textrun with Start alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Page numbering.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table row that doesnt fit page.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table single row.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with group.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with header 2.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with header.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin bottom.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin top single table.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with margin top.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with rowSpan multipages.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Pagebreak table with rowSpan.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table all auto.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table all fix.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table background.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table cell padding of image.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table cell padding of text.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table colSpan and rowSpan.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table minimal row height.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table mix auto fix.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table padding.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table right alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table row alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table text alignment in cell with wrapping.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table text alignment in cell.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with default colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with header.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with multi colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Simple table with single colored borders.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single date.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single figure.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink centered.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink no underline.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink right aligned.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single hyperlink.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image from URL.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color hex.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color name.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg color url.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image svg dasharray.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single image.pdf +0 -0
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun baseline alphabetic.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun baseline bottom.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun baseline hanging.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun baseline middle.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun baseline top.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Center alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Center alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with End alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with End alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Justify alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Start alignment that linebreaks.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with Start alignment.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun with super and subscripts.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Single textrun.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/Table of content separator.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/hello with roman font.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/hello.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/pagebreak.pdf +2 -2
- package/src/abstract-document-exporters/__tests__/pdf/tmp/world.pdf +2 -2
- package/src/abstract-document-xml/abstract-doc-of-xml/creator.ts +17 -28
- package/src/abstract-document-xml/abstract-doc-of-xml/custom-elements.tsx +28 -24
- package/src/abstract-document-xml/xsd-template/custom-elements.ts +7 -7
|
@@ -71,7 +71,7 @@ endobj
|
|
|
71
71
|
(PDFKit)
|
|
72
72
|
endobj
|
|
73
73
|
14 0 obj
|
|
74
|
-
(D:
|
|
74
|
+
(D:20231008115808Z)
|
|
75
75
|
endobj
|
|
76
76
|
11 0 obj
|
|
77
77
|
<<
|
|
@@ -136,7 +136,7 @@ trailer
|
|
|
136
136
|
/Size 15
|
|
137
137
|
/Root 3 0 R
|
|
138
138
|
/Info 11 0 R
|
|
139
|
-
/ID [<
|
|
139
|
+
/ID [<41e71d861a1a625d5078d9dc5408f12f> <41e71d861a1a625d5078d9dc5408f12f>]
|
|
140
140
|
>>
|
|
141
141
|
startxref
|
|
142
142
|
1232
|
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20231008115806Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<810f3941d064af38ff82e0c2405d678e> <810f3941d064af38ff82e0c2405d678e>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
894
|
|
@@ -79,7 +79,7 @@ endobj
|
|
|
79
79
|
(PDFKit)
|
|
80
80
|
endobj
|
|
81
81
|
15 0 obj
|
|
82
|
-
(D:
|
|
82
|
+
(D:20231008115807Z)
|
|
83
83
|
endobj
|
|
84
84
|
12 0 obj
|
|
85
85
|
<<
|
|
@@ -145,7 +145,7 @@ trailer
|
|
|
145
145
|
/Size 16
|
|
146
146
|
/Root 3 0 R
|
|
147
147
|
/Info 12 0 R
|
|
148
|
-
/ID [<
|
|
148
|
+
/ID [<6ca4670ddedcc61748157cf907154719> <6ca4670ddedcc61748157cf907154719>]
|
|
149
149
|
>>
|
|
150
150
|
startxref
|
|
151
151
|
1212
|
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20231008115806Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<0401ed786b4941c90f6f899b18612b9f> <0401ed786b4941c90f6f899b18612b9f>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
824
|
|
@@ -43,7 +43,7 @@ endobj
|
|
|
43
43
|
(PDFKit)
|
|
44
44
|
endobj
|
|
45
45
|
12 0 obj
|
|
46
|
-
(D:
|
|
46
|
+
(D:20231008115808Z)
|
|
47
47
|
endobj
|
|
48
48
|
9 0 obj
|
|
49
49
|
<<
|
|
@@ -106,7 +106,7 @@ trailer
|
|
|
106
106
|
/Size 13
|
|
107
107
|
/Root 3 0 R
|
|
108
108
|
/Info 9 0 R
|
|
109
|
-
/ID [<
|
|
109
|
+
/ID [<811e2c0578472193d0ded3101de72ed9> <811e2c0578472193d0ded3101de72ed9>]
|
|
110
110
|
>>
|
|
111
111
|
startxref
|
|
112
112
|
837
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
TextRun,
|
|
20
20
|
TocSeparator,
|
|
21
21
|
Types,
|
|
22
|
-
ImageResource as ADImageResource,
|
|
23
22
|
TextStyle,
|
|
24
23
|
} from "../../abstract-document/index";
|
|
25
24
|
import {
|
|
@@ -35,12 +34,11 @@ import {
|
|
|
35
34
|
ImageRowProps,
|
|
36
35
|
ImageParagraph,
|
|
37
36
|
ImageRow,
|
|
37
|
+
ImageResource,
|
|
38
38
|
} from "./custom-elements";
|
|
39
39
|
|
|
40
40
|
export type ADCreatorFn = (props?: Record<string, unknown>, children?: ReadonlyArray<unknown>) => unknown;
|
|
41
41
|
|
|
42
|
-
export type ImageResource = ADImageResource.ImageResource & { readonly width?: number; readonly height?: number };
|
|
43
|
-
|
|
44
42
|
export type TextRunProps = {
|
|
45
43
|
readonly text: string;
|
|
46
44
|
readonly styleName?: string;
|
|
@@ -65,22 +63,11 @@ export const creators: (
|
|
|
65
63
|
TextCell: (props: TextCellProps) => TextCell(props, styleNames),
|
|
66
64
|
TextParagraph: (props: TextParagraphProps) => TextParagraph(props, styleNames),
|
|
67
65
|
TextRun: (props) => TextRun.create(props as unknown as TextRun.TextRunProps),
|
|
68
|
-
ImageRow: (props: ImageRowProps) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
mutateImageProps(images, props);
|
|
74
|
-
return ImageCell(props, styleNames);
|
|
75
|
-
},
|
|
76
|
-
ImageParagraph: (props: ImageParagraphProps) => {
|
|
77
|
-
mutateImageProps(images, props);
|
|
78
|
-
return ImageParagraph(props, styleNames);
|
|
79
|
-
},
|
|
80
|
-
Image: (props: Record<string, unknown>) => {
|
|
81
|
-
mutateImageProps(images, props);
|
|
82
|
-
return Image.create(props as unknown as Image.ImageProps);
|
|
83
|
-
},
|
|
66
|
+
ImageRow: (props: ImageRowProps) => ImageRow(imageProps(images, props) as unknown as ImageRowProps, styleNames),
|
|
67
|
+
ImageCell: (props: ImageCellProps) => ImageCell(imageProps(images, props) as unknown as ImageCellProps, styleNames),
|
|
68
|
+
ImageParagraph: (props: ImageParagraphProps) =>
|
|
69
|
+
ImageParagraph(imageProps(images, props) as unknown as ImageParagraphProps, styleNames),
|
|
70
|
+
Image: (props: Record<string, unknown>) => Image.create(imageProps(images, props) as unknown as Image.ImageProps),
|
|
84
71
|
Table: (props, children: ReadonlyArray<TableRow.TableRow>) =>
|
|
85
72
|
Table.create(props as unknown as Table.TableProps, children),
|
|
86
73
|
TableRow: (props, children: ReadonlyArray<TableCell.TableCell>) => TableRow.create(props, children),
|
|
@@ -267,22 +254,24 @@ export const propsCreators: Record<string, ADCreatorFn> = {
|
|
|
267
254
|
},
|
|
268
255
|
};
|
|
269
256
|
|
|
270
|
-
function
|
|
271
|
-
const
|
|
257
|
+
function imageProps(images: Record<string, ImageResource>, props: Record<string, unknown>): Record<string, unknown> {
|
|
258
|
+
const newProps = { ...props };
|
|
259
|
+
const image = images[(newProps.src as string) ?? ""];
|
|
272
260
|
if (image) {
|
|
273
261
|
if (image.width && image.height) {
|
|
274
|
-
|
|
275
|
-
|
|
262
|
+
newProps.width = image.width;
|
|
263
|
+
newProps.height = image.height;
|
|
276
264
|
} else {
|
|
277
|
-
const scaleX = (
|
|
278
|
-
const scaleY = (
|
|
265
|
+
const scaleX = (newProps.width as number) / image.abstractImage.size.width;
|
|
266
|
+
const scaleY = (newProps.height as number) / image.abstractImage.size.height;
|
|
279
267
|
if (scaleX < scaleY) {
|
|
280
|
-
|
|
268
|
+
newProps.height = (newProps.height as number) * (scaleX / scaleY);
|
|
281
269
|
} else {
|
|
282
|
-
|
|
270
|
+
newProps.width = (newProps.width as number) * (scaleY / scaleX);
|
|
283
271
|
}
|
|
284
272
|
}
|
|
285
273
|
|
|
286
|
-
|
|
274
|
+
newProps.imageResource = images[newProps.src as string];
|
|
287
275
|
}
|
|
276
|
+
return newProps;
|
|
288
277
|
}
|
|
@@ -2,12 +2,12 @@ import {
|
|
|
2
2
|
TextStyle,
|
|
3
3
|
ParagraphStyle,
|
|
4
4
|
TableCellStyle,
|
|
5
|
-
ImageResource,
|
|
6
5
|
TextRun,
|
|
7
6
|
Paragraph,
|
|
8
7
|
TableCell,
|
|
9
8
|
TableRow,
|
|
10
9
|
Image,
|
|
10
|
+
ImageResource as ADImageResource,
|
|
11
11
|
} from "../../abstract-document/index";
|
|
12
12
|
|
|
13
13
|
type StyleProps = {
|
|
@@ -44,69 +44,73 @@ export function extractStyleNames(
|
|
|
44
44
|
return styleNameProps;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export type TextRowProps = TextCellProps & {};
|
|
47
|
+
export type TextRowProps = Omit<TextCellProps, "style"> & { readonly cellStyle?: TableCellStyle.TableCellStyle };
|
|
48
48
|
|
|
49
49
|
export function TextRow(props: TextRowProps, styleNameTypes: Record<string, string>): TableRow.TableRow {
|
|
50
|
-
return TableRow.create({}, [TextCell(props, styleNameTypes)]);
|
|
50
|
+
return TableRow.create({}, [TextCell({ ...props, style: props.cellStyle }, styleNameTypes)]);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export type TextCellProps = TextParagraphProps & {
|
|
53
|
+
export type TextCellProps = Omit<TextParagraphProps, "style"> & {
|
|
54
54
|
readonly columnSpan?: number;
|
|
55
55
|
readonly rowSpan?: number;
|
|
56
|
-
readonly
|
|
56
|
+
readonly style?: TableCellStyle.TableCellStyle;
|
|
57
|
+
readonly paragraphStyle?: ParagraphStyle.ParagraphStyle;
|
|
57
58
|
readonly styleNames?: string;
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
export function TextCell(props: TextCellProps, styleNameTypes: Record<string, string>): TableCell.TableCell {
|
|
61
|
-
const { text, textStyle, paragraphStyle,
|
|
62
|
+
const { text, textStyle, paragraphStyle, style, columnSpan, rowSpan } = props;
|
|
62
63
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
63
64
|
const textRun = TextRun.create({ text, style: textStyle, styleName: styleNames.TextStyle });
|
|
64
65
|
const paragraph = Paragraph.create({ style: paragraphStyle, styleName: styleNames.ParagraphStyle }, [textRun]);
|
|
65
|
-
return TableCell.create({ columnSpan, rowSpan, style
|
|
66
|
+
return TableCell.create({ columnSpan, rowSpan, style, styleName: styleNames.TableCellStyle }, [paragraph]);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export type TextParagraphProps = {
|
|
69
70
|
readonly text: string;
|
|
71
|
+
readonly style?: ParagraphStyle.ParagraphStyle;
|
|
70
72
|
readonly textStyle?: TextStyle.TextStyle;
|
|
71
|
-
readonly paragraphStyle?: ParagraphStyle.ParagraphStyle;
|
|
72
73
|
readonly styleNames?: string;
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
export function TextParagraph(props: TextParagraphProps, styleNameTypes: Record<string, string>): Paragraph.Paragraph {
|
|
76
|
-
const { text, textStyle,
|
|
77
|
+
const { text, textStyle, style } = props;
|
|
77
78
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
78
79
|
const textRun = TextRun.create({ text, style: textStyle, styleName: styleNames.TextStyle });
|
|
79
|
-
return Paragraph.create({ style
|
|
80
|
+
return Paragraph.create({ style, styleName: styleNames.ParagraphStyle }, [textRun]);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
export type
|
|
83
|
+
export type ImageResource = ADImageResource.ImageResource & { readonly width?: number; readonly height?: number };
|
|
83
84
|
|
|
84
|
-
export
|
|
85
|
-
|
|
85
|
+
export type ImageRowProps = Omit<ImageCellProps, "style"> & { readonly cellStyle?: TableCellStyle.TableCellStyle };
|
|
86
|
+
|
|
87
|
+
export function ImageRow(props: ImageRowProps, styleNameTypes: Record<string, string>): TableRow.TableRow {
|
|
88
|
+
return TableRow.create({}, [ImageCell({ ...props, style: props.cellStyle }, styleNameTypes)]);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
export type ImageCellProps = {
|
|
89
|
-
readonly
|
|
91
|
+
export type ImageCellProps = Omit<ImageParagraphProps, "style"> & {
|
|
92
|
+
readonly style?: TableCellStyle.TableCellStyle;
|
|
93
|
+
readonly paragraphStyle?: ParagraphStyle.ParagraphStyle;
|
|
90
94
|
readonly columnSpan?: number;
|
|
91
95
|
readonly rowSpan?: number;
|
|
92
|
-
}
|
|
96
|
+
};
|
|
93
97
|
|
|
94
98
|
export function ImageCell(props: ImageCellProps, styleNameTypes: Record<string, string>): TableCell.TableCell {
|
|
95
|
-
const {
|
|
99
|
+
const { imageResource, width, height, paragraphStyle, style, columnSpan, rowSpan } = props;
|
|
96
100
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
97
|
-
const imageElement =
|
|
101
|
+
const imageElement = imageResource && Image.create({ imageResource, width, height });
|
|
98
102
|
const pararaphProps = { style: paragraphStyle, styleName: styleNames.ParagraphStyle };
|
|
99
103
|
const paragraph = imageElement
|
|
100
104
|
? Paragraph.create(pararaphProps, [imageElement])
|
|
101
105
|
: Paragraph.create(pararaphProps, [ImageMissing]);
|
|
102
|
-
return TableCell.create({ columnSpan, rowSpan, style
|
|
106
|
+
return TableCell.create({ columnSpan, rowSpan, style, styleName: styleNames.TableCellStyle }, [paragraph]);
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
export type ImageParagraphProps = {
|
|
106
|
-
readonly
|
|
110
|
+
readonly imageResource: ImageResource;
|
|
107
111
|
readonly width: number;
|
|
108
112
|
readonly height: number;
|
|
109
|
-
readonly
|
|
113
|
+
readonly style?: ParagraphStyle.ParagraphStyle;
|
|
110
114
|
readonly styleNames?: string;
|
|
111
115
|
};
|
|
112
116
|
|
|
@@ -114,10 +118,10 @@ export function ImageParagraph(
|
|
|
114
118
|
props: ImageParagraphProps,
|
|
115
119
|
styleNameTypes: Record<string, string>
|
|
116
120
|
): Paragraph.Paragraph | undefined {
|
|
117
|
-
const {
|
|
121
|
+
const { imageResource, width, height, style } = props;
|
|
118
122
|
const styleNames = extractStyleNames(props.styleNames, styleNameTypes);
|
|
119
|
-
const imageElement =
|
|
120
|
-
const pararaphProps = { style
|
|
123
|
+
const imageElement = imageResource && Image.create({ imageResource, width, height });
|
|
124
|
+
const pararaphProps = { style, styleName: styleNames.ParagraphStyle };
|
|
121
125
|
return imageElement
|
|
122
126
|
? Paragraph.create(pararaphProps, [imageElement])
|
|
123
127
|
: Paragraph.create(pararaphProps, [ImageMissing]);
|
|
@@ -10,7 +10,7 @@ export const textRow = `<xs:complexType name="TextRow">
|
|
|
10
10
|
<xs:element name="paragraphStyle" type="ParagraphStyle" />
|
|
11
11
|
</xs:choice>
|
|
12
12
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
13
|
-
<xs:element name="
|
|
13
|
+
<xs:element name="textStyle" type="TextStyle" />
|
|
14
14
|
</xs:choice>
|
|
15
15
|
<xs:attribute name="styleNames" type="xs:string" >
|
|
16
16
|
<xs:annotation>
|
|
@@ -29,13 +29,13 @@ export const textCell = `<xs:complexType name="TextCell">
|
|
|
29
29
|
<xs:documentation>Shortcut to create a \\<TableCell> \\<Paragraph> \\<TextRun text="..." /> \\</Paragraph> \\</TableCell></xs:documentation>
|
|
30
30
|
</xs:annotation>
|
|
31
31
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
32
|
-
<xs:element name="
|
|
32
|
+
<xs:element name="style" type="TableCellStyle" />
|
|
33
33
|
</xs:choice>
|
|
34
34
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
35
35
|
<xs:element name="paragraphStyle" type="ParagraphStyle" />
|
|
36
36
|
</xs:choice>
|
|
37
37
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
38
|
-
<xs:element name="
|
|
38
|
+
<xs:element name="textStyle" type="TextStyle" />
|
|
39
39
|
</xs:choice>
|
|
40
40
|
<xs:attribute name="styleNames" type="xs:string" >
|
|
41
41
|
<xs:annotation>
|
|
@@ -54,10 +54,10 @@ export const textParagraph = `<xs:complexType name="TextParagraph">
|
|
|
54
54
|
<xs:documentation>Shortcut to create \\<Paragraph> \\<TextRun text="..." /> \\</Paragraph></xs:documentation>
|
|
55
55
|
</xs:annotation>
|
|
56
56
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
57
|
-
<xs:element name="
|
|
57
|
+
<xs:element name="style" type="ParagraphStyle" />
|
|
58
58
|
</xs:choice>
|
|
59
59
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
60
|
-
<xs:element name="
|
|
60
|
+
<xs:element name="textStyle" type="TextStyle" />
|
|
61
61
|
</xs:choice>
|
|
62
62
|
<xs:attribute name="styleNames" type="xs:string" >
|
|
63
63
|
<xs:annotation>
|
|
@@ -99,7 +99,7 @@ export const imageCell = `<xs:complexType name="ImageCell">
|
|
|
99
99
|
<xs:attribute name="width" type="xs:decimal" />
|
|
100
100
|
<xs:attribute name="height" type="xs:decimal" />
|
|
101
101
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
102
|
-
<xs:element name="
|
|
102
|
+
<xs:element name="style" type="TableCellStyle" />
|
|
103
103
|
</xs:choice>
|
|
104
104
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
105
105
|
<xs:element name="paragraphStyle" type="ParagraphStyle" />
|
|
@@ -116,7 +116,7 @@ export const imageParagraph = `<xs:complexType name="ImageParagraph">
|
|
|
116
116
|
<xs:attribute name="width" type="xs:decimal" />
|
|
117
117
|
<xs:attribute name="height" type="xs:decimal" />
|
|
118
118
|
<xs:choice minOccurs="0" maxOccurs="1">
|
|
119
|
-
<xs:element name="
|
|
119
|
+
<xs:element name="style" type="ParagraphStyle" />
|
|
120
120
|
</xs:choice>
|
|
121
121
|
</xs:complexType>`;
|
|
122
122
|
export const imageParagraphElement = `<xs:element name="ImageParagraph" type="ImageParagraph" maxOccurs="unbounded" />`;
|