Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

abstract-document

Package Overview
Dependencies
137
Maintainers
15
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.12.3 to 6.12.4

56

lib/abstract-document-xml/abstract-doc-of-xml/creator.js

@@ -14,11 +14,12 @@ "use strict";

},
Section: (props, children) => index_1.Section.create(props, children),
Paragraph: (props, children) => index_1.Paragraph.create(props, children),
Section: (props, children) => index_1.Section.create(props, children),
TextRun: (props) => index_1.TextRun.create(props),
TextRow: (props) => (0, custom_elements_1.TextRow)(props, styleNames),
TextCell: (props) => (0, custom_elements_1.TextCell)(props, styleNames),
TextParagraph: (props) => (0, custom_elements_1.TextParagraph)(props, styleNames),
ImageRow: (props) => (0, custom_elements_1.ImageRow)(props, styleNames),
ImageCell: (props) => (0, custom_elements_1.ImageCell)(props, styleNames),
ImageParagraph: (props) => (0, custom_elements_1.ImageParagraph)(props, styleNames),
TextRun: (props) => index_1.TextRun.create(props),
ImageRow: (props) => (0, custom_elements_1.ImageRow)(imageProps(images, props), styleNames),
ImageCell: (props) => (0, custom_elements_1.ImageCell)(imageProps(images, props), styleNames),
ImageParagraph: (props) => (0, custom_elements_1.ImageParagraph)(imageProps(images, props), styleNames),
Image: (props) => index_1.Image.create(imageProps(images, props)),
Table: (props, children) => index_1.Table.create(props, children),

@@ -28,24 +29,2 @@ TableRow: (props, children) => index_1.TableRow.create(props, children),

TextField: (props) => index_1.TextField.create(props),
Image: (props) => {
var _a;
const image = images[(_a = props.src) !== null && _a !== void 0 ? _a : ""];
if (image) {
if (image.width && image.height) {
props.width = image.width;
props.height = image.height;
}
else {
const scaleX = props.width / image.abstractImage.size.width;
const scaleY = props.height / image.abstractImage.size.height;
if (scaleX < scaleY) {
props.height = props.height * (scaleX / scaleY);
}
else {
props.width = props.width * (scaleY / scaleX);
}
}
props.imageResource = images[props.src];
}
return index_1.Image.create(props);
},
Group: (props, children) => index_1.Group.create(props, children),

@@ -222,2 +201,25 @@ PageBreak: () => index_1.PageBreak.create(),

};
function imageProps(images, props) {
var _a;
const newProps = Object.assign(Object.assign({}, props), { width: props.width, height: props.height, imageResource: props.src });
const image = images[(_a = props.src) !== null && _a !== void 0 ? _a : ""];
if (image) {
if (image.width && image.height) {
newProps.width = image.width;
newProps.height = image.height;
}
else {
const scaleX = props.width / image.abstractImage.size.width;
const scaleY = props.height / image.abstractImage.size.height;
if (scaleX < scaleY) {
newProps.height = props.height * (scaleX / scaleY);
}
else {
newProps.width = props.width * (scaleY / scaleX);
}
}
newProps.imageResource = props.src;
}
return newProps;
}
//# sourceMappingURL=creator.js.map

@@ -52,4 +52,7 @@ "use strict";

const imageElement = image && index_1.Image.create({ imageResource: image, width, height });
const paragraph = imageElement && index_1.Paragraph.create({ style: paragraphStyle, styleName: styleNames.ParagraphStyle }, [imageElement]);
return index_1.TableCell.create({ columnSpan, rowSpan, style: cellStyle, styleName: styleNames.TableCellStyle }, paragraph && [paragraph]);
const pararaphProps = { style: paragraphStyle, styleName: styleNames.ParagraphStyle };
const paragraph = imageElement
? index_1.Paragraph.create(pararaphProps, [imageElement])
: index_1.Paragraph.create(pararaphProps, [ImageMissing]);
return index_1.TableCell.create({ columnSpan, rowSpan, style: cellStyle, styleName: styleNames.TableCellStyle }, [paragraph]);
}

@@ -61,6 +64,9 @@ exports.ImageCell = ImageCell;

const imageElement = image && index_1.Image.create({ imageResource: image, width, height });
const paragraph = imageElement && index_1.Paragraph.create({ style: paragraphStyle, styleName: styleNames.ParagraphStyle }, [imageElement]);
return paragraph;
const pararaphProps = { style: paragraphStyle, styleName: styleNames.ParagraphStyle };
return imageElement
? index_1.Paragraph.create(pararaphProps, [imageElement])
: index_1.Paragraph.create(pararaphProps, [ImageMissing]);
}
exports.ImageParagraph = ImageParagraph;
const ImageMissing = index_1.TextRun.create({ text: "Image missing" });
//# sourceMappingURL=custom-elements.js.map

@@ -1,13 +0,13 @@

export declare const textRow = "<xs:complexType name=\"TextRow\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableRow> \\<TableCell> \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph> \\</TableCell> \\</TableRow></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textRow = "<xs:complexType name=\"TextRow\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableRow> \\<TableCell> \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph> \\</TableCell> \\</TableRow></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"cellStyle\" type=\"TableCellStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textRowElement = "<xs:element name=\"TextRow\" type=\"TextRow\" maxOccurs=\"unbounded\" />";
export declare const textCell = "<xs:complexType name=\"TextCell\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableCell> \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph> \\</TableCell></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textCell = "<xs:complexType name=\"TextCell\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableCell> \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph> \\</TableCell></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"cellStyle\" type=\"TableCellStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textCellElement = "<xs:element name=\"TextCell\" type=\"TextCell\" minOccurs=\"0\" maxOccurs=\"unbounded\" />";
export declare const textParagraph = "<xs:complexType name=\"TextParagraph\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textParagraph = "<xs:complexType name=\"TextParagraph\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create \\<Paragraph> \\<TextRun text=\"...\" /> \\</Paragraph></xs:documentation>\n\t</xs:annotation>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"style\" type=\"TextStyle\" />\n\t</xs:choice>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" >\n\t\t<xs:annotation>\n\t\t\t<xs:documentation>Refrence to a TextStyle that is defined in \\<AbstractDoc> \\<StyleNames> \\<StyleName name=\"...\" /> \\</StyleNames> \\</AbstractDoc></xs:documentation>\n\t\t</xs:annotation>\n\t</xs:attribute>\n\t<xs:attribute name=\"target\" type=\"xs:string\" />\n\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"required\" />\n</xs:complexType>";
export declare const textParagraphElement = "<xs:element name=\"TextParagraph\" type=\"TextParagraph\" maxOccurs=\"unbounded\" />";
export declare const imageRow = "<xs:complexType name=\"ImageRow\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableRow> \\<TableCell> \\<Paragraph> \\<Image src text=\"...\" /> \\</Paragraph> \\</TableCell> \\</TableRow></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" use=\"required\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" use=\"required\" />\n</xs:complexType>";
export declare const imageRow = "<xs:complexType name=\"ImageRow\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<TableRow> \\<TableCell> \\<Paragraph> \\<Image src text=\"...\" /> \\</Paragraph> \\</TableCell> \\</TableRow></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" />\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"cellStyle\" type=\"TableCellStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n</xs:complexType>";
export declare const imageRowElement = "<xs:element name=\"ImageRow\" type=\"ImageRow\" maxOccurs=\"unbounded\" />";
export declare const imageCell = "<xs:complexType name=\"ImageCell\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<ImageCell> \\<Paragraph> \\<Image src=\"...\" /> \\</Paragraph> \\</TableCell></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" use=\"required\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" use=\"required\" />\n</xs:complexType>";
export declare const imageCell = "<xs:complexType name=\"ImageCell\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create a \\<ImageCell> \\<Paragraph> \\<Image src=\"...\" /> \\</Paragraph> \\</TableCell></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"columnSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"rowSpan\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" />\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"cellStyle\" type=\"TableCellStyle\" />\n\t</xs:choice>\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n</xs:complexType>";
export declare const imageCellElement = "<xs:element name=\"ImageCell\" type=\"ImageCell\" minOccurs=\"0\" maxOccurs=\"unbounded\" />";
export declare const imageParagraph = "<xs:complexType name=\"ImageParagraph\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create \\<Paragraph> \\<Image src=\"...\" /> \\</Paragraph></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" use=\"required\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" use=\"required\" />\n</xs:complexType>";
export declare const imageParagraph = "<xs:complexType name=\"ImageParagraph\">\n\t<xs:annotation>\n\t\t<xs:documentation>Shortcut to create \\<Paragraph> \\<Image src=\"...\" /> \\</Paragraph></xs:documentation>\n\t</xs:annotation>\n\t<xs:attribute name=\"styleNames\" type=\"xs:string\" />\n\t<xs:attribute name=\"src\" type=\"xs:string\" use=\"required\" />\n\t<xs:attribute name=\"width\" type=\"xs:decimal\" />\n\t<xs:attribute name=\"height\" type=\"xs:decimal\" />\n\t<xs:choice minOccurs=\"0\" maxOccurs=\"1\">\n\t\t<xs:element name=\"paragraphStyle\" type=\"ParagraphStyle\" />\n\t</xs:choice>\n</xs:complexType>";
export declare const imageParagraphElement = "<xs:element name=\"ImageParagraph\" type=\"ImageParagraph\" maxOccurs=\"unbounded\" />";
//# sourceMappingURL=custom-elements.d.ts.map

@@ -10,2 +10,8 @@ "use strict";

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -29,2 +35,8 @@ </xs:choice>

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -48,2 +60,5 @@ </xs:choice>

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -68,4 +83,10 @@ </xs:choice>

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;

@@ -81,4 +102,10 @@ exports.imageRowElement = `<xs:element name="ImageRow" type="ImageRow" maxOccurs="unbounded" />`;

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;

@@ -92,6 +119,9 @@ exports.imageCellElement = `<xs:element name="ImageCell" type="ImageCell" minOccurs="0" maxOccurs="unbounded" />`;

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;
exports.imageParagraphElement = `<xs:element name="ImageParagraph" type="ImageParagraph" maxOccurs="unbounded" />`;
//# sourceMappingURL=custom-elements.js.map

@@ -26,12 +26,5 @@ "use strict";

const { styleName = "", fieldType, style = TextStyle.create(), target = "" } = props;
return {
type: "TextField",
styleName,
fieldType,
style,
target,
text: ""
};
return { type: "TextField", styleName, fieldType, style, target, text: "" };
}
exports.create = create;
//# sourceMappingURL=text-field.js.map

@@ -5,9 +5,5 @@ "use strict";

function create({ id, abstractImage, renderScale = 1.0 }) {
return {
id,
abstractImage,
renderScale
};
return { id, abstractImage, renderScale };
}
exports.create = create;
//# sourceMappingURL=image-resource.js.map
{
"name": "abstract-document",
"version": "6.12.3",
"version": "6.12.4",
"description": "Dynamically create documents using code or JSX and render to any format",

@@ -43,3 +43,3 @@ "repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-document",

},
"gitHead": "61adc448052be945843ccf550967a29dc4276411"
"gitHead": "b9f791d809bfd9b80c25852c7a52fc40a4bae868"
}

@@ -0,1 +1,3 @@

import { propIs } from "ramda";
import { ImageProps } from "../../abstract-document/atoms/image";
import {

@@ -60,11 +62,13 @@ AbstractDoc,

},
Section: (props, children: ReadonlyArray<SectionElement.SectionElement>) => Section.create(props, children),
Paragraph: (props, children: ReadonlyArray<Atom.Atom>) => Paragraph.create(props, children),
Section: (props, children: ReadonlyArray<SectionElement.SectionElement>) => Section.create(props, children),
TextRun: (props) => TextRun.create(props as unknown as TextRun.TextRunProps),
TextRow: (props: TextRowProps) => TextRow(props, styleNames),
TextCell: (props: TextCellProps) => TextCell(props, styleNames),
TextParagraph: (props: TextParagraphProps) => TextParagraph(props, styleNames),
ImageRow: (props: ImageRowProps) => ImageRow(props, styleNames),
ImageCell: (props: ImageCellProps) => ImageCell(props, styleNames),
ImageParagraph: (props: ImageParagraphProps) => ImageParagraph(props, styleNames),
TextRun: (props) => TextRun.create(props as unknown as TextRun.TextRunProps),
ImageRow: (props: ImageRowProps) => ImageRow(imageProps(images, props) as unknown as ImageRowProps, styleNames),
ImageCell: (props: ImageCellProps) => ImageCell(imageProps(images, props) as unknown as ImageCellProps, styleNames),
ImageParagraph: (props: ImageParagraphProps) =>
ImageParagraph(imageProps(images, props) as unknown as ImageParagraphProps, styleNames),
Image: (props: Record<string, unknown>) => Image.create(imageProps(images, props)),
Table: (props, children: ReadonlyArray<TableRow.TableRow>) =>

@@ -75,22 +79,2 @@ Table.create(props as unknown as Table.TableProps, children),

TextField: (props) => TextField.create(props as unknown as TextField.TextFieldProps),
Image: (props: Record<string, unknown>) => {
const image = images[(props.src as string) ?? ""];
if (image) {
if (image.width && image.height) {
props.width = image.width;
props.height = image.height;
} else {
const scaleX = (props.width as number) / image.abstractImage.size.width;
const scaleY = (props.height as number) / image.abstractImage.size.height;
if (scaleX < scaleY) {
props.height = (props.height as number) * (scaleX / scaleY);
} else {
props.width = (props.width as number) * (scaleY / scaleX);
}
}
props.imageResource = images[props.src as string];
}
return Image.create(props as unknown as Image.ImageProps);
},
Group: (props, children) => Group.create(props, children as ReadonlyArray<Group.Group>),

@@ -276,1 +260,22 @@ PageBreak: () => PageBreak.create(),

};
function imageProps(images: Record<string, ImageResource>, props: Record<string, unknown>): Image.ImageProps {
const newProps = { ...props, width: props.width, height: props.height, imageResource: props.src };
const image = images[(props.src as string) ?? ""];
if (image) {
if (image.width && image.height) {
newProps.width = image.width;
newProps.height = image.height;
} else {
const scaleX = (props.width as number) / image.abstractImage.size.width;
const scaleY = (props.height as number) / image.abstractImage.size.height;
if (scaleX < scaleY) {
newProps.height = (props.height as number) * (scaleX / scaleY);
} else {
newProps.width = (props.width as number) * (scaleY / scaleX);
}
}
newProps.imageResource = props.src as string;
}
return newProps as unknown as Image.ImageProps;
}

@@ -7,2 +7,8 @@ /* eslint-disable no-useless-escape */

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -27,2 +33,8 @@ </xs:choice>

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -47,2 +59,5 @@ </xs:choice>

<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="style" type="TextStyle" />

@@ -68,4 +83,10 @@ </xs:choice>

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;

@@ -82,4 +103,10 @@ export const imageRowElement = `<xs:element name="ImageRow" type="ImageRow" maxOccurs="unbounded" />`;

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="cellStyle" type="TableCellStyle" />
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;

@@ -94,5 +121,8 @@ export const imageCellElement = `<xs:element name="ImageCell" type="ImageCell" minOccurs="0" maxOccurs="unbounded" />`;

<xs:attribute name="src" type="xs:string" use="required" />
<xs:attribute name="width" type="xs:decimal" use="required" />
<xs:attribute name="height" type="xs:decimal" use="required" />
<xs:attribute name="width" type="xs:decimal" />
<xs:attribute name="height" type="xs:decimal" />
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="paragraphStyle" type="ParagraphStyle" />
</xs:choice>
</xs:complexType>`;
export const imageParagraphElement = `<xs:element name="ImageParagraph" type="ImageParagraph" maxOccurs="unbounded" />`;

@@ -17,6 +17,3 @@ import { ImageResource } from "../primitives/image-resource";

export function create(props: ImageProps): Image {
return {
type: "Image",
...props
};
return { type: "Image", ...props };
}

@@ -22,16 +22,4 @@ import * as TextStyle from "../styles/text-style";

export function create(props: TextFieldProps): TextField {
const {
styleName = "",
fieldType,
style = TextStyle.create(),
target = ""
} = props;
return {
type: "TextField",
styleName,
fieldType,
style,
target,
text: ""
};
const { styleName = "", fieldType, style = TextStyle.create(), target = "" } = props;
return { type: "TextField", styleName, fieldType, style, target, text: "" };
}

@@ -17,12 +17,4 @@ import { AbstractImage } from "abstract-image";

export function create({
id,
abstractImage,
renderScale = 1.0
}: ImageResourceProps): ImageResource {
return {
id,
abstractImage,
renderScale
};
export function create({ id, abstractImage, renderScale = 1.0 }: ImageResourceProps): ImageResource {
return { id, abstractImage, renderScale };
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc