@beyondwork/docx-react-component 1.0.120 → 1.0.122
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/tailwind.cjs
CHANGED
|
@@ -2457,8 +2457,8 @@ function TwToolbarIconButton(props) {
|
|
|
2457
2457
|
"transition-colors duration-[var(--motion-fast)]",
|
|
2458
2458
|
"disabled:opacity-30 disabled:cursor-not-allowed",
|
|
2459
2459
|
props.active ? (
|
|
2460
|
-
// Active =
|
|
2461
|
-
"bg-[var(--color-
|
|
2460
|
+
// Active = neutral elevated surface + accent glyph + accent border. No mint fill.
|
|
2461
|
+
"bg-[var(--color-bg-elevated)] text-[var(--color-accent-primary)] border-[var(--color-border-accent)]"
|
|
2462
2462
|
) : props.emphasis ? "text-[var(--color-accent-primary)] hover:bg-[var(--color-bg-hover)] hover:border-[var(--color-border-subtle)]" : "text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-hover)] hover:text-[var(--color-text-primary)] hover:border-[var(--color-border-subtle)]",
|
|
2463
2463
|
focusRingClass
|
|
2464
2464
|
].join(" "),
|
|
@@ -2622,7 +2622,7 @@ function TwToolbar(props) {
|
|
|
2622
2622
|
},
|
|
2623
2623
|
className: [
|
|
2624
2624
|
"shrink-0 rounded-[var(--radius-sm)] border border-[var(--color-border-subtle)]",
|
|
2625
|
-
"bg-[var(--color-bg-chrome)]
|
|
2625
|
+
"bg-[var(--color-bg-chrome)] px-2.5",
|
|
2626
2626
|
isCompact ? "flex min-h-10 flex-wrap items-center gap-1.5 py-1.5" : "flex items-center gap-1"
|
|
2627
2627
|
].join(" "),
|
|
2628
2628
|
children: [
|
|
@@ -5685,29 +5685,29 @@ var import_lucide_react7 = require("lucide-react");
|
|
|
5685
5685
|
var BRAND_TOKENS = {
|
|
5686
5686
|
color: {
|
|
5687
5687
|
bg: {
|
|
5688
|
-
app: "#
|
|
5689
|
-
chrome: "#
|
|
5690
|
-
sidebar: "#
|
|
5688
|
+
app: "#F6F6F6",
|
|
5689
|
+
chrome: "#FBFBFB",
|
|
5690
|
+
sidebar: "#F4F4F4",
|
|
5691
5691
|
canvas: "#FFFFFF",
|
|
5692
5692
|
elevated: "#FFFFFF",
|
|
5693
|
-
hover: "#
|
|
5694
|
-
selected: "#
|
|
5695
|
-
muted: "#
|
|
5696
|
-
overlay: "rgba(
|
|
5693
|
+
hover: "#F0F0F0",
|
|
5694
|
+
selected: "#E8E8E8",
|
|
5695
|
+
muted: "#F5F5F5",
|
|
5696
|
+
overlay: "rgba(17, 17, 17, 0.10)"
|
|
5697
5697
|
},
|
|
5698
5698
|
border: {
|
|
5699
|
-
subtle: "#
|
|
5700
|
-
default: "#
|
|
5701
|
-
strong: "#
|
|
5699
|
+
subtle: "#E6E6E6",
|
|
5700
|
+
default: "#D6D6D6",
|
|
5701
|
+
strong: "#BFBFBF",
|
|
5702
5702
|
accent: "#8FC9AD"
|
|
5703
5703
|
},
|
|
5704
5704
|
text: {
|
|
5705
|
-
primary: "#
|
|
5706
|
-
secondary: "#
|
|
5707
|
-
tertiary: "#
|
|
5708
|
-
quiet: "#
|
|
5709
|
-
inverse: "#
|
|
5710
|
-
onAccent: "#
|
|
5705
|
+
primary: "#111111",
|
|
5706
|
+
secondary: "#555555",
|
|
5707
|
+
tertiary: "#888888",
|
|
5708
|
+
quiet: "#A8A8A8",
|
|
5709
|
+
inverse: "#FAFAFA",
|
|
5710
|
+
onAccent: "#FAFAFA",
|
|
5711
5711
|
onSoftAccent: "#18563F"
|
|
5712
5712
|
},
|
|
5713
5713
|
accent: {
|
|
@@ -5955,7 +5955,7 @@ function ToolbarActionButton(props) {
|
|
|
5955
5955
|
disabled: props.disabled,
|
|
5956
5956
|
onMouseDown: preserveEditorSelectionMouseDown,
|
|
5957
5957
|
onClick: props.onClick,
|
|
5958
|
-
className: `inline-flex h-[30px] w-[30px] items-center justify-center rounded-[8px] transition-colors duration-[var(--motion-fast)] disabled:cursor-not-allowed disabled:opacity-40 ${props.pressed ? "
|
|
5958
|
+
className: `inline-flex h-[30px] w-[30px] items-center justify-center rounded-[8px] border transition-colors duration-[var(--motion-fast)] disabled:cursor-not-allowed disabled:opacity-40 ${props.pressed ? "border-[var(--color-border-accent)] bg-[var(--color-bg-elevated)] text-[var(--color-accent-primary)]" : "border-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-hover)] hover:text-[var(--color-text-primary)]"} ${focusRingClass3}`,
|
|
5959
5959
|
children: props.icon
|
|
5960
5960
|
}
|
|
5961
5961
|
) }),
|
|
@@ -6321,7 +6321,7 @@ function parseTextStory(content) {
|
|
|
6321
6321
|
function countLogicalPositions(units) {
|
|
6322
6322
|
let size = 0;
|
|
6323
6323
|
for (const unit of units) {
|
|
6324
|
-
|
|
6324
|
+
size += unitLogicalSize(unit);
|
|
6325
6325
|
}
|
|
6326
6326
|
return size;
|
|
6327
6327
|
}
|
|
@@ -6381,7 +6381,29 @@ function flattenInlineNodes(nodes, hyperlinkHref) {
|
|
|
6381
6381
|
});
|
|
6382
6382
|
break;
|
|
6383
6383
|
case "hyperlink":
|
|
6384
|
-
units.push(
|
|
6384
|
+
units.push({
|
|
6385
|
+
kind: "protected_inline",
|
|
6386
|
+
node: structuredClone(node),
|
|
6387
|
+
logicalSize: inlineLogicalLength(node),
|
|
6388
|
+
reason: "hyperlink"
|
|
6389
|
+
});
|
|
6390
|
+
break;
|
|
6391
|
+
case "field":
|
|
6392
|
+
units.push({
|
|
6393
|
+
kind: "protected_inline",
|
|
6394
|
+
node: structuredClone(node),
|
|
6395
|
+
logicalSize: inlineLogicalLength(node),
|
|
6396
|
+
reason: "field"
|
|
6397
|
+
});
|
|
6398
|
+
break;
|
|
6399
|
+
case "bookmark_start":
|
|
6400
|
+
case "bookmark_end":
|
|
6401
|
+
units.push({
|
|
6402
|
+
kind: "protected_inline",
|
|
6403
|
+
node: structuredClone(node),
|
|
6404
|
+
logicalSize: 0,
|
|
6405
|
+
reason: "bookmark"
|
|
6406
|
+
});
|
|
6385
6407
|
break;
|
|
6386
6408
|
case "image":
|
|
6387
6409
|
units.push({
|
|
@@ -6415,6 +6437,32 @@ function flattenInlineNodes(nodes, hyperlinkHref) {
|
|
|
6415
6437
|
}
|
|
6416
6438
|
return units;
|
|
6417
6439
|
}
|
|
6440
|
+
function unitLogicalSize(unit) {
|
|
6441
|
+
switch (unit.kind) {
|
|
6442
|
+
case "scope_marker":
|
|
6443
|
+
return 0;
|
|
6444
|
+
case "protected_inline":
|
|
6445
|
+
return unit.logicalSize;
|
|
6446
|
+
default:
|
|
6447
|
+
return 1;
|
|
6448
|
+
}
|
|
6449
|
+
}
|
|
6450
|
+
function inlineLogicalLength(node) {
|
|
6451
|
+
switch (node.type) {
|
|
6452
|
+
case "text":
|
|
6453
|
+
return Array.from(node.text).length;
|
|
6454
|
+
case "hyperlink":
|
|
6455
|
+
case "field":
|
|
6456
|
+
return node.children.reduce((total, child) => total + inlineLogicalLength(child), 0);
|
|
6457
|
+
case "bookmark_start":
|
|
6458
|
+
case "bookmark_end":
|
|
6459
|
+
case "scope_marker_start":
|
|
6460
|
+
case "scope_marker_end":
|
|
6461
|
+
return 0;
|
|
6462
|
+
default:
|
|
6463
|
+
return 1;
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6418
6466
|
function extractParagraphProperties(paragraph) {
|
|
6419
6467
|
return {
|
|
6420
6468
|
...paragraph.styleId ? { styleId: paragraph.styleId } : {},
|
|
@@ -7148,7 +7196,19 @@ function createHeaderFooterStoryKey(input) {
|
|
|
7148
7196
|
function createNoteStoryKey(kind, noteId) {
|
|
7149
7197
|
return `${kind}:${noteId}`;
|
|
7150
7198
|
}
|
|
7151
|
-
function
|
|
7199
|
+
function collectCanonicalLayoutInputs(doc) {
|
|
7200
|
+
const blockContexts = collectStoryBlockContexts(doc);
|
|
7201
|
+
return {
|
|
7202
|
+
stories: collectCanonicalStoryIdentities(doc),
|
|
7203
|
+
fieldRegions: collectCanonicalFieldRegionIdentities(doc),
|
|
7204
|
+
numbering: collectCanonicalNumberingLayoutInputs(doc, blockContexts),
|
|
7205
|
+
tables: collectCanonicalTableLayoutInputs(blockContexts),
|
|
7206
|
+
anchors: collectCanonicalAnchorLayoutInputs(doc, blockContexts),
|
|
7207
|
+
scopes: collectCanonicalScopeLayoutInputs(blockContexts),
|
|
7208
|
+
editableTargets: collectEditableTargetRefs(doc)
|
|
7209
|
+
};
|
|
7210
|
+
}
|
|
7211
|
+
function collectEditableTargetRefs(doc, cache) {
|
|
7152
7212
|
const targets = [];
|
|
7153
7213
|
for (const context of collectStoryBlockContexts(doc)) {
|
|
7154
7214
|
collectEditableTargetsInBlocks(
|
|
@@ -7160,17 +7220,53 @@ function collectEditableTargetRefs(doc) {
|
|
|
7160
7220
|
insideTextBox: false,
|
|
7161
7221
|
tableDepth: 0
|
|
7162
7222
|
},
|
|
7163
|
-
targets
|
|
7223
|
+
targets,
|
|
7224
|
+
cache
|
|
7164
7225
|
);
|
|
7165
7226
|
}
|
|
7227
|
+
collectFieldRegionRefreshTargets(doc, targets);
|
|
7228
|
+
collectBookmarkContentRangeTargets(doc, targets);
|
|
7166
7229
|
collectReviewEditableTargets(doc, targets);
|
|
7167
7230
|
return targets;
|
|
7168
7231
|
}
|
|
7169
|
-
function
|
|
7232
|
+
function buildBlockCacheSignature(context, blockIndex) {
|
|
7233
|
+
const cc = context.contentControl;
|
|
7234
|
+
const tt = context.tableTarget;
|
|
7235
|
+
const owner = tt?.editableOwnersByChildIndex?.get(blockIndex);
|
|
7236
|
+
return [
|
|
7237
|
+
context.storyKey,
|
|
7238
|
+
context.insideSdt ? "1" : "0",
|
|
7239
|
+
context.insideTextBox ? "1" : "0",
|
|
7240
|
+
String(context.tableDepth),
|
|
7241
|
+
cc?.sdtId ?? "",
|
|
7242
|
+
cc?.tag ?? "",
|
|
7243
|
+
cc?.alias ?? "",
|
|
7244
|
+
cc?.sdtType ?? "",
|
|
7245
|
+
cc?.lock ?? "",
|
|
7246
|
+
tt?.tablePath ?? "",
|
|
7247
|
+
tt?.tableDepth ?? "",
|
|
7248
|
+
tt?.rowIndex ?? "",
|
|
7249
|
+
tt?.cellIndex ?? "",
|
|
7250
|
+
tt?.gridColumnStart ?? "",
|
|
7251
|
+
tt?.cell?.verticalMerge ?? "",
|
|
7252
|
+
tt?.cell?.gridSpan ?? "",
|
|
7253
|
+
owner?.targetKey ?? ""
|
|
7254
|
+
].join("|");
|
|
7255
|
+
}
|
|
7256
|
+
function collectEditableTargetsInBlocks(blocks, context, targets, cache) {
|
|
7170
7257
|
for (let blockIndex = 0; blockIndex < blocks.length; blockIndex += 1) {
|
|
7171
7258
|
const block = blocks[blockIndex];
|
|
7172
7259
|
if (!block) continue;
|
|
7173
7260
|
const blockPath = `${context.basePath}/block[${blockIndex}]`;
|
|
7261
|
+
const signature = cache !== void 0 ? buildBlockCacheSignature(context, blockIndex) : "";
|
|
7262
|
+
if (cache !== void 0) {
|
|
7263
|
+
const cached = cache.get(block);
|
|
7264
|
+
if (cached !== void 0 && cached.blockPath === blockPath && cached.signature === signature) {
|
|
7265
|
+
for (const target of cached.targets) targets.push(target);
|
|
7266
|
+
continue;
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
const blockStart = targets.length;
|
|
7174
7270
|
if (block.type === "paragraph") {
|
|
7175
7271
|
const targetKind = editableParagraphTargetKind(context);
|
|
7176
7272
|
if (targetKind !== null) {
|
|
@@ -7182,14 +7278,13 @@ function collectEditableTargetsInBlocks(blocks, context, targets) {
|
|
|
7182
7278
|
blockPath,
|
|
7183
7279
|
editableParagraphTargetPosture(targetKind),
|
|
7184
7280
|
context.contentControl,
|
|
7185
|
-
context.tableTarget
|
|
7281
|
+
context.tableTarget,
|
|
7282
|
+
context.tableTarget?.editableOwnersByChildIndex?.get(blockIndex)
|
|
7186
7283
|
)
|
|
7187
7284
|
);
|
|
7188
7285
|
}
|
|
7189
7286
|
collectEditableTargetsInInlines(block.children ?? [], `${blockPath}/inline`, context, targets);
|
|
7190
|
-
|
|
7191
|
-
}
|
|
7192
|
-
if (block.type === "sdt") {
|
|
7287
|
+
} else if (block.type === "sdt") {
|
|
7193
7288
|
const contentControl = contentControlIdentityForSdt(block, context.contentControl);
|
|
7194
7289
|
collectEditableTargetsInBlocks(
|
|
7195
7290
|
block.children,
|
|
@@ -7199,11 +7294,10 @@ function collectEditableTargetsInBlocks(blocks, context, targets) {
|
|
|
7199
7294
|
insideSdt: true,
|
|
7200
7295
|
contentControl
|
|
7201
7296
|
},
|
|
7202
|
-
targets
|
|
7297
|
+
targets,
|
|
7298
|
+
cache
|
|
7203
7299
|
);
|
|
7204
|
-
|
|
7205
|
-
}
|
|
7206
|
-
if (block.type === "custom_xml") {
|
|
7300
|
+
} else if (block.type === "custom_xml") {
|
|
7207
7301
|
targets.push(createCustomXmlEditableTarget(block, context.storyKey, blockPath));
|
|
7208
7302
|
collectEditableTargetsInBlocks(
|
|
7209
7303
|
block.children,
|
|
@@ -7211,25 +7305,29 @@ function collectEditableTargetsInBlocks(blocks, context, targets) {
|
|
|
7211
7305
|
...context,
|
|
7212
7306
|
basePath: blockPath
|
|
7213
7307
|
},
|
|
7214
|
-
targets
|
|
7308
|
+
targets,
|
|
7309
|
+
cache
|
|
7215
7310
|
);
|
|
7216
|
-
|
|
7217
|
-
}
|
|
7218
|
-
if (block.type === "opaque_block") {
|
|
7311
|
+
} else if (block.type === "opaque_block") {
|
|
7219
7312
|
targets.push(createOpaqueBlockEditableTarget(block, context.storyKey, blockPath));
|
|
7220
|
-
|
|
7221
|
-
}
|
|
7222
|
-
if (block.type === "alt_chunk") {
|
|
7313
|
+
} else if (block.type === "alt_chunk") {
|
|
7223
7314
|
targets.push(createAltChunkEditableTarget(block.relationshipId, context.storyKey, blockPath));
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7315
|
+
} else if (block.type === "table") {
|
|
7316
|
+
collectEditableTargetsInTable(block, blockPath, context, targets, cache);
|
|
7317
|
+
}
|
|
7318
|
+
if (cache !== void 0) {
|
|
7319
|
+
const blockTargets = targets.slice(blockStart);
|
|
7320
|
+
cache.set(block, {
|
|
7321
|
+
blockPath,
|
|
7322
|
+
signature,
|
|
7323
|
+
targets: blockTargets
|
|
7324
|
+
});
|
|
7228
7325
|
}
|
|
7229
7326
|
}
|
|
7230
7327
|
}
|
|
7231
|
-
function collectEditableTargetsInTable(table, tablePath, context, targets) {
|
|
7328
|
+
function collectEditableTargetsInTable(table, tablePath, context, targets, cache) {
|
|
7232
7329
|
const tableDepth = context.tableDepth + 1;
|
|
7330
|
+
const verticalMergeOwners = [];
|
|
7233
7331
|
targets.push(createTableStructureTarget({
|
|
7234
7332
|
scope: "table",
|
|
7235
7333
|
kind: "table-structure-table",
|
|
@@ -7268,6 +7366,10 @@ function collectEditableTargetsInTable(table, tablePath, context, targets) {
|
|
|
7268
7366
|
const cell = row.cells[cellIndex];
|
|
7269
7367
|
if (!cell) continue;
|
|
7270
7368
|
const gridSpan = cell.gridSpan ?? 1;
|
|
7369
|
+
const continuationOwner = cell.verticalMerge === "continue" ? findVerticalMergeOwner(verticalMergeOwners, gridColumnStart, gridSpan) : null;
|
|
7370
|
+
if (cell.verticalMerge !== "continue") {
|
|
7371
|
+
clearVerticalMergeOwners(verticalMergeOwners, gridColumnStart, gridSpan);
|
|
7372
|
+
}
|
|
7271
7373
|
targets.push(createTableStructureTarget({
|
|
7272
7374
|
scope: "cell",
|
|
7273
7375
|
kind: "table-structure-cell",
|
|
@@ -7310,15 +7412,136 @@ function collectEditableTargetsInTable(table, tablePath, context, targets) {
|
|
|
7310
7412
|
row,
|
|
7311
7413
|
cellIndex,
|
|
7312
7414
|
cell,
|
|
7313
|
-
gridColumnStart
|
|
7415
|
+
gridColumnStart,
|
|
7416
|
+
...continuationOwner ? {
|
|
7417
|
+
editableOwnersByChildIndex: continuationOwnerTargetsByChildIndex(
|
|
7418
|
+
continuationOwner,
|
|
7419
|
+
cell.children.length
|
|
7420
|
+
)
|
|
7421
|
+
} : {}
|
|
7314
7422
|
}
|
|
7315
7423
|
},
|
|
7316
|
-
targets
|
|
7424
|
+
targets,
|
|
7425
|
+
cache
|
|
7317
7426
|
);
|
|
7427
|
+
if (cell.verticalMerge === "restart") {
|
|
7428
|
+
verticalMergeOwners.push(createVerticalMergeOwnerState({
|
|
7429
|
+
context,
|
|
7430
|
+
table,
|
|
7431
|
+
tablePath,
|
|
7432
|
+
tableDepth,
|
|
7433
|
+
rowIndex,
|
|
7434
|
+
row,
|
|
7435
|
+
cellIndex,
|
|
7436
|
+
cell,
|
|
7437
|
+
gridColumnStart,
|
|
7438
|
+
gridSpan
|
|
7439
|
+
}));
|
|
7440
|
+
}
|
|
7318
7441
|
gridColumnStart += gridSpan;
|
|
7319
7442
|
}
|
|
7320
7443
|
}
|
|
7321
7444
|
}
|
|
7445
|
+
function findVerticalMergeOwner(owners, gridColumnStart, gridSpan) {
|
|
7446
|
+
return owners.find(
|
|
7447
|
+
(owner) => owner.gridColumnStart === gridColumnStart && owner.gridSpan === gridSpan
|
|
7448
|
+
) ?? null;
|
|
7449
|
+
}
|
|
7450
|
+
function clearVerticalMergeOwners(owners, gridColumnStart, gridSpan) {
|
|
7451
|
+
const gridColumnEnd = gridColumnStart + gridSpan;
|
|
7452
|
+
for (let index = owners.length - 1; index >= 0; index -= 1) {
|
|
7453
|
+
const owner = owners[index];
|
|
7454
|
+
if (!owner) continue;
|
|
7455
|
+
const ownerEnd = owner.gridColumnStart + owner.gridSpan;
|
|
7456
|
+
if (gridColumnStart < ownerEnd && owner.gridColumnStart < gridColumnEnd) {
|
|
7457
|
+
owners.splice(index, 1);
|
|
7458
|
+
}
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
function continuationOwnerTargetsByChildIndex(owner, childCount) {
|
|
7462
|
+
if (!owner.fallbackOwnerTarget) return void 0;
|
|
7463
|
+
const targets = /* @__PURE__ */ new Map();
|
|
7464
|
+
for (let childIndex = 0; childIndex < childCount; childIndex += 1) {
|
|
7465
|
+
targets.set(
|
|
7466
|
+
childIndex,
|
|
7467
|
+
owner.ownerTargetsByChildIndex.get(childIndex) ?? owner.fallbackOwnerTarget
|
|
7468
|
+
);
|
|
7469
|
+
}
|
|
7470
|
+
return targets;
|
|
7471
|
+
}
|
|
7472
|
+
function createVerticalMergeOwnerState(input) {
|
|
7473
|
+
const ownerTargetsByChildIndex = /* @__PURE__ */ new Map();
|
|
7474
|
+
for (let childIndex = 0; childIndex < input.cell.children.length; childIndex += 1) {
|
|
7475
|
+
const owner = createVerticalMergeEditableOwner({ ...input, childIndex });
|
|
7476
|
+
if (owner) ownerTargetsByChildIndex.set(childIndex, owner);
|
|
7477
|
+
}
|
|
7478
|
+
return {
|
|
7479
|
+
gridColumnStart: input.gridColumnStart,
|
|
7480
|
+
gridSpan: input.gridSpan,
|
|
7481
|
+
ownerTargetsByChildIndex,
|
|
7482
|
+
...ownerTargetsByChildIndex.size > 0 ? { fallbackOwnerTarget: ownerTargetsByChildIndex.values().next().value } : {}
|
|
7483
|
+
};
|
|
7484
|
+
}
|
|
7485
|
+
function createVerticalMergeEditableOwner(input) {
|
|
7486
|
+
const child = input.cell.children[input.childIndex];
|
|
7487
|
+
if (child?.type !== "paragraph") return null;
|
|
7488
|
+
const ownerTableTarget = {
|
|
7489
|
+
table: input.table,
|
|
7490
|
+
tablePath: input.tablePath,
|
|
7491
|
+
tableDepth: input.tableDepth,
|
|
7492
|
+
rowIndex: input.rowIndex,
|
|
7493
|
+
row: input.row,
|
|
7494
|
+
cellIndex: input.cellIndex,
|
|
7495
|
+
cell: input.cell,
|
|
7496
|
+
gridColumnStart: input.gridColumnStart
|
|
7497
|
+
};
|
|
7498
|
+
const kind = editableParagraphTargetKind({
|
|
7499
|
+
...input.context,
|
|
7500
|
+
basePath: `${input.tablePath}/row[${input.rowIndex}]/cell[${input.cellIndex}]`,
|
|
7501
|
+
tableDepth: input.tableDepth,
|
|
7502
|
+
tableTarget: ownerTableTarget
|
|
7503
|
+
});
|
|
7504
|
+
if (!kind) return null;
|
|
7505
|
+
const blockPath = `${input.tablePath}/row[${input.rowIndex}]/cell[${input.cellIndex}]/block[${input.childIndex}]`;
|
|
7506
|
+
const paragraphTextHash = hashText(collectParagraphText(child));
|
|
7507
|
+
const table = createTableIdentity({
|
|
7508
|
+
scope: "text",
|
|
7509
|
+
context: {
|
|
7510
|
+
storyKey: input.context.storyKey,
|
|
7511
|
+
insideSdt: input.context.contentControl !== void 0
|
|
7512
|
+
},
|
|
7513
|
+
...ownerTableTarget
|
|
7514
|
+
});
|
|
7515
|
+
return {
|
|
7516
|
+
targetKey: `${input.context.storyKey}:${blockPath}:text`,
|
|
7517
|
+
kind,
|
|
7518
|
+
storyKey: input.context.storyKey,
|
|
7519
|
+
blockPath,
|
|
7520
|
+
leafPath: `${blockPath}/inline`,
|
|
7521
|
+
commandFamily: "text-leaf",
|
|
7522
|
+
reason: "vertical-merge-restart-cell",
|
|
7523
|
+
canonicalAddress: ownerRoutingFromAddress(
|
|
7524
|
+
createTableTargetCanonicalAddress(
|
|
7525
|
+
table,
|
|
7526
|
+
"paragraph",
|
|
7527
|
+
paragraphTextHash,
|
|
7528
|
+
{ rangeBoundary: { boundaryKind: "cell-fragment" } }
|
|
7529
|
+
)
|
|
7530
|
+
),
|
|
7531
|
+
table: {
|
|
7532
|
+
tableKey: table.tableKey,
|
|
7533
|
+
tablePath: table.tablePath,
|
|
7534
|
+
...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
|
|
7535
|
+
...table.rowSourceRef !== void 0 ? { rowSourceRef: table.rowSourceRef } : {},
|
|
7536
|
+
...table.cellSourceRef !== void 0 ? { cellSourceRef: table.cellSourceRef } : {},
|
|
7537
|
+
...table.rowIndex !== void 0 ? { rowIndex: table.rowIndex } : {},
|
|
7538
|
+
...table.cellIndex !== void 0 ? { cellIndex: table.cellIndex } : {},
|
|
7539
|
+
...table.gridColumnStart !== void 0 ? { gridColumnStart: table.gridColumnStart } : {},
|
|
7540
|
+
...table.gridSpan !== void 0 ? { gridSpan: table.gridSpan } : {},
|
|
7541
|
+
...table.verticalMerge !== void 0 ? { verticalMerge: table.verticalMerge } : {}
|
|
7542
|
+
}
|
|
7543
|
+
};
|
|
7544
|
+
}
|
|
7322
7545
|
function computeTableStructureColumnCount(table) {
|
|
7323
7546
|
let columnCount = table.gridColumns.length;
|
|
7324
7547
|
for (const row of table.rows) {
|
|
@@ -7338,6 +7561,7 @@ function createTableStructureTarget(input) {
|
|
|
7338
7561
|
const columnPath = input.columnIndex !== void 0 ? `${input.tablePath}/column[${input.columnIndex}]` : void 0;
|
|
7339
7562
|
const blockPath = cellPath ?? rowPath ?? columnPath ?? input.tablePath;
|
|
7340
7563
|
const tableIdentity = createTableIdentity(input);
|
|
7564
|
+
const targetHash = hashTableStructureTarget(input);
|
|
7341
7565
|
return {
|
|
7342
7566
|
targetKey: `${tableKey}:structure:${tableIdentity.operationScope}${tableTargetSuffix(tableIdentity)}`,
|
|
7343
7567
|
kind: input.kind,
|
|
@@ -7349,8 +7573,14 @@ function createTableStructureTarget(input) {
|
|
|
7349
7573
|
...input.table.sourceRef !== void 0 ? { sourceRef: input.table.sourceRef } : {},
|
|
7350
7574
|
...input.context.contentControl !== void 0 ? { contentControl: input.context.contentControl } : {},
|
|
7351
7575
|
table: tableIdentity,
|
|
7576
|
+
canonicalAddress: createTableTargetCanonicalAddress(
|
|
7577
|
+
tableIdentity,
|
|
7578
|
+
tableStructureBlockType(input.scope),
|
|
7579
|
+
targetHash,
|
|
7580
|
+
{ rangeBoundary: { boundaryKind: "table-grid" } }
|
|
7581
|
+
),
|
|
7352
7582
|
staleCheck: {
|
|
7353
|
-
targetHash
|
|
7583
|
+
targetHash,
|
|
7354
7584
|
childCount: input.scope === "table" ? input.table.rows.length : input.scope === "row" ? input.row?.cells.length ?? 0 : input.scope === "cell" || input.scope === "span" ? input.cell?.children.length ?? 0 : computeTableStructureColumnCount(input.table),
|
|
7355
7585
|
blockType: tableStructureBlockType(input.scope),
|
|
7356
7586
|
...input.table.sourceRef !== void 0 ? { sourceRef: input.table.sourceRef } : {}
|
|
@@ -7361,10 +7591,15 @@ function createTableStructureTarget(input) {
|
|
|
7361
7591
|
function createTableIdentity(input) {
|
|
7362
7592
|
const tableKey = `${input.context.storyKey}:${input.tablePath}`;
|
|
7363
7593
|
const columnCount = computeTableStructureColumnCount(input.table);
|
|
7594
|
+
const rowRange = tableFragmentRowRange(input).rowRange;
|
|
7595
|
+
const columnRange = tableFragmentColumnRange(input, columnCount).columnRange;
|
|
7364
7596
|
const base = {
|
|
7365
7597
|
operationScope: input.scope,
|
|
7366
7598
|
tableKey,
|
|
7367
7599
|
tablePath: input.tablePath,
|
|
7600
|
+
...input.table.sourceRef !== void 0 ? { sourceRef: input.table.sourceRef } : {},
|
|
7601
|
+
...input.row?.sourceRef !== void 0 ? { rowSourceRef: input.row.sourceRef } : {},
|
|
7602
|
+
...input.cell?.sourceRef !== void 0 ? { cellSourceRef: input.cell.sourceRef } : {},
|
|
7368
7603
|
...tablePathIndexes(input.tablePath),
|
|
7369
7604
|
tableDepth: input.tableDepth,
|
|
7370
7605
|
...input.tableDepth >= 2 ? { nestedTable: true } : {},
|
|
@@ -7372,7 +7607,10 @@ function createTableIdentity(input) {
|
|
|
7372
7607
|
...input.context.storyKey !== MAIN_STORY_KEY ? { secondaryStory: true } : {},
|
|
7373
7608
|
rowCount: input.table.rows.length,
|
|
7374
7609
|
columnCount,
|
|
7375
|
-
fragment: createTableFragmentIdentity(input, tableKey, columnCount)
|
|
7610
|
+
fragment: createTableFragmentIdentity(input, tableKey, columnCount),
|
|
7611
|
+
...input.cell !== void 0 ? {
|
|
7612
|
+
cellFragment: createTableCellFragmentIdentity(input, tableKey, rowRange, columnRange)
|
|
7613
|
+
} : {}
|
|
7376
7614
|
};
|
|
7377
7615
|
return {
|
|
7378
7616
|
...base,
|
|
@@ -7386,6 +7624,25 @@ function createTableIdentity(input) {
|
|
|
7386
7624
|
...input.cell !== void 0 ? { blockCount: input.cell.children.length } : {}
|
|
7387
7625
|
};
|
|
7388
7626
|
}
|
|
7627
|
+
function createTableCellFragmentIdentity(input, tableKey, rowRange, columnRange) {
|
|
7628
|
+
const text = (input.cell?.children ?? []).map(blockTextForTargetHash).join("");
|
|
7629
|
+
return {
|
|
7630
|
+
fragmentKey: hashText(JSON.stringify({
|
|
7631
|
+
tableKey,
|
|
7632
|
+
rowIndex: input.rowIndex ?? null,
|
|
7633
|
+
cellIndex: input.cellIndex ?? null,
|
|
7634
|
+
gridColumnStart: input.gridColumnStart ?? null,
|
|
7635
|
+
gridSpan: input.cell?.gridSpan ?? 1,
|
|
7636
|
+
verticalMerge: input.cell?.verticalMerge ?? null,
|
|
7637
|
+
sourceId: input.cell?.sourceRef?.sourceId ?? null
|
|
7638
|
+
})),
|
|
7639
|
+
textHash: hashText(text),
|
|
7640
|
+
blockCount: input.cell?.children.length ?? 0,
|
|
7641
|
+
...rowRange !== void 0 ? { rowRange } : {},
|
|
7642
|
+
...columnRange !== void 0 ? { columnRange } : {},
|
|
7643
|
+
...sourceJoinHashForRefs(input.table.sourceRef, input.row?.sourceRef, input.cell?.sourceRef)
|
|
7644
|
+
};
|
|
7645
|
+
}
|
|
7389
7646
|
function tablePathIndexes(tablePath) {
|
|
7390
7647
|
const blockIndexes = [...tablePath.matchAll(/\/block\[(\d+)\]/gu)].map((match) => Number(match[1]));
|
|
7391
7648
|
const storyBlockIndex = blockIndexes[0];
|
|
@@ -7551,13 +7808,39 @@ function collectEditableTargetsInInlines(inlines, basePath, context, targets) {
|
|
|
7551
7808
|
}
|
|
7552
7809
|
}
|
|
7553
7810
|
}
|
|
7554
|
-
function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget) {
|
|
7811
|
+
function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, targetPosture = { editability: "editable", posture: { blockers: [] } }, contentControl, tableTarget, editableOwner) {
|
|
7555
7812
|
const paragraphText = collectParagraphText(paragraph);
|
|
7813
|
+
const paragraphTextHash = hashText(paragraphText);
|
|
7556
7814
|
const sourceRef = paragraph.sourceRef;
|
|
7557
7815
|
const lockedContentControl = contentControlLocksContent(contentControl);
|
|
7558
|
-
const
|
|
7816
|
+
const syntheticLayoutCell = tableTarget?.cell?.verticalMerge === "continue";
|
|
7817
|
+
const tableIdentity = tableTarget !== void 0 ? createTableIdentity({
|
|
7818
|
+
scope: "text",
|
|
7819
|
+
context: { storyKey, insideSdt: contentControl !== void 0 },
|
|
7820
|
+
...tableTarget
|
|
7821
|
+
}) : void 0;
|
|
7822
|
+
const listAddress = tableIdentity === void 0 && paragraph.numbering !== void 0 ? createCanonicalAddress({
|
|
7823
|
+
addressKind: "list-item-text",
|
|
7824
|
+
storyKey,
|
|
7825
|
+
staleCheckKind: "paragraph",
|
|
7826
|
+
operationScope: "list-text",
|
|
7827
|
+
sourceRefs: [sourceRef],
|
|
7828
|
+
staleHash: paragraphTextHash,
|
|
7829
|
+
rangeBoundary: { boundaryKind: "list-item-text" },
|
|
7830
|
+
discriminator: {
|
|
7831
|
+
blockPath,
|
|
7832
|
+
numberingInstanceId: paragraph.numbering.numberingInstanceId,
|
|
7833
|
+
level: paragraph.numbering.level,
|
|
7834
|
+
sourceId: sourceRef?.sourceId ?? null,
|
|
7835
|
+
paraId: paragraph.wordExtensionIds?.paraId ?? null,
|
|
7836
|
+
textId: paragraph.wordExtensionIds?.textId ?? null
|
|
7837
|
+
}
|
|
7838
|
+
}) : void 0;
|
|
7839
|
+
const tableAwarePosture = syntheticLayoutCell ? mergeTargetPosture(targetPosture.posture, ["synthetic-layout-cell"]) : targetPosture.posture;
|
|
7840
|
+
const posture = lockedContentControl ? mergeTargetPosture(tableAwarePosture, ["locked-content-control"], {
|
|
7559
7841
|
lockedContentControl: true
|
|
7560
|
-
}) :
|
|
7842
|
+
}) : tableAwarePosture;
|
|
7843
|
+
const editability = lockedContentControl || syntheticLayoutCell ? "non-editable" : targetPosture.editability;
|
|
7561
7844
|
return {
|
|
7562
7845
|
targetKey: `${storyKey}:${blockPath}:text`,
|
|
7563
7846
|
kind,
|
|
@@ -7565,12 +7848,24 @@ function createParagraphEditableTarget(paragraph, kind, storyKey, blockPath, tar
|
|
|
7565
7848
|
blockPath,
|
|
7566
7849
|
leafPath: `${blockPath}/inline`,
|
|
7567
7850
|
commandFamily: "text-leaf",
|
|
7568
|
-
editability
|
|
7851
|
+
editability,
|
|
7569
7852
|
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
7570
7853
|
...contentControl !== void 0 ? { contentControl } : {},
|
|
7571
|
-
...
|
|
7854
|
+
...tableIdentity !== void 0 ? { table: tableIdentity } : {},
|
|
7855
|
+
...editableOwner !== void 0 ? { editableOwner } : {},
|
|
7856
|
+
...tableIdentity !== void 0 ? {
|
|
7857
|
+
canonicalAddress: createTableTargetCanonicalAddress(
|
|
7858
|
+
tableIdentity,
|
|
7859
|
+
"paragraph",
|
|
7860
|
+
paragraphTextHash,
|
|
7861
|
+
{
|
|
7862
|
+
rangeBoundary: { boundaryKind: "cell-fragment" },
|
|
7863
|
+
owner: editableOwner?.canonicalAddress
|
|
7864
|
+
}
|
|
7865
|
+
)
|
|
7866
|
+
} : listAddress !== void 0 ? { canonicalAddress: listAddress } : {},
|
|
7572
7867
|
staleCheck: {
|
|
7573
|
-
paragraphTextHash
|
|
7868
|
+
paragraphTextHash,
|
|
7574
7869
|
paragraphTextLength: Array.from(paragraphText).length,
|
|
7575
7870
|
inlineCount: paragraph.children?.length ?? 0,
|
|
7576
7871
|
blockType: "paragraph",
|
|
@@ -7601,12 +7896,27 @@ function collectInlineTarget(inline, storyKey, inlinePath, targets) {
|
|
|
7601
7896
|
return;
|
|
7602
7897
|
case "hyperlink":
|
|
7603
7898
|
targets.push(createHyperlinkEditableTarget(inline, storyKey, inlinePath));
|
|
7899
|
+
targets.push(createHyperlinkDestinationEditableTarget(inline, storyKey, inlinePath));
|
|
7604
7900
|
return;
|
|
7605
7901
|
case "bookmark_start":
|
|
7606
|
-
targets.push(createBookmarkEditableTarget(
|
|
7902
|
+
targets.push(createBookmarkEditableTarget(
|
|
7903
|
+
inline.bookmarkId,
|
|
7904
|
+
inline.name,
|
|
7905
|
+
storyKey,
|
|
7906
|
+
inlinePath,
|
|
7907
|
+
"start",
|
|
7908
|
+
inline.sourceRef
|
|
7909
|
+
));
|
|
7607
7910
|
return;
|
|
7608
7911
|
case "bookmark_end":
|
|
7609
|
-
targets.push(createBookmarkEditableTarget(
|
|
7912
|
+
targets.push(createBookmarkEditableTarget(
|
|
7913
|
+
inline.bookmarkId,
|
|
7914
|
+
void 0,
|
|
7915
|
+
storyKey,
|
|
7916
|
+
inlinePath,
|
|
7917
|
+
"end",
|
|
7918
|
+
inline.sourceRef
|
|
7919
|
+
));
|
|
7610
7920
|
return;
|
|
7611
7921
|
case "image":
|
|
7612
7922
|
targets.push(createImageEditableTarget(inline, storyKey, inlinePath));
|
|
@@ -7630,6 +7940,7 @@ function collectInlineTarget(inline, storyKey, inlinePath, targets) {
|
|
|
7630
7940
|
function createFieldEditableTarget(field, storyKey, inlinePath) {
|
|
7631
7941
|
const resultText = field.children.map(inlineTextForTargetHash).join("");
|
|
7632
7942
|
const sourceRef = field.sourceRef;
|
|
7943
|
+
const targetHash = hashText(`${field.instruction}\0${resultText}`);
|
|
7633
7944
|
const preserveOnly = field.refreshStatus === "preserve-only" || field.fieldFamily === "UNKNOWN";
|
|
7634
7945
|
const blockers = preserveOnly ? ["field-generated-text", "preserve-only"] : ["field-generated-text", "unmodeled-target"];
|
|
7635
7946
|
return {
|
|
@@ -7649,9 +7960,28 @@ function createFieldEditableTarget(field, storyKey, inlinePath) {
|
|
|
7649
7960
|
...field.locked !== void 0 ? { locked: field.locked } : {},
|
|
7650
7961
|
...field.dirty !== void 0 ? { dirty: field.dirty } : {}
|
|
7651
7962
|
},
|
|
7963
|
+
canonicalAddress: createCanonicalAddress({
|
|
7964
|
+
addressKind: "field-result",
|
|
7965
|
+
storyKey,
|
|
7966
|
+
staleCheckKind: "field",
|
|
7967
|
+
operationScope: "field-refresh",
|
|
7968
|
+
sourceRefs: [sourceRef],
|
|
7969
|
+
staleHash: targetHash,
|
|
7970
|
+
rangeBoundary: {
|
|
7971
|
+
boundaryKind: "field-result",
|
|
7972
|
+
from: 0,
|
|
7973
|
+
to: Array.from(resultText).length
|
|
7974
|
+
},
|
|
7975
|
+
discriminator: {
|
|
7976
|
+
canonicalFieldId: field.canonicalFieldId ?? null,
|
|
7977
|
+
fieldFamily: field.fieldFamily ?? null,
|
|
7978
|
+
fieldTarget: field.fieldTarget ?? null,
|
|
7979
|
+
sourceId: sourceRef?.sourceId ?? null
|
|
7980
|
+
}
|
|
7981
|
+
}),
|
|
7652
7982
|
staleCheck: {
|
|
7653
7983
|
blockType: "field",
|
|
7654
|
-
targetHash
|
|
7984
|
+
targetHash,
|
|
7655
7985
|
targetTextLength: Array.from(resultText).length,
|
|
7656
7986
|
childCount: field.children.length,
|
|
7657
7987
|
...sourceRef !== void 0 ? { sourceRef } : {}
|
|
@@ -7665,6 +7995,7 @@ function createFieldEditableTarget(field, storyKey, inlinePath) {
|
|
|
7665
7995
|
function createHyperlinkEditableTarget(hyperlink, storyKey, inlinePath) {
|
|
7666
7996
|
const text = hyperlink.children.map(inlineTextForTargetHash).join("");
|
|
7667
7997
|
const sourceRef = hyperlink.sourceRef ?? hyperlink.fieldCarrier?.sourceRef;
|
|
7998
|
+
const targetHash = hashText(`${hyperlink.href}\0${text}`);
|
|
7668
7999
|
return {
|
|
7669
8000
|
targetKey: `${storyKey}:${inlinePath}:hyperlink`,
|
|
7670
8001
|
kind: "hyperlink-text",
|
|
@@ -7675,9 +8006,25 @@ function createHyperlinkEditableTarget(hyperlink, storyKey, inlinePath) {
|
|
|
7675
8006
|
editability: "editable",
|
|
7676
8007
|
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
7677
8008
|
link: { href: hyperlink.href },
|
|
8009
|
+
canonicalAddress: createCanonicalAddress({
|
|
8010
|
+
addressKind: "hyperlink-display-text",
|
|
8011
|
+
storyKey,
|
|
8012
|
+
staleCheckKind: "hyperlink",
|
|
8013
|
+
sourceRefs: [sourceRef],
|
|
8014
|
+
staleHash: targetHash,
|
|
8015
|
+
rangeBoundary: {
|
|
8016
|
+
boundaryKind: "hyperlink-display",
|
|
8017
|
+
from: 0,
|
|
8018
|
+
to: Array.from(text).length
|
|
8019
|
+
},
|
|
8020
|
+
discriminator: {
|
|
8021
|
+
href: hyperlink.href,
|
|
8022
|
+
sourceId: sourceRef?.sourceId ?? null
|
|
8023
|
+
}
|
|
8024
|
+
}),
|
|
7678
8025
|
staleCheck: {
|
|
7679
8026
|
blockType: "hyperlink",
|
|
7680
|
-
targetHash
|
|
8027
|
+
targetHash,
|
|
7681
8028
|
targetTextLength: Array.from(text).length,
|
|
7682
8029
|
childCount: hyperlink.children.length,
|
|
7683
8030
|
...sourceRef !== void 0 ? { sourceRef } : {}
|
|
@@ -7685,7 +8032,52 @@ function createHyperlinkEditableTarget(hyperlink, storyKey, inlinePath) {
|
|
|
7685
8032
|
posture: { blockers: [] }
|
|
7686
8033
|
};
|
|
7687
8034
|
}
|
|
7688
|
-
function
|
|
8035
|
+
function createHyperlinkDestinationEditableTarget(hyperlink, storyKey, inlinePath) {
|
|
8036
|
+
const sourceRef = hyperlink.sourceRef ?? hyperlink.fieldCarrier?.sourceRef;
|
|
8037
|
+
const destinationKind = hyperlink.href.startsWith("#") ? "internal-anchor" : "external";
|
|
8038
|
+
const targetHash = hashText(`destination\0${hyperlink.href}`);
|
|
8039
|
+
return {
|
|
8040
|
+
targetKey: `${storyKey}:${inlinePath}:hyperlink-destination`,
|
|
8041
|
+
kind: "hyperlink-destination",
|
|
8042
|
+
storyKey,
|
|
8043
|
+
blockPath: inlinePath,
|
|
8044
|
+
leafPath: `${inlinePath}/destination`,
|
|
8045
|
+
commandFamily: "link-bookmark",
|
|
8046
|
+
editability: "non-editable",
|
|
8047
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
8048
|
+
link: {
|
|
8049
|
+
href: hyperlink.href,
|
|
8050
|
+
destinationKind
|
|
8051
|
+
},
|
|
8052
|
+
canonicalAddress: createCanonicalAddress({
|
|
8053
|
+
addressKind: "hyperlink-destination",
|
|
8054
|
+
storyKey,
|
|
8055
|
+
staleCheckKind: "hyperlink",
|
|
8056
|
+
operationScope: "link-destination",
|
|
8057
|
+
sourceRefs: [sourceRef],
|
|
8058
|
+
staleHash: targetHash,
|
|
8059
|
+
rangeBoundary: {
|
|
8060
|
+
boundaryKind: "hyperlink-destination",
|
|
8061
|
+
...sourceRef !== void 0 ? { startSourceJoinHash: sourceJoinHash([sourceRef]) } : {},
|
|
8062
|
+
...sourceRef !== void 0 ? { endSourceJoinHash: sourceJoinHash([sourceRef]) } : {}
|
|
8063
|
+
},
|
|
8064
|
+
discriminator: {
|
|
8065
|
+
href: hyperlink.href,
|
|
8066
|
+
destinationKind,
|
|
8067
|
+
sourceId: sourceRef?.sourceId ?? null
|
|
8068
|
+
}
|
|
8069
|
+
}),
|
|
8070
|
+
staleCheck: {
|
|
8071
|
+
blockType: "hyperlink",
|
|
8072
|
+
targetHash,
|
|
8073
|
+
childCount: hyperlink.children.length,
|
|
8074
|
+
...sourceRef !== void 0 ? { sourceRef } : {}
|
|
8075
|
+
},
|
|
8076
|
+
posture: { blockers: ["unmodeled-target"] }
|
|
8077
|
+
};
|
|
8078
|
+
}
|
|
8079
|
+
function createBookmarkEditableTarget(bookmarkId, bookmarkName, storyKey, inlinePath, edge, sourceRef) {
|
|
8080
|
+
const targetHash = hashText(`${edge}\0${bookmarkId}\0${bookmarkName ?? ""}`);
|
|
7689
8081
|
return {
|
|
7690
8082
|
targetKey: `${storyKey}:${inlinePath}:bookmark:${edge}:${bookmarkId}`,
|
|
7691
8083
|
kind: "bookmark-anchor",
|
|
@@ -7694,14 +8086,34 @@ function createBookmarkEditableTarget(bookmarkId, bookmarkName, storyKey, inline
|
|
|
7694
8086
|
leafPath: inlinePath,
|
|
7695
8087
|
commandFamily: "link-bookmark",
|
|
7696
8088
|
editability: "non-editable",
|
|
8089
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
7697
8090
|
link: {
|
|
7698
8091
|
bookmarkId,
|
|
7699
8092
|
...bookmarkName !== void 0 ? { bookmarkName } : {}
|
|
7700
8093
|
},
|
|
8094
|
+
canonicalAddress: createCanonicalAddress({
|
|
8095
|
+
addressKind: "bookmark-anchor",
|
|
8096
|
+
storyKey,
|
|
8097
|
+
staleCheckKind: "bookmark",
|
|
8098
|
+
sourceRefs: [sourceRef],
|
|
8099
|
+
staleHash: targetHash,
|
|
8100
|
+
rangeBoundary: {
|
|
8101
|
+
boundaryKind: "bookmark-anchor",
|
|
8102
|
+
...sourceRef !== void 0 ? { startSourceJoinHash: sourceJoinHash([sourceRef]) } : {},
|
|
8103
|
+
...sourceRef !== void 0 ? { endSourceJoinHash: sourceJoinHash([sourceRef]) } : {}
|
|
8104
|
+
},
|
|
8105
|
+
discriminator: {
|
|
8106
|
+
bookmarkId,
|
|
8107
|
+
bookmarkName: bookmarkName ?? null,
|
|
8108
|
+
edge,
|
|
8109
|
+
sourceId: sourceRef?.sourceId ?? null
|
|
8110
|
+
}
|
|
8111
|
+
}),
|
|
7701
8112
|
staleCheck: {
|
|
7702
8113
|
blockType: "bookmark",
|
|
7703
|
-
targetHash
|
|
7704
|
-
childCount: 0
|
|
8114
|
+
targetHash,
|
|
8115
|
+
childCount: 0,
|
|
8116
|
+
...sourceRef !== void 0 ? { sourceRef } : {}
|
|
7705
8117
|
},
|
|
7706
8118
|
posture: { blockers: ["unmodeled-target"] }
|
|
7707
8119
|
};
|
|
@@ -7749,6 +8161,7 @@ function createObjectEditableTarget(inline, storyKey, inlinePath) {
|
|
|
7749
8161
|
storyKey,
|
|
7750
8162
|
inlinePath,
|
|
7751
8163
|
objectKind: "ole",
|
|
8164
|
+
sourceRef: inline.sourceRef,
|
|
7752
8165
|
targetHash: `${inline.id}\0${inline.relationshipId}`,
|
|
7753
8166
|
object: {
|
|
7754
8167
|
objectKind: "ole",
|
|
@@ -7870,6 +8283,167 @@ function createOpaqueEditableTarget(input) {
|
|
|
7870
8283
|
}
|
|
7871
8284
|
};
|
|
7872
8285
|
}
|
|
8286
|
+
function collectFieldRegionRefreshTargets(doc, targets) {
|
|
8287
|
+
for (const region of collectCanonicalFieldRegionIdentities(doc)) {
|
|
8288
|
+
targets.push(createFieldRegionRefreshEditableTarget(region));
|
|
8289
|
+
}
|
|
8290
|
+
}
|
|
8291
|
+
function createFieldRegionRefreshEditableTarget(region) {
|
|
8292
|
+
const isToc = region.kind === "toc-region" || region.fieldFamily === "TOC";
|
|
8293
|
+
const sourceRef = region.sourceRef;
|
|
8294
|
+
const targetHash = hashText(JSON.stringify({
|
|
8295
|
+
regionId: region.regionId,
|
|
8296
|
+
canonicalFieldId: region.canonicalFieldId,
|
|
8297
|
+
fieldFamily: region.fieldFamily,
|
|
8298
|
+
refreshStatus: region.refreshStatus,
|
|
8299
|
+
tocId: region.tocId ?? null,
|
|
8300
|
+
resultRange: region.resultRange ?? null,
|
|
8301
|
+
status: region.status ?? null
|
|
8302
|
+
}));
|
|
8303
|
+
return {
|
|
8304
|
+
targetKey: `${region.storyKey}:field-region:${region.regionId}:refresh`,
|
|
8305
|
+
kind: isToc ? "toc-region-refresh" : "field-region-refresh",
|
|
8306
|
+
storyKey: region.storyKey,
|
|
8307
|
+
blockPath: `${region.storyKey}/field-region[${region.regionId}]`,
|
|
8308
|
+
leafPath: `${region.storyKey}/field-region[${region.regionId}]/refresh`,
|
|
8309
|
+
commandFamily: "field",
|
|
8310
|
+
editability: "non-editable",
|
|
8311
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
8312
|
+
field: {
|
|
8313
|
+
canonicalFieldId: region.canonicalFieldId,
|
|
8314
|
+
regionId: region.regionId,
|
|
8315
|
+
fieldFamily: region.fieldFamily,
|
|
8316
|
+
refreshStatus: region.refreshStatus,
|
|
8317
|
+
...region.sourcePath !== void 0 ? { sourcePath: region.sourcePath } : {},
|
|
8318
|
+
...region.tocId !== void 0 ? { tocId: region.tocId } : {},
|
|
8319
|
+
...region.resultRange !== void 0 ? {
|
|
8320
|
+
resultRangeFromParagraphIndex: region.resultRange.fromParagraphIndex,
|
|
8321
|
+
resultRangeToParagraphIndex: region.resultRange.toParagraphIndex
|
|
8322
|
+
} : {},
|
|
8323
|
+
...region.status !== void 0 ? { status: region.status } : {},
|
|
8324
|
+
...region.cachedEntryCount !== void 0 ? { cachedEntryCount: region.cachedEntryCount } : {},
|
|
8325
|
+
...region.generatedEntryCount !== void 0 ? { generatedEntryCount: region.generatedEntryCount } : {}
|
|
8326
|
+
},
|
|
8327
|
+
canonicalAddress: createCanonicalAddress({
|
|
8328
|
+
addressKind: isToc ? "toc-region-refresh" : "field-region-refresh",
|
|
8329
|
+
storyKey: region.storyKey,
|
|
8330
|
+
staleCheckKind: "field",
|
|
8331
|
+
operationScope: isToc ? "toc-refresh" : "field-refresh",
|
|
8332
|
+
sourceRefs: [sourceRef],
|
|
8333
|
+
staleHash: targetHash,
|
|
8334
|
+
rangeBoundary: {
|
|
8335
|
+
boundaryKind: "field-region",
|
|
8336
|
+
...region.resultRange !== void 0 ? {
|
|
8337
|
+
from: region.resultRange.fromParagraphIndex,
|
|
8338
|
+
to: region.resultRange.toParagraphIndex
|
|
8339
|
+
} : { from: region.paragraphIndex, to: region.paragraphIndex }
|
|
8340
|
+
},
|
|
8341
|
+
discriminator: {
|
|
8342
|
+
regionId: region.regionId,
|
|
8343
|
+
canonicalFieldId: region.canonicalFieldId,
|
|
8344
|
+
fieldIndex: region.fieldIndex,
|
|
8345
|
+
fieldFamily: region.fieldFamily,
|
|
8346
|
+
tocId: region.tocId ?? null
|
|
8347
|
+
}
|
|
8348
|
+
}),
|
|
8349
|
+
staleCheck: {
|
|
8350
|
+
blockType: "field",
|
|
8351
|
+
targetHash,
|
|
8352
|
+
childCount: region.cachedEntryCount ?? 0,
|
|
8353
|
+
...sourceRef !== void 0 ? { sourceRef } : {}
|
|
8354
|
+
},
|
|
8355
|
+
posture: {
|
|
8356
|
+
blockers: ["field-generated-text", "unmodeled-target"]
|
|
8357
|
+
}
|
|
8358
|
+
};
|
|
8359
|
+
}
|
|
8360
|
+
function collectBookmarkContentRangeTargets(doc, targets) {
|
|
8361
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
8362
|
+
for (const context of collectStoryBlockContexts(doc)) {
|
|
8363
|
+
walkBlocks(context.blocks, context.storyKey, context.basePath, {
|
|
8364
|
+
inline(inline, _blockPath, inlinePath) {
|
|
8365
|
+
if (inline.type !== "bookmark_start" && inline.type !== "bookmark_end") return;
|
|
8366
|
+
const key = `${context.storyKey}:${inline.bookmarkId}`;
|
|
8367
|
+
const previous = candidates.get(key);
|
|
8368
|
+
if (inline.type === "bookmark_start") {
|
|
8369
|
+
candidates.set(key, {
|
|
8370
|
+
...previous ?? { storyKey: context.storyKey, bookmarkId: inline.bookmarkId },
|
|
8371
|
+
bookmarkName: inline.name,
|
|
8372
|
+
startPath: inlinePath,
|
|
8373
|
+
startSourceRef: inline.sourceRef
|
|
8374
|
+
});
|
|
8375
|
+
return;
|
|
8376
|
+
}
|
|
8377
|
+
candidates.set(key, {
|
|
8378
|
+
...previous ?? { storyKey: context.storyKey, bookmarkId: inline.bookmarkId },
|
|
8379
|
+
endPath: inlinePath,
|
|
8380
|
+
endSourceRef: inline.sourceRef
|
|
8381
|
+
});
|
|
8382
|
+
}
|
|
8383
|
+
});
|
|
8384
|
+
}
|
|
8385
|
+
for (const candidate of candidates.values()) {
|
|
8386
|
+
if (candidate.startPath === void 0 || candidate.endPath === void 0) continue;
|
|
8387
|
+
targets.push(createBookmarkContentRangeEditableTarget({
|
|
8388
|
+
...candidate,
|
|
8389
|
+
startPath: candidate.startPath,
|
|
8390
|
+
endPath: candidate.endPath
|
|
8391
|
+
}));
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
function createBookmarkContentRangeEditableTarget(candidate) {
|
|
8395
|
+
const startSourceJoinHash = sourceJoinHash([candidate.startSourceRef]);
|
|
8396
|
+
const endSourceJoinHash = sourceJoinHash([candidate.endSourceRef]);
|
|
8397
|
+
const rangeKey = hashText(JSON.stringify({
|
|
8398
|
+
storyKey: candidate.storyKey,
|
|
8399
|
+
bookmarkId: candidate.bookmarkId,
|
|
8400
|
+
bookmarkName: candidate.bookmarkName ?? null,
|
|
8401
|
+
startSourceId: candidate.startSourceRef?.sourceId ?? null,
|
|
8402
|
+
endSourceId: candidate.endSourceRef?.sourceId ?? null
|
|
8403
|
+
}));
|
|
8404
|
+
const targetHash = hashText(`range\0${candidate.bookmarkId}\0${candidate.bookmarkName ?? ""}\0${candidate.startPath}\0${candidate.endPath}`);
|
|
8405
|
+
return {
|
|
8406
|
+
targetKey: `${candidate.storyKey}:bookmark:${candidate.bookmarkId}:content-range`,
|
|
8407
|
+
kind: "bookmark-content-range",
|
|
8408
|
+
storyKey: candidate.storyKey,
|
|
8409
|
+
blockPath: `${candidate.storyKey}/bookmark[${candidate.bookmarkId}]`,
|
|
8410
|
+
leafPath: `${candidate.storyKey}/bookmark[${candidate.bookmarkId}]/content-range`,
|
|
8411
|
+
commandFamily: "link-bookmark",
|
|
8412
|
+
editability: "non-editable",
|
|
8413
|
+
...candidate.startSourceRef !== void 0 ? { sourceRef: candidate.startSourceRef } : {},
|
|
8414
|
+
link: {
|
|
8415
|
+
bookmarkId: candidate.bookmarkId,
|
|
8416
|
+
...candidate.bookmarkName !== void 0 ? { bookmarkName: candidate.bookmarkName } : {},
|
|
8417
|
+
rangeKey
|
|
8418
|
+
},
|
|
8419
|
+
canonicalAddress: createCanonicalAddress({
|
|
8420
|
+
addressKind: "bookmark-content-range",
|
|
8421
|
+
storyKey: candidate.storyKey,
|
|
8422
|
+
staleCheckKind: "bookmark",
|
|
8423
|
+
operationScope: "bookmark-range",
|
|
8424
|
+
sourceRefs: [candidate.startSourceRef, candidate.endSourceRef],
|
|
8425
|
+
staleHash: targetHash,
|
|
8426
|
+
rangeBoundary: {
|
|
8427
|
+
boundaryKind: "bookmark-content",
|
|
8428
|
+
...startSourceJoinHash !== void 0 ? { startSourceJoinHash } : {},
|
|
8429
|
+
...endSourceJoinHash !== void 0 ? { endSourceJoinHash } : {}
|
|
8430
|
+
},
|
|
8431
|
+
discriminator: {
|
|
8432
|
+
bookmarkId: candidate.bookmarkId,
|
|
8433
|
+
bookmarkName: candidate.bookmarkName ?? null,
|
|
8434
|
+
startSourceId: candidate.startSourceRef?.sourceId ?? null,
|
|
8435
|
+
endSourceId: candidate.endSourceRef?.sourceId ?? null
|
|
8436
|
+
}
|
|
8437
|
+
}),
|
|
8438
|
+
staleCheck: {
|
|
8439
|
+
blockType: "bookmark",
|
|
8440
|
+
targetHash,
|
|
8441
|
+
childCount: 2,
|
|
8442
|
+
...candidate.startSourceRef !== void 0 ? { sourceRef: candidate.startSourceRef } : {}
|
|
8443
|
+
},
|
|
8444
|
+
posture: { blockers: ["unmodeled-target"] }
|
|
8445
|
+
};
|
|
8446
|
+
}
|
|
7873
8447
|
function inlineObjectKind(inline) {
|
|
7874
8448
|
switch (inline.type) {
|
|
7875
8449
|
case "chart_preview":
|
|
@@ -7992,6 +8566,16 @@ function collectParagraphText(paragraph) {
|
|
|
7992
8566
|
}
|
|
7993
8567
|
return text;
|
|
7994
8568
|
}
|
|
8569
|
+
function blockTextForTargetHash(block) {
|
|
8570
|
+
if (block.type === "paragraph") return collectParagraphText(block);
|
|
8571
|
+
if (block.type === "sdt" || block.type === "custom_xml") {
|
|
8572
|
+
return block.children.map(blockTextForTargetHash).join("");
|
|
8573
|
+
}
|
|
8574
|
+
if (block.type === "table") {
|
|
8575
|
+
return block.rows.flatMap((row) => row.cells).flatMap((cell) => cell.children).map(blockTextForTargetHash).join("");
|
|
8576
|
+
}
|
|
8577
|
+
return "";
|
|
8578
|
+
}
|
|
7995
8579
|
function inlineTextForTargetHash(inline) {
|
|
7996
8580
|
if (inline.type === "text") return inline.text;
|
|
7997
8581
|
if (inline.type === "symbol") return inline.char;
|
|
@@ -8002,10 +8586,229 @@ function inlineTextForTargetHash(inline) {
|
|
|
8002
8586
|
if (inline.type === "hyperlink") {
|
|
8003
8587
|
return inline.children.map(inlineTextForTargetHash).join("");
|
|
8004
8588
|
}
|
|
8005
|
-
if (inline.type === "field") {
|
|
8006
|
-
return inline.children.map(inlineTextForTargetHash).join("");
|
|
8589
|
+
if (inline.type === "field") {
|
|
8590
|
+
return inline.children.map(inlineTextForTargetHash).join("");
|
|
8591
|
+
}
|
|
8592
|
+
return "";
|
|
8593
|
+
}
|
|
8594
|
+
function createTableTargetCanonicalAddress(table, staleCheckKind, staleHash, resolver = {}) {
|
|
8595
|
+
return createCanonicalAddress({
|
|
8596
|
+
addressKind: "table-target",
|
|
8597
|
+
storyKey: tableStoryKey(table),
|
|
8598
|
+
staleCheckKind,
|
|
8599
|
+
operationScope: table.operationScope,
|
|
8600
|
+
rowRange: table.fragment?.rowRange,
|
|
8601
|
+
columnRange: table.fragment?.columnRange,
|
|
8602
|
+
sourceRefs: [table.sourceRef, table.rowSourceRef, table.cellSourceRef],
|
|
8603
|
+
staleHash,
|
|
8604
|
+
...resolver,
|
|
8605
|
+
discriminator: {
|
|
8606
|
+
operationScope: table.operationScope,
|
|
8607
|
+
tableDepth: table.tableDepth,
|
|
8608
|
+
rowIndex: table.rowIndex ?? null,
|
|
8609
|
+
columnIndex: table.columnIndex ?? null,
|
|
8610
|
+
cellIndex: table.cellIndex ?? null,
|
|
8611
|
+
gridColumnStart: table.gridColumnStart ?? null,
|
|
8612
|
+
gridSpan: table.gridSpan ?? null,
|
|
8613
|
+
verticalMerge: table.verticalMerge ?? null,
|
|
8614
|
+
sourceId: table.sourceRef?.sourceId ?? null,
|
|
8615
|
+
rowSourceId: table.rowSourceRef?.sourceId ?? null,
|
|
8616
|
+
cellSourceId: table.cellSourceRef?.sourceId ?? null
|
|
8617
|
+
},
|
|
8618
|
+
secondaryStory: table.secondaryStory,
|
|
8619
|
+
nestedTable: table.nestedTable,
|
|
8620
|
+
insideSdt: table.insideSdt
|
|
8621
|
+
});
|
|
8622
|
+
}
|
|
8623
|
+
function tableStoryKey(table) {
|
|
8624
|
+
const suffix = `:${table.tablePath}`;
|
|
8625
|
+
return table.tableKey.endsWith(suffix) ? table.tableKey.slice(0, -suffix.length) : MAIN_STORY_KEY;
|
|
8626
|
+
}
|
|
8627
|
+
function createCanonicalAddress(input) {
|
|
8628
|
+
const sourceHash = sourceJoinHash(input.sourceRefs ?? []);
|
|
8629
|
+
const payload = {
|
|
8630
|
+
addressKind: input.addressKind,
|
|
8631
|
+
storyKey: input.storyKey,
|
|
8632
|
+
operationScope: input.operationScope ?? null,
|
|
8633
|
+
rowRange: input.rowRange ?? null,
|
|
8634
|
+
columnRange: input.columnRange ?? null,
|
|
8635
|
+
sourceHash: sourceHash ?? null,
|
|
8636
|
+
discriminator: input.discriminator
|
|
8637
|
+
};
|
|
8638
|
+
return {
|
|
8639
|
+
addressKey: `editable-address:${hashText(JSON.stringify(payload))}`,
|
|
8640
|
+
addressKind: input.addressKind,
|
|
8641
|
+
storyKey: input.storyKey,
|
|
8642
|
+
staleCheckKind: input.staleCheckKind,
|
|
8643
|
+
...input.operationScope !== void 0 ? { operationScope: input.operationScope } : {},
|
|
8644
|
+
...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
|
|
8645
|
+
...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
|
|
8646
|
+
...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
|
|
8647
|
+
...input.secondaryStory === true ? { secondaryStory: true } : {},
|
|
8648
|
+
...input.nestedTable === true ? { nestedTable: true } : {},
|
|
8649
|
+
...input.insideSdt === true ? { insideSdt: true } : {},
|
|
8650
|
+
resolver: {
|
|
8651
|
+
staleHash: input.staleHash,
|
|
8652
|
+
...sourceHash !== void 0 ? { sourceJoinHash: sourceHash } : {},
|
|
8653
|
+
...input.rowRange !== void 0 ? { rowRange: input.rowRange } : {},
|
|
8654
|
+
...input.columnRange !== void 0 ? { columnRange: input.columnRange } : {},
|
|
8655
|
+
...input.rangeBoundary !== void 0 ? { rangeBoundary: input.rangeBoundary } : {},
|
|
8656
|
+
...input.owner !== void 0 ? { owner: input.owner } : {}
|
|
8657
|
+
}
|
|
8658
|
+
};
|
|
8659
|
+
}
|
|
8660
|
+
function ownerRoutingFromAddress(address) {
|
|
8661
|
+
return {
|
|
8662
|
+
addressKey: address.addressKey,
|
|
8663
|
+
addressKind: address.addressKind,
|
|
8664
|
+
storyKey: address.storyKey,
|
|
8665
|
+
...address.operationScope !== void 0 ? { operationScope: address.operationScope } : {},
|
|
8666
|
+
...address.sourceJoinHash !== void 0 ? { sourceJoinHash: address.sourceJoinHash } : {},
|
|
8667
|
+
staleHash: address.resolver?.staleHash ?? "",
|
|
8668
|
+
...address.rowRange !== void 0 ? { rowRange: address.rowRange } : {},
|
|
8669
|
+
...address.columnRange !== void 0 ? { columnRange: address.columnRange } : {}
|
|
8670
|
+
};
|
|
8671
|
+
}
|
|
8672
|
+
function sourceJoinHashForRefs(...refs) {
|
|
8673
|
+
const sourceHash = sourceJoinHash(refs);
|
|
8674
|
+
return sourceHash === void 0 ? {} : { sourceJoinHash: sourceHash };
|
|
8675
|
+
}
|
|
8676
|
+
function sourceJoinHash(refs) {
|
|
8677
|
+
const sourceIds = refs.map((ref) => ref?.sourceId).filter((sourceId) => sourceId !== void 0);
|
|
8678
|
+
if (sourceIds.length === 0) return void 0;
|
|
8679
|
+
return hashText(sourceIds.join("\0"));
|
|
8680
|
+
}
|
|
8681
|
+
function collectCanonicalStoryIdentities(doc) {
|
|
8682
|
+
const stories = [
|
|
8683
|
+
{
|
|
8684
|
+
storyKey: MAIN_STORY_KEY,
|
|
8685
|
+
kind: "main",
|
|
8686
|
+
blockCount: doc.content.children.length
|
|
8687
|
+
}
|
|
8688
|
+
];
|
|
8689
|
+
const sectionCount = countSections(doc);
|
|
8690
|
+
for (const header of doc.subParts?.headers ?? []) {
|
|
8691
|
+
const bindings = collectHeaderFooterBindings(
|
|
8692
|
+
doc,
|
|
8693
|
+
"header",
|
|
8694
|
+
header.relationshipId,
|
|
8695
|
+
header.variant,
|
|
8696
|
+
header.sectionIndex,
|
|
8697
|
+
sectionCount
|
|
8698
|
+
);
|
|
8699
|
+
stories.push({
|
|
8700
|
+
storyKey: createHeaderFooterStoryKey({
|
|
8701
|
+
kind: "header",
|
|
8702
|
+
relationshipId: header.relationshipId,
|
|
8703
|
+
variant: header.variant,
|
|
8704
|
+
...header.sectionIndex !== void 0 ? { sectionIndex: header.sectionIndex } : {}
|
|
8705
|
+
}),
|
|
8706
|
+
kind: "header",
|
|
8707
|
+
blockCount: header.blocks.length,
|
|
8708
|
+
variant: header.variant,
|
|
8709
|
+
relationshipId: header.relationshipId,
|
|
8710
|
+
partPath: header.partPath,
|
|
8711
|
+
...header.sectionIndex !== void 0 ? { sectionIndex: header.sectionIndex } : {},
|
|
8712
|
+
boundSectionIndexes: bindings.boundSectionIndexes,
|
|
8713
|
+
explicitSectionIndexes: bindings.explicitSectionIndexes,
|
|
8714
|
+
inheritedSectionIndexes: bindings.inheritedSectionIndexes
|
|
8715
|
+
});
|
|
8716
|
+
}
|
|
8717
|
+
for (const footer of doc.subParts?.footers ?? []) {
|
|
8718
|
+
const bindings = collectHeaderFooterBindings(
|
|
8719
|
+
doc,
|
|
8720
|
+
"footer",
|
|
8721
|
+
footer.relationshipId,
|
|
8722
|
+
footer.variant,
|
|
8723
|
+
footer.sectionIndex,
|
|
8724
|
+
sectionCount
|
|
8725
|
+
);
|
|
8726
|
+
stories.push({
|
|
8727
|
+
storyKey: createHeaderFooterStoryKey({
|
|
8728
|
+
kind: "footer",
|
|
8729
|
+
relationshipId: footer.relationshipId,
|
|
8730
|
+
variant: footer.variant,
|
|
8731
|
+
...footer.sectionIndex !== void 0 ? { sectionIndex: footer.sectionIndex } : {}
|
|
8732
|
+
}),
|
|
8733
|
+
kind: "footer",
|
|
8734
|
+
blockCount: footer.blocks.length,
|
|
8735
|
+
variant: footer.variant,
|
|
8736
|
+
relationshipId: footer.relationshipId,
|
|
8737
|
+
partPath: footer.partPath,
|
|
8738
|
+
...footer.sectionIndex !== void 0 ? { sectionIndex: footer.sectionIndex } : {},
|
|
8739
|
+
boundSectionIndexes: bindings.boundSectionIndexes,
|
|
8740
|
+
explicitSectionIndexes: bindings.explicitSectionIndexes,
|
|
8741
|
+
inheritedSectionIndexes: bindings.inheritedSectionIndexes
|
|
8742
|
+
});
|
|
8743
|
+
}
|
|
8744
|
+
const notes = doc.subParts?.footnoteCollection;
|
|
8745
|
+
if (notes) {
|
|
8746
|
+
for (const note of Object.values(notes.footnotes)) {
|
|
8747
|
+
stories.push({
|
|
8748
|
+
storyKey: createNoteStoryKey("footnote", note.noteId),
|
|
8749
|
+
kind: "footnote",
|
|
8750
|
+
noteId: note.noteId,
|
|
8751
|
+
blockCount: note.blocks.length
|
|
8752
|
+
});
|
|
8753
|
+
}
|
|
8754
|
+
for (const note of Object.values(notes.endnotes)) {
|
|
8755
|
+
stories.push({
|
|
8756
|
+
storyKey: createNoteStoryKey("endnote", note.noteId),
|
|
8757
|
+
kind: "endnote",
|
|
8758
|
+
noteId: note.noteId,
|
|
8759
|
+
blockCount: note.blocks.length
|
|
8760
|
+
});
|
|
8761
|
+
}
|
|
8762
|
+
}
|
|
8763
|
+
return stories;
|
|
8764
|
+
}
|
|
8765
|
+
function collectCanonicalNumberingLayoutInputs(doc, contexts = collectStoryBlockContexts(doc)) {
|
|
8766
|
+
const inputs = [];
|
|
8767
|
+
for (const context of contexts) {
|
|
8768
|
+
walkBlocks(context.blocks, context.storyKey, context.basePath, {
|
|
8769
|
+
paragraph(paragraph, blockPath) {
|
|
8770
|
+
const styleNumbering = paragraph.numbering === void 0 && paragraph.styleId !== void 0 ? resolveParagraphStyleNumbering(doc, paragraph.styleId) : void 0;
|
|
8771
|
+
const numbering = paragraph.numbering ?? styleNumbering;
|
|
8772
|
+
if (numbering === void 0) {
|
|
8773
|
+
return;
|
|
8774
|
+
}
|
|
8775
|
+
const instance = doc.numbering.instances[numbering.numberingInstanceId];
|
|
8776
|
+
const abstractDefinition = instance?.abstractNumberingId === void 0 ? void 0 : doc.numbering.abstractDefinitions[instance.abstractNumberingId];
|
|
8777
|
+
inputs.push({
|
|
8778
|
+
numberingKey: `${context.storyKey}:${blockPath}:numbering`,
|
|
8779
|
+
storyKey: context.storyKey,
|
|
8780
|
+
blockPath,
|
|
8781
|
+
paragraphIndex: blockIndexFromPath(blockPath),
|
|
8782
|
+
...paragraph.sourceRef !== void 0 ? { sourceRef: paragraph.sourceRef } : {},
|
|
8783
|
+
...paragraph.numbering?.sourceRef !== void 0 ? { numberingSourceRef: paragraph.numbering.sourceRef } : {},
|
|
8784
|
+
numberingOrigin: paragraph.numbering === void 0 ? "paragraph-style" : "paragraph",
|
|
8785
|
+
...paragraph.numbering === void 0 && paragraph.styleId !== void 0 ? { paragraphStyleId: paragraph.styleId } : {},
|
|
8786
|
+
numberingInstanceId: numbering.numberingInstanceId,
|
|
8787
|
+
...instance?.sourceRef !== void 0 ? { numberingInstanceSourceRef: instance.sourceRef } : {},
|
|
8788
|
+
...instance?.abstractNumberingId !== void 0 ? { abstractNumberingId: instance.abstractNumberingId } : {},
|
|
8789
|
+
...abstractDefinition?.sourceRef !== void 0 ? { abstractNumberingSourceRef: abstractDefinition.sourceRef } : {},
|
|
8790
|
+
level: numbering.level ?? 0
|
|
8791
|
+
});
|
|
8792
|
+
}
|
|
8793
|
+
});
|
|
8794
|
+
}
|
|
8795
|
+
return inputs;
|
|
8796
|
+
}
|
|
8797
|
+
function resolveParagraphStyleNumbering(doc, styleId) {
|
|
8798
|
+
const visited = /* @__PURE__ */ new Set();
|
|
8799
|
+
let currentStyleId = styleId;
|
|
8800
|
+
while (currentStyleId !== void 0 && !visited.has(currentStyleId)) {
|
|
8801
|
+
visited.add(currentStyleId);
|
|
8802
|
+
const style = doc.styles.paragraphs[currentStyleId];
|
|
8803
|
+
if (style === void 0) {
|
|
8804
|
+
return void 0;
|
|
8805
|
+
}
|
|
8806
|
+
if (style.numbering !== void 0) {
|
|
8807
|
+
return style.numbering;
|
|
8808
|
+
}
|
|
8809
|
+
currentStyleId = style.basedOn;
|
|
8007
8810
|
}
|
|
8008
|
-
return
|
|
8811
|
+
return void 0;
|
|
8009
8812
|
}
|
|
8010
8813
|
function collectCanonicalFieldRegionIdentities(doc) {
|
|
8011
8814
|
const registry = doc.fieldRegistry;
|
|
@@ -8132,6 +8935,42 @@ function blockIndexFromPath(blockPath) {
|
|
|
8132
8935
|
const last = matches.at(-1);
|
|
8133
8936
|
return last ? Number.parseInt(last[1], 10) : 0;
|
|
8134
8937
|
}
|
|
8938
|
+
function collectCanonicalTableLayoutInputs(contexts) {
|
|
8939
|
+
const tables = [];
|
|
8940
|
+
for (const context of contexts) {
|
|
8941
|
+
walkBlocks(context.blocks, context.storyKey, context.basePath, {
|
|
8942
|
+
table(table, blockPath) {
|
|
8943
|
+
tables.push(projectTableLayoutInput(table, context.storyKey, blockPath));
|
|
8944
|
+
}
|
|
8945
|
+
});
|
|
8946
|
+
}
|
|
8947
|
+
return tables;
|
|
8948
|
+
}
|
|
8949
|
+
function collectCanonicalAnchorLayoutInputs(doc, contexts = collectStoryBlockContexts(doc)) {
|
|
8950
|
+
const anchors = [];
|
|
8951
|
+
for (const context of contexts) {
|
|
8952
|
+
walkBlocks(context.blocks, context.storyKey, context.basePath, {
|
|
8953
|
+
inline(inline, blockPath, inlinePath) {
|
|
8954
|
+
const anchor = projectAnchorLayoutInput(
|
|
8955
|
+
doc,
|
|
8956
|
+
inline,
|
|
8957
|
+
context.storyKey,
|
|
8958
|
+
blockPath,
|
|
8959
|
+
inlinePath
|
|
8960
|
+
);
|
|
8961
|
+
if (anchor) anchors.push(anchor);
|
|
8962
|
+
}
|
|
8963
|
+
});
|
|
8964
|
+
}
|
|
8965
|
+
return anchors;
|
|
8966
|
+
}
|
|
8967
|
+
function collectCanonicalScopeLayoutInputs(contexts) {
|
|
8968
|
+
const scopes = [];
|
|
8969
|
+
for (const context of contexts) {
|
|
8970
|
+
scopes.push(...collectScopeLayoutInputsForStory(context));
|
|
8971
|
+
}
|
|
8972
|
+
return scopes.sort((left, right) => left.scopeKey.localeCompare(right.scopeKey));
|
|
8973
|
+
}
|
|
8135
8974
|
function collectStoryBlockContexts(doc) {
|
|
8136
8975
|
const contexts = [
|
|
8137
8976
|
{ storyKey: MAIN_STORY_KEY, blocks: doc.content.children, basePath: "main" }
|
|
@@ -8204,7 +9043,7 @@ function walkBlocks(blocks, storyKey, basePath, visitor) {
|
|
|
8204
9043
|
}
|
|
8205
9044
|
if (block.type === "paragraph") {
|
|
8206
9045
|
visitor.paragraph?.(block, blockPath);
|
|
8207
|
-
walkInlines(block.children, storyKey, blockPath, `${blockPath}/inline`, visitor);
|
|
9046
|
+
walkInlines(block.children ?? [], storyKey, blockPath, `${blockPath}/inline`, visitor);
|
|
8208
9047
|
continue;
|
|
8209
9048
|
}
|
|
8210
9049
|
if (block.type === "sdt" || block.type === "custom_xml") {
|
|
@@ -8231,6 +9070,393 @@ function walkInlines(inlines, storyKey, blockPath, basePath, visitor) {
|
|
|
8231
9070
|
}
|
|
8232
9071
|
}
|
|
8233
9072
|
}
|
|
9073
|
+
function projectTableLayoutInput(table, storyKey, blockPath) {
|
|
9074
|
+
const tableKey = `${storyKey}:${blockPath}`;
|
|
9075
|
+
const rows = table.rows.map(
|
|
9076
|
+
(row, rowIndex) => projectTableRowLayoutInput(row, tableKey, rowIndex)
|
|
9077
|
+
);
|
|
9078
|
+
return {
|
|
9079
|
+
tableKey,
|
|
9080
|
+
storyKey,
|
|
9081
|
+
blockPath,
|
|
9082
|
+
...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
|
|
9083
|
+
...table.styleId !== void 0 ? { styleId: table.styleId } : {},
|
|
9084
|
+
rowCount: table.rows.length,
|
|
9085
|
+
columnCount: table.gridColumns.length,
|
|
9086
|
+
gridColumns: [...table.gridColumns],
|
|
9087
|
+
...table.width !== void 0 ? { width: table.width } : {},
|
|
9088
|
+
...table.alignment !== void 0 ? { alignment: table.alignment } : {},
|
|
9089
|
+
...table.borders !== void 0 ? { borders: table.borders } : {},
|
|
9090
|
+
...table.cellMargins !== void 0 ? { cellMargins: table.cellMargins } : {},
|
|
9091
|
+
...table.tblLook !== void 0 ? { tblLook: table.tblLook } : {},
|
|
9092
|
+
...table.indent !== void 0 ? { indent: table.indent } : {},
|
|
9093
|
+
...table.layoutMode !== void 0 ? { layoutMode: table.layoutMode } : {},
|
|
9094
|
+
...table.cellSpacing !== void 0 ? { cellSpacing: table.cellSpacing } : {},
|
|
9095
|
+
...table.bidiVisual !== void 0 ? { bidiVisual: table.bidiVisual } : {},
|
|
9096
|
+
...table.floating !== void 0 ? { floating: table.floating } : {},
|
|
9097
|
+
rows
|
|
9098
|
+
};
|
|
9099
|
+
}
|
|
9100
|
+
function projectTableRowLayoutInput(row, tableKey, rowIndex) {
|
|
9101
|
+
const rowKey = `${tableKey}:row[${rowIndex}]`;
|
|
9102
|
+
let gridColumn = row.gridBefore ?? 0;
|
|
9103
|
+
const cells = row.cells.map((cell, cellIndex) => {
|
|
9104
|
+
const input = projectTableCellLayoutInput(cell, rowKey, rowIndex, cellIndex, gridColumn);
|
|
9105
|
+
gridColumn += input.gridSpan;
|
|
9106
|
+
return input;
|
|
9107
|
+
});
|
|
9108
|
+
return {
|
|
9109
|
+
rowKey,
|
|
9110
|
+
...row.sourceRef !== void 0 ? { sourceRef: row.sourceRef } : {},
|
|
9111
|
+
rowIndex,
|
|
9112
|
+
cellCount: row.cells.length,
|
|
9113
|
+
...row.gridBefore !== void 0 ? { gridBefore: row.gridBefore } : {},
|
|
9114
|
+
...row.widthBefore !== void 0 ? { widthBefore: row.widthBefore } : {},
|
|
9115
|
+
...row.gridAfter !== void 0 ? { gridAfter: row.gridAfter } : {},
|
|
9116
|
+
...row.widthAfter !== void 0 ? { widthAfter: row.widthAfter } : {},
|
|
9117
|
+
...row.height !== void 0 ? { height: row.height } : {},
|
|
9118
|
+
...row.heightRule !== void 0 ? { heightRule: row.heightRule } : {},
|
|
9119
|
+
...row.isHeader !== void 0 ? { isHeader: row.isHeader } : {},
|
|
9120
|
+
...row.cantSplit !== void 0 ? { cantSplit: row.cantSplit } : {},
|
|
9121
|
+
...row.horizontalAlignment !== void 0 ? { horizontalAlignment: row.horizontalAlignment } : {},
|
|
9122
|
+
...row.cnfStyle !== void 0 ? { cnfStyle: row.cnfStyle } : {},
|
|
9123
|
+
cells
|
|
9124
|
+
};
|
|
9125
|
+
}
|
|
9126
|
+
function projectTableCellLayoutInput(cell, rowKey, rowIndex, cellIndex, gridColumnStart) {
|
|
9127
|
+
const gridSpan = cell.gridSpan ?? 1;
|
|
9128
|
+
return {
|
|
9129
|
+
cellKey: `${rowKey}:cell[${cellIndex}]`,
|
|
9130
|
+
...cell.sourceRef !== void 0 ? { sourceRef: cell.sourceRef } : {},
|
|
9131
|
+
rowIndex,
|
|
9132
|
+
cellIndex,
|
|
9133
|
+
gridColumnStart,
|
|
9134
|
+
gridSpan,
|
|
9135
|
+
...cell.verticalMerge !== void 0 ? { verticalMerge: cell.verticalMerge } : {},
|
|
9136
|
+
...cell.width !== void 0 ? { width: cell.width } : {},
|
|
9137
|
+
...cell.borders !== void 0 ? { borders: cell.borders } : {},
|
|
9138
|
+
...cell.shading !== void 0 ? { shading: cell.shading } : {},
|
|
9139
|
+
...cell.verticalAlign !== void 0 ? { verticalAlign: cell.verticalAlign } : {},
|
|
9140
|
+
...cell.textDirection !== void 0 ? { textDirection: cell.textDirection } : {},
|
|
9141
|
+
...cell.noWrap !== void 0 ? { noWrap: cell.noWrap } : {},
|
|
9142
|
+
...cell.fitText !== void 0 ? { fitText: cell.fitText } : {},
|
|
9143
|
+
...cell.margins !== void 0 ? { margins: cell.margins } : {},
|
|
9144
|
+
...cell.cnfStyle !== void 0 ? { cnfStyle: cell.cnfStyle } : {},
|
|
9145
|
+
blockCount: cell.children.length
|
|
9146
|
+
};
|
|
9147
|
+
}
|
|
9148
|
+
function projectAnchorLayoutInput(doc, inline, storyKey, blockPath, inlinePath) {
|
|
9149
|
+
if (inline.type === "drawing_frame") {
|
|
9150
|
+
return projectDrawingFrameAnchor(inline, storyKey, blockPath, inlinePath);
|
|
9151
|
+
}
|
|
9152
|
+
if (inline.type === "image") {
|
|
9153
|
+
return projectLegacyImageAnchor(doc, inline, storyKey, blockPath, inlinePath);
|
|
9154
|
+
}
|
|
9155
|
+
return null;
|
|
9156
|
+
}
|
|
9157
|
+
function projectDrawingFrameAnchor(node, storyKey, blockPath, inlinePath) {
|
|
9158
|
+
const anchor = node.anchor;
|
|
9159
|
+
const content = node.content;
|
|
9160
|
+
const shapeBlocks = content.type === "shape" ? content.txbxBlocks : void 0;
|
|
9161
|
+
const objectKind = drawingContentKind(content);
|
|
9162
|
+
const sourceRef = node.sourceRef ?? drawingContentSourceRef(content);
|
|
9163
|
+
const objectKey = `${storyKey}:${inlinePath}`;
|
|
9164
|
+
const textBoxBody = projectTextBoxBodyLayoutInput(content, objectKey, sourceRef, `${inlinePath}/txbx`);
|
|
9165
|
+
return {
|
|
9166
|
+
objectKey,
|
|
9167
|
+
storyKey,
|
|
9168
|
+
blockPath,
|
|
9169
|
+
inlinePath,
|
|
9170
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
9171
|
+
objectKind,
|
|
9172
|
+
editPosture: drawingEditPosture(node),
|
|
9173
|
+
display: anchor.display,
|
|
9174
|
+
extent: anchor.extent,
|
|
9175
|
+
wrapMode: anchor.wrapMode,
|
|
9176
|
+
...anchor.wrapPolygon !== void 0 ? { wrapPolygonPointCount: anchor.wrapPolygon.length } : {},
|
|
9177
|
+
...anchor.positionH !== void 0 ? { positionH: anchor.positionH } : {},
|
|
9178
|
+
...anchor.positionV !== void 0 ? { positionV: anchor.positionV } : {},
|
|
9179
|
+
...anchor.distMargins !== void 0 ? { distMargins: anchor.distMargins } : {},
|
|
9180
|
+
...anchor.relativeHeight !== void 0 ? { relativeHeight: anchor.relativeHeight } : {},
|
|
9181
|
+
...anchor.behindDoc !== void 0 ? { zOrder: anchor.behindDoc ? "behind-document" : "in-front-of-text" } : {},
|
|
9182
|
+
...anchor.layoutInCell !== void 0 ? { layoutInCell: anchor.layoutInCell } : {},
|
|
9183
|
+
...anchor.allowOverlap !== void 0 ? { allowOverlap: anchor.allowOverlap } : {},
|
|
9184
|
+
...anchor.simplePos !== void 0 ? { simplePos: anchor.simplePos } : {},
|
|
9185
|
+
...anchor.docPr?.id !== void 0 ? { docPrId: anchor.docPr.id } : {},
|
|
9186
|
+
...anchor.docPr?.name !== void 0 ? { docPrName: anchor.docPr.name } : {},
|
|
9187
|
+
...anchor.docPr?.descr !== void 0 ? { docPrDescription: anchor.docPr.descr } : {},
|
|
9188
|
+
...anchor.docPr?.hidden !== void 0 ? { hidden: anchor.docPr.hidden } : {},
|
|
9189
|
+
...anchor.frameLocks !== void 0 ? { frameLocks: anchor.frameLocks } : {},
|
|
9190
|
+
...content.type === "picture" && content.mediaId !== void 0 ? { mediaId: content.mediaId } : {},
|
|
9191
|
+
...content.type === "picture" && content.packagePartName !== void 0 ? { packagePartName: content.packagePartName } : {},
|
|
9192
|
+
...content.type === "picture" ? { relationshipId: content.blipRef } : {},
|
|
9193
|
+
...content.type === "picture" && content.isLinked !== void 0 ? { isLinked: content.isLinked } : {},
|
|
9194
|
+
...shapeBlocks !== void 0 ? { hasTextBoxBlocks: true } : {},
|
|
9195
|
+
...shapeBlocks !== void 0 ? { textBoxBlockCount: shapeBlocks.length } : {},
|
|
9196
|
+
...textBoxBody !== void 0 ? { textBoxBody } : {},
|
|
9197
|
+
rawXmlPreserved: content.type !== "picture" || content.rawXml !== void 0
|
|
9198
|
+
};
|
|
9199
|
+
}
|
|
9200
|
+
function projectTextBoxBodyLayoutInput(content, objectKey, sourceRef, basePath) {
|
|
9201
|
+
if (content.type !== "shape") return void 0;
|
|
9202
|
+
if (!content.isTextBox && content.txbxContentXml === void 0 && content.txbxBlocks === void 0) {
|
|
9203
|
+
return void 0;
|
|
9204
|
+
}
|
|
9205
|
+
const bodyKey = `${objectKey}:txbx`;
|
|
9206
|
+
const blockCount = content.txbxBlocks?.length ?? 0;
|
|
9207
|
+
if (content.txbxBlocks === void 0) {
|
|
9208
|
+
return {
|
|
9209
|
+
bodyKey,
|
|
9210
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
9211
|
+
status: content.txbxContentXml !== void 0 ? "preserve-only" : "unavailable",
|
|
9212
|
+
unavailableReason: "txbx-blocks-unavailable",
|
|
9213
|
+
...content.textBoxBody !== void 0 ? { bodyProperties: content.textBoxBody } : {},
|
|
9214
|
+
blockCount,
|
|
9215
|
+
paragraphCount: 0,
|
|
9216
|
+
unsupportedBlockCount: 0,
|
|
9217
|
+
paragraphs: []
|
|
9218
|
+
};
|
|
9219
|
+
}
|
|
9220
|
+
const paragraphs = content.txbxBlocks.flatMap(
|
|
9221
|
+
(block, index) => block.type === "paragraph" ? [projectTextBoxParagraphLayoutInput(block, bodyKey, `${basePath}/block[${index}]`, index)] : []
|
|
9222
|
+
);
|
|
9223
|
+
const unsupportedBlockCount = content.txbxBlocks.length - paragraphs.length;
|
|
9224
|
+
const unavailableReason = content.txbxBlocks.length === 0 ? "empty-body" : paragraphs.length === 0 ? "unsupported-content" : void 0;
|
|
9225
|
+
return {
|
|
9226
|
+
bodyKey,
|
|
9227
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
9228
|
+
status: unavailableReason === void 0 ? "modeled" : "unavailable",
|
|
9229
|
+
...unavailableReason !== void 0 ? { unavailableReason } : {},
|
|
9230
|
+
...content.textBoxBody !== void 0 ? { bodyProperties: content.textBoxBody } : {},
|
|
9231
|
+
blockCount,
|
|
9232
|
+
paragraphCount: paragraphs.length,
|
|
9233
|
+
unsupportedBlockCount,
|
|
9234
|
+
paragraphs
|
|
9235
|
+
};
|
|
9236
|
+
}
|
|
9237
|
+
function projectTextBoxParagraphLayoutInput(paragraph, bodyKey, blockPath, blockIndex) {
|
|
9238
|
+
const runs = paragraph.children.map(
|
|
9239
|
+
(inline, inlineIndex) => projectTextBoxRunLayoutInput(inline, `${bodyKey}:block[${blockIndex}]`, inlineIndex)
|
|
9240
|
+
);
|
|
9241
|
+
const text = runs.map((run) => run.text ?? "").join("");
|
|
9242
|
+
return {
|
|
9243
|
+
paragraphKey: `${bodyKey}:block[${blockIndex}]`,
|
|
9244
|
+
blockPath,
|
|
9245
|
+
blockIndex,
|
|
9246
|
+
...paragraph.sourceRef !== void 0 ? { sourceRef: paragraph.sourceRef } : {},
|
|
9247
|
+
...paragraph.styleId !== void 0 ? { styleId: paragraph.styleId } : {},
|
|
9248
|
+
...paragraph.alignment !== void 0 ? { alignment: paragraph.alignment } : {},
|
|
9249
|
+
...paragraph.borders !== void 0 ? { borders: paragraph.borders } : {},
|
|
9250
|
+
text,
|
|
9251
|
+
textLength: Array.from(text).length,
|
|
9252
|
+
runCount: runs.length,
|
|
9253
|
+
runs
|
|
9254
|
+
};
|
|
9255
|
+
}
|
|
9256
|
+
function projectTextBoxRunLayoutInput(inline, paragraphKey, inlineIndex) {
|
|
9257
|
+
const runKey = `${paragraphKey}:inline[${inlineIndex}]`;
|
|
9258
|
+
if (inline.type === "text") {
|
|
9259
|
+
return {
|
|
9260
|
+
runKey,
|
|
9261
|
+
inlineIndex,
|
|
9262
|
+
kind: "text",
|
|
9263
|
+
text: inline.text,
|
|
9264
|
+
textLength: Array.from(inline.text).length,
|
|
9265
|
+
...inline.marks !== void 0 ? { marks: inline.marks } : {}
|
|
9266
|
+
};
|
|
9267
|
+
}
|
|
9268
|
+
if (inline.type === "tab") {
|
|
9269
|
+
return { runKey, inlineIndex, kind: "tab", text: " ", textLength: 1 };
|
|
9270
|
+
}
|
|
9271
|
+
if (inline.type === "hard_break") {
|
|
9272
|
+
return { runKey, inlineIndex, kind: "hard-break", text: "\n", textLength: 1 };
|
|
9273
|
+
}
|
|
9274
|
+
if (inline.type === "symbol") {
|
|
9275
|
+
return {
|
|
9276
|
+
runKey,
|
|
9277
|
+
inlineIndex,
|
|
9278
|
+
kind: "symbol",
|
|
9279
|
+
text: inline.char,
|
|
9280
|
+
textLength: Array.from(inline.char).length
|
|
9281
|
+
};
|
|
9282
|
+
}
|
|
9283
|
+
return { runKey, inlineIndex, kind: "unsupported" };
|
|
9284
|
+
}
|
|
9285
|
+
function projectLegacyImageAnchor(doc, node, storyKey, blockPath, inlinePath) {
|
|
9286
|
+
const media = doc.media.items[node.mediaId];
|
|
9287
|
+
return {
|
|
9288
|
+
objectKey: `${storyKey}:${inlinePath}`,
|
|
9289
|
+
storyKey,
|
|
9290
|
+
blockPath,
|
|
9291
|
+
inlinePath,
|
|
9292
|
+
objectKind: "legacy-image",
|
|
9293
|
+
editPosture: "editable",
|
|
9294
|
+
...node.display !== void 0 ? { display: node.display } : {},
|
|
9295
|
+
...media?.widthEmu !== void 0 && media.heightEmu !== void 0 ? { extent: { widthEmu: media.widthEmu, heightEmu: media.heightEmu } } : {},
|
|
9296
|
+
...node.floating?.wrap !== void 0 ? { wrapMode: node.floating.wrap } : {},
|
|
9297
|
+
...node.floating?.horizontalPosition !== void 0 ? { positionH: normalizeFloatingAxis(node.floating.horizontalPosition) } : {},
|
|
9298
|
+
...node.floating?.verticalPosition !== void 0 ? { positionV: normalizeFloatingAxis(node.floating.verticalPosition) } : {},
|
|
9299
|
+
...node.floating?.behindDoc !== void 0 ? { zOrder: node.floating.behindDoc ? "behind-document" : "in-front-of-text" } : {},
|
|
9300
|
+
...node.floating?.layoutInCell !== void 0 ? { layoutInCell: node.floating.layoutInCell } : {},
|
|
9301
|
+
...node.floating?.allowOverlap !== void 0 ? { allowOverlap: node.floating.allowOverlap } : {},
|
|
9302
|
+
mediaId: node.mediaId,
|
|
9303
|
+
...node.sourceRef !== void 0 ? { sourceRef: node.sourceRef } : {},
|
|
9304
|
+
...media?.packagePartName !== void 0 ? { packagePartName: media.packagePartName } : {},
|
|
9305
|
+
...media?.relationshipId !== void 0 ? { relationshipId: media.relationshipId } : {},
|
|
9306
|
+
...node.placementXml !== void 0 ? { rawXmlPreserved: true } : {}
|
|
9307
|
+
};
|
|
9308
|
+
}
|
|
9309
|
+
function preserveOnlySourceRef(sourceId) {
|
|
9310
|
+
return sourceId === void 0 ? void 0 : { sourceId };
|
|
9311
|
+
}
|
|
9312
|
+
function drawingContentSourceRef(content) {
|
|
9313
|
+
if ("preserveOnlyObject" in content) {
|
|
9314
|
+
return preserveOnlySourceRef(content.preserveOnlyObject?.sourceId);
|
|
9315
|
+
}
|
|
9316
|
+
return void 0;
|
|
9317
|
+
}
|
|
9318
|
+
function normalizeFloatingAxis(axis) {
|
|
9319
|
+
return {
|
|
9320
|
+
relativeFrom: axis?.relativeFrom ?? "",
|
|
9321
|
+
...axis?.align !== void 0 ? { align: axis.align } : {},
|
|
9322
|
+
...axis?.offset !== void 0 ? { offset: axis.offset } : {}
|
|
9323
|
+
};
|
|
9324
|
+
}
|
|
9325
|
+
function drawingContentKind(content) {
|
|
9326
|
+
if (content.type === "picture") return "picture";
|
|
9327
|
+
if (content.type === "shape") {
|
|
9328
|
+
return content.isTextBox || content.txbxBlocks || content.txbxContentXml ? "textbox" : "shape";
|
|
9329
|
+
}
|
|
9330
|
+
if (content.type === "chart_preview") return "chart";
|
|
9331
|
+
if (content.type === "smartart_preview") return "smartart";
|
|
9332
|
+
return "opaque";
|
|
9333
|
+
}
|
|
9334
|
+
function drawingEditPosture(node) {
|
|
9335
|
+
if (node.content.type === "picture" && !node.content.isLinked) return "editable";
|
|
9336
|
+
if (node.content.type === "opaque") return "preserve-only";
|
|
9337
|
+
return "read-only-preview";
|
|
9338
|
+
}
|
|
9339
|
+
function collectScopeLayoutInputsForStory(context) {
|
|
9340
|
+
const occurrences = [];
|
|
9341
|
+
walkBlocks(context.blocks, context.storyKey, context.basePath, {
|
|
9342
|
+
inline(inline, blockPath, inlinePath) {
|
|
9343
|
+
if (inline.type !== "scope_marker_start" && inline.type !== "scope_marker_end") {
|
|
9344
|
+
return;
|
|
9345
|
+
}
|
|
9346
|
+
occurrences.push({
|
|
9347
|
+
scopeId: inline.scopeId,
|
|
9348
|
+
markerType: inline.type === "scope_marker_start" ? "start" : "end",
|
|
9349
|
+
markerIndex: occurrences.length,
|
|
9350
|
+
blockPath,
|
|
9351
|
+
inlinePath
|
|
9352
|
+
});
|
|
9353
|
+
}
|
|
9354
|
+
});
|
|
9355
|
+
const open = /* @__PURE__ */ new Map();
|
|
9356
|
+
const scopes = [];
|
|
9357
|
+
for (const marker of occurrences) {
|
|
9358
|
+
if (marker.markerType === "start") {
|
|
9359
|
+
const stack2 = open.get(marker.scopeId) ?? [];
|
|
9360
|
+
stack2.push(marker);
|
|
9361
|
+
open.set(marker.scopeId, stack2);
|
|
9362
|
+
continue;
|
|
9363
|
+
}
|
|
9364
|
+
const stack = open.get(marker.scopeId);
|
|
9365
|
+
const opener = stack?.pop();
|
|
9366
|
+
if (stack && stack.length === 0) {
|
|
9367
|
+
open.delete(marker.scopeId);
|
|
9368
|
+
}
|
|
9369
|
+
if (opener) {
|
|
9370
|
+
scopes.push(createScopeLayoutInput(context.storyKey, "paired", opener, marker));
|
|
9371
|
+
continue;
|
|
9372
|
+
}
|
|
9373
|
+
scopes.push(createScopeLayoutInput(context.storyKey, "end-only", void 0, marker));
|
|
9374
|
+
}
|
|
9375
|
+
for (const stack of open.values()) {
|
|
9376
|
+
for (const opener of stack) {
|
|
9377
|
+
scopes.push(createScopeLayoutInput(context.storyKey, "start-only", opener, void 0));
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9380
|
+
return scopes.sort(
|
|
9381
|
+
(left, right) => (left.start?.markerIndex ?? left.end?.markerIndex ?? Number.MAX_SAFE_INTEGER) - (right.start?.markerIndex ?? right.end?.markerIndex ?? Number.MAX_SAFE_INTEGER) || left.scopeId.localeCompare(right.scopeId)
|
|
9382
|
+
);
|
|
9383
|
+
}
|
|
9384
|
+
function createScopeLayoutInput(storyKey, status, start, end) {
|
|
9385
|
+
const scopeId = start?.scopeId ?? end?.scopeId ?? "";
|
|
9386
|
+
const keyIndex = start?.markerIndex ?? end?.markerIndex ?? 0;
|
|
9387
|
+
return {
|
|
9388
|
+
scopeKey: `${storyKey}:scope:${scopeId}:${keyIndex}`,
|
|
9389
|
+
scopeId,
|
|
9390
|
+
storyKey,
|
|
9391
|
+
status,
|
|
9392
|
+
source: "canonical-marker",
|
|
9393
|
+
...start !== void 0 ? { start: createScopeMarkerReference(storyKey, start) } : {},
|
|
9394
|
+
...end !== void 0 ? { end: createScopeMarkerReference(storyKey, end) } : {}
|
|
9395
|
+
};
|
|
9396
|
+
}
|
|
9397
|
+
function createScopeMarkerReference(storyKey, marker) {
|
|
9398
|
+
return {
|
|
9399
|
+
markerKey: `${storyKey}:scope-marker:${marker.scopeId}:${marker.markerIndex}`,
|
|
9400
|
+
blockPath: marker.blockPath,
|
|
9401
|
+
inlinePath: marker.inlinePath,
|
|
9402
|
+
markerIndex: marker.markerIndex
|
|
9403
|
+
};
|
|
9404
|
+
}
|
|
9405
|
+
function countSections(doc) {
|
|
9406
|
+
let explicitBreaks = 0;
|
|
9407
|
+
for (const block of doc.content.children) {
|
|
9408
|
+
if (block.type === "section_break") explicitBreaks += 1;
|
|
9409
|
+
}
|
|
9410
|
+
return explicitBreaks + 1;
|
|
9411
|
+
}
|
|
9412
|
+
function collectHeaderFooterBindings(doc, kind, relationshipId, variant, fallbackSectionIndex, sectionCount) {
|
|
9413
|
+
const bound = /* @__PURE__ */ new Set();
|
|
9414
|
+
const explicit = /* @__PURE__ */ new Set();
|
|
9415
|
+
const inherited = /* @__PURE__ */ new Set();
|
|
9416
|
+
const effectiveByVariant = /* @__PURE__ */ new Map();
|
|
9417
|
+
const sectionProperties = collectSectionProperties(doc);
|
|
9418
|
+
for (let sectionIndex = 0; sectionIndex < sectionCount; sectionIndex += 1) {
|
|
9419
|
+
const properties = sectionProperties[sectionIndex];
|
|
9420
|
+
const refs = getHeaderFooterReferences(properties, kind);
|
|
9421
|
+
const hasRequestedVariant = refs.some((ref) => ref.variant === variant);
|
|
9422
|
+
if (!hasRequestedVariant && effectiveByVariant.get(variant) === relationshipId) {
|
|
9423
|
+
inherited.add(sectionIndex);
|
|
9424
|
+
bound.add(sectionIndex);
|
|
9425
|
+
}
|
|
9426
|
+
if (refs.some(
|
|
9427
|
+
(ref) => ref.relationshipId === relationshipId && ref.variant === variant
|
|
9428
|
+
)) {
|
|
9429
|
+
explicit.add(sectionIndex);
|
|
9430
|
+
bound.add(sectionIndex);
|
|
9431
|
+
}
|
|
9432
|
+
for (const ref of refs) {
|
|
9433
|
+
effectiveByVariant.set(ref.variant, ref.relationshipId);
|
|
9434
|
+
}
|
|
9435
|
+
}
|
|
9436
|
+
if (fallbackSectionIndex !== void 0) {
|
|
9437
|
+
bound.add(fallbackSectionIndex);
|
|
9438
|
+
} else if (bound.size === 0) {
|
|
9439
|
+
for (let sectionIndex = 0; sectionIndex < sectionCount; sectionIndex += 1) {
|
|
9440
|
+
bound.add(sectionIndex);
|
|
9441
|
+
}
|
|
9442
|
+
}
|
|
9443
|
+
return {
|
|
9444
|
+
boundSectionIndexes: sortIndexes(bound),
|
|
9445
|
+
explicitSectionIndexes: sortIndexes(explicit),
|
|
9446
|
+
inheritedSectionIndexes: sortIndexes(inherited)
|
|
9447
|
+
};
|
|
9448
|
+
}
|
|
9449
|
+
function collectSectionProperties(doc) {
|
|
9450
|
+
const sectionProperties = doc.content.children.filter((block) => block.type === "section_break").map((block) => block.sectionProperties);
|
|
9451
|
+
sectionProperties.push(doc.subParts?.finalSectionProperties);
|
|
9452
|
+
return sectionProperties;
|
|
9453
|
+
}
|
|
9454
|
+
function getHeaderFooterReferences(properties, kind) {
|
|
9455
|
+
return (kind === "header" ? properties?.headerReferences : properties?.footerReferences) ?? [];
|
|
9456
|
+
}
|
|
9457
|
+
function sortIndexes(indexes) {
|
|
9458
|
+
return [...indexes].sort((left, right) => left - right);
|
|
9459
|
+
}
|
|
8234
9460
|
|
|
8235
9461
|
// src/preservation/store.ts
|
|
8236
9462
|
var BLOCKED_IMPORT_FEATURE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -10654,7 +11880,7 @@ function createEditorSurfaceSnapshot(document2, _selection, activeStory = { kind
|
|
|
10654
11880
|
...options.getEffectiveMarkupMode ? { getEffectiveMarkupMode: options.getEffectiveMarkupMode } : {},
|
|
10655
11881
|
...options.authorColorPalette ? { authorColorPalette: options.authorColorPalette } : {}
|
|
10656
11882
|
});
|
|
10657
|
-
const editableTargetsByBlockPath = indexEditableTargetsByBlockPath(document2);
|
|
11883
|
+
const editableTargetsByBlockPath = options.editableTargetsByBlockPath ?? indexEditableTargetsByBlockPath(document2);
|
|
10658
11884
|
const activeStoryBlockPathBase = getActiveStoryBlockPathBase(document2, activeStory);
|
|
10659
11885
|
chartModelStore.beginBuildPass(document2);
|
|
10660
11886
|
const unsupportedNumberingFormatsSeen = options.emitFormattingTelemetry ? /* @__PURE__ */ new Set() : null;
|
|
@@ -10935,6 +12161,7 @@ function createTableBlock(tableIndex, table, document2, cursor, counters, format
|
|
|
10935
12161
|
from: cursor,
|
|
10936
12162
|
to: innerCursor,
|
|
10937
12163
|
styleId: table.styleId,
|
|
12164
|
+
...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
|
|
10938
12165
|
gridColumns: table.gridColumns,
|
|
10939
12166
|
rows: []
|
|
10940
12167
|
},
|
|
@@ -11004,6 +12231,7 @@ function createTableBlock(tableIndex, table, document2, cursor, counters, format
|
|
|
11004
12231
|
resolvedTable.table?.cellMargins
|
|
11005
12232
|
);
|
|
11006
12233
|
cells.push({
|
|
12234
|
+
...cell.sourceRef !== void 0 ? { sourceRef: cell.sourceRef } : {},
|
|
11007
12235
|
gridSpan: cell.gridSpan ?? 1,
|
|
11008
12236
|
verticalMerge: cell.verticalMerge ?? null,
|
|
11009
12237
|
colspan: cell.gridSpan ?? 1,
|
|
@@ -11027,6 +12255,7 @@ function createTableBlock(tableIndex, table, document2, cursor, counters, format
|
|
|
11027
12255
|
}
|
|
11028
12256
|
const headerLike = row.isHeader === true || resolvedRow?.style.isHeader === true;
|
|
11029
12257
|
rows.push({
|
|
12258
|
+
...row.sourceRef !== void 0 ? { sourceRef: row.sourceRef } : {},
|
|
11030
12259
|
cells,
|
|
11031
12260
|
...row.gridBefore !== void 0 ? { gridBefore: row.gridBefore } : {},
|
|
11032
12261
|
...row.gridAfter !== void 0 ? { gridAfter: row.gridAfter } : {},
|
|
@@ -11057,6 +12286,7 @@ function createTableBlock(tableIndex, table, document2, cursor, counters, format
|
|
|
11057
12286
|
from: cursor,
|
|
11058
12287
|
to: innerCursor,
|
|
11059
12288
|
styleId: table.styleId,
|
|
12289
|
+
...table.sourceRef !== void 0 ? { sourceRef: table.sourceRef } : {},
|
|
11060
12290
|
gridColumns: table.gridColumns,
|
|
11061
12291
|
...gridColumnsRelative ? { gridColumnsRelative } : {},
|
|
11062
12292
|
...resolvedTable.table?.alignment ? { alignment: resolvedTable.table.alignment } : {},
|
|
@@ -11601,6 +12831,7 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
|
|
|
11601
12831
|
const anchor = surfaceAnchorFromGeometry(node.anchor);
|
|
11602
12832
|
const txbxTextSegment = c.isTextBox ? extractTxbxFirstTextSegment(c.txbxBlocks) : void 0;
|
|
11603
12833
|
const txbxText = txbxTextSegment?.text ?? (c.isTextBox ? c.text : void 0);
|
|
12834
|
+
const txbxBody = c.isTextBox ? surfaceTextBoxBodyFromShape(c, node.sourceRef) : void 0;
|
|
11604
12835
|
const surfaceFill = c.fill;
|
|
11605
12836
|
paragraph.segments.push({
|
|
11606
12837
|
segmentId: `${paragraph.blockId}-segment-${paragraph.segments.length}`,
|
|
@@ -11617,6 +12848,7 @@ function appendInlineSegments(paragraph, node, document2, start, promoteSecondar
|
|
|
11617
12848
|
...c.textBoxBody ? { textBoxBody: c.textBoxBody } : {},
|
|
11618
12849
|
...c.preserveOnlyObject ? { preserveOnlyObject: surfacePreserveOnlyObject(c.preserveOnlyObject) } : {},
|
|
11619
12850
|
...txbxText ? { txbxText } : {},
|
|
12851
|
+
...txbxBody ? { txbxBody } : {},
|
|
11620
12852
|
...txbxTextSegment?.marks && txbxTextSegment.marks.length > 0 ? { txbxMarks: txbxTextSegment.marks } : {},
|
|
11621
12853
|
...txbxTextSegment?.markAttrs ? { txbxMarkAttrs: txbxTextSegment.markAttrs } : {}
|
|
11622
12854
|
});
|
|
@@ -12029,6 +13261,97 @@ function extractTxbxFirstTextSegment(blocks) {
|
|
|
12029
13261
|
}
|
|
12030
13262
|
return void 0;
|
|
12031
13263
|
}
|
|
13264
|
+
function surfaceTextBoxBodyFromShape(shape, sourceRef) {
|
|
13265
|
+
if (!shape.isTextBox && shape.txbxContentXml === void 0 && shape.txbxBlocks === void 0) {
|
|
13266
|
+
return void 0;
|
|
13267
|
+
}
|
|
13268
|
+
if (shape.txbxBlocks === void 0) {
|
|
13269
|
+
return {
|
|
13270
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
13271
|
+
status: shape.txbxContentXml !== void 0 ? "preserve-only" : "unavailable",
|
|
13272
|
+
unavailableReason: "txbx-blocks-unavailable",
|
|
13273
|
+
...shape.textBoxBody !== void 0 ? { bodyProperties: shape.textBoxBody } : {},
|
|
13274
|
+
blockCount: 0,
|
|
13275
|
+
paragraphCount: 0,
|
|
13276
|
+
unsupportedBlockCount: 0,
|
|
13277
|
+
paragraphs: []
|
|
13278
|
+
};
|
|
13279
|
+
}
|
|
13280
|
+
const paragraphs = shape.txbxBlocks.flatMap((block, blockIndex) => {
|
|
13281
|
+
if (block.type !== "paragraph") return [];
|
|
13282
|
+
const children = block.children;
|
|
13283
|
+
const legacyRuns = block.runs;
|
|
13284
|
+
const runs = children !== void 0 ? children.map(
|
|
13285
|
+
(inline, inlineIndex) => surfaceTextBoxRunFromInline(inline, inlineIndex)
|
|
13286
|
+
) : legacyRuns?.map(
|
|
13287
|
+
(run, inlineIndex) => surfaceTextBoxRunFromLegacyRun(run, inlineIndex)
|
|
13288
|
+
) ?? [];
|
|
13289
|
+
const text = runs.map((run) => run.text ?? "").join("");
|
|
13290
|
+
return [{
|
|
13291
|
+
...block.sourceRef !== void 0 ? { sourceRef: block.sourceRef } : {},
|
|
13292
|
+
blockIndex,
|
|
13293
|
+
text,
|
|
13294
|
+
textLength: Array.from(text).length,
|
|
13295
|
+
...block.borders !== void 0 ? { borders: block.borders } : {},
|
|
13296
|
+
runs
|
|
13297
|
+
}];
|
|
13298
|
+
});
|
|
13299
|
+
const unsupportedBlockCount = shape.txbxBlocks.length - paragraphs.length;
|
|
13300
|
+
const unavailableReason = shape.txbxBlocks.length === 0 ? "empty-body" : paragraphs.length === 0 ? "unsupported-content" : void 0;
|
|
13301
|
+
return {
|
|
13302
|
+
...sourceRef !== void 0 ? { sourceRef } : {},
|
|
13303
|
+
status: unavailableReason === void 0 ? "modeled" : "unavailable",
|
|
13304
|
+
...unavailableReason !== void 0 ? { unavailableReason } : {},
|
|
13305
|
+
...shape.textBoxBody !== void 0 ? { bodyProperties: shape.textBoxBody } : {},
|
|
13306
|
+
blockCount: shape.txbxBlocks.length,
|
|
13307
|
+
paragraphCount: paragraphs.length,
|
|
13308
|
+
unsupportedBlockCount,
|
|
13309
|
+
paragraphs
|
|
13310
|
+
};
|
|
13311
|
+
}
|
|
13312
|
+
function surfaceTextBoxRunFromLegacyRun(run, inlineIndex) {
|
|
13313
|
+
const text = run.text ?? "";
|
|
13314
|
+
const cloned = run.marks ? cloneMarks2(run.marks) : void 0;
|
|
13315
|
+
return {
|
|
13316
|
+
inlineIndex,
|
|
13317
|
+
kind: "text",
|
|
13318
|
+
text,
|
|
13319
|
+
textLength: Array.from(text).length,
|
|
13320
|
+
...cloned?.marks && cloned.marks.length > 0 ? { marks: cloned.marks } : {},
|
|
13321
|
+
...cloned?.markAttrs ? { markAttrs: cloned.markAttrs } : {}
|
|
13322
|
+
};
|
|
13323
|
+
}
|
|
13324
|
+
function surfaceTextBoxRunFromInline(inline, inlineIndex) {
|
|
13325
|
+
if (inline.type === "text") {
|
|
13326
|
+
const cloned = inline.marks ? cloneMarks2(inline.marks) : void 0;
|
|
13327
|
+
return {
|
|
13328
|
+
inlineIndex,
|
|
13329
|
+
kind: "text",
|
|
13330
|
+
text: inline.text,
|
|
13331
|
+
textLength: Array.from(inline.text).length,
|
|
13332
|
+
...cloned?.marks && cloned.marks.length > 0 ? { marks: cloned.marks } : {},
|
|
13333
|
+
...cloned?.markAttrs ? { markAttrs: cloned.markAttrs } : {}
|
|
13334
|
+
};
|
|
13335
|
+
}
|
|
13336
|
+
if (inline.type === "tab") {
|
|
13337
|
+
return { inlineIndex, kind: "tab", text: " ", textLength: 1 };
|
|
13338
|
+
}
|
|
13339
|
+
if (inline.type === "hard_break") {
|
|
13340
|
+
return { inlineIndex, kind: "hard-break", text: "\n", textLength: 1 };
|
|
13341
|
+
}
|
|
13342
|
+
if (inline.type === "symbol") {
|
|
13343
|
+
const cloned = inline.marks ? cloneMarks2(inline.marks) : void 0;
|
|
13344
|
+
return {
|
|
13345
|
+
inlineIndex,
|
|
13346
|
+
kind: "symbol",
|
|
13347
|
+
text: inline.char,
|
|
13348
|
+
textLength: Array.from(inline.char).length,
|
|
13349
|
+
...cloned?.marks && cloned.marks.length > 0 ? { marks: cloned.marks } : {},
|
|
13350
|
+
...cloned?.markAttrs ? { markAttrs: cloned.markAttrs } : {}
|
|
13351
|
+
};
|
|
13352
|
+
}
|
|
13353
|
+
return { inlineIndex, kind: "unsupported" };
|
|
13354
|
+
}
|
|
12032
13355
|
function appendComplexPreviewSegment(paragraph, node, start, label, detail, extras = {}) {
|
|
12033
13356
|
const preserveOnlyObject = node.preserveOnlyObject ? surfacePreserveOnlyObject(node.preserveOnlyObject) : void 0;
|
|
12034
13357
|
paragraph.segments.push({
|
|
@@ -15160,6 +16483,7 @@ var PAGE_INSTANCE_FIELD_FAMILIES = /* @__PURE__ */ new Set([
|
|
|
15160
16483
|
"NUMPAGES",
|
|
15161
16484
|
"SECTIONPAGES"
|
|
15162
16485
|
]);
|
|
16486
|
+
var MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS = 140;
|
|
15163
16487
|
var EMUS_PER_TWIP = 635;
|
|
15164
16488
|
function buildPageGraph(inputOrPages, sectionsArg, storiesArg) {
|
|
15165
16489
|
const input = Array.isArray(inputOrPages) ? {
|
|
@@ -15472,6 +16796,8 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
|
|
|
15472
16796
|
layout,
|
|
15473
16797
|
pageFieldCounts
|
|
15474
16798
|
}) : [];
|
|
16799
|
+
const previewParts = source ? collectPageLocalStoryPreviewParts(source.blocks, storyKey) : [];
|
|
16800
|
+
const previewText = renderPageLocalStoryPreviewText(previewParts, resolvedFields);
|
|
15475
16801
|
const objectLedger = source ? collectStoryAnchoredObjects(source.blocks, {
|
|
15476
16802
|
frameId,
|
|
15477
16803
|
storyKey,
|
|
@@ -15486,6 +16812,7 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
|
|
|
15486
16812
|
relationshipId: target.relationshipId,
|
|
15487
16813
|
sectionPart,
|
|
15488
16814
|
measuredFrameHeightTwips,
|
|
16815
|
+
previewText,
|
|
15489
16816
|
resolvedFields,
|
|
15490
16817
|
anchoredObjects: objectLedger.objects
|
|
15491
16818
|
});
|
|
@@ -15499,6 +16826,8 @@ function buildPageLocalStoryInstance(frameId, pageId, pageIndex, sectionIndex, d
|
|
|
15499
16826
|
relationshipId: target.relationshipId,
|
|
15500
16827
|
...target.sectionIndex === void 0 ? {} : { sectionIndex: target.sectionIndex },
|
|
15501
16828
|
resolvedFields,
|
|
16829
|
+
previewText,
|
|
16830
|
+
previewParts,
|
|
15502
16831
|
anchoredObjects: objectLedger.objects,
|
|
15503
16832
|
measuredFrameHeightTwips,
|
|
15504
16833
|
signature
|
|
@@ -15514,6 +16843,7 @@ function buildPageLocalStorySignature(input) {
|
|
|
15514
16843
|
input.relationshipId,
|
|
15515
16844
|
input.sectionPart,
|
|
15516
16845
|
input.measuredFrameHeightTwips,
|
|
16846
|
+
input.previewText,
|
|
15517
16847
|
...input.resolvedFields.map(
|
|
15518
16848
|
(field) => [field.fieldId, field.family, field.displayText].join(":")
|
|
15519
16849
|
),
|
|
@@ -15604,6 +16934,74 @@ function collectResolvedStoryFields(blocks, context) {
|
|
|
15604
16934
|
for (const block of blocks) visitBlock(block);
|
|
15605
16935
|
return fields;
|
|
15606
16936
|
}
|
|
16937
|
+
function collectPageLocalStoryPreviewParts(blocks, storyKey) {
|
|
16938
|
+
const parts = [];
|
|
16939
|
+
let pageFieldOrdinal = 0;
|
|
16940
|
+
const visitBlock = (block) => {
|
|
16941
|
+
switch (block.type) {
|
|
16942
|
+
case "paragraph":
|
|
16943
|
+
for (const child of block.children) visitInline(child);
|
|
16944
|
+
parts.push({ kind: "text", text: " " });
|
|
16945
|
+
break;
|
|
16946
|
+
case "table":
|
|
16947
|
+
for (const row of block.rows) {
|
|
16948
|
+
for (const cell of row.cells) {
|
|
16949
|
+
for (const childBlock of cell.children) visitBlock(childBlock);
|
|
16950
|
+
}
|
|
16951
|
+
}
|
|
16952
|
+
break;
|
|
16953
|
+
case "sdt":
|
|
16954
|
+
for (const child of block.children) visitBlock(child);
|
|
16955
|
+
break;
|
|
16956
|
+
default:
|
|
16957
|
+
break;
|
|
16958
|
+
}
|
|
16959
|
+
};
|
|
16960
|
+
const visitInline = (inline) => {
|
|
16961
|
+
switch (inline.type) {
|
|
16962
|
+
case "text":
|
|
16963
|
+
parts.push({ kind: "text", text: inline.text });
|
|
16964
|
+
break;
|
|
16965
|
+
case "tab":
|
|
16966
|
+
case "hard_break":
|
|
16967
|
+
parts.push({ kind: "text", text: " " });
|
|
16968
|
+
break;
|
|
16969
|
+
case "field": {
|
|
16970
|
+
const family = inline.fieldFamily ?? classifyFieldInstructionLocal(inline.instruction);
|
|
16971
|
+
const fallbackText = flattenInline(inline.children);
|
|
16972
|
+
if (PAGE_INSTANCE_FIELD_FAMILIES.has(family)) {
|
|
16973
|
+
parts.push({
|
|
16974
|
+
kind: "field",
|
|
16975
|
+
fieldId: `${storyKey}:field-${pageFieldOrdinal}:${family}`,
|
|
16976
|
+
fallbackText
|
|
16977
|
+
});
|
|
16978
|
+
pageFieldOrdinal += 1;
|
|
16979
|
+
} else {
|
|
16980
|
+
parts.push({ kind: "text", text: fallbackText });
|
|
16981
|
+
}
|
|
16982
|
+
break;
|
|
16983
|
+
}
|
|
16984
|
+
case "hyperlink":
|
|
16985
|
+
for (const child of inline.children) visitInline(child);
|
|
16986
|
+
break;
|
|
16987
|
+
default:
|
|
16988
|
+
break;
|
|
16989
|
+
}
|
|
16990
|
+
};
|
|
16991
|
+
for (const block of blocks) visitBlock(block);
|
|
16992
|
+
return parts;
|
|
16993
|
+
}
|
|
16994
|
+
function renderPageLocalStoryPreviewText(parts, resolvedFields) {
|
|
16995
|
+
const fieldsById = new Map(resolvedFields.map((field) => [field.fieldId, field]));
|
|
16996
|
+
const text = parts.map(
|
|
16997
|
+
(part) => part.kind === "field" ? fieldsById.get(part.fieldId)?.displayText ?? part.fallbackText : part.text
|
|
16998
|
+
).join("").replace(/\s+/g, " ").trim();
|
|
16999
|
+
return truncatePageLocalStoryPreview(text);
|
|
17000
|
+
}
|
|
17001
|
+
function truncatePageLocalStoryPreview(text) {
|
|
17002
|
+
if (text.length <= MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS) return text;
|
|
17003
|
+
return `${text.slice(0, MAX_PAGE_LOCAL_STORY_PREVIEW_CHARS - 1).trimEnd()}\u2026`;
|
|
17004
|
+
}
|
|
15607
17005
|
function collectStoryAnchoredObjects(blocks, context) {
|
|
15608
17006
|
const objects = [];
|
|
15609
17007
|
const divergences = [];
|
|
@@ -16004,6 +17402,7 @@ function freezeRuntimePageGraph(graph) {
|
|
|
16004
17402
|
for (const page of graph.pages) {
|
|
16005
17403
|
freezePageNode(page);
|
|
16006
17404
|
}
|
|
17405
|
+
for (const fragment of graph.fragments) freezeBlockFragment(fragment);
|
|
16007
17406
|
Object.freeze(graph.pages);
|
|
16008
17407
|
Object.freeze(graph.fragments);
|
|
16009
17408
|
Object.freeze(graph.anchors);
|
|
@@ -16018,6 +17417,64 @@ function freezePageNode(page) {
|
|
|
16018
17417
|
Object.freeze(page.noteAllocations);
|
|
16019
17418
|
Object.freeze(page);
|
|
16020
17419
|
}
|
|
17420
|
+
function freezeBlockFragment(fragment) {
|
|
17421
|
+
if (fragment.layoutObject) {
|
|
17422
|
+
Object.freeze(fragment.layoutObject.measuredExtentTwips);
|
|
17423
|
+
if (fragment.layoutObject.fieldFamilies) Object.freeze(fragment.layoutObject.fieldFamilies);
|
|
17424
|
+
if (fragment.layoutObject.fieldRegions) {
|
|
17425
|
+
for (const region of fragment.layoutObject.fieldRegions) {
|
|
17426
|
+
if (region.resultRange) Object.freeze(region.resultRange);
|
|
17427
|
+
if (region.sourceRef) Object.freeze(region.sourceRef);
|
|
17428
|
+
if (region.fieldEvidence?.sourceRef) Object.freeze(region.fieldEvidence.sourceRef);
|
|
17429
|
+
if (region.fieldEvidence) Object.freeze(region.fieldEvidence);
|
|
17430
|
+
Object.freeze(region);
|
|
17431
|
+
}
|
|
17432
|
+
Object.freeze(fragment.layoutObject.fieldRegions);
|
|
17433
|
+
}
|
|
17434
|
+
if (fragment.layoutObject.bookmarkRanges) {
|
|
17435
|
+
for (const range of fragment.layoutObject.bookmarkRanges) {
|
|
17436
|
+
if (range.sourceRef) Object.freeze(range.sourceRef);
|
|
17437
|
+
if (range.startSourceRef) Object.freeze(range.startSourceRef);
|
|
17438
|
+
if (range.endSourceRef) Object.freeze(range.endSourceRef);
|
|
17439
|
+
Object.freeze(range);
|
|
17440
|
+
}
|
|
17441
|
+
Object.freeze(fragment.layoutObject.bookmarkRanges);
|
|
17442
|
+
}
|
|
17443
|
+
if (fragment.layoutObject.hyperlinks) {
|
|
17444
|
+
for (const hyperlink of fragment.layoutObject.hyperlinks) {
|
|
17445
|
+
if (hyperlink.sourceRef) Object.freeze(hyperlink.sourceRef);
|
|
17446
|
+
Object.freeze(hyperlink);
|
|
17447
|
+
}
|
|
17448
|
+
Object.freeze(fragment.layoutObject.hyperlinks);
|
|
17449
|
+
}
|
|
17450
|
+
if (fragment.layoutObject.numbering) freezeNumberingLayoutFacts(fragment.layoutObject.numbering);
|
|
17451
|
+
if (fragment.layoutObject.numberingRows) {
|
|
17452
|
+
for (const numbering of fragment.layoutObject.numberingRows) {
|
|
17453
|
+
freezeNumberingLayoutFacts(numbering);
|
|
17454
|
+
}
|
|
17455
|
+
Object.freeze(fragment.layoutObject.numberingRows);
|
|
17456
|
+
}
|
|
17457
|
+
Object.freeze(fragment.layoutObject);
|
|
17458
|
+
}
|
|
17459
|
+
if (fragment.paragraphLineRange) Object.freeze(fragment.paragraphLineRange);
|
|
17460
|
+
if (fragment.tableRowRange) Object.freeze(fragment.tableRowRange);
|
|
17461
|
+
if (fragment.continuation) Object.freeze(fragment.continuation);
|
|
17462
|
+
Object.freeze(fragment);
|
|
17463
|
+
}
|
|
17464
|
+
function freezeNumberingLayoutFacts(numbering) {
|
|
17465
|
+
if (!numbering) return;
|
|
17466
|
+
if (numbering.sourceRef) Object.freeze(numbering.sourceRef);
|
|
17467
|
+
if (numbering.numberingSourceRef) Object.freeze(numbering.numberingSourceRef);
|
|
17468
|
+
if (numbering.numberingInstanceSourceRef) Object.freeze(numbering.numberingInstanceSourceRef);
|
|
17469
|
+
if (numbering.abstractNumberingSourceRef) Object.freeze(numbering.abstractNumberingSourceRef);
|
|
17470
|
+
if (numbering.markerLane) Object.freeze(numbering.markerLane);
|
|
17471
|
+
if (numbering.textColumn) Object.freeze(numbering.textColumn);
|
|
17472
|
+
if (numbering.tabStops) {
|
|
17473
|
+
for (const tab of numbering.tabStops) Object.freeze(tab);
|
|
17474
|
+
Object.freeze(numbering.tabStops);
|
|
17475
|
+
}
|
|
17476
|
+
Object.freeze(numbering);
|
|
17477
|
+
}
|
|
16021
17478
|
function freezePageRegions(regions) {
|
|
16022
17479
|
freezePageRegion(regions.body);
|
|
16023
17480
|
if (regions.header) freezePageRegion(regions.header);
|
|
@@ -16040,6 +17497,12 @@ function freezePageRegion(region) {
|
|
|
16040
17497
|
function freezePageFrame(frame) {
|
|
16041
17498
|
Object.freeze(frame.physicalBoundsTwips);
|
|
16042
17499
|
Object.freeze(frame.divergenceIds);
|
|
17500
|
+
for (const story of frame.pageLocalStories) {
|
|
17501
|
+
Object.freeze(story.resolvedFields);
|
|
17502
|
+
Object.freeze(story.previewParts);
|
|
17503
|
+
Object.freeze(story.anchoredObjects);
|
|
17504
|
+
Object.freeze(story);
|
|
17505
|
+
}
|
|
16043
17506
|
Object.freeze(frame.pageLocalStories);
|
|
16044
17507
|
Object.freeze(frame);
|
|
16045
17508
|
}
|
|
@@ -16073,16 +17536,22 @@ function normalizePageLocalStoryFieldsForPages(pages) {
|
|
|
16073
17536
|
return { ...field, displayText };
|
|
16074
17537
|
});
|
|
16075
17538
|
if (!storyChanged) return story;
|
|
17539
|
+
const previewText = renderPageLocalStoryPreviewText(
|
|
17540
|
+
story.previewParts,
|
|
17541
|
+
resolvedFields
|
|
17542
|
+
);
|
|
16076
17543
|
const sectionPart = story.sectionIndex === void 0 ? "section-unknown" : `section-${story.sectionIndex}`;
|
|
16077
17544
|
return {
|
|
16078
17545
|
...story,
|
|
16079
17546
|
resolvedFields,
|
|
17547
|
+
previewText,
|
|
16080
17548
|
signature: buildPageLocalStorySignature({
|
|
16081
17549
|
kind: story.kind,
|
|
16082
17550
|
variant: story.variant,
|
|
16083
17551
|
relationshipId: story.relationshipId,
|
|
16084
17552
|
sectionPart,
|
|
16085
17553
|
measuredFrameHeightTwips: story.measuredFrameHeightTwips,
|
|
17554
|
+
previewText,
|
|
16086
17555
|
resolvedFields,
|
|
16087
17556
|
anchoredObjects: story.anchoredObjects
|
|
16088
17557
|
})
|
|
@@ -16189,10 +17658,13 @@ function collectSplitRowCarryForPage(ranges, pageRangeIndex) {
|
|
|
16189
17658
|
}
|
|
16190
17659
|
|
|
16191
17660
|
// src/runtime/layout/project-block-fragments.ts
|
|
16192
|
-
function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlockIdByPageIndex, fragmentMeasurementsByPageIndex, fieldRegions = []) {
|
|
17661
|
+
function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlockIdByPageIndex, fragmentMeasurementsByPageIndex, fieldRegions = [], editableTargets = [], numberingInputs = []) {
|
|
16193
17662
|
const byPage = /* @__PURE__ */ new Map();
|
|
16194
17663
|
const perPageCounter = /* @__PURE__ */ new Map();
|
|
16195
17664
|
const fieldRegionsByParagraphIndex = buildFieldRegionsByParagraphIndex(fieldRegions);
|
|
17665
|
+
const generatedTargets = buildGeneratedTargets(editableTargets);
|
|
17666
|
+
const bookmarkRanges = buildBookmarkRanges(editableTargets);
|
|
17667
|
+
const numberingByParagraphIndex = buildNumberingByParagraphIndex(numberingInputs);
|
|
16196
17668
|
const pushFragment = (pageIndex, fragment) => {
|
|
16197
17669
|
const existing = byPage.get(pageIndex);
|
|
16198
17670
|
if (existing) {
|
|
@@ -16227,6 +17699,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
|
|
|
16227
17699
|
});
|
|
16228
17700
|
},
|
|
16229
17701
|
fieldRegionsByParagraphIndex,
|
|
17702
|
+
generatedTargets,
|
|
17703
|
+
bookmarkRanges,
|
|
17704
|
+
numberingByParagraphIndex,
|
|
16230
17705
|
blockPath
|
|
16231
17706
|
);
|
|
16232
17707
|
continue;
|
|
@@ -16246,6 +17721,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
|
|
|
16246
17721
|
});
|
|
16247
17722
|
},
|
|
16248
17723
|
fieldRegionsByParagraphIndex,
|
|
17724
|
+
generatedTargets,
|
|
17725
|
+
bookmarkRanges,
|
|
17726
|
+
numberingByParagraphIndex,
|
|
16249
17727
|
blockPath
|
|
16250
17728
|
);
|
|
16251
17729
|
continue;
|
|
@@ -16276,6 +17754,9 @@ function projectSurfaceBlocksToPageFragments(surface, pages, splits, columnByBlo
|
|
|
16276
17754
|
widthTwips,
|
|
16277
17755
|
paginationRole: "whole",
|
|
16278
17756
|
fieldRegionsByParagraphIndex,
|
|
17757
|
+
generatedTargets,
|
|
17758
|
+
bookmarkRanges,
|
|
17759
|
+
numberingByParagraphIndex,
|
|
16279
17760
|
blockPath
|
|
16280
17761
|
}),
|
|
16281
17762
|
...columnIndex !== void 0 ? { columnIndex } : {}
|
|
@@ -16422,7 +17903,7 @@ function buildRunAnchorsForLine(input) {
|
|
|
16422
17903
|
}
|
|
16423
17904
|
return anchors;
|
|
16424
17905
|
}
|
|
16425
|
-
function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
|
|
17906
|
+
function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
|
|
16426
17907
|
for (let i = 0; i < slices.length; i += 1) {
|
|
16427
17908
|
const slice = slices[i];
|
|
16428
17909
|
const heightTwips = slice.heightTwips ?? estimateSliceHeightFromLines(slice.lineRange);
|
|
@@ -16446,6 +17927,9 @@ function emitSlicedParagraph(block, slices, emit, fieldRegionsByParagraphIndex =
|
|
|
16446
17927
|
widthTwips: slice.widthTwips,
|
|
16447
17928
|
paginationRole: slice.lineRange.from > 0 ? "continuation" : "slice",
|
|
16448
17929
|
fieldRegionsByParagraphIndex,
|
|
17930
|
+
generatedTargets,
|
|
17931
|
+
bookmarkRanges,
|
|
17932
|
+
numberingByParagraphIndex,
|
|
16449
17933
|
blockPath
|
|
16450
17934
|
})
|
|
16451
17935
|
};
|
|
@@ -16466,7 +17950,7 @@ function estimateSliceHeightFromLines(lineRange) {
|
|
|
16466
17950
|
const lines = Math.max(0, lineRange.to - lineRange.from);
|
|
16467
17951
|
return lines * 240;
|
|
16468
17952
|
}
|
|
16469
|
-
function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
|
|
17953
|
+
function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /* @__PURE__ */ new Map(), generatedTargets = [], bookmarkRanges = [], numberingByParagraphIndex = /* @__PURE__ */ new Map(), blockPath) {
|
|
16470
17954
|
for (let i = 0; i < slices.length; i += 1) {
|
|
16471
17955
|
const slice = slices[i];
|
|
16472
17956
|
const heightTwips = slice.heightTwips ?? estimateSliceHeightFromRows(slice.rowRange);
|
|
@@ -16489,6 +17973,9 @@ function emitSlicedTable(block, slices, emit, fieldRegionsByParagraphIndex = /*
|
|
|
16489
17973
|
heightTwips,
|
|
16490
17974
|
paginationRole: slice.rowRange.from > 0 ? "continuation" : "slice",
|
|
16491
17975
|
fieldRegionsByParagraphIndex,
|
|
17976
|
+
generatedTargets,
|
|
17977
|
+
bookmarkRanges,
|
|
17978
|
+
numberingByParagraphIndex,
|
|
16492
17979
|
blockPath
|
|
16493
17980
|
}),
|
|
16494
17981
|
...slice.columnIndex !== void 0 ? { columnIndex: slice.columnIndex } : {}
|
|
@@ -16559,13 +18046,27 @@ function estimateSliceHeightFromRows(rowRange) {
|
|
|
16559
18046
|
function buildFragmentLayoutObject(input) {
|
|
16560
18047
|
const fieldFamilies = collectFieldFamilies(input.block);
|
|
16561
18048
|
const kind = resolveFragmentLayoutObjectKind(input.block, fieldFamilies);
|
|
16562
|
-
const numberingRows = collectNumberingLayoutFactsForBlock(
|
|
18049
|
+
const numberingRows = collectNumberingLayoutFactsForBlock(
|
|
18050
|
+
input.block,
|
|
18051
|
+
input.blockPath,
|
|
18052
|
+
input.numberingByParagraphIndex
|
|
18053
|
+
);
|
|
16563
18054
|
const numbering = input.block.kind === "paragraph" ? numberingRows[0] : void 0;
|
|
16564
18055
|
const fieldRegions = collectFieldRegionLayoutFacts(
|
|
16565
18056
|
input.block,
|
|
16566
18057
|
input.fragmentId,
|
|
16567
18058
|
input.fieldRegionsByParagraphIndex
|
|
16568
18059
|
);
|
|
18060
|
+
const bookmarkRanges = collectBookmarkRangeLayoutFacts(
|
|
18061
|
+
input.fragmentId,
|
|
18062
|
+
input.blockPath,
|
|
18063
|
+
input.bookmarkRanges
|
|
18064
|
+
);
|
|
18065
|
+
const hyperlinks = collectHyperlinkLayoutFacts(
|
|
18066
|
+
input.fragmentId,
|
|
18067
|
+
input.blockPath,
|
|
18068
|
+
input.generatedTargets
|
|
18069
|
+
);
|
|
16569
18070
|
return {
|
|
16570
18071
|
objectId: `${kind}:${input.fragmentId}`,
|
|
16571
18072
|
kind,
|
|
@@ -16577,6 +18078,8 @@ function buildFragmentLayoutObject(input) {
|
|
|
16577
18078
|
},
|
|
16578
18079
|
...fieldFamilies.length > 0 ? { fieldFamilies } : {},
|
|
16579
18080
|
...fieldRegions.length > 0 ? { fieldRegions } : {},
|
|
18081
|
+
...bookmarkRanges.length > 0 ? { bookmarkRanges } : {},
|
|
18082
|
+
...hyperlinks.length > 0 ? { hyperlinks } : {},
|
|
16580
18083
|
...numbering ? { numbering } : {},
|
|
16581
18084
|
...numberingRows.length > 0 ? { numberingRows } : {}
|
|
16582
18085
|
};
|
|
@@ -16691,6 +18194,18 @@ function toRuntimeFieldRegionLayoutFacts(region, fieldRegionId) {
|
|
|
16691
18194
|
paragraphIndex: region.paragraphIndex,
|
|
16692
18195
|
fieldFamily: region.fieldFamily,
|
|
16693
18196
|
refreshStatus: region.refreshStatus,
|
|
18197
|
+
...region.tocId !== void 0 ? { tocId: region.tocId } : {},
|
|
18198
|
+
...region.sourcePath !== void 0 ? { sourcePath: region.sourcePath } : {},
|
|
18199
|
+
...region.parentKind !== void 0 ? { parentKind: region.parentKind } : {},
|
|
18200
|
+
...region.resultRange !== void 0 ? {
|
|
18201
|
+
resultRange: {
|
|
18202
|
+
fromParagraphIndex: region.resultRange.fromParagraphIndex,
|
|
18203
|
+
toParagraphIndex: region.resultRange.toParagraphIndex
|
|
18204
|
+
}
|
|
18205
|
+
} : {},
|
|
18206
|
+
...region.status !== void 0 ? { status: region.status } : {},
|
|
18207
|
+
...region.cachedEntryCount !== void 0 ? { cachedEntryCount: region.cachedEntryCount } : {},
|
|
18208
|
+
...region.generatedEntryCount !== void 0 ? { generatedEntryCount: region.generatedEntryCount } : {},
|
|
16694
18209
|
...region.sourceRef !== void 0 ? { sourceRef: { ...region.sourceRef } } : {},
|
|
16695
18210
|
...region.fieldEvidence !== void 0 ? {
|
|
16696
18211
|
fieldEvidence: {
|
|
@@ -16700,6 +18215,134 @@ function toRuntimeFieldRegionLayoutFacts(region, fieldRegionId) {
|
|
|
16700
18215
|
} : {}
|
|
16701
18216
|
};
|
|
16702
18217
|
}
|
|
18218
|
+
function buildGeneratedTargets(targets) {
|
|
18219
|
+
return targets.filter(
|
|
18220
|
+
(target) => target.kind === "field-result-text" || target.kind === "hyperlink-text" || target.kind === "hyperlink-destination" || target.kind === "bookmark-anchor" || target.kind === "bookmark-content-range"
|
|
18221
|
+
);
|
|
18222
|
+
}
|
|
18223
|
+
function buildBookmarkRanges(targets) {
|
|
18224
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
18225
|
+
const contentRanges = /* @__PURE__ */ new Map();
|
|
18226
|
+
for (const target of targets) {
|
|
18227
|
+
const bookmarkId = target.link?.bookmarkId;
|
|
18228
|
+
if (!bookmarkId) continue;
|
|
18229
|
+
const key = `${target.storyKey}:${bookmarkId}`;
|
|
18230
|
+
if (target.kind === "bookmark-content-range") {
|
|
18231
|
+
contentRanges.set(key, target);
|
|
18232
|
+
continue;
|
|
18233
|
+
}
|
|
18234
|
+
if (target.kind !== "bookmark-anchor") continue;
|
|
18235
|
+
const entry = anchors.get(key) ?? {};
|
|
18236
|
+
if (target.targetKey.includes(":bookmark:start:")) entry.start = target;
|
|
18237
|
+
else if (target.targetKey.includes(":bookmark:end:")) entry.end = target;
|
|
18238
|
+
anchors.set(key, entry);
|
|
18239
|
+
}
|
|
18240
|
+
const ranges = [];
|
|
18241
|
+
for (const [key, pair] of anchors) {
|
|
18242
|
+
if (!pair.start || !pair.end) continue;
|
|
18243
|
+
const startBlockPath = topLevelBlockPath(pair.start.blockPath);
|
|
18244
|
+
const endBlockPath = topLevelBlockPath(pair.end.blockPath);
|
|
18245
|
+
const startBlockIndex = parseTopLevelBlockIndex(startBlockPath);
|
|
18246
|
+
const endBlockIndex = parseTopLevelBlockIndex(endBlockPath);
|
|
18247
|
+
if (startBlockPath === void 0 || endBlockPath === void 0 || startBlockIndex === void 0 || endBlockIndex === void 0) {
|
|
18248
|
+
continue;
|
|
18249
|
+
}
|
|
18250
|
+
const contentRange = contentRanges.get(key);
|
|
18251
|
+
ranges.push({
|
|
18252
|
+
bookmarkId: pair.start.link?.bookmarkId ?? pair.end.link?.bookmarkId ?? key,
|
|
18253
|
+
...pair.start.link?.bookmarkName !== void 0 ? { bookmarkName: pair.start.link.bookmarkName } : {},
|
|
18254
|
+
storyKey: pair.start.storyKey,
|
|
18255
|
+
...contentRange?.link?.rangeKey !== void 0 ? { rangeKey: contentRange.link.rangeKey } : {},
|
|
18256
|
+
...contentRange?.targetKey !== void 0 ? { contentRangeTargetKey: contentRange.targetKey } : {},
|
|
18257
|
+
startTargetKey: pair.start.targetKey,
|
|
18258
|
+
endTargetKey: pair.end.targetKey,
|
|
18259
|
+
startBlockPath,
|
|
18260
|
+
endBlockPath,
|
|
18261
|
+
startBlockIndex,
|
|
18262
|
+
endBlockIndex,
|
|
18263
|
+
...cloneRuntimeSourceRef(contentRange?.sourceRef ?? pair.start.sourceRef) !== void 0 ? { sourceRef: cloneRuntimeSourceRef(contentRange?.sourceRef ?? pair.start.sourceRef) } : {},
|
|
18264
|
+
...cloneRuntimeSourceRef(pair.start.sourceRef) !== void 0 ? { startSourceRef: cloneRuntimeSourceRef(pair.start.sourceRef) } : {},
|
|
18265
|
+
...cloneRuntimeSourceRef(pair.end.sourceRef) !== void 0 ? { endSourceRef: cloneRuntimeSourceRef(pair.end.sourceRef) } : {}
|
|
18266
|
+
});
|
|
18267
|
+
}
|
|
18268
|
+
return ranges;
|
|
18269
|
+
}
|
|
18270
|
+
function buildNumberingByParagraphIndex(numberingInputs) {
|
|
18271
|
+
const byParagraph = /* @__PURE__ */ new Map();
|
|
18272
|
+
for (const input of numberingInputs) {
|
|
18273
|
+
if (!byParagraph.has(input.paragraphIndex)) {
|
|
18274
|
+
byParagraph.set(input.paragraphIndex, input);
|
|
18275
|
+
}
|
|
18276
|
+
}
|
|
18277
|
+
return byParagraph;
|
|
18278
|
+
}
|
|
18279
|
+
function collectBookmarkRangeLayoutFacts(fragmentId, blockPath, bookmarkRanges) {
|
|
18280
|
+
if (!blockPath || !bookmarkRanges || bookmarkRanges.length === 0) return [];
|
|
18281
|
+
const blockIndex = parseTopLevelBlockIndex(blockPath);
|
|
18282
|
+
if (blockIndex === void 0) return [];
|
|
18283
|
+
const facts = [];
|
|
18284
|
+
for (const range of bookmarkRanges) {
|
|
18285
|
+
const from = Math.min(range.startBlockIndex, range.endBlockIndex);
|
|
18286
|
+
const to = Math.max(range.startBlockIndex, range.endBlockIndex);
|
|
18287
|
+
if (blockIndex < from || blockIndex > to) continue;
|
|
18288
|
+
const startsHere = blockIndex === range.startBlockIndex;
|
|
18289
|
+
const endsHere = blockIndex === range.endBlockIndex;
|
|
18290
|
+
facts.push({
|
|
18291
|
+
bookmarkRangeId: `bookmark-range:${range.storyKey}:${range.bookmarkId}:${fragmentId}`,
|
|
18292
|
+
bookmarkId: range.bookmarkId,
|
|
18293
|
+
...range.bookmarkName !== void 0 ? { bookmarkName: range.bookmarkName } : {},
|
|
18294
|
+
storyKey: range.storyKey,
|
|
18295
|
+
rangeRole: startsHere && endsHere ? "whole" : startsHere ? "start" : endsHere ? "end" : "inside",
|
|
18296
|
+
startBlockPath: range.startBlockPath,
|
|
18297
|
+
endBlockPath: range.endBlockPath,
|
|
18298
|
+
...range.rangeKey !== void 0 ? { rangeKey: range.rangeKey } : {},
|
|
18299
|
+
...range.contentRangeTargetKey !== void 0 ? { contentRangeTargetKey: range.contentRangeTargetKey } : {},
|
|
18300
|
+
...range.startTargetKey !== void 0 ? { startTargetKey: range.startTargetKey } : {},
|
|
18301
|
+
...range.endTargetKey !== void 0 ? { endTargetKey: range.endTargetKey } : {},
|
|
18302
|
+
...range.sourceRef !== void 0 ? { sourceRef: { ...range.sourceRef } } : {},
|
|
18303
|
+
...range.startSourceRef !== void 0 ? { startSourceRef: { ...range.startSourceRef } } : {},
|
|
18304
|
+
...range.endSourceRef !== void 0 ? { endSourceRef: { ...range.endSourceRef } } : {}
|
|
18305
|
+
});
|
|
18306
|
+
}
|
|
18307
|
+
return facts;
|
|
18308
|
+
}
|
|
18309
|
+
function collectHyperlinkLayoutFacts(fragmentId, blockPath, targets) {
|
|
18310
|
+
if (!blockPath || !targets || targets.length === 0) return [];
|
|
18311
|
+
const facts = [];
|
|
18312
|
+
for (const target of targets) {
|
|
18313
|
+
if (target.kind !== "hyperlink-text" && target.kind !== "hyperlink-destination") continue;
|
|
18314
|
+
if (!pathParticipatesInBlock(target.blockPath, blockPath)) continue;
|
|
18315
|
+
const href = target.link?.href;
|
|
18316
|
+
facts.push({
|
|
18317
|
+
hyperlinkLayoutId: `hyperlink:${target.targetKey}:${fragmentId}`,
|
|
18318
|
+
targetKey: target.targetKey,
|
|
18319
|
+
storyKey: target.storyKey,
|
|
18320
|
+
blockPath: target.blockPath,
|
|
18321
|
+
leafPath: target.leafPath,
|
|
18322
|
+
role: target.kind === "hyperlink-text" ? "display-text" : "destination",
|
|
18323
|
+
...href !== void 0 ? { href } : {},
|
|
18324
|
+
...target.link?.destinationKind !== void 0 ? { destinationKind: target.link.destinationKind } : href?.startsWith("#") ? { destinationKind: "internal-anchor" } : href !== void 0 ? { destinationKind: "external" } : {},
|
|
18325
|
+
...target.link?.bookmarkName !== void 0 ? { targetBookmarkName: target.link.bookmarkName } : href?.startsWith("#") && href.length > 1 ? { targetBookmarkName: href.slice(1) } : {},
|
|
18326
|
+
...cloneRuntimeSourceRef(target.sourceRef) !== void 0 ? { sourceRef: cloneRuntimeSourceRef(target.sourceRef) } : {}
|
|
18327
|
+
});
|
|
18328
|
+
}
|
|
18329
|
+
return facts;
|
|
18330
|
+
}
|
|
18331
|
+
function pathParticipatesInBlock(targetPath, blockPath) {
|
|
18332
|
+
return targetPath === blockPath || targetPath.startsWith(`${blockPath}/`);
|
|
18333
|
+
}
|
|
18334
|
+
function topLevelBlockPath(path) {
|
|
18335
|
+
const match = /^(main\/block\[\d+\])(?:\/|$)/u.exec(path);
|
|
18336
|
+
return match?.[1];
|
|
18337
|
+
}
|
|
18338
|
+
function parseTopLevelBlockIndex(path) {
|
|
18339
|
+
if (!path) return void 0;
|
|
18340
|
+
const match = /^main\/block\[(\d+)\]$/u.exec(path);
|
|
18341
|
+
return match ? Number(match[1]) : void 0;
|
|
18342
|
+
}
|
|
18343
|
+
function cloneRuntimeSourceRef(sourceRef) {
|
|
18344
|
+
return sourceRef !== void 0 ? { ...sourceRef } : void 0;
|
|
18345
|
+
}
|
|
16703
18346
|
function collectNumberingLayoutFacts(block) {
|
|
16704
18347
|
if (block.kind !== "paragraph") return void 0;
|
|
16705
18348
|
if (!block.numbering && !block.resolvedNumbering && block.numberingPrefix === void 0) {
|
|
@@ -16739,13 +18382,14 @@ function collectNumberingLayoutFacts(block) {
|
|
|
16739
18382
|
} : {}
|
|
16740
18383
|
};
|
|
16741
18384
|
}
|
|
16742
|
-
function collectNumberingLayoutFactsForBlock(block, blockPath) {
|
|
18385
|
+
function collectNumberingLayoutFactsForBlock(block, blockPath, numberingByParagraphIndex) {
|
|
16743
18386
|
const rows = [];
|
|
16744
18387
|
const seen = /* @__PURE__ */ new Set();
|
|
16745
18388
|
visitParagraphBlocks(block, (paragraph, context) => {
|
|
16746
18389
|
const numbering = collectNumberingLayoutFacts(paragraph);
|
|
16747
18390
|
if (!numbering) return;
|
|
16748
18391
|
const paragraphIndex = parseParagraphBlockIndex(paragraph.blockId);
|
|
18392
|
+
const canonical = paragraphIndex !== void 0 ? numberingByParagraphIndex?.get(paragraphIndex) : void 0;
|
|
16749
18393
|
const numberingKey = context.path !== void 0 ? `main:${context.path}:numbering` : void 0;
|
|
16750
18394
|
const numberingLayoutId = numberingKey ?? [
|
|
16751
18395
|
"numbering",
|
|
@@ -16758,9 +18402,17 @@ function collectNumberingLayoutFactsForBlock(block, blockPath) {
|
|
|
16758
18402
|
rows.push({
|
|
16759
18403
|
numberingLayoutId,
|
|
16760
18404
|
...numberingKey !== void 0 ? { numberingKey } : {},
|
|
16761
|
-
...
|
|
18405
|
+
...canonical?.storyKey !== void 0 ? { storyKey: canonical.storyKey } : {},
|
|
18406
|
+
...canonical?.blockPath !== void 0 ? { sourceBlockPath: canonical.blockPath } : context.path !== void 0 ? { sourceBlockPath: context.path } : {},
|
|
16762
18407
|
sourceBlockId: paragraph.blockId,
|
|
16763
18408
|
...paragraphIndex !== void 0 ? { paragraphIndex } : {},
|
|
18409
|
+
...canonical?.sourceRef !== void 0 ? { sourceRef: { ...canonical.sourceRef } } : {},
|
|
18410
|
+
...canonical?.numberingSourceRef !== void 0 ? { numberingSourceRef: { ...canonical.numberingSourceRef } } : {},
|
|
18411
|
+
...canonical?.numberingOrigin !== void 0 ? { numberingOrigin: canonical.numberingOrigin } : {},
|
|
18412
|
+
...canonical?.paragraphStyleId !== void 0 ? { paragraphStyleId: canonical.paragraphStyleId } : {},
|
|
18413
|
+
...canonical?.numberingInstanceSourceRef !== void 0 ? { numberingInstanceSourceRef: { ...canonical.numberingInstanceSourceRef } } : {},
|
|
18414
|
+
...canonical?.abstractNumberingId !== void 0 ? { abstractNumberingId: canonical.abstractNumberingId } : {},
|
|
18415
|
+
...canonical?.abstractNumberingSourceRef !== void 0 ? { abstractNumberingSourceRef: { ...canonical.abstractNumberingSourceRef } } : {},
|
|
16764
18416
|
...numbering
|
|
16765
18417
|
});
|
|
16766
18418
|
}, blockPath);
|
|
@@ -17142,7 +18794,7 @@ function createEmpiricalProvider() {
|
|
|
17142
18794
|
}
|
|
17143
18795
|
|
|
17144
18796
|
// src/runtime/layout/layout-engine-version.ts
|
|
17145
|
-
var LAYOUT_ENGINE_VERSION =
|
|
18797
|
+
var LAYOUT_ENGINE_VERSION = 87;
|
|
17146
18798
|
|
|
17147
18799
|
// src/runtime/layout/layout-engine-instance.ts
|
|
17148
18800
|
var FULL_VIEWPORT_WINDOW_KEY = "full";
|
|
@@ -17449,7 +19101,8 @@ function createLayoutEngine(options = {}) {
|
|
|
17449
19101
|
MAIN_STORY_TARGET
|
|
17450
19102
|
);
|
|
17451
19103
|
const sections = buildResolvedSections(document2);
|
|
17452
|
-
const
|
|
19104
|
+
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
19105
|
+
const fieldRegions = layoutInputs.fieldRegions;
|
|
17453
19106
|
const pageStack = buildPageStackWithSplits(
|
|
17454
19107
|
document2,
|
|
17455
19108
|
sections,
|
|
@@ -17465,7 +19118,9 @@ function createLayoutEngine(options = {}) {
|
|
|
17465
19118
|
pageStack.splits,
|
|
17466
19119
|
pageStack.columnByBlockIdByPageIndex,
|
|
17467
19120
|
pageStack.fragmentMeasurementsByPageIndex,
|
|
17468
|
-
fieldRegions
|
|
19121
|
+
fieldRegions,
|
|
19122
|
+
layoutInputs.editableTargets,
|
|
19123
|
+
layoutInputs.numbering
|
|
17469
19124
|
);
|
|
17470
19125
|
const lineBoxesByPageIndex = projectLineBoxesForPageFragments(
|
|
17471
19126
|
pages,
|
|
@@ -17589,14 +19244,17 @@ function createLayoutEngine(options = {}) {
|
|
|
17589
19244
|
const freshSnapshotsToRebuild = freshSnapshots.slice(0, convergenceIndex);
|
|
17590
19245
|
const convergedTailStart = convergenceIndex < freshSnapshots.length ? firstDirty + convergenceIndex : void 0;
|
|
17591
19246
|
const freshStories = resolvePageStories(freshSnapshotsToRebuild);
|
|
17592
|
-
const
|
|
19247
|
+
const layoutInputs = collectCanonicalLayoutInputs(document2);
|
|
19248
|
+
const fieldRegions = layoutInputs.fieldRegions;
|
|
17593
19249
|
const freshBodyFragmentsByPageIndex = projectSurfaceBlocksToPageFragments(
|
|
17594
19250
|
mainSurface,
|
|
17595
19251
|
freshSnapshotsToRebuild,
|
|
17596
19252
|
freshResult.splits,
|
|
17597
19253
|
freshResult.columnByBlockIdByPageIndex,
|
|
17598
19254
|
freshResult.fragmentMeasurementsByPageIndex,
|
|
17599
|
-
fieldRegions
|
|
19255
|
+
fieldRegions,
|
|
19256
|
+
layoutInputs.editableTargets,
|
|
19257
|
+
layoutInputs.numbering
|
|
17600
19258
|
);
|
|
17601
19259
|
const freshLineBoxesByPageIndex = projectLineBoxesForPageFragments(
|
|
17602
19260
|
freshSnapshotsToRebuild,
|
|
@@ -18060,9 +19718,9 @@ function TwImageContextToolbar(props) {
|
|
|
18060
19718
|
widthEmu: preset.widthEmu,
|
|
18061
19719
|
heightEmu: preset.heightEmu
|
|
18062
19720
|
}),
|
|
18063
|
-
className: `inline-flex h-6 items-center px-2 text-[length:var(--text-xs)] font-medium rounded-[var(--radius-sm)] transition-colors disabled:cursor-not-allowed disabled:opacity-40
|
|
18064
|
-
aria-pressed:
|
|
18065
|
-
text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)]`,
|
|
19721
|
+
className: `inline-flex h-6 items-center px-2 text-[length:var(--text-xs)] font-medium rounded-[var(--radius-sm)] border border-transparent transition-colors disabled:cursor-not-allowed disabled:opacity-40
|
|
19722
|
+
aria-pressed:border-[var(--color-border-accent)] aria-pressed:text-[var(--color-accent-primary)]
|
|
19723
|
+
text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] hover:bg-[var(--color-bg-hover)]`,
|
|
18066
19724
|
children: shortLabel
|
|
18067
19725
|
},
|
|
18068
19726
|
preset.label
|
|
@@ -18127,7 +19785,7 @@ function ToolbarButton(props) {
|
|
|
18127
19785
|
disabled: props.disabled,
|
|
18128
19786
|
onMouseDown: preserveEditorSelectionMouseDown,
|
|
18129
19787
|
onClick: props.onClick,
|
|
18130
|
-
className: "inline-flex h-7 items-center rounded-md px-2 text-[length:var(--text-xs)] font-medium text-[var(--color-text-primary)] transition-colors hover:bg-[var(--color-
|
|
19788
|
+
className: "inline-flex h-7 items-center rounded-md px-2 text-[length:var(--text-xs)] font-medium text-[var(--color-text-primary)] transition-colors hover:bg-[var(--color-bg-hover)] disabled:cursor-not-allowed disabled:opacity-40",
|
|
18131
19789
|
children: props.children
|
|
18132
19790
|
}
|
|
18133
19791
|
);
|
|
@@ -20670,7 +22328,7 @@ function TwReviewRailFooter(props) {
|
|
|
20670
22328
|
// src/ui-tailwind/review/tw-review-rail.tsx
|
|
20671
22329
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
20672
22330
|
var focusRingClass10 = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-canvas";
|
|
20673
|
-
var PILL_TRIGGER_CLASS = `flex-1
|
|
22331
|
+
var PILL_TRIGGER_CLASS = `flex-1 px-3 py-1.5 text-xs font-medium text-[var(--color-text-tertiary)] border-b-2 border-transparent transition-colors data-[state=active]:border-[var(--color-accent-primary)] data-[state=active]:text-[var(--color-text-primary)] data-[state=active]:font-semibold outline-none ${focusRingClass10}`;
|
|
20674
22332
|
var UNDERLINE_TRIGGER_CLASS = `flex items-center gap-1.5 px-3 py-2 text-xs font-medium text-[var(--color-text-tertiary)] border-b-2 border-transparent transition-colors data-[state=active]:border-[var(--color-accent-primary)] data-[state=active]:text-[var(--color-text-primary)] outline-none ${focusRingClass10}`;
|
|
20675
22333
|
function TwReviewRail(props) {
|
|
20676
22334
|
const variant = props.variant ?? "docked";
|
|
@@ -20689,7 +22347,7 @@ function TwReviewRail(props) {
|
|
|
20689
22347
|
"data-wre-drawer": variant === "drawer" ? "true" : "false",
|
|
20690
22348
|
"data-editorial-header": editorial ? "true" : "false",
|
|
20691
22349
|
className: [
|
|
20692
|
-
"flex flex-col border-l border-[var(--color-border-subtle)]
|
|
22350
|
+
"flex flex-col border-l border-[var(--color-border-subtle)] bg-[var(--color-bg-chrome)]",
|
|
20693
22351
|
variant === "drawer" ? `h-full ${drawerWidthClass} max-w-full shrink-0 shadow-[var(--shadow-float)]` : `${widthClass} shrink-0`
|
|
20694
22352
|
].join(" "),
|
|
20695
22353
|
children: [
|
|
@@ -22111,7 +23769,7 @@ function TwCommandPalette(props) {
|
|
|
22111
23769
|
"text-sm",
|
|
22112
23770
|
"transition-colors duration-[var(--motion-fast)]",
|
|
22113
23771
|
"disabled:opacity-40 disabled:cursor-not-allowed",
|
|
22114
|
-
isActive ? "bg-[var(--color-
|
|
23772
|
+
isActive ? "bg-[var(--color-bg-hover)] text-[var(--color-text-primary)] font-medium" : "text-[var(--color-text-primary)] hover:bg-[var(--color-bg-hover)]"
|
|
22115
23773
|
].join(" "),
|
|
22116
23774
|
children: [
|
|
22117
23775
|
cmd.icon ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
@@ -25739,7 +27397,7 @@ var TwActiveBandRibbon = import_react24.default.memo(({
|
|
|
25739
27397
|
pointerEvents: "auto",
|
|
25740
27398
|
zIndex: 2
|
|
25741
27399
|
},
|
|
25742
|
-
className: "flex flex-col gap-1 rounded-md border border-border
|
|
27400
|
+
className: "flex flex-col gap-1 rounded-md border border-border bg-canvas px-2 py-1 shadow-sm",
|
|
25743
27401
|
children: [
|
|
25744
27402
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
25745
27403
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("span", { className: "text-[10px] font-semibold uppercase tracking-[var(--tracking-status)] text-tertiary", children: [
|
|
@@ -29456,7 +31114,9 @@ function resolveBlockRangeFromOffsetSpan(input) {
|
|
|
29456
31114
|
const block = blocks[index];
|
|
29457
31115
|
if (!block) continue;
|
|
29458
31116
|
if (block.from >= endOffset) break;
|
|
29459
|
-
|
|
31117
|
+
const intersectsSpan = block.from < endOffset && block.to > startOffset;
|
|
31118
|
+
const zeroWidthInsideSpan = block.from === block.to && block.from >= startOffset && block.from < endOffset;
|
|
31119
|
+
if (intersectsSpan || zeroWidthInsideSpan) {
|
|
29460
31120
|
if (first < 0) first = index;
|
|
29461
31121
|
last = index;
|
|
29462
31122
|
}
|
|
@@ -31273,12 +32933,13 @@ function TwReviewWorkspace(inputProps) {
|
|
|
31273
32933
|
var import_react52 = require("react");
|
|
31274
32934
|
|
|
31275
32935
|
// src/ui/headless/selection-helpers.ts
|
|
31276
|
-
function createSelectionSnapshot2(anchor, head = anchor) {
|
|
32936
|
+
function createSelectionSnapshot2(anchor, head = anchor, editableTarget) {
|
|
31277
32937
|
return {
|
|
31278
32938
|
anchor,
|
|
31279
32939
|
head,
|
|
31280
32940
|
isCollapsed: anchor === head,
|
|
31281
|
-
activeRange: createPublicRangeAnchor(anchor, head)
|
|
32941
|
+
activeRange: createPublicRangeAnchor(anchor, head),
|
|
32942
|
+
...editableTarget ? { editableTarget } : {}
|
|
31282
32943
|
};
|
|
31283
32944
|
}
|
|
31284
32945
|
function selectionTouchesRange(selection, from, to) {
|
|
@@ -31951,8 +33612,8 @@ var focusRingClass13 = "focus-visible:outline-none focus-visible:shadow-[var(--s
|
|
|
31951
33612
|
function TwShellHeader(props) {
|
|
31952
33613
|
const className = [
|
|
31953
33614
|
"grid h-12 shrink-0 grid-cols-[1fr_auto_1fr] items-center gap-2 px-4",
|
|
31954
|
-
"bg-[var(--color-bg-chrome)]
|
|
31955
|
-
|
|
33615
|
+
"bg-[var(--color-bg-chrome)]",
|
|
33616
|
+
"border-b border-[var(--color-border-subtle)]",
|
|
31956
33617
|
"transition-colors duration-[var(--motion-fast)]",
|
|
31957
33618
|
props.className
|
|
31958
33619
|
].filter(Boolean).join(" ");
|