@superdoc/mcp 1.7.0-next.11 → 1.7.0-next.12
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 +243 -37
- 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.
|
|
31603
|
+
var SDK_VERSION = "2.20.0-next.12";
|
|
31604
31604
|
|
|
31605
31605
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31606
31606
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -167575,6 +167575,130 @@ function extractNamespaceClosedParagraphMarkRunPropertiesFromParagraph(paragraph
|
|
|
167575
167575
|
return null;
|
|
167576
167576
|
return namespaceClosedOpenTag + runPropertiesXml.slice(runPropertiesNode.openEnd);
|
|
167577
167577
|
}
|
|
167578
|
+
function namespaceCloseParagraphPropertiesForRelocation(paragraphPropertiesXml, paragraphXml, inheritedNamespaceBindings, ancestorOpenTags = []) {
|
|
167579
|
+
const paragraph = readValidatedXmlNodeAt(paragraphXml, 0);
|
|
167580
|
+
if (!paragraph || paragraph.kind !== "element" || xmlLocalName(paragraph.qname) !== "p" || paragraph.selfClosing || paragraphXml.slice(paragraph.end).trim())
|
|
167581
|
+
return null;
|
|
167582
|
+
const paragraphOpenTag = paragraphXml.slice(0, paragraph.openEnd);
|
|
167583
|
+
const ancestorPolicySources = readAncestorPolicySources(ancestorOpenTags);
|
|
167584
|
+
if (ancestorPolicySources == null)
|
|
167585
|
+
return null;
|
|
167586
|
+
const { pPr } = splitLeadingParagraphPropertyBlock(paragraphXml.slice(paragraph.openEnd, paragraph.closeStart));
|
|
167587
|
+
const sourcePropertiesStart = pPr.search(/<(?:[\w.-]+:)?pPr\b/);
|
|
167588
|
+
const sourceProperties = sourcePropertiesStart >= 0 ? readValidatedXmlNodeAt(pPr, sourcePropertiesStart) : null;
|
|
167589
|
+
if (sourceProperties && (sourceProperties.kind !== "element" || xmlLocalName(sourceProperties.qname) !== "pPr"))
|
|
167590
|
+
return null;
|
|
167591
|
+
const sourcePropertiesOpenTag = sourceProperties ? pPr.slice(sourcePropertiesStart, sourceProperties.openEnd) : "";
|
|
167592
|
+
const paragraphDeclarations = readLocalNamespaceDeclarations(paragraphOpenTag);
|
|
167593
|
+
if (paragraphDeclarations == null)
|
|
167594
|
+
return null;
|
|
167595
|
+
const sourceBindings = { ...inheritedNamespaceBindings };
|
|
167596
|
+
for (const declaration of paragraphDeclarations)
|
|
167597
|
+
sourceBindings[declaration.prefix] = declaration.namespaceUri;
|
|
167598
|
+
const paragraphBindings = { ...sourceBindings };
|
|
167599
|
+
const sourcePropertiesDeclarations = readLocalNamespaceDeclarations(sourcePropertiesOpenTag);
|
|
167600
|
+
if (sourcePropertiesDeclarations == null)
|
|
167601
|
+
return null;
|
|
167602
|
+
for (const declaration of sourcePropertiesDeclarations)
|
|
167603
|
+
sourceBindings[declaration.prefix] = declaration.namespaceUri;
|
|
167604
|
+
return closePropertyFragmentWithCompatibilityPolicy(paragraphPropertiesXml, "pPr", sourceBindings, [
|
|
167605
|
+
...ancestorPolicySources,
|
|
167606
|
+
[paragraphOpenTag, paragraphBindings],
|
|
167607
|
+
[sourcePropertiesOpenTag, sourceBindings]
|
|
167608
|
+
]);
|
|
167609
|
+
}
|
|
167610
|
+
function namespaceCloseRunPropertiesWithAncestorPolicy(runPropertiesXml, paragraphOpenTag, inheritedNamespaceBindings, ancestorOpenTags) {
|
|
167611
|
+
if (!runPropertiesXml)
|
|
167612
|
+
return "";
|
|
167613
|
+
const ancestorPolicySources = readAncestorPolicySources(ancestorOpenTags);
|
|
167614
|
+
const declarations = readLocalNamespaceDeclarations(paragraphOpenTag);
|
|
167615
|
+
if (ancestorPolicySources == null || declarations == null)
|
|
167616
|
+
return null;
|
|
167617
|
+
const bindings = { ...inheritedNamespaceBindings };
|
|
167618
|
+
for (const declaration of declarations)
|
|
167619
|
+
bindings[declaration.prefix] = declaration.namespaceUri;
|
|
167620
|
+
return closePropertyFragmentWithCompatibilityPolicy(runPropertiesXml, "rPr", bindings, [
|
|
167621
|
+
...ancestorPolicySources,
|
|
167622
|
+
[paragraphOpenTag, bindings]
|
|
167623
|
+
]);
|
|
167624
|
+
}
|
|
167625
|
+
function readAncestorPolicySources(ancestorOpenTags) {
|
|
167626
|
+
const sources = [];
|
|
167627
|
+
const bindings = {};
|
|
167628
|
+
for (const openTag of ancestorOpenTags) {
|
|
167629
|
+
const declarations = readLocalNamespaceDeclarations(openTag);
|
|
167630
|
+
if (declarations == null)
|
|
167631
|
+
return null;
|
|
167632
|
+
for (const declaration of declarations)
|
|
167633
|
+
bindings[declaration.prefix] = declaration.namespaceUri;
|
|
167634
|
+
sources.push([openTag, { ...bindings }]);
|
|
167635
|
+
}
|
|
167636
|
+
return sources;
|
|
167637
|
+
}
|
|
167638
|
+
function closePropertyFragmentWithCompatibilityPolicy(propertiesXml, propertyName, inheritedNamespaceBindings, policySources) {
|
|
167639
|
+
const node2 = readValidatedXmlNodeAt(propertiesXml, 0);
|
|
167640
|
+
if (!node2 || node2.kind !== "element" || xmlLocalName(node2.qname) !== propertyName || node2.end !== propertiesXml.length)
|
|
167641
|
+
return null;
|
|
167642
|
+
let openTag = propertiesXml.slice(0, node2.openEnd);
|
|
167643
|
+
const localDeclarations = readLocalNamespaceDeclarations(openTag);
|
|
167644
|
+
if (localDeclarations == null)
|
|
167645
|
+
return null;
|
|
167646
|
+
const bindings = { ...inheritedNamespaceBindings };
|
|
167647
|
+
for (const declaration of localDeclarations)
|
|
167648
|
+
bindings[declaration.prefix] = declaration.namespaceUri;
|
|
167649
|
+
const prefix = parseRawXmlElementTag(openTag)?.prefix;
|
|
167650
|
+
if (prefix == null)
|
|
167651
|
+
return null;
|
|
167652
|
+
if (bindings[prefix] == null)
|
|
167653
|
+
bindings[prefix] = NS_W;
|
|
167654
|
+
if (bindings[prefix] !== NS_W)
|
|
167655
|
+
return null;
|
|
167656
|
+
for (const [sourceOpenTag, policyBindings] of policySources) {
|
|
167657
|
+
const policyPrefixes = markupCompatibilityValuePrefixes(sourceOpenTag, new Map(Object.entries(policyBindings)));
|
|
167658
|
+
if (policyPrefixes == null || [...policyPrefixes].some((key2) => policyBindings[key2] !== bindings[key2]))
|
|
167659
|
+
return null;
|
|
167660
|
+
for (const attribute of scanRawXmlAttributes(sourceOpenTag)) {
|
|
167661
|
+
if (policyBindings[attribute.prefix] !== NS_MC)
|
|
167662
|
+
continue;
|
|
167663
|
+
if (bindings[attribute.prefix] !== NS_MC)
|
|
167664
|
+
return null;
|
|
167665
|
+
const existing = [...scanRawXmlAttributes(openTag)].find((candidate) => bindings[candidate.prefix] === NS_MC && candidate.localName === attribute.localName);
|
|
167666
|
+
if (existing) {
|
|
167667
|
+
const currentValue = decodeXmlText(existing.value);
|
|
167668
|
+
const sourceValue = decodeXmlText(attribute.value);
|
|
167669
|
+
if (currentValue !== sourceValue) {
|
|
167670
|
+
if (!INHERITED_MC_LIST_ATTRIBUTES.has(attribute.localName))
|
|
167671
|
+
return null;
|
|
167672
|
+
const tokens = [...new Set([...currentValue.split(/\s+/), ...sourceValue.split(/\s+/)].filter(Boolean))];
|
|
167673
|
+
openTag = openTag.slice(0, existing.valueStart) + escapeXmlAttribute(tokens.join(" ")) + openTag.slice(existing.valueEnd);
|
|
167674
|
+
}
|
|
167675
|
+
} else {
|
|
167676
|
+
const sourceXml = sourceOpenTag.slice(attribute.sourceStart, attribute.sourceEnd);
|
|
167677
|
+
openTag = openTag.replace(/\s*(\/?)>$/, (_match, slash) => ` ${sourceXml.trim()}${slash}>`);
|
|
167678
|
+
}
|
|
167679
|
+
}
|
|
167680
|
+
}
|
|
167681
|
+
const fragment3 = openTag + propertiesXml.slice(node2.openEnd);
|
|
167682
|
+
const required2 = namespacePrefixesRequiredByFragment(fragment3);
|
|
167683
|
+
const compatibilityPrefixes = markupCompatibilityValuePrefixes(openTag, new Map(Object.entries(bindings)));
|
|
167684
|
+
if (required2 == null || compatibilityPrefixes == null)
|
|
167685
|
+
return null;
|
|
167686
|
+
const declarations = [];
|
|
167687
|
+
for (const requiredPrefix of new Set([...required2, ...compatibilityPrefixes])) {
|
|
167688
|
+
if (requiredPrefix === "xml")
|
|
167689
|
+
continue;
|
|
167690
|
+
const namespaceUri = bindings[requiredPrefix];
|
|
167691
|
+
if (!namespaceUri || namespaceUri.startsWith("urn:superdoc:unresolved-namespace-prefix:"))
|
|
167692
|
+
return null;
|
|
167693
|
+
declarations.push({
|
|
167694
|
+
prefix: requiredPrefix,
|
|
167695
|
+
namespaceUri,
|
|
167696
|
+
sourceXml: requiredPrefix ? ` xmlns:${requiredPrefix}="${escapeXmlAttribute(namespaceUri)}"` : ` xmlns="${escapeXmlAttribute(namespaceUri)}"`
|
|
167697
|
+
});
|
|
167698
|
+
}
|
|
167699
|
+
const closed = addNamespaceDeclarations(openTag, declarations);
|
|
167700
|
+
return closed == null ? null : closed + propertiesXml.slice(node2.openEnd);
|
|
167701
|
+
}
|
|
167578
167702
|
function namespaceCloseRunPropertiesForRelocation(runPropertiesXml, namespaceSourceOpenTag, inheritedNamespaceBindings = {}) {
|
|
167579
167703
|
const runPropertiesNode = readValidatedXmlNodeAt(runPropertiesXml, 0);
|
|
167580
167704
|
if (!runPropertiesNode || runPropertiesNode.kind !== "element" || runPropertiesNode.selfClosing || xmlLocalName(runPropertiesNode.qname) !== "rPr" || runPropertiesNode.end !== runPropertiesXml.length) {
|
|
@@ -168117,11 +168241,12 @@ function addNamespaceDeclarations(openTag, sourceNamespaces, inheritedNamespaceB
|
|
|
168117
168241
|
}
|
|
168118
168242
|
return additions.length > 0 ? openTag.replace(/\s*(\/?)>$/, (_match, selfClosing) => `${additions}${selfClosing}>`) : openTag;
|
|
168119
168243
|
}
|
|
168120
|
-
var PARAGRAPH_MARK_REVISION_CHILDREN;
|
|
168244
|
+
var PARAGRAPH_MARK_REVISION_CHILDREN, INHERITED_MC_LIST_ATTRIBUTES;
|
|
168121
168245
|
var init_paragraph_property_block = __esm(() => {
|
|
168122
168246
|
init_xml_text();
|
|
168123
168247
|
init_xml_sax();
|
|
168124
168248
|
PARAGRAPH_MARK_REVISION_CHILDREN = new Set(["ins", "del", "moveFrom", "moveTo", "rPrChange"]);
|
|
168249
|
+
INHERITED_MC_LIST_ATTRIBUTES = new Set(["Ignorable", "PreserveAttributes", "PreserveElements", "ProcessContent"]);
|
|
168125
168250
|
});
|
|
168126
168251
|
|
|
168127
168252
|
// ../../../v2/editor-core/dist/document/transactions/collapsed-inline-insertion-site.js
|
|
@@ -188004,11 +188129,18 @@ var init_part_wml_scan_cache = __esm(() => {
|
|
|
188004
188129
|
|
|
188005
188130
|
// ../../../v2/editor-core/dist/document/transactions/paragraph-para-id-attrs.js
|
|
188006
188131
|
function namespaceBindingsAtPosition(bytes, byteOffset, localOpenTag = "") {
|
|
188132
|
+
return namespaceContextAtPosition(bytes, byteOffset, localOpenTag).bindings;
|
|
188133
|
+
}
|
|
188134
|
+
function namespaceContextAtPosition(bytes, byteOffset, localOpenTag = "") {
|
|
188135
|
+
const scopes = readNamespaceScopesBeforeByte(bytes, byteOffset);
|
|
188007
188136
|
const bindings = {
|
|
188008
|
-
...
|
|
188137
|
+
...scopes.reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {}),
|
|
188009
188138
|
...readNamespaceDeclarations2(localOpenTag)
|
|
188010
188139
|
};
|
|
188011
|
-
return
|
|
188140
|
+
return {
|
|
188141
|
+
bindings: Object.fromEntries(Object.entries(bindings).filter((entry) => entry[1] != null)),
|
|
188142
|
+
ancestorOpenTags: scopes.map((frame) => frame.openTag)
|
|
188143
|
+
};
|
|
188012
188144
|
}
|
|
188013
188145
|
function matchParagraphOpenTag(paragraphXml) {
|
|
188014
188146
|
return paragraphXml.match(PARAGRAPH_OPEN_TAG_RE2)?.[0] ?? null;
|
|
@@ -188036,6 +188168,9 @@ function readPartRootNamespaces(bytes) {
|
|
|
188036
188168
|
return readNamespaceDeclarations2(rootOpenTag);
|
|
188037
188169
|
}
|
|
188038
188170
|
function readNamespacesBeforeByte(bytes, byteOffset) {
|
|
188171
|
+
return readNamespaceScopesBeforeByte(bytes, byteOffset).reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {});
|
|
188172
|
+
}
|
|
188173
|
+
function readNamespaceScopesBeforeByte(bytes, byteOffset) {
|
|
188039
188174
|
ancestorNamespacePrefixScanCount += 1;
|
|
188040
188175
|
const prefix = stripXmlCommentsAndCdata(TD33.decode(bytes.subarray(0, Math.max(0, byteOffset))));
|
|
188041
188176
|
const stack = [];
|
|
@@ -188058,9 +188193,9 @@ function readNamespacesBeforeByte(bytes, byteOffset) {
|
|
|
188058
188193
|
const namespaces = readNamespaceDeclarations2(match[0]);
|
|
188059
188194
|
if (/\/\s*>$/.test(match[0]))
|
|
188060
188195
|
continue;
|
|
188061
|
-
stack.push({ name, namespaces });
|
|
188196
|
+
stack.push({ name, namespaces, openTag: match[0] });
|
|
188062
188197
|
}
|
|
188063
|
-
return stack
|
|
188198
|
+
return stack;
|
|
188064
188199
|
}
|
|
188065
188200
|
function stripXmlCommentsAndCdata(xml) {
|
|
188066
188201
|
let result = "";
|
|
@@ -219349,7 +219484,7 @@ function resolveInsertionFormattingContext(state, input) {
|
|
|
219349
219484
|
const style = resolveInsertionStyle(state, paragraphXml, input.anchor, input.styleRef, inheritance, input.fallbackToDocumentDefaultStyle ?? false);
|
|
219350
219485
|
if (!style.ok)
|
|
219351
219486
|
return style;
|
|
219352
|
-
const direct = inheritance === "anchor" && paragraphXml != null ? resolveDirectInsertionFormatting(paragraphXml, input.anchor.placement, readAnchorNamespaceBindings(state, input.anchor.entry)) : {
|
|
219487
|
+
const direct = inheritance === "anchor" && paragraphXml != null ? resolveDirectInsertionFormatting(paragraphXml, input.anchor.placement, readAnchorNamespaceBindings(state, input.anchor.entry), input.includeRunProperties ?? true) : {
|
|
219353
219488
|
paragraphPropertiesXml: null,
|
|
219354
219489
|
paragraphMarkRunPropertiesXml: null,
|
|
219355
219490
|
runPropertiesXml: null,
|
|
@@ -219512,10 +219647,10 @@ function lookupNextStyle(state, styleId) {
|
|
|
219512
219647
|
function readWordAttribute2(tag, namespaceUri, localName2) {
|
|
219513
219648
|
return readXmlAttribute(tag, namespaceUri, localName2)?.value;
|
|
219514
219649
|
}
|
|
219515
|
-
function resolveDirectInsertionFormatting(paragraphXml, placement2, inheritedNamespaceBindings = {}) {
|
|
219650
|
+
function resolveDirectInsertionFormatting(paragraphXml, placement2, inheritedNamespaceBindings = {}, includeRunProperties = true) {
|
|
219516
219651
|
const paragraphPropertiesXml = cloneDirectParagraphPropertiesForInsert(paragraphXml);
|
|
219517
219652
|
const paragraphMarkRunPropertiesXml = cloneParagraphMarkRunPropertiesForInsert(paragraphXml);
|
|
219518
|
-
const adjacentRunProperties = cloneAdjacentRunPropertiesForInsert(paragraphXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings);
|
|
219653
|
+
const adjacentRunProperties = includeRunProperties ? cloneAdjacentRunPropertiesForInsert(paragraphXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings) : { ok: true, runPropertiesXml: null };
|
|
219519
219654
|
if (!adjacentRunProperties.ok)
|
|
219520
219655
|
return adjacentRunProperties;
|
|
219521
219656
|
const runPropertiesXml = adjacentRunProperties.runPropertiesXml;
|
|
@@ -241424,31 +241559,32 @@ var init_compile_paste_lists = __esm(() => {
|
|
|
241424
241559
|
});
|
|
241425
241560
|
|
|
241426
241561
|
// ../../../v2/editor-core/dist/document/transactions/match-destination-paste.js
|
|
241427
|
-
function normalizeMatchDestinationBlocks(blocks) {
|
|
241428
|
-
return blocks.map((block) => {
|
|
241429
|
-
|
|
241430
|
-
|
|
241431
|
-
|
|
241432
|
-
kind: "paragraph",
|
|
241433
|
-
runs: block.runs.map((run) => ({ text: run.text, ...run.sourcePath ? { sourcePath: run.sourcePath } : {} })),
|
|
241434
|
-
...block.sourcePath ? { sourcePath: block.sourcePath } : {},
|
|
241435
|
-
...block.inlines ? {
|
|
241436
|
-
inlines: block.inlines.map((inline) => inline.kind === "text" ? {
|
|
241437
|
-
kind: "text",
|
|
241438
|
-
text: inline.text,
|
|
241439
|
-
...inline.sourcePath ? { sourcePath: inline.sourcePath } : {}
|
|
241440
|
-
} : inline.kind === "hyperlink" ? {
|
|
241441
|
-
...inline,
|
|
241442
|
-
inlines: inline.inlines.map((child) => child.kind === "text" ? {
|
|
241443
|
-
kind: "text",
|
|
241444
|
-
text: child.text,
|
|
241445
|
-
...child.sourcePath ? { sourcePath: child.sourcePath } : {}
|
|
241446
|
-
} : child)
|
|
241447
|
-
} : inline)
|
|
241448
|
-
} : {}
|
|
241449
|
-
};
|
|
241450
|
-
});
|
|
241562
|
+
function normalizeMatchDestinationBlocks(blocks, destinationTableParagraphPropertiesXml) {
|
|
241563
|
+
return blocks.map((block) => block.kind === "table" ? mapPasteTableParagraphs(block, (paragraph) => ({
|
|
241564
|
+
...normalizeMatchDestinationParagraph(paragraph),
|
|
241565
|
+
...destinationTableParagraphPropertiesXml ? { pPrXml: destinationTableParagraphPropertiesXml, complete: true } : {}
|
|
241566
|
+
})) : block.kind === "paragraph" ? normalizeMatchDestinationParagraph(block) : block);
|
|
241451
241567
|
}
|
|
241568
|
+
function normalizeMatchDestinationParagraph(block) {
|
|
241569
|
+
return {
|
|
241570
|
+
kind: "paragraph",
|
|
241571
|
+
runs: block.runs.map(withoutSourceMarks),
|
|
241572
|
+
...block.sourcePath ? { sourcePath: block.sourcePath } : {},
|
|
241573
|
+
...block.inlines ? {
|
|
241574
|
+
inlines: block.inlines.map((inline) => inline.kind === "text" ? withoutSourceMarks(inline) : inline.kind === "hyperlink" ? {
|
|
241575
|
+
...inline,
|
|
241576
|
+
inlines: inline.inlines.map((child) => child.kind === "text" ? withoutSourceMarks(child) : child)
|
|
241577
|
+
} : inline)
|
|
241578
|
+
} : {}
|
|
241579
|
+
};
|
|
241580
|
+
}
|
|
241581
|
+
function withoutSourceMarks(run) {
|
|
241582
|
+
const { marks: _sourceMarks, ...retained } = run;
|
|
241583
|
+
return retained;
|
|
241584
|
+
}
|
|
241585
|
+
var init_match_destination_paste = __esm(() => {
|
|
241586
|
+
init_paste_blocks();
|
|
241587
|
+
});
|
|
241452
241588
|
|
|
241453
241589
|
// ../../../v2/editor-core/dist/document/transactions/image-catalog.js
|
|
241454
241590
|
function buildImageCatalog(input) {
|
|
@@ -243932,7 +244068,32 @@ function preparePasteFragmentMutation(input) {
|
|
|
243932
244068
|
if (!isMaterializablePasteBlocks(blocks)) {
|
|
243933
244069
|
return rejected18(txId, "paste-structure-unsupported");
|
|
243934
244070
|
}
|
|
243935
|
-
|
|
244071
|
+
let destinationTableParagraphPropertiesXml = null;
|
|
244072
|
+
if (isTextTarget2(pasteTarget) && op.formattingMode === "match-destination" && blocks.some((block) => block.kind === "table")) {
|
|
244073
|
+
const anchor = resolveParagraph3(state, pasteTarget.storyId, pasteTarget.paraId);
|
|
244074
|
+
if (!anchor)
|
|
244075
|
+
return rejected18(txId, "paste-target-unsupported");
|
|
244076
|
+
const destination = resolveInsertionFormattingContext(state, {
|
|
244077
|
+
anchor: { entry: anchor.entry, placement: "before" },
|
|
244078
|
+
includeRunProperties: false
|
|
244079
|
+
});
|
|
244080
|
+
if (!destination.ok)
|
|
244081
|
+
return rejected18(txId, destination.reason);
|
|
244082
|
+
if (destination.context.paragraphPropertiesXml) {
|
|
244083
|
+
const bytes = state.packageBytes.get(anchor.partUri);
|
|
244084
|
+
if (!bytes)
|
|
244085
|
+
return rejected18(txId, "paste-target-unsupported");
|
|
244086
|
+
const paragraphXml = TD70.decode(bytes.subarray(anchor.byteStart, anchor.byteEnd));
|
|
244087
|
+
const openTag = matchParagraphOpenTag(paragraphXml);
|
|
244088
|
+
if (!openTag)
|
|
244089
|
+
return rejected18(txId, "paste-target-unsupported");
|
|
244090
|
+
const namespaceContext = namespaceContextAtPosition(bytes, anchor.byteStart, openTag);
|
|
244091
|
+
destinationTableParagraphPropertiesXml = namespaceCloseParagraphPropertiesForRelocation(destination.context.paragraphPropertiesXml, paragraphXml, namespaceContext.bindings, namespaceContext.ancestorOpenTags);
|
|
244092
|
+
if (destinationTableParagraphPropertiesXml == null)
|
|
244093
|
+
return rejected18(txId, "paste-structure-unsupported");
|
|
244094
|
+
}
|
|
244095
|
+
}
|
|
244096
|
+
const normalizedBlocks = isTextTarget2(pasteTarget) && op.formattingMode === "match-destination" ? normalizeMatchDestinationBlocks(blocks, destinationTableParagraphPropertiesXml) : blocks;
|
|
243936
244097
|
const imageValidation = validateImageFragment(op.fragment);
|
|
243937
244098
|
if (!imageValidation.ok)
|
|
243938
244099
|
return rejected18(txId, imageValidation.reason);
|
|
@@ -244032,7 +244193,13 @@ function preparePasteFragmentMutation(input) {
|
|
|
244032
244193
|
if (!anchor || !bytes)
|
|
244033
244194
|
return rejected18(txId, "paste-target-unsupported");
|
|
244034
244195
|
const anchorXml = TD70.decode(bytes.subarray(anchor.byteStart, anchor.byteEnd));
|
|
244035
|
-
const destination =
|
|
244196
|
+
const destination = resolveDestinationPasteRunProperties({
|
|
244197
|
+
paragraphXml: anchorXml,
|
|
244198
|
+
charOffset: target.start.charOffset,
|
|
244199
|
+
partBytes: bytes,
|
|
244200
|
+
paragraphStartByte: anchor.byteStart,
|
|
244201
|
+
replaceToOffset: anchor.entry.textLength
|
|
244202
|
+
});
|
|
244036
244203
|
if (!destination.ok)
|
|
244037
244204
|
return rejected18(txId, destination.reason);
|
|
244038
244205
|
imageExtras.value = {
|
|
@@ -244945,6 +245112,24 @@ function tryRunTableRowPasteCommit(input, pasteTarget, pastedBlocks, additionalP
|
|
|
244945
245112
|
const targetTableLocation = findContainingTableCell(tableCatalog, targetParagraph);
|
|
244946
245113
|
if (!targetTableLocation)
|
|
244947
245114
|
return null;
|
|
245115
|
+
if (input.op.formattingMode === "match-destination" && storyPartBytes) {
|
|
245116
|
+
const paragraphXml = TD70.decode(storyPartBytes.subarray(targetParagraph.byteStart, targetParagraph.byteEnd));
|
|
245117
|
+
const destination = resolveDestinationPasteRunProperties({
|
|
245118
|
+
paragraphXml,
|
|
245119
|
+
charOffset: pasteTarget.charOffset,
|
|
245120
|
+
partBytes: storyPartBytes,
|
|
245121
|
+
paragraphStartByte: targetParagraph.byteStart,
|
|
245122
|
+
replaceToOffset: pasteTarget.replaceToOffset,
|
|
245123
|
+
collapsedInlineAffinity: pasteTarget.collapsedInlineAffinity,
|
|
245124
|
+
collapsedObjectBoundary: pasteTarget.collapsedObjectBoundary
|
|
245125
|
+
});
|
|
245126
|
+
if (!destination.ok)
|
|
245127
|
+
return rejected18(transactionId, destination.reason);
|
|
245128
|
+
pastedImageExtras = {
|
|
245129
|
+
...pastedImageExtras,
|
|
245130
|
+
inlineSpecs: inheritDestinationInlineSpecs(pastedImageExtras.inlineSpecs, pastedBlocks, destination.runPropertiesXml ?? "")
|
|
245131
|
+
};
|
|
245132
|
+
}
|
|
244948
245133
|
if (targetTableLocation.table.hasVMerge) {
|
|
244949
245134
|
return rejected18(transactionId, "paste-target-unsupported");
|
|
244950
245135
|
}
|
|
@@ -245444,7 +245629,15 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
|
|
|
245444
245629
|
const anchorXml = TD70.decode(bytes.subarray(paragraphStartByte, paragraphEndByte));
|
|
245445
245630
|
let inlineSpecs = imageExtras.inlineSpecs;
|
|
245446
245631
|
if (input.op.formattingMode === "match-destination") {
|
|
245447
|
-
const destination =
|
|
245632
|
+
const destination = resolveDestinationPasteRunProperties({
|
|
245633
|
+
paragraphXml: anchorXml,
|
|
245634
|
+
charOffset: target.charOffset,
|
|
245635
|
+
partBytes: bytes,
|
|
245636
|
+
paragraphStartByte,
|
|
245637
|
+
replaceToOffset: target.replaceToOffset,
|
|
245638
|
+
collapsedInlineAffinity: target.collapsedInlineAffinity,
|
|
245639
|
+
collapsedObjectBoundary: target.collapsedObjectBoundary
|
|
245640
|
+
});
|
|
245448
245641
|
if (!destination.ok)
|
|
245449
245642
|
return rejected18(txId, destination.reason);
|
|
245450
245643
|
inlineSpecs = inheritDestinationInlineSpecs(inlineSpecs, resolvedBlocks, destination.runPropertiesXml ?? "");
|
|
@@ -245610,9 +245803,20 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
|
|
|
245610
245803
|
}
|
|
245611
245804
|
});
|
|
245612
245805
|
}
|
|
245806
|
+
function resolveDestinationPasteRunProperties(input) {
|
|
245807
|
+
const openTag = matchParagraphOpenTag(input.paragraphXml);
|
|
245808
|
+
if (!openTag)
|
|
245809
|
+
return { ok: false, reason: "unsupported-context" };
|
|
245810
|
+
const context = namespaceContextAtPosition(input.partBytes, input.paragraphStartByte, openTag);
|
|
245811
|
+
const destination = resolveCaretRunPropertiesForInsertion(input.paragraphXml, input.charOffset, context.bindings, input.replaceToOffset, input.collapsedInlineAffinity, input.collapsedObjectBoundary);
|
|
245812
|
+
if (!destination.ok)
|
|
245813
|
+
return destination;
|
|
245814
|
+
const runPropertiesXml = namespaceCloseRunPropertiesWithAncestorPolicy(destination.runPropertiesXml ?? "", openTag, context.bindings, context.ancestorOpenTags);
|
|
245815
|
+
return runPropertiesXml == null ? { ok: false, reason: "unsupported-context" } : { ok: true, runPropertiesXml };
|
|
245816
|
+
}
|
|
245613
245817
|
function inheritDestinationInlineSpecs(inlineSpecs, blocks, runPropertiesXml) {
|
|
245614
245818
|
const inherited = new Map(inlineSpecs);
|
|
245615
|
-
for (const block of blocks) {
|
|
245819
|
+
for (const block of walkPasteBlocks(blocks)) {
|
|
245616
245820
|
if (block.kind !== "paragraph")
|
|
245617
245821
|
continue;
|
|
245618
245822
|
inherited.set(block, (inlineSpecs.get(block) ?? block.runs.map(toPasteTextRunSpec)).map((run) => withDestinationRunProperties(run, runPropertiesXml)));
|
|
@@ -246869,8 +247073,10 @@ var init_compile_paste_fragment = __esm(() => {
|
|
|
246869
247073
|
init_compile_paste_splice();
|
|
246870
247074
|
init_compile_paste_lists();
|
|
246871
247075
|
init_paste_blocks();
|
|
247076
|
+
init_match_destination_paste();
|
|
246872
247077
|
init_paragraph_para_id_attrs();
|
|
246873
247078
|
init_insertion_formatting_context();
|
|
247079
|
+
init_paragraph_property_block();
|
|
246874
247080
|
init_table_catalog();
|
|
246875
247081
|
init_comments_catalog();
|
|
246876
247082
|
init_comment_package_profile();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.7.0-next.
|
|
3
|
+
"version": "1.7.0-next.12",
|
|
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.
|
|
27
|
+
"@superdoc/sdk": "2.20.0-next.12",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.23.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.22.0-next.
|
|
32
|
+
"superdoc": "2.23.0-next.12",
|
|
33
|
+
"@superdoc/docx-engine": "0.22.0-next.12",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|