@superdoc/mcp 1.16.0-next.14 → 1.16.0-next.22
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 +620 -331
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31332,7 +31332,7 @@ var init_host = __esm(() => {
|
|
|
31332
31332
|
});
|
|
31333
31333
|
|
|
31334
31334
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31335
|
-
var SDK_VERSION = "2.29.0-next.
|
|
31335
|
+
var SDK_VERSION = "2.29.0-next.22";
|
|
31336
31336
|
|
|
31337
31337
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31338
31338
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -152773,7 +152773,7 @@ function buildTrackedCarrierRefinementLogicalEntryWithLookupContext(lookupContex
|
|
|
152773
152773
|
const nextParagraphXml = input.nextParagraphXml ?? "";
|
|
152774
152774
|
if (hasCrossParagraphReviewBridge(previousParagraphXml) || hasCrossParagraphReviewBridge(nextParagraphXml))
|
|
152775
152775
|
return null;
|
|
152776
|
-
const advanced = input.priorEntry ? advanceTrackedCarrierRefinementEntry(input.priorEntry, before, after, proof) : null;
|
|
152776
|
+
const advanced = input.priorEntry ? advanceTrackedCarrierRefinementEntry(input.priorEntry, before, after, proof, input.namespaceBindings) : null;
|
|
152777
152777
|
if (advanced) {
|
|
152778
152778
|
return rebaseTrackedCarrierRefinementEntry(advanced, input.paragraphByteStart, input.paragraphStoryTextStart);
|
|
152779
152779
|
}
|
|
@@ -152809,7 +152809,7 @@ function rebaseTrackedCarrierRefinementEntry(entry, paragraphByteStart, paragrap
|
|
|
152809
152809
|
fragments: rebasedFragments
|
|
152810
152810
|
};
|
|
152811
152811
|
}
|
|
152812
|
-
function advanceTrackedCarrierRefinementEntry(prior, before, after, proof) {
|
|
152812
|
+
function advanceTrackedCarrierRefinementEntry(prior, before, after, proof, namespaceBindings) {
|
|
152813
152813
|
if (!["insertion", "deletion", "replacement"].includes(prior.type) || prior.reviewGroup != null || prior.overlap != null || prior.subsumption != null || prior.movePair != null || prior.formattingFragments.length !== 0 || prior.structuralFragments.length !== 0 || !prior.contributingRsids.includes(proof.rsid))
|
|
152814
152814
|
return null;
|
|
152815
152815
|
const expectedRsids = new Set(prior.contributingRsids);
|
|
@@ -152831,8 +152831,21 @@ function advanceTrackedCarrierRefinementEntry(prior, before, after, proof) {
|
|
|
152831
152831
|
const fragments = prior.contributingRsids.flatMap((rsid) => after.byRsid.get(rsid) ?? []).sort((left, right) => left.byteStart - right.byteStart || left.byteEnd - right.byteEnd);
|
|
152832
152832
|
if (fragments.length === 0)
|
|
152833
152833
|
return null;
|
|
152834
|
+
const textFor = (kind) => fragments.filter((fragment2) => fragment2.kind === kind).map((fragment2) => extractScopedReviewText(after, prior.partUri, proof.after.paragraphXml, fragment2.byteStart, fragment2.byteEnd, kind, () => collectXmlElementRanges(proof.after.paragraphXml, {
|
|
152835
|
+
fragment: true,
|
|
152836
|
+
additionalNamespaces: xmlFragmentAdditionalNamespaces(proof.after.paragraphXml, new Map(Object.entries(namespaceBindings ?? {})), { w: NS_W })
|
|
152837
|
+
}).ranges)).join("");
|
|
152838
|
+
const beforeText = textFor("del");
|
|
152839
|
+
const afterText = textFor("ins");
|
|
152834
152840
|
return {
|
|
152835
152841
|
...prior,
|
|
152842
|
+
before: { text: beforeText },
|
|
152843
|
+
after: { text: afterText },
|
|
152844
|
+
excerpt: afterText || beforeText,
|
|
152845
|
+
sides: prior.sides ? {
|
|
152846
|
+
inserted: prior.sides.inserted ? { ...prior.sides.inserted, excerpt: afterText } : null,
|
|
152847
|
+
deleted: prior.sides.deleted ? { ...prior.sides.deleted, excerpt: beforeText } : null
|
|
152848
|
+
} : null,
|
|
152836
152849
|
documentOrderStart: Math.min(...fragments.map((fragment2) => fragment2.byteStart)),
|
|
152837
152850
|
documentOrderEnd: Math.max(...fragments.map((fragment2) => fragment2.byteEnd)),
|
|
152838
152851
|
fragments
|
|
@@ -210514,6 +210527,20 @@ var init_paste_run_validation = __esm(() => {
|
|
|
210514
210527
|
]);
|
|
210515
210528
|
});
|
|
210516
210529
|
|
|
210530
|
+
// ../../../v2/editor-core/dist/document/transactions/types.js
|
|
210531
|
+
function isPasteTabAlignment(value) {
|
|
210532
|
+
return PASTE_TAB_ALIGNMENTS.some((alignment) => alignment === value);
|
|
210533
|
+
}
|
|
210534
|
+
function isPasteTabLeader(value) {
|
|
210535
|
+
return PASTE_TAB_LEADERS.some((leader) => leader === value);
|
|
210536
|
+
}
|
|
210537
|
+
var SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS, PASTE_TAB_ALIGNMENTS, PASTE_TAB_LEADERS;
|
|
210538
|
+
var init_types6 = __esm(() => {
|
|
210539
|
+
SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS = new Set(["v2.1", "v2.2"]);
|
|
210540
|
+
PASTE_TAB_ALIGNMENTS = ["left", "center", "right", "decimal", "bar", "clear", "num"];
|
|
210541
|
+
PASTE_TAB_LEADERS = ["none", "dot", "hyphen", "underscore", "middleDot", "heavy"];
|
|
210542
|
+
});
|
|
210543
|
+
|
|
210517
210544
|
// ../../../v2/editor-core/dist/document/transactions/paragraph-contribution.js
|
|
210518
210545
|
function renderParagraphProperties(styleId, numberingProperties, paragraphProperties) {
|
|
210519
210546
|
const parts = [];
|
|
@@ -210523,6 +210550,9 @@ function renderParagraphProperties(styleId, numberingProperties, paragraphProper
|
|
|
210523
210550
|
if (numberingProperties) {
|
|
210524
210551
|
parts.push(`<w:numPr><w:ilvl w:val="${escapeXmlAttribute(numberingProperties.ilvl)}"/>` + `<w:numId w:val="${escapeXmlAttribute(numberingProperties.numId)}"/></w:numPr>`);
|
|
210525
210552
|
}
|
|
210553
|
+
const tabs = renderPasteParagraphTabs(paragraphProperties?.tabs);
|
|
210554
|
+
if (tabs)
|
|
210555
|
+
parts.push(tabs);
|
|
210526
210556
|
const spacing = renderPasteParagraphSpacing(paragraphProperties?.spacing);
|
|
210527
210557
|
if (spacing)
|
|
210528
210558
|
parts.push(spacing);
|
|
@@ -210592,6 +210622,12 @@ function renderTrackedPasteParagraphBlock(spec, stamp) {
|
|
|
210592
210622
|
const nsDecl = spec.bindW14NamespaceInline ? ` xmlns:w14="${W14_NAMESPACE}"` : "";
|
|
210593
210623
|
return `<w:p${nsDecl} w14:paraId="${escapeXmlAttribute(spec.paraId)}" ` + `w:rsidR="${escapeXmlAttribute(stamp.rsid)}">` + `${pPr}${renderTrackedPasteRuns(spec.runs, stamp)}</w:p>`;
|
|
210594
210624
|
}
|
|
210625
|
+
function renderPasteParagraphTabs(tabs, prefix2 = "w") {
|
|
210626
|
+
if (!tabs?.length)
|
|
210627
|
+
return "";
|
|
210628
|
+
const stops = tabs.map((tab) => `<${prefix2}:tab ${prefix2}:val="${tab.alignment}" ${prefix2}:pos="${pointsToTwips(tab.position)}"${tab.leader ? ` ${prefix2}:leader="${tab.leader}"` : ""}/>`);
|
|
210629
|
+
return `<${prefix2}:tabs>${stops.join("")}</${prefix2}:tabs>`;
|
|
210630
|
+
}
|
|
210595
210631
|
function renderPasteParagraphSpacing(spacing) {
|
|
210596
210632
|
if (!spacing)
|
|
210597
210633
|
return "";
|
|
@@ -210627,17 +210663,28 @@ function pointsToTwips(points) {
|
|
|
210627
210663
|
function isValidPasteParagraphProperties(value) {
|
|
210628
210664
|
if (value === undefined)
|
|
210629
210665
|
return true;
|
|
210630
|
-
if (!isRecord5(value) || !hasOnlyKeys(value, ["alignment", "indent", "spacing", "markRunProps"]))
|
|
210666
|
+
if (!isRecord5(value) || !hasOnlyKeys(value, ["alignment", "indent", "spacing", "markRunProps", "tabs"]))
|
|
210631
210667
|
return false;
|
|
210632
210668
|
if (value.alignment !== undefined && value.alignment !== "left" && value.alignment !== "center" && value.alignment !== "right" && value.alignment !== "justify") {
|
|
210633
210669
|
return false;
|
|
210634
210670
|
}
|
|
210635
210671
|
if (!isValidPasteRunMarks(value.markRunProps))
|
|
210636
210672
|
return false;
|
|
210673
|
+
if (!isValidPasteTabStops(value.tabs))
|
|
210674
|
+
return false;
|
|
210637
210675
|
if (!isValidPasteParagraphIndent(value.indent))
|
|
210638
210676
|
return false;
|
|
210639
210677
|
return isValidPasteParagraphSpacing(value.spacing);
|
|
210640
210678
|
}
|
|
210679
|
+
function isValidPasteTabStops(value) {
|
|
210680
|
+
if (value === undefined)
|
|
210681
|
+
return true;
|
|
210682
|
+
return Array.isArray(value) && value.every((tab) => {
|
|
210683
|
+
if (!isRecord5(tab) || !hasOnlyKeys(tab, ["position", "alignment", "leader"]))
|
|
210684
|
+
return false;
|
|
210685
|
+
return isSafeTwipPointNumber(tab.position) && isPasteTabAlignment(tab.alignment) && (tab.leader === undefined || isPasteTabLeader(tab.leader));
|
|
210686
|
+
});
|
|
210687
|
+
}
|
|
210641
210688
|
function isValidPasteParagraphIndent(value) {
|
|
210642
210689
|
if (value === undefined)
|
|
210643
210690
|
return true;
|
|
@@ -211192,6 +211239,7 @@ var init_paragraph_contribution = __esm(() => {
|
|
|
211192
211239
|
init_paragraph_para_id_attrs();
|
|
211193
211240
|
init_highlight_ooxml();
|
|
211194
211241
|
init_paste_run_validation();
|
|
211242
|
+
init_types6();
|
|
211195
211243
|
PASTE_TABLE_GRID_TWIPS = PASTE_TABLE_DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
211196
211244
|
});
|
|
211197
211245
|
|
|
@@ -232905,23 +232953,7 @@ function splitInsertionAroundDirectReplacement(input, allTokens, parent) {
|
|
|
232905
232953
|
});
|
|
232906
232954
|
const hasHead = localStart > 0;
|
|
232907
232955
|
const hasTail = localEnd < text.length;
|
|
232908
|
-
|
|
232909
|
-
let tailXml = renderSide(localEnd, text.length, parent.wId, parent.rsidR);
|
|
232910
|
-
if (hasHead && hasTail) {
|
|
232911
|
-
const tailWId = String(input.reserveWId ? input.reserveWId() : resolveNextWId(input));
|
|
232912
|
-
tailXml = renderSide(localEnd, text.length, tailWId, "");
|
|
232913
|
-
splitPart = {
|
|
232914
|
-
rsid: synthesizeTrackedChangeRsidFromRawMetadata({
|
|
232915
|
-
storyId: input.storyId,
|
|
232916
|
-
kind: "ins",
|
|
232917
|
-
author: parent.sourceIdentity.author,
|
|
232918
|
-
date: parent.sourceIdentity.date,
|
|
232919
|
-
wId: tailWId,
|
|
232920
|
-
occurrence: 0
|
|
232921
|
-
}),
|
|
232922
|
-
wId: tailWId
|
|
232923
|
-
};
|
|
232924
|
-
}
|
|
232956
|
+
const tailXml = renderSide(localEnd, text.length, parent.wId, parent.rsidR);
|
|
232925
232957
|
const plain = renderDirectReplacementFromInsertion(input, parent, localStart);
|
|
232926
232958
|
if (plain == null)
|
|
232927
232959
|
return { ok: false, reason: "text-range-in-unsupported-tracked-wrapper" };
|
|
@@ -232942,7 +232974,6 @@ function splitInsertionAroundDirectReplacement(input, allTokens, parent) {
|
|
|
232942
232974
|
return result;
|
|
232943
232975
|
return {
|
|
232944
232976
|
...result,
|
|
232945
|
-
...splitPart ? { splitRevisionParts: [splitPart], splitRevisionMappings: [{ sourceWId: parent.wId, successorWId: splitPart.wId }] } : {},
|
|
232946
232977
|
requiresCollaborationSessionSync: true
|
|
232947
232978
|
};
|
|
232948
232979
|
}
|
|
@@ -236694,6 +236725,38 @@ function commitPreparedResidentText(input, view, paragraph, edit) {
|
|
|
236694
236725
|
if (!leaf || leaf.kind !== "text")
|
|
236695
236726
|
return null;
|
|
236696
236727
|
const range2 = { byteStart: paragraph.byteStart, byteEnd: paragraph.byteEnd };
|
|
236728
|
+
const orphan = planOrphanedInsertionWhitespaceRemoval(input, paragraph.byteStart, edit.before.model, edit.after.model);
|
|
236729
|
+
if (orphan) {
|
|
236730
|
+
return finalizeCommit({
|
|
236731
|
+
input,
|
|
236732
|
+
reconcileTrackedChangeRefs: true,
|
|
236733
|
+
perPart: { [op.on.partUri]: { kind: "modify", patches: [{
|
|
236734
|
+
kind: "replaceBytes",
|
|
236735
|
+
order: 0,
|
|
236736
|
+
startByte: range2.byteStart,
|
|
236737
|
+
endByte: range2.byteEnd,
|
|
236738
|
+
bytes: orphan.bytes
|
|
236739
|
+
}] } },
|
|
236740
|
+
preconditions: [localizedByteWindowPrecondition(op.on.partUri, view.bytes, localRange, view.byteBase)],
|
|
236741
|
+
patchMaps: { [op.on.partUri]: { partUri: op.on.partUri, ranges: [] } },
|
|
236742
|
+
textRangeShifts: orphan.ranges.map((piece) => ({
|
|
236743
|
+
storyId: op.on.storyId,
|
|
236744
|
+
...storyCharOffset(state, op.on.storyId, op.on.startBlockId, piece.visibleStart),
|
|
236745
|
+
delta: piece.visibleStart - piece.visibleEnd
|
|
236746
|
+
})),
|
|
236747
|
+
trackedTextRangeShifts: orphan.ranges.map((piece) => ({
|
|
236748
|
+
storyId: op.on.storyId,
|
|
236749
|
+
blockId: op.on.startBlockId,
|
|
236750
|
+
atCharInBlock: piece.trackedStart,
|
|
236751
|
+
delta: piece.trackedStart - piece.trackedEnd
|
|
236752
|
+
})),
|
|
236753
|
+
notes: { direct: true },
|
|
236754
|
+
resyncFromSession: true,
|
|
236755
|
+
requiresCollaborationSessionSync: true,
|
|
236756
|
+
pushHistory: input.pushHistory,
|
|
236757
|
+
paragraphWindow: range2
|
|
236758
|
+
});
|
|
236759
|
+
}
|
|
236697
236760
|
const collapsed = op.on.startOffset === op.on.endOffset;
|
|
236698
236761
|
const leadingBookmarkBoundary = collapsed && op.newText.length > 0 && edit.visibleStart === 0 && edit.before.model.leaves().some((piece) => piece.kind === "marker" && piece.visibleStart === 0 && (piece.markerKind === "bookmarkStart" || piece.markerKind === "bookmarkEnd"));
|
|
236699
236762
|
const visibleEnd = edit.visibleStart + op.on.endOffset - op.on.startOffset;
|
|
@@ -236773,6 +236836,84 @@ function commitPreparedResidentText(input, view, paragraph, edit) {
|
|
|
236773
236836
|
paragraphWindow: range2
|
|
236774
236837
|
});
|
|
236775
236838
|
}
|
|
236839
|
+
function planOrphanedInsertionWhitespaceRemoval(input, paragraphByteStart, beforeModel, afterModel) {
|
|
236840
|
+
const { state, op } = input;
|
|
236841
|
+
if (op.changeMode !== "direct" || op.newText !== "" || op.preserveInsertionWhitespace || op.on.startOffset >= op.on.endOffset || state.sourceCompletePosture !== "source-complete")
|
|
236842
|
+
return null;
|
|
236843
|
+
const candidates = beforeModel.pieces.filter((piece) => {
|
|
236844
|
+
if (piece.kind !== "tracked" || piece.trackedKind !== "ins" || !piece.revisionId)
|
|
236845
|
+
return false;
|
|
236846
|
+
const start = op.on.coordinateSpace === "tracked" ? piece.trackedStart : piece.visibleStart;
|
|
236847
|
+
const end = op.on.coordinateSpace === "tracked" ? piece.trackedEnd : piece.visibleEnd;
|
|
236848
|
+
return start < op.on.endOffset && end > op.on.startOffset;
|
|
236849
|
+
});
|
|
236850
|
+
if (candidates.length !== 1)
|
|
236851
|
+
return null;
|
|
236852
|
+
const before = candidates[0];
|
|
236853
|
+
if (!before)
|
|
236854
|
+
return null;
|
|
236855
|
+
const mode2 = input.options.trackedChangesReplacementMode ?? "paired";
|
|
236856
|
+
const catalog = readCurrentTrackedChangeLogicalCatalog(state, mode2) ?? accessTrackedChangeLogicalCatalog(state, mode2);
|
|
236857
|
+
const owners = [...catalog.logical.byId.values()].filter((item2) => item2.storyId === op.on.storyId && item2.fragments.some((fragment5) => fragment5.partUri === op.on.partUri && fragment5.sourceByteStart === paragraphByteStart + before.byteStart && fragment5.sourceByteEnd === paragraphByteStart + before.byteEnd));
|
|
236858
|
+
if (owners.length !== 1)
|
|
236859
|
+
return null;
|
|
236860
|
+
const owner = owners[0];
|
|
236861
|
+
if (!owner || owner.type !== "insertion" || owner.formattingFragments.length || owner.structuralFragments.length || owner.reviewGroup || owner.subsumption || owner.movePair)
|
|
236862
|
+
return null;
|
|
236863
|
+
const fragment4 = owner.fragments[0];
|
|
236864
|
+
if (!fragment4?.rsid || !fragment4.wId || owner.fragments.some((item2) => item2.rsid !== fragment4.rsid || item2.wId !== fragment4.wId))
|
|
236865
|
+
return null;
|
|
236866
|
+
const sameRevision = (piece) => piece.kind === "tracked" && piece.trackedKind === "ins" && piece.revisionId === before.revisionId && piece.author === before.author && piece.date === before.date && piece.rsid === before.rsid;
|
|
236867
|
+
const beforePieces = beforeModel.pieces.filter(sameRevision);
|
|
236868
|
+
if (beforePieces.length !== owner.fragments.length || owner.fragments.some((item2) => item2.partUri !== op.on.partUri || !beforePieces.some((piece) => item2.sourceByteStart === paragraphByteStart + piece.byteStart && item2.sourceByteEnd === paragraphByteStart + piece.byteEnd)))
|
|
236869
|
+
return null;
|
|
236870
|
+
const afterPieces = afterModel.pieces.filter(sameRevision);
|
|
236871
|
+
if (beforePieces.some((carrier) => carrier.children.some((piece) => piece.kind !== "text" || piece.textRole !== "visible" || piece.runFormattingRevisionIds?.length)) || afterPieces.some((carrier) => carrier.children.some((piece) => piece.kind !== "text" || piece.textRole !== "visible")))
|
|
236872
|
+
return null;
|
|
236873
|
+
const text = (carrier) => carrier.children.flatMap((piece) => piece.kind === "text" ? [piece.decodedText] : []).join("");
|
|
236874
|
+
const original = beforePieces.map(text).join("");
|
|
236875
|
+
const remaining = beforePieces.map((piece) => {
|
|
236876
|
+
const start = op.on.coordinateSpace === "tracked" ? piece.trackedStart : piece.visibleStart;
|
|
236877
|
+
const value = text(piece);
|
|
236878
|
+
return value.slice(0, Math.max(0, Math.min(value.length, op.on.startOffset - start))) + value.slice(Math.max(0, Math.min(value.length, op.on.endOffset - start)));
|
|
236879
|
+
}).join("");
|
|
236880
|
+
if (!/\S/u.test(original) || !/^ +$/u.test(remaining) || afterPieces.map(text).join("") !== remaining)
|
|
236881
|
+
return null;
|
|
236882
|
+
const trackedOffset = (offset) => {
|
|
236883
|
+
if (op.on.coordinateSpace === "tracked")
|
|
236884
|
+
return offset;
|
|
236885
|
+
if (offset === beforeModel.visibleLength)
|
|
236886
|
+
return beforeModel.trackedLength;
|
|
236887
|
+
const leaf = beforeModel.leaves().find((piece) => piece.visibleStart <= offset && piece.visibleEnd > offset && piece.visibleEnd - piece.visibleStart === piece.trackedEnd - piece.trackedStart);
|
|
236888
|
+
return leaf ? leaf.trackedStart + offset - leaf.visibleStart : null;
|
|
236889
|
+
};
|
|
236890
|
+
const trackedStart = trackedOffset(op.on.startOffset);
|
|
236891
|
+
const trackedEnd = trackedOffset(op.on.endOffset);
|
|
236892
|
+
if (trackedStart === null || trackedEnd === null)
|
|
236893
|
+
return null;
|
|
236894
|
+
const visibleStart = projectTrackedParagraphOffsetToVisible(beforeModel.paragraphXml, trackedStart, beforeModel);
|
|
236895
|
+
const visibleEnd = projectTrackedParagraphOffsetToVisible(beforeModel.paragraphXml, trackedEnd, beforeModel);
|
|
236896
|
+
if (visibleStart === null || visibleEnd === null)
|
|
236897
|
+
return null;
|
|
236898
|
+
const ranges = [];
|
|
236899
|
+
for (const piece of [...beforePieces, { visibleStart, visibleEnd, trackedStart, trackedEnd }].sort((a, b) => a.trackedStart - b.trackedStart)) {
|
|
236900
|
+
const last = ranges.at(-1);
|
|
236901
|
+
if (last && last.visibleEnd >= piece.visibleStart && last.trackedEnd >= piece.trackedStart) {
|
|
236902
|
+
last.visibleEnd = Math.max(last.visibleEnd, piece.visibleEnd);
|
|
236903
|
+
last.trackedEnd = Math.max(last.trackedEnd, piece.trackedEnd);
|
|
236904
|
+
} else
|
|
236905
|
+
ranges.push({ visibleStart: piece.visibleStart, visibleEnd: piece.visibleEnd, trackedStart: piece.trackedStart, trackedEnd: piece.trackedEnd });
|
|
236906
|
+
}
|
|
236907
|
+
let afterXml = afterModel.paragraphXml;
|
|
236908
|
+
for (const piece of [...afterPieces].reverse())
|
|
236909
|
+
afterXml = afterXml.slice(0, piece.charStart) + afterXml.slice(piece.charEnd);
|
|
236910
|
+
return {
|
|
236911
|
+
bytes: TE24.encode(afterXml),
|
|
236912
|
+
ranges: ranges.reverse(),
|
|
236913
|
+
rsid: fragment4.rsid,
|
|
236914
|
+
wId: fragment4.wId
|
|
236915
|
+
};
|
|
236916
|
+
}
|
|
236776
236917
|
function runDirectEditTextBatchCommit(input, edits) {
|
|
236777
236918
|
const { state, txId, op } = input;
|
|
236778
236919
|
if (op.changeMode !== "direct")
|
|
@@ -236820,7 +236961,6 @@ function runDirectEditTextBatchCommit(input, edits) {
|
|
|
236820
236961
|
const overlapUpdatedRsids = [];
|
|
236821
236962
|
const overlapRetiredRevisions = [];
|
|
236822
236963
|
const overlapResolvedInsertions = [];
|
|
236823
|
-
const overlapSplitRsids = [];
|
|
236824
236964
|
const overlapSplitRemappings = [];
|
|
236825
236965
|
const overlapCascadeCommentWIds = [];
|
|
236826
236966
|
const consumedCommentWIds = [];
|
|
@@ -236904,7 +237044,6 @@ function runDirectEditTextBatchCommit(input, edits) {
|
|
|
236904
237044
|
overlapUpdatedRsids.push(...overlap.updatedRsids);
|
|
236905
237045
|
overlapRetiredRevisions.push(...overlap.retiredRevisions);
|
|
236906
237046
|
overlapResolvedInsertions.push(...overlap.resolvedInsertionRevisions);
|
|
236907
|
-
overlapSplitRsids.push(...overlap.splitRevisionRsids);
|
|
236908
237047
|
overlapCascadeCommentWIds.push(...overlap.cascadeCommentWIds);
|
|
236909
237048
|
requiresCollaborationSessionSync || (requiresCollaborationSessionSync = overlap.requiresCollaborationSessionSync === true);
|
|
236910
237049
|
if (overlap.emittedRsids.length === 0)
|
|
@@ -237067,7 +237206,7 @@ function runDirectEditTextBatchCommit(input, edits) {
|
|
|
237067
237206
|
reservations: { conflictRule: "first-choice-strict" },
|
|
237068
237207
|
localApplyBundle: forwardPatchGroup,
|
|
237069
237208
|
semanticDelta: {
|
|
237070
|
-
createdRefs:
|
|
237209
|
+
createdRefs: overlapEmittedRsids.map((entityId) => ({
|
|
237071
237210
|
kind: "trackedChange",
|
|
237072
237211
|
entityId,
|
|
237073
237212
|
storyId
|
|
@@ -238361,7 +238500,6 @@ function commitDirect(input, view) {
|
|
|
238361
238500
|
let trackedCarrierRefinement;
|
|
238362
238501
|
let overlapRetiredRevisions = [];
|
|
238363
238502
|
let overlapResolvedInsertions = [];
|
|
238364
|
-
let overlapSplitRsids = [];
|
|
238365
238503
|
let overlapSplitMappings = [];
|
|
238366
238504
|
let overlapCascadeCommentWIds = [];
|
|
238367
238505
|
const directAuthor = input.authorOverride ?? input.author;
|
|
@@ -238374,7 +238512,6 @@ function commitDirect(input, view) {
|
|
|
238374
238512
|
trackedCarrierRefinement = overlap.trackedCarrierRefinement;
|
|
238375
238513
|
overlapRetiredRevisions = overlap.retiredRevisions;
|
|
238376
238514
|
overlapResolvedInsertions = overlap.resolvedInsertionRevisions;
|
|
238377
|
-
overlapSplitRsids = overlap.splitRevisionRsids;
|
|
238378
238515
|
overlapSplitMappings = overlap.splitRevisionMappings;
|
|
238379
238516
|
overlapCascadeCommentWIds = overlap.cascadeCommentWIds;
|
|
238380
238517
|
return {
|
|
@@ -238402,7 +238539,6 @@ function commitDirect(input, view) {
|
|
|
238402
238539
|
trackedCarrierRefinement = overlap.trackedCarrierRefinement;
|
|
238403
238540
|
overlapRetiredRevisions = overlap.retiredRevisions;
|
|
238404
238541
|
overlapResolvedInsertions = overlap.resolvedInsertionRevisions;
|
|
238405
|
-
overlapSplitRsids = overlap.splitRevisionRsids;
|
|
238406
238542
|
overlapSplitMappings = overlap.splitRevisionMappings;
|
|
238407
238543
|
overlapCascadeCommentWIds = overlap.cascadeCommentWIds;
|
|
238408
238544
|
} else {
|
|
@@ -238432,13 +238568,18 @@ function commitDirect(input, view) {
|
|
|
238432
238568
|
trackedCarrierRefinement = overlap.trackedCarrierRefinement;
|
|
238433
238569
|
overlapRetiredRevisions = overlap.retiredRevisions;
|
|
238434
238570
|
overlapResolvedInsertions = overlap.resolvedInsertionRevisions;
|
|
238435
|
-
overlapSplitRsids = overlap.splitRevisionRsids;
|
|
238436
238571
|
overlapSplitMappings = overlap.splitRevisionMappings;
|
|
238437
238572
|
overlapCascadeCommentWIds = overlap.cascadeCommentWIds;
|
|
238438
238573
|
}
|
|
238439
238574
|
}
|
|
238440
238575
|
if (!localized.ok)
|
|
238441
238576
|
return rejected3(txId, localized.reason);
|
|
238577
|
+
const orphan = op.newText === "" && compileOp.on.startOffset < compileOp.on.endOffset ? planOrphanedInsertionWhitespaceRemoval(compileInput, byteBase + window2.byteStart, inlineModel, parseParagraphInlineMap(TD52.decode(localized.bytes), localizedNamespaceBindings)) : null;
|
|
238578
|
+
if (orphan) {
|
|
238579
|
+
localized = { ...localized, bytes: orphan.bytes, requiresCollaborationSessionSync: true };
|
|
238580
|
+
overlapUpdatedRsids = overlapUpdatedRsids.filter((rsid) => rsid !== orphan.rsid);
|
|
238581
|
+
overlapResolvedInsertions.push({ rsid: orphan.rsid, wId: orphan.wId });
|
|
238582
|
+
}
|
|
238442
238583
|
if (op.newText.includes("\t"))
|
|
238443
238584
|
localized = { ...localized, requiresCollaborationSessionSync: true };
|
|
238444
238585
|
let directTextInsert;
|
|
@@ -238520,7 +238661,11 @@ function commitDirect(input, view) {
|
|
|
238520
238661
|
const removedChars = visibleStartOffset !== null && visibleEndOffset !== null ? visibleEndOffset - visibleStartOffset : op.on.endOffset - op.on.startOffset;
|
|
238521
238662
|
const suppressShifts = overlapEmittedRsids !== null && overlapEmittedRsids.length > 0 || visibleStartOffset === null || visibleEndOffset === null;
|
|
238522
238663
|
const delta = addedChars - removedChars;
|
|
238523
|
-
const shifts =
|
|
238664
|
+
const shifts = orphan ? orphan.ranges.map((piece) => ({
|
|
238665
|
+
storyId: op.on.storyId,
|
|
238666
|
+
...storyCharOffset(state, op.on.storyId, op.on.startBlockId, piece.visibleStart),
|
|
238667
|
+
delta: piece.visibleStart - piece.visibleEnd
|
|
238668
|
+
})) : suppressShifts || delta === 0 && removedChars === 0 ? [] : [{
|
|
238524
238669
|
storyId: op.on.storyId,
|
|
238525
238670
|
...storyCharOffset(state, op.on.storyId, op.on.startBlockId, visibleStartOffset),
|
|
238526
238671
|
delta,
|
|
@@ -238566,8 +238711,14 @@ function commitDirect(input, view) {
|
|
|
238566
238711
|
preconditions,
|
|
238567
238712
|
patchMaps,
|
|
238568
238713
|
textRangeShifts: shifts,
|
|
238714
|
+
...orphan ? { trackedTextRangeShifts: orphan.ranges.map((piece) => ({
|
|
238715
|
+
storyId: op.on.storyId,
|
|
238716
|
+
blockId: op.on.startBlockId,
|
|
238717
|
+
atCharInBlock: piece.trackedStart,
|
|
238718
|
+
delta: piece.trackedStart - piece.trackedEnd
|
|
238719
|
+
})) } : {},
|
|
238569
238720
|
notes: {
|
|
238570
|
-
...overlapEmittedRsids !== null && overlapEmittedRsids.length > 0 ? { direct: false, emittedRsids: overlapEmittedRsids, updatedRsids: overlapUpdatedRsids } : { direct: true, updatedRsids: overlapUpdatedRsids
|
|
238721
|
+
...overlapEmittedRsids !== null && overlapEmittedRsids.length > 0 ? { direct: false, emittedRsids: overlapEmittedRsids, updatedRsids: overlapUpdatedRsids } : { direct: true, updatedRsids: overlapUpdatedRsids },
|
|
238571
238722
|
...overlapSplitMappings.length > 0 ? {
|
|
238572
238723
|
splitMappings: overlapSplitMappings,
|
|
238573
238724
|
splitBeforeXml: paragraphXml,
|
|
@@ -238594,7 +238745,7 @@ function commitDirect(input, view) {
|
|
|
238594
238745
|
acceptedTextInsertionSplit,
|
|
238595
238746
|
trackedCarrierRefinement,
|
|
238596
238747
|
directTextInsert,
|
|
238597
|
-
resyncFromSession: usedSpanningDelete || Boolean(noteSidecar) || op.on.coordinateSpace === "tracked" && (visibleStartOffset !== op.on.startOffset || visibleEndOffset !== op.on.endOffset),
|
|
238748
|
+
resyncFromSession: usedSpanningDelete || Boolean(noteSidecar) || Boolean(orphan) || op.on.coordinateSpace === "tracked" && (visibleStartOffset !== op.on.startOffset || visibleEndOffset !== op.on.endOffset),
|
|
238598
238749
|
requiresCollaborationSessionSync: localized.requiresCollaborationSessionSync || Boolean(noteSidecar),
|
|
238599
238750
|
pushHistory,
|
|
238600
238751
|
paragraphWindow: counterpartPlan?.ownerParagraphWindow ?? {
|
|
@@ -239498,7 +239649,7 @@ function finalizeCommit(args) {
|
|
|
239498
239649
|
reservations: { conflictRule: "first-choice-strict" },
|
|
239499
239650
|
localApplyBundle: forwardPatchGroup,
|
|
239500
239651
|
semanticDelta: {
|
|
239501
|
-
createdRefs: (args.notes.direct ?
|
|
239652
|
+
createdRefs: (args.notes.direct ? [] : args.notes.emittedRsids ?? [op.rsid]).map((rsid) => ({
|
|
239502
239653
|
kind: "trackedChange",
|
|
239503
239654
|
entityId: rsid,
|
|
239504
239655
|
storyId: op.on.storyId
|
|
@@ -239921,7 +240072,6 @@ function tryOverlapRewriteDirect(input, bytes, window2, byteBase, inheritedNames
|
|
|
239921
240072
|
trackedCarrierRefinement: compiled.trackedCarrierRefinement,
|
|
239922
240073
|
retiredRevisions: compiled.retiredRevisions ?? [],
|
|
239923
240074
|
resolvedInsertionRevisions: compiled.resolvedInsertionRevisions ?? [],
|
|
239924
|
-
splitRevisionRsids: (compiled.splitRevisionParts ?? []).map((part) => part.rsid),
|
|
239925
240075
|
splitRevisionMappings: compiled.splitRevisionMappings ?? [],
|
|
239926
240076
|
cascadeCommentWIds: compiled.cascadeCommentWIds ?? [],
|
|
239927
240077
|
requiresCollaborationSessionSync: compiled.requiresCollaborationSessionSync
|
|
@@ -244450,12 +244600,6 @@ var init_semantic_style_dependencies = __esm(() => {
|
|
|
244450
244600
|
};
|
|
244451
244601
|
});
|
|
244452
244602
|
|
|
244453
|
-
// ../../../v2/editor-core/dist/document/transactions/types.js
|
|
244454
|
-
var SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS;
|
|
244455
|
-
var init_types6 = __esm(() => {
|
|
244456
|
-
SD_PASTE_FRAGMENT_SUPPORTED_VERSIONS = new Set(["v2.1", "v2.2"]);
|
|
244457
|
-
});
|
|
244458
|
-
|
|
244459
244603
|
// ../../../v2/editor-core/dist/document/transactions/paste-list-level-text.js
|
|
244460
244604
|
function levelTextPlaceholders(text) {
|
|
244461
244605
|
return [...text.matchAll(/%(\d)/g)].map((match) => Number(match[1]));
|
|
@@ -290997,6 +291141,7 @@ class TxContext {
|
|
|
290997
291141
|
changeMode: input.changeMode,
|
|
290998
291142
|
on: input.on,
|
|
290999
291143
|
newText: input.newText,
|
|
291144
|
+
...input.preserveInsertionWhitespace ? { preserveInsertionWhitespace: true } : {},
|
|
291000
291145
|
rsid: input.rsid ?? allocateTxRsid(this.txId),
|
|
291001
291146
|
...input.insRsid !== undefined ? { insRsid: input.insRsid } : {}
|
|
291002
291147
|
};
|
|
@@ -307687,6 +307832,7 @@ var init_selection_text_replacement_preflight = __esm(() => {
|
|
|
307687
307832
|
var init_sd_document_session_internal = __esm(() => {
|
|
307688
307833
|
init_sd_document_session();
|
|
307689
307834
|
init_core_properties();
|
|
307835
|
+
init_types6();
|
|
307690
307836
|
init_complex_script_run_properties();
|
|
307691
307837
|
init_docx_package_sanitizer();
|
|
307692
307838
|
init_scalar_properties();
|
|
@@ -348707,19 +348853,15 @@ function mapDirectionContext(props) {
|
|
|
348707
348853
|
};
|
|
348708
348854
|
}
|
|
348709
348855
|
function mapAlignment(value, isRightToLeft) {
|
|
348710
|
-
if (value === "left")
|
|
348856
|
+
if (value === "left" || value === "start")
|
|
348711
348857
|
return isRightToLeft ? "right" : "left";
|
|
348712
|
-
if (value === "right")
|
|
348858
|
+
if (value === "right" || value === "end")
|
|
348713
348859
|
return isRightToLeft ? "left" : "right";
|
|
348714
348860
|
if (value === "center" || value === "justify")
|
|
348715
348861
|
return value;
|
|
348716
348862
|
if (value === "both" || value === "distribute" || value === "numTab" || value === "thaiDistribute" || value === "lowKashida" || value === "mediumKashida" || value === "highKashida") {
|
|
348717
348863
|
return "justify";
|
|
348718
348864
|
}
|
|
348719
|
-
if (value === "start")
|
|
348720
|
-
return "left";
|
|
348721
|
-
if (value === "end")
|
|
348722
|
-
return "right";
|
|
348723
348865
|
return;
|
|
348724
348866
|
}
|
|
348725
348867
|
function mapSpacing(spacing, isList) {
|
|
@@ -362516,9 +362658,9 @@ function readParagraphSpacing(paragraphXml) {
|
|
|
362516
362658
|
...lineRule != null ? { lineRule } : {}
|
|
362517
362659
|
};
|
|
362518
362660
|
}
|
|
362519
|
-
function setParagraphAlignment(paragraphXml, alignment) {
|
|
362661
|
+
function setParagraphAlignment(paragraphXml, alignment, rightToLeft) {
|
|
362520
362662
|
return rewriteParagraphProperties(paragraphXml, (children3, prefix2) => {
|
|
362521
|
-
const stored = mapAlignmentToStoredValue(alignment, isParagraphRtl(children3));
|
|
362663
|
+
const stored = mapAlignmentToStoredValue(alignment, rightToLeft ?? isParagraphRtl(children3));
|
|
362522
362664
|
return setParagraphPropertyChild(children3, "jc", `<${prefix2}:jc w:val="${stored}"/>`);
|
|
362523
362665
|
});
|
|
362524
362666
|
}
|
|
@@ -362810,8 +362952,7 @@ function setParagraphDirection(paragraphXml, input) {
|
|
|
362810
362952
|
return rewriteParagraphProperties(paragraphXml, (children3, prefix2) => {
|
|
362811
362953
|
let next = input.direction === "rtl" ? setParagraphPropertyChild(children3, "bidi", `<${prefix2}:bidi/>`) : setParagraphPropertyChild(children3, "bidi", `<${prefix2}:bidi w:val="0"/>`);
|
|
362812
362954
|
if (input.alignmentPolicy === "matchDirection") {
|
|
362813
|
-
|
|
362814
|
-
next = setParagraphPropertyChild(next, "jc", `<${prefix2}:jc w:val="${alignment}"/>`);
|
|
362955
|
+
next = setParagraphPropertyChild(next, "jc", `<${prefix2}:jc w:val="left"/>`);
|
|
362815
362956
|
}
|
|
362816
362957
|
return next;
|
|
362817
362958
|
});
|
|
@@ -387326,6 +387467,11 @@ function lowerFragmentToApplyPlan(fragment5, options = {}) {
|
|
|
387326
387467
|
});
|
|
387327
387468
|
if (blocks.length === 0)
|
|
387328
387469
|
invalid5([], "Fragment must lower to at least one block.");
|
|
387470
|
+
if (options.allowParagraphTabs === false) {
|
|
387471
|
+
const path8 = findParagraphTabStop(blocks);
|
|
387472
|
+
if (path8)
|
|
387473
|
+
unsupported3(path8, "Tracked replacements cannot materialize paragraph tab stops.");
|
|
387474
|
+
}
|
|
387329
387475
|
const outputViolation = inspectFragmentStringOutput(blocks, Number.MAX_SAFE_INTEGER);
|
|
387330
387476
|
if (outputViolation?.kind === "structure") {
|
|
387331
387477
|
invalid5(outputViolation.path, "Fragment output exceeds the rich inbound structure limit.");
|
|
@@ -387338,6 +387484,21 @@ function lowerFragmentToApplyPlan(fragment5, options = {}) {
|
|
|
387338
387484
|
throw error48;
|
|
387339
387485
|
}
|
|
387340
387486
|
}
|
|
387487
|
+
function findParagraphTabStop(blocks) {
|
|
387488
|
+
for (const block of blocks) {
|
|
387489
|
+
if (block.kind === "table") {
|
|
387490
|
+
for (const row of block.rows ?? [])
|
|
387491
|
+
for (const cell of row.cells) {
|
|
387492
|
+
const path8 = findParagraphTabStop(cell.blocks);
|
|
387493
|
+
if (path8)
|
|
387494
|
+
return path8;
|
|
387495
|
+
}
|
|
387496
|
+
} else if ((block.kind === "paragraph" || block.kind === "heading") && block.paragraphProps?.tabs !== undefined) {
|
|
387497
|
+
return block.sourcePath ?? [];
|
|
387498
|
+
}
|
|
387499
|
+
}
|
|
387500
|
+
return null;
|
|
387501
|
+
}
|
|
387341
387502
|
function createLoweredStructureBudget() {
|
|
387342
387503
|
let valueVisits = 1;
|
|
387343
387504
|
return {
|
|
@@ -387541,12 +387702,41 @@ function lowerRunMarks(props, path8) {
|
|
|
387541
387702
|
return marks;
|
|
387542
387703
|
}
|
|
387543
387704
|
function lowerParagraphProperties(props, path8) {
|
|
387544
|
-
const supported = new Set(["alignment", "indent", "spacing", "markRunProps"]);
|
|
387705
|
+
const supported = new Set(["alignment", "indent", "spacing", "markRunProps", "tabs"]);
|
|
387545
387706
|
const unsupportedKeys = Object.keys(props).filter((key3) => !supported.has(key3));
|
|
387546
387707
|
if (unsupportedKeys.length > 0) {
|
|
387547
387708
|
unsupported3(path8, `Paragraph properties are not materializable: ${unsupportedKeys.sort().join(", ")}.`);
|
|
387548
387709
|
}
|
|
387549
387710
|
const out = {};
|
|
387711
|
+
if (props.tabs !== undefined) {
|
|
387712
|
+
if (!Array.isArray(props.tabs))
|
|
387713
|
+
invalid5([...path8, "tabs"], "Paragraph tabs must be an array.");
|
|
387714
|
+
out.tabs = props.tabs.map((tab, index2) => {
|
|
387715
|
+
const tabPath = [...path8, "tabs", index2];
|
|
387716
|
+
if (!tab || typeof tab !== "object" || Array.isArray(tab))
|
|
387717
|
+
invalid5(tabPath, "A tab stop must be an object.");
|
|
387718
|
+
const unsupportedTab = Object.keys(tab).filter((key3) => !["kind", "position", "alignment", "leader"].includes(key3));
|
|
387719
|
+
if (unsupportedTab.length)
|
|
387720
|
+
unsupported3(tabPath, `Tab stop properties are not materializable: ${unsupportedTab.sort().join(", ")}.`);
|
|
387721
|
+
if (tab.kind !== "set" && tab.kind !== "clear")
|
|
387722
|
+
invalid5([...tabPath, "kind"], "Tab stop kind must be set or clear.");
|
|
387723
|
+
if (typeof tab.position !== "number")
|
|
387724
|
+
invalid5([...tabPath, "position"], "Tab stop position must be a number of points.");
|
|
387725
|
+
const position2 = safeScaledFinite(tab.position, 20, [...tabPath, "position"]);
|
|
387726
|
+
if (tab.kind === "clear" && tab.alignment !== undefined && tab.alignment !== "clear" || tab.kind === "set" && tab.alignment === "clear") {
|
|
387727
|
+
invalid5([...tabPath, "alignment"], "Tab stop kind and alignment must agree.");
|
|
387728
|
+
}
|
|
387729
|
+
const alignment = tab.kind === "clear" ? "clear" : tab.alignment ?? "left";
|
|
387730
|
+
if (!isPasteTabAlignment(alignment)) {
|
|
387731
|
+
unsupported3([...tabPath, "alignment"], "Tab stop alignment is not materializable.");
|
|
387732
|
+
}
|
|
387733
|
+
const leader = tab.leader;
|
|
387734
|
+
if (leader !== undefined && !isPasteTabLeader(leader)) {
|
|
387735
|
+
unsupported3([...tabPath, "leader"], "Tab stop leader is not materializable.");
|
|
387736
|
+
}
|
|
387737
|
+
return { position: position2, alignment, ...leader !== undefined ? { leader } : {} };
|
|
387738
|
+
});
|
|
387739
|
+
}
|
|
387550
387740
|
if (props.markRunProps !== undefined) {
|
|
387551
387741
|
out.markRunProps = lowerRunMarks(props.markRunProps, [...path8, "markRunProps"]);
|
|
387552
387742
|
}
|
|
@@ -397736,6 +397926,7 @@ class V2SelectionMutationAdapter {
|
|
|
397736
397926
|
...collapsedOutsideContentControl ? { collapsedOutsideContentControl: true } : {}
|
|
397737
397927
|
} : edit.on,
|
|
397738
397928
|
newText: edit.newText,
|
|
397929
|
+
...request.text.length > 0 && edit.newText.length === 0 ? { preserveInsertionWhitespace: true } : {},
|
|
397739
397930
|
...options?.changeMode === "tracked" && (isRewrite || edits.length > 1) && !typingHistoryMetadata(options) && story.storyKind !== "textbox" ? {
|
|
397740
397931
|
rewriteGroupId: `${tx.txId}:0`,
|
|
397741
397932
|
...isRewrite && !structuralRewrite ? { preserveExistingRevisions: true } : {}
|
|
@@ -414246,6 +414437,251 @@ var init_adapter9 = __esm(() => {
|
|
|
414246
414437
|
BLOCK_NUMBERING_CACHE = new WeakMap;
|
|
414247
414438
|
});
|
|
414248
414439
|
|
|
414440
|
+
// ../../../v2/document-api-v2-adapter/dist/content-controls/json-preset.js
|
|
414441
|
+
function encodeStructuredPresetNodes(nodes) {
|
|
414442
|
+
const blocks = [];
|
|
414443
|
+
for (const node4 of nodes) {
|
|
414444
|
+
const encoded = encodeStructuredPresetNode(node4);
|
|
414445
|
+
if (!encoded.ok)
|
|
414446
|
+
return encoded;
|
|
414447
|
+
blocks.push(...encoded.blocks);
|
|
414448
|
+
}
|
|
414449
|
+
return { ok: true, blocks };
|
|
414450
|
+
}
|
|
414451
|
+
function encodeStructuredPresetNode(node4) {
|
|
414452
|
+
const record3 = asRecord5(node4);
|
|
414453
|
+
const kind = typeof record3?.kind === "string" ? record3.kind : typeof record3?.type === "string" ? record3.type : null;
|
|
414454
|
+
if (!record3 || !kind) {
|
|
414455
|
+
return unsupportedPreset('preset content nodes must be objects with a "kind" or "type" discriminator.');
|
|
414456
|
+
}
|
|
414457
|
+
if (kind === "paragraph") {
|
|
414458
|
+
const paragraph3 = structuredParagraphBlock(record3);
|
|
414459
|
+
return paragraph3 ? { ok: true, blocks: [paragraph3] } : unsupportedPreset("paragraph preset content contains unsupported inline nodes.");
|
|
414460
|
+
}
|
|
414461
|
+
if (kind === "heading") {
|
|
414462
|
+
const heading = structuredHeadingBlock(record3);
|
|
414463
|
+
return heading ? { ok: true, blocks: [heading] } : unsupportedPreset("heading preset content contains unsupported inline nodes.");
|
|
414464
|
+
}
|
|
414465
|
+
if (kind === "table") {
|
|
414466
|
+
const table = structuredTableBlock(record3);
|
|
414467
|
+
return table.ok ? { ok: true, blocks: [table.block] } : table;
|
|
414468
|
+
}
|
|
414469
|
+
if (kind === "list") {
|
|
414470
|
+
const list2 = structuredListBlocks(record3);
|
|
414471
|
+
return list2.ok ? { ok: true, blocks: list2.blocks } : list2;
|
|
414472
|
+
}
|
|
414473
|
+
if (kind === "sdt" || kind === "customXml") {
|
|
414474
|
+
const content3 = readNestedContentNodes(record3);
|
|
414475
|
+
return encodeStructuredPresetNodes(content3);
|
|
414476
|
+
}
|
|
414477
|
+
return unsupportedPreset(`preset content node kind "${kind}" is not supported by the v2 content-control adapter.`);
|
|
414478
|
+
}
|
|
414479
|
+
function structuredParagraphBlock(record3) {
|
|
414480
|
+
const payload = asRecord5(record3.paragraph);
|
|
414481
|
+
if (payload) {
|
|
414482
|
+
const text4 = readStructuredInlineText(payload.inlines);
|
|
414483
|
+
if (text4 == null)
|
|
414484
|
+
return null;
|
|
414485
|
+
return {
|
|
414486
|
+
kind: "paragraph",
|
|
414487
|
+
text: text4,
|
|
414488
|
+
...typeof payload.styleRef === "string" && payload.styleRef.length > 0 ? { styleRef: payload.styleRef } : {}
|
|
414489
|
+
};
|
|
414490
|
+
}
|
|
414491
|
+
const legacyText = readLegacyInlineText(record3.content);
|
|
414492
|
+
if (legacyText == null) {
|
|
414493
|
+
if (record3.content === undefined || Array.isArray(record3.content) && record3.content.length === 0) {
|
|
414494
|
+
return { kind: "paragraph", text: "" };
|
|
414495
|
+
}
|
|
414496
|
+
return null;
|
|
414497
|
+
}
|
|
414498
|
+
return { kind: "paragraph", text: legacyText };
|
|
414499
|
+
}
|
|
414500
|
+
function structuredHeadingBlock(record3) {
|
|
414501
|
+
const payload = asRecord5(record3.heading);
|
|
414502
|
+
if (payload) {
|
|
414503
|
+
const text4 = readStructuredInlineText(payload.inlines);
|
|
414504
|
+
if (text4 == null)
|
|
414505
|
+
return null;
|
|
414506
|
+
if (typeof payload.styleRef === "string" && payload.styleRef.length > 0) {
|
|
414507
|
+
return { kind: "paragraph", text: text4, styleRef: payload.styleRef };
|
|
414508
|
+
}
|
|
414509
|
+
const level2 = typeof payload.level === "number" && payload.level >= 1 && payload.level <= 6 ? payload.level : 1;
|
|
414510
|
+
const semanticStyleRole2 = semanticHeadingRole(level2);
|
|
414511
|
+
return semanticStyleRole2 ? { kind: "paragraph", text: text4, semanticStyleRole: semanticStyleRole2 } : null;
|
|
414512
|
+
}
|
|
414513
|
+
const legacyText = readLegacyInlineText(record3.content);
|
|
414514
|
+
if (legacyText == null)
|
|
414515
|
+
return null;
|
|
414516
|
+
const level = typeof record3.level === "number" && record3.level >= 1 && record3.level <= 6 ? record3.level : 1;
|
|
414517
|
+
const semanticStyleRole = semanticHeadingRole(level);
|
|
414518
|
+
return semanticStyleRole ? { kind: "paragraph", text: legacyText, semanticStyleRole } : null;
|
|
414519
|
+
}
|
|
414520
|
+
function structuredTableBlock(record3) {
|
|
414521
|
+
const sdmRows = asArray(asRecord5(record3.table)?.rows);
|
|
414522
|
+
const legacyRows = asArray(record3.rows);
|
|
414523
|
+
const pmRows = asArray(record3.content)?.filter((node4) => asRecord5(node4)?.type === "tableRow" || asRecord5(asRecord5(node4)?.tableRow) != null);
|
|
414524
|
+
const rowsSource = sdmRows ?? legacyRows ?? pmRows;
|
|
414525
|
+
if (!rowsSource || rowsSource.length === 0) {
|
|
414526
|
+
return unsupportedPreset("table preset content must contain at least one row.");
|
|
414527
|
+
}
|
|
414528
|
+
const rows = [];
|
|
414529
|
+
for (const row of rowsSource) {
|
|
414530
|
+
const rowRecord = asRecord5(row);
|
|
414531
|
+
const pmCells = asArray(rowRecord?.content)?.filter((node4) => asRecord5(node4)?.type === "tableCell" || asRecord5(node4)?.type === "tableHeader");
|
|
414532
|
+
const cellsSource = asArray(asRecord5(rowRecord?.tableRow)?.cells) ?? asArray(rowRecord?.cells) ?? pmCells;
|
|
414533
|
+
if (!rowRecord || !cellsSource || cellsSource.length === 0) {
|
|
414534
|
+
return unsupportedPreset("table preset content rows must contain at least one cell.");
|
|
414535
|
+
}
|
|
414536
|
+
const cells = [];
|
|
414537
|
+
for (const cell of cellsSource) {
|
|
414538
|
+
const cellRecord = asRecord5(cell);
|
|
414539
|
+
const cellPayload = asRecord5(cellRecord?.tableCell);
|
|
414540
|
+
const content3 = asArray(cellPayload?.content) ?? asArray(cellRecord?.content) ?? [];
|
|
414541
|
+
const encoded = encodeStructuredPresetNodes(content3);
|
|
414542
|
+
if (!encoded.ok)
|
|
414543
|
+
return encoded;
|
|
414544
|
+
cells.push({
|
|
414545
|
+
blocks: encoded.blocks,
|
|
414546
|
+
...typeof cellPayload?.colSpan === "number" && cellPayload.colSpan > 1 ? { colSpan: cellPayload.colSpan } : {},
|
|
414547
|
+
...typeof cellRecord?.colSpan === "number" && cellRecord.colSpan > 1 ? { colSpan: cellRecord.colSpan } : {}
|
|
414548
|
+
});
|
|
414549
|
+
}
|
|
414550
|
+
rows.push(cells);
|
|
414551
|
+
}
|
|
414552
|
+
return { ok: true, block: { kind: "table", rows } };
|
|
414553
|
+
}
|
|
414554
|
+
function structuredListBlocks(record3) {
|
|
414555
|
+
const payload = asRecord5(record3.list);
|
|
414556
|
+
const items = asArray(payload?.items) ?? asArray(record3.items);
|
|
414557
|
+
if (!items || items.length === 0) {
|
|
414558
|
+
return unsupportedPreset("list preset content must contain at least one item.");
|
|
414559
|
+
}
|
|
414560
|
+
const ordered = asRecord5(asArray(payload?.levels)?.[0])?.kind === "ordered" || record3.ordered === true;
|
|
414561
|
+
const blocks = [];
|
|
414562
|
+
for (let index2 = 0;index2 < items.length; index2 += 1) {
|
|
414563
|
+
const item2 = items[index2];
|
|
414564
|
+
const itemRecord = asRecord5(item2);
|
|
414565
|
+
const nested = asArray(itemRecord?.content);
|
|
414566
|
+
if (nested && nested.length > 0) {
|
|
414567
|
+
const encoded = flattenTextFromNodes(nested);
|
|
414568
|
+
if (encoded == null) {
|
|
414569
|
+
return unsupportedPreset("list preset content contains unsupported nested list-item blocks.");
|
|
414570
|
+
}
|
|
414571
|
+
const marker = typeof itemRecord?.marker === "string" && itemRecord.marker.length > 0 ? itemRecord.marker : ordered ? `${index2 + 1}.` : "•";
|
|
414572
|
+
blocks.push({ kind: "paragraph", text: `${marker} ${encoded}`.trim() });
|
|
414573
|
+
continue;
|
|
414574
|
+
}
|
|
414575
|
+
const inlineText = readLegacyInlineText(itemRecord?.content);
|
|
414576
|
+
if (inlineText != null) {
|
|
414577
|
+
const marker = typeof itemRecord?.marker === "string" && itemRecord.marker.length > 0 ? itemRecord.marker : ordered ? `${index2 + 1}.` : "•";
|
|
414578
|
+
blocks.push({ kind: "paragraph", text: `${marker} ${inlineText}`.trim() });
|
|
414579
|
+
}
|
|
414580
|
+
}
|
|
414581
|
+
if (blocks.length === 0) {
|
|
414582
|
+
return unsupportedPreset("list preset content contains no supported list items.");
|
|
414583
|
+
}
|
|
414584
|
+
return { ok: true, blocks };
|
|
414585
|
+
}
|
|
414586
|
+
function readStructuredInlineText(value3) {
|
|
414587
|
+
const inlines = asArray(value3);
|
|
414588
|
+
if (!inlines)
|
|
414589
|
+
return null;
|
|
414590
|
+
let text4 = "";
|
|
414591
|
+
for (const inline of inlines) {
|
|
414592
|
+
const record3 = asRecord5(inline);
|
|
414593
|
+
if (!record3)
|
|
414594
|
+
return null;
|
|
414595
|
+
const kind = typeof record3.kind === "string" ? record3.kind : null;
|
|
414596
|
+
if (kind === "run") {
|
|
414597
|
+
const run = asRecord5(record3.run);
|
|
414598
|
+
text4 += typeof run?.text === "string" ? run.text : "";
|
|
414599
|
+
continue;
|
|
414600
|
+
}
|
|
414601
|
+
if (kind === "tab") {
|
|
414602
|
+
text4 += "\t";
|
|
414603
|
+
continue;
|
|
414604
|
+
}
|
|
414605
|
+
if (kind === "lineBreak") {
|
|
414606
|
+
text4 += `
|
|
414607
|
+
`;
|
|
414608
|
+
continue;
|
|
414609
|
+
}
|
|
414610
|
+
return null;
|
|
414611
|
+
}
|
|
414612
|
+
return text4;
|
|
414613
|
+
}
|
|
414614
|
+
function readLegacyInlineText(value3) {
|
|
414615
|
+
const items = asArray(value3);
|
|
414616
|
+
if (!items)
|
|
414617
|
+
return null;
|
|
414618
|
+
let text4 = "";
|
|
414619
|
+
for (const item2 of items) {
|
|
414620
|
+
const record3 = asRecord5(item2);
|
|
414621
|
+
const type = typeof record3?.type === "string" ? record3.type : null;
|
|
414622
|
+
if (type === "text") {
|
|
414623
|
+
if (typeof record3?.text !== "string")
|
|
414624
|
+
return null;
|
|
414625
|
+
text4 += record3.text;
|
|
414626
|
+
continue;
|
|
414627
|
+
}
|
|
414628
|
+
if (type === "run") {
|
|
414629
|
+
const runText = readLegacyInlineText(record3?.content);
|
|
414630
|
+
if (runText == null)
|
|
414631
|
+
return null;
|
|
414632
|
+
text4 += runText;
|
|
414633
|
+
continue;
|
|
414634
|
+
}
|
|
414635
|
+
return null;
|
|
414636
|
+
}
|
|
414637
|
+
return text4;
|
|
414638
|
+
}
|
|
414639
|
+
function readNestedContentNodes(record3) {
|
|
414640
|
+
return asArray(record3.content) ?? asArray(asRecord5(record3.sdt)?.content) ?? asArray(asRecord5(record3.customXml)?.content) ?? [];
|
|
414641
|
+
}
|
|
414642
|
+
function flattenTextFromNodes(nodes) {
|
|
414643
|
+
const parts = [];
|
|
414644
|
+
for (const node4 of nodes) {
|
|
414645
|
+
const record3 = asRecord5(node4);
|
|
414646
|
+
if (!record3)
|
|
414647
|
+
return null;
|
|
414648
|
+
const kind = typeof record3.kind === "string" ? record3.kind : typeof record3.type === "string" ? record3.type : null;
|
|
414649
|
+
if (kind === "paragraph") {
|
|
414650
|
+
const paragraph3 = structuredParagraphBlock(record3);
|
|
414651
|
+
if (!paragraph3)
|
|
414652
|
+
return null;
|
|
414653
|
+
parts.push(paragraph3.text);
|
|
414654
|
+
continue;
|
|
414655
|
+
}
|
|
414656
|
+
if (kind === "heading") {
|
|
414657
|
+
const heading = structuredHeadingBlock(record3);
|
|
414658
|
+
if (!heading)
|
|
414659
|
+
return null;
|
|
414660
|
+
parts.push(heading.text);
|
|
414661
|
+
continue;
|
|
414662
|
+
}
|
|
414663
|
+
}
|
|
414664
|
+
return parts.join(" ").trim();
|
|
414665
|
+
}
|
|
414666
|
+
function unsupportedPreset(message) {
|
|
414667
|
+
return {
|
|
414668
|
+
ok: false,
|
|
414669
|
+
failure: {
|
|
414670
|
+
code: "CAPABILITY_UNAVAILABLE",
|
|
414671
|
+
message
|
|
414672
|
+
}
|
|
414673
|
+
};
|
|
414674
|
+
}
|
|
414675
|
+
function asRecord5(value3) {
|
|
414676
|
+
return isRecord7(value3) ? value3 : null;
|
|
414677
|
+
}
|
|
414678
|
+
function asArray(value3) {
|
|
414679
|
+
return Array.isArray(value3) ? value3 : null;
|
|
414680
|
+
}
|
|
414681
|
+
var init_json_preset = __esm(() => {
|
|
414682
|
+
init_src6();
|
|
414683
|
+
});
|
|
414684
|
+
|
|
414249
414685
|
// ../../../v2/document-api-v2-adapter/dist/content-controls/wrap-text-selection.js
|
|
414250
414686
|
function wrapTextSelectionInParagraphXml(input) {
|
|
414251
414687
|
const original = wrapRangeWithMarkupInParagraphXml(input);
|
|
@@ -414699,7 +415135,7 @@ function executeRichFragmentWrite(context, kind, input, options) {
|
|
|
414699
415135
|
conversion: { format: input.type, lossy: false, diagnostics: [] }
|
|
414700
415136
|
};
|
|
414701
415137
|
}
|
|
414702
|
-
const prepared = prepareFragment(input);
|
|
415138
|
+
const prepared = prepareFragment(input, { allowParagraphTabs: kind !== "replace" || options?.changeMode !== "tracked" });
|
|
414703
415139
|
if (!prepared.ok) {
|
|
414704
415140
|
return failureReceipt(prepared.code, prepared.message, beforeRevision, {
|
|
414705
415141
|
...prepared.path ? { path: [...prepared.path] } : {},
|
|
@@ -414868,7 +415304,7 @@ function executeGuardedRichFragmentWrite(context, kind, input, options, execute
|
|
|
414868
415304
|
function isRichStringInput(input) {
|
|
414869
415305
|
return "value" in input && (input.type === "html" || input.type === "markdown");
|
|
414870
415306
|
}
|
|
414871
|
-
function prepareFragment(input) {
|
|
415307
|
+
function prepareFragment(input, options = {}) {
|
|
414872
415308
|
let fragment5;
|
|
414873
415309
|
let conversion;
|
|
414874
415310
|
if ("content" in input && input.content !== undefined) {
|
|
@@ -414896,7 +415332,7 @@ function prepareFragment(input) {
|
|
|
414896
415332
|
} else {
|
|
414897
415333
|
return { ok: false, code: "INVALID_PAYLOAD", message: "Rich writes require HTML, Markdown, or SDFragment content." };
|
|
414898
415334
|
}
|
|
414899
|
-
const lowered = lowerFragmentToApplyPlan(fragment5);
|
|
415335
|
+
const lowered = lowerFragmentToApplyPlan(fragment5, options);
|
|
414900
415336
|
if (!lowered.ok) {
|
|
414901
415337
|
return {
|
|
414902
415338
|
ok: false,
|
|
@@ -416986,7 +417422,7 @@ class V2ContentControlsAdapter {
|
|
|
416986
417422
|
return { success: false, failure: freshness };
|
|
416987
417423
|
if (structuralReplacementXml === undefined && input.html !== undefined && htmlPresetShouldPreserveList(input.html)) {
|
|
416988
417424
|
if (options?.changeMode === "tracked") {
|
|
416989
|
-
const refused2 =
|
|
417425
|
+
const refused2 = unsupportedPreset2("This HTML list preset cannot be preserved as a native list while tracking changes. " + 'Create a placeholder block content control and use doc.replace({ type: "html" }) on its entire placeholder paragraph.');
|
|
416990
417426
|
return { success: false, failure: refused2.failure };
|
|
416991
417427
|
}
|
|
416992
417428
|
return this.createPreservedListHtml(input, options);
|
|
@@ -418432,7 +418868,7 @@ class V2ContentControlsAdapter {
|
|
|
418432
418868
|
createdRefs = prepared.wordIds.map((entityId) => ({ kind: "trackedChange", entityId, storyId: control2.storyId }));
|
|
418433
418869
|
}
|
|
418434
418870
|
let nextXml = replaceRange3(part.xml, control2.start, control2.end, replacement2);
|
|
418435
|
-
if (prefix2 === "content-control-pr" &&
|
|
418871
|
+
if (prefix2 === "content-control-pr" && asRecord6(input)?.appearance != null) {
|
|
418436
418872
|
const withNamespace = ensureAppearanceNamespace(nextXml, { start: control2.start, end: control2.start + replacement2.length });
|
|
418437
418873
|
if (withNamespace === null) {
|
|
418438
418874
|
return { success: false, failure: { code: "INVALID_CONTEXT", message: "content-control-pr: conflicting appearance namespace" } };
|
|
@@ -419429,16 +419865,16 @@ function buildHtmlPresetContentXml(context, html) {
|
|
|
419429
419865
|
const converted = convertContentToFragment({ format: "html", source: html });
|
|
419430
419866
|
const fatal = converted.diagnostics.find((diagnostic2) => diagnostic2.severity === "error");
|
|
419431
419867
|
if (fatal)
|
|
419432
|
-
return
|
|
419868
|
+
return unsupportedPreset2(fatal.message);
|
|
419433
419869
|
const nodes = Array.isArray(converted.fragment) ? converted.fragment : [converted.fragment];
|
|
419434
419870
|
const table = parseSimpleHtmlTable(html);
|
|
419435
419871
|
if (table || nodes.some((node4) => node4.kind === "table")) {
|
|
419436
419872
|
const dropped = converted.diagnostics.find(isDroppedConversionContent);
|
|
419437
419873
|
if (dropped) {
|
|
419438
|
-
return
|
|
419874
|
+
return unsupportedPreset2("This HTML table preset cannot be preserved because conversion discarded content. " + `${dropped.message} Remove the unsupported element before creating the control.`);
|
|
419439
419875
|
}
|
|
419440
419876
|
if (!table || nodes.length !== 1 || nodes[0]?.kind !== "table") {
|
|
419441
|
-
return
|
|
419877
|
+
return unsupportedPreset2("This HTML table preset cannot be preserved: creation requires a single table without surrounding blocks. " + 'For mixed HTML, create a placeholder block content control and use doc.replace({ type: "html" }) on its entire placeholder paragraph.');
|
|
419442
419878
|
}
|
|
419443
419879
|
return { ok: true, contentXml: buildStructuredTableXml(table.rows, allocParaId) };
|
|
419444
419880
|
}
|
|
@@ -419496,151 +419932,6 @@ function buildStructuredBlocksFromNodes(context, nodes, allocParaId) {
|
|
|
419496
419932
|
const blocks = encoded.blocks;
|
|
419497
419933
|
return buildResolvedStructuredBlocksXml(context, blocks, allocParaId);
|
|
419498
419934
|
}
|
|
419499
|
-
function encodeStructuredPresetNodes(nodes) {
|
|
419500
|
-
const blocks = [];
|
|
419501
|
-
for (const node4 of nodes) {
|
|
419502
|
-
const encoded = encodeStructuredPresetNode(node4);
|
|
419503
|
-
if (!encoded.ok)
|
|
419504
|
-
return encoded;
|
|
419505
|
-
blocks.push(...encoded.blocks);
|
|
419506
|
-
}
|
|
419507
|
-
return { ok: true, blocks };
|
|
419508
|
-
}
|
|
419509
|
-
function encodeStructuredPresetNode(node4) {
|
|
419510
|
-
const record3 = asRecord5(node4);
|
|
419511
|
-
const kind = typeof record3?.kind === "string" ? record3.kind : typeof record3?.type === "string" ? record3.type : null;
|
|
419512
|
-
if (!record3 || !kind) {
|
|
419513
|
-
return unsupportedPreset('preset content nodes must be objects with a "kind" or "type" discriminator.');
|
|
419514
|
-
}
|
|
419515
|
-
if (kind === "paragraph") {
|
|
419516
|
-
const paragraph4 = structuredParagraphBlock(record3);
|
|
419517
|
-
return paragraph4 ? { ok: true, blocks: [paragraph4] } : unsupportedPreset("paragraph preset content contains unsupported inline nodes.");
|
|
419518
|
-
}
|
|
419519
|
-
if (kind === "heading") {
|
|
419520
|
-
const heading = structuredHeadingBlock(record3);
|
|
419521
|
-
return heading ? { ok: true, blocks: [heading] } : unsupportedPreset("heading preset content contains unsupported inline nodes.");
|
|
419522
|
-
}
|
|
419523
|
-
if (kind === "table") {
|
|
419524
|
-
const table = structuredTableBlock(record3);
|
|
419525
|
-
return table.ok ? { ok: true, blocks: [table.block] } : table;
|
|
419526
|
-
}
|
|
419527
|
-
if (kind === "list") {
|
|
419528
|
-
const list2 = structuredListBlocks(record3);
|
|
419529
|
-
return list2.ok ? { ok: true, blocks: list2.blocks } : list2;
|
|
419530
|
-
}
|
|
419531
|
-
if (kind === "sdt" || kind === "customXml") {
|
|
419532
|
-
const content3 = readNestedContentNodes(record3);
|
|
419533
|
-
return encodeStructuredPresetNodes(content3);
|
|
419534
|
-
}
|
|
419535
|
-
return unsupportedPreset(`preset content node kind "${kind}" is not supported by the v2 content-control adapter.`);
|
|
419536
|
-
}
|
|
419537
|
-
function structuredParagraphBlock(record3) {
|
|
419538
|
-
const payload = asRecord5(record3.paragraph);
|
|
419539
|
-
if (payload) {
|
|
419540
|
-
const text4 = readStructuredInlineText(payload.inlines);
|
|
419541
|
-
if (text4 == null)
|
|
419542
|
-
return null;
|
|
419543
|
-
return {
|
|
419544
|
-
kind: "paragraph",
|
|
419545
|
-
text: text4,
|
|
419546
|
-
...typeof payload.styleRef === "string" && payload.styleRef.length > 0 ? { styleRef: payload.styleRef } : {}
|
|
419547
|
-
};
|
|
419548
|
-
}
|
|
419549
|
-
const legacyText = readLegacyInlineText(record3.content);
|
|
419550
|
-
if (legacyText == null) {
|
|
419551
|
-
if (record3.content === undefined || Array.isArray(record3.content) && record3.content.length === 0) {
|
|
419552
|
-
return { kind: "paragraph", text: "" };
|
|
419553
|
-
}
|
|
419554
|
-
return null;
|
|
419555
|
-
}
|
|
419556
|
-
return { kind: "paragraph", text: legacyText };
|
|
419557
|
-
}
|
|
419558
|
-
function structuredHeadingBlock(record3) {
|
|
419559
|
-
const payload = asRecord5(record3.heading);
|
|
419560
|
-
if (payload) {
|
|
419561
|
-
const text4 = readStructuredInlineText(payload.inlines);
|
|
419562
|
-
if (text4 == null)
|
|
419563
|
-
return null;
|
|
419564
|
-
if (typeof payload.styleRef === "string" && payload.styleRef.length > 0) {
|
|
419565
|
-
return { kind: "paragraph", text: text4, styleRef: payload.styleRef };
|
|
419566
|
-
}
|
|
419567
|
-
const level2 = typeof payload.level === "number" && payload.level >= 1 && payload.level <= 6 ? payload.level : 1;
|
|
419568
|
-
const semanticStyleRole2 = semanticHeadingRole(level2);
|
|
419569
|
-
return semanticStyleRole2 ? { kind: "paragraph", text: text4, semanticStyleRole: semanticStyleRole2 } : null;
|
|
419570
|
-
}
|
|
419571
|
-
const legacyText = readLegacyInlineText(record3.content);
|
|
419572
|
-
if (legacyText == null)
|
|
419573
|
-
return null;
|
|
419574
|
-
const level = typeof record3.level === "number" && record3.level >= 1 && record3.level <= 6 ? record3.level : 1;
|
|
419575
|
-
const semanticStyleRole = semanticHeadingRole(level);
|
|
419576
|
-
return semanticStyleRole ? { kind: "paragraph", text: legacyText, semanticStyleRole } : null;
|
|
419577
|
-
}
|
|
419578
|
-
function structuredTableBlock(record3) {
|
|
419579
|
-
const sdmRows = asArray(asRecord5(record3.table)?.rows);
|
|
419580
|
-
const legacyRows = asArray(record3.rows);
|
|
419581
|
-
const pmRows = asArray(record3.content)?.filter((node4) => asRecord5(node4)?.type === "tableRow" || asRecord5(asRecord5(node4)?.tableRow) != null);
|
|
419582
|
-
const rowsSource = sdmRows ?? legacyRows ?? pmRows;
|
|
419583
|
-
if (!rowsSource || rowsSource.length === 0) {
|
|
419584
|
-
return unsupportedPreset("table preset content must contain at least one row.");
|
|
419585
|
-
}
|
|
419586
|
-
const rows = [];
|
|
419587
|
-
for (const row of rowsSource) {
|
|
419588
|
-
const rowRecord = asRecord5(row);
|
|
419589
|
-
const pmCells = asArray(rowRecord?.content)?.filter((node4) => asRecord5(node4)?.type === "tableCell" || asRecord5(node4)?.type === "tableHeader");
|
|
419590
|
-
const cellsSource = asArray(asRecord5(rowRecord?.tableRow)?.cells) ?? asArray(rowRecord?.cells) ?? pmCells;
|
|
419591
|
-
if (!rowRecord || !cellsSource || cellsSource.length === 0) {
|
|
419592
|
-
return unsupportedPreset("table preset content rows must contain at least one cell.");
|
|
419593
|
-
}
|
|
419594
|
-
const cells = [];
|
|
419595
|
-
for (const cell of cellsSource) {
|
|
419596
|
-
const cellRecord = asRecord5(cell);
|
|
419597
|
-
const cellPayload = asRecord5(cellRecord?.tableCell);
|
|
419598
|
-
const content3 = asArray(cellPayload?.content) ?? asArray(cellRecord?.content) ?? [];
|
|
419599
|
-
const encoded = encodeStructuredPresetNodes(content3);
|
|
419600
|
-
if (!encoded.ok)
|
|
419601
|
-
return encoded;
|
|
419602
|
-
cells.push({
|
|
419603
|
-
blocks: encoded.blocks,
|
|
419604
|
-
...typeof cellPayload?.colSpan === "number" && cellPayload.colSpan > 1 ? { colSpan: cellPayload.colSpan } : {},
|
|
419605
|
-
...typeof cellRecord?.colSpan === "number" && cellRecord.colSpan > 1 ? { colSpan: cellRecord.colSpan } : {}
|
|
419606
|
-
});
|
|
419607
|
-
}
|
|
419608
|
-
rows.push(cells);
|
|
419609
|
-
}
|
|
419610
|
-
return { ok: true, block: { kind: "table", rows } };
|
|
419611
|
-
}
|
|
419612
|
-
function structuredListBlocks(record3) {
|
|
419613
|
-
const payload = asRecord5(record3.list);
|
|
419614
|
-
const items = asArray(payload?.items) ?? asArray(record3.items);
|
|
419615
|
-
if (!items || items.length === 0) {
|
|
419616
|
-
return unsupportedPreset("list preset content must contain at least one item.");
|
|
419617
|
-
}
|
|
419618
|
-
const ordered = asArray(payload?.levels)?.[0]?.kind === "ordered" || record3.ordered === true;
|
|
419619
|
-
const blocks = [];
|
|
419620
|
-
for (let index2 = 0;index2 < items.length; index2 += 1) {
|
|
419621
|
-
const item2 = items[index2];
|
|
419622
|
-
const itemRecord = asRecord5(item2);
|
|
419623
|
-
const nested = asArray(itemRecord?.content);
|
|
419624
|
-
if (nested && nested.length > 0) {
|
|
419625
|
-
const encoded = flattenTextFromNodes(nested);
|
|
419626
|
-
if (encoded == null) {
|
|
419627
|
-
return unsupportedPreset("list preset content contains unsupported nested list-item blocks.");
|
|
419628
|
-
}
|
|
419629
|
-
const marker = typeof itemRecord?.marker === "string" && itemRecord.marker.length > 0 ? itemRecord.marker : ordered ? `${index2 + 1}.` : "•";
|
|
419630
|
-
blocks.push({ kind: "paragraph", text: `${marker} ${encoded}`.trim() });
|
|
419631
|
-
continue;
|
|
419632
|
-
}
|
|
419633
|
-
const inlineText = readLegacyInlineText(itemRecord?.content);
|
|
419634
|
-
if (inlineText != null) {
|
|
419635
|
-
const marker = typeof itemRecord?.marker === "string" && itemRecord.marker.length > 0 ? itemRecord.marker : ordered ? `${index2 + 1}.` : "•";
|
|
419636
|
-
blocks.push({ kind: "paragraph", text: `${marker} ${inlineText}`.trim() });
|
|
419637
|
-
}
|
|
419638
|
-
}
|
|
419639
|
-
if (blocks.length === 0) {
|
|
419640
|
-
return unsupportedPreset("list preset content contains no supported list items.");
|
|
419641
|
-
}
|
|
419642
|
-
return { ok: true, blocks };
|
|
419643
|
-
}
|
|
419644
419935
|
function buildStructuredBlocksXml(blocks, allocParaId) {
|
|
419645
419936
|
return blocks.map((block) => {
|
|
419646
419937
|
if (block.kind === "table") {
|
|
@@ -419765,86 +420056,6 @@ function buildStructuredTextRuns(text4) {
|
|
|
419765
420056
|
flush();
|
|
419766
420057
|
return out.join("");
|
|
419767
420058
|
}
|
|
419768
|
-
function readStructuredInlineText(value3) {
|
|
419769
|
-
const inlines = asArray(value3);
|
|
419770
|
-
if (!inlines)
|
|
419771
|
-
return null;
|
|
419772
|
-
let text4 = "";
|
|
419773
|
-
for (const inline of inlines) {
|
|
419774
|
-
const record3 = asRecord5(inline);
|
|
419775
|
-
if (!record3)
|
|
419776
|
-
return null;
|
|
419777
|
-
const kind = typeof record3.kind === "string" ? record3.kind : null;
|
|
419778
|
-
if (kind === "run") {
|
|
419779
|
-
const run = asRecord5(record3.run);
|
|
419780
|
-
text4 += typeof run?.text === "string" ? run.text : "";
|
|
419781
|
-
continue;
|
|
419782
|
-
}
|
|
419783
|
-
if (kind === "tab") {
|
|
419784
|
-
text4 += "\t";
|
|
419785
|
-
continue;
|
|
419786
|
-
}
|
|
419787
|
-
if (kind === "lineBreak") {
|
|
419788
|
-
text4 += `
|
|
419789
|
-
`;
|
|
419790
|
-
continue;
|
|
419791
|
-
}
|
|
419792
|
-
return null;
|
|
419793
|
-
}
|
|
419794
|
-
return text4;
|
|
419795
|
-
}
|
|
419796
|
-
function readLegacyInlineText(value3) {
|
|
419797
|
-
const items = asArray(value3);
|
|
419798
|
-
if (!items)
|
|
419799
|
-
return null;
|
|
419800
|
-
let text4 = "";
|
|
419801
|
-
for (const item2 of items) {
|
|
419802
|
-
const record3 = asRecord5(item2);
|
|
419803
|
-
const type = typeof record3?.type === "string" ? record3.type : null;
|
|
419804
|
-
if (type === "text") {
|
|
419805
|
-
if (typeof record3?.text !== "string")
|
|
419806
|
-
return null;
|
|
419807
|
-
text4 += record3.text;
|
|
419808
|
-
continue;
|
|
419809
|
-
}
|
|
419810
|
-
if (type === "run") {
|
|
419811
|
-
const runText = readLegacyInlineText(record3?.content);
|
|
419812
|
-
if (runText == null)
|
|
419813
|
-
return null;
|
|
419814
|
-
text4 += runText;
|
|
419815
|
-
continue;
|
|
419816
|
-
}
|
|
419817
|
-
return null;
|
|
419818
|
-
}
|
|
419819
|
-
return text4;
|
|
419820
|
-
}
|
|
419821
|
-
function readNestedContentNodes(record3) {
|
|
419822
|
-
return asArray(record3.content) ?? asArray(asRecord5(record3.sdt)?.content) ?? asArray(asRecord5(record3.customXml)?.content) ?? [];
|
|
419823
|
-
}
|
|
419824
|
-
function flattenTextFromNodes(nodes) {
|
|
419825
|
-
const parts = [];
|
|
419826
|
-
for (const node4 of nodes) {
|
|
419827
|
-
const record3 = asRecord5(node4);
|
|
419828
|
-
if (!record3)
|
|
419829
|
-
return null;
|
|
419830
|
-
const kind = typeof record3.kind === "string" ? record3.kind : typeof record3.type === "string" ? record3.type : null;
|
|
419831
|
-
if (kind === "paragraph") {
|
|
419832
|
-
const paragraph4 = structuredParagraphBlock(record3);
|
|
419833
|
-
if (!paragraph4)
|
|
419834
|
-
return null;
|
|
419835
|
-
parts.push(paragraph4.text);
|
|
419836
|
-
continue;
|
|
419837
|
-
}
|
|
419838
|
-
if (kind === "heading") {
|
|
419839
|
-
const heading = structuredHeadingBlock(record3);
|
|
419840
|
-
if (!heading)
|
|
419841
|
-
return null;
|
|
419842
|
-
parts.push(heading.text);
|
|
419843
|
-
continue;
|
|
419844
|
-
}
|
|
419845
|
-
}
|
|
419846
|
-
return parts.join(" ").trim();
|
|
419847
|
-
}
|
|
419848
420059
|
function parseSimpleHtmlTable(html) {
|
|
419849
420060
|
if (!/<table\b/i.test(html))
|
|
419850
420061
|
return null;
|
|
@@ -419885,9 +420096,9 @@ function prepareListHtmlFragment(html) {
|
|
|
419885
420096
|
const converted = convertContentToFragment({ format: "html", source: html });
|
|
419886
420097
|
const fatal = converted.diagnostics.find((diagnostic2) => diagnostic2.severity === "error");
|
|
419887
420098
|
if (fatal)
|
|
419888
|
-
return
|
|
420099
|
+
return unsupportedPreset2(fatal.message);
|
|
419889
420100
|
const lowered = lowerFragmentToApplyPlan(converted.fragment);
|
|
419890
|
-
return lowered.ok ? { ok: true } :
|
|
420101
|
+
return lowered.ok ? { ok: true } : unsupportedPreset2(lowered.message);
|
|
419891
420102
|
}
|
|
419892
420103
|
function htmlText2(fragment5) {
|
|
419893
420104
|
return decodeHtml(fragment5.replace(/<br\b[^>]*\/?>/gi, `
|
|
@@ -419897,7 +420108,7 @@ function htmlText2(fragment5) {
|
|
|
419897
420108
|
function decodeHtml(text4) {
|
|
419898
420109
|
return text4.replace(/ /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/g, "'");
|
|
419899
420110
|
}
|
|
419900
|
-
function
|
|
420111
|
+
function unsupportedPreset2(message) {
|
|
419901
420112
|
return {
|
|
419902
420113
|
ok: false,
|
|
419903
420114
|
failure: {
|
|
@@ -419906,12 +420117,9 @@ function unsupportedPreset(message) {
|
|
|
419906
420117
|
}
|
|
419907
420118
|
};
|
|
419908
420119
|
}
|
|
419909
|
-
function
|
|
420120
|
+
function asRecord6(value3) {
|
|
419910
420121
|
return value3 && typeof value3 === "object" && !Array.isArray(value3) ? value3 : null;
|
|
419911
420122
|
}
|
|
419912
|
-
function asArray(value3) {
|
|
419913
|
-
return Array.isArray(value3) ? value3 : null;
|
|
419914
|
-
}
|
|
419915
420123
|
function buildSdtXml(context, input) {
|
|
419916
420124
|
const pr = buildSdtPr(input);
|
|
419917
420125
|
const content3 = input.innerXml ?? buildContentXml(input.content ?? "", input.kind, createParaIdAllocator(context));
|
|
@@ -421078,6 +421286,7 @@ function replaceTextRangeInParagraph2(paragraphXml, start, end, replacement2) {
|
|
|
421078
421286
|
}
|
|
421079
421287
|
var CheckboxSelectionDeleteError, ListHtmlPresetAbort, DEFAULT_CHECKED, DEFAULT_UNCHECKED, SECONDARY_STORY_MUTATION_MESSAGE = "Content control mutations outside the document body are not supported by this adapter.", UNMODELED_TYPE_TAGS, TYPE_TAGS, COOPERATIVE_PARSE_SLICE_PARAGRAPHS = 128, COOPERATIVE_PARSE_SLICE_CONTROLS = 16, RAW_ATTRIBUTE_PATTERN, COPIED_PROPERTY_REVISIONS, DATE_CHILD_ORDER;
|
|
421080
421288
|
var init_adapter10 = __esm(() => {
|
|
421289
|
+
init_json_preset();
|
|
421081
421290
|
init_sd_document_session_internal();
|
|
421082
421291
|
init_src6();
|
|
421083
421292
|
init_part();
|
|
@@ -427848,12 +428057,10 @@ function readCurrentLiveInsertionText(entry, trackedAssociations) {
|
|
|
427848
428057
|
if (fragments.length === 0)
|
|
427849
428058
|
return null;
|
|
427850
428059
|
fragments.sort((a, b) => a.byteStart - b.byteStart);
|
|
427851
|
-
const first = fragments[0];
|
|
427852
|
-
const last = fragments[fragments.length - 1];
|
|
427853
428060
|
const partXml = trackedAssociations.partXmlByUri.get(entry.partUri);
|
|
427854
428061
|
if (!partXml)
|
|
427855
428062
|
return null;
|
|
427856
|
-
return readInsertedTextFromXml(partXml.slice(
|
|
428063
|
+
return fragments.map((fragment5) => readInsertedTextFromXml(partXml.slice(fragment5.byteStart, fragment5.byteEnd))).join("");
|
|
427857
428064
|
}
|
|
427858
428065
|
function readInsertedTextFromXml(xml) {
|
|
427859
428066
|
const out = [];
|
|
@@ -473079,9 +473286,11 @@ function validateAttributedTextPlan(context, input, compiled) {
|
|
|
473079
473286
|
}
|
|
473080
473287
|
}
|
|
473081
473288
|
}
|
|
473082
|
-
function receiptValidationError(failure22) {
|
|
473289
|
+
function receiptValidationError(failure22, stepId) {
|
|
473083
473290
|
const details = failure22.details;
|
|
473084
|
-
|
|
473291
|
+
const context = isRecord7(details) ? details : {};
|
|
473292
|
+
const error49 = new DocumentApiValidationError2(failure22.code, failure22.message, stepId ? { ...context, stepId } : Object.keys(context).length ? context : undefined);
|
|
473293
|
+
return stepId ? Object.assign(error49, { stepId }) : error49;
|
|
473085
473294
|
}
|
|
473086
473295
|
async function applyPlan(context, input) {
|
|
473087
473296
|
const startedAt = performance.now();
|
|
@@ -473092,7 +473301,7 @@ async function applyPlan(context, input) {
|
|
|
473092
473301
|
validateAttributedTextPlan(context, input, compiled);
|
|
473093
473302
|
if (compiled.failures.length > 0) {
|
|
473094
473303
|
const first = compiled.failures[0];
|
|
473095
|
-
throw
|
|
473304
|
+
throw receiptValidationError(first, first.stepId);
|
|
473096
473305
|
}
|
|
473097
473306
|
const beforeRevision = compiled.evaluatedRevision;
|
|
473098
473307
|
const mutatingSteps = compiled.steps.filter((step3) => step3.op !== "assert");
|
|
@@ -473124,7 +473333,7 @@ async function applyPlan(context, input) {
|
|
|
473124
473333
|
});
|
|
473125
473334
|
const receipt4 = committedReceipt;
|
|
473126
473335
|
if (!receipt4.success) {
|
|
473127
|
-
throw receiptValidationError(receipt4.failure);
|
|
473336
|
+
throw receiptValidationError(receipt4.failure, mutatingSteps.length === 1 ? mutatingSteps[0]?.stepId : undefined);
|
|
473128
473337
|
}
|
|
473129
473338
|
const programTrackedChanges = readTrackedChangeRefs3(receipt4);
|
|
473130
473339
|
appendUniqueTrackedChangeRefs(trackedChanges, programTrackedChanges);
|
|
@@ -473162,7 +473371,11 @@ async function applyPlan(context, input) {
|
|
|
473162
473371
|
});
|
|
473163
473372
|
const receipt4 = committedReceipt;
|
|
473164
473373
|
if (!receipt4.success) {
|
|
473165
|
-
|
|
473374
|
+
if (fresh.op === "format.apply" && receipt4.failure.code === "NO_OP" && compiled.steps.length > 1) {
|
|
473375
|
+
outcomes.push(buildStepOutcome(fresh, "noop"));
|
|
473376
|
+
continue;
|
|
473377
|
+
}
|
|
473378
|
+
throw receiptValidationError(receipt4.failure, fresh.stepId);
|
|
473166
473379
|
}
|
|
473167
473380
|
const stepTrackedChanges = readTrackedChangeRefs3(receipt4);
|
|
473168
473381
|
const stepTrackedChangeCount = readTrackedChangeCount(receipt4);
|
|
@@ -477365,12 +477578,12 @@ function buildNoteBodyXmlFromFragment(body2, noteType, referenceStyleId, textSty
|
|
|
477365
477578
|
function noteBodyHasReference(body2) {
|
|
477366
477579
|
const nodes = Array.isArray(body2) ? body2 : [body2];
|
|
477367
477580
|
return nodes.some((node4) => {
|
|
477368
|
-
const record3 =
|
|
477581
|
+
const record3 = asRecord7(node4);
|
|
477369
477582
|
if (record3?.kind !== "paragraph" && record3?.kind !== "heading")
|
|
477370
477583
|
return false;
|
|
477371
|
-
const payload =
|
|
477584
|
+
const payload = asRecord7(record3[record3.kind]);
|
|
477372
477585
|
return Array.isArray(payload?.inlines) && payload.inlines.some((inline) => {
|
|
477373
|
-
const kind =
|
|
477586
|
+
const kind = asRecord7(inline)?.kind;
|
|
477374
477587
|
return kind === "footnoteRef" || kind === "endnoteRef";
|
|
477375
477588
|
});
|
|
477376
477589
|
});
|
|
@@ -477380,24 +477593,24 @@ function noteBodyNeedsTextStyle(body2) {
|
|
|
477380
477593
|
return true;
|
|
477381
477594
|
const nodes = Array.isArray(body2) ? body2 : [body2];
|
|
477382
477595
|
return nodes.some((node4) => {
|
|
477383
|
-
const record3 =
|
|
477596
|
+
const record3 = asRecord7(node4);
|
|
477384
477597
|
if (record3?.kind !== "paragraph" && record3?.kind !== "heading")
|
|
477385
477598
|
return false;
|
|
477386
|
-
const payload =
|
|
477599
|
+
const payload = asRecord7(record3[record3.kind]);
|
|
477387
477600
|
return typeof payload?.styleRef !== "string" || payload.styleRef.length === 0;
|
|
477388
477601
|
});
|
|
477389
477602
|
}
|
|
477390
477603
|
function encodeContentNode(node4, noteType, referenceStyleId, textStyleId) {
|
|
477391
|
-
const record3 =
|
|
477604
|
+
const record3 = asRecord7(node4);
|
|
477392
477605
|
if (!record3) {
|
|
477393
477606
|
throw new NoteBodyEncodeError("note body: content nodes must be objects.");
|
|
477394
477607
|
}
|
|
477395
477608
|
const kind = record3?.kind;
|
|
477396
477609
|
if (kind === "paragraph" || kind === "heading") {
|
|
477397
477610
|
const payloadSource = record3[kind === "heading" ? "heading" : "paragraph"];
|
|
477398
|
-
const payload =
|
|
477611
|
+
const payload = asRecord7(payloadSource) ?? {};
|
|
477399
477612
|
const styleRef = typeof payload.styleRef === "string" && payload.styleRef.length > 0 ? payload.styleRef : textStyleId;
|
|
477400
|
-
const props =
|
|
477613
|
+
const props = asRecord7(payload.props);
|
|
477401
477614
|
const markRunProps = props?.markRunProps;
|
|
477402
477615
|
const inlines = Array.isArray(payload.inlines) ? payload.inlines : [];
|
|
477403
477616
|
return encodeParagraph({ styleRef, markRunProps, inlines, noteType, referenceStyleId });
|
|
@@ -477421,15 +477634,15 @@ function encodeParagraphProperties(styleRef, markRunProps) {
|
|
|
477421
477634
|
return children3.length > 0 ? renderElement("w:pPr", children3.join("")) : "";
|
|
477422
477635
|
}
|
|
477423
477636
|
function encodeInline(inline, noteType, paragraphMarkRunProps, referenceStyleId) {
|
|
477424
|
-
const record3 =
|
|
477637
|
+
const record3 = asRecord7(inline);
|
|
477425
477638
|
const kind = record3?.kind;
|
|
477426
477639
|
switch (kind) {
|
|
477427
477640
|
case "run":
|
|
477428
|
-
return encodeRun2(
|
|
477641
|
+
return encodeRun2(asRecord7(record3?.run) ?? {});
|
|
477429
477642
|
case "tab":
|
|
477430
477643
|
return wrapInRun(renderEmptyElement("w:tab"));
|
|
477431
477644
|
case "lineBreak":
|
|
477432
|
-
return encodeLineBreak(
|
|
477645
|
+
return encodeLineBreak(asRecord7(record3?.lineBreak));
|
|
477433
477646
|
case "footnoteRef":
|
|
477434
477647
|
case "endnoteRef":
|
|
477435
477648
|
return encodeNoteRef(noteType, paragraphMarkRunProps, referenceStyleId);
|
|
@@ -477649,7 +477862,7 @@ function xmlEscapeText2(value3) {
|
|
|
477649
477862
|
function xmlEscapeAttr2(value3) {
|
|
477650
477863
|
return xmlEscapeText2(value3).replace(/"/g, """);
|
|
477651
477864
|
}
|
|
477652
|
-
function
|
|
477865
|
+
function asRecord7(value3) {
|
|
477653
477866
|
return value3 && typeof value3 === "object" ? value3 : undefined;
|
|
477654
477867
|
}
|
|
477655
477868
|
function isFiniteNumber2(value3) {
|
|
@@ -479542,12 +479755,14 @@ function failureFromParse(parse7) {
|
|
|
479542
479755
|
};
|
|
479543
479756
|
}
|
|
479544
479757
|
function failure26(code2, message, unsupportedReason, diagnostics = unsupportedReason ? [diagnostic(unsupportedReason, message)] : []) {
|
|
479758
|
+
const rejection = textRangeRejectionDetails(message).details;
|
|
479759
|
+
const unsupported4 = unsupportedReason || diagnostics.length > 0 ? { unsupportedReason, diagnostics } : undefined;
|
|
479545
479760
|
return {
|
|
479546
479761
|
success: false,
|
|
479547
479762
|
failure: {
|
|
479548
479763
|
code: code2,
|
|
479549
479764
|
message,
|
|
479550
|
-
...
|
|
479765
|
+
...rejection || unsupported4 ? { details: { ...rejection, ...unsupported4 } } : {}
|
|
479551
479766
|
}
|
|
479552
479767
|
};
|
|
479553
479768
|
}
|
|
@@ -483186,7 +483401,8 @@ function mergeNumberingDefinitions(currentXml3, sourceXml) {
|
|
|
483186
483401
|
const reconciled = reconcileAdoptedFragmentNamespaces(currentXml3, sourceXml, additions);
|
|
483187
483402
|
if ("error" in reconciled)
|
|
483188
483403
|
return reconciled;
|
|
483189
|
-
const
|
|
483404
|
+
const root = findRootStartTag(reconciled.xml);
|
|
483405
|
+
const rootXml = root?.selfClosing ? `${reconciled.xml.slice(0, root.end - 2)}></${root.name}>${reconciled.xml.slice(root.end)}` : reconciled.xml;
|
|
483190
483406
|
const rootClose = /<\/(?:[\w.-]+:)?[\w.-]+>\s*$/.exec(rootXml);
|
|
483191
483407
|
if (!rootClose) {
|
|
483192
483408
|
return { xml: currentXml3, changed: false, idMappings };
|
|
@@ -512042,6 +512258,53 @@ var init_legacy_furniture_source = __esm(() => {
|
|
|
512042
512258
|
CACHE = new WeakMap;
|
|
512043
512259
|
});
|
|
512044
512260
|
|
|
512261
|
+
// ../../../v2/collaboration-v2/dist/story-shard/comment-marker-removal.js
|
|
512262
|
+
function storyMeta2(marker) {
|
|
512263
|
+
let node4 = marker;
|
|
512264
|
+
while (node4 instanceof YMap || node4 instanceof YArray) {
|
|
512265
|
+
if (node4 !== marker && node4 instanceof YMap) {
|
|
512266
|
+
const meta3 = node4.get(STORY_SHARD_ROOT.meta);
|
|
512267
|
+
if (meta3 instanceof YMap)
|
|
512268
|
+
return meta3;
|
|
512269
|
+
}
|
|
512270
|
+
if (!node4.parent)
|
|
512271
|
+
return node4.doc ? node4.doc.getMap(STORY_SHARD_ROOT.meta) : null;
|
|
512272
|
+
node4 = node4.parent;
|
|
512273
|
+
}
|
|
512274
|
+
return null;
|
|
512275
|
+
}
|
|
512276
|
+
function removalContext(marker) {
|
|
512277
|
+
const origin = marker.get("sdtCommentOrigin");
|
|
512278
|
+
const meta3 = typeof origin === "string" ? storyMeta2(marker) : null;
|
|
512279
|
+
return typeof origin === "string" && meta3 ? { meta: meta3, prefix: `${REMOVAL_PREFIX}${encodeURIComponent(origin)}:` } : null;
|
|
512280
|
+
}
|
|
512281
|
+
function removedSdtCommentMarkerOrigin(key3) {
|
|
512282
|
+
if (typeof key3 !== "string" || !key3.startsWith(REMOVAL_PREFIX))
|
|
512283
|
+
return null;
|
|
512284
|
+
const end = key3.lastIndexOf(":");
|
|
512285
|
+
if (end < REMOVAL_PREFIX.length)
|
|
512286
|
+
return null;
|
|
512287
|
+
try {
|
|
512288
|
+
return decodeURIComponent(key3.slice(REMOVAL_PREFIX.length, end));
|
|
512289
|
+
} catch {
|
|
512290
|
+
return null;
|
|
512291
|
+
}
|
|
512292
|
+
}
|
|
512293
|
+
function sdtCommentMarkerRemoved(marker) {
|
|
512294
|
+
const context = removalContext(marker);
|
|
512295
|
+
if (!context)
|
|
512296
|
+
return false;
|
|
512297
|
+
for (const key3 of context.meta.keys())
|
|
512298
|
+
if (key3.startsWith(context.prefix) && context.meta.get(key3) === true)
|
|
512299
|
+
return true;
|
|
512300
|
+
return false;
|
|
512301
|
+
}
|
|
512302
|
+
var REMOVAL_PREFIX = "sdtCommentMarkerRemoved:";
|
|
512303
|
+
var init_comment_marker_removal = __esm(() => {
|
|
512304
|
+
init_yjs();
|
|
512305
|
+
init_constants4();
|
|
512306
|
+
});
|
|
512307
|
+
|
|
512045
512308
|
// ../../../v2/collaboration-v2/dist/story-shard/inline-control-position.js
|
|
512046
512309
|
function ownerText2(atom) {
|
|
512047
512310
|
const array3 = atom.parent;
|
|
@@ -512277,12 +512540,34 @@ function versionTypes(doc2) {
|
|
|
512277
512540
|
return;
|
|
512278
512541
|
VERSIONED_DOCS.add(doc2);
|
|
512279
512542
|
doc2.on("beforeObserverCalls", (transaction) => {
|
|
512280
|
-
for (const changed of transaction.changed
|
|
512543
|
+
for (const [changed, keys3] of transaction.changed) {
|
|
512281
512544
|
let parent = changed;
|
|
512282
512545
|
while (parent instanceof AbstractType) {
|
|
512283
512546
|
TYPE_VERSIONS.set(parent, ++typeVersion);
|
|
512284
512547
|
parent = parent._item?.parent;
|
|
512285
512548
|
}
|
|
512549
|
+
if (!(changed instanceof YMap))
|
|
512550
|
+
continue;
|
|
512551
|
+
let origins2 = null;
|
|
512552
|
+
for (const key3 of keys3) {
|
|
512553
|
+
const origin = removedSdtCommentMarkerOrigin(key3);
|
|
512554
|
+
if (origin !== null)
|
|
512555
|
+
(origins2 ?? (origins2 = new Set)).add(origin);
|
|
512556
|
+
}
|
|
512557
|
+
if (!origins2)
|
|
512558
|
+
continue;
|
|
512559
|
+
const removed = origins2;
|
|
512560
|
+
const holder = changed.parent;
|
|
512561
|
+
const blocks = holder instanceof YMap ? holder.get(STORY_SHARD_ROOT.blocks) : doc2.getArray(STORY_SHARD_ROOT.blocks);
|
|
512562
|
+
if (!(blocks instanceof YArray))
|
|
512563
|
+
continue;
|
|
512564
|
+
for (const block of blocks.toArray()) {
|
|
512565
|
+
if (!(block instanceof YMap))
|
|
512566
|
+
continue;
|
|
512567
|
+
const atoms = block.get(BLOCK_KEY.atoms), anchors = block.get(BLOCK_KEY.anchors);
|
|
512568
|
+
if ([atoms, anchors].some((array3) => array3 instanceof YArray && array3.toArray().some((marker) => marker instanceof YMap && removed.has(String(marker.get("sdtCommentOrigin"))))))
|
|
512569
|
+
TYPE_VERSIONS.set(block, ++typeVersion);
|
|
512570
|
+
}
|
|
512286
512571
|
}
|
|
512287
512572
|
});
|
|
512288
512573
|
}
|
|
@@ -512336,11 +512621,14 @@ function readBlockSnapshot(blockMap) {
|
|
|
512336
512621
|
}
|
|
512337
512622
|
const atoms = [];
|
|
512338
512623
|
getBlockAtoms(blockMap).forEach((atomMap) => {
|
|
512339
|
-
if (!controlMarkerRemoved(atomMap))
|
|
512624
|
+
if (!controlMarkerRemoved(atomMap) && !sdtCommentMarkerRemoved(atomMap))
|
|
512340
512625
|
atoms.push(readAtom(atomMap));
|
|
512341
512626
|
});
|
|
512342
512627
|
const anchors = [];
|
|
512343
|
-
getBlockAnchors(blockMap).forEach((anchorMap) =>
|
|
512628
|
+
getBlockAnchors(blockMap).forEach((anchorMap) => {
|
|
512629
|
+
if (!sdtCommentMarkerRemoved(anchorMap))
|
|
512630
|
+
anchors.push(readAnchor(anchorMap));
|
|
512631
|
+
});
|
|
512344
512632
|
const diagnostics = [];
|
|
512345
512633
|
getBlockDiagnostics(blockMap).forEach((diagMap) => {
|
|
512346
512634
|
diagnostics.push({
|
|
@@ -512647,6 +512935,7 @@ var init_read_view = __esm(() => {
|
|
|
512647
512935
|
init_schema4();
|
|
512648
512936
|
init_scope3();
|
|
512649
512937
|
init_content_control_groups();
|
|
512938
|
+
init_comment_marker_removal();
|
|
512650
512939
|
init_inline_control_position();
|
|
512651
512940
|
init_drawing_run_attributes();
|
|
512652
512941
|
TYPE_VERSIONS = new WeakMap;
|
|
@@ -540751,7 +541040,7 @@ function collectLiveTrackedTextSpansInBlock(block, rsid, trackedKind) {
|
|
|
540751
541040
|
const blockId = String(block.get(BLOCK_KEY.blockId) ?? "");
|
|
540752
541041
|
const atoms = [];
|
|
540753
541042
|
getBlockAtoms(block).forEach((atom, index2) => {
|
|
540754
|
-
const meta3 =
|
|
541043
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
540755
541044
|
const id2 = String(atom.get(ATOM_KEY.id) ?? "");
|
|
540756
541045
|
const offset = Number(atom.get(ATOM_KEY.visibleOffset) ?? 0);
|
|
540757
541046
|
if (!id2 || !Number.isFinite(offset))
|
|
@@ -540834,7 +541123,7 @@ function rangeAnchorIdentityForAtom(atom) {
|
|
|
540834
541123
|
const atomKind = atom.get(ATOM_KEY.kind);
|
|
540835
541124
|
if (atomKind !== INLINE_ATOM_KIND.commentMarker && atomKind !== INLINE_ATOM_KIND.bookmark)
|
|
540836
541125
|
return null;
|
|
540837
|
-
const marker = String(
|
|
541126
|
+
const marker = String(asRecord8(atom.get(ATOM_KEY.meta)).marker ?? "");
|
|
540838
541127
|
const boundary = marker.endsWith("End") ? "end" : marker.endsWith("Start") ? "start" : "point";
|
|
540839
541128
|
return { kind: atomKind === INLINE_ATOM_KIND.commentMarker ? "comment" : "bookmark", boundary };
|
|
540840
541129
|
}
|
|
@@ -540859,7 +541148,7 @@ function collectCommentCarriers(doc2, commentIds, session) {
|
|
|
540859
541148
|
const anchors2 = new Set;
|
|
540860
541149
|
const bindings2 = bindingsByBlock.get(String(block.get(BLOCK_KEY.blockId) ?? "")) ?? {};
|
|
540861
541150
|
for (const atom of getBlockAtoms(block).toArray()) {
|
|
540862
|
-
const meta3 =
|
|
541151
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
540863
541152
|
const marker = String(meta3.marker ?? meta3.tag ?? "");
|
|
540864
541153
|
if (!["commentRangeStart", "commentRangeEnd", "commentReference"].includes(marker))
|
|
540865
541154
|
continue;
|
|
@@ -540952,7 +541241,7 @@ function getTrackedDecisionLedger(doc2, create10) {
|
|
|
540952
541241
|
meta3.set(TRACKED_CHANGE_DECISIONS_LEDGER_KEY, ledger);
|
|
540953
541242
|
return ledger;
|
|
540954
541243
|
}
|
|
540955
|
-
function
|
|
541244
|
+
function asRecord8(value3) {
|
|
540956
541245
|
return value3 && typeof value3 === "object" ? value3 : {};
|
|
540957
541246
|
}
|
|
540958
541247
|
function admitPreparedStorySurfaceMutation(prepared, options) {
|
|
@@ -541501,7 +541790,7 @@ function trackedDecisionRequiresMergedCarrierSync(prepared, extension2, options)
|
|
|
541501
541790
|
continue;
|
|
541502
541791
|
if (chain.length < 2 || chain.some(({ block }) => collectLiveTrackedTextSpansInBlock(block, target.rsid, target.trackedKind).length > 0))
|
|
541503
541792
|
return false;
|
|
541504
|
-
const wrappers = chain.flatMap(({ block }) => getBlockAtoms(block).toArray().filter((atom) => atom.get(ATOM_KEY.kind) === INLINE_ATOM_KIND.trackedWrapper).map((atom) =>
|
|
541793
|
+
const wrappers = chain.flatMap(({ block }) => getBlockAtoms(block).toArray().filter((atom) => atom.get(ATOM_KEY.kind) === INLINE_ATOM_KIND.trackedWrapper).map((atom) => asRecord8(atom.get(ATOM_KEY.meta))).filter((meta3) => meta3.wrapper === target.trackedKind && String(meta3.rsid ?? "") === target.rsid));
|
|
541505
541794
|
const starts = wrappers.filter((meta3) => meta3.position === "start");
|
|
541506
541795
|
const ends = wrappers.filter((meta3) => meta3.position === "end");
|
|
541507
541796
|
if (starts.length !== 1 || ends.length !== 1 || starts[0].wId !== ends[0].wId || wrappers.indexOf(starts[0]) >= wrappers.indexOf(ends[0]))
|
|
@@ -541696,7 +541985,7 @@ function removeEmptyRunFilledByInsert(block, offset, attributes) {
|
|
|
541696
541985
|
const atoms = getBlockAtoms(block);
|
|
541697
541986
|
const atStart = atoms.toArray().flatMap((atom, index2) => Number(atom.get(ATOM_KEY.visibleOffset) ?? -1) === 0 ? [{ atom, index: index2 }] : []);
|
|
541698
541987
|
const emptyRunXml = (atom) => String(atom.get(ATOM_KEY.xml) ?? "");
|
|
541699
|
-
if (atStart.some(({ atom }) => atom.get(ATOM_KEY.kind) !== INLINE_ATOM_KIND.preserved ||
|
|
541988
|
+
if (atStart.some(({ atom }) => atom.get(ATOM_KEY.kind) !== INLINE_ATOM_KIND.preserved || asRecord8(atom.get(ATOM_KEY.meta)).tag !== "r"))
|
|
541700
541989
|
return;
|
|
541701
541990
|
const filled = atStart.find(({ atom }) => RUN_TEXT_PATTERN.test(emptyRunXml(atom).replace(RUN_PROPERTIES_PATTERN, "")));
|
|
541702
541991
|
if (!filled)
|
|
@@ -541753,7 +542042,7 @@ function findInnermostTrackedWrapper(atoms, offset) {
|
|
|
541753
542042
|
return enclosing[0] ?? null;
|
|
541754
542043
|
}
|
|
541755
542044
|
function trackedInsertionPosition(atom) {
|
|
541756
|
-
const meta3 =
|
|
542045
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
541757
542046
|
if (meta3.wrapper !== "ins" && !/^<\/?[\w.-]+:ins\b/.test(String(atom.get(ATOM_KEY.xml) ?? ""))) {
|
|
541758
542047
|
return null;
|
|
541759
542048
|
}
|
|
@@ -542334,7 +542623,7 @@ function mirrorTrackedTextEdit(input) {
|
|
|
542334
542623
|
let survivingRightBoundaryOffset = Number.POSITIVE_INFINITY;
|
|
542335
542624
|
atoms.forEach((atom) => {
|
|
542336
542625
|
const offset = Number(atom.get(ATOM_KEY.visibleOffset) ?? -1);
|
|
542337
|
-
const meta3 =
|
|
542626
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
542338
542627
|
if (hasReplacementText && offset === input.offset && Number(atom.get(ATOM_KEY.length) ?? 0) === 0) {
|
|
542339
542628
|
leftBoundaryAtoms.push(atom);
|
|
542340
542629
|
}
|
|
@@ -542521,7 +542810,7 @@ function writeCommentAnchorMarkers(input) {
|
|
|
542521
542810
|
if (alreadyMirrored)
|
|
542522
542811
|
return;
|
|
542523
542812
|
const endBeforeDeletionIndex = input.endBeforeDeletedContent ? atoms.toArray().findIndex((atom) => {
|
|
542524
|
-
const meta3 =
|
|
542813
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
542525
542814
|
return atom.get(ATOM_KEY.kind) === INLINE_ATOM_KIND.trackedWrapper && Number(atom.get(ATOM_KEY.visibleOffset)) === input.endOffset && (meta3.wrapper === "del" || meta3.wrapper === "moveFrom") && meta3.position === "start";
|
|
542526
542815
|
}) : -1;
|
|
542527
542816
|
const scope = resolveStoryShardScope(input.doc);
|
|
@@ -542677,7 +542966,7 @@ function locateTrackedDeletionCarrier(block, anchor, expectedLength) {
|
|
|
542677
542966
|
const start = atoms.get(startIndex);
|
|
542678
542967
|
if (!(start instanceof YMap))
|
|
542679
542968
|
return [];
|
|
542680
|
-
const meta3 =
|
|
542969
|
+
const meta3 = asRecord8(start.get(ATOM_KEY.meta));
|
|
542681
542970
|
return String(meta3.wId ?? "") === anchor.carrier.wId ? [{ startIndex, endIndex }] : [];
|
|
542682
542971
|
});
|
|
542683
542972
|
if (resolved.length !== 1) {
|
|
@@ -542755,7 +543044,7 @@ function locateTrackedInsertionCarrier(block, anchor) {
|
|
|
542755
543044
|
const start = atoms.get(startIndex);
|
|
542756
543045
|
if (!(start instanceof YMap))
|
|
542757
543046
|
return [];
|
|
542758
|
-
const meta3 =
|
|
543047
|
+
const meta3 = asRecord8(start.get(ATOM_KEY.meta));
|
|
542759
543048
|
return String(meta3.wId ?? "") === anchor.carrier.wId ? [{ startIndex, endIndex }] : [];
|
|
542760
543049
|
});
|
|
542761
543050
|
if (resolved.length !== 1) {
|
|
@@ -542852,7 +543141,7 @@ function findUnsafeAtomRejectionReason(block, startOffset2, endOffset2, extensio
|
|
|
542852
543141
|
const length3 = Number(atom.get(ATOM_KEY.length) ?? 0);
|
|
542853
543142
|
if (!atomOverlapsRange(at, length3, startOffset2, endOffset2))
|
|
542854
543143
|
return;
|
|
542855
|
-
const meta3 =
|
|
543144
|
+
const meta3 = asRecord8(atom.get(ATOM_KEY.meta));
|
|
542856
543145
|
const isDeletedTextCarrier = kind === INLINE_ATOM_KIND.preserved && meta3.tag === "delTextRun";
|
|
542857
543146
|
const attributedBreakXml = typeof meta3.sourceXml === "string" ? meta3.sourceXml : "";
|
|
542858
543147
|
const isAttributedBreakCarrier = kind === INLINE_ATOM_KIND.preserved && length3 === 1 && meta3.tag === "br" && meta3.container === "run-child" && /^<(?:[\w.-]+:)?br\b/.test(attributedBreakXml) && getBlockText(block).toString()[at] === `
|
|
@@ -549123,10 +549412,10 @@ function createHeadlessCollabRoomCoordinator(options) {
|
|
|
549123
549412
|
continue;
|
|
549124
549413
|
const part = parts.get(descriptor.story.sourcePartKey);
|
|
549125
549414
|
const scope = getUnitScope(options.rootDoc, descriptor.shardId);
|
|
549126
|
-
const
|
|
549127
|
-
if (!part || !scope || !(
|
|
549415
|
+
const storyMeta3 = scope?.get(STORY_SHARD_ROOT.meta);
|
|
549416
|
+
if (!part || !scope || !(storyMeta3 instanceof YMap))
|
|
549128
549417
|
throw new Error("replacement story is incomplete");
|
|
549129
|
-
const storyId =
|
|
549418
|
+
const storyId = storyMeta3.get(STORY_META_KEY.storyId);
|
|
549130
549419
|
const storyKind = descriptor.story.kind;
|
|
549131
549420
|
active2.add(descriptor.shardId);
|
|
549132
549421
|
const handle = options.graph.storyHandles.get(descriptor.shardId) ?? {
|