@superdoc/mcp 1.6.0-next.18 → 1.6.0-next.19
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/index.js +929 -788
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31600,7 +31600,7 @@ var init_host = __esm(() => {
|
|
|
31600
31600
|
});
|
|
31601
31601
|
|
|
31602
31602
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31603
|
-
var SDK_VERSION = "2.19.0-next.
|
|
31603
|
+
var SDK_VERSION = "2.19.0-next.19";
|
|
31604
31604
|
|
|
31605
31605
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31606
31606
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -103230,12 +103230,19 @@ function normalizeMutationOptions(options, supportCheckOperation) {
|
|
|
103230
103230
|
}
|
|
103231
103231
|
}
|
|
103232
103232
|
const offsetSpace = options?.offsetSpace;
|
|
103233
|
+
const tableCellSelection = options?.tableCellSelection;
|
|
103233
103234
|
return {
|
|
103234
103235
|
expectedRevision: options?.expectedRevision,
|
|
103235
103236
|
changeMode: options?.changeMode ?? "direct",
|
|
103236
103237
|
dryRun: options?.dryRun ?? false,
|
|
103237
103238
|
...supportCheck ? { supportCheck } : {},
|
|
103238
|
-
...offsetSpace === "selection" || offsetSpace === "kernel" ? { offsetSpace } : {}
|
|
103239
|
+
...offsetSpace === "selection" || offsetSpace === "kernel" ? { offsetSpace } : {},
|
|
103240
|
+
...typeof tableCellSelection?.anchorBlockId === "string" && typeof tableCellSelection?.focusBlockId === "string" ? {
|
|
103241
|
+
tableCellSelection: {
|
|
103242
|
+
anchorBlockId: tableCellSelection.anchorBlockId,
|
|
103243
|
+
focusBlockId: tableCellSelection.focusBlockId
|
|
103244
|
+
}
|
|
103245
|
+
} : {}
|
|
103239
103246
|
};
|
|
103240
103247
|
}
|
|
103241
103248
|
function validateSupportCheckGuard(value, operation) {
|
|
@@ -330726,6 +330733,731 @@ var init_review_read_model = __esm(() => {
|
|
|
330726
330733
|
init_comparison_hunk_groups();
|
|
330727
330734
|
});
|
|
330728
330735
|
|
|
330736
|
+
// ../../../v2/document-api-v2-adapter/dist/core/text-coordinate-space.js
|
|
330737
|
+
function projectVisibleOffsetToTracked(map3, offset, bias) {
|
|
330738
|
+
if (!Number.isInteger(offset) || offset < 0 || offset > map3.visibleLength)
|
|
330739
|
+
return null;
|
|
330740
|
+
const candidates = new Set;
|
|
330741
|
+
if (offset === 0)
|
|
330742
|
+
candidates.add(0);
|
|
330743
|
+
if (offset === map3.visibleLength)
|
|
330744
|
+
candidates.add(map3.trackedLength);
|
|
330745
|
+
for (const piece of map3.leaves()) {
|
|
330746
|
+
const visibleWidth2 = piece.visibleEnd - piece.visibleStart;
|
|
330747
|
+
const trackedWidth2 = piece.trackedEnd - piece.trackedStart;
|
|
330748
|
+
if (visibleWidth2 > 0 && trackedWidth2 === visibleWidth2) {
|
|
330749
|
+
if (offset >= piece.visibleStart && offset <= piece.visibleEnd) {
|
|
330750
|
+
candidates.add(piece.trackedStart + offset - piece.visibleStart);
|
|
330751
|
+
}
|
|
330752
|
+
continue;
|
|
330753
|
+
}
|
|
330754
|
+
if (offset === piece.visibleStart)
|
|
330755
|
+
candidates.add(piece.trackedStart);
|
|
330756
|
+
if (offset === piece.visibleEnd)
|
|
330757
|
+
candidates.add(piece.trackedEnd);
|
|
330758
|
+
}
|
|
330759
|
+
if (candidates.size === 0)
|
|
330760
|
+
return null;
|
|
330761
|
+
const values2 = [...candidates];
|
|
330762
|
+
return bias === "upstream" ? Math.min(...values2) : Math.max(...values2);
|
|
330763
|
+
}
|
|
330764
|
+
function projectTrackedOffsetToVisible(map3, offset) {
|
|
330765
|
+
if (!Number.isInteger(offset) || offset < 0 || offset > map3.trackedLength)
|
|
330766
|
+
return null;
|
|
330767
|
+
if (offset === map3.trackedLength)
|
|
330768
|
+
return map3.visibleLength;
|
|
330769
|
+
for (const piece of map3.leaves()) {
|
|
330770
|
+
if (offset < piece.trackedStart || offset > piece.trackedEnd)
|
|
330771
|
+
continue;
|
|
330772
|
+
if (offset === piece.trackedStart)
|
|
330773
|
+
return piece.visibleStart;
|
|
330774
|
+
if (offset === piece.trackedEnd)
|
|
330775
|
+
return piece.visibleEnd;
|
|
330776
|
+
const trackedWidth2 = piece.trackedEnd - piece.trackedStart;
|
|
330777
|
+
const visibleWidth2 = piece.visibleEnd - piece.visibleStart;
|
|
330778
|
+
if (trackedWidth2 === 0 || visibleWidth2 === 0)
|
|
330779
|
+
return piece.visibleStart;
|
|
330780
|
+
if (trackedWidth2 !== visibleWidth2)
|
|
330781
|
+
return null;
|
|
330782
|
+
return piece.visibleStart + offset - piece.trackedStart;
|
|
330783
|
+
}
|
|
330784
|
+
return null;
|
|
330785
|
+
}
|
|
330786
|
+
function projectVisibleRangeToTracked(map3, start, end) {
|
|
330787
|
+
if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start)
|
|
330788
|
+
return null;
|
|
330789
|
+
if (start === end) {
|
|
330790
|
+
const offset = projectVisibleOffsetToTracked(map3, start, "upstream");
|
|
330791
|
+
return offset == null ? null : { start: offset, end: offset };
|
|
330792
|
+
}
|
|
330793
|
+
const trackedStart = projectVisibleOffsetToTracked(map3, start, "downstream");
|
|
330794
|
+
const trackedEnd = projectVisibleOffsetToTracked(map3, end, "upstream");
|
|
330795
|
+
if (trackedStart == null || trackedEnd == null || trackedEnd < trackedStart)
|
|
330796
|
+
return null;
|
|
330797
|
+
return { start: trackedStart, end: trackedEnd };
|
|
330798
|
+
}
|
|
330799
|
+
|
|
330800
|
+
// ../../../v2/document-api-v2-adapter/dist/selection/footnote-range.js
|
|
330801
|
+
function resolveFootnoteRangeIndex(session, index2, start, end) {
|
|
330802
|
+
if (start.story.storyType !== "footnote" || end.story.storyType !== "footnote")
|
|
330803
|
+
return null;
|
|
330804
|
+
const main = getSDDocumentSessionInternalSourceSignalsSnapshot(session)?.stories.find((story) => story.storyKind === "main");
|
|
330805
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, FOOTNOTES_PART_URI3);
|
|
330806
|
+
if (!main || main.completeness.noteAnchorRefs !== "complete" || !bytes)
|
|
330807
|
+
return null;
|
|
330808
|
+
const xml = new TextDecoder().decode(bytes);
|
|
330809
|
+
const parsed = collectXmlElementRanges(xml);
|
|
330810
|
+
if (parsed.errors.length)
|
|
330811
|
+
return null;
|
|
330812
|
+
const notes = parsed.ranges.filter(({ tag }) => tag.namespaceUri === W_NS6 && tag.localName === "footnote").sort((a, b) => a.start - b.start);
|
|
330813
|
+
const sourceEntries = [...index2.entries].sort((a, b) => a.byteStart - b.byteStart);
|
|
330814
|
+
const groups = new Map;
|
|
330815
|
+
let charCursor = 0;
|
|
330816
|
+
let byteCursor = bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
330817
|
+
let entryCursor = 0;
|
|
330818
|
+
for (const note of notes) {
|
|
330819
|
+
const id = readXmlAttributes(note.tag, W_NS6, "id")[0]?.value;
|
|
330820
|
+
if (!id || groups.has(id))
|
|
330821
|
+
return null;
|
|
330822
|
+
byteCursor += TE49.encode(xml.slice(charCursor, note.start)).byteLength;
|
|
330823
|
+
const byteStart = byteCursor;
|
|
330824
|
+
byteCursor += TE49.encode(xml.slice(note.start, note.end)).byteLength;
|
|
330825
|
+
charCursor = note.end;
|
|
330826
|
+
const group = [];
|
|
330827
|
+
while (entryCursor < sourceEntries.length && sourceEntries[entryCursor].byteStart < byteCursor) {
|
|
330828
|
+
const entry = sourceEntries[entryCursor++];
|
|
330829
|
+
if (entry.byteStart >= byteStart && entry.byteEnd <= byteCursor)
|
|
330830
|
+
group.push(entry);
|
|
330831
|
+
}
|
|
330832
|
+
groups.set(id, group);
|
|
330833
|
+
}
|
|
330834
|
+
const entries = [];
|
|
330835
|
+
const seen = new Set;
|
|
330836
|
+
let startOwned = false;
|
|
330837
|
+
let endOwned = false;
|
|
330838
|
+
const references = [...main.noteAnchorRefs].sort((a, b) => (a.bodyChildOrdinal ?? 0) - (b.bodyChildOrdinal ?? 0) || (a.sourceAnchor.stability === "byte-span" ? a.sourceAnchor.byteSpan[0] : 0) - (b.sourceAnchor.stability === "byte-span" ? b.sourceAnchor.byteSpan[0] : 0));
|
|
330839
|
+
for (const ref5 of references) {
|
|
330840
|
+
if (ref5.kind !== "footnote" || !ref5.nativeId || ref5.trackedChangeState === "deleted" || ref5.trackedChangeState === "move-from" || seen.has(ref5.nativeId))
|
|
330841
|
+
continue;
|
|
330842
|
+
seen.add(ref5.nativeId);
|
|
330843
|
+
const group = groups.get(ref5.nativeId);
|
|
330844
|
+
if (!group)
|
|
330845
|
+
return null;
|
|
330846
|
+
for (const entry of group) {
|
|
330847
|
+
startOwned || (startOwned = ref5.nativeId === start.story.noteId && entry.blockId === start.blockId);
|
|
330848
|
+
endOwned || (endOwned = ref5.nativeId === end.story.noteId && entry.blockId === end.blockId);
|
|
330849
|
+
entries.push({ ...entry, ordinal: entries.length });
|
|
330850
|
+
}
|
|
330851
|
+
}
|
|
330852
|
+
if (!startOwned || !endOwned)
|
|
330853
|
+
return null;
|
|
330854
|
+
const byBlockId = new Map(entries.map((entry) => [entry.blockId, entry]));
|
|
330855
|
+
return {
|
|
330856
|
+
entries,
|
|
330857
|
+
duplicateParaIds: index2.duplicateParaIds,
|
|
330858
|
+
entriesByBlockId: byBlockId,
|
|
330859
|
+
byParaId: (blockId) => byBlockId.get(blockId) ?? null
|
|
330860
|
+
};
|
|
330861
|
+
}
|
|
330862
|
+
var W_NS6 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", TE49;
|
|
330863
|
+
var init_footnote_range = __esm(() => {
|
|
330864
|
+
init_sd_document_session_internal();
|
|
330865
|
+
init_note_story();
|
|
330866
|
+
TE49 = new TextEncoder;
|
|
330867
|
+
});
|
|
330868
|
+
|
|
330869
|
+
// ../../../v2/document-api-v2-adapter/dist/selection/live-selection.js
|
|
330870
|
+
function distinctFootnotes(start, end) {
|
|
330871
|
+
return start.storyType === "footnote" && end.storyType === "footnote" && start.noteId !== end.noteId;
|
|
330872
|
+
}
|
|
330873
|
+
function buildVisibleSelectionTarget(story, start, end) {
|
|
330874
|
+
return {
|
|
330875
|
+
kind: "selection",
|
|
330876
|
+
start: { kind: "text", blockId: start.blockId, offset: start.offset, story: start.story ?? story },
|
|
330877
|
+
end: { kind: "text", blockId: end.blockId, offset: end.offset, story: end.story ?? story },
|
|
330878
|
+
...distinctFootnotes(start.story ?? story, end.story ?? story) ? {} : { story }
|
|
330879
|
+
};
|
|
330880
|
+
}
|
|
330881
|
+
function buildSelectionTarget(session, story, start, end, entries) {
|
|
330882
|
+
const hasTrackedEndpoint = start.trackedOffset != null || end.trackedOffset != null;
|
|
330883
|
+
if (!hasTrackedEndpoint)
|
|
330884
|
+
return buildVisibleSelectionTarget(story, start, end);
|
|
330885
|
+
const startEntry = entries[0];
|
|
330886
|
+
const endEntry = entries[entries.length - 1];
|
|
330887
|
+
if (!startEntry || !endEntry)
|
|
330888
|
+
return null;
|
|
330889
|
+
const startMap = readParagraphInlineMap(session, startEntry);
|
|
330890
|
+
const endMap = startEntry === endEntry ? startMap : readParagraphInlineMap(session, endEntry);
|
|
330891
|
+
if (!startMap || !endMap)
|
|
330892
|
+
return null;
|
|
330893
|
+
const resolvedStart = resolveTrackedSelectionEndpoint(startMap, start, "upstream");
|
|
330894
|
+
const resolvedEnd = resolveTrackedSelectionEndpoint(endMap, end, "downstream");
|
|
330895
|
+
if (resolvedStart == null || resolvedEnd == null) {
|
|
330896
|
+
return null;
|
|
330897
|
+
}
|
|
330898
|
+
const [orderedStart2, orderedEnd] = start.blockId === end.blockId && resolvedEnd < resolvedStart ? [resolvedEnd, resolvedStart] : [resolvedStart, resolvedEnd];
|
|
330899
|
+
return {
|
|
330900
|
+
kind: "selection",
|
|
330901
|
+
start: { kind: "text", blockId: start.blockId, offset: orderedStart2, story: start.story ?? story },
|
|
330902
|
+
end: { kind: "text", blockId: end.blockId, offset: orderedEnd, story: end.story ?? story },
|
|
330903
|
+
...distinctFootnotes(start.story ?? story, end.story ?? story) ? {} : { story },
|
|
330904
|
+
coordinateSpace: "tracked"
|
|
330905
|
+
};
|
|
330906
|
+
}
|
|
330907
|
+
function readParagraphInlineMap(session, entry) {
|
|
330908
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
330909
|
+
if (!bytes)
|
|
330910
|
+
return null;
|
|
330911
|
+
return parseParagraphInlineMap(TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
|
|
330912
|
+
}
|
|
330913
|
+
function resolveTrackedSelectionEndpoint(map3, point3, bias) {
|
|
330914
|
+
if (point3.trackedOffset != null) {
|
|
330915
|
+
return Number.isInteger(point3.trackedOffset) && point3.trackedOffset >= 0 && point3.trackedOffset <= map3.trackedLength ? point3.trackedOffset : null;
|
|
330916
|
+
}
|
|
330917
|
+
return projectVisibleOffsetToTracked(map3, clampOffset(point3.offset, map3.visibleLength), bias);
|
|
330918
|
+
}
|
|
330919
|
+
function resolveBrowserLiveSelectionParagraphIndex(session, story, startBlockId, endBlockId) {
|
|
330920
|
+
const mainIndex = getSDDocumentSessionInternalParagraphIndex(session);
|
|
330921
|
+
const stories = listSDDocumentSessionInternalStories(session);
|
|
330922
|
+
if (!story || story.storyType === "body") {
|
|
330923
|
+
return hasSelectionBlocks(mainIndex, startBlockId, endBlockId) ? mainIndex : null;
|
|
330924
|
+
}
|
|
330925
|
+
if (story.storyType === "headerFooterPart") {
|
|
330926
|
+
const resolved = getSDDocumentSessionInternalHeaderFooterPartUriForRefId(session, story.refId);
|
|
330927
|
+
if (!resolved)
|
|
330928
|
+
return null;
|
|
330929
|
+
const match = stories.find((candidate2) => candidate2.partUri === resolved.partUri);
|
|
330930
|
+
if (!match)
|
|
330931
|
+
return null;
|
|
330932
|
+
return paragraphIndexForStory2(session, match.storyId, mainIndex);
|
|
330933
|
+
}
|
|
330934
|
+
const candidates = stories.filter((candidate2) => storyCandidateMatches(candidate2, story));
|
|
330935
|
+
for (const candidate2 of candidates) {
|
|
330936
|
+
const index2 = paragraphIndexForStory2(session, candidate2.storyId, mainIndex);
|
|
330937
|
+
if (hasSelectionBlocks(index2, startBlockId, endBlockId))
|
|
330938
|
+
return index2;
|
|
330939
|
+
}
|
|
330940
|
+
return null;
|
|
330941
|
+
}
|
|
330942
|
+
function paragraphIndexForStory2(session, storyId, mainIndex) {
|
|
330943
|
+
if (mainIndex?.entries[0]?.storyId === storyId)
|
|
330944
|
+
return mainIndex;
|
|
330945
|
+
return getSDDocumentSessionInternalStoryParagraphIndex(session, storyId);
|
|
330946
|
+
}
|
|
330947
|
+
function storyCandidateMatches(candidate2, story) {
|
|
330948
|
+
switch (story.storyType) {
|
|
330949
|
+
case "headerFooterSlot":
|
|
330950
|
+
return candidate2.storyKind === story.headerFooterKind;
|
|
330951
|
+
case "footnote":
|
|
330952
|
+
return candidate2.storyKind === "footnotes";
|
|
330953
|
+
case "endnote":
|
|
330954
|
+
return candidate2.storyKind === "endnotes";
|
|
330955
|
+
case "textbox":
|
|
330956
|
+
return candidate2.storyKind === "textbox" && candidate2.textboxId === story.textboxId;
|
|
330957
|
+
default:
|
|
330958
|
+
return false;
|
|
330959
|
+
}
|
|
330960
|
+
}
|
|
330961
|
+
function hasSelectionBlocks(index2, startBlockId, endBlockId) {
|
|
330962
|
+
return Boolean(index2?.byParaId(startBlockId) && index2.byParaId(endBlockId));
|
|
330963
|
+
}
|
|
330964
|
+
function clampOffset(offset, textLength) {
|
|
330965
|
+
return Math.max(0, Math.min(textLength, offset));
|
|
330966
|
+
}
|
|
330967
|
+
function resolveTableCellSelectionEntries(session, story, anchorBlockId, focusBlockId) {
|
|
330968
|
+
const index2 = resolveBrowserLiveSelectionParagraphIndex(session, story, anchorBlockId, focusBlockId);
|
|
330969
|
+
const anchorEntry = index2?.byParaId(anchorBlockId);
|
|
330970
|
+
if (!index2 || !anchorEntry || index2.duplicateParaIds.has(anchorBlockId) || index2.duplicateParaIds.has(focusBlockId))
|
|
330971
|
+
return null;
|
|
330972
|
+
const catalog = readTableCatalogForSession(session, anchorEntry.storyId);
|
|
330973
|
+
const anchor = catalog?.byParagraphId.get(anchorBlockId);
|
|
330974
|
+
const focus = catalog?.byParagraphId.get(focusBlockId);
|
|
330975
|
+
if (!anchor || !focus || anchor.table !== focus.table || anchor.cell === focus.cell)
|
|
330976
|
+
return null;
|
|
330977
|
+
for (const endpoint of [anchor, focus]) {
|
|
330978
|
+
if (endpoint.paragraph.isDirectCellChild)
|
|
330979
|
+
continue;
|
|
330980
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, anchorEntry.partUri);
|
|
330981
|
+
if (!bytes)
|
|
330982
|
+
return null;
|
|
330983
|
+
const context = buildStructuralBoundaryMap(bytes.subarray(endpoint.cell.bodyByteStart, endpoint.cell.bodyByteEnd)).byBlockId(endpoint.paragraph.paragraphId);
|
|
330984
|
+
if (!context?.blockSdtPath.length || context.tableCellPath.length || context.hasNonEditableBlockSdtContent)
|
|
330985
|
+
return null;
|
|
330986
|
+
}
|
|
330987
|
+
const minRow = Math.min(anchor.row.rowIndex, focus.row.rowIndex);
|
|
330988
|
+
const maxRow = Math.max(anchor.row.rowIndex, focus.row.rowIndex);
|
|
330989
|
+
const minCol = Math.min(anchor.cell.cellOrdinal, focus.cell.cellOrdinal);
|
|
330990
|
+
const maxCol = Math.max(anchor.cell.cellOrdinal, focus.cell.cellOrdinal);
|
|
330991
|
+
const selectedCells = anchor.table.rows.filter((row) => row.rowIndex >= minRow && row.rowIndex <= maxRow).flatMap((row) => row.cells.filter((cell) => cell.cellOrdinal >= minCol && cell.cellOrdinal <= maxCol));
|
|
330992
|
+
const entries = [];
|
|
330993
|
+
for (const cell of selectedCells) {
|
|
330994
|
+
for (const paragraph3 of cell.paragraphs) {
|
|
330995
|
+
if (!paragraph3.paragraphId || index2.duplicateParaIds.has(paragraph3.paragraphId))
|
|
330996
|
+
return null;
|
|
330997
|
+
const entry = index2.byParaId(paragraph3.paragraphId);
|
|
330998
|
+
if (!entry || entry.byteStart < cell.bodyByteStart || entry.byteEnd > cell.bodyByteEnd)
|
|
330999
|
+
return null;
|
|
331000
|
+
if (!entries.includes(entry))
|
|
331001
|
+
entries.push(entry);
|
|
331002
|
+
}
|
|
331003
|
+
}
|
|
331004
|
+
return entries.length ? entries.sort((a, b) => a.ordinal - b.ordinal) : null;
|
|
331005
|
+
}
|
|
331006
|
+
function resolveEntries(session, input) {
|
|
331007
|
+
let index2 = resolveBrowserLiveSelectionParagraphIndex(session, input.story, input.start.blockId, input.end.blockId);
|
|
331008
|
+
if (!index2)
|
|
331009
|
+
return null;
|
|
331010
|
+
if (input.tableCells) {
|
|
331011
|
+
const entries2 = resolveTableCellSelectionEntries(session, input.story, input.start.blockId, input.end.blockId);
|
|
331012
|
+
if (!entries2?.length)
|
|
331013
|
+
return null;
|
|
331014
|
+
const first = entries2[0];
|
|
331015
|
+
const last = entries2[entries2.length - 1];
|
|
331016
|
+
return {
|
|
331017
|
+
entries: entries2,
|
|
331018
|
+
start: { blockId: first.blockId, offset: 0 },
|
|
331019
|
+
end: { blockId: last.blockId, offset: last.textLength },
|
|
331020
|
+
target: {
|
|
331021
|
+
kind: "text",
|
|
331022
|
+
segments: entries2.map((entry) => ({
|
|
331023
|
+
blockId: entry.blockId,
|
|
331024
|
+
range: { start: 0, end: entry.textLength }
|
|
331025
|
+
})),
|
|
331026
|
+
story: input.story
|
|
331027
|
+
}
|
|
331028
|
+
};
|
|
331029
|
+
}
|
|
331030
|
+
const startStory = input.start.story ?? input.story;
|
|
331031
|
+
const endStory = input.end.story ?? input.story;
|
|
331032
|
+
if (distinctFootnotes(startStory, endStory)) {
|
|
331033
|
+
index2 = resolveFootnoteRangeIndex(session, index2, { blockId: input.start.blockId, story: startStory }, { blockId: input.end.blockId, story: endStory });
|
|
331034
|
+
if (!index2)
|
|
331035
|
+
return null;
|
|
331036
|
+
}
|
|
331037
|
+
if (index2.duplicateParaIds.has(input.start.blockId) || index2.duplicateParaIds.has(input.end.blockId))
|
|
331038
|
+
return null;
|
|
331039
|
+
let startEntry = index2.byParaId(input.start.blockId);
|
|
331040
|
+
let endEntry = index2.byParaId(input.end.blockId);
|
|
331041
|
+
if (!startEntry || !endEntry || startEntry.storyId !== endEntry.storyId)
|
|
331042
|
+
return null;
|
|
331043
|
+
let startPoint = input.start;
|
|
331044
|
+
let endPoint = input.end;
|
|
331045
|
+
if (startEntry.ordinal > endEntry.ordinal) {
|
|
331046
|
+
[startEntry, endEntry] = [endEntry, startEntry];
|
|
331047
|
+
[startPoint, endPoint] = [endPoint, startPoint];
|
|
331048
|
+
}
|
|
331049
|
+
const entries = index2.entries.slice(startEntry.ordinal, endEntry.ordinal + 1);
|
|
331050
|
+
if (entries.length === 0)
|
|
331051
|
+
return null;
|
|
331052
|
+
const visibleStart = resolveVisibleSelectionOffset(session, startEntry, startPoint);
|
|
331053
|
+
const visibleEnd = resolveVisibleSelectionOffset(session, endEntry, endPoint);
|
|
331054
|
+
if (visibleStart == null || visibleEnd == null)
|
|
331055
|
+
return null;
|
|
331056
|
+
const segments = entries.map((entry, idx) => {
|
|
331057
|
+
const start = idx === 0 ? visibleStart : 0;
|
|
331058
|
+
const end = idx === entries.length - 1 ? visibleEnd : entry.textLength;
|
|
331059
|
+
return {
|
|
331060
|
+
blockId: entry.blockId,
|
|
331061
|
+
range: { start, end: Math.max(start, end) }
|
|
331062
|
+
};
|
|
331063
|
+
});
|
|
331064
|
+
return {
|
|
331065
|
+
target: {
|
|
331066
|
+
kind: "text",
|
|
331067
|
+
segments,
|
|
331068
|
+
...input.story ? { story: input.story } : {}
|
|
331069
|
+
},
|
|
331070
|
+
entries,
|
|
331071
|
+
start: startPoint,
|
|
331072
|
+
end: endPoint
|
|
331073
|
+
};
|
|
331074
|
+
}
|
|
331075
|
+
function resolveVisibleSelectionOffset(session, entry, point3) {
|
|
331076
|
+
if (point3.trackedOffset == null)
|
|
331077
|
+
return clampOffset(point3.offset, entry.textLength);
|
|
331078
|
+
const map3 = readParagraphInlineMap(session, entry);
|
|
331079
|
+
return map3 ? projectTrackedOffsetToVisible(map3, point3.trackedOffset) : null;
|
|
331080
|
+
}
|
|
331081
|
+
function resolveBrowserLiveSelectionForSession(session, input, options = {}) {
|
|
331082
|
+
const resolved = resolveEntries(session, input);
|
|
331083
|
+
if (!resolved)
|
|
331084
|
+
return null;
|
|
331085
|
+
const selectionTarget = buildSelectionTarget(session, input.story, resolved.start, resolved.end, resolved.entries);
|
|
331086
|
+
if (!selectionTarget)
|
|
331087
|
+
return null;
|
|
331088
|
+
const contiguous = resolved.entries.every((entry, i2) => i2 === 0 || entry.ordinal === resolved.entries[i2 - 1].ordinal + 1);
|
|
331089
|
+
const reviewIds = readActiveReviewIds(session, resolved.entries, resolved.target.segments, options);
|
|
331090
|
+
return {
|
|
331091
|
+
target: distinctFootnotes(resolved.start.story ?? input.story, resolved.end.story ?? input.story) ? null : resolved.target,
|
|
331092
|
+
selectionTarget: input.tableCells && !contiguous ? null : selectionTarget,
|
|
331093
|
+
text: input.includeText === true ? readSelectionText(session, resolved.entries, resolved.target.segments) : "",
|
|
331094
|
+
activeMarks: readActiveMarks(session, resolved.entries, resolved.target.segments),
|
|
331095
|
+
activeCommentIds: reviewIds.activeCommentIds,
|
|
331096
|
+
activeChangeIds: reviewIds.activeChangeIds
|
|
331097
|
+
};
|
|
331098
|
+
}
|
|
331099
|
+
function readSelectionText(session, entries, segments) {
|
|
331100
|
+
const slices = [];
|
|
331101
|
+
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
331102
|
+
const entry = entries[i2];
|
|
331103
|
+
const segment = segments[i2];
|
|
331104
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
331105
|
+
if (!bytes)
|
|
331106
|
+
return "";
|
|
331107
|
+
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
331108
|
+
const paragraphText2 = visibleParagraphTextFromXml(xml);
|
|
331109
|
+
const start = clampOffset(segment.range.start, paragraphText2.length);
|
|
331110
|
+
const end = clampOffset(segment.range.end, paragraphText2.length);
|
|
331111
|
+
slices.push(paragraphText2.slice(start, Math.max(start, end)));
|
|
331112
|
+
}
|
|
331113
|
+
return slices.join(" ");
|
|
331114
|
+
}
|
|
331115
|
+
function readActiveMarks(session, entries, segments) {
|
|
331116
|
+
let common = null;
|
|
331117
|
+
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
331118
|
+
const entry = entries[i2];
|
|
331119
|
+
const segment = segments[i2];
|
|
331120
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
331121
|
+
if (!bytes)
|
|
331122
|
+
return [];
|
|
331123
|
+
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
331124
|
+
const paragraphText2 = visibleParagraphTextFromXml(xml);
|
|
331125
|
+
const start = clampOffset(segment.range.start, paragraphText2.length);
|
|
331126
|
+
const end = clampOffset(segment.range.end, paragraphText2.length);
|
|
331127
|
+
const marks = new Set(activeMarksForParagraphXmlRange(xml, start, Math.max(start, end)));
|
|
331128
|
+
common = common == null ? marks : intersectStringSets(common, marks);
|
|
331129
|
+
}
|
|
331130
|
+
if (!common)
|
|
331131
|
+
return [];
|
|
331132
|
+
return ACTIVE_MARK_ORDER.filter((mark) => common.has(mark));
|
|
331133
|
+
}
|
|
331134
|
+
function readActiveReviewIds(session, entries, segments, options) {
|
|
331135
|
+
return {
|
|
331136
|
+
activeCommentIds: readActiveCommentIds(session, segments),
|
|
331137
|
+
activeChangeIds: readActiveChangeIds(session, entries, segments, options)
|
|
331138
|
+
};
|
|
331139
|
+
}
|
|
331140
|
+
function readActiveCommentIds(session, segments) {
|
|
331141
|
+
const catalog = getSDDocumentSessionInternalCommentsCatalog(session);
|
|
331142
|
+
if (!catalog)
|
|
331143
|
+
return [];
|
|
331144
|
+
const anchorIndex = getSDDocumentSessionInternalCommentAnchorIndex(session);
|
|
331145
|
+
const ids = [];
|
|
331146
|
+
for (const [sourceWId, hits] of anchorIndex.hitsBySourceWId) {
|
|
331147
|
+
const catalogEntries = catalog.commentsBySourceWId.get(sourceWId);
|
|
331148
|
+
if (!catalogEntries || catalogEntries.length === 0)
|
|
331149
|
+
continue;
|
|
331150
|
+
let overlaps2 = false;
|
|
331151
|
+
for (const hit of hits) {
|
|
331152
|
+
for (const hitSegment of hit.segments) {
|
|
331153
|
+
if (!hitSegment.blockId)
|
|
331154
|
+
continue;
|
|
331155
|
+
const selectionSegment = segments.find((segment) => segment.blockId === hitSegment.blockId);
|
|
331156
|
+
if (!selectionSegment)
|
|
331157
|
+
continue;
|
|
331158
|
+
if (rangesOverlap9(hitSegment.start, hitSegment.end, selectionSegment.range.start, selectionSegment.range.end)) {
|
|
331159
|
+
overlaps2 = true;
|
|
331160
|
+
break;
|
|
331161
|
+
}
|
|
331162
|
+
}
|
|
331163
|
+
if (overlaps2)
|
|
331164
|
+
break;
|
|
331165
|
+
}
|
|
331166
|
+
if (!overlaps2)
|
|
331167
|
+
continue;
|
|
331168
|
+
for (const entry of catalogEntries)
|
|
331169
|
+
pushUnique(ids, entry.commentId);
|
|
331170
|
+
}
|
|
331171
|
+
return ids;
|
|
331172
|
+
}
|
|
331173
|
+
function readActiveChangeIds(session, entries, segments, options) {
|
|
331174
|
+
const activeSourceIds = new Set;
|
|
331175
|
+
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
331176
|
+
const entry = entries[i2];
|
|
331177
|
+
const segment = segments[i2];
|
|
331178
|
+
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
331179
|
+
if (!bytes)
|
|
331180
|
+
return [];
|
|
331181
|
+
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
331182
|
+
const paragraphText2 = visibleParagraphTextFromXml(xml);
|
|
331183
|
+
const start = clampOffset(segment.range.start, paragraphText2.length);
|
|
331184
|
+
const end = clampOffset(segment.range.end, paragraphText2.length);
|
|
331185
|
+
for (const sourceId of activeTrackedChangeSourceIdsForParagraphXmlRange(xml, start, Math.max(start, end))) {
|
|
331186
|
+
activeSourceIds.add(sourceId);
|
|
331187
|
+
}
|
|
331188
|
+
}
|
|
331189
|
+
if (activeSourceIds.size === 0)
|
|
331190
|
+
return [];
|
|
331191
|
+
const resolved = options.resolveTrackChangeIds?.(activeSourceIds);
|
|
331192
|
+
if (resolved)
|
|
331193
|
+
return [...new Set(resolved)];
|
|
331194
|
+
const sourceIdToChangeIds = buildTrackedChangeSourceMap(options.trackChangesList?.()?.items ?? []);
|
|
331195
|
+
if (sourceIdToChangeIds.size === 0)
|
|
331196
|
+
return [];
|
|
331197
|
+
const out = [];
|
|
331198
|
+
for (const sourceId of activeSourceIds) {
|
|
331199
|
+
const changeIds = sourceIdToChangeIds.get(sourceId);
|
|
331200
|
+
if (!changeIds)
|
|
331201
|
+
continue;
|
|
331202
|
+
for (const changeId of changeIds)
|
|
331203
|
+
pushUnique(out, changeId);
|
|
331204
|
+
}
|
|
331205
|
+
return out;
|
|
331206
|
+
}
|
|
331207
|
+
function buildTrackedChangeSourceMap(items) {
|
|
331208
|
+
const map3 = new Map;
|
|
331209
|
+
for (const item of items) {
|
|
331210
|
+
if (!item || typeof item !== "object")
|
|
331211
|
+
continue;
|
|
331212
|
+
const record3 = item;
|
|
331213
|
+
const id = typeof record3.id === "string" ? record3.id : null;
|
|
331214
|
+
if (!id)
|
|
331215
|
+
continue;
|
|
331216
|
+
const sourceIds = record3.sourceIds && typeof record3.sourceIds === "object" ? record3.sourceIds : {};
|
|
331217
|
+
const wordRevisionIds = record3.wordRevisionIds && typeof record3.wordRevisionIds === "object" ? record3.wordRevisionIds : {};
|
|
331218
|
+
pushTrackedSourceMap(map3, sourceIds.wordIdInsert, id);
|
|
331219
|
+
pushTrackedSourceMap(map3, sourceIds.wordIdDelete, id);
|
|
331220
|
+
for (const sourceId of Array.isArray(sourceIds.wordIdOther) ? sourceIds.wordIdOther : []) {
|
|
331221
|
+
pushTrackedSourceMap(map3, sourceId, id);
|
|
331222
|
+
}
|
|
331223
|
+
pushTrackedSourceMap(map3, wordRevisionIds.insert, id);
|
|
331224
|
+
pushTrackedSourceMap(map3, wordRevisionIds.delete, id);
|
|
331225
|
+
pushTrackedSourceMap(map3, wordRevisionIds.format, id);
|
|
331226
|
+
}
|
|
331227
|
+
return map3;
|
|
331228
|
+
}
|
|
331229
|
+
function pushTrackedSourceMap(map3, sourceId, changeId) {
|
|
331230
|
+
if (typeof sourceId !== "string" || sourceId.length === 0)
|
|
331231
|
+
return;
|
|
331232
|
+
const ids = map3.get(sourceId) ?? [];
|
|
331233
|
+
pushUnique(ids, changeId);
|
|
331234
|
+
map3.set(sourceId, ids);
|
|
331235
|
+
}
|
|
331236
|
+
function visibleParagraphTextFromXml(xml) {
|
|
331237
|
+
const stripped = stripTextboxContent2(stripParagraphProperties3(stripDeletedRevisions(xml)));
|
|
331238
|
+
let out = "";
|
|
331239
|
+
for (const token of stripped.matchAll(/<[\w.-]+:t\b[^>]*>([\s\S]*?)<\/[\w.-]+:t>|<[\w.-]+:(tab|br|cr)\b[^>]*\/>/g)) {
|
|
331240
|
+
if (token[1] != null) {
|
|
331241
|
+
out += decodeXmlText10(token[1]);
|
|
331242
|
+
continue;
|
|
331243
|
+
}
|
|
331244
|
+
out += token[2] === "tab" ? "\t" : `
|
|
331245
|
+
`;
|
|
331246
|
+
}
|
|
331247
|
+
return out;
|
|
331248
|
+
}
|
|
331249
|
+
function visibleRunMarkSlicesFromXml(xml) {
|
|
331250
|
+
const stripped = stripTextboxContent2(stripParagraphProperties3(stripDeletedRevisions(xml)));
|
|
331251
|
+
const slices = [];
|
|
331252
|
+
let cursor = 0;
|
|
331253
|
+
for (const match of stripped.matchAll(/<(?:[\w.-]+:)?r\b[^>]*>[\s\S]*?<\/(?:[\w.-]+:)?r>/g)) {
|
|
331254
|
+
const runXml = match[0];
|
|
331255
|
+
const textLength = visibleParagraphTextFromXml(runXml).length;
|
|
331256
|
+
if (textLength > 0) {
|
|
331257
|
+
slices.push({ start: cursor, end: cursor + textLength, marks: activeMarksForRunXml(runXml) });
|
|
331258
|
+
}
|
|
331259
|
+
cursor += textLength;
|
|
331260
|
+
}
|
|
331261
|
+
return slices;
|
|
331262
|
+
}
|
|
331263
|
+
function activeMarksForRunXml(runXml) {
|
|
331264
|
+
const rPr = findFirstElement(runXml, "rPr")?.xml ?? "";
|
|
331265
|
+
if (!rPr)
|
|
331266
|
+
return [];
|
|
331267
|
+
const marks = [];
|
|
331268
|
+
if (hasOnOffRunProperty(rPr, "b"))
|
|
331269
|
+
marks.push("bold");
|
|
331270
|
+
if (hasOnOffRunProperty(rPr, "i"))
|
|
331271
|
+
marks.push("italic");
|
|
331272
|
+
if (hasOnOffRunProperty(rPr, "u"))
|
|
331273
|
+
marks.push("underline");
|
|
331274
|
+
if (hasOnOffRunProperty(rPr, "strike"))
|
|
331275
|
+
marks.push("strikethrough");
|
|
331276
|
+
return marks;
|
|
331277
|
+
}
|
|
331278
|
+
function hasOnOffRunProperty(rPrXml, localName2) {
|
|
331279
|
+
const match = rPrXml.match(new RegExp(`<(?:[\\w.-]+:)?${localName2}\\b([^>]*)\\/?>`, "i"));
|
|
331280
|
+
if (!match)
|
|
331281
|
+
return false;
|
|
331282
|
+
const attrs = match[1] ?? "";
|
|
331283
|
+
const val = attrs.match(/(?:^|\s)(?:[\w.-]+:)?val=(["'])(.*?)\1/i)?.[2]?.toLowerCase();
|
|
331284
|
+
return val !== "0" && val !== "false" && val !== "off" && val !== "none";
|
|
331285
|
+
}
|
|
331286
|
+
function activeMarksForParagraphXmlRange(xml, start, end) {
|
|
331287
|
+
const slices = visibleRunMarkSlicesFromXml(xml);
|
|
331288
|
+
if (slices.length === 0)
|
|
331289
|
+
return [];
|
|
331290
|
+
if (start === end) {
|
|
331291
|
+
const containing = slices.find((slice) => start > slice.start && start < slice.end);
|
|
331292
|
+
if (containing)
|
|
331293
|
+
return containing.marks;
|
|
331294
|
+
let previous3 = null;
|
|
331295
|
+
for (const slice of slices) {
|
|
331296
|
+
if (slice.end <= start)
|
|
331297
|
+
previous3 = slice;
|
|
331298
|
+
}
|
|
331299
|
+
if (previous3)
|
|
331300
|
+
return previous3.marks;
|
|
331301
|
+
return slices[0]?.marks ?? [];
|
|
331302
|
+
}
|
|
331303
|
+
let common = null;
|
|
331304
|
+
for (const slice of slices) {
|
|
331305
|
+
if (Math.max(start, slice.start) >= Math.min(end, slice.end))
|
|
331306
|
+
continue;
|
|
331307
|
+
const marks = new Set(slice.marks);
|
|
331308
|
+
common = common == null ? marks : intersectStringSets(common, marks);
|
|
331309
|
+
}
|
|
331310
|
+
if (!common)
|
|
331311
|
+
return [];
|
|
331312
|
+
return ACTIVE_MARK_ORDER.filter((mark) => common.has(mark));
|
|
331313
|
+
}
|
|
331314
|
+
function activeTrackedChangeSourceIdsForParagraphXmlRange(xml, start, end) {
|
|
331315
|
+
const slices = visibleTrackedChangeSourceSlicesFromXml(xml);
|
|
331316
|
+
if (slices.length === 0)
|
|
331317
|
+
return [];
|
|
331318
|
+
const out = [];
|
|
331319
|
+
for (const slice of slices) {
|
|
331320
|
+
if (!rangesOverlap9(slice.start, slice.end, start, end))
|
|
331321
|
+
continue;
|
|
331322
|
+
for (const sourceId of slice.sourceIds)
|
|
331323
|
+
pushUnique(out, sourceId);
|
|
331324
|
+
}
|
|
331325
|
+
return out;
|
|
331326
|
+
}
|
|
331327
|
+
function visibleTrackedChangeSourceSlicesFromXml(xml) {
|
|
331328
|
+
const stripped = stripTextboxContent2(stripParagraphProperties3(xml));
|
|
331329
|
+
const slices = [];
|
|
331330
|
+
const activeSourceIdStack = [];
|
|
331331
|
+
const elementStack = [];
|
|
331332
|
+
let delDepth = 0;
|
|
331333
|
+
let cursor = 0;
|
|
331334
|
+
const tokenRe = /<\/(?:[\w.-]+:)?(ins|del|moveFrom|moveTo)>|<(?:[\w.-]+:)?t\b[^>]*>([\s\S]*?)<\/(?:[\w.-]+:)?t>|<(?:[\w.-]+:)?delText\b[^>]*>([\s\S]*?)<\/(?:[\w.-]+:)?delText>|<(?:[\w.-]+:)?(ins|del|moveFrom|moveTo|tab|br|cr)\b([^>]*)\/?>/g;
|
|
331335
|
+
for (const match of stripped.matchAll(tokenRe)) {
|
|
331336
|
+
const closingName = match[1];
|
|
331337
|
+
const tText = match[2];
|
|
331338
|
+
const delText = match[3];
|
|
331339
|
+
const openingName = match[4];
|
|
331340
|
+
const attrs = match[5] ?? "";
|
|
331341
|
+
if (closingName) {
|
|
331342
|
+
const frame = elementStack.pop();
|
|
331343
|
+
if (frame?.hadId)
|
|
331344
|
+
activeSourceIdStack.pop();
|
|
331345
|
+
if (closingName === "del")
|
|
331346
|
+
delDepth = Math.max(0, delDepth - 1);
|
|
331347
|
+
continue;
|
|
331348
|
+
}
|
|
331349
|
+
if (tText != null) {
|
|
331350
|
+
if (delDepth > 0) {
|
|
331351
|
+
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
331352
|
+
} else {
|
|
331353
|
+
cursor = pushTrackedSourceSlice(slices, cursor, decodeXmlText10(tText).length, activeSourceIdStack);
|
|
331354
|
+
}
|
|
331355
|
+
continue;
|
|
331356
|
+
}
|
|
331357
|
+
if (delText != null) {
|
|
331358
|
+
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
331359
|
+
continue;
|
|
331360
|
+
}
|
|
331361
|
+
if (!openingName)
|
|
331362
|
+
continue;
|
|
331363
|
+
if (openingName === "tab" || openingName === "br" || openingName === "cr") {
|
|
331364
|
+
if (delDepth > 0) {
|
|
331365
|
+
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
331366
|
+
} else {
|
|
331367
|
+
cursor = pushTrackedSourceSlice(slices, cursor, 1, activeSourceIdStack);
|
|
331368
|
+
}
|
|
331369
|
+
continue;
|
|
331370
|
+
}
|
|
331371
|
+
const sourceId = readXmlAttribute4(attrs, "id");
|
|
331372
|
+
const selfClosing = match[0].endsWith("/>");
|
|
331373
|
+
if (!selfClosing) {
|
|
331374
|
+
elementStack.push({ name: openingName, hadId: Boolean(sourceId) });
|
|
331375
|
+
if (sourceId)
|
|
331376
|
+
activeSourceIdStack.push(sourceId);
|
|
331377
|
+
if (openingName === "del")
|
|
331378
|
+
delDepth += 1;
|
|
331379
|
+
}
|
|
331380
|
+
}
|
|
331381
|
+
return slices;
|
|
331382
|
+
}
|
|
331383
|
+
function pushTrackedSourceSlice(slices, cursor, textLength, activeSourceIds) {
|
|
331384
|
+
if (textLength <= 0)
|
|
331385
|
+
return cursor;
|
|
331386
|
+
if (activeSourceIds.length > 0) {
|
|
331387
|
+
slices.push({ start: cursor, end: cursor + textLength, sourceIds: [...new Set(activeSourceIds)] });
|
|
331388
|
+
}
|
|
331389
|
+
return cursor + textLength;
|
|
331390
|
+
}
|
|
331391
|
+
function pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIds) {
|
|
331392
|
+
if (activeSourceIds.length === 0)
|
|
331393
|
+
return;
|
|
331394
|
+
slices.push({ start: cursor, end: cursor, sourceIds: [...new Set(activeSourceIds)] });
|
|
331395
|
+
}
|
|
331396
|
+
function readXmlAttribute4(attrs, localName2) {
|
|
331397
|
+
const match = attrs.match(new RegExp(`(?:^|\\s)(?:[\\w.-]+:)?${localName2}=(["'])(.*?)\\1`, "i"));
|
|
331398
|
+
return match?.[2] ?? null;
|
|
331399
|
+
}
|
|
331400
|
+
function rangesOverlap9(aStart, aEnd, bStart, bEnd) {
|
|
331401
|
+
const leftStart = Math.min(aStart, aEnd);
|
|
331402
|
+
const leftEnd = Math.max(aStart, aEnd);
|
|
331403
|
+
const rightStart = Math.min(bStart, bEnd);
|
|
331404
|
+
const rightEnd = Math.max(bStart, bEnd);
|
|
331405
|
+
if (rightStart === rightEnd)
|
|
331406
|
+
return rightStart >= leftStart && rightStart <= leftEnd;
|
|
331407
|
+
if (leftStart === leftEnd)
|
|
331408
|
+
return leftStart >= rightStart && leftStart <= rightEnd;
|
|
331409
|
+
return Math.max(leftStart, rightStart) < Math.min(leftEnd, rightEnd);
|
|
331410
|
+
}
|
|
331411
|
+
function intersectStringSets(left, right) {
|
|
331412
|
+
const out = new Set;
|
|
331413
|
+
for (const value2 of left) {
|
|
331414
|
+
if (right.has(value2))
|
|
331415
|
+
out.add(value2);
|
|
331416
|
+
}
|
|
331417
|
+
return out;
|
|
331418
|
+
}
|
|
331419
|
+
function stripParagraphProperties3(xml) {
|
|
331420
|
+
return stripElements(xml, "pPr");
|
|
331421
|
+
}
|
|
331422
|
+
function stripDeletedRevisions(xml) {
|
|
331423
|
+
return xml.replace(/<[\w.-]+:del\b(?![^>]*\/>)[^>]*>[\s\S]*?<\/[\w.-]+:del>/g, "");
|
|
331424
|
+
}
|
|
331425
|
+
function stripTextboxContent2(xml) {
|
|
331426
|
+
return xml.replace(/<(?:[\w.-]+:)?txbxContent\b[^>]*>[\s\S]*?<\/(?:[\w.-]+:)?txbxContent>/g, "").replace(/<(?:[\w.-]+:)?txbxContent\b[^>]*>[\s\S]*$/g, "");
|
|
331427
|
+
}
|
|
331428
|
+
function decodeXmlText10(escaped) {
|
|
331429
|
+
return escaped.replace(/&(lt|gt|amp|quot|apos|#\d+|#x[0-9a-fA-F]+);/g, (_, entity) => {
|
|
331430
|
+
switch (entity) {
|
|
331431
|
+
case "lt":
|
|
331432
|
+
return "<";
|
|
331433
|
+
case "gt":
|
|
331434
|
+
return ">";
|
|
331435
|
+
case "amp":
|
|
331436
|
+
return "&";
|
|
331437
|
+
case "quot":
|
|
331438
|
+
return '"';
|
|
331439
|
+
case "apos":
|
|
331440
|
+
return "'";
|
|
331441
|
+
default: {
|
|
331442
|
+
const cp = entity.startsWith("#x") ? Number.parseInt(entity.slice(2), 16) : Number.parseInt(entity.slice(1), 10);
|
|
331443
|
+
return Number.isFinite(cp) ? String.fromCodePoint(cp) : `&${entity};`;
|
|
331444
|
+
}
|
|
331445
|
+
}
|
|
331446
|
+
});
|
|
331447
|
+
}
|
|
331448
|
+
function pushUnique(out, id) {
|
|
331449
|
+
if (typeof id === "string" && id.length > 0 && !out.includes(id))
|
|
331450
|
+
out.push(id);
|
|
331451
|
+
}
|
|
331452
|
+
var TEXT_DECODER7, ACTIVE_MARK_ORDER;
|
|
331453
|
+
var init_live_selection = __esm(() => {
|
|
331454
|
+
init_sd_document_session_internal();
|
|
331455
|
+
init_sd_document_session_internal();
|
|
331456
|
+
init_footnote_range();
|
|
331457
|
+
TEXT_DECODER7 = new TextDecoder;
|
|
331458
|
+
ACTIVE_MARK_ORDER = ["bold", "italic", "underline", "strikethrough"];
|
|
331459
|
+
});
|
|
331460
|
+
|
|
330729
331461
|
// ../../../v2/document-api-v2-adapter/dist/tracked-changes/local-text-projection.js
|
|
330730
331462
|
function currentCache(context) {
|
|
330731
331463
|
const revision = getSDDocumentSessionInternalPackageRevision(context.session);
|
|
@@ -331705,7 +332437,7 @@ class V2ClearContentAdapter {
|
|
|
331705
332437
|
}
|
|
331706
332438
|
if (options?.dryRun)
|
|
331707
332439
|
return { success: true };
|
|
331708
|
-
const nextBytes =
|
|
332440
|
+
const nextBytes = TE50.encode(nextXml);
|
|
331709
332441
|
const committed = commitKernelStorySurfacePatch({
|
|
331710
332442
|
context: this.context,
|
|
331711
332443
|
txIdPrefix: selectedBlockIds ? "range-ref-whole-body-replace" : "internal-clearContent",
|
|
@@ -331808,14 +332540,14 @@ function rewriteBodyToSingleEmptyParagraph(xml, paragraphId2) {
|
|
|
331808
332540
|
const emptyParagraph = `<${wordPrefix}:p${identityNamespace} ${identityPrefix}:paraId="${paragraphId2}">` + `<${wordPrefix}:r><${wordPrefix}:t></${wordPrefix}:t></${wordPrefix}:r></${wordPrefix}:p>`;
|
|
331809
332541
|
return `${xml.slice(0, body.openEnd)}${emptyParagraph}${sectPrXml}${xml.slice(body.closeStart)}`;
|
|
331810
332542
|
}
|
|
331811
|
-
var
|
|
332543
|
+
var TE50, WORD_NS4 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", STRICT_WORD_NS = "http://purl.oclc.org/ooxml/wordprocessingml/main", WORD_2010_NS = "http://schemas.microsoft.com/office/word/2010/wordml";
|
|
331812
332544
|
var init_clear_content_adapter = __esm(() => {
|
|
331813
332545
|
init_sd_document_session_internal();
|
|
331814
332546
|
init_document_reader();
|
|
331815
332547
|
init_xml();
|
|
331816
332548
|
init_tracked_body_replacement();
|
|
331817
332549
|
init_receipt_entities();
|
|
331818
|
-
|
|
332550
|
+
TE50 = new TextEncoder;
|
|
331819
332551
|
});
|
|
331820
332552
|
|
|
331821
332553
|
// ../../../v2/document-api-v2-adapter/dist/selection-mutation/replacement-span.js
|
|
@@ -333242,7 +333974,35 @@ async function readEffectiveInlineUniformity(context, input) {
|
|
|
333242
333974
|
...input.offsetSpace ? { offsetSpace: input.offsetSpace } : {}
|
|
333243
333975
|
};
|
|
333244
333976
|
let ranges;
|
|
333245
|
-
if (
|
|
333977
|
+
if (input.tableCellSelection) {
|
|
333978
|
+
const entries = resolveTableCellSelectionEntries(context.session, storyLocator ?? { kind: "story", storyType: "body" }, input.tableCellSelection.anchorBlockId, input.tableCellSelection.focusBlockId);
|
|
333979
|
+
if (!entries) {
|
|
333980
|
+
return {
|
|
333981
|
+
success: false,
|
|
333982
|
+
failure: { code: "TARGET_NOT_FOUND", message: "The selected table cells no longer resolve." }
|
|
333983
|
+
};
|
|
333984
|
+
}
|
|
333985
|
+
const cellRanges = [];
|
|
333986
|
+
for (const entry of entries) {
|
|
333987
|
+
if (entry.textLength === 0)
|
|
333988
|
+
continue;
|
|
333989
|
+
const resolved = resolveSelectionTargetToRange({
|
|
333990
|
+
...resolveInput,
|
|
333991
|
+
target: {
|
|
333992
|
+
kind: "selection",
|
|
333993
|
+
start: { kind: "text", blockId: entry.blockId, offset: 0 },
|
|
333994
|
+
end: { kind: "text", blockId: entry.blockId, offset: entry.textLength },
|
|
333995
|
+
...storyLocator ? { story: storyLocator } : {}
|
|
333996
|
+
},
|
|
333997
|
+
offsetSpace: "kernel"
|
|
333998
|
+
});
|
|
333999
|
+
if ("error" in resolved) {
|
|
334000
|
+
return { success: false, failure: { code: resolved.error, message: resolved.message } };
|
|
334001
|
+
}
|
|
334002
|
+
cellRanges.push(resolved);
|
|
334003
|
+
}
|
|
334004
|
+
ranges = cellRanges;
|
|
334005
|
+
} else if (target.start.blockId !== target.end.blockId) {
|
|
333246
334006
|
const plan = resolveCrossBlockFormatSelection(resolveInput, input.in);
|
|
333247
334007
|
if ("error" in plan) {
|
|
333248
334008
|
return { success: false, failure: { code: plan.error, message: plan.message } };
|
|
@@ -333346,6 +334106,7 @@ var init_effective_inline_uniformity = __esm(() => {
|
|
|
333346
334106
|
init_sd_document_session_internal();
|
|
333347
334107
|
init_story_surface();
|
|
333348
334108
|
init_part();
|
|
334109
|
+
init_live_selection();
|
|
333349
334110
|
TD92 = new TextDecoder;
|
|
333350
334111
|
MODEL_CACHE = new WeakMap;
|
|
333351
334112
|
TABLE_CELLS_BY_CATALOG = new WeakMap;
|
|
@@ -333477,7 +334238,7 @@ class V2SelectionMutationAdapter {
|
|
|
333477
334238
|
};
|
|
333478
334239
|
if (newText.length !== 0)
|
|
333479
334240
|
return { on, newText, ...stamps, resultKey };
|
|
333480
|
-
const matchingFields = fieldEntries.filter((entry) => entry.storyId === on.storyId && entry.blockId === on.startBlockId && entry.descriptor.resultText === resolution.text &&
|
|
334241
|
+
const matchingFields = fieldEntries.filter((entry) => entry.storyId === on.storyId && entry.blockId === on.startBlockId && entry.descriptor.resultText === resolution.text && rangesOverlap10(on.startByte, on.endByte, entry.descriptor.byteStart, entry.descriptor.byteEnd));
|
|
333481
334242
|
if (matchingFields.length !== 1)
|
|
333482
334243
|
return { on, newText, ...stamps, resultKey };
|
|
333483
334244
|
if (options?.changeMode === "tracked") {
|
|
@@ -333549,11 +334310,11 @@ class V2SelectionMutationAdapter {
|
|
|
333549
334310
|
const updatedRefs = receipt3.updatedRefs ?? [];
|
|
333550
334311
|
const inserted = createdRefs.length <= 100 ? projectTrackedTextEntities(this.context, createdRefs, edits[0].on.startBlockId) : undefined;
|
|
333551
334312
|
const updated = updatedRefs.length <= 100 ? projectTrackedTextEntities(this.context, updatedRefs, edits[0].on.startBlockId) : undefined;
|
|
333552
|
-
|
|
333553
|
-
|
|
333554
|
-
|
|
333555
|
-
|
|
333556
|
-
|
|
334313
|
+
let trackedOutcomeLogicalView = null;
|
|
334314
|
+
const resolveTrackedOutcomeId = (rawId) => {
|
|
334315
|
+
trackedOutcomeLogicalView ?? (trackedOutcomeLogicalView = buildCachedTrackedChangeLogicalView(this.context).logical);
|
|
334316
|
+
return trackedOutcomeLogicalView.rsidToLogicalId.get(rawId) ?? rawId;
|
|
334317
|
+
};
|
|
333557
334318
|
const trackedChangeOutcomes = (receipt3.trackedTextEditOutcomes ?? []).map((outcome) => {
|
|
333558
334319
|
const source = edits[Number(outcome.resultKey)];
|
|
333559
334320
|
const origin = source.rewriteIntent ? ownerIds.get(source.ownerStepId ?? "") : undefined;
|
|
@@ -333561,7 +334322,7 @@ class V2SelectionMutationAdapter {
|
|
|
333561
334322
|
const refs = parentId && (outcome.createdRsids.length > 0 || outcome.updatedRsids.length > 0) ? [{ kind: "entity", entityType: "trackedChange", entityId: parentId }] : dedupeTrackedChangeReceiptEntities([...outcome.createdRsids, ...outcome.updatedRsids].map((rawId) => ({
|
|
333562
334323
|
kind: "entity",
|
|
333563
334324
|
entityType: "trackedChange",
|
|
333564
|
-
entityId:
|
|
334325
|
+
entityId: resolveTrackedOutcomeId(rawId)
|
|
333565
334326
|
})));
|
|
333566
334327
|
return {
|
|
333567
334328
|
editIndex: Number(outcome.resultKey),
|
|
@@ -334783,7 +335544,8 @@ class V2SelectionMutationAdapter {
|
|
|
334783
335544
|
};
|
|
334784
335545
|
}
|
|
334785
335546
|
executeFormat(request, options, offsetSpace) {
|
|
334786
|
-
const
|
|
335547
|
+
const cellSelection = options?.tableCellSelection;
|
|
335548
|
+
const resolvedTarget = cellSelection ? this.resolveCellFormatSelection(request.target, request.in, options, cellSelection) : request.ref !== undefined && request.target === undefined ? this.resolveRefSelection(request.ref, request.in, options) : this.resolveExplicitSelection(request.target, request.in, options, offsetSpace);
|
|
334787
335549
|
if (!resolvedTarget.ok)
|
|
334788
335550
|
return resolvedTarget.receipt;
|
|
334789
335551
|
const { resolution, storyLocator } = resolvedTarget.value;
|
|
@@ -334929,6 +335691,49 @@ class V2SelectionMutationAdapter {
|
|
|
334929
335691
|
resolution
|
|
334930
335692
|
};
|
|
334931
335693
|
}
|
|
335694
|
+
resolveCellFormatSelection(target, overrideStory, options, cellSelection) {
|
|
335695
|
+
const story = target ? pickStoryLocator(target, overrideStory) : overrideStory;
|
|
335696
|
+
const entries = resolveTableCellSelectionEntries(this.context.session, story ?? { kind: "story", storyType: "body" }, cellSelection.anchorBlockId, cellSelection.focusBlockId);
|
|
335697
|
+
if (!entries)
|
|
335698
|
+
return {
|
|
335699
|
+
ok: false,
|
|
335700
|
+
receipt: failureWithoutResolution("TARGET_NOT_FOUND", "The selected table cells no longer resolve.")
|
|
335701
|
+
};
|
|
335702
|
+
const ranges = [];
|
|
335703
|
+
const texts = [];
|
|
335704
|
+
let firstResolved;
|
|
335705
|
+
for (const entry of entries) {
|
|
335706
|
+
if (entry.textLength === 0)
|
|
335707
|
+
continue;
|
|
335708
|
+
const selected = this.resolveExplicitSelection({
|
|
335709
|
+
kind: "selection",
|
|
335710
|
+
start: { kind: "text", blockId: entry.blockId, offset: 0 },
|
|
335711
|
+
end: { kind: "text", blockId: entry.blockId, offset: entry.textLength },
|
|
335712
|
+
...story ? { story } : {}
|
|
335713
|
+
}, overrideStory, options, "kernel");
|
|
335714
|
+
if (!selected.ok)
|
|
335715
|
+
return selected;
|
|
335716
|
+
firstResolved ?? (firstResolved = selected.value);
|
|
335717
|
+
ranges.push(...selected.value.mode === "multi" ? selected.value.ranges : [selected.value.resolved]);
|
|
335718
|
+
texts.push(selected.value.resolution.text);
|
|
335719
|
+
}
|
|
335720
|
+
if (!firstResolved || !ranges.length)
|
|
335721
|
+
return { ok: false, receipt: failureWithoutResolution("NO_OP", "The selected cells contain no text.") };
|
|
335722
|
+
return {
|
|
335723
|
+
ok: true,
|
|
335724
|
+
value: {
|
|
335725
|
+
mode: "multi",
|
|
335726
|
+
ranges,
|
|
335727
|
+
storyLocator: firstResolved.storyLocator,
|
|
335728
|
+
resolution: {
|
|
335729
|
+
...firstResolved.resolution,
|
|
335730
|
+
text: texts.join(`
|
|
335731
|
+
`),
|
|
335732
|
+
range: { from: ranges[0].startByte, to: ranges[ranges.length - 1].endByte }
|
|
335733
|
+
}
|
|
335734
|
+
}
|
|
335735
|
+
};
|
|
335736
|
+
}
|
|
334932
335737
|
resolveExplicitSelection(target, overrideStory, _options, offsetSpace) {
|
|
334933
335738
|
if (!target) {
|
|
334934
335739
|
return {
|
|
@@ -335232,7 +336037,7 @@ class V2SelectionMutationAdapter {
|
|
|
335232
336037
|
txIdPrefix: "range-ref-whole-body-replace",
|
|
335233
336038
|
expectedRevision: options?.expectedRevision != null ? String(options.expectedRevision) : undefined,
|
|
335234
336039
|
perPart: {
|
|
335235
|
-
[story.partUri]: replaceWholePartEntry(bytes,
|
|
336040
|
+
[story.partUri]: replaceWholePartEntry(bytes, TE51.encode(nextXml))
|
|
335236
336041
|
},
|
|
335237
336042
|
storyIds: [story.storyId],
|
|
335238
336043
|
createdRefs,
|
|
@@ -335519,7 +336324,7 @@ function typingHistoryMetadata(options) {
|
|
|
335519
336324
|
function tryDeleteMatchedFieldRef(context, replacementText, outcome, resolution) {
|
|
335520
336325
|
if (replacementText.length !== 0)
|
|
335521
336326
|
return null;
|
|
335522
|
-
const matches = listCanonicalFieldEntries(context).filter((entry2) => entry2.storyId === outcome.payload.storyId && entry2.blockId === outcome.payload.blockId && entry2.descriptor.resultText === outcome.payload.matchText &&
|
|
336327
|
+
const matches = listCanonicalFieldEntries(context).filter((entry2) => entry2.storyId === outcome.payload.storyId && entry2.blockId === outcome.payload.blockId && entry2.descriptor.resultText === outcome.payload.matchText && rangesOverlap10(outcome.resolved.startByte, outcome.resolved.endByte, entry2.descriptor.byteStart, entry2.descriptor.byteEnd));
|
|
335523
336328
|
if (matches.length !== 1)
|
|
335524
336329
|
return null;
|
|
335525
336330
|
const entry = matches[0];
|
|
@@ -335539,7 +336344,7 @@ function tryDeleteMatchedFieldRef(context, replacementText, outcome, resolution)
|
|
|
335539
336344
|
resolution
|
|
335540
336345
|
};
|
|
335541
336346
|
}
|
|
335542
|
-
function
|
|
336347
|
+
function rangesOverlap10(start, end, otherStart, otherEnd) {
|
|
335543
336348
|
return start < otherEnd && end > otherStart;
|
|
335544
336349
|
}
|
|
335545
336350
|
function failureWithoutResolution(code2, message) {
|
|
@@ -336047,9 +336852,10 @@ function rewriteReviewId(on, resolution, origin) {
|
|
|
336047
336852
|
const noteId = story && "noteId" in story ? story.noteId : undefined;
|
|
336048
336853
|
return buildTextRewriteReviewGroupId(on.storyId, origin, noteId);
|
|
336049
336854
|
}
|
|
336050
|
-
var TD93,
|
|
336855
|
+
var TD93, TE51, PERMISSION_DENIED_DOC_PROTECTION = "document protection permits edits only within an everyone permission range.", FORMAT_STRADDLE_MARKER_KINDS;
|
|
336051
336856
|
var init_adapter9 = __esm(() => {
|
|
336052
336857
|
init_review_read_model();
|
|
336858
|
+
init_live_selection();
|
|
336053
336859
|
init_sd_document_session_internal();
|
|
336054
336860
|
init_logical_view_cache();
|
|
336055
336861
|
init_local_text_projection();
|
|
@@ -336083,7 +336889,7 @@ var init_adapter9 = __esm(() => {
|
|
|
336083
336889
|
init_cross_cell_delete();
|
|
336084
336890
|
init_effective_inline_uniformity();
|
|
336085
336891
|
TD93 = new TextDecoder;
|
|
336086
|
-
|
|
336892
|
+
TE51 = new TextEncoder;
|
|
336087
336893
|
FORMAT_STRADDLE_MARKER_KINDS = new Set([
|
|
336088
336894
|
"bookmarkStart",
|
|
336089
336895
|
"bookmarkEnd",
|
|
@@ -336877,7 +337683,7 @@ function richWriteAnalysisSha256(input) {
|
|
|
336877
337683
|
return digest({ ...input, atomic: true });
|
|
336878
337684
|
}
|
|
336879
337685
|
function digest(value2) {
|
|
336880
|
-
return sha256HexSync(
|
|
337686
|
+
return sha256HexSync(TE52.encode(canonicalJson(value2)));
|
|
336881
337687
|
}
|
|
336882
337688
|
function canonicalJson(value2) {
|
|
336883
337689
|
if (value2 === null || typeof value2 === "boolean" || typeof value2 === "string")
|
|
@@ -336895,10 +337701,10 @@ function canonicalJson(value2) {
|
|
|
336895
337701
|
}
|
|
336896
337702
|
throw new Error(`Support-check digests cannot encode ${typeof value2}.`);
|
|
336897
337703
|
}
|
|
336898
|
-
var
|
|
337704
|
+
var TE52;
|
|
336899
337705
|
var init_digest = __esm(() => {
|
|
336900
337706
|
init_sd_document_session_internal();
|
|
336901
|
-
|
|
337707
|
+
TE52 = new TextEncoder;
|
|
336902
337708
|
});
|
|
336903
337709
|
|
|
336904
337710
|
// ../../../v2/document-api-v2-adapter/dist/write/rich-fragment-apply.js
|
|
@@ -337696,7 +338502,7 @@ function commitKernelXmlRewrites(input) {
|
|
|
337696
338502
|
}
|
|
337697
338503
|
};
|
|
337698
338504
|
}
|
|
337699
|
-
const nextBytes =
|
|
338505
|
+
const nextBytes = TE53.encode(rewrite.nextXml);
|
|
337700
338506
|
return bytesEqual16(currentBytes, nextBytes) ? null : {
|
|
337701
338507
|
rewrite,
|
|
337702
338508
|
currentBytes,
|
|
@@ -337771,11 +338577,11 @@ function bytesEqual16(left, right) {
|
|
|
337771
338577
|
}
|
|
337772
338578
|
return true;
|
|
337773
338579
|
}
|
|
337774
|
-
var
|
|
338580
|
+
var TE53, TD95;
|
|
337775
338581
|
var init_xml_rewrite = __esm(() => {
|
|
337776
338582
|
init_sd_document_session_internal();
|
|
337777
338583
|
init_xml();
|
|
337778
|
-
|
|
338584
|
+
TE53 = new TextEncoder;
|
|
337779
338585
|
TD95 = new TextDecoder;
|
|
337780
338586
|
});
|
|
337781
338587
|
|
|
@@ -347339,7 +348145,7 @@ function storyErrorMessage3(error48) {
|
|
|
347339
348145
|
}
|
|
347340
348146
|
}
|
|
347341
348147
|
function splicePartBytes(bytes, start, end, replacementXml) {
|
|
347342
|
-
const replacement =
|
|
348148
|
+
const replacement = TE54.encode(replacementXml);
|
|
347343
348149
|
const next = new Uint8Array(start + replacement.length + (bytes.length - end));
|
|
347344
348150
|
next.set(bytes.subarray(0, start), 0);
|
|
347345
348151
|
next.set(replacement, start);
|
|
@@ -347442,7 +348248,7 @@ function txIdPrefixToOperation(prefix) {
|
|
|
347442
348248
|
return prefix;
|
|
347443
348249
|
}
|
|
347444
348250
|
}
|
|
347445
|
-
var TD97,
|
|
348251
|
+
var TD97, TE54;
|
|
347446
348252
|
var init_adapter15 = __esm(() => {
|
|
347447
348253
|
init_sd_document_session_internal();
|
|
347448
348254
|
init_src6();
|
|
@@ -347456,7 +348262,7 @@ var init_adapter15 = __esm(() => {
|
|
|
347456
348262
|
init_part();
|
|
347457
348263
|
init_paragraph();
|
|
347458
348264
|
TD97 = new TextDecoder;
|
|
347459
|
-
|
|
348265
|
+
TE54 = new TextEncoder;
|
|
347460
348266
|
});
|
|
347461
348267
|
|
|
347462
348268
|
// ../../../v2/document-api-v2-adapter/dist/header-footers/page-numbers.js
|
|
@@ -351123,7 +351929,7 @@ function readInsertedTextFromXml(xml) {
|
|
|
351123
351929
|
const textRe = /<([\w.-]+):t\b([^>]*?)>([\s\S]*?)<\/\1:t>/g;
|
|
351124
351930
|
let match;
|
|
351125
351931
|
while (match = textRe.exec(xml)) {
|
|
351126
|
-
out.push(
|
|
351932
|
+
out.push(decodeXmlText11(match[3] ?? ""));
|
|
351127
351933
|
}
|
|
351128
351934
|
return out.join("");
|
|
351129
351935
|
}
|
|
@@ -351366,7 +352172,7 @@ function computeFragmentCharRangesForParagraph(paragraphXml, paragraphByteStart,
|
|
|
351366
352172
|
}
|
|
351367
352173
|
}
|
|
351368
352174
|
} else if (m[7]) {
|
|
351369
|
-
const decoded =
|
|
352175
|
+
const decoded = decodeXmlText11(m[9] ?? "");
|
|
351370
352176
|
charCursor += decoded.length;
|
|
351371
352177
|
}
|
|
351372
352178
|
}
|
|
@@ -351649,7 +352455,7 @@ function rangesContainOrAreContained(left, right) {
|
|
|
351649
352455
|
function rangesAreAdjacent(left, right) {
|
|
351650
352456
|
return Math.abs(left.start - right.byteEnd) <= 64 || Math.abs(right.byteStart - left.end) <= 64;
|
|
351651
352457
|
}
|
|
351652
|
-
function
|
|
352458
|
+
function decodeXmlText11(value2) {
|
|
351653
352459
|
return value2.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
351654
352460
|
}
|
|
351655
352461
|
function escapeRegex12(value2) {
|
|
@@ -358780,11 +359586,11 @@ function findStructuredImageDrawings(partXml, identity2) {
|
|
|
358780
359586
|
const relationshipId = /\br:embed="([^"]+)"/.exec(drawing.xml)?.[1] ?? null;
|
|
358781
359587
|
if (!relationshipId || normalizeImageIdComponent(relationshipId) !== identity2.relationshipScope)
|
|
358782
359588
|
continue;
|
|
358783
|
-
const byteStart =
|
|
359589
|
+
const byteStart = TE55.encode(partXml.slice(0, drawing.start)).byteLength;
|
|
358784
359590
|
out.push({
|
|
358785
359591
|
start: drawing.start,
|
|
358786
359592
|
byteStart,
|
|
358787
|
-
byteEnd: byteStart +
|
|
359593
|
+
byteEnd: byteStart + TE55.encode(drawing.xml).byteLength,
|
|
358788
359594
|
relationshipId,
|
|
358789
359595
|
xml: drawing.xml
|
|
358790
359596
|
});
|
|
@@ -359262,14 +360068,14 @@ function decodeXmlAttr2(value2) {
|
|
|
359262
360068
|
function emuToPx(value2) {
|
|
359263
360069
|
return value2 / EMU_PER_PX4;
|
|
359264
360070
|
}
|
|
359265
|
-
var TD98,
|
|
360071
|
+
var TD98, TE55, EMU_PER_PX4 = 9525, CROP_SCALE = 1000, DECORATIVE_DESCRIPTION_CLEARED, BODY_IMAGE_ENTRIES_CACHE, TRACKED_WRAPPER_KINDS2;
|
|
359266
360072
|
var init_public_model = __esm(() => {
|
|
359267
360073
|
init_sd_document_session_internal();
|
|
359268
360074
|
init_caption_style();
|
|
359269
360075
|
init_xml_rewrite();
|
|
359270
360076
|
init_document_reader();
|
|
359271
360077
|
TD98 = new TextDecoder;
|
|
359272
|
-
|
|
360078
|
+
TE55 = new TextEncoder;
|
|
359273
360079
|
DECORATIVE_DESCRIPTION_CLEARED = new WeakMap;
|
|
359274
360080
|
BODY_IMAGE_ENTRIES_CACHE = new WeakMap;
|
|
359275
360081
|
TRACKED_WRAPPER_KINDS2 = new Set(["ins", "del", "moveFrom", "moveTo"]);
|
|
@@ -364665,7 +365471,7 @@ function computeFragmentParagraphCharRange(paragraphXml, fragLocalStart, fragLoc
|
|
|
364665
365471
|
let match;
|
|
364666
365472
|
while (match = re.exec(paragraphXml)) {
|
|
364667
365473
|
const raw = match[1] ?? "";
|
|
364668
|
-
const decoded =
|
|
365474
|
+
const decoded = decodeXmlText12(raw);
|
|
364669
365475
|
const tOpenStart = match.index;
|
|
364670
365476
|
const tCloseEnd = match.index + match[0].length;
|
|
364671
365477
|
const insideFragment = tOpenStart >= fragLocalStart && tCloseEnd <= fragLocalEnd;
|
|
@@ -364757,7 +365563,7 @@ function buildParagraphCharOffsetMap(paragraphXml, paragraphByteStart, coordinat
|
|
|
364757
365563
|
const re = coordinateSpace === "tracked" ? /<[\w.-]+:(?:t|delText)\b[^>]*>([\s\S]*?)<\/[\w.-]+:(?:t|delText)>/g : /<[\w.-]+:t\b[^>]*>([\s\S]*?)<\/[\w.-]+:t>/g;
|
|
364758
365564
|
for (const match of paragraphXml.matchAll(re)) {
|
|
364759
365565
|
const raw = match[1] ?? "";
|
|
364760
|
-
const decoded =
|
|
365566
|
+
const decoded = decodeXmlText12(raw);
|
|
364761
365567
|
const contentCharStart = (match.index ?? 0) + match[0].indexOf(">") + 1;
|
|
364762
365568
|
advanceXmlTo(contentCharStart);
|
|
364763
365569
|
const contentStart = paragraphByteStart + xmlByteCursor;
|
|
@@ -364824,7 +365630,7 @@ function deriveStoryLocatorForFragment(context, fragment4) {
|
|
|
364824
365630
|
}
|
|
364825
365631
|
return;
|
|
364826
365632
|
}
|
|
364827
|
-
function
|
|
365633
|
+
function decodeXmlText12(value2) {
|
|
364828
365634
|
return value2.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
364829
365635
|
}
|
|
364830
365636
|
function fail4(code2, message) {
|
|
@@ -366889,8 +367695,8 @@ var init_adapter23 = __esm(() => {
|
|
|
366889
367695
|
|
|
366890
367696
|
// ../../../v2/document-api-v2-adapter/dist/diff/tracked-table-property-replay.js
|
|
366891
367697
|
function buildTrackedTablePropertyReplayPlan(base3, target) {
|
|
366892
|
-
const baseBytes =
|
|
366893
|
-
const targetBytes =
|
|
367698
|
+
const baseBytes = TE56.encode(base3.xml);
|
|
367699
|
+
const targetBytes = TE56.encode(target.xml);
|
|
366894
367700
|
const baseTables = buildTableCatalog({ bytes: baseBytes, storyId: STORY_ID });
|
|
366895
367701
|
const targetTables = buildTableCatalog({ bytes: targetBytes, storyId: STORY_ID });
|
|
366896
367702
|
const baseBody = collectXmlElementRanges(base3.xml).ranges.find((range) => range.tag.namespaceUri === W20 && range.tag.localName === "body");
|
|
@@ -366936,10 +367742,10 @@ function buildTrackedTablePropertyReplayPlan(base3, target) {
|
|
|
366936
367742
|
}
|
|
366937
367743
|
return steps.length ? { steps } : null;
|
|
366938
367744
|
}
|
|
366939
|
-
var
|
|
367745
|
+
var TE56, TD101, STORY_ID = "body:/word/document.xml", W20 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
|
|
366940
367746
|
var init_tracked_table_property_replay = __esm(() => {
|
|
366941
367747
|
init_sd_document_session_internal();
|
|
366942
|
-
|
|
367748
|
+
TE56 = new TextEncoder;
|
|
366943
367749
|
TD101 = new TextDecoder;
|
|
366944
367750
|
});
|
|
366945
367751
|
|
|
@@ -367038,15 +367844,15 @@ var init_fingerprint = __esm(() => {
|
|
|
367038
367844
|
// ../../../v2/document-api-v2-adapter/dist/compare/part-fingerprint.js
|
|
367039
367845
|
function comparePartContentFingerprint(partUri, bytes) {
|
|
367040
367846
|
const partHash = sha256HexSync(bytes);
|
|
367041
|
-
return `fp:${sha256HexSync(
|
|
367847
|
+
return `fp:${sha256HexSync(TE57.encode(`${partUri}:${partHash}`))}`;
|
|
367042
367848
|
}
|
|
367043
367849
|
function comparePartXmlFingerprint(partUri, xml) {
|
|
367044
|
-
return comparePartContentFingerprint(partUri,
|
|
367850
|
+
return comparePartContentFingerprint(partUri, TE57.encode(xml));
|
|
367045
367851
|
}
|
|
367046
|
-
var
|
|
367852
|
+
var TE57;
|
|
367047
367853
|
var init_part_fingerprint = __esm(() => {
|
|
367048
367854
|
init_sd_document_session_internal();
|
|
367049
|
-
|
|
367855
|
+
TE57 = new TextEncoder;
|
|
367050
367856
|
});
|
|
367051
367857
|
|
|
367052
367858
|
// ../../../v2/document-api-v2-adapter/dist/compare/inventory.js
|
|
@@ -367267,7 +368073,7 @@ function captureCompareSourceInventory(context) {
|
|
|
367267
368073
|
return buildCompareSourceInventory(buildCompareSourceObservation(context));
|
|
367268
368074
|
}
|
|
367269
368075
|
function textBytes(value2) {
|
|
367270
|
-
return
|
|
368076
|
+
return TE58.encode(value2);
|
|
367271
368077
|
}
|
|
367272
368078
|
function countOccurrences(haystack, needle) {
|
|
367273
368079
|
let count = 0;
|
|
@@ -367324,19 +368130,19 @@ function accumulateStoryCatalogs(context, story, acc) {
|
|
|
367324
368130
|
}
|
|
367325
368131
|
} catch {}
|
|
367326
368132
|
}
|
|
367327
|
-
var TD102, BODY_PART_URI = "/word/document.xml",
|
|
368133
|
+
var TD102, BODY_PART_URI = "/word/document.xml", TE58;
|
|
367328
368134
|
var init_inventory = __esm(() => {
|
|
367329
368135
|
init_src2();
|
|
367330
368136
|
init_sd_document_session_internal();
|
|
367331
368137
|
init_document_reader();
|
|
367332
368138
|
init_part_fingerprint();
|
|
367333
368139
|
TD102 = new TextDecoder("utf-8", { fatal: false });
|
|
367334
|
-
|
|
368140
|
+
TE58 = new TextEncoder;
|
|
367335
368141
|
});
|
|
367336
368142
|
|
|
367337
368143
|
// ../../../v2/document-api-v2-adapter/dist/compare/definitions.js
|
|
367338
368144
|
function digest2(value2) {
|
|
367339
|
-
return sha256HexSync(
|
|
368145
|
+
return sha256HexSync(TE59.encode(value2));
|
|
367340
368146
|
}
|
|
367341
368147
|
function tagAttr2(tag, local) {
|
|
367342
368148
|
const match = new RegExp(`\\b(?:[\\w.-]+:)?${local}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag);
|
|
@@ -367640,14 +368446,14 @@ function projectCompareDefinitions(context) {
|
|
|
367640
368446
|
{ family: "theme", entries: projectTheme(context) }
|
|
367641
368447
|
];
|
|
367642
368448
|
}
|
|
367643
|
-
var TD103,
|
|
368449
|
+
var TD103, TE59, SETTINGS_PART_URI4 = "/word/settings.xml", WORDPROCESSINGML_NS3 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", XML_ATTR_RE;
|
|
367644
368450
|
var init_definitions = __esm(() => {
|
|
367645
368451
|
init_src2();
|
|
367646
368452
|
init_sd_document_session_internal();
|
|
367647
368453
|
init_adapter13();
|
|
367648
368454
|
init_part();
|
|
367649
368455
|
TD103 = new TextDecoder("utf-8", { fatal: false });
|
|
367650
|
-
|
|
368456
|
+
TE59 = new TextEncoder;
|
|
367651
368457
|
XML_ATTR_RE = /\s+[\w.-]+(?::[\w.-]+)?=(?:"[^"]*"|'[^']*')/g;
|
|
367652
368458
|
});
|
|
367653
368459
|
|
|
@@ -367662,7 +368468,7 @@ function contentControlIdentity(properties) {
|
|
|
367662
368468
|
|
|
367663
368469
|
// ../../../v2/document-api-v2-adapter/dist/compare/annotations.js
|
|
367664
368470
|
function digest3(value2) {
|
|
367665
|
-
return sha256HexSync(
|
|
368471
|
+
return sha256HexSync(TE60.encode(value2));
|
|
367666
368472
|
}
|
|
367667
368473
|
function storyLocatorSignature(story) {
|
|
367668
368474
|
if (!story || story.storyType === "body")
|
|
@@ -368009,17 +368815,17 @@ function projectCompareAnnotations(context) {
|
|
|
368009
368815
|
{ family: "permissions", entries: projectPermissions(context) }
|
|
368010
368816
|
];
|
|
368011
368817
|
}
|
|
368012
|
-
var TD104,
|
|
368818
|
+
var TD104, TE60, BODY_PART_URI2 = "/word/document.xml", CUSTOM_XML_PROPS_RELS_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps";
|
|
368013
368819
|
var init_annotations2 = __esm(() => {
|
|
368014
368820
|
init_sd_document_session_internal();
|
|
368015
368821
|
init_read();
|
|
368016
368822
|
TD104 = new TextDecoder("utf-8", { fatal: false });
|
|
368017
|
-
|
|
368823
|
+
TE60 = new TextEncoder;
|
|
368018
368824
|
});
|
|
368019
368825
|
|
|
368020
368826
|
// ../../../v2/document-api-v2-adapter/dist/compare/objects.js
|
|
368021
368827
|
function digest4(value2) {
|
|
368022
|
-
return sha256HexSync(
|
|
368828
|
+
return sha256HexSync(TE61.encode(value2));
|
|
368023
368829
|
}
|
|
368024
368830
|
function isMediaKind(partKind) {
|
|
368025
368831
|
return classifyComparePartKind(partKind).family === "media";
|
|
@@ -368236,12 +369042,12 @@ function projectCompareObjects(context) {
|
|
|
368236
369042
|
{ family: "package-graph", entries: projectPackageGraph(context) }
|
|
368237
369043
|
];
|
|
368238
369044
|
}
|
|
368239
|
-
var TD105,
|
|
369045
|
+
var TD105, TE61, CONTENT_TYPES_PART_URI15 = "/[Content_Types].xml", PACKAGE_ROOT_OWNER = "/";
|
|
368240
369046
|
var init_objects = __esm(() => {
|
|
368241
369047
|
init_src2();
|
|
368242
369048
|
init_sd_document_session_internal();
|
|
368243
369049
|
TD105 = new TextDecoder("utf-8", { fatal: false });
|
|
368244
|
-
|
|
369050
|
+
TE61 = new TextEncoder;
|
|
368245
369051
|
});
|
|
368246
369052
|
|
|
368247
369053
|
// ../../../v2/document-api-v2-adapter/dist/compare/run-signature.js
|
|
@@ -368296,12 +369102,12 @@ function paragraphContext(rawXml, inherited) {
|
|
|
368296
369102
|
const paragraph4 = /^<(([A-Za-z_][\w.-]*)(?::([A-Za-z_][\w.-]*))?)/.exec(openTag);
|
|
368297
369103
|
const paragraphPrefix = paragraph4?.[3] === undefined ? "" : paragraph4[2];
|
|
368298
369104
|
if (paragraph4 && context[paragraphPrefix] === undefined)
|
|
368299
|
-
context[paragraphPrefix] =
|
|
369105
|
+
context[paragraphPrefix] = W_NS7;
|
|
368300
369106
|
return context;
|
|
368301
369107
|
}
|
|
368302
369108
|
function isWordprocessingElement4(element, context) {
|
|
368303
369109
|
const local = namespaceDeclarations3(element.openTag);
|
|
368304
|
-
return (local[element.prefix] ?? context[element.prefix]) ===
|
|
369110
|
+
return (local[element.prefix] ?? context[element.prefix]) === W_NS7;
|
|
368305
369111
|
}
|
|
368306
369112
|
function makeTopLevelElementsSelfContained2(xml, context) {
|
|
368307
369113
|
let result = xml;
|
|
@@ -368362,7 +369168,7 @@ function computeParagraphPropertiesSignature2(paragraphPropertiesXml) {
|
|
|
368362
369168
|
}
|
|
368363
369169
|
return `v2-ppr-${hash2.toString(16).padStart(8, "0")}`;
|
|
368364
369170
|
}
|
|
368365
|
-
var REVISION_ATTR_RE2,
|
|
369171
|
+
var REVISION_ATTR_RE2, W_NS7 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", XML_TAG_RE3, XML_ATTRIBUTE_RE2;
|
|
368366
369172
|
var init_run_signature2 = __esm(() => {
|
|
368367
369173
|
init_src2();
|
|
368368
369174
|
init_src2();
|
|
@@ -369295,70 +370101,6 @@ var init_compare = __esm(() => {
|
|
|
369295
370101
|
init_src2();
|
|
369296
370102
|
});
|
|
369297
370103
|
|
|
369298
|
-
// ../../../v2/document-api-v2-adapter/dist/core/text-coordinate-space.js
|
|
369299
|
-
function projectVisibleOffsetToTracked(map3, offset, bias) {
|
|
369300
|
-
if (!Number.isInteger(offset) || offset < 0 || offset > map3.visibleLength)
|
|
369301
|
-
return null;
|
|
369302
|
-
const candidates = new Set;
|
|
369303
|
-
if (offset === 0)
|
|
369304
|
-
candidates.add(0);
|
|
369305
|
-
if (offset === map3.visibleLength)
|
|
369306
|
-
candidates.add(map3.trackedLength);
|
|
369307
|
-
for (const piece of map3.leaves()) {
|
|
369308
|
-
const visibleWidth2 = piece.visibleEnd - piece.visibleStart;
|
|
369309
|
-
const trackedWidth2 = piece.trackedEnd - piece.trackedStart;
|
|
369310
|
-
if (visibleWidth2 > 0 && trackedWidth2 === visibleWidth2) {
|
|
369311
|
-
if (offset >= piece.visibleStart && offset <= piece.visibleEnd) {
|
|
369312
|
-
candidates.add(piece.trackedStart + offset - piece.visibleStart);
|
|
369313
|
-
}
|
|
369314
|
-
continue;
|
|
369315
|
-
}
|
|
369316
|
-
if (offset === piece.visibleStart)
|
|
369317
|
-
candidates.add(piece.trackedStart);
|
|
369318
|
-
if (offset === piece.visibleEnd)
|
|
369319
|
-
candidates.add(piece.trackedEnd);
|
|
369320
|
-
}
|
|
369321
|
-
if (candidates.size === 0)
|
|
369322
|
-
return null;
|
|
369323
|
-
const values2 = [...candidates];
|
|
369324
|
-
return bias === "upstream" ? Math.min(...values2) : Math.max(...values2);
|
|
369325
|
-
}
|
|
369326
|
-
function projectTrackedOffsetToVisible(map3, offset) {
|
|
369327
|
-
if (!Number.isInteger(offset) || offset < 0 || offset > map3.trackedLength)
|
|
369328
|
-
return null;
|
|
369329
|
-
if (offset === map3.trackedLength)
|
|
369330
|
-
return map3.visibleLength;
|
|
369331
|
-
for (const piece of map3.leaves()) {
|
|
369332
|
-
if (offset < piece.trackedStart || offset > piece.trackedEnd)
|
|
369333
|
-
continue;
|
|
369334
|
-
if (offset === piece.trackedStart)
|
|
369335
|
-
return piece.visibleStart;
|
|
369336
|
-
if (offset === piece.trackedEnd)
|
|
369337
|
-
return piece.visibleEnd;
|
|
369338
|
-
const trackedWidth2 = piece.trackedEnd - piece.trackedStart;
|
|
369339
|
-
const visibleWidth2 = piece.visibleEnd - piece.visibleStart;
|
|
369340
|
-
if (trackedWidth2 === 0 || visibleWidth2 === 0)
|
|
369341
|
-
return piece.visibleStart;
|
|
369342
|
-
if (trackedWidth2 !== visibleWidth2)
|
|
369343
|
-
return null;
|
|
369344
|
-
return piece.visibleStart + offset - piece.trackedStart;
|
|
369345
|
-
}
|
|
369346
|
-
return null;
|
|
369347
|
-
}
|
|
369348
|
-
function projectVisibleRangeToTracked(map3, start, end) {
|
|
369349
|
-
if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start)
|
|
369350
|
-
return null;
|
|
369351
|
-
if (start === end) {
|
|
369352
|
-
const offset = projectVisibleOffsetToTracked(map3, start, "upstream");
|
|
369353
|
-
return offset == null ? null : { start: offset, end: offset };
|
|
369354
|
-
}
|
|
369355
|
-
const trackedStart = projectVisibleOffsetToTracked(map3, start, "downstream");
|
|
369356
|
-
const trackedEnd = projectVisibleOffsetToTracked(map3, end, "upstream");
|
|
369357
|
-
if (trackedStart == null || trackedEnd == null || trackedEnd < trackedStart)
|
|
369358
|
-
return null;
|
|
369359
|
-
return { start: trackedStart, end: trackedEnd };
|
|
369360
|
-
}
|
|
369361
|
-
|
|
369362
370104
|
// ../../../v2/document-api-v2-adapter/dist/tracked-changes/range-resolver.js
|
|
369363
370105
|
function scanParagraphFragments(paragraph4, partBytes, catalogFragments) {
|
|
369364
370106
|
const paragraphXml = TD107.decode(partBytes.subarray(paragraph4.byteStart, paragraph4.byteEnd));
|
|
@@ -369398,7 +370140,7 @@ function scanParagraphFragments(paragraph4, partBytes, catalogFragments) {
|
|
|
369398
370140
|
});
|
|
369399
370141
|
}
|
|
369400
370142
|
} else if (m[7]) {
|
|
369401
|
-
const decoded =
|
|
370143
|
+
const decoded = decodeXmlText13(m[9] ?? "");
|
|
369402
370144
|
trackedTextLength += decoded.length;
|
|
369403
370145
|
}
|
|
369404
370146
|
}
|
|
@@ -369411,7 +370153,7 @@ function findLastStackIndex2(stack, kind) {
|
|
|
369411
370153
|
}
|
|
369412
370154
|
return -1;
|
|
369413
370155
|
}
|
|
369414
|
-
function
|
|
370156
|
+
function decodeXmlText13(escaped) {
|
|
369415
370157
|
return escaped.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
369416
370158
|
}
|
|
369417
370159
|
function resolveTextRangeToFragmentOverlaps(input) {
|
|
@@ -371880,7 +372622,7 @@ function extractImageRelationshipId(xml) {
|
|
|
371880
372622
|
}
|
|
371881
372623
|
function extractImagePreviewAlt(xml) {
|
|
371882
372624
|
const docPr = /<[^>]*(?:[\w.-]+:)?docPr\b[^>]*>/i.exec(xml)?.[0] ?? "";
|
|
371883
|
-
const raw =
|
|
372625
|
+
const raw = readXmlAttribute5(docPr, "descr") ?? readXmlAttribute5(docPr, "title") ?? readXmlAttribute5(docPr, "name");
|
|
371884
372626
|
const normalized = raw ? decodeXmlAttribute3(raw).trim() : "";
|
|
371885
372627
|
return normalized.length > 0 ? normalized : null;
|
|
371886
372628
|
}
|
|
@@ -371897,7 +372639,7 @@ function extractImagePreviewExtent(xml) {
|
|
|
371897
372639
|
height: Math.max(1, Math.round(cy / EMUS_PER_CSS_PIXEL))
|
|
371898
372640
|
};
|
|
371899
372641
|
}
|
|
371900
|
-
function
|
|
372642
|
+
function readXmlAttribute5(tagXml, localName2) {
|
|
371901
372643
|
const match = new RegExp(`\\b(?:[\\w.-]+:)?${localName2}=["']([^"']*)["']`).exec(tagXml);
|
|
371902
372644
|
return match?.[1] ?? null;
|
|
371903
372645
|
}
|
|
@@ -372508,7 +373250,7 @@ function buildHeaderFooterLifecyclePlan(base3, target) {
|
|
|
372508
373250
|
family: "header-footer-parts",
|
|
372509
373251
|
partUri: DOCUMENT_RELS_URI2,
|
|
372510
373252
|
kind: "create",
|
|
372511
|
-
nextBytes:
|
|
373253
|
+
nextBytes: TE62.encode(nextRels),
|
|
372512
373254
|
contentType: "application/vnd.openxmlformats-package.relationships+xml"
|
|
372513
373255
|
});
|
|
372514
373256
|
} else if (nextRels !== baseRels) {
|
|
@@ -372516,7 +373258,7 @@ function buildHeaderFooterLifecyclePlan(base3, target) {
|
|
|
372516
373258
|
family: "header-footer-parts",
|
|
372517
373259
|
partUri: DOCUMENT_RELS_URI2,
|
|
372518
373260
|
kind: "modify",
|
|
372519
|
-
nextBytes:
|
|
373261
|
+
nextBytes: TE62.encode(nextRels)
|
|
372520
373262
|
});
|
|
372521
373263
|
}
|
|
372522
373264
|
const baseContentTypes = TD108.decode(Uint8Array.from(base3.contentTypesBytes));
|
|
@@ -372529,7 +373271,7 @@ function buildHeaderFooterLifecyclePlan(base3, target) {
|
|
|
372529
373271
|
family: "header-footer-parts",
|
|
372530
373272
|
partUri: CONTENT_TYPES_URI2,
|
|
372531
373273
|
kind: "modify",
|
|
372532
|
-
nextBytes:
|
|
373274
|
+
nextBytes: TE62.encode(nextContentTypes)
|
|
372533
373275
|
});
|
|
372534
373276
|
}
|
|
372535
373277
|
return {
|
|
@@ -372678,8 +373420,8 @@ function coveredGraphKeys(baseRels, targetRels, baseContentTypes, targetContentT
|
|
|
372678
373420
|
}
|
|
372679
373421
|
}
|
|
372680
373422
|
const partUris = new Set([
|
|
372681
|
-
...headerFooterPartsFromDocumentRelationships(
|
|
372682
|
-
...headerFooterPartsFromDocumentRelationships(
|
|
373423
|
+
...headerFooterPartsFromDocumentRelationships(TE62.encode(baseRels)).keys(),
|
|
373424
|
+
...headerFooterPartsFromDocumentRelationships(TE62.encode(targetRels)).keys()
|
|
372683
373425
|
]);
|
|
372684
373426
|
const baseOverrides = headerFooterOverrideRecords(baseContentTypes, partUris);
|
|
372685
373427
|
const targetOverrides = headerFooterOverrideRecords(targetContentTypes, partUris);
|
|
@@ -372702,14 +373444,14 @@ function headerFooterOverrideRecords(xml, partUris) {
|
|
|
372702
373444
|
function relationshipSemanticKey(relationship) {
|
|
372703
373445
|
return JSON.stringify([relationship.id, relationship.type, relationship.target, relationship.targetMode ?? "Internal"]);
|
|
372704
373446
|
}
|
|
372705
|
-
var TD108,
|
|
373447
|
+
var TD108, TE62, DOCUMENT_RELS_URI2 = "/word/_rels/document.xml.rels", CONTENT_TYPES_URI2 = "/[Content_Types].xml", EMPTY_RELS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>', HEADER_REL_SUFFIX2 = "/relationships/header", FOOTER_REL_SUFFIX2 = "/relationships/footer", OFFICE_RELATIONSHIPS_NAMESPACES, RELATIONSHIP_REFERENCE_ATTRIBUTES;
|
|
372706
373448
|
var init_header_footer_lifecycle = __esm(() => {
|
|
372707
373449
|
init_sd_document_session_internal();
|
|
372708
373450
|
init_part_fingerprint();
|
|
372709
373451
|
init_header_footer_parts();
|
|
372710
373452
|
init_opc_xml();
|
|
372711
373453
|
TD108 = new TextDecoder;
|
|
372712
|
-
|
|
373454
|
+
TE62 = new TextEncoder;
|
|
372713
373455
|
OFFICE_RELATIONSHIPS_NAMESPACES = new Set([
|
|
372714
373456
|
"http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
372715
373457
|
"http://purl.oclc.org/ooxml/officeDocument/relationships"
|
|
@@ -372877,8 +373619,8 @@ function buildTrackedTableRowReplayPlan(input) {
|
|
|
372877
373619
|
if (input.base.xml === input.target.xml) {
|
|
372878
373620
|
return { steps: [], bodyOperations: input.bodyOperations, unsafeReasons: [] };
|
|
372879
373621
|
}
|
|
372880
|
-
const baseBytes =
|
|
372881
|
-
const targetBytes =
|
|
373622
|
+
const baseBytes = TE63.encode(input.base.xml);
|
|
373623
|
+
const targetBytes = TE63.encode(input.target.xml);
|
|
372882
373624
|
const baseCatalog = buildTableCatalog({ bytes: baseBytes, storyId: STORY_ID2 });
|
|
372883
373625
|
const targetCatalog = buildTableCatalog({ bytes: targetBytes, storyId: STORY_ID2 });
|
|
372884
373626
|
const baseRoot = documentRootContext(input.base.xml);
|
|
@@ -373551,10 +374293,10 @@ function escapeRegExp18(value2) {
|
|
|
373551
374293
|
function escapeXmlAttribute5(value2) {
|
|
373552
374294
|
return value2.replaceAll("&", "&").replaceAll('"', """);
|
|
373553
374295
|
}
|
|
373554
|
-
var
|
|
374296
|
+
var TE63, STORY_ID2 = "body:/word/document.xml", WORDPROCESSINGML_NS4 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NS = "http://schemas.microsoft.com/office/word/2010/wordml", MARKUP_COMPATIBILITY_NS2 = "http://schemas.openxmlformats.org/markup-compatibility/2006", MC_PREFIX_LIST_ATTRIBUTES, MC_QNAME_LIST_ATTRIBUTES, EXACT_ROW_UNSAFE_REVISION_LOCAL_NAMES2, EXACT_ROW_UNSAFE_W14_REVISION_LOCAL_NAMES2;
|
|
373555
374297
|
var init_tracked_table_row_replay = __esm(() => {
|
|
373556
374298
|
init_sd_document_session_internal();
|
|
373557
|
-
|
|
374299
|
+
TE63 = new TextEncoder;
|
|
373558
374300
|
MC_PREFIX_LIST_ATTRIBUTES = new Set(["Ignorable", "MustUnderstand"]);
|
|
373559
374301
|
MC_QNAME_LIST_ATTRIBUTES = new Set(["PreserveElements", "PreserveAttributes", "ProcessContent"]);
|
|
373560
374302
|
EXACT_ROW_UNSAFE_REVISION_LOCAL_NAMES2 = new Set([
|
|
@@ -373608,7 +374350,7 @@ function read(xml) {
|
|
|
373608
374350
|
children2.push(range);
|
|
373609
374351
|
cursor = range.end;
|
|
373610
374352
|
}
|
|
373611
|
-
const bytes =
|
|
374353
|
+
const bytes = TE64.encode(xml);
|
|
373612
374354
|
const byteOffsets = buildUtf8ByteOffsetTable(xml);
|
|
373613
374355
|
const tables2 = buildTableCatalog({ bytes, storyId: STORY }).tables;
|
|
373614
374356
|
if (tables2.some((table) => table.containsNestedTable || !table.isRectangular || table.hasVMerge || table.hasGridSpan))
|
|
@@ -373730,11 +374472,11 @@ function buildTrackedTableBlockReplayPlan(input) {
|
|
|
373730
374472
|
bodyOperations: input.bodyOperations.filter((operation) => !ownedIds.has(operation.blockId))
|
|
373731
374473
|
};
|
|
373732
374474
|
}
|
|
373733
|
-
var W21 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", W146 = "http://schemas.microsoft.com/office/word/2010/wordml", STORY = "body:/word/document.xml",
|
|
374475
|
+
var W21 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", W146 = "http://schemas.microsoft.com/office/word/2010/wordml", STORY = "body:/word/document.xml", TE64, paragraphId2 = (range) => range.tag.attributes.find((attr3) => attr3.namespaceUri === W146 && attr3.localName === "paraId")?.value;
|
|
373734
374476
|
var init_tracked_table_block_replay = __esm(() => {
|
|
373735
374477
|
init_sd_document_session_internal();
|
|
373736
374478
|
init_tracked_table_row_replay();
|
|
373737
|
-
|
|
374479
|
+
TE64 = new TextEncoder;
|
|
373738
374480
|
});
|
|
373739
374481
|
|
|
373740
374482
|
// ../../../v2/document-api-v2-adapter/dist/diff/comments-replay.js
|
|
@@ -373786,7 +374528,7 @@ function validateDiffCommentSource(source, snapshot2, label) {
|
|
|
373786
374528
|
return problems;
|
|
373787
374529
|
}
|
|
373788
374530
|
function digest5(value2) {
|
|
373789
|
-
return sha256HexSync(
|
|
374531
|
+
return sha256HexSync(TE65.encode(value2));
|
|
373790
374532
|
}
|
|
373791
374533
|
function commentContentSignature(record3) {
|
|
373792
374534
|
return digest5(`body:${record3.bodyText}#author:${record3.author}#parent:${record3.parentParaId ?? ""}` + `#done:${record3.doneState ? "1" : "0"}#date:${record3.date ?? ""}` + `#anchor:${commentAnchorSignature2(record3.anchor)}`);
|
|
@@ -374134,12 +374876,12 @@ function isResolutionSidecarAddition(key2, targetEntry) {
|
|
|
374134
374876
|
if (!targetEntry)
|
|
374135
374877
|
return false;
|
|
374136
374878
|
if (key2 === "ct:override:/word/commentsExtended.xml") {
|
|
374137
|
-
return targetEntry.semanticKey === key2 && targetEntry.contentSignature === sha256HexSync(
|
|
374879
|
+
return targetEntry.semanticKey === key2 && targetEntry.contentSignature === sha256HexSync(TE65.encode("override:/word/commentsExtended.xml=" + "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml"));
|
|
374138
374880
|
}
|
|
374139
374881
|
if (!key2.startsWith("rel:/word/document.xml|"))
|
|
374140
374882
|
return false;
|
|
374141
374883
|
const type = "http://schemas.microsoft.com/office/2011/relationships/commentsExtended";
|
|
374142
|
-
return targetEntry.semanticKey === `/word/document.xml|${type}` && targetEntry.contentSignature === sha256HexSync(
|
|
374884
|
+
return targetEntry.semanticKey === `/word/document.xml|${type}` && targetEntry.contentSignature === sha256HexSync(TE65.encode(`type:${type}#mode:Internal#target:/word/commentsExtended.xml`));
|
|
374143
374885
|
}
|
|
374144
374886
|
function isCommentScopedPackageKey(context, key2, presentInBase, hasCommentCreate, targetEntry) {
|
|
374145
374887
|
if (key2.startsWith("ct:")) {
|
|
@@ -374257,14 +374999,14 @@ function validateAnchorResolvable(context, commentId, anchor) {
|
|
|
374257
374999
|
});
|
|
374258
375000
|
return page.hits.length > 0 ? null : `comment "${commentId}" target text was not found`;
|
|
374259
375001
|
}
|
|
374260
|
-
var
|
|
375002
|
+
var TE65;
|
|
374261
375003
|
var init_comments_replay = __esm(() => {
|
|
374262
375004
|
init_sd_document_session_internal();
|
|
374263
375005
|
init_read();
|
|
374264
375006
|
init_collect_text_page();
|
|
374265
375007
|
init_scope2();
|
|
374266
375008
|
init_part_fingerprint();
|
|
374267
|
-
|
|
375009
|
+
TE65 = new TextEncoder;
|
|
374268
375010
|
});
|
|
374269
375011
|
|
|
374270
375012
|
// ../../../v2/document-api-v2-adapter/dist/diff/styles-replay.js
|
|
@@ -374402,8 +375144,8 @@ function snapshotNumberingInventory(snapshot2) {
|
|
|
374402
375144
|
return snapshot2.sourceInventory?.families.find((f) => f.family === "numbering") ?? null;
|
|
374403
375145
|
}
|
|
374404
375146
|
function capturedNumberingFingerprint(xml) {
|
|
374405
|
-
const partHash = sha256HexSync(
|
|
374406
|
-
return `fp:${sha256HexSync(
|
|
375147
|
+
const partHash = sha256HexSync(TE66.encode(xml));
|
|
375148
|
+
return `fp:${sha256HexSync(TE66.encode(`${NUMBERING_PART_URI}:${partHash}`))}`;
|
|
374407
375149
|
}
|
|
374408
375150
|
function validateNumberingSourceAgainstSnapshot(source, snapshot2, label) {
|
|
374409
375151
|
const problems = [];
|
|
@@ -374446,12 +375188,12 @@ function validateNumberingSourceAgainstSnapshot(source, snapshot2, label) {
|
|
|
374446
375188
|
}
|
|
374447
375189
|
return problems;
|
|
374448
375190
|
}
|
|
374449
|
-
var TD110,
|
|
375191
|
+
var TD110, TE66;
|
|
374450
375192
|
var init_numbering_replay = __esm(() => {
|
|
374451
375193
|
init_sd_document_session_internal();
|
|
374452
375194
|
init_definitions();
|
|
374453
375195
|
TD110 = new TextDecoder("utf-8", { fatal: false });
|
|
374454
|
-
|
|
375196
|
+
TE66 = new TextEncoder;
|
|
374455
375197
|
});
|
|
374456
375198
|
|
|
374457
375199
|
// ../../../v2/document-api-v2-adapter/dist/diff/settings-replay.js
|
|
@@ -374506,7 +375248,7 @@ function hasSettingsRoot(xml) {
|
|
|
374506
375248
|
});
|
|
374507
375249
|
parser.on("opentag", (tag) => {
|
|
374508
375250
|
if (rootCount === 0) {
|
|
374509
|
-
if (tag.namespaceUri !==
|
|
375251
|
+
if (tag.namespaceUri !== W_NS8 && tag.namespaceUri !== STRICT_W_NS || tag.localName !== "settings")
|
|
374510
375252
|
valid = false;
|
|
374511
375253
|
rootCount++;
|
|
374512
375254
|
}
|
|
@@ -374519,7 +375261,7 @@ function hasSettingsRoot(xml) {
|
|
|
374519
375261
|
}
|
|
374520
375262
|
return valid && rootCount === 1;
|
|
374521
375263
|
}
|
|
374522
|
-
var SETTINGS_PART_URI5 = "/word/settings.xml",
|
|
375264
|
+
var SETTINGS_PART_URI5 = "/word/settings.xml", W_NS8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", STRICT_W_NS = "http://purl.oclc.org/ooxml/wordprocessingml/main", TD111;
|
|
374523
375265
|
var init_settings_replay = __esm(() => {
|
|
374524
375266
|
init_sd_document_session_internal();
|
|
374525
375267
|
init_definitions();
|
|
@@ -374618,7 +375360,7 @@ function paragraphStyleOutlineLevelsFromStylesSource(stylesXml) {
|
|
|
374618
375360
|
return stylesXml == null ? new Map : parseParagraphStyleOutlineLevels(stylesXml);
|
|
374619
375361
|
}
|
|
374620
375362
|
function projectMainDocumentBodyEntries(source, options = {}) {
|
|
374621
|
-
const bytes =
|
|
375363
|
+
const bytes = TE67.encode(source.xml);
|
|
374622
375364
|
const paragraphStyleOutlineLevels = options.paragraphStyleOutlineLevels ?? paragraphStyleOutlineLevelMap(source.paragraphStyleOutlineLevels);
|
|
374623
375365
|
const paragraphIndex = buildParagraphIndex({
|
|
374624
375366
|
bytes,
|
|
@@ -374667,14 +375409,14 @@ function paragraphStyleOutlineLevelMap(record3) {
|
|
|
374667
375409
|
function capturedMainDocumentFingerprint(xml) {
|
|
374668
375410
|
return comparePartXmlFingerprint(MAIN_DOCUMENT_PART_URI, xml);
|
|
374669
375411
|
}
|
|
374670
|
-
var TD112,
|
|
375412
|
+
var TD112, TE67, MAIN_DOCUMENT_PART_URI = "/word/document.xml", MAIN_DOCUMENT_STORY_ID = "body:/word/document.xml", SNAPSHOT_REVISION = "snapshot";
|
|
374671
375413
|
var init_main_document_source = __esm(() => {
|
|
374672
375414
|
init_sd_document_session_internal();
|
|
374673
375415
|
init_document_reader();
|
|
374674
375416
|
init_run_signature2();
|
|
374675
375417
|
init_part_fingerprint();
|
|
374676
375418
|
TD112 = new TextDecoder("utf-8", { fatal: false });
|
|
374677
|
-
|
|
375419
|
+
TE67 = new TextEncoder;
|
|
374678
375420
|
});
|
|
374679
375421
|
|
|
374680
375422
|
// ../../../v2/document-api-v2-adapter/dist/diff/payloads.js
|
|
@@ -377917,7 +378659,7 @@ class V2DiffAdapter {
|
|
|
377917
378659
|
family: "tables",
|
|
377918
378660
|
partUri: DOCUMENT_PART_URI6,
|
|
377919
378661
|
kind: "modify",
|
|
377920
|
-
nextBytes:
|
|
378662
|
+
nextBytes: TE68.encode(step3.nextXml)
|
|
377921
378663
|
}));
|
|
377922
378664
|
const packageRewrites = [
|
|
377923
378665
|
...slotPlan.rewrites,
|
|
@@ -378505,7 +379247,7 @@ function buildKernelPackageRewrites(styleSteps, numberingSteps, settingsSteps) {
|
|
|
378505
379247
|
family: "styles",
|
|
378506
379248
|
partUri: step3.partUri,
|
|
378507
379249
|
kind: "modify",
|
|
378508
|
-
nextBytes:
|
|
379250
|
+
nextBytes: TE68.encode(step3.nextXml)
|
|
378509
379251
|
});
|
|
378510
379252
|
}
|
|
378511
379253
|
for (const step3 of numberingSteps) {
|
|
@@ -378515,7 +379257,7 @@ function buildKernelPackageRewrites(styleSteps, numberingSteps, settingsSteps) {
|
|
|
378515
379257
|
family: "numbering",
|
|
378516
379258
|
partUri: NUMBERING_PART_URI4,
|
|
378517
379259
|
kind: "modify",
|
|
378518
|
-
nextBytes:
|
|
379260
|
+
nextBytes: TE68.encode(step3.nextXml)
|
|
378519
379261
|
});
|
|
378520
379262
|
}
|
|
378521
379263
|
for (const step3 of settingsSteps) {
|
|
@@ -378523,7 +379265,7 @@ function buildKernelPackageRewrites(styleSteps, numberingSteps, settingsSteps) {
|
|
|
378523
379265
|
family: "settings",
|
|
378524
379266
|
partUri: step3.partUri,
|
|
378525
379267
|
kind: "modify",
|
|
378526
|
-
nextBytes:
|
|
379268
|
+
nextBytes: TE68.encode(step3.nextXml)
|
|
378527
379269
|
});
|
|
378528
379270
|
}
|
|
378529
379271
|
return rewrites;
|
|
@@ -379495,7 +380237,7 @@ function stripRootReplayNamespaceDeclarations(xml) {
|
|
|
379495
380237
|
const openEnd = xml.indexOf(">") + 1;
|
|
379496
380238
|
return stripReplayNamespaceDeclarations(xml.slice(0, openEnd)) + xml.slice(openEnd);
|
|
379497
380239
|
}
|
|
379498
|
-
var FULL_DIFF_APPLY_SUPPORTED_FAMILIES,
|
|
380240
|
+
var FULL_DIFF_APPLY_SUPPORTED_FAMILIES, TE68, TD114, DOCUMENT_PART_URI6 = "/word/document.xml", NUMBERING_PART_URI4 = "/word/numbering.xml", EMPTY_MAIN_DOCUMENT_SOURCE, WORDPROCESSINGML_NS7 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NS2 = "http://schemas.microsoft.com/office/word/2010/wordml", WORDPROCESSING_MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math", MARKUP_COMPATIBILITY_NS3 = "http://schemas.openxmlformats.org/markup-compatibility/2006", VML_NS = "urn:schemas-microsoft-com:vml", STRUCTURAL_PARA_EDIT_DELETE_WML_NAMES, STRUCTURAL_PARA_EDIT_DELETE_MATH_NAMES, STRUCTURAL_PARA_FORMAT_EDIT_WML_NAMES;
|
|
379499
380241
|
var init_adapter25 = __esm(() => {
|
|
379500
380242
|
init_tracked_table_property_replay();
|
|
379501
380243
|
init_src2();
|
|
@@ -379535,7 +380277,7 @@ var init_adapter25 = __esm(() => {
|
|
|
379535
380277
|
"fields-references",
|
|
379536
380278
|
"tracked-changes"
|
|
379537
380279
|
]);
|
|
379538
|
-
|
|
380280
|
+
TE68 = new TextEncoder;
|
|
379539
380281
|
TD114 = new TextDecoder;
|
|
379540
380282
|
EMPTY_MAIN_DOCUMENT_SOURCE = { xml: "" };
|
|
379541
380283
|
STRUCTURAL_PARA_EDIT_DELETE_WML_NAMES = new Set([
|
|
@@ -381303,8 +382045,8 @@ function commitTrackedDefinitionMutation(runtime, abstractNumId, txIdPrefix, mut
|
|
|
381303
382045
|
const id = reference.tag.attributes.find((attr3) => attr3.namespaceUri === WORDPROCESSINGML_NAMESPACE8 && attr3.localName === "val")?.value;
|
|
381304
382046
|
if (!id || !numIds.has(id))
|
|
381305
382047
|
continue;
|
|
381306
|
-
const startByte =
|
|
381307
|
-
const endByte =
|
|
382048
|
+
const startByte = TE69.encode(xml.slice(0, reference.start)).length;
|
|
382049
|
+
const endByte = TE69.encode(xml.slice(0, reference.end)).length;
|
|
381308
382050
|
if (!owners.some((owner) => owner.runtime.partUri === partUri && owner.paragraph.byteStart < startByte && owner.paragraph.byteEnd > endByte)) {
|
|
381309
382051
|
return { ok: false, code: "CAPABILITY_UNAVAILABLE", message: "Tracked shared numbering has an owner outside the editable paragraph stories." };
|
|
381310
382052
|
}
|
|
@@ -381714,7 +382456,7 @@ function commitLocalizedRuntimeMutation(input) {
|
|
|
381714
382456
|
paraId: edit.paraId,
|
|
381715
382457
|
startByte: paragraph4.byteStart,
|
|
381716
382458
|
endByte: paragraph4.byteEnd,
|
|
381717
|
-
bytes: edit.replacementXml === null ? new Uint8Array :
|
|
382459
|
+
bytes: edit.replacementXml === null ? new Uint8Array : TE69.encode(edit.replacementXml)
|
|
381718
382460
|
};
|
|
381719
382461
|
}).filter((row) => row !== null).sort((left, right) => left.startByte - right.startByte);
|
|
381720
382462
|
if (patchRows.length !== input.documentEdits.length || patchRows.length === 0) {
|
|
@@ -381761,7 +382503,7 @@ function commitLocalizedRuntimeMutation(input) {
|
|
|
381761
382503
|
order: 0,
|
|
381762
382504
|
startByte: 0,
|
|
381763
382505
|
endByte: currentBytes.length,
|
|
381764
|
-
bytes:
|
|
382506
|
+
bytes: TE69.encode(serializeNumberingDocument(input.nextNumbering))
|
|
381765
382507
|
}]
|
|
381766
382508
|
};
|
|
381767
382509
|
}
|
|
@@ -381813,7 +382555,7 @@ function applyParagraphEdits(currentBytes, paragraphs, edits) {
|
|
|
381813
382555
|
return {
|
|
381814
382556
|
startByte: paragraph4.byteStart,
|
|
381815
382557
|
endByte: paragraph4.byteEnd,
|
|
381816
|
-
bytes: edit.replacementXml === null ? new Uint8Array :
|
|
382558
|
+
bytes: edit.replacementXml === null ? new Uint8Array : TE69.encode(edit.replacementXml)
|
|
381817
382559
|
};
|
|
381818
382560
|
}).filter((entry) => entry !== null).sort((left, right) => left.startByte - right.startByte);
|
|
381819
382561
|
const chunks = [];
|
|
@@ -382370,7 +383112,7 @@ function escapeForRegex2(value2) {
|
|
|
382370
383112
|
function createEmptyLevelXml(level, prefix = "w") {
|
|
382371
383113
|
return `<${prefix}:lvl w:ilvl="${level}"></${prefix}:lvl>`;
|
|
382372
383114
|
}
|
|
382373
|
-
var NUMBERING_PART_URI5 = "/word/numbering.xml", WORDPROCESSINGML_NAMESPACE8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
383115
|
+
var NUMBERING_PART_URI5 = "/word/numbering.xml", WORDPROCESSINGML_NAMESPACE8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", TE69, TD115;
|
|
382374
383116
|
var init_runtime3 = __esm(() => {
|
|
382375
383117
|
init_src3();
|
|
382376
383118
|
init_sd_document_session_internal();
|
|
@@ -382380,7 +383122,7 @@ var init_runtime3 = __esm(() => {
|
|
|
382380
383122
|
init_xml();
|
|
382381
383123
|
init_xml_rewrite();
|
|
382382
383124
|
init_tracked_sequence_edits();
|
|
382383
|
-
|
|
383125
|
+
TE69 = new TextEncoder;
|
|
382384
383126
|
TD115 = new TextDecoder;
|
|
382385
383127
|
});
|
|
382386
383128
|
|
|
@@ -384435,7 +385177,7 @@ function resolveStoryIdForParagraphInStory(context, paraId, story) {
|
|
|
384435
385177
|
const storyId = resolveStoryIdForListRange(context, story);
|
|
384436
385178
|
if (!storyId)
|
|
384437
385179
|
return null;
|
|
384438
|
-
const entry =
|
|
385180
|
+
const entry = paragraphIndexForStory3(context, storyId)?.byParaId(paraId) ?? null;
|
|
384439
385181
|
return entry?.storyId === storyId ? storyId : null;
|
|
384440
385182
|
}
|
|
384441
385183
|
function resolveStoryIdForListRange(context, story) {
|
|
@@ -384509,7 +385251,7 @@ function resolveParagraphIdsForTarget(context, target) {
|
|
|
384509
385251
|
const toEntry = findParagraphEntry(context, toId);
|
|
384510
385252
|
if (!fromEntry || !toEntry || fromEntry.storyId !== toEntry.storyId)
|
|
384511
385253
|
return [];
|
|
384512
|
-
const index2 =
|
|
385254
|
+
const index2 = paragraphIndexForStory3(context, fromEntry.storyId);
|
|
384513
385255
|
if (!index2)
|
|
384514
385256
|
return [];
|
|
384515
385257
|
const start = index2.entries.findIndex((entry) => entry.blockId === fromId);
|
|
@@ -384914,7 +385656,7 @@ function findPreviousListItemId(context, paraId) {
|
|
|
384914
385656
|
const storyId = resolveStoryIdForParagraph(context, paraId);
|
|
384915
385657
|
if (!storyId)
|
|
384916
385658
|
return null;
|
|
384917
|
-
const index2 =
|
|
385659
|
+
const index2 = paragraphIndexForStory3(context, storyId);
|
|
384918
385660
|
if (!index2)
|
|
384919
385661
|
return null;
|
|
384920
385662
|
const targetIndex = index2.entries.findIndex((entry) => entry.blockId === paraId && entry.storyId === storyId);
|
|
@@ -384948,7 +385690,7 @@ function compatibleMergeParaIds(context, storyId, paraIds, options) {
|
|
|
384948
385690
|
const authorName = tracked ? readTrackedAuthor(context).name : "";
|
|
384949
385691
|
if (tracked && authorName.length === 0)
|
|
384950
385692
|
return [];
|
|
384951
|
-
const index2 =
|
|
385693
|
+
const index2 = paragraphIndexForStory3(context, storyId);
|
|
384952
385694
|
if (!index2)
|
|
384953
385695
|
return [];
|
|
384954
385696
|
for (const paraId of paraIds) {
|
|
@@ -384969,7 +385711,7 @@ function compatibleMergeParaIds(context, storyId, paraIds, options) {
|
|
|
384969
385711
|
return paraIds;
|
|
384970
385712
|
}
|
|
384971
385713
|
function findImmediatelyAdjacentCompatibleListReuse(context, storyId, paraIds, seed, ilvl, requestedPreset) {
|
|
384972
|
-
const index2 =
|
|
385714
|
+
const index2 = paragraphIndexForStory3(context, storyId);
|
|
384973
385715
|
if (!index2 || paraIds.length === 0)
|
|
384974
385716
|
return;
|
|
384975
385717
|
const targetIndexes = paraIds.map((paraId) => index2.entries.findIndex((entry) => entry.blockId === paraId && entry.storyId === storyId));
|
|
@@ -385102,7 +385844,7 @@ function canReuseAdjacentListDefinition(context, definitionNumId, abstractNumId,
|
|
|
385102
385844
|
}
|
|
385103
385845
|
return Array.from(abstract.levels.values()).every((level) => !level.isLgl && !/\blgl\b/i.test(level.numFmt));
|
|
385104
385846
|
}
|
|
385105
|
-
function
|
|
385847
|
+
function paragraphIndexForStory3(context, storyId) {
|
|
385106
385848
|
return getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
|
|
385107
385849
|
}
|
|
385108
385850
|
function findParagraphEntry(context, paraId) {
|
|
@@ -386598,7 +387340,7 @@ function detectTargetConflicts(context, steps, failures) {
|
|
|
386598
387340
|
const key2 = `${storyKeyForTarget(target)}::${target.blockId}`;
|
|
386599
387341
|
const { from, to } = conflictRangeForResolution(context, step3, resolution);
|
|
386600
387342
|
for (const prior of claimedByKey.get(key2) ?? []) {
|
|
386601
|
-
if (
|
|
387343
|
+
if (rangesOverlap11(from, to, prior.from, prior.to)) {
|
|
386602
387344
|
failures.push({
|
|
386603
387345
|
code: "PLAN_CONFLICT_OVERLAP",
|
|
386604
387346
|
stepId: step3.stepId,
|
|
@@ -387594,7 +388336,7 @@ function paragraphOrdinalForTarget(context, target) {
|
|
|
387594
388336
|
const index2 = isMainStoryId(story.storyId) ? getSDDocumentSessionInternalParagraphIndex(context.session) : getSDDocumentSessionInternalStoryParagraphIndex(context.session, story.storyId);
|
|
387595
388337
|
return index2?.byParaId(target.blockId)?.ordinal ?? -1;
|
|
387596
388338
|
}
|
|
387597
|
-
function
|
|
388339
|
+
function rangesOverlap11(start, end, otherStart, otherEnd) {
|
|
387598
388340
|
return start < otherEnd && end > otherStart;
|
|
387599
388341
|
}
|
|
387600
388342
|
function elapsed(startedAt) {
|
|
@@ -389263,7 +390005,7 @@ class V2HyperlinksAdapter {
|
|
|
389263
390005
|
if (!paragraph4) {
|
|
389264
390006
|
return mutationFailure4("TARGET_NOT_FOUND", `Block "${resolved.startBlockId}" was not found.`);
|
|
389265
390007
|
}
|
|
389266
|
-
const existingOverlap = readBodyHyperlinkEntries(this.context).some((entry) => entry.address.anchor.start.blockId === paragraph4.blockId &&
|
|
390008
|
+
const existingOverlap = readBodyHyperlinkEntries(this.context).some((entry) => entry.address.anchor.start.blockId === paragraph4.blockId && rangesOverlap12(entry.address.anchor.start.offset, entry.address.anchor.end.offset, resolved.startOffset, resolved.endOffset));
|
|
389267
390009
|
if (existingOverlap) {
|
|
389268
390010
|
return mutationFailure4("INVALID_TARGET", "hyperlinks.wrap does not support ranges that overlap an existing hyperlink.");
|
|
389269
390011
|
}
|
|
@@ -389592,7 +390334,7 @@ class V2HyperlinksAdapter {
|
|
|
389592
390334
|
after: {
|
|
389593
390335
|
partUri: entry.partUri,
|
|
389594
390336
|
startByte: entry.descriptor.byteStart,
|
|
389595
|
-
endByte: entry.descriptor.byteEnd +
|
|
390337
|
+
endByte: entry.descriptor.byteEnd + TE70.encode(nextHyperlinkXml).length - TE70.encode(hyperlinkXml).length
|
|
389596
390338
|
},
|
|
389597
390339
|
...input.patch.rel !== undefined ? { rel: input.patch.rel } : {}
|
|
389598
390340
|
}],
|
|
@@ -389874,7 +390616,7 @@ function hyperlinkSessionAnchor(partUri, descriptor) {
|
|
|
389874
390616
|
}
|
|
389875
390617
|
function createdHyperlinkAnchor(paragraph4, nextParagraphXml, nextDocumentXml, start, end) {
|
|
389876
390618
|
const catalog = buildHyperlinkCatalog({
|
|
389877
|
-
bytes:
|
|
390619
|
+
bytes: TE70.encode(nextDocumentXml),
|
|
389878
390620
|
storyId: paragraph4.storyId,
|
|
389879
390621
|
partUri: paragraph4.partUri,
|
|
389880
390622
|
relsBytes: null
|
|
@@ -390095,7 +390837,7 @@ function operationError12(code2, message, operationId) {
|
|
|
390095
390837
|
error48.details = { operationId };
|
|
390096
390838
|
return error48;
|
|
390097
390839
|
}
|
|
390098
|
-
function
|
|
390840
|
+
function rangesOverlap12(startA, endA, startB, endB) {
|
|
390099
390841
|
return startA < endB && startB < endA;
|
|
390100
390842
|
}
|
|
390101
390843
|
function relsPartUriForPart2(partUri) {
|
|
@@ -390199,7 +390941,7 @@ function escapeRegex15(value2) {
|
|
|
390199
390941
|
function defaultRelationshipsXml3() {
|
|
390200
390942
|
return '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
|
|
390201
390943
|
}
|
|
390202
|
-
var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD120,
|
|
390944
|
+
var HYPERLINK_REL_TYPE3 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", TD120, TE70;
|
|
390203
390945
|
var init_adapter34 = __esm(() => {
|
|
390204
390946
|
init_sd_document_session_internal();
|
|
390205
390947
|
init_inline();
|
|
@@ -390210,7 +390952,7 @@ var init_adapter34 = __esm(() => {
|
|
|
390210
390952
|
init_stories();
|
|
390211
390953
|
init_registry3();
|
|
390212
390954
|
TD120 = new TextDecoder;
|
|
390213
|
-
|
|
390955
|
+
TE70 = new TextEncoder;
|
|
390214
390956
|
});
|
|
390215
390957
|
|
|
390216
390958
|
// ../../../v2/document-api-v2-adapter/dist/watermarks/serialization.js
|
|
@@ -394405,75 +395147,6 @@ var init_parse5 = __esm(() => {
|
|
|
394405
395147
|
init_plan3();
|
|
394406
395148
|
});
|
|
394407
395149
|
|
|
394408
|
-
// ../../../v2/document-api-v2-adapter/dist/selection/footnote-range.js
|
|
394409
|
-
function resolveFootnoteRangeIndex(session, index2, start, end) {
|
|
394410
|
-
if (start.story.storyType !== "footnote" || end.story.storyType !== "footnote")
|
|
394411
|
-
return null;
|
|
394412
|
-
const main = getSDDocumentSessionInternalSourceSignalsSnapshot(session)?.stories.find((story) => story.storyKind === "main");
|
|
394413
|
-
const bytes = getSDDocumentSessionInternalPartBytes(session, FOOTNOTES_PART_URI3);
|
|
394414
|
-
if (!main || main.completeness.noteAnchorRefs !== "complete" || !bytes)
|
|
394415
|
-
return null;
|
|
394416
|
-
const xml = new TextDecoder().decode(bytes);
|
|
394417
|
-
const parsed = collectXmlElementRanges(xml);
|
|
394418
|
-
if (parsed.errors.length)
|
|
394419
|
-
return null;
|
|
394420
|
-
const notes = parsed.ranges.filter(({ tag }) => tag.namespaceUri === W_NS8 && tag.localName === "footnote").sort((a, b) => a.start - b.start);
|
|
394421
|
-
const sourceEntries = [...index2.entries].sort((a, b) => a.byteStart - b.byteStart);
|
|
394422
|
-
const groups = new Map;
|
|
394423
|
-
let charCursor = 0;
|
|
394424
|
-
let byteCursor = bytes[0] === 239 && bytes[1] === 187 && bytes[2] === 191 ? 3 : 0;
|
|
394425
|
-
let entryCursor = 0;
|
|
394426
|
-
for (const note of notes) {
|
|
394427
|
-
const id = readXmlAttributes(note.tag, W_NS8, "id")[0]?.value;
|
|
394428
|
-
if (!id || groups.has(id))
|
|
394429
|
-
return null;
|
|
394430
|
-
byteCursor += TE70.encode(xml.slice(charCursor, note.start)).byteLength;
|
|
394431
|
-
const byteStart = byteCursor;
|
|
394432
|
-
byteCursor += TE70.encode(xml.slice(note.start, note.end)).byteLength;
|
|
394433
|
-
charCursor = note.end;
|
|
394434
|
-
const group = [];
|
|
394435
|
-
while (entryCursor < sourceEntries.length && sourceEntries[entryCursor].byteStart < byteCursor) {
|
|
394436
|
-
const entry = sourceEntries[entryCursor++];
|
|
394437
|
-
if (entry.byteStart >= byteStart && entry.byteEnd <= byteCursor)
|
|
394438
|
-
group.push(entry);
|
|
394439
|
-
}
|
|
394440
|
-
groups.set(id, group);
|
|
394441
|
-
}
|
|
394442
|
-
const entries = [];
|
|
394443
|
-
const seen = new Set;
|
|
394444
|
-
let startOwned = false;
|
|
394445
|
-
let endOwned = false;
|
|
394446
|
-
const references = [...main.noteAnchorRefs].sort((a, b) => (a.bodyChildOrdinal ?? 0) - (b.bodyChildOrdinal ?? 0) || (a.sourceAnchor.stability === "byte-span" ? a.sourceAnchor.byteSpan[0] : 0) - (b.sourceAnchor.stability === "byte-span" ? b.sourceAnchor.byteSpan[0] : 0));
|
|
394447
|
-
for (const ref5 of references) {
|
|
394448
|
-
if (ref5.kind !== "footnote" || !ref5.nativeId || ref5.trackedChangeState === "deleted" || ref5.trackedChangeState === "move-from" || seen.has(ref5.nativeId))
|
|
394449
|
-
continue;
|
|
394450
|
-
seen.add(ref5.nativeId);
|
|
394451
|
-
const group = groups.get(ref5.nativeId);
|
|
394452
|
-
if (!group)
|
|
394453
|
-
return null;
|
|
394454
|
-
for (const entry of group) {
|
|
394455
|
-
startOwned || (startOwned = ref5.nativeId === start.story.noteId && entry.blockId === start.blockId);
|
|
394456
|
-
endOwned || (endOwned = ref5.nativeId === end.story.noteId && entry.blockId === end.blockId);
|
|
394457
|
-
entries.push({ ...entry, ordinal: entries.length });
|
|
394458
|
-
}
|
|
394459
|
-
}
|
|
394460
|
-
if (!startOwned || !endOwned)
|
|
394461
|
-
return null;
|
|
394462
|
-
const byBlockId = new Map(entries.map((entry) => [entry.blockId, entry]));
|
|
394463
|
-
return {
|
|
394464
|
-
entries,
|
|
394465
|
-
duplicateParaIds: index2.duplicateParaIds,
|
|
394466
|
-
entriesByBlockId: byBlockId,
|
|
394467
|
-
byParaId: (blockId) => byBlockId.get(blockId) ?? null
|
|
394468
|
-
};
|
|
394469
|
-
}
|
|
394470
|
-
var W_NS8 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", TE70;
|
|
394471
|
-
var init_footnote_range = __esm(() => {
|
|
394472
|
-
init_sd_document_session_internal();
|
|
394473
|
-
init_note_story();
|
|
394474
|
-
TE70 = new TextEncoder;
|
|
394475
|
-
});
|
|
394476
|
-
|
|
394477
395150
|
// ../../../v2/document-api-v2-adapter/dist/clipboard/serialize.js
|
|
394478
395151
|
class SelectionHyperlinkDescriptorResolver {
|
|
394479
395152
|
constructor(context, storyId) {
|
|
@@ -394962,7 +395635,7 @@ function serializeSelectedDrawing(input) {
|
|
|
394962
395635
|
return fail6("inline-object", "Inline objects (drawings, pictures, embedded objects) are not preserved by copy.");
|
|
394963
395636
|
if (/<[\w.-]+:srcRect\b/.test(xml))
|
|
394964
395637
|
return fail6("cropped-image", "Cropped images are not preserved by copy.");
|
|
394965
|
-
const rId =
|
|
395638
|
+
const rId = readXmlAttribute6(xml, "blip", "embed", "r");
|
|
394966
395639
|
if (!rId)
|
|
394967
395640
|
return fail6("inline-object", "Inline objects (drawings, pictures, embedded objects) are not preserved by copy.");
|
|
394968
395641
|
const mediaPartUri = resolveImageRelationship(input.context, input.storyPartUri, rId);
|
|
@@ -395053,9 +395726,9 @@ function clampImageDimension(value2) {
|
|
|
395053
395726
|
return Math.max(1, Math.min(1e4, Number.isFinite(value2) ? value2 : 1));
|
|
395054
395727
|
}
|
|
395055
395728
|
function boundedAttribute(xml, tag, attribute2) {
|
|
395056
|
-
return
|
|
395729
|
+
return readXmlAttribute6(xml, tag, attribute2)?.slice(0, MAX_IMAGE_METADATA_CHARS) || undefined;
|
|
395057
395730
|
}
|
|
395058
|
-
function
|
|
395731
|
+
function readXmlAttribute6(xml, tag, attribute2, prefix) {
|
|
395059
395732
|
const open2 = new RegExp(`<[\\w.-]+:${tag}\\b[^>]*>`).exec(xml)?.[0];
|
|
395060
395733
|
return open2 ? readBareAttribute(open2, prefix ? `${prefix}:${attribute2}` : attribute2) : null;
|
|
395061
395734
|
}
|
|
@@ -401273,538 +401946,6 @@ var init_prepared_mutation2 = __esm(() => {
|
|
|
401273
401946
|
]);
|
|
401274
401947
|
});
|
|
401275
401948
|
|
|
401276
|
-
// ../../../v2/document-api-v2-adapter/dist/selection/live-selection.js
|
|
401277
|
-
function distinctFootnotes(start, end) {
|
|
401278
|
-
return start.storyType === "footnote" && end.storyType === "footnote" && start.noteId !== end.noteId;
|
|
401279
|
-
}
|
|
401280
|
-
function buildVisibleSelectionTarget(story, start, end) {
|
|
401281
|
-
return {
|
|
401282
|
-
kind: "selection",
|
|
401283
|
-
start: { kind: "text", blockId: start.blockId, offset: start.offset, story: start.story ?? story },
|
|
401284
|
-
end: { kind: "text", blockId: end.blockId, offset: end.offset, story: end.story ?? story },
|
|
401285
|
-
...distinctFootnotes(start.story ?? story, end.story ?? story) ? {} : { story }
|
|
401286
|
-
};
|
|
401287
|
-
}
|
|
401288
|
-
function buildSelectionTarget(session, story, start, end, entries) {
|
|
401289
|
-
const hasTrackedEndpoint = start.trackedOffset != null || end.trackedOffset != null;
|
|
401290
|
-
if (!hasTrackedEndpoint)
|
|
401291
|
-
return buildVisibleSelectionTarget(story, start, end);
|
|
401292
|
-
const startEntry = entries[0];
|
|
401293
|
-
const endEntry = entries[entries.length - 1];
|
|
401294
|
-
if (!startEntry || !endEntry)
|
|
401295
|
-
return null;
|
|
401296
|
-
const startMap = readParagraphInlineMap(session, startEntry);
|
|
401297
|
-
const endMap = startEntry === endEntry ? startMap : readParagraphInlineMap(session, endEntry);
|
|
401298
|
-
if (!startMap || !endMap)
|
|
401299
|
-
return null;
|
|
401300
|
-
const resolvedStart = resolveTrackedSelectionEndpoint(startMap, start, "upstream");
|
|
401301
|
-
const resolvedEnd = resolveTrackedSelectionEndpoint(endMap, end, "downstream");
|
|
401302
|
-
if (resolvedStart == null || resolvedEnd == null) {
|
|
401303
|
-
return null;
|
|
401304
|
-
}
|
|
401305
|
-
const [orderedStart2, orderedEnd] = start.blockId === end.blockId && resolvedEnd < resolvedStart ? [resolvedEnd, resolvedStart] : [resolvedStart, resolvedEnd];
|
|
401306
|
-
return {
|
|
401307
|
-
kind: "selection",
|
|
401308
|
-
start: { kind: "text", blockId: start.blockId, offset: orderedStart2, story: start.story ?? story },
|
|
401309
|
-
end: { kind: "text", blockId: end.blockId, offset: orderedEnd, story: end.story ?? story },
|
|
401310
|
-
...distinctFootnotes(start.story ?? story, end.story ?? story) ? {} : { story },
|
|
401311
|
-
coordinateSpace: "tracked"
|
|
401312
|
-
};
|
|
401313
|
-
}
|
|
401314
|
-
function readParagraphInlineMap(session, entry) {
|
|
401315
|
-
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
401316
|
-
if (!bytes)
|
|
401317
|
-
return null;
|
|
401318
|
-
return parseParagraphInlineMap(TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd)));
|
|
401319
|
-
}
|
|
401320
|
-
function resolveTrackedSelectionEndpoint(map3, point3, bias) {
|
|
401321
|
-
if (point3.trackedOffset != null) {
|
|
401322
|
-
return Number.isInteger(point3.trackedOffset) && point3.trackedOffset >= 0 && point3.trackedOffset <= map3.trackedLength ? point3.trackedOffset : null;
|
|
401323
|
-
}
|
|
401324
|
-
return projectVisibleOffsetToTracked(map3, clampOffset(point3.offset, map3.visibleLength), bias);
|
|
401325
|
-
}
|
|
401326
|
-
function resolveBrowserLiveSelectionParagraphIndex(session, story, startBlockId, endBlockId) {
|
|
401327
|
-
const mainIndex = getSDDocumentSessionInternalParagraphIndex(session);
|
|
401328
|
-
const stories = listSDDocumentSessionInternalStories(session);
|
|
401329
|
-
if (!story || story.storyType === "body") {
|
|
401330
|
-
return hasSelectionBlocks(mainIndex, startBlockId, endBlockId) ? mainIndex : null;
|
|
401331
|
-
}
|
|
401332
|
-
if (story.storyType === "headerFooterPart") {
|
|
401333
|
-
const resolved = getSDDocumentSessionInternalHeaderFooterPartUriForRefId(session, story.refId);
|
|
401334
|
-
if (!resolved)
|
|
401335
|
-
return null;
|
|
401336
|
-
const match = stories.find((candidate2) => candidate2.partUri === resolved.partUri);
|
|
401337
|
-
if (!match)
|
|
401338
|
-
return null;
|
|
401339
|
-
return paragraphIndexForStory3(session, match.storyId, mainIndex);
|
|
401340
|
-
}
|
|
401341
|
-
const candidates = stories.filter((candidate2) => storyCandidateMatches(candidate2, story));
|
|
401342
|
-
for (const candidate2 of candidates) {
|
|
401343
|
-
const index2 = paragraphIndexForStory3(session, candidate2.storyId, mainIndex);
|
|
401344
|
-
if (hasSelectionBlocks(index2, startBlockId, endBlockId))
|
|
401345
|
-
return index2;
|
|
401346
|
-
}
|
|
401347
|
-
return null;
|
|
401348
|
-
}
|
|
401349
|
-
function paragraphIndexForStory3(session, storyId, mainIndex) {
|
|
401350
|
-
if (mainIndex?.entries[0]?.storyId === storyId)
|
|
401351
|
-
return mainIndex;
|
|
401352
|
-
return getSDDocumentSessionInternalStoryParagraphIndex(session, storyId);
|
|
401353
|
-
}
|
|
401354
|
-
function storyCandidateMatches(candidate2, story) {
|
|
401355
|
-
switch (story.storyType) {
|
|
401356
|
-
case "headerFooterSlot":
|
|
401357
|
-
return candidate2.storyKind === story.headerFooterKind;
|
|
401358
|
-
case "footnote":
|
|
401359
|
-
return candidate2.storyKind === "footnotes";
|
|
401360
|
-
case "endnote":
|
|
401361
|
-
return candidate2.storyKind === "endnotes";
|
|
401362
|
-
case "textbox":
|
|
401363
|
-
return candidate2.storyKind === "textbox" && candidate2.textboxId === story.textboxId;
|
|
401364
|
-
default:
|
|
401365
|
-
return false;
|
|
401366
|
-
}
|
|
401367
|
-
}
|
|
401368
|
-
function hasSelectionBlocks(index2, startBlockId, endBlockId) {
|
|
401369
|
-
return Boolean(index2?.byParaId(startBlockId) && index2.byParaId(endBlockId));
|
|
401370
|
-
}
|
|
401371
|
-
function clampOffset(offset, textLength) {
|
|
401372
|
-
return Math.max(0, Math.min(textLength, offset));
|
|
401373
|
-
}
|
|
401374
|
-
function resolveEntries(session, input) {
|
|
401375
|
-
let index2 = resolveBrowserLiveSelectionParagraphIndex(session, input.story, input.start.blockId, input.end.blockId);
|
|
401376
|
-
if (!index2)
|
|
401377
|
-
return null;
|
|
401378
|
-
const startStory = input.start.story ?? input.story;
|
|
401379
|
-
const endStory = input.end.story ?? input.story;
|
|
401380
|
-
if (distinctFootnotes(startStory, endStory)) {
|
|
401381
|
-
index2 = resolveFootnoteRangeIndex(session, index2, { blockId: input.start.blockId, story: startStory }, { blockId: input.end.blockId, story: endStory });
|
|
401382
|
-
if (!index2)
|
|
401383
|
-
return null;
|
|
401384
|
-
}
|
|
401385
|
-
if (index2.duplicateParaIds.has(input.start.blockId) || index2.duplicateParaIds.has(input.end.blockId))
|
|
401386
|
-
return null;
|
|
401387
|
-
let startEntry = index2.byParaId(input.start.blockId);
|
|
401388
|
-
let endEntry = index2.byParaId(input.end.blockId);
|
|
401389
|
-
if (!startEntry || !endEntry || startEntry.storyId !== endEntry.storyId)
|
|
401390
|
-
return null;
|
|
401391
|
-
let startPoint = input.start;
|
|
401392
|
-
let endPoint = input.end;
|
|
401393
|
-
if (startEntry.ordinal > endEntry.ordinal) {
|
|
401394
|
-
[startEntry, endEntry] = [endEntry, startEntry];
|
|
401395
|
-
[startPoint, endPoint] = [endPoint, startPoint];
|
|
401396
|
-
}
|
|
401397
|
-
const entries = index2.entries.slice(startEntry.ordinal, endEntry.ordinal + 1);
|
|
401398
|
-
if (entries.length === 0)
|
|
401399
|
-
return null;
|
|
401400
|
-
const visibleStart = resolveVisibleSelectionOffset(session, startEntry, startPoint);
|
|
401401
|
-
const visibleEnd = resolveVisibleSelectionOffset(session, endEntry, endPoint);
|
|
401402
|
-
if (visibleStart == null || visibleEnd == null)
|
|
401403
|
-
return null;
|
|
401404
|
-
const segments = entries.map((entry, idx) => {
|
|
401405
|
-
const start = idx === 0 ? visibleStart : 0;
|
|
401406
|
-
const end = idx === entries.length - 1 ? visibleEnd : entry.textLength;
|
|
401407
|
-
return {
|
|
401408
|
-
blockId: entry.blockId,
|
|
401409
|
-
range: { start, end: Math.max(start, end) }
|
|
401410
|
-
};
|
|
401411
|
-
});
|
|
401412
|
-
return {
|
|
401413
|
-
target: {
|
|
401414
|
-
kind: "text",
|
|
401415
|
-
segments,
|
|
401416
|
-
...input.story ? { story: input.story } : {}
|
|
401417
|
-
},
|
|
401418
|
-
entries,
|
|
401419
|
-
start: startPoint,
|
|
401420
|
-
end: endPoint
|
|
401421
|
-
};
|
|
401422
|
-
}
|
|
401423
|
-
function resolveVisibleSelectionOffset(session, entry, point3) {
|
|
401424
|
-
if (point3.trackedOffset == null)
|
|
401425
|
-
return clampOffset(point3.offset, entry.textLength);
|
|
401426
|
-
const map3 = readParagraphInlineMap(session, entry);
|
|
401427
|
-
return map3 ? projectTrackedOffsetToVisible(map3, point3.trackedOffset) : null;
|
|
401428
|
-
}
|
|
401429
|
-
function resolveBrowserLiveSelectionForSession(session, input, options = {}) {
|
|
401430
|
-
const resolved = resolveEntries(session, input);
|
|
401431
|
-
if (!resolved)
|
|
401432
|
-
return null;
|
|
401433
|
-
const selectionTarget = buildSelectionTarget(session, input.story, resolved.start, resolved.end, resolved.entries);
|
|
401434
|
-
if (!selectionTarget)
|
|
401435
|
-
return null;
|
|
401436
|
-
const reviewIds = readActiveReviewIds(session, resolved.entries, resolved.target.segments, options);
|
|
401437
|
-
return {
|
|
401438
|
-
target: distinctFootnotes(resolved.start.story ?? input.story, resolved.end.story ?? input.story) ? null : resolved.target,
|
|
401439
|
-
selectionTarget,
|
|
401440
|
-
text: input.includeText === true ? readSelectionText(session, resolved.entries, resolved.target.segments) : "",
|
|
401441
|
-
activeMarks: readActiveMarks(session, resolved.entries, resolved.target.segments),
|
|
401442
|
-
activeCommentIds: reviewIds.activeCommentIds,
|
|
401443
|
-
activeChangeIds: reviewIds.activeChangeIds
|
|
401444
|
-
};
|
|
401445
|
-
}
|
|
401446
|
-
function readSelectionText(session, entries, segments) {
|
|
401447
|
-
const slices = [];
|
|
401448
|
-
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
401449
|
-
const entry = entries[i2];
|
|
401450
|
-
const segment = segments[i2];
|
|
401451
|
-
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
401452
|
-
if (!bytes)
|
|
401453
|
-
return "";
|
|
401454
|
-
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
401455
|
-
const paragraphText3 = visibleParagraphTextFromXml(xml);
|
|
401456
|
-
const start = clampOffset(segment.range.start, paragraphText3.length);
|
|
401457
|
-
const end = clampOffset(segment.range.end, paragraphText3.length);
|
|
401458
|
-
slices.push(paragraphText3.slice(start, Math.max(start, end)));
|
|
401459
|
-
}
|
|
401460
|
-
return slices.join(" ");
|
|
401461
|
-
}
|
|
401462
|
-
function readActiveMarks(session, entries, segments) {
|
|
401463
|
-
let common = null;
|
|
401464
|
-
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
401465
|
-
const entry = entries[i2];
|
|
401466
|
-
const segment = segments[i2];
|
|
401467
|
-
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
401468
|
-
if (!bytes)
|
|
401469
|
-
return [];
|
|
401470
|
-
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
401471
|
-
const paragraphText3 = visibleParagraphTextFromXml(xml);
|
|
401472
|
-
const start = clampOffset(segment.range.start, paragraphText3.length);
|
|
401473
|
-
const end = clampOffset(segment.range.end, paragraphText3.length);
|
|
401474
|
-
const marks = new Set(activeMarksForParagraphXmlRange(xml, start, Math.max(start, end)));
|
|
401475
|
-
common = common == null ? marks : intersectStringSets(common, marks);
|
|
401476
|
-
}
|
|
401477
|
-
if (!common)
|
|
401478
|
-
return [];
|
|
401479
|
-
return ACTIVE_MARK_ORDER.filter((mark) => common.has(mark));
|
|
401480
|
-
}
|
|
401481
|
-
function readActiveReviewIds(session, entries, segments, options) {
|
|
401482
|
-
return {
|
|
401483
|
-
activeCommentIds: readActiveCommentIds(session, segments),
|
|
401484
|
-
activeChangeIds: readActiveChangeIds(session, entries, segments, options)
|
|
401485
|
-
};
|
|
401486
|
-
}
|
|
401487
|
-
function readActiveCommentIds(session, segments) {
|
|
401488
|
-
const catalog = getSDDocumentSessionInternalCommentsCatalog(session);
|
|
401489
|
-
if (!catalog)
|
|
401490
|
-
return [];
|
|
401491
|
-
const anchorIndex = getSDDocumentSessionInternalCommentAnchorIndex(session);
|
|
401492
|
-
const ids = [];
|
|
401493
|
-
for (const [sourceWId, hits] of anchorIndex.hitsBySourceWId) {
|
|
401494
|
-
const catalogEntries = catalog.commentsBySourceWId.get(sourceWId);
|
|
401495
|
-
if (!catalogEntries || catalogEntries.length === 0)
|
|
401496
|
-
continue;
|
|
401497
|
-
let overlaps2 = false;
|
|
401498
|
-
for (const hit of hits) {
|
|
401499
|
-
for (const hitSegment of hit.segments) {
|
|
401500
|
-
if (!hitSegment.blockId)
|
|
401501
|
-
continue;
|
|
401502
|
-
const selectionSegment = segments.find((segment) => segment.blockId === hitSegment.blockId);
|
|
401503
|
-
if (!selectionSegment)
|
|
401504
|
-
continue;
|
|
401505
|
-
if (rangesOverlap12(hitSegment.start, hitSegment.end, selectionSegment.range.start, selectionSegment.range.end)) {
|
|
401506
|
-
overlaps2 = true;
|
|
401507
|
-
break;
|
|
401508
|
-
}
|
|
401509
|
-
}
|
|
401510
|
-
if (overlaps2)
|
|
401511
|
-
break;
|
|
401512
|
-
}
|
|
401513
|
-
if (!overlaps2)
|
|
401514
|
-
continue;
|
|
401515
|
-
for (const entry of catalogEntries)
|
|
401516
|
-
pushUnique(ids, entry.commentId);
|
|
401517
|
-
}
|
|
401518
|
-
return ids;
|
|
401519
|
-
}
|
|
401520
|
-
function readActiveChangeIds(session, entries, segments, options) {
|
|
401521
|
-
const activeSourceIds = new Set;
|
|
401522
|
-
for (let i2 = 0;i2 < entries.length && i2 < segments.length; i2 += 1) {
|
|
401523
|
-
const entry = entries[i2];
|
|
401524
|
-
const segment = segments[i2];
|
|
401525
|
-
const bytes = getSDDocumentSessionInternalPartBytes(session, entry.partUri);
|
|
401526
|
-
if (!bytes)
|
|
401527
|
-
return [];
|
|
401528
|
-
const xml = TEXT_DECODER7.decode(bytes.subarray(entry.byteStart, entry.byteEnd));
|
|
401529
|
-
const paragraphText3 = visibleParagraphTextFromXml(xml);
|
|
401530
|
-
const start = clampOffset(segment.range.start, paragraphText3.length);
|
|
401531
|
-
const end = clampOffset(segment.range.end, paragraphText3.length);
|
|
401532
|
-
for (const sourceId of activeTrackedChangeSourceIdsForParagraphXmlRange(xml, start, Math.max(start, end))) {
|
|
401533
|
-
activeSourceIds.add(sourceId);
|
|
401534
|
-
}
|
|
401535
|
-
}
|
|
401536
|
-
if (activeSourceIds.size === 0)
|
|
401537
|
-
return [];
|
|
401538
|
-
const resolved = options.resolveTrackChangeIds?.(activeSourceIds);
|
|
401539
|
-
if (resolved)
|
|
401540
|
-
return [...new Set(resolved)];
|
|
401541
|
-
const sourceIdToChangeIds = buildTrackedChangeSourceMap(options.trackChangesList?.()?.items ?? []);
|
|
401542
|
-
if (sourceIdToChangeIds.size === 0)
|
|
401543
|
-
return [];
|
|
401544
|
-
const out = [];
|
|
401545
|
-
for (const sourceId of activeSourceIds) {
|
|
401546
|
-
const changeIds = sourceIdToChangeIds.get(sourceId);
|
|
401547
|
-
if (!changeIds)
|
|
401548
|
-
continue;
|
|
401549
|
-
for (const changeId of changeIds)
|
|
401550
|
-
pushUnique(out, changeId);
|
|
401551
|
-
}
|
|
401552
|
-
return out;
|
|
401553
|
-
}
|
|
401554
|
-
function buildTrackedChangeSourceMap(items) {
|
|
401555
|
-
const map3 = new Map;
|
|
401556
|
-
for (const item of items) {
|
|
401557
|
-
if (!item || typeof item !== "object")
|
|
401558
|
-
continue;
|
|
401559
|
-
const record3 = item;
|
|
401560
|
-
const id = typeof record3.id === "string" ? record3.id : null;
|
|
401561
|
-
if (!id)
|
|
401562
|
-
continue;
|
|
401563
|
-
const sourceIds = record3.sourceIds && typeof record3.sourceIds === "object" ? record3.sourceIds : {};
|
|
401564
|
-
const wordRevisionIds = record3.wordRevisionIds && typeof record3.wordRevisionIds === "object" ? record3.wordRevisionIds : {};
|
|
401565
|
-
pushTrackedSourceMap(map3, sourceIds.wordIdInsert, id);
|
|
401566
|
-
pushTrackedSourceMap(map3, sourceIds.wordIdDelete, id);
|
|
401567
|
-
for (const sourceId of Array.isArray(sourceIds.wordIdOther) ? sourceIds.wordIdOther : []) {
|
|
401568
|
-
pushTrackedSourceMap(map3, sourceId, id);
|
|
401569
|
-
}
|
|
401570
|
-
pushTrackedSourceMap(map3, wordRevisionIds.insert, id);
|
|
401571
|
-
pushTrackedSourceMap(map3, wordRevisionIds.delete, id);
|
|
401572
|
-
pushTrackedSourceMap(map3, wordRevisionIds.format, id);
|
|
401573
|
-
}
|
|
401574
|
-
return map3;
|
|
401575
|
-
}
|
|
401576
|
-
function pushTrackedSourceMap(map3, sourceId, changeId) {
|
|
401577
|
-
if (typeof sourceId !== "string" || sourceId.length === 0)
|
|
401578
|
-
return;
|
|
401579
|
-
const ids = map3.get(sourceId) ?? [];
|
|
401580
|
-
pushUnique(ids, changeId);
|
|
401581
|
-
map3.set(sourceId, ids);
|
|
401582
|
-
}
|
|
401583
|
-
function visibleParagraphTextFromXml(xml) {
|
|
401584
|
-
const stripped = stripTextboxContent2(stripParagraphProperties3(stripDeletedRevisions(xml)));
|
|
401585
|
-
let out = "";
|
|
401586
|
-
for (const token of stripped.matchAll(/<[\w.-]+:t\b[^>]*>([\s\S]*?)<\/[\w.-]+:t>|<[\w.-]+:(tab|br|cr)\b[^>]*\/>/g)) {
|
|
401587
|
-
if (token[1] != null) {
|
|
401588
|
-
out += decodeXmlText13(token[1]);
|
|
401589
|
-
continue;
|
|
401590
|
-
}
|
|
401591
|
-
out += token[2] === "tab" ? "\t" : `
|
|
401592
|
-
`;
|
|
401593
|
-
}
|
|
401594
|
-
return out;
|
|
401595
|
-
}
|
|
401596
|
-
function visibleRunMarkSlicesFromXml(xml) {
|
|
401597
|
-
const stripped = stripTextboxContent2(stripParagraphProperties3(stripDeletedRevisions(xml)));
|
|
401598
|
-
const slices = [];
|
|
401599
|
-
let cursor = 0;
|
|
401600
|
-
for (const match of stripped.matchAll(/<(?:[\w.-]+:)?r\b[^>]*>[\s\S]*?<\/(?:[\w.-]+:)?r>/g)) {
|
|
401601
|
-
const runXml = match[0];
|
|
401602
|
-
const textLength = visibleParagraphTextFromXml(runXml).length;
|
|
401603
|
-
if (textLength > 0) {
|
|
401604
|
-
slices.push({ start: cursor, end: cursor + textLength, marks: activeMarksForRunXml(runXml) });
|
|
401605
|
-
}
|
|
401606
|
-
cursor += textLength;
|
|
401607
|
-
}
|
|
401608
|
-
return slices;
|
|
401609
|
-
}
|
|
401610
|
-
function activeMarksForRunXml(runXml) {
|
|
401611
|
-
const rPr = findFirstElement(runXml, "rPr")?.xml ?? "";
|
|
401612
|
-
if (!rPr)
|
|
401613
|
-
return [];
|
|
401614
|
-
const marks = [];
|
|
401615
|
-
if (hasOnOffRunProperty(rPr, "b"))
|
|
401616
|
-
marks.push("bold");
|
|
401617
|
-
if (hasOnOffRunProperty(rPr, "i"))
|
|
401618
|
-
marks.push("italic");
|
|
401619
|
-
if (hasOnOffRunProperty(rPr, "u"))
|
|
401620
|
-
marks.push("underline");
|
|
401621
|
-
if (hasOnOffRunProperty(rPr, "strike"))
|
|
401622
|
-
marks.push("strikethrough");
|
|
401623
|
-
return marks;
|
|
401624
|
-
}
|
|
401625
|
-
function hasOnOffRunProperty(rPrXml, localName2) {
|
|
401626
|
-
const match = rPrXml.match(new RegExp(`<(?:[\\w.-]+:)?${localName2}\\b([^>]*)\\/?>`, "i"));
|
|
401627
|
-
if (!match)
|
|
401628
|
-
return false;
|
|
401629
|
-
const attrs = match[1] ?? "";
|
|
401630
|
-
const val = attrs.match(/(?:^|\s)(?:[\w.-]+:)?val=(["'])(.*?)\1/i)?.[2]?.toLowerCase();
|
|
401631
|
-
return val !== "0" && val !== "false" && val !== "off" && val !== "none";
|
|
401632
|
-
}
|
|
401633
|
-
function activeMarksForParagraphXmlRange(xml, start, end) {
|
|
401634
|
-
const slices = visibleRunMarkSlicesFromXml(xml);
|
|
401635
|
-
if (slices.length === 0)
|
|
401636
|
-
return [];
|
|
401637
|
-
if (start === end) {
|
|
401638
|
-
const containing = slices.find((slice) => start > slice.start && start < slice.end);
|
|
401639
|
-
if (containing)
|
|
401640
|
-
return containing.marks;
|
|
401641
|
-
let previous3 = null;
|
|
401642
|
-
for (const slice of slices) {
|
|
401643
|
-
if (slice.end <= start)
|
|
401644
|
-
previous3 = slice;
|
|
401645
|
-
}
|
|
401646
|
-
if (previous3)
|
|
401647
|
-
return previous3.marks;
|
|
401648
|
-
return slices[0]?.marks ?? [];
|
|
401649
|
-
}
|
|
401650
|
-
let common = null;
|
|
401651
|
-
for (const slice of slices) {
|
|
401652
|
-
if (Math.max(start, slice.start) >= Math.min(end, slice.end))
|
|
401653
|
-
continue;
|
|
401654
|
-
const marks = new Set(slice.marks);
|
|
401655
|
-
common = common == null ? marks : intersectStringSets(common, marks);
|
|
401656
|
-
}
|
|
401657
|
-
if (!common)
|
|
401658
|
-
return [];
|
|
401659
|
-
return ACTIVE_MARK_ORDER.filter((mark) => common.has(mark));
|
|
401660
|
-
}
|
|
401661
|
-
function activeTrackedChangeSourceIdsForParagraphXmlRange(xml, start, end) {
|
|
401662
|
-
const slices = visibleTrackedChangeSourceSlicesFromXml(xml);
|
|
401663
|
-
if (slices.length === 0)
|
|
401664
|
-
return [];
|
|
401665
|
-
const out = [];
|
|
401666
|
-
for (const slice of slices) {
|
|
401667
|
-
if (!rangesOverlap12(slice.start, slice.end, start, end))
|
|
401668
|
-
continue;
|
|
401669
|
-
for (const sourceId of slice.sourceIds)
|
|
401670
|
-
pushUnique(out, sourceId);
|
|
401671
|
-
}
|
|
401672
|
-
return out;
|
|
401673
|
-
}
|
|
401674
|
-
function visibleTrackedChangeSourceSlicesFromXml(xml) {
|
|
401675
|
-
const stripped = stripTextboxContent2(stripParagraphProperties3(xml));
|
|
401676
|
-
const slices = [];
|
|
401677
|
-
const activeSourceIdStack = [];
|
|
401678
|
-
const elementStack = [];
|
|
401679
|
-
let delDepth = 0;
|
|
401680
|
-
let cursor = 0;
|
|
401681
|
-
const tokenRe = /<\/(?:[\w.-]+:)?(ins|del|moveFrom|moveTo)>|<(?:[\w.-]+:)?t\b[^>]*>([\s\S]*?)<\/(?:[\w.-]+:)?t>|<(?:[\w.-]+:)?delText\b[^>]*>([\s\S]*?)<\/(?:[\w.-]+:)?delText>|<(?:[\w.-]+:)?(ins|del|moveFrom|moveTo|tab|br|cr)\b([^>]*)\/?>/g;
|
|
401682
|
-
for (const match of stripped.matchAll(tokenRe)) {
|
|
401683
|
-
const closingName = match[1];
|
|
401684
|
-
const tText = match[2];
|
|
401685
|
-
const delText = match[3];
|
|
401686
|
-
const openingName = match[4];
|
|
401687
|
-
const attrs = match[5] ?? "";
|
|
401688
|
-
if (closingName) {
|
|
401689
|
-
const frame = elementStack.pop();
|
|
401690
|
-
if (frame?.hadId)
|
|
401691
|
-
activeSourceIdStack.pop();
|
|
401692
|
-
if (closingName === "del")
|
|
401693
|
-
delDepth = Math.max(0, delDepth - 1);
|
|
401694
|
-
continue;
|
|
401695
|
-
}
|
|
401696
|
-
if (tText != null) {
|
|
401697
|
-
if (delDepth > 0) {
|
|
401698
|
-
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
401699
|
-
} else {
|
|
401700
|
-
cursor = pushTrackedSourceSlice(slices, cursor, decodeXmlText13(tText).length, activeSourceIdStack);
|
|
401701
|
-
}
|
|
401702
|
-
continue;
|
|
401703
|
-
}
|
|
401704
|
-
if (delText != null) {
|
|
401705
|
-
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
401706
|
-
continue;
|
|
401707
|
-
}
|
|
401708
|
-
if (!openingName)
|
|
401709
|
-
continue;
|
|
401710
|
-
if (openingName === "tab" || openingName === "br" || openingName === "cr") {
|
|
401711
|
-
if (delDepth > 0) {
|
|
401712
|
-
pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIdStack);
|
|
401713
|
-
} else {
|
|
401714
|
-
cursor = pushTrackedSourceSlice(slices, cursor, 1, activeSourceIdStack);
|
|
401715
|
-
}
|
|
401716
|
-
continue;
|
|
401717
|
-
}
|
|
401718
|
-
const sourceId = readXmlAttribute6(attrs, "id");
|
|
401719
|
-
const selfClosing = match[0].endsWith("/>");
|
|
401720
|
-
if (!selfClosing) {
|
|
401721
|
-
elementStack.push({ name: openingName, hadId: Boolean(sourceId) });
|
|
401722
|
-
if (sourceId)
|
|
401723
|
-
activeSourceIdStack.push(sourceId);
|
|
401724
|
-
if (openingName === "del")
|
|
401725
|
-
delDepth += 1;
|
|
401726
|
-
}
|
|
401727
|
-
}
|
|
401728
|
-
return slices;
|
|
401729
|
-
}
|
|
401730
|
-
function pushTrackedSourceSlice(slices, cursor, textLength, activeSourceIds) {
|
|
401731
|
-
if (textLength <= 0)
|
|
401732
|
-
return cursor;
|
|
401733
|
-
if (activeSourceIds.length > 0) {
|
|
401734
|
-
slices.push({ start: cursor, end: cursor + textLength, sourceIds: [...new Set(activeSourceIds)] });
|
|
401735
|
-
}
|
|
401736
|
-
return cursor + textLength;
|
|
401737
|
-
}
|
|
401738
|
-
function pushZeroWidthTrackedSourceSlice(slices, cursor, activeSourceIds) {
|
|
401739
|
-
if (activeSourceIds.length === 0)
|
|
401740
|
-
return;
|
|
401741
|
-
slices.push({ start: cursor, end: cursor, sourceIds: [...new Set(activeSourceIds)] });
|
|
401742
|
-
}
|
|
401743
|
-
function readXmlAttribute6(attrs, localName2) {
|
|
401744
|
-
const match = attrs.match(new RegExp(`(?:^|\\s)(?:[\\w.-]+:)?${localName2}=(["'])(.*?)\\1`, "i"));
|
|
401745
|
-
return match?.[2] ?? null;
|
|
401746
|
-
}
|
|
401747
|
-
function rangesOverlap12(aStart, aEnd, bStart, bEnd) {
|
|
401748
|
-
const leftStart = Math.min(aStart, aEnd);
|
|
401749
|
-
const leftEnd = Math.max(aStart, aEnd);
|
|
401750
|
-
const rightStart = Math.min(bStart, bEnd);
|
|
401751
|
-
const rightEnd = Math.max(bStart, bEnd);
|
|
401752
|
-
if (rightStart === rightEnd)
|
|
401753
|
-
return rightStart >= leftStart && rightStart <= leftEnd;
|
|
401754
|
-
if (leftStart === leftEnd)
|
|
401755
|
-
return leftStart >= rightStart && leftStart <= rightEnd;
|
|
401756
|
-
return Math.max(leftStart, rightStart) < Math.min(leftEnd, rightEnd);
|
|
401757
|
-
}
|
|
401758
|
-
function intersectStringSets(left, right) {
|
|
401759
|
-
const out = new Set;
|
|
401760
|
-
for (const value2 of left) {
|
|
401761
|
-
if (right.has(value2))
|
|
401762
|
-
out.add(value2);
|
|
401763
|
-
}
|
|
401764
|
-
return out;
|
|
401765
|
-
}
|
|
401766
|
-
function stripParagraphProperties3(xml) {
|
|
401767
|
-
return stripElements(xml, "pPr");
|
|
401768
|
-
}
|
|
401769
|
-
function stripDeletedRevisions(xml) {
|
|
401770
|
-
return xml.replace(/<[\w.-]+:del\b(?![^>]*\/>)[^>]*>[\s\S]*?<\/[\w.-]+:del>/g, "");
|
|
401771
|
-
}
|
|
401772
|
-
function stripTextboxContent2(xml) {
|
|
401773
|
-
return xml.replace(/<(?:[\w.-]+:)?txbxContent\b[^>]*>[\s\S]*?<\/(?:[\w.-]+:)?txbxContent>/g, "").replace(/<(?:[\w.-]+:)?txbxContent\b[^>]*>[\s\S]*$/g, "");
|
|
401774
|
-
}
|
|
401775
|
-
function decodeXmlText13(escaped) {
|
|
401776
|
-
return escaped.replace(/&(lt|gt|amp|quot|apos|#\d+|#x[0-9a-fA-F]+);/g, (_, entity) => {
|
|
401777
|
-
switch (entity) {
|
|
401778
|
-
case "lt":
|
|
401779
|
-
return "<";
|
|
401780
|
-
case "gt":
|
|
401781
|
-
return ">";
|
|
401782
|
-
case "amp":
|
|
401783
|
-
return "&";
|
|
401784
|
-
case "quot":
|
|
401785
|
-
return '"';
|
|
401786
|
-
case "apos":
|
|
401787
|
-
return "'";
|
|
401788
|
-
default: {
|
|
401789
|
-
const cp = entity.startsWith("#x") ? Number.parseInt(entity.slice(2), 16) : Number.parseInt(entity.slice(1), 10);
|
|
401790
|
-
return Number.isFinite(cp) ? String.fromCodePoint(cp) : `&${entity};`;
|
|
401791
|
-
}
|
|
401792
|
-
}
|
|
401793
|
-
});
|
|
401794
|
-
}
|
|
401795
|
-
function pushUnique(out, id) {
|
|
401796
|
-
if (typeof id === "string" && id.length > 0 && !out.includes(id))
|
|
401797
|
-
out.push(id);
|
|
401798
|
-
}
|
|
401799
|
-
var TEXT_DECODER7, ACTIVE_MARK_ORDER;
|
|
401800
|
-
var init_live_selection = __esm(() => {
|
|
401801
|
-
init_sd_document_session_internal();
|
|
401802
|
-
init_sd_document_session_internal();
|
|
401803
|
-
init_footnote_range();
|
|
401804
|
-
TEXT_DECODER7 = new TextDecoder;
|
|
401805
|
-
ACTIVE_MARK_ORDER = ["bold", "italic", "underline", "strikethrough"];
|
|
401806
|
-
});
|
|
401807
|
-
|
|
401808
401949
|
// ../../../v2/document-api-v2-adapter/dist/selection/story-text-extent.js
|
|
401809
401950
|
async function resolveBrowserStoryTextExtentForSession(session, input, options) {
|
|
401810
401951
|
try {
|