Skip to content

Commit 6cc7117

Browse files
authored
🤖 Merge PR DefinitelyTyped#74402 [pdfmake] Fixes and new properties for 0.2 by @kryops
1 parent 37ca828 commit 6cc7117

6 files changed

Lines changed: 75 additions & 12 deletions

File tree

types/pdfmake/build/vfs_fonts.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export let vfs: { [file: string]: string };
1+
declare const vfs: { [file: string]: string };
2+
3+
export = vfs;

types/pdfmake/interfaces.d.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,16 @@ export interface Style {
836836
*/
837837
noWrap?: boolean | undefined;
838838

839+
/**
840+
* Controls the line breaking behavior.
841+
*
842+
* - `normal` breaks lines at spaces
843+
* - `break-all` breaks lines anywhere
844+
*
845+
* Defaults to `normal`.
846+
*/
847+
wordBreak?: "normal" | "break-all" | undefined;
848+
839849
/**
840850
* Space between columns in `pt`.
841851
*
@@ -1043,13 +1053,13 @@ export interface ContentCanvas extends ContentBase, ForbidOtherElementProperties
10431053
*/
10441054
export interface ContentSvg extends ContentBase, ContentLink, ForbidOtherElementProperties<"svg"> {
10451055
/**
1046-
* Renders the given SVG content string as an image.
1056+
* Renders the given SVG element or content string as an image.
10471057
*
10481058
* For images other than SVG, use the `image` property instead.
10491059
*
10501060
* Simple vectors can also be rendered using the `canvas` property instead.
10511061
*/
1052-
svg: string;
1062+
svg: string | SVGElement;
10531063

10541064
/**
10551065
* Width of the image in `pt`.
@@ -1563,6 +1573,15 @@ export interface OrderedListElementProperties {
15631573
* Defaults to the list's {@link ContentOrderedList.type}.
15641574
*/
15651575
listType?: OrderedListType | undefined;
1576+
1577+
/**
1578+
* Color of the list marker (i.e. number).
1579+
*
1580+
* Supports well-known color names like `blue` or hexadecimal color strings like `#ccffcc`.
1581+
*
1582+
* Defaults to the list's marker color.
1583+
*/
1584+
markerColor?: string | undefined;
15661585
}
15671586

15681587
/**
@@ -1590,6 +1609,15 @@ export interface UnorderedListElementProperties {
15901609
* Defaults to the list's {@link ContentUnorderedList.type}.
15911610
*/
15921611
listType?: UnorderedListType | undefined;
1612+
1613+
/**
1614+
* Color of the list marker (i.e. bullet point).
1615+
*
1616+
* Supports well-known color names like `blue` or hexadecimal color strings like `#ccffcc`.
1617+
*
1618+
* Defaults to the list's marker color.
1619+
*/
1620+
markerColor?: string | undefined;
15931621
}
15941622

15951623
/**
@@ -2069,7 +2097,7 @@ export interface TDocumentDefinitions {
20692097
*
20702098
* @param currentNode - The current content node to check.
20712099
* @param followingNodesOnPage - The content nodes defined after the current node on the same page.
2072-
* @param nodesOnNextPage - The content nodes on the page after the current node's page.
2100+
* @param nodesOnNextPage - The content nodes on the next page.
20732101
* @param previousNodesOnPage - The content nodes defined before the current node on the same page.
20742102
*
20752103
* @returns whether to insert a page break before the current node.

types/pdfmake/test/pdfmake-examples-tests.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ const lists: TDocumentDefinitions = {
684684
{
685685
color: "blue",
686686
markerColor: "red",
687-
ul: ["item 1", "item 2", "item 3"],
687+
ul: ["item 1", "item 2", { text: "item 3 with custom marker color", markerColor: "lime" }],
688688
},
689689
{ text: "\n\nColored ordered list", style: "header" },
690690
{
@@ -698,7 +698,7 @@ const lists: TDocumentDefinitions = {
698698
{
699699
color: "blue",
700700
markerColor: "red",
701-
ol: ["item 1", "item 2", "item 3"],
701+
ol: ["item 1", "item 2", { text: "item 3 with custom marker color", markerColor: "lime" }],
702702
},
703703
{ text: "\n\nOrdered list - type: lower-alpha", style: "header" },
704704
{
@@ -1447,7 +1447,37 @@ const stylingProperties: TDocumentDefinitions = {
14471447
" World",
14481448
],
14491449
},
1450+
"\n\n",
1451+
{
1452+
text: "Text background pattern",
1453+
background: ["stripe45d", "gray"],
1454+
},
1455+
{
1456+
text: "Customize word break:",
1457+
pageBreak: "before",
1458+
},
1459+
{
1460+
text: "DefaultLine\n\"BreakBehaviour\" \"ForATextWithVeryVery\" \"LongLongWords\"",
1461+
fontSize: 30,
1462+
},
1463+
{
1464+
text: "\n\n",
1465+
fontSize: 30,
1466+
},
1467+
{
1468+
text: "BreakAll\n\"LineBreakBehaviour\" \"ForATextWithVeryVery\" \"LongLongWords\"",
1469+
fontSize: 30,
1470+
wordBreak: "break-all",
1471+
},
14501472
],
1473+
patterns: {
1474+
stripe45d: {
1475+
boundingBox: [1, 1, 4, 4],
1476+
xStep: 3,
1477+
yStep: 3,
1478+
pattern: "1 w 0 1 m 4 5 l s 2 0 m 5 3 l s",
1479+
},
1480+
},
14511481
};
14521482

14531483
const svgs: TDocumentDefinitions = {

types/pdfmake/test/pdfmake-import-default-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pdfMake from "pdfmake/build/pdfmake";
22
import pdfFonts from "pdfmake/build/vfs_fonts";
33

4-
pdfMake.vfs = pdfFonts.vfs;
4+
pdfMake.vfs = pdfFonts;
55

66
const dd = {
77
content: "Hello world!",

types/pdfmake/test/pdfmake-module-browser-min-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import pdfFonts = require("pdfmake/build/vfs_fonts");
22
import pdfMake = require("pdfmake/build/pdfmake.min");
33
import { BufferOptions, CustomTableLayout, TFontDictionary } from "pdfmake/interfaces";
44

5-
pdfMake.vfs = pdfFonts.vfs;
5+
pdfMake.vfs = pdfFonts;
66

77
const dd = {
88
content: "Hello world!",

types/pdfmake/test/pdfmake-module-browser-tests.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import pdfFonts = require("pdfmake/build/vfs_fonts");
22
import pdfMake = require("pdfmake/build/pdfmake");
3-
import { BufferOptions, CustomTableLayout, TFontDictionary } from "pdfmake/interfaces";
3+
import { BufferOptions, CustomTableLayout, TDocumentDefinitions, TFontDictionary } from "pdfmake/interfaces";
44

5-
pdfMake.vfs = pdfFonts.vfs;
5+
pdfMake.vfs = pdfFonts;
66

7-
const dd = {
8-
content: "Hello world!",
7+
const dd: TDocumentDefinitions = {
8+
content: [
9+
"Hello world!",
10+
{ svg: new SVGElement() },
11+
],
912
};
1013

1114
const options: BufferOptions = {

0 commit comments

Comments
 (0)