@superdoc/mcp 1.7.0-next.3 → 1.7.0-next.5

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.
Files changed (2) hide show
  1. package/dist/index.js +178 -39
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31600,7 +31600,7 @@ var init_host = __esm(() => {
31600
31600
  });
31601
31601
 
31602
31602
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31603
- var SDK_VERSION = "2.20.0-next.3";
31603
+ var SDK_VERSION = "2.20.0-next.5";
31604
31604
 
31605
31605
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31606
31606
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -166262,9 +166262,11 @@ function extractNamespaceClosedParagraphMarkRunPropertiesFromParagraph(paragraph
166262
166262
  return null;
166263
166263
  }
166264
166264
  const paragraphNode = readValidatedXmlNodeAt(paragraphXml, 0);
166265
- if (!paragraphNode || paragraphNode.kind !== "element" || paragraphNode.selfClosing || xmlLocalName(paragraphNode.qname) !== "p" || paragraphXml.slice(paragraphNode.end).trim().length > 0) {
166265
+ if (!paragraphNode || paragraphNode.kind !== "element" || xmlLocalName(paragraphNode.qname) !== "p" || paragraphXml.slice(paragraphNode.end).trim().length > 0) {
166266
166266
  return null;
166267
166267
  }
166268
+ if (paragraphNode.selfClosing)
166269
+ return "";
166268
166270
  const paragraphOpenTag = paragraphXml.slice(0, paragraphNode.openEnd);
166269
166271
  const inner = paragraphXml.slice(paragraphNode.openEnd, paragraphNode.closeStart);
166270
166272
  const { pPr } = splitLeadingParagraphPropertyBlock(inner);
@@ -166389,9 +166391,11 @@ function markupCompatibilityValuePrefixes(openTag, namespaceByPrefix) {
166389
166391
  }
166390
166392
  function paragraphMarkRunPropertyNamespacesAreSupported(paragraphXml, inheritedNamespaceBindings = {}) {
166391
166393
  const paragraphNode = readValidatedXmlNodeAt(paragraphXml, 0);
166392
- if (!paragraphNode || paragraphNode.kind !== "element" || paragraphNode.selfClosing || xmlLocalName(paragraphNode.qname) !== "p" || paragraphXml.slice(paragraphNode.end).trim().length > 0) {
166394
+ if (!paragraphNode || paragraphNode.kind !== "element" || xmlLocalName(paragraphNode.qname) !== "p" || paragraphXml.slice(paragraphNode.end).trim().length > 0) {
166393
166395
  return false;
166394
166396
  }
166397
+ if (paragraphNode.selfClosing)
166398
+ return true;
166395
166399
  const inner = paragraphXml.slice(paragraphNode.openEnd, paragraphNode.closeStart);
166396
166400
  const { pPr } = splitLeadingParagraphPropertyBlock(inner);
166397
166401
  if (!pPr)
@@ -166989,7 +166993,7 @@ function planDirectInlineEdit(paragraphBytes, startOffset, endOffset, newText, c
166989
166993
  return { ok: false, reason: "text-range-in-sdt" };
166990
166994
  }
166991
166995
  }
166992
- const adjacent = collapsedObjectBoundary.edge === "before" ? lastVisibleTextEndingAt(model.pieces, startOffset) : firstVisibleTextStartingAt(model.pieces, startOffset);
166996
+ const adjacent = visibleTextBesideObjectAt(model.pieces, startOffset, collapsedObjectBoundary);
166993
166997
  return {
166994
166998
  ok: true,
166995
166999
  bytes: spliceBytes(paragraphBytes, [{ start: insertByte, end: insertByte, bytes: encodeRun(adjacent, newText, "") }]),
@@ -167478,9 +167482,7 @@ function planCollapsedInsert(paragraphBytes, xml, pieces, leaves, at, newText, t
167478
167482
  runPropertiesXml: carrier?.runProperties ?? paragraphMarkRPr
167479
167483
  };
167480
167484
  }
167481
- function planCollapsedInsertBesideContainer(paragraphBytes, xml, pieces, at, newText, collapsedInlineAffinity) {
167482
- if (newText.length === 0)
167483
- return null;
167485
+ function collapsedOutsideContainerAt(pieces, at, collapsedInlineAffinity) {
167484
167486
  for (const piece of pieces) {
167485
167487
  if (piece.kind !== "container")
167486
167488
  continue;
@@ -167495,31 +167497,41 @@ function planCollapsedInsertBesideContainer(paragraphBytes, xml, pieces, at, new
167495
167497
  const trailing = isSdt ? piece.visibleEnd === at && collapsedInlineAffinity === "downstream" : atTrailing;
167496
167498
  if (!leading && !trailing)
167497
167499
  continue;
167498
- const blocked = findBlockingPiece(pieces, at, at);
167499
- if (blocked)
167500
- return { ok: false, reason: blocked };
167501
- const markersAtPoint = pieces.filter((candidate) => candidate.kind === "marker" && candidate.visibleStart === at && !isFieldMarker(candidate.markerKind));
167502
- const leadingRangeStarts = markersAtPoint.filter((marker) => marker.role === "range-start");
167503
- const trailingRangeEnds = markersAtPoint.filter((marker) => marker.role === "range-end" || marker.role === "reference");
167504
- const paragraphMarkRPr = extractParagraphMarkRunPropertiesFromParagraph(xml) ?? "";
167505
- const freshRunQnames = paragraphRunQnames(xml);
167506
- if (!freshRunQnames)
167507
- return { ok: false, reason: "invalid-range" };
167508
- const insertByte = leading ? Math.min(piece.byteStart, ...leadingRangeStarts.map((marker) => marker.runByteStart ?? marker.byteStart)) : Math.max(piece.byteEnd, ...trailingRangeEnds.map((marker) => marker.runByteEnd ?? marker.byteEnd));
167509
- const op = {
167510
- start: insertByte,
167511
- end: insertByte,
167512
- bytes: encodeRun(null, newText, paragraphMarkRPr, freshRunQnames)
167513
- };
167514
- return {
167515
- ok: true,
167516
- bytes: spliceBytes(paragraphBytes, [op]),
167517
- runPropertiesXml: paragraphMarkRPr,
167518
- ...isSdt ? { requiresCollaborationSessionSync: true } : {}
167519
- };
167500
+ return { piece, leading, trailing };
167520
167501
  }
167521
167502
  return null;
167522
167503
  }
167504
+ function planCollapsedInsertBesideContainer(paragraphBytes, xml, pieces, at, newText, collapsedInlineAffinity) {
167505
+ if (newText.length === 0)
167506
+ return null;
167507
+ const edge = collapsedOutsideContainerAt(pieces, at, collapsedInlineAffinity);
167508
+ if (!edge)
167509
+ return null;
167510
+ const { piece, leading } = edge;
167511
+ const isSdt = piece.containerKind === "sdt";
167512
+ const blocked = findBlockingPiece(pieces, at, at);
167513
+ if (blocked)
167514
+ return { ok: false, reason: blocked };
167515
+ const markersAtPoint = pieces.filter((candidate) => candidate.kind === "marker" && candidate.visibleStart === at && !isFieldMarker(candidate.markerKind));
167516
+ const leadingRangeStarts = markersAtPoint.filter((marker) => marker.role === "range-start");
167517
+ const trailingRangeEnds = markersAtPoint.filter((marker) => marker.role === "range-end" || marker.role === "reference");
167518
+ const paragraphMarkRPr = extractParagraphMarkRunPropertiesFromParagraph(xml) ?? "";
167519
+ const freshRunQnames = paragraphRunQnames(xml);
167520
+ if (!freshRunQnames)
167521
+ return { ok: false, reason: "invalid-range" };
167522
+ const insertByte = leading ? Math.min(piece.byteStart, ...leadingRangeStarts.map((marker) => marker.runByteStart ?? marker.byteStart)) : Math.max(piece.byteEnd, ...trailingRangeEnds.map((marker) => marker.runByteEnd ?? marker.byteEnd));
167523
+ const op = {
167524
+ start: insertByte,
167525
+ end: insertByte,
167526
+ bytes: encodeRun(null, newText, paragraphMarkRPr, freshRunQnames)
167527
+ };
167528
+ return {
167529
+ ok: true,
167530
+ bytes: spliceBytes(paragraphBytes, [op]),
167531
+ runPropertiesXml: paragraphMarkRPr,
167532
+ ...isSdt ? { requiresCollaborationSessionSync: true } : {}
167533
+ };
167534
+ }
167523
167535
  function findBlockingPiece(pieces, start, end) {
167524
167536
  const collapsed = start === end;
167525
167537
  for (const piece of pieces) {
@@ -168314,6 +168326,9 @@ function isLiveControl(piece) {
168314
168326
  function isLiveNoteReference(piece) {
168315
168327
  return piece.kind === "noteReference" && !piece.deleted;
168316
168328
  }
168329
+ function visibleTextBesideObjectAt(pieces, at, boundary) {
168330
+ return boundary.edge === "before" ? lastVisibleTextEndingAt(pieces, at) : firstVisibleTextStartingAt(pieces, at);
168331
+ }
168317
168332
  function lastVisibleTextEndingAt(pieces, at) {
168318
168333
  let found = null;
168319
168334
  for (const piece of pieces) {
@@ -194585,6 +194600,31 @@ function renderPasteTableCell(cell, renderParagraph = renderPasteParagraphBlock,
194585
194600
  const tcPr = `<w:tcPr><w:tcW w:w="0" w:type="auto"/>` + (gridSpan > 1 ? `<w:gridSpan w:val="${gridSpan}"/>` : "") + shading + tcMar + "</w:tcPr>";
194586
194601
  return `<w:tc>${tcPr}${cell.paragraphs.map((block) => ("rows" in block) ? renderTable(block) : renderParagraph(block)).join("")}</w:tc>`;
194587
194602
  }
194603
+ function renderPasteRunProperties(run, options) {
194604
+ const properties = run.runPropertiesXml;
194605
+ if (properties === undefined)
194606
+ return renderRunPropertiesXml(run.marks, options);
194607
+ if (!options.characterStyleId)
194608
+ return properties;
194609
+ if (!properties)
194610
+ return renderRunPropertiesXml(undefined, options);
194611
+ const parsed = collectXmlElementRanges(properties, { additionalNamespaces: { w: WORDPROCESSINGML_NAMESPACE3 } });
194612
+ const root = parsed.ranges.find((range) => range.start === 0 && range.end === properties.length);
194613
+ const node2 = readXmlNodeAt(properties, 0);
194614
+ if (parsed.errors.length || !root || root.tag.namespaceUri !== WORDPROCESSINGML_NAMESPACE3 || root.tag.localName !== "rPr" || node2?.kind !== "element")
194615
+ return properties;
194616
+ const prefix = root.tag.prefix || "sdw";
194617
+ const declaration = root.tag.prefix ? "" : ` xmlns:sdw="${WORDPROCESSINGML_NAMESPACE3}"`;
194618
+ const style = `<${prefix}:rStyle${declaration} ${prefix}:val="${escapeXmlAttribute(options.characterStyleId)}"/>`;
194619
+ if (node2.selfClosing)
194620
+ return properties.slice(0, node2.openEnd).replace(/\/\s*>$/, ">") + style + `</${node2.qname}>`;
194621
+ const styles = parsed.ranges.filter((range) => range.tag.namespaceUri === WORDPROCESSINGML_NAMESPACE3 && range.tag.localName === "rStyle" && !parsed.ranges.some((parent) => parent !== root && parent.start < range.start && parent.end >= range.end));
194622
+ let inner = properties.slice(root.openEnd, root.closeStart);
194623
+ for (const range of styles.sort((left, right) => right.start - left.start)) {
194624
+ inner = inner.slice(0, range.start - root.openEnd) + inner.slice(range.end - root.openEnd);
194625
+ }
194626
+ return properties.slice(0, root.openEnd) + style + inner + properties.slice(root.closeStart);
194627
+ }
194588
194628
  function renderPasteRun(run, options = {}) {
194589
194629
  if (run.kind === "sdt")
194590
194630
  return renderPasteSdt(run);
@@ -194598,11 +194638,11 @@ function renderPasteRun(run, options = {}) {
194598
194638
  return `<w:r><w:rPr><w:rStyle w:val="${style}"/></w:rPr><w:${local} w:id="${escapeXmlAttribute(run.noteId)}"/></w:r>`;
194599
194639
  }
194600
194640
  if (run.kind === "lineBreak") {
194601
- return `<w:r>${renderRunPropertiesXml(run.marks, options)}<w:br/></w:r>`;
194641
+ return `<w:r>${renderPasteRunProperties(run, options)}<w:br/></w:r>`;
194602
194642
  }
194603
194643
  if (!("text" in run))
194604
194644
  return "";
194605
- const rPr = renderRunPropertiesXml(run.marks, options);
194645
+ const rPr = renderPasteRunProperties(run, options);
194606
194646
  if (run.text.length === 0)
194607
194647
  return "";
194608
194648
  const segments = run.text.split("\t");
@@ -194818,6 +194858,7 @@ function collidesWithExistingParaId(state, candidate2) {
194818
194858
  }
194819
194859
  var WORDPROCESSINGML_NAMESPACE3 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", PASTE_TABLE_GRID_TWIPS = 9360, VML_NAMESPACE = "urn:schemas-microsoft-com:vml", OFFICE_NAMESPACE = "urn:schemas-microsoft-com:office:office";
194820
194860
  var init_paragraph_contribution = __esm(() => {
194861
+ init_xml_sax();
194821
194862
  init_xml_text();
194822
194863
  init_paragraph_para_id_attrs();
194823
194864
  init_highlight_ooxml();
@@ -217939,9 +217980,9 @@ function resolveDirectInsertionFormatting(paragraphXml, placement2, inheritedNam
217939
217980
  ...!paragraphPropertiesXml && !runPropertiesXml ? { skippedReason: "no-direct-formatting" } : {}
217940
217981
  };
217941
217982
  }
217942
- function cloneAdjacentRunPropertiesCarrierForInsertion(paragraphXml, placement2, inheritedNamespaceBindings = {}) {
217983
+ function cloneAdjacentRunPropertiesCarrierForInsertion(paragraphXml, placement2, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary) {
217943
217984
  const paragraphWithoutNestedTextboxes = stripElements(paragraphXml, "txbxContent");
217944
- const run = adjacentFormattingCarrierRun(paragraphWithoutNestedTextboxes, placement2, inheritedNamespaceBindings);
217985
+ const run = adjacentFormattingCarrierRun(paragraphWithoutNestedTextboxes, placement2, inheritedNamespaceBindings, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary);
217945
217986
  if (!run.ok)
217946
217987
  return run;
217947
217988
  if (!run.run)
@@ -218022,8 +218063,8 @@ function topLevelMarkRPrSpan(pPrXml) {
218022
218063
  return null;
218023
218064
  return { start: openOffset, end: openOffset + span.length };
218024
218065
  }
218025
- function cloneAdjacentRunPropertiesForInsert(paraXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings = {}) {
218026
- const carrierResult = cloneAdjacentRunPropertiesCarrierForInsertion(paraXml, placement2, inheritedNamespaceBindings);
218066
+ function cloneAdjacentRunPropertiesForInsert(paraXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary) {
218067
+ const carrierResult = cloneAdjacentRunPropertiesCarrierForInsertion(paraXml, placement2, inheritedNamespaceBindings, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary);
218027
218068
  if (!carrierResult.ok)
218028
218069
  return carrierResult;
218029
218070
  const carrier = carrierResult.carrier;
@@ -218047,13 +218088,29 @@ function cloneAdjacentRunPropertiesForInsert(paraXml, placement2, paragraphMarkR
218047
218088
  runPropertiesXml
218048
218089
  };
218049
218090
  }
218050
- function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespaceBindings = {}) {
218091
+ function resolveCaretRunPropertiesForInsertion(paragraphXml, charOffset, inheritedNamespaceBindings = {}, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary) {
218092
+ const model = parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings);
218093
+ if (!collapsedObjectBoundary && (replaceToOffset ?? charOffset) === charOffset && collapsedOutsideContainerAt(model.pieces, charOffset, collapsedInlineAffinity)) {
218094
+ const runPropertiesXml = extractNamespaceClosedParagraphMarkRunPropertiesFromParagraph(paragraphXml, inheritedNamespaceBindings);
218095
+ return runPropertiesXml === null ? { ok: false, reason: "unsupported-context" } : { ok: true, runPropertiesXml };
218096
+ }
218097
+ let paragraphMarkRunPropertiesXml = null;
218098
+ if (!collapsedObjectBoundary && model.visibleLength === 0) {
218099
+ paragraphMarkRunPropertiesXml = extractNamespaceClosedParagraphMarkRunPropertiesFromParagraph(paragraphXml, inheritedNamespaceBindings);
218100
+ if (paragraphMarkRunPropertiesXml === null)
218101
+ return { ok: false, reason: "unsupported-context" };
218102
+ }
218103
+ return cloneAdjacentRunPropertiesForInsert(paragraphXml, "before", paragraphMarkRunPropertiesXml, inheritedNamespaceBindings, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary);
218104
+ }
218105
+ function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary) {
218051
218106
  const paragraphPrefix = /^<(?:(?<prefix>[\w.-]+):)?p\b/.exec(paragraphXml)?.groups?.prefix ?? "";
218052
218107
  const additionalNamespaces = xmlFragmentAdditionalNamespaces(paragraphXml, new Map(Object.entries(inheritedNamespaceBindings)), { w: NS_W, [paragraphPrefix]: NS_W });
218053
218108
  const parsed = collectXmlElementRanges(paragraphXml, { additionalNamespaces });
218054
218109
  if (parsed.errors.length > 0)
218055
218110
  return { ok: true, run: undefined };
218056
- const carrier = adjacentFormattingCarrierPiece(parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces, placement2);
218111
+ const pieces = parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces;
218112
+ const downstream = charOffset !== undefined && (replaceToOffset ?? charOffset) === charOffset && collapsedInlineAffinity === "downstream" ? findDownstreamVisibleCarrierAfterHiddenRun(paragraphXml, pieces, charOffset, inheritedNamespaceBindings) : null;
218113
+ const carrier = collapsedObjectBoundary && charOffset !== undefined ? { ok: true, piece: visibleTextBesideObjectAt(pieces, charOffset, collapsedObjectBoundary) ?? undefined } : downstream ? { ok: true, piece: downstream } : charOffset === undefined ? adjacentFormattingCarrierPiece(pieces, placement2) : formattingCarrierPieceAtOffset(pieces, charOffset, replaceToOffset);
218057
218114
  if (!carrier.ok)
218058
218115
  return carrier;
218059
218116
  const carrierPiece = carrier.piece;
@@ -218075,6 +218132,40 @@ function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespa
218075
218132
  }
218076
218133
  };
218077
218134
  }
218135
+ function formattingCarrierPieceAtOffset(pieces, charOffset, replaceToOffset) {
218136
+ const candidates = [];
218137
+ const collect = (items) => {
218138
+ for (const piece2 of items) {
218139
+ if (piece2.kind === "text" && piece2.textRole === "visible")
218140
+ candidates.push(piece2);
218141
+ else if (piece2.kind === "control" && !piece2.deleted)
218142
+ candidates.push(piece2);
218143
+ else if (piece2.kind === "tracked" && !piece2.removesVisible) {
218144
+ if (!collect(piece2.children))
218145
+ return false;
218146
+ } else if (piece2.kind === "container") {
218147
+ if (piece2.policy === "fail-closed" && charOffset >= piece2.visibleStart && charOffset <= piece2.visibleEnd)
218148
+ return false;
218149
+ if (piece2.policy !== "atomic" && piece2.policy !== "fail-closed" && !collect(piece2.children))
218150
+ return false;
218151
+ }
218152
+ }
218153
+ return true;
218154
+ };
218155
+ if (!collect(pieces))
218156
+ return { ok: false, reason: "unsupported-context" };
218157
+ if (replaceToOffset !== undefined && replaceToOffset > charOffset) {
218158
+ const selected = candidates.filter((piece2) => piece2.visibleEnd > charOffset && piece2.visibleStart < replaceToOffset);
218159
+ return { ok: true, piece: selected.find((piece2) => piece2.kind === "text") ?? selected[0] };
218160
+ }
218161
+ const text = candidates.filter((piece2) => piece2.kind === "text" && piece2.visibleEnd > piece2.visibleStart);
218162
+ const inside = text.find((piece2) => piece2.visibleStart < charOffset && charOffset < piece2.visibleEnd);
218163
+ const previousText = text.filter((piece2) => piece2.visibleEnd === charOffset).at(-1);
218164
+ const previousControl = candidates.filter((piece2) => piece2.kind === "control" && piece2.visibleEnd === charOffset).at(-1);
218165
+ const nextText = text.find((piece2) => piece2.visibleStart === charOffset);
218166
+ const piece = inside ?? previousText ?? previousControl ?? nextText;
218167
+ return { ok: true, piece };
218168
+ }
218078
218169
  function adjacentFormattingCarrierPiece(pieces, placement2) {
218079
218170
  const candidates = placement2 === "before" ? pieces : [...pieces].reverse();
218080
218171
  for (const piece of candidates) {
@@ -218306,6 +218397,7 @@ var init_insertion_formatting_context = __esm(() => {
218306
218397
  init_xml_sax();
218307
218398
  init_paragraph_contribution();
218308
218399
  init_direct_paragraph_list_properties();
218400
+ init_compile_edit_text_inline_plan();
218309
218401
  init_paragraph_property_block();
218310
218402
  init_paragraph_para_id_attrs();
218311
218403
  TD53 = new TextDecoder;
@@ -242385,6 +242477,21 @@ function preparePasteFragmentMutation(input) {
242385
242477
  if (preflight.plan.target.kind !== "text")
242386
242478
  return rejected18(txId, "paste-target-unsupported");
242387
242479
  if (preflight.plan.target.crossParagraph) {
242480
+ if (op.formattingMode === "match-destination") {
242481
+ const target = preflight.plan.target;
242482
+ const anchor = resolveParagraph3(state, target.storyId, target.start.paraId);
242483
+ const bytes = state.packageBytes.get(target.partUri);
242484
+ if (!anchor || !bytes)
242485
+ return rejected18(txId, "paste-target-unsupported");
242486
+ const anchorXml = TD70.decode(bytes.subarray(anchor.byteStart, anchor.byteEnd));
242487
+ const destination = resolveCaretRunPropertiesForInsertion(anchorXml, target.start.charOffset, namespaceBindingsAtPosition(bytes, anchor.byteStart, matchParagraphOpenTag(anchorXml) ?? ""), anchor.entry.textLength);
242488
+ if (!destination.ok)
242489
+ return rejected18(txId, destination.reason);
242490
+ imageExtras.value = {
242491
+ ...imageExtras.value,
242492
+ inlineSpecs: inheritDestinationInlineSpecs(imageExtras.value.inlineSpecs, resolvedBlocks, destination.runPropertiesXml ?? "")
242493
+ };
242494
+ }
242388
242495
  if (changeMode === "tracked") {
242389
242496
  return runCrossParagraphTrackedPasteCommit(input, preflight.plan.target, resolvedBlocks, commitExtras, imageExtras.value);
242390
242497
  }
@@ -243787,6 +243894,13 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
243787
243894
  const paragraphStartByte = anchor.byteStart - byteBase;
243788
243895
  const paragraphEndByte = anchor.byteEnd - byteBase;
243789
243896
  const anchorXml = TD70.decode(bytes.subarray(paragraphStartByte, paragraphEndByte));
243897
+ let inlineSpecs = imageExtras.inlineSpecs;
243898
+ if (input.op.formattingMode === "match-destination") {
243899
+ const destination = resolveCaretRunPropertiesForInsertion(anchorXml, target.charOffset, namespaceBindingsAtPosition(bytes, paragraphStartByte, matchParagraphOpenTag(anchorXml) ?? ""), target.replaceToOffset, target.collapsedInlineAffinity, target.collapsedObjectBoundary);
243900
+ if (!destination.ok)
243901
+ return rejected18(txId, destination.reason);
243902
+ inlineSpecs = inheritDestinationInlineSpecs(inlineSpecs, resolvedBlocks, destination.runPropertiesXml ?? "");
243903
+ }
243790
243904
  const changeMode = input.op.changeMode ?? "direct";
243791
243905
  const wrapAllTracked = changeMode === "tracked";
243792
243906
  const fragmentTracked = fragmentHasTrackedInsertion(resolvedBlocks);
@@ -243824,7 +243938,7 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
243824
243938
  partBytes: bytes,
243825
243939
  paragraphStartByte,
243826
243940
  mintParaId: mintParaId3,
243827
- inlineSpecs: imageExtras.inlineSpecs,
243941
+ inlineSpecs,
243828
243942
  blockSdtIds: imageExtras.blockSdtIds,
243829
243943
  ...stamp ? { trackedStamp: stamp, wrapAllTracked } : {},
243830
243944
  ...listExtras.commentIdMap ? { commentIdMap: listExtras.commentIdMap } : {},
@@ -243948,6 +244062,24 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
243948
244062
  }
243949
244063
  });
243950
244064
  }
244065
+ function inheritDestinationInlineSpecs(inlineSpecs, blocks, runPropertiesXml) {
244066
+ const inherited = new Map(inlineSpecs);
244067
+ for (const block of blocks) {
244068
+ if (block.kind !== "paragraph")
244069
+ continue;
244070
+ inherited.set(block, (inlineSpecs.get(block) ?? block.runs.map(toPasteTextRunSpec)).map((run) => withDestinationRunProperties(run, runPropertiesXml)));
244071
+ }
244072
+ return inherited;
244073
+ }
244074
+ function withDestinationRunProperties(run, runPropertiesXml) {
244075
+ if (run.kind === "hyperlink" || run.kind === "sdt") {
244076
+ return { ...run, runs: run.runs.map((child) => withDestinationRunProperties(child, runPropertiesXml)) };
244077
+ }
244078
+ if (run.kind === "lineBreak" || run.kind === undefined || run.kind === "text") {
244079
+ return { ...run, runPropertiesXml };
244080
+ }
244081
+ return run;
244082
+ }
243951
244083
  function collectSemanticStyleRoles(blocks) {
243952
244084
  const roles = new Set;
243953
244085
  const collectParagraph = (block) => {
@@ -245175,6 +245307,7 @@ var init_compile_paste_fragment = __esm(() => {
245175
245307
  init_compile_paste_lists();
245176
245308
  init_paste_blocks();
245177
245309
  init_paragraph_para_id_attrs();
245310
+ init_insertion_formatting_context();
245178
245311
  init_table_catalog();
245179
245312
  init_comments_catalog();
245180
245313
  init_comment_package_profile();
@@ -399435,7 +399568,7 @@ class V2ClipboardAdapter {
399435
399568
  const operation = {
399436
399569
  target: target.kernelTarget,
399437
399570
  changeMode: input.changeMode ?? options?.changeMode ?? "direct",
399438
- formattingMode: input.formattingMode ?? "preserve-source",
399571
+ formattingMode: planned.plan.summary.sourceKind === "plain-text" ? "match-destination" : input.formattingMode ?? "preserve-source",
399439
399572
  fragment: planned.applyPlan
399440
399573
  };
399441
399574
  if (options?.dryRun) {
@@ -399720,6 +399853,10 @@ function selectionOffsetSpaceOption(options) {
399720
399853
  const offsetSpace = options?.offsetSpace;
399721
399854
  return offsetSpace === "selection" || offsetSpace === "kernel" ? offsetSpace : undefined;
399722
399855
  }
399856
+ function selectionCollapsedInlineAffinityOption(options) {
399857
+ const affinity = options?.collapsedInlineAffinity;
399858
+ return affinity === "upstream" || affinity === "downstream" ? affinity : undefined;
399859
+ }
399723
399860
  function buildOffsetMapForCoordinateSpace5(bytes, byteStart, byteEnd, coordinateSpace) {
399724
399861
  return coordinateSpace === "tracked" ? buildSDDocumentSessionInternalTrackedParagraphOffsetMap(bytes, byteStart, byteEnd) : buildSDDocumentSessionInternalParagraphOffsetMap(bytes, byteStart, byteEnd);
399725
399862
  }
@@ -399905,6 +400042,7 @@ function resolveSelectionPasteTarget(context, target, options, applyPlan2) {
399905
400042
  const anchorEntry = index2.byParaId(resolved.startBlockId);
399906
400043
  const anchorBytes = anchorEntry ? getSDDocumentSessionInternalPartBytes(context.session, anchorEntry.partUri) : null;
399907
400044
  const anchorXml = anchorEntry && anchorBytes ? CLIPBOARD_TD.decode(anchorBytes.subarray(anchorEntry.byteStart, anchorEntry.byteEnd)) : null;
400045
+ const collapsedInlineAffinity = resolved.startOffset === resolved.endOffset ? selectionCollapsedInlineAffinityOption(options) : undefined;
399908
400046
  return {
399909
400047
  ok: true,
399910
400048
  kernelTarget: {
@@ -399913,6 +400051,7 @@ function resolveSelectionPasteTarget(context, target, options, applyPlan2) {
399913
400051
  paraId: resolved.startBlockId,
399914
400052
  charOffset: resolved.startOffset,
399915
400053
  ...resolved.endOffset > resolved.startOffset ? { replaceToOffset: resolved.endOffset } : {},
400054
+ ...collapsedInlineAffinity ? { collapsedInlineAffinity } : {},
399916
400055
  ...resolved.collapsedObjectBoundary ? { collapsedObjectBoundary: resolved.collapsedObjectBoundary } : {}
399917
400056
  },
399918
400057
  storyLocator,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.7.0-next.3",
3
+ "version": "1.7.0-next.5",
4
4
  "description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.26.0",
27
- "@superdoc/sdk": "2.20.0-next.3",
27
+ "@superdoc/sdk": "2.20.0-next.5",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.23.0-next.3",
33
- "@superdoc/docx-engine": "0.22.0-next.3",
32
+ "superdoc": "2.23.0-next.5",
33
+ "@superdoc/docx-engine": "0.22.0-next.5",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",