reamkit 1.32.0 → 1.33.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 +5 -4
- package/dist/esm/core/bidi/algorithm.js +2 -2
- package/dist/esm/core/bidi/char-types.js +1 -1
- package/dist/esm/core/bidi/index.js +3 -3
- package/dist/esm/core/bytes.js +1 -1
- package/dist/esm/core/converter/facade.js +3 -2
- package/dist/esm/core/converter/ream.js +12 -5
- package/dist/esm/core/crypto/asn1.js +2 -2
- package/dist/esm/core/crypto/cms.js +5 -3
- package/dist/esm/core/crypto/index.js +2 -1
- package/dist/esm/core/crypto/offcrypto.js +64 -19
- package/dist/esm/core/crypto/primitives.js +16 -16
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +174 -2
- package/dist/esm/core/drawingml/chart-geometry.d.ts +45 -17
- package/dist/esm/core/drawingml/chart-geometry.js +1090 -257
- package/dist/esm/core/drawingml/chart-parser.d.ts +24 -1
- package/dist/esm/core/drawingml/chart-parser.js +334 -41
- package/dist/esm/core/drawingml/chart-text.d.ts +41 -0
- package/dist/esm/core/drawingml/chart-text.js +93 -0
- package/dist/esm/core/drawingml/colors.js +5 -5
- package/dist/esm/core/drawingml/diagram/layout-engine.js +1 -4
- package/dist/esm/core/drawingml/diagram/run.js +2 -1
- package/dist/esm/core/drawingml/preset-geometry.js +4 -6
- package/dist/esm/core/drawingml/shape-render.js +1 -1
- package/dist/esm/core/drawingml/text-warp.js +4 -16
- package/dist/esm/core/drawingml/theme-parser.js +14 -8
- package/dist/esm/core/font/arabic-joining.js +2 -2
- package/dist/esm/core/font/binary-reader.js +2 -0
- package/dist/esm/core/font/font-registry.js +1 -0
- package/dist/esm/core/font/ligatures.js +1 -1
- package/dist/esm/core/font/opentype-layout.js +11 -5
- package/dist/esm/core/font/ttf-build.js +6 -10
- package/dist/esm/core/font/ttf-parser.js +2 -1
- package/dist/esm/core/font/ttf-subset.js +8 -8
- package/dist/esm/core/fonts/families.js +1 -1
- package/dist/esm/core/fonts/remote-fonts.js +4 -4
- package/dist/esm/core/hyphenation/index.js +1 -1
- package/dist/esm/core/images.js +8 -8
- package/dist/esm/core/ir/loss.js +1 -0
- package/dist/esm/core/line-breaker/cjk.js +1 -1
- package/dist/esm/core/line-breaker/index.js +4 -3
- package/dist/esm/core/links.js +1 -1
- package/dist/esm/core/lzw.js +1 -1
- package/dist/esm/core/metafile/blit.js +1 -1
- package/dist/esm/core/metafile/emf.js +5 -7
- package/dist/esm/core/metafile/picture.js +1 -1
- package/dist/esm/core/metafile/symbol-fonts.js +7 -7
- package/dist/esm/core/metafile/wmf.js +5 -7
- package/dist/esm/core/number-format.d.ts +40 -15
- package/dist/esm/core/number-format.js +284 -79
- package/dist/esm/core/numbering/index.js +3 -2
- package/dist/esm/core/ole/cfb.js +4 -4
- package/dist/esm/core/ole/escher-blip.js +1 -1
- package/dist/esm/core/opc/index.js +5 -4
- package/dist/esm/core/opc/package.js +3 -1
- package/dist/esm/core/opc/tag-scan.d.ts +15 -0
- package/dist/esm/core/opc/tag-scan.js +41 -0
- package/dist/esm/core/opc/xml-entities.js +40 -3
- package/dist/esm/core/outline.js +1 -1
- package/dist/esm/core/png-encode.js +3 -3
- package/dist/esm/core/po-helpers.js +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +6 -0
- package/dist/esm/core/style-cascade/index.js +4 -3
- package/dist/esm/core/tiff.js +3 -1
- package/dist/esm/excel/activex-parser.js +1 -1
- package/dist/esm/excel/conditional-format.js +7 -7
- package/dist/esm/excel/formula/functions.js +45 -18
- package/dist/esm/excel/formula/index.js +3 -3
- package/dist/esm/excel/formula/lexer.js +2 -2
- package/dist/esm/excel/formula/parser.js +4 -3
- package/dist/esm/excel/formula/value.js +1 -1
- package/dist/esm/excel/index.js +7 -6
- package/dist/esm/excel/print-model.js +18 -7
- package/dist/esm/excel/printer-settings.js +6 -7
- package/dist/esm/excel/rich-value.js +1 -1
- package/dist/esm/excel/sheet-shape-parser.js +4 -2
- package/dist/esm/excel/sheet-to-flow.js +13 -11
- package/dist/esm/excel/styles-parser.js +5 -3
- package/dist/esm/excel/tint.js +5 -5
- package/dist/esm/excel/vml-drawing.js +3 -3
- package/dist/esm/excel/worksheet-parser.js +5 -5
- package/dist/esm/excel/xls/biff-chart.js +1 -3
- package/dist/esm/excel/xls/biff-reader.js +10 -11
- package/dist/esm/excel/xls/xls-reader.js +1 -1
- package/dist/esm/excel/xlsx-reader.js +56 -9
- package/dist/esm/excel/xlsx-to-pdf.js +1 -1
- package/dist/esm/excel/xlsx-writer.js +2 -2
- package/dist/esm/html/html-writer.js +18 -10
- package/dist/esm/layout/line-paint.js +1 -1
- package/dist/esm/layout/math-layout.js +5 -8
- package/dist/esm/layout/styled-layout.js +104 -32
- package/dist/esm/layout/turned-section.js +2 -2
- package/dist/esm/markdown/markdown-writer.js +59 -8
- package/dist/esm/pdf/encryption.js +9 -9
- package/dist/esm/pdf/icc-profile.js +2 -2
- package/dist/esm/pdf/index.js +3 -2
- package/dist/esm/pdf/objects.js +7 -0
- package/dist/esm/pdf/serialize.js +1 -1
- package/dist/esm/pdf/struct-tree.js +3 -1
- package/dist/esm/pdf/styled-page-emitter.js +23 -15
- package/dist/esm/pdf/styled-page-renderer.js +9 -5
- package/dist/esm/pdf-reader/annot-draw.js +5 -5
- package/dist/esm/pdf-reader/annots.js +3 -1
- package/dist/esm/pdf-reader/ccitt.js +2 -1
- package/dist/esm/pdf-reader/cff-outline.js +1 -4
- package/dist/esm/pdf-reader/content.js +13 -15
- package/dist/esm/pdf-reader/decrypt.js +5 -4
- package/dist/esm/pdf-reader/document.js +6 -2
- package/dist/esm/pdf-reader/encodings.js +1 -1
- package/dist/esm/pdf-reader/flow-build.js +4 -6
- package/dist/esm/pdf-reader/font.js +4 -4
- package/dist/esm/pdf-reader/function.js +8 -7
- package/dist/esm/pdf-reader/icc.js +1 -1
- package/dist/esm/pdf-reader/images.js +1 -1
- package/dist/esm/pdf-reader/jbig2.js +36 -38
- package/dist/esm/pdf-reader/jpeg.js +14 -13
- package/dist/esm/pdf-reader/layout.js +13 -10
- package/dist/esm/pdf-reader/lexer.js +2 -1
- package/dist/esm/pdf-reader/math-rows.js +2 -2
- package/dist/esm/pdf-reader/optional-content.js +1 -1
- package/dist/esm/pdf-reader/page-numbers.js +1 -1
- package/dist/esm/pdf-reader/pattern-tint.js +1 -2
- package/dist/esm/pdf-reader/reader.js +2 -2
- package/dist/esm/pdf-reader/struct-tree.js +1 -1
- package/dist/esm/pdf-reader/tagged.js +3 -2
- package/dist/esm/pdf-reader/text.js +2 -2
- package/dist/esm/pdf-reader/type1-outline.js +1 -3
- package/dist/esm/pptx/embedded-fonts.js +3 -5
- package/dist/esm/pptx/placeholder-cascade.js +1 -1
- package/dist/esm/pptx/ppt/ppt-reader.js +5 -4
- package/dist/esm/pptx/ppt/ppt-text.js +9 -10
- package/dist/esm/pptx/pptx-reader.js +6 -5
- package/dist/esm/pptx/preset-table-styles.js +1 -1
- package/dist/esm/pptx/slide-parser.js +6 -4
- package/dist/esm/pptx/sp-helpers.js +1 -1
- package/dist/esm/pptx/table-style.js +2 -1
- package/dist/esm/svg/svg-writer.js +1 -1
- package/dist/esm/word/doc/doc-reader.js +2 -2
- package/dist/esm/word/doc/doc-text.js +20 -22
- package/dist/esm/word/document-parser.js +27 -22
- package/dist/esm/word/docx-reader.js +15 -10
- package/dist/esm/word/docx-to-pdf.js +6 -6
- package/dist/esm/word/docx-writer.js +10 -6
- package/dist/esm/word/drawing-parser.js +18 -18
- package/dist/esm/word/font-table.js +90 -11
- package/dist/esm/word/index.js +6 -5
- package/dist/esm/word/numbering-parser.js +5 -4
- package/dist/esm/word/omml-parser.js +1 -1
- package/dist/esm/word/paragraph-properties.js +11 -10
- package/dist/esm/word/run-properties.js +4 -4
- package/dist/esm/word/settings-parser.js +2 -1
- package/dist/esm/word/shading.js +1 -1
- package/dist/esm/word/styles-parser.js +5 -4
- package/dist/esm/word/table-parser.js +4 -4
- package/dist/esm/word/theme-fonts.js +1 -1
- package/package.json +10 -4
|
@@ -24,7 +24,7 @@ var parser = new XMLParser({
|
|
|
24
24
|
trimValues: false,
|
|
25
25
|
maxNestedTags: 1e3
|
|
26
26
|
});
|
|
27
|
-
var RUN_CONTAINER_TAGS = new Set([
|
|
27
|
+
var RUN_CONTAINER_TAGS = /* @__PURE__ */ new Set([
|
|
28
28
|
"w:hyperlink",
|
|
29
29
|
"w:sdt",
|
|
30
30
|
"w:sdtContent",
|
|
@@ -102,7 +102,8 @@ function parseBackgroundFill(documentXml, resolveImage) {
|
|
|
102
102
|
return fill.kind === "gradient" || fill.kind === "picture" ? fill : void 0;
|
|
103
103
|
}
|
|
104
104
|
function backgroundNode(documentXml) {
|
|
105
|
-
const
|
|
105
|
+
const tree = parser.parse(resolveInternalEntities(decoder.decode(documentXml)));
|
|
106
|
+
const doc = poFindByPath(tree, ["w:document"]);
|
|
106
107
|
return doc ? poChildren(doc).find((c) => poIs(c, "w:background")) : void 0;
|
|
107
108
|
}
|
|
108
109
|
/** A fresh {@link BlockCounter}. */
|
|
@@ -125,7 +126,7 @@ function bodyIndexForBlock(blocks, blockEnd) {
|
|
|
125
126
|
while (n < blocks.index.length && blocks.index[n] < blockEnd) n++;
|
|
126
127
|
return n;
|
|
127
128
|
}
|
|
128
|
-
var HF_TYPES = new Set([
|
|
129
|
+
var HF_TYPES = /* @__PURE__ */ new Set([
|
|
129
130
|
"default",
|
|
130
131
|
"first",
|
|
131
132
|
"even"
|
|
@@ -400,7 +401,7 @@ function parseBodyElements(children, ctx = DEFAULT_PARSE_CONTEXT, blocks, sdtRun
|
|
|
400
401
|
}
|
|
401
402
|
return out;
|
|
402
403
|
}
|
|
403
|
-
var COLLAPSE_TRANSPARENT_TAGS = new Set([
|
|
404
|
+
var COLLAPSE_TRANSPARENT_TAGS = /* @__PURE__ */ new Set([
|
|
404
405
|
"w:ins",
|
|
405
406
|
"w:moveTo",
|
|
406
407
|
"w:sdt",
|
|
@@ -560,7 +561,8 @@ function parseParagraph(p, ctx, extraBookmarks, anchored, sdtRunProps) {
|
|
|
560
561
|
const mathPara = poChildren(p).find((c) => poIs(c, "m:oMathPara"));
|
|
561
562
|
if (mathPara && properties.alignment === void 0) {
|
|
562
563
|
const paraPr = poChildren(mathPara).find((c) => poIs(c, "m:oMathParaPr"));
|
|
563
|
-
const
|
|
564
|
+
const jcNode = paraPr ? poChildren(paraPr).find((c) => poIs(c, "m:jc")) : void 0;
|
|
565
|
+
const jcVal = poAttr(jcNode, "val");
|
|
564
566
|
const alignment = jcVal === "left" ? "left" : jcVal === "right" ? "right" : "center";
|
|
565
567
|
properties = {
|
|
566
568
|
...properties,
|
|
@@ -619,7 +621,7 @@ function collectPositionTabs(p) {
|
|
|
619
621
|
* @returns The display text, or `undefined` when this is not a MACROBUTTON.
|
|
620
622
|
*/
|
|
621
623
|
function macroButtonText(instr) {
|
|
622
|
-
const shown = /^\s*MACROBUTTON\s+\S+\s(.*)$/su.exec(instr)?.[1]?.
|
|
624
|
+
const shown = /^\s*MACROBUTTON\s+\S+\s(.*)$/su.exec(instr)?.[1]?.trimEnd();
|
|
623
625
|
return shown !== void 0 && shown !== "" ? shown : void 0;
|
|
624
626
|
}
|
|
625
627
|
function parseFieldInstr(instr) {
|
|
@@ -632,7 +634,7 @@ function fieldKeyword(instr) {
|
|
|
632
634
|
}
|
|
633
635
|
var CHECKBOX_CLEAR = "☐";
|
|
634
636
|
var CHECKBOX_CHECKED = "☒";
|
|
635
|
-
var SILENT_FIELDS = new Set([
|
|
637
|
+
var SILENT_FIELDS = /* @__PURE__ */ new Set([
|
|
636
638
|
"SET",
|
|
637
639
|
"ASK",
|
|
638
640
|
"XE",
|
|
@@ -655,17 +657,18 @@ function applyFieldFsm(collected) {
|
|
|
655
657
|
let st = null;
|
|
656
658
|
for (const c of collected) {
|
|
657
659
|
if (c.fldChar === "begin") {
|
|
658
|
-
if (st)
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
660
|
+
if (st) {
|
|
661
|
+
if (st.phase === "instr") st.depth++;
|
|
662
|
+
else {
|
|
663
|
+
out.push(...st.result);
|
|
664
|
+
st = {
|
|
665
|
+
phase: "instr",
|
|
666
|
+
instr: "",
|
|
667
|
+
result: [],
|
|
668
|
+
depth: 0
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
} else st = {
|
|
669
672
|
phase: "instr",
|
|
670
673
|
instr: "",
|
|
671
674
|
result: [],
|
|
@@ -808,7 +811,7 @@ function sdtRunProperties(sdt, themeFonts) {
|
|
|
808
811
|
const props = parseRunProperties(poElementToFlat(rPr), themeFonts);
|
|
809
812
|
return Object.keys(props).length > 0 ? props : void 0;
|
|
810
813
|
}
|
|
811
|
-
var WINGDINGS_TO_UNICODE = new Map([
|
|
814
|
+
var WINGDINGS_TO_UNICODE = /* @__PURE__ */ new Map([
|
|
812
815
|
[108, "●"],
|
|
813
816
|
[109, "❍"],
|
|
814
817
|
[110, "■"],
|
|
@@ -835,7 +838,7 @@ var WINGDINGS_TO_UNICODE = new Map([
|
|
|
835
838
|
[237, "↙"],
|
|
836
839
|
[238, "↘"]
|
|
837
840
|
]);
|
|
838
|
-
var SYMBOL_TO_UNICODE = new Map([
|
|
841
|
+
var SYMBOL_TO_UNICODE = /* @__PURE__ */ new Map([
|
|
839
842
|
[34, "∀"],
|
|
840
843
|
[36, "∃"],
|
|
841
844
|
[64, "≅"],
|
|
@@ -1031,7 +1034,8 @@ function elementTag(node) {
|
|
|
1031
1034
|
*/
|
|
1032
1035
|
function parseNotes(notesXml, rootTag, noteTag, ctx = DEFAULT_PARSE_CONTEXT) {
|
|
1033
1036
|
const xml = resolveInternalEntities(decoder.decode(notesXml));
|
|
1034
|
-
const
|
|
1037
|
+
const tree = parser.parse(xml);
|
|
1038
|
+
const root = poFindByPath(tree, [rootTag]);
|
|
1035
1039
|
const out = /* @__PURE__ */ new Map();
|
|
1036
1040
|
if (!root) return out;
|
|
1037
1041
|
for (const note of poChildren(root)) {
|
|
@@ -1046,7 +1050,8 @@ function parseNotes(notesXml, rootTag, noteTag, ctx = DEFAULT_PARSE_CONTEXT) {
|
|
|
1046
1050
|
}
|
|
1047
1051
|
function parseCommentsRaw(commentsXml, ctx) {
|
|
1048
1052
|
const xml = resolveInternalEntities(decoder.decode(commentsXml));
|
|
1049
|
-
const
|
|
1053
|
+
const tree = parser.parse(xml);
|
|
1054
|
+
const root = poFindByPath(tree, ["w:comments"]);
|
|
1050
1055
|
const comments = /* @__PURE__ */ new Map();
|
|
1051
1056
|
const paraIds = /* @__PURE__ */ new Map();
|
|
1052
1057
|
if (!root) return {
|
|
@@ -7,14 +7,15 @@ import { applyNumbering, applyNumberingToHeadersFooters } from "../core/numberin
|
|
|
7
7
|
import "../core/numbering/index.js";
|
|
8
8
|
import { cachedDiagramTree, laidOutDiagramTree } from "../core/drawingml/diagram/run.js";
|
|
9
9
|
import { packageHasPart } from "../core/bytes.js";
|
|
10
|
+
import { parseTheme, parseThemeBgFillStyles, parseThemeEffectStyles, parseThemeFillStyles, parseThemeFonts, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
10
11
|
import { DEFAULT_THEME_PALETTE, makeColorResolver } from "../core/drawingml/colors.js";
|
|
11
12
|
import { parseChart, withChartColorStyle } from "../core/drawingml/chart-parser.js";
|
|
12
|
-
import { parseTheme, parseThemeBgFillStyles, parseThemeEffectStyles, parseThemeFillStyles, parseThemeFonts, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
13
13
|
import { isOoxmlRel } from "../core/opc/relationship-types.js";
|
|
14
14
|
import { OpcPackage } from "../core/opc/package.js";
|
|
15
15
|
import { parseCoreProperties } from "../core/opc/core-properties.js";
|
|
16
16
|
import "../core/opc/index.js";
|
|
17
17
|
import { parseXml } from "../pptx/pptx-reader.js";
|
|
18
|
+
import { firstTagMatch } from "../core/opc/tag-scan.js";
|
|
18
19
|
import { EMPTY_NUMBERING, parseNumbering } from "./numbering-parser.js";
|
|
19
20
|
import { EMPTY_SECTION, applyAuthorIds, bodyIndexForBlock, newBlockCounter, parseBackgroundColor, parseBackgroundFill, parseCommentThreads, parseDocument, parseHeaderFooter, parseNotes, parsePeople, parseSections } from "./document-parser.js";
|
|
20
21
|
import { parseStyles } from "./styles-parser.js";
|
|
@@ -156,7 +157,7 @@ function readDocx(docx) {
|
|
|
156
157
|
var docxReader = {
|
|
157
158
|
id: "docx",
|
|
158
159
|
produces: "flow",
|
|
159
|
-
supports: new Set([
|
|
160
|
+
supports: /* @__PURE__ */ new Set([
|
|
160
161
|
FEATURES.text,
|
|
161
162
|
FEATURES.tables,
|
|
162
163
|
FEATURES.tablesNested,
|
|
@@ -214,21 +215,26 @@ function makeDiagramResolver(pkg, partName, store) {
|
|
|
214
215
|
return resolved;
|
|
215
216
|
};
|
|
216
217
|
}
|
|
218
|
+
function partIndex(path) {
|
|
219
|
+
const dot = path.lastIndexOf(".");
|
|
220
|
+
if (dot < 0 || dot === path.length - 1) return "";
|
|
221
|
+
let from = dot;
|
|
222
|
+
while (from > 0 && path.charCodeAt(from - 1) >= 48 && path.charCodeAt(from - 1) <= 57) from--;
|
|
223
|
+
return path.slice(from, dot);
|
|
224
|
+
}
|
|
217
225
|
function siblingPart(pkg, ownerPart, dataPart, type) {
|
|
218
226
|
const own = pkg.getPartRelationships(dataPart).find((r) => r.type.endsWith(type));
|
|
219
227
|
if (own) return pkg.resolveRelatedPart(dataPart, own)?.data;
|
|
220
|
-
const
|
|
221
|
-
const want = index(dataPart);
|
|
228
|
+
const want = partIndex(dataPart);
|
|
222
229
|
const rels = pkg.getPartRelationships(ownerPart).filter((r) => r.type.endsWith(type));
|
|
223
|
-
const rel = rels.find((r) =>
|
|
230
|
+
const rel = rels.find((r) => partIndex(r.target) === want) ?? (rels.length === 1 ? rels[0] : void 0);
|
|
224
231
|
return rel ? pkg.resolveRelatedPart(ownerPart, rel)?.data : void 0;
|
|
225
232
|
}
|
|
226
233
|
function drawingFromOwner(pkg, ownerPart, dataPart) {
|
|
227
234
|
const drawings = pkg.getPartRelationships(ownerPart).filter((r) => r.type.endsWith("/diagramDrawing"));
|
|
228
235
|
if (drawings.length === 0) return void 0;
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const rel = drawings.find((r) => index(r.target) === want) ?? (drawings.length === 1 ? drawings[0] : void 0);
|
|
236
|
+
const want = partIndex(dataPart);
|
|
237
|
+
const rel = drawings.find((r) => partIndex(r.target) === want) ?? (drawings.length === 1 ? drawings[0] : void 0);
|
|
232
238
|
return rel ? pkg.resolveRelatedPart(ownerPart, rel) : void 0;
|
|
233
239
|
}
|
|
234
240
|
function makeImageResolver(pkg, store, partName = MAIN_DOCUMENT_PART) {
|
|
@@ -377,11 +383,10 @@ function chartOwningParts(pkg, sections, mainPart) {
|
|
|
377
383
|
return parts;
|
|
378
384
|
}
|
|
379
385
|
function detectDocxLanguage(stylesData, documentData) {
|
|
380
|
-
const re = /<w:lang\b[^>]*\bw:val="([^"]+)"/;
|
|
381
386
|
const decoder = new TextDecoder();
|
|
382
387
|
for (const data of [stylesData, documentData]) {
|
|
383
388
|
if (!data) continue;
|
|
384
|
-
const m =
|
|
389
|
+
const m = firstTagMatch(decoder.decode(data), "<w:lang", true, /<w:lang\b[^>]*\bw:val="([^"]+)"/y);
|
|
385
390
|
if (m?.[1]) return m[1];
|
|
386
391
|
}
|
|
387
392
|
}
|
|
@@ -6,6 +6,7 @@ import "../pdf/index.js";
|
|
|
6
6
|
import { parseThemeFonts } from "../core/drawingml/theme-parser.js";
|
|
7
7
|
import { OpcPackage } from "../core/opc/package.js";
|
|
8
8
|
import "../core/opc/index.js";
|
|
9
|
+
import { tagMatches } from "../core/opc/tag-scan.js";
|
|
9
10
|
import { resolveWordThemeFont } from "./theme-fonts.js";
|
|
10
11
|
import { readDocx } from "./docx-reader.js";
|
|
11
12
|
import { flowRenderOptions } from "../core/converter/project.js";
|
|
@@ -13,6 +14,7 @@ import { flowRenderOptions } from "../core/converter/project.js";
|
|
|
13
14
|
var STYLES_PART = "word/styles.xml";
|
|
14
15
|
var THEME_PART = "word/theme/theme1.xml";
|
|
15
16
|
var MAIN_DOCUMENT_PART = "word/document.xml";
|
|
17
|
+
var ASCII_FONT = /<w:rFonts[^>]*?\bw:(ascii|asciiTheme)="([^"]+)"/y;
|
|
16
18
|
/**
|
|
17
19
|
* Synchronous one-shot conversion (requires `fonts`/`fontBytes`, no network).
|
|
18
20
|
*
|
|
@@ -63,7 +65,7 @@ function prepareDocxStyledRender(docx, options) {
|
|
|
63
65
|
* cannot be opened.
|
|
64
66
|
*/
|
|
65
67
|
function detectDocxFamilyKeys(docx) {
|
|
66
|
-
const keys = new Set(["arimo"]);
|
|
68
|
+
const keys = /* @__PURE__ */ new Set(["arimo"]);
|
|
67
69
|
let pkg;
|
|
68
70
|
try {
|
|
69
71
|
pkg = OpcPackage.open(docx);
|
|
@@ -72,13 +74,11 @@ function detectDocxFamilyKeys(docx) {
|
|
|
72
74
|
}
|
|
73
75
|
const decoder = new TextDecoder("utf-8");
|
|
74
76
|
const themeFonts = docxThemeFonts(pkg);
|
|
75
|
-
const re = /<w:rFonts[^>]*?\bw:(ascii|asciiTheme)="([^"]+)"/g;
|
|
76
77
|
for (const part of [STYLES_PART, MAIN_DOCUMENT_PART]) {
|
|
77
78
|
const data = pkg.getPart(part);
|
|
78
79
|
if (!data) continue;
|
|
79
80
|
const xml = decoder.decode(data);
|
|
80
|
-
|
|
81
|
-
while ((m = re.exec(xml)) !== null) {
|
|
81
|
+
for (const m of tagMatches(xml, "<w:rFonts", false, ASCII_FONT)) {
|
|
82
82
|
const name = m[1] === "ascii" ? m[2] : resolveWordThemeFont(m[2], themeFonts);
|
|
83
83
|
if (name !== void 0) keys.add(resolveFamilyKey(name));
|
|
84
84
|
}
|
|
@@ -134,7 +134,7 @@ async function buildUnsignedDocxPdf(docx, options) {
|
|
|
134
134
|
*/
|
|
135
135
|
async function resolveDocxAutoFonts(docx, options = {}) {
|
|
136
136
|
const fetchOpt = options.fontFetch ? { fetch: options.fontFetch } : {};
|
|
137
|
-
const keys = options.fontFamily ? new Set([resolveFamilyKey(options.fontFamily)]) : detectDocxFamilyKeys(docx);
|
|
137
|
+
const keys = options.fontFamily ? /* @__PURE__ */ new Set([resolveFamilyKey(options.fontFamily)]) : detectDocxFamilyKeys(docx);
|
|
138
138
|
if (keys.size <= 1) {
|
|
139
139
|
const family = keys.values().next().value;
|
|
140
140
|
return { fonts: await fetchFontSet({
|
|
@@ -158,4 +158,4 @@ async function resolveDocxAutoFonts(docx, options = {}) {
|
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
//#endregion
|
|
161
|
-
export { convertDocxToPdf };
|
|
161
|
+
export { convertDocxToPdf, convertDocxToPdfSync, detectDocxFamilyKeys, resolveDocxAutoFonts };
|
|
@@ -531,7 +531,7 @@ function emitHeadersFooters(flow, section, state, docScope, extraParts, extraPar
|
|
|
531
531
|
var docxWriter = {
|
|
532
532
|
id: "docx",
|
|
533
533
|
consumes: "flow",
|
|
534
|
-
supports: new Set([FEATURES.text, FEATURES.fontsEmbedding]),
|
|
534
|
+
supports: /* @__PURE__ */ new Set([FEATURES.text, FEATURES.fontsEmbedding]),
|
|
535
535
|
write: (doc) => writeDocx(doc)
|
|
536
536
|
};
|
|
537
537
|
/**
|
|
@@ -1177,7 +1177,7 @@ function pPrWithSect(p, closingSectPr) {
|
|
|
1177
1177
|
*/
|
|
1178
1178
|
var stated = (pt) => Number.isFinite(pt);
|
|
1179
1179
|
/** §17.18.44 ST_Jc — the tokens the attribute admits, so nothing else is written. */
|
|
1180
|
-
var JC = new Set([
|
|
1180
|
+
var JC = /* @__PURE__ */ new Set([
|
|
1181
1181
|
"left",
|
|
1182
1182
|
"right",
|
|
1183
1183
|
"center",
|
|
@@ -1188,8 +1188,10 @@ function indXml(p) {
|
|
|
1188
1188
|
const attrs = [];
|
|
1189
1189
|
if (stated(p.indentLeft) && p.indentLeft !== DEFAULT_PARA.indentLeft) attrs.push(`w:left="${twips(p.indentLeft)}"`);
|
|
1190
1190
|
if (stated(p.indentRight) && p.indentRight !== DEFAULT_PARA.indentRight) attrs.push(`w:right="${twips(p.indentRight)}"`);
|
|
1191
|
-
if (stated(p.indentFirstLine) && p.indentFirstLine !== DEFAULT_PARA.indentFirstLine)
|
|
1192
|
-
|
|
1191
|
+
if (stated(p.indentFirstLine) && p.indentFirstLine !== DEFAULT_PARA.indentFirstLine) {
|
|
1192
|
+
if (p.indentFirstLine < 0) attrs.push(`w:hanging="${twips(-p.indentFirstLine)}"`);
|
|
1193
|
+
else attrs.push(`w:firstLine="${twips(p.indentFirstLine)}"`);
|
|
1194
|
+
}
|
|
1193
1195
|
return attrs.length > 0 ? `<w:ind ${attrs.join(" ")}/>` : "";
|
|
1194
1196
|
}
|
|
1195
1197
|
function spacingXml(p) {
|
|
@@ -1248,8 +1250,10 @@ function rawParaPrXml(p) {
|
|
|
1248
1250
|
const attrs = [];
|
|
1249
1251
|
if (p.indentLeft !== void 0 && stated(p.indentLeft)) attrs.push(`w:left="${twips(p.indentLeft)}"`);
|
|
1250
1252
|
if (p.indentRight !== void 0 && stated(p.indentRight)) attrs.push(`w:right="${twips(p.indentRight)}"`);
|
|
1251
|
-
if (p.indentFirstLine !== void 0 && stated(p.indentFirstLine))
|
|
1252
|
-
|
|
1253
|
+
if (p.indentFirstLine !== void 0 && stated(p.indentFirstLine)) {
|
|
1254
|
+
if (p.indentFirstLine < 0) attrs.push(`w:hanging="${twips(-p.indentFirstLine)}"`);
|
|
1255
|
+
else attrs.push(`w:firstLine="${twips(p.indentFirstLine)}"`);
|
|
1256
|
+
}
|
|
1253
1257
|
const ind = attrs.length > 0 ? `<w:ind ${attrs.join(" ")}/>` : "";
|
|
1254
1258
|
const jc = p.alignment !== void 0 && JC.has(p.alignment) ? `<w:jc w:val="${p.alignment}"/>` : "";
|
|
1255
1259
|
return ind || jc ? `<w:pPr>${jc}${ind}</w:pPr>` : "";
|
|
@@ -15,7 +15,7 @@ var EMPTY_GEOMETRY = {
|
|
|
15
15
|
pathHeight: 0,
|
|
16
16
|
commands: []
|
|
17
17
|
};
|
|
18
|
-
var UNDERSTOOD_NS = new Set([
|
|
18
|
+
var UNDERSTOOD_NS = /* @__PURE__ */ new Set([
|
|
19
19
|
"wps",
|
|
20
20
|
"wpg",
|
|
21
21
|
"wpc"
|
|
@@ -72,12 +72,12 @@ function parseFloatAnchor(anchor) {
|
|
|
72
72
|
...posV ? { posV } : {}
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
var ANCHOR_ALIGNS = new Set([
|
|
75
|
+
var ANCHOR_ALIGNS = /* @__PURE__ */ new Set([
|
|
76
76
|
"left",
|
|
77
77
|
"center",
|
|
78
78
|
"right"
|
|
79
79
|
]);
|
|
80
|
-
var ANCHOR_V_ALIGNS = new Set([
|
|
80
|
+
var ANCHOR_V_ALIGNS = /* @__PURE__ */ new Set([
|
|
81
81
|
"top",
|
|
82
82
|
"center",
|
|
83
83
|
"bottom"
|
|
@@ -583,7 +583,7 @@ function pairOf(v) {
|
|
|
583
583
|
const m = v !== void 0 ? /^\s*(-?\d+)[ ,]+(-?\d+)\s*$/u.exec(v) : null;
|
|
584
584
|
return m ? [Number(m[1]), Number(m[2])] : void 0;
|
|
585
585
|
}
|
|
586
|
-
var VML_PATH_PAIRS = new Set([
|
|
586
|
+
var VML_PATH_PAIRS = /* @__PURE__ */ new Set([
|
|
587
587
|
"nf",
|
|
588
588
|
"ns",
|
|
589
589
|
"qx",
|
|
@@ -745,7 +745,7 @@ function parseVmlGroup(group, parseBody, shapeTypes, sizePt) {
|
|
|
745
745
|
fill: { kind: "none" }
|
|
746
746
|
};
|
|
747
747
|
}
|
|
748
|
-
var VML_SHAPE_TAGS = new Set([
|
|
748
|
+
var VML_SHAPE_TAGS = /* @__PURE__ */ new Set([
|
|
749
749
|
"v:rect",
|
|
750
750
|
"v:roundrect",
|
|
751
751
|
"v:oval",
|
|
@@ -1021,14 +1021,14 @@ function vmlLine(shape, shapeType) {
|
|
|
1021
1021
|
...tailEnd ? { tailEnd } : {}
|
|
1022
1022
|
};
|
|
1023
1023
|
}
|
|
1024
|
-
var VML_ARROWS = new Map([
|
|
1024
|
+
var VML_ARROWS = /* @__PURE__ */ new Map([
|
|
1025
1025
|
["block", "triangle"],
|
|
1026
1026
|
["classic", "stealth"],
|
|
1027
1027
|
["diamond", "diamond"],
|
|
1028
1028
|
["oval", "oval"],
|
|
1029
1029
|
["open", "arrow"]
|
|
1030
1030
|
]);
|
|
1031
|
-
var VML_ARROW_SIZES = new Map([
|
|
1031
|
+
var VML_ARROW_SIZES = /* @__PURE__ */ new Map([
|
|
1032
1032
|
["narrow", "sm"],
|
|
1033
1033
|
["short", "sm"],
|
|
1034
1034
|
["medium", "med"],
|
|
@@ -1439,7 +1439,8 @@ function memberOrigin(wgp, fallback) {
|
|
|
1439
1439
|
let minY = Infinity;
|
|
1440
1440
|
for (const child of expandMcChildren(poChildren(wgp))) {
|
|
1441
1441
|
if (!isGroupMember(child)) continue;
|
|
1442
|
-
const
|
|
1442
|
+
const spPr = poChildren(child).find((c) => poIsLocal(c, "spPr") || poIsLocal(c, "grpSpPr"));
|
|
1443
|
+
const xfrm = poChildren(spPr).find((c) => poIs(c, "a:xfrm"));
|
|
1443
1444
|
const off = xfrm ? poChildren(xfrm).find((c) => poIs(c, "a:off")) : void 0;
|
|
1444
1445
|
const x = poIntAttr(off, "x");
|
|
1445
1446
|
const y = poIntAttr(off, "y");
|
|
@@ -1569,7 +1570,7 @@ function styleRefShadow(style, resolveColor, themeEffectStyles) {
|
|
|
1569
1570
|
const phHex = child ? resolveColorNode(child, resolveColor) : void 0;
|
|
1570
1571
|
return shadowFromOuterShdw(shdw, phHex ? placeholderColors(resolveColor, phHex) : resolveColor);
|
|
1571
1572
|
}
|
|
1572
|
-
var FILL_TAGS = new Set([
|
|
1573
|
+
var FILL_TAGS = /* @__PURE__ */ new Set([
|
|
1573
1574
|
"a:noFill",
|
|
1574
1575
|
"a:solidFill",
|
|
1575
1576
|
"a:gradFill",
|
|
@@ -1639,10 +1640,11 @@ function styleRefLine(style, resolveColor, themeLineWidths) {
|
|
|
1639
1640
|
const colorHex = child ? resolveColorNode(child, resolveColor) : void 0;
|
|
1640
1641
|
if (colorHex === void 0) return void 0;
|
|
1641
1642
|
const idx = poIntAttr(ref, "idx");
|
|
1643
|
+
const width = idx !== void 0 && idx > 0 ? themeLineWidths?.[idx - 1] : void 0;
|
|
1642
1644
|
return {
|
|
1643
1645
|
fill: "solid",
|
|
1644
1646
|
colorHex,
|
|
1645
|
-
width: pt(
|
|
1647
|
+
width: pt(width ?? .75)
|
|
1646
1648
|
};
|
|
1647
1649
|
}
|
|
1648
1650
|
/**
|
|
@@ -1827,9 +1829,7 @@ function parseCustGeom(cust) {
|
|
|
1827
1829
|
swAng: poIntAttr(node, "swAng") ?? 0
|
|
1828
1830
|
});
|
|
1829
1831
|
break;
|
|
1830
|
-
case "a:close":
|
|
1831
|
-
commands.push({ cmd: "close" });
|
|
1832
|
-
break;
|
|
1832
|
+
case "a:close": commands.push({ cmd: "close" });
|
|
1833
1833
|
}
|
|
1834
1834
|
if (pathWidth <= 0 || pathHeight <= 0 || commands.length === 0) return {
|
|
1835
1835
|
kind: "preset",
|
|
@@ -1963,7 +1963,7 @@ function patternCoverage(prst) {
|
|
|
1963
1963
|
if (DENSE_PATTERNS.has(prst)) return .5;
|
|
1964
1964
|
return .25;
|
|
1965
1965
|
}
|
|
1966
|
-
var DENSE_PATTERNS = new Set([
|
|
1966
|
+
var DENSE_PATTERNS = /* @__PURE__ */ new Set([
|
|
1967
1967
|
"trellis",
|
|
1968
1968
|
"weave",
|
|
1969
1969
|
"plaid",
|
|
@@ -2211,14 +2211,14 @@ function pictureOutline(line) {
|
|
|
2211
2211
|
widthPt: pt(stroke.widthPt)
|
|
2212
2212
|
};
|
|
2213
2213
|
}
|
|
2214
|
-
var LINE_END_TYPES = new Set([
|
|
2214
|
+
var LINE_END_TYPES = /* @__PURE__ */ new Set([
|
|
2215
2215
|
"triangle",
|
|
2216
2216
|
"stealth",
|
|
2217
2217
|
"diamond",
|
|
2218
2218
|
"oval",
|
|
2219
2219
|
"arrow"
|
|
2220
2220
|
]);
|
|
2221
|
-
var LINE_END_SIZES = new Set([
|
|
2221
|
+
var LINE_END_SIZES = /* @__PURE__ */ new Set([
|
|
2222
2222
|
"sm",
|
|
2223
2223
|
"med",
|
|
2224
2224
|
"lg"
|
|
@@ -2263,7 +2263,7 @@ function parseCustDash(custDash) {
|
|
|
2263
2263
|
}
|
|
2264
2264
|
return out.length > 0 ? out : void 0;
|
|
2265
2265
|
}
|
|
2266
|
-
var DASH_VALUES = new Set([
|
|
2266
|
+
var DASH_VALUES = /* @__PURE__ */ new Set([
|
|
2267
2267
|
"solid",
|
|
2268
2268
|
"dot",
|
|
2269
2269
|
"dash",
|
|
@@ -2387,4 +2387,4 @@ function clampUnit(x) {
|
|
|
2387
2387
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
2388
2388
|
}
|
|
2389
2389
|
//#endregion
|
|
2390
|
-
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseSrcRect, parseVmlPicture, parseXfrm, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill, withStatedDirection };
|
|
2390
|
+
export { colorChangeOf, expandMcChildren, parseCustGeom, parseDrawing, parseFill, parseLine, parsePrstGeom, parseShadow, parseSrcRect, parseVmlPicture, parseXfrm, resolveMc, shadowFromOuterShdw, statesFill, styleRefFill, styleRefFontColor, styleRefLine, vmlFill, withStatedDirection, withStyleFontColor };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FontRegistry } from "../core/font/font-registry.js";
|
|
2
|
+
import { isWordChar, tagMatches } from "../core/opc/tag-scan.js";
|
|
2
3
|
//#region src/word/font-table.ts
|
|
3
4
|
var FONT_TABLE_PART = "word/fontTable.xml";
|
|
4
5
|
var REL_FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
|
|
@@ -19,7 +20,7 @@ var VARIANT_BY_TAG = {
|
|
|
19
20
|
function deobfuscateEmbeddedFont(data, fontKey) {
|
|
20
21
|
const hex = fontKey.replace(/[{}-]/g, "");
|
|
21
22
|
if (hex.length !== 32) return data;
|
|
22
|
-
const key = new Uint8Array(16);
|
|
23
|
+
const key = /* @__PURE__ */ new Uint8Array(16);
|
|
23
24
|
for (let i = 0; i < 16; i++) key[i] = parseInt(hex.substring(i * 2, i * 2 + 2), 16);
|
|
24
25
|
key.reverse();
|
|
25
26
|
const out = new Uint8Array(data);
|
|
@@ -48,19 +49,15 @@ function obfuscateEmbeddedFont(data, fontKey) {
|
|
|
48
49
|
function parseFontTable(data) {
|
|
49
50
|
const xml = new TextDecoder("utf-8").decode(data);
|
|
50
51
|
const out = [];
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
while ((fm = fontRe.exec(xml)) !== null) {
|
|
52
|
+
const closed = xml.slice(0, xml.lastIndexOf("</w:font>") + 9);
|
|
53
|
+
for (const fm of tagMatches(closed, "<w:font", true, FONT)) {
|
|
54
54
|
const name = fm[1];
|
|
55
|
-
const inner = fm[2];
|
|
56
55
|
const embeds = {};
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
while ((em = embedRe.exec(inner)) !== null) {
|
|
60
|
-
const variant = VARIANT_BY_TAG[em[1]];
|
|
56
|
+
for (const em of embedRefs(fm[2])) {
|
|
57
|
+
const variant = VARIANT_BY_TAG[em.tag];
|
|
61
58
|
if (variant) embeds[variant] = {
|
|
62
|
-
rId: em
|
|
63
|
-
fontKey: em
|
|
59
|
+
rId: em.rId,
|
|
60
|
+
fontKey: em.fontKey
|
|
64
61
|
};
|
|
65
62
|
}
|
|
66
63
|
if (Object.keys(embeds).length > 0) out.push({
|
|
@@ -70,6 +67,88 @@ function parseFontTable(data) {
|
|
|
70
67
|
}
|
|
71
68
|
return out;
|
|
72
69
|
}
|
|
70
|
+
/** A named `w:font` and everything up to its close. Sticky, for tagMatches. */
|
|
71
|
+
var FONT = /<w:font\b[^>]*\bw:name="([^"]+)"[^>]*>([\s\S]*?)<\/w:font>/y;
|
|
72
|
+
var EMBED_HEAD = /<w:embed(Regular|Bold|Italic|BoldItalic)\b/y;
|
|
73
|
+
/**
|
|
74
|
+
* The faces a font's element embeds — what
|
|
75
|
+
* `/<w:embed(Regular|Bold|Italic|BoldItalic)\b[^>]*\br:id="([^"]+)"[^>]*\bw:fontKey="([^"]+)"/g`
|
|
76
|
+
* finds in it, in one pass. The expression gave the tag back one `r:id` at a
|
|
77
|
+
* time and read the rest of it again for a `w:fontKey` after each, quadratic
|
|
78
|
+
* in a tag with many; and searching, it read each tag again from every
|
|
79
|
+
* `<w:embed` inside it. Where a start fails, every later one before the tag's
|
|
80
|
+
* `>` does too, so the search moves past it.
|
|
81
|
+
*/
|
|
82
|
+
function embedRefs(inner) {
|
|
83
|
+
const out = [];
|
|
84
|
+
let at = inner.indexOf("<w:embed");
|
|
85
|
+
while (at >= 0) {
|
|
86
|
+
EMBED_HEAD.lastIndex = at;
|
|
87
|
+
const head = EMBED_HEAD.exec(inner);
|
|
88
|
+
if (head === null) {
|
|
89
|
+
at = inner.indexOf("<w:embed", at + 1);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const from = EMBED_HEAD.lastIndex;
|
|
93
|
+
const tagEnd = endOfStretch(inner, from);
|
|
94
|
+
const found = embedRef(inner, from, tagEnd);
|
|
95
|
+
if (found) {
|
|
96
|
+
out.push({
|
|
97
|
+
tag: head[1],
|
|
98
|
+
rId: found.rId,
|
|
99
|
+
fontKey: found.fontKey
|
|
100
|
+
});
|
|
101
|
+
at = inner.indexOf("<w:embed", found.end);
|
|
102
|
+
} else if (tagEnd < inner.length) at = inner.indexOf("<w:embed", tagEnd + 1);
|
|
103
|
+
else break;
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
/** The first `>` at or after `from`, or the end of the text. */
|
|
108
|
+
function endOfStretch(s, from) {
|
|
109
|
+
const gt = s.indexOf(">", from);
|
|
110
|
+
return gt < 0 ? s.length : gt;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The reference one `<w:embed…` makes, its attributes read from `from` up to
|
|
114
|
+
* the tag's `>` at `tagEnd`. The first `[^>]*` gives back the last `r:id`
|
|
115
|
+
* first; the second takes the last `w:fontKey` before the `>` that follows the
|
|
116
|
+
* `r:id`'s value — and that one is the same for every `r:id` whose value ends
|
|
117
|
+
* in one stretch, so it is looked for once per stretch.
|
|
118
|
+
*/
|
|
119
|
+
function embedRef(s, from, tagEnd) {
|
|
120
|
+
const keys = /* @__PURE__ */ new Map();
|
|
121
|
+
const lastKey = (stretchEnd) => {
|
|
122
|
+
if (keys.has(stretchEnd)) return keys.get(stretchEnd);
|
|
123
|
+
const start = s.lastIndexOf(">", stretchEnd - 1) + 1;
|
|
124
|
+
let key;
|
|
125
|
+
for (let f = s.lastIndexOf("w:fontKey=\"", stretchEnd - 11); f >= start; f = s.lastIndexOf("w:fontKey=\"", f - 1)) {
|
|
126
|
+
const close = s.indexOf("\"", f + 11);
|
|
127
|
+
if (!isWordChar(s.charCodeAt(f - 1)) && close > f + 11) {
|
|
128
|
+
key = {
|
|
129
|
+
at: f,
|
|
130
|
+
value: s.slice(f + 11, close),
|
|
131
|
+
end: close + 1
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
if (f === 0) break;
|
|
136
|
+
}
|
|
137
|
+
keys.set(stretchEnd, key);
|
|
138
|
+
return key;
|
|
139
|
+
};
|
|
140
|
+
for (let p = s.lastIndexOf("r:id=\"", tagEnd - 6); p >= from; p = s.lastIndexOf("r:id=\"", p - 1)) {
|
|
141
|
+
if (isWordChar(s.charCodeAt(p - 1))) continue;
|
|
142
|
+
const close = s.indexOf("\"", p + 6);
|
|
143
|
+
if (close <= p + 6) continue;
|
|
144
|
+
const key = lastKey(close < tagEnd ? tagEnd : endOfStretch(s, close + 1));
|
|
145
|
+
if (key !== void 0 && key.at > close) return {
|
|
146
|
+
rId: s.slice(p + 6, close),
|
|
147
|
+
fontKey: key.value,
|
|
148
|
+
end: key.end
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
73
152
|
/**
|
|
74
153
|
* De-obfuscate and load every embedded font in the package, building one
|
|
75
154
|
* {@link FontRegistry} per font keyed by its normalized (trimmed, lower-cased)
|
package/dist/esm/word/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "./run-properties.js";
|
|
2
2
|
import "./paragraph-properties.js";
|
|
3
3
|
import "./table-parser.js";
|
|
4
|
-
import "./numbering-parser.js";
|
|
5
|
-
import "./document-parser.js";
|
|
4
|
+
import { EMPTY_NUMBERING, parseNumbering } from "./numbering-parser.js";
|
|
5
|
+
import { EMPTY_SECTION, applyAuthorIds, bodyIndexForBlock, newBlockCounter, parseBackgroundColor, parseBackgroundFill, parseCommentThreads, parseDocument, parseHeaderFooter, parseNotes, parsePeople, parseSections } from "./document-parser.js";
|
|
6
6
|
import "./text-extractor.js";
|
|
7
|
-
import "./styles-parser.js";
|
|
8
|
-
import "./font-table.js";
|
|
9
|
-
import "./settings-parser.js";
|
|
7
|
+
import { parseStyles } from "./styles-parser.js";
|
|
8
|
+
import { loadEmbeddedFonts } from "./font-table.js";
|
|
9
|
+
import { EMPTY_SETTINGS, parseSettings } from "./settings-parser.js";
|
|
10
|
+
export { EMPTY_NUMBERING, EMPTY_SECTION, EMPTY_SETTINGS, applyAuthorIds, bodyIndexForBlock, loadEmbeddedFonts, newBlockCounter, parseBackgroundColor, parseBackgroundFill, parseCommentThreads, parseDocument, parseHeaderFooter, parseNotes, parseNumbering, parsePeople, parseSections, parseSettings, parseStyles };
|
|
@@ -15,7 +15,7 @@ var parser = new XMLParser({
|
|
|
15
15
|
trimValues: false
|
|
16
16
|
});
|
|
17
17
|
/** §17.18.59 ST_NumberFormat — the formats this reader knows by name. */
|
|
18
|
-
var FORMATS = new Set([
|
|
18
|
+
var FORMATS = /* @__PURE__ */ new Set([
|
|
19
19
|
"decimal",
|
|
20
20
|
"decimalZero",
|
|
21
21
|
"decimalFullWidth",
|
|
@@ -59,7 +59,8 @@ var EMPTY_NUMBERING = {
|
|
|
59
59
|
*/
|
|
60
60
|
function parseNumbering(data, resolveImage, themeFonts) {
|
|
61
61
|
const xml = decoder.decode(data);
|
|
62
|
-
const
|
|
62
|
+
const tree = parser.parse(xml);
|
|
63
|
+
const root = asElement(tree["w:numbering"]);
|
|
63
64
|
if (!root) return EMPTY_NUMBERING;
|
|
64
65
|
const picBullets = parsePicBullets(root, resolveImage);
|
|
65
66
|
const abstractNums = /* @__PURE__ */ new Map();
|
|
@@ -162,7 +163,7 @@ function parsePicBullets(root, resolveImage) {
|
|
|
162
163
|
}
|
|
163
164
|
return out;
|
|
164
165
|
}
|
|
165
|
-
var CSS_UNITS = new Map([
|
|
166
|
+
var CSS_UNITS = /* @__PURE__ */ new Map([
|
|
166
167
|
["pt", 1],
|
|
167
168
|
["in", 72],
|
|
168
169
|
["cm", 72 / 2.54],
|
|
@@ -171,7 +172,7 @@ var CSS_UNITS = new Map([
|
|
|
171
172
|
["px", .75]
|
|
172
173
|
]);
|
|
173
174
|
function cssLengthPt(raw) {
|
|
174
|
-
const m = raw !== void 0 ?
|
|
175
|
+
const m = raw !== void 0 ? /^(-?[\d.]+)\s*([a-z%]*)$/u.exec(raw.trim()) : null;
|
|
175
176
|
if (!m) return void 0;
|
|
176
177
|
const n = Number(m[1]);
|
|
177
178
|
if (!Number.isFinite(n)) return void 0;
|