@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
|
@@ -215,8 +215,8 @@ export type NotePartPatch = {
|
|
|
215
215
|
* dirty paragraphs. A tracked paragraph-break resolution can change that
|
|
216
216
|
* shape, so it replaces the one affected note. Separator notes, unrelated
|
|
217
217
|
* notes, and unaffected equal-shape paragraphs remain byte-exact.
|
|
218
|
-
* `replacementXml`
|
|
219
|
-
*
|
|
218
|
+
* `replacementXml` gives a note new to the part its automatic reference mark;
|
|
219
|
+
* a note the part already has carries its own, or none, in the model.
|
|
220
220
|
*
|
|
221
221
|
* A comment can be anchored on a note's own text, so its range spans that
|
|
222
222
|
* note's paragraphs and an edit inside the span moves a range half from one
|
|
@@ -263,8 +263,9 @@ export declare const patchNumberingDefinitions: ({ originalXml, baselineXml, cur
|
|
|
263
263
|
/**
|
|
264
264
|
* Append added `w:abstractNum` / `w:num` definitions from `currentXml` to
|
|
265
265
|
* `xml`. ECMA-376 §17.9 orders every `w:abstractNum` before the first `w:num`,
|
|
266
|
-
*
|
|
267
|
-
*
|
|
266
|
+
* and `w:numIdMacAtCleanup` after the last, so abstract definitions go right
|
|
267
|
+
* before the first `<w:num ` and instances right before that marker, or the
|
|
268
|
+
* root close when the part has neither. A
|
|
268
269
|
* synthetic numFmt in an added abstract is restored from the original
|
|
269
270
|
* definition it was cloned from (the one with an identical body), so a custom
|
|
270
271
|
* format survives cloning. Returns null when an added id cannot be extracted
|
|
@@ -792,8 +792,8 @@ const collectChangedNoteParaIds = (baselineXml, currentXml) => {
|
|
|
792
792
|
* dirty paragraphs. A tracked paragraph-break resolution can change that
|
|
793
793
|
* shape, so it replaces the one affected note. Separator notes, unrelated
|
|
794
794
|
* notes, and unaffected equal-shape paragraphs remain byte-exact.
|
|
795
|
-
* `replacementXml`
|
|
796
|
-
*
|
|
795
|
+
* `replacementXml` gives a note new to the part its automatic reference mark;
|
|
796
|
+
* a note the part already has carries its own, or none, in the model.
|
|
797
797
|
*
|
|
798
798
|
* A comment can be anchored on a note's own text, so its range spans that
|
|
799
799
|
* note's paragraphs and an edit inside the span moves a range half from one
|
|
@@ -1220,6 +1220,7 @@ function collectAddedNumberingDefs(baselineXml, currentXml) {
|
|
|
1220
1220
|
};
|
|
1221
1221
|
}
|
|
1222
1222
|
const NUMBERING_CLOSE_ROOT = "</w:numbering>";
|
|
1223
|
+
const NUMBERING_CLEANUP_MARKER = "<w:numIdMacAtCleanup";
|
|
1223
1224
|
const numberingDefinitionIdentity = (element) => {
|
|
1224
1225
|
if (!WORDPROCESSINGML_NAMESPACE_URIS.has(getNamespaceUri(element) ?? "")) return null;
|
|
1225
1226
|
const kind = getLocalName(element.name);
|
|
@@ -1283,8 +1284,9 @@ const patchNumberingDefinitions = ({ originalXml, baselineXml, currentXml }) =>
|
|
|
1283
1284
|
/**
|
|
1284
1285
|
* Append added `w:abstractNum` / `w:num` definitions from `currentXml` to
|
|
1285
1286
|
* `xml`. ECMA-376 §17.9 orders every `w:abstractNum` before the first `w:num`,
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1287
|
+
* and `w:numIdMacAtCleanup` after the last, so abstract definitions go right
|
|
1288
|
+
* before the first `<w:num ` and instances right before that marker, or the
|
|
1289
|
+
* root close when the part has neither. A
|
|
1288
1290
|
* synthetic numFmt in an added abstract is restored from the original
|
|
1289
1291
|
* definition it was cloned from (the one with an identical body), so a custom
|
|
1290
1292
|
* format survives cloning. Returns null when an added id cannot be extracted
|
|
@@ -1307,10 +1309,12 @@ function appendNumberingDefs(xml, currentXml, added) {
|
|
|
1307
1309
|
numXmls.push(def);
|
|
1308
1310
|
}
|
|
1309
1311
|
const firstNum = findFirstElement(xml, NUMBERING_OPEN_LITERAL.num, NUMBERING_CLOSE_TAG.num);
|
|
1310
|
-
const
|
|
1312
|
+
const cleanupMarker = xml.indexOf(NUMBERING_CLEANUP_MARKER);
|
|
1313
|
+
const instancesEnd = cleanupMarker < 0 ? rootClose : cleanupMarker;
|
|
1314
|
+
const abstractInsertAt = firstNum ? firstNum.start : instancesEnd;
|
|
1311
1315
|
const head = xml.slice(0, abstractInsertAt);
|
|
1312
|
-
const middle = xml.slice(abstractInsertAt,
|
|
1313
|
-
const tail = xml.slice(
|
|
1316
|
+
const middle = xml.slice(abstractInsertAt, instancesEnd);
|
|
1317
|
+
const tail = xml.slice(instancesEnd);
|
|
1314
1318
|
return head + abstractXmls.join("") + middle + numXmls.join("") + tail;
|
|
1315
1319
|
}
|
|
1316
1320
|
/**
|
|
@@ -2,7 +2,7 @@ import { getDocumentSourceBaseline } from "../headerFooterVerbatim.js";
|
|
|
2
2
|
import { buildDocumentBlockReplay, canReplayDocumentSource } from "../storyBlockReplay.js";
|
|
3
3
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
4
4
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
5
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
5
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
6
6
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
7
7
|
import { serializePartElement } from "./partNamespaces.js";
|
|
8
8
|
import { resetAutoIdCounter } from "./runSerializer.js";
|
|
@@ -68,6 +68,8 @@ function serializeBlockContent(block) {
|
|
|
68
68
|
case "moveFromRangeEnd":
|
|
69
69
|
case "moveToRangeStart":
|
|
70
70
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
71
|
+
case "commentRangeStart":
|
|
72
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
71
73
|
default: return block;
|
|
72
74
|
}
|
|
73
75
|
}
|
|
@@ -102,11 +104,12 @@ function serializeDocumentBody(body) {
|
|
|
102
104
|
if (body.finalSectionProperties) parts.push(serializeSectionProperties(body.finalSectionProperties));
|
|
103
105
|
return parts.join("");
|
|
104
106
|
}
|
|
107
|
+
const withoutByteOrderMark = (xml) => xml.startsWith("") ? xml.slice(1) : xml;
|
|
105
108
|
const replayableDocumentSources = /* @__PURE__ */ new WeakMap();
|
|
106
109
|
function serializeDocument(doc, sourceBindings, source) {
|
|
107
110
|
resetAutoIdCounter();
|
|
108
111
|
const baseline = source?.bodyAuthority === "canonical" ? getDocumentSourceBaseline(doc) : { type: "missing" };
|
|
109
|
-
const sourceMatches = baseline.type === "captured" && (source?.xml === void 0 || source.xml === baseline.xml);
|
|
112
|
+
const sourceMatches = baseline.type === "captured" && (source?.xml === void 0 || withoutByteOrderMark(source.xml) === withoutByteOrderMark(baseline.xml));
|
|
110
113
|
if (baseline.type === "captured" && sourceMatches && JSON.stringify(doc.package.document) === baseline.fingerprint) {
|
|
111
114
|
if (replayableDocumentSources.get(baseline.body) === baseline.xml) return baseline.xml;
|
|
112
115
|
if (canReplayDocumentSource(baseline.xml, baseline.body)) {
|
|
@@ -5,7 +5,7 @@ import { captureVerbatimXml } from "../verbatimCapture.js";
|
|
|
5
5
|
import { getLocalName, parseXmlDocument } from "../xmlParser.js";
|
|
6
6
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
7
7
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
8
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
8
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
9
9
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
10
10
|
import { serializePartElement } from "./partNamespaces.js";
|
|
11
11
|
import { serializeTable } from "./tableSerializer.js";
|
|
@@ -51,6 +51,8 @@ function serializeBlock(block) {
|
|
|
51
51
|
case "moveFromRangeEnd":
|
|
52
52
|
case "moveToRangeStart":
|
|
53
53
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
54
|
+
case "commentRangeStart":
|
|
55
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
54
56
|
default: return block;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -16,4 +16,9 @@ export declare const moveBookmarkAttributes: (marker: document_d_exports.MoveFro
|
|
|
16
16
|
* One move range marker, wherever it stands: a paragraph child or a block, so
|
|
17
17
|
* the serializers share one writer as they do for bookmarks.
|
|
18
18
|
*/
|
|
19
|
-
export declare const serializeMoveRangeMarker: (marker: document_d_exports.MoveFromRangeStart | document_d_exports.MoveFromRangeEnd | document_d_exports.MoveToRangeStart | document_d_exports.MoveToRangeEnd) => string;
|
|
19
|
+
export declare const serializeMoveRangeMarker: (marker: document_d_exports.MoveFromRangeStart | document_d_exports.MoveFromRangeEnd | document_d_exports.MoveToRangeStart | document_d_exports.MoveToRangeEnd) => string;
|
|
20
|
+
/**
|
|
21
|
+
* One comment range marker, wherever it stands: a paragraph child or a block,
|
|
22
|
+
* so the serializers share one writer as they do for bookmarks and moves.
|
|
23
|
+
*/
|
|
24
|
+
export declare const serializeCommentRangeMarker: (marker: document_d_exports.CommentRangeStart | document_d_exports.CommentRangeEnd) => string;
|
|
@@ -55,4 +55,9 @@ const serializeMoveRangeMarker = (marker) => {
|
|
|
55
55
|
default: return marker;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* One comment range marker, wherever it stands: a paragraph child or a block,
|
|
60
|
+
* so the serializers share one writer as they do for bookmarks and moves.
|
|
61
|
+
*/
|
|
62
|
+
const serializeCommentRangeMarker = (marker) => `<w:${marker.type} ${markupRangeAttributes(marker).join(" ")}/>`;
|
|
63
|
+
export { bookmarkRangeAttributes, markupRangeAttributes, moveBookmarkAttributes, serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker };
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
/** What a new note part is written for. */
|
|
3
|
+
export type NewNotePartContext = {
|
|
4
|
+
/** The document the notes belong to, which says whether a note's reference shows a custom mark. */
|
|
5
|
+
document?: document_d_exports.Document;
|
|
6
|
+
/**
|
|
7
|
+
* Notes the source package already has. Their content says whether they
|
|
8
|
+
* show a reference mark, as read, edited and resolved; only a note new to
|
|
9
|
+
* the package is given one.
|
|
10
|
+
*/
|
|
11
|
+
sourceNoteIds?: ReadonlySet<number>;
|
|
12
|
+
};
|
|
2
13
|
/**
|
|
3
14
|
* Serialize footnotes to a complete word/footnotes.xml string.
|
|
4
15
|
*
|
|
@@ -14,8 +25,10 @@ export declare function serializeFootnotes(footnotes: readonly document_d_export
|
|
|
14
25
|
*/
|
|
15
26
|
export declare function serializeEndnotes(endnotes: readonly document_d_exports.Endnote[]): string;
|
|
16
27
|
/** Serialize a brand-new footnote part, including Word's required separators
|
|
17
|
-
* and the automatic reference mark at the start of every normal note
|
|
18
|
-
|
|
28
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
29
|
+
* the package. */
|
|
30
|
+
export declare function serializeNewFootnotesPart(footnotes: readonly document_d_exports.Footnote[], context?: NewNotePartContext): string;
|
|
19
31
|
/** Serialize a brand-new endnote part, including Word's required separators
|
|
20
|
-
* and the automatic reference mark at the start of every normal note
|
|
21
|
-
|
|
32
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
33
|
+
* the package. */
|
|
34
|
+
export declare function serializeNewEndnotesPart(endnotes: readonly document_d_exports.Endnote[], context?: NewNotePartContext): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hasNoteReferenceMark } from "../noteReferenceMark.js";
|
|
2
2
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
3
3
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
4
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
4
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
5
5
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
6
6
|
import { serializePartElement } from "./partNamespaces.js";
|
|
7
7
|
import { serializeTable } from "./tableSerializer.js";
|
|
@@ -75,6 +75,8 @@ function serializeBlock(block) {
|
|
|
75
75
|
case "moveFromRangeEnd":
|
|
76
76
|
case "moveToRangeStart":
|
|
77
77
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
78
|
+
case "commentRangeStart":
|
|
79
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
78
80
|
default: return block;
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -105,13 +107,16 @@ function insertNoteReferenceMark({ xml, elementName, note, customMark }) {
|
|
|
105
107
|
const referenceRun = `<w:r><w:rPr><w:rStyle w:val="${elementName === "footnote" ? "FootnoteReference" : "EndnoteReference"}"/></w:rPr><w:${elementName}Ref/></w:r>`;
|
|
106
108
|
return `${xml.slice(0, insertAt)}${referenceRun}${xml.slice(insertAt)}`;
|
|
107
109
|
}
|
|
108
|
-
function serializeNewNotePart({ elementName, notes, document }) {
|
|
109
|
-
const serializedNotes = notes.map((note) =>
|
|
110
|
-
xml
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
function serializeNewNotePart({ elementName, notes, document, sourceNoteIds }) {
|
|
111
|
+
const serializedNotes = notes.map((note) => {
|
|
112
|
+
const xml = serializeNote(elementName, note);
|
|
113
|
+
return sourceNoteIds?.has(note.id) === true ? xml : insertNoteReferenceMark({
|
|
114
|
+
xml,
|
|
115
|
+
elementName,
|
|
116
|
+
note,
|
|
117
|
+
customMark: document ? noteUsesCustomMark(document, note) : false
|
|
118
|
+
});
|
|
119
|
+
}).join("");
|
|
115
120
|
return serializeNotePart(elementName, serializeRequiredNoteSeparators(elementName) + serializedNotes);
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
@@ -133,21 +138,23 @@ function serializeEndnotes(endnotes) {
|
|
|
133
138
|
return serializeNotePart("endnote", endnotes.map((en) => serializeNote("endnote", en)).join(""));
|
|
134
139
|
}
|
|
135
140
|
/** Serialize a brand-new footnote part, including Word's required separators
|
|
136
|
-
* and the automatic reference mark at the start of every normal note
|
|
137
|
-
|
|
141
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
142
|
+
* the package. */
|
|
143
|
+
function serializeNewFootnotesPart(footnotes, context = {}) {
|
|
138
144
|
return serializeNewNotePart({
|
|
145
|
+
...context,
|
|
139
146
|
elementName: "footnote",
|
|
140
|
-
notes: footnotes
|
|
141
|
-
...document ? { document } : {}
|
|
147
|
+
notes: footnotes
|
|
142
148
|
});
|
|
143
149
|
}
|
|
144
150
|
/** Serialize a brand-new endnote part, including Word's required separators
|
|
145
|
-
* and the automatic reference mark at the start of every normal note
|
|
146
|
-
|
|
151
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
152
|
+
* the package. */
|
|
153
|
+
function serializeNewEndnotesPart(endnotes, context = {}) {
|
|
147
154
|
return serializeNewNotePart({
|
|
155
|
+
...context,
|
|
148
156
|
elementName: "endnote",
|
|
149
|
-
notes: endnotes
|
|
150
|
-
...document ? { document } : {}
|
|
157
|
+
notes: endnotes
|
|
151
158
|
});
|
|
152
159
|
}
|
|
153
160
|
export { serializeEndnotes, serializeFootnotes, serializeNewEndnotesPart, serializeNewFootnotesPart };
|
|
@@ -4,13 +4,13 @@ import { CONTAINER_CHILDREN, TRACKED_RUN_WORDPROCESSING_CHILDREN } from "../cont
|
|
|
4
4
|
import { fieldStateAttributes } from "../fieldState.js";
|
|
5
5
|
import { serializeEmptyMarkProperties } from "../paragraphMarkPropertyPresence.js";
|
|
6
6
|
import { getParagraphPropertySource, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceMatchesAuthoredIndentation, paragraphPropertySourceMatchesEmission } from "../paragraphPropertySource.js";
|
|
7
|
-
import {
|
|
7
|
+
import { paragraphMarkResolutionJoinAttributes, serializeParagraphMarkResolutionJoin, serializeResolutionJoins, serializeSplitResolutionPiece } from "../reviewResolutionProvenance.js";
|
|
8
8
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
9
9
|
import { toTransitionalNamespaceUri } from "../transitionalSpelling.js";
|
|
10
10
|
import { captureVerbatimXml, createCapturedXmlSanitizer } from "../verbatimCapture.js";
|
|
11
11
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, getChildElements, getLocalName, parseXml } from "../xmlParser.js";
|
|
12
12
|
import { writeGroupTextBoxesBack } from "./groupTextBoxWriteBack.js";
|
|
13
|
-
import {
|
|
13
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
14
14
|
import { serializeRun, serializeShapeTextBody } from "./runSerializer.js";
|
|
15
15
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
16
16
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
@@ -314,6 +314,10 @@ function serializeHyperlinkChild(child, spelling) {
|
|
|
314
314
|
case "moveToRangeEnd": return serializeMoveRangeMarker(child);
|
|
315
315
|
case "inlineWrapper": return serializeParagraphContent(child, spelling);
|
|
316
316
|
case "preservedInline": return child.xml;
|
|
317
|
+
case "complexField": {
|
|
318
|
+
const xml = serializeComplexField(child);
|
|
319
|
+
return spelling === "deletedText" ? rewriteRunTextAsDeleted(xml) : xml;
|
|
320
|
+
}
|
|
317
321
|
default: return child;
|
|
318
322
|
}
|
|
319
323
|
}
|
|
@@ -572,14 +576,41 @@ const trackedChangeSegments = (change) => {
|
|
|
572
576
|
const tag = TRACKED_CHANGE_ELEMENT[change.type];
|
|
573
577
|
const spelling = TRACKED_CHANGE_TEXT_SPELLING[tag];
|
|
574
578
|
const segments = walkTrackedInlineContent(change.content, spelling);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
579
|
+
const info = serializeTrackedChangeAttributes(change.info);
|
|
580
|
+
const joins = change.resolutionJoins;
|
|
581
|
+
const pieces = wrappedPieceCount(segments);
|
|
582
|
+
if (pieces > 1) {
|
|
583
|
+
let piece = 0;
|
|
584
|
+
return wrapTrackedInlineSegments(segments, (xml) => {
|
|
585
|
+
const split = serializeSplitResolutionPiece(piece === 0 && joins !== void 0 ? {
|
|
586
|
+
piece,
|
|
587
|
+
pieces,
|
|
588
|
+
joins
|
|
589
|
+
} : {
|
|
590
|
+
piece,
|
|
591
|
+
pieces
|
|
592
|
+
});
|
|
593
|
+
piece += 1;
|
|
594
|
+
return `<w:${tag} ${info}${split}>${xml}</w:${tag}>`;
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
const attrs = info + serializeResolutionJoins(joins);
|
|
581
598
|
return wrapTrackedInlineSegments(segments, (xml) => `<w:${tag} ${attrs}>${xml}</w:${tag}>`);
|
|
582
599
|
};
|
|
600
|
+
/** How many elements {@link wrapTrackedInlineSegments} writes for these segments. */
|
|
601
|
+
const wrappedPieceCount = (segments) => {
|
|
602
|
+
if (segments.length === 0) return 1;
|
|
603
|
+
let count = 0;
|
|
604
|
+
let plain = false;
|
|
605
|
+
for (const segment of segments) if (segment.type === "plain") {
|
|
606
|
+
if (!plain) count += 1;
|
|
607
|
+
plain = true;
|
|
608
|
+
} else {
|
|
609
|
+
count += 1;
|
|
610
|
+
plain = false;
|
|
611
|
+
}
|
|
612
|
+
return count;
|
|
613
|
+
};
|
|
583
614
|
const UnrepresentableNestedHyperlinkErrorBase = TaggedError("UnrepresentableNestedHyperlinkError");
|
|
584
615
|
var UnrepresentableNestedHyperlinkError = class extends UnrepresentableNestedHyperlinkErrorBase {};
|
|
585
616
|
/** One exhaustive recursive owner for all containers inside a tracked revision. */
|
|
@@ -605,9 +636,22 @@ const walkTrackedInlineContent = (content, spelling) => {
|
|
|
605
636
|
case "moveTo":
|
|
606
637
|
segments.push(...trackedChangeSegments(item));
|
|
607
638
|
break;
|
|
608
|
-
case "inlineWrapper":
|
|
609
|
-
|
|
639
|
+
case "inlineWrapper": {
|
|
640
|
+
const inner = walkTrackedInlineContent(item.content, spelling);
|
|
641
|
+
const pieces = wrappedPieceCount(inner);
|
|
642
|
+
let piece = 0;
|
|
643
|
+
segments.push(...wrapTrackedInlineSegments(inner, (xml) => {
|
|
644
|
+
const markup = serializeInlineWrapperMarkup(item, xml);
|
|
645
|
+
if (pieces === 1) return markup;
|
|
646
|
+
const split = serializeSplitResolutionPiece({
|
|
647
|
+
piece,
|
|
648
|
+
pieces
|
|
649
|
+
});
|
|
650
|
+
piece += 1;
|
|
651
|
+
return markup.replace(/^<([^\s>/]+)/u, `<$1${split}`);
|
|
652
|
+
}));
|
|
610
653
|
break;
|
|
654
|
+
}
|
|
611
655
|
case "inlineSdt":
|
|
612
656
|
segments.push({
|
|
613
657
|
type: "plain",
|
|
@@ -723,8 +767,8 @@ function serializeParagraphContent(content, spelling = "text") {
|
|
|
723
767
|
case "simpleField": return serializeSimpleField(content);
|
|
724
768
|
case "complexField": return serializeComplexField(content);
|
|
725
769
|
case "inlineSdt": return serializeInlineSdt(content, spelling);
|
|
726
|
-
case "commentRangeStart":
|
|
727
|
-
case "commentRangeEnd": return
|
|
770
|
+
case "commentRangeStart":
|
|
771
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(content);
|
|
728
772
|
case "commentReference": return serializeCommentReferenceRun(content.id);
|
|
729
773
|
case "insertion":
|
|
730
774
|
case "deletion":
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TaggedErrorClass } from "better-result";
|
|
2
|
-
import { OoxmlPrefix } from "@stll/docx-
|
|
2
|
+
import { OoxmlPrefix } from "@stll/docx-core/xml/namespaces";
|
|
3
3
|
declare const UnboundNamespacePrefixErrorBase: TaggedErrorClass<"UnboundNamespacePrefixError">;
|
|
4
4
|
/**
|
|
5
5
|
* A namespace a rebuilt WordprocessingML part may declare.
|
|
@@ -2,7 +2,7 @@ import { FOLIO_REVIEW_HISTORY_NAMESPACE } from "../reviewHistoryNamespace.js";
|
|
|
2
2
|
import { toTransitionalNamespaceUri } from "../transitionalSpelling.js";
|
|
3
3
|
import { TaggedError } from "better-result";
|
|
4
4
|
import { assertValidOoxmlNumericIds, escapeXmlAttribute } from "@stll/docx-core";
|
|
5
|
-
import { OOXML_NS } from "@stll/docx-
|
|
5
|
+
import { OOXML_NS } from "@stll/docx-core/xml/namespaces";
|
|
6
6
|
// src/docx/serializer/partNamespaces.ts
|
|
7
7
|
/**
|
|
8
8
|
* Namespace declarations for parts folio rebuilds from the model.
|
|
@@ -5,9 +5,7 @@ import { document_d_exports } from "../../types/document.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function resetAutoIdCounter(): void;
|
|
7
7
|
/** Serialize text body content for shapes/textboxes */
|
|
8
|
-
export declare function serializeShapeTextBody(blocks:
|
|
9
|
-
type: "paragraph" | "table";
|
|
10
|
-
}>[]): string;
|
|
8
|
+
export declare function serializeShapeTextBody(blocks: readonly document_d_exports.BlockContent[]): string;
|
|
11
9
|
/**
|
|
12
10
|
* Serialize a run to OOXML XML (w:r)
|
|
13
11
|
*
|
|
@@ -13,7 +13,7 @@ import { serializeEmptyRunProperties, serializePreviousRunProperties } from "../
|
|
|
13
13
|
import { replayableShapeAlternateContent, synchronizedTextShapeAlternateContent } from "../shapeAlternateContent.js";
|
|
14
14
|
import { requiredWrapPolygon, serializeWrapPolygon } from "../wrapPolygon.js";
|
|
15
15
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
16
|
-
import {
|
|
16
|
+
import { serializeCellContent } from "./tableSerializer.js";
|
|
17
17
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
18
18
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
19
19
|
import { intAttr } from "./xmlUtils.js";
|
|
@@ -409,7 +409,7 @@ function serializeDrawingContent(content) {
|
|
|
409
409
|
}
|
|
410
410
|
/** Serialize text body content for shapes/textboxes */
|
|
411
411
|
function serializeShapeTextBody(blocks) {
|
|
412
|
-
return blocks.
|
|
412
|
+
return blocks.length === 0 ? "" : serializeCellContent(blocks, serializeParagraph);
|
|
413
413
|
}
|
|
414
414
|
const serializeTextBodyAnchor = (anchor) => {
|
|
415
415
|
switch (anchor) {
|
|
@@ -12,6 +12,10 @@ export declare function serializeTableRowFormatting(formatting: document_d_expor
|
|
|
12
12
|
* Serialize table cell formatting properties (w:tcPr)
|
|
13
13
|
*/
|
|
14
14
|
export declare function serializeTableCellFormatting(formatting: document_d_exports.TableCellFormatting | undefined, propertyChanges?: document_d_exports.TableCellPropertyChange[], structuralChange?: document_d_exports.TableStructuralChangeInfo): string;
|
|
15
|
+
/**
|
|
16
|
+
* Serialize cell content (paragraphs, nested tables)
|
|
17
|
+
*/
|
|
18
|
+
export declare function serializeCellContent(content: readonly document_d_exports.TableCellBlock[], serializeParagraph: ParagraphSerializer): string;
|
|
15
19
|
/**
|
|
16
20
|
* Serialize a table cell (w:tc)
|
|
17
21
|
*/
|
|
@@ -10,7 +10,7 @@ import { OOXML_NAMESPACE_SCOPE, parseXml } from "../xmlParser.js";
|
|
|
10
10
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
11
11
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
12
12
|
import { serializeBorder } from "./borderSerializer.js";
|
|
13
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
13
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
14
14
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
15
15
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
16
16
|
import { intAttr } from "./xmlUtils.js";
|
|
@@ -527,6 +527,8 @@ function serializeCellContent(content, serializeParagraph) {
|
|
|
527
527
|
case "moveFromRangeEnd":
|
|
528
528
|
case "moveToRangeStart":
|
|
529
529
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
530
|
+
case "commentRangeStart":
|
|
531
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
530
532
|
default: return block;
|
|
531
533
|
}
|
|
532
534
|
};
|
|
@@ -697,4 +699,4 @@ function createTextCell(text, formatting) {
|
|
|
697
699
|
}]
|
|
698
700
|
};
|
|
699
701
|
}
|
|
700
|
-
export { createEmptyTable, createTextCell, getTableColumnCount, getTableRowCount, hasCellContent, hasCellFormatting, hasRowCells, hasRowFormatting, hasTableFormatting, hasTableRows, serializeTable, serializeTableCell, serializeTableCellFormatting, serializeTableFormatting, serializeTableRow, serializeTableRowFormatting, serializeTables };
|
|
702
|
+
export { createEmptyTable, createTextCell, getTableColumnCount, getTableRowCount, hasCellContent, hasCellFormatting, hasRowCells, hasRowFormatting, hasTableFormatting, hasTableRows, serializeCellContent, serializeTable, serializeTableCell, serializeTableCellFormatting, serializeTableFormatting, serializeTableRow, serializeTableRowFormatting, serializeTables };
|
|
@@ -14,13 +14,17 @@ const FolioDocxXmlPatchApplicationErrorBase = TaggedError("FolioDocxXmlPatchAppl
|
|
|
14
14
|
var FolioDocxXmlPatchApplicationError = class extends FolioDocxXmlPatchApplicationErrorBase {};
|
|
15
15
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
16
16
|
const snapshotInput = (bytes) => Uint8Array.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes));
|
|
17
|
+
/**
|
|
18
|
+
* A copy of the caller's archive policy, taken before the first await so a
|
|
19
|
+
* later mutation cannot change it mid-call. Every field is carried: a field
|
|
20
|
+
* left out here would silently fall back to its default.
|
|
21
|
+
*/
|
|
17
22
|
const snapshotArchiveOptions = (archive) => {
|
|
18
23
|
if (archive === void 0) return;
|
|
24
|
+
const { xmlLimits, ...byteLimits } = archive;
|
|
19
25
|
return {
|
|
20
|
-
...
|
|
21
|
-
...
|
|
22
|
-
...archive.maxTotalBytes === void 0 ? {} : { maxTotalBytes: archive.maxTotalBytes },
|
|
23
|
-
...archive.maxEntries === void 0 ? {} : { maxEntries: archive.maxEntries }
|
|
26
|
+
...byteLimits,
|
|
27
|
+
...xmlLimits === void 0 ? {} : { xmlLimits: { ...xmlLimits } }
|
|
24
28
|
};
|
|
25
29
|
};
|
|
26
30
|
const snapshotProposalLimits = (limits) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ShadingProperties } from "../../types/colors.js";
|
|
2
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { ShadingProperties } from "../../types/colors.js";
|
|
3
3
|
import { ParagraphFormatting, TextFormatting } from "../../types/formatting.js";
|
|
4
4
|
import { Hyperlink, Paragraph, ParagraphContent, Run, Table } from "../../types/content.js";
|
|
5
5
|
import { TaggedErrorClass } from "better-result";
|
|
@@ -241,6 +241,8 @@ const flattenBlocks = (content) => {
|
|
|
241
241
|
case "preservedBlock":
|
|
242
242
|
case "bookmarkStart":
|
|
243
243
|
case "bookmarkEnd":
|
|
244
|
+
case "commentRangeStart":
|
|
245
|
+
case "commentRangeEnd":
|
|
244
246
|
case "moveFromRangeStart":
|
|
245
247
|
case "moveFromRangeEnd":
|
|
246
248
|
case "moveToRangeStart":
|
|
@@ -509,6 +511,25 @@ const remapListRendering = (rendering, cloner) => {
|
|
|
509
511
|
...clonedAbstract !== void 0 && { abstractNumId: clonedAbstract }
|
|
510
512
|
};
|
|
511
513
|
};
|
|
514
|
+
/**
|
|
515
|
+
* The editable ids that name exactly one body paragraph. A package id that
|
|
516
|
+
* several paragraphs repeat is not a handle: the snapshot keeps it for the
|
|
517
|
+
* first and renumbers the rest, so a manifest row could point at the wrong
|
|
518
|
+
* paragraph.
|
|
519
|
+
*/
|
|
520
|
+
const uniqueParagraphHandles = (content, editableParagraphIds) => {
|
|
521
|
+
const counts = /* @__PURE__ */ new Map();
|
|
522
|
+
const visit = (blocks) => {
|
|
523
|
+
for (const item of blocks) if (item.type === "paragraph") {
|
|
524
|
+
if (item.paraId !== void 0) counts.set(item.paraId, (counts.get(item.paraId) ?? 0) + 1);
|
|
525
|
+
} else if (item.type === "table") for (const row of item.rows) for (const cell of row.cells) visit(cell.content);
|
|
526
|
+
else if (item.type === "blockSdt" || item.type === "blockCustomXml") visit(item.content);
|
|
527
|
+
};
|
|
528
|
+
visit(content);
|
|
529
|
+
const handles = /* @__PURE__ */ new Set();
|
|
530
|
+
for (const id of editableParagraphIds) if ((counts.get(id) ?? 0) <= 1) handles.add(id);
|
|
531
|
+
return handles;
|
|
532
|
+
};
|
|
512
533
|
const collectTableParagraphs = (table) => {
|
|
513
534
|
const out = [];
|
|
514
535
|
const collectBlocks = (blocks) => {
|
|
@@ -756,6 +777,7 @@ const createParaIdMinter = (taken) => {
|
|
|
756
777
|
* in document order.
|
|
757
778
|
*/
|
|
758
779
|
function readBilingualDocument(document, editableParagraphIds) {
|
|
780
|
+
const handles = uniqueParagraphHandles(document.package.document.content, editableParagraphIds);
|
|
759
781
|
const styleById = new Map((document.package.styles?.styles ?? []).map((style) => [style.styleId, style]));
|
|
760
782
|
const builtInStyles = createBuiltInStyleIndex(styleById.values(), document.package.styles?.docDefaults);
|
|
761
783
|
const numberingMap = document.package.numbering ? getCachedNumberingMap(document.package.numbering) : null;
|
|
@@ -784,9 +806,9 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
784
806
|
}
|
|
785
807
|
const paragraphs = [];
|
|
786
808
|
for (const [index, source] of sourceParagraphs.entries()) {
|
|
787
|
-
if (!isTranslatableParagraph(source,
|
|
809
|
+
if (!isTranslatableParagraph(source, handles)) continue;
|
|
788
810
|
const target = targetParagraphs.at(index);
|
|
789
|
-
if (target?.paraId === void 0 || target.paraId === source.paraId || !
|
|
811
|
+
if (target?.paraId === void 0 || target.paraId === source.paraId || !handles.has(target.paraId)) {
|
|
790
812
|
missingHandleCount += 1;
|
|
791
813
|
continue;
|
|
792
814
|
}
|
|
@@ -808,7 +830,7 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
808
830
|
missingHandleCount += 1;
|
|
809
831
|
continue;
|
|
810
832
|
}
|
|
811
|
-
const paragraphs = collectTableParagraphs(sourceTable).filter((paragraph) => isTranslatableParagraph(paragraph,
|
|
833
|
+
const paragraphs = collectTableParagraphs(sourceTable).filter((paragraph) => isTranslatableParagraph(paragraph, handles)).map((paragraph) => ({
|
|
812
834
|
paraId: paragraph.paraId,
|
|
813
835
|
sourceText: getParagraphText(paragraph)
|
|
814
836
|
}));
|
|
@@ -827,8 +849,8 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
827
849
|
missingHandleCount += 1;
|
|
828
850
|
continue;
|
|
829
851
|
}
|
|
830
|
-
const sourceMissing = source.paraId === void 0 || !
|
|
831
|
-
const targetMissing = !
|
|
852
|
+
const sourceMissing = source.paraId === void 0 || !handles.has(source.paraId);
|
|
853
|
+
const targetMissing = !handles.has(target.paraId);
|
|
832
854
|
if (sourceMissing) missingHandleCount += 1;
|
|
833
855
|
if (targetMissing) missingHandleCount += 1;
|
|
834
856
|
if (sourceMissing || targetMissing) continue;
|
|
@@ -97,6 +97,10 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
97
97
|
const paragraphsRewritten = migratedAttrs.value;
|
|
98
98
|
const migrated = Y.encodeStateAsUpdate(ydoc);
|
|
99
99
|
ydoc.destroy();
|
|
100
|
+
if (migrated.byteLength > 10485760) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
101
|
+
code: "update_too_large",
|
|
102
|
+
message: "The migrated Yjs update exceeds the snapshot size limit."
|
|
103
|
+
}));
|
|
100
104
|
return Result.ok({
|
|
101
105
|
fromVersion,
|
|
102
106
|
paragraphsRewritten,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getDocumentSourceNumberingIds } from "./headerFooterVerbatim.js";
|
|
2
|
+
// src/docx/sessionListPruning.ts
|
|
3
|
+
const SKIPPED_PACKAGE_KEYS = /* @__PURE__ */ new Set([
|
|
4
|
+
"numbering",
|
|
5
|
+
"media",
|
|
6
|
+
"fonts"
|
|
7
|
+
]);
|
|
8
|
+
/** Every `numId` a numbering reference outside the numbering part names. */
|
|
9
|
+
const referencedNumIds = (document) => {
|
|
10
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
11
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
const visit = (value) => {
|
|
13
|
+
if (typeof value !== "object" || value === null) return;
|
|
14
|
+
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return;
|
|
15
|
+
if (visited.has(value)) return;
|
|
16
|
+
visited.add(value);
|
|
17
|
+
if (value instanceof Map) {
|
|
18
|
+
for (const entry of value.values()) visit(entry);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const numId = Reflect.get(value, "numId");
|
|
22
|
+
if (Reflect.get(value, "kind") === "reference" && typeof numId === "number") referenced.add(numId);
|
|
23
|
+
for (const child of Object.values(value)) visit(child);
|
|
24
|
+
};
|
|
25
|
+
for (const [key, value] of Object.entries(document.package)) if (!SKIPPED_PACKAGE_KEYS.has(key)) visit(value);
|
|
26
|
+
return referenced;
|
|
27
|
+
};
|
|
28
|
+
const withoutUnusedSessionLists = (document) => {
|
|
29
|
+
const numbering = document.package.numbering;
|
|
30
|
+
const source = getDocumentSourceNumberingIds(document);
|
|
31
|
+
if (numbering === void 0 || source === void 0) return document;
|
|
32
|
+
const referenced = referencedNumIds(document);
|
|
33
|
+
const nums = numbering.nums.filter(({ numId }) => source.nums.has(numId) || referenced.has(numId));
|
|
34
|
+
const usedAbstracts = new Set(nums.map(({ abstractNumId }) => abstractNumId));
|
|
35
|
+
const abstractNums = numbering.abstractNums.filter(({ abstractNumId }) => source.abstractNums.has(abstractNumId) || usedAbstracts.has(abstractNumId));
|
|
36
|
+
if (nums.length === numbering.nums.length && abstractNums.length === numbering.abstractNums.length) return document;
|
|
37
|
+
const kept = {
|
|
38
|
+
...numbering,
|
|
39
|
+
nums,
|
|
40
|
+
abstractNums
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
...document,
|
|
44
|
+
package: {
|
|
45
|
+
...document.package,
|
|
46
|
+
numbering: kept
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export { withoutUnusedSessionLists };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
import { SplitResolutionPiece } from "./reviewResolutionProvenance.js";
|
|
3
|
+
/**
|
|
4
|
+
* The pieces of changes and wrappers the serializer wrote as several
|
|
5
|
+
* elements around a lifted link, by the record each was read into. The
|
|
6
|
+
* paragraph parser puts them back together once a paragraph is read.
|
|
7
|
+
*/
|
|
8
|
+
export declare const splitPieces: WeakMap<object, SplitResolutionPiece>;
|
|
9
|
+
/** Record that `record` was read from `node`, a piece of a split element. */
|
|
10
|
+
export declare const tagSplitPiece: (node: XmlElement, record: object) => void;
|