@beyondwork/docx-react-component 1.0.128 → 1.0.130
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/dist/api/public-types.cjs +809 -78
- package/dist/api/public-types.d.cts +2 -2
- package/dist/api/public-types.d.ts +2 -2
- package/dist/api/public-types.js +4 -4
- package/dist/api/v3.cjs +2059 -402
- package/dist/api/v3.d.cts +3 -3
- package/dist/api/v3.d.ts +3 -3
- package/dist/api/v3.js +13 -13
- package/dist/{canonical-document-CXCFCbAz.d.cts → canonical-document-BMtONpgf.d.cts} +6 -0
- package/dist/{canonical-document-CXCFCbAz.d.ts → canonical-document-BMtONpgf.d.ts} +6 -0
- package/dist/{chunk-MWSBGJQO.js → chunk-35RHOE6I.js} +105 -4
- package/dist/{chunk-2QL5DAKF.js → chunk-3YCQM2RV.js} +6 -6
- package/dist/{chunk-ESJ2MES5.js → chunk-4YCWECLZ.js} +1 -1
- package/dist/{chunk-4EENH4FG.js → chunk-6TBLDBCL.js} +1 -1
- package/dist/{chunk-XRACP43Q.js → chunk-7G5GR3VV.js} +469 -32
- package/dist/{chunk-CXSYRB37.js → chunk-A3GSNB4G.js} +183 -55
- package/dist/{chunk-5DGKFNQT.js → chunk-A66ZVUAT.js} +150 -1
- package/dist/{chunk-YIYM4ZAP.js → chunk-CI2TD3T4.js} +1 -1
- package/dist/{chunk-TQDQU2E3.js → chunk-DGA7M77X.js} +2 -2
- package/dist/{chunk-EB6M3GE6.js → chunk-FM4K4XFJ.js} +100 -97
- package/dist/{chunk-D5HYZQTG.js → chunk-HYHCRMR7.js} +1 -1
- package/dist/{chunk-6F5QW44A.js → chunk-KNHMXKC6.js} +2 -2
- package/dist/{chunk-4YJVRIUB.js → chunk-M7YRJX6V.js} +61 -29
- package/dist/{chunk-KFCQYZXR.js → chunk-OVLZQ6FZ.js} +61 -0
- package/dist/{chunk-BYSRJ4FE.js → chunk-PHMWH23E.js} +1 -1
- package/dist/{chunk-ZDOAUP3V.js → chunk-Q7Y57KOK.js} +2 -2
- package/dist/{chunk-LZVBNDGU.js → chunk-QXKQPUOM.js} +3 -3
- package/dist/{chunk-CX42VC67.js → chunk-SYQWQ6FE.js} +1 -1
- package/dist/{chunk-KV435YXO.js → chunk-T5YYFDZB.js} +1 -1
- package/dist/{chunk-YHZHPXDB.js → chunk-THVM6EP5.js} +419 -24
- package/dist/{chunk-V6XVZFFH.js → chunk-VRKK2CSZ.js} +111 -90
- package/dist/{chunk-OL2UEHRP.js → chunk-WUDSNHWF.js} +1 -1
- package/dist/{chunk-LCYYR57Q.js → chunk-WZDKNF37.js} +666 -107
- package/dist/{chunk-6EROGFUF.js → chunk-YLL7MF5C.js} +444 -131
- package/dist/{chunk-YD2JE54B.js → chunk-ZVC23LKV.js} +1 -1
- package/dist/compare.cjs +100 -97
- 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 +182 -54
- 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 +5 -5
- 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 +182 -54
- 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 +4 -4
- package/dist/core/commands/text-commands.cjs +182 -54
- 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 +5 -5
- package/dist/core/selection/mapping.d.cts +2 -2
- package/dist/core/selection/mapping.d.ts +2 -2
- package/dist/core/state/editor-state.d.cts +2 -2
- package/dist/core/state/editor-state.d.ts +2 -2
- package/dist/index.cjs +2765 -557
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +52 -28
- package/dist/io/docx-session.cjs +267 -211
- package/dist/io/docx-session.d.cts +4 -4
- package/dist/io/docx-session.d.ts +4 -4
- package/dist/io/docx-session.js +6 -6
- package/dist/legal.cjs +9 -20
- package/dist/legal.d.cts +1 -1
- package/dist/legal.d.ts +1 -1
- package/dist/legal.js +3 -3
- package/dist/{loader-19ct2Be0.d.ts → loader-B-aL5HGD.d.ts} +3 -3
- package/dist/{loader-CoXQ2wGd.d.cts → loader-DiY_ZgKl.d.cts} +3 -3
- package/dist/{measurement-backend-canvas-Q3MJMEYX.js → measurement-backend-canvas-F7ZYDACK.js} +1 -1
- package/dist/{public-types-B-CskQen.d.cts → public-types-DyqnxxO9.d.ts} +252 -2
- package/dist/{public-types-7KZsNGE2.d.ts → public-types-gvubspUI.d.cts} +252 -2
- package/dist/public-types.cjs +809 -78
- package/dist/public-types.d.cts +2 -2
- package/dist/public-types.d.ts +2 -2
- package/dist/public-types.js +4 -4
- package/dist/runtime/collab.d.cts +3 -3
- package/dist/runtime/collab.d.ts +3 -3
- package/dist/runtime/document-runtime.cjs +1887 -313
- package/dist/runtime/document-runtime.d.cts +2 -2
- package/dist/runtime/document-runtime.d.ts +2 -2
- package/dist/runtime/document-runtime.js +17 -17
- package/dist/{session-B5015J4v.d.cts → session-BUN6B-Vj.d.cts} +3 -3
- package/dist/{session-C2i8-d6v.d.ts → session-CDB0hohT.d.ts} +3 -3
- package/dist/session.cjs +267 -211
- package/dist/session.d.cts +5 -5
- package/dist/session.d.ts +5 -5
- package/dist/session.js +7 -7
- package/dist/tailwind.cjs +809 -78
- package/dist/tailwind.d.cts +2 -2
- package/dist/tailwind.d.ts +2 -2
- package/dist/tailwind.js +8 -8
- package/dist/{types-DNhN0WeN.d.cts → types-C4bz3kDU.d.cts} +2 -2
- package/dist/{types-yvrQuGX9.d.ts → types-VWH6CRvG.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 +5 -5
- package/dist/ui-tailwind.cjs +809 -78
- package/dist/ui-tailwind.d.cts +3 -3
- package/dist/ui-tailwind.d.ts +3 -3
- package/dist/ui-tailwind.js +8 -8
- package/package.json +1 -1
|
@@ -7,30 +7,31 @@ import {
|
|
|
7
7
|
resolveSectionForStoryTarget,
|
|
8
8
|
searchSecondaryStories,
|
|
9
9
|
searchSurfaceBlocks
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-THVM6EP5.js";
|
|
11
11
|
import {
|
|
12
12
|
createEditorSurfaceSnapshot,
|
|
13
13
|
createFormattingContext,
|
|
14
14
|
resolveTableStyleResolution
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-A3GSNB4G.js";
|
|
16
16
|
import {
|
|
17
17
|
createSelectionSnapshot
|
|
18
18
|
} from "./chunk-OYGMRRR7.js";
|
|
19
19
|
import {
|
|
20
20
|
normalizeParsedTextDocument
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-4YCWECLZ.js";
|
|
22
22
|
import {
|
|
23
23
|
buildFieldRegistry,
|
|
24
24
|
parseMainDocumentXml,
|
|
25
25
|
parseTocLevelRange
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-M7YRJX6V.js";
|
|
27
27
|
import {
|
|
28
28
|
collectEditableTargetRefs,
|
|
29
|
+
collectLayoutInputIdentities,
|
|
29
30
|
validateEditableTargetRef
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-A66ZVUAT.js";
|
|
31
32
|
import {
|
|
32
33
|
serializeMainDocument
|
|
33
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-FM4K4XFJ.js";
|
|
34
35
|
import {
|
|
35
36
|
findOpaqueFragmentsIntersectingRange
|
|
36
37
|
} from "./chunk-UFVDIR2C.js";
|
|
@@ -858,6 +859,12 @@ function resolveScopeRange(entry, handle, positionMap) {
|
|
|
858
859
|
if (inlineRange) return inlineRange;
|
|
859
860
|
return positionMap.blocks.get(entry.blockIndex) ?? null;
|
|
860
861
|
}
|
|
862
|
+
case "image": {
|
|
863
|
+
const key = `${entry.blockIndex}:${entry.inlineIndex}`;
|
|
864
|
+
const inlineRange = positionMap.inlines.get(key);
|
|
865
|
+
if (inlineRange) return inlineRange;
|
|
866
|
+
return positionMap.blocks.get(entry.blockIndex) ?? null;
|
|
867
|
+
}
|
|
861
868
|
case "comment-thread":
|
|
862
869
|
return anchorToRange(entry.thread.anchor);
|
|
863
870
|
case "revision":
|
|
@@ -996,6 +1003,11 @@ function deriveReplaceability(kind, provenance) {
|
|
|
996
1003
|
level: "preserve-only",
|
|
997
1004
|
reason: "field-result-is-computed-preserve-only"
|
|
998
1005
|
};
|
|
1006
|
+
case "image":
|
|
1007
|
+
return {
|
|
1008
|
+
level: "preserve-only",
|
|
1009
|
+
reason: "image-object-command-required"
|
|
1010
|
+
};
|
|
999
1011
|
case "comment-thread":
|
|
1000
1012
|
return {
|
|
1001
1013
|
level: "preserve-only",
|
|
@@ -1700,6 +1712,55 @@ function compileHeadingScope(entry, options = {}) {
|
|
|
1700
1712
|
};
|
|
1701
1713
|
}
|
|
1702
1714
|
|
|
1715
|
+
// src/runtime/scopes/scope-kinds/image.ts
|
|
1716
|
+
function imageAltText(image) {
|
|
1717
|
+
if (image.type === "image") return image.altText ?? "";
|
|
1718
|
+
return image.anchor.docPr?.descr ?? image.anchor.docPr?.name ?? "";
|
|
1719
|
+
}
|
|
1720
|
+
function imageMediaId(image) {
|
|
1721
|
+
if (image.type === "image") return image.mediaId;
|
|
1722
|
+
return image.content.type === "picture" ? image.content.mediaId : void 0;
|
|
1723
|
+
}
|
|
1724
|
+
function imageDisplay(image) {
|
|
1725
|
+
if (image.type === "image") return image.display;
|
|
1726
|
+
return image.anchor.display;
|
|
1727
|
+
}
|
|
1728
|
+
function imageSourceKind(image) {
|
|
1729
|
+
return image.type === "image" ? "legacy-image" : "drawing-picture";
|
|
1730
|
+
}
|
|
1731
|
+
function compileImageScope(entry) {
|
|
1732
|
+
const { handle, image } = entry;
|
|
1733
|
+
const altText = imageAltText(image);
|
|
1734
|
+
const mediaId = imageMediaId(image);
|
|
1735
|
+
const display = imageDisplay(image);
|
|
1736
|
+
const sourceKind = imageSourceKind(image);
|
|
1737
|
+
return {
|
|
1738
|
+
handle,
|
|
1739
|
+
kind: "image",
|
|
1740
|
+
classifications: entry.classifications,
|
|
1741
|
+
content: {
|
|
1742
|
+
text: altText,
|
|
1743
|
+
excerpt: buildExcerpt(altText),
|
|
1744
|
+
authority: "structural-summary"
|
|
1745
|
+
},
|
|
1746
|
+
formatting: {},
|
|
1747
|
+
layout: display ? { flowKind: display } : {},
|
|
1748
|
+
geometry: {},
|
|
1749
|
+
workflow: { scopeIds: [], effectiveMode: "edit" },
|
|
1750
|
+
replaceability: deriveReplaceability("image", handle.provenance),
|
|
1751
|
+
audit: {
|
|
1752
|
+
source: "runtime",
|
|
1753
|
+
derivedFrom: [
|
|
1754
|
+
"canonical",
|
|
1755
|
+
`image-source:${sourceKind}`,
|
|
1756
|
+
...mediaId ? [`media-id:${mediaId}`] : []
|
|
1757
|
+
],
|
|
1758
|
+
confidence: "medium"
|
|
1759
|
+
},
|
|
1760
|
+
partial: true
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1703
1764
|
// src/runtime/scopes/scope-kinds/list-item.ts
|
|
1704
1765
|
function compileListItemScope(entry, options = {}) {
|
|
1705
1766
|
const { handle, paragraph } = entry;
|
|
@@ -2288,6 +2349,8 @@ function compileScope(entry, optionsOrCatalog) {
|
|
|
2288
2349
|
});
|
|
2289
2350
|
case "field":
|
|
2290
2351
|
return compileFieldScope(entry);
|
|
2352
|
+
case "image":
|
|
2353
|
+
return compileImageScope(entry);
|
|
2291
2354
|
case "comment-thread":
|
|
2292
2355
|
return compileCommentThreadScope(entry);
|
|
2293
2356
|
case "revision":
|
|
@@ -2476,6 +2539,44 @@ function enumerateFieldsInParagraph(paragraph, blockIndex, documentId, parentSco
|
|
|
2476
2539
|
}
|
|
2477
2540
|
return out;
|
|
2478
2541
|
}
|
|
2542
|
+
function isImageInline(child) {
|
|
2543
|
+
return child.type === "image" || child.type === "drawing_frame" && child.content.type === "picture";
|
|
2544
|
+
}
|
|
2545
|
+
function enumerateImagesInParagraph(paragraph, blockIndex, documentId, parentScopeId) {
|
|
2546
|
+
const out = [];
|
|
2547
|
+
for (let i = 0; i < paragraph.children.length; i += 1) {
|
|
2548
|
+
const child = paragraph.children[i];
|
|
2549
|
+
if (!isImageInline(child)) continue;
|
|
2550
|
+
const semanticPath = [
|
|
2551
|
+
"body",
|
|
2552
|
+
"paragraph",
|
|
2553
|
+
String(blockIndex),
|
|
2554
|
+
"image",
|
|
2555
|
+
String(i)
|
|
2556
|
+
];
|
|
2557
|
+
const scopeId = `image:${blockIndex}:${i}`;
|
|
2558
|
+
const handle = {
|
|
2559
|
+
scopeId,
|
|
2560
|
+
documentId,
|
|
2561
|
+
storyTarget: MAIN_STORY,
|
|
2562
|
+
semanticPath,
|
|
2563
|
+
parentScopeId,
|
|
2564
|
+
stableRef: { kind: "semantic-path", value: semanticPath.join("/") },
|
|
2565
|
+
provenance: "derived",
|
|
2566
|
+
rangePrecision: "canonical"
|
|
2567
|
+
};
|
|
2568
|
+
out.push({
|
|
2569
|
+
kind: "image",
|
|
2570
|
+
handle,
|
|
2571
|
+
image: child,
|
|
2572
|
+
paragraph,
|
|
2573
|
+
blockIndex,
|
|
2574
|
+
inlineIndex: i,
|
|
2575
|
+
classifications: Object.freeze([])
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
return out;
|
|
2579
|
+
}
|
|
2479
2580
|
function enumerateCommentThreads(document, documentId) {
|
|
2480
2581
|
const review = document.review;
|
|
2481
2582
|
const comments = review?.comments;
|
|
@@ -2606,6 +2707,8 @@ function enumerateScopes(document, inputs = {}) {
|
|
|
2606
2707
|
});
|
|
2607
2708
|
const fields = enumerateFieldsInParagraph(block, index, documentId, scopeId);
|
|
2608
2709
|
for (const field of fields) results.push(field);
|
|
2710
|
+
const images = enumerateImagesInParagraph(block, index, documentId, scopeId);
|
|
2711
|
+
for (const image of images) results.push(image);
|
|
2609
2712
|
continue;
|
|
2610
2713
|
}
|
|
2611
2714
|
if (block.type === "table") {
|
|
@@ -2995,6 +3098,15 @@ var LIST_TEXT_TARGET_KINDS = /* @__PURE__ */ new Set([
|
|
|
2995
3098
|
"sdt-paragraph-text",
|
|
2996
3099
|
"secondary-story-paragraph-text"
|
|
2997
3100
|
]);
|
|
3101
|
+
var OBJECT_COMMAND_INTENTS = /* @__PURE__ */ new Set([
|
|
3102
|
+
"image-layout",
|
|
3103
|
+
"image-frame",
|
|
3104
|
+
"chart-edit",
|
|
3105
|
+
"custom-xml-update",
|
|
3106
|
+
"embedded-content-update",
|
|
3107
|
+
"opaque-content-preserve",
|
|
3108
|
+
"object-edit"
|
|
3109
|
+
]);
|
|
2998
3110
|
function freezeList(values) {
|
|
2999
3111
|
return Object.freeze([...values]);
|
|
3000
3112
|
}
|
|
@@ -3539,6 +3651,35 @@ function listStructureCapability(scope, context) {
|
|
|
3539
3651
|
]
|
|
3540
3652
|
);
|
|
3541
3653
|
}
|
|
3654
|
+
function objectEditCapability(context) {
|
|
3655
|
+
const objectTargets = (context?.editableTargets?.entries ?? []).filter(
|
|
3656
|
+
(entry) => entry.kind === "object-anchor" || entry.kind === "custom-xml-content" || entry.kind === "opaque-content" || entry.commandFamily === "object" || entry.commandFamily === "preserve-only-refusal" || entry.runtimeCommand.intents.some((intent) => OBJECT_COMMAND_INTENTS.has(intent))
|
|
3657
|
+
);
|
|
3658
|
+
const supportedTargets = objectTargets.filter(
|
|
3659
|
+
(entry) => entry.runtimeCommand.status === "supported" && entry.runtimeCommand.intents.some((intent) => OBJECT_COMMAND_INTENTS.has(intent))
|
|
3660
|
+
);
|
|
3661
|
+
if (supportedTargets.length > 0) {
|
|
3662
|
+
return supportedCommand(
|
|
3663
|
+
"compile-supported:object-edit:editable-target",
|
|
3664
|
+
supportedTargets
|
|
3665
|
+
);
|
|
3666
|
+
}
|
|
3667
|
+
if (objectTargets.length > 0) {
|
|
3668
|
+
const blockers = commandTargetBlockers(objectTargets);
|
|
3669
|
+
return blocked(
|
|
3670
|
+
"compile-blocked:object-edit:target-ref-blocked",
|
|
3671
|
+
blockers.length > 0 ? blockers : ["compile-blocked:object-edit:target-ref-blocked"]
|
|
3672
|
+
);
|
|
3673
|
+
}
|
|
3674
|
+
return unsupported(
|
|
3675
|
+
"compile-unsupported:object-edit:no-target-family",
|
|
3676
|
+
[
|
|
3677
|
+
"compile-unsupported:object-edit:no-target-family",
|
|
3678
|
+
"capability:object-edit:l02-object-target-required",
|
|
3679
|
+
"capability:object-edit:l07-command-support-required"
|
|
3680
|
+
]
|
|
3681
|
+
);
|
|
3682
|
+
}
|
|
3542
3683
|
function deriveScopeCapabilities(scope, context = {}) {
|
|
3543
3684
|
return {
|
|
3544
3685
|
canReplaceText: replaceTextCapability(scope, context),
|
|
@@ -3555,7 +3696,8 @@ function deriveScopeCapabilities(scope, context = {}) {
|
|
|
3555
3696
|
canEditTableStructure: tableStructureCapability(scope, context),
|
|
3556
3697
|
canUseTableContinuationEvidence: tableContinuationEvidenceCapability(scope, context),
|
|
3557
3698
|
canEditListText: listTextCapability(scope, context),
|
|
3558
|
-
canEditListStructure: listStructureCapability(scope, context)
|
|
3699
|
+
canEditListStructure: listStructureCapability(scope, context),
|
|
3700
|
+
canEditObject: objectEditCapability(context)
|
|
3559
3701
|
};
|
|
3560
3702
|
}
|
|
3561
3703
|
|
|
@@ -3827,6 +3969,11 @@ function tokensForScope(entry) {
|
|
|
3827
3969
|
{ kind: "row", index: entry.rowIndex },
|
|
3828
3970
|
{ kind: "cell", index: entry.cellIndex }
|
|
3829
3971
|
]);
|
|
3972
|
+
case "image":
|
|
3973
|
+
return Object.freeze([
|
|
3974
|
+
{ kind: "block", index: entry.blockIndex },
|
|
3975
|
+
{ kind: "inline", index: entry.inlineIndex }
|
|
3976
|
+
]);
|
|
3830
3977
|
default:
|
|
3831
3978
|
return null;
|
|
3832
3979
|
}
|
|
@@ -3910,6 +4057,19 @@ function paragraphHasBookmarkId(paragraph, bookmarkId) {
|
|
|
3910
4057
|
function commandActionHandleForAddress(commandFamily, address) {
|
|
3911
4058
|
return address ? `scope-command:${commandFamily}:${address.addressKey}` : void 0;
|
|
3912
4059
|
}
|
|
4060
|
+
function layoutIdentityIndexes(document) {
|
|
4061
|
+
const byTargetKey = /* @__PURE__ */ new Map();
|
|
4062
|
+
const byStoryBlockPath = /* @__PURE__ */ new Map();
|
|
4063
|
+
for (const identity of collectLayoutInputIdentities(document)) {
|
|
4064
|
+
byStoryBlockPath.set(`${identity.storyKey}:${identity.blockPath}`, identity);
|
|
4065
|
+
const targetKey = identity.editableTargetRef?.targetKey;
|
|
4066
|
+
if (targetKey) byTargetKey.set(targetKey, identity);
|
|
4067
|
+
}
|
|
4068
|
+
return { byTargetKey, byStoryBlockPath };
|
|
4069
|
+
}
|
|
4070
|
+
function layoutIdentityForTarget(target, indexes) {
|
|
4071
|
+
return indexes.byTargetKey.get(target.targetKey) ?? indexes.byStoryBlockPath.get(`${target.storyKey}:${target.blockPath}`);
|
|
4072
|
+
}
|
|
3913
4073
|
function withCommandAction(evidence, target, canonicalAddress = target.canonicalAddress) {
|
|
3914
4074
|
if (evidence.status !== "supported" || !canonicalAddress) return evidence;
|
|
3915
4075
|
return {
|
|
@@ -3921,6 +4081,24 @@ function withCommandAction(evidence, target, canonicalAddress = target.canonical
|
|
|
3921
4081
|
function commandAddressForTarget(target, scopeKind) {
|
|
3922
4082
|
return scopeKind === "list-item" && target.listAddress !== void 0 ? target.listAddress : target.canonicalAddress;
|
|
3923
4083
|
}
|
|
4084
|
+
function freezeCommandIntents(intents) {
|
|
4085
|
+
return Object.freeze([...new Set(intents)]);
|
|
4086
|
+
}
|
|
4087
|
+
function relatedListActionHandlesForTarget(target, primaryAddress) {
|
|
4088
|
+
if (target.commandFamily !== "text-leaf" || target.listAddress === void 0 || !LIST_TEXT_TARGET_KINDS2.has(target.kind) || target.listAddress.addressKey === primaryAddress?.addressKey) {
|
|
4089
|
+
return void 0;
|
|
4090
|
+
}
|
|
4091
|
+
const actionHandle = commandActionHandleForAddress(target.commandFamily, target.listAddress);
|
|
4092
|
+
if (!actionHandle) return void 0;
|
|
4093
|
+
return Object.freeze([
|
|
4094
|
+
{
|
|
4095
|
+
actionHandle,
|
|
4096
|
+
canonicalAddress: target.listAddress,
|
|
4097
|
+
intents: freezeCommandIntents(["list-text-edit", "list-structure-action"]),
|
|
4098
|
+
reason: "l07:list-address-target-supported"
|
|
4099
|
+
}
|
|
4100
|
+
]);
|
|
4101
|
+
}
|
|
3924
4102
|
function runtimeTextCommandEvidence(target, workflowBlockers) {
|
|
3925
4103
|
const shapeIssues = validateEditableTargetRef(target);
|
|
3926
4104
|
if (shapeIssues.length > 0) {
|
|
@@ -4020,13 +4198,16 @@ function runtimeCommandEvidence(target, workflowBlockers, textCommand, scopeKind
|
|
|
4020
4198
|
};
|
|
4021
4199
|
}
|
|
4022
4200
|
if (target.commandFamily === "text-leaf") {
|
|
4201
|
+
const canonicalAddress = commandAddressForTarget(target, scopeKind);
|
|
4202
|
+
const relatedActionHandles = relatedListActionHandlesForTarget(target, canonicalAddress);
|
|
4023
4203
|
return withCommandAction({
|
|
4024
4204
|
status: textCommand.status,
|
|
4025
4205
|
commandFamily: target.commandFamily,
|
|
4026
4206
|
intents: commandIntentsForTarget(target, scopeKind),
|
|
4027
4207
|
reason: textCommand.reason,
|
|
4208
|
+
...relatedActionHandles !== void 0 ? { relatedActionHandles } : {},
|
|
4028
4209
|
...textCommand.blockers ? { blockers: textCommand.blockers } : {}
|
|
4029
|
-
}, target,
|
|
4210
|
+
}, target, canonicalAddress);
|
|
4030
4211
|
}
|
|
4031
4212
|
if (target.commandFamily === "comment-revision") {
|
|
4032
4213
|
const isOpen = target.review?.status === "open";
|
|
@@ -4351,19 +4532,21 @@ function commandIntentsForTarget(target, scopeKind) {
|
|
|
4351
4532
|
if (target.kind === "hyperlink-text") {
|
|
4352
4533
|
return Object.freeze(["text-leaf-edit", "hyperlink-display-text-edit"]);
|
|
4353
4534
|
}
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4535
|
+
{
|
|
4536
|
+
const intents = ["text-leaf-edit"];
|
|
4537
|
+
if (target.table?.operationScope === "text") {
|
|
4538
|
+
intents.push(
|
|
4539
|
+
"table-text-paste",
|
|
4540
|
+
"table-text-drop",
|
|
4541
|
+
"table-structured-fragment-paste",
|
|
4542
|
+
"table-structured-fragment-drop"
|
|
4543
|
+
);
|
|
4544
|
+
}
|
|
4545
|
+
if ((scopeKind === "list-item" || target.listAddress !== void 0) && LIST_TEXT_TARGET_KINDS2.has(target.kind)) {
|
|
4546
|
+
intents.push("list-text-edit", "list-structure-action");
|
|
4547
|
+
}
|
|
4548
|
+
return freezeCommandIntents(intents);
|
|
4365
4549
|
}
|
|
4366
|
-
return Object.freeze(["text-leaf-edit"]);
|
|
4367
4550
|
case "field":
|
|
4368
4551
|
return Object.freeze(
|
|
4369
4552
|
target.field?.fieldFamily === "TOC" ? ["toc-refresh", "field-update"] : ["field-update"]
|
|
@@ -4510,7 +4693,7 @@ function readbackForTarget(document, target, runtimeTextCommand) {
|
|
|
4510
4693
|
source: "canonical-text-leaf"
|
|
4511
4694
|
};
|
|
4512
4695
|
}
|
|
4513
|
-
function projectTarget(document, target, relation, workflowBlockers, scopeKind) {
|
|
4696
|
+
function projectTarget(document, target, relation, workflowBlockers, scopeKind, layoutIdentity) {
|
|
4514
4697
|
const runtimeTextCommand = runtimeTextCommandEvidence(target, workflowBlockers);
|
|
4515
4698
|
const readback = readbackForTarget(document, target, runtimeTextCommand);
|
|
4516
4699
|
return {
|
|
@@ -4531,6 +4714,7 @@ function projectTarget(document, target, relation, workflowBlockers, scopeKind)
|
|
|
4531
4714
|
...target.table ? { table: target.table } : {},
|
|
4532
4715
|
...target.editableOwner ? { editableOwner: target.editableOwner } : {},
|
|
4533
4716
|
...target.canonicalAddress ? { canonicalAddress: target.canonicalAddress } : {},
|
|
4717
|
+
...layoutIdentity ? { layoutIdentity } : {},
|
|
4534
4718
|
staleCheck: target.staleCheck,
|
|
4535
4719
|
posture: target.posture,
|
|
4536
4720
|
...workflowBlockers.length > 0 ? { workflowBlockers: Object.freeze([...workflowBlockers]) } : {},
|
|
@@ -4546,7 +4730,7 @@ function deriveScopeEditableTargetEvidence(document, scope, entry, options = {})
|
|
|
4546
4730
|
facts.push(projectWorkflowBlockerFact(fact));
|
|
4547
4731
|
factsByTargetKey.set(fact.targetKey, facts);
|
|
4548
4732
|
}
|
|
4549
|
-
const
|
|
4733
|
+
const relatedTargets = collectEditableTargetRefs(document, options.editableTargetCache).map((target) => {
|
|
4550
4734
|
const relation = relationForTarget(target, scope, entry);
|
|
4551
4735
|
if (!relation) return null;
|
|
4552
4736
|
const workflowBlockers = Object.freeze(
|
|
@@ -4554,8 +4738,19 @@ function deriveScopeEditableTargetEvidence(document, scope, entry, options = {})
|
|
|
4554
4738
|
(left, right) => left.source.localeCompare(right.source) || left.blocker.localeCompare(right.blocker) || left.refusalId.localeCompare(right.refusalId)
|
|
4555
4739
|
)
|
|
4556
4740
|
);
|
|
4557
|
-
return
|
|
4558
|
-
}).filter((target) => target !== null)
|
|
4741
|
+
return { target, relation, workflowBlockers };
|
|
4742
|
+
}).filter((target) => target !== null);
|
|
4743
|
+
const layoutIndexes = relatedTargets.length > 0 ? layoutIdentityIndexes(document) : void 0;
|
|
4744
|
+
const entries = relatedTargets.map(
|
|
4745
|
+
({ target, relation, workflowBlockers }) => projectTarget(
|
|
4746
|
+
document,
|
|
4747
|
+
target,
|
|
4748
|
+
relation,
|
|
4749
|
+
workflowBlockers,
|
|
4750
|
+
scope.kind,
|
|
4751
|
+
layoutIndexes ? layoutIdentityForTarget(target, layoutIndexes) : void 0
|
|
4752
|
+
)
|
|
4753
|
+
).sort((a, b) => a.targetKey.localeCompare(b.targetKey));
|
|
4559
4754
|
const blockers = /* @__PURE__ */ new Set();
|
|
4560
4755
|
let supportedTextTargetCount = 0;
|
|
4561
4756
|
for (const target of entries) {
|
|
@@ -4574,6 +4769,114 @@ function deriveScopeEditableTargetEvidence(document, scope, entry, options = {})
|
|
|
4574
4769
|
};
|
|
4575
4770
|
}
|
|
4576
4771
|
|
|
4772
|
+
// src/runtime/scopes/object-evidence.ts
|
|
4773
|
+
var OBJECT_INTENTS = /* @__PURE__ */ new Set([
|
|
4774
|
+
"image-layout",
|
|
4775
|
+
"image-frame",
|
|
4776
|
+
"chart-edit",
|
|
4777
|
+
"custom-xml-update",
|
|
4778
|
+
"embedded-content-update",
|
|
4779
|
+
"opaque-content-preserve",
|
|
4780
|
+
"object-edit",
|
|
4781
|
+
"preserve-only-refusal"
|
|
4782
|
+
]);
|
|
4783
|
+
function unique(values) {
|
|
4784
|
+
return Object.freeze([...new Set(values.filter((value) => value.length > 0))]);
|
|
4785
|
+
}
|
|
4786
|
+
function isObjectTarget(entry) {
|
|
4787
|
+
return entry.object !== void 0 || entry.kind === "object-anchor" || entry.kind === "custom-xml-content" || entry.kind === "opaque-content" || entry.commandFamily === "object" || entry.runtimeCommand.intents.some((intent) => OBJECT_INTENTS.has(intent));
|
|
4788
|
+
}
|
|
4789
|
+
function blockersFor(entry) {
|
|
4790
|
+
return unique([
|
|
4791
|
+
...entry.posture.blockers,
|
|
4792
|
+
...entry.runtimeCommand.blockers ?? [],
|
|
4793
|
+
...entry.runtimeTextCommand.blockers ?? [],
|
|
4794
|
+
...(entry.workflowBlockers ?? []).flatMap((blocker) => [
|
|
4795
|
+
blocker.blocker,
|
|
4796
|
+
blocker.refusalId
|
|
4797
|
+
]),
|
|
4798
|
+
entry.runtimeCommand.status === "blocked" ? entry.runtimeCommand.reason : ""
|
|
4799
|
+
]);
|
|
4800
|
+
}
|
|
4801
|
+
function projectEntry2(entry) {
|
|
4802
|
+
const blockers = blockersFor(entry);
|
|
4803
|
+
return {
|
|
4804
|
+
targetKey: entry.targetKey,
|
|
4805
|
+
kind: entry.kind,
|
|
4806
|
+
...entry.object?.objectKind ? { objectKind: entry.object.objectKind } : {},
|
|
4807
|
+
relation: entry.relation,
|
|
4808
|
+
commandFamily: entry.commandFamily,
|
|
4809
|
+
editability: entry.editability,
|
|
4810
|
+
...entry.sourceRef ? { sourceRef: entry.sourceRef } : {},
|
|
4811
|
+
...entry.object ? { object: entry.object } : {},
|
|
4812
|
+
runtimeCommand: entry.runtimeCommand,
|
|
4813
|
+
blockers,
|
|
4814
|
+
...entry.posture.preserveOnly ? { preserveOnly: true } : {}
|
|
4815
|
+
};
|
|
4816
|
+
}
|
|
4817
|
+
function familyKindFor(entry) {
|
|
4818
|
+
return entry.objectKind ?? "unknown";
|
|
4819
|
+
}
|
|
4820
|
+
function familyStatusFor(entries) {
|
|
4821
|
+
if (entries.some((entry) => entry.runtimeCommand.status === "supported")) {
|
|
4822
|
+
return "supported";
|
|
4823
|
+
}
|
|
4824
|
+
if (entries.length > 0 && entries.every(
|
|
4825
|
+
(entry) => entry.preserveOnly === true || entry.commandFamily === "preserve-only-refusal"
|
|
4826
|
+
)) {
|
|
4827
|
+
return "preserve-only";
|
|
4828
|
+
}
|
|
4829
|
+
return "blocked";
|
|
4830
|
+
}
|
|
4831
|
+
function summarizeFamily(objectKind, entries) {
|
|
4832
|
+
const sortedEntries = [...entries].sort(
|
|
4833
|
+
(left, right) => left.targetKey.localeCompare(right.targetKey)
|
|
4834
|
+
);
|
|
4835
|
+
const preserveOnly = sortedEntries.some((entry) => entry.preserveOnly === true);
|
|
4836
|
+
return {
|
|
4837
|
+
objectKind,
|
|
4838
|
+
status: familyStatusFor(sortedEntries),
|
|
4839
|
+
count: sortedEntries.length,
|
|
4840
|
+
targetKeys: unique(sortedEntries.map((entry) => entry.targetKey)),
|
|
4841
|
+
relations: unique(sortedEntries.map((entry) => entry.relation)),
|
|
4842
|
+
commandFamilies: unique(sortedEntries.map((entry) => entry.commandFamily)),
|
|
4843
|
+
runtimeIntents: unique(
|
|
4844
|
+
sortedEntries.flatMap((entry) => [...entry.runtimeCommand.intents])
|
|
4845
|
+
),
|
|
4846
|
+
blockers: unique(sortedEntries.flatMap((entry) => [...entry.blockers])),
|
|
4847
|
+
...preserveOnly ? { preserveOnly: true } : {}
|
|
4848
|
+
};
|
|
4849
|
+
}
|
|
4850
|
+
function summarizeFamilies(entries) {
|
|
4851
|
+
const byFamily = /* @__PURE__ */ new Map();
|
|
4852
|
+
for (const entry of entries) {
|
|
4853
|
+
const objectKind = familyKindFor(entry);
|
|
4854
|
+
const bucket = byFamily.get(objectKind);
|
|
4855
|
+
if (bucket) {
|
|
4856
|
+
bucket.push(entry);
|
|
4857
|
+
continue;
|
|
4858
|
+
}
|
|
4859
|
+
byFamily.set(objectKind, [entry]);
|
|
4860
|
+
}
|
|
4861
|
+
return Object.freeze(
|
|
4862
|
+
[...byFamily.entries()].map(([objectKind, familyEntries]) => summarizeFamily(objectKind, familyEntries)).sort((left, right) => left.objectKind.localeCompare(right.objectKind))
|
|
4863
|
+
);
|
|
4864
|
+
}
|
|
4865
|
+
function deriveScopeObjectEvidence(editableTargets) {
|
|
4866
|
+
const entries = Object.freeze(
|
|
4867
|
+
[...editableTargets?.entries ?? []].filter(isObjectTarget).map(projectEntry2).sort((left, right) => left.targetKey.localeCompare(right.targetKey))
|
|
4868
|
+
);
|
|
4869
|
+
const blockers = unique(entries.flatMap((entry) => [...entry.blockers]));
|
|
4870
|
+
const families = summarizeFamilies(entries);
|
|
4871
|
+
return {
|
|
4872
|
+
status: entries.length > 0 ? "present" : "none",
|
|
4873
|
+
count: entries.length,
|
|
4874
|
+
blockers,
|
|
4875
|
+
families,
|
|
4876
|
+
entries
|
|
4877
|
+
};
|
|
4878
|
+
}
|
|
4879
|
+
|
|
4577
4880
|
// src/runtime/scopes/table-evidence.ts
|
|
4578
4881
|
function isTableFamilyEntry(entry) {
|
|
4579
4882
|
return entry?.kind === "table" || entry?.kind === "table-row" || entry?.kind === "table-cell";
|
|
@@ -5143,7 +5446,7 @@ function deriveScopeGeometryEvidence(scopeId, provider, context) {
|
|
|
5143
5446
|
function freezeList2(values) {
|
|
5144
5447
|
return values ? Object.freeze([...values]) : void 0;
|
|
5145
5448
|
}
|
|
5146
|
-
function
|
|
5449
|
+
function unique2(values) {
|
|
5147
5450
|
return Object.freeze([...new Set(values)]);
|
|
5148
5451
|
}
|
|
5149
5452
|
function parseTableFamilyScopeId2(scopeId) {
|
|
@@ -5173,7 +5476,7 @@ function candidateTableBlockIds(blockIndex, mapped) {
|
|
|
5173
5476
|
const mappedId = mapped?.get(blockIndex);
|
|
5174
5477
|
if (mappedId) ids.push(mappedId);
|
|
5175
5478
|
ids.push(`table-${blockIndex}`, `table:${blockIndex}`, `block-${blockIndex}`);
|
|
5176
|
-
return
|
|
5479
|
+
return unique2(ids);
|
|
5177
5480
|
}
|
|
5178
5481
|
function rowInFragment(fragment, rowIndex) {
|
|
5179
5482
|
const range = fragment.tableRowRange;
|
|
@@ -5210,19 +5513,19 @@ function projectTableFramePage(fragment) {
|
|
|
5210
5513
|
...fragment.tableRowRange ? { rowRange: { ...fragment.tableRowRange } } : {},
|
|
5211
5514
|
...fragment.continuation?.continuesFromPreviousPage !== void 0 ? { continuesFromPreviousPage: fragment.continuation.continuesFromPreviousPage } : {},
|
|
5212
5515
|
...fragment.continuation?.continuesToNextPage !== void 0 ? { continuesToNextPage: fragment.continuation.continuesToNextPage } : {},
|
|
5213
|
-
...repeated ? { repeatedHeaderRowIndexes:
|
|
5516
|
+
...repeated ? { repeatedHeaderRowIndexes: unique2(repeated) } : {},
|
|
5214
5517
|
...splitRowCarry ? { splitRowCarry: Object.freeze(splitRowCarry.map((item) => ({ ...item }))) } : {},
|
|
5215
5518
|
...carry ? { verticalMergeCarry: Object.freeze(carry.map((item) => ({ ...item }))) } : {}
|
|
5216
5519
|
};
|
|
5217
5520
|
}
|
|
5218
5521
|
function projectTableFrame(blockId, parsed, fragments) {
|
|
5219
|
-
const pageIds =
|
|
5220
|
-
const pageSliceIds =
|
|
5221
|
-
const layoutObjectIds =
|
|
5522
|
+
const pageIds = unique2(fragments.map((fragment) => fragment.pageId));
|
|
5523
|
+
const pageSliceIds = unique2(fragments.map((fragment) => fragment.fragmentId));
|
|
5524
|
+
const layoutObjectIds = unique2(
|
|
5222
5525
|
fragments.map((fragment) => fragment.layoutObject?.objectId).filter((objectId) => typeof objectId === "string" && objectId.length > 0)
|
|
5223
5526
|
);
|
|
5224
5527
|
const rowRangesByPage = Object.freeze(fragments.map(projectTableFramePage));
|
|
5225
|
-
const repeatedHeaderRowIndexes =
|
|
5528
|
+
const repeatedHeaderRowIndexes = unique2(
|
|
5226
5529
|
fragments.flatMap((fragment) => fragment.continuation?.repeatedHeaderRowIndexes ?? [])
|
|
5227
5530
|
);
|
|
5228
5531
|
const verticalMergeCarry = Object.freeze(
|
|
@@ -5247,7 +5550,7 @@ function projectTableFrame(blockId, parsed, fragments) {
|
|
|
5247
5550
|
};
|
|
5248
5551
|
}
|
|
5249
5552
|
function continuationFromTableFrame(fragments) {
|
|
5250
|
-
const pageIds =
|
|
5553
|
+
const pageIds = unique2(fragments.map((fragment) => fragment.pageId));
|
|
5251
5554
|
return {
|
|
5252
5555
|
...pageIds.length > 0 ? { pageIds } : {},
|
|
5253
5556
|
pageCount: pageIds.length,
|
|
@@ -5545,6 +5848,7 @@ function composeEvidence(inputs) {
|
|
|
5545
5848
|
...editableTargets ? { editableTargets } : {},
|
|
5546
5849
|
layout
|
|
5547
5850
|
});
|
|
5851
|
+
const objects = deriveScopeObjectEvidence(editableTargets);
|
|
5548
5852
|
return {
|
|
5549
5853
|
formattingSummary: formattingSummaryOf(scope),
|
|
5550
5854
|
reviewItemIds,
|
|
@@ -5555,6 +5859,7 @@ function composeEvidence(inputs) {
|
|
|
5555
5859
|
...adjacentGeometry ? { adjacentGeometry } : {},
|
|
5556
5860
|
visualization: deriveScopeVisualization(scope),
|
|
5557
5861
|
...editableTargets ? { editableTargets } : {},
|
|
5862
|
+
objects,
|
|
5558
5863
|
...table ? { table } : {},
|
|
5559
5864
|
contentControls,
|
|
5560
5865
|
capabilities,
|
|
@@ -8599,6 +8904,133 @@ function sortJson(value) {
|
|
|
8599
8904
|
return value;
|
|
8600
8905
|
}
|
|
8601
8906
|
|
|
8907
|
+
// src/io/ooxml/numbering-catalog-mutation.ts
|
|
8908
|
+
function cloneNumberingCatalog(catalog) {
|
|
8909
|
+
return structuredClone(catalog);
|
|
8910
|
+
}
|
|
8911
|
+
function getListKind(catalog, numberingInstanceId) {
|
|
8912
|
+
const instance = catalog.instances[numberingInstanceId];
|
|
8913
|
+
const definition = instance ? catalog.abstractDefinitions[instance.abstractNumberingId] : void 0;
|
|
8914
|
+
const levelZero = definition?.levels.find((level) => level.level === 0);
|
|
8915
|
+
if (!levelZero) return void 0;
|
|
8916
|
+
return levelZero.format === "bullet" ? "bulleted" : "numbered";
|
|
8917
|
+
}
|
|
8918
|
+
function ensureDefaultListInstance(catalog, kind) {
|
|
8919
|
+
const existing = Object.values(catalog.instances).find(
|
|
8920
|
+
(instance) => getListKind(catalog, instance.numberingInstanceId) === kind
|
|
8921
|
+
);
|
|
8922
|
+
if (existing) return existing.numberingInstanceId;
|
|
8923
|
+
const abstractNumberingId = allocateAbstractDefinition(catalog, {
|
|
8924
|
+
levels: defaultLevels(kind),
|
|
8925
|
+
multiLevelType: "hybridMultilevel"
|
|
8926
|
+
});
|
|
8927
|
+
return allocateNumberingInstance(catalog, abstractNumberingId);
|
|
8928
|
+
}
|
|
8929
|
+
function allocateNumberingInstance(catalog, abstractNumberingId, overrides = []) {
|
|
8930
|
+
const numberingInstanceId = nextCanonicalNumericId(
|
|
8931
|
+
"num:",
|
|
8932
|
+
Object.keys(catalog.instances)
|
|
8933
|
+
);
|
|
8934
|
+
catalog.instances[numberingInstanceId] = {
|
|
8935
|
+
numberingInstanceId,
|
|
8936
|
+
abstractNumberingId,
|
|
8937
|
+
overrides: cloneOverrides(overrides)
|
|
8938
|
+
};
|
|
8939
|
+
return numberingInstanceId;
|
|
8940
|
+
}
|
|
8941
|
+
function allocateAbstractDefinition(catalog, input) {
|
|
8942
|
+
const abstractNumberingId = input.abstractNumberingId && !catalog.abstractDefinitions[input.abstractNumberingId] ? input.abstractNumberingId : nextCanonicalNumericId("abstract-num:", Object.keys(catalog.abstractDefinitions));
|
|
8943
|
+
catalog.abstractDefinitions[abstractNumberingId] = {
|
|
8944
|
+
abstractNumberingId,
|
|
8945
|
+
levels: structuredClone(input.levels),
|
|
8946
|
+
...input.nsid ? { nsid: input.nsid } : { nsid: freshLongHex(catalog, abstractNumberingId, "nsid") },
|
|
8947
|
+
...input.multiLevelType ? { multiLevelType: input.multiLevelType } : {},
|
|
8948
|
+
...input.tplc ? { tplc: input.tplc } : { tplc: freshLongHex(catalog, abstractNumberingId, "tmpl") },
|
|
8949
|
+
...input.styleLink ? { styleLink: input.styleLink } : {},
|
|
8950
|
+
...input.numStyleLink ? { numStyleLink: input.numStyleLink } : {}
|
|
8951
|
+
};
|
|
8952
|
+
return abstractNumberingId;
|
|
8953
|
+
}
|
|
8954
|
+
function setStartOverride(catalog, numberingInstanceId, level, startAt) {
|
|
8955
|
+
const instance = catalog.instances[numberingInstanceId];
|
|
8956
|
+
if (!instance) return;
|
|
8957
|
+
catalog.instances[numberingInstanceId] = {
|
|
8958
|
+
...instance,
|
|
8959
|
+
overrides: mergeOverride(instance.overrides, { level, startAt })
|
|
8960
|
+
};
|
|
8961
|
+
}
|
|
8962
|
+
function mergeOverride(overrides, nextOverride) {
|
|
8963
|
+
return [
|
|
8964
|
+
...overrides.filter((override) => override.level !== nextOverride.level),
|
|
8965
|
+
structuredClone(nextOverride)
|
|
8966
|
+
].sort((left, right) => left.level - right.level);
|
|
8967
|
+
}
|
|
8968
|
+
function cloneOverrides(overrides) {
|
|
8969
|
+
return overrides.map((override) => structuredClone(override));
|
|
8970
|
+
}
|
|
8971
|
+
function defaultLevels(kind) {
|
|
8972
|
+
if (kind === "bulleted") {
|
|
8973
|
+
return [
|
|
8974
|
+
{ level: 0, format: "bullet", text: "\u2022" },
|
|
8975
|
+
{ level: 1, format: "bullet", text: "o" },
|
|
8976
|
+
{ level: 2, format: "bullet", text: "\u25A0" },
|
|
8977
|
+
{ level: 3, format: "bullet", text: "\u2022" },
|
|
8978
|
+
{ level: 4, format: "bullet", text: "o" },
|
|
8979
|
+
{ level: 5, format: "bullet", text: "\u25A0" },
|
|
8980
|
+
{ level: 6, format: "bullet", text: "\u2022" },
|
|
8981
|
+
{ level: 7, format: "bullet", text: "o" },
|
|
8982
|
+
{ level: 8, format: "bullet", text: "\u25A0" }
|
|
8983
|
+
];
|
|
8984
|
+
}
|
|
8985
|
+
return [
|
|
8986
|
+
{ level: 0, format: "decimal", text: "%1." },
|
|
8987
|
+
{ level: 1, format: "decimal", text: "%1.%2." },
|
|
8988
|
+
{ level: 2, format: "lowerLetter", text: "(%3)" },
|
|
8989
|
+
{ level: 3, format: "lowerRoman", text: "(%4)" },
|
|
8990
|
+
{ level: 4, format: "decimal", text: "%5." },
|
|
8991
|
+
{ level: 5, format: "lowerLetter", text: "(%6)" },
|
|
8992
|
+
{ level: 6, format: "lowerRoman", text: "(%7)" },
|
|
8993
|
+
{ level: 7, format: "decimal", text: "%8." },
|
|
8994
|
+
{ level: 8, format: "lowerLetter", text: "(%9)" }
|
|
8995
|
+
];
|
|
8996
|
+
}
|
|
8997
|
+
function nextCanonicalNumericId(prefix, ids) {
|
|
8998
|
+
return `${prefix}${nextNumericString(ids.map((id) => stripPrefix(id, prefix)))}`;
|
|
8999
|
+
}
|
|
9000
|
+
function nextNumericString(ids) {
|
|
9001
|
+
const used = new Set(ids);
|
|
9002
|
+
let next = 1;
|
|
9003
|
+
for (const id of ids) {
|
|
9004
|
+
const parsed = Number.parseInt(id, 10);
|
|
9005
|
+
if (Number.isFinite(parsed) && parsed >= next) next = parsed + 1;
|
|
9006
|
+
}
|
|
9007
|
+
while (used.has(String(next))) next += 1;
|
|
9008
|
+
return String(next);
|
|
9009
|
+
}
|
|
9010
|
+
function stripPrefix(value, prefix) {
|
|
9011
|
+
return value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
9012
|
+
}
|
|
9013
|
+
function freshLongHex(catalog, abstractNumberingId, salt) {
|
|
9014
|
+
const existing = new Set(
|
|
9015
|
+
Object.values(catalog.abstractDefinitions).map((definition) => salt === "nsid" ? definition.nsid : definition.tplc).filter((value) => Boolean(value))
|
|
9016
|
+
);
|
|
9017
|
+
let attempt = 0;
|
|
9018
|
+
while (attempt < 1e3) {
|
|
9019
|
+
const candidate = hashLongHex(`${salt}:${abstractNumberingId}:${attempt}`);
|
|
9020
|
+
if (!existing.has(candidate)) return candidate;
|
|
9021
|
+
attempt += 1;
|
|
9022
|
+
}
|
|
9023
|
+
return hashLongHex(`${salt}:${abstractNumberingId}:${Date.now()}`);
|
|
9024
|
+
}
|
|
9025
|
+
function hashLongHex(input) {
|
|
9026
|
+
let hash = 2166136261;
|
|
9027
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
9028
|
+
hash ^= input.charCodeAt(index);
|
|
9029
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
9030
|
+
}
|
|
9031
|
+
return hash.toString(16).toUpperCase().padStart(8, "0").slice(-8);
|
|
9032
|
+
}
|
|
9033
|
+
|
|
8602
9034
|
// src/runtime/formatting/projector.ts
|
|
8603
9035
|
function buildFormattingDebugEntry(inputs) {
|
|
8604
9036
|
const { doc, revisionMarkupMode, recentSamples } = inputs;
|
|
@@ -8620,6 +9052,11 @@ function buildFormattingDebugEntry(inputs) {
|
|
|
8620
9052
|
}
|
|
8621
9053
|
|
|
8622
9054
|
export {
|
|
9055
|
+
cloneNumberingCatalog,
|
|
9056
|
+
getListKind,
|
|
9057
|
+
ensureDefaultListInstance,
|
|
9058
|
+
allocateNumberingInstance,
|
|
9059
|
+
setStartOverride,
|
|
8623
9060
|
collectScopeLocations,
|
|
8624
9061
|
resolveScope,
|
|
8625
9062
|
findAllScopesAt,
|