@bendyline/squisq-formats 2.7.3 → 2.7.4
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/dist/{chunk-GRIARAMQ.js → chunk-32AQL6I6.js} +5 -3
- package/dist/{chunk-YITBSNPM.js → chunk-5YYF3Z6C.js} +4 -2
- package/dist/{chunk-ETK2SKVQ.js → chunk-B6UQPW75.js} +7 -3
- package/dist/{chunk-PKFWF4FX.js → chunk-GESOAVYN.js} +5 -2
- package/dist/{chunk-RSU3V5IQ.js → chunk-JZR32FON.js} +14 -1
- package/dist/{chunk-52RXDH24.js → chunk-OOM2YMXU.js} +2 -2
- package/dist/{chunk-CUQ7YITW.js → chunk-RRULGPWV.js} +1 -1
- package/dist/{chunk-GHHIYBUT.js → chunk-VU7M3YV6.js} +1 -1
- package/dist/{chunk-YVCUNZB5.js → chunk-WMIDXNGR.js} +1 -1
- package/dist/docx/index.js +2 -2
- package/dist/epub/index.js +3 -3
- package/dist/html/index.js +3 -3
- package/dist/images-PQCYRJJ5.js +14 -0
- package/dist/index.js +9 -9
- package/dist/outside-in/index.js +2 -2
- package/dist/pdf/index.js +2 -2
- package/dist/pptx/index.js +3 -3
- package/dist/registry/index.js +1 -1
- package/package.json +2 -2
- package/dist/images-CAWESWRF.js +0 -10
|
@@ -13,9 +13,10 @@ import {
|
|
|
13
13
|
fontAwesomeGlyph
|
|
14
14
|
} from "./chunk-LBXBRFBZ.js";
|
|
15
15
|
import {
|
|
16
|
+
authoredImageSize,
|
|
16
17
|
fitWithin,
|
|
17
18
|
readImageDimensions
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JZR32FON.js";
|
|
19
20
|
|
|
20
21
|
// src/pdf/export.ts
|
|
21
22
|
import { PDFDocument, StandardFonts, rgb, PDFString } from "pdf-lib";
|
|
@@ -1019,9 +1020,10 @@ function renderImageParagraph(node, ctx, x0, width) {
|
|
|
1019
1020
|
drawSpans(note, ctx, width, x0);
|
|
1020
1021
|
continue;
|
|
1021
1022
|
}
|
|
1023
|
+
const display = authoredImageSize(imageNode, embedded) ?? embedded;
|
|
1022
1024
|
const size = fitWithin(
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
+
display.width * POINTS_PER_CSS_PIXEL,
|
|
1026
|
+
display.height * POINTS_PER_CSS_PIXEL,
|
|
1025
1027
|
width,
|
|
1026
1028
|
maxHeight
|
|
1027
1029
|
);
|
|
@@ -67,10 +67,11 @@ import {
|
|
|
67
67
|
obfuscateDocxFont
|
|
68
68
|
} from "./chunk-LBXBRFBZ.js";
|
|
69
69
|
import {
|
|
70
|
+
authoredImageSize,
|
|
70
71
|
extToMime,
|
|
71
72
|
fitWithin,
|
|
72
73
|
readImageDimensions
|
|
73
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-JZR32FON.js";
|
|
74
75
|
|
|
75
76
|
// src/docx/export.ts
|
|
76
77
|
import { resolveFontFamily } from "@bendyline/squisq/schemas";
|
|
@@ -703,7 +704,8 @@ function convertImage(node, ctx) {
|
|
|
703
704
|
const ext = contentType.split("/")[1]?.replace("jpeg", "jpg") || "png";
|
|
704
705
|
const filename = `image${ctx.images.length + 1}.${ext}`;
|
|
705
706
|
const { relId, docPrId } = ctx.addImage(data, contentType, filename);
|
|
706
|
-
const
|
|
707
|
+
const natural = imageEntry.width && imageEntry.height ? { width: imageEntry.width, height: imageEntry.height } : readImageDimensions(data);
|
|
708
|
+
const dims = authoredImageSize(node, natural) ?? natural;
|
|
707
709
|
const EMU_PER_INCH3 = 914400;
|
|
708
710
|
const MAX_WIDTH_EMU2 = 6 * EMU_PER_INCH3;
|
|
709
711
|
const MAX_HEIGHT_EMU2 = 8 * EMU_PER_INCH3;
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
arrayBufferToBase64DataUrl,
|
|
3
3
|
extractFilename,
|
|
4
4
|
inferMimeType
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WMIDXNGR.js";
|
|
6
6
|
import {
|
|
7
7
|
exportImageBytes
|
|
8
8
|
} from "./chunk-VCZUXQUL.js";
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
FootnoteIndex,
|
|
11
11
|
footnoteIds
|
|
12
12
|
} from "./chunk-BXWNU4T5.js";
|
|
13
|
+
import {
|
|
14
|
+
imageSizeAttributes
|
|
15
|
+
} from "./chunk-JZR32FON.js";
|
|
13
16
|
|
|
14
17
|
// src/html/index.ts
|
|
15
18
|
import JSZip3 from "jszip";
|
|
@@ -504,7 +507,8 @@ function extractFirstImageFromBlock(block) {
|
|
|
504
507
|
);
|
|
505
508
|
const replacement = remainingKids.length === 0 ? null : { ...b, children: remainingKids };
|
|
506
509
|
return {
|
|
507
|
-
image
|
|
510
|
+
// A resized image parses with the size it was given in the editor.
|
|
511
|
+
image: { src: img.url, alt: img.alt ?? "", width: img.width, height: img.height },
|
|
508
512
|
replacement
|
|
509
513
|
};
|
|
510
514
|
}
|
|
@@ -780,7 +784,7 @@ function nodeToHtml(node, ctx) {
|
|
|
780
784
|
const resolved = ctx?.images?.get(original) ?? original;
|
|
781
785
|
const safeSrc = sanitizeUrl(resolved, "media") ?? svgDataImageToHtmlSrc(resolved);
|
|
782
786
|
if (!safeSrc) return escapeHtml2(node.alt ?? "");
|
|
783
|
-
return `<img src="${escapeAttr(safeSrc)}" alt="${escapeAttr(node.alt ?? "")}" />`;
|
|
787
|
+
return `<img src="${escapeAttr(safeSrc)}" alt="${escapeAttr(node.alt ?? "")}"${imageSizeAttributes(node)} />`;
|
|
784
788
|
}
|
|
785
789
|
case "thematicBreak":
|
|
786
790
|
return "<hr />";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
extractFilename,
|
|
3
3
|
inferMimeType
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WMIDXNGR.js";
|
|
5
5
|
import {
|
|
6
6
|
exportImageBytes,
|
|
7
7
|
svgIslandsAsImages
|
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
fontAwesomeFaces,
|
|
22
22
|
fontAwesomeGlyph
|
|
23
23
|
} from "./chunk-LBXBRFBZ.js";
|
|
24
|
+
import {
|
|
25
|
+
imageSizeAttributes
|
|
26
|
+
} from "./chunk-JZR32FON.js";
|
|
24
27
|
|
|
25
28
|
// src/epub/export.ts
|
|
26
29
|
import JSZip from "jszip";
|
|
@@ -432,7 +435,7 @@ function inlineToXhtml(node, ctx) {
|
|
|
432
435
|
const safeSrc = resolved ? `../images/${resolved.filename}` : sanitizeUrl(node.url, "media");
|
|
433
436
|
if (!safeSrc) return alt;
|
|
434
437
|
const src = escapeXml(safeSrc);
|
|
435
|
-
return `<img src="${src}" alt="${alt}"/>`;
|
|
438
|
+
return `<img src="${src}" alt="${alt}"${imageSizeAttributes(node)}/>`;
|
|
436
439
|
}
|
|
437
440
|
case "break":
|
|
438
441
|
return "<br/>";
|
|
@@ -65,9 +65,22 @@ function fitWithin(width, height, maxWidth, maxHeight) {
|
|
|
65
65
|
const scale = Math.min(1, maxWidth / width, maxHeight / height);
|
|
66
66
|
return { width: width * scale, height: height * scale };
|
|
67
67
|
}
|
|
68
|
+
function imageSizeAttributes(image) {
|
|
69
|
+
return (image.width !== void 0 ? ` width="${image.width}"` : "") + (image.height !== void 0 ? ` height="${image.height}"` : "");
|
|
70
|
+
}
|
|
71
|
+
function authoredImageSize(image, intrinsic) {
|
|
72
|
+
const { width, height } = image;
|
|
73
|
+
if (width !== void 0 && height !== void 0) return { width, height };
|
|
74
|
+
if (!intrinsic || intrinsic.width <= 0 || intrinsic.height <= 0) return void 0;
|
|
75
|
+
if (width !== void 0) return { width, height: width * intrinsic.height / intrinsic.width };
|
|
76
|
+
if (height !== void 0) return { width: height * intrinsic.width / intrinsic.height, height };
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
68
79
|
|
|
69
80
|
export {
|
|
70
81
|
extToMime,
|
|
71
82
|
readImageDimensions,
|
|
72
|
-
fitWithin
|
|
83
|
+
fitWithin,
|
|
84
|
+
imageSizeAttributes,
|
|
85
|
+
authoredImageSize
|
|
73
86
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
inferMimeType
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WMIDXNGR.js";
|
|
4
4
|
import {
|
|
5
5
|
RelIdAllocator,
|
|
6
6
|
blipXml,
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
} from "./chunk-LBXBRFBZ.js";
|
|
64
64
|
import {
|
|
65
65
|
extToMime
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-JZR32FON.js";
|
|
67
67
|
|
|
68
68
|
// src/pptx/export.ts
|
|
69
69
|
import { resolveFontFamily, VIEWPORT_PRESETS } from "@bendyline/squisq/schemas";
|
|
@@ -262,7 +262,7 @@ function dataReferenceWarnings(doc, formatLabel) {
|
|
|
262
262
|
}
|
|
263
263
|
async function collectContainerDocxImages(container, signal) {
|
|
264
264
|
const images = await collectContainerImages(container, signal);
|
|
265
|
-
const { extToMime } = await import("./images-
|
|
265
|
+
const { extToMime } = await import("./images-PQCYRJJ5.js");
|
|
266
266
|
return new Map(
|
|
267
267
|
[...images].map(([path, data]) => [
|
|
268
268
|
path,
|
package/dist/docx/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
docxToDoc,
|
|
5
5
|
docxToMarkdownDoc,
|
|
6
6
|
markdownDocToDocx
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-5YYF3Z6C.js";
|
|
8
8
|
import "../chunk-XVBQB2SL.js";
|
|
9
9
|
import "../chunk-VCZUXQUL.js";
|
|
10
10
|
import "../chunk-AVOZAKGP.js";
|
|
@@ -15,7 +15,7 @@ import "../chunk-7AWFHP5U.js";
|
|
|
15
15
|
import "../chunk-BXWNU4T5.js";
|
|
16
16
|
import "../chunk-IIQYS2YH.js";
|
|
17
17
|
import "../chunk-LBXBRFBZ.js";
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-JZR32FON.js";
|
|
19
19
|
export {
|
|
20
20
|
docToDocx,
|
|
21
21
|
docxToContainer,
|
package/dist/epub/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
docToEpub,
|
|
3
3
|
markdownDocToEpub
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-GESOAVYN.js";
|
|
5
|
+
import "../chunk-WMIDXNGR.js";
|
|
6
6
|
import "../chunk-VCZUXQUL.js";
|
|
7
7
|
import "../chunk-AVOZAKGP.js";
|
|
8
8
|
import "../chunk-JU2RHXUB.js";
|
|
9
9
|
import "../chunk-BXWNU4T5.js";
|
|
10
10
|
import "../chunk-LBXBRFBZ.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-JZR32FON.js";
|
|
12
12
|
export {
|
|
13
13
|
docToEpub,
|
|
14
14
|
markdownDocToEpub
|
package/dist/html/index.js
CHANGED
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
markdownDocToPlainHtml,
|
|
11
11
|
markdownDocsToHtmlBundle,
|
|
12
12
|
markdownDocsToPlainHtmlBundle
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-B6UQPW75.js";
|
|
14
14
|
import {
|
|
15
15
|
arrayBufferToBase64DataUrl,
|
|
16
16
|
extractFilename,
|
|
17
17
|
inferMimeType
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-WMIDXNGR.js";
|
|
19
19
|
import "../chunk-VCZUXQUL.js";
|
|
20
20
|
import "../chunk-BXWNU4T5.js";
|
|
21
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-JZR32FON.js";
|
|
22
22
|
export {
|
|
23
23
|
arrayBufferToBase64DataUrl,
|
|
24
24
|
collectImagePaths,
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
htmlToMarkdown,
|
|
6
6
|
htmlToMarkdownDoc,
|
|
7
7
|
htmlToMarkdownDocSync
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-B6UQPW75.js";
|
|
9
9
|
import {
|
|
10
10
|
docToEpub,
|
|
11
11
|
markdownDocToEpub
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GESOAVYN.js";
|
|
13
13
|
import {
|
|
14
14
|
BUILTIN_FORMAT_IDS
|
|
15
15
|
} from "./chunk-2P5HJAQL.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
renderOutsideInDocument,
|
|
29
29
|
withOutsideInMarkdownEditing,
|
|
30
30
|
withOutsideInMetadata
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-VU7M3YV6.js";
|
|
32
32
|
import {
|
|
33
33
|
DEFAULT_CONVERSION_LIMITS,
|
|
34
34
|
convert,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
defaultRegistry,
|
|
38
38
|
prepareConversion,
|
|
39
39
|
resolveConversionLimits
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-RRULGPWV.js";
|
|
41
41
|
import {
|
|
42
42
|
ConversionError
|
|
43
43
|
} from "./chunk-KXOZMWBS.js";
|
|
@@ -52,15 +52,15 @@ import {
|
|
|
52
52
|
docxToDoc,
|
|
53
53
|
docxToMarkdownDoc,
|
|
54
54
|
markdownDocToDocx
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-5YYF3Z6C.js";
|
|
56
56
|
import {
|
|
57
57
|
docToPptx,
|
|
58
58
|
markdownDocToPptx,
|
|
59
59
|
pptxToDoc,
|
|
60
60
|
pptxToMarkdownDoc
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-OOM2YMXU.js";
|
|
62
62
|
import "./chunk-6N2J7C2B.js";
|
|
63
|
-
import "./chunk-
|
|
63
|
+
import "./chunk-WMIDXNGR.js";
|
|
64
64
|
import "./chunk-XVBQB2SL.js";
|
|
65
65
|
import "./chunk-VCZUXQUL.js";
|
|
66
66
|
import {
|
|
@@ -94,12 +94,12 @@ import {
|
|
|
94
94
|
markdownDocToPdf,
|
|
95
95
|
pdfToDoc,
|
|
96
96
|
pdfToMarkdownDoc
|
|
97
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-32AQL6I6.js";
|
|
98
98
|
import "./chunk-34KECNZO.js";
|
|
99
99
|
import "./chunk-BXWNU4T5.js";
|
|
100
100
|
import "./chunk-IIQYS2YH.js";
|
|
101
101
|
import "./chunk-LBXBRFBZ.js";
|
|
102
|
-
import "./chunk-
|
|
102
|
+
import "./chunk-JZR32FON.js";
|
|
103
103
|
export {
|
|
104
104
|
BUILTIN_FORMAT_IDS,
|
|
105
105
|
ConversionError,
|
package/dist/outside-in/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
renderOutsideInDocument,
|
|
7
7
|
withOutsideInMarkdownEditing,
|
|
8
8
|
withOutsideInMetadata
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-VU7M3YV6.js";
|
|
10
|
+
import "../chunk-RRULGPWV.js";
|
|
11
11
|
import "../chunk-KXOZMWBS.js";
|
|
12
12
|
import {
|
|
13
13
|
OUTSIDE_IN_FORMAT_IDS,
|
package/dist/pdf/index.js
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
pdfToContainer,
|
|
6
6
|
pdfToDoc,
|
|
7
7
|
pdfToMarkdownDoc
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-32AQL6I6.js";
|
|
9
9
|
import "../chunk-34KECNZO.js";
|
|
10
10
|
import "../chunk-BXWNU4T5.js";
|
|
11
11
|
import "../chunk-IIQYS2YH.js";
|
|
12
12
|
import "../chunk-LBXBRFBZ.js";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-JZR32FON.js";
|
|
14
14
|
export {
|
|
15
15
|
configurePdfWorker,
|
|
16
16
|
docToPdf,
|
package/dist/pptx/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
pptxToContainer,
|
|
5
5
|
pptxToDoc,
|
|
6
6
|
pptxToMarkdownDoc
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-OOM2YMXU.js";
|
|
8
8
|
import {
|
|
9
9
|
analyzePptxLayouts,
|
|
10
10
|
inspectPptxLayouts
|
|
11
11
|
} from "../chunk-6N2J7C2B.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-WMIDXNGR.js";
|
|
13
13
|
import "../chunk-XVBQB2SL.js";
|
|
14
14
|
import "../chunk-VCZUXQUL.js";
|
|
15
15
|
import "../chunk-AVOZAKGP.js";
|
|
@@ -19,7 +19,7 @@ import "../chunk-S5PCVMKU.js";
|
|
|
19
19
|
import "../chunk-7AWFHP5U.js";
|
|
20
20
|
import "../chunk-IIQYS2YH.js";
|
|
21
21
|
import "../chunk-LBXBRFBZ.js";
|
|
22
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-JZR32FON.js";
|
|
23
23
|
export {
|
|
24
24
|
analyzePptxLayouts,
|
|
25
25
|
docToPptx,
|
package/dist/registry/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/squisq-formats",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "Document format converters — DOCX, PDF, OOXML import/export",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bendyline",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
"typecheck": "tsc --noEmit"
|
|
126
126
|
},
|
|
127
127
|
"dependencies": {
|
|
128
|
-
"@bendyline/squisq": "2.12.
|
|
128
|
+
"@bendyline/squisq": "2.12.4",
|
|
129
129
|
"@pdf-lib/fontkit": "1.1.1",
|
|
130
130
|
"@pdf-lib/upng": "1.0.1",
|
|
131
131
|
"@xmldom/xmldom": "0.9.12",
|