@beyondwork/docx-react-component 1.0.120 → 1.0.121
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 +1 -0
- package/dist/api/public-types.cjs +1713 -55
- package/dist/api/public-types.d.cts +2 -2
- package/dist/api/public-types.d.ts +2 -2
- package/dist/api/public-types.js +6 -6
- package/dist/api/v3.cjs +4958 -406
- package/dist/api/v3.d.cts +3 -3
- package/dist/api/v3.d.ts +3 -3
- package/dist/api/v3.js +14 -14
- package/dist/{canonical-document-fNawStsc.d.cts → canonical-document-ByIqTd4s.d.cts} +9 -1
- package/dist/{canonical-document-fNawStsc.d.ts → canonical-document-ByIqTd4s.d.ts} +9 -1
- package/dist/{chunk-5RNMPLXU.js → chunk-37SEJQ3G.js} +4 -4
- package/dist/{chunk-FXGQM2JB.js → chunk-3OFSP2IX.js} +11 -5
- package/dist/{chunk-U5BSQXF4.js → chunk-3OHVK2D6.js} +70 -12
- package/dist/{chunk-AUQDC5BD.js → chunk-3TUQCHYT.js} +101 -2
- package/dist/{chunk-SJSMYEMU.js → chunk-B4YHWFE3.js} +3 -3
- package/dist/{chunk-XC56YLIS.js → chunk-C2LWJ4CZ.js} +4 -0
- package/dist/{chunk-VDIUVT46.js → chunk-CX42VC67.js} +1 -1
- package/dist/{chunk-KCHEAX4Z.js → chunk-EMDH4IQN.js} +148 -70
- package/dist/{chunk-TMQGWF7R.js → chunk-G3B2OBCZ.js} +352 -17
- package/dist/{chunk-VCL5MJMZ.js → chunk-GON2DNTE.js} +149 -28
- package/dist/{chunk-WVZX4NYG.js → chunk-GZW2ERUO.js} +601 -47
- package/dist/{chunk-WDNEPRFW.js → chunk-ICX54W4U.js} +1 -1
- package/dist/{chunk-FIGWJ43K.js → chunk-IT2DK3A7.js} +1883 -90
- package/dist/{chunk-2ZWFQ74R.js → chunk-OBCP6VTG.js} +1 -1
- package/dist/{chunk-FLNQY74K.js → chunk-OYGMRRR7.js} +1 -1
- package/dist/{chunk-MPYYBRVN.js → chunk-PCXTMEGY.js} +782 -124
- package/dist/{chunk-4JNUMMM7.js → chunk-PGGPPZ65.js} +17 -2
- package/dist/{chunk-KHZNNBTN.js → chunk-QFU7ZOAD.js} +43 -39
- package/dist/{chunk-4ZNQFWFM.js → chunk-QIO6V46H.js} +84 -4
- package/dist/{chunk-IQ2VJEF6.js → chunk-QNGJRZ2D.js} +1 -1
- package/dist/{chunk-BM5NSDII.js → chunk-S4ANOS2M.js} +2 -2
- package/dist/{chunk-AQA7OZ2R.js → chunk-TFSXOIAI.js} +959 -43
- package/dist/{chunk-NQZUGMLW.js → chunk-TMU7JMXX.js} +184 -32
- package/dist/{chunk-KD5K5XIA.js → chunk-UHQOUTAX.js} +568 -88
- package/dist/{chunk-327AIUXL.js → chunk-UWDWGQH5.js} +11 -4
- package/dist/{chunk-BBB4GSDB.js → chunk-XVFENXLK.js} +2 -2
- package/dist/{chunk-MUEN2WOG.js → chunk-ZKSDVHGH.js} +6 -3
- package/dist/compare.cjs +17 -2
- package/dist/compare.d.cts +1 -1
- package/dist/compare.d.ts +1 -1
- package/dist/compare.js +3 -3
- package/dist/core/commands/formatting-commands.d.cts +2 -2
- package/dist/core/commands/formatting-commands.d.ts +2 -2
- package/dist/core/commands/image-commands.cjs +814 -45
- package/dist/core/commands/image-commands.d.cts +2 -2
- package/dist/core/commands/image-commands.d.ts +2 -2
- package/dist/core/commands/image-commands.js +8 -8
- package/dist/core/commands/section-layout-commands.d.cts +2 -2
- package/dist/core/commands/section-layout-commands.d.ts +2 -2
- package/dist/core/commands/style-commands.d.cts +2 -2
- package/dist/core/commands/style-commands.d.ts +2 -2
- package/dist/core/commands/table-structure-commands.cjs +750 -42
- package/dist/core/commands/table-structure-commands.d.cts +2 -2
- package/dist/core/commands/table-structure-commands.d.ts +2 -2
- package/dist/core/commands/table-structure-commands.js +6 -6
- package/dist/core/commands/text-commands.cjs +910 -57
- package/dist/core/commands/text-commands.d.cts +2 -2
- package/dist/core/commands/text-commands.d.ts +2 -2
- package/dist/core/commands/text-commands.js +8 -8
- package/dist/core/selection/mapping.d.cts +2 -2
- package/dist/core/selection/mapping.d.ts +2 -2
- package/dist/core/state/editor-state.cjs +17 -2
- package/dist/core/state/editor-state.d.cts +2 -2
- package/dist/core/state/editor-state.d.ts +2 -2
- package/dist/core/state/editor-state.js +2 -2
- package/dist/index.cjs +6203 -625
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +299 -67
- package/dist/io/docx-session.cjs +354 -102
- package/dist/io/docx-session.d.cts +4 -4
- package/dist/io/docx-session.d.ts +4 -4
- package/dist/io/docx-session.js +5 -5
- package/dist/legal.cjs +183 -31
- package/dist/legal.d.cts +1 -1
- package/dist/legal.d.ts +1 -1
- package/dist/legal.js +3 -3
- package/dist/{loader-CaohrhNl.d.ts → loader-BF8ju_LK.d.ts} +22 -4
- package/dist/{loader-BpCyGnZl.d.cts → loader-g54WRvj1.d.cts} +22 -4
- package/dist/{public-types-Dpch9JG0.d.cts → public-types-D_y4Ptcj.d.cts} +747 -21
- package/dist/{public-types-C948HNVF.d.ts → public-types-Dl1jiWjk.d.ts} +747 -21
- package/dist/public-types.cjs +1713 -55
- package/dist/public-types.d.cts +2 -2
- package/dist/public-types.d.ts +2 -2
- package/dist/public-types.js +6 -6
- package/dist/runtime/collab.cjs +4 -0
- package/dist/runtime/collab.d.cts +3 -3
- package/dist/runtime/collab.d.ts +3 -3
- package/dist/runtime/collab.js +2 -2
- package/dist/runtime/document-runtime.cjs +3699 -507
- package/dist/runtime/document-runtime.d.cts +2 -2
- package/dist/runtime/document-runtime.d.ts +2 -2
- package/dist/runtime/document-runtime.js +18 -18
- package/dist/{session-Dqg17V3s.d.ts → session-C1EPAkcI.d.ts} +3 -3
- package/dist/{session-BlXE5zxz.d.cts → session-D15QOO0Q.d.cts} +3 -3
- package/dist/session.cjs +951 -104
- package/dist/session.d.cts +5 -5
- package/dist/session.d.ts +5 -5
- package/dist/session.js +10 -8
- package/dist/tailwind.cjs +1752 -91
- package/dist/tailwind.d.cts +2 -2
- package/dist/tailwind.d.ts +2 -2
- package/dist/tailwind.js +10 -10
- package/dist/{types-C9vZVpKy.d.cts → types-BoSRp2Vg.d.cts} +2 -2
- package/dist/{types-B1tlF1bq.d.ts → types-DEvRwq9C.d.ts} +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
- package/dist/ui-tailwind/editor-surface/search-plugin.js +7 -7
- package/dist/ui-tailwind/theme/editor-theme.css +5 -5
- package/dist/ui-tailwind.cjs +1752 -91
- package/dist/ui-tailwind.d.cts +8 -8
- package/dist/ui-tailwind.d.ts +8 -8
- package/dist/ui-tailwind.js +10 -10
- package/package.json +17 -5
- package/dist/ui-tailwind/theme/tokens.css +0 -382
package/dist/io/docx-session.cjs
CHANGED
|
@@ -8954,6 +8954,9 @@ function validateDocumentNode(value, path, issues, context = "root") {
|
|
|
8954
8954
|
}
|
|
8955
8955
|
return;
|
|
8956
8956
|
case "table_row":
|
|
8957
|
+
if (record.sourceRef !== void 0) {
|
|
8958
|
+
validateCanonicalSourceRef(record.sourceRef, `${path}.sourceRef`, issues);
|
|
8959
|
+
}
|
|
8957
8960
|
if (!Array.isArray(record.cells)) {
|
|
8958
8961
|
issues.push({ path: `${path}.cells`, message: "cells must be an array." });
|
|
8959
8962
|
} else {
|
|
@@ -8963,6 +8966,9 @@ function validateDocumentNode(value, path, issues, context = "root") {
|
|
|
8963
8966
|
}
|
|
8964
8967
|
return;
|
|
8965
8968
|
case "table_cell":
|
|
8969
|
+
if (record.sourceRef !== void 0) {
|
|
8970
|
+
validateCanonicalSourceRef(record.sourceRef, `${path}.sourceRef`, issues);
|
|
8971
|
+
}
|
|
8966
8972
|
if (!Array.isArray(record.children)) {
|
|
8967
8973
|
issues.push({ path: `${path}.children`, message: "children must be an array." });
|
|
8968
8974
|
} else {
|
|
@@ -8993,9 +8999,15 @@ function validateDocumentNode(value, path, issues, context = "root") {
|
|
|
8993
8999
|
case "bookmark_start":
|
|
8994
9000
|
expectString(record.bookmarkId, `${path}.bookmarkId`, issues);
|
|
8995
9001
|
expectString(record.name, `${path}.name`, issues);
|
|
9002
|
+
if (record.sourceRef !== void 0) {
|
|
9003
|
+
validateCanonicalSourceRef(record.sourceRef, `${path}.sourceRef`, issues);
|
|
9004
|
+
}
|
|
8996
9005
|
return;
|
|
8997
9006
|
case "bookmark_end":
|
|
8998
9007
|
expectString(record.bookmarkId, `${path}.bookmarkId`, issues);
|
|
9008
|
+
if (record.sourceRef !== void 0) {
|
|
9009
|
+
validateCanonicalSourceRef(record.sourceRef, `${path}.sourceRef`, issues);
|
|
9010
|
+
}
|
|
8999
9011
|
return;
|
|
9000
9012
|
case "scope_marker_start":
|
|
9001
9013
|
case "scope_marker_end":
|
|
@@ -9096,6 +9108,9 @@ function validateDocumentNode(value, path, issues, context = "root") {
|
|
|
9096
9108
|
return;
|
|
9097
9109
|
}
|
|
9098
9110
|
case "ole_embed":
|
|
9111
|
+
if (record.sourceRef !== void 0) {
|
|
9112
|
+
validateCanonicalSourceRef(record.sourceRef, `${path}.sourceRef`, issues);
|
|
9113
|
+
}
|
|
9099
9114
|
expectString(record.id, `${path}.id`, issues);
|
|
9100
9115
|
expectString(record.relationshipId, `${path}.relationshipId`, issues);
|
|
9101
9116
|
expectString(record.rawXml, `${path}.rawXml`, issues);
|
|
@@ -9224,12 +9239,12 @@ function validateCanonicalSourceRef(value, path, issues) {
|
|
|
9224
9239
|
return;
|
|
9225
9240
|
}
|
|
9226
9241
|
expectString(record.sourceId, `${path}.sourceId`, issues);
|
|
9227
|
-
for (const key of ["partPath", "storyKind", "element"]) {
|
|
9242
|
+
for (const key of ["partPath", "storyKind", "element", "xmlPath", "tableCellPath"]) {
|
|
9228
9243
|
if (record[key] !== void 0) {
|
|
9229
9244
|
expectString(record[key], `${path}.${key}`, issues);
|
|
9230
9245
|
}
|
|
9231
9246
|
}
|
|
9232
|
-
for (const key of ["ordinal", "startOffset", "endOffset"]) {
|
|
9247
|
+
for (const key of ["ordinal", "startOffset", "endOffset", "tableDepth"]) {
|
|
9233
9248
|
if (record[key] !== void 0 && (!Number.isInteger(record[key]) || record[key] < 0)) {
|
|
9234
9249
|
issues.push({
|
|
9235
9250
|
path: `${path}.${key}`,
|
|
@@ -14134,6 +14149,7 @@ function resolveContentType(path, contentTypes) {
|
|
|
14134
14149
|
// src/io/ooxml/parse-bookmark-references.ts
|
|
14135
14150
|
var HYPERLINK_ANCHOR_RE = /<(?:\w+:)?hyperlink\b[^>]*\bw:anchor\s*=\s*"([^"]*)"/gi;
|
|
14136
14151
|
var INSTR_TEXT_RE = /<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gi;
|
|
14152
|
+
var SIMPLE_FIELD_INSTR_RE = /<(?:\w+:)?fldSimple\b[^>]*\bw:instr\s*=\s*"([^"]*)"/gi;
|
|
14137
14153
|
var TOC_FIELD_RE = /\bTOC\b/;
|
|
14138
14154
|
var REFLIKE_FIELD_RE = /\b(?:HYPERLINK|REF|PAGEREF|NOTEREF)\s+([A-Za-z0-9_:.\-]+)/g;
|
|
14139
14155
|
var DATA_BINDING_RE = /<(?:\w+:)?dataBinding\b/i;
|
|
@@ -14152,12 +14168,14 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
|
|
|
14152
14168
|
}
|
|
14153
14169
|
INSTR_TEXT_RE.lastIndex = 0;
|
|
14154
14170
|
while ((m = INSTR_TEXT_RE.exec(documentXml)) !== null) {
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14171
|
+
if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
|
|
14172
|
+
retainAllToc = true;
|
|
14173
|
+
}
|
|
14174
|
+
}
|
|
14175
|
+
SIMPLE_FIELD_INSTR_RE.lastIndex = 0;
|
|
14176
|
+
while ((m = SIMPLE_FIELD_INSTR_RE.exec(documentXml)) !== null) {
|
|
14177
|
+
if (scanInstructionForRetainedBookmarks(m[1] ?? "", retained)) {
|
|
14178
|
+
retainAllToc = true;
|
|
14161
14179
|
}
|
|
14162
14180
|
}
|
|
14163
14181
|
retainRevisionBoundedBookmarks(documentXml, retained);
|
|
@@ -14167,6 +14185,15 @@ function scanBookmarkReferences(documentXml, callerAllowlist = []) {
|
|
|
14167
14185
|
retainAll
|
|
14168
14186
|
};
|
|
14169
14187
|
}
|
|
14188
|
+
function scanInstructionForRetainedBookmarks(instruction, retained) {
|
|
14189
|
+
const hasTocField = TOC_FIELD_RE.test(instruction);
|
|
14190
|
+
REFLIKE_FIELD_RE.lastIndex = 0;
|
|
14191
|
+
let r;
|
|
14192
|
+
while ((r = REFLIKE_FIELD_RE.exec(instruction)) !== null) {
|
|
14193
|
+
if (r[1]) retained.add(r[1]);
|
|
14194
|
+
}
|
|
14195
|
+
return hasTocField;
|
|
14196
|
+
}
|
|
14170
14197
|
function retainRevisionBoundedBookmarks(documentXml, retained) {
|
|
14171
14198
|
const starts = /* @__PURE__ */ new Map();
|
|
14172
14199
|
BOOKMARK_START_RE.lastIndex = 0;
|
|
@@ -17669,7 +17696,7 @@ var SAFE_TABLE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
|
|
|
17669
17696
|
"FORMULA"
|
|
17670
17697
|
]);
|
|
17671
17698
|
var RISKY_TABLE_MARKUP_RE = /<w:(ins|del|moveFrom|moveTo|rPrChange|pPrChange|tblPrChange|trPrChange|tcPrChange|sectPrChange|cellIns|cellDel|cellMerge|smartTag)\b/;
|
|
17672
|
-
var
|
|
17699
|
+
var SIMPLE_FIELD_INSTR_RE2 = /\bw:instr="([^"]*)"/g;
|
|
17673
17700
|
var COMPLEX_FIELD_TOKEN_RE = /<(?:\w+:)?fldChar\b[^>]*?(?:\w+:)?fldCharType="(begin|separate|end)"[^>]*?(?:\/>|>[\s\S]*?<\/(?:\w+:)?fldChar>)|<(?:\w+:)?instrText\b[^>]*>([\s\S]*?)<\/(?:\w+:)?instrText>/gu;
|
|
17674
17701
|
function decodeXmlEntities5(text) {
|
|
17675
17702
|
return text.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
@@ -17710,7 +17737,7 @@ function isSafeTableFieldInstruction(instruction) {
|
|
|
17710
17737
|
}
|
|
17711
17738
|
function tableRequiresOpaquePreservation(rawXml) {
|
|
17712
17739
|
if (RISKY_TABLE_MARKUP_RE.test(rawXml)) return true;
|
|
17713
|
-
const simpleInstructions = [...rawXml.matchAll(
|
|
17740
|
+
const simpleInstructions = [...rawXml.matchAll(SIMPLE_FIELD_INSTR_RE2)].map(
|
|
17714
17741
|
(match) => match[1] ?? ""
|
|
17715
17742
|
);
|
|
17716
17743
|
const complexInstructions = extractComplexFieldInstructionsFromRaw(rawXml);
|
|
@@ -18393,7 +18420,11 @@ function parseMainDocumentXmlInner(xml, relationships, mediaParts, sourcePartPat
|
|
|
18393
18420
|
const documentElement2 = findChildElement4(root, "document");
|
|
18394
18421
|
const bodyElement = findChildElement4(documentElement2, "body");
|
|
18395
18422
|
const relationshipMap = new Map(relationships.map((relationship) => [relationship.id, relationship]));
|
|
18396
|
-
const allBlocks =
|
|
18423
|
+
const allBlocks = mapElementChildrenWithXmlPath(
|
|
18424
|
+
bodyElement,
|
|
18425
|
+
"/document[1]/body[1]",
|
|
18426
|
+
(node, xmlPath) => parseBodyChild(node, xml, relationshipMap, relationships, mediaParts, sourcePartPath, 0, xmlPath)
|
|
18427
|
+
).filter((block) => !(block.type === "opaque_block" && block.rawXml === ""));
|
|
18397
18428
|
let finalSectionProperties;
|
|
18398
18429
|
const blocks = [];
|
|
18399
18430
|
for (let i = 0; i < allBlocks.length; i++) {
|
|
@@ -18483,22 +18514,25 @@ function parseBlockStreamFromXml(xml, ctx) {
|
|
|
18483
18514
|
const priorDepth = activeTxbxBlockStreamDepth;
|
|
18484
18515
|
activeTxbxBlockStreamDepth = depth;
|
|
18485
18516
|
try {
|
|
18486
|
-
return
|
|
18487
|
-
|
|
18517
|
+
return mapElementChildrenWithXmlPath(
|
|
18518
|
+
wrapper,
|
|
18519
|
+
`/${localName(wrapper.name)}[1]`,
|
|
18520
|
+
(n, xmlPath) => parseBodyChild(
|
|
18488
18521
|
n,
|
|
18489
18522
|
xml,
|
|
18490
18523
|
relationshipMap,
|
|
18491
18524
|
ctx.relationships,
|
|
18492
18525
|
ctx.mediaParts,
|
|
18493
18526
|
ctx.sourcePartPath,
|
|
18494
|
-
depth
|
|
18527
|
+
depth,
|
|
18528
|
+
xmlPath
|
|
18495
18529
|
)
|
|
18496
18530
|
);
|
|
18497
18531
|
} finally {
|
|
18498
18532
|
activeTxbxBlockStreamDepth = priorDepth;
|
|
18499
18533
|
}
|
|
18500
18534
|
}
|
|
18501
|
-
function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0) {
|
|
18535
|
+
function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, _depth = 0, sourceXmlPath = `/${localName(node.name)}[1]`) {
|
|
18502
18536
|
const nodeType = localName(node.name);
|
|
18503
18537
|
if (nodeType === "tbl") {
|
|
18504
18538
|
const rawTableXml = sourceXml.slice(node.start, node.end);
|
|
@@ -18509,7 +18543,15 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
|
|
|
18509
18543
|
};
|
|
18510
18544
|
}
|
|
18511
18545
|
try {
|
|
18512
|
-
return parseTableElement(
|
|
18546
|
+
return parseTableElement(
|
|
18547
|
+
node,
|
|
18548
|
+
sourceXml,
|
|
18549
|
+
relationshipMap,
|
|
18550
|
+
relationships,
|
|
18551
|
+
mediaParts,
|
|
18552
|
+
sourcePartPath,
|
|
18553
|
+
sourceXmlPath
|
|
18554
|
+
);
|
|
18513
18555
|
} catch {
|
|
18514
18556
|
return {
|
|
18515
18557
|
type: "opaque_block",
|
|
@@ -18518,10 +18560,26 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
|
|
|
18518
18560
|
}
|
|
18519
18561
|
}
|
|
18520
18562
|
if (nodeType === "sdt") {
|
|
18521
|
-
return parseSdtElement(
|
|
18563
|
+
return parseSdtElement(
|
|
18564
|
+
node,
|
|
18565
|
+
sourceXml,
|
|
18566
|
+
relationshipMap,
|
|
18567
|
+
relationships,
|
|
18568
|
+
mediaParts,
|
|
18569
|
+
sourcePartPath,
|
|
18570
|
+
sourceXmlPath
|
|
18571
|
+
);
|
|
18522
18572
|
}
|
|
18523
18573
|
if (nodeType === "customXml") {
|
|
18524
|
-
return parseCustomXmlElement(
|
|
18574
|
+
return parseCustomXmlElement(
|
|
18575
|
+
node,
|
|
18576
|
+
sourceXml,
|
|
18577
|
+
relationshipMap,
|
|
18578
|
+
relationships,
|
|
18579
|
+
mediaParts,
|
|
18580
|
+
sourcePartPath,
|
|
18581
|
+
sourceXmlPath
|
|
18582
|
+
);
|
|
18525
18583
|
}
|
|
18526
18584
|
if (nodeType === "altChunk") {
|
|
18527
18585
|
return parseAltChunkElement(node, sourceXml);
|
|
@@ -18667,6 +18725,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
|
|
|
18667
18725
|
type: "bookmark_start",
|
|
18668
18726
|
bookmarkId: bkId,
|
|
18669
18727
|
name: bkName,
|
|
18728
|
+
sourceRef: createElementSourceRef(sourcePartPath, "bookmarkStart", child),
|
|
18670
18729
|
rawXml: sourceXml.slice(child.start, child.end)
|
|
18671
18730
|
};
|
|
18672
18731
|
flushActiveComplexField(children, () => {
|
|
@@ -18694,6 +18753,7 @@ function parseBodyChild(node, sourceXml, relationshipMap, relationships, mediaPa
|
|
|
18694
18753
|
const bookmarkNode = {
|
|
18695
18754
|
type: "bookmark_end",
|
|
18696
18755
|
bookmarkId: bkEndId,
|
|
18756
|
+
sourceRef: createElementSourceRef(sourcePartPath, "bookmarkEnd", child),
|
|
18697
18757
|
rawXml: sourceXml.slice(child.start, child.end)
|
|
18698
18758
|
};
|
|
18699
18759
|
flushActiveComplexField(children, () => {
|
|
@@ -18901,7 +18961,7 @@ function flushActiveComplexField(children, reset, activeComplexField) {
|
|
|
18901
18961
|
});
|
|
18902
18962
|
reset();
|
|
18903
18963
|
}
|
|
18904
|
-
function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
|
|
18964
|
+
function parseTableElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
|
|
18905
18965
|
let styleId;
|
|
18906
18966
|
let tblLook;
|
|
18907
18967
|
let propertiesXml;
|
|
@@ -18945,13 +19005,24 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
|
|
|
18945
19005
|
break;
|
|
18946
19006
|
}
|
|
18947
19007
|
case "tr": {
|
|
18948
|
-
rows.push(
|
|
19008
|
+
rows.push(
|
|
19009
|
+
parseTableRowElement(
|
|
19010
|
+
child,
|
|
19011
|
+
sourceXml,
|
|
19012
|
+
relationshipMap,
|
|
19013
|
+
relationships,
|
|
19014
|
+
mediaParts,
|
|
19015
|
+
sourcePartPath,
|
|
19016
|
+
`${sourceXmlPath}/tr[${rows.length + 1}]`
|
|
19017
|
+
)
|
|
19018
|
+
);
|
|
18949
19019
|
break;
|
|
18950
19020
|
}
|
|
18951
19021
|
}
|
|
18952
19022
|
}
|
|
18953
19023
|
return {
|
|
18954
19024
|
type: "table",
|
|
19025
|
+
sourceRef: createStableTableSourceRef(sourcePartPath, "tbl", sourceXmlPath),
|
|
18955
19026
|
...styleId ? { styleId } : {},
|
|
18956
19027
|
...tblLook ? { tblLook } : {},
|
|
18957
19028
|
...propertiesXml ? { propertiesXml } : {},
|
|
@@ -18972,7 +19043,7 @@ function parseTableElement(node, sourceXml, relationshipMap, relationships, medi
|
|
|
18972
19043
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
18973
19044
|
};
|
|
18974
19045
|
}
|
|
18975
|
-
function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
|
|
19046
|
+
function parseTableRowElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
|
|
18976
19047
|
let propertiesXml;
|
|
18977
19048
|
let unknownPropertyChildren;
|
|
18978
19049
|
let gridBefore;
|
|
@@ -19004,12 +19075,23 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
|
|
|
19004
19075
|
cnfStyle = readRowCnfStyle2(child);
|
|
19005
19076
|
break;
|
|
19006
19077
|
case "tc":
|
|
19007
|
-
cells.push(
|
|
19078
|
+
cells.push(
|
|
19079
|
+
parseTableCellElement(
|
|
19080
|
+
child,
|
|
19081
|
+
sourceXml,
|
|
19082
|
+
relationshipMap,
|
|
19083
|
+
relationships,
|
|
19084
|
+
mediaParts,
|
|
19085
|
+
sourcePartPath,
|
|
19086
|
+
`${sourceXmlPath}/tc[${cells.length + 1}]`
|
|
19087
|
+
)
|
|
19088
|
+
);
|
|
19008
19089
|
break;
|
|
19009
19090
|
}
|
|
19010
19091
|
}
|
|
19011
19092
|
return {
|
|
19012
19093
|
type: "table_row",
|
|
19094
|
+
sourceRef: createStableTableSourceRef(sourcePartPath, "tr", sourceXmlPath),
|
|
19013
19095
|
...propertiesXml ? { propertiesXml } : {},
|
|
19014
19096
|
...unknownPropertyChildren ? { unknownPropertyChildren } : {},
|
|
19015
19097
|
...gridBefore !== void 0 ? { gridBefore } : {},
|
|
@@ -19026,7 +19108,7 @@ function parseTableRowElement(node, sourceXml, relationshipMap, relationships, m
|
|
|
19026
19108
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
19027
19109
|
};
|
|
19028
19110
|
}
|
|
19029
|
-
function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
|
|
19111
|
+
function parseTableCellElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
|
|
19030
19112
|
let propertiesXml;
|
|
19031
19113
|
let unknownPropertyChildren;
|
|
19032
19114
|
let gridSpan;
|
|
@@ -19061,13 +19143,27 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
|
|
|
19061
19143
|
break;
|
|
19062
19144
|
}
|
|
19063
19145
|
default: {
|
|
19064
|
-
children.push(
|
|
19146
|
+
children.push(
|
|
19147
|
+
parseBodyChild(
|
|
19148
|
+
child,
|
|
19149
|
+
sourceXml,
|
|
19150
|
+
relationshipMap,
|
|
19151
|
+
relationships,
|
|
19152
|
+
mediaParts,
|
|
19153
|
+
sourcePartPath,
|
|
19154
|
+
0,
|
|
19155
|
+
`${sourceXmlPath}/${localName(child.name)}[${countPriorElementSiblingsByName(node, child) + 1}]`
|
|
19156
|
+
)
|
|
19157
|
+
);
|
|
19065
19158
|
break;
|
|
19066
19159
|
}
|
|
19067
19160
|
}
|
|
19068
19161
|
}
|
|
19069
19162
|
return {
|
|
19070
19163
|
type: "table_cell",
|
|
19164
|
+
sourceRef: createStableTableSourceRef(sourcePartPath, "tc", sourceXmlPath, {
|
|
19165
|
+
tableCellPath: sourceXmlPath
|
|
19166
|
+
}),
|
|
19071
19167
|
...propertiesXml ? { propertiesXml } : {},
|
|
19072
19168
|
...unknownPropertyChildren ? { unknownPropertyChildren } : {},
|
|
19073
19169
|
...gridSpan ? { gridSpan } : {},
|
|
@@ -19085,7 +19181,7 @@ function parseTableCellElement(node, sourceXml, relationshipMap, relationships,
|
|
|
19085
19181
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
19086
19182
|
};
|
|
19087
19183
|
}
|
|
19088
|
-
function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
|
|
19184
|
+
function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
|
|
19089
19185
|
const propertiesNode = node.children.find(
|
|
19090
19186
|
(child) => child.type === "element" && localName(child.name) === "sdtPr"
|
|
19091
19187
|
);
|
|
@@ -19098,7 +19194,20 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
|
|
|
19098
19194
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
19099
19195
|
};
|
|
19100
19196
|
}
|
|
19101
|
-
const children =
|
|
19197
|
+
const children = mapElementChildrenWithXmlPath(
|
|
19198
|
+
contentNode,
|
|
19199
|
+
`${sourceXmlPath}/sdtContent[1]`,
|
|
19200
|
+
(child, childXmlPath) => parseBodyChild(
|
|
19201
|
+
child,
|
|
19202
|
+
sourceXml,
|
|
19203
|
+
relationshipMap,
|
|
19204
|
+
relationships,
|
|
19205
|
+
mediaParts,
|
|
19206
|
+
sourcePartPath,
|
|
19207
|
+
0,
|
|
19208
|
+
childXmlPath
|
|
19209
|
+
)
|
|
19210
|
+
);
|
|
19102
19211
|
return {
|
|
19103
19212
|
type: "sdt",
|
|
19104
19213
|
sourceRef: createElementSourceRef(sourcePartPath, "sdt", node),
|
|
@@ -19107,7 +19216,7 @@ function parseSdtElement(node, sourceXml, relationshipMap, relationships, mediaP
|
|
|
19107
19216
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
19108
19217
|
};
|
|
19109
19218
|
}
|
|
19110
|
-
function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath) {
|
|
19219
|
+
function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships, mediaParts, sourcePartPath, sourceXmlPath) {
|
|
19111
19220
|
const uri = readOptionalAttribute2(node, "uri");
|
|
19112
19221
|
const element = readOptionalAttribute2(node, "element");
|
|
19113
19222
|
if (!uri && !element) {
|
|
@@ -19116,9 +19225,20 @@ function parseCustomXmlElement(node, sourceXml, relationshipMap, relationships,
|
|
|
19116
19225
|
rawXml: sourceXml.slice(node.start, node.end)
|
|
19117
19226
|
};
|
|
19118
19227
|
}
|
|
19119
|
-
const children =
|
|
19120
|
-
|
|
19121
|
-
|
|
19228
|
+
const children = mapElementChildrenWithXmlPath(
|
|
19229
|
+
node,
|
|
19230
|
+
sourceXmlPath,
|
|
19231
|
+
(child, childXmlPath) => localName(child.name) === "customXmlPr" ? void 0 : parseBodyChild(
|
|
19232
|
+
child,
|
|
19233
|
+
sourceXml,
|
|
19234
|
+
relationshipMap,
|
|
19235
|
+
relationships,
|
|
19236
|
+
mediaParts,
|
|
19237
|
+
sourcePartPath,
|
|
19238
|
+
0,
|
|
19239
|
+
childXmlPath
|
|
19240
|
+
)
|
|
19241
|
+
).filter((child) => child !== void 0);
|
|
19122
19242
|
return {
|
|
19123
19243
|
type: "custom_xml",
|
|
19124
19244
|
...uri ? { uri } : {},
|
|
@@ -19650,6 +19770,43 @@ function createElementSourceRef(partPath, element, node) {
|
|
|
19650
19770
|
endOffset: node.end
|
|
19651
19771
|
};
|
|
19652
19772
|
}
|
|
19773
|
+
function createStableTableSourceRef(partPath, element, xmlPath, extras = {}) {
|
|
19774
|
+
return {
|
|
19775
|
+
sourceId: `part:${partPath}#${xmlPath}`,
|
|
19776
|
+
partPath,
|
|
19777
|
+
storyKind: storyKindFromPartPath(partPath),
|
|
19778
|
+
element,
|
|
19779
|
+
xmlPath,
|
|
19780
|
+
...extras
|
|
19781
|
+
};
|
|
19782
|
+
}
|
|
19783
|
+
function mapElementChildrenWithXmlPath(parent, parentXmlPath, mapChild) {
|
|
19784
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
19785
|
+
const mapped = [];
|
|
19786
|
+
for (const child of parent.children) {
|
|
19787
|
+
if (child.type !== "element") {
|
|
19788
|
+
continue;
|
|
19789
|
+
}
|
|
19790
|
+
const name = localName(child.name);
|
|
19791
|
+
const ordinal = (ordinals.get(name) ?? 0) + 1;
|
|
19792
|
+
ordinals.set(name, ordinal);
|
|
19793
|
+
mapped.push(mapChild(child, `${parentXmlPath}/${name}[${ordinal}]`));
|
|
19794
|
+
}
|
|
19795
|
+
return mapped;
|
|
19796
|
+
}
|
|
19797
|
+
function countPriorElementSiblingsByName(parent, target) {
|
|
19798
|
+
const name = localName(target.name);
|
|
19799
|
+
let count = 0;
|
|
19800
|
+
for (const child of parent.children) {
|
|
19801
|
+
if (child === target) {
|
|
19802
|
+
return count;
|
|
19803
|
+
}
|
|
19804
|
+
if (child.type === "element" && localName(child.name) === name) {
|
|
19805
|
+
count += 1;
|
|
19806
|
+
}
|
|
19807
|
+
}
|
|
19808
|
+
return count;
|
|
19809
|
+
}
|
|
19653
19810
|
function createFieldSequenceSourceRef(partPath, node) {
|
|
19654
19811
|
activeFieldSequenceOrdinal += 1;
|
|
19655
19812
|
return {
|
|
@@ -19751,7 +19908,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
|
|
|
19751
19908
|
})
|
|
19752
19909
|
});
|
|
19753
19910
|
if (frame) {
|
|
19754
|
-
result.push(
|
|
19911
|
+
result.push({
|
|
19912
|
+
...frame,
|
|
19913
|
+
sourceRef: createElementSourceRef(sourcePartPath, "drawing", child)
|
|
19914
|
+
});
|
|
19755
19915
|
break;
|
|
19756
19916
|
}
|
|
19757
19917
|
} catch {
|
|
@@ -19800,6 +19960,7 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
|
|
|
19800
19960
|
...parsedMedia.map((media) => ({
|
|
19801
19961
|
type: "image",
|
|
19802
19962
|
mediaId: media.mediaId,
|
|
19963
|
+
sourceRef: createElementSourceRef(sourcePartPath, "drawing", child),
|
|
19803
19964
|
relationshipId: media.relationshipId,
|
|
19804
19965
|
packagePartName: media.packagePartName,
|
|
19805
19966
|
contentType: media.contentType,
|
|
@@ -19830,7 +19991,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
|
|
|
19830
19991
|
})
|
|
19831
19992
|
});
|
|
19832
19993
|
if (frame) {
|
|
19833
|
-
result.push(
|
|
19994
|
+
result.push({
|
|
19995
|
+
...frame,
|
|
19996
|
+
sourceRef: createElementSourceRef(sourcePartPath, "AlternateContent", child)
|
|
19997
|
+
});
|
|
19834
19998
|
break;
|
|
19835
19999
|
}
|
|
19836
20000
|
} catch {
|
|
@@ -19867,7 +20031,10 @@ function parseRun(node, sourceXml, relationships, mediaParts, sourcePartPath) {
|
|
|
19867
20031
|
try {
|
|
19868
20032
|
const oleNode = parseObject(child, objectXml, relationships);
|
|
19869
20033
|
if (oleNode) {
|
|
19870
|
-
result.push(
|
|
20034
|
+
result.push({
|
|
20035
|
+
...oleNode,
|
|
20036
|
+
sourceRef: createElementSourceRef(sourcePartPath, "object", child)
|
|
20037
|
+
});
|
|
19871
20038
|
break;
|
|
19872
20039
|
}
|
|
19873
20040
|
} catch {
|
|
@@ -20895,6 +21062,7 @@ function normalizeTable(table, state, packagePartName) {
|
|
|
20895
21062
|
state.cursor += 1;
|
|
20896
21063
|
return {
|
|
20897
21064
|
type: "table",
|
|
21065
|
+
...table.sourceRef ? { sourceRef: table.sourceRef } : {},
|
|
20898
21066
|
...table.styleId ? { styleId: table.styleId } : {},
|
|
20899
21067
|
...table.propertiesXml ? { propertiesXml: table.propertiesXml } : {},
|
|
20900
21068
|
...table.unknownPropertyChildren ? { unknownPropertyChildren: table.unknownPropertyChildren } : {},
|
|
@@ -20918,6 +21086,7 @@ function normalizeTableRow(row, state, packagePartName) {
|
|
|
20918
21086
|
const cells = row.cells.map((cell) => normalizeTableCell(cell, state, packagePartName));
|
|
20919
21087
|
return {
|
|
20920
21088
|
type: "table_row",
|
|
21089
|
+
...row.sourceRef ? { sourceRef: row.sourceRef } : {},
|
|
20921
21090
|
...row.propertiesXml ? { propertiesXml: row.propertiesXml } : {},
|
|
20922
21091
|
...row.unknownPropertyChildren ? { unknownPropertyChildren: row.unknownPropertyChildren } : {},
|
|
20923
21092
|
...row.gridBefore !== void 0 ? { gridBefore: row.gridBefore } : {},
|
|
@@ -20943,6 +21112,7 @@ function normalizeTableCell(cell, state, packagePartName) {
|
|
|
20943
21112
|
}
|
|
20944
21113
|
return {
|
|
20945
21114
|
type: "table_cell",
|
|
21115
|
+
...cell.sourceRef ? { sourceRef: cell.sourceRef } : {},
|
|
20946
21116
|
...cell.propertiesXml ? { propertiesXml: cell.propertiesXml } : {},
|
|
20947
21117
|
...cell.unknownPropertyChildren ? { unknownPropertyChildren: cell.unknownPropertyChildren } : {},
|
|
20948
21118
|
...cell.gridSpan ? { gridSpan: cell.gridSpan } : {},
|
|
@@ -21111,6 +21281,7 @@ function normalizeInlineChildren(nodes, state, packagePartName) {
|
|
|
21111
21281
|
case "ole_embed":
|
|
21112
21282
|
normalized.push({
|
|
21113
21283
|
type: "ole_embed",
|
|
21284
|
+
...node.sourceRef ? { sourceRef: node.sourceRef } : {},
|
|
21114
21285
|
id: node.id,
|
|
21115
21286
|
...node.progId ? { progId: node.progId } : {},
|
|
21116
21287
|
embedType: node.embedType,
|
|
@@ -21124,13 +21295,15 @@ function normalizeInlineChildren(nodes, state, packagePartName) {
|
|
|
21124
21295
|
normalized.push({
|
|
21125
21296
|
type: "bookmark_start",
|
|
21126
21297
|
bookmarkId: node.bookmarkId,
|
|
21127
|
-
name: node.name
|
|
21298
|
+
name: node.name,
|
|
21299
|
+
...node.sourceRef ? { sourceRef: node.sourceRef } : {}
|
|
21128
21300
|
});
|
|
21129
21301
|
break;
|
|
21130
21302
|
case "bookmark_end":
|
|
21131
21303
|
normalized.push({
|
|
21132
21304
|
type: "bookmark_end",
|
|
21133
|
-
bookmarkId: node.bookmarkId
|
|
21305
|
+
bookmarkId: node.bookmarkId,
|
|
21306
|
+
...node.sourceRef ? { sourceRef: node.sourceRef } : {}
|
|
21134
21307
|
});
|
|
21135
21308
|
break;
|
|
21136
21309
|
case "scope_marker_start":
|
|
@@ -21203,6 +21376,7 @@ function normalizeImageNode(node, state) {
|
|
|
21203
21376
|
return {
|
|
21204
21377
|
type: "image",
|
|
21205
21378
|
mediaId: node.mediaId,
|
|
21379
|
+
...node.sourceRef ? { sourceRef: node.sourceRef } : {},
|
|
21206
21380
|
...node.altText ? { altText: node.altText } : {},
|
|
21207
21381
|
...node.placementXml ? { placementXml: node.placementXml } : {},
|
|
21208
21382
|
...node.display ? { display: node.display } : {},
|
|
@@ -23763,16 +23937,14 @@ function parseHdrFtrXml(xml, rootLocalName, opts = { relationships: [] }) {
|
|
|
23763
23937
|
return { blocks: [] };
|
|
23764
23938
|
}
|
|
23765
23939
|
const blocks = [];
|
|
23766
|
-
|
|
23767
|
-
|
|
23768
|
-
continue;
|
|
23769
|
-
}
|
|
23940
|
+
const rootXmlPath = `/${rootLocalName}[1]`;
|
|
23941
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath(hdrFtrElement, rootXmlPath)) {
|
|
23770
23942
|
const name = localName(child.name);
|
|
23771
23943
|
if (name === "p") {
|
|
23772
23944
|
blocks.push(parseParagraphElement(child, xml, opts));
|
|
23773
23945
|
} else if (name === "tbl") {
|
|
23774
23946
|
if (isSimpleSecondaryStoryTable(child)) {
|
|
23775
|
-
blocks.push(parseSimpleTableElement(child, xml, opts));
|
|
23947
|
+
blocks.push(parseSimpleTableElement(child, xml, opts, childXmlPath));
|
|
23776
23948
|
} else {
|
|
23777
23949
|
blocks.push({
|
|
23778
23950
|
type: "opaque_block",
|
|
@@ -23821,7 +23993,7 @@ function parseParagraphElement(pElement, sourceXml, opts) {
|
|
|
23821
23993
|
} else if (name === "hyperlink") {
|
|
23822
23994
|
children.push(parseHyperlinkElement(child, opts));
|
|
23823
23995
|
} else if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
23824
|
-
children.push(parseBookmarkElement(child));
|
|
23996
|
+
children.push(parseBookmarkElement(child, opts.sourcePartPath ?? "/word/document.xml"));
|
|
23825
23997
|
} else if (name === "fldSimple") {
|
|
23826
23998
|
if (activeComplexField && activeComplexField.instruction.trim().length > 0) {
|
|
23827
23999
|
children.push(
|
|
@@ -23847,7 +24019,7 @@ function parseParagraphElement(pElement, sourceXml, opts) {
|
|
|
23847
24019
|
} else if (gname === "hyperlink") {
|
|
23848
24020
|
children.push(parseHyperlinkElement(grandchild, opts));
|
|
23849
24021
|
} else if (gname === "bookmarkStart" || gname === "bookmarkEnd") {
|
|
23850
|
-
children.push(parseBookmarkElement(grandchild));
|
|
24022
|
+
children.push(parseBookmarkElement(grandchild, opts.sourcePartPath ?? "/word/document.xml"));
|
|
23851
24023
|
} else if (gname === "fldSimple") {
|
|
23852
24024
|
pushFieldNode(children, grandchild, "simple", opts.sourcePartPath);
|
|
23853
24025
|
}
|
|
@@ -23976,12 +24148,12 @@ function parseRunElement(rElement, opts) {
|
|
|
23976
24148
|
nodes.push(ref);
|
|
23977
24149
|
}
|
|
23978
24150
|
} else if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
23979
|
-
nodes.push(parseBookmarkElement(child));
|
|
24151
|
+
nodes.push(parseBookmarkElement(child, opts.sourcePartPath ?? "/word/document.xml"));
|
|
23980
24152
|
} else if (name === "instrText") {
|
|
23981
24153
|
pushFieldNode(nodes, child, "complex", opts.sourcePartPath);
|
|
23982
24154
|
} else if (name === "drawing") {
|
|
23983
24155
|
const drawingXml = currentSourceXml.slice(child.start, child.end);
|
|
23984
|
-
const drawingResult = parseDrawingInlineNode(drawingXml, opts);
|
|
24156
|
+
const drawingResult = parseDrawingInlineNode(drawingXml, opts, void 0, child);
|
|
23985
24157
|
if (drawingResult) {
|
|
23986
24158
|
nodes.push(drawingResult);
|
|
23987
24159
|
}
|
|
@@ -24063,11 +24235,11 @@ function parseRunChildNode(child, marks, opts) {
|
|
|
24063
24235
|
return null;
|
|
24064
24236
|
}
|
|
24065
24237
|
if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
24066
|
-
return parseBookmarkElement(child);
|
|
24238
|
+
return parseBookmarkElement(child, opts.sourcePartPath ?? "/word/document.xml");
|
|
24067
24239
|
}
|
|
24068
24240
|
if (name === "drawing") {
|
|
24069
24241
|
const drawingXml = currentSourceXml.slice(child.start, child.end);
|
|
24070
|
-
return parseDrawingInlineNode(drawingXml, opts);
|
|
24242
|
+
return parseDrawingInlineNode(drawingXml, opts, void 0, child);
|
|
24071
24243
|
}
|
|
24072
24244
|
if (name === "pict") {
|
|
24073
24245
|
const pictXml = currentSourceXml.slice(child.start, child.end);
|
|
@@ -24113,7 +24285,7 @@ function parseHyperlinkElement(element, opts) {
|
|
|
24113
24285
|
children
|
|
24114
24286
|
};
|
|
24115
24287
|
}
|
|
24116
|
-
function parseDrawingInlineNode(rawXml, opts, legacyDrawingXml) {
|
|
24288
|
+
function parseDrawingInlineNode(rawXml, opts, legacyDrawingXml, sourceElement) {
|
|
24117
24289
|
try {
|
|
24118
24290
|
const frame = parseDrawingFrame(rawXml, {
|
|
24119
24291
|
...opts,
|
|
@@ -24128,7 +24300,14 @@ function parseDrawingInlineNode(rawXml, opts, legacyDrawingXml) {
|
|
|
24128
24300
|
blockParser: (xml) => parseTxbxBlocksForHeaderFooter(xml, opts, 1)
|
|
24129
24301
|
});
|
|
24130
24302
|
if (frame && !(frame.content.type === "shape" && frame.content.isTextBox)) {
|
|
24131
|
-
return
|
|
24303
|
+
return sourceElement ? {
|
|
24304
|
+
...frame,
|
|
24305
|
+
sourceRef: createElementSourceRef2(
|
|
24306
|
+
opts.sourcePartPath ?? "/word/document.xml",
|
|
24307
|
+
"drawing",
|
|
24308
|
+
sourceElement
|
|
24309
|
+
)
|
|
24310
|
+
} : frame;
|
|
24132
24311
|
}
|
|
24133
24312
|
if (frame?.content.type !== "shape" || !frame.content.isTextBox) {
|
|
24134
24313
|
return frame;
|
|
@@ -24167,14 +24346,13 @@ function parseTxbxBlocksForHeaderFooter(innerXml, opts, depth) {
|
|
|
24167
24346
|
currentSourceXml = innerXml;
|
|
24168
24347
|
try {
|
|
24169
24348
|
const blocks = [];
|
|
24170
|
-
for (const child of txbxContent
|
|
24171
|
-
if (child.type !== "element") continue;
|
|
24349
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath(txbxContent, "/txbxContent[1]")) {
|
|
24172
24350
|
const name = localName(child.name);
|
|
24173
24351
|
if (name === "p") {
|
|
24174
24352
|
blocks.push(parseParagraphElement(child, innerXml, opts));
|
|
24175
24353
|
} else if (name === "tbl") {
|
|
24176
24354
|
if (isSimpleSecondaryStoryTable(child)) {
|
|
24177
|
-
blocks.push(parseSimpleTableElement(child, innerXml, opts));
|
|
24355
|
+
blocks.push(parseSimpleTableElement(child, innerXml, opts, childXmlPath));
|
|
24178
24356
|
} else {
|
|
24179
24357
|
blocks.push({
|
|
24180
24358
|
type: "opaque_block",
|
|
@@ -24190,18 +24368,21 @@ function parseTxbxBlocksForHeaderFooter(innerXml, opts, depth) {
|
|
|
24190
24368
|
currentSourceXml = previousSourceXml;
|
|
24191
24369
|
}
|
|
24192
24370
|
}
|
|
24193
|
-
function parseBookmarkElement(element) {
|
|
24371
|
+
function parseBookmarkElement(element, partPath) {
|
|
24194
24372
|
const bookmarkId = readStringAttr(element, "w:id") ?? "0";
|
|
24373
|
+
const sourceRef = createElementSourceRef2(partPath, localName(element.name), element);
|
|
24195
24374
|
if (localName(element.name) === "bookmarkStart") {
|
|
24196
24375
|
return {
|
|
24197
24376
|
type: "bookmark_start",
|
|
24198
24377
|
bookmarkId,
|
|
24199
|
-
name: readStringAttr(element, "w:name") ?? ""
|
|
24378
|
+
name: readStringAttr(element, "w:name") ?? "",
|
|
24379
|
+
sourceRef
|
|
24200
24380
|
};
|
|
24201
24381
|
}
|
|
24202
24382
|
return {
|
|
24203
24383
|
type: "bookmark_end",
|
|
24204
|
-
bookmarkId
|
|
24384
|
+
bookmarkId,
|
|
24385
|
+
sourceRef
|
|
24205
24386
|
};
|
|
24206
24387
|
}
|
|
24207
24388
|
function pushFieldNode(nodes, element, fieldType, sourcePartPath = "/word/document.xml") {
|
|
@@ -24244,6 +24425,40 @@ function createFieldSequenceSourceRef2(partPath, node) {
|
|
|
24244
24425
|
endOffset: node.end
|
|
24245
24426
|
};
|
|
24246
24427
|
}
|
|
24428
|
+
function createElementSourceRef2(partPath, element, node) {
|
|
24429
|
+
return {
|
|
24430
|
+
sourceId: `part:${partPath}#${element}:${node.start}`,
|
|
24431
|
+
partPath,
|
|
24432
|
+
storyKind: /\/footer\d+\.xml$/i.test(partPath) ? "footer" : "header",
|
|
24433
|
+
element,
|
|
24434
|
+
startOffset: node.start,
|
|
24435
|
+
endOffset: node.end
|
|
24436
|
+
};
|
|
24437
|
+
}
|
|
24438
|
+
function createStableTableSourceRef2(partPath, element, xmlPath, extras = {}) {
|
|
24439
|
+
return {
|
|
24440
|
+
sourceId: `part:${partPath}#${xmlPath}`,
|
|
24441
|
+
partPath,
|
|
24442
|
+
storyKind: /\/footer\d+\.xml$/i.test(partPath) ? "footer" : "header",
|
|
24443
|
+
element,
|
|
24444
|
+
xmlPath,
|
|
24445
|
+
...extras
|
|
24446
|
+
};
|
|
24447
|
+
}
|
|
24448
|
+
function elementChildrenWithXmlPath(parent, parentXmlPath) {
|
|
24449
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
24450
|
+
const children = [];
|
|
24451
|
+
for (const child of parent.children) {
|
|
24452
|
+
if (child.type !== "element") {
|
|
24453
|
+
continue;
|
|
24454
|
+
}
|
|
24455
|
+
const name = localName(child.name);
|
|
24456
|
+
const ordinal = (ordinals.get(name) ?? 0) + 1;
|
|
24457
|
+
ordinals.set(name, ordinal);
|
|
24458
|
+
children.push([child, `${parentXmlPath}/${name}[${ordinal}]`]);
|
|
24459
|
+
}
|
|
24460
|
+
return children;
|
|
24461
|
+
}
|
|
24247
24462
|
function readFieldInstruction(element) {
|
|
24248
24463
|
const instruction = readStringAttr(element, "w:instr") ?? extractTextContent(element);
|
|
24249
24464
|
return instruction.trim().length > 0 ? instruction : void 0;
|
|
@@ -24470,7 +24685,7 @@ function containsRiskyElement(element) {
|
|
|
24470
24685
|
}
|
|
24471
24686
|
return false;
|
|
24472
24687
|
}
|
|
24473
|
-
function parseSimpleTableElement(tblElement, sourceXml, opts) {
|
|
24688
|
+
function parseSimpleTableElement(tblElement, sourceXml, opts, sourceXmlPath) {
|
|
24474
24689
|
let gridColumns = [];
|
|
24475
24690
|
const rows = [];
|
|
24476
24691
|
let propertiesXml;
|
|
@@ -24508,11 +24723,12 @@ function parseSimpleTableElement(tblElement, sourceXml, opts) {
|
|
|
24508
24723
|
} else if (name === "tblGrid") {
|
|
24509
24724
|
gridColumns = readGridColumns2(child);
|
|
24510
24725
|
} else if (name === "tr") {
|
|
24511
|
-
rows.push(parseSimpleTableRow(child, sourceXml, opts));
|
|
24726
|
+
rows.push(parseSimpleTableRow(child, sourceXml, opts, `${sourceXmlPath}/tr[${rows.length + 1}]`));
|
|
24512
24727
|
}
|
|
24513
24728
|
}
|
|
24514
24729
|
return {
|
|
24515
24730
|
type: "table",
|
|
24731
|
+
sourceRef: createStableTableSourceRef2(opts.sourcePartPath ?? "/word/document.xml", "tbl", sourceXmlPath),
|
|
24516
24732
|
...styleId ? { styleId } : {},
|
|
24517
24733
|
...propertiesXml ? { propertiesXml } : {},
|
|
24518
24734
|
gridColumns,
|
|
@@ -24534,7 +24750,7 @@ function parseSimpleTableElement(tblElement, sourceXml, opts) {
|
|
|
24534
24750
|
function readGridColumns2(tblGrid) {
|
|
24535
24751
|
return readGridColumns(tblGrid);
|
|
24536
24752
|
}
|
|
24537
|
-
function parseSimpleTableRow(trElement, sourceXml, opts) {
|
|
24753
|
+
function parseSimpleTableRow(trElement, sourceXml, opts, sourceXmlPath) {
|
|
24538
24754
|
const cells = [];
|
|
24539
24755
|
let propertiesXml;
|
|
24540
24756
|
let height;
|
|
@@ -24555,11 +24771,12 @@ function parseSimpleTableRow(trElement, sourceXml, opts) {
|
|
|
24555
24771
|
horizontalAlignment = readRowHorizontalAlignment(child);
|
|
24556
24772
|
cnfStyle = readRowCnfStyle(child);
|
|
24557
24773
|
} else if (name === "tc") {
|
|
24558
|
-
cells.push(parseSimpleTableCell(child, sourceXml, opts));
|
|
24774
|
+
cells.push(parseSimpleTableCell(child, sourceXml, opts, `${sourceXmlPath}/tc[${cells.length + 1}]`));
|
|
24559
24775
|
}
|
|
24560
24776
|
}
|
|
24561
24777
|
return {
|
|
24562
24778
|
type: "table_row",
|
|
24779
|
+
sourceRef: createStableTableSourceRef2(opts.sourcePartPath ?? "/word/document.xml", "tr", sourceXmlPath),
|
|
24563
24780
|
...propertiesXml ? { propertiesXml } : {},
|
|
24564
24781
|
...height !== void 0 ? { height } : {},
|
|
24565
24782
|
...heightRule ? { heightRule } : {},
|
|
@@ -24570,7 +24787,7 @@ function parseSimpleTableRow(trElement, sourceXml, opts) {
|
|
|
24570
24787
|
cells
|
|
24571
24788
|
};
|
|
24572
24789
|
}
|
|
24573
|
-
function parseSimpleTableCell(tcElement, sourceXml, opts) {
|
|
24790
|
+
function parseSimpleTableCell(tcElement, sourceXml, opts, sourceXmlPath) {
|
|
24574
24791
|
const children = [];
|
|
24575
24792
|
let propertiesXml;
|
|
24576
24793
|
let gridSpan;
|
|
@@ -24612,6 +24829,9 @@ function parseSimpleTableCell(tcElement, sourceXml, opts) {
|
|
|
24612
24829
|
}
|
|
24613
24830
|
return {
|
|
24614
24831
|
type: "table_cell",
|
|
24832
|
+
sourceRef: createStableTableSourceRef2(opts.sourcePartPath ?? "/word/document.xml", "tc", sourceXmlPath, {
|
|
24833
|
+
tableCellPath: sourceXmlPath
|
|
24834
|
+
}),
|
|
24615
24835
|
...propertiesXml ? { propertiesXml } : {},
|
|
24616
24836
|
...gridSpan ? { gridSpan } : {},
|
|
24617
24837
|
...verticalMerge ? { verticalMerge } : {},
|
|
@@ -24657,28 +24877,22 @@ function parseFootnotesXml(xml) {
|
|
|
24657
24877
|
const footnotes = {};
|
|
24658
24878
|
const endnotes = {};
|
|
24659
24879
|
if (footnotesElement) {
|
|
24660
|
-
for (const child of footnotesElement
|
|
24661
|
-
if (child.type !== "element") {
|
|
24662
|
-
continue;
|
|
24663
|
-
}
|
|
24880
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath2(footnotesElement, "/footnotes[1]")) {
|
|
24664
24881
|
if (localName(child.name) !== "footnote") {
|
|
24665
24882
|
continue;
|
|
24666
24883
|
}
|
|
24667
|
-
const definition = parseNoteElement(child, "footnote");
|
|
24884
|
+
const definition = parseNoteElement(child, "footnote", childXmlPath);
|
|
24668
24885
|
if (definition) {
|
|
24669
24886
|
footnotes[definition.noteId] = definition;
|
|
24670
24887
|
}
|
|
24671
24888
|
}
|
|
24672
24889
|
}
|
|
24673
24890
|
if (endnotesElement) {
|
|
24674
|
-
for (const child of endnotesElement
|
|
24675
|
-
if (child.type !== "element") {
|
|
24676
|
-
continue;
|
|
24677
|
-
}
|
|
24891
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath2(endnotesElement, "/endnotes[1]")) {
|
|
24678
24892
|
if (localName(child.name) !== "endnote") {
|
|
24679
24893
|
continue;
|
|
24680
24894
|
}
|
|
24681
|
-
const definition = parseNoteElement(child, "endnote");
|
|
24895
|
+
const definition = parseNoteElement(child, "endnote", childXmlPath);
|
|
24682
24896
|
if (definition) {
|
|
24683
24897
|
endnotes[definition.noteId] = definition;
|
|
24684
24898
|
}
|
|
@@ -24698,14 +24912,11 @@ function parseEndnotesXml(xml, existing) {
|
|
|
24698
24912
|
...existing?.endnotes ?? {}
|
|
24699
24913
|
};
|
|
24700
24914
|
if (endnotesElement) {
|
|
24701
|
-
for (const child of endnotesElement
|
|
24702
|
-
if (child.type !== "element") {
|
|
24703
|
-
continue;
|
|
24704
|
-
}
|
|
24915
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath2(endnotesElement, "/endnotes[1]")) {
|
|
24705
24916
|
if (localName(child.name) !== "endnote") {
|
|
24706
24917
|
continue;
|
|
24707
24918
|
}
|
|
24708
|
-
const definition = parseNoteElement(child, "endnote");
|
|
24919
|
+
const definition = parseNoteElement(child, "endnote", childXmlPath);
|
|
24709
24920
|
if (definition) {
|
|
24710
24921
|
endnotes[definition.noteId] = definition;
|
|
24711
24922
|
}
|
|
@@ -24754,7 +24965,7 @@ function parseFootnoteSeparators(xml) {
|
|
|
24754
24965
|
...continuationSeparatorParagraphXml !== void 0 ? { continuationSeparatorParagraphXml } : {}
|
|
24755
24966
|
};
|
|
24756
24967
|
}
|
|
24757
|
-
function parseNoteElement(element, kind) {
|
|
24968
|
+
function parseNoteElement(element, kind, sourceXmlPath) {
|
|
24758
24969
|
const rawId = readStringAttr(element, "w:id") ?? "";
|
|
24759
24970
|
const rawType = readStringAttr(element, "w:type") ?? "";
|
|
24760
24971
|
if (!rawId || SPECIAL_NOTE_IDS.has(rawId) || SPECIAL_NOTE_TYPES.has(rawType)) {
|
|
@@ -24762,16 +24973,13 @@ function parseNoteElement(element, kind) {
|
|
|
24762
24973
|
}
|
|
24763
24974
|
const noteId = rawId;
|
|
24764
24975
|
const blocks = [];
|
|
24765
|
-
for (const child of element
|
|
24766
|
-
if (child.type !== "element") {
|
|
24767
|
-
continue;
|
|
24768
|
-
}
|
|
24976
|
+
for (const [child, childXmlPath] of elementChildrenWithXmlPath2(element, sourceXmlPath)) {
|
|
24769
24977
|
const name = localName(child.name);
|
|
24770
24978
|
if (name === "p") {
|
|
24771
|
-
blocks.push(parseParagraphElement2(child));
|
|
24979
|
+
blocks.push(parseParagraphElement2(child, kind));
|
|
24772
24980
|
} else if (name === "tbl") {
|
|
24773
24981
|
if (isSimpleSecondaryStoryTable2(child)) {
|
|
24774
|
-
blocks.push(parseSimpleTableElement2(child));
|
|
24982
|
+
blocks.push(parseSimpleTableElement2(child, kind, childXmlPath));
|
|
24775
24983
|
} else {
|
|
24776
24984
|
blocks.push({
|
|
24777
24985
|
type: "opaque_block",
|
|
@@ -24791,7 +24999,7 @@ function parseNoteElement(element, kind) {
|
|
|
24791
24999
|
}
|
|
24792
25000
|
return { noteId, kind, blocks };
|
|
24793
25001
|
}
|
|
24794
|
-
function parseParagraphElement2(pElement) {
|
|
25002
|
+
function parseParagraphElement2(pElement, noteKind) {
|
|
24795
25003
|
let styleId;
|
|
24796
25004
|
let alignment;
|
|
24797
25005
|
let spacing;
|
|
@@ -24814,15 +25022,15 @@ function parseParagraphElement2(pElement) {
|
|
|
24814
25022
|
spacing = readParagraphSpacing4(child);
|
|
24815
25023
|
indentation = readParagraphIndentation4(child);
|
|
24816
25024
|
} else if (name === "r") {
|
|
24817
|
-
activeComplexField = appendRunNodes2(child, children, activeComplexField);
|
|
25025
|
+
activeComplexField = appendRunNodes2(child, children, activeComplexField, noteKind);
|
|
24818
25026
|
} else if (name === "hyperlink") {
|
|
24819
25027
|
if (activeComplexField && activeComplexField.instruction.trim().length > 0) {
|
|
24820
25028
|
children.push(createFieldNode2(activeComplexField.instruction, "complex", activeComplexField.children));
|
|
24821
25029
|
activeComplexField = null;
|
|
24822
25030
|
}
|
|
24823
|
-
children.push(parseHyperlinkElement2(child));
|
|
25031
|
+
children.push(parseHyperlinkElement2(child, noteKind));
|
|
24824
25032
|
} else if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
24825
|
-
const bookmarkNode = parseBookmarkElement2(child);
|
|
25033
|
+
const bookmarkNode = parseBookmarkElement2(child, noteKind);
|
|
24826
25034
|
if (activeComplexField?.mode === "result") {
|
|
24827
25035
|
activeComplexField.children.push(bookmarkNode);
|
|
24828
25036
|
} else {
|
|
@@ -24852,7 +25060,7 @@ function parseParagraphElement2(pElement) {
|
|
|
24852
25060
|
children
|
|
24853
25061
|
};
|
|
24854
25062
|
}
|
|
24855
|
-
function appendRunNodes2(rElement, nodes, activeComplexField) {
|
|
25063
|
+
function appendRunNodes2(rElement, nodes, activeComplexField, noteKind) {
|
|
24856
25064
|
const marks = parseRunProperties2(rElement);
|
|
24857
25065
|
for (const child of rElement.children) {
|
|
24858
25066
|
if (child.type !== "element") {
|
|
@@ -24881,7 +25089,7 @@ function appendRunNodes2(rElement, nodes, activeComplexField) {
|
|
|
24881
25089
|
}
|
|
24882
25090
|
continue;
|
|
24883
25091
|
}
|
|
24884
|
-
const inlineNode = parseRunChildNode2(child, marks);
|
|
25092
|
+
const inlineNode = parseRunChildNode2(child, marks, noteKind);
|
|
24885
25093
|
if (!inlineNode) {
|
|
24886
25094
|
continue;
|
|
24887
25095
|
}
|
|
@@ -24893,7 +25101,7 @@ function appendRunNodes2(rElement, nodes, activeComplexField) {
|
|
|
24893
25101
|
}
|
|
24894
25102
|
return activeComplexField;
|
|
24895
25103
|
}
|
|
24896
|
-
function parseRunElement2(rElement) {
|
|
25104
|
+
function parseRunElement2(rElement, noteKind) {
|
|
24897
25105
|
const nodes = [];
|
|
24898
25106
|
const marks = parseRunProperties2(rElement);
|
|
24899
25107
|
for (const child of rElement.children) {
|
|
@@ -24926,14 +25134,14 @@ function parseRunElement2(rElement) {
|
|
|
24926
25134
|
nodes.push({ type: "footnote_ref", noteId, noteKind: "endnote" });
|
|
24927
25135
|
}
|
|
24928
25136
|
} else if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
24929
|
-
nodes.push(parseBookmarkElement2(child));
|
|
25137
|
+
nodes.push(parseBookmarkElement2(child, noteKind));
|
|
24930
25138
|
} else if (name === "instrText") {
|
|
24931
25139
|
pushFieldNode2(nodes, child, "complex");
|
|
24932
25140
|
}
|
|
24933
25141
|
}
|
|
24934
25142
|
return nodes;
|
|
24935
25143
|
}
|
|
24936
|
-
function parseRunChildNode2(child, marks) {
|
|
25144
|
+
function parseRunChildNode2(child, marks, noteKind) {
|
|
24937
25145
|
const name = localName(child.name);
|
|
24938
25146
|
if (name === "t") {
|
|
24939
25147
|
const text = extractTextContent2(child);
|
|
@@ -24967,16 +25175,16 @@ function parseRunChildNode2(child, marks) {
|
|
|
24967
25175
|
return null;
|
|
24968
25176
|
}
|
|
24969
25177
|
if (name === "bookmarkStart" || name === "bookmarkEnd") {
|
|
24970
|
-
return parseBookmarkElement2(child);
|
|
25178
|
+
return parseBookmarkElement2(child, noteKind);
|
|
24971
25179
|
}
|
|
24972
25180
|
return null;
|
|
24973
25181
|
}
|
|
24974
|
-
function parseHyperlinkElement2(element) {
|
|
25182
|
+
function parseHyperlinkElement2(element, noteKind) {
|
|
24975
25183
|
const href = element.attributes["w:anchor"] ? `#${element.attributes["w:anchor"]}` : element.attributes["r:id"] ?? "relationship:unknown";
|
|
24976
25184
|
const children = [];
|
|
24977
25185
|
for (const child of element.children) {
|
|
24978
25186
|
if (child.type === "element" && localName(child.name) === "r") {
|
|
24979
|
-
for (const runChild of parseRunElement2(child)) {
|
|
25187
|
+
for (const runChild of parseRunElement2(child, noteKind)) {
|
|
24980
25188
|
if (runChild.type === "text" || runChild.type === "hard_break" || runChild.type === "tab") {
|
|
24981
25189
|
children.push(runChild);
|
|
24982
25190
|
}
|
|
@@ -24989,18 +25197,21 @@ function parseHyperlinkElement2(element) {
|
|
|
24989
25197
|
children
|
|
24990
25198
|
};
|
|
24991
25199
|
}
|
|
24992
|
-
function parseBookmarkElement2(element) {
|
|
25200
|
+
function parseBookmarkElement2(element, noteKind) {
|
|
24993
25201
|
const bookmarkId = readStringAttr(element, "w:id") ?? "0";
|
|
25202
|
+
const sourceRef = createElementSourceRef3(noteKind, localName(element.name), element);
|
|
24994
25203
|
if (localName(element.name) === "bookmarkStart") {
|
|
24995
25204
|
return {
|
|
24996
25205
|
type: "bookmark_start",
|
|
24997
25206
|
bookmarkId,
|
|
24998
|
-
name: readStringAttr(element, "w:name") ?? ""
|
|
25207
|
+
name: readStringAttr(element, "w:name") ?? "",
|
|
25208
|
+
sourceRef
|
|
24999
25209
|
};
|
|
25000
25210
|
}
|
|
25001
25211
|
return {
|
|
25002
25212
|
type: "bookmark_end",
|
|
25003
|
-
bookmarkId
|
|
25213
|
+
bookmarkId,
|
|
25214
|
+
sourceRef
|
|
25004
25215
|
};
|
|
25005
25216
|
}
|
|
25006
25217
|
function pushFieldNode2(nodes, element, fieldType) {
|
|
@@ -25172,7 +25383,7 @@ function containsRiskyElement2(element) {
|
|
|
25172
25383
|
}
|
|
25173
25384
|
return false;
|
|
25174
25385
|
}
|
|
25175
|
-
function parseSimpleTableElement2(tblElement) {
|
|
25386
|
+
function parseSimpleTableElement2(tblElement, noteKind = "footnote", sourceXmlPath = `/${noteKind === "endnote" ? "endnotes" : "footnotes"}[1]/tbl[1]`) {
|
|
25176
25387
|
let gridColumns = [];
|
|
25177
25388
|
const rows = [];
|
|
25178
25389
|
let propertiesXml;
|
|
@@ -25210,11 +25421,12 @@ function parseSimpleTableElement2(tblElement) {
|
|
|
25210
25421
|
} else if (name === "tblGrid") {
|
|
25211
25422
|
gridColumns = readGridColumns3(child);
|
|
25212
25423
|
} else if (name === "tr") {
|
|
25213
|
-
rows.push(parseSimpleTableRow2(child));
|
|
25424
|
+
rows.push(parseSimpleTableRow2(child, noteKind, `${sourceXmlPath}/tr[${rows.length + 1}]`));
|
|
25214
25425
|
}
|
|
25215
25426
|
}
|
|
25216
25427
|
return {
|
|
25217
25428
|
type: "table",
|
|
25429
|
+
sourceRef: createStableTableSourceRef3(noteKind, "tbl", sourceXmlPath),
|
|
25218
25430
|
...styleId ? { styleId } : {},
|
|
25219
25431
|
...propertiesXml ? { propertiesXml } : {},
|
|
25220
25432
|
gridColumns,
|
|
@@ -25236,7 +25448,7 @@ function parseSimpleTableElement2(tblElement) {
|
|
|
25236
25448
|
function readGridColumns3(tblGrid) {
|
|
25237
25449
|
return readGridColumns(tblGrid);
|
|
25238
25450
|
}
|
|
25239
|
-
function parseSimpleTableRow2(trElement) {
|
|
25451
|
+
function parseSimpleTableRow2(trElement, noteKind, sourceXmlPath) {
|
|
25240
25452
|
const cells = [];
|
|
25241
25453
|
let propertiesXml;
|
|
25242
25454
|
let height;
|
|
@@ -25257,11 +25469,12 @@ function parseSimpleTableRow2(trElement) {
|
|
|
25257
25469
|
horizontalAlignment = readRowHorizontalAlignment(child);
|
|
25258
25470
|
cnfStyle = readRowCnfStyle(child);
|
|
25259
25471
|
} else if (name === "tc") {
|
|
25260
|
-
cells.push(parseSimpleTableCell2(child));
|
|
25472
|
+
cells.push(parseSimpleTableCell2(child, noteKind, `${sourceXmlPath}/tc[${cells.length + 1}]`));
|
|
25261
25473
|
}
|
|
25262
25474
|
}
|
|
25263
25475
|
return {
|
|
25264
25476
|
type: "table_row",
|
|
25477
|
+
sourceRef: createStableTableSourceRef3(noteKind, "tr", sourceXmlPath),
|
|
25265
25478
|
...propertiesXml ? { propertiesXml } : {},
|
|
25266
25479
|
...height !== void 0 ? { height } : {},
|
|
25267
25480
|
...heightRule ? { heightRule } : {},
|
|
@@ -25272,7 +25485,7 @@ function parseSimpleTableRow2(trElement) {
|
|
|
25272
25485
|
cells
|
|
25273
25486
|
};
|
|
25274
25487
|
}
|
|
25275
|
-
function parseSimpleTableCell2(tcElement) {
|
|
25488
|
+
function parseSimpleTableCell2(tcElement, noteKind, sourceXmlPath) {
|
|
25276
25489
|
const children = [];
|
|
25277
25490
|
let propertiesXml;
|
|
25278
25491
|
let gridSpan;
|
|
@@ -25309,11 +25522,14 @@ function parseSimpleTableCell2(tcElement) {
|
|
|
25309
25522
|
margins = readCellMargins(child);
|
|
25310
25523
|
cnfStyle = readCellCnfStyle(child);
|
|
25311
25524
|
} else if (name === "p") {
|
|
25312
|
-
children.push(parseParagraphElement2(child));
|
|
25525
|
+
children.push(parseParagraphElement2(child, noteKind));
|
|
25313
25526
|
}
|
|
25314
25527
|
}
|
|
25315
25528
|
return {
|
|
25316
25529
|
type: "table_cell",
|
|
25530
|
+
sourceRef: createStableTableSourceRef3(noteKind, "tc", sourceXmlPath, {
|
|
25531
|
+
tableCellPath: sourceXmlPath
|
|
25532
|
+
}),
|
|
25317
25533
|
...propertiesXml ? { propertiesXml } : {},
|
|
25318
25534
|
...gridSpan ? { gridSpan } : {},
|
|
25319
25535
|
...verticalMerge ? { verticalMerge } : {},
|
|
@@ -25329,6 +25545,42 @@ function parseSimpleTableCell2(tcElement) {
|
|
|
25329
25545
|
children: children.length > 0 ? children : [{ type: "paragraph", children: [] }]
|
|
25330
25546
|
};
|
|
25331
25547
|
}
|
|
25548
|
+
function createStableTableSourceRef3(noteKind, element, xmlPath, extras = {}) {
|
|
25549
|
+
const partPath = noteKind === "endnote" ? "/word/endnotes.xml" : "/word/footnotes.xml";
|
|
25550
|
+
return {
|
|
25551
|
+
sourceId: `part:${partPath}#${xmlPath}`,
|
|
25552
|
+
partPath,
|
|
25553
|
+
storyKind: noteKind,
|
|
25554
|
+
element,
|
|
25555
|
+
xmlPath,
|
|
25556
|
+
...extras
|
|
25557
|
+
};
|
|
25558
|
+
}
|
|
25559
|
+
function createElementSourceRef3(noteKind, element, node) {
|
|
25560
|
+
const partPath = noteKind === "endnote" ? "/word/endnotes.xml" : "/word/footnotes.xml";
|
|
25561
|
+
return {
|
|
25562
|
+
sourceId: `part:${partPath}#${element}:${node.start}`,
|
|
25563
|
+
partPath,
|
|
25564
|
+
storyKind: noteKind,
|
|
25565
|
+
element,
|
|
25566
|
+
startOffset: node.start,
|
|
25567
|
+
endOffset: node.end
|
|
25568
|
+
};
|
|
25569
|
+
}
|
|
25570
|
+
function elementChildrenWithXmlPath2(parent, parentXmlPath) {
|
|
25571
|
+
const ordinals = /* @__PURE__ */ new Map();
|
|
25572
|
+
const children = [];
|
|
25573
|
+
for (const child of parent.children) {
|
|
25574
|
+
if (child.type !== "element") {
|
|
25575
|
+
continue;
|
|
25576
|
+
}
|
|
25577
|
+
const name = localName(child.name);
|
|
25578
|
+
const ordinal = (ordinals.get(name) ?? 0) + 1;
|
|
25579
|
+
ordinals.set(name, ordinal);
|
|
25580
|
+
children.push([child, `${parentXmlPath}/${name}[${ordinal}]`]);
|
|
25581
|
+
}
|
|
25582
|
+
return children;
|
|
25583
|
+
}
|
|
25332
25584
|
function serializeElementToXml2(element) {
|
|
25333
25585
|
const attrs = Object.entries(element.attributes).map(([key, value]) => ` ${key}="${escapeXmlAttribute5(value)}"`).join("");
|
|
25334
25586
|
const children = element.children.map((child) => {
|