kordoc 4.0.6 → 4.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/{-NDU7YGSS.js → -6HWEFXVV.js} +9 -9
- package/dist/{chunk-UVSOSFER.js → chunk-2SN3CKME.js} +2 -2
- package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
- package/dist/chunk-3TBUDJDE.js.map +1 -0
- package/dist/{chunk-HOGJ5ALY.js → chunk-5OKHAJ62.js} +2 -2
- package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
- package/dist/chunk-AIQ3ISQU.js.map +1 -0
- package/dist/{chunk-5SOZXPQY.js → chunk-BKWHX3RC.js} +3 -3
- package/dist/{chunk-5CJGKKMZ.js → chunk-CFQLK3LM.js} +1 -1
- package/dist/chunk-CFQLK3LM.js.map +1 -0
- package/dist/{chunk-L3I4TIRP.js → chunk-CNM75ZSX.js} +2 -2
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-63ASYC4N.js → chunk-NGSHDBQR.js} +3 -3
- package/dist/{chunk-KA4FEBS2.js → chunk-ONXVBURQ.js} +2 -2
- package/dist/{chunk-4C7SBZNW.js → chunk-Q7EN4EUJ.js} +2 -2
- package/dist/{chunk-HC2SEH6I.js → chunk-TJJTLM76.js} +166 -97
- package/dist/chunk-TJJTLM76.js.map +1 -0
- package/dist/{chunk-DQJTNXVS.cjs → chunk-U25XGCNH.cjs} +2 -2
- package/dist/chunk-U25XGCNH.cjs.map +1 -0
- package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
- package/dist/chunk-X34YWRL5.cjs.map +1 -0
- package/dist/cli.js +17 -17
- package/dist/{detect-PJZMUL2Z.js → detect-NTR2FUEG.js} +2 -2
- package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
- package/dist/formula-KOQV353G.js.map +1 -0
- package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
- package/dist/formula-MEDGYQXS.js.map +1 -0
- package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
- package/dist/formula-ZYUDQHD3.cjs.map +1 -0
- package/dist/index.cjs +298 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +160 -91
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +13 -13
- package/dist/page-range-CIRRJPXJ.js +7 -0
- package/dist/page-range-OF5I4PQY.js +8 -0
- package/dist/page-range-TPIRSA3J.cjs +8 -0
- package/dist/page-range-TPIRSA3J.cjs.map +1 -0
- package/dist/{parser-C636QIOB.js → parser-5EHWYJMC.js} +24 -6
- package/dist/parser-5EHWYJMC.js.map +1 -0
- package/dist/{parser-VEY4B5CJ.cjs → parser-E6U5TNAU.cjs} +36 -18
- package/dist/parser-E6U5TNAU.cjs.map +1 -0
- package/dist/{parser-DMKHIV4E.js → parser-UGB3NIVH.js} +23 -5
- package/dist/parser-UGB3NIVH.js.map +1 -0
- package/dist/{profile-io-JYGCC6XQ.js → profile-io-CAKRPQRD.js} +3 -3
- package/dist/provider-5K7O3Z2O.cjs.map +1 -1
- package/dist/render-P6663O4I.js +10 -0
- package/dist/seal-7PPTXKKV.js +10 -0
- package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
- package/dist/setup-QSJ2INNS.js.map +1 -0
- package/dist/{watch-ZQUFJBFR.js → watch-RMX427YR.js} +9 -9
- package/package.json +1 -1
- package/dist/chunk-5CJGKKMZ.js.map +0 -1
- package/dist/chunk-DCZVOIEO.cjs.map +0 -1
- package/dist/chunk-DQJTNXVS.cjs.map +0 -1
- package/dist/chunk-GE43BE46.js.map +0 -1
- package/dist/chunk-HC2SEH6I.js.map +0 -1
- package/dist/chunk-MOL7MDBG.js.map +0 -1
- package/dist/formula-5NKVS2LR.cjs.map +0 -1
- package/dist/formula-JCNF43NE.js.map +0 -1
- package/dist/formula-RXVSQPXI.js.map +0 -1
- package/dist/page-range-737B4EZW.js +0 -8
- package/dist/page-range-LNMXJU6W.js +0 -7
- package/dist/page-range-P7SDW6LR.cjs +0 -8
- package/dist/page-range-P7SDW6LR.cjs.map +0 -1
- package/dist/parser-C636QIOB.js.map +0 -1
- package/dist/parser-DMKHIV4E.js.map +0 -1
- package/dist/parser-VEY4B5CJ.cjs.map +0 -1
- package/dist/render-ISOEOMTM.js +0 -10
- package/dist/seal-676ZIAZZ.js +0 -10
- package/dist/setup-57FB3LSP.js.map +0 -1
- /package/dist/{-NDU7YGSS.js.map → -6HWEFXVV.js.map} +0 -0
- /package/dist/{chunk-UVSOSFER.js.map → chunk-2SN3CKME.js.map} +0 -0
- /package/dist/{chunk-HOGJ5ALY.js.map → chunk-5OKHAJ62.js.map} +0 -0
- /package/dist/{chunk-5SOZXPQY.js.map → chunk-BKWHX3RC.js.map} +0 -0
- /package/dist/{chunk-L3I4TIRP.js.map → chunk-CNM75ZSX.js.map} +0 -0
- /package/dist/{chunk-63ASYC4N.js.map → chunk-NGSHDBQR.js.map} +0 -0
- /package/dist/{chunk-KA4FEBS2.js.map → chunk-ONXVBURQ.js.map} +0 -0
- /package/dist/{chunk-4C7SBZNW.js.map → chunk-Q7EN4EUJ.js.map} +0 -0
- /package/dist/{detect-PJZMUL2Z.js.map → detect-NTR2FUEG.js.map} +0 -0
- /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
- /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
- /package/dist/{profile-io-JYGCC6XQ.js.map → profile-io-CAKRPQRD.js.map} +0 -0
- /package/dist/{render-ISOEOMTM.js.map → render-P6663O4I.js.map} +0 -0
- /package/dist/{seal-676ZIAZZ.js.map → seal-7PPTXKKV.js.map} +0 -0
- /package/dist/{watch-ZQUFJBFR.js.map → watch-RMX427YR.js.map} +0 -0
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
dedupeRunningHeaders,
|
|
12
12
|
flattenLayoutTables,
|
|
13
13
|
mapPuaText
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2SN3CKME.js";
|
|
15
15
|
import {
|
|
16
16
|
detectFormat,
|
|
17
17
|
detectOle2Format,
|
|
18
18
|
detectZipFormat,
|
|
19
19
|
parseLenientCfb
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-CFQLK3LM.js";
|
|
21
21
|
import {
|
|
22
22
|
parsePageRange
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-3TBUDJDE.js";
|
|
24
24
|
import {
|
|
25
25
|
allLinesegRemovalSplices,
|
|
26
26
|
applySplices,
|
|
@@ -32,14 +32,14 @@ import {
|
|
|
32
32
|
paraTextPureT,
|
|
33
33
|
patchZipEntries,
|
|
34
34
|
scanSectionXml
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-NGSHDBQR.js";
|
|
36
36
|
import {
|
|
37
37
|
SPACE_EM_FIXED,
|
|
38
38
|
charWidthEm1000,
|
|
39
39
|
fitRatioForFewerLines,
|
|
40
40
|
measureTextWidth,
|
|
41
41
|
simulateWrap
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-BKWHX3RC.js";
|
|
43
43
|
import {
|
|
44
44
|
MAX_DECOMPRESS_SIZE,
|
|
45
45
|
MAX_XML_DEPTH,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
createXmlParser,
|
|
51
51
|
extractTextFromNode,
|
|
52
52
|
findChildByLocalName
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-Q7EN4EUJ.js";
|
|
54
54
|
import {
|
|
55
55
|
KordocError,
|
|
56
56
|
classifyError,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
sanitizeHref,
|
|
62
62
|
stripDtd,
|
|
63
63
|
toArrayBuffer
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-CNM75ZSX.js";
|
|
65
65
|
|
|
66
66
|
// src/index.ts
|
|
67
67
|
import { readFile } from "fs/promises";
|
|
@@ -17572,7 +17572,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
17572
17572
|
}
|
|
17573
17573
|
let pageFilter = null;
|
|
17574
17574
|
if (options?.pages) {
|
|
17575
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
17575
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
|
|
17576
17576
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
17577
17577
|
}
|
|
17578
17578
|
const blocks = [];
|
|
@@ -18210,7 +18210,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
18210
18210
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
18211
18211
|
let pageFilter = null;
|
|
18212
18212
|
if (options?.pages) {
|
|
18213
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
18213
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
|
|
18214
18214
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
18215
18215
|
}
|
|
18216
18216
|
const allBlocks = [];
|
|
@@ -18812,6 +18812,102 @@ function extractRun(r) {
|
|
|
18812
18812
|
}
|
|
18813
18813
|
return { text, bold, italic };
|
|
18814
18814
|
}
|
|
18815
|
+
function fieldUrlFromInstr(instr) {
|
|
18816
|
+
if (!/HYPERLINK\b/i.test(instr)) return null;
|
|
18817
|
+
const urlM = instr.match(/HYPERLINK\s+"([^"]*)"/i);
|
|
18818
|
+
const anchorM = instr.match(/\\l\s+"([^"]*)"/i);
|
|
18819
|
+
if (urlM && urlM[1]) {
|
|
18820
|
+
return anchorM && anchorM[1] ? `${urlM[1]}#${anchorM[1]}` : urlM[1];
|
|
18821
|
+
}
|
|
18822
|
+
if (anchorM && anchorM[1]) return `#${anchorM[1]}`;
|
|
18823
|
+
return null;
|
|
18824
|
+
}
|
|
18825
|
+
function makeLink(text, rawHref) {
|
|
18826
|
+
if (!text) return "";
|
|
18827
|
+
if (!rawHref) return text;
|
|
18828
|
+
const href = sanitizeHref(rawHref);
|
|
18829
|
+
return href ? `[${text}](${href})` : text;
|
|
18830
|
+
}
|
|
18831
|
+
function collectInline(p, footnotes, rels) {
|
|
18832
|
+
const parts = [];
|
|
18833
|
+
let bold = false;
|
|
18834
|
+
let italic = false;
|
|
18835
|
+
let footnoteText;
|
|
18836
|
+
let fieldActive = false;
|
|
18837
|
+
let fieldStage = "instr";
|
|
18838
|
+
let fieldInstr = "";
|
|
18839
|
+
let fieldDisplay = "";
|
|
18840
|
+
const flushField = () => {
|
|
18841
|
+
if (!fieldActive) return;
|
|
18842
|
+
if (fieldDisplay) {
|
|
18843
|
+
const url = fieldUrlFromInstr(fieldInstr);
|
|
18844
|
+
parts.push(url ? makeLink(fieldDisplay, url) : fieldDisplay);
|
|
18845
|
+
}
|
|
18846
|
+
fieldActive = false;
|
|
18847
|
+
fieldStage = "instr";
|
|
18848
|
+
fieldInstr = "";
|
|
18849
|
+
fieldDisplay = "";
|
|
18850
|
+
};
|
|
18851
|
+
for (const el of effectiveChildElements(p)) {
|
|
18852
|
+
if (matchesLocal(el, "hyperlink")) {
|
|
18853
|
+
const rId = getAttr(el, "id");
|
|
18854
|
+
const anchor = getAttr(el, "anchor");
|
|
18855
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
18856
|
+
if (!t) continue;
|
|
18857
|
+
let raw = null;
|
|
18858
|
+
if (rId && rels.has(rId)) raw = rels.get(rId);
|
|
18859
|
+
else if (anchor) raw = `#${anchor}`;
|
|
18860
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += t;
|
|
18861
|
+
else parts.push(makeLink(t, raw));
|
|
18862
|
+
continue;
|
|
18863
|
+
}
|
|
18864
|
+
if (matchesLocal(el, "fldSimple")) {
|
|
18865
|
+
const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
|
|
18866
|
+
if (!t) continue;
|
|
18867
|
+
const url = fieldUrlFromInstr(getAttr(el, "instr") ?? "");
|
|
18868
|
+
parts.push(url ? makeLink(t, url) : t);
|
|
18869
|
+
continue;
|
|
18870
|
+
}
|
|
18871
|
+
if (matchesLocal(el, "r")) {
|
|
18872
|
+
for (const fc of getChildElements(el, "fldChar")) {
|
|
18873
|
+
const ty = getAttr(fc, "fldCharType");
|
|
18874
|
+
if (ty === "begin") {
|
|
18875
|
+
flushField();
|
|
18876
|
+
fieldActive = true;
|
|
18877
|
+
fieldStage = "instr";
|
|
18878
|
+
} else if (ty === "separate") {
|
|
18879
|
+
if (fieldActive) fieldStage = "display";
|
|
18880
|
+
} else if (ty === "end") flushField();
|
|
18881
|
+
}
|
|
18882
|
+
if (fieldActive && fieldStage === "instr") {
|
|
18883
|
+
for (const it of getChildElements(el, "instrText")) fieldInstr += it.textContent ?? "";
|
|
18884
|
+
}
|
|
18885
|
+
const rr = extractRun(el);
|
|
18886
|
+
if (rr.bold) bold = true;
|
|
18887
|
+
if (rr.italic) italic = true;
|
|
18888
|
+
const fnRefEls = getChildElements(el, "footnoteReference");
|
|
18889
|
+
if (fnRefEls.length > 0) {
|
|
18890
|
+
const fnId = getAttr(fnRefEls[0], "id");
|
|
18891
|
+
if (fnId && footnotes.has(fnId)) footnoteText = footnotes.get(fnId);
|
|
18892
|
+
}
|
|
18893
|
+
if (rr.text) {
|
|
18894
|
+
if (fieldActive && fieldStage === "display") fieldDisplay += rr.text;
|
|
18895
|
+
else if (fieldActive && fieldStage === "instr") {
|
|
18896
|
+
} else parts.push(rr.text);
|
|
18897
|
+
}
|
|
18898
|
+
continue;
|
|
18899
|
+
}
|
|
18900
|
+
}
|
|
18901
|
+
flushField();
|
|
18902
|
+
for (const om of collectOmmlRoots(p)) {
|
|
18903
|
+
const latex = ommlElementToLatex(om);
|
|
18904
|
+
if (!latex) continue;
|
|
18905
|
+
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
18906
|
+
else parts.push(" $" + latex + "$ ");
|
|
18907
|
+
}
|
|
18908
|
+
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18909
|
+
return { text, bold, italic, footnoteText };
|
|
18910
|
+
}
|
|
18815
18911
|
function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
18816
18912
|
const pPrEls = getChildElements(p, "pPr");
|
|
18817
18913
|
let styleId = "";
|
|
@@ -18828,54 +18924,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18828
18924
|
ilvl = ilvlEls.length > 0 ? parseInt(getAttr(ilvlEls[0], "val") ?? "0", 10) : 0;
|
|
18829
18925
|
}
|
|
18830
18926
|
}
|
|
18831
|
-
const
|
|
18832
|
-
let hasBold = false;
|
|
18833
|
-
let hasItalic = false;
|
|
18834
|
-
let href;
|
|
18835
|
-
let footnoteText;
|
|
18836
|
-
const hyperlinks = getChildElements(p, "hyperlink");
|
|
18837
|
-
const hyperlinkTexts = /* @__PURE__ */ new Set();
|
|
18838
|
-
for (const hl of hyperlinks) {
|
|
18839
|
-
const rId = getAttr(hl, "id");
|
|
18840
|
-
const hlText = [];
|
|
18841
|
-
const runs2 = findElements(hl, "r");
|
|
18842
|
-
for (const r of runs2) {
|
|
18843
|
-
const result = extractRun(r);
|
|
18844
|
-
hlText.push(result.text);
|
|
18845
|
-
}
|
|
18846
|
-
const text2 = hlText.join("");
|
|
18847
|
-
if (text2) {
|
|
18848
|
-
hyperlinkTexts.add(text2);
|
|
18849
|
-
if (rId && rels.has(rId)) {
|
|
18850
|
-
href = rels.get(rId);
|
|
18851
|
-
parts.push(text2);
|
|
18852
|
-
} else {
|
|
18853
|
-
parts.push(text2);
|
|
18854
|
-
}
|
|
18855
|
-
}
|
|
18856
|
-
}
|
|
18857
|
-
const runs = getChildElements(p, "r");
|
|
18858
|
-
for (const r of runs) {
|
|
18859
|
-
if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
|
|
18860
|
-
const result = extractRun(r);
|
|
18861
|
-
if (result.bold) hasBold = true;
|
|
18862
|
-
if (result.italic) hasItalic = true;
|
|
18863
|
-
const fnRefEls = getChildElements(r, "footnoteReference");
|
|
18864
|
-
if (fnRefEls.length > 0) {
|
|
18865
|
-
const fnId = getAttr(fnRefEls[0], "id");
|
|
18866
|
-
if (fnId && footnotes.has(fnId)) {
|
|
18867
|
-
footnoteText = footnotes.get(fnId);
|
|
18868
|
-
}
|
|
18869
|
-
}
|
|
18870
|
-
if (result.text) parts.push(result.text);
|
|
18871
|
-
}
|
|
18872
|
-
for (const om of collectOmmlRoots(p)) {
|
|
18873
|
-
const latex = ommlElementToLatex(om);
|
|
18874
|
-
if (!latex) continue;
|
|
18875
|
-
if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
|
|
18876
|
-
else parts.push(" $" + latex + "$ ");
|
|
18877
|
-
}
|
|
18878
|
-
const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
|
|
18927
|
+
const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
|
|
18879
18928
|
if (!text) return null;
|
|
18880
18929
|
const style = styles.get(styleId);
|
|
18881
18930
|
if (style?.outlineLevel !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
|
|
@@ -18895,7 +18944,6 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
|
|
|
18895
18944
|
if (hasBold || hasItalic) {
|
|
18896
18945
|
block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
|
|
18897
18946
|
}
|
|
18898
|
-
if (href) block.href = href;
|
|
18899
18947
|
if (footnoteText) block.footnoteText = footnoteText;
|
|
18900
18948
|
return block;
|
|
18901
18949
|
}
|
|
@@ -18996,46 +19044,61 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
|
|
|
18996
19044
|
}
|
|
18997
19045
|
return parts;
|
|
18998
19046
|
}
|
|
18999
|
-
async function
|
|
19000
|
-
const
|
|
19047
|
+
async function buildImageMap(zip, rels, doc, warnings) {
|
|
19048
|
+
const imageMap = /* @__PURE__ */ new Map();
|
|
19001
19049
|
const images = [];
|
|
19002
|
-
const drawingElements = findElements(doc.documentElement, "drawing");
|
|
19003
19050
|
let imgIdx = 0;
|
|
19004
|
-
for (const
|
|
19005
|
-
const
|
|
19006
|
-
|
|
19007
|
-
|
|
19008
|
-
|
|
19009
|
-
|
|
19010
|
-
|
|
19011
|
-
|
|
19012
|
-
|
|
19013
|
-
|
|
19014
|
-
|
|
19015
|
-
|
|
19016
|
-
|
|
19017
|
-
|
|
19018
|
-
|
|
19019
|
-
|
|
19020
|
-
|
|
19021
|
-
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
|
|
19025
|
-
|
|
19026
|
-
|
|
19027
|
-
|
|
19028
|
-
|
|
19029
|
-
|
|
19030
|
-
|
|
19031
|
-
|
|
19032
|
-
|
|
19033
|
-
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19034
|
-
});
|
|
19035
|
-
}
|
|
19051
|
+
for (const blip of findElements(doc.documentElement, "blip")) {
|
|
19052
|
+
const embedId = getAttr(blip, "embed");
|
|
19053
|
+
if (!embedId || imageMap.has(embedId)) continue;
|
|
19054
|
+
const target = rels.get(embedId);
|
|
19055
|
+
if (!target) continue;
|
|
19056
|
+
const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
|
|
19057
|
+
const imgFile = zip.file(imgPath);
|
|
19058
|
+
if (!imgFile) continue;
|
|
19059
|
+
try {
|
|
19060
|
+
const data = await imgFile.async("uint8array");
|
|
19061
|
+
imgIdx++;
|
|
19062
|
+
const ext = imgPath.split(".").pop()?.toLowerCase() ?? "png";
|
|
19063
|
+
const mimeMap = {
|
|
19064
|
+
png: "image/png",
|
|
19065
|
+
jpg: "image/jpeg",
|
|
19066
|
+
jpeg: "image/jpeg",
|
|
19067
|
+
gif: "image/gif",
|
|
19068
|
+
bmp: "image/bmp",
|
|
19069
|
+
wmf: "image/wmf",
|
|
19070
|
+
emf: "image/emf"
|
|
19071
|
+
};
|
|
19072
|
+
const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
|
|
19073
|
+
images.push({ filename, data, mimeType: mimeMap[ext] ?? "image/png" });
|
|
19074
|
+
imageMap.set(embedId, filename);
|
|
19075
|
+
} catch (err) {
|
|
19076
|
+
warnings.push({
|
|
19077
|
+
code: "SKIPPED_IMAGE",
|
|
19078
|
+
message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
|
|
19079
|
+
});
|
|
19036
19080
|
}
|
|
19037
19081
|
}
|
|
19038
|
-
return {
|
|
19082
|
+
return { imageMap, images };
|
|
19083
|
+
}
|
|
19084
|
+
function collectParagraphBlips(node, out = [], depth = 0) {
|
|
19085
|
+
if (depth > 40) return out;
|
|
19086
|
+
for (const el of effectiveChildElements(node)) {
|
|
19087
|
+
if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
|
|
19088
|
+
if (matchesLocal(el, "blip")) out.push(el);
|
|
19089
|
+
else collectParagraphBlips(el, out, depth + 1);
|
|
19090
|
+
}
|
|
19091
|
+
return out;
|
|
19092
|
+
}
|
|
19093
|
+
function emitParagraphImages(p, imageMap, linked, out) {
|
|
19094
|
+
for (const blip of collectParagraphBlips(p)) {
|
|
19095
|
+
const embedId = getAttr(blip, "embed");
|
|
19096
|
+
if (!embedId) continue;
|
|
19097
|
+
const filename = imageMap.get(embedId);
|
|
19098
|
+
if (!filename) continue;
|
|
19099
|
+
linked.add(embedId);
|
|
19100
|
+
out.push({ type: "image", text: filename });
|
|
19101
|
+
}
|
|
19039
19102
|
}
|
|
19040
19103
|
async function parseDocxDocument(buffer, options) {
|
|
19041
19104
|
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE4);
|
|
@@ -19092,6 +19155,8 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19092
19155
|
if (body.length === 0) {
|
|
19093
19156
|
throw new KordocError("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19094
19157
|
}
|
|
19158
|
+
const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
|
|
19159
|
+
const linkedImages = /* @__PURE__ */ new Set();
|
|
19095
19160
|
const blocks = [];
|
|
19096
19161
|
const bodyEl = body[0];
|
|
19097
19162
|
const topLevel = effectiveChildElements(bodyEl);
|
|
@@ -19100,16 +19165,20 @@ async function parseDocxDocument(buffer, options) {
|
|
|
19100
19165
|
if (localName2 === "p") {
|
|
19101
19166
|
const block = parseParagraph2(el, styles, numbering, footnotes, rels);
|
|
19102
19167
|
if (block) blocks.push(block);
|
|
19168
|
+
if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
|
|
19103
19169
|
for (const tp of collectTextboxParagraphs(el)) {
|
|
19104
19170
|
const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
|
|
19105
19171
|
if (tb) blocks.push(tb);
|
|
19172
|
+
if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
|
|
19106
19173
|
}
|
|
19107
19174
|
} else if (localName2 === "tbl") {
|
|
19108
19175
|
const block = parseTable(el, styles, numbering, footnotes, rels);
|
|
19109
19176
|
if (block) blocks.push(block);
|
|
19110
19177
|
}
|
|
19111
19178
|
}
|
|
19112
|
-
const
|
|
19179
|
+
for (const [embedId, filename] of imageMap) {
|
|
19180
|
+
if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
|
|
19181
|
+
}
|
|
19113
19182
|
const metadata = {};
|
|
19114
19183
|
const coreFile = zip.file("docProps/core.xml");
|
|
19115
19184
|
if (coreFile) {
|
|
@@ -27103,7 +27172,7 @@ async function parseHwp(buffer, options) {
|
|
|
27103
27172
|
async function parsePdf(buffer, options) {
|
|
27104
27173
|
let parsePdfDocument;
|
|
27105
27174
|
try {
|
|
27106
|
-
const mod = await import("./parser-
|
|
27175
|
+
const mod = await import("./parser-5EHWYJMC.js");
|
|
27107
27176
|
parsePdfDocument = mod.parsePdfDocument;
|
|
27108
27177
|
} catch {
|
|
27109
27178
|
return {
|
|
@@ -27236,4 +27305,4 @@ export {
|
|
|
27236
27305
|
parseHwpml,
|
|
27237
27306
|
fillForm
|
|
27238
27307
|
};
|
|
27239
|
-
//# sourceMappingURL=chunk-
|
|
27308
|
+
//# sourceMappingURL=chunk-TJJTLM76.js.map
|