@stll/folio-core 0.67.0 → 0.69.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.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +106 -36
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/newListNumbering.d.ts +14 -1
- package/dist/ai-edits/newListNumbering.js +24 -1
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/pending-suggestions.js +2 -2
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +31 -14
- package/dist/controller/canonicalComposition.js +35 -6
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +32 -7
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +23 -0
- package/dist/controller/canonicalLockGuard.js +133 -0
- package/dist/controller/canonicalProjectionBlocks.d.ts +79 -0
- package/dist/controller/canonicalProjectionBlocks.js +75 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +676 -46
- package/dist/controller/canonicalSeedContent.d.ts +12 -0
- package/dist/controller/canonicalSeedContent.js +131 -0
- package/dist/controller/canonicalSession.d.ts +133 -21
- package/dist/controller/canonicalSession.js +738 -205
- package/dist/controller/canonicalSourceNormalization.d.ts +21 -0
- package/dist/controller/canonicalSourceNormalization.js +148 -0
- package/dist/controller/canonicalStoryEditor.d.ts +4 -3
- package/dist/controller/canonicalStoryEditor.js +20 -15
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +4 -0
- package/dist/controller/headerFooterEditorManager.d.ts +7 -2
- package/dist/controller/headerFooterEditorManager.js +11 -6
- package/dist/controller/hiddenEditorApi.d.ts +17 -2
- package/dist/controller/hiddenEditorApi.js +4 -0
- package/dist/controller/hiddenEditorManager.d.ts +11 -3
- package/dist/controller/hiddenEditorManager.js +157 -48
- package/dist/controller/layoutPipeline.js +50 -16
- package/dist/controller/layoutSession.d.ts +3 -0
- package/dist/controller/layoutSession.js +3 -1
- package/dist/controller/noteEditorManager.d.ts +7 -2
- package/dist/controller/noteEditorManager.js +11 -6
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +13 -11
- package/dist/document-operations.d.ts +9 -1
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +11 -2
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +40 -5
- package/dist/docx/commentAnchorIndex.js +94 -12
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/contentTypeRegistry.js +1 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +27 -0
- package/dist/docx/hostCommentThreads.js +72 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +226 -96
- package/dist/docx/listNumberingInstances.d.ts +1 -1
- package/dist/docx/listNumberingInstances.js +2 -2
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/numberingIds.d.ts +6 -0
- package/dist/docx/numberingIds.js +6 -1
- package/dist/docx/numberingReferenceNormalization.d.ts +4 -0
- package/dist/docx/numberingReferenceNormalization.js +12 -2
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +29 -0
- package/dist/docx/paragraphPropertySource.js +106 -16
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +8 -0
- package/dist/docx/removeHeaderFooterParts.js +1 -1
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +171 -33
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +5 -2
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/partNamespaces.d.ts +1 -1
- package/dist/docx/serializer/partNamespaces.js +1 -1
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/build.d.ts +1 -1
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +19 -2
- package/dist/docx/structuralXmlPatch.js +44 -11
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/docx/xmlParser.d.ts +1 -1
- package/dist/docx/xmlParser.js +2 -3
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +3 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +51 -0
- package/dist/i18n/messages/catalogs.gen.js +51 -0
- package/dist/i18n/messages/cs.gen.js +3 -0
- package/dist/i18n/messages/de.gen.js +3 -0
- package/dist/i18n/messages/en.gen.js +3 -0
- package/dist/i18n/messages/es.gen.js +3 -0
- package/dist/i18n/messages/et.gen.js +3 -0
- package/dist/i18n/messages/fr.gen.js +3 -0
- package/dist/i18n/messages/he.gen.js +3 -0
- package/dist/i18n/messages/hi.gen.js +3 -0
- package/dist/i18n/messages/hu.gen.js +3 -0
- package/dist/i18n/messages/lt.gen.js +3 -0
- package/dist/i18n/messages/lv.gen.js +3 -0
- package/dist/i18n/messages/messages.gen.d.ts +3 -0
- package/dist/i18n/messages/pl.gen.js +3 -0
- package/dist/i18n/messages/pt-BR.gen.js +3 -0
- package/dist/i18n/messages/sk.gen.js +3 -0
- package/dist/i18n/messages/tr.gen.js +3 -0
- package/dist/i18n/messages/zh-CN.gen.js +3 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunDescendantIndex.d.ts +7 -2
- package/dist/internal/pageBreakRunDescendantIndex.js +12 -3
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/internal/subtreeHolds.d.ts +12 -0
- package/dist/internal/subtreeHolds.js +25 -0
- package/dist/internal/wholeStoryRevisionResolution.js +1 -1
- package/dist/layout-bridge/cellSelectionHighlight.js +3 -3
- package/dist/layout-bridge/convert/flowBlockPostprocessing.js +20 -12
- package/dist/layout-bridge/convert/flowConversionShared.d.ts +15 -1
- package/dist/layout-bridge/convert/flowConversionShared.js +9 -1
- package/dist/layout-bridge/convert/paragraphAttrs.d.ts +15 -4
- package/dist/layout-bridge/convert/paragraphAttrs.js +11 -4
- package/dist/layout-bridge/convert/paragraphBlockCache.d.ts +26 -0
- package/dist/layout-bridge/convert/paragraphBlockCache.js +137 -0
- package/dist/layout-bridge/convert/paragraphConversion.d.ts +12 -2
- package/dist/layout-bridge/convert/paragraphConversion.js +37 -5
- package/dist/layout-bridge/convert/paragraphRuns.d.ts +2 -2
- package/dist/layout-bridge/convert/sectionBoundaries.js +16 -0
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/convert/toFlowBlocks.js +144 -15
- package/dist/layout-bridge/convert/topLevelConversion.d.ts +74 -0
- package/dist/layout-bridge/convert/topLevelConversion.js +109 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +41 -40
- package/dist/layout-bridge/dom/findBodyPmSpans.js +4 -3
- package/dist/layout-bridge/dom/findHfPmSpans.js +10 -15
- package/dist/layout-bridge/dom/imeCaretAnchor.d.ts +8 -0
- package/dist/layout-bridge/dom/imeCaretAnchor.js +71 -7
- package/dist/layout-bridge/dom/textStreamDom.js +3 -2
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-bridge/headerFooterLayout.js +12 -11
- package/dist/layout-bridge/tableInsertHover.js +2 -1
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.d.ts +2 -0
- package/dist/layout-engine/measure/cache.js +16 -6
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/measure/paragraphKeyMemo.d.ts +8 -0
- package/dist/layout-engine/measure/paragraphKeyMemo.js +92 -0
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +42 -1
- package/dist/layout-painter/imageLayout.js +2 -1
- package/dist/layout-painter/pageShellStyles.d.ts +10 -0
- package/dist/layout-painter/pageShellStyles.js +32 -0
- package/dist/layout-painter/reconcileRenderedContent.d.ts +19 -0
- package/dist/layout-painter/reconcileRenderedContent.js +117 -0
- package/dist/layout-painter/renderFragment.js +4 -6
- package/dist/layout-painter/renderImage.js +2 -2
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +54 -46
- package/dist/layout-painter/renderParagraph.js +3 -3
- package/dist/layout-painter/renderTable.js +16 -16
- package/dist/layout-painter/renderTextBox.js +2 -2
- package/dist/layout-painter/sdtBoundary.js +3 -2
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/paged-layout/blockGeometry.js +3 -2
- package/dist/paged-layout/editorScrollRoot.d.ts +9 -0
- package/dist/paged-layout/editorScrollRoot.js +10 -1
- package/dist/paged-layout/rangeProjection.js +5 -4
- package/dist/paged-layout/scrollToPmPosition.js +3 -3
- package/dist/paged-layout/selectionViewportRect.d.ts +6 -0
- package/dist/paged-layout/selectionViewportRect.js +8 -2
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +2 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +30 -2
- package/dist/prosemirror/commands/comments.js +189 -18
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentRecords.d.ts +137 -0
- package/dist/prosemirror/commentRecords.js +400 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +85 -34
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +140 -4
- package/dist/prosemirror/conversion/toProseDoc.js +432 -76
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +23 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +61 -32
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +8 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +3 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/nativeSelection.d.ts +33 -0
- package/dist/prosemirror/nativeSelection.js +74 -0
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/numberedRefFields.d.ts +2 -0
- package/dist/prosemirror/numberedRefFields.js +16 -5
- package/dist/prosemirror/paragraphMarkJoin.d.ts +6 -8
- package/dist/prosemirror/paragraphMarkJoin.js +155 -16
- package/dist/prosemirror/plugins/contentControlWidgets.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +37 -15
- package/dist/prosemirror/plugins/suggestionMode.js +33 -10
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runIdentityAcrossRevisions.d.ts +23 -1
- package/dist/prosemirror/runIdentityAcrossRevisions.js +57 -8
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +13 -1
- package/dist/prosemirror/storyListNumbering.js +7 -2
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/tableResize.d.ts +10 -9
- package/dist/prosemirror/tableResize.js +60 -49
- package/dist/prosemirror/textInput.d.ts +30 -1
- package/dist/prosemirror/textInput.js +144 -17
- package/dist/prosemirror/utils/visualLineNavigation.js +20 -18
- package/dist/prosemirror/validation.d.ts +19 -0
- package/dist/prosemirror/validation.js +79 -5
- package/dist/redline.js +23 -9
- package/dist/render-dom/HeaderFooterSelectionOverlay.js +5 -4
- package/dist/render-dom/RenderedDomContext.js +7 -6
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +38 -16
- package/dist/types/canonicalCapabilities.js +21 -18
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/findMatchView.js +4 -3
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/formatToStyle.d.ts +1 -1
- package/dist/utils/mergeDocumentContent.js +2 -2
- package/dist/utils/paintedPositions.d.ts +60 -0
- package/dist/utils/paintedPositions.js +101 -0
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -3
|
@@ -44,7 +44,8 @@ const PARSE_WARNING_MESSAGES = {
|
|
|
44
44
|
[PARSE_WARNING_CODES.pageBreakProjectionApproximated]: (warning) => `${warning.detail ?? "An explicit page break is laid out approximately"}${where(warning)}.`,
|
|
45
45
|
[PARSE_WARNING_CODES.altChunkUnsupported]: (warning) => `Preserved ${plural(warning.count, "w:altChunk")}; Folio cannot import its external content. Readers show a diagnostic marker.`,
|
|
46
46
|
[PARSE_WARNING_CODES.revisionCarrierOpaque]: (warning) => `Preserved ${plural(warning.count, "block-level tracked-change wrapper")}; Folio cannot interpret its block content, so that content is unavailable to readers or edits.`,
|
|
47
|
-
[PARSE_WARNING_CODES.nestedRowOpaque]: (warning) => `Preserved ${plural(warning.count, "nested table row")} as opaque markup; readers show a diagnostic marker for its content
|
|
47
|
+
[PARSE_WARNING_CODES.nestedRowOpaque]: (warning) => `Preserved ${plural(warning.count, "nested table row")} as opaque markup; readers show a diagnostic marker for its content.`,
|
|
48
|
+
[PARSE_WARNING_CODES.reviewProvenanceDropped]: (warning) => `Dropped ${plural(warning.count, "review provenance value")} Folio cannot read (${warning.detail ?? "invalid"})${where(warning)}; the revisions they annotate are kept.`
|
|
48
49
|
};
|
|
49
50
|
const formatParseWarning = (warning) => PARSE_WARNING_MESSAGES[warning.code](warning);
|
|
50
51
|
const formatParseWarnings = (warnings) => warnings.map(formatParseWarning);
|
package/dist/docx/parser.js
CHANGED
|
@@ -33,6 +33,7 @@ import { createPackagePreviewBudget } from "./previewBudget.js";
|
|
|
33
33
|
import { detectRasterMimeType } from "./rasterMime.js";
|
|
34
34
|
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
35
35
|
import { normalizeRenderedPageBreakHints } from "./renderedPageBreakNormalization.js";
|
|
36
|
+
import { diagnoseReviewProvenance } from "./reviewProvenanceDiagnostics.js";
|
|
36
37
|
import { parseSettings } from "./settingsParser.js";
|
|
37
38
|
import { parseStylesPackage } from "./styleParser.js";
|
|
38
39
|
import { applyThemeFontLang, parseTheme } from "./themeParser.js";
|
|
@@ -91,6 +92,8 @@ const countAltChunks = (blocks) => {
|
|
|
91
92
|
case "paragraph":
|
|
92
93
|
case "bookmarkStart":
|
|
93
94
|
case "bookmarkEnd":
|
|
95
|
+
case "commentRangeStart":
|
|
96
|
+
case "commentRangeEnd":
|
|
94
97
|
case "moveFromRangeStart":
|
|
95
98
|
case "moveFromRangeEnd":
|
|
96
99
|
case "moveToRangeStart":
|
|
@@ -169,6 +172,8 @@ const countOpaqueRevisionCarriers = (blocks) => {
|
|
|
169
172
|
case "paragraph":
|
|
170
173
|
case "bookmarkStart":
|
|
171
174
|
case "bookmarkEnd":
|
|
175
|
+
case "commentRangeStart":
|
|
176
|
+
case "commentRangeEnd":
|
|
172
177
|
case "moveFromRangeStart":
|
|
173
178
|
case "moveFromRangeEnd":
|
|
174
179
|
case "moveToRangeStart":
|
|
@@ -207,6 +212,7 @@ async function parseDocxWithPreviewBudget(input, options, previewBudget) {
|
|
|
207
212
|
extractAllXml: false
|
|
208
213
|
}));
|
|
209
214
|
diagnoseImportedIdCollisions(raw.allXml, parseContext);
|
|
215
|
+
diagnoseReviewProvenance(raw.allXml, parseContext);
|
|
210
216
|
await replaceRawDocxXmlParts(raw, normalizeBookmarkIdsInXmlParts(raw.allXml));
|
|
211
217
|
const repairedDocumentTree = await normalizeRawDocxNumericIds(raw);
|
|
212
218
|
const paragraphPropertySourceDigest = sha256Hex(raw.originalBuffer);
|
|
@@ -357,6 +363,8 @@ async function parseDocxWithPreviewBudget(input, options, previewBudget) {
|
|
|
357
363
|
styles: styleDefinitions?.styles ?? [],
|
|
358
364
|
numbering
|
|
359
365
|
});
|
|
366
|
+
const danglingNumIds = [.../* @__PURE__ */ new Set([...numberingReferenceNormalization.danglingNumIds, ...styleNumberingNormalization.danglingNumIds])].sort((left, right) => left - right);
|
|
367
|
+
if (danglingNumIds.length > 0) numbering.definitions.danglingNumIds = danglingNumIds;
|
|
360
368
|
for (const styleId of styleNumberingNormalization.unnumberedStyleIds) parseContext.warn({
|
|
361
369
|
code: UNNUMBERED_STYLE_WARNING,
|
|
362
370
|
value: styleId,
|
|
@@ -4,7 +4,7 @@ import { parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
|
4
4
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
5
5
|
import { OFFICE_RELATIONSHIP_NAMESPACE_URIS, cloneElement, getAttribute, getLocalName, getNamespaceUri, parseXmlDocument } from "./xmlParser.js";
|
|
6
6
|
import { panic } from "better-result";
|
|
7
|
-
import { OOXML_NS } from "@stll/docx-
|
|
7
|
+
import { OOXML_NS } from "@stll/docx-core/xml/namespaces";
|
|
8
8
|
// src/docx/removeHeaderFooterParts.ts
|
|
9
9
|
const DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels";
|
|
10
10
|
const officeRelationshipHasType = (type, kind) => [...OFFICE_RELATIONSHIP_NAMESPACE_URIS].some((namespace) => type === `${namespace}/${kind}`);
|
|
@@ -30,7 +30,7 @@ const scanRun = (run, scan) => {
|
|
|
30
30
|
};
|
|
31
31
|
const scanHyperlink = (hyperlink, scan) => {
|
|
32
32
|
for (const child of hyperlink.children) {
|
|
33
|
-
if (child.type !== "run" && child.type !== "inlineWrapper") continue;
|
|
33
|
+
if (child.type !== "run" && child.type !== "inlineWrapper" && child.type !== "complexField") continue;
|
|
34
34
|
const result = child.type === "run" ? scanRun(child, scan) : scanParagraphContent(child, scan);
|
|
35
35
|
if (result !== void 0) return result;
|
|
36
36
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParseContext } from "./parseContext.js";
|
|
2
|
+
/**
|
|
3
|
+
* Report each review provenance value the reader drops: a version, a field or
|
|
4
|
+
* a value folio cannot read. Reading drops them and keeps the revisions; this
|
|
5
|
+
* is how the host learns that it did.
|
|
6
|
+
*/
|
|
7
|
+
export declare const diagnoseReviewProvenance: (parts: ReadonlyMap<string, string>, context: ParseContext) => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { sliceText } from "../utils/sliceText.js";
|
|
2
|
+
import "./reviewHistoryNamespace.js";
|
|
3
|
+
import { reviewProvenanceIssue } from "./reviewResolutionProvenance.js";
|
|
4
|
+
import { getLocalName, resolveAttributeNamespaceUri } from "./xmlParser.js";
|
|
5
|
+
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
6
|
+
import { scanStreamingXmlElements } from "@stll/docx-core/xml";
|
|
7
|
+
// src/docx/reviewProvenanceDiagnostics.ts
|
|
8
|
+
/** The longest value a warning quotes; the rest is elided. */
|
|
9
|
+
const QUOTED_VALUE_LIMIT = 200;
|
|
10
|
+
/**
|
|
11
|
+
* Report each review provenance value the reader drops: a version, a field or
|
|
12
|
+
* a value folio cannot read. Reading drops them and keeps the revisions; this
|
|
13
|
+
* is how the host learns that it did.
|
|
14
|
+
*/
|
|
15
|
+
const diagnoseReviewProvenance = (parts, context) => {
|
|
16
|
+
for (const [part, xml] of parts) {
|
|
17
|
+
if (!xml.includes("urn:stella:folio:review-history:1")) continue;
|
|
18
|
+
const scoped = context.scoped({ part });
|
|
19
|
+
scanStreamingXmlElements(xml, ({ element }) => {
|
|
20
|
+
for (const [name, value] of Object.entries(element.attributes ?? {})) {
|
|
21
|
+
if (!name.includes(":") || name.startsWith("xmlns:") || resolveAttributeNamespaceUri(element, name) !== "urn:stella:folio:review-history:1") continue;
|
|
22
|
+
const encoded = String(value);
|
|
23
|
+
const issue = reviewProvenanceIssue(getLocalName(name), encoded);
|
|
24
|
+
if (issue === void 0) continue;
|
|
25
|
+
scoped.warn({
|
|
26
|
+
code: PARSE_WARNING_CODES.reviewProvenanceDropped,
|
|
27
|
+
...element.name === void 0 ? {} : { element: element.name },
|
|
28
|
+
value: encoded.length > QUOTED_VALUE_LIMIT ? `${sliceText({
|
|
29
|
+
text: encoded,
|
|
30
|
+
units: "codeUnits",
|
|
31
|
+
end: QUOTED_VALUE_LIMIT
|
|
32
|
+
})}...` : encoded,
|
|
33
|
+
detail: issue === "unsupportedVersion" ? `${getLocalName(name)}: unsupported version` : `${getLocalName(name)}: invalid value`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export { diagnoseReviewProvenance };
|
|
@@ -19,9 +19,35 @@ export declare const parseCopyOriginAncestors: (node: XmlElement) => CopyOriginA
|
|
|
19
19
|
export declare const serializeResolutionJoins: (value: document_d_exports.Insertion["resolutionJoins"]) => string;
|
|
20
20
|
export declare const serializeBoundaryJoins: (value: document_d_exports.RunPropertyChange["boundaryJoins"]) => string;
|
|
21
21
|
export declare const serializeCopyOriginAncestors: (value: CopyOriginAncestorList | undefined) => string | undefined;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* A paragraph mark's private review provenance: its rejection join depth
|
|
24
|
+
* (null carries an owned undefined depth) and the paragraph rejecting it
|
|
25
|
+
* keeps. A missing attribute carries no field.
|
|
26
|
+
*/
|
|
27
|
+
export declare const parseParagraphMarkResolutionJoin: (node: XmlElement) => Pick<document_d_exports.ParagraphMarkChange, "resolutionJoin" | "survivor">;
|
|
24
28
|
export declare const serializeParagraphMarkResolutionJoin: (mark: document_d_exports.ParagraphMarkChange) => string;
|
|
25
|
-
/** Captured paragraph properties compose the same
|
|
29
|
+
/** Captured paragraph properties compose the same envelopes into a parsed XML element. */
|
|
26
30
|
export declare const paragraphMarkResolutionJoinAttributes: (mark: document_d_exports.ParagraphMarkChange) => Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* One piece of a tracked change written as several elements: a revision that
|
|
33
|
+
* holds a hyperlink is written with the revision inside the link, so a
|
|
34
|
+
* change spanning text and a link becomes one element per stretch. The first
|
|
35
|
+
* piece carries the whole change's resolution joins; every piece says which
|
|
36
|
+
* one it is, so a reader rebuilds the one change, and a change nested in it
|
|
37
|
+
* can be rebuilt in turn. It is its own attribute: a reader that does not know
|
|
38
|
+
* it drops the joins and keeps the revisions.
|
|
39
|
+
*/
|
|
40
|
+
export type SplitResolutionPiece = {
|
|
41
|
+
piece: number;
|
|
42
|
+
pieces: number;
|
|
43
|
+
joins?: ResolutionJoins;
|
|
44
|
+
};
|
|
45
|
+
export declare const isSplitResolutionPiece: (value: unknown) => value is SplitResolutionPiece;
|
|
46
|
+
export declare const parseSplitResolutionPiece: (node: XmlElement) => SplitResolutionPiece | undefined;
|
|
47
|
+
export declare const serializeSplitResolutionPiece: (value: SplitResolutionPiece) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Why the reader drops a provenance attribute's value, or `undefined` when it
|
|
50
|
+
* reads it (or does not read that attribute at all).
|
|
51
|
+
*/
|
|
52
|
+
export declare const reviewProvenanceIssue: (attribute: string, encoded: string) => "invalid" | "unsupportedVersion" | undefined;
|
|
27
53
|
export {};
|
|
@@ -23,8 +23,20 @@ const JOIN_FIELDS = {
|
|
|
23
23
|
remove: true,
|
|
24
24
|
retainedAfter: true,
|
|
25
25
|
deferredRemove: true,
|
|
26
|
-
acceptance: true
|
|
26
|
+
acceptance: true,
|
|
27
|
+
plainSides: true,
|
|
28
|
+
retainedEnclosing: true
|
|
27
29
|
};
|
|
30
|
+
const ENCLOSING_FIELDS = {
|
|
31
|
+
levels: true,
|
|
32
|
+
source: true,
|
|
33
|
+
target: true
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Saved as its own attribute: a reader that does not know it keeps the
|
|
37
|
+
* joins and drops only the handoff.
|
|
38
|
+
*/
|
|
39
|
+
const ENCLOSING_ATTRIBUTE = "retainedEnclosing";
|
|
28
40
|
const ACCEPTANCE_POLICIES = { "merge-plain-runs": true };
|
|
29
41
|
const PARAGRAPH_MARK_FIELDS = {
|
|
30
42
|
kind: { type: "ooxml" },
|
|
@@ -32,6 +44,10 @@ const PARAGRAPH_MARK_FIELDS = {
|
|
|
32
44
|
resolutionJoin: {
|
|
33
45
|
type: "private",
|
|
34
46
|
attribute: "resolutionJoin"
|
|
47
|
+
},
|
|
48
|
+
survivor: {
|
|
49
|
+
type: "private",
|
|
50
|
+
attribute: "rejectionSurvivor"
|
|
35
51
|
}
|
|
36
52
|
};
|
|
37
53
|
const DEFERRED_REMOVAL_FIELDS = {
|
|
@@ -47,6 +63,13 @@ const retained = (value) => Array.isArray(value) && value.every((item) => {
|
|
|
47
63
|
const target = item["target"];
|
|
48
64
|
return Object.keys(item).every((key) => Object.hasOwn(RETAINED_FIELDS, key)) && natural(item["depth"]) && slots(source) && slots(target) && source.length === target.length && source.every((slot, index) => slot.space === target.at(index)?.space);
|
|
49
65
|
});
|
|
66
|
+
const enclosingHandoffs = (value) => Array.isArray(value) && value.length > 0 && value.every((item) => {
|
|
67
|
+
if (!record(item)) return false;
|
|
68
|
+
const levels = item["levels"];
|
|
69
|
+
const source = item["source"];
|
|
70
|
+
const target = item["target"];
|
|
71
|
+
return Object.keys(item).every((key) => Object.hasOwn(ENCLOSING_FIELDS, key)) && natural(levels) && levels >= 1 && levels <= MAX_REVISION_ID && slots(source) && slots(target) && source.length > 0 && source.length === target.length && source.every((slot, index) => slot.space === target.at(index)?.space);
|
|
72
|
+
});
|
|
50
73
|
const deferredRemoval = (value) => {
|
|
51
74
|
if (!record(value) || Object.keys(value).some((key) => !Object.hasOwn(DEFERRED_REMOVAL_FIELDS, key))) return false;
|
|
52
75
|
const depth = value["depth"];
|
|
@@ -61,32 +84,78 @@ const deferredRemovals = (value) => {
|
|
|
61
84
|
}));
|
|
62
85
|
return new Set(groups).size === groups.length;
|
|
63
86
|
};
|
|
64
|
-
const isResolutionJoins = (value) => record(value) && Object.keys(value).every((key) => Object.hasOwn(JOIN_FIELDS, key)) && natural(value["before"]) && natural(value["after"]) && natural(value["remove"]) && (!Object.hasOwn(value, "acceptance") || typeof value["acceptance"] === "string" && Object.hasOwn(ACCEPTANCE_POLICIES, value["acceptance"])) && (value["retainedAfter"] === void 0 || retained(value["retainedAfter"])) && (!Object.hasOwn(value, "deferredRemove") || deferredRemovals(value["deferredRemove"]));
|
|
87
|
+
const isResolutionJoins = (value) => record(value) && Object.keys(value).every((key) => Object.hasOwn(JOIN_FIELDS, key)) && natural(value["before"]) && natural(value["after"]) && natural(value["remove"]) && (!Object.hasOwn(value, "acceptance") || typeof value["acceptance"] === "string" && Object.hasOwn(ACCEPTANCE_POLICIES, value["acceptance"])) && (value["retainedAfter"] === void 0 || retained(value["retainedAfter"])) && (!Object.hasOwn(value, "deferredRemove") || deferredRemovals(value["deferredRemove"])) && (!Object.hasOwn(value, "plainSides") || isBoundaryJoins(value["plainSides"])) && (!Object.hasOwn(value, ENCLOSING_ATTRIBUTE) || enclosingHandoffs(value[ENCLOSING_ATTRIBUTE]));
|
|
88
|
+
/** The joins as `folio:resolutionJoins` holds them: without the handoff. */
|
|
89
|
+
const isStoredResolutionJoins = (value) => isResolutionJoins(value) && !Object.hasOwn(value, ENCLOSING_ATTRIBUTE);
|
|
90
|
+
const storedJoins = (joins) => {
|
|
91
|
+
const { retainedEnclosing: _handoff, ...stored } = joins;
|
|
92
|
+
return stored;
|
|
93
|
+
};
|
|
94
|
+
const withEnclosing = (joins, node) => {
|
|
95
|
+
const handoffs = parseAttribute({
|
|
96
|
+
node,
|
|
97
|
+
attribute: ENCLOSING_ATTRIBUTE,
|
|
98
|
+
valid: enclosingHandoffs
|
|
99
|
+
});
|
|
100
|
+
return handoffs === void 0 ? joins : {
|
|
101
|
+
...joins,
|
|
102
|
+
retainedEnclosing: handoffs
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
const serializeEnclosing = (joins) => serializeAttribute({
|
|
106
|
+
attribute: ENCLOSING_ATTRIBUTE,
|
|
107
|
+
value: joins?.retainedEnclosing,
|
|
108
|
+
valid: enclosingHandoffs
|
|
109
|
+
});
|
|
65
110
|
const isParagraphMarkResolutionJoin = (value) => natural(value) && value <= MAX_REVISION_ID;
|
|
66
111
|
const isEncodedParagraphMarkResolutionJoin = (value) => value === null || isParagraphMarkResolutionJoin(value);
|
|
67
112
|
const isBoundaryJoins = (value) => Array.isArray(value) && value.length <= 2 && new Set(value).size === value.length && value.every((side) => side === "before" || side === "after");
|
|
68
113
|
const ReviewResolutionProvenanceErrorBase = TaggedError("ReviewResolutionProvenanceError");
|
|
69
114
|
var ReviewResolutionProvenanceError = class extends ReviewResolutionProvenanceErrorBase {};
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
message: `Invalid or unsupported ${attribute} review provenance.`,
|
|
76
|
-
reason
|
|
77
|
-
});
|
|
78
|
-
if (encoded.length > 32768) throw failed();
|
|
115
|
+
const decodeProvenance = (encoded, valid) => {
|
|
116
|
+
if (encoded.length > 32768) return {
|
|
117
|
+
status: "dropped",
|
|
118
|
+
reason: "invalid"
|
|
119
|
+
};
|
|
79
120
|
const parsed = Result.try({
|
|
80
121
|
try: () => JSON.parse(encoded),
|
|
81
|
-
catch: () =>
|
|
122
|
+
catch: () => void 0
|
|
82
123
|
});
|
|
83
|
-
if (parsed.isErr())
|
|
124
|
+
if (parsed.isErr()) return {
|
|
125
|
+
status: "dropped",
|
|
126
|
+
reason: "invalid"
|
|
127
|
+
};
|
|
84
128
|
const decoded = parsed.value;
|
|
85
|
-
if (!record(decoded) || Object.keys(decoded).some((key) => key !== "version" && key !== "value"))
|
|
129
|
+
if (!record(decoded) || Object.keys(decoded).some((key) => key !== "version" && key !== "value")) return {
|
|
130
|
+
status: "dropped",
|
|
131
|
+
reason: "invalid"
|
|
132
|
+
};
|
|
133
|
+
if (decoded["version"] !== VERSION) return {
|
|
134
|
+
status: "dropped",
|
|
135
|
+
reason: "unsupportedVersion"
|
|
136
|
+
};
|
|
86
137
|
const value = decoded["value"];
|
|
87
|
-
if (!valid(value))
|
|
88
|
-
|
|
89
|
-
|
|
138
|
+
if (!valid(value)) return {
|
|
139
|
+
status: "dropped",
|
|
140
|
+
reason: "invalid"
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
status: "read",
|
|
144
|
+
value
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Read one provenance attribute. Provenance is advisory, ignorable metadata:
|
|
149
|
+
* a value folio cannot read (another version, a field it does not know, a
|
|
150
|
+
* malformed value) is dropped and the revisions it would annotate are read
|
|
151
|
+
* as they are; {@link reviewProvenanceIssues} reports what was dropped.
|
|
152
|
+
* What folio writes is validated strictly before it is written.
|
|
153
|
+
*/
|
|
154
|
+
const parseAttribute = ({ node, attribute, valid }) => {
|
|
155
|
+
const encoded = getAttributeByNamespaceUri(node, NAMESPACES, attribute);
|
|
156
|
+
if (encoded === null) return void 0;
|
|
157
|
+
const decoded = decodeProvenance(encoded, valid);
|
|
158
|
+
return decoded.status === "read" ? decoded.value : void 0;
|
|
90
159
|
};
|
|
91
160
|
const encodeAttribute = ({ attribute, value, valid }) => {
|
|
92
161
|
if (value === void 0) return void 0;
|
|
@@ -110,11 +179,14 @@ const serializeAttribute = (options) => {
|
|
|
110
179
|
const encoded = encodeAttribute(options);
|
|
111
180
|
return encoded === void 0 ? "" : ` folio:${options.attribute}="${escapeXmlAttribute(encoded)}"`;
|
|
112
181
|
};
|
|
113
|
-
const parseResolutionJoins = (node) =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
182
|
+
const parseResolutionJoins = (node) => {
|
|
183
|
+
const joins = parseAttribute({
|
|
184
|
+
node,
|
|
185
|
+
attribute: "resolutionJoins",
|
|
186
|
+
valid: isStoredResolutionJoins
|
|
187
|
+
});
|
|
188
|
+
return joins === void 0 ? void 0 : withEnclosing(joins, node);
|
|
189
|
+
};
|
|
118
190
|
const parseBoundaryJoins = (node) => parseAttribute({
|
|
119
191
|
node,
|
|
120
192
|
attribute: "boundaryJoins",
|
|
@@ -127,9 +199,9 @@ const parseCopyOriginAncestors = (node) => parseAttribute({
|
|
|
127
199
|
});
|
|
128
200
|
const serializeResolutionJoins = (value) => serializeAttribute({
|
|
129
201
|
attribute: "resolutionJoins",
|
|
130
|
-
value,
|
|
131
|
-
valid:
|
|
132
|
-
});
|
|
202
|
+
value: value === void 0 ? void 0 : storedJoins(value),
|
|
203
|
+
valid: isStoredResolutionJoins
|
|
204
|
+
}) + serializeEnclosing(value);
|
|
133
205
|
const serializeBoundaryJoins = (value) => serializeAttribute({
|
|
134
206
|
attribute: "boundaryJoins",
|
|
135
207
|
value,
|
|
@@ -140,25 +212,91 @@ const serializeCopyOriginAncestors = (value) => encodeAttribute({
|
|
|
140
212
|
value,
|
|
141
213
|
valid: isCopyOriginAncestors
|
|
142
214
|
});
|
|
143
|
-
|
|
215
|
+
const isParagraphMarkSurvivor = (value) => value === "first";
|
|
216
|
+
/**
|
|
217
|
+
* A paragraph mark's private review provenance: its rejection join depth
|
|
218
|
+
* (null carries an owned undefined depth) and the paragraph rejecting it
|
|
219
|
+
* keeps. A missing attribute carries no field.
|
|
220
|
+
*/
|
|
144
221
|
const parseParagraphMarkResolutionJoin = (node) => {
|
|
145
222
|
const value = parseAttribute({
|
|
146
223
|
node,
|
|
147
224
|
attribute: PARAGRAPH_MARK_FIELDS.resolutionJoin.attribute,
|
|
148
225
|
valid: isEncodedParagraphMarkResolutionJoin
|
|
149
226
|
});
|
|
150
|
-
|
|
227
|
+
const survivor = parseAttribute({
|
|
228
|
+
node,
|
|
229
|
+
attribute: PARAGRAPH_MARK_FIELDS.survivor.attribute,
|
|
230
|
+
valid: isParagraphMarkSurvivor
|
|
231
|
+
});
|
|
232
|
+
return {
|
|
233
|
+
...value === void 0 ? {} : { resolutionJoin: value === null ? void 0 : value },
|
|
234
|
+
...survivor === void 0 ? {} : { survivor }
|
|
235
|
+
};
|
|
151
236
|
};
|
|
237
|
+
const paragraphMarkSurvivorOptions = (mark) => ({
|
|
238
|
+
attribute: PARAGRAPH_MARK_FIELDS.survivor.attribute,
|
|
239
|
+
value: mark.survivor,
|
|
240
|
+
valid: isParagraphMarkSurvivor
|
|
241
|
+
});
|
|
152
242
|
const paragraphMarkResolutionJoinOptions = (mark) => ({
|
|
153
243
|
attribute: PARAGRAPH_MARK_FIELDS.resolutionJoin.attribute,
|
|
154
244
|
value: Object.hasOwn(mark, "resolutionJoin") ? mark.resolutionJoin ?? null : void 0,
|
|
155
245
|
valid: isEncodedParagraphMarkResolutionJoin
|
|
156
246
|
});
|
|
157
|
-
const serializeParagraphMarkResolutionJoin = (mark) => serializeAttribute(paragraphMarkResolutionJoinOptions(mark));
|
|
158
|
-
/** Captured paragraph properties compose the same
|
|
247
|
+
const serializeParagraphMarkResolutionJoin = (mark) => serializeAttribute(paragraphMarkResolutionJoinOptions(mark)) + serializeAttribute(paragraphMarkSurvivorOptions(mark));
|
|
248
|
+
/** Captured paragraph properties compose the same envelopes into a parsed XML element. */
|
|
159
249
|
const paragraphMarkResolutionJoinAttributes = (mark) => {
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
|
|
250
|
+
const attributes = {};
|
|
251
|
+
for (const options of [paragraphMarkResolutionJoinOptions(mark), paragraphMarkSurvivorOptions(mark)]) {
|
|
252
|
+
const encoded = encodeAttribute(options);
|
|
253
|
+
if (encoded !== void 0) attributes[`folio:${options.attribute}`] = encoded;
|
|
254
|
+
}
|
|
255
|
+
return attributes;
|
|
256
|
+
};
|
|
257
|
+
const SPLIT_PIECE_FIELDS = {
|
|
258
|
+
piece: true,
|
|
259
|
+
pieces: true,
|
|
260
|
+
joins: true
|
|
261
|
+
};
|
|
262
|
+
const isSplitResolutionPiece = (value) => record(value) && Object.keys(value).every((key) => Object.hasOwn(SPLIT_PIECE_FIELDS, key)) && natural(value["piece"]) && natural(value["pieces"]) && value["pieces"] >= 2 && value["piece"] < value["pieces"] && (!Object.hasOwn(value, "joins") || value["piece"] === 0 && isStoredResolutionJoins(value["joins"]));
|
|
263
|
+
const parseSplitResolutionPiece = (node) => {
|
|
264
|
+
const piece = parseAttribute({
|
|
265
|
+
node,
|
|
266
|
+
attribute: "splitResolutionJoins",
|
|
267
|
+
valid: isSplitResolutionPiece
|
|
268
|
+
});
|
|
269
|
+
return piece?.joins === void 0 ? piece : {
|
|
270
|
+
...piece,
|
|
271
|
+
joins: withEnclosing(piece.joins, node)
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
const serializeSplitResolutionPiece = (value) => serializeAttribute({
|
|
275
|
+
attribute: "splitResolutionJoins",
|
|
276
|
+
value: value.joins === void 0 ? value : {
|
|
277
|
+
...value,
|
|
278
|
+
joins: storedJoins(value.joins)
|
|
279
|
+
},
|
|
280
|
+
valid: isSplitResolutionPiece
|
|
281
|
+
}) + serializeEnclosing(value.joins);
|
|
282
|
+
/** Every provenance attribute folio reads, with the shape its value must have. */
|
|
283
|
+
const PROVENANCE_VALUE_SHAPES = {
|
|
284
|
+
resolutionJoins: isStoredResolutionJoins,
|
|
285
|
+
boundaryJoins: isBoundaryJoins,
|
|
286
|
+
[PARAGRAPH_MARK_FIELDS.resolutionJoin.attribute]: isEncodedParagraphMarkResolutionJoin,
|
|
287
|
+
copyOriginAncestors: isCopyOriginAncestors,
|
|
288
|
+
splitResolutionJoins: isSplitResolutionPiece,
|
|
289
|
+
[ENCLOSING_ATTRIBUTE]: enclosingHandoffs,
|
|
290
|
+
[PARAGRAPH_MARK_FIELDS.survivor.attribute]: isParagraphMarkSurvivor
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Why the reader drops a provenance attribute's value, or `undefined` when it
|
|
294
|
+
* reads it (or does not read that attribute at all).
|
|
295
|
+
*/
|
|
296
|
+
const reviewProvenanceIssue = (attribute, encoded) => {
|
|
297
|
+
const shape = PROVENANCE_VALUE_SHAPES[attribute];
|
|
298
|
+
if (shape === void 0) return void 0;
|
|
299
|
+
const decoded = decodeProvenance(encoded, shape);
|
|
300
|
+
return decoded.status === "dropped" ? decoded.reason : void 0;
|
|
163
301
|
};
|
|
164
|
-
export { ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseParagraphMarkResolutionJoin, parseResolutionJoins, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeParagraphMarkResolutionJoin, serializeResolutionJoins };
|
|
302
|
+
export { ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, isSplitResolutionPiece, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseParagraphMarkResolutionJoin, parseResolutionJoins, parseSplitResolutionPiece, reviewProvenanceIssue, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeParagraphMarkResolutionJoin, serializeResolutionJoins, serializeSplitResolutionPiece };
|
package/dist/docx/rezip.d.ts
CHANGED
|
@@ -55,6 +55,12 @@ export declare const assertSectionCarriersMatchModel: ({ doc, serializedSectionC
|
|
|
55
55
|
doc: document_d_exports.Document;
|
|
56
56
|
serializedSectionCount: number;
|
|
57
57
|
}) => void;
|
|
58
|
+
/**
|
|
59
|
+
* A relationships part to add to. A package need not have one for a part that
|
|
60
|
+
* has no relationships yet, so a missing part reads as an empty one: adding to
|
|
61
|
+
* it must create it, never skip the relationship it was asked for.
|
|
62
|
+
*/
|
|
63
|
+
export declare function readRelsOrStub(zip: ZipArchive, relsPath: string): Promise<string>;
|
|
58
64
|
declare const CanonicalImageRelationshipRefusalErrorBase: TaggedErrorClass<"CanonicalImageRelationshipRefusalError">;
|
|
59
65
|
export declare class CanonicalImageRelationshipRefusalError extends CanonicalImageRelationshipRefusalErrorBase<{
|
|
60
66
|
message: string;
|
package/dist/docx/rezip.js
CHANGED
|
@@ -215,8 +215,8 @@ async function syncCommentsExtendedPart(plan, zip, compressionLevel) {
|
|
|
215
215
|
/** Read a packaging file, apply a pure transform, and write it back if it changed. */
|
|
216
216
|
async function transformPackagingFile(zip, path, transform, compressionLevel) {
|
|
217
217
|
const file = zip.entry(path);
|
|
218
|
-
if (!file) return;
|
|
219
|
-
const xml = await file.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true }));
|
|
218
|
+
if (!file && !path.endsWith(".rels")) return;
|
|
219
|
+
const xml = file ? await file.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true })) : await readRelsOrStub(zip, path);
|
|
220
220
|
const next = transform(xml);
|
|
221
221
|
if (next !== xml) zip.set(path, next, { level: compressionLevel });
|
|
222
222
|
}
|
|
@@ -300,6 +300,11 @@ function collectDocxParts(doc, zip) {
|
|
|
300
300
|
addNoteParts(doc.package.endnotes, "word/endnotes.xml");
|
|
301
301
|
return parts;
|
|
302
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* A relationships part to add to. A package need not have one for a part that
|
|
305
|
+
* has no relationships yet, so a missing part reads as an empty one: adding to
|
|
306
|
+
* it must create it, never skip the relationship it was asked for.
|
|
307
|
+
*/
|
|
303
308
|
async function readRelsOrStub(zip, relsPath) {
|
|
304
309
|
const file = zip.entry(relsPath);
|
|
305
310
|
return (file ? await file.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true })) : EMPTY_RELS_XML).replace(/<Relationships(?<attrs>[^>]*)\/>/u, "<Relationships$<attrs>></Relationships>");
|
|
@@ -1047,9 +1052,7 @@ async function ensureCommentsContentType(zip, compressionLevel) {
|
|
|
1047
1052
|
*/
|
|
1048
1053
|
async function ensureCommentsRelationship(zip, compressionLevel) {
|
|
1049
1054
|
const relsPath = "word/_rels/document.xml.rels";
|
|
1050
|
-
|
|
1051
|
-
if (!relsFile) return;
|
|
1052
|
-
let relsXml = await relsFile.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true }));
|
|
1055
|
+
let relsXml = await readRelsOrStub(zip, relsPath);
|
|
1053
1056
|
if (relsXml.toLowerCase().includes("comments.xml")) return;
|
|
1054
1057
|
const commentsPartPath = findZipEntryCaseInsensitive(zip, "word/comments.xml")?.path ?? "word/comments.xml";
|
|
1055
1058
|
const newRId = `rId${findMaxRId(relsXml) + 1}`;
|
|
@@ -1122,9 +1125,7 @@ async function applyUpdatesToZip(zip, updates, options = {}) {
|
|
|
1122
1125
|
async function addRelationship(originalBuffer, relationship) {
|
|
1123
1126
|
const zip = await ZipArchive.read(originalBuffer);
|
|
1124
1127
|
const relsPath = "word/_rels/document.xml.rels";
|
|
1125
|
-
const
|
|
1126
|
-
if (!relsFile) panic("document.xml.rels not found in DOCX");
|
|
1127
|
-
const relsXml = await relsFile.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true }));
|
|
1128
|
+
const relsXml = await readRelsOrStub(zip, relsPath);
|
|
1128
1129
|
const newRId = `rId${findMaxRId(relsXml) + 1}`;
|
|
1129
1130
|
const targetModeAttr = relationship.targetMode === "External" ? " TargetMode=\"External\"" : "";
|
|
1130
1131
|
const newRelElement = `<Relationship Id="${newRId}" Type="${relationship.type}" Target="${escapeXmlAttribute(relationship.target)}"${targetModeAttr}/>`;
|
|
@@ -1501,8 +1502,16 @@ async function serializeNotesToZip({ doc, originalZip, newZip, compressionLevel,
|
|
|
1501
1502
|
if (originalFootnotes) await patchNotePartIntoZip({
|
|
1502
1503
|
conventionalLowerPath: "word/footnotes.xml",
|
|
1503
1504
|
currentXml: serializeFootnotes(footnotes),
|
|
1504
|
-
|
|
1505
|
-
|
|
1505
|
+
fromOriginal: (xml) => {
|
|
1506
|
+
const source = parseFootnotes(xml).getNormalFootnotes();
|
|
1507
|
+
return {
|
|
1508
|
+
baselineXml: serializeFootnotes(source),
|
|
1509
|
+
replacementXml: serializeNewFootnotesPart(footnotes, {
|
|
1510
|
+
document: doc,
|
|
1511
|
+
sourceNoteIds: new Set(source.map(({ id }) => id))
|
|
1512
|
+
})
|
|
1513
|
+
};
|
|
1514
|
+
},
|
|
1506
1515
|
elementName: "footnote",
|
|
1507
1516
|
changedNoteParaIds,
|
|
1508
1517
|
originalZip,
|
|
@@ -1514,7 +1523,7 @@ async function serializeNotesToZip({ doc, originalZip, newZip, compressionLevel,
|
|
|
1514
1523
|
newZip,
|
|
1515
1524
|
partPath: "word/footnotes.xml",
|
|
1516
1525
|
relationshipType: RELATIONSHIP_TYPES.footnotes,
|
|
1517
|
-
serializedPart: serializeNewFootnotesPart(footnotes, doc),
|
|
1526
|
+
serializedPart: serializeNewFootnotesPart(footnotes, { document: doc }),
|
|
1518
1527
|
compressionLevel
|
|
1519
1528
|
});
|
|
1520
1529
|
}
|
|
@@ -1524,8 +1533,16 @@ async function serializeNotesToZip({ doc, originalZip, newZip, compressionLevel,
|
|
|
1524
1533
|
if (originalEndnotes) await patchNotePartIntoZip({
|
|
1525
1534
|
conventionalLowerPath: "word/endnotes.xml",
|
|
1526
1535
|
currentXml: serializeEndnotes(endnotes),
|
|
1527
|
-
|
|
1528
|
-
|
|
1536
|
+
fromOriginal: (xml) => {
|
|
1537
|
+
const source = parseEndnotes(xml).getNormalEndnotes();
|
|
1538
|
+
return {
|
|
1539
|
+
baselineXml: serializeEndnotes(source),
|
|
1540
|
+
replacementXml: serializeNewEndnotesPart(endnotes, {
|
|
1541
|
+
document: doc,
|
|
1542
|
+
sourceNoteIds: new Set(source.map(({ id }) => id))
|
|
1543
|
+
})
|
|
1544
|
+
};
|
|
1545
|
+
},
|
|
1529
1546
|
elementName: "endnote",
|
|
1530
1547
|
changedNoteParaIds,
|
|
1531
1548
|
originalZip,
|
|
@@ -1537,24 +1554,24 @@ async function serializeNotesToZip({ doc, originalZip, newZip, compressionLevel,
|
|
|
1537
1554
|
newZip,
|
|
1538
1555
|
partPath: "word/endnotes.xml",
|
|
1539
1556
|
relationshipType: RELATIONSHIP_TYPES.endnotes,
|
|
1540
|
-
serializedPart: serializeNewEndnotesPart(endnotes, doc),
|
|
1557
|
+
serializedPart: serializeNewEndnotesPart(endnotes, { document: doc }),
|
|
1541
1558
|
compressionLevel
|
|
1542
1559
|
});
|
|
1543
1560
|
}
|
|
1544
1561
|
}
|
|
1545
1562
|
async function materializeNewNotePart({ contentType, newZip, partPath, relationshipType, serializedPart, compressionLevel }) {
|
|
1546
1563
|
const contentTypesFile = findNotePartEntry(newZip, "[content_types].xml");
|
|
1547
|
-
|
|
1548
|
-
|
|
1564
|
+
if (!contentTypesFile) throw new DocxPackageFidelityError(`Cannot create ${partPath}: the DOCX package is missing content types`);
|
|
1565
|
+
const relationshipsPath = findNotePartEntry(newZip, "word/_rels/document.xml.rels")?.path ?? "word/_rels/document.xml.rels";
|
|
1549
1566
|
const compressionOptions = { level: compressionLevel };
|
|
1550
1567
|
const contentTypesXml = await contentTypesFile.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true }));
|
|
1551
1568
|
const partName = `/${partPath}`;
|
|
1552
1569
|
if (!contentTypesXml.toLowerCase().includes(partName.toLowerCase())) newZip.set(contentTypesFile.path, contentTypesXml.replace("</Types>", () => `<Override PartName="${partName}" ContentType="${contentType}"/></Types>`), compressionOptions);
|
|
1553
|
-
const relationshipsXml = await
|
|
1570
|
+
const relationshipsXml = await readRelsOrStub(newZip, relationshipsPath);
|
|
1554
1571
|
if (!relationshipsXml.includes(relationshipType)) {
|
|
1555
1572
|
const relationshipId = `rId${findMaxRId(relationshipsXml) + 1}`;
|
|
1556
1573
|
const target = partPath.slice(5);
|
|
1557
|
-
newZip.set(
|
|
1574
|
+
newZip.set(relationshipsPath, relationshipsXml.replace("</Relationships>", () => `<Relationship Id="${relationshipId}" Type="${relationshipType}" Target="${target}"/></Relationships>`), compressionOptions);
|
|
1558
1575
|
}
|
|
1559
1576
|
newZip.set(partPath, serializedPart, compressionOptions);
|
|
1560
1577
|
}
|
|
@@ -1799,11 +1816,11 @@ const notePartXmlFor = ({ patch, originalXml, replacementXml, hasDirtyParagraph,
|
|
|
1799
1816
|
default: return panic("Unhandled note-part patch", { patch });
|
|
1800
1817
|
}
|
|
1801
1818
|
};
|
|
1802
|
-
async function patchNotePartIntoZip({ conventionalLowerPath, currentXml,
|
|
1819
|
+
async function patchNotePartIntoZip({ conventionalLowerPath, currentXml, fromOriginal, elementName, changedNoteParaIds, originalZip, newZip, compressionLevel }) {
|
|
1803
1820
|
const file = findNotePartEntry(originalZip, conventionalLowerPath);
|
|
1804
1821
|
if (!file) return;
|
|
1805
1822
|
const originalXml = await file.bytes().then((bytes) => decodeText(bytes, { ignoreBOM: true }));
|
|
1806
|
-
const baselineXml =
|
|
1823
|
+
const { baselineXml, replacementXml } = fromOriginal(originalXml);
|
|
1807
1824
|
const effectiveChangedNoteParaIds = changedNoteParaIds ?? collectChangedNoteParaIds(baselineXml, currentXml);
|
|
1808
1825
|
const currentParaIds = collectParaIds(currentXml);
|
|
1809
1826
|
const patchedXml = notePartXmlFor({
|
|
@@ -2078,4 +2095,4 @@ const assertStyleNumberingReferences = (doc) => {
|
|
|
2078
2095
|
if (!numberingInstanceResolves(definitions, numId)) panic(`Numbering definition ${numId} defines no level`);
|
|
2079
2096
|
}
|
|
2080
2097
|
};
|
|
2081
|
-
export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENDED_PART, COMMENTS_EXTENDED_PART_LOWER, CanonicalImageRelationshipRefusalError, DocxDuplicateSectionCarrierError, DocxPackageFidelityError, addCommentsExtendedOverride, addCommentsExtendedRelationship, addMedia, addRelationship, applyUpdatesToZip, assertSectionCarriersMatchModel, collectHeaderFooterUpdates, collectHyperlinksWithoutRId, createDocx, createEmptyDocx, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedHyperlinkBindings, hasUnmaterializedInlineResources, isDocxBuffer, notePartRelsPath, planAddedStyles, publishCanonicalImageResources, removeCommentsExtendedOverride, removeCommentsExtendedRelationship, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx, withoutAttachedTemplate };
|
|
2098
|
+
export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENDED_PART, COMMENTS_EXTENDED_PART_LOWER, CanonicalImageRelationshipRefusalError, DocxDuplicateSectionCarrierError, DocxPackageFidelityError, addCommentsExtendedOverride, addCommentsExtendedRelationship, addMedia, addRelationship, applyUpdatesToZip, assertSectionCarriersMatchModel, collectHeaderFooterUpdates, collectHyperlinksWithoutRId, createDocx, createEmptyDocx, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedHyperlinkBindings, hasUnmaterializedInlineResources, isDocxBuffer, notePartRelsPath, planAddedStyles, publishCanonicalImageResources, readRelsOrStub, removeCommentsExtendedOverride, removeCommentsExtendedRelationship, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx, withoutAttachedTemplate };
|
|
@@ -8,7 +8,7 @@ import { parseNumbering } from "./numberingParser.js";
|
|
|
8
8
|
import { normalizeImportedNumericIds } from "./numericIdNormalization.js";
|
|
9
9
|
import { isUnsafePackagePath } from "./packageParts.js";
|
|
10
10
|
import { RELATIONSHIP_TYPES } from "./relsParser.js";
|
|
11
|
-
import { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_PART_LOWER, addCommentsExtendedOverride, addCommentsExtendedRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedHyperlinkBindings, hasUnmaterializedInlineResources, planAddedStyles, publishCanonicalImageResources, updateCoreProperties, withoutAttachedTemplate } from "./rezip.js";
|
|
11
|
+
import { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_PART_LOWER, addCommentsExtendedOverride, addCommentsExtendedRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, findMaxRId, hasModelDrivenPictureWatermark, hasUnmaterializedHeaderFooter, hasUnmaterializedHyperlinkBindings, hasUnmaterializedInlineResources, planAddedStyles, publishCanonicalImageResources, readRelsOrStub, updateCoreProperties, withoutAttachedTemplate } from "./rezip.js";
|
|
12
12
|
import "./selectiveSaveFlags.js";
|
|
13
13
|
import { buildPatchedDocumentXml, buildPatchedNoteXml, collectAddedNumberingDefs, collectParaIds, patchNumberingDefinitions } from "./selectiveXmlPatch.js";
|
|
14
14
|
import { canReplayCommentsPart, hasOwnedCommentsPart, planCommentParts, serializeComments, serializeCommentsExtended } from "./serializer/commentSerializer.js";
|
|
@@ -112,8 +112,7 @@ async function ensureCommentsExtendedPackaging(zip, updates) {
|
|
|
112
112
|
const nextCt = addCommentsExtendedOverride(ctXml);
|
|
113
113
|
if (nextCt !== ctXml) updates.set(ctPath, nextCt);
|
|
114
114
|
const relsPath = "word/_rels/document.xml.rels";
|
|
115
|
-
const relsXml = updates.get(relsPath) ?? await zip
|
|
116
|
-
if (relsXml === void 0) return false;
|
|
115
|
+
const relsXml = updates.get(relsPath) ?? await readRelsOrStub(zip, relsPath);
|
|
117
116
|
const nextRels = addCommentsExtendedRelationship(relsXml);
|
|
118
117
|
if (nextRels !== relsXml) updates.set(relsPath, nextRels);
|
|
119
118
|
return true;
|
|
@@ -274,13 +273,10 @@ async function attemptSelectiveSave(doc, originalBuffer, options) {
|
|
|
274
273
|
if (!ctXml.toLowerCase().includes("/word/comments.xml")) updates.set("[Content_Types].xml", ctXml.replace("</Types>", `<Override PartName="/${commentsPartPath}" ContentType="${COMMENTS_CONTENT_TYPE}"/></Types>`));
|
|
275
274
|
}
|
|
276
275
|
const relsPath = "word/_rels/document.xml.rels";
|
|
277
|
-
const
|
|
278
|
-
if (
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
const maxId = findMaxRId(relsXml);
|
|
282
|
-
updates.set(relsPath, relsXml.replace("</Relationships>", `<Relationship Id="rId${maxId + 1}" Type="${RELATIONSHIP_TYPES.comments}" Target="${commentsPartPath.slice(5)}"/></Relationships>`));
|
|
283
|
-
}
|
|
276
|
+
const relsXml = await readRelsOrStub(zip, relsPath);
|
|
277
|
+
if (!relsXml.toLowerCase().includes("comments.xml")) {
|
|
278
|
+
const maxId = findMaxRId(relsXml);
|
|
279
|
+
updates.set(relsPath, relsXml.replace("</Relationships>", `<Relationship Id="rId${maxId + 1}" Type="${RELATIONSHIP_TYPES.comments}" Target="${commentsPartPath.slice(5)}"/></Relationships>`));
|
|
284
280
|
}
|
|
285
281
|
}
|
|
286
282
|
if (!commentsUnchanged && !await patchCommentsExtended(zip, commentPlan, updates)) return null;
|