@stll/folio-core 0.73.0 → 0.75.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/clean-text.d.ts +4 -1
- package/dist/ai-edits/clean-text.js +21 -7
- package/dist/ai-edits/headless.d.ts +5 -2
- package/dist/ai-edits/headless.js +20 -14
- package/dist/ai-edits/note-references.d.ts +1 -1
- package/dist/ai-edits/note-references.js +1 -1
- package/dist/ai-edits/pending-suggestions.d.ts +9 -7
- package/dist/ai-edits/pending-suggestions.js +134 -88
- package/dist/ai-edits/pendingJoin.d.ts +5 -1
- package/dist/ai-edits/pendingJoin.js +12 -3
- package/dist/ai-edits/result-validation.js +1 -1
- package/dist/ai-edits/retired-comment-receipts.d.ts +2 -2
- package/dist/ai-edits/retired-comment-receipts.js +3 -18
- package/dist/ai-edits/snapshot.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +1 -1
- package/dist/ai-edits/tracked-batch-fidelity.d.ts +6 -10
- package/dist/ai-edits/tracked-batch-fidelity.js +3 -182
- package/dist/canonical/canonicalBatchReview.d.ts +4 -1
- package/dist/canonical/canonicalBatchReview.js +32 -14
- package/dist/canonical/canonicalComments.d.ts +6 -2
- package/dist/canonical/canonicalComments.js +8 -4
- package/dist/canonical/canonicalInlineGaps.d.ts +56 -0
- package/dist/canonical/canonicalInlineGaps.js +118 -0
- package/dist/canonical/canonicalInlineProjection.d.ts +4 -13
- package/dist/canonical/canonicalInlineProjection.js +6 -28
- package/dist/canonical/canonicalProjectionBlocks.d.ts +4 -4
- package/dist/canonical/canonicalPublicOperations.js +99 -36
- package/dist/canonical/canonicalRefusalGrounds.d.ts +4 -0
- package/dist/canonical/canonicalRefusalGrounds.js +56 -0
- package/dist/canonical/canonicalSelection.js +1 -1
- package/dist/canonical/canonicalSession.d.ts +12 -6
- package/dist/canonical/canonicalSession.js +129 -141
- package/dist/canonical/canonicalTrackedBatchFidelity.js +3 -3
- package/dist/compare/inline-atoms.d.ts +35 -41
- package/dist/compare/inline-atoms.js +2 -465
- package/dist/compare/section-boundary-properties.d.ts +3 -30
- package/dist/compare/section-boundary-properties.js +4 -72
- package/dist/controller/autocompleteSuggestion.js +1 -1
- package/dist/controller/canonicalClipboard.js +45 -44
- package/dist/controller/canonicalComposition.d.ts +1 -1
- package/dist/controller/canonicalComposition.js +6 -6
- package/dist/controller/canonicalInput.d.ts +4 -2
- package/dist/controller/canonicalInput.js +34 -17
- package/dist/controller/canonicalPresence.js +1 -1
- package/dist/controller/canonicalRoomAuthority.js +1 -1
- package/dist/controller/canonicalRoomWire.js +1 -1
- package/dist/controller/canonicalStoryEditor.d.ts +2 -3
- package/dist/controller/canonicalStoryEditor.js +43 -25
- package/dist/controller/canonicalStructure.d.ts +19 -2
- package/dist/controller/canonicalStructure.js +140 -43
- package/dist/controller/canonicalTabRoom.js +1 -1
- package/dist/controller/canonicalYjsRoom.js +1 -1
- package/dist/controller/deferredDisplayListPainter.d.ts +8 -0
- package/dist/controller/deferredDisplayListPainter.js +34 -0
- package/dist/controller/folioEditor.js +4 -2
- package/dist/controller/headerFooterEditorManager.js +3 -17
- package/dist/controller/hiddenEditorApi.d.ts +24 -3
- package/dist/controller/hiddenEditorApi.js +4 -17
- package/dist/controller/hiddenEditorManager.js +136 -197
- package/dist/controller/layoutPipeline.d.ts +4 -86
- package/dist/controller/layoutPipeline.js +8 -727
- package/dist/controller/layoutPipelineExecution.d.ts +94 -0
- package/dist/controller/layoutPipelineExecution.js +730 -0
- package/dist/controller/noteEditorManager.js +3 -16
- package/dist/document-operations.js +1 -1
- package/dist/docx/blockContentParser.d.ts +1 -3
- package/dist/docx/blockContentParser.js +3 -10
- package/dist/docx/canonicalSave.d.ts +4 -3
- package/dist/docx/canonicalSave.js +4 -3
- package/dist/docx/canonicalSessionInput.js +1 -1
- package/dist/docx/containerChildren.js +1 -1
- package/dist/docx/createDocx.d.ts +4 -0
- package/dist/docx/createDocx.js +6 -0
- package/dist/docx/listMarkerComputation.d.ts +24 -17
- package/dist/docx/listMarkerComputation.js +31 -60
- package/dist/docx/listModelNormalization.js +8 -15
- package/dist/docx/modelValidation.js +1 -1
- package/dist/docx/parser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.js +1 -1
- package/dist/docx/rezip.d.ts +16 -3
- package/dist/docx/rezip.js +36 -10
- package/dist/docx/selectiveSave.js +13 -5
- package/dist/docx/serializer/borderSerializer.js +1 -1
- package/dist/docx/serializer/commentSerializer.js +1 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +3 -3
- package/dist/docx/serializer/runSerializer.js +1 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +1 -1
- package/dist/docx/serializer/tableSerializer.js +1 -1
- package/dist/docx/serializer/textFormattingSerializer.js +1 -1
- package/dist/docx/serializer/trackedChangeAttributes.js +1 -1
- package/dist/docx/server/templatePlan/apply.js +107 -14
- package/dist/docx/server/templatePlan/blocks.d.ts +16 -1
- package/dist/docx/server/templatePlan/blocks.js +93 -7
- package/dist/docx/server/templatePlan/builders.d.ts +37 -2
- package/dist/docx/server/templatePlan/builders.js +196 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +2 -0
- package/dist/docx/server/templatePlan/inspect.js +81 -61
- package/dist/docx/server/templatePlan/labels.d.ts +16 -2
- package/dist/docx/server/templatePlan/labels.js +131 -20
- package/dist/docx/server/templatePlan/plan.d.ts +15 -1
- package/dist/docx/server/templatePlan/plan.js +62 -13
- package/dist/docx/server/templatePlan/planShape.js +52 -4
- package/dist/docx/server/templatePlan/story.d.ts +8 -0
- package/dist/docx/server/templatePlan/story.js +11 -1
- package/dist/docx/server/templatePlan/types.d.ts +176 -18
- package/dist/docx/server/templatePlan/types.js +1 -0
- package/dist/docx/server/templatePlan/verify.js +60 -11
- package/dist/docx/server/templatePlan/xml.d.ts +5 -0
- package/dist/docx/server/templatePlan/xml.js +7 -1
- package/dist/docx/storyBlockReplay.js +1 -1
- package/dist/docx/xmlParser.js +1 -1
- package/dist/i18n/loadMessages.d.ts +5 -0
- package/dist/i18n/loadMessages.js +46 -0
- package/dist/i18n/locales.d.ts +3 -0
- package/dist/i18n/locales.js +17 -0
- package/dist/i18n/messages/ar.gen.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +17 -0
- package/dist/i18n/messages/catalogs.gen.js +17 -0
- package/dist/i18n/messages/cs.gen.js +1 -0
- package/dist/i18n/messages/de.gen.js +1 -0
- package/dist/i18n/messages/en.gen.js +1 -0
- package/dist/i18n/messages/es.gen.js +1 -0
- package/dist/i18n/messages/et.gen.js +1 -0
- package/dist/i18n/messages/fr.gen.js +1 -0
- package/dist/i18n/messages/he.gen.js +1 -0
- package/dist/i18n/messages/hi.gen.js +1 -0
- package/dist/i18n/messages/hu.gen.js +1 -0
- package/dist/i18n/messages/lt.gen.js +1 -0
- package/dist/i18n/messages/lv.gen.js +1 -0
- package/dist/i18n/messages/messages.gen.d.ts +1 -0
- package/dist/i18n/messages/pl.gen.js +1 -0
- package/dist/i18n/messages/pt-BR.gen.js +1 -0
- package/dist/i18n/messages/sk.gen.js +1 -0
- package/dist/i18n/messages/tr.gen.js +1 -0
- package/dist/i18n/messages/zh-CN.gen.js +1 -0
- package/dist/i18n/messages.d.ts +3 -2
- package/dist/i18n/messages.js +4 -16
- package/dist/internal/clipboardTransformPlugin.d.ts +3 -0
- package/dist/internal/clipboardTransformPlugin.js +13 -0
- package/dist/internal/extensionRuntime.d.ts +7 -0
- package/dist/internal/extensionRuntime.js +28 -0
- package/dist/internal/paragraphFormattingSerialization.js +1 -1
- package/dist/internal/starterKitExtensions.d.ts +20 -0
- package/dist/internal/starterKitExtensions.js +123 -0
- package/dist/internal/wholeStoryRevisionResolution.js +2 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +0 -12
- package/dist/layout-bridge/convert/topLevelConversion.js +1 -10
- package/dist/prosemirror/attrs/index.js +1 -1
- package/dist/prosemirror/canonicalSelectionRange.js +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -1
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/contentControls.js +1 -1
- package/dist/prosemirror/commands/pastePlainText.js +2 -3
- package/dist/prosemirror/commands/replaceRangeText.js +1 -1
- package/dist/prosemirror/commentRecords.js +2 -2
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -5
- package/dist/prosemirror/conversion/fromProseDoc.js +2 -9
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/index.js +2 -2
- package/dist/prosemirror/extensions/ExtensionManager.js +4 -22
- package/dist/prosemirror/extensions/StarterKit.d.ts +4 -27
- package/dist/prosemirror/extensions/StarterKit.js +29 -115
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -2
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +7 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/index.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +7 -40
- package/dist/prosemirror/hyperlinkRemoval.js +7 -2
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/keptRangeBoundaries.js +1 -1
- package/dist/prosemirror/listMarker.d.ts +1 -6
- package/dist/prosemirror/listMarker.js +4 -56
- package/dist/prosemirror/listNumbering.js +1 -1
- package/dist/prosemirror/noteReferenceOccurrences.js +1 -1
- package/dist/prosemirror/noteReferenceReview.d.ts +2 -56
- package/dist/prosemirror/noteReferenceReview.js +2 -243
- package/dist/prosemirror/pastedCommentCopies.js +1 -1
- package/dist/prosemirror/plugins/documentNumbering.js +1 -1
- package/dist/prosemirror/plugins/documentStyles.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -1
- package/dist/prosemirror/suggestionCommands.d.ts +47 -0
- package/dist/prosemirror/suggestionCommands.js +31 -0
- package/dist/prosemirror/tableCellPaste.js +1 -1
- package/dist/prosemirror/tableRunIn.js +1 -1
- package/dist/prosemirror/textInput.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +42 -93
- package/dist/types/canonicalCapabilities.js +53 -91
- package/dist/types/canonicalComments.d.ts +2 -2
- package/dist/types/canonicalSections.d.ts +2 -2
- package/dist/utils/clipboard.d.ts +2 -28
- package/dist/utils/clipboard.js +1 -96
- package/dist/utils/clipboardFiles.d.ts +27 -0
- package/dist/utils/clipboardFiles.js +98 -0
- package/dist/utils/rulerControl.d.ts +1 -0
- package/dist/utils/rulerControl.js +2 -1
- package/package.json +2 -2
- package/dist/ai-edits/apply.d.ts +0 -94
- package/dist/ai-edits/apply.js +0 -6637
- package/dist/ai-edits/note-story-inventory.d.ts +0 -5
- package/dist/ai-edits/note-story-inventory.js +0 -10
- package/dist/ai-edits/revisionStretches.d.ts +0 -32
- package/dist/ai-edits/revisionStretches.js +0 -147
- package/dist/document-operations-apply.d.ts +0 -15
- package/dist/document-operations-apply.js +0 -280
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -12
- package/dist/prosemirror/extensions/core/HistoryExtension.js +0 -114
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -23
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +0 -270
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +0 -51
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +0 -411
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -92
- package/dist/prosemirror/plugins/suggestionMode.js +0 -1515
- package/dist/prosemirror/tablePositionedBookmarks.d.ts +0 -8
- package/dist/prosemirror/tablePositionedBookmarks.js +0 -80
package/dist/docx/rezip.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { consumeTrackedSectionEndpointRemoval } from "../internal/sectionEndpointResolution.js";
|
|
2
2
|
import { consumeSectionReferenceResolution } from "../internal/sectionReferenceResolution.js";
|
|
3
|
-
import { CANONICAL_GAP } from "../types/canonicalCapabilities.js";
|
|
4
3
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
5
4
|
import { base64ToBytes, decodeText, encodeUtf8 } from "../utils/textEncoding.js";
|
|
6
5
|
import { isAllowedExternalWatermarkImageUrl } from "../watermark/index.js";
|
|
@@ -44,8 +43,8 @@ import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
|
44
43
|
import { hasCanonicalWordprocessingPrefixes } from "./wordprocessingPrefixes.js";
|
|
45
44
|
import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, findAttributeByNamespaceUri, findChild, findChildByNamespaceUri, findChildrenByNamespaceUri, getAttribute, getAttributeByNamespaceUri, getChildElements, getLocalName, getNamespaceUri, matchesName, parseXml, parseXmlDocument, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
46
45
|
import { Result, TaggedError, panic } from "better-result";
|
|
47
|
-
import { mintRelationshipId, numberingInstanceResolves } from "@stll/docx-core/model";
|
|
48
46
|
import { assertValidOoxmlNumericIds, escapeXmlAttribute, escapeXmlText, validateDocxPackage } from "@stll/docx-core";
|
|
47
|
+
import { mintRelationshipId, numberingInstanceResolves } from "@stll/docx-core/model";
|
|
49
48
|
import { getXmlSourceRange, parseStreamingXmlWithSourceRanges } from "@stll/docx-core/xml";
|
|
50
49
|
import { ZipArchive } from "@stll/docx-core/zip";
|
|
51
50
|
// src/docx/rezip.ts
|
|
@@ -451,6 +450,11 @@ const materializeEmbeddedMedia = async ({ document, zip, compressionLevel }) =>
|
|
|
451
450
|
await registerImageExtensions(zip, extensions, compressionLevel);
|
|
452
451
|
};
|
|
453
452
|
const CanonicalImageRelationshipRefusalErrorBase = TaggedError("CanonicalImageRelationshipRefusalError");
|
|
453
|
+
/**
|
|
454
|
+
* A picture the save cannot publish: the model and the package disagree on its
|
|
455
|
+
* relationship (`conflict` in the main document part, `unresolved`), its
|
|
456
|
+
* bytes are missing, or its target is unsafe.
|
|
457
|
+
*/
|
|
454
458
|
var CanonicalImageRelationshipRefusalError = class extends CanonicalImageRelationshipRefusalErrorBase {};
|
|
455
459
|
/**
|
|
456
460
|
* Write the media a canonical session replaced or removed since the package
|
|
@@ -504,7 +508,8 @@ const publishCanonicalMediaReplacements = async ({ document, zip, compressionLev
|
|
|
504
508
|
zip.set(registry.path, xml, { level: compressionLevel });
|
|
505
509
|
};
|
|
506
510
|
/** Publish allocated pictures into each owning story without rebinding canonical ids. */
|
|
507
|
-
const publishCanonicalImageResources = async ({ document, zip, compressionLevel }) => {
|
|
511
|
+
const publishCanonicalImageResources = async ({ document, zip, compressionLevel, rebind }) => {
|
|
512
|
+
const rebindingParts = [];
|
|
508
513
|
await publishCanonicalMediaReplacements({
|
|
509
514
|
document,
|
|
510
515
|
zip,
|
|
@@ -525,19 +530,25 @@ const publishCanonicalImageResources = async ({ document, zip, compressionLevel
|
|
|
525
530
|
const local = parseRelationships(xml);
|
|
526
531
|
const partPath = relsPath.replace("/_rels/", "/").replace(/\.rels$/u, "");
|
|
527
532
|
let changed = false;
|
|
533
|
+
const rebound = /* @__PURE__ */ new Map();
|
|
528
534
|
for (const image of images) {
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
535
|
+
const rootId = image.rId;
|
|
536
|
+
if (rootId === void 0) continue;
|
|
537
|
+
const reboundId = rebound.get(rootId);
|
|
538
|
+
if (reboundId !== void 0) {
|
|
539
|
+
image.rId = reboundId;
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
let id = rootId;
|
|
531
543
|
const refuse = (reason, message) => {
|
|
532
544
|
throw new CanonicalImageRelationshipRefusalError({
|
|
533
545
|
message,
|
|
534
|
-
gap: CANONICAL_GAP.save,
|
|
535
546
|
part: relsPath,
|
|
536
547
|
relationshipId: id,
|
|
537
548
|
reason
|
|
538
549
|
});
|
|
539
550
|
};
|
|
540
|
-
|
|
551
|
+
let source = local.get(id);
|
|
541
552
|
const allocated = document.package.relationships?.get(id);
|
|
542
553
|
const allocatedMediaPath = allocated?.targetMode === "External" || allocated?.type !== RELATIONSHIP_TYPES.image ? void 0 : resolveRelativePath("word/_rels/document.xml.rels", allocated.target);
|
|
543
554
|
const allocatedMedia = allocatedMediaPath === void 0 ? void 0 : document.package.media?.get(allocatedMediaPath);
|
|
@@ -550,7 +561,19 @@ const publishCanonicalImageResources = async ({ document, zip, compressionLevel
|
|
|
550
561
|
if (absolute !== void 0 && isUnsafePackagePath(absolute)) return refuse("unsafeTarget", "A canonical inline picture has an unsafe media target.");
|
|
551
562
|
if (source) {
|
|
552
563
|
const sourceAbsolute = source.targetMode === "External" ? void 0 : resolveRelativePath(relsPath, source.target);
|
|
553
|
-
if (source.type !== RELATIONSHIP_TYPES.image || source.targetMode === "External" !== (desired.targetMode === "External") || (absolute === void 0 ? source.target !== desired.target : sourceAbsolute !== absolute))
|
|
564
|
+
if (source.type !== RELATIONSHIP_TYPES.image || source.targetMode === "External" !== (desired.targetMode === "External") || (absolute === void 0 ? source.target !== desired.target : sourceAbsolute !== absolute)) {
|
|
565
|
+
if (desired !== allocated || relsPath === "word/_rels/document.xml.rels") return refuse("conflict", "A canonical inline picture relationship conflicts with its owning source binding.");
|
|
566
|
+
if (!rebind) {
|
|
567
|
+
if (!rebindingParts.includes(partPath)) rebindingParts.push(partPath);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
let index = 1;
|
|
571
|
+
while (local.has(`rId${index}`)) index += 1;
|
|
572
|
+
id = mintRelationshipId(index);
|
|
573
|
+
rebound.set(rootId, id);
|
|
574
|
+
image.rId = id;
|
|
575
|
+
source = void 0;
|
|
576
|
+
}
|
|
554
577
|
}
|
|
555
578
|
if (absolute !== void 0 && !findZipEntryCaseInsensitive(zip, absolute.toLowerCase())) {
|
|
556
579
|
const media = document.package.media?.get(absolute);
|
|
@@ -581,6 +604,7 @@ const publishCanonicalImageResources = async ({ document, zip, compressionLevel
|
|
|
581
604
|
}
|
|
582
605
|
if (changed) zip.set(relsPath, xml, { level: compressionLevel });
|
|
583
606
|
}
|
|
607
|
+
return rebindingParts;
|
|
584
608
|
};
|
|
585
609
|
const collectExternalHyperlinkResources = (blocks) => {
|
|
586
610
|
const resources = [];
|
|
@@ -853,7 +877,8 @@ const finishRepack = async ({ document: sourceDocument, originalZip, outputZip,
|
|
|
853
877
|
if (bodyAuthority === "canonical") await publishCanonicalImageResources({
|
|
854
878
|
document,
|
|
855
879
|
zip: outputZip,
|
|
856
|
-
compressionLevel
|
|
880
|
+
compressionLevel,
|
|
881
|
+
rebind: true
|
|
857
882
|
});
|
|
858
883
|
const parts = collectDocxParts(document, outputZip);
|
|
859
884
|
normalizeExportDrawingIds(document);
|
|
@@ -975,7 +1000,8 @@ async function repackDocxFromRaw(doc, rawContent, options = {}) {
|
|
|
975
1000
|
if (options.bodyAuthority === "canonical") await publishCanonicalImageResources({
|
|
976
1001
|
document: exportDocument,
|
|
977
1002
|
zip: newZip,
|
|
978
|
-
compressionLevel
|
|
1003
|
+
compressionLevel,
|
|
1004
|
+
rebind: true
|
|
979
1005
|
});
|
|
980
1006
|
const parts = collectDocxParts(exportDocument, newZip);
|
|
981
1007
|
normalizeExportDrawingIds(exportDocument);
|
|
@@ -346,11 +346,19 @@ async function writeChangedParts({ doc, originalBuffer, options, collectDiagnost
|
|
|
346
346
|
}
|
|
347
347
|
for (const [path, xml] of normalizeImportedNumericIds(sourceParts)) if (xml !== sourceParts.get(path)) zip.set(path, xml);
|
|
348
348
|
}
|
|
349
|
-
if (options.bodyAuthority === "canonical")
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
349
|
+
if (options.bodyAuthority === "canonical") {
|
|
350
|
+
const part = (await publishCanonicalImageResources({
|
|
351
|
+
document: doc,
|
|
352
|
+
zip,
|
|
353
|
+
compressionLevel: 6,
|
|
354
|
+
rebind: false
|
|
355
|
+
})).at(0);
|
|
356
|
+
if (part !== void 0) return decline({
|
|
357
|
+
scope: "part",
|
|
358
|
+
part,
|
|
359
|
+
reason: "unmaterializedStoryResource"
|
|
360
|
+
});
|
|
361
|
+
}
|
|
354
362
|
const updates = /* @__PURE__ */ new Map();
|
|
355
363
|
if (changedParaIds.size > 0 || structuralChange) {
|
|
356
364
|
const docXmlFile = zip.entry("word/document.xml");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
2
2
|
import { intAttr } from "./xmlUtils.js";
|
|
3
|
-
import { borderStyleToken, themeColorToken } from "@stll/docx-core/model";
|
|
4
3
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
4
|
+
import { borderStyleToken, themeColorToken } from "@stll/docx-core/model";
|
|
5
5
|
// src/docx/serializer/borderSerializer.ts
|
|
6
6
|
/**
|
|
7
7
|
* Shared single-border serializer for every `CT_Border` field — table borders
|
|
@@ -7,8 +7,8 @@ import { serializeParagraph } from "./paragraphSerializer.js";
|
|
|
7
7
|
import { serializePartElement } from "./partNamespaces.js";
|
|
8
8
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
9
9
|
import { Result } from "better-result";
|
|
10
|
-
import { COMMENT_PART_RELATIONSHIPS } from "@stll/docx-core/model";
|
|
11
10
|
import { assertValidOoxmlNumericIds, escapeXmlAttribute } from "@stll/docx-core";
|
|
11
|
+
import { COMMENT_PART_RELATIONSHIPS } from "@stll/docx-core/model";
|
|
12
12
|
// src/docx/serializer/commentSerializer.ts
|
|
13
13
|
/**
|
|
14
14
|
* Comment Serializer
|
|
@@ -10,8 +10,8 @@ import { serializePartElement } from "./partNamespaces.js";
|
|
|
10
10
|
import { resetAutoIdCounter } from "./runSerializer.js";
|
|
11
11
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
12
12
|
import { serializeTable } from "./tableSerializer.js";
|
|
13
|
-
import { themeColorToken } from "@stll/docx-core/model";
|
|
14
13
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
14
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
15
15
|
// src/docx/serializer/documentSerializer.ts
|
|
16
16
|
/**
|
|
17
17
|
* Document Serializer - Serialize complete document.xml
|
|
@@ -17,8 +17,8 @@ import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
|
17
17
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
18
18
|
import { serializeTrackedChangeAttributes, trackedChangeAttributeRecord } from "./trackedChangeAttributes.js";
|
|
19
19
|
import { TaggedError, panic } from "better-result";
|
|
20
|
-
import { PARAGRAPH_MARK_CHANGE_KINDS, finalizeParagraphFormatting } from "@stll/docx-core/model";
|
|
21
20
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
21
|
+
import { PARAGRAPH_MARK_CHANGE_KINDS, finalizeParagraphFormatting as finalizeParagraphFormatting$1 } from "@stll/docx-core/model";
|
|
22
22
|
import { SEQUENCE_CHILDREN } from "@stll/docx-core/schema";
|
|
23
23
|
// src/docx/serializer/paragraphSerializer.ts
|
|
24
24
|
/**
|
|
@@ -883,7 +883,7 @@ function hasParagraphFormatting(paragraph) {
|
|
|
883
883
|
* Create an empty paragraph
|
|
884
884
|
*/
|
|
885
885
|
function createEmptyParagraph(formatting) {
|
|
886
|
-
const finalizedFormatting = finalizeParagraphFormatting(formatting);
|
|
886
|
+
const finalizedFormatting = finalizeParagraphFormatting$1(formatting);
|
|
887
887
|
return {
|
|
888
888
|
type: "paragraph",
|
|
889
889
|
...finalizedFormatting !== void 0 ? { formatting: finalizedFormatting } : {},
|
|
@@ -894,7 +894,7 @@ function createEmptyParagraph(formatting) {
|
|
|
894
894
|
* Create a paragraph with a single text run
|
|
895
895
|
*/
|
|
896
896
|
function createTextParagraph(text, paragraphFormatting, textFormatting) {
|
|
897
|
-
const finalizedFormatting = finalizeParagraphFormatting(paragraphFormatting);
|
|
897
|
+
const finalizedFormatting = finalizeParagraphFormatting$1(paragraphFormatting);
|
|
898
898
|
return {
|
|
899
899
|
type: "paragraph",
|
|
900
900
|
...finalizedFormatting !== void 0 ? { formatting: finalizedFormatting } : {},
|
|
@@ -18,8 +18,8 @@ import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
|
18
18
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
19
19
|
import { intAttr } from "./xmlUtils.js";
|
|
20
20
|
import { panic } from "better-result";
|
|
21
|
-
import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, getSingularRunPropertyChange, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
|
|
22
21
|
import { escapeXmlAttribute, escapeXmlText, isValidOoxmlNumericId, requiresXmlSpacePreserve } from "@stll/docx-core";
|
|
22
|
+
import { SCHEME_COLOR_VALUE_BY_THEME_COLOR, getSingularRunPropertyChange, knownThemeColor, presetLineDashToken } from "@stll/docx-core/model";
|
|
23
23
|
// src/docx/serializer/runSerializer.ts
|
|
24
24
|
/**
|
|
25
25
|
* Run Serializer - Serialize runs to OOXML XML
|
|
@@ -3,8 +3,8 @@ import { serializeSectionReferenceHistory } from "../sectionReferenceHistory.js"
|
|
|
3
3
|
import { serializeBorder } from "./borderSerializer.js";
|
|
4
4
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
5
5
|
import { intAttr } from "./xmlUtils.js";
|
|
6
|
-
import { themeColorToken } from "@stll/docx-core/model";
|
|
7
6
|
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
7
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
8
8
|
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
9
9
|
// src/docx/serializer/sectionPropertiesSerializer.ts
|
|
10
10
|
const serializeHeaderReference = (ref) => `<w:headerReference w:type="${ref.type}" r:id="${escapeXmlAttribute(ref.rId)}"/>`;
|
|
@@ -15,8 +15,8 @@ import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRang
|
|
|
15
15
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
16
16
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
17
17
|
import { intAttr } from "./xmlUtils.js";
|
|
18
|
-
import { themeColorToken } from "@stll/docx-core/model";
|
|
19
18
|
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
19
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
20
20
|
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
21
21
|
// src/docx/serializer/tableSerializer.ts
|
|
22
22
|
/**
|
|
@@ -3,8 +3,8 @@ import { isValidHexColor } from "../../utils/colorResolver.js";
|
|
|
3
3
|
import { roundHorizontalScalePercentForSerialization } from "../../utils/horizontalScale.js";
|
|
4
4
|
import { serializePreservedAttributes } from "../attributeRemainder.js";
|
|
5
5
|
import { intAttr } from "./xmlUtils.js";
|
|
6
|
-
import { themeColorToken } from "@stll/docx-core/model";
|
|
7
6
|
import { escapeXmlAttribute, serializeOnOffElement } from "@stll/docx-core";
|
|
7
|
+
import { themeColorToken } from "@stll/docx-core/model";
|
|
8
8
|
import { serializeSequenceChildren } from "@stll/docx-core/schema";
|
|
9
9
|
// src/docx/serializer/textFormattingSerializer.ts
|
|
10
10
|
const VALID_HIGHLIGHT_COLORS = new Set(HIGHLIGHT_COLOR_VALUES);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
2
|
-
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
3
2
|
import { assertValidOoxmlNumericId, escapeXmlAttribute } from "@stll/docx-core";
|
|
3
|
+
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
4
4
|
// src/docx/serializer/trackedChangeAttributes.ts
|
|
5
5
|
/** Normalized, unescaped attributes in schema order for an XML element or string serializer. */
|
|
6
6
|
const trackedChangeAttributeEntries = (info) => {
|
|
@@ -4,7 +4,7 @@ import { spliceXml } from "../../selectiveXmlPatch.js";
|
|
|
4
4
|
import { NAMESPACES, getLocalName } from "../../xmlParser.js";
|
|
5
5
|
import { appendToXmlRoot } from "../../xmlRootInsertion.js";
|
|
6
6
|
import { analyzeDocument } from "./blocks.js";
|
|
7
|
-
import { freezeFields, setUpdateFieldsOnOpen, withoutContained } from "./builders.js";
|
|
7
|
+
import { freezeFields, sectionPropertiesXml, setKeepShiftReturnSpacing, setUpdateFieldsOnOpen, withoutContained } from "./builders.js";
|
|
8
8
|
import { createRelationshipsEditor, noteXml, paragraphContentXml, paragraphXml, tableXml, templateCharacterStyles } from "./emit.js";
|
|
9
9
|
import { readHeaderFooterParts } from "./inspect.js";
|
|
10
10
|
import { styleNumbering } from "./labels.js";
|
|
@@ -13,7 +13,7 @@ import { resolvePlan } from "./plan.js";
|
|
|
13
13
|
import { readStoryResources } from "./resources.js";
|
|
14
14
|
import { TemplatePlanError } from "./types.js";
|
|
15
15
|
import { reportTemplatePlanOutput } from "./verify.js";
|
|
16
|
-
import { elementChildren, escapeXmlAttribute, innerRangeOf, integerOrNull, isW, maxOf, partPrefixes, rangeOf, readRawPart, sliceWithSplices, wAttr, wChild, wChildren, wName, walkElements } from "./xml.js";
|
|
16
|
+
import { elementChildren, escapeXmlAttribute, innerRangeOf, integerOrNull, isW, maxOf, partPrefixes, rangeOf, readRawPart, sliceWithSplices, twipsOrNull, wAttr, wChild, wChildren, wName, walkElements } from "./xml.js";
|
|
17
17
|
import { Result } from "better-result";
|
|
18
18
|
import { ZipArchive } from "@stll/docx-core/zip";
|
|
19
19
|
// src/docx/server/templatePlan/apply.ts
|
|
@@ -109,6 +109,56 @@ const LEVEL_CHILD_ORDER = [
|
|
|
109
109
|
"pPr",
|
|
110
110
|
"rPr"
|
|
111
111
|
];
|
|
112
|
+
/** Children of `w:pPr` that follow `w:ind` in the schema's order. */
|
|
113
|
+
const AFTER_INDENT = [
|
|
114
|
+
"contextualSpacing",
|
|
115
|
+
"mirrorIndents",
|
|
116
|
+
"suppressOverlap",
|
|
117
|
+
"jc",
|
|
118
|
+
"textDirection",
|
|
119
|
+
"textAlignment",
|
|
120
|
+
"textboxTightWrap",
|
|
121
|
+
"outlineLvl",
|
|
122
|
+
"divId",
|
|
123
|
+
"cnfStyle",
|
|
124
|
+
"rPr",
|
|
125
|
+
"sectPr",
|
|
126
|
+
"pPrChange"
|
|
127
|
+
];
|
|
128
|
+
/**
|
|
129
|
+
* The `w:pPr` of a level with the planned indent. What the level states and
|
|
130
|
+
* the patch leaves out is kept; a hanging and a first-line indent exclude
|
|
131
|
+
* each other, and an indent counted in characters would override the planned
|
|
132
|
+
* one, so those are not carried over.
|
|
133
|
+
*/
|
|
134
|
+
const levelPropertiesXml = ({ part, level, w, indent }) => {
|
|
135
|
+
const properties = wChild(level, "pPr");
|
|
136
|
+
const existing = wChild(properties, "ind");
|
|
137
|
+
const stated = (name) => twipsOrNull(wAttr(existing, name));
|
|
138
|
+
const hanging = indent.hanging ?? (indent.firstLine === void 0 ? stated("hanging") : null);
|
|
139
|
+
const firstLine = indent.firstLine ?? (indent.hanging === void 0 ? stated("firstLine") : null);
|
|
140
|
+
const indentXml = `<${w}:ind${[
|
|
141
|
+
["left", indent.left ?? stated("left") ?? stated("start")],
|
|
142
|
+
["right", wAttr(existing, "right") ?? wAttr(existing, "end")],
|
|
143
|
+
["hanging", hanging],
|
|
144
|
+
["firstLine", firstLine]
|
|
145
|
+
].flatMap(([name, value]) => value === null ? [] : [` ${w}:${name}="${escapeXmlAttribute(String(value))}"`]).join("")}/>`;
|
|
146
|
+
const range = properties === null ? null : rangeOf(properties);
|
|
147
|
+
if (properties === null || range === null) return `<${w}:pPr>${indentXml}</${w}:pPr>`;
|
|
148
|
+
const existingRange = existing === null ? null : rangeOf(existing);
|
|
149
|
+
if (existingRange !== null) return sliceWithSplices(part.xml, range, [{
|
|
150
|
+
...existingRange,
|
|
151
|
+
newXml: indentXml
|
|
152
|
+
}]);
|
|
153
|
+
const inner = innerRangeOf(part.xml, properties);
|
|
154
|
+
if (inner === null) {
|
|
155
|
+
const name = properties.name ?? `${w}:pPr`;
|
|
156
|
+
return `${part.xml.slice(range.start, range.end - 2).trimEnd()}>${indentXml}</${name}>`;
|
|
157
|
+
}
|
|
158
|
+
const later = AFTER_INDENT.map((name) => wChild(properties, name)).find((element) => element !== null);
|
|
159
|
+
const at = (later === void 0 || later === null ? null : rangeOf(later))?.start ?? inner.end;
|
|
160
|
+
return `${part.xml.slice(range.start, at)}${indentXml}${part.xml.slice(at, range.end)}`;
|
|
161
|
+
};
|
|
112
162
|
/** The template numbering part with level patches and new list instances. */
|
|
113
163
|
const editNumbering = (part, { patches, mints }) => {
|
|
114
164
|
const prefixes = partPrefixes(part.root);
|
|
@@ -131,17 +181,25 @@ const editNumbering = (part, { patches, mints }) => {
|
|
|
131
181
|
code: "unsupported-content",
|
|
132
182
|
message: `Level ${patch.ilvl} of list definition ${patch.abstractNumId} holds markup a patch cannot change.`
|
|
133
183
|
}));
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
184
|
+
const valued = (name, value) => `<${w}:${name} ${w}:val="${escapeXmlAttribute(value)}"/>`;
|
|
185
|
+
const properties = patch.indent === void 0 ? void 0 : levelPropertiesXml({
|
|
186
|
+
part,
|
|
187
|
+
level,
|
|
188
|
+
w,
|
|
189
|
+
indent: patch.indent
|
|
190
|
+
});
|
|
191
|
+
if (properties === null) return Result.err(unreadable(part.path, "The numbering part could not be patched."));
|
|
192
|
+
const planned = {
|
|
193
|
+
...patch.start === void 0 ? {} : { start: valued("start", String(patch.start)) },
|
|
194
|
+
...patch.numFmt === void 0 ? {} : { numFmt: valued("numFmt", patch.numFmt) },
|
|
195
|
+
...patch.suff === void 0 ? {} : { suff: valued("suff", patch.suff) },
|
|
196
|
+
...patch.lvlText === void 0 ? {} : { lvlText: valued("lvlText", patch.lvlText) },
|
|
197
|
+
...properties === void 0 ? {} : { pPr: properties }
|
|
139
198
|
};
|
|
140
199
|
const inner = innerRangeOf(part.xml, level);
|
|
141
200
|
for (const [index, name] of LEVEL_CHILD_ORDER.entries()) {
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
const xml = `<${w}:${name} ${w}:val="${escapeXmlAttribute(value)}"/>`;
|
|
201
|
+
const xml = planned[name];
|
|
202
|
+
if (xml === void 0) continue;
|
|
145
203
|
const existing = wChild(level, name);
|
|
146
204
|
const existingRange = existing === null ? null : rangeOf(existing);
|
|
147
205
|
if (existingRange !== null) {
|
|
@@ -160,8 +218,8 @@ const editNumbering = (part, { patches, mints }) => {
|
|
|
160
218
|
}
|
|
161
219
|
if (inner === null) {
|
|
162
220
|
const children = LEVEL_CHILD_ORDER.flatMap((name) => {
|
|
163
|
-
const
|
|
164
|
-
return
|
|
221
|
+
const xml = planned[name];
|
|
222
|
+
return xml === void 0 ? [] : [xml];
|
|
165
223
|
}).join("");
|
|
166
224
|
insertions.delete(levelRange.end - 2);
|
|
167
225
|
splices.push({
|
|
@@ -330,9 +388,23 @@ const writeOutput = async ({ source, template, plan, resolved }) => {
|
|
|
330
388
|
};
|
|
331
389
|
const instructions = new Map(resolved.references.map(({ reference, instruction }) => [reference, instruction]));
|
|
332
390
|
const instructionOf = (segment) => segment.kind === "reference" ? instructions.get(segment.reference) ?? null : null;
|
|
391
|
+
const bodySection = wChild(template.body, "sectPr");
|
|
392
|
+
const sectionEnds = resolved.items.flatMap((item) => item.kind === "paragraph" && item.paragraph.endsSection !== null ? [item.paragraph] : []);
|
|
393
|
+
const sectionXmlOf = /* @__PURE__ */ new Map();
|
|
394
|
+
for (const [position, paragraph] of sectionEnds.entries()) {
|
|
395
|
+
const section = paragraph.endsSection;
|
|
396
|
+
const xml = bodySection === null || section === null ? null : sectionPropertiesXml(template.document.xml, bodySection, documentContext.prefixes.w, {
|
|
397
|
+
first: position === 0,
|
|
398
|
+
page: section.page,
|
|
399
|
+
start: position === 0 ? null : section.start ?? "nextPage"
|
|
400
|
+
});
|
|
401
|
+
if (xml === null) return Result.err(unreadable(pkg.documentPath, "A section could not be built."));
|
|
402
|
+
sectionXmlOf.set(paragraph, xml);
|
|
403
|
+
}
|
|
333
404
|
const emitOf = (paragraph) => ({
|
|
334
405
|
paragraph,
|
|
335
406
|
bookmark: resolved.bookmarks.get(paragraph),
|
|
407
|
+
sectionXml: sectionXmlOf.get(paragraph) ?? null,
|
|
336
408
|
instructionOf,
|
|
337
409
|
styleBindsList: styleNumbering(paragraph.styleId ?? template.defaultStyleId, template.styles, template.numbering)?.kind === "reference"
|
|
338
410
|
});
|
|
@@ -366,7 +438,6 @@ const writeOutput = async ({ source, template, plan, resolved }) => {
|
|
|
366
438
|
end: inner.end
|
|
367
439
|
});
|
|
368
440
|
}
|
|
369
|
-
const bodySection = wChild(template.body, "sectPr");
|
|
370
441
|
const keptElements = [
|
|
371
442
|
...resolved.keptTemplateBlocks.map(({ element }) => element),
|
|
372
443
|
...resolved.items.flatMap((item) => item.kind === "slot" ? [item.templateBlock.element] : []),
|
|
@@ -395,6 +466,9 @@ const writeOutput = async ({ source, template, plan, resolved }) => {
|
|
|
395
466
|
case "paragraph":
|
|
396
467
|
xml = paragraphXml(emitOf(item.paragraph), documentContext);
|
|
397
468
|
break;
|
|
469
|
+
case "separator":
|
|
470
|
+
xml = Result.ok(`<${documentContext.prefixes.w}:p/>`);
|
|
471
|
+
break;
|
|
398
472
|
case "table":
|
|
399
473
|
xml = tableXml({
|
|
400
474
|
table: item.block.element,
|
|
@@ -411,7 +485,13 @@ const writeOutput = async ({ source, template, plan, resolved }) => {
|
|
|
411
485
|
body.push(xml.value);
|
|
412
486
|
}
|
|
413
487
|
if (bodySection !== null) {
|
|
414
|
-
const
|
|
488
|
+
const { lastSection } = plan;
|
|
489
|
+
const rebuilt = sectionEnds.length > 0 || lastSection !== void 0 ? sectionPropertiesXml(template.document.xml, bodySection, documentContext.prefixes.w, {
|
|
490
|
+
first: sectionEnds.length === 0,
|
|
491
|
+
page: lastSection?.page,
|
|
492
|
+
start: sectionEnds.length === 0 ? null : lastSection?.start ?? null
|
|
493
|
+
}) : null;
|
|
494
|
+
const section = rebuilt === null ? keptXml(bodySection) : Result.ok(rebuilt);
|
|
415
495
|
if (Result.isError(section)) return section;
|
|
416
496
|
body.push(section.value);
|
|
417
497
|
}
|
|
@@ -540,6 +620,19 @@ const writeOutput = async ({ source, template, plan, resolved }) => {
|
|
|
540
620
|
if (settings !== settingsXml.value) parts.set(settingsPath, settings);
|
|
541
621
|
}
|
|
542
622
|
}
|
|
623
|
+
if (plan.compat?.doNotExpandShiftReturn === true) {
|
|
624
|
+
const settingsPath = pkg.partPath("settings");
|
|
625
|
+
const written = settingsPath === null ? void 0 : parts.get(settingsPath);
|
|
626
|
+
const settingsXml = typeof written === "string" ? Result.ok(written) : await readTemplateText(settingsPath);
|
|
627
|
+
if (Result.isError(settingsXml)) return settingsXml;
|
|
628
|
+
if (settingsPath === null || settingsXml.value === null) return Result.err(new TemplatePlanError({
|
|
629
|
+
code: "part-missing",
|
|
630
|
+
message: "The template has no settings part to set a compatibility setting in."
|
|
631
|
+
}));
|
|
632
|
+
const settings = setKeepShiftReturnSpacing(settingsXml.value);
|
|
633
|
+
if (settings === null) return Result.err(unreadable(settingsPath, "The settings part could not be updated."));
|
|
634
|
+
if (settings !== settingsXml.value) parts.set(settingsPath, settings);
|
|
635
|
+
}
|
|
543
636
|
return await Result.tryPromise({
|
|
544
637
|
try: async () => {
|
|
545
638
|
const zip = await ZipArchive.read(pkg.bytes);
|
|
@@ -7,7 +7,7 @@ import { Emphasis } from "./emphasis.js";
|
|
|
7
7
|
import { LabelCounter, ParagraphLabel } from "./labels.js";
|
|
8
8
|
import { LoadedPackage } from "./package.js";
|
|
9
9
|
import { ParagraphRead, StoryState } from "./story.js";
|
|
10
|
-
import { DocxBlock, DocxBlockManifest, TemplatePlanError } from "./types.js";
|
|
10
|
+
import { DocxBlock, DocxBlockManifest, DocxSection, TemplatePlanError } from "./types.js";
|
|
11
11
|
import { RawPart } from "./xml.js";
|
|
12
12
|
import { Result } from "better-result";
|
|
13
13
|
export declare const blockHash: (text: string, label: string | null) => string;
|
|
@@ -32,6 +32,8 @@ export type AnalyzedStory = {
|
|
|
32
32
|
state: StoryState;
|
|
33
33
|
/** `w:sectPr` elements in document order, the body's own last. */
|
|
34
34
|
sections: XmlElement[];
|
|
35
|
+
/** Whether the body states section properties of its own. */
|
|
36
|
+
hasBodySection: boolean;
|
|
35
37
|
/** Names of block-level elements the walk has no reading for. */
|
|
36
38
|
unreadBlocks: string[];
|
|
37
39
|
warnings: string[];
|
|
@@ -39,10 +41,23 @@ export type AnalyzedStory = {
|
|
|
39
41
|
type StoryResources = {
|
|
40
42
|
styles: StyleMap;
|
|
41
43
|
defaultStyleId: string | null;
|
|
44
|
+
/** The language the document defaults give every run, or null. */
|
|
45
|
+
defaultLanguage: string | null;
|
|
42
46
|
numbering: NumberingMap | null;
|
|
47
|
+
/** The alignment each paragraph style states for itself (`w:jc`). */
|
|
48
|
+
alignments?: ReadonlyMap<string, string>;
|
|
43
49
|
};
|
|
44
50
|
/** The heading level a style outlines its paragraphs at, 0 being the highest. */
|
|
45
51
|
export declare const styleOutlineLevel: (style: document_d_exports.Style | undefined) => number | null;
|
|
52
|
+
/** The alignment each style of a styles part states for itself (`w:jc`). */
|
|
53
|
+
export declare const statedAlignments: (stylesPath: string | null, stylesXml: string | null) => Map<string, string>;
|
|
54
|
+
/** The alignment of the nearest style in the `basedOn` chain that states one. */
|
|
55
|
+
export declare const styleAlignment: (styleId: string | null, styles: StyleMap, stated: ReadonlyMap<string, string>) => string | null;
|
|
56
|
+
/**
|
|
57
|
+
* The sections of a story with what each states. A body without section
|
|
58
|
+
* properties of its own still ends in a section, which states nothing.
|
|
59
|
+
*/
|
|
60
|
+
export declare const storySections: ({ sections, hasBodySection }: AnalyzedStory) => DocxSection[];
|
|
46
61
|
type AnalyzeStoryOptions = {
|
|
47
62
|
container: XmlElement;
|
|
48
63
|
resources: StoryResources;
|