@superdoc/mcp 1.7.0-next.11 → 1.7.0-next.13
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 +428 -82
- 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.13";
|
|
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();
|
|
@@ -312270,6 +312476,7 @@ function convertHtmlToFragment(html, options = {}) {
|
|
|
312270
312476
|
range: { startOffset: 0, endOffset: html.length }
|
|
312271
312477
|
}), limits.maxDiagnostics);
|
|
312272
312478
|
}
|
|
312479
|
+
attachSiblingListsToPreviousItems(tree);
|
|
312273
312480
|
const treeViolation = inspectTreeLimits(tree, limits);
|
|
312274
312481
|
if (treeViolation) {
|
|
312275
312482
|
appendBoundedConversionDiagnostic(diagnostics, htmlDiagnostic({
|
|
@@ -312331,6 +312538,34 @@ function convertHtmlToFragment(html, options = {}) {
|
|
|
312331
312538
|
diagnostics
|
|
312332
312539
|
};
|
|
312333
312540
|
}
|
|
312541
|
+
function attachSiblingListsToPreviousItems(parent) {
|
|
312542
|
+
const pending = [parent];
|
|
312543
|
+
while (pending.length > 0) {
|
|
312544
|
+
const current = pending.pop();
|
|
312545
|
+
if ("tagName" in current && (current.tagName === "ul" || current.tagName === "ol")) {
|
|
312546
|
+
let previousItem = null;
|
|
312547
|
+
const retained = [];
|
|
312548
|
+
for (const child of current.childNodes) {
|
|
312549
|
+
if (isElement(child) && child.tagName === "li") {
|
|
312550
|
+
previousItem = child;
|
|
312551
|
+
retained.push(child);
|
|
312552
|
+
} else if (previousItem && isElement(child) && (child.tagName === "ul" || child.tagName === "ol")) {
|
|
312553
|
+
previousItem.childNodes.push(child);
|
|
312554
|
+
child.parentNode = previousItem;
|
|
312555
|
+
} else {
|
|
312556
|
+
if (!isText(child) || child.value.trim() !== "")
|
|
312557
|
+
previousItem = null;
|
|
312558
|
+
retained.push(child);
|
|
312559
|
+
}
|
|
312560
|
+
}
|
|
312561
|
+
current.childNodes = retained;
|
|
312562
|
+
}
|
|
312563
|
+
for (const child of current.childNodes) {
|
|
312564
|
+
if (isElement(child))
|
|
312565
|
+
pending.push(child);
|
|
312566
|
+
}
|
|
312567
|
+
}
|
|
312568
|
+
}
|
|
312334
312569
|
function parseErrorDiagnostic(error48) {
|
|
312335
312570
|
return htmlDiagnostic({
|
|
312336
312571
|
code: "conversion-malformed-input",
|
|
@@ -312708,9 +312943,9 @@ function convertSemanticList(root, context, inherited, path6) {
|
|
|
312708
312943
|
level,
|
|
312709
312944
|
path: canonicalPath,
|
|
312710
312945
|
...itemValue !== undefined && itemValue !== null ? { marker: `${itemValue}${definition.text?.endsWith(")") ? ")" : "."}` } : {},
|
|
312711
|
-
content: content.length > 0 ? content : [
|
|
312946
|
+
content: applyListItemParagraphMarkRunProps(content.length > 0 ? content : [
|
|
312712
312947
|
paragraph2(context, [], undefined, itemPath, context.droppedContentCount === droppedContentStart)
|
|
312713
|
-
]
|
|
312948
|
+
], itemContext.runProps)
|
|
312714
312949
|
});
|
|
312715
312950
|
for (let nestedIndex = 0;nestedIndex < child.childNodes.length; nestedIndex += 1) {
|
|
312716
312951
|
const nested = child.childNodes[nestedIndex];
|
|
@@ -312778,7 +313013,7 @@ function convertSemanticList(root, context, inherited, path6) {
|
|
|
312778
313013
|
level,
|
|
312779
313014
|
path: canonicalPath,
|
|
312780
313015
|
...itemValue !== undefined && itemValue !== null ? { marker: `${itemValue}${definition.text?.endsWith(")") ? ")" : "."}` } : {},
|
|
312781
|
-
content: nestedContent
|
|
313016
|
+
content: applyListItemParagraphMarkRunProps(nestedContent, itemContext.runProps)
|
|
312782
313017
|
});
|
|
312783
313018
|
}
|
|
312784
313019
|
if (nestedItems.length === 0)
|
|
@@ -312892,7 +313127,7 @@ function convertWordListGroup(group, context, inherited) {
|
|
|
312892
313127
|
level: descriptor.level,
|
|
312893
313128
|
path: canonicalPath,
|
|
312894
313129
|
...exceptionalMarker ? { marker: exceptionalMarker } : {},
|
|
312895
|
-
content:
|
|
313130
|
+
content: applyListItemParagraphMarkRunProps(itemContent, itemContext.runProps)
|
|
312896
313131
|
});
|
|
312897
313132
|
previousLevel = descriptor.level;
|
|
312898
313133
|
}
|
|
@@ -312904,7 +313139,7 @@ function convertWordListGroup(group, context, inherited) {
|
|
|
312904
313139
|
list: { levels: [...levels.values()].sort((a, b) => a.level - b.level), items }
|
|
312905
313140
|
};
|
|
312906
313141
|
}
|
|
312907
|
-
function
|
|
313142
|
+
function applyListItemParagraphMarkRunProps(content, runProps) {
|
|
312908
313143
|
if (Object.keys(runProps).length === 0)
|
|
312909
313144
|
return content;
|
|
312910
313145
|
let applied = false;
|
|
@@ -326116,22 +326351,50 @@ function comparablePlainTokenVariants(plan, plain) {
|
|
|
326116
326351
|
return variants;
|
|
326117
326352
|
}
|
|
326118
326353
|
function normalizeRepresentedListMarkers(plan, lines) {
|
|
326119
|
-
const
|
|
326120
|
-
|
|
326354
|
+
const representedTokens = [];
|
|
326355
|
+
const listStarts = new Set;
|
|
326356
|
+
for (const block of plan.blocks) {
|
|
326357
|
+
const tokens = comparableTokens(blockText(block));
|
|
326358
|
+
if (tokens.length > 0 && block.kind === "paragraph" && block.listIntent) {
|
|
326359
|
+
listStarts.add(representedTokens.length);
|
|
326360
|
+
}
|
|
326361
|
+
for (const token of tokens)
|
|
326362
|
+
representedTokens.push(token);
|
|
326363
|
+
}
|
|
326364
|
+
if (listStarts.size === 0)
|
|
326121
326365
|
return null;
|
|
326122
|
-
let
|
|
326366
|
+
let tokenIndex = 0;
|
|
326367
|
+
const matchesNext = (tokens) => tokens.length > 0 && tokens.every((token, index2) => token === representedTokens[tokenIndex + index2]);
|
|
326123
326368
|
let changed = false;
|
|
326124
326369
|
const normalized = lines.map((line) => {
|
|
326125
|
-
|
|
326370
|
+
const tokens = comparableTokens(line);
|
|
326371
|
+
if (matchesNext(tokens)) {
|
|
326372
|
+
tokenIndex += tokens.length;
|
|
326373
|
+
return line;
|
|
326374
|
+
}
|
|
326375
|
+
if (!listStarts.has(tokenIndex))
|
|
326126
326376
|
return line;
|
|
326127
|
-
const withoutMarker =
|
|
326128
|
-
if (
|
|
326377
|
+
const withoutMarker = stripRepresentedListMarker(line);
|
|
326378
|
+
if (withoutMarker === null)
|
|
326129
326379
|
return line;
|
|
326130
|
-
|
|
326380
|
+
const withoutMarkerTokens = comparableTokens(withoutMarker);
|
|
326381
|
+
if (!matchesNext(withoutMarkerTokens))
|
|
326382
|
+
return line;
|
|
326383
|
+
tokenIndex += withoutMarkerTokens.length;
|
|
326131
326384
|
changed = true;
|
|
326132
326385
|
return withoutMarker;
|
|
326133
326386
|
});
|
|
326134
|
-
return changed &&
|
|
326387
|
+
return changed && tokenIndex === representedTokens.length ? normalized : null;
|
|
326388
|
+
}
|
|
326389
|
+
function stripRepresentedListMarker(line) {
|
|
326390
|
+
if (hasPlainListMarker(line))
|
|
326391
|
+
return stripPlainListMarker(line);
|
|
326392
|
+
const separator = line.indexOf("\t");
|
|
326393
|
+
if (separator < 1)
|
|
326394
|
+
return null;
|
|
326395
|
+
if (!/^(?:o|[\uE000-\uF8FF])$/u.test(line.slice(0, separator).trim()))
|
|
326396
|
+
return null;
|
|
326397
|
+
return line.slice(separator).replace(/^\t+/u, "");
|
|
326135
326398
|
}
|
|
326136
326399
|
function hasPlainListMarker(value2) {
|
|
326137
326400
|
return PLAIN_LIST_MARKER_PATTERN.test(value2);
|
|
@@ -326167,7 +326430,7 @@ function isSubsequence(needles, haystack) {
|
|
|
326167
326430
|
var PLAIN_LIST_MARKER_PATTERN;
|
|
326168
326431
|
var init_html_plain_reconciliation = __esm(() => {
|
|
326169
326432
|
init_contracts();
|
|
326170
|
-
PLAIN_LIST_MARKER_PATTERN = /^(?:[
|
|
326433
|
+
PLAIN_LIST_MARKER_PATTERN = /^(?:[•◦▪‣⁃●○■□▫◻◽*+-]|\d{1,9}[.)]|[A-Za-z][.)]|[ivxlcdmIVXLCDM]{1,8}[.)])(?:[\t ]+)/u;
|
|
326171
326434
|
});
|
|
326172
326435
|
|
|
326173
326436
|
// ../../../v2/document-api-v2-adapter/dist/clipboard/parse-v1-slice.js
|
|
@@ -328302,15 +328565,14 @@ function* serializeSelectionRangeSteps(context, target, includeHtml, options) {
|
|
|
328302
328565
|
let numbering = properties.numbering;
|
|
328303
328566
|
const listState = readListStateForSession(context.session, resolved.storyId, entry.blockId);
|
|
328304
328567
|
let listKind = listState?.isListItem ? listState.numFmt === "bullet" ? "bullet" : listState.numFmt ? "ordered" : undefined : undefined;
|
|
328568
|
+
const marker = fullyCovered || listKind ? resolveNumberingLevelForMarker({
|
|
328569
|
+
resolverParams: styleModel.resolverParams,
|
|
328570
|
+
numId: listState?.isListItem && listState.numId != null ? Number(listState.numId) : properties.numbering ? Number(properties.numbering.numId) : undefined,
|
|
328571
|
+
ilvl: listState?.isListItem ? listState.ilvl : properties.numbering ? Number(properties.numbering.ilvl) : undefined,
|
|
328572
|
+
paragraphStyleId: properties.styleRef
|
|
328573
|
+
}) : null;
|
|
328305
328574
|
if (fullyCovered) {
|
|
328306
|
-
|
|
328307
|
-
const marker = resolveNumberingLevelForMarker({
|
|
328308
|
-
resolverParams: model.resolverParams,
|
|
328309
|
-
numId: properties.numbering ? Number(properties.numbering.numId) : undefined,
|
|
328310
|
-
ilvl: properties.numbering ? Number(properties.numbering.ilvl) : undefined,
|
|
328311
|
-
paragraphStyleId: properties.styleRef
|
|
328312
|
-
});
|
|
328313
|
-
if (marker.definition && !marker.definition.suppressed) {
|
|
328575
|
+
if (marker?.definition && !marker.definition.suppressed) {
|
|
328314
328576
|
numbering = {
|
|
328315
328577
|
numId: String(marker.definition.numId),
|
|
328316
328578
|
ilvl: String(marker.definition.ilvl)
|
|
@@ -328358,7 +328620,8 @@ function* serializeSelectionRangeSteps(context, target, includeHtml, options) {
|
|
|
328358
328620
|
...cellFormatting
|
|
328359
328621
|
}
|
|
328360
328622
|
} : {},
|
|
328361
|
-
...listKind ? { listKind } : {},
|
|
328623
|
+
...listKind ? { listKind, listLevel: listState?.isListItem ? listState.ilvl : listLevel ?? 0 } : {},
|
|
328624
|
+
...listKind && marker?.definition ? { listMarkerStyle: portableListMarkerStyle(marker.definition, styleModel, paragraphXml) } : {},
|
|
328362
328625
|
...semanticHeadingLevel != null && semanticHeadingLevel >= 1 && semanticHeadingLevel <= 6 ? { headingLevel: semanticHeadingLevel } : {},
|
|
328363
328626
|
parts
|
|
328364
328627
|
});
|
|
@@ -329568,14 +329831,14 @@ function paragraphPaintedLength(xml) {
|
|
|
329568
329831
|
const map3 = parseParagraphInlineMap(xml);
|
|
329569
329832
|
return map3.visibleLength + map3.leaves().filter(isVisibleZeroWidthObjectPiece).length;
|
|
329570
329833
|
}
|
|
329571
|
-
function blockInlineHtml(block, assets) {
|
|
329572
|
-
return block.parts.map((part) => renderHtmlPart(part, assets)).join("");
|
|
329834
|
+
function blockInlineHtml(block, assets, defaultTextColor) {
|
|
329835
|
+
return block.parts.map((part) => renderHtmlPart(part, assets, defaultTextColor)).join("");
|
|
329573
329836
|
}
|
|
329574
|
-
function renderHtmlPart(part, assets) {
|
|
329837
|
+
function renderHtmlPart(part, assets, defaultTextColor) {
|
|
329575
329838
|
if (part.kind === "break")
|
|
329576
329839
|
return "<br/>";
|
|
329577
329840
|
if (part.kind === "run")
|
|
329578
|
-
return renderHtmlRun(part.run);
|
|
329841
|
+
return renderHtmlRun(part.run, defaultTextColor);
|
|
329579
329842
|
if (part.kind === "image") {
|
|
329580
329843
|
const asset = assets.get(part.image.assetId);
|
|
329581
329844
|
if (!asset)
|
|
@@ -329584,18 +329847,17 @@ function renderHtmlPart(part, assets) {
|
|
|
329584
329847
|
return `<img src="data:${asset.mimeType};base64,${asset.data}" width="${widthPx}" height="${heightPx}"` + (alt ? ` alt="${escapeHtmlAttribute(alt)}"` : "") + (title2 ? ` title="${escapeHtmlAttribute(title2)}"` : "") + "/>";
|
|
329585
329848
|
}
|
|
329586
329849
|
if (part.kind === "sdt")
|
|
329587
|
-
return part.parts.map((child) => renderHtmlPart(child, assets)).join("");
|
|
329850
|
+
return part.parts.map((child) => renderHtmlPart(child, assets, defaultTextColor)).join("");
|
|
329588
329851
|
const href = part.target.kind === "external" ? part.target.url : `#${part.target.anchor}`;
|
|
329589
329852
|
const title = part.tooltip ? ` title="${escapeHtmlAttribute(part.tooltip)}"` : "";
|
|
329590
|
-
return `<a href="${escapeHtmlAttribute(href)}"${title}>${part.parts.map((child) => renderHtmlPart(child, assets)).join("")}</a>`;
|
|
329853
|
+
return `<a href="${escapeHtmlAttribute(href)}"${title}>${part.parts.map((child) => renderHtmlPart(child, assets, defaultTextColor)).join("")}</a>`;
|
|
329591
329854
|
}
|
|
329592
329855
|
function buildHtmlFlavor(grouped, assets) {
|
|
329593
329856
|
const out = [];
|
|
329594
|
-
|
|
329857
|
+
const openLists = [];
|
|
329595
329858
|
const closeList = () => {
|
|
329596
|
-
|
|
329597
|
-
out.push(
|
|
329598
|
-
openList = null;
|
|
329859
|
+
while (openLists.length > 0) {
|
|
329860
|
+
out.push(`</li></${openLists.pop().tag}>`);
|
|
329599
329861
|
}
|
|
329600
329862
|
};
|
|
329601
329863
|
for (const entry of grouped) {
|
|
@@ -329605,15 +329867,41 @@ function buildHtmlFlavor(grouped, assets) {
|
|
|
329605
329867
|
continue;
|
|
329606
329868
|
}
|
|
329607
329869
|
const block = entry.block;
|
|
329608
|
-
const inline = blockInlineHtml(block, assets);
|
|
329870
|
+
const inline = blockInlineHtml(block, assets, block.listMarkerStyle?.color && block.listMarkerStyle.color !== "000000" ? "000000" : undefined);
|
|
329609
329871
|
if (block.listKind) {
|
|
329610
329872
|
const tag = block.listKind === "bullet" ? "ul" : "ol";
|
|
329611
|
-
|
|
329612
|
-
|
|
329613
|
-
|
|
329614
|
-
|
|
329615
|
-
|
|
329616
|
-
|
|
329873
|
+
const styleType = block.listMarkerStyle?.type;
|
|
329874
|
+
const level = block.listLevel ?? 0;
|
|
329875
|
+
if (openLists.length > 0)
|
|
329876
|
+
openLists[0].sourceLevel = Math.min(openLists[0].sourceLevel, level);
|
|
329877
|
+
while (openLists.length > 1 && openLists[openLists.length - 1].sourceLevel > level) {
|
|
329878
|
+
out.push(`</li></${openLists.pop().tag}>`);
|
|
329879
|
+
}
|
|
329880
|
+
const depth = openLists.length === 0 ? 0 : level > openLists[openLists.length - 1].sourceLevel ? openLists.length : openLists.length - 1;
|
|
329881
|
+
if (openLists.length === depth + 1) {
|
|
329882
|
+
out.push("</li>");
|
|
329883
|
+
if (openLists[depth].tag !== tag || openLists[depth].styleType !== styleType) {
|
|
329884
|
+
out.push(`</${openLists.pop().tag}>`);
|
|
329885
|
+
}
|
|
329886
|
+
}
|
|
329887
|
+
if (openLists.length === depth) {
|
|
329888
|
+
const listStyles = [
|
|
329889
|
+
...styleType ? [`list-style-type: ${styleType}`] : [],
|
|
329890
|
+
...openLists[depth - 1]?.currentItemHasMarkerColor ? ["color: #000000"] : []
|
|
329891
|
+
];
|
|
329892
|
+
const orderedType = tag === "ol" ? orderedListTypeAttribute(styleType) : undefined;
|
|
329893
|
+
out.push(`<${tag}${orderedType ? ` type="${orderedType}"` : ""}` + `${listStyles.length > 0 ? ` style="${listStyles.join("; ")}"` : ""}>`);
|
|
329894
|
+
openLists.push({ tag, sourceLevel: level, ...styleType ? { styleType } : {}, currentItemHasMarkerColor: false });
|
|
329895
|
+
}
|
|
329896
|
+
const markerColor = block.listMarkerStyle?.color;
|
|
329897
|
+
const previousItemHadColoredMarker = openLists[openLists.length - 1].currentItemHasMarkerColor;
|
|
329898
|
+
const itemColor = markerColor && markerColor !== "000000" ? markerColor : previousItemHadColoredMarker ? "000000" : undefined;
|
|
329899
|
+
const itemStyles = [
|
|
329900
|
+
...styleType ? [`list-style-type: ${styleType}`] : [],
|
|
329901
|
+
...itemColor ? [`color: #${itemColor}`] : []
|
|
329902
|
+
];
|
|
329903
|
+
out.push(`<li${itemStyles.length > 0 ? ` style="${itemStyles.join("; ")}"` : ""}>${inline}`);
|
|
329904
|
+
openLists[openLists.length - 1].currentItemHasMarkerColor = Boolean(markerColor && markerColor !== "000000");
|
|
329617
329905
|
continue;
|
|
329618
329906
|
}
|
|
329619
329907
|
closeList();
|
|
@@ -329625,6 +329913,63 @@ function buildHtmlFlavor(grouped, assets) {
|
|
|
329625
329913
|
closeList();
|
|
329626
329914
|
return out.join("");
|
|
329627
329915
|
}
|
|
329916
|
+
function portableListMarkerStyle(definition2, model, paragraphXml) {
|
|
329917
|
+
const glyph = definition2.lvlText?.trim();
|
|
329918
|
+
const type = definition2.numFmt === "bullet" ? glyph === "•" || glyph === "●" || glyph === "" ? "disc" : glyph === "◦" || glyph === "○" ? "circle" : glyph === "▪" || glyph === "■" || glyph === "◼" ? "square" : undefined : portableOrderedListStyleType(definition2.numFmt);
|
|
329919
|
+
const runContext = {
|
|
329920
|
+
themeColors: model.themeColors,
|
|
329921
|
+
themeFontScheme: model.themeFontScheme
|
|
329922
|
+
};
|
|
329923
|
+
const directParagraphProperties = parseWordParagraphPropertiesXml(paragraphXml);
|
|
329924
|
+
const resolvedParagraphProperties = model.resolveParagraph({ inlineProps: directParagraphProperties });
|
|
329925
|
+
const markerRun = model.resolveRun({
|
|
329926
|
+
inlineRpr: parseWordRunPropertiesXml(extractParagraphMarkRPrXml(paragraphXml)),
|
|
329927
|
+
resolvedParagraphProperties,
|
|
329928
|
+
isListNumber: true,
|
|
329929
|
+
numberingDefinedInline: directParagraphProperties.numberingProperties != null
|
|
329930
|
+
});
|
|
329931
|
+
const markerColor = normalizeRunAttrsFromOoxml(markerRun, runContext).color;
|
|
329932
|
+
const color2 = markerColor && /^#[0-9a-f]{6}$/i.test(markerColor) ? markerColor.slice(1).toUpperCase() : undefined;
|
|
329933
|
+
return {
|
|
329934
|
+
...type ? { type } : {},
|
|
329935
|
+
...color2 ? { color: color2 } : {}
|
|
329936
|
+
};
|
|
329937
|
+
}
|
|
329938
|
+
function portableOrderedListStyleType(numFmt) {
|
|
329939
|
+
switch (numFmt) {
|
|
329940
|
+
case "decimal":
|
|
329941
|
+
return "decimal";
|
|
329942
|
+
case "decimalZero":
|
|
329943
|
+
return "decimal-leading-zero";
|
|
329944
|
+
case "lowerLetter":
|
|
329945
|
+
return "lower-alpha";
|
|
329946
|
+
case "upperLetter":
|
|
329947
|
+
return "upper-alpha";
|
|
329948
|
+
case "lowerRoman":
|
|
329949
|
+
return "lower-roman";
|
|
329950
|
+
case "upperRoman":
|
|
329951
|
+
return "upper-roman";
|
|
329952
|
+
default:
|
|
329953
|
+
return;
|
|
329954
|
+
}
|
|
329955
|
+
}
|
|
329956
|
+
function orderedListTypeAttribute(styleType) {
|
|
329957
|
+
switch (styleType) {
|
|
329958
|
+
case "decimal":
|
|
329959
|
+
case "decimal-leading-zero":
|
|
329960
|
+
return "1";
|
|
329961
|
+
case "lower-alpha":
|
|
329962
|
+
return "a";
|
|
329963
|
+
case "upper-alpha":
|
|
329964
|
+
return "A";
|
|
329965
|
+
case "lower-roman":
|
|
329966
|
+
return "i";
|
|
329967
|
+
case "upper-roman":
|
|
329968
|
+
return "I";
|
|
329969
|
+
default:
|
|
329970
|
+
return;
|
|
329971
|
+
}
|
|
329972
|
+
}
|
|
329628
329973
|
function tableCellHtmlStyle(cell) {
|
|
329629
329974
|
const styles = [];
|
|
329630
329975
|
if (cell.shadingColor)
|
|
@@ -329655,14 +330000,15 @@ function tableCellHtmlStyle(cell) {
|
|
|
329655
330000
|
}
|
|
329656
330001
|
return styles.length > 0 ? ` style="${styles.join("; ")}"` : "";
|
|
329657
330002
|
}
|
|
329658
|
-
function renderHtmlRun(run) {
|
|
330003
|
+
function renderHtmlRun(run, defaultTextColor) {
|
|
329659
330004
|
let html = escapeHtmlText(run.text);
|
|
329660
|
-
|
|
329661
|
-
if (!marks)
|
|
330005
|
+
if (!run.marks && !defaultTextColor)
|
|
329662
330006
|
return html;
|
|
330007
|
+
const marks = run.marks ?? {};
|
|
329663
330008
|
const styles = [];
|
|
329664
|
-
|
|
329665
|
-
|
|
330009
|
+
const color2 = marks.color ?? defaultTextColor;
|
|
330010
|
+
if (color2)
|
|
330011
|
+
styles.push(`color: #${color2}`);
|
|
329666
330012
|
if (marks.fontSizePt)
|
|
329667
330013
|
styles.push(`font-size: ${marks.fontSizePt}pt`);
|
|
329668
330014
|
if (marks.fontFamily)
|
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.13",
|
|
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.13",
|
|
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.13",
|
|
33
|
+
"@superdoc/docx-engine": "0.22.0-next.13",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|