@bendyline/squisq-formats 1.3.0 → 1.4.0
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-6M7Z25LA.js +46 -0
- package/dist/chunk-6M7Z25LA.js.map +1 -0
- package/dist/{chunk-S3Y7H2BK.js → chunk-APSIAEXL.js} +9 -8
- package/dist/chunk-APSIAEXL.js.map +1 -0
- package/dist/{chunk-UDS45KUJ.js → chunk-BJQIJ4S4.js} +36 -52
- package/dist/chunk-BJQIJ4S4.js.map +1 -0
- package/dist/{chunk-33YRFXZZ.js → chunk-CRTC6DEX.js} +259 -13
- package/dist/chunk-CRTC6DEX.js.map +1 -0
- package/dist/chunk-FMOIGA5T.js +201 -0
- package/dist/chunk-FMOIGA5T.js.map +1 -0
- package/dist/{chunk-VN2KEOYB.js → chunk-I2GFTEOV.js} +321 -91
- package/dist/chunk-I2GFTEOV.js.map +1 -0
- package/dist/chunk-JBNVE2GV.js +116 -0
- package/dist/chunk-JBNVE2GV.js.map +1 -0
- package/dist/chunk-L53YIGYS.js +141 -0
- package/dist/chunk-L53YIGYS.js.map +1 -0
- package/dist/{chunk-ERZ627GR.js → chunk-ON232HJR.js} +11 -26
- package/dist/chunk-ON232HJR.js.map +1 -0
- package/dist/chunk-PN52A5AA.js +32 -0
- package/dist/chunk-PN52A5AA.js.map +1 -0
- package/dist/{chunk-7DEUGIOO.js → chunk-QSE7EWE7.js} +12 -87
- package/dist/chunk-QSE7EWE7.js.map +1 -0
- package/dist/container/index.d.ts +7 -5
- package/dist/container/index.js +39 -70
- package/dist/container/index.js.map +1 -1
- package/dist/csv/index.d.ts +37 -0
- package/dist/csv/index.js +13 -0
- package/dist/csv/index.js.map +1 -0
- package/dist/docx/index.d.ts +128 -15
- package/dist/docx/index.js +19 -22
- package/dist/docx/index.js.map +1 -1
- package/dist/epub/index.d.ts +66 -11
- package/dist/epub/index.js +11 -18
- package/dist/epub/index.js.map +1 -1
- package/dist/html/index.d.ts +315 -15
- package/dist/html/index.js +32 -165
- package/dist/html/index.js.map +1 -1
- package/dist/index.d.ts +10 -38
- package/dist/index.js +80 -37
- package/dist/index.js.map +1 -1
- package/dist/ooxml/index.d.ts +353 -14
- package/dist/ooxml/index.js +116 -22
- package/dist/ooxml/index.js.map +1 -1
- package/dist/pdf/index.d.ts +143 -17
- package/dist/pdf/index.js +16 -25
- package/dist/pdf/index.js.map +1 -1
- package/dist/pptx/index.d.ts +98 -21
- package/dist/pptx/index.js +18 -34
- package/dist/pptx/index.js.map +1 -1
- package/dist/xlsx/index.d.ts +29 -25
- package/dist/xlsx/index.js +13 -44
- package/dist/xlsx/index.js.map +1 -1
- package/package.json +7 -2
- package/src/__tests__/csvImport.test.ts +51 -0
- package/src/__tests__/exportThemeReconciliation.test.ts +87 -0
- package/src/__tests__/htmlImport.test.ts +57 -0
- package/src/__tests__/plainHtml.test.ts +31 -0
- package/src/__tests__/pptxExport.test.ts +138 -0
- package/src/__tests__/pptxImport.test.ts +70 -0
- package/src/__tests__/roundTripMatrix.fixtures.ts +86 -0
- package/src/__tests__/roundTripMatrix.helpers.ts +154 -0
- package/src/__tests__/roundTripMatrix.test.ts +136 -0
- package/src/__tests__/xlsxImport.test.ts +80 -0
- package/src/csv/index.ts +165 -0
- package/src/docx/export.ts +27 -44
- package/src/docx/import.ts +1 -2
- package/src/epub/export.ts +10 -27
- package/src/html/import.ts +297 -0
- package/src/html/index.ts +4 -0
- package/src/html/plainHtml.ts +66 -16
- package/src/index.ts +10 -3
- package/src/ooxml/namespaces.ts +3 -0
- package/src/pdf/export.ts +10 -5
- package/src/pdf/import.ts +1 -1
- package/src/pptx/export.ts +225 -85
- package/src/pptx/import.ts +156 -0
- package/src/pptx/index.ts +10 -28
- package/src/shared/inlineRuns.ts +99 -0
- package/src/shared/text.ts +41 -0
- package/src/xlsx/import.ts +159 -0
- package/src/xlsx/index.ts +11 -28
- package/dist/__tests__/container.test.d.ts +0 -8
- package/dist/__tests__/container.test.d.ts.map +0 -1
- package/dist/__tests__/container.test.js +0 -147
- package/dist/__tests__/container.test.js.map +0 -1
- package/dist/__tests__/docxExport.test.d.ts +0 -8
- package/dist/__tests__/docxExport.test.d.ts.map +0 -1
- package/dist/__tests__/docxExport.test.js +0 -383
- package/dist/__tests__/docxExport.test.js.map +0 -1
- package/dist/__tests__/docxImport.test.d.ts +0 -8
- package/dist/__tests__/docxImport.test.d.ts.map +0 -1
- package/dist/__tests__/docxImport.test.js +0 -309
- package/dist/__tests__/docxImport.test.js.map +0 -1
- package/dist/__tests__/epub.test.d.ts +0 -8
- package/dist/__tests__/epub.test.d.ts.map +0 -1
- package/dist/__tests__/epub.test.js +0 -472
- package/dist/__tests__/epub.test.js.map +0 -1
- package/dist/__tests__/html.test.d.ts +0 -8
- package/dist/__tests__/html.test.d.ts.map +0 -1
- package/dist/__tests__/html.test.js +0 -317
- package/dist/__tests__/html.test.js.map +0 -1
- package/dist/__tests__/ooxml.test.d.ts +0 -5
- package/dist/__tests__/ooxml.test.d.ts.map +0 -1
- package/dist/__tests__/ooxml.test.js +0 -152
- package/dist/__tests__/ooxml.test.js.map +0 -1
- package/dist/__tests__/pdfExport.test.d.ts +0 -8
- package/dist/__tests__/pdfExport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfExport.test.js +0 -275
- package/dist/__tests__/pdfExport.test.js.map +0 -1
- package/dist/__tests__/pdfImport.test.d.ts +0 -11
- package/dist/__tests__/pdfImport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfImport.test.js +0 -254
- package/dist/__tests__/pdfImport.test.js.map +0 -1
- package/dist/__tests__/plainHtml.test.d.ts +0 -5
- package/dist/__tests__/plainHtml.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtml.test.js +0 -327
- package/dist/__tests__/plainHtml.test.js.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.d.ts +0 -11
- package/dist/__tests__/plainHtmlBundle.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.js +0 -210
- package/dist/__tests__/plainHtmlBundle.test.js.map +0 -1
- package/dist/__tests__/roundTrip.test.d.ts +0 -7
- package/dist/__tests__/roundTrip.test.d.ts.map +0 -1
- package/dist/__tests__/roundTrip.test.js +0 -173
- package/dist/__tests__/roundTrip.test.js.map +0 -1
- package/dist/chunk-33YRFXZZ.js.map +0 -1
- package/dist/chunk-67KIJHV2.js +0 -21
- package/dist/chunk-67KIJHV2.js.map +0 -1
- package/dist/chunk-7DEUGIOO.js.map +0 -1
- package/dist/chunk-ERZ627GR.js.map +0 -1
- package/dist/chunk-S3Y7H2BK.js.map +0 -1
- package/dist/chunk-UDS45KUJ.js.map +0 -1
- package/dist/chunk-VN2KEOYB.js.map +0 -1
- package/dist/chunk-YN5HFCEW.js +0 -120
- package/dist/chunk-YN5HFCEW.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/docx/export.d.ts +0 -69
- package/dist/docx/export.d.ts.map +0 -1
- package/dist/docx/export.js +0 -985
- package/dist/docx/export.js.map +0 -1
- package/dist/docx/import.d.ts +0 -65
- package/dist/docx/import.d.ts.map +0 -1
- package/dist/docx/import.js +0 -779
- package/dist/docx/import.js.map +0 -1
- package/dist/docx/index.d.ts.map +0 -1
- package/dist/docx/styles.d.ts +0 -68
- package/dist/docx/styles.d.ts.map +0 -1
- package/dist/docx/styles.js +0 -125
- package/dist/docx/styles.js.map +0 -1
- package/dist/epub/export.d.ts +0 -72
- package/dist/epub/export.d.ts.map +0 -1
- package/dist/epub/export.js +0 -698
- package/dist/epub/export.js.map +0 -1
- package/dist/epub/index.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.d.ts +0 -53
- package/dist/html/docsHtmlBundle.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.js +0 -299
- package/dist/html/docsHtmlBundle.js.map +0 -1
- package/dist/html/htmlTemplate.d.ts +0 -70
- package/dist/html/htmlTemplate.d.ts.map +0 -1
- package/dist/html/htmlTemplate.js +0 -282
- package/dist/html/htmlTemplate.js.map +0 -1
- package/dist/html/imageUtils.d.ts +0 -29
- package/dist/html/imageUtils.d.ts.map +0 -1
- package/dist/html/imageUtils.js +0 -63
- package/dist/html/imageUtils.js.map +0 -1
- package/dist/html/index.d.ts.map +0 -1
- package/dist/html/plainHtml.d.ts +0 -79
- package/dist/html/plainHtml.d.ts.map +0 -1
- package/dist/html/plainHtml.js +0 -614
- package/dist/html/plainHtml.js.map +0 -1
- package/dist/html/plainHtmlBundle.d.ts +0 -93
- package/dist/html/plainHtmlBundle.d.ts.map +0 -1
- package/dist/html/plainHtmlBundle.js +0 -357
- package/dist/html/plainHtmlBundle.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/ooxml/index.d.ts.map +0 -1
- package/dist/ooxml/namespaces.d.ts +0 -77
- package/dist/ooxml/namespaces.d.ts.map +0 -1
- package/dist/ooxml/namespaces.js +0 -104
- package/dist/ooxml/namespaces.js.map +0 -1
- package/dist/ooxml/reader.d.ts +0 -52
- package/dist/ooxml/reader.d.ts.map +0 -1
- package/dist/ooxml/reader.js +0 -190
- package/dist/ooxml/reader.js.map +0 -1
- package/dist/ooxml/types.d.ts +0 -82
- package/dist/ooxml/types.d.ts.map +0 -1
- package/dist/ooxml/types.js +0 -9
- package/dist/ooxml/types.js.map +0 -1
- package/dist/ooxml/writer.d.ts +0 -71
- package/dist/ooxml/writer.d.ts.map +0 -1
- package/dist/ooxml/writer.js +0 -200
- package/dist/ooxml/writer.js.map +0 -1
- package/dist/ooxml/xmlUtils.d.ts +0 -76
- package/dist/ooxml/xmlUtils.d.ts.map +0 -1
- package/dist/ooxml/xmlUtils.js +0 -108
- package/dist/ooxml/xmlUtils.js.map +0 -1
- package/dist/pdf/export.d.ts +0 -56
- package/dist/pdf/export.d.ts.map +0 -1
- package/dist/pdf/export.js +0 -768
- package/dist/pdf/export.js.map +0 -1
- package/dist/pdf/import.d.ts +0 -94
- package/dist/pdf/import.d.ts.map +0 -1
- package/dist/pdf/import.js +0 -796
- package/dist/pdf/import.js.map +0 -1
- package/dist/pdf/index.d.ts.map +0 -1
- package/dist/pdf/styles.d.ts +0 -142
- package/dist/pdf/styles.d.ts.map +0 -1
- package/dist/pdf/styles.js +0 -145
- package/dist/pdf/styles.js.map +0 -1
- package/dist/pptx/export.d.ts +0 -75
- package/dist/pptx/export.d.ts.map +0 -1
- package/dist/pptx/export.js +0 -724
- package/dist/pptx/export.js.map +0 -1
- package/dist/pptx/index.d.ts.map +0 -1
- package/dist/pptx/styles.d.ts +0 -54
- package/dist/pptx/styles.d.ts.map +0 -1
- package/dist/pptx/styles.js +0 -73
- package/dist/pptx/styles.js.map +0 -1
- package/dist/pptx/templates.d.ts +0 -24
- package/dist/pptx/templates.d.ts.map +0 -1
- package/dist/pptx/templates.js +0 -158
- package/dist/pptx/templates.js.map +0 -1
- package/dist/xlsx/index.d.ts.map +0 -1
package/dist/docx/index.d.ts
CHANGED
|
@@ -1,23 +1,136 @@
|
|
|
1
|
+
import { Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
import { ContentContainer } from '@bendyline/squisq/storage';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
6
|
+
* DOCX Export
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
8
|
+
* Converts a squisq MarkdownDocument (or Doc) into a .docx file
|
|
9
|
+
* by generating WordprocessingML XML and assembling the OOXML package.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
11
|
+
* No third-party docx library — all XML is generated directly using
|
|
12
|
+
* the shared ooxml/ infrastructure of this package.
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```ts
|
|
11
|
-
* import {
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* import { parseMarkdown } from '@bendyline/squisq/markdown';
|
|
17
|
+
* import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
|
|
18
|
+
*
|
|
19
|
+
* const md = parseMarkdown('# Hello\n\nWorld **bold** text');
|
|
20
|
+
* const blob = await markdownDocToDocx(md);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Options for DOCX export.
|
|
26
|
+
*/
|
|
27
|
+
interface DocxExportOptions {
|
|
28
|
+
/** Document title (appears in core properties) */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Document author */
|
|
31
|
+
author?: string;
|
|
32
|
+
/** Document description */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Default body font family. Default: "Calibri" */
|
|
35
|
+
defaultFont?: string;
|
|
36
|
+
/** Default body font size in points. Default: 11 */
|
|
37
|
+
defaultFontSize?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
|
|
40
|
+
* When set, overrides fonts with the theme's typography and applies
|
|
41
|
+
* the theme's primary color to headings.
|
|
42
|
+
*/
|
|
43
|
+
themeId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Pre-resolved image data keyed by image URL/path as it appears in the
|
|
46
|
+
* markdown source. When provided, images are embedded in the .docx file
|
|
47
|
+
* as binary parts instead of emitting placeholder text.
|
|
48
|
+
*/
|
|
49
|
+
images?: Map<string, {
|
|
50
|
+
data: ArrayBuffer | Uint8Array;
|
|
51
|
+
contentType: string;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Convert a MarkdownDocument to a .docx Blob.
|
|
56
|
+
*
|
|
57
|
+
* @param doc - The parsed markdown document
|
|
58
|
+
* @param options - Export options
|
|
59
|
+
* @returns An ArrayBuffer containing the .docx file
|
|
60
|
+
*/
|
|
61
|
+
declare function markdownDocToDocx(doc: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
|
|
62
|
+
/**
|
|
63
|
+
* Convert a squisq Doc to a .docx Blob.
|
|
64
|
+
*
|
|
65
|
+
* Convenience wrapper that converts Doc → MarkdownDocument → DOCX.
|
|
66
|
+
*
|
|
67
|
+
* @param doc - The squisq Doc
|
|
68
|
+
* @param options - Export options
|
|
69
|
+
* @returns An ArrayBuffer containing the .docx file
|
|
70
|
+
*/
|
|
71
|
+
declare function docToDocx(doc: Doc, options?: DocxExportOptions): Promise<ArrayBuffer>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* DOCX Import
|
|
75
|
+
*
|
|
76
|
+
* Parses a .docx file (Office Open XML WordprocessingML) and converts
|
|
77
|
+
* its content into a squisq MarkdownDocument (or Doc).
|
|
78
|
+
*
|
|
79
|
+
* Uses JSZip + DOMParser to read the archive and parse the XML — no
|
|
80
|
+
* third-party docx library. Handles headings, paragraphs, inline
|
|
81
|
+
* formatting (bold, italic, strikethrough), hyperlinks, lists, tables,
|
|
82
|
+
* blockquotes, code blocks, images, and footnotes.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { docxToMarkdownDoc } from '@bendyline/squisq-formats/docx';
|
|
87
|
+
*
|
|
88
|
+
* const response = await fetch('document.docx');
|
|
89
|
+
* const data = await response.arrayBuffer();
|
|
90
|
+
* const doc = await docxToMarkdownDoc(data);
|
|
17
91
|
* ```
|
|
18
92
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Options for DOCX import.
|
|
96
|
+
*/
|
|
97
|
+
interface DocxImportOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Whether to extract embedded images as base64 data URIs.
|
|
100
|
+
* When false, images are represented as `[Image]` placeholders.
|
|
101
|
+
* Default: false
|
|
102
|
+
*/
|
|
103
|
+
extractImages?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Convert a .docx file to a MarkdownDocument.
|
|
107
|
+
*
|
|
108
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
109
|
+
* @param options - Import options
|
|
110
|
+
* @returns A MarkdownDocument representing the document content
|
|
111
|
+
*/
|
|
112
|
+
declare function docxToMarkdownDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<MarkdownDocument>;
|
|
113
|
+
/**
|
|
114
|
+
* Convert a .docx file to a squisq Doc.
|
|
115
|
+
*
|
|
116
|
+
* Convenience wrapper: DOCX → MarkdownDocument → Doc.
|
|
117
|
+
*
|
|
118
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
119
|
+
* @param options - Import options
|
|
120
|
+
* @returns A squisq Doc
|
|
121
|
+
*/
|
|
122
|
+
declare function docxToDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<Doc>;
|
|
123
|
+
/**
|
|
124
|
+
* Convert a .docx file to a ContentContainer with markdown + extracted images.
|
|
125
|
+
*
|
|
126
|
+
* The container will contain:
|
|
127
|
+
* - The primary markdown document (index.md)
|
|
128
|
+
* - Any embedded images under images/ (e.g., images/image1.png)
|
|
129
|
+
*
|
|
130
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
131
|
+
* @param options - Import options
|
|
132
|
+
* @returns A ContentContainer with the document and its media
|
|
133
|
+
*/
|
|
134
|
+
declare function docxToContainer(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<ContentContainer>;
|
|
135
|
+
|
|
136
|
+
export { type DocxExportOptions, type DocxImportOptions, docToDocx, docxToContainer, docxToDoc, docxToMarkdownDoc, markdownDocToDocx };
|
package/dist/docx/index.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export { markdownDocToDocx, docToDocx } from './export.js';
|
|
21
|
-
// Import
|
|
22
|
-
export { docxToMarkdownDoc, docxToDoc, docxToContainer } from './import.js';
|
|
1
|
+
import {
|
|
2
|
+
docToDocx,
|
|
3
|
+
docxToContainer,
|
|
4
|
+
docxToDoc,
|
|
5
|
+
docxToMarkdownDoc,
|
|
6
|
+
markdownDocToDocx
|
|
7
|
+
} from "../chunk-BJQIJ4S4.js";
|
|
8
|
+
import "../chunk-6M7Z25LA.js";
|
|
9
|
+
import "../chunk-PN52A5AA.js";
|
|
10
|
+
import "../chunk-QSE7EWE7.js";
|
|
11
|
+
import "../chunk-U4MRIFKL.js";
|
|
12
|
+
import "../chunk-FMOIGA5T.js";
|
|
13
|
+
export {
|
|
14
|
+
docToDocx,
|
|
15
|
+
docxToContainer,
|
|
16
|
+
docxToDoc,
|
|
17
|
+
docxToMarkdownDoc,
|
|
18
|
+
markdownDocToDocx
|
|
19
|
+
};
|
|
23
20
|
//# sourceMappingURL=index.js.map
|
package/dist/docx/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/epub/index.d.ts
CHANGED
|
@@ -1,20 +1,75 @@
|
|
|
1
|
+
import { AudioSegment, Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* EPUB 3 Export
|
|
3
6
|
*
|
|
4
|
-
*
|
|
7
|
+
* Converts a MarkdownDocument (or Doc) to an EPUB 3 file (.epub).
|
|
5
8
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* An EPUB is a ZIP archive containing XHTML chapter files, images,
|
|
10
|
+
* a package manifest (content.opf), and a navigation document (toc.xhtml).
|
|
11
|
+
* Content is split into chapters at H1/H2 heading boundaries.
|
|
12
|
+
*
|
|
13
|
+
* Uses JSZip for packaging (already a dependency), escapeXml from the
|
|
14
|
+
* OOXML utils, and image utilities from the HTML exporter.
|
|
9
15
|
*
|
|
10
16
|
* @example
|
|
11
17
|
* ```ts
|
|
12
|
-
* import { markdownDocToEpub
|
|
18
|
+
* import { markdownDocToEpub } from '@bendyline/squisq-formats/epub';
|
|
13
19
|
*
|
|
14
|
-
* const epub = await markdownDocToEpub(markdownDoc, {
|
|
15
|
-
*
|
|
20
|
+
* const epub = await markdownDocToEpub(markdownDoc, {
|
|
21
|
+
* title: 'My Book',
|
|
22
|
+
* author: 'Jane Doe',
|
|
23
|
+
* });
|
|
16
24
|
* ```
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
|
|
27
|
+
interface EpubExportOptions {
|
|
28
|
+
/** Book title (default: 'Untitled') */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Author name */
|
|
31
|
+
author?: string;
|
|
32
|
+
/** Book description / summary */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** BCP-47 language code (default: 'en') */
|
|
35
|
+
language?: string;
|
|
36
|
+
/** Publisher name */
|
|
37
|
+
publisher?: string;
|
|
38
|
+
/** Squisq theme ID for CSS styling */
|
|
39
|
+
themeId?: string;
|
|
40
|
+
/** Pre-resolved image data keyed by relative path as it appears in the markdown */
|
|
41
|
+
images?: Map<string, ArrayBuffer>;
|
|
42
|
+
/** Cover image data (JPEG or PNG) */
|
|
43
|
+
coverImage?: ArrayBuffer;
|
|
44
|
+
/**
|
|
45
|
+
* Audio narration data keyed by segment src/name.
|
|
46
|
+
* When provided alongside audioSegments, EPUB 3 Media Overlays (SMIL)
|
|
47
|
+
* are generated for synchronized audio playback.
|
|
48
|
+
*/
|
|
49
|
+
audio?: Map<string, ArrayBuffer>;
|
|
50
|
+
/**
|
|
51
|
+
* Audio segment metadata (from Doc.audio.segments).
|
|
52
|
+
* Required together with `audio` to generate Media Overlays.
|
|
53
|
+
* Each segment's duration and startTime are used to build SMIL timing.
|
|
54
|
+
*/
|
|
55
|
+
audioSegments?: AudioSegment[];
|
|
56
|
+
/** Total document duration in seconds (used for Media Overlay metadata) */
|
|
57
|
+
totalDuration?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Convert a MarkdownDocument to an EPUB 3 file.
|
|
61
|
+
*
|
|
62
|
+
* Chapters are split at H1/H2 heading boundaries. All referenced images
|
|
63
|
+
* (provided via `options.images`) are embedded in the archive.
|
|
64
|
+
*/
|
|
65
|
+
declare function markdownDocToEpub(doc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
|
|
66
|
+
/**
|
|
67
|
+
* Convert a squisq Doc to an EPUB 3 file.
|
|
68
|
+
*
|
|
69
|
+
* Convenience wrapper: Doc → MarkdownDocument → EPUB.
|
|
70
|
+
* When the Doc has audio segments and `options.audio` is provided,
|
|
71
|
+
* EPUB 3 Media Overlays are generated for narrated playback.
|
|
72
|
+
*/
|
|
73
|
+
declare function docToEpub(doc: Doc, options?: EpubExportOptions): Promise<ArrayBuffer>;
|
|
74
|
+
|
|
75
|
+
export { type EpubExportOptions, docToEpub, markdownDocToEpub };
|
package/dist/epub/index.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* import { markdownDocToEpub, docToEpub } from '@bendyline/squisq-formats/epub';
|
|
13
|
-
*
|
|
14
|
-
* const epub = await markdownDocToEpub(markdownDoc, { title: 'My Book' });
|
|
15
|
-
* const epub2 = await docToEpub(doc, { author: 'Jane Doe' });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export { markdownDocToEpub, docToEpub } from './export.js';
|
|
1
|
+
import {
|
|
2
|
+
docToEpub,
|
|
3
|
+
markdownDocToEpub
|
|
4
|
+
} from "../chunk-ON232HJR.js";
|
|
5
|
+
import "../chunk-PN52A5AA.js";
|
|
6
|
+
import "../chunk-U4MRIFKL.js";
|
|
7
|
+
import "../chunk-A3FHLTY5.js";
|
|
8
|
+
export {
|
|
9
|
+
docToEpub,
|
|
10
|
+
markdownDocToEpub
|
|
11
|
+
};
|
|
19
12
|
//# sourceMappingURL=index.js.map
|
package/dist/epub/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/html/index.d.ts
CHANGED
|
@@ -1,3 +1,312 @@
|
|
|
1
|
+
import { Doc, Theme } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { HtmlPolicy, MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTML Template Generation for SquisqPlayer Exports
|
|
6
|
+
*
|
|
7
|
+
* Generates complete, self-contained HTML documents that load the SquisqPlayer
|
|
8
|
+
* IIFE bundle and render a Doc as either an interactive slideshow or a static
|
|
9
|
+
* scrollable document.
|
|
10
|
+
*
|
|
11
|
+
* Two variants:
|
|
12
|
+
* 1. **Inline** — All JS, CSS, and images are embedded in the HTML (single file).
|
|
13
|
+
* 2. **External** — JS is referenced via `<script src>`, images via relative paths.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface HtmlExportOptions {
|
|
17
|
+
/** The IIFE player bundle source code (from @bendyline/squisq-react/standalone-source) */
|
|
18
|
+
playerScript: string;
|
|
19
|
+
/**
|
|
20
|
+
* Map of relative image paths (as they appear in the Doc) to binary image data.
|
|
21
|
+
* For inline HTML export, these are converted to base64 data URIs.
|
|
22
|
+
* For ZIP export, these are written as separate files.
|
|
23
|
+
*/
|
|
24
|
+
images?: Map<string, ArrayBuffer>;
|
|
25
|
+
/**
|
|
26
|
+
* Map of audio segment identifiers to binary audio data.
|
|
27
|
+
* Keys should match the audio segment `name` or `url` fields in the Doc.
|
|
28
|
+
* Only used in ZIP exports — single HTML uses timer-based playback.
|
|
29
|
+
*/
|
|
30
|
+
audio?: Map<string, ArrayBuffer>;
|
|
31
|
+
/** Rendering mode: 'slideshow' (interactive, default) or 'static' (scrollable) */
|
|
32
|
+
mode?: 'slideshow' | 'static';
|
|
33
|
+
/** HTML page title (default: 'Squisq Document') */
|
|
34
|
+
title?: string;
|
|
35
|
+
/** Auto-play slideshow on load (default: false) */
|
|
36
|
+
autoPlay?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
|
|
39
|
+
* When set, the theme is assigned to the Doc before rendering,
|
|
40
|
+
* so the SquisqPlayer renders with that theme's colors and typography.
|
|
41
|
+
*/
|
|
42
|
+
themeId?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Collect all relative image paths referenced in a Doc's layers and template blocks.
|
|
46
|
+
* Returns a Set of unique relative paths that need to be resolved.
|
|
47
|
+
*/
|
|
48
|
+
declare function collectImagePaths(doc: Doc): Set<string>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Image Utilities for HTML Export
|
|
52
|
+
*
|
|
53
|
+
* Browser-compatible helpers for converting image data to base64 data URIs
|
|
54
|
+
* and inferring MIME types from filenames.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Infer a MIME type from a filename's extension.
|
|
58
|
+
* Returns 'application/octet-stream' for unknown types.
|
|
59
|
+
*/
|
|
60
|
+
declare function inferMimeType(filename: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Convert an ArrayBuffer to a base64-encoded data URI string.
|
|
63
|
+
*
|
|
64
|
+
* @param buffer - The binary image data
|
|
65
|
+
* @param mimeType - MIME type (e.g., 'image/jpeg'). If not provided, defaults to
|
|
66
|
+
* 'application/octet-stream'.
|
|
67
|
+
* @returns A `data:` URI string
|
|
68
|
+
*/
|
|
69
|
+
declare function arrayBufferToBase64DataUrl(buffer: ArrayBuffer, mimeType: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Extract the filename from a path or URL (strips directory and query).
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* extractFilename('images/hero.jpg') // 'hero.jpg'
|
|
75
|
+
* extractFilename('https://example.com/photo.png?v=2') // 'photo.png'
|
|
76
|
+
*/
|
|
77
|
+
declare function extractFilename(path: string): string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Plain HTML Export — semantic, player-free
|
|
81
|
+
*
|
|
82
|
+
* Renders a MarkdownDocument to a self-contained HTML string. Unlike
|
|
83
|
+
* `docToHtml` (which bundles the SquisqPlayer IIFE and renders SVG block
|
|
84
|
+
* cards), this output is what a reader-mode tool would produce: semantic
|
|
85
|
+
* `<h1>`/`<p>`/`<ul>`/etc. with a small embedded stylesheet, no JS, no
|
|
86
|
+
* runtime path-rewriting. Drives both the "Page" preview tab in the
|
|
87
|
+
* editor and the plain-style branch of the export dialog so what users
|
|
88
|
+
* see live matches the file they download.
|
|
89
|
+
*
|
|
90
|
+
* Image URLs default to the markdown's own paths. Pass `images` to
|
|
91
|
+
* substitute a different value per source URL — typically pre-resolved
|
|
92
|
+
* blob URLs (live preview) or data URIs (single-file export).
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
interface PlainHtmlExportOptions {
|
|
96
|
+
/** Document title — populates `<title>` and is HTML-escaped. */
|
|
97
|
+
title?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Substitution map for image `src` URLs. Keys are the URL exactly as
|
|
100
|
+
* it appears in the markdown source; values are the URL to emit in
|
|
101
|
+
* the rendered `<img src>`. URLs not present in the map fall through
|
|
102
|
+
* unchanged (so external `https://…` references still work).
|
|
103
|
+
*/
|
|
104
|
+
images?: Map<string, string>;
|
|
105
|
+
/**
|
|
106
|
+
* Substitution map for anchor `href` URLs. Keys are the URL exactly
|
|
107
|
+
* as it appears in the markdown source (e.g. `'resume.md'`,
|
|
108
|
+
* `'resume.md#experience'`); values are the URL to emit. URLs not in
|
|
109
|
+
* the map pass through unchanged. Used by the recursive bundle
|
|
110
|
+
* exporter to rewrite `.md` references to `.html` so a static export
|
|
111
|
+
* of a linked document tree is internally browsable.
|
|
112
|
+
*/
|
|
113
|
+
links?: Map<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* Optional Squisq theme. When provided, the rendered page uses the
|
|
116
|
+
* theme's colors and typography, and any Google-hosted fonts the
|
|
117
|
+
* theme references are loaded via a `<link>` to fonts.googleapis.com
|
|
118
|
+
* so the face renders correctly without host preloads.
|
|
119
|
+
*
|
|
120
|
+
* When omitted, the function falls back (in order) to {@link themeId}
|
|
121
|
+
* and then to `doc.frontmatter.themeId` — so an authored
|
|
122
|
+
* `themeId: warm-earth` in the doc's frontmatter styles the export
|
|
123
|
+
* automatically, without the caller having to wire theme resolution
|
|
124
|
+
* themselves.
|
|
125
|
+
*/
|
|
126
|
+
theme?: Theme;
|
|
127
|
+
/**
|
|
128
|
+
* Optional theme id (e.g. `'warm-earth'`, `'gezellig'`). Convenient
|
|
129
|
+
* for hosts whose export dialog tracks themes by id — they can pass
|
|
130
|
+
* the id straight through instead of resolving to a `Theme` object.
|
|
131
|
+
* When both `theme` and `themeId` are provided, `theme` wins.
|
|
132
|
+
*/
|
|
133
|
+
themeId?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Optional FontAwesome CSS text to inline into the rendered page,
|
|
136
|
+
* replacing the default cross-origin `<link>` to cdnjs. Required for
|
|
137
|
+
* sandboxed iframe previews where tracking prevention or stricter
|
|
138
|
+
* origin policies can silently drop cross-origin font fetches —
|
|
139
|
+
* inlining keeps the icons resolvable purely from same-origin
|
|
140
|
+
* resources. Hosts typically gather this string by scraping
|
|
141
|
+
* `document.styleSheets` for `@font-face` rules whose family starts
|
|
142
|
+
* with `"Font Awesome"`. The CDN `<link>` is only emitted when this
|
|
143
|
+
* option is not provided.
|
|
144
|
+
*/
|
|
145
|
+
iconsCss?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Raw HTML policy. Defaults to `sanitize`, which removes unsafe tags,
|
|
148
|
+
* event handlers, and executable URL schemes before emitting HTML.
|
|
149
|
+
*/
|
|
150
|
+
htmlPolicy?: HtmlPolicy;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Render a parsed markdown document as a complete, semantic HTML page.
|
|
154
|
+
*
|
|
155
|
+
* When `options.theme` is provided, the output adopts the theme's
|
|
156
|
+
* colors and typography. Google-hosted fonts referenced by the theme
|
|
157
|
+
* are loaded via a single `<link>` to fonts.googleapis.com so the page
|
|
158
|
+
* renders consistently when opened standalone.
|
|
159
|
+
*/
|
|
160
|
+
declare function markdownDocToPlainHtml(doc: MarkdownDocument, options?: PlainHtmlExportOptions): string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Recursive plain-HTML bundle export.
|
|
164
|
+
*
|
|
165
|
+
* `markdownDocsToPlainHtmlBundle` starts from a single entry markdown
|
|
166
|
+
* file, walks its relative `[…](other.md)` links, recursively pulls in
|
|
167
|
+
* any sibling/child documents (scope-limited to the entry doc's
|
|
168
|
+
* directory tree), renders every visited file via
|
|
169
|
+
* `markdownDocToPlainHtml`, rewrites cross-doc references from `.md`
|
|
170
|
+
* to `.html`, and ships everything as a single ZIP.
|
|
171
|
+
*
|
|
172
|
+
* The function is provider-agnostic — callers pass `readDocument` and
|
|
173
|
+
* `readBinary` callbacks that resolve relative paths against whatever
|
|
174
|
+
* storage they use (`FileSystemContentContainer`, `MemoryContent-
|
|
175
|
+
* Container`, in-memory map for tests, …). Failure to read any
|
|
176
|
+
* discovered file aborts the whole export with a thrown error.
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
interface PlainHtmlBundleOptions {
|
|
180
|
+
/** Entry document path relative to the container root (e.g. `'home.md'`). */
|
|
181
|
+
entryPath: string;
|
|
182
|
+
/** Reads a UTF-8 markdown file from the container. Returns null when absent. */
|
|
183
|
+
readDocument: (path: string) => Promise<string | null>;
|
|
184
|
+
/** Reads a binary asset (image) from the container. Returns null when absent. */
|
|
185
|
+
readBinary: (path: string) => Promise<ArrayBuffer | null>;
|
|
186
|
+
/** Optional document title for the entry. Others derive from filename. */
|
|
187
|
+
title?: string;
|
|
188
|
+
/** Optional theme applied uniformly to every page. Overrides {@link themeId}. */
|
|
189
|
+
theme?: Theme;
|
|
190
|
+
/**
|
|
191
|
+
* Optional theme id (e.g. `'warm-earth'`, `'gezellig'`). Resolved via
|
|
192
|
+
* `resolveTheme` and applied to every page. Convenient for callers
|
|
193
|
+
* that track themes by id (like the host export dialog) without
|
|
194
|
+
* having to resolve to a `Theme` object first. When both `theme` and
|
|
195
|
+
* `themeId` are supplied, `theme` wins.
|
|
196
|
+
*/
|
|
197
|
+
themeId?: string;
|
|
198
|
+
/** Maximum recursion depth (default: unlimited; cycles always handled). */
|
|
199
|
+
maxDepth?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Emit the entry doc as `index.html` (preserving its parent directory)
|
|
202
|
+
* instead of `<basename>.html`. Cross-doc links pointing at the entry
|
|
203
|
+
* also rewrite to `index.html`, so a sibling `resume.md → home.md`
|
|
204
|
+
* link doesn't 404 after the rename. Convenient for static-site
|
|
205
|
+
* deploys where the landing page must be named `index.html`.
|
|
206
|
+
* Default: false.
|
|
207
|
+
*/
|
|
208
|
+
entryAsIndex?: boolean;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Render an entry markdown document and every reachable sibling/child
|
|
212
|
+
* `.md` document it links to, bundled as a single ZIP with plain-HTML
|
|
213
|
+
* pages, per-document asset folders, and cross-doc `<a href>`
|
|
214
|
+
* references rewritten from `.md` to `.html`.
|
|
215
|
+
*/
|
|
216
|
+
declare function markdownDocsToPlainHtmlBundle(options: PlainHtmlBundleOptions): Promise<Blob>;
|
|
217
|
+
/**
|
|
218
|
+
* Collect every `<a>`-style link URL referenced in a document. Markdown
|
|
219
|
+
* `link` nodes plus any raw HTML `<a href>` tags. Returns the raw URLs
|
|
220
|
+
* as authored, so callers can use them as both the linkMap *key* and
|
|
221
|
+
* the basis for resolution.
|
|
222
|
+
*/
|
|
223
|
+
declare function collectLinkRefs(doc: MarkdownDocument): Set<string>;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Recursive rendered-HTML bundle export.
|
|
227
|
+
*
|
|
228
|
+
* `markdownDocsToHtmlBundle` is the rendered-pipeline counterpart of
|
|
229
|
+
* `markdownDocsToPlainHtmlBundle`. Starting from a single entry markdown
|
|
230
|
+
* file, it walks every relative `[…](other.md)` link, builds a Doc for
|
|
231
|
+
* each visited page via `markdownToDoc`, rewrites cross-doc link URLs
|
|
232
|
+
* inside the Doc tree from `.md` → relative `.html`, then renders each
|
|
233
|
+
* Doc to a SquisqPlayer-backed HTML page sharing one `squisq-player.js`.
|
|
234
|
+
* Images preserve their authored relative paths so per-doc folders
|
|
235
|
+
* (`resume_files/hero.png`, etc.) sit beside the rendered HTML.
|
|
236
|
+
*
|
|
237
|
+
* The rewrite happens on the Doc, *before* JSON serialization, because
|
|
238
|
+
* the rendered HTML embeds the Doc as JSON and SquisqPlayer emits the
|
|
239
|
+
* `<a href>` at runtime — there is no post-render link rewrite hook in
|
|
240
|
+
* the player path.
|
|
241
|
+
*/
|
|
242
|
+
interface HtmlBundleOptions {
|
|
243
|
+
/** Entry document path relative to the container root (e.g. `'home.md'`). */
|
|
244
|
+
entryPath: string;
|
|
245
|
+
/** Reads a UTF-8 markdown file from the container. Returns null when absent. */
|
|
246
|
+
readDocument: (path: string) => Promise<string | null>;
|
|
247
|
+
/** Reads a binary asset (image) from the container. Returns null when absent. */
|
|
248
|
+
readBinary: (path: string) => Promise<ArrayBuffer | null>;
|
|
249
|
+
/** SquisqPlayer IIFE bundle. Written once as `squisq-player.js` in the zip. */
|
|
250
|
+
playerScript: string;
|
|
251
|
+
/** Optional document title for the entry. Other pages derive from filename. */
|
|
252
|
+
title?: string;
|
|
253
|
+
/** Theme id applied uniformly to every page. */
|
|
254
|
+
themeId?: string;
|
|
255
|
+
/** Rendering mode for every page (default: 'static' — scrollable, link-friendly). */
|
|
256
|
+
mode?: 'slideshow' | 'static';
|
|
257
|
+
/** Maximum recursion depth (default: unlimited; cycles always handled). */
|
|
258
|
+
maxDepth?: number;
|
|
259
|
+
/**
|
|
260
|
+
* Emit the entry doc as `index.html` (preserving its parent directory)
|
|
261
|
+
* instead of `<basename>.html`. Cross-doc links pointing at the entry
|
|
262
|
+
* also rewrite to `index.html`, so a sibling `resume.md → home.md`
|
|
263
|
+
* link doesn't 404 after the rename. Convenient for static-site
|
|
264
|
+
* deploys where the landing page must be named `index.html`.
|
|
265
|
+
* Default: false.
|
|
266
|
+
*/
|
|
267
|
+
entryAsIndex?: boolean;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Render an entry markdown document and every reachable sibling/child
|
|
271
|
+
* `.md` document it links to, bundled as a single ZIP with one rendered
|
|
272
|
+
* HTML page per doc, per-document asset folders, a shared
|
|
273
|
+
* `squisq-player.js`, and cross-doc `<a href>` references rewritten
|
|
274
|
+
* from `.md` to `.html` inside each Doc's serialized AST.
|
|
275
|
+
*/
|
|
276
|
+
declare function markdownDocsToHtmlBundle(options: HtmlBundleOptions): Promise<Blob>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* HTML Import Module — @bendyline/squisq-formats/html
|
|
280
|
+
*
|
|
281
|
+
* Converts an HTML document (or fragment) into a squisq `MarkdownDocument`.
|
|
282
|
+
* Built on the existing `parseHtmlToNodes` (parse5-backed) + `sanitizeHtmlNodes`
|
|
283
|
+
* from `@bendyline/squisq/markdown`, so no new dependency is introduced.
|
|
284
|
+
*
|
|
285
|
+
* The primary consumer is email: HTML mail bodies are hostile input, so the
|
|
286
|
+
* parse is sanitized by default (scripts/styles/event handlers/dangerous URLs
|
|
287
|
+
* stripped) before the tree is walked into markdown nodes.
|
|
288
|
+
*
|
|
289
|
+
* Two entry points mirror the docx/pdf importers:
|
|
290
|
+
* - `htmlToMarkdownDoc(data, options?)` → `MarkdownDocument`
|
|
291
|
+
* - `htmlToMarkdown(html, options?)` → markdown string (convenience for the
|
|
292
|
+
* string-in/string-out path email body conversion needs)
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
interface HtmlImportOptions {
|
|
296
|
+
/**
|
|
297
|
+
* Strip scripts / styles / event handlers / dangerous URLs before walking
|
|
298
|
+
* the tree. Default `true` — HTML email is untrusted; only disable for
|
|
299
|
+
* trusted input where you want raw fidelity.
|
|
300
|
+
*/
|
|
301
|
+
sanitize?: boolean;
|
|
302
|
+
}
|
|
303
|
+
/** Parse HTML into a squisq `MarkdownDocument`. */
|
|
304
|
+
declare function htmlToMarkdownDocSync(html: string, options?: HtmlImportOptions): MarkdownDocument;
|
|
305
|
+
/** Async, ArrayBuffer-accepting entry mirroring docx/pdf importers. */
|
|
306
|
+
declare function htmlToMarkdownDoc(data: ArrayBuffer | Uint8Array | string, options?: HtmlImportOptions): Promise<MarkdownDocument>;
|
|
307
|
+
/** Convenience string→string conversion (used for email HTML bodies). */
|
|
308
|
+
declare function htmlToMarkdown(html: string, options?: HtmlImportOptions): string;
|
|
309
|
+
|
|
1
310
|
/**
|
|
2
311
|
* HTML Export Module — @bendyline/squisq-formats/html
|
|
3
312
|
*
|
|
@@ -28,10 +337,8 @@
|
|
|
28
337
|
* const zipBlob = await docToHtmlZip(doc, { playerScript: PLAYER_BUNDLE, images, audio });
|
|
29
338
|
* ```
|
|
30
339
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export type { HtmlExportOptions };
|
|
34
|
-
export interface HtmlZipExportOptions extends HtmlExportOptions {
|
|
340
|
+
|
|
341
|
+
interface HtmlZipExportOptions extends HtmlExportOptions {
|
|
35
342
|
/**
|
|
36
343
|
* Map of audio segment identifiers to binary audio data.
|
|
37
344
|
* Keys should match the audio segment `name` or `url` fields in the Doc.
|
|
@@ -60,7 +367,7 @@ export interface HtmlZipExportOptions extends HtmlExportOptions {
|
|
|
60
367
|
* const blob = new Blob([html], { type: 'text/html' });
|
|
61
368
|
* ```
|
|
62
369
|
*/
|
|
63
|
-
|
|
370
|
+
declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
|
|
64
371
|
/**
|
|
65
372
|
* Export a Doc as a ZIP archive containing HTML, JS, images, and optionally audio.
|
|
66
373
|
*
|
|
@@ -92,13 +399,6 @@ export declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
|
|
|
92
399
|
* const url = URL.createObjectURL(blob);
|
|
93
400
|
* ```
|
|
94
401
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
export {
|
|
98
|
-
export { markdownDocToPlainHtml } from './plainHtml.js';
|
|
99
|
-
export type { PlainHtmlExportOptions } from './plainHtml.js';
|
|
100
|
-
export { markdownDocsToPlainHtmlBundle, collectLinkRefs } from './plainHtmlBundle.js';
|
|
101
|
-
export type { PlainHtmlBundleOptions } from './plainHtmlBundle.js';
|
|
102
|
-
export { markdownDocsToHtmlBundle } from './docsHtmlBundle.js';
|
|
103
|
-
export type { HtmlBundleOptions } from './docsHtmlBundle.js';
|
|
104
|
-
//# sourceMappingURL=index.d.ts.map
|
|
402
|
+
declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
|
|
403
|
+
|
|
404
|
+
export { type HtmlBundleOptions, type HtmlExportOptions, type HtmlImportOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, arrayBufferToBase64DataUrl, collectImagePaths, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, htmlToMarkdown, htmlToMarkdownDoc, htmlToMarkdownDocSync, inferMimeType, markdownDocToPlainHtml, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
|