@stll/folio-core 0.47.7 → 0.49.0
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/ai-edits/apply.js +565 -121
- package/dist/ai-edits/minimal-replacement.d.ts +64 -0
- package/dist/ai-edits/minimal-replacement.js +282 -0
- package/dist/controller/fontReadiness.js +3 -3
- package/dist/controller/hyphenationReadiness.d.ts +19 -0
- package/dist/controller/hyphenationReadiness.js +47 -0
- package/dist/controller/layoutPipeline.d.ts +3 -0
- package/dist/controller/layoutPipeline.js +70 -18
- package/dist/display-list/build/buildDisplayList.js +39 -12
- package/dist/display-list/build/pageFurniture.d.ts +7 -1
- package/dist/display-list/build/pageFurniture.js +21 -8
- package/dist/display-list/build/paragraphPrimitives.js +68 -11
- package/dist/display-list/build/tablePrimitives.js +10 -6
- package/dist/display-list/build/textBoxPrimitives.js +1 -1
- package/dist/display-list/build/unsupported.d.ts +2 -2
- package/dist/display-list/build/unsupported.js +0 -0
- package/dist/display-list/dom/renderDisplayListToDom.js +0 -1
- package/dist/docx/attributeRemainder.js +10 -2
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +79 -64
- package/dist/docx/bulletMarkers.d.ts +18 -2
- package/dist/docx/bulletMarkers.js +27 -2
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +57 -45
- package/dist/docx/containerChildren.d.ts +21 -8
- package/dist/docx/containerChildren.js +39 -9
- package/dist/docx/documentParser.d.ts +5 -1
- package/dist/docx/documentParser.js +8 -5
- package/dist/docx/documentSectionFacts.d.ts +22 -0
- package/dist/docx/documentSectionFacts.js +43 -0
- package/dist/docx/drawingGroupChildren.d.ts +60 -0
- package/dist/docx/drawingGroupChildren.js +176 -0
- package/dist/docx/drawingUtils.js +3 -0
- package/dist/docx/fieldParser.d.ts +8 -1
- package/dist/docx/fieldParser.js +47 -3
- package/dist/docx/fontTableParser.js +34 -27
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +15 -12
- package/dist/docx/groupDrawingParser.d.ts +9 -2
- package/dist/docx/groupDrawingParser.js +125 -37
- package/dist/docx/headerFooterParser.d.ts +7 -2
- package/dist/docx/headerFooterParser.js +15 -5
- package/dist/docx/hyperlinkParser.d.ts +48 -36
- package/dist/docx/hyperlinkParser.js +97 -82
- package/dist/docx/numberingParser.js +108 -84
- package/dist/docx/packageParts.d.ts +45 -1
- package/dist/docx/packageParts.js +93 -2
- package/dist/docx/paraIdAttribute.d.ts +3 -2
- package/dist/docx/paragraphParser.d.ts +5 -1
- package/dist/docx/paragraphParser.js +468 -365
- package/dist/docx/paragraphProperties.js +123 -109
- package/dist/docx/paragraphPropertySource.d.ts +6 -1
- package/dist/docx/paragraphPropertySource.js +9 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +143 -10
- package/dist/docx/parser.d.ts +7 -1
- package/dist/docx/parser.js +33 -16
- package/dist/docx/previewBudget.d.ts +55 -33
- package/dist/docx/previewBudget.js +59 -65
- package/dist/docx/rezip.js +41 -58
- package/dist/docx/runParser.d.ts +4 -1
- package/dist/docx/runParser.js +182 -184
- package/dist/docx/sdtProperties.js +87 -84
- package/dist/docx/sectionParser.js +169 -160
- package/dist/docx/selectiveSaveFlags.d.ts +10 -3
- package/dist/docx/selectiveSaveFlags.js +1 -1
- package/dist/docx/selectiveXmlPatch.d.ts +56 -34
- package/dist/docx/selectiveXmlPatch.js +222 -115
- package/dist/docx/serializer/groupTextBoxWriteBack.d.ts +12 -0
- package/dist/docx/serializer/groupTextBoxWriteBack.js +101 -0
- package/dist/docx/serializer/paragraphSerializer.js +47 -42
- package/dist/docx/serializer/runSerializer.d.ts +5 -1
- package/dist/docx/serializer/runSerializer.js +4 -3
- package/dist/docx/serializer/settingsSerializer.js +19 -1
- package/dist/docx/settingsParser.js +8 -0
- package/dist/docx/shapeAlternateContent.d.ts +25 -0
- package/dist/docx/shapeAlternateContent.js +52 -0
- package/dist/docx/streamingXmlParser.d.ts +6 -2
- package/dist/docx/streamingXmlParser.js +12 -7
- package/dist/docx/styleParser.js +34 -8
- package/dist/docx/tableParser.d.ts +21 -12
- package/dist/docx/tableParser.js +518 -441
- package/dist/docx/textBoxParser.d.ts +18 -5
- package/dist/docx/textBoxParser.js +12 -6
- package/dist/docx/verbatimCapture.d.ts +10 -8
- package/dist/docx/verbatimCapture.js +45 -2
- package/dist/docx/vmlImageParser.d.ts +15 -13
- package/dist/docx/vmlImageParser.js +75 -60
- package/dist/docx/vmlPreview.d.ts +3 -3
- package/dist/docx/vmlPreview.js +3 -4
- package/dist/docx/xmlNamespaceContext.d.ts +9 -0
- package/dist/docx/xmlNamespaceContext.js +54 -0
- package/dist/docx/xmlParser.d.ts +6 -3
- package/dist/docx/xmlParser.js +11 -41
- package/dist/docx/xmlResourceLimits.d.ts +2 -1
- package/dist/docx/xmlResourceLimits.js +4 -1
- package/dist/fonts/headlessMeasure.js +0 -0
- package/dist/headless-layout.d.ts +11 -2
- package/dist/headless-layout.js +153 -107
- package/dist/internal/headlessRevisionResolution.js +50 -13
- package/dist/internal/paragraphFormattingSerialization.js +3 -3
- package/dist/layout-bridge/convert/endnoteLayout.d.ts +65 -0
- package/dist/layout-bridge/convert/endnoteLayout.js +227 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +19 -3
- package/dist/layout-bridge/convert/footnoteLayout.js +40 -31
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -7
- package/dist/layout-bridge/convert/headerFooterLayout.js +5 -20
- package/dist/layout-bridge/convert/paragraphMarkFormatting.d.ts +10 -0
- package/dist/layout-bridge/convert/paragraphMarkFormatting.js +59 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +29 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +284 -39
- package/dist/layout-bridge/engine/hitTest.js +5 -3
- package/dist/layout-bridge/engine/selectionRects.js +5 -3
- package/dist/layout-engine/anchorLayoutInCellCompatibility.d.ts +10 -0
- package/dist/layout-engine/anchorLayoutInCellCompatibility.js +22 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +102 -14
- package/dist/layout-engine/justificationCompatibility.d.ts +1 -1
- package/dist/layout-engine/justificationCompatibility.js +9 -5
- package/dist/layout-engine/keep-together.d.ts +15 -6
- package/dist/layout-engine/keep-together.js +43 -16
- package/dist/layout-engine/layoutInstrumentation.d.ts +8 -2
- package/dist/layout-engine/layoutInstrumentation.js +8 -1
- package/dist/layout-engine/measure/advanceComposition.js +50 -7
- package/dist/layout-engine/measure/hyphenationDictionaries.d.ts +74 -0
- package/dist/layout-engine/measure/hyphenationDictionaries.js +138 -0
- package/dist/layout-engine/measure/hyphenationPreload.d.ts +11 -0
- package/dist/layout-engine/measure/hyphenationPreload.js +24 -0
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +12 -2
- package/dist/layout-engine/measure/lineBreakProvider.js +30 -30
- package/dist/layout-engine/measure/lineBreaks.d.ts +6 -1
- package/dist/layout-engine/measure/lineBreaks.js +10 -3
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +9 -6
- package/dist/layout-engine/measure/listMarkerWidth.js +20 -22
- package/dist/layout-engine/measure/measureBlocks.js +46 -10
- package/dist/layout-engine/measure/measureContainer.js +51 -8
- package/dist/layout-engine/measure/measureHelpers.d.ts +15 -3
- package/dist/layout-engine/measure/measureHelpers.js +34 -8
- package/dist/layout-engine/measure/measureParagraph.js +143 -101
- package/dist/layout-engine/measure/measureTypes.d.ts +5 -0
- package/dist/layout-engine/measure/smallCapsCasing.d.ts +56 -0
- package/dist/layout-engine/measure/smallCapsCasing.js +88 -0
- package/dist/layout-engine/measure/tabCalculator.d.ts +2 -0
- package/dist/layout-engine/measure/tabCalculator.js +2 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +51 -19
- package/dist/layout-engine/measure/tableCellGrid.d.ts +28 -3
- package/dist/layout-engine/measure/tableCellGrid.js +45 -5
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/noteAreaFlow.d.ts +19 -0
- package/dist/layout-engine/noteAreaFlow.js +83 -0
- package/dist/layout-engine/paginator.d.ts +12 -1
- package/dist/layout-engine/paginator.js +18 -2
- package/dist/layout-engine/paragraphSpacing.d.ts +4 -2
- package/dist/layout-engine/paragraphSpacing.js +2 -1
- package/dist/layout-engine/tableRowBreak.d.ts +8 -1
- package/dist/layout-engine/tableRowBreak.js +25 -2
- package/dist/layout-engine/types.d.ts +108 -3
- package/dist/layout-engine/types.js +96 -1
- package/dist/layout-painter/index.d.ts +3 -0
- package/dist/layout-painter/renderPage.js +32 -83
- package/dist/layout-painter/renderParagraph.d.ts +6 -1
- package/dist/layout-painter/renderParagraph.js +75 -26
- package/dist/layout-painter/renderTable.js +26 -13
- package/dist/layout-painter/renderTextBox.d.ts +12 -2
- package/dist/layout-painter/renderTextBox.js +26 -2
- package/dist/prosemirror/alternateContentAttrs.d.ts +9 -0
- package/dist/prosemirror/alternateContentAttrs.js +35 -0
- package/dist/prosemirror/attrs/index.d.ts +9 -9
- package/dist/prosemirror/attrs/index.js +133 -11
- package/dist/prosemirror/commands/comments.js +51 -41
- package/dist/prosemirror/contentControlRevisions.d.ts +43 -0
- package/dist/prosemirror/contentControlRevisions.js +84 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +54 -23
- package/dist/prosemirror/conversion/markInterner.d.ts +21 -0
- package/dist/prosemirror/conversion/markInterner.js +90 -0
- package/dist/prosemirror/conversion/toProseDoc.js +117 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +2 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +1 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +7 -7
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +7 -7
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +6 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +39 -51
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +9 -2
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +5 -1
- package/dist/prosemirror/listMarker.d.ts +1 -0
- package/dist/prosemirror/listMarker.js +4 -2
- package/dist/prosemirror/listRenderingAttrs.d.ts +1 -0
- package/dist/prosemirror/listRenderingAttrs.js +3 -0
- package/dist/prosemirror/paragraphDirection.d.ts +29 -2
- package/dist/prosemirror/paragraphDirection.js +21 -2
- package/dist/prosemirror/plugins/suggestionMode.js +37 -8
- package/dist/prosemirror/rejoinRunCarriers.d.ts +27 -0
- package/dist/prosemirror/rejoinRunCarriers.js +66 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +10 -0
- package/dist/prosemirror/runIdentityAcrossRevisions.js +90 -0
- package/dist/prosemirror/schema/nodes.d.ts +50 -6
- package/dist/prosemirror/textBoxHostParagraph.d.ts +13 -0
- package/dist/prosemirror/textBoxHostParagraph.js +21 -0
- package/dist/prosemirror/validation.js +91 -80
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +10 -1
- package/dist/utils/scriptSegments.d.ts +33 -4
- package/dist/utils/scriptSegments.js +39 -6
- package/dist/utils/textFormattingMerge.d.ts +17 -3
- package/dist/utils/textFormattingMerge.js +18 -12
- package/dist/utils/trailingText.d.ts +22 -0
- package/dist/utils/trailingText.js +32 -0
- package/package.json +2 -2
- package/dist/layout-engine/justifiedLineFit.d.ts +0 -7
- package/dist/layout-engine/justifiedLineFit.js +0 -6
|
@@ -5,10 +5,11 @@ import { fieldStateAttributes } from "../fieldState.js";
|
|
|
5
5
|
import { getParagraphPropertySource, paragraphPropertySourceMatchesEmission } from "../paragraphPropertySource.js";
|
|
6
6
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
7
7
|
import { toTransitionalNamespaceUri } from "../transitionalSpelling.js";
|
|
8
|
-
import { captureVerbatimXml,
|
|
8
|
+
import { captureVerbatimXml, createCapturedXmlSanitizer } from "../verbatimCapture.js";
|
|
9
9
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, cloneElement, getChildElements, getLocalName, parseXml } from "../xmlParser.js";
|
|
10
|
+
import { writeGroupTextBoxesBack } from "./groupTextBoxWriteBack.js";
|
|
10
11
|
import { markupRangeAttributes, moveBookmarkAttributes, serializeBookmarkMarker } from "./markupRangeAttributes.js";
|
|
11
|
-
import { serializeRun } from "./runSerializer.js";
|
|
12
|
+
import { serializeRun, serializeShapeTextBody } from "./runSerializer.js";
|
|
12
13
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
13
14
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
14
15
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
@@ -162,37 +163,35 @@ const hasInvalidParagraphMarkProperties = (root) => {
|
|
|
162
163
|
}
|
|
163
164
|
return false;
|
|
164
165
|
};
|
|
165
|
-
const replayableParagraphPropertySourceXml = (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
previousChildOrder = childOrder;
|
|
184
|
-
}
|
|
185
|
-
if (localName !== "rPr" || !isWordprocessingChild) {
|
|
186
|
-
if (hasDescendantNamed(child, NAMESPACES.w, "rPr")) return false;
|
|
187
|
-
continue;
|
|
188
|
-
}
|
|
189
|
-
if (paragraphMarkProperties !== null || toTransitionalNamespaceUri(resolveNamespaceBinding(child.namespaceScope, "w") ?? "") !== NAMESPACES.w) return false;
|
|
190
|
-
paragraphMarkProperties = child;
|
|
166
|
+
const replayableParagraphPropertySourceXml = createCapturedXmlSanitizer({
|
|
167
|
+
allowedLocalNames: PARAGRAPH_PROPERTY_ROOT_NAME,
|
|
168
|
+
allowedNamespaceUris: WORDPROCESSINGML_NAMESPACE,
|
|
169
|
+
inheritedNamespaceScope: OOXML_NAMESPACE_SCOPE,
|
|
170
|
+
requiredNamespaceBindings: PARAGRAPH_APPEND_PREFIXES,
|
|
171
|
+
validate: (root) => {
|
|
172
|
+
let paragraphMarkProperties = null;
|
|
173
|
+
const seenChildren = /* @__PURE__ */ new Set();
|
|
174
|
+
let previousChildOrder = -1;
|
|
175
|
+
for (const child of getChildElements(root)) {
|
|
176
|
+
const localName = getLocalName(child.name);
|
|
177
|
+
const isWordprocessingChild = toTransitionalNamespaceUri(child.namespaceUri ?? "") === NAMESPACES.w;
|
|
178
|
+
if (isWordprocessingChild) {
|
|
179
|
+
if (RESERVED_PARAGRAPH_PROPERTY_CHILDREN.has(localName)) return false;
|
|
180
|
+
const childOrder = PARAGRAPH_PROPERTY_CHILD_ORDER.get(localName);
|
|
181
|
+
if (childOrder === void 0 || seenChildren.has(localName) || childOrder < previousChildOrder) return false;
|
|
182
|
+
seenChildren.add(localName);
|
|
183
|
+
previousChildOrder = childOrder;
|
|
191
184
|
}
|
|
192
|
-
|
|
185
|
+
if (localName !== "rPr" || !isWordprocessingChild) {
|
|
186
|
+
if (hasDescendantNamed(child, NAMESPACES.w, "rPr")) return false;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (paragraphMarkProperties !== null || toTransitionalNamespaceUri(resolveNamespaceBinding(child.namespaceScope, "w") ?? "") !== NAMESPACES.w) return false;
|
|
190
|
+
paragraphMarkProperties = child;
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
}
|
|
192
|
+
return !(paragraphMarkProperties && hasInvalidParagraphMarkProperties(paragraphMarkProperties) || hasInvalidParagraphPropertyShape(root) || hasInvalidParagraphPropertyRevision(root));
|
|
193
|
+
}
|
|
194
|
+
});
|
|
196
195
|
const verifiedParagraphPropertySource = (formatting, source) => {
|
|
197
196
|
if (!source) return null;
|
|
198
197
|
const replayableSource = replayableParagraphPropertySourceXml(source.xml);
|
|
@@ -323,7 +322,7 @@ function serializeSimpleField(field) {
|
|
|
323
322
|
*/
|
|
324
323
|
function serializeComplexField(field) {
|
|
325
324
|
const parts = [];
|
|
326
|
-
const structuralFormatting = field.formatting ?? field.fieldResult[0]?.formatting;
|
|
325
|
+
const structuralFormatting = field.formatting ?? (field.fieldResultIsFallback ? void 0 : field.fieldResult[0]?.formatting);
|
|
327
326
|
const rPrXml = structuralFormatting ? serializeTextFormatting(structuralFormatting) : "";
|
|
328
327
|
const beginAttrs = ["w:fldCharType=\"begin\"", ...fieldStateAttributes(field)];
|
|
329
328
|
parts.push(`<w:r>${rPrXml}<w:fldChar ${beginAttrs.join(" ")}/></w:r>`);
|
|
@@ -333,7 +332,7 @@ function serializeComplexField(field) {
|
|
|
333
332
|
parts.push(`<w:r>${rPrXml}<w:instrText${spaceAttr}>${escapeXmlText(field.instruction)}</w:instrText></w:r>`);
|
|
334
333
|
}
|
|
335
334
|
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="separate"/></w:r>`);
|
|
336
|
-
parts.push(...field.fieldResult.map((run) => serializeRun(run)));
|
|
335
|
+
if (!field.fieldResultIsFallback) parts.push(...field.fieldResult.map((run) => serializeRun(run)));
|
|
337
336
|
parts.push(`<w:r>${rPrXml}<w:fldChar w:fldCharType="end"/></w:r>`);
|
|
338
337
|
return parts.join("");
|
|
339
338
|
}
|
|
@@ -458,9 +457,19 @@ function serializeTrackedChange(tag, change) {
|
|
|
458
457
|
flushPending();
|
|
459
458
|
return segments.join("");
|
|
460
459
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
460
|
+
/** The properties element each tagged wrapper declares ahead of its content. */
|
|
461
|
+
const TAGGED_WRAPPER_PROPERTIES = {
|
|
462
|
+
smartTag: "smartTagPr",
|
|
463
|
+
customXml: "customXmlPr"
|
|
464
|
+
};
|
|
465
|
+
const taggedWrapperPropertiesSanitizer = (propertiesName) => createCapturedXmlSanitizer({
|
|
466
|
+
allowedLocalNames: /* @__PURE__ */ new Set([propertiesName]),
|
|
467
|
+
allowedNamespaceUris: WORDPROCESSINGML_NAMESPACE,
|
|
468
|
+
inheritedNamespaceScope: OOXML_NAMESPACE_SCOPE
|
|
469
|
+
});
|
|
470
|
+
const TAGGED_WRAPPER_PROPERTIES_SANITIZERS = {
|
|
471
|
+
smartTag: taggedWrapperPropertiesSanitizer(TAGGED_WRAPPER_PROPERTIES.smartTag),
|
|
472
|
+
customXml: taggedWrapperPropertiesSanitizer(TAGGED_WRAPPER_PROPERTIES.customXml)
|
|
464
473
|
};
|
|
465
474
|
/**
|
|
466
475
|
* Emit a `w:smartTag` or a run-level `w:customXml` around content already written.
|
|
@@ -477,11 +486,7 @@ const TAGGED_WRAPPER_PROPERTY_NAMES = {
|
|
|
477
486
|
*/
|
|
478
487
|
function serializeTaggedWrapper(kind, wrapper, inner) {
|
|
479
488
|
const uri = wrapper.uri === void 0 ? "" : ` w:uri="${escapeXmlAttribute(wrapper.uri)}"`;
|
|
480
|
-
const properties =
|
|
481
|
-
allowedLocalNames: TAGGED_WRAPPER_PROPERTY_NAMES[kind],
|
|
482
|
-
allowedNamespaceUris: WORDPROCESSINGML_NAMESPACE,
|
|
483
|
-
inheritedNamespaceScope: OOXML_NAMESPACE_SCOPE
|
|
484
|
-
}) ?? "";
|
|
489
|
+
const properties = TAGGED_WRAPPER_PROPERTIES_SANITIZERS[kind](wrapper.propertiesXml) ?? "";
|
|
485
490
|
return `<w:${kind}${uri} w:element="${escapeXmlAttribute(wrapper.element)}">${properties}${inner}</w:${kind}>`;
|
|
486
491
|
}
|
|
487
492
|
/** Emit the `<w:commentReference>` run Word places after a comment range end. */
|
|
@@ -554,7 +559,7 @@ function serializeParagraph(paragraph) {
|
|
|
554
559
|
sectionProperties: paragraph.sectionProperties
|
|
555
560
|
}));
|
|
556
561
|
let pendingRenderedPageBreak = paragraph.renderedPageBreakBefore === true;
|
|
557
|
-
for (const content of paragraph
|
|
562
|
+
for (const content of writeGroupTextBoxesBack(paragraph, serializeShapeTextBody)) {
|
|
558
563
|
let contentXml = serializeParagraphContent(content);
|
|
559
564
|
if (contentXml) {
|
|
560
565
|
if (pendingRenderedPageBreak) {
|
|
@@ -5,6 +5,10 @@ import { document_d_exports } from "../../types/document.js";
|
|
|
5
5
|
* to keep IDs deterministic across saves.
|
|
6
6
|
*/
|
|
7
7
|
declare function resetAutoIdCounter(): void;
|
|
8
|
+
/** Serialize text body content for shapes/textboxes */
|
|
9
|
+
declare function serializeShapeTextBody(blocks: Extract<document_d_exports.BlockContent, {
|
|
10
|
+
type: "paragraph" | "table";
|
|
11
|
+
}>[]): string;
|
|
8
12
|
/**
|
|
9
13
|
* Serialize a run to OOXML XML (w:r)
|
|
10
14
|
*
|
|
@@ -44,4 +48,4 @@ declare function createBreakRun(breakType?: "page" | "column" | "textWrapping",
|
|
|
44
48
|
*/
|
|
45
49
|
declare function createTabRun(formatting?: document_d_exports.TextFormatting): document_d_exports.Run;
|
|
46
50
|
//#endregion
|
|
47
|
-
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns };
|
|
51
|
+
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns, serializeShapeTextBody };
|
|
@@ -8,6 +8,7 @@ import { DECORATIVE_EXTENSION_URI, DECORATIVE_NAMESPACE } from "../imageParser.j
|
|
|
8
8
|
import { canReplayEditableImageRawXml } from "../imageRawXml.js";
|
|
9
9
|
import { serializeNonVisualDrawingNames } from "../nonVisualDrawingProps.js";
|
|
10
10
|
import { runHoldsPayload } from "../runPayload.js";
|
|
11
|
+
import { replayableShapeAlternateContent } from "../shapeAlternateContent.js";
|
|
11
12
|
import { requiredWrapPolygon, serializeWrapPolygon } from "../wrapPolygon.js";
|
|
12
13
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
13
14
|
import { serializeTable } from "./tableSerializer.js";
|
|
@@ -148,7 +149,7 @@ function serializeFill(fill) {
|
|
|
148
149
|
if (fill.type === "gradient" && fill.gradient) {
|
|
149
150
|
const g = fill.gradient;
|
|
150
151
|
return `<a:gradFill><a:gsLst>${g.stops.map((s) => `<a:gs pos="${s.position}">${serializeDrawingColor(s.color)}</a:gs>`).join("")}</a:gsLst>${(() => {
|
|
151
|
-
if (g.type === "linear") return `<a:lin ang="${(g.angle ?? 0) * 6e4}" scaled="1"/>`;
|
|
152
|
+
if (g.type === "linear") return `<a:lin ang="${(g.angle ?? 0) * 6e4}" scaled="${g.scaled === false ? 0 : 1}"/>`;
|
|
152
153
|
let path = "shape";
|
|
153
154
|
if (g.type === "radial") path = "circle";
|
|
154
155
|
else if (g.type === "rectangular") path = "rect";
|
|
@@ -544,7 +545,7 @@ function serializeRunContent(content) {
|
|
|
544
545
|
case "drawing":
|
|
545
546
|
if (content.rawXml && canReplayEditableImageRawXml(content)) return content.rawXml;
|
|
546
547
|
return serializeDrawingContent(content);
|
|
547
|
-
case "shape": return serializeShapeContent(content);
|
|
548
|
+
case "shape": return replayableShapeAlternateContent(content) ?? serializeShapeContent(content);
|
|
548
549
|
default: return "";
|
|
549
550
|
}
|
|
550
551
|
}
|
|
@@ -633,4 +634,4 @@ function createTabRun(formatting) {
|
|
|
633
634
|
};
|
|
634
635
|
}
|
|
635
636
|
//#endregion
|
|
636
|
-
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns };
|
|
637
|
+
export { createBreakRun, createEmptyRun, createTabRun, createTextRun, getRunPlainText, hasRunFormatting, resetAutoIdCounter, serializeRun, serializeRuns, serializeShapeTextBody };
|
|
@@ -2,11 +2,29 @@ import { serializePartElement } from "./partNamespaces.js";
|
|
|
2
2
|
import { intAttr } from "./xmlUtils.js";
|
|
3
3
|
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
4
4
|
//#region src/docx/serializer/settingsSerializer.ts
|
|
5
|
+
/** `w:compatSetting/@w:uri` the named application compatibility settings share. */
|
|
6
|
+
const COMPAT_SETTING_URI = "http://schemas.microsoft.com/office/word";
|
|
7
|
+
/**
|
|
8
|
+
* Named compatibility settings written on alongside `compatibilityMode` 15 and
|
|
9
|
+
* later. Layout never gates run typography on a compatibility setting and
|
|
10
|
+
* never flips `w:mirrorIndents`, so declaring both on describes how the
|
|
11
|
+
* package is already laid out.
|
|
12
|
+
*/
|
|
13
|
+
const MODERN_COMPAT_SETTINGS = ["enableOpenTypeFeatures", "doNotFlipMirrorIndents"];
|
|
14
|
+
const FIRST_MODERN_COMPATIBILITY_MODE = 15;
|
|
15
|
+
const compatSettingXml = (name, val) => `<w:compatSetting w:name="${name}" w:uri="${COMPAT_SETTING_URI}" w:val="${intAttr(val)}"/>`;
|
|
16
|
+
const serializeCompat = (compatibilityMode) => {
|
|
17
|
+
if (compatibilityMode === void 0) return "";
|
|
18
|
+
const settings = [compatSettingXml("compatibilityMode", compatibilityMode)];
|
|
19
|
+
if (compatibilityMode >= FIRST_MODERN_COMPATIBILITY_MODE) for (const name of MODERN_COMPAT_SETTINGS) settings.push(compatSettingXml(name, 1));
|
|
20
|
+
return `<w:compat>${settings.join("")}</w:compat>`;
|
|
21
|
+
};
|
|
5
22
|
const serializeSettingsXml = (settings) => {
|
|
6
23
|
const parts = [
|
|
7
24
|
`<w:defaultTabStop w:val="${intAttr(settings.defaultTabStop)}"/>`,
|
|
8
25
|
serializeOnOffElement(settings.evenAndOddHeaders, "evenAndOddHeaders"),
|
|
9
|
-
serializeOnOffElement(settings.updateFields, "updateFields")
|
|
26
|
+
serializeOnOffElement(settings.updateFields, "updateFields"),
|
|
27
|
+
serializeCompat(settings.compatibilityMode)
|
|
10
28
|
];
|
|
11
29
|
if (settings.themeFontLang) {
|
|
12
30
|
const attrs = [];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseEndnoteProperties } from "./notePropertiesParser.js";
|
|
1
2
|
import { WORDPROCESSINGML_NAMESPACE_URIS, findChild, findChildByNamespaceUri, findChildren, getAttribute, parseBooleanElement, parseXmlDocument } from "./xmlParser.js";
|
|
2
3
|
//#region src/docx/settingsParser.ts
|
|
3
4
|
/** OOXML default per §17.6.13 when `w:defaultTabStop` is absent. */
|
|
@@ -61,6 +62,8 @@ function parseSettings(xml) {
|
|
|
61
62
|
const wordprocessingCompat = root ? findChildByNamespaceUri(root, WORDPROCESSINGML_NAMESPACE_URIS, "compat") : null;
|
|
62
63
|
const adjustLineHeightInTable = wordprocessingCompat ? findChildByNamespaceUri(wordprocessingCompat, WORDPROCESSINGML_NAMESPACE_URIS, "adjustLineHeightInTable") : null;
|
|
63
64
|
if (adjustLineHeightInTable && parseBooleanElement(adjustLineHeightInTable)) settings.adjustLineHeightInTable = true;
|
|
65
|
+
const doNotUseIndentAsNumberingTabStop = wordprocessingCompat ? findChildByNamespaceUri(wordprocessingCompat, WORDPROCESSINGML_NAMESPACE_URIS, "doNotUseIndentAsNumberingTabStop") : null;
|
|
66
|
+
if (doNotUseIndentAsNumberingTabStop && parseBooleanElement(doNotUseIndentAsNumberingTabStop)) settings.doNotUseIndentAsNumberingTabStop = true;
|
|
64
67
|
const applyBreakingRules = compat ? findChild(compat, "w", "applyBreakingRules") : null;
|
|
65
68
|
const useLegacyEthiopicAmharicRules = applyBreakingRules !== null && parseBooleanElement(applyBreakingRules);
|
|
66
69
|
if (noLineBreaksBefore || noLineBreaksAfter || useLegacyEthiopicAmharicRules) settings.lineBreakRules = {
|
|
@@ -68,6 +71,11 @@ function parseSettings(xml) {
|
|
|
68
71
|
...noLineBreaksAfter ? { noLineBreaksAfter } : {},
|
|
69
72
|
...useLegacyEthiopicAmharicRules ? { useLegacyEthiopicAmharicRules: true } : {}
|
|
70
73
|
};
|
|
74
|
+
const endnotePr = root ? findChild(root, "w", "endnotePr") : null;
|
|
75
|
+
if (endnotePr) {
|
|
76
|
+
const endnoteProperties = parseEndnoteProperties(endnotePr);
|
|
77
|
+
if (Object.keys(endnoteProperties).length > 0) settings.endnotePr = endnoteProperties;
|
|
78
|
+
}
|
|
71
79
|
return settings;
|
|
72
80
|
}
|
|
73
81
|
function parseCompatibilityMode(compat) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Shape, ShapeAlternateContent, ShapeContent } from "../types/content.js";
|
|
2
|
+
import { XmlElement } from "./xmlParser.js";
|
|
3
|
+
//#region src/docx/shapeAlternateContent.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Capture the `mc:AlternateContent` a shape was read from, when the shape's
|
|
6
|
+
* drawing is the sole child of the branch it came from.
|
|
7
|
+
*/
|
|
8
|
+
declare const captureShapeAlternateContent: ({ shape, alternateContent, branch, drawing }: {
|
|
9
|
+
shape: Shape;
|
|
10
|
+
alternateContent: XmlElement;
|
|
11
|
+
branch: XmlElement;
|
|
12
|
+
drawing: XmlElement;
|
|
13
|
+
}) => ShapeAlternateContent | undefined;
|
|
14
|
+
/** Re-fingerprint a capture for a shape rebuilt from an unedited projection. */
|
|
15
|
+
declare const refingerprintShapeAlternateContent: (shape: Shape, verbatimXml: string) => ShapeAlternateContent;
|
|
16
|
+
/**
|
|
17
|
+
* The captured `mc:AlternateContent` to write in place of the shape's drawing,
|
|
18
|
+
* or undefined when the shape must be regenerated.
|
|
19
|
+
*
|
|
20
|
+
* Replay requires the modeled shape to still match the capture. An edited shape
|
|
21
|
+
* is regenerated as a bare `w:drawing` without the stale Fallback.
|
|
22
|
+
*/
|
|
23
|
+
declare const replayableShapeAlternateContent: (content: ShapeContent) => string | undefined;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { captureShapeAlternateContent, refingerprintShapeAlternateContent, replayableShapeAlternateContent };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
2
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
|
+
import { getChildElements, getLocalName } from "./xmlParser.js";
|
|
4
|
+
//#region src/docx/shapeAlternateContent.ts
|
|
5
|
+
/**
|
|
6
|
+
* Every modeled field, text body included: the Fallback repeats the shape's
|
|
7
|
+
* geometry and its text, so an edit to either makes the captured element stale.
|
|
8
|
+
*/
|
|
9
|
+
const shapeFingerprint = (shape) => canonicalJson(shape);
|
|
10
|
+
/**
|
|
11
|
+
* Whether `element` is the only child element of its `mc:Choice` or
|
|
12
|
+
* `mc:Fallback` branch.
|
|
13
|
+
*
|
|
14
|
+
* A branch holding more than the one drawing cannot be written back by the
|
|
15
|
+
* drawing's shape alone: the siblings are parsed into their own run content,
|
|
16
|
+
* and replaying the whole element would write them twice.
|
|
17
|
+
*/
|
|
18
|
+
const isSoleBranchChild = (branch, element) => {
|
|
19
|
+
const children = getChildElements(branch);
|
|
20
|
+
return children.length === 1 && children[0] === element;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Capture the `mc:AlternateContent` a shape was read from, when the shape's
|
|
24
|
+
* drawing is the sole child of the branch it came from.
|
|
25
|
+
*/
|
|
26
|
+
const captureShapeAlternateContent = ({ shape, alternateContent, branch, drawing }) => {
|
|
27
|
+
if (getLocalName(alternateContent.name ?? "") !== "AlternateContent") return;
|
|
28
|
+
if (!isSoleBranchChild(branch, drawing)) return;
|
|
29
|
+
return {
|
|
30
|
+
verbatimXml: captureVerbatimXml(alternateContent),
|
|
31
|
+
verbatimFingerprint: shapeFingerprint(shape)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** Re-fingerprint a capture for a shape rebuilt from an unedited projection. */
|
|
35
|
+
const refingerprintShapeAlternateContent = (shape, verbatimXml) => ({
|
|
36
|
+
verbatimXml,
|
|
37
|
+
verbatimFingerprint: shapeFingerprint(shape)
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* The captured `mc:AlternateContent` to write in place of the shape's drawing,
|
|
41
|
+
* or undefined when the shape must be regenerated.
|
|
42
|
+
*
|
|
43
|
+
* Replay requires the modeled shape to still match the capture. An edited shape
|
|
44
|
+
* is regenerated as a bare `w:drawing` without the stale Fallback.
|
|
45
|
+
*/
|
|
46
|
+
const replayableShapeAlternateContent = (content) => {
|
|
47
|
+
const captured = content.alternateContent;
|
|
48
|
+
if (captured === void 0) return;
|
|
49
|
+
return captured.verbatimFingerprint === shapeFingerprint(content.shape) ? captured.verbatimXml : void 0;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
export { captureShapeAlternateContent, refingerprintShapeAlternateContent, replayableShapeAlternateContent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XmlElement } from "./xmlParser.js";
|
|
1
|
+
import { XmlElement, XmlNamespaceScope } from "./xmlParser.js";
|
|
2
2
|
//#region src/docx/streamingXmlParser.d.ts
|
|
3
3
|
type ParseXmlResult = {
|
|
4
4
|
status: "parsed";
|
|
@@ -16,7 +16,11 @@ type AttributeValueSpan = {
|
|
|
16
16
|
end: number;
|
|
17
17
|
};
|
|
18
18
|
type OpenTagVisitor = (element: XmlElement, attributeValueSpans: ReadonlyMap<string, AttributeValueSpan>) => ReadonlyMap<string, string> | null;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param inheritedNamespaceScope the bindings in scope around `xml`, for a
|
|
21
|
+
* fragment captured out of a part whose root declared them.
|
|
22
|
+
*/
|
|
23
|
+
declare const parseStreamingXml: (xml: string, inheritedNamespaceScope?: XmlNamespaceScope) => ParseXmlResult;
|
|
20
24
|
/** Rewrite selected decimal attribute values while preserving every other source byte. */
|
|
21
25
|
declare const rewriteStreamingXmlDecimalAttributes: (xml: string, visitOpenTag: OpenTagVisitor) => {
|
|
22
26
|
status: "rewritten";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attachXmlNamespaceContext } from "./
|
|
1
|
+
import { EMPTY_NAMESPACE_SCOPE, attachXmlNamespaceContext } from "./xmlNamespaceContext.js";
|
|
2
2
|
import { FOLIO_XML_RESOURCE_LIMITS } from "./xmlResourceLimits.js";
|
|
3
3
|
//#region src/docx/streamingXmlParser.ts
|
|
4
4
|
const BUILT_IN_ENTITIES = {
|
|
@@ -8,7 +8,7 @@ const BUILT_IN_ENTITIES = {
|
|
|
8
8
|
lt: "<",
|
|
9
9
|
quot: "\""
|
|
10
10
|
};
|
|
11
|
-
const parseStreamingXmlInternal = (xml, visitOpenTag) => {
|
|
11
|
+
const parseStreamingXmlInternal = (xml, visitOpenTag, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) => {
|
|
12
12
|
const root = { elements: [] };
|
|
13
13
|
const stack = [];
|
|
14
14
|
const replacements = [];
|
|
@@ -39,6 +39,7 @@ const parseStreamingXmlInternal = (xml, visitOpenTag) => {
|
|
|
39
39
|
const close = xml.indexOf("?>", open + 2);
|
|
40
40
|
if (close === -1) return { status: "unsupported" };
|
|
41
41
|
cursor = close + 2;
|
|
42
|
+
mergeAdjacentText = false;
|
|
42
43
|
continue;
|
|
43
44
|
}
|
|
44
45
|
if (xml.startsWith("<!", open)) return { status: "unsupported" };
|
|
@@ -54,8 +55,8 @@ const parseStreamingXmlInternal = (xml, visitOpenTag) => {
|
|
|
54
55
|
}
|
|
55
56
|
const parsedTag = parseOpenTag(xml, open + 1, close, visitOpenTag !== void 0);
|
|
56
57
|
if (parsedTag.status === "unsupported") return parsedTag;
|
|
57
|
-
const parent = stack.at(-1)?.element
|
|
58
|
-
attachXmlNamespaceContext(parsedTag.element, parent.namespaceScope);
|
|
58
|
+
const parent = stack.at(-1)?.element;
|
|
59
|
+
attachXmlNamespaceContext(parsedTag.element, parent === void 0 ? inheritedNamespaceScope : parent.namespaceScope);
|
|
59
60
|
const rewritten = visitOpenTag?.(parsedTag.element, parsedTag.attributeValueSpans ?? /* @__PURE__ */ new Map());
|
|
60
61
|
if (rewritten) for (const [attributeName, value] of rewritten) {
|
|
61
62
|
const span = parsedTag.attributeValueSpans?.get(attributeName);
|
|
@@ -65,7 +66,7 @@ const parseStreamingXmlInternal = (xml, visitOpenTag) => {
|
|
|
65
66
|
value
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
|
-
appendElement(parent, parsedTag.element);
|
|
69
|
+
appendElement(parent ?? root, parsedTag.element);
|
|
69
70
|
if (!parsedTag.selfClosing) {
|
|
70
71
|
if (stack.length >= FOLIO_XML_RESOURCE_LIMITS.maxDepth) return { status: "unsupported" };
|
|
71
72
|
stack.push({
|
|
@@ -83,8 +84,12 @@ const parseStreamingXmlInternal = (xml, visitOpenTag) => {
|
|
|
83
84
|
replacements
|
|
84
85
|
};
|
|
85
86
|
};
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @param inheritedNamespaceScope the bindings in scope around `xml`, for a
|
|
89
|
+
* fragment captured out of a part whose root declared them.
|
|
90
|
+
*/
|
|
91
|
+
const parseStreamingXml = (xml, inheritedNamespaceScope = EMPTY_NAMESPACE_SCOPE) => {
|
|
92
|
+
const parsed = parseStreamingXmlInternal(xml, void 0, inheritedNamespaceScope);
|
|
88
93
|
return parsed.status === "parsed" ? {
|
|
89
94
|
status: "parsed",
|
|
90
95
|
value: parsed.value
|
package/dist/docx/styleParser.js
CHANGED
|
@@ -407,22 +407,48 @@ function resolveStyleInheritance(style, styleMap, visited = /* @__PURE__ */ new
|
|
|
407
407
|
const mergedRPr = mergeStyleTextFormatting(resolvedParent.rPr, style.rPr);
|
|
408
408
|
if (mergedRPr) resolved.rPr = mergedRPr;
|
|
409
409
|
if (style.type === "table") {
|
|
410
|
-
if (resolvedParent.tblPr || style.tblPr)
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
410
|
+
if (resolvedParent.tblPr || style.tblPr) {
|
|
411
|
+
const tblPr = {
|
|
412
|
+
...resolvedParent.tblPr,
|
|
413
|
+
...style.tblPr
|
|
414
|
+
};
|
|
415
|
+
const borders = mergeSides(resolvedParent.tblPr?.borders, style.tblPr?.borders);
|
|
416
|
+
if (borders) tblPr.borders = borders;
|
|
417
|
+
const cellMargins = mergeSides(resolvedParent.tblPr?.cellMargins, style.tblPr?.cellMargins);
|
|
418
|
+
if (cellMargins) tblPr.cellMargins = cellMargins;
|
|
419
|
+
resolved.tblPr = tblPr;
|
|
420
|
+
}
|
|
414
421
|
if (resolvedParent.trPr || style.trPr) resolved.trPr = {
|
|
415
422
|
...resolvedParent.trPr,
|
|
416
423
|
...style.trPr
|
|
417
424
|
};
|
|
418
|
-
if (resolvedParent.tcPr || style.tcPr)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
425
|
+
if (resolvedParent.tcPr || style.tcPr) {
|
|
426
|
+
const tcPr = {
|
|
427
|
+
...resolvedParent.tcPr,
|
|
428
|
+
...style.tcPr
|
|
429
|
+
};
|
|
430
|
+
const borders = mergeSides(resolvedParent.tcPr?.borders, style.tcPr?.borders);
|
|
431
|
+
if (borders) tcPr.borders = borders;
|
|
432
|
+
const margins = mergeSides(resolvedParent.tcPr?.margins, style.tcPr?.margins);
|
|
433
|
+
if (margins) tcPr.margins = margins;
|
|
434
|
+
resolved.tcPr = tcPr;
|
|
435
|
+
}
|
|
422
436
|
}
|
|
423
437
|
return resolved;
|
|
424
438
|
}
|
|
425
439
|
/**
|
|
440
|
+
* Each child of `w:tblBorders`, `w:tcBorders`, `w:tblCellMar` and `w:tcMar` is
|
|
441
|
+
* its own property, so a style that states one side inherits the others from
|
|
442
|
+
* its `w:basedOn` parent (ECMA-376 §17.7.4.3).
|
|
443
|
+
*/
|
|
444
|
+
function mergeSides(parent, child) {
|
|
445
|
+
if (!parent || !child) return child ?? parent;
|
|
446
|
+
return {
|
|
447
|
+
...parent,
|
|
448
|
+
...child
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
426
452
|
* Parse styles.xml content
|
|
427
453
|
*
|
|
428
454
|
* @param stylesXml - XML content of styles.xml
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
3
|
import { XmlElement } from "./xmlParser.js";
|
|
4
|
+
import { PreviewLedger } from "./previewBudget.js";
|
|
4
5
|
import { StyleMap } from "./styleParser.js";
|
|
5
6
|
//#region src/docx/tableParser.d.ts
|
|
6
7
|
/**
|
|
@@ -89,7 +90,7 @@ declare function parseConditionalFormatStyle(cnfElement: XmlElement | null): doc
|
|
|
89
90
|
*/
|
|
90
91
|
declare function parseTableCellProperties(tcPrElement: XmlElement | null): document_d_exports.TableCellFormatting | undefined;
|
|
91
92
|
/**
|
|
92
|
-
* Parse
|
|
93
|
+
* Parse table cell content, including nested block controls.
|
|
93
94
|
*
|
|
94
95
|
* @param tcElement - The w:tc element
|
|
95
96
|
* @param styles - Style definitions
|
|
@@ -97,12 +98,26 @@ declare function parseTableCellProperties(tcPrElement: XmlElement | null): docum
|
|
|
97
98
|
* @param numbering - Numbering definitions for lists
|
|
98
99
|
* @param rels - Relationships for hyperlinks
|
|
99
100
|
* @param media - Media files for images
|
|
100
|
-
* @returns
|
|
101
|
+
* @returns Array of content blocks
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
+
type TableParseOptions = {
|
|
103
104
|
inHeaderFooter?: boolean;
|
|
104
105
|
rootXmlns?: Record<string, string>;
|
|
105
|
-
|
|
106
|
+
/** The ledger of the package this table belongs to; a table read on its own has none. */
|
|
107
|
+
previews?: PreviewLedger;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Parse a table cell (w:tc)
|
|
111
|
+
*
|
|
112
|
+
* @param tcElement - The w:tc element
|
|
113
|
+
* @param styles - Style definitions
|
|
114
|
+
* @param theme - Theme for color/font resolution
|
|
115
|
+
* @param numbering - Numbering definitions for lists
|
|
116
|
+
* @param rels - Relationships for hyperlinks
|
|
117
|
+
* @param media - Media files for images
|
|
118
|
+
* @returns Parsed table cell
|
|
119
|
+
*/
|
|
120
|
+
declare function parseTableCell(tcElement: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: TableParseOptions): document_d_exports.TableCell;
|
|
106
121
|
/**
|
|
107
122
|
* Parse a table row (w:tr)
|
|
108
123
|
*
|
|
@@ -114,10 +129,7 @@ declare function parseTableCell(tcElement: XmlElement, styles: StyleMap | null,
|
|
|
114
129
|
* @param media - Media files for images
|
|
115
130
|
* @returns Parsed table row
|
|
116
131
|
*/
|
|
117
|
-
declare function parseTableRow(trElement: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?:
|
|
118
|
-
inHeaderFooter?: boolean;
|
|
119
|
-
rootXmlns?: Record<string, string>;
|
|
120
|
-
}): document_d_exports.TableRow;
|
|
132
|
+
declare function parseTableRow(trElement: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: TableParseOptions): document_d_exports.TableRow;
|
|
121
133
|
/**
|
|
122
134
|
* Parse table grid (w:tblGrid) for column widths
|
|
123
135
|
*
|
|
@@ -136,10 +148,7 @@ declare function parseTableGrid(tblGridElement: XmlElement | null): number[] | u
|
|
|
136
148
|
* @param media - Media files for images
|
|
137
149
|
* @returns Parsed table
|
|
138
150
|
*/
|
|
139
|
-
declare function parseTable(tblElement: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?:
|
|
140
|
-
inHeaderFooter?: boolean;
|
|
141
|
-
rootXmlns?: Record<string, string>;
|
|
142
|
-
}): document_d_exports.Table | undefined;
|
|
151
|
+
declare function parseTable(tblElement: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: TableParseOptions): document_d_exports.Table | undefined;
|
|
143
152
|
/**
|
|
144
153
|
* Get the number of columns in a table
|
|
145
154
|
*
|