documents.js 2.1.0 → 2.3.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 +72 -33
- package/dist/codecs/registry.cjs +7 -0
- package/dist/codecs/registry.js +7 -0
- package/dist/convert/capability.cjs +5 -0
- package/dist/convert/capability.js +5 -0
- package/dist/convert/codec.cjs +10 -0
- package/dist/convert/codec.d.cts +3 -1
- package/dist/convert/codec.d.ts +3 -1
- package/dist/convert/codec.js +11 -3
- package/dist/convert/composition.cjs +17 -0
- package/dist/convert/composition.d.cts +5 -2
- package/dist/convert/composition.d.ts +5 -2
- package/dist/convert/composition.js +17 -0
- package/dist/convert/convert.cjs +16 -0
- package/dist/convert/convert.d.cts +13 -1
- package/dist/convert/convert.d.ts +13 -1
- package/dist/convert/convert.js +13 -1
- package/dist/convert/local.cjs +2 -1
- package/dist/convert/local.js +2 -1
- package/dist/convert/port.cjs +1 -0
- package/dist/convert/port.d.cts +2 -0
- package/dist/convert/port.d.ts +2 -0
- package/dist/convert/port.js +1 -0
- package/dist/diagnostics-C5-bG09J.d.cts +18 -0
- package/dist/diagnostics-C5-bG09J.d.ts +18 -0
- package/dist/edit/odg/scaffold.js +8 -8
- package/dist/edit/odp/scaffold.js +8 -8
- package/dist/edit/ods/scaffold.js +8 -8
- package/dist/edit/odt/scaffold.js +8 -8
- package/dist/index.cjs +31 -0
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +12 -4
- package/dist/latex/diagnostics.cjs +21 -0
- package/dist/latex/diagnostics.d.cts +2 -0
- package/dist/latex/diagnostics.d.ts +2 -0
- package/dist/latex/diagnostics.js +19 -0
- package/dist/latex/lint.cjs +82 -0
- package/dist/latex/lint.d.cts +6 -0
- package/dist/latex/lint.d.ts +6 -0
- package/dist/latex/lint.js +81 -0
- package/dist/latex/lower.cjs +550 -0
- package/dist/latex/lower.d.cts +24 -0
- package/dist/latex/lower.d.ts +24 -0
- package/dist/latex/lower.js +548 -0
- package/dist/latex/rational.cjs +29 -0
- package/dist/latex/rational.d.cts +11 -0
- package/dist/latex/rational.d.ts +11 -0
- package/dist/latex/rational.js +27 -0
- package/dist/latex/symbols.cjs +128 -0
- package/dist/latex/symbols.d.cts +16 -0
- package/dist/latex/symbols.d.ts +16 -0
- package/dist/latex/symbols.js +124 -0
- package/dist/latex/temml.cjs +121 -0
- package/dist/latex/temml.d.cts +25 -0
- package/dist/latex/temml.d.ts +25 -0
- package/dist/latex/temml.js +93 -0
- package/dist/markdown/math.cjs +110 -0
- package/dist/markdown/math.d.cts +9 -0
- package/dist/markdown/math.d.ts +9 -0
- package/dist/markdown/math.js +109 -0
- package/dist/markdown/read.cjs +3 -2
- package/dist/markdown/read.d.cts +2 -1
- package/dist/markdown/read.d.ts +2 -1
- package/dist/markdown/read.js +3 -2
- package/dist/markdown/write.cjs +23 -4
- package/dist/markdown/write.js +23 -4
- package/dist/metadata/write.cjs +1 -0
- package/dist/metadata/write.js +1 -0
- package/dist/model/bytes.cjs +5 -0
- package/dist/model/bytes.d.cts +2 -1
- package/dist/model/bytes.d.ts +2 -1
- package/dist/model/bytes.js +5 -1
- package/dist/model/formula.cjs +1 -1
- package/dist/model/formula.js +1 -1
- package/dist/svg/diagnostics.cjs +19 -0
- package/dist/svg/diagnostics.d.cts +10 -0
- package/dist/svg/diagnostics.d.ts +10 -0
- package/dist/svg/diagnostics.js +18 -0
- package/dist/svg/paint.cjs +817 -0
- package/dist/svg/paint.d.cts +19 -0
- package/dist/svg/paint.d.ts +19 -0
- package/dist/svg/paint.js +814 -0
- package/dist/svg/path.cjs +337 -0
- package/dist/svg/path.d.cts +22 -0
- package/dist/svg/path.d.ts +22 -0
- package/dist/svg/path.js +336 -0
- package/dist/svg/read.cjs +677 -0
- package/dist/svg/read.d.cts +12 -0
- package/dist/svg/read.d.ts +12 -0
- package/dist/svg/read.js +675 -0
- package/dist/svg/text.cjs +22 -0
- package/dist/svg/text.d.cts +8 -0
- package/dist/svg/text.d.ts +8 -0
- package/dist/svg/text.js +19 -0
- package/dist/svg/transform.cjs +206 -0
- package/dist/svg/transform.d.cts +23 -0
- package/dist/svg/transform.d.ts +23 -0
- package/dist/svg/transform.js +197 -0
- package/dist/svg/units.cjs +47 -0
- package/dist/svg/units.d.cts +12 -0
- package/dist/svg/units.d.ts +12 -0
- package/dist/svg/units.js +44 -0
- package/dist/svg/write.cjs +127 -0
- package/dist/svg/write.d.cts +23 -0
- package/dist/svg/write.d.ts +23 -0
- package/dist/svg/write.js +123 -0
- package/dist/xml/odf-text.js +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { buildFormulaBlock } from "../model/formula.js";
|
|
2
|
+
import { extractSymbolDefinitionsFromProse } from "../latex/symbols.js";
|
|
3
|
+
import { latexToFormula } from "../latex/lower.js";
|
|
4
|
+
//#region src/markdown/math.ts
|
|
5
|
+
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
6
|
+
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
7
|
+
const STAND_IN_FRAME = {
|
|
8
|
+
xPt: 0,
|
|
9
|
+
yPt: 0,
|
|
10
|
+
widthPt: 0,
|
|
11
|
+
heightPt: 22
|
|
12
|
+
};
|
|
13
|
+
const MATH_BLOCK_SOURCE = "markdown:math-block";
|
|
14
|
+
const MATH_INLINE_SOURCE = "markdown:math-inline";
|
|
15
|
+
function extractInlineMath(runs) {
|
|
16
|
+
const latexRuns = [];
|
|
17
|
+
const remainingRuns = [];
|
|
18
|
+
for (const run of runs) {
|
|
19
|
+
if (run.fontFamily === MATH_INLINE_FONT_MARKER && run.text.trim() !== "") {
|
|
20
|
+
latexRuns.push(run.text);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
remainingRuns.push(run);
|
|
24
|
+
}
|
|
25
|
+
const consumed = latexRuns.length > 0 && remainingRuns.every((run) => run.text === "");
|
|
26
|
+
return {
|
|
27
|
+
latexRuns,
|
|
28
|
+
remainingRuns: consumed ? [] : remainingRuns,
|
|
29
|
+
consumed
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function lowerMarkdownMath(document, options) {
|
|
33
|
+
if (document.kind !== "wordprocessing") return document;
|
|
34
|
+
const sink = options?.onDiagnostic;
|
|
35
|
+
const proseEntries = extractSymbolDefinitionsFromProse(document, sink);
|
|
36
|
+
const known = new Map(proseEntries.map((entry) => [entry.glyph, entry]));
|
|
37
|
+
const minted = /* @__PURE__ */ new Map();
|
|
38
|
+
const lowerOne = (latex, source) => {
|
|
39
|
+
if (latex.trim() === "") return;
|
|
40
|
+
const result = latexToFormula(latex, {
|
|
41
|
+
symbolEntries: [...known.values()],
|
|
42
|
+
source
|
|
43
|
+
});
|
|
44
|
+
for (const diagnostic of result.diagnostics) sink?.(diagnostic);
|
|
45
|
+
for (const entry of result.mintedSymbols) if (!known.has(entry.glyph) && !minted.has(entry.glyph)) minted.set(entry.glyph, entry);
|
|
46
|
+
return buildFormulaBlock(result.formula, STAND_IN_FRAME, source);
|
|
47
|
+
};
|
|
48
|
+
const lowerBlocks = (blocks) => {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const block of blocks) {
|
|
51
|
+
if (block.kind === "table") {
|
|
52
|
+
out.push({
|
|
53
|
+
...block,
|
|
54
|
+
rows: block.rows.map((row) => ({
|
|
55
|
+
...row,
|
|
56
|
+
cells: row.cells.map((cell) => ({
|
|
57
|
+
...cell,
|
|
58
|
+
blocks: lowerBlocks(cell.blocks)
|
|
59
|
+
}))
|
|
60
|
+
}))
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (block.kind !== "paragraph") {
|
|
65
|
+
out.push(block);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (block.styleId === MATH_BLOCK_STYLE_ID) {
|
|
69
|
+
const latex = block.runs.map((run) => run.text).join("");
|
|
70
|
+
const formulaBlock = lowerOne(latex, MATH_BLOCK_SOURCE);
|
|
71
|
+
out.push(formulaBlock ?? block);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const extraction = extractInlineMath(block.runs);
|
|
75
|
+
if (extraction.latexRuns.length === 0) {
|
|
76
|
+
out.push(block);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!extraction.consumed) out.push({
|
|
80
|
+
...block,
|
|
81
|
+
runs: [...extraction.remainingRuns]
|
|
82
|
+
});
|
|
83
|
+
for (const latex of extraction.latexRuns) {
|
|
84
|
+
const formulaBlock = lowerOne(latex, MATH_INLINE_SOURCE);
|
|
85
|
+
if (formulaBlock !== void 0) out.push(formulaBlock);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
};
|
|
90
|
+
const sections = document.sections.map((section) => ({
|
|
91
|
+
...section,
|
|
92
|
+
blocks: lowerBlocks(section.blocks)
|
|
93
|
+
}));
|
|
94
|
+
const symbols = [...known.values(), ...minted.values()];
|
|
95
|
+
if (symbols.length === 0) return {
|
|
96
|
+
...document,
|
|
97
|
+
sections
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
...document,
|
|
101
|
+
sections,
|
|
102
|
+
symbolTable: {
|
|
103
|
+
symbols,
|
|
104
|
+
units: []
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { lowerMarkdownMath };
|
package/dist/markdown/read.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_markdown_math = require("./math.cjs");
|
|
2
3
|
let markdown_codec = require("markdown-codec");
|
|
3
4
|
//#region src/markdown/read.ts
|
|
4
|
-
function readMarkdownContent(text, options) {
|
|
5
|
+
function readMarkdownContent(text, options, math) {
|
|
5
6
|
const { document } = (0, markdown_codec.readMarkdown)(text, {
|
|
6
7
|
frontMatter: true,
|
|
7
8
|
...options
|
|
8
9
|
});
|
|
9
10
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
|
|
10
|
-
return document;
|
|
11
|
+
return require_markdown_math.lowerMarkdownMath(document, math);
|
|
11
12
|
}
|
|
12
13
|
//#endregion
|
|
13
14
|
exports.readMarkdownContent = readMarkdownContent;
|
package/dist/markdown/read.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MarkdownMathLoweringOptions } from "./math.cjs";
|
|
1
2
|
import { ContentDocument } from "document-schema.js";
|
|
2
3
|
import { ReadMarkdownOptions } from "markdown-codec";
|
|
3
4
|
//#region src/markdown/read.d.ts
|
|
4
|
-
declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions): ContentDocument;
|
|
5
|
+
declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions, math?: MarkdownMathLoweringOptions): ContentDocument;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { readMarkdownContent };
|
package/dist/markdown/read.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { MarkdownMathLoweringOptions } from "./math.js";
|
|
1
2
|
import { ContentDocument } from "document-schema.js";
|
|
2
3
|
import { ReadMarkdownOptions } from "markdown-codec";
|
|
3
4
|
//#region src/markdown/read.d.ts
|
|
4
|
-
declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions): ContentDocument;
|
|
5
|
+
declare function readMarkdownContent(text: string, options?: ReadMarkdownOptions, math?: MarkdownMathLoweringOptions): ContentDocument;
|
|
5
6
|
//#endregion
|
|
6
7
|
export { readMarkdownContent };
|
package/dist/markdown/read.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { lowerMarkdownMath } from "./math.js";
|
|
1
2
|
import { readMarkdown } from "markdown-codec";
|
|
2
3
|
//#region src/markdown/read.ts
|
|
3
|
-
function readMarkdownContent(text, options) {
|
|
4
|
+
function readMarkdownContent(text, options, math) {
|
|
4
5
|
const { document } = readMarkdown(text, {
|
|
5
6
|
frontMatter: true,
|
|
6
7
|
...options
|
|
7
8
|
});
|
|
8
9
|
if (document.kind !== "wordprocessing") throw new Error("readMarkdown returned a non-wordprocessing ContentDocument");
|
|
9
|
-
return document;
|
|
10
|
+
return lowerMarkdownMath(document, math);
|
|
10
11
|
}
|
|
11
12
|
//#endregion
|
|
12
13
|
export { readMarkdownContent };
|
package/dist/markdown/write.cjs
CHANGED
|
@@ -2,6 +2,28 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_model_formula = require("../model/formula.cjs");
|
|
3
3
|
let markdown_codec = require("markdown-codec");
|
|
4
4
|
//#region src/markdown/write.ts
|
|
5
|
+
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
6
|
+
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
7
|
+
const MATH_INLINE_SOURCE = "markdown:math-inline";
|
|
8
|
+
function formulaParagraph(formula) {
|
|
9
|
+
const latex = formula.presentation?.latex;
|
|
10
|
+
if (latex === void 0) return {
|
|
11
|
+
kind: "paragraph",
|
|
12
|
+
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
13
|
+
};
|
|
14
|
+
if (formula.provenance?.source === MATH_INLINE_SOURCE) return {
|
|
15
|
+
kind: "paragraph",
|
|
16
|
+
runs: [{
|
|
17
|
+
text: latex,
|
|
18
|
+
fontFamily: MATH_INLINE_FONT_MARKER
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
kind: "paragraph",
|
|
23
|
+
runs: [{ text: latex }],
|
|
24
|
+
styleId: MATH_BLOCK_STYLE_ID
|
|
25
|
+
};
|
|
26
|
+
}
|
|
5
27
|
function markdownBlock(block) {
|
|
6
28
|
if (block.kind === "table") return {
|
|
7
29
|
...block,
|
|
@@ -12,10 +34,7 @@ function markdownBlock(block) {
|
|
|
12
34
|
};
|
|
13
35
|
if (block.kind === "embeddedObject") {
|
|
14
36
|
const formula = require_model_formula.formulaOfBlock(block);
|
|
15
|
-
if (formula !== void 0) return
|
|
16
|
-
kind: "paragraph",
|
|
17
|
-
runs: [{ text: require_model_formula.formulaPlaceholderText(formula) }]
|
|
18
|
-
};
|
|
37
|
+
if (formula !== void 0) return formulaParagraph(formula);
|
|
19
38
|
return block;
|
|
20
39
|
}
|
|
21
40
|
return block;
|
package/dist/markdown/write.js
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { formulaOfBlock, formulaPlaceholderText } from "../model/formula.js";
|
|
2
2
|
import { MarkdownUnsupportedDocumentKindError, writeMarkdown } from "markdown-codec";
|
|
3
3
|
//#region src/markdown/write.ts
|
|
4
|
+
const MATH_BLOCK_STYLE_ID = "MathBlock";
|
|
5
|
+
const MATH_INLINE_FONT_MARKER = "Cambria Math";
|
|
6
|
+
const MATH_INLINE_SOURCE = "markdown:math-inline";
|
|
7
|
+
function formulaParagraph(formula) {
|
|
8
|
+
const latex = formula.presentation?.latex;
|
|
9
|
+
if (latex === void 0) return {
|
|
10
|
+
kind: "paragraph",
|
|
11
|
+
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
12
|
+
};
|
|
13
|
+
if (formula.provenance?.source === MATH_INLINE_SOURCE) return {
|
|
14
|
+
kind: "paragraph",
|
|
15
|
+
runs: [{
|
|
16
|
+
text: latex,
|
|
17
|
+
fontFamily: MATH_INLINE_FONT_MARKER
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
kind: "paragraph",
|
|
22
|
+
runs: [{ text: latex }],
|
|
23
|
+
styleId: MATH_BLOCK_STYLE_ID
|
|
24
|
+
};
|
|
25
|
+
}
|
|
4
26
|
function markdownBlock(block) {
|
|
5
27
|
if (block.kind === "table") return {
|
|
6
28
|
...block,
|
|
@@ -11,10 +33,7 @@ function markdownBlock(block) {
|
|
|
11
33
|
};
|
|
12
34
|
if (block.kind === "embeddedObject") {
|
|
13
35
|
const formula = formulaOfBlock(block);
|
|
14
|
-
if (formula !== void 0) return
|
|
15
|
-
kind: "paragraph",
|
|
16
|
-
runs: [{ text: formulaPlaceholderText(formula) }]
|
|
17
|
-
};
|
|
36
|
+
if (formula !== void 0) return formulaParagraph(formula);
|
|
18
37
|
return block;
|
|
19
38
|
}
|
|
20
39
|
return block;
|
package/dist/metadata/write.cjs
CHANGED
|
@@ -39,6 +39,7 @@ function classifyWritePath(source, target) {
|
|
|
39
39
|
if (source === "pdf" && target === "pdf") return { kind: "pdf" };
|
|
40
40
|
if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
|
|
41
41
|
if (target === "csv" || source === "csv") return { errorMessage: "'csv' is not a supported setDocumentMetadata source or target -- RFC 4180 text has no metadata container, so a rebuild would silently drop the override. Convert to or from csv first, then patch metadata on the package format." };
|
|
42
|
+
if (target === "svg" || source === "svg") return { errorMessage: "'svg' is not a supported setDocumentMetadata source or target -- this package's SVG metadata surface is the root <title> element alone, so an author/subject/keywords override would be silently dropped by the rebuild. Convert to or from svg first, then patch metadata on the package format." };
|
|
42
43
|
if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
|
|
43
44
|
if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
|
|
44
45
|
return {
|
package/dist/metadata/write.js
CHANGED
|
@@ -38,6 +38,7 @@ function classifyWritePath(source, target) {
|
|
|
38
38
|
if (source === "pdf" && target === "pdf") return { kind: "pdf" };
|
|
39
39
|
if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
|
|
40
40
|
if (target === "csv" || source === "csv") return { errorMessage: "'csv' is not a supported setDocumentMetadata source or target -- RFC 4180 text has no metadata container, so a rebuild would silently drop the override. Convert to or from csv first, then patch metadata on the package format." };
|
|
41
|
+
if (target === "svg" || source === "svg") return { errorMessage: "'svg' is not a supported setDocumentMetadata source or target -- this package's SVG metadata surface is the root <title> element alone, so an author/subject/keywords override would be silently dropped by the rebuild. Convert to or from svg first, then patch metadata on the package format." };
|
|
41
42
|
if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
|
|
42
43
|
if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
|
|
43
44
|
return {
|
package/dist/model/bytes.cjs
CHANGED
|
@@ -90,6 +90,10 @@ function isWellFormedUtf8Text(bytes) {
|
|
|
90
90
|
}
|
|
91
91
|
const MarkdownBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
|
|
92
92
|
const CsvBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
|
|
93
|
+
const SvgBytesSchema = zod.z.instanceof(Uint8Array).refine((bytes) => {
|
|
94
|
+
if (!isWellFormedUtf8Text(bytes)) return false;
|
|
95
|
+
return new TextDecoder().decode(bytes).toLowerCase().includes("<svg");
|
|
96
|
+
}, { message: "not a valid SVG file: not well-formed UTF-8 text containing an <svg root element" });
|
|
93
97
|
//#endregion
|
|
94
98
|
exports.CsvBytesSchema = CsvBytesSchema;
|
|
95
99
|
exports.DocxBytesSchema = DocxBytesSchema;
|
|
@@ -100,4 +104,5 @@ exports.OdsBytesSchema = OdsBytesSchema;
|
|
|
100
104
|
exports.OdtBytesSchema = OdtBytesSchema;
|
|
101
105
|
exports.PdfBytesSchema = PdfBytesSchema;
|
|
102
106
|
exports.PptxBytesSchema = PptxBytesSchema;
|
|
107
|
+
exports.SvgBytesSchema = SvgBytesSchema;
|
|
103
108
|
exports.XlsxBytesSchema = XlsxBytesSchema;
|
package/dist/model/bytes.d.cts
CHANGED
|
@@ -10,5 +10,6 @@ declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
|
|
|
10
10
|
declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
11
11
|
declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
12
12
|
declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
|
+
declare const SvgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
14
|
//#endregion
|
|
14
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
|
|
15
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
package/dist/model/bytes.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
|
|
|
10
10
|
declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
11
11
|
declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
12
12
|
declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
|
+
declare const SvgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
|
|
13
14
|
//#endregion
|
|
14
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
|
|
15
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
package/dist/model/bytes.js
CHANGED
|
@@ -89,5 +89,9 @@ function isWellFormedUtf8Text(bytes) {
|
|
|
89
89
|
}
|
|
90
90
|
const MarkdownBytesSchema = z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
|
|
91
91
|
const CsvBytesSchema = z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
|
|
92
|
+
const SvgBytesSchema = z.instanceof(Uint8Array).refine((bytes) => {
|
|
93
|
+
if (!isWellFormedUtf8Text(bytes)) return false;
|
|
94
|
+
return new TextDecoder().decode(bytes).toLowerCase().includes("<svg");
|
|
95
|
+
}, { message: "not a valid SVG file: not well-formed UTF-8 text containing an <svg root element" });
|
|
92
96
|
//#endregion
|
|
93
|
-
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
|
|
97
|
+
export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, SvgBytesSchema, XlsxBytesSchema };
|
package/dist/model/formula.cjs
CHANGED
|
@@ -22,7 +22,7 @@ function formulaOfBlock(block) {
|
|
|
22
22
|
return block.document.kind === "formula" ? block.document.formula : void 0;
|
|
23
23
|
}
|
|
24
24
|
function formulaPlaceholderText(formula) {
|
|
25
|
-
return formula.starMath ?? "[formula]";
|
|
25
|
+
return formula.starMath ?? formula.presentation?.latex ?? "[formula]";
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
28
|
exports.buildFormulaBlock = buildFormulaBlock;
|
package/dist/model/formula.js
CHANGED
|
@@ -21,7 +21,7 @@ function formulaOfBlock(block) {
|
|
|
21
21
|
return block.document.kind === "formula" ? block.document.formula : void 0;
|
|
22
22
|
}
|
|
23
23
|
function formulaPlaceholderText(formula) {
|
|
24
|
-
return formula.starMath ?? "[formula]";
|
|
24
|
+
return formula.starMath ?? formula.presentation?.latex ?? "[formula]";
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
27
|
export { buildFormulaBlock, formulaDocument, formulaOfBlock, formulaPlaceholderText };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/svg/diagnostics.ts
|
|
3
|
+
const SVG_DIAGNOSTIC_CODES = [
|
|
4
|
+
"svg/text-unsupported",
|
|
5
|
+
"svg/image-unsupported",
|
|
6
|
+
"svg/use-unsupported",
|
|
7
|
+
"svg/gradient-unsupported",
|
|
8
|
+
"svg/element-unsupported",
|
|
9
|
+
"svg/element-skipped",
|
|
10
|
+
"svg/css-style-ignored",
|
|
11
|
+
"svg/paint-unsupported",
|
|
12
|
+
"svg/opacity-ignored",
|
|
13
|
+
"svg/preserve-aspect-ratio-stretched",
|
|
14
|
+
"svg/default-size-assumed",
|
|
15
|
+
"svg/shape-unsupported",
|
|
16
|
+
"svg/stroke-style-unsupported"
|
|
17
|
+
];
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.SVG_DIAGNOSTIC_CODES = SVG_DIAGNOSTIC_CODES;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/svg/diagnostics.d.ts
|
|
2
|
+
declare const SVG_DIAGNOSTIC_CODES: readonly ["svg/text-unsupported", "svg/image-unsupported", "svg/use-unsupported", "svg/gradient-unsupported", "svg/element-unsupported", "svg/element-skipped", "svg/css-style-ignored", "svg/paint-unsupported", "svg/opacity-ignored", "svg/preserve-aspect-ratio-stretched", "svg/default-size-assumed", "svg/shape-unsupported", "svg/stroke-style-unsupported"];
|
|
3
|
+
type SvgDiagnosticCode = (typeof SVG_DIAGNOSTIC_CODES)[number];
|
|
4
|
+
interface SvgDiagnostic {
|
|
5
|
+
readonly code: SvgDiagnosticCode;
|
|
6
|
+
readonly detail?: string;
|
|
7
|
+
}
|
|
8
|
+
type SvgDiagnosticSink = (diagnostic: SvgDiagnostic) => void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { SVG_DIAGNOSTIC_CODES, SvgDiagnostic, SvgDiagnosticCode, SvgDiagnosticSink };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/svg/diagnostics.d.ts
|
|
2
|
+
declare const SVG_DIAGNOSTIC_CODES: readonly ["svg/text-unsupported", "svg/image-unsupported", "svg/use-unsupported", "svg/gradient-unsupported", "svg/element-unsupported", "svg/element-skipped", "svg/css-style-ignored", "svg/paint-unsupported", "svg/opacity-ignored", "svg/preserve-aspect-ratio-stretched", "svg/default-size-assumed", "svg/shape-unsupported", "svg/stroke-style-unsupported"];
|
|
3
|
+
type SvgDiagnosticCode = (typeof SVG_DIAGNOSTIC_CODES)[number];
|
|
4
|
+
interface SvgDiagnostic {
|
|
5
|
+
readonly code: SvgDiagnosticCode;
|
|
6
|
+
readonly detail?: string;
|
|
7
|
+
}
|
|
8
|
+
type SvgDiagnosticSink = (diagnostic: SvgDiagnostic) => void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { SVG_DIAGNOSTIC_CODES, SvgDiagnostic, SvgDiagnosticCode, SvgDiagnosticSink };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/svg/diagnostics.ts
|
|
2
|
+
const SVG_DIAGNOSTIC_CODES = [
|
|
3
|
+
"svg/text-unsupported",
|
|
4
|
+
"svg/image-unsupported",
|
|
5
|
+
"svg/use-unsupported",
|
|
6
|
+
"svg/gradient-unsupported",
|
|
7
|
+
"svg/element-unsupported",
|
|
8
|
+
"svg/element-skipped",
|
|
9
|
+
"svg/css-style-ignored",
|
|
10
|
+
"svg/paint-unsupported",
|
|
11
|
+
"svg/opacity-ignored",
|
|
12
|
+
"svg/preserve-aspect-ratio-stretched",
|
|
13
|
+
"svg/default-size-assumed",
|
|
14
|
+
"svg/shape-unsupported",
|
|
15
|
+
"svg/stroke-style-unsupported"
|
|
16
|
+
];
|
|
17
|
+
//#endregion
|
|
18
|
+
export { SVG_DIAGNOSTIC_CODES };
|