@bendyline/squisq-formats 2.8.8 → 2.8.10

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.
Files changed (40) hide show
  1. package/README.md +15 -13
  2. package/dist/chunk-4LIFEQKX.js +358 -0
  3. package/dist/{chunk-UXEANVBI.js → chunk-5HUHSLGA.js} +1 -84
  4. package/dist/{chunk-BXWNU4T5.js → chunk-DTJQK7U7.js} +43 -0
  5. package/dist/{chunk-GDUZJ75A.js → chunk-MJTPWLVV.js} +59 -21
  6. package/dist/{chunk-6ALSRHD7.js → chunk-NCDY3EOL.js} +66 -9
  7. package/dist/{chunk-TMOXUUTG.js → chunk-NQNIFIDP.js} +6 -4
  8. package/dist/{chunk-LK4KCVN6.js → chunk-QPJHAMOW.js} +70 -28
  9. package/dist/{chunk-QU4EVC62.js → chunk-S5VXWSRR.js} +1 -1
  10. package/dist/{chunk-KROH7FNT.js → chunk-VKLJUHC2.js} +6 -4
  11. package/dist/chunk-YRFBWYAD.js +128 -0
  12. package/dist/{chunk-SVYTUYZM.js → chunk-ZJERBWTB.js} +6 -4
  13. package/dist/data/index.d.ts +27 -5
  14. package/dist/data/index.js +6 -2
  15. package/dist/diagrams/index.d.ts +19 -8
  16. package/dist/diagrams/index.js +7 -242
  17. package/dist/docx/index.d.ts +1 -1
  18. package/dist/docx/index.js +3 -3
  19. package/dist/epub/index.d.ts +1 -1
  20. package/dist/epub/index.js +3 -3
  21. package/dist/fontAwesome-C6FRDYTY.js +14 -0
  22. package/dist/html/icons.d.ts +29 -0
  23. package/dist/html/icons.js +62 -0
  24. package/dist/html/index.d.ts +3 -130
  25. package/dist/html/index.js +2 -2
  26. package/dist/html/prepare.d.ts +97 -0
  27. package/dist/html/prepare.js +85 -0
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.js +16 -16
  30. package/dist/{materialize-G4WC5UG3.js → materialize-ICXNO4S4.js} +4 -1
  31. package/dist/outside-in/index.d.ts +12 -0
  32. package/dist/outside-in/index.js +3 -3
  33. package/dist/pdf/index.d.ts +1 -1
  34. package/dist/pdf/index.js +3 -3
  35. package/dist/plainHtml-B6IXcSet.d.ts +148 -0
  36. package/dist/pptx/index.js +2 -2
  37. package/dist/readers-3P5A6A2A.js +17 -0
  38. package/dist/registry/index.js +1 -1
  39. package/package.json +12 -2
  40. /package/dist/{chunk-LBXBRFBZ.js → chunk-DDMPZZJF.js} +0 -0
@@ -0,0 +1,62 @@
1
+ // src/html/plainHtmlIcons.ts
2
+ var fonts = /* @__PURE__ */ new Map();
3
+ function loadFont(family) {
4
+ let font = fonts.get(family);
5
+ if (!font) {
6
+ font = Promise.all([import("@pdf-lib/fontkit"), import("../fontAwesome-C6FRDYTY.js")]).then(
7
+ ([fontkit, { fontAwesomeFace }]) => fontkit.default.create(fontAwesomeFace(family).data)
8
+ );
9
+ font.catch(() => fonts.delete(family));
10
+ fonts.set(family, font);
11
+ }
12
+ return font;
13
+ }
14
+ function usedIcons(doc) {
15
+ const used = /* @__PURE__ */ new Map();
16
+ const visit = (node) => {
17
+ if (!node || typeof node !== "object") return;
18
+ const n = node;
19
+ if (n.type === "inlineIcon" && n.family && n.name) {
20
+ used.set(`${n.family}:${n.name}`, [n.family, n.name]);
21
+ }
22
+ if (Array.isArray(n.children)) n.children.forEach(visit);
23
+ };
24
+ visit(doc);
25
+ return used;
26
+ }
27
+ var round = (n) => Math.round(n * 100) / 100;
28
+ function glyphPath(font, glyph) {
29
+ const y = (value) => round(font.ascent - value);
30
+ const parts = [];
31
+ const sink = {
32
+ moveTo: (x, py) => parts.push(`M${round(x)} ${y(py)}`),
33
+ lineTo: (x, py) => parts.push(`L${round(x)} ${y(py)}`),
34
+ quadraticCurveTo: (cx, cy, x, py) => parts.push(`Q${round(cx)} ${y(cy)} ${round(x)} ${y(py)}`),
35
+ bezierCurveTo: (c1x, c1y, c2x, c2y, x, py) => parts.push(`C${round(c1x)} ${y(c1y)} ${round(c2x)} ${y(c2y)} ${round(x)} ${y(py)}`),
36
+ closePath: () => parts.push("Z")
37
+ };
38
+ glyph.path.toFunction()(sink);
39
+ return parts.join("");
40
+ }
41
+ async function plainHtmlIcons(doc) {
42
+ const icons = /* @__PURE__ */ new Map();
43
+ const used = usedIcons(doc);
44
+ if (used.size === 0) return icons;
45
+ const { fontAwesomeGlyph } = await import("../fontAwesome-C6FRDYTY.js");
46
+ for (const [key, [family, name]] of used) {
47
+ const glyph = fontAwesomeGlyph(family, name);
48
+ if (!glyph) continue;
49
+ const font = await loadFont(family);
50
+ const outline = font.glyphForCodePoint(glyph.codePointAt(0));
51
+ if (!outline || outline.advanceWidth <= 0) continue;
52
+ icons.set(key, {
53
+ width: outline.advanceWidth,
54
+ height: font.unitsPerEm,
55
+ path: glyphPath(font, outline)
56
+ });
57
+ }
58
+ return icons;
59
+ }
60
+ export {
61
+ plainHtmlIcons
62
+ };
@@ -1,7 +1,8 @@
1
1
  import { Theme, ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
2
2
  import { H as HtmlExportOptions } from '../import-ipP4Ghp8.js';
3
3
  export { a as HtmlImportOptions, c as collectImagePaths, g as generateExternalHtml, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from '../import-ipP4Ghp8.js';
4
- import { HtmlPolicy, MarkdownDocument } from '@bendyline/squisq/markdown';
4
+ export { a as PlainHtmlExportOptions, P as PlainHtmlIcon, b as PlainHtmlParts, m as markdownDocToPlainHtml, c as markdownDocToPlainHtmlParts } from '../plainHtml-B6IXcSet.js';
5
+ import { MarkdownDocument } from '@bendyline/squisq/markdown';
5
6
 
6
7
  /**
7
8
  * Image Utilities for HTML Export
@@ -35,134 +36,6 @@ declare function arrayBufferToBase64DataUrl(buffer: ArrayBuffer, mimeType: strin
35
36
  */
36
37
  declare function extractFilename(path: string): string;
37
38
 
38
- /**
39
- * Plain HTML Export — semantic, player-free
40
- *
41
- * Renders a MarkdownDocument to a self-contained HTML string. Unlike
42
- * `docToHtml` (which bundles the SquisqPlayer IIFE and renders SVG block
43
- * cards), this output is what a reader-mode tool would produce: semantic
44
- * `<h1>`/`<p>`/`<ul>`/etc. with a small embedded stylesheet, no JS, no
45
- * runtime path-rewriting. Drives both the "Page" preview tab in the
46
- * editor and the plain-style branch of the export dialog so what users
47
- * see live matches the file they download.
48
- *
49
- * Image URLs default to the markdown's own paths. Pass `images` to
50
- * substitute a different value per source URL — typically pre-resolved
51
- * blob URLs (live preview) or data URIs (single-file export).
52
- */
53
-
54
- interface PlainHtmlExportOptions {
55
- /** Document title — populates `<title>` and is HTML-escaped. */
56
- title?: string;
57
- /**
58
- * Substitution map for image `src` URLs. Keys are the URL exactly as
59
- * it appears in the markdown source; values are the URL to emit in
60
- * the rendered `<img src>`. URLs not present in the map fall through
61
- * unchanged (so external `https://…` references still work).
62
- */
63
- images?: Map<string, string>;
64
- /**
65
- * Substitution map for anchor `href` URLs. Keys are the URL exactly
66
- * as it appears in the markdown source (e.g. `'resume.md'`,
67
- * `'resume.md#experience'`); values are the URL to emit. URLs not in
68
- * the map pass through unchanged. Used by the recursive bundle
69
- * exporter to rewrite `.md` references to `.html` so a static export
70
- * of a linked document tree is internally browsable.
71
- */
72
- links?: Map<string, string>;
73
- /**
74
- * Optional Squisq theme. When provided, the rendered page uses the
75
- * theme's colors and typography, and any Google-hosted fonts the
76
- * theme references are loaded via a `<link>` to fonts.googleapis.com
77
- * so the face renders correctly without host preloads.
78
- *
79
- * When omitted, the function falls back (in order) to {@link themeId}
80
- * and then to `doc.frontmatter.themeId` — so an authored
81
- * `themeId: warm-earth` in the doc's frontmatter styles the export
82
- * automatically, without the caller having to wire theme resolution
83
- * themselves.
84
- */
85
- theme?: Theme;
86
- /**
87
- * Optional theme id (e.g. `'warm-earth'`, `'gezellig'`). Convenient
88
- * for hosts whose export dialog tracks themes by id — they can pass
89
- * the id straight through instead of resolving to a `Theme` object.
90
- * When both `theme` and `themeId` are provided, `theme` wins.
91
- */
92
- themeId?: string;
93
- /** Explicit caller-owned registry for non-document custom themes. */
94
- themeRegistry?: ThemeRegistry;
95
- /**
96
- * Optional FontAwesome CSS text to inline into the rendered page,
97
- * replacing the default cross-origin `<link>` to cdnjs. Required for
98
- * sandboxed iframe previews where tracking prevention or stricter
99
- * origin policies can silently drop cross-origin font fetches —
100
- * inlining keeps the icons resolvable purely from same-origin
101
- * resources. Hosts typically gather this string by scraping
102
- * `document.styleSheets` for `@font-face` rules whose family starts
103
- * with `"Font Awesome"`. A CDN `<link>` is emitted only when this option
104
- * is absent and {@link externalResources} is explicitly `allow`.
105
- */
106
- iconsCss?: string;
107
- /**
108
- * Whether this exporter may add remote font/icon stylesheets. Defaults to
109
- * `deny`, keeping the generated file self-contained. Authored links and
110
- * images are unaffected; bundle exporters are responsible for inlining or
111
- * rewriting those document resources.
112
- */
113
- externalResources?: 'deny' | 'allow';
114
- /**
115
- * Raw HTML policy. Defaults to `sanitize`, which removes unsafe tags,
116
- * event handlers, and executable URL schemes before emitting HTML.
117
- */
118
- htmlPolicy?: HtmlPolicy;
119
- /**
120
- * How a hosted video (a paragraph that is only a link to a YouTube, Vimeo,
121
- * Loom or Wistia page, or that provider's `<iframe>` embed
122
- * code) renders:
123
- *
124
- * - `player` (default) — the provider's player iframe;
125
- * - `poster` — a static card linking to the video's page (the provider's
126
- * thumbnail where it serves one). For contexts where a player cannot run:
127
- * a preview iframe sandboxed without `allow-scripts` (nested frames
128
- * inherit the sandbox, so the player would load broken), or print.
129
- */
130
- videoEmbeds?: 'player' | 'poster';
131
- }
132
- /**
133
- * Render a parsed markdown document as a complete, semantic HTML page.
134
- *
135
- * When `options.theme` is provided, the output adopts the theme's
136
- * colors and typography. Google-hosted fonts referenced by the theme
137
- * are loaded via a single `<link>` to fonts.googleapis.com so the page
138
- * renders consistently when opened standalone.
139
- */
140
- declare function markdownDocToPlainHtml(doc: MarkdownDocument, options?: PlainHtmlExportOptions): string;
141
- /**
142
- * The pieces of a plain HTML page that belong to the document itself, for a
143
- * host that places the document inside a page of its own (see
144
- * `applyHtmlPageTemplate`).
145
- */
146
- interface PlainHtmlParts {
147
- /** The `title` option, unescaped. */
148
- title: string;
149
- /** The rendered document body, footnotes included. */
150
- bodyHtml: string;
151
- /**
152
- * `<head>` markup for the CSS the body's own constructs need — feature
153
- * sections, video embeds, SVG islands, icons — and nothing that styles the
154
- * page around them: no theme typography, colors, fonts, or `body` rules.
155
- */
156
- featureHeadHtml: string;
157
- }
158
- /**
159
- * Render a document's body and the functional CSS it depends on, without the
160
- * page shell or theme stylesheet `markdownDocToPlainHtml` wraps around them.
161
- * The theme (when one resolves) still informs body rendering, such as the
162
- * color an SVG island's `currentColor` follows.
163
- */
164
- declare function markdownDocToPlainHtmlParts(doc: MarkdownDocument, options?: PlainHtmlExportOptions): PlainHtmlParts;
165
-
166
39
  /**
167
40
  * HTML Page Templates
168
41
  *
@@ -477,4 +350,4 @@ declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
477
350
  */
478
351
  declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
479
352
 
480
- export { HTML_PAGE_TEMPLATE_CONTENT_END, HTML_PAGE_TEMPLATE_CONTENT_START, type HtmlBundleOptions, HtmlExportOptions, type HtmlPageTemplateContent, HtmlPageTemplateError, type HtmlPageTemplateInspection, type HtmlPageTemplateIssue, type HtmlPageTemplateOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, type PlainHtmlParts, applyHtmlPageTemplate, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, extractHtmlPageTemplateContent, inferMimeType, inspectHtmlPageTemplate, isHtmlPageTemplate, markdownDocToPlainHtml, markdownDocToPlainHtmlParts, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
353
+ export { HTML_PAGE_TEMPLATE_CONTENT_END, HTML_PAGE_TEMPLATE_CONTENT_START, type HtmlBundleOptions, HtmlExportOptions, type HtmlPageTemplateContent, HtmlPageTemplateError, type HtmlPageTemplateInspection, type HtmlPageTemplateIssue, type HtmlPageTemplateOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, applyHtmlPageTemplate, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, extractHtmlPageTemplateContent, inferMimeType, inspectHtmlPageTemplate, isHtmlPageTemplate, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
@@ -18,14 +18,14 @@ import {
18
18
  markdownDocToPlainHtmlParts,
19
19
  markdownDocsToHtmlBundle,
20
20
  markdownDocsToPlainHtmlBundle
21
- } from "../chunk-LK4KCVN6.js";
21
+ } from "../chunk-QPJHAMOW.js";
22
22
  import {
23
23
  arrayBufferToBase64DataUrl,
24
24
  extractFilename,
25
25
  inferMimeType
26
26
  } from "../chunk-WMIDXNGR.js";
27
27
  import "../chunk-VCZUXQUL.js";
28
- import "../chunk-BXWNU4T5.js";
28
+ import "../chunk-DTJQK7U7.js";
29
29
  import "../chunk-JZR32FON.js";
30
30
  export {
31
31
  HTML_PAGE_TEMPLATE_CONTENT_END,
@@ -0,0 +1,97 @@
1
+ import { MarkdownDocument } from '@bendyline/squisq/markdown';
2
+ import { DataSourceTable } from '@bendyline/squisq/doc';
3
+ import { ContentContainer } from '@bendyline/squisq/storage';
4
+ import { DiagramRasterizer } from '../diagrams/index.js';
5
+ import { P as PlainHtmlIcon } from '../plainHtml-B6IXcSet.js';
6
+ import '@bendyline/squisq/schemas';
7
+
8
+ /**
9
+ * Preparing a document for a static HTML page.
10
+ *
11
+ * A plain HTML page (`markdownDocToPlainHtml`, or a page template filled from
12
+ * `markdownDocToPlainHtmlParts`) runs no script, so what the player draws at
13
+ * runtime has to be settled before the page is written:
14
+ *
15
+ * - `{[dataTable src=…]}` references (and charts fed by one) get the table
16
+ * they point at, bounded to a preview window with a "Showing N of M rows"
17
+ * note — the author's body link to the full file follows it;
18
+ * - Mermaid fences, ASCII diagrams and timelines, drawing / layout / diagram
19
+ * blocks, and charts become pictures, drawn by a host-supplied renderer
20
+ * (drawing needs a browser) and returned as `data:` URLs;
21
+ * - inline icons become inline SVG outlines, drawn by a host-supplied
22
+ * outliner (`plainHtmlIcons` from `@bendyline/squisq-formats/html-icons`),
23
+ * so the page needs no Font Awesome stylesheet or font.
24
+ *
25
+ * File trees stay preformatted text, which a page shows as well as a picture
26
+ * would and keeps selectable; SVG islands the renderer already draws.
27
+ *
28
+ * This module is its own entry, `@bendyline/squisq-formats/html-prepare`, and
29
+ * nothing under `/html` imports it. A bundler that writes one file inlines
30
+ * every dynamic import it can reach, and filling data tables reaches the XLSX
31
+ * reader (an XML parser and zip code, ~300 KB) that a host only rendering
32
+ * plain HTML — say, an editor-extension host — must not carry. Both drawing
33
+ * steps are the host's to pass in for the same reason: the icon outlines alone
34
+ * (Font Awesome's faces and their parser) are ~2.5 MB.
35
+ */
36
+
37
+ /**
38
+ * Outlines the inline icons `doc` uses, keyed `family:name` — the renderer's
39
+ * `icons` option. `plainHtmlIcons` from `@bendyline/squisq-formats/html-icons`
40
+ * is one.
41
+ */
42
+ type PlainHtmlIconOutliner = (doc: MarkdownDocument) => Promise<Map<string, PlainHtmlIcon>>;
43
+ interface PlainHtmlPreparationOptions {
44
+ /**
45
+ * Draws diagrams and charts as pictures. In a browser, pass
46
+ * `createDiagramPictureRenderer()` from
47
+ * `@bendyline/squisq-react/diagram-pictures`. Without one, diagrams stay as
48
+ * their source and charts as their table.
49
+ */
50
+ renderDiagram?: DiagramRasterizer;
51
+ /**
52
+ * Draws inline icons as SVG outlines. Pass `plainHtmlIcons` from
53
+ * `@bendyline/squisq-formats/html-icons`; it needs no browser. Without one,
54
+ * icons keep their Font Awesome markup.
55
+ */
56
+ outlineIcons?: PlainHtmlIconOutliner;
57
+ /**
58
+ * The container holding the document's data sidecars. Without one, a data
59
+ * reference keeps only its link.
60
+ */
61
+ container?: ContentContainer | null;
62
+ /** Rows per data table; a block's own `previewRows` wins. Default 100. */
63
+ maxDataRows?: number;
64
+ /**
65
+ * A caller-owned memo of data-file reads, for a host that prepares the
66
+ * same document again and again (a live preview). The caller clears it
67
+ * when the files may have changed.
68
+ */
69
+ dataTableCache?: Map<string, Promise<DataSourceTable>>;
70
+ signal?: AbortSignal;
71
+ /** Receives a note for each table or picture that could not be produced. */
72
+ onWarning?: (message: string) => void;
73
+ }
74
+ interface PreparedPlainHtmlDocument {
75
+ /** The document to render, with data tables filled in and pictures in place. */
76
+ markdownDoc: MarkdownDocument;
77
+ /**
78
+ * The pictures as `data:` URLs, keyed by the image URL written into
79
+ * `markdownDoc`. Merge them into the renderer's `images` option.
80
+ */
81
+ images: Map<string, string>;
82
+ /** Outlines of the document's inline icons: the renderer's `icons` option. */
83
+ icons: Map<string, PlainHtmlIcon>;
84
+ }
85
+ /**
86
+ * Whether {@link prepareMarkdownDocForPlainHtml} would change anything for
87
+ * `doc` with these options — so a live preview renders a document with
88
+ * nothing to prepare at once, without waiting on the asynchronous step.
89
+ */
90
+ declare function needsPlainHtmlPreparation(doc: MarkdownDocument, options?: Pick<PlainHtmlPreparationOptions, 'renderDiagram' | 'outlineIcons' | 'container'>): boolean;
91
+ /**
92
+ * Settle everything in `doc` a script-free page cannot draw. Never throws for
93
+ * one table or picture: each degrades to its link or source with a warning.
94
+ */
95
+ declare function prepareMarkdownDocForPlainHtml(doc: MarkdownDocument, options?: PlainHtmlPreparationOptions): Promise<PreparedPlainHtmlDocument>;
96
+
97
+ export { type PlainHtmlIconOutliner, type PlainHtmlPreparationOptions, type PreparedPlainHtmlDocument, needsPlainHtmlPreparation, prepareMarkdownDocForPlainHtml };
@@ -0,0 +1,85 @@
1
+ import {
2
+ findDiagrams,
3
+ rasterizeDiagrams
4
+ } from "../chunk-4LIFEQKX.js";
5
+ import {
6
+ arrayBufferToBase64DataUrl
7
+ } from "../chunk-WMIDXNGR.js";
8
+ import "../chunk-JZR32FON.js";
9
+
10
+ // src/html/plainHtmlPrepare.ts
11
+ import { isDataFilePath } from "@bendyline/squisq/doc";
12
+ var PAGE_DIAGRAM_KINDS = [
13
+ "mermaid",
14
+ "diagram",
15
+ "timeline",
16
+ "container",
17
+ "chart"
18
+ ];
19
+ function needsPlainHtmlPreparation(doc, options = {}) {
20
+ let icons = false;
21
+ let data = false;
22
+ const visit = (node) => {
23
+ if (!node || typeof node !== "object" || icons && data) return;
24
+ const n = node;
25
+ if (n.type === "inlineIcon") icons = true;
26
+ if (n.type === "heading") {
27
+ const src = n.templateAnnotation?.params?.src;
28
+ if (src && isDataFilePath(src)) data = true;
29
+ }
30
+ if (Array.isArray(n.children)) n.children.forEach(visit);
31
+ };
32
+ doc.children.forEach(visit);
33
+ if (icons && options.outlineIcons || data && options.container) return true;
34
+ if (!options.renderDiagram) return false;
35
+ return findDiagrams(doc).some((diagram) => PAGE_DIAGRAM_KINDS.includes(diagram.kind));
36
+ }
37
+ async function prepareMarkdownDocForPlainHtml(doc, options = {}) {
38
+ const { renderDiagram, outlineIcons, container, signal, onWarning } = options;
39
+ let markdownDoc = doc;
40
+ if (container) {
41
+ const { materializeDataReferences, DATA_PREVIEW_ROWS } = await import("../materialize-ICXNO4S4.js");
42
+ markdownDoc = await materializeDataReferences(markdownDoc, container, onWarning, {
43
+ maxRows: options.maxDataRows ?? DATA_PREVIEW_ROWS,
44
+ tableCache: options.dataTableCache
45
+ });
46
+ }
47
+ signal?.throwIfAborted();
48
+ const icons = outlineIcons ? await outlineIcons(markdownDoc) : /* @__PURE__ */ new Map();
49
+ const images = /* @__PURE__ */ new Map();
50
+ if (!renderDiagram) return { markdownDoc, images, icons };
51
+ const pictured = await rasterizeDiagrams(markdownDoc, renderDiagram, {
52
+ kinds: PAGE_DIAGRAM_KINDS,
53
+ urlPrefix: "squisq-picture",
54
+ signal,
55
+ onWarning
56
+ });
57
+ const widths = /* @__PURE__ */ new Map();
58
+ for (const [url, picture] of pictured.images) {
59
+ const bytes = picture.data;
60
+ const buffer = bytes.buffer.slice(
61
+ bytes.byteOffset,
62
+ bytes.byteOffset + bytes.byteLength
63
+ );
64
+ images.set(url, arrayBufferToBase64DataUrl(buffer, picture.contentType));
65
+ widths.set(url, Math.round(picture.width));
66
+ }
67
+ return { markdownDoc: withPictureWidths(pictured.markdownDoc, widths), images, icons };
68
+ }
69
+ function withPictureWidths(doc, widths) {
70
+ if (widths.size === 0) return doc;
71
+ const visit = (node) => {
72
+ if (node.type === "image") {
73
+ const width = widths.get(node.url);
74
+ return width === void 0 ? node : { ...node, width };
75
+ }
76
+ const children = node.children;
77
+ if (!Array.isArray(children)) return node;
78
+ return { ...node, children: children.map(visit) };
79
+ };
80
+ return { ...doc, children: doc.children.map(visit) };
81
+ }
82
+ export {
83
+ needsPlainHtmlPreparation,
84
+ prepareMarkdownDocForPlainHtml
85
+ };
package/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ import '@bendyline/squisq/markdown';
19
19
  import './reader-B_m1aKZC.js';
20
20
  import '@bendyline/squisq/storage';
21
21
  import './layouts-CTdPlB-u.js';
22
+ import './plainHtml-B6IXcSet.js';
22
23
  import './themeReader-DCtwC83Q.js';
23
24
  import '@bendyline/squisq/transform';
24
25
  import './container/index.js';
26
+ import './diagrams/index.js';
package/dist/index.js CHANGED
@@ -5,11 +5,11 @@ import {
5
5
  htmlToMarkdown,
6
6
  htmlToMarkdownDoc,
7
7
  htmlToMarkdownDocSync
8
- } from "./chunk-LK4KCVN6.js";
8
+ } from "./chunk-QPJHAMOW.js";
9
9
  import {
10
10
  docToEpub,
11
11
  markdownDocToEpub
12
- } from "./chunk-SVYTUYZM.js";
12
+ } from "./chunk-ZJERBWTB.js";
13
13
  import {
14
14
  BUILTIN_FORMAT_IDS
15
15
  } from "./chunk-2P5HJAQL.js";
@@ -29,7 +29,14 @@ import {
29
29
  renderOutsideInDocument,
30
30
  withOutsideInMarkdownEditing,
31
31
  withOutsideInMetadata
32
- } from "./chunk-6ALSRHD7.js";
32
+ } from "./chunk-NCDY3EOL.js";
33
+ import {
34
+ OUTSIDE_IN_FORMAT_IDS,
35
+ OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
36
+ chooseOutsideInMarkdownPath,
37
+ isOutsideInTargetPath,
38
+ resolveOutsideInLayout
39
+ } from "./chunk-WJTC5OD6.js";
33
40
  import {
34
41
  DEFAULT_CONVERSION_LIMITS,
35
42
  convert,
@@ -38,29 +45,22 @@ import {
38
45
  defaultRegistry,
39
46
  prepareConversion,
40
47
  resolveConversionLimits
41
- } from "./chunk-GDUZJ75A.js";
48
+ } from "./chunk-MJTPWLVV.js";
42
49
  import {
43
50
  ConversionError
44
51
  } from "./chunk-KXOZMWBS.js";
45
- import {
46
- OUTSIDE_IN_FORMAT_IDS,
47
- OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
48
- chooseOutsideInMarkdownPath,
49
- isOutsideInTargetPath,
50
- resolveOutsideInLayout
51
- } from "./chunk-WJTC5OD6.js";
52
52
  import {
53
53
  docToDocx,
54
54
  docxToDoc,
55
55
  docxToMarkdownDoc,
56
56
  markdownDocToDocx
57
- } from "./chunk-KROH7FNT.js";
57
+ } from "./chunk-VKLJUHC2.js";
58
58
  import {
59
59
  docToPptx,
60
60
  markdownDocToPptx,
61
61
  pptxToDoc,
62
62
  pptxToMarkdownDoc
63
- } from "./chunk-QU4EVC62.js";
63
+ } from "./chunk-S5VXWSRR.js";
64
64
  import "./chunk-6N2J7C2B.js";
65
65
  import "./chunk-WMIDXNGR.js";
66
66
  import "./chunk-DHAK4PII.js";
@@ -96,11 +96,11 @@ import {
96
96
  markdownDocToPdf,
97
97
  pdfToDoc,
98
98
  pdfToMarkdownDoc
99
- } from "./chunk-TMOXUUTG.js";
99
+ } from "./chunk-NQNIFIDP.js";
100
100
  import "./chunk-34KECNZO.js";
101
- import "./chunk-BXWNU4T5.js";
101
+ import "./chunk-DTJQK7U7.js";
102
102
  import "./chunk-IIQYS2YH.js";
103
- import "./chunk-LBXBRFBZ.js";
103
+ import "./chunk-DDMPZZJF.js";
104
104
  import "./chunk-JZR32FON.js";
105
105
  export {
106
106
  BUILTIN_FORMAT_IDS,
@@ -1,11 +1,14 @@
1
1
  import {
2
+ DATA_PREVIEW_ROWS,
2
3
  materializeDataReferences
3
- } from "./chunk-UXEANVBI.js";
4
+ } from "./chunk-YRFBWYAD.js";
5
+ import "./chunk-5HUHSLGA.js";
4
6
  import "./chunk-ATWVNF7D.js";
5
7
  import "./chunk-Q77KNJIN.js";
6
8
  import "./chunk-DXYWKZ52.js";
7
9
  import "./chunk-S5PCVMKU.js";
8
10
  import "./chunk-7AWFHP5U.js";
9
11
  export {
12
+ DATA_PREVIEW_ROWS,
10
13
  materializeDataReferences
11
14
  };
@@ -1,6 +1,7 @@
1
1
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
2
2
  import { ContentContainer } from '@bendyline/squisq/storage';
3
3
  import { c as ConvertOptions, b as ConversionResult } from '../types-CVv9eldp.js';
4
+ import { DiagramRasterizer } from '../diagrams/index.js';
4
5
  import { OutsideInLayout, OutsideInFormatId } from './layout.js';
5
6
  export { OUTSIDE_IN_FORMAT_IDS, OUTSIDE_IN_OUTPUT_TEMPLATE_KEY, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout } from './layout.js';
6
7
  import '@bendyline/squisq/schemas';
@@ -58,6 +59,17 @@ interface RenderOutsideInOptions extends ConvertOptions {
58
59
  /** URL from the rendered HTML file to its companion media folder. */
59
60
  basePath?: string;
60
61
  };
62
+ /**
63
+ * Draws diagrams as pictures for the targets that cannot draw them: Word
64
+ * and PDF get pictures in place of Mermaid, ASCII diagrams, timelines, file
65
+ * trees, drawings, and layouts (PDF also of SVG islands, which Word embeds
66
+ * as vector art over the picture); PowerPoint, whose own shapes draw the
67
+ * rest, gets pictures of Mermaid and of SVG islands. In a browser, pass
68
+ * `createDiagramPictureRenderer()` from
69
+ * `@bendyline/squisq-react/diagram-pictures`. Without one those diagrams
70
+ * render as their source text. HTML targets draw their own.
71
+ */
72
+ renderDiagram?: DiagramRasterizer;
61
73
  }
62
74
  /** Read outside-in metadata without interpreting the output path as authority. */
63
75
  declare function readOutsideInMetadata(source: string): OutsideInMetadata | null;
@@ -7,9 +7,7 @@ import {
7
7
  renderOutsideInDocument,
8
8
  withOutsideInMarkdownEditing,
9
9
  withOutsideInMetadata
10
- } from "../chunk-6ALSRHD7.js";
11
- import "../chunk-GDUZJ75A.js";
12
- import "../chunk-KXOZMWBS.js";
10
+ } from "../chunk-NCDY3EOL.js";
13
11
  import {
14
12
  OUTSIDE_IN_FORMAT_IDS,
15
13
  OUTSIDE_IN_OUTPUT_TEMPLATE_KEY,
@@ -17,6 +15,8 @@ import {
17
15
  isOutsideInTargetPath,
18
16
  resolveOutsideInLayout
19
17
  } from "../chunk-WJTC5OD6.js";
18
+ import "../chunk-MJTPWLVV.js";
19
+ import "../chunk-KXOZMWBS.js";
20
20
  import "../chunk-7AWFHP5U.js";
21
21
  export {
22
22
  OUTSIDE_IN_FORMAT_IDS,
@@ -116,7 +116,7 @@ interface PdfExportOptions {
116
116
  /**
117
117
  * Convert a MarkdownDocument to a PDF ArrayBuffer.
118
118
  */
119
- declare function markdownDocToPdf(doc: MarkdownDocument, options?: PdfExportOptions): Promise<ArrayBuffer>;
119
+ declare function markdownDocToPdf(source: MarkdownDocument, options?: PdfExportOptions): Promise<ArrayBuffer>;
120
120
  /**
121
121
  * Convert a squisq Doc to a PDF ArrayBuffer.
122
122
  *
package/dist/pdf/index.js CHANGED
@@ -5,11 +5,11 @@ import {
5
5
  pdfToContainer,
6
6
  pdfToDoc,
7
7
  pdfToMarkdownDoc
8
- } from "../chunk-TMOXUUTG.js";
8
+ } from "../chunk-NQNIFIDP.js";
9
9
  import "../chunk-34KECNZO.js";
10
- import "../chunk-BXWNU4T5.js";
10
+ import "../chunk-DTJQK7U7.js";
11
11
  import "../chunk-IIQYS2YH.js";
12
- import "../chunk-LBXBRFBZ.js";
12
+ import "../chunk-DDMPZZJF.js";
13
13
  import "../chunk-JZR32FON.js";
14
14
  export {
15
15
  configurePdfWorker,