documents.js 1.61.0 → 1.63.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/README.md +120 -47
- package/dist/{blr-types-CYYC3yYU.d.cts → blr-types-DVgO1DQ9.d.cts} +1 -1
- package/dist/{blr-types-CYYC3yYU.d.ts → blr-types-DVgO1DQ9.d.ts} +1 -1
- package/dist/convert/capability.cjs +1 -0
- package/dist/convert/capability.d.cts +1 -1
- package/dist/convert/capability.d.ts +1 -1
- package/dist/convert/capability.js +1 -0
- package/dist/convert/convert.cjs +92 -38
- package/dist/convert/convert.d.cts +11 -4
- package/dist/convert/convert.d.ts +11 -4
- package/dist/convert/convert.js +93 -39
- package/dist/convert/local.cjs +15 -2
- package/dist/convert/local.js +15 -2
- package/dist/convert/port.d.cts +8 -4
- package/dist/convert/port.d.ts +8 -4
- package/dist/edit/docx/content.cjs +75 -13
- package/dist/edit/docx/content.d.cts +8 -2
- package/dist/edit/docx/content.d.ts +8 -2
- package/dist/edit/docx/content.js +75 -13
- package/dist/edit/docx/paragraph.cjs +14 -0
- package/dist/edit/docx/paragraph.d.cts +5 -0
- package/dist/edit/docx/paragraph.d.ts +5 -0
- package/dist/edit/docx/paragraph.js +14 -0
- package/dist/edit/docx/run.cjs +1 -1
- package/dist/edit/docx/run.js +1 -1
- package/dist/edit/docx/table.cjs +41 -0
- package/dist/edit/docx/table.d.cts +7 -1
- package/dist/edit/docx/table.d.ts +7 -1
- package/dist/edit/docx/table.js +42 -1
- package/dist/edit/geometry.cjs +38 -0
- package/dist/edit/geometry.d.cts +7 -0
- package/dist/edit/geometry.d.ts +7 -0
- package/dist/edit/geometry.js +36 -0
- package/dist/edit/odg/content.cjs +15 -12
- package/dist/edit/odg/content.js +15 -12
- package/dist/edit/odg/editor.d.cts +1 -1
- package/dist/edit/odg/editor.d.ts +1 -1
- package/dist/edit/odg/page.d.cts +3 -3
- package/dist/edit/odg/page.d.ts +3 -3
- package/dist/edit/odg/vector.cjs +22 -13
- package/dist/edit/odg/vector.d.cts +1 -1
- package/dist/edit/odg/vector.d.ts +1 -1
- package/dist/edit/odg/vector.js +23 -14
- package/dist/edit/odp/content.cjs +15 -0
- package/dist/edit/odp/content.js +16 -1
- package/dist/edit/odp/editor.d.cts +1 -1
- package/dist/edit/odp/editor.d.ts +1 -1
- package/dist/edit/odp/image.d.cts +1 -1
- package/dist/edit/odp/image.d.ts +1 -1
- package/dist/edit/odp/shape.cjs +11 -30
- package/dist/edit/odp/shape.d.cts +2 -2
- package/dist/edit/odp/shape.d.ts +2 -2
- package/dist/edit/odp/shape.js +13 -33
- package/dist/edit/odp/slide.cjs +11 -0
- package/dist/edit/odp/slide.d.cts +14 -4
- package/dist/edit/odp/slide.d.ts +14 -4
- package/dist/edit/odp/slide.js +12 -1
- package/dist/edit/odt/content.cjs +56 -16
- package/dist/edit/odt/content.d.cts +4 -2
- package/dist/edit/odt/content.d.ts +4 -2
- package/dist/edit/odt/content.js +56 -17
- package/dist/edit/odt/editor.d.cts +1 -1
- package/dist/edit/odt/editor.d.ts +1 -1
- package/dist/edit/odt/table.cjs +36 -0
- package/dist/edit/odt/table.d.cts +1 -36
- package/dist/edit/odt/table.d.ts +1 -36
- package/dist/edit/odt/table.js +37 -1
- package/dist/edit/pptx/content.cjs +71 -3
- package/dist/edit/pptx/content.js +71 -3
- package/dist/edit/pptx/editor.d.cts +1 -1
- package/dist/edit/pptx/editor.d.ts +1 -1
- package/dist/edit/pptx/image.d.cts +1 -1
- package/dist/edit/pptx/image.d.ts +1 -1
- package/dist/edit/pptx/shape.cjs +23 -1
- package/dist/edit/pptx/shape.d.cts +2 -2
- package/dist/edit/pptx/shape.d.ts +2 -2
- package/dist/edit/pptx/shape.js +23 -3
- package/dist/edit/pptx/slide.cjs +10 -1
- package/dist/edit/pptx/slide.d.cts +11 -4
- package/dist/edit/pptx/slide.d.ts +11 -4
- package/dist/edit/pptx/slide.js +10 -1
- package/dist/edit/pptx/table.cjs +136 -0
- package/dist/edit/pptx/table.d.cts +2 -0
- package/dist/edit/pptx/table.d.ts +2 -0
- package/dist/edit/pptx/table.js +131 -0
- package/dist/firebird/backup.d.cts +1 -1
- package/dist/firebird/backup.d.ts +1 -1
- package/dist/firebird/blr-types.cjs +2 -2
- package/dist/firebird/blr-types.d.cts +1 -1
- package/dist/firebird/blr-types.d.ts +1 -1
- package/dist/firebird/blr-types.js +2 -2
- package/dist/firebird/data.cjs +68 -14
- package/dist/firebird/data.d.cts +1 -1
- package/dist/firebird/data.d.ts +1 -1
- package/dist/firebird/data.js +68 -14
- package/dist/firebird/schema.cjs +13 -1
- package/dist/firebird/schema.d.cts +1 -1
- package/dist/firebird/schema.d.ts +1 -1
- package/dist/firebird/schema.js +13 -1
- package/dist/fonts/obfuscation.cjs +50 -0
- package/dist/fonts/obfuscation.d.cts +9 -0
- package/dist/fonts/obfuscation.d.ts +9 -0
- package/dist/fonts/obfuscation.js +46 -0
- package/dist/fonts/odf.cjs +86 -0
- package/dist/fonts/odf.d.cts +9 -0
- package/dist/fonts/odf.d.ts +9 -0
- package/dist/fonts/odf.js +84 -0
- package/dist/fonts/ooxml.cjs +129 -0
- package/dist/fonts/ooxml.d.cts +9 -0
- package/dist/fonts/ooxml.d.ts +9 -0
- package/dist/fonts/ooxml.js +127 -0
- package/dist/fonts/registry.cjs +18 -0
- package/dist/fonts/registry.d.cts +2 -0
- package/dist/fonts/registry.d.ts +2 -0
- package/dist/fonts/registry.js +16 -0
- package/dist/{geometry-DvwdrIij.d.cts → geometry-DaJr8yQW.d.cts} +2 -2
- package/dist/{geometry-DvwdrIij.d.ts → geometry-DaJr8yQW.d.ts} +2 -2
- package/dist/hsqldb/binary-script.cjs +154 -0
- package/dist/hsqldb/binary-script.d.cts +15 -0
- package/dist/hsqldb/binary-script.d.ts +15 -0
- package/dist/hsqldb/binary-script.js +151 -0
- package/dist/hsqldb/cache.cjs +18 -11
- package/dist/hsqldb/cache.d.cts +9 -4
- package/dist/hsqldb/cache.d.ts +9 -4
- package/dist/hsqldb/cache.js +18 -11
- package/dist/hsqldb/rowformat.cjs +60 -16
- package/dist/hsqldb/rowformat.d.cts +2 -21
- package/dist/hsqldb/rowformat.d.ts +2 -21
- package/dist/hsqldb/rowformat.js +60 -17
- package/dist/{image-BZDy72Jb.d.cts → image-7snmKIxn.d.cts} +1 -1
- package/dist/{image-B-xQWYYS.d.ts → image-Cs8xF753.d.ts} +1 -1
- package/dist/{image-CeqwL-Qs.d.ts → image-DHcA9kaK.d.ts} +1 -1
- package/dist/{image-DWX6cNOD.d.cts → image-M5SezZVI.d.cts} +1 -1
- package/dist/index.cjs +86 -3
- package/dist/index.d.cts +33 -21
- package/dist/index.d.ts +33 -21
- package/dist/index.js +18 -5
- package/dist/layout/cell-typing.cjs +209 -0
- package/dist/layout/cell-typing.d.cts +22 -0
- package/dist/layout/cell-typing.d.ts +22 -0
- package/dist/layout/cell-typing.js +208 -0
- package/dist/layout/drawing.cjs +193 -17
- package/dist/layout/drawing.js +193 -17
- package/dist/layout/engine.cjs +46 -29
- package/dist/layout/engine.d.cts +0 -2
- package/dist/layout/engine.d.ts +0 -2
- package/dist/layout/engine.js +47 -30
- package/dist/layout/lattice.cjs +139 -0
- package/dist/layout/lattice.d.cts +20 -0
- package/dist/layout/lattice.d.ts +20 -0
- package/dist/layout/lattice.js +135 -0
- package/dist/layout/reconstruct.cjs +176 -113
- package/dist/layout/reconstruct.d.cts +2 -0
- package/dist/layout/reconstruct.d.ts +2 -0
- package/dist/layout/reconstruct.js +173 -110
- package/dist/layout/shared.cjs +52 -0
- package/dist/layout/shared.d.cts +4 -2
- package/dist/layout/shared.d.ts +4 -2
- package/dist/layout/shared.js +51 -1
- package/dist/layout/sheets.cjs +45 -11
- package/dist/layout/sheets.js +46 -12
- package/dist/layout/slides.cjs +7 -7
- package/dist/layout/slides.d.cts +0 -3
- package/dist/layout/slides.d.ts +0 -3
- package/dist/layout/slides.js +7 -7
- package/dist/markdown/write.cjs +19 -6
- package/dist/markdown/write.js +19 -6
- package/dist/mathml/layout.cjs +2 -2
- package/dist/mathml/layout.d.cts +1 -1
- package/dist/mathml/layout.d.ts +1 -1
- package/dist/mathml/layout.js +2 -2
- package/dist/model/embedded-drawing.cjs +32 -0
- package/dist/model/embedded-drawing.d.cts +8 -0
- package/dist/model/embedded-drawing.d.ts +8 -0
- package/dist/model/embedded-drawing.js +30 -0
- package/dist/model/formula.cjs +31 -0
- package/dist/model/formula.d.cts +6 -6
- package/dist/model/formula.d.ts +6 -6
- package/dist/model/formula.js +27 -0
- package/dist/model/geometry.d.cts +1 -1
- package/dist/model/geometry.d.ts +1 -1
- package/dist/model/paint-order.cjs +15 -0
- package/dist/model/paint-order.d.cts +14 -0
- package/dist/model/paint-order.d.ts +14 -0
- package/dist/model/paint-order.js +14 -0
- package/dist/odb/components.cjs +12 -0
- package/dist/odb/components.d.cts +6 -0
- package/dist/odb/components.d.ts +6 -0
- package/dist/odb/components.js +10 -0
- package/dist/odb/read.cjs +11 -7
- package/dist/odb/read.d.cts +3 -2
- package/dist/odb/read.d.ts +3 -2
- package/dist/odb/read.js +11 -7
- package/dist/odf/formula/detect.cjs +86 -18
- package/dist/odf/formula/detect.d.cts +10 -6
- package/dist/odf/formula/detect.d.ts +10 -6
- package/dist/odf/formula/detect.js +86 -19
- package/dist/odf/formula/read.cjs +4 -16
- package/dist/odf/formula/read.d.cts +4 -8
- package/dist/odf/formula/read.d.ts +4 -8
- package/dist/odf/formula/read.js +5 -17
- package/dist/odf/odp/read.cjs +9 -19
- package/dist/odf/odp/read.d.cts +2 -7
- package/dist/odf/odp/read.d.ts +2 -7
- package/dist/odf/odp/read.js +10 -20
- package/dist/odf/odt/read.cjs +63 -23
- package/dist/odf/odt/read.d.cts +2 -7
- package/dist/odf/odt/read.d.ts +2 -7
- package/dist/odf/odt/read.js +64 -24
- package/dist/omml/write.cjs +258 -0
- package/dist/omml/write.d.cts +2 -0
- package/dist/omml/write.d.ts +2 -0
- package/dist/omml/write.js +256 -0
- package/dist/registry-CrSqLIcn.d.ts +19 -0
- package/dist/registry-CtPhMD0f.d.cts +19 -0
- package/dist/rowformat-Cl2exlEh.d.cts +25 -0
- package/dist/rowformat-Cl2exlEh.d.ts +25 -0
- package/dist/{schema-Acco3Ezi.d.cts → schema-BeR_KJ0X.d.cts} +3 -1
- package/dist/{schema-VkAA6pF5.d.ts → schema-CSKwSb_v.d.ts} +3 -1
- package/dist/{shape-BUfjw5eZ.d.cts → shape-BhkP6HB8.d.cts} +6 -2
- package/dist/{shape-CTkl6kt8.d.ts → shape-BkVcwPcf.d.ts} +6 -2
- package/dist/{shape-BfN3m52m.d.ts → shape-CVXedeL7.d.ts} +3 -2
- package/dist/{shape-CN2ycxOo.d.cts → shape-CXZ6fejV.d.cts} +3 -2
- package/dist/table-C3CPZ--2.d.cts +35 -0
- package/dist/table-DjYcNOFm.d.cts +44 -0
- package/dist/table-DqfqMkVq.d.ts +44 -0
- package/dist/table-DvS_7UQS.d.ts +35 -0
- package/dist/{vector-ClohqsOe.d.cts → vector-Puuqu_IT.d.cts} +4 -0
- package/dist/{vector-ClohqsOe.d.ts → vector-Puuqu_IT.d.ts} +4 -0
- package/dist/write-DuyfnbL_.d.cts +16 -0
- package/dist/write-Zqwx6pka.d.ts +16 -0
- package/package.json +4 -4
- package/dist/odf/formula/placeholder.cjs +0 -36
- package/dist/odf/formula/placeholder.d.cts +0 -14
- package/dist/odf/formula/placeholder.d.ts +0 -14
- package/dist/odf/formula/placeholder.js +0 -36
package/dist/layout/sheets.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { flipY } from "../model/geometry.js";
|
|
1
2
|
import { COLOR_BLACK as COLOR_BLACK$1, rgbHexToColor } from "../model/color.js";
|
|
2
3
|
import { DEFAULT_LAYOUT_FONT } from "../model/style.js";
|
|
3
|
-
import { alignmentOffsetPt, lineNaturalHeightPt, sumColumnWidthsPt, toStyledRuns } from "./shared.js";
|
|
4
|
+
import { alignmentOffsetPt, lineNaturalHeightPt, pushCellBorderLines, sumColumnWidthsPt, toStyledRuns } from "./shared.js";
|
|
4
5
|
import { throwIfAborted } from "../ports/abort.js";
|
|
5
6
|
import { LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
6
7
|
import { wrapRunsToWidth } from "pdf-codec";
|
|
@@ -183,15 +184,39 @@ function axisSpanSizePt(axis, startIndex, span) {
|
|
|
183
184
|
if (startPosition === void 0) return 0;
|
|
184
185
|
return sumColumnWidthsPt(axis.sizesPt, startPosition, span);
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
+
function resolveCellFrame(cell, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt) {
|
|
187
188
|
const columnPosition = columnAxis.positionByIndex.get(cell.column);
|
|
188
189
|
const rowPosition = rowAxis.positionByIndex.get(cell.row);
|
|
189
190
|
if (columnPosition === void 0 || rowPosition === void 0) return;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
return {
|
|
192
|
+
xPt: gridLeftXPt + columnAxis.offsetsPt[columnPosition],
|
|
193
|
+
yPt: gridTopYDownPt + rowAxis.offsetsPt[rowPosition],
|
|
194
|
+
widthPt: axisSpanSizePt(columnAxis, cell.column, cell.colSpan ?? 1),
|
|
195
|
+
heightPt: axisSpanSizePt(rowAxis, cell.row, cell.rowSpan ?? 1)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function renderCellBackground(cell, frameYDown, pageHeightPt, out) {
|
|
199
|
+
if (cell.background === void 0) return;
|
|
200
|
+
const flipped = flipY(frameYDown, pageHeightPt);
|
|
201
|
+
out.push({
|
|
202
|
+
kind: "rect",
|
|
203
|
+
xPt: flipped.xPt,
|
|
204
|
+
yPt: flipped.yPt,
|
|
205
|
+
widthPt: flipped.widthPt,
|
|
206
|
+
heightPt: flipped.heightPt,
|
|
207
|
+
fill: cell.background,
|
|
208
|
+
sourcePath: cell.sourcePath
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const DEFAULT_CELL_VERTICAL_ALIGNMENT = "bottom";
|
|
212
|
+
function verticalLineTopYDownPt(verticalAlignment, cellTopYDownPt, cellHeightPt, lineHeightPt) {
|
|
213
|
+
if (verticalAlignment === "top") return cellTopYDownPt + CELL_TEXT_PADDING_PT;
|
|
214
|
+
if (verticalAlignment === "middle") return cellTopYDownPt + Math.max(CELL_TEXT_PADDING_PT, (cellHeightPt - lineHeightPt) / 2);
|
|
215
|
+
return cellTopYDownPt + Math.max(CELL_TEXT_PADDING_PT, cellHeightPt - CELL_TEXT_PADDING_PT - lineHeightPt);
|
|
216
|
+
}
|
|
217
|
+
function renderCellText(cell, frameYDown, rowCells, columnAxis, pageHeightPt, measurer, out) {
|
|
218
|
+
const { xPt: xLeftPt, yPt: yTopDownPt, widthPt: ownWidthPt, heightPt } = frameYDown;
|
|
219
|
+
const alignment = cell.alignment ?? defaultAlignmentForValue(cell.value.kind);
|
|
195
220
|
const numericLike = isNumericLikeValue(cell.value.kind);
|
|
196
221
|
const styledRuns = cellStyledRuns(cell);
|
|
197
222
|
const naturalLine = wrapRunsToWidth(styledRuns, measurer, Number.POSITIVE_INFINITY)[0];
|
|
@@ -221,7 +246,7 @@ function renderCellText(cell, rowCells, columnAxis, rowAxis, gridLeftXPt, gridTo
|
|
|
221
246
|
const alignOffsetPt = alignmentOffsetPt(alignment, availableWidthPt, lineWidthPt);
|
|
222
247
|
const textStartXPt = xLeftPt + CELL_TEXT_PADDING_PT + alignOffsetPt;
|
|
223
248
|
const lineHeightPt = lineNaturalHeightPt(naturalLine, measurer, styledRuns[0]);
|
|
224
|
-
const baselineYDownPt =
|
|
249
|
+
const baselineYDownPt = verticalLineTopYDownPt(cell.verticalAlignment ?? DEFAULT_CELL_VERTICAL_ALIGNMENT, yTopDownPt, heightPt, lineHeightPt) + naturalLine.ascentPt;
|
|
225
250
|
for (const fragment of fragments) {
|
|
226
251
|
const textItem = {
|
|
227
252
|
kind: "text",
|
|
@@ -381,18 +406,27 @@ function convertSheetToPages(sheet, measurer, signal, out) {
|
|
|
381
406
|
const gridTopYDownPt = margins.topPt + gutter.heightPt;
|
|
382
407
|
const gridWidthPt = columnAxis.offsetsPt[columnAxis.offsetsPt.length - 1];
|
|
383
408
|
const gridHeightPt = rowAxis.offsetsPt[rowAxis.offsetsPt.length - 1];
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
409
|
+
const backgroundItems = [];
|
|
410
|
+
const borderItems = [];
|
|
411
|
+
const textItems = [];
|
|
387
412
|
for (const rowIndex of rowAxis.indices) {
|
|
388
413
|
const rowCells = cellsByRow.get(rowIndex);
|
|
389
414
|
if (rowCells === void 0) continue;
|
|
390
415
|
for (const [columnIndex, cell] of rowCells) {
|
|
391
416
|
throwIfAborted(signal);
|
|
392
417
|
if (!columnAxis.positionByIndex.has(columnIndex) || hiddenColumnIndices.has(columnIndex) || hiddenRowIndices.has(cell.row)) continue;
|
|
393
|
-
|
|
418
|
+
const cellFrame = resolveCellFrame(cell, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt);
|
|
419
|
+
if (cellFrame === void 0) continue;
|
|
420
|
+
renderCellBackground(cell, cellFrame, pageSize.heightPt, backgroundItems);
|
|
421
|
+
if (cell.borders !== void 0) pushCellBorderLines(cell.borders, cellFrame, pageSize.heightPt, cell.sourcePath, borderItems);
|
|
422
|
+
renderCellText(cell, cellFrame, rowCells, columnAxis, pageSize.heightPt, measurer, textItems);
|
|
394
423
|
}
|
|
395
424
|
}
|
|
425
|
+
const items = [...backgroundItems];
|
|
426
|
+
if (printSettings.gridlines) renderGridlines(gridLeftXPt, gridTopYDownPt, gridWidthPt, gridHeightPt, columnAxis.offsetsPt, rowAxis.offsetsPt, pageSize.heightPt, items);
|
|
427
|
+
items.push(...borderItems);
|
|
428
|
+
if (printSettings.headers) renderHeaderLabels(gutter, columnAxis, rowAxis, gridLeftXPt, gridTopYDownPt, pageSize.heightPt, measurer, items);
|
|
429
|
+
items.push(...textItems);
|
|
396
430
|
out.push({
|
|
397
431
|
widthPt: pageSize.widthPt,
|
|
398
432
|
heightPt: pageSize.heightPt,
|
package/dist/layout/slides.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_model_geometry = require("../model/geometry.cjs");
|
|
3
|
+
const require_model_formula = require("../model/formula.cjs");
|
|
3
4
|
const require_mathml_layout = require("../mathml/layout.cjs");
|
|
4
5
|
const require_layout_shared = require("./shared.cjs");
|
|
5
6
|
let document_schema_js = require("document-schema.js");
|
|
@@ -115,11 +116,11 @@ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideH
|
|
|
115
116
|
return cursorYDown;
|
|
116
117
|
}
|
|
117
118
|
function layoutShapeFormula(block, flippedFrame, formulaContext) {
|
|
118
|
-
const
|
|
119
|
-
if (
|
|
119
|
+
const formula = require_model_formula.formulaOfBlock(block);
|
|
120
|
+
if (formula === void 0 || formula.mathml.length === 0) return;
|
|
120
121
|
const sizePt = formulaSizePtFromFrame(block.frame.heightPt);
|
|
121
122
|
const metrics = (0, pdf_codec.loadMathFont)().metricsAt(sizePt);
|
|
122
|
-
const { box } = require_mathml_layout.layoutFormula(
|
|
123
|
+
const { box } = require_mathml_layout.layoutFormula(formula.mathml, {
|
|
123
124
|
metrics,
|
|
124
125
|
sizePt,
|
|
125
126
|
color: document_schema_js.COLOR_BLACK
|
|
@@ -160,10 +161,9 @@ function convertShape(shape, slideHeightPt, measurer, images, out, formulaContex
|
|
|
160
161
|
} else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, measurer, out);
|
|
161
162
|
else if (block.kind === "embeddedObject" && block.objectKind === "formula" && formulaContext !== void 0) layoutShapeFormula(block, flippedFrame, formulaContext);
|
|
162
163
|
}
|
|
163
|
-
function convertSlide(slide, slideIndex, measurer, images,
|
|
164
|
+
function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
164
165
|
const items = [];
|
|
165
|
-
const formulaContext =
|
|
166
|
-
formulas,
|
|
166
|
+
const formulaContext = {
|
|
167
167
|
pageIndex: slideIndex,
|
|
168
168
|
positioned
|
|
169
169
|
};
|
|
@@ -178,7 +178,7 @@ function convertSlide(slide, slideIndex, measurer, images, formulas, positioned)
|
|
|
178
178
|
function convertPresentationToLayout(doc, options) {
|
|
179
179
|
const images = {};
|
|
180
180
|
const formulas = [];
|
|
181
|
-
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images,
|
|
181
|
+
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas));
|
|
182
182
|
return {
|
|
183
183
|
document: {
|
|
184
184
|
formatVersion: document_schema_js.LAYOUT_FORMAT_VERSION,
|
package/dist/layout/slides.d.cts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../model/formula.cjs";
|
|
2
1
|
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem } from "document-schema.js";
|
|
3
2
|
import { PositionedFormula, TextMeasurer } from "pdf-codec";
|
|
4
3
|
//#region src/layout/slides.d.ts
|
|
5
4
|
interface SlidesLayoutOptions {
|
|
6
5
|
readonly measurer: TextMeasurer;
|
|
7
|
-
readonly formulas?: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
6
|
}
|
|
9
7
|
interface PresentationLayoutResult {
|
|
10
8
|
readonly document: LayoutDocument;
|
|
@@ -14,7 +12,6 @@ type PresentationContentDocument = Extract<ContentDocument, {
|
|
|
14
12
|
kind: 'presentation';
|
|
15
13
|
}>;
|
|
16
14
|
interface ShapeFormulaContext {
|
|
17
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
18
15
|
readonly pageIndex: number;
|
|
19
16
|
readonly positioned: PositionedFormula[];
|
|
20
17
|
}
|
package/dist/layout/slides.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { EmbeddedFormula } from "../model/formula.js";
|
|
2
1
|
import { ContentDocument, ContentShape, LayoutDocument, LayoutImageAsset, LayoutItem } from "document-schema.js";
|
|
3
2
|
import { PositionedFormula, TextMeasurer } from "pdf-codec";
|
|
4
3
|
//#region src/layout/slides.d.ts
|
|
5
4
|
interface SlidesLayoutOptions {
|
|
6
5
|
readonly measurer: TextMeasurer;
|
|
7
|
-
readonly formulas?: ReadonlyMap<string, EmbeddedFormula>;
|
|
8
6
|
}
|
|
9
7
|
interface PresentationLayoutResult {
|
|
10
8
|
readonly document: LayoutDocument;
|
|
@@ -14,7 +12,6 @@ type PresentationContentDocument = Extract<ContentDocument, {
|
|
|
14
12
|
kind: 'presentation';
|
|
15
13
|
}>;
|
|
16
14
|
interface ShapeFormulaContext {
|
|
17
|
-
readonly formulas: ReadonlyMap<string, EmbeddedFormula>;
|
|
18
15
|
readonly pageIndex: number;
|
|
19
16
|
readonly positioned: PositionedFormula[];
|
|
20
17
|
}
|
package/dist/layout/slides.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { flipY } from "../model/geometry.js";
|
|
2
|
+
import { formulaOfBlock } from "../model/formula.js";
|
|
2
3
|
import { layoutFormula } from "../mathml/layout.js";
|
|
3
4
|
import { alignmentOffsetPt, effectiveStyledRuns, estimateRowHeightPt, lineNaturalHeightPt, registerImage, sumColumnWidthsPt } from "./shared.js";
|
|
4
5
|
import { COLOR_BLACK, LAYOUT_FORMAT_VERSION } from "document-schema.js";
|
|
@@ -114,11 +115,11 @@ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideH
|
|
|
114
115
|
return cursorYDown;
|
|
115
116
|
}
|
|
116
117
|
function layoutShapeFormula(block, flippedFrame, formulaContext) {
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
118
|
+
const formula = formulaOfBlock(block);
|
|
119
|
+
if (formula === void 0 || formula.mathml.length === 0) return;
|
|
119
120
|
const sizePt = formulaSizePtFromFrame(block.frame.heightPt);
|
|
120
121
|
const metrics = loadMathFont().metricsAt(sizePt);
|
|
121
|
-
const { box } = layoutFormula(
|
|
122
|
+
const { box } = layoutFormula(formula.mathml, {
|
|
122
123
|
metrics,
|
|
123
124
|
sizePt,
|
|
124
125
|
color: COLOR_BLACK
|
|
@@ -159,10 +160,9 @@ function convertShape(shape, slideHeightPt, measurer, images, out, formulaContex
|
|
|
159
160
|
} else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, measurer, out);
|
|
160
161
|
else if (block.kind === "embeddedObject" && block.objectKind === "formula" && formulaContext !== void 0) layoutShapeFormula(block, flippedFrame, formulaContext);
|
|
161
162
|
}
|
|
162
|
-
function convertSlide(slide, slideIndex, measurer, images,
|
|
163
|
+
function convertSlide(slide, slideIndex, measurer, images, positioned) {
|
|
163
164
|
const items = [];
|
|
164
|
-
const formulaContext =
|
|
165
|
-
formulas,
|
|
165
|
+
const formulaContext = {
|
|
166
166
|
pageIndex: slideIndex,
|
|
167
167
|
positioned
|
|
168
168
|
};
|
|
@@ -177,7 +177,7 @@ function convertSlide(slide, slideIndex, measurer, images, formulas, 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,
|
|
180
|
+
const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas));
|
|
181
181
|
return {
|
|
182
182
|
document: {
|
|
183
183
|
formatVersion: LAYOUT_FORMAT_VERSION,
|
package/dist/markdown/write.cjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_formula = require("../model/formula.cjs");
|
|
3
|
+
const require_model_embedded_drawing = require("../model/embedded-drawing.cjs");
|
|
2
4
|
let markdown_codec = require("markdown-codec");
|
|
3
5
|
//#region src/markdown/write.ts
|
|
4
6
|
function toLegacyEmbeddedDocument(document) {
|
|
@@ -12,16 +14,27 @@ function toLegacyBlock(block) {
|
|
|
12
14
|
...row,
|
|
13
15
|
cells: row.cells.map((cell) => ({
|
|
14
16
|
...cell,
|
|
15
|
-
blocks: cell.blocks
|
|
17
|
+
blocks: toLegacyBlocks(cell.blocks)
|
|
16
18
|
}))
|
|
17
19
|
}))
|
|
18
20
|
};
|
|
19
|
-
if (block.kind === "embeddedObject")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if (block.kind === "embeddedObject") {
|
|
22
|
+
if (require_model_embedded_drawing.drawingOfBlock(block) !== void 0) return;
|
|
23
|
+
const formula = require_model_formula.formulaOfBlock(block);
|
|
24
|
+
if (formula !== void 0) return {
|
|
25
|
+
kind: "paragraph",
|
|
26
|
+
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
...block,
|
|
30
|
+
document: toLegacyEmbeddedDocument(block.document)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
23
33
|
return block;
|
|
24
34
|
}
|
|
35
|
+
function toLegacyBlocks(blocks) {
|
|
36
|
+
return blocks.map(toLegacyBlock).filter((block) => block !== void 0);
|
|
37
|
+
}
|
|
25
38
|
function toLegacyWordprocessingDocument(document) {
|
|
26
39
|
return {
|
|
27
40
|
kind: "wordprocessing",
|
|
@@ -29,7 +42,7 @@ function toLegacyWordprocessingDocument(document) {
|
|
|
29
42
|
metadata: document.metadata,
|
|
30
43
|
sections: document.sections.map((section) => ({
|
|
31
44
|
...section,
|
|
32
|
-
blocks: section.blocks
|
|
45
|
+
blocks: toLegacyBlocks(section.blocks)
|
|
33
46
|
}))
|
|
34
47
|
};
|
|
35
48
|
}
|
package/dist/markdown/write.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
|
|
2
|
+
import { drawingOfBlock } from "../model/embedded-drawing.js";
|
|
1
3
|
import { MarkdownUnsupportedDocumentKindError, writeMarkdown } from "markdown-codec";
|
|
2
4
|
//#region src/markdown/write.ts
|
|
3
5
|
function toLegacyEmbeddedDocument(document) {
|
|
@@ -11,16 +13,27 @@ function toLegacyBlock(block) {
|
|
|
11
13
|
...row,
|
|
12
14
|
cells: row.cells.map((cell) => ({
|
|
13
15
|
...cell,
|
|
14
|
-
blocks: cell.blocks
|
|
16
|
+
blocks: toLegacyBlocks(cell.blocks)
|
|
15
17
|
}))
|
|
16
18
|
}))
|
|
17
19
|
};
|
|
18
|
-
if (block.kind === "embeddedObject")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (block.kind === "embeddedObject") {
|
|
21
|
+
if (drawingOfBlock(block) !== void 0) return;
|
|
22
|
+
const formula = formulaOfBlock(block);
|
|
23
|
+
if (formula !== void 0) return {
|
|
24
|
+
kind: "paragraph",
|
|
25
|
+
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
...block,
|
|
29
|
+
document: toLegacyEmbeddedDocument(block.document)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
22
32
|
return block;
|
|
23
33
|
}
|
|
34
|
+
function toLegacyBlocks(blocks) {
|
|
35
|
+
return blocks.map(toLegacyBlock).filter((block) => block !== void 0);
|
|
36
|
+
}
|
|
24
37
|
function toLegacyWordprocessingDocument(document) {
|
|
25
38
|
return {
|
|
26
39
|
kind: "wordprocessing",
|
|
@@ -28,7 +41,7 @@ function toLegacyWordprocessingDocument(document) {
|
|
|
28
41
|
metadata: document.metadata,
|
|
29
42
|
sections: document.sections.map((section) => ({
|
|
30
43
|
...section,
|
|
31
|
-
blocks: section.blocks
|
|
44
|
+
blocks: toLegacyBlocks(section.blocks)
|
|
32
45
|
}))
|
|
33
46
|
};
|
|
34
47
|
}
|
package/dist/mathml/layout.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mathml_compose = require("./compose.cjs");
|
|
3
2
|
const require_mathml_length = require("./length.cjs");
|
|
4
3
|
const require_mathml_nodes = require("./nodes.cjs");
|
|
5
4
|
const require_mathml_operators = require("./operators.cjs");
|
|
6
|
-
const require_mathml_radical = require("./radical.cjs");
|
|
7
5
|
const require_mathml_variant = require("./variant.cjs");
|
|
6
|
+
const require_mathml_compose = require("./compose.cjs");
|
|
7
|
+
const require_mathml_radical = require("./radical.cjs");
|
|
8
8
|
//#region src/mathml/layout.ts
|
|
9
9
|
function rootContext(options, diagnostics) {
|
|
10
10
|
return {
|
package/dist/mathml/layout.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { r as MathMlNode } from "../nodes-pArN9ilm.cjs";
|
|
1
2
|
import { MathBox, MathColor, MathDiagnostic, MathLayoutResult } from "./layout-types.cjs";
|
|
2
3
|
import { MathFontMetrics } from "./metrics.cjs";
|
|
3
|
-
import { r as MathMlNode } from "../nodes-pArN9ilm.cjs";
|
|
4
4
|
import { MathVariant } from "./variant.cjs";
|
|
5
5
|
//#region src/mathml/layout.d.ts
|
|
6
6
|
interface LayoutFormulaOptions {
|
package/dist/mathml/layout.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { r as MathMlNode } from "../nodes-pArN9ilm.js";
|
|
1
2
|
import { MathBox, MathColor, MathDiagnostic, MathLayoutResult } from "./layout-types.js";
|
|
2
3
|
import { MathFontMetrics } from "./metrics.js";
|
|
3
|
-
import { r as MathMlNode } from "../nodes-pArN9ilm.js";
|
|
4
4
|
import { MathVariant } from "./variant.js";
|
|
5
5
|
//#region src/mathml/layout.d.ts
|
|
6
6
|
interface LayoutFormulaOptions {
|
package/dist/mathml/layout.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EMPTY_BOX, concatBoxesHorizontally, placeChild, shiftItems } from "./compose.js";
|
|
2
1
|
import { parseMathLength } from "./length.js";
|
|
3
2
|
import { attrValue, elementChildren, elementLocalName, isMathMlElement, textContent } from "./nodes.js";
|
|
4
3
|
import { operatorProperties } from "./operators.js";
|
|
5
|
-
import { buildRadicalSign } from "./radical.js";
|
|
6
4
|
import { applyMathVariant, isMathVariant } from "./variant.js";
|
|
5
|
+
import { EMPTY_BOX, concatBoxesHorizontally, placeChild, shiftItems } from "./compose.js";
|
|
6
|
+
import { buildRadicalSign } from "./radical.js";
|
|
7
7
|
//#region src/mathml/layout.ts
|
|
8
8
|
function rootContext(options, diagnostics) {
|
|
9
9
|
return {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let document_schema_js = require("document-schema.js");
|
|
3
|
+
//#region src/model/embedded-drawing.ts
|
|
4
|
+
function buildDrawingBlock(size, vectors) {
|
|
5
|
+
const page = {
|
|
6
|
+
size,
|
|
7
|
+
shapes: [],
|
|
8
|
+
vectors: [...vectors]
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
kind: "embeddedObject",
|
|
12
|
+
objectKind: "drawing",
|
|
13
|
+
document: {
|
|
14
|
+
kind: "drawing",
|
|
15
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
16
|
+
metadata: {},
|
|
17
|
+
pages: [page]
|
|
18
|
+
},
|
|
19
|
+
frame: {
|
|
20
|
+
xPt: 0,
|
|
21
|
+
yPt: 0,
|
|
22
|
+
widthPt: size.widthPt,
|
|
23
|
+
heightPt: size.heightPt
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function drawingOfBlock(block) {
|
|
28
|
+
return block.document.kind === "drawing" ? block.document : void 0;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.buildDrawingBlock = buildDrawingBlock;
|
|
32
|
+
exports.drawingOfBlock = drawingOfBlock;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContentDocument, ContentEmbeddedObjectBlock, ContentVector, PageSize } from "document-schema.js";
|
|
2
|
+
//#region src/model/embedded-drawing.d.ts
|
|
3
|
+
declare function buildDrawingBlock(size: PageSize, vectors: readonly ContentVector[]): ContentEmbeddedObjectBlock;
|
|
4
|
+
declare function drawingOfBlock(block: ContentEmbeddedObjectBlock): Extract<ContentDocument, {
|
|
5
|
+
kind: 'drawing';
|
|
6
|
+
}> | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buildDrawingBlock, drawingOfBlock };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContentDocument, ContentEmbeddedObjectBlock, ContentVector, PageSize } from "document-schema.js";
|
|
2
|
+
//#region src/model/embedded-drawing.d.ts
|
|
3
|
+
declare function buildDrawingBlock(size: PageSize, vectors: readonly ContentVector[]): ContentEmbeddedObjectBlock;
|
|
4
|
+
declare function drawingOfBlock(block: ContentEmbeddedObjectBlock): Extract<ContentDocument, {
|
|
5
|
+
kind: 'drawing';
|
|
6
|
+
}> | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buildDrawingBlock, drawingOfBlock };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CONTENT_FORMAT_VERSION } from "document-schema.js";
|
|
2
|
+
//#region src/model/embedded-drawing.ts
|
|
3
|
+
function buildDrawingBlock(size, vectors) {
|
|
4
|
+
const page = {
|
|
5
|
+
size,
|
|
6
|
+
shapes: [],
|
|
7
|
+
vectors: [...vectors]
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
kind: "embeddedObject",
|
|
11
|
+
objectKind: "drawing",
|
|
12
|
+
document: {
|
|
13
|
+
kind: "drawing",
|
|
14
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
15
|
+
metadata: {},
|
|
16
|
+
pages: [page]
|
|
17
|
+
},
|
|
18
|
+
frame: {
|
|
19
|
+
xPt: 0,
|
|
20
|
+
yPt: 0,
|
|
21
|
+
widthPt: size.widthPt,
|
|
22
|
+
heightPt: size.heightPt
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function drawingOfBlock(block) {
|
|
27
|
+
return block.document.kind === "drawing" ? block.document : void 0;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { buildDrawingBlock, drawingOfBlock };
|
package/dist/model/formula.cjs
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let document_schema_js = require("document-schema.js");
|
|
3
|
+
//#region src/model/formula.ts
|
|
4
|
+
function formulaDocument(formula, metadata = {}) {
|
|
5
|
+
return {
|
|
6
|
+
kind: "formula",
|
|
7
|
+
formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
|
|
8
|
+
metadata,
|
|
9
|
+
formula
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function buildFormulaBlock(formula, frame, sourcePath) {
|
|
13
|
+
return {
|
|
14
|
+
kind: "embeddedObject",
|
|
15
|
+
objectKind: "formula",
|
|
16
|
+
document: formulaDocument(formula),
|
|
17
|
+
frame,
|
|
18
|
+
sourcePath
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function formulaOfBlock(block) {
|
|
22
|
+
return block.document.kind === "formula" ? block.document.formula : void 0;
|
|
23
|
+
}
|
|
24
|
+
function formulaPlaceholderText(formula) {
|
|
25
|
+
return formula.starMath ?? "[formula]";
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.buildFormulaBlock = buildFormulaBlock;
|
|
29
|
+
exports.formulaDocument = formulaDocument;
|
|
30
|
+
exports.formulaOfBlock = formulaOfBlock;
|
|
31
|
+
exports.formulaPlaceholderText = formulaPlaceholderText;
|
package/dist/model/formula.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Box, ContentDocument, ContentEmbeddedObjectBlock, ContentFormula, LayoutMetadata } from "document-schema.js";
|
|
2
2
|
//#region src/model/formula.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare function formulaDocument(formula: ContentFormula, metadata?: LayoutMetadata): ContentDocument;
|
|
4
|
+
declare function buildFormulaBlock(formula: ContentFormula, frame: Box, sourcePath: string): ContentEmbeddedObjectBlock;
|
|
5
|
+
declare function formulaOfBlock(block: ContentEmbeddedObjectBlock): ContentFormula | undefined;
|
|
6
|
+
declare function formulaPlaceholderText(formula: ContentFormula): string;
|
|
7
7
|
//#endregion
|
|
8
|
-
export {
|
|
8
|
+
export { buildFormulaBlock, formulaDocument, formulaOfBlock, formulaPlaceholderText };
|
package/dist/model/formula.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Box, ContentDocument, ContentEmbeddedObjectBlock, ContentFormula, LayoutMetadata } from "document-schema.js";
|
|
2
2
|
//#region src/model/formula.d.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare function formulaDocument(formula: ContentFormula, metadata?: LayoutMetadata): ContentDocument;
|
|
4
|
+
declare function buildFormulaBlock(formula: ContentFormula, frame: Box, sourcePath: string): ContentEmbeddedObjectBlock;
|
|
5
|
+
declare function formulaOfBlock(block: ContentEmbeddedObjectBlock): ContentFormula | undefined;
|
|
6
|
+
declare function formulaPlaceholderText(formula: ContentFormula): string;
|
|
7
7
|
//#endregion
|
|
8
|
-
export {
|
|
8
|
+
export { buildFormulaBlock, formulaDocument, formulaOfBlock, formulaPlaceholderText };
|
package/dist/model/formula.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CONTENT_FORMAT_VERSION } from "document-schema.js";
|
|
2
|
+
//#region src/model/formula.ts
|
|
3
|
+
function formulaDocument(formula, metadata = {}) {
|
|
4
|
+
return {
|
|
5
|
+
kind: "formula",
|
|
6
|
+
formatVersion: CONTENT_FORMAT_VERSION,
|
|
7
|
+
metadata,
|
|
8
|
+
formula
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function buildFormulaBlock(formula, frame, sourcePath) {
|
|
12
|
+
return {
|
|
13
|
+
kind: "embeddedObject",
|
|
14
|
+
objectKind: "formula",
|
|
15
|
+
document: formulaDocument(formula),
|
|
16
|
+
frame,
|
|
17
|
+
sourcePath
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function formulaOfBlock(block) {
|
|
21
|
+
return block.document.kind === "formula" ? block.document.formula : void 0;
|
|
22
|
+
}
|
|
23
|
+
function formulaPlaceholderText(formula) {
|
|
24
|
+
return formula.starMath ?? "[formula]";
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { buildFormulaBlock, formulaDocument, formulaOfBlock, formulaPlaceholderText };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PAGE_SIZE_A4, c as PageSizeSchema, d as flipY, i as MarginsSchema, l as SLIDE_SIZE_STANDARD, n as BoxSchema, o as PAGE_SIZE_LETTER, r as Margins, s as PageSize, t as Box, u as SLIDE_SIZE_WIDESCREEN } from "../geometry-
|
|
1
|
+
import { a as PAGE_SIZE_A4, c as PageSizeSchema, d as flipY, i as MarginsSchema, l as SLIDE_SIZE_STANDARD, n as BoxSchema, o as PAGE_SIZE_LETTER, r as Margins, s as PageSize, t as Box, u as SLIDE_SIZE_WIDESCREEN } from "../geometry-DaJr8yQW.cjs";
|
|
2
2
|
export { type Box, BoxSchema, type Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, flipY };
|
package/dist/model/geometry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PAGE_SIZE_A4, c as PageSizeSchema, d as flipY, i as MarginsSchema, l as SLIDE_SIZE_STANDARD, n as BoxSchema, o as PAGE_SIZE_LETTER, r as Margins, s as PageSize, t as Box, u as SLIDE_SIZE_WIDESCREEN } from "../geometry-
|
|
1
|
+
import { a as PAGE_SIZE_A4, c as PageSizeSchema, d as flipY, i as MarginsSchema, l as SLIDE_SIZE_STANDARD, n as BoxSchema, o as PAGE_SIZE_LETTER, r as Margins, s as PageSize, t as Box, u as SLIDE_SIZE_WIDESCREEN } from "../geometry-DaJr8yQW.js";
|
|
2
2
|
export { type Box, BoxSchema, type Margins, MarginsSchema, PAGE_SIZE_A4, PAGE_SIZE_LETTER, type PageSize, PageSizeSchema, SLIDE_SIZE_STANDARD, SLIDE_SIZE_WIDESCREEN, flipY };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/model/paint-order.ts
|
|
3
|
+
function mergeByPaintOrder(vectors, shapes) {
|
|
4
|
+
const entries = [...vectors.map((value) => ({
|
|
5
|
+
kind: "vector",
|
|
6
|
+
value
|
|
7
|
+
})), ...shapes.map((value) => ({
|
|
8
|
+
kind: "shape",
|
|
9
|
+
value
|
|
10
|
+
}))];
|
|
11
|
+
if (entries.some((entry) => entry.value.paintOrder === void 0)) return entries;
|
|
12
|
+
return entries.sort((a, b) => (a.value.paintOrder ?? 0) - (b.value.paintOrder ?? 0));
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.mergeByPaintOrder = mergeByPaintOrder;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/model/paint-order.d.ts
|
|
2
|
+
interface PaintOrdered {
|
|
3
|
+
readonly paintOrder?: number;
|
|
4
|
+
}
|
|
5
|
+
type PaintOrderEntry<V, S> = {
|
|
6
|
+
readonly kind: 'vector';
|
|
7
|
+
readonly value: V;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'shape';
|
|
10
|
+
readonly value: S;
|
|
11
|
+
};
|
|
12
|
+
declare function mergeByPaintOrder<V extends PaintOrdered, S extends PaintOrdered>(vectors: readonly V[], shapes: readonly S[]): PaintOrderEntry<V, S>[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PaintOrderEntry, PaintOrdered, mergeByPaintOrder };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/model/paint-order.d.ts
|
|
2
|
+
interface PaintOrdered {
|
|
3
|
+
readonly paintOrder?: number;
|
|
4
|
+
}
|
|
5
|
+
type PaintOrderEntry<V, S> = {
|
|
6
|
+
readonly kind: 'vector';
|
|
7
|
+
readonly value: V;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'shape';
|
|
10
|
+
readonly value: S;
|
|
11
|
+
};
|
|
12
|
+
declare function mergeByPaintOrder<V extends PaintOrdered, S extends PaintOrdered>(vectors: readonly V[], shapes: readonly S[]): PaintOrderEntry<V, S>[];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PaintOrderEntry, PaintOrdered, mergeByPaintOrder };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/model/paint-order.ts
|
|
2
|
+
function mergeByPaintOrder(vectors, shapes) {
|
|
3
|
+
const entries = [...vectors.map((value) => ({
|
|
4
|
+
kind: "vector",
|
|
5
|
+
value
|
|
6
|
+
})), ...shapes.map((value) => ({
|
|
7
|
+
kind: "shape",
|
|
8
|
+
value
|
|
9
|
+
}))];
|
|
10
|
+
if (entries.some((entry) => entry.value.paintOrder === void 0)) return entries;
|
|
11
|
+
return entries.sort((a, b) => (a.value.paintOrder ?? 0) - (b.value.paintOrder ?? 0));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { mergeByPaintOrder };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let odf_js = require("odf.js");
|
|
3
|
+
//#region src/odb/components.ts
|
|
4
|
+
function readOdbForms(pkg) {
|
|
5
|
+
return (0, odf_js.readOdbInventory)(pkg).forms.map((component) => (0, odf_js.readOdbForm)(pkg, component.name));
|
|
6
|
+
}
|
|
7
|
+
function readOdbReports(pkg) {
|
|
8
|
+
return (0, odf_js.readOdbInventory)(pkg).reports.map((component) => (0, odf_js.readOdbReport)(pkg, component.name));
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.readOdbForms = readOdbForms;
|
|
12
|
+
exports.readOdbReports = readOdbReports;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OdbForm, OdbReport, Package } from "odf.js";
|
|
2
|
+
//#region src/odb/components.d.ts
|
|
3
|
+
declare function readOdbForms(pkg: Package): readonly OdbForm[];
|
|
4
|
+
declare function readOdbReports(pkg: Package): readonly OdbReport[];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { readOdbForms, readOdbReports };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OdbForm, OdbReport, Package } from "odf.js";
|
|
2
|
+
//#region src/odb/components.d.ts
|
|
3
|
+
declare function readOdbForms(pkg: Package): readonly OdbForm[];
|
|
4
|
+
declare function readOdbReports(pkg: Package): readonly OdbReport[];
|
|
5
|
+
//#endregion
|
|
6
|
+
export { readOdbForms, readOdbReports };
|