js.documents 1.91.6 → 1.91.7
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/convert/convert.cjs +30 -7
- package/dist/convert/convert.js +30 -7
- package/dist/layout/engine.cjs +4 -5
- package/dist/layout/engine.d.cts +2 -1
- package/dist/layout/engine.d.ts +2 -1
- package/dist/layout/engine.js +4 -5
- package/dist/layout/shared.cjs +2 -2
- package/dist/layout/shared.d.cts +2 -2
- package/dist/layout/shared.d.ts +2 -2
- package/dist/layout/shared.js +3 -3
- package/dist/layout/sheets.cjs +6 -7
- package/dist/layout/sheets.d.cts +2 -1
- package/dist/layout/sheets.d.ts +2 -1
- package/dist/layout/sheets.js +6 -7
- package/dist/layout/slides.cjs +6 -6
- package/dist/layout/slides.d.cts +3 -1
- package/dist/layout/slides.d.ts +3 -1
- package/dist/layout/slides.js +6 -6
- package/package.json +1 -1
package/dist/convert/convert.cjs
CHANGED
|
@@ -34,6 +34,7 @@ let document_schema_js = require("document-schema.js");
|
|
|
34
34
|
let odf_js = require("odf.js");
|
|
35
35
|
let pdf_codec = require("pdf-codec");
|
|
36
36
|
//#region src/convert/convert.ts
|
|
37
|
+
const mathMetricsAt = (sizePt) => (0, pdf_codec.loadMathFont)().metricsAt(sizePt);
|
|
37
38
|
function docxToPdf(bytes, options) {
|
|
38
39
|
const pkg = require_edit_docx_editor.openDocx(bytes).toPackage();
|
|
39
40
|
const content = require_ooxml_docx_read.readDocxContent(pkg, { onMathDiagnostic: options?.onMathDiagnostic });
|
|
@@ -42,7 +43,10 @@ function docxToPdf(bytes, options) {
|
|
|
42
43
|
kind: "docx",
|
|
43
44
|
package: pkg
|
|
44
45
|
}, options);
|
|
45
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
46
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
47
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
48
|
+
mathMetricsAt
|
|
49
|
+
});
|
|
46
50
|
options?.onDocument?.({
|
|
47
51
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
48
52
|
content,
|
|
@@ -63,7 +67,10 @@ function odtToPdf(bytes, options) {
|
|
|
63
67
|
kind: "odf",
|
|
64
68
|
package: pkg
|
|
65
69
|
}, options);
|
|
66
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
70
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
71
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
72
|
+
mathMetricsAt
|
|
73
|
+
});
|
|
67
74
|
options?.onDocument?.({
|
|
68
75
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
69
76
|
content,
|
|
@@ -84,7 +91,10 @@ function pptxToPdf(bytes, options) {
|
|
|
84
91
|
kind: "pptx",
|
|
85
92
|
package: pkg
|
|
86
93
|
}, options);
|
|
87
|
-
const { document: layout, formulas } = require_layout_slides.convertPresentationToLayout(content, {
|
|
94
|
+
const { document: layout, formulas } = require_layout_slides.convertPresentationToLayout(content, {
|
|
95
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
96
|
+
mathMetricsAt
|
|
97
|
+
});
|
|
88
98
|
options?.onDocument?.({
|
|
89
99
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
90
100
|
content,
|
|
@@ -105,7 +115,10 @@ function odpToPdf(bytes, options) {
|
|
|
105
115
|
kind: "odf",
|
|
106
116
|
package: pkg
|
|
107
117
|
}, options);
|
|
108
|
-
const { document: layout, formulas } = require_layout_slides.convertPresentationToLayout(content, {
|
|
118
|
+
const { document: layout, formulas } = require_layout_slides.convertPresentationToLayout(content, {
|
|
119
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
120
|
+
mathMetricsAt
|
|
121
|
+
});
|
|
109
122
|
options?.onDocument?.({
|
|
110
123
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
111
124
|
content,
|
|
@@ -128,6 +141,7 @@ function odsToPdf(bytes, options) {
|
|
|
128
141
|
}, options);
|
|
129
142
|
const { document: layout, formulas } = require_layout_sheets.convertSpreadsheetToLayout(content, {
|
|
130
143
|
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
144
|
+
mathMetricsAt,
|
|
131
145
|
signal: options?.signal
|
|
132
146
|
});
|
|
133
147
|
options?.onDocument?.({
|
|
@@ -174,7 +188,10 @@ function markdownToPdf(bytes, options) {
|
|
|
174
188
|
fonts: options?.fonts,
|
|
175
189
|
onSubstitution: options?.onFontSubstitution
|
|
176
190
|
});
|
|
177
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
191
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
192
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
193
|
+
mathMetricsAt
|
|
194
|
+
});
|
|
178
195
|
options?.onDocument?.({
|
|
179
196
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
180
197
|
content,
|
|
@@ -562,7 +579,10 @@ function odmToPdf(bytes, options) {
|
|
|
562
579
|
fonts: options?.fonts,
|
|
563
580
|
onSubstitution: options?.onFontSubstitution
|
|
564
581
|
});
|
|
565
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
582
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
583
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
584
|
+
mathMetricsAt
|
|
585
|
+
});
|
|
566
586
|
return (0, pdf_codec.writePdf)(layout, {
|
|
567
587
|
signal: options?.signal,
|
|
568
588
|
onSubstitution: options?.onSubstitution,
|
|
@@ -600,7 +620,10 @@ function odbReportToPdf(content, options) {
|
|
|
600
620
|
fonts: options?.fonts,
|
|
601
621
|
onSubstitution: options?.onFontSubstitution
|
|
602
622
|
});
|
|
603
|
-
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
623
|
+
const { document: layout, formulas } = require_layout_engine.convertWordprocessingToLayout(content, {
|
|
624
|
+
measurer: (0, pdf_codec.createFontMeasurer)(fonts),
|
|
625
|
+
mathMetricsAt
|
|
626
|
+
});
|
|
604
627
|
options?.onDocument?.({
|
|
605
628
|
formatVersion: document_schema_js.DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
606
629
|
content,
|
package/dist/convert/convert.js
CHANGED
|
@@ -33,6 +33,7 @@ import { COLOR_BLACK, CONTENT_FORMAT_VERSION, DOCUMENT_PACKAGE_FORMAT_VERSION, L
|
|
|
33
33
|
import { decodePackage as decodePackage$1, encodePackage as encodePackage$1, readOdfMetadata, readOdfParagraph, readOdfTable, readOdm } from "odf.js";
|
|
34
34
|
import { createFontMeasurer, createFontRegistry, loadMathFont, readPdf, writePdf } from "pdf-codec";
|
|
35
35
|
//#region src/convert/convert.ts
|
|
36
|
+
const mathMetricsAt = (sizePt) => loadMathFont().metricsAt(sizePt);
|
|
36
37
|
function docxToPdf(bytes, options) {
|
|
37
38
|
const pkg = openDocx(bytes).toPackage();
|
|
38
39
|
const content = readDocxContent(pkg, { onMathDiagnostic: options?.onMathDiagnostic });
|
|
@@ -41,7 +42,10 @@ function docxToPdf(bytes, options) {
|
|
|
41
42
|
kind: "docx",
|
|
42
43
|
package: pkg
|
|
43
44
|
}, options);
|
|
44
|
-
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
45
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
46
|
+
measurer: createFontMeasurer(fonts),
|
|
47
|
+
mathMetricsAt
|
|
48
|
+
});
|
|
45
49
|
options?.onDocument?.({
|
|
46
50
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
47
51
|
content,
|
|
@@ -62,7 +66,10 @@ function odtToPdf(bytes, options) {
|
|
|
62
66
|
kind: "odf",
|
|
63
67
|
package: pkg
|
|
64
68
|
}, options);
|
|
65
|
-
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
69
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
70
|
+
measurer: createFontMeasurer(fonts),
|
|
71
|
+
mathMetricsAt
|
|
72
|
+
});
|
|
66
73
|
options?.onDocument?.({
|
|
67
74
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
68
75
|
content,
|
|
@@ -83,7 +90,10 @@ function pptxToPdf(bytes, options) {
|
|
|
83
90
|
kind: "pptx",
|
|
84
91
|
package: pkg
|
|
85
92
|
}, options);
|
|
86
|
-
const { document: layout, formulas } = convertPresentationToLayout(content, {
|
|
93
|
+
const { document: layout, formulas } = convertPresentationToLayout(content, {
|
|
94
|
+
measurer: createFontMeasurer(fonts),
|
|
95
|
+
mathMetricsAt
|
|
96
|
+
});
|
|
87
97
|
options?.onDocument?.({
|
|
88
98
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
89
99
|
content,
|
|
@@ -104,7 +114,10 @@ function odpToPdf(bytes, options) {
|
|
|
104
114
|
kind: "odf",
|
|
105
115
|
package: pkg
|
|
106
116
|
}, options);
|
|
107
|
-
const { document: layout, formulas } = convertPresentationToLayout(content, {
|
|
117
|
+
const { document: layout, formulas } = convertPresentationToLayout(content, {
|
|
118
|
+
measurer: createFontMeasurer(fonts),
|
|
119
|
+
mathMetricsAt
|
|
120
|
+
});
|
|
108
121
|
options?.onDocument?.({
|
|
109
122
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
110
123
|
content,
|
|
@@ -127,6 +140,7 @@ function odsToPdf(bytes, options) {
|
|
|
127
140
|
}, options);
|
|
128
141
|
const { document: layout, formulas } = convertSpreadsheetToLayout(content, {
|
|
129
142
|
measurer: createFontMeasurer(fonts),
|
|
143
|
+
mathMetricsAt,
|
|
130
144
|
signal: options?.signal
|
|
131
145
|
});
|
|
132
146
|
options?.onDocument?.({
|
|
@@ -173,7 +187,10 @@ function markdownToPdf(bytes, options) {
|
|
|
173
187
|
fonts: options?.fonts,
|
|
174
188
|
onSubstitution: options?.onFontSubstitution
|
|
175
189
|
});
|
|
176
|
-
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
190
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
191
|
+
measurer: createFontMeasurer(fonts),
|
|
192
|
+
mathMetricsAt
|
|
193
|
+
});
|
|
177
194
|
options?.onDocument?.({
|
|
178
195
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
179
196
|
content,
|
|
@@ -561,7 +578,10 @@ function odmToPdf(bytes, options) {
|
|
|
561
578
|
fonts: options?.fonts,
|
|
562
579
|
onSubstitution: options?.onFontSubstitution
|
|
563
580
|
});
|
|
564
|
-
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
581
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
582
|
+
measurer: createFontMeasurer(fonts),
|
|
583
|
+
mathMetricsAt
|
|
584
|
+
});
|
|
565
585
|
return writePdf(layout, {
|
|
566
586
|
signal: options?.signal,
|
|
567
587
|
onSubstitution: options?.onSubstitution,
|
|
@@ -599,7 +619,10 @@ function odbReportToPdf(content, options) {
|
|
|
599
619
|
fonts: options?.fonts,
|
|
600
620
|
onSubstitution: options?.onFontSubstitution
|
|
601
621
|
});
|
|
602
|
-
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
622
|
+
const { document: layout, formulas } = convertWordprocessingToLayout(content, {
|
|
623
|
+
measurer: createFontMeasurer(fonts),
|
|
624
|
+
mathMetricsAt
|
|
625
|
+
});
|
|
603
626
|
options?.onDocument?.({
|
|
604
627
|
formatVersion: DOCUMENT_PACKAGE_FORMAT_VERSION,
|
|
605
628
|
content,
|
package/dist/layout/engine.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require_mathml_layout = require("../mathml/layout.cjs");
|
|
|
5
5
|
const require_layout_text_layout = require("./text-layout.cjs");
|
|
6
6
|
const require_layout_shared = require("./shared.cjs");
|
|
7
7
|
let document_schema_js = require("document-schema.js");
|
|
8
|
-
let pdf_codec = require("pdf-codec");
|
|
9
8
|
//#region src/layout/engine.ts
|
|
10
9
|
function newFlowState(section) {
|
|
11
10
|
return {
|
|
@@ -170,14 +169,14 @@ function layoutFormulaFallback(block, section, pages, state, contentLeftXDown, c
|
|
|
170
169
|
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
171
170
|
}, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
172
171
|
}
|
|
173
|
-
function layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, formulas) {
|
|
172
|
+
function layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, mathMetricsAt, formulas) {
|
|
174
173
|
const formula = require_model_formula.formulaOfBlock(block);
|
|
175
174
|
if (formula === void 0 || formula.mathml.length === 0) {
|
|
176
175
|
layoutFormulaFallback(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
177
176
|
return;
|
|
178
177
|
}
|
|
179
|
-
const sizePt = require_layout_shared.formulaSizePtForFrame(formula.mathml, block.frame);
|
|
180
|
-
const metrics = (
|
|
178
|
+
const sizePt = require_layout_shared.formulaSizePtForFrame(formula.mathml, block.frame, mathMetricsAt);
|
|
179
|
+
const metrics = mathMetricsAt(sizePt);
|
|
181
180
|
const { box } = require_mathml_layout.layoutFormula(formula.mathml, {
|
|
182
181
|
metrics,
|
|
183
182
|
sizePt,
|
|
@@ -208,7 +207,7 @@ function paginateSection(section, measurer, images, pages, options, formulas) {
|
|
|
208
207
|
} else if (block.kind === "paragraph") layoutParagraphFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
209
208
|
else if (block.kind === "table") layoutTableFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
210
209
|
else if (block.kind === "image") layoutImageFlow(block, section, pages, state, contentLeftXDown, contentBottomYDown, images);
|
|
211
|
-
else if (block.kind === "embeddedObject" && block.objectKind === "formula") layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, formulas);
|
|
210
|
+
else if (block.kind === "embeddedObject" && block.objectKind === "formula") layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, options.mathMetricsAt, formulas);
|
|
212
211
|
flushPage(state, section, pages);
|
|
213
212
|
}
|
|
214
213
|
function convertWordprocessingToLayout(doc, options) {
|
package/dist/layout/engine.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, LayoutDocument, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, LayoutDocument, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/engine.d.ts
|
|
3
3
|
interface EngineLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
}
|
|
6
7
|
interface WordprocessingLayoutResult {
|
|
7
8
|
readonly document: LayoutDocument;
|
package/dist/layout/engine.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, LayoutDocument, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, LayoutDocument, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/engine.d.ts
|
|
3
3
|
interface EngineLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
}
|
|
6
7
|
interface WordprocessingLayoutResult {
|
|
7
8
|
readonly document: LayoutDocument;
|
package/dist/layout/engine.js
CHANGED
|
@@ -4,7 +4,6 @@ import { layoutFormula } from "../mathml/layout.js";
|
|
|
4
4
|
import { wrapRunsToWidth } from "./text-layout.js";
|
|
5
5
|
import { alignmentOffsetPt, effectiveStyledRuns, estimateRowHeightPt, formulaSizePtForFrame, justifyLineGapsPt, lineNaturalHeightPt, pushCellBorderLines, registerImage, sumColumnWidthsPt } from "./shared.js";
|
|
6
6
|
import { COLOR_BLACK, LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
7
|
-
import { loadMathFont } from "pdf-codec";
|
|
8
7
|
//#region src/layout/engine.ts
|
|
9
8
|
function newFlowState(section) {
|
|
10
9
|
return {
|
|
@@ -169,14 +168,14 @@ function layoutFormulaFallback(block, section, pages, state, contentLeftXDown, c
|
|
|
169
168
|
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
170
169
|
}, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
171
170
|
}
|
|
172
|
-
function layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, formulas) {
|
|
171
|
+
function layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, mathMetricsAt, formulas) {
|
|
173
172
|
const formula = formulaOfBlock(block);
|
|
174
173
|
if (formula === void 0 || formula.mathml.length === 0) {
|
|
175
174
|
layoutFormulaFallback(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
176
175
|
return;
|
|
177
176
|
}
|
|
178
|
-
const sizePt = formulaSizePtForFrame(formula.mathml, block.frame);
|
|
179
|
-
const metrics =
|
|
177
|
+
const sizePt = formulaSizePtForFrame(formula.mathml, block.frame, mathMetricsAt);
|
|
178
|
+
const metrics = mathMetricsAt(sizePt);
|
|
180
179
|
const { box } = layoutFormula(formula.mathml, {
|
|
181
180
|
metrics,
|
|
182
181
|
sizePt,
|
|
@@ -207,7 +206,7 @@ function paginateSection(section, measurer, images, pages, options, formulas) {
|
|
|
207
206
|
} else if (block.kind === "paragraph") layoutParagraphFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
208
207
|
else if (block.kind === "table") layoutTableFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer);
|
|
209
208
|
else if (block.kind === "image") layoutImageFlow(block, section, pages, state, contentLeftXDown, contentBottomYDown, images);
|
|
210
|
-
else if (block.kind === "embeddedObject" && block.objectKind === "formula") layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, formulas);
|
|
209
|
+
else if (block.kind === "embeddedObject" && block.objectKind === "formula") layoutFormulaFlow(block, section, pages, state, contentLeftXDown, contentWidthPt, contentBottomYDown, measurer, options.mathMetricsAt, formulas);
|
|
211
210
|
flushPage(state, section, pages);
|
|
212
211
|
}
|
|
213
212
|
function convertWordprocessingToLayout(doc, options) {
|
package/dist/layout/shared.cjs
CHANGED
|
@@ -8,8 +8,8 @@ let document_schema_js = require("document-schema.js");
|
|
|
8
8
|
const NOMINAL_TEXT_SIZE_PT = 18;
|
|
9
9
|
const MIN_FORMULA_SIZE_PT = 8;
|
|
10
10
|
const REFERENCE_FORMULA_SIZE_PT = 12;
|
|
11
|
-
function formulaSizePtForFrame(mathml, frame) {
|
|
12
|
-
const referenceMetrics = (
|
|
11
|
+
function formulaSizePtForFrame(mathml, frame, mathMetricsAt) {
|
|
12
|
+
const referenceMetrics = mathMetricsAt(REFERENCE_FORMULA_SIZE_PT);
|
|
13
13
|
const { box } = require_mathml_layout.layoutFormula(mathml, {
|
|
14
14
|
metrics: referenceMetrics,
|
|
15
15
|
sizePt: REFERENCE_FORMULA_SIZE_PT,
|
package/dist/layout/shared.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as LayoutFont, t as Alignment } from "../style-DkamR3aY.cjs";
|
|
2
|
-
import { Box, ContentCellBorders, ContentImageBlock, ContentRun, ContentTableRow, LayoutImageAsset, LayoutItem, MathMlNode, StyledRun, TextMeasurer, WrappedLine } from "document-schema.js";
|
|
2
|
+
import { Box, ContentCellBorders, ContentImageBlock, ContentRun, ContentTableRow, LayoutImageAsset, LayoutItem, MathFontMetrics, MathMlNode, StyledRun, TextMeasurer, WrappedLine } from "document-schema.js";
|
|
3
3
|
//#region src/layout/shared.d.ts
|
|
4
4
|
declare const NOMINAL_TEXT_SIZE_PT = 18;
|
|
5
|
-
declare function formulaSizePtForFrame(mathml: readonly MathMlNode[], frame: Box): number;
|
|
5
|
+
declare function formulaSizePtForFrame(mathml: readonly MathMlNode[], frame: Box, mathMetricsAt: (sizePt: number) => MathFontMetrics): number;
|
|
6
6
|
declare function runFont(run: ContentRun): LayoutFont;
|
|
7
7
|
declare function toStyledRuns(runs: readonly ContentRun[], fontScale?: number): StyledRun[];
|
|
8
8
|
declare function effectiveStyledRuns(runs: readonly ContentRun[], fontScale?: number): StyledRun[];
|
package/dist/layout/shared.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as LayoutFont, t as Alignment } from "../style-DkamR3aY.js";
|
|
2
|
-
import { Box, ContentCellBorders, ContentImageBlock, ContentRun, ContentTableRow, LayoutImageAsset, LayoutItem, MathMlNode, StyledRun, TextMeasurer, WrappedLine } from "document-schema.js";
|
|
2
|
+
import { Box, ContentCellBorders, ContentImageBlock, ContentRun, ContentTableRow, LayoutImageAsset, LayoutItem, MathFontMetrics, MathMlNode, StyledRun, TextMeasurer, WrappedLine } from "document-schema.js";
|
|
3
3
|
//#region src/layout/shared.d.ts
|
|
4
4
|
declare const NOMINAL_TEXT_SIZE_PT = 18;
|
|
5
|
-
declare function formulaSizePtForFrame(mathml: readonly MathMlNode[], frame: Box): number;
|
|
5
|
+
declare function formulaSizePtForFrame(mathml: readonly MathMlNode[], frame: Box, mathMetricsAt: (sizePt: number) => MathFontMetrics): number;
|
|
6
6
|
declare function runFont(run: ContentRun): LayoutFont;
|
|
7
7
|
declare function toStyledRuns(runs: readonly ContentRun[], fontScale?: number): StyledRun[];
|
|
8
8
|
declare function effectiveStyledRuns(runs: readonly ContentRun[], fontScale?: number): StyledRun[];
|
package/dist/layout/shared.js
CHANGED
|
@@ -3,13 +3,13 @@ import { DEFAULT_LAYOUT_FONT } from "../model/style.js";
|
|
|
3
3
|
import { layoutFormula } from "../mathml/layout.js";
|
|
4
4
|
import { wrapRunsToWidth } from "./text-layout.js";
|
|
5
5
|
import { base64ToBytes } from "ooxml.js";
|
|
6
|
-
import { crc32, decodePng,
|
|
6
|
+
import { crc32, decodePng, readJpegInfo } from "pdf-codec";
|
|
7
7
|
//#region src/layout/shared.ts
|
|
8
8
|
const NOMINAL_TEXT_SIZE_PT = 18;
|
|
9
9
|
const MIN_FORMULA_SIZE_PT = 8;
|
|
10
10
|
const REFERENCE_FORMULA_SIZE_PT = 12;
|
|
11
|
-
function formulaSizePtForFrame(mathml, frame) {
|
|
12
|
-
const referenceMetrics =
|
|
11
|
+
function formulaSizePtForFrame(mathml, frame, mathMetricsAt) {
|
|
12
|
+
const referenceMetrics = mathMetricsAt(REFERENCE_FORMULA_SIZE_PT);
|
|
13
13
|
const { box } = layoutFormula(mathml, {
|
|
14
14
|
metrics: referenceMetrics,
|
|
15
15
|
sizePt: REFERENCE_FORMULA_SIZE_PT,
|
package/dist/layout/sheets.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require_layout_text_layout = require("./text-layout.cjs");
|
|
|
5
5
|
const require_layout_shared = require("./shared.cjs");
|
|
6
6
|
const require_ports_abort = require("../ports/abort.cjs");
|
|
7
7
|
let document_schema_js = require("document-schema.js");
|
|
8
|
-
let pdf_codec = require("pdf-codec");
|
|
9
8
|
//#region src/layout/sheets.ts
|
|
10
9
|
function anchoredFormulas(sheet) {
|
|
11
10
|
const resolved = [];
|
|
@@ -366,13 +365,13 @@ function renderGridlines(gridLeftXPt, gridTopYDownPt, gridWidthPt, gridHeightPt,
|
|
|
366
365
|
out.push(line);
|
|
367
366
|
}
|
|
368
367
|
}
|
|
369
|
-
function renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageHeightPt, pageIndex, hiddenColumnIndices, hiddenRowIndices, out) {
|
|
368
|
+
function renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageHeightPt, pageIndex, hiddenColumnIndices, hiddenRowIndices, out, mathMetricsAt) {
|
|
370
369
|
for (const anchored of formulas) {
|
|
371
370
|
const columnPosition = columnAxis.positionByIndex.get(anchored.anchorColumn);
|
|
372
371
|
const rowPosition = rowAxis.positionByIndex.get(anchored.anchorRow);
|
|
373
372
|
if (columnPosition === void 0 || rowPosition === void 0 || hiddenColumnIndices.has(anchored.anchorColumn) || hiddenRowIndices.has(anchored.anchorRow)) continue;
|
|
374
|
-
const sizePt = require_layout_shared.formulaSizePtForFrame(anchored.formula.mathml, anchored.frame);
|
|
375
|
-
const metrics = (
|
|
373
|
+
const sizePt = require_layout_shared.formulaSizePtForFrame(anchored.formula.mathml, anchored.frame, mathMetricsAt);
|
|
374
|
+
const metrics = mathMetricsAt(sizePt);
|
|
376
375
|
const { box } = require_mathml_layout.layoutFormula(anchored.formula.mathml, {
|
|
377
376
|
metrics,
|
|
378
377
|
sizePt,
|
|
@@ -431,7 +430,7 @@ function rangeIndices(start, end) {
|
|
|
431
430
|
for (let i = start; i <= end; i++) indices.push(i);
|
|
432
431
|
return indices;
|
|
433
432
|
}
|
|
434
|
-
function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images) {
|
|
433
|
+
function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images, mathMetricsAt) {
|
|
435
434
|
require_ports_abort.throwIfAborted(signal);
|
|
436
435
|
const formulas = anchoredFormulas(sheet);
|
|
437
436
|
const range = resolvePrintRange(sheet, formulas);
|
|
@@ -520,7 +519,7 @@ function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images)
|
|
|
520
519
|
items.push(...borderItems);
|
|
521
520
|
if (printSettings.headers) renderHeaderLabels(gutter, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, measurer, items);
|
|
522
521
|
items.push(...textItems);
|
|
523
|
-
renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, out.length, hiddenColumnIndices, hiddenRowIndices, formulasOut);
|
|
522
|
+
renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, out.length, hiddenColumnIndices, hiddenRowIndices, formulasOut, mathMetricsAt);
|
|
524
523
|
renderAnchoredImages(sheet.images, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, hiddenColumnIndices, hiddenRowIndices, items, images);
|
|
525
524
|
out.push({
|
|
526
525
|
widthPt: pageSize.widthPt,
|
|
@@ -533,7 +532,7 @@ function convertSpreadsheetToLayout(doc, options) {
|
|
|
533
532
|
const pages = [];
|
|
534
533
|
const formulas = [];
|
|
535
534
|
const images = {};
|
|
536
|
-
for (const sheet of doc.sheets) convertSheetToPages(sheet, options.measurer, options.signal, pages, formulas, images);
|
|
535
|
+
for (const sheet of doc.sheets) convertSheetToPages(sheet, options.measurer, options.signal, pages, formulas, images, options.mathMetricsAt);
|
|
537
536
|
return {
|
|
538
537
|
document: {
|
|
539
538
|
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
package/dist/layout/sheets.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, LayoutDocument, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, LayoutDocument, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/sheets.d.ts
|
|
3
3
|
interface SheetsLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
readonly signal?: AbortSignal;
|
|
6
7
|
}
|
|
7
8
|
interface SpreadsheetLayoutResult {
|
package/dist/layout/sheets.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, LayoutDocument, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, LayoutDocument, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/sheets.d.ts
|
|
3
3
|
interface SheetsLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
readonly signal?: AbortSignal;
|
|
6
7
|
}
|
|
7
8
|
interface SpreadsheetLayoutResult {
|
package/dist/layout/sheets.js
CHANGED
|
@@ -6,7 +6,6 @@ import { wrapRunsToWidth } from "./text-layout.js";
|
|
|
6
6
|
import { alignmentOffsetPt, formulaSizePtForFrame, justifyLineGapsPt, lineNaturalHeightPt, pushCellBorderLines, registerImage, sumColumnWidthsPt, toStyledRuns } from "./shared.js";
|
|
7
7
|
import { throwIfAborted } from "../ports/abort.js";
|
|
8
8
|
import { LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
9
|
-
import { loadMathFont } from "pdf-codec";
|
|
10
9
|
//#region src/layout/sheets.ts
|
|
11
10
|
function anchoredFormulas(sheet) {
|
|
12
11
|
const resolved = [];
|
|
@@ -367,13 +366,13 @@ function renderGridlines(gridLeftXPt, gridTopYDownPt, gridWidthPt, gridHeightPt,
|
|
|
367
366
|
out.push(line);
|
|
368
367
|
}
|
|
369
368
|
}
|
|
370
|
-
function renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageHeightPt, pageIndex, hiddenColumnIndices, hiddenRowIndices, out) {
|
|
369
|
+
function renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageHeightPt, pageIndex, hiddenColumnIndices, hiddenRowIndices, out, mathMetricsAt) {
|
|
371
370
|
for (const anchored of formulas) {
|
|
372
371
|
const columnPosition = columnAxis.positionByIndex.get(anchored.anchorColumn);
|
|
373
372
|
const rowPosition = rowAxis.positionByIndex.get(anchored.anchorRow);
|
|
374
373
|
if (columnPosition === void 0 || rowPosition === void 0 || hiddenColumnIndices.has(anchored.anchorColumn) || hiddenRowIndices.has(anchored.anchorRow)) continue;
|
|
375
|
-
const sizePt = formulaSizePtForFrame(anchored.formula.mathml, anchored.frame);
|
|
376
|
-
const metrics =
|
|
374
|
+
const sizePt = formulaSizePtForFrame(anchored.formula.mathml, anchored.frame, mathMetricsAt);
|
|
375
|
+
const metrics = mathMetricsAt(sizePt);
|
|
377
376
|
const { box } = layoutFormula(anchored.formula.mathml, {
|
|
378
377
|
metrics,
|
|
379
378
|
sizePt,
|
|
@@ -432,7 +431,7 @@ function rangeIndices(start, end) {
|
|
|
432
431
|
for (let i = start; i <= end; i++) indices.push(i);
|
|
433
432
|
return indices;
|
|
434
433
|
}
|
|
435
|
-
function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images) {
|
|
434
|
+
function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images, mathMetricsAt) {
|
|
436
435
|
throwIfAborted(signal);
|
|
437
436
|
const formulas = anchoredFormulas(sheet);
|
|
438
437
|
const range = resolvePrintRange(sheet, formulas);
|
|
@@ -521,7 +520,7 @@ function convertSheetToPages(sheet, measurer, signal, out, formulasOut, images)
|
|
|
521
520
|
items.push(...borderItems);
|
|
522
521
|
if (printSettings.headers) renderHeaderLabels(gutter, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, measurer, items);
|
|
523
522
|
items.push(...textItems);
|
|
524
|
-
renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, out.length, hiddenColumnIndices, hiddenRowIndices, formulasOut);
|
|
523
|
+
renderAnchoredFormulas(formulas, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, out.length, hiddenColumnIndices, hiddenRowIndices, formulasOut, mathMetricsAt);
|
|
525
524
|
renderAnchoredImages(sheet.images, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, hiddenColumnIndices, hiddenRowIndices, items, images);
|
|
526
525
|
out.push({
|
|
527
526
|
widthPt: pageSize.widthPt,
|
|
@@ -534,7 +533,7 @@ function convertSpreadsheetToLayout(doc, options) {
|
|
|
534
533
|
const pages = [];
|
|
535
534
|
const formulas = [];
|
|
536
535
|
const images = {};
|
|
537
|
-
for (const sheet of doc.sheets) convertSheetToPages(sheet, options.measurer, options.signal, pages, formulas, images);
|
|
536
|
+
for (const sheet of doc.sheets) convertSheetToPages(sheet, options.measurer, options.signal, pages, formulas, images, options.mathMetricsAt);
|
|
538
537
|
return {
|
|
539
538
|
document: {
|
|
540
539
|
formatVersion: LAYOUT_FORMAT_VERSION,
|
package/dist/layout/slides.cjs
CHANGED
|
@@ -5,7 +5,6 @@ const require_mathml_layout = require("../mathml/layout.cjs");
|
|
|
5
5
|
const require_layout_text_layout = require("./text-layout.cjs");
|
|
6
6
|
const require_layout_shared = require("./shared.cjs");
|
|
7
7
|
let document_schema_js = require("document-schema.js");
|
|
8
|
-
let pdf_codec = require("pdf-codec");
|
|
9
8
|
//#region src/layout/slides.ts
|
|
10
9
|
function shapePlacement(flippedFrame, rotationDeg) {
|
|
11
10
|
if (rotationDeg === void 0 || rotationDeg === 0) return {
|
|
@@ -117,8 +116,8 @@ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideH
|
|
|
117
116
|
function layoutShapeFormula(block, flippedFrame, formulaContext) {
|
|
118
117
|
const formula = require_model_formula.formulaOfBlock(block);
|
|
119
118
|
if (formula === void 0 || formula.mathml.length === 0) return;
|
|
120
|
-
const sizePt = require_layout_shared.formulaSizePtForFrame(formula.mathml, block.frame);
|
|
121
|
-
const metrics =
|
|
119
|
+
const sizePt = require_layout_shared.formulaSizePtForFrame(formula.mathml, block.frame, formulaContext.mathMetricsAt);
|
|
120
|
+
const metrics = formulaContext.mathMetricsAt(sizePt);
|
|
122
121
|
const { box } = require_mathml_layout.layoutFormula(formula.mathml, {
|
|
123
122
|
metrics,
|
|
124
123
|
sizePt,
|
|
@@ -160,11 +159,12 @@ function convertShape(shape, slideHeightPt, measurer, images, out, formulaContex
|
|
|
160
159
|
} else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, measurer, out);
|
|
161
160
|
else if (block.kind === "embeddedObject" && block.objectKind === "formula" && formulaContext !== void 0) layoutShapeFormula(block, flippedFrame, formulaContext);
|
|
162
161
|
}
|
|
163
|
-
function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
162
|
+
function convertSlide(slide, slideIndex, measurer, images, positioned, mathMetricsAt) {
|
|
164
163
|
const items = [];
|
|
165
164
|
const formulaContext = {
|
|
166
165
|
pageIndex: slideIndex,
|
|
167
|
-
positioned
|
|
166
|
+
positioned,
|
|
167
|
+
mathMetricsAt
|
|
168
168
|
};
|
|
169
169
|
for (const shape of slide.shapes) convertShape(shape, slide.size.heightPt, measurer, images, items, formulaContext);
|
|
170
170
|
return {
|
|
@@ -177,7 +177,7 @@ function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
|
177
177
|
function convertPresentationToLayout(doc, options) {
|
|
178
178
|
const images = {};
|
|
179
179
|
const formulas = [];
|
|
180
|
-
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas));
|
|
180
|
+
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas, options.mathMetricsAt));
|
|
181
181
|
return {
|
|
182
182
|
document: {
|
|
183
183
|
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
package/dist/layout/slides.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/slides.d.ts
|
|
3
3
|
interface SlidesLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
}
|
|
6
7
|
interface PresentationLayoutResult {
|
|
7
8
|
readonly document: LayoutDocument;
|
|
@@ -13,6 +14,7 @@ type PresentationContentDocument = Extract<ContentDocument, {
|
|
|
13
14
|
interface ShapeFormulaContext {
|
|
14
15
|
readonly pageIndex: number;
|
|
15
16
|
readonly positioned: PositionedFormula[];
|
|
17
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
16
18
|
}
|
|
17
19
|
declare function convertShape(shape: ContentShape, slideHeightPt: number, measurer: TextMeasurer, images: Record<string, LayoutImageAsset>, out: LayoutItem[], formulaContext?: ShapeFormulaContext): void;
|
|
18
20
|
declare function convertPresentationToLayout(doc: PresentationContentDocument, options: SlidesLayoutOptions): PresentationLayoutResult;
|
package/dist/layout/slides.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
1
|
+
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem, MathFontMetrics, PositionedFormula, TextMeasurer } from "document-schema.js";
|
|
2
2
|
//#region src/layout/slides.d.ts
|
|
3
3
|
interface SlidesLayoutOptions {
|
|
4
4
|
readonly measurer: TextMeasurer;
|
|
5
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
5
6
|
}
|
|
6
7
|
interface PresentationLayoutResult {
|
|
7
8
|
readonly document: LayoutDocument;
|
|
@@ -13,6 +14,7 @@ type PresentationContentDocument = Extract<ContentDocument, {
|
|
|
13
14
|
interface ShapeFormulaContext {
|
|
14
15
|
readonly pageIndex: number;
|
|
15
16
|
readonly positioned: PositionedFormula[];
|
|
17
|
+
readonly mathMetricsAt: (sizePt: number) => MathFontMetrics;
|
|
16
18
|
}
|
|
17
19
|
declare function convertShape(shape: ContentShape, slideHeightPt: number, measurer: TextMeasurer, images: Record<string, LayoutImageAsset>, out: LayoutItem[], formulaContext?: ShapeFormulaContext): void;
|
|
18
20
|
declare function convertPresentationToLayout(doc: PresentationContentDocument, options: SlidesLayoutOptions): PresentationLayoutResult;
|
package/dist/layout/slides.js
CHANGED
|
@@ -4,7 +4,6 @@ import { layoutFormula } from "../mathml/layout.js";
|
|
|
4
4
|
import { wrapRunsToWidth } from "./text-layout.js";
|
|
5
5
|
import { alignmentOffsetPt, effectiveStyledRuns, estimateRowHeightPt, formulaSizePtForFrame, justifyLineGapsPt, lineNaturalHeightPt, registerImage, sumColumnWidthsPt } from "./shared.js";
|
|
6
6
|
import { COLOR_BLACK, LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
7
|
-
import { loadMathFont } from "pdf-codec";
|
|
8
7
|
//#region src/layout/slides.ts
|
|
9
8
|
function shapePlacement(flippedFrame, rotationDeg) {
|
|
10
9
|
if (rotationDeg === void 0 || rotationDeg === 0) return {
|
|
@@ -116,8 +115,8 @@ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideH
|
|
|
116
115
|
function layoutShapeFormula(block, flippedFrame, formulaContext) {
|
|
117
116
|
const formula = formulaOfBlock(block);
|
|
118
117
|
if (formula === void 0 || formula.mathml.length === 0) return;
|
|
119
|
-
const sizePt = formulaSizePtForFrame(formula.mathml, block.frame);
|
|
120
|
-
const metrics =
|
|
118
|
+
const sizePt = formulaSizePtForFrame(formula.mathml, block.frame, formulaContext.mathMetricsAt);
|
|
119
|
+
const metrics = formulaContext.mathMetricsAt(sizePt);
|
|
121
120
|
const { box } = layoutFormula(formula.mathml, {
|
|
122
121
|
metrics,
|
|
123
122
|
sizePt,
|
|
@@ -159,11 +158,12 @@ function convertShape(shape, slideHeightPt, measurer, images, out, formulaContex
|
|
|
159
158
|
} else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, measurer, out);
|
|
160
159
|
else if (block.kind === "embeddedObject" && block.objectKind === "formula" && formulaContext !== void 0) layoutShapeFormula(block, flippedFrame, formulaContext);
|
|
161
160
|
}
|
|
162
|
-
function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
161
|
+
function convertSlide(slide, slideIndex, measurer, images, positioned, mathMetricsAt) {
|
|
163
162
|
const items = [];
|
|
164
163
|
const formulaContext = {
|
|
165
164
|
pageIndex: slideIndex,
|
|
166
|
-
positioned
|
|
165
|
+
positioned,
|
|
166
|
+
mathMetricsAt
|
|
167
167
|
};
|
|
168
168
|
for (const shape of slide.shapes) convertShape(shape, slide.size.heightPt, measurer, images, items, formulaContext);
|
|
169
169
|
return {
|
|
@@ -176,7 +176,7 @@ function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
|
176
176
|
function convertPresentationToLayout(doc, options) {
|
|
177
177
|
const images = {};
|
|
178
178
|
const formulas = [];
|
|
179
|
-
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas));
|
|
179
|
+
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas, options.mathMetricsAt));
|
|
180
180
|
return {
|
|
181
181
|
document: {
|
|
182
182
|
formatVersion: LAYOUT_FORMAT_VERSION,
|
package/package.json
CHANGED