@bendyline/squisq-formats 2.3.5 → 2.3.6
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/NOTICE.md +8 -7
- package/THIRD_PARTY_LICENSES.txt +170 -0
- package/dist/{chunk-TAAENIRB.js → chunk-6N2J7C2B.js} +1 -1
- package/dist/{chunk-SBUW7NHR.js → chunk-6X5XN3CZ.js} +2 -0
- package/dist/{chunk-26ISNJ7Y.js → chunk-BGDN7BXK.js} +49 -7
- package/dist/{chunk-GX7RAUME.js → chunk-DWNNYO5H.js} +3 -1
- package/dist/{chunk-4V3KCHAP.js → chunk-ILCJ3WFD.js} +1 -1
- package/dist/{chunk-6S6GU3ZG.js → chunk-KMBBO5H7.js} +3 -3
- package/dist/{chunk-K6XRMVPW.js → chunk-KN62QJYK.js} +42 -5
- package/dist/{chunk-GYIVES2E.js → chunk-KT5DX2QP.js} +42 -1
- package/dist/{chunk-EJTNGKEA.js → chunk-OK622ILP.js} +1 -1
- package/dist/{chunk-X2DEAXNK.js → chunk-S5PCVMKU.js} +6 -0
- package/dist/{chunk-ZBPGMRFQ.js → chunk-TBB4PAX5.js} +106 -19
- package/dist/{chunk-OGS5VCGJ.js → chunk-UIBTXX4L.js} +3 -3
- package/dist/chunk-USU6HTKB.js +94 -0
- package/dist/{chunk-PU7REGWV.js → chunk-WATAOG4Y.js} +2 -2
- package/dist/docx/index.js +6 -5
- package/dist/epub/index.js +3 -2
- package/dist/{extract-MN7LA3NL.js → extract-UTAOG7LV.js} +3 -3
- package/dist/index.js +15 -14
- package/dist/infer/index.js +4 -4
- package/dist/{layouts-DRWZGSPD.js → layouts-2A7QNF6Y.js} +2 -2
- package/dist/ooxml/index.d.ts +7 -1
- package/dist/ooxml/index.js +9 -3
- package/dist/pdf/index.d.ts +2 -2
- package/dist/pdf/index.js +2 -1
- package/dist/pptx/index.js +7 -6
- package/dist/registry/index.js +1 -1
- package/dist/xlsx/index.js +4 -4
- package/package.json +5 -3
- /package/dist/{chunk-3DRWKOF4.js → chunk-GK23NBPZ.js} +0 -0
package/NOTICE.md
CHANGED
|
@@ -6,13 +6,14 @@ Third-party components remain under their respective license terms.
|
|
|
6
6
|
|
|
7
7
|
## Runtime dependencies
|
|
8
8
|
|
|
9
|
-
| Package
|
|
10
|
-
|
|
|
11
|
-
| @pdf-lib/
|
|
12
|
-
| @
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
9
|
+
| Package | Version | License | Repository |
|
|
10
|
+
| ---------------- | ------- | ----------------------- | ---------------------------------- |
|
|
11
|
+
| @pdf-lib/fontkit | 1.1.1 | MIT | https://github.com/Hopding/fontkit |
|
|
12
|
+
| @pdf-lib/upng | 1.0.1 | MIT | https://github.com/Hopding/upng |
|
|
13
|
+
| @xmldom/xmldom | 0.9.10 | MIT | https://github.com/xmldom/xmldom |
|
|
14
|
+
| jszip | 3.10.1 | MIT OR GPL-3.0-or-later | https://github.com/Stuk/jszip |
|
|
15
|
+
| pdf-lib | 1.17.1 | MIT | https://pdf-lib.js.org |
|
|
16
|
+
| pdfjs-dist | 4.10.38 | Apache-2.0 | https://mozilla.github.io/pdf.js |
|
|
16
17
|
|
|
17
18
|
Squisq uses jszip under its MIT license option. Copyright and complete license
|
|
18
19
|
texts for these dependencies are included in their respective npm
|
package/THIRD_PARTY_LICENSES.txt
CHANGED
|
@@ -5,4 +5,174 @@ and notice files are reproduced verbatim. When an npm tarball omits its
|
|
|
5
5
|
repository license, the pinned upstream copy is vendored and identified below.
|
|
6
6
|
|
|
7
7
|
COMPONENTS
|
|
8
|
+
- @fortawesome/fontawesome-free@7.2.0 ((CC-BY-4.0 AND OFL-1.1 AND MIT)); files: LICENSE.txt
|
|
9
|
+
|
|
10
|
+
==============================================================================
|
|
11
|
+
@fortawesome/fontawesome-free@7.2.0 - LICENSE.txt
|
|
12
|
+
==============================================================================
|
|
13
|
+
Fonticons, Inc. (https://fontawesome.com)
|
|
14
|
+
|
|
15
|
+
--------------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
Font Awesome Free License
|
|
18
|
+
|
|
19
|
+
Font Awesome Free is free, open source, and GPL friendly. You can use it for
|
|
20
|
+
commercial projects, open source projects, or really almost whatever you want.
|
|
21
|
+
Full Font Awesome Free license: https://fontawesome.com/license/free.
|
|
22
|
+
|
|
23
|
+
--------------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
|
|
26
|
+
|
|
27
|
+
The Font Awesome Free download is licensed under a Creative Commons
|
|
28
|
+
Attribution 4.0 International License and applies to all icons packaged
|
|
29
|
+
as SVG and JS file types.
|
|
30
|
+
|
|
31
|
+
--------------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
# Fonts: SIL OFL 1.1 License
|
|
34
|
+
|
|
35
|
+
In the Font Awesome Free download, the SIL OFL license applies to all icons
|
|
36
|
+
packaged as web and desktop font files.
|
|
37
|
+
|
|
38
|
+
Copyright (c) 2026 Fonticons, Inc. (https://fontawesome.com)
|
|
39
|
+
with Reserved Font Name: "Font Awesome".
|
|
40
|
+
|
|
41
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
42
|
+
This license is copied below, and is also available with a FAQ at:
|
|
43
|
+
http://scripts.sil.org/OFL
|
|
44
|
+
|
|
45
|
+
SIL OPEN FONT LICENSE
|
|
46
|
+
Version 1.1 - 26 February 2007
|
|
47
|
+
|
|
48
|
+
PREAMBLE
|
|
49
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
50
|
+
development of collaborative font projects, to support the font creation
|
|
51
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
52
|
+
open framework in which fonts may be shared and improved in partnership
|
|
53
|
+
with others.
|
|
54
|
+
|
|
55
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
56
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
57
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
58
|
+
redistributed and/or sold with any software provided that any reserved
|
|
59
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
60
|
+
however, cannot be released under any other type of license. The
|
|
61
|
+
requirement for fonts to remain under this license does not apply
|
|
62
|
+
to any document created using the fonts or their derivatives.
|
|
63
|
+
|
|
64
|
+
DEFINITIONS
|
|
65
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
66
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
67
|
+
include source files, build scripts and documentation.
|
|
68
|
+
|
|
69
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
70
|
+
copyright statement(s).
|
|
71
|
+
|
|
72
|
+
"Original Version" refers to the collection of Font Software components as
|
|
73
|
+
distributed by the Copyright Holder(s).
|
|
74
|
+
|
|
75
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
76
|
+
or substituting — in part or in whole — any of the components of the
|
|
77
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
78
|
+
new environment.
|
|
79
|
+
|
|
80
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
81
|
+
writer or other person who contributed to the Font Software.
|
|
82
|
+
|
|
83
|
+
PERMISSION & CONDITIONS
|
|
84
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
85
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
86
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
87
|
+
Software, subject to the following conditions:
|
|
88
|
+
|
|
89
|
+
1) Neither the Font Software nor any of its individual components,
|
|
90
|
+
in Original or Modified Versions, may be sold by itself.
|
|
91
|
+
|
|
92
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
93
|
+
redistributed and/or sold with any software, provided that each copy
|
|
94
|
+
contains the above copyright notice and this license. These can be
|
|
95
|
+
included either as stand-alone text files, human-readable headers or
|
|
96
|
+
in the appropriate machine-readable metadata fields within text or
|
|
97
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
98
|
+
|
|
99
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
100
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
101
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
102
|
+
presented to the users.
|
|
103
|
+
|
|
104
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
105
|
+
Software shall not be used to promote, endorse or advertise any
|
|
106
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
107
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
108
|
+
permission.
|
|
109
|
+
|
|
110
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
111
|
+
must be distributed entirely under this license, and must not be
|
|
112
|
+
distributed under any other license. The requirement for fonts to
|
|
113
|
+
remain under this license does not apply to any document created
|
|
114
|
+
using the Font Software.
|
|
115
|
+
|
|
116
|
+
TERMINATION
|
|
117
|
+
This license becomes null and void if any of the above conditions are
|
|
118
|
+
not met.
|
|
119
|
+
|
|
120
|
+
DISCLAIMER
|
|
121
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
124
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
125
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
126
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
127
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
128
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
129
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
130
|
+
|
|
131
|
+
--------------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
# Code: MIT License (https://opensource.org/licenses/MIT)
|
|
134
|
+
|
|
135
|
+
In the Font Awesome Free download, the MIT license applies to all non-font and
|
|
136
|
+
non-icon files.
|
|
137
|
+
|
|
138
|
+
Copyright 2026 Fonticons, Inc.
|
|
139
|
+
|
|
140
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
141
|
+
this software and associated documentation files (the "Software"), to deal in the
|
|
142
|
+
Software without restriction, including without limitation the rights to use, copy,
|
|
143
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
144
|
+
and to permit persons to whom the Software is furnished to do so, subject to the
|
|
145
|
+
following conditions:
|
|
146
|
+
|
|
147
|
+
The above copyright notice and this permission notice shall be included in all
|
|
148
|
+
copies or substantial portions of the Software.
|
|
149
|
+
|
|
150
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
151
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
153
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
154
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
155
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
156
|
+
|
|
157
|
+
--------------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
# Attribution
|
|
160
|
+
|
|
161
|
+
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
|
|
162
|
+
Awesome Free files already contain embedded comments with sufficient
|
|
163
|
+
attribution, so you shouldn't need to do anything additional when using these
|
|
164
|
+
files normally.
|
|
165
|
+
|
|
166
|
+
We've kept attribution comments terse, so we ask that you do not actively work
|
|
167
|
+
to remove them from files, especially code. They're a great way for folks to
|
|
168
|
+
learn about Font Awesome.
|
|
169
|
+
|
|
170
|
+
--------------------------------------------------------------------------------
|
|
171
|
+
|
|
172
|
+
# Brand Icons
|
|
173
|
+
|
|
174
|
+
All brand icons are trademarks of their respective owners. The use of these
|
|
175
|
+
trademarks does not indicate endorsement of the trademark holder by Font
|
|
176
|
+
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
|
|
177
|
+
to represent the company, product, or service to which they refer.**
|
|
8
178
|
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
inlineNodesToRuns,
|
|
5
5
|
normalizeOoxmlHex,
|
|
6
6
|
sanitizeOfficeHyperlink
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-DWNNYO5H.js";
|
|
8
8
|
import {
|
|
9
9
|
stripHtmlTags
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6X5XN3CZ.js";
|
|
11
11
|
import {
|
|
12
12
|
createPackage
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ILCJ3WFD.js";
|
|
14
14
|
import {
|
|
15
15
|
escapeXml,
|
|
16
16
|
xmlDeclaration
|
|
@@ -22,11 +22,13 @@ import {
|
|
|
22
22
|
CONTENT_TYPE_DOCX_FOOTNOTES,
|
|
23
23
|
CONTENT_TYPE_DOCX_HEADER,
|
|
24
24
|
CONTENT_TYPE_DOCX_NUMBERING,
|
|
25
|
+
CONTENT_TYPE_DOCX_OBFUSCATED_FONT,
|
|
25
26
|
CONTENT_TYPE_DOCX_SETTINGS,
|
|
26
27
|
CONTENT_TYPE_DOCX_STYLES,
|
|
27
28
|
NS_MC,
|
|
28
29
|
NS_R,
|
|
29
30
|
NS_WML,
|
|
31
|
+
REL_FONT,
|
|
30
32
|
REL_FONT_TABLE,
|
|
31
33
|
REL_FOOTER,
|
|
32
34
|
REL_FOOTNOTES,
|
|
@@ -44,10 +46,16 @@ import {
|
|
|
44
46
|
openPackage,
|
|
45
47
|
requireMainPartPath,
|
|
46
48
|
resolveTarget
|
|
47
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-S5PCVMKU.js";
|
|
48
50
|
import {
|
|
49
51
|
buildContainer
|
|
50
52
|
} from "./chunk-IIQYS2YH.js";
|
|
53
|
+
import {
|
|
54
|
+
fontAwesomeFace,
|
|
55
|
+
fontAwesomeFaces,
|
|
56
|
+
fontAwesomeGlyph,
|
|
57
|
+
obfuscateDocxFont
|
|
58
|
+
} from "./chunk-USU6HTKB.js";
|
|
51
59
|
import {
|
|
52
60
|
extToMime
|
|
53
61
|
} from "./chunk-AONELFLA.js";
|
|
@@ -171,6 +179,8 @@ var ExportContext = class {
|
|
|
171
179
|
this.hasLists = false;
|
|
172
180
|
/** Whether we have any footnotes */
|
|
173
181
|
this.hasFootnotes = false;
|
|
182
|
+
/** Font Awesome families referenced while converting body/header/footer runs. */
|
|
183
|
+
this.iconFamilies = /* @__PURE__ */ new Set();
|
|
174
184
|
this.nextDocPrId = 1;
|
|
175
185
|
let themeFont;
|
|
176
186
|
let themeTitleFont;
|
|
@@ -439,6 +449,7 @@ function docxRunHandlers(ctx) {
|
|
|
439
449
|
run: (text, format) => makeRun(text, format),
|
|
440
450
|
link: (node, format) => convertLink(node, ctx, format),
|
|
441
451
|
image: (node) => convertImage(node, ctx),
|
|
452
|
+
icon: (node, format) => makeIconRun(node, format, ctx),
|
|
442
453
|
lineBreak: () => `<w:r><w:br/></w:r>`,
|
|
443
454
|
footnoteRef: (node) => convertFootnoteRef(node, ctx)
|
|
444
455
|
};
|
|
@@ -463,6 +474,19 @@ function makeRun(text, format) {
|
|
|
463
474
|
const rPr = rPrParts.length > 0 ? `<w:rPr>${rPrParts.join("")}</w:rPr>` : "";
|
|
464
475
|
return `<w:r>${rPr}<w:t xml:space="preserve">${escapeXml(text)}</w:t></w:r>`;
|
|
465
476
|
}
|
|
477
|
+
function makeIconRun(node, format, ctx) {
|
|
478
|
+
const glyph = fontAwesomeGlyph(node.family, node.name);
|
|
479
|
+
if (!glyph) return makeRun(`{[${node.token}]}`, format);
|
|
480
|
+
const face = fontAwesomeFace(node.family);
|
|
481
|
+
ctx.iconFamilies.add(node.family);
|
|
482
|
+
const typeface = escapeXml(face.typeface);
|
|
483
|
+
const rPrParts = [
|
|
484
|
+
`<w:rFonts w:ascii="${typeface}" w:hAnsi="${typeface}" w:eastAsia="${typeface}" w:cs="${typeface}"/>`
|
|
485
|
+
];
|
|
486
|
+
if (format.strike) rPrParts.push("<w:strike/>");
|
|
487
|
+
if (format.color) rPrParts.push(`<w:color w:val="${format.color}"/>`);
|
|
488
|
+
return `<w:r><w:rPr>${rPrParts.join("")}</w:rPr><w:t xml:space="preserve">${escapeXml(glyph)}</w:t></w:r>`;
|
|
489
|
+
}
|
|
466
490
|
function convertLink(node, ctx, format) {
|
|
467
491
|
const rId = ctx.addHyperlink(node.url);
|
|
468
492
|
if (!rId) return convertInlines(node.children, ctx, format);
|
|
@@ -558,6 +582,7 @@ function convertFootnoteRef(node, ctx) {
|
|
|
558
582
|
}
|
|
559
583
|
async function buildDocxPackage(bodyXml, headerXml, footerXml, ctx, options) {
|
|
560
584
|
const pkg = createPackage();
|
|
585
|
+
const embeddedIconFonts = fontAwesomeFaces(ctx.iconFamilies);
|
|
561
586
|
const hasHeader = headerXml.trim().length > 0;
|
|
562
587
|
const hasFooter = footerXml.trim().length > 0;
|
|
563
588
|
const stylesRelId = ctx.allocRelIdFor("document");
|
|
@@ -579,8 +604,22 @@ async function buildDocxPackage(bodyXml, headerXml, footerXml, ctx, options) {
|
|
|
579
604
|
pkg.addPart("word/styles.xml", stylesXml, CONTENT_TYPE_DOCX_STYLES);
|
|
580
605
|
const settingsXml = buildSettingsXml(ctx.backgroundColor !== void 0);
|
|
581
606
|
pkg.addPart("word/settings.xml", settingsXml, CONTENT_TYPE_DOCX_SETTINGS);
|
|
582
|
-
const fontTableXml = buildFontTableXml(options);
|
|
607
|
+
const fontTableXml = buildFontTableXml(options, embeddedIconFonts);
|
|
583
608
|
pkg.addPart("word/fontTable.xml", fontTableXml, CONTENT_TYPE_DOCX_FONT_TABLE);
|
|
609
|
+
for (let index = 0; index < embeddedIconFonts.length; index++) {
|
|
610
|
+
const face = embeddedIconFonts[index];
|
|
611
|
+
const filename = `${face.fileStem}.odttf`;
|
|
612
|
+
pkg.addBinaryPart(
|
|
613
|
+
`word/fonts/${filename}`,
|
|
614
|
+
obfuscateDocxFont(face),
|
|
615
|
+
CONTENT_TYPE_DOCX_OBFUSCATED_FONT
|
|
616
|
+
);
|
|
617
|
+
pkg.addRelationship("word/fontTable.xml", {
|
|
618
|
+
id: `rId${index + 1}`,
|
|
619
|
+
type: REL_FONT,
|
|
620
|
+
target: `fonts/${filename}`
|
|
621
|
+
});
|
|
622
|
+
}
|
|
584
623
|
if (ctx.hasLists) {
|
|
585
624
|
const numberingXml = buildNumberingXml(ctx);
|
|
586
625
|
pkg.addPart("word/numbering.xml", numberingXml, CONTENT_TYPE_DOCX_NUMBERING);
|
|
@@ -692,9 +731,12 @@ function buildSettingsXml(displayBackground) {
|
|
|
692
731
|
const compatXml = `<w:compat><w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15"/><w:compatSetting w:name="overrideTableStyleFontSizeAndJustification" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="enableOpenTypeFeatures" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="doNotFlipMirrorIndents" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/><w:compatSetting w:name="differentiateMultirowTableHeaders" w:uri="http://schemas.microsoft.com/office/word" w:val="1"/></w:compat>`;
|
|
693
732
|
return xmlDeclaration() + `<w:settings xmlns:w="${NS_WML}">` + (displayBackground ? `<w:displayBackgroundShape/>` : "") + `<w:defaultTabStop w:val="720"/><w:characterSpacingControl w:val="doNotCompress"/>` + compatXml + `</w:settings>`;
|
|
694
733
|
}
|
|
695
|
-
function buildFontTableXml(options) {
|
|
734
|
+
function buildFontTableXml(options, embeddedIconFonts) {
|
|
696
735
|
const font = options.defaultFont ?? DEFAULT_FONT;
|
|
697
|
-
|
|
736
|
+
const embeddedXml = embeddedIconFonts.map(
|
|
737
|
+
(face, index) => `<w:font w:name="${escapeXml(face.typeface)}"><w:charset w:val="00"/><w:family w:val="decorative"/><w:pitch w:val="variable"/><w:embedRegular r:id="rId${index + 1}" w:fontKey="{${face.docxFontKey}}"/></w:font>`
|
|
738
|
+
).join("");
|
|
739
|
+
return xmlDeclaration() + `<w:fonts xmlns:w="${NS_WML}" xmlns:r="${NS_R}"><w:font w:name="${escapeXml(font)}"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/></w:font><w:font w:name="${DEFAULT_HEADING_FONT}"><w:panose1 w:val="020F0302020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/></w:font><w:font w:name="${DEFAULT_CODE_FONT}"><w:charset w:val="00"/><w:family w:val="modern"/><w:pitch w:val="fixed"/></w:font>` + embeddedXml + `</w:fonts>`;
|
|
698
740
|
}
|
|
699
741
|
function buildNumberingXml(ctx) {
|
|
700
742
|
const abstract = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
stripHtmlTags
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6X5XN3CZ.js";
|
|
4
4
|
|
|
5
5
|
// src/ooxml/relIds.ts
|
|
6
6
|
var RelIdAllocator = class {
|
|
@@ -102,6 +102,8 @@ function inlineNodeToRuns(node, handlers, format) {
|
|
|
102
102
|
return handlers.link(node, format);
|
|
103
103
|
case "image":
|
|
104
104
|
return handlers.image(node, format);
|
|
105
|
+
case "inlineIcon":
|
|
106
|
+
return handlers.icon(node, format);
|
|
105
107
|
case "break":
|
|
106
108
|
return handlers.lineBreak();
|
|
107
109
|
case "footnoteReference":
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
extractDocxTheme,
|
|
6
6
|
extractPptxTheme,
|
|
7
7
|
extractXlsxTheme
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WATAOG4Y.js";
|
|
9
9
|
import {
|
|
10
10
|
colorHintsFromExtraction,
|
|
11
11
|
compileExtractedTheme
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
openPackage,
|
|
15
15
|
throwIfOoxmlAborted
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S5PCVMKU.js";
|
|
17
17
|
|
|
18
18
|
// src/infer/index.ts
|
|
19
19
|
async function looksLikePdf(data, signal) {
|
|
@@ -107,7 +107,7 @@ async function inferThemeFromFile(data, options = {}) {
|
|
|
107
107
|
if (format !== "pptx") {
|
|
108
108
|
warnings.push("Layout inference is only available for PowerPoint files; skipped.");
|
|
109
109
|
} else {
|
|
110
|
-
const { analyzePptxLayouts } = await import("./layouts-
|
|
110
|
+
const { analyzePptxLayouts } = await import("./layouts-2A7QNF6Y.js");
|
|
111
111
|
const analysis = await analyzePptxLayouts(pkg, {
|
|
112
112
|
colors: colorHintsFromExtraction(extraction),
|
|
113
113
|
signal: options.signal
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
extractPlainText
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6X5XN3CZ.js";
|
|
4
4
|
import {
|
|
5
5
|
escapeXml
|
|
6
6
|
} from "./chunk-JU2RHXUB.js";
|
|
7
|
+
import {
|
|
8
|
+
collectInlineIconFamilies,
|
|
9
|
+
fontAwesomeFaces,
|
|
10
|
+
fontAwesomeGlyph
|
|
11
|
+
} from "./chunk-USU6HTKB.js";
|
|
7
12
|
import {
|
|
8
13
|
extractFilename,
|
|
9
14
|
inferMimeType
|
|
@@ -24,6 +29,7 @@ async function markdownDocToEpub(doc, options = {}) {
|
|
|
24
29
|
const description = options.description ?? "";
|
|
25
30
|
const publisher = options.publisher ?? "";
|
|
26
31
|
const uuid = createEpubUuid();
|
|
32
|
+
const embeddedIconFonts = fontAwesomeFaces(collectInlineIconFamilies(doc));
|
|
27
33
|
const chapters = splitIntoChapters(doc.children);
|
|
28
34
|
const imageEntries = collectDocImages(doc.children);
|
|
29
35
|
const resolvedImages = /* @__PURE__ */ new Map();
|
|
@@ -43,12 +49,16 @@ async function markdownDocToEpub(doc, options = {}) {
|
|
|
43
49
|
const css = generateStylesheet(
|
|
44
50
|
options.themeId ?? readFrontmatterThemeId(doc.frontmatter),
|
|
45
51
|
doc,
|
|
46
|
-
options.themeRegistry
|
|
52
|
+
options.themeRegistry,
|
|
53
|
+
embeddedIconFonts
|
|
47
54
|
);
|
|
48
55
|
const zip = new JSZip();
|
|
49
56
|
zip.file("mimetype", "application/epub+zip", { compression: "STORE" });
|
|
50
57
|
zip.file("META-INF/container.xml", CONTAINER_XML);
|
|
51
58
|
zip.file("OEBPS/styles.css", css);
|
|
59
|
+
for (const face of embeddedIconFonts) {
|
|
60
|
+
zip.file(`OEBPS/fonts/${face.fileStem}.otf`, face.data);
|
|
61
|
+
}
|
|
52
62
|
for (const [, img] of resolvedImages) {
|
|
53
63
|
options.signal?.throwIfAborted();
|
|
54
64
|
zip.file(`OEBPS/images/${img.filename}`, img.data);
|
|
@@ -173,7 +183,8 @@ async function markdownDocToEpub(doc, options = {}) {
|
|
|
173
183
|
images: resolvedImages,
|
|
174
184
|
coverFilename,
|
|
175
185
|
audioFiles: allAudioFiles,
|
|
176
|
-
totalDuration: options.totalDuration
|
|
186
|
+
totalDuration: options.totalDuration,
|
|
187
|
+
iconFonts: embeddedIconFonts
|
|
177
188
|
})
|
|
178
189
|
);
|
|
179
190
|
const blob = await zip.generateAsync({
|
|
@@ -375,6 +386,11 @@ function inlineToXhtml(node, images) {
|
|
|
375
386
|
return `<span class="math">${escapeXml(node.value)}</span>`;
|
|
376
387
|
case "htmlInline":
|
|
377
388
|
return escapeXml(node.rawHtml.replace(/<[^>]+>/g, ""));
|
|
389
|
+
case "inlineIcon": {
|
|
390
|
+
const icon = node;
|
|
391
|
+
const glyph = fontAwesomeGlyph(icon.family, icon.name);
|
|
392
|
+
return glyph ? `<span class="squisq-fa-${icon.family}">${escapeXml(glyph)}</span>` : escapeXml(`{[${icon.token}]}`);
|
|
393
|
+
}
|
|
378
394
|
default:
|
|
379
395
|
return "";
|
|
380
396
|
}
|
|
@@ -478,7 +494,8 @@ function generateContentOpf(params) {
|
|
|
478
494
|
images,
|
|
479
495
|
coverFilename,
|
|
480
496
|
audioFiles,
|
|
481
|
-
totalDuration
|
|
497
|
+
totalDuration,
|
|
498
|
+
iconFonts
|
|
482
499
|
} = params;
|
|
483
500
|
const modified = (/* @__PURE__ */ new Date()).toISOString().replace(/\.\d+Z$/, "Z");
|
|
484
501
|
const hasOverlays = chapters.some((c) => c.smilFilename);
|
|
@@ -486,6 +503,11 @@ function generateContentOpf(params) {
|
|
|
486
503
|
' <item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" properties="nav"/>',
|
|
487
504
|
' <item id="css" href="styles.css" media-type="text/css"/>'
|
|
488
505
|
];
|
|
506
|
+
for (const face of iconFonts) {
|
|
507
|
+
manifestItems.push(
|
|
508
|
+
` <item id="font-${face.family}" href="fonts/${face.fileStem}.otf" media-type="font/otf"/>`
|
|
509
|
+
);
|
|
510
|
+
}
|
|
489
511
|
if (coverFilename) {
|
|
490
512
|
const mime = inferMimeType(coverFilename);
|
|
491
513
|
manifestItems.push(
|
|
@@ -587,7 +609,7 @@ ${navItems}
|
|
|
587
609
|
</body>
|
|
588
610
|
</html>`;
|
|
589
611
|
}
|
|
590
|
-
function generateStylesheet(themeId, doc, registry) {
|
|
612
|
+
function generateStylesheet(themeId, doc, registry, iconFonts = []) {
|
|
591
613
|
let themeVars = "";
|
|
592
614
|
if (themeId) {
|
|
593
615
|
const theme = resolveThemeForDoc(doc, themeId, registry);
|
|
@@ -598,7 +620,22 @@ function generateStylesheet(themeId, doc, registry) {
|
|
|
598
620
|
--epub-heading-font: ${resolveFontFamily(theme.typography.titleFont, "serif")};
|
|
599
621
|
--epub-body-font: ${resolveFontFamily(theme.typography.bodyFont, "sans-serif")};`;
|
|
600
622
|
}
|
|
623
|
+
const iconCss = iconFonts.map(
|
|
624
|
+
(face) => `@font-face {
|
|
625
|
+
font-family: '${face.typeface}';
|
|
626
|
+
src: url('fonts/${face.fileStem}.otf') format('opentype');
|
|
627
|
+
font-style: normal;
|
|
628
|
+
font-weight: normal;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.squisq-fa-${face.family} {
|
|
632
|
+
font-family: '${face.typeface}';
|
|
633
|
+
font-style: normal;
|
|
634
|
+
font-weight: normal;
|
|
635
|
+
}`
|
|
636
|
+
).join("\n\n");
|
|
601
637
|
return `/* Squisq EPUB Stylesheet */
|
|
638
|
+
${iconCss}
|
|
602
639
|
:root {${themeVars}
|
|
603
640
|
}
|
|
604
641
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildContainer
|
|
3
3
|
} from "./chunk-IIQYS2YH.js";
|
|
4
|
+
import {
|
|
5
|
+
collectInlineIconFamilies,
|
|
6
|
+
fontAwesomeFaces,
|
|
7
|
+
fontAwesomeGlyph
|
|
8
|
+
} from "./chunk-USU6HTKB.js";
|
|
4
9
|
|
|
5
10
|
// src/pdf/export.ts
|
|
6
11
|
import { PDFDocument, StandardFonts, rgb, PDFString } from "pdf-lib";
|
|
12
|
+
import fontkit from "@pdf-lib/fontkit";
|
|
7
13
|
import { docToMarkdown, resolveThemeForDoc } from "@bendyline/squisq/doc";
|
|
8
14
|
import { readFrontmatterThemeId, sanitizeUrl } from "@bendyline/squisq/markdown";
|
|
9
15
|
|
|
@@ -404,6 +410,16 @@ async function createExportContext(pdfDoc, options, doc) {
|
|
|
404
410
|
pdfDoc.embedFont(StandardFonts.Courier),
|
|
405
411
|
pdfDoc.embedFont(StandardFonts.CourierBold)
|
|
406
412
|
]);
|
|
413
|
+
const icons = {};
|
|
414
|
+
const iconFamilies = collectInlineIconFamilies(doc);
|
|
415
|
+
if (iconFamilies.size > 0) {
|
|
416
|
+
pdfDoc.registerFontkit(fontkit);
|
|
417
|
+
await Promise.all(
|
|
418
|
+
fontAwesomeFaces(iconFamilies).map(async (face) => {
|
|
419
|
+
icons[face.family] = await pdfDoc.embedFont(face.data, { subset: true });
|
|
420
|
+
})
|
|
421
|
+
);
|
|
422
|
+
}
|
|
407
423
|
const isA4 = options.pageSize === "a4";
|
|
408
424
|
const pageWidth = isA4 ? PAGE_WIDTH_A4 : PAGE_WIDTH_LETTER;
|
|
409
425
|
const pageHeight = isA4 ? PAGE_HEIGHT_A4 : PAGE_HEIGHT_LETTER;
|
|
@@ -424,7 +440,7 @@ async function createExportContext(pdfDoc, options, doc) {
|
|
|
424
440
|
}
|
|
425
441
|
return {
|
|
426
442
|
pdfDoc,
|
|
427
|
-
fonts: { regular, bold, italic, boldItalic, mono, monoBold },
|
|
443
|
+
fonts: { regular, bold, italic, boldItalic, mono, monoBold, icons },
|
|
428
444
|
pageWidth,
|
|
429
445
|
pageHeight,
|
|
430
446
|
margin,
|
|
@@ -514,6 +530,31 @@ function flattenInlines(nodes, ctx, state) {
|
|
|
514
530
|
});
|
|
515
531
|
break;
|
|
516
532
|
}
|
|
533
|
+
case "inlineIcon": {
|
|
534
|
+
const iconNode = node;
|
|
535
|
+
const glyph = fontAwesomeGlyph(iconNode.family, iconNode.name);
|
|
536
|
+
const font = ctx.fonts.icons[iconNode.family];
|
|
537
|
+
if (glyph && font) {
|
|
538
|
+
spans.push({
|
|
539
|
+
text: glyph,
|
|
540
|
+
font,
|
|
541
|
+
fontSize: ctx.fontSize,
|
|
542
|
+
color: state.color ?? ctx.colors.text,
|
|
543
|
+
link: state.link,
|
|
544
|
+
strikethrough: state.strikethrough
|
|
545
|
+
});
|
|
546
|
+
} else {
|
|
547
|
+
spans.push({
|
|
548
|
+
text: ctx.text.clean(`{[${iconNode.token}]}`),
|
|
549
|
+
font: pickFont(ctx, state.bold, state.italic),
|
|
550
|
+
fontSize: ctx.fontSize,
|
|
551
|
+
color: state.color ?? ctx.colors.text,
|
|
552
|
+
link: state.link,
|
|
553
|
+
strikethrough: state.strikethrough
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
517
558
|
case "break":
|
|
518
559
|
spans.push({
|
|
519
560
|
text: "\n",
|
|
@@ -11,6 +11,7 @@ var REL_EXTENDED_PROPERTIES = "http://schemas.openxmlformats.org/officeDocument/
|
|
|
11
11
|
var REL_STYLES = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
|
|
12
12
|
var REL_NUMBERING = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
|
|
13
13
|
var REL_FONT_TABLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
|
|
14
|
+
var REL_FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
|
|
14
15
|
var REL_SETTINGS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
|
|
15
16
|
var REL_HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
16
17
|
var REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
@@ -38,6 +39,7 @@ var CONTENT_TYPE_DOCX_STYLES = "application/vnd.openxmlformats-officedocument.wo
|
|
|
38
39
|
var CONTENT_TYPE_DOCX_NUMBERING = "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
|
|
39
40
|
var CONTENT_TYPE_DOCX_SETTINGS = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
|
|
40
41
|
var CONTENT_TYPE_DOCX_FONT_TABLE = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
|
|
42
|
+
var CONTENT_TYPE_DOCX_OBFUSCATED_FONT = "application/vnd.openxmlformats-officedocument.obfuscatedFont";
|
|
41
43
|
var CONTENT_TYPE_DOCX_FOOTNOTES = "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml";
|
|
42
44
|
var CONTENT_TYPE_DOCX_HEADER = "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml";
|
|
43
45
|
var CONTENT_TYPE_DOCX_FOOTER = "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";
|
|
@@ -46,6 +48,7 @@ var CONTENT_TYPE_PPTX_SLIDE = "application/vnd.openxmlformats-officedocument.pre
|
|
|
46
48
|
var CONTENT_TYPE_PPTX_SLIDE_LAYOUT = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
|
47
49
|
var CONTENT_TYPE_PPTX_SLIDE_MASTER = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
|
|
48
50
|
var CONTENT_TYPE_PPTX_THEME = "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
51
|
+
var CONTENT_TYPE_PPTX_FONT = "application/x-fontdata";
|
|
49
52
|
var REL_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
|
|
50
53
|
var REL_SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
|
51
54
|
var REL_SLIDE_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
|
@@ -269,6 +272,7 @@ export {
|
|
|
269
272
|
REL_STYLES,
|
|
270
273
|
REL_NUMBERING,
|
|
271
274
|
REL_FONT_TABLE,
|
|
275
|
+
REL_FONT,
|
|
272
276
|
REL_SETTINGS,
|
|
273
277
|
REL_HYPERLINK,
|
|
274
278
|
REL_IMAGE,
|
|
@@ -296,6 +300,7 @@ export {
|
|
|
296
300
|
CONTENT_TYPE_DOCX_NUMBERING,
|
|
297
301
|
CONTENT_TYPE_DOCX_SETTINGS,
|
|
298
302
|
CONTENT_TYPE_DOCX_FONT_TABLE,
|
|
303
|
+
CONTENT_TYPE_DOCX_OBFUSCATED_FONT,
|
|
299
304
|
CONTENT_TYPE_DOCX_FOOTNOTES,
|
|
300
305
|
CONTENT_TYPE_DOCX_HEADER,
|
|
301
306
|
CONTENT_TYPE_DOCX_FOOTER,
|
|
@@ -304,6 +309,7 @@ export {
|
|
|
304
309
|
CONTENT_TYPE_PPTX_SLIDE_LAYOUT,
|
|
305
310
|
CONTENT_TYPE_PPTX_SLIDE_MASTER,
|
|
306
311
|
CONTENT_TYPE_PPTX_THEME,
|
|
312
|
+
CONTENT_TYPE_PPTX_FONT,
|
|
307
313
|
REL_SLIDE,
|
|
308
314
|
REL_SLIDE_LAYOUT,
|
|
309
315
|
REL_SLIDE_MASTER,
|