@stll/folio-core 0.52.0 → 0.54.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1779 -141
- package/dist/ai-edits/batch-claims.d.ts +145 -0
- package/dist/ai-edits/batch-claims.js +275 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +91 -7
- package/dist/ai-edits/headless.js +520 -51
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +6 -4
- package/dist/ai-edits/read.js +113 -50
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/revisionStretches.js +80 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +180 -25
- package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
- package/dist/ai-edits/table-cell-mutations.js +6 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
- package/dist/ai-edits/table-row-column-mutations.js +86 -34
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.d.ts +5 -1
- package/dist/compare/content-alignment.js +52 -34
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/inline-provenance.js +1 -1
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +65 -11
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/archiveInflation.d.ts +127 -0
- package/dist/docx/archiveInflation.js +181 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/metadataPrivacy.js +24 -1
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/noteReferenceMark.d.ts +15 -0
- package/dist/docx/noteReferenceMark.js +48 -0
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +96 -27
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +10 -2
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +175 -22
- package/dist/docx/rezip.js +31 -7
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.d.ts +3 -1
- package/dist/docx/selectiveXmlPatch.js +186 -39
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/boundedArchive.d.ts +8 -13
- package/dist/docx/server/boundedArchive.js +70 -59
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/server/extractDocxText.d.ts +8 -2
- package/dist/docx/server/extractDocxText.js +2 -2
- package/dist/docx/server/validateDocxConformance.d.ts +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -0
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +20 -2
- package/dist/docx/unzip.js +136 -25
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
- package/dist/i18n/messages/catalogs.gen.js +187 -51
- package/dist/i18n/messages/messages.gen.d.ts +10 -2
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +600 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureParagraph.js +2 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
- package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/escape.d.ts +2 -2
- package/dist/markdown/escape.js +4 -5
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +121 -25
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.d.ts +10 -1
- package/dist/markdown/renderRuns.js +323 -69
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/clearRunColor.d.ts +6 -0
- package/dist/prosemirror/clearRunColor.js +46 -0
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +281 -212
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.js +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/hyperlink.js +2 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
- package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
- package/dist/prosemirror/containerFinalParagraph.js +7 -6
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
- package/dist/prosemirror/conversion/toProseDoc.js +70 -154
- package/dist/prosemirror/documentSchema.d.ts +8 -0
- package/dist/prosemirror/documentSchema.js +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +5 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
- package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
- package/dist/prosemirror/extensions/types.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
- package/dist/prosemirror/hyperlinkRemoval.js +129 -0
- package/dist/prosemirror/index.d.ts +5 -3
- package/dist/prosemirror/index.js +5 -3
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +92 -0
- package/dist/prosemirror/listNumbering.js +330 -0
- package/dist/prosemirror/listRendering.d.ts +27 -0
- package/dist/prosemirror/listRendering.js +27 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewNotes.d.ts +8 -0
- package/dist/prosemirror/markupViewNotes.js +49 -0
- package/dist/prosemirror/markupViewProjection.d.ts +97 -0
- package/dist/prosemirror/markupViewProjection.js +88 -0
- package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
- package/dist/prosemirror/noteReferenceReview.js +332 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +32 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
- package/dist/prosemirror/paragraphMarkJoin.js +26 -0
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
- package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
- package/dist/prosemirror/plugins/documentStyleState.js +32 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
- package/dist/prosemirror/plugins/documentStyles.js +67 -17
- package/dist/prosemirror/plugins/index.d.ts +2 -1
- package/dist/prosemirror/plugins/index.js +2 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
- package/dist/prosemirror/plugins/suggestionMode.js +490 -63
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
- package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
- package/dist/prosemirror/runFormattingFromMarks.js +567 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -9
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +44 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
- package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
- package/dist/prosemirror/tableCellPaste.d.ts +74 -0
- package/dist/prosemirror/tableCellPaste.js +525 -0
- package/dist/prosemirror/tableGridMutation.d.ts +87 -2
- package/dist/prosemirror/tableGridMutation.js +255 -2
- package/dist/prosemirror/tableRunIn.d.ts +51 -0
- package/dist/prosemirror/tableRunIn.js +165 -0
- package/dist/prosemirror/textInput.js +11 -2
- package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
- package/dist/prosemirror/trackedRevisionPath.js +32 -0
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/server.d.ts +2 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +6 -5
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
//#region src/docx/archiveInflation.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default ceiling on inflated bytes per compressed byte.
|
|
4
|
+
*
|
|
5
|
+
* Document parts in the repository's fixtures stay under 75:1, and parts over a
|
|
6
|
+
* mebibyte under 15:1. A DEFLATE stream tops out near 1032:1, which is the
|
|
7
|
+
* shape of an entry made of one repeated byte.
|
|
8
|
+
*/
|
|
9
|
+
const DOCX_MAX_COMPRESSION_RATIO = 200;
|
|
10
|
+
/**
|
|
11
|
+
* Inflated size below which the ratio cap does not apply.
|
|
12
|
+
*
|
|
13
|
+
* A small part can compress extremely well without costing anything to hold,
|
|
14
|
+
* so the ratio only has to bound entries (and packages) large enough to
|
|
15
|
+
* matter. The byte caps still apply below this size.
|
|
16
|
+
*/
|
|
17
|
+
const DOCX_COMPRESSION_RATIO_GRACE_BYTES = 4 * 1024 * 1024;
|
|
18
|
+
const CENTRAL_DIRECTORY_RECORD_SIGNATURE = [
|
|
19
|
+
80,
|
|
20
|
+
75,
|
|
21
|
+
1,
|
|
22
|
+
2
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Upper bound on the central-directory records in `bytes`, counted without
|
|
26
|
+
* parsing the archive and stopping once the count passes `stopAfter`.
|
|
27
|
+
*
|
|
28
|
+
* Every record JSZip reads starts with the record signature, so the number of
|
|
29
|
+
* signature occurrences cannot be lower than the number of entries JSZip would
|
|
30
|
+
* build, whatever the end-of-central-directory record claims.
|
|
31
|
+
*/
|
|
32
|
+
const countCentralDirectoryRecords = (bytes, stopAfter) => {
|
|
33
|
+
const [first, second, third, fourth] = CENTRAL_DIRECTORY_RECORD_SIGNATURE;
|
|
34
|
+
let count = 0;
|
|
35
|
+
let offset = bytes.indexOf(first);
|
|
36
|
+
while (offset !== -1 && offset + 3 < bytes.length) {
|
|
37
|
+
if (bytes[offset + 1] === second && bytes[offset + 2] === third && bytes[offset + 3] === fourth) {
|
|
38
|
+
count += 1;
|
|
39
|
+
if (count > stopAfter) return count;
|
|
40
|
+
}
|
|
41
|
+
offset = bytes.indexOf(first, offset + 1);
|
|
42
|
+
}
|
|
43
|
+
return count;
|
|
44
|
+
};
|
|
45
|
+
const finiteSize = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
46
|
+
/** Declared sizes of an entry JSZip loaded from an archive. */
|
|
47
|
+
const getZipEntrySizes = (entry) => {
|
|
48
|
+
const data = "_data" in entry ? entry._data : void 0;
|
|
49
|
+
if (typeof data !== "object" || data === null) return {
|
|
50
|
+
compressedBytes: null,
|
|
51
|
+
uncompressedBytes: null
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
compressedBytes: "compressedSize" in data ? finiteSize(data.compressedSize) : null,
|
|
55
|
+
uncompressedBytes: "uncompressedSize" in data ? finiteSize(data.uncompressedSize) : null
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const STORED_COMPRESSION_MAGIC = "\0\0";
|
|
59
|
+
/**
|
|
60
|
+
* Whether a loaded entry is stored rather than compressed. A stored entry
|
|
61
|
+
* reads back exactly the bytes the archive carries, so it cannot expand.
|
|
62
|
+
*/
|
|
63
|
+
const isStoredZipEntry = (entry) => {
|
|
64
|
+
const data = "_data" in entry ? entry._data : void 0;
|
|
65
|
+
if (typeof data !== "object" || data === null || !("compression" in data)) return false;
|
|
66
|
+
const { compression } = data;
|
|
67
|
+
return typeof compression === "object" && compression !== null && "magic" in compression && compression.magic === STORED_COMPRESSION_MAGIC;
|
|
68
|
+
};
|
|
69
|
+
const RATIO_BOUNDED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
70
|
+
"xml",
|
|
71
|
+
"rels",
|
|
72
|
+
"vml",
|
|
73
|
+
"txt",
|
|
74
|
+
"htm",
|
|
75
|
+
"html",
|
|
76
|
+
"mht",
|
|
77
|
+
"mhtml",
|
|
78
|
+
"rtf"
|
|
79
|
+
]);
|
|
80
|
+
/**
|
|
81
|
+
* Whether the per-entry ratio cap applies to a part. Markup and text parts
|
|
82
|
+
* never compress anywhere near the cap. Binary parts can: an uncompressed
|
|
83
|
+
* bitmap of one colour compresses like a run of one byte. Those stay bounded
|
|
84
|
+
* by the byte caps and the package-wide ratio instead.
|
|
85
|
+
*/
|
|
86
|
+
const isRatioBoundedPart = (path) => RATIO_BOUNDED_EXTENSIONS.has(path.slice(path.lastIndexOf(".") + 1).toLowerCase());
|
|
87
|
+
/** The per-entry ratio cap for `path`: `maxRatio`, or none for a binary part. */
|
|
88
|
+
const compressionRatioLimitFor = (path, maxRatio) => isRatioBoundedPart(path) ? maxRatio : Number.POSITIVE_INFINITY;
|
|
89
|
+
/**
|
|
90
|
+
* Whether `inflatedBytes` produced from `compressedBytes` passes the ratio cap.
|
|
91
|
+
* Sizes under {@link DOCX_COMPRESSION_RATIO_GRACE_BYTES} never do, and an
|
|
92
|
+
* unknown compressed size is left to the byte caps.
|
|
93
|
+
*/
|
|
94
|
+
const exceedsCompressionRatio = ({ inflatedBytes, compressedBytes, maxRatio }) => compressedBytes !== null && inflatedBytes > 4194304 && inflatedBytes > compressedBytes * maxRatio;
|
|
95
|
+
const createInflationBudget = (maxTotalBytes) => ({
|
|
96
|
+
maxTotalBytes,
|
|
97
|
+
inflatedBytes: 0,
|
|
98
|
+
aborted: false
|
|
99
|
+
});
|
|
100
|
+
const EMPTY_BYTES = /* @__PURE__ */ new Uint8Array(0);
|
|
101
|
+
const concatChunks = (chunks, totalBytes) => {
|
|
102
|
+
const merged = new Uint8Array(totalBytes);
|
|
103
|
+
let offset = 0;
|
|
104
|
+
for (const chunk of chunks) {
|
|
105
|
+
merged.set(chunk, offset);
|
|
106
|
+
offset += chunk.length;
|
|
107
|
+
}
|
|
108
|
+
return merged;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Inflate one entry chunk by chunk, checking every bound before a chunk is
|
|
112
|
+
* kept. Pausing the stream abandons the rest of the entry, so a limit bounds
|
|
113
|
+
* memory rather than reporting an overrun afterwards.
|
|
114
|
+
*
|
|
115
|
+
* The budget is charged as chunks arrive, which keeps concurrent inflations
|
|
116
|
+
* of one package honest, and refunded when this entry stops at a limit or
|
|
117
|
+
* fails, since none of its bytes are kept. Stream errors (a corrupt entry)
|
|
118
|
+
* reject; limits resolve with `ok: false` for the caller to map onto its own
|
|
119
|
+
* error or skip policy.
|
|
120
|
+
*/
|
|
121
|
+
const inflateEntryWithinLimits = async ({ entry, maxEntryBytes, maxCompressionRatio, budget, retain = true }) => {
|
|
122
|
+
const { compressedBytes, uncompressedBytes } = getZipEntrySizes(entry);
|
|
123
|
+
return await new Promise((resolve, reject) => {
|
|
124
|
+
const stream = entry.internalStream("uint8array");
|
|
125
|
+
const chunks = [];
|
|
126
|
+
let entryBytes = 0;
|
|
127
|
+
let settled = false;
|
|
128
|
+
const settle = () => {
|
|
129
|
+
if (settled) return false;
|
|
130
|
+
settled = true;
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
const refund = () => {
|
|
134
|
+
budget.inflatedBytes -= entryBytes;
|
|
135
|
+
};
|
|
136
|
+
const stop = (limit) => {
|
|
137
|
+
if (!settle()) return;
|
|
138
|
+
stream.pause();
|
|
139
|
+
refund();
|
|
140
|
+
resolve({
|
|
141
|
+
ok: false,
|
|
142
|
+
limit
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const limitFor = () => {
|
|
146
|
+
if (budget.aborted) return "aborted";
|
|
147
|
+
if (uncompressedBytes !== null && entryBytes > uncompressedBytes) return "declared-size";
|
|
148
|
+
if (exceedsCompressionRatio({
|
|
149
|
+
inflatedBytes: entryBytes,
|
|
150
|
+
compressedBytes,
|
|
151
|
+
maxRatio: maxCompressionRatio
|
|
152
|
+
})) return "compression-ratio";
|
|
153
|
+
if (entryBytes > maxEntryBytes) return "entry";
|
|
154
|
+
if (budget.inflatedBytes > budget.maxTotalBytes) return "total";
|
|
155
|
+
return null;
|
|
156
|
+
};
|
|
157
|
+
stream.on("data", (chunk) => {
|
|
158
|
+
if (settled) return;
|
|
159
|
+
entryBytes += chunk.length;
|
|
160
|
+
budget.inflatedBytes += chunk.length;
|
|
161
|
+
const limit = limitFor();
|
|
162
|
+
if (limit !== null) {
|
|
163
|
+
stop(limit);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (retain) chunks.push(chunk);
|
|
167
|
+
}).on("end", () => {
|
|
168
|
+
if (!settle()) return;
|
|
169
|
+
resolve({
|
|
170
|
+
ok: true,
|
|
171
|
+
bytes: retain ? concatChunks(chunks, entryBytes) : EMPTY_BYTES
|
|
172
|
+
});
|
|
173
|
+
}).on("error", (error) => {
|
|
174
|
+
if (!settle()) return;
|
|
175
|
+
refund();
|
|
176
|
+
reject(error);
|
|
177
|
+
}).resume();
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
export { DOCX_COMPRESSION_RATIO_GRACE_BYTES, DOCX_MAX_COMPRESSION_RATIO, compressionRatioLimitFor, countCentralDirectoryRecords, createInflationBudget, exceedsCompressionRatio, getZipEntrySizes, inflateEntryWithinLimits, isRatioBoundedPart, isStoredZipEntry };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModelledAttributes } from "./propertyElementAttributes.js";
|
|
2
1
|
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
import { ModelledAttributes } from "./propertyElementAttributes.js";
|
|
3
3
|
import { PreservedAttribute } from "@stll/docx-core/model";
|
|
4
4
|
//#region src/docx/attributeRemainder.d.ts
|
|
5
5
|
declare const InvalidPreservedAttributeError_base: import("better-result").TaggedErrorClass<"InvalidPreservedAttributeError">;
|
|
@@ -2,6 +2,7 @@ import { document_d_exports } from "../types/document.js";
|
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
3
|
import { ParseContext } from "./parseContext.js";
|
|
4
4
|
import { XmlElement } from "./xmlParser.js";
|
|
5
|
+
import { OwnedElsewhere } from "./containerChildren.js";
|
|
5
6
|
import { PreviewLedger } from "./previewBudget.js";
|
|
6
7
|
import { StyleMap } from "./styleParser.js";
|
|
7
8
|
//#region src/docx/blockContentParser.d.ts
|
|
@@ -11,6 +12,68 @@ type ParseBlockContentOptions = {
|
|
|
11
12
|
context?: ParseContext | undefined;
|
|
12
13
|
previews?: PreviewLedger;
|
|
13
14
|
};
|
|
15
|
+
/** The options every block below the entry point reads, with its ledger settled. */
|
|
16
|
+
type BlockContentScope = ParseBlockContentOptions & {
|
|
17
|
+
previews: PreviewLedger;
|
|
18
|
+
};
|
|
19
|
+
type PreviousListState = {
|
|
20
|
+
abstractNumId: number | null;
|
|
21
|
+
fromStyle: boolean;
|
|
22
|
+
numId: number | null;
|
|
23
|
+
};
|
|
24
|
+
type ParseBlockContentState = {
|
|
25
|
+
listCounters: Map<number, number[]>;
|
|
26
|
+
abstractCounters: Map<number, number[]>;
|
|
27
|
+
restartedNumIds: Set<number>;
|
|
28
|
+
previousList: PreviousListState;
|
|
29
|
+
options: BlockContentScope;
|
|
30
|
+
};
|
|
14
31
|
declare const parseBlockContent: (parent: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options?: ParseBlockContentOptions) => document_d_exports.BlockContent[];
|
|
32
|
+
/** The parts and maps a block sequence is read against. */
|
|
33
|
+
type BlockContentResources = {
|
|
34
|
+
styles: StyleMap | null;
|
|
35
|
+
theme: document_d_exports.Theme | null;
|
|
36
|
+
numbering: NumberingMap | null;
|
|
37
|
+
rels: document_d_exports.RelationshipMap | null;
|
|
38
|
+
media: Map<string, document_d_exports.MediaFile> | null;
|
|
39
|
+
};
|
|
40
|
+
/** One block container's children as they are read. */
|
|
41
|
+
type BlockContentWalk = {
|
|
42
|
+
resources: BlockContentResources;
|
|
43
|
+
state: ParseBlockContentState;
|
|
44
|
+
modelled: document_d_exports.BlockContent[];
|
|
45
|
+
};
|
|
46
|
+
declare const BLOCK_CONTENT_HANDLERS: {
|
|
47
|
+
readonly altChunk: "capture";
|
|
48
|
+
readonly commentRangeEnd: "capture";
|
|
49
|
+
readonly commentRangeStart: "capture";
|
|
50
|
+
readonly customXmlDelRangeEnd: "capture";
|
|
51
|
+
readonly customXmlDelRangeStart: "capture";
|
|
52
|
+
readonly customXmlInsRangeEnd: "capture";
|
|
53
|
+
readonly customXmlInsRangeStart: "capture";
|
|
54
|
+
readonly customXmlMoveFromRangeEnd: "capture";
|
|
55
|
+
readonly customXmlMoveFromRangeStart: "capture";
|
|
56
|
+
readonly customXmlMoveToRangeEnd: "capture";
|
|
57
|
+
readonly customXmlMoveToRangeStart: "capture";
|
|
58
|
+
readonly del: "capture";
|
|
59
|
+
readonly ins: "capture";
|
|
60
|
+
readonly moveFrom: "capture";
|
|
61
|
+
readonly moveFromRangeEnd: "capture";
|
|
62
|
+
readonly moveFromRangeStart: "capture";
|
|
63
|
+
readonly moveTo: "capture";
|
|
64
|
+
readonly moveToRangeEnd: "capture";
|
|
65
|
+
readonly moveToRangeStart: "capture";
|
|
66
|
+
readonly permEnd: "capture";
|
|
67
|
+
readonly permStart: "capture";
|
|
68
|
+
readonly proofErr: "capture";
|
|
69
|
+
readonly sectPr: OwnedElsewhere<"block-content", "sectPr">;
|
|
70
|
+
readonly tcPr: OwnedElsewhere<"block-content", "tcPr">;
|
|
71
|
+
readonly p: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, state, modelled }: BlockContentWalk) => void;
|
|
72
|
+
readonly tbl: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, state, modelled }: BlockContentWalk) => "capture" | undefined;
|
|
73
|
+
readonly sdt: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, state, modelled }: BlockContentWalk) => void;
|
|
74
|
+
readonly customXml: (child: XmlElement, { resources: { styles, theme, numbering, rels, media }, state, modelled }: BlockContentWalk) => void;
|
|
75
|
+
readonly bookmarkStart: (child: XmlElement, { modelled }: BlockContentWalk) => void;
|
|
76
|
+
readonly bookmarkEnd: (child: XmlElement, { modelled }: BlockContentWalk) => void;
|
|
77
|
+
};
|
|
15
78
|
//#endregion
|
|
16
|
-
export { parseBlockContent };
|
|
79
|
+
export { BLOCK_CONTENT_HANDLERS, parseBlockContent };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blockCustomXmlShell } from "./blockCustomXmlShell.js";
|
|
1
2
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
2
3
|
import { bulletMarkerFontName, convertBulletToUnicode } from "./bulletMarkers.js";
|
|
3
4
|
import { CAPTURE, dispatchChildrenWithContext, ownedElsewhere, withPreservedChildren } from "./containerChildren.js";
|
|
@@ -8,7 +9,7 @@ import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
|
8
9
|
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
9
10
|
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
10
11
|
import { parseTable } from "./tableParser.js";
|
|
11
|
-
import { findWordprocessingChild, mergeXmlnsDeclarations, selectAlternateContentBranch } from "./xmlParser.js";
|
|
12
|
+
import { findWordprocessingChild, getLocalName, mergeXmlnsDeclarations, selectAlternateContentBranch } from "./xmlParser.js";
|
|
12
13
|
//#region src/docx/blockContentParser.ts
|
|
13
14
|
const computeListMarker = (paragraph, { numbering, listCounters, abstractCounters, restartedNumIds, previousList }) => {
|
|
14
15
|
const listRendering = paragraph.listRendering;
|
|
@@ -131,6 +132,13 @@ const BLOCK_CONTENT_UNDECLARED = { AlternateContent: (child, { resources: { styl
|
|
|
131
132
|
if (!selectedBranch) return;
|
|
132
133
|
modelled.push(...parseBlockContentWithState(selectedBranch, styles, theme, numbering, rels, media, withContainerXmlns(withContainerXmlns(state, child), selectedBranch)));
|
|
133
134
|
} };
|
|
135
|
+
const parseBlockCustomXml = (child, styles, theme, numbering, rels, media, state) => {
|
|
136
|
+
return {
|
|
137
|
+
type: "blockCustomXml",
|
|
138
|
+
...blockCustomXmlShell(child),
|
|
139
|
+
content: parseBlockContentWithState(child, styles, theme, numbering, rels, media, withContainerXmlns(state, child))
|
|
140
|
+
};
|
|
141
|
+
};
|
|
134
142
|
const BLOCK_CONTENT_HANDLERS = {
|
|
135
143
|
p: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
136
144
|
const paragraph = parseParagraph(child, styles, theme, numbering, rels, media, {
|
|
@@ -149,12 +157,18 @@ const BLOCK_CONTENT_HANDLERS = {
|
|
|
149
157
|
},
|
|
150
158
|
tbl: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
151
159
|
const table = parseTable(child, styles, theme, numbering, rels, media, state.options);
|
|
152
|
-
if (!table) return
|
|
160
|
+
if (!table) return child.elements?.some((tableChild) => {
|
|
161
|
+
const localName = getLocalName(tableChild.name ?? "");
|
|
162
|
+
return localName !== "tblPr" && localName !== "tblGrid";
|
|
163
|
+
}) ?? false ? CAPTURE : void 0;
|
|
153
164
|
modelled.push(table);
|
|
154
165
|
},
|
|
155
166
|
sdt: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
156
167
|
modelled.push(parseBlockSdt(child, styles, theme, numbering, rels, media, state));
|
|
157
168
|
},
|
|
169
|
+
customXml: (child, { resources: { styles, theme, numbering, rels, media }, state, modelled }) => {
|
|
170
|
+
modelled.push(parseBlockCustomXml(child, styles, theme, numbering, rels, media, state));
|
|
171
|
+
},
|
|
158
172
|
bookmarkStart: (child, { modelled }) => {
|
|
159
173
|
modelled.push(parseBookmarkStart(child));
|
|
160
174
|
},
|
|
@@ -165,7 +179,6 @@ const BLOCK_CONTENT_HANDLERS = {
|
|
|
165
179
|
altChunk: CAPTURE,
|
|
166
180
|
commentRangeEnd: CAPTURE,
|
|
167
181
|
commentRangeStart: CAPTURE,
|
|
168
|
-
customXml: CAPTURE,
|
|
169
182
|
customXmlDelRangeEnd: CAPTURE,
|
|
170
183
|
customXmlDelRangeStart: CAPTURE,
|
|
171
184
|
customXmlInsRangeEnd: CAPTURE,
|
|
@@ -223,4 +236,4 @@ const parseBlockSdt = (child, styles, theme, numbering, rels, media, state) => {
|
|
|
223
236
|
};
|
|
224
237
|
};
|
|
225
238
|
//#endregion
|
|
226
|
-
export { parseBlockContent };
|
|
239
|
+
export { BLOCK_CONTENT_HANDLERS, parseBlockContent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { XmlElement } from "./xmlParser.js";
|
|
3
|
+
//#region src/docx/blockCustomXmlShell.d.ts
|
|
4
|
+
/** Capture the wrapper independently of its modeled and preserved children. */
|
|
5
|
+
declare const blockCustomXmlShell: (element: XmlElement) => Pick<document_d_exports.BlockCustomXml, "openingXml" | "closingXml">;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { blockCustomXmlShell };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
2
|
+
import { cloneElement } from "./xmlParser.js";
|
|
3
|
+
//#region src/docx/blockCustomXmlShell.ts
|
|
4
|
+
/** Capture the wrapper independently of its modeled and preserved children. */
|
|
5
|
+
const blockCustomXmlShell = (element) => {
|
|
6
|
+
const shell = captureVerbatimXml(cloneElement(element, { elements: [] }));
|
|
7
|
+
const name = element.name ?? "w:customXml";
|
|
8
|
+
return {
|
|
9
|
+
openingXml: shell.endsWith("/>") ? `${shell.slice(0, -2)}>` : shell,
|
|
10
|
+
closingXml: `</${name}>`
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { blockCustomXmlShell };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ALT_CHUNK_READER_DIAGNOSTIC, isAltChunkMarkup } from "./altChunk.js";
|
|
2
|
+
import { OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC, isOpaqueNestedRowMarkup, opaqueRevisionCarrierName } from "./opaqueCarrier.js";
|
|
1
3
|
import { getParagraphText } from "./paragraphParser.js";
|
|
2
4
|
import { panic } from "better-result";
|
|
3
5
|
//#region src/docx/blockPlainText.ts
|
|
@@ -29,9 +31,14 @@ const collectBlockTexts = (blocks) => {
|
|
|
29
31
|
}
|
|
30
32
|
break;
|
|
31
33
|
case "blockSdt":
|
|
34
|
+
case "blockCustomXml":
|
|
32
35
|
texts.push(...collectBlockTexts(block.content));
|
|
33
36
|
break;
|
|
34
37
|
case "preservedBlock":
|
|
38
|
+
if (isAltChunkMarkup(block.xml)) texts.push(block.readerText === void 0 ? ALT_CHUNK_READER_DIAGNOSTIC : `${ALT_CHUNK_READER_DIAGNOSTIC}\n${block.readerText}`);
|
|
39
|
+
else if (opaqueRevisionCarrierName(block.xml) !== void 0) texts.push(OPAQUE_REVISION_CARRIER_READER_DIAGNOSTIC);
|
|
40
|
+
else if (isOpaqueNestedRowMarkup(block.xml)) texts.push("[Unsupported nested w:tr content]");
|
|
41
|
+
break;
|
|
35
42
|
case "bookmarkStart":
|
|
36
43
|
case "bookmarkEnd": break;
|
|
37
44
|
default: panic(`Unsupported block in plain-text extraction: ${JSON.stringify(block)}`);
|
|
@@ -19,7 +19,7 @@ const visitCommentMarkers = (blocks, visit) => {
|
|
|
19
19
|
for (const row of block.rows) for (const cell of row.cells) visitBlocks(cell.content);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
if (block.type !== "blockSdt") return;
|
|
22
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") return;
|
|
23
23
|
visitBlocks(block.content);
|
|
24
24
|
};
|
|
25
25
|
const visitBlocks = (nested) => {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { cloneParagraphWithPropertySource } from "./paragraphPropertySource.js";
|
|
2
2
|
//#region src/docx/commentRangeIntegrity.ts
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A range marker under any prefix, or none: this is the guard a splice is
|
|
5
|
+
* refused by, and a guard that only knows `w:` passes every patch of a part
|
|
6
|
+
* that spells WordprocessingML another way.
|
|
7
|
+
*/
|
|
8
|
+
const COMMENT_RANGE_MARKER_PATTERN = /<(?:[\w.-]+:)?commentRange(Start|End)(?:\s[^>]*?)?\s(?:[\w.-]+:)?id=["'](\d+)["']/gu;
|
|
4
9
|
/**
|
|
5
10
|
* Comment ids whose range is not a start followed by an end in this story's
|
|
6
11
|
* XML. Either half alone is invalid OOXML and anchors nothing: Word shows no
|
|
@@ -147,7 +152,7 @@ const withoutOrphanBlockMarkers = (blocks, validCommentIds) => {
|
|
|
147
152
|
const withoutOrphanBlockMarker = (block, validCommentIds) => {
|
|
148
153
|
if (block.type === "paragraph") return withoutOrphanParagraphMarkers(block, validCommentIds);
|
|
149
154
|
if (block.type === "table") return withoutOrphanTableMarkers(block, validCommentIds);
|
|
150
|
-
if (block.type !== "blockSdt") return block;
|
|
155
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") return block;
|
|
151
156
|
const content = withoutOrphanBlockMarkers(block.content, validCommentIds);
|
|
152
157
|
if (!content) return block;
|
|
153
158
|
return {
|
|
@@ -204,7 +209,7 @@ const withoutOrphanTableCellBlockMarkers = (blocks, validCommentIds) => {
|
|
|
204
209
|
const withoutOrphanTableCellBlockMarker = (block, validCommentIds) => {
|
|
205
210
|
if (block.type === "paragraph") return withoutOrphanParagraphMarkers(block, validCommentIds);
|
|
206
211
|
if (block.type === "table") return withoutOrphanTableMarkers(block, validCommentIds);
|
|
207
|
-
if (block.type === "blockSdt") {
|
|
212
|
+
if (block.type === "blockSdt" || block.type === "blockCustomXml") {
|
|
208
213
|
const content = withoutOrphanTableCellBlockMarkers(block.content, validCommentIds);
|
|
209
214
|
return content ? {
|
|
210
215
|
...block,
|
|
@@ -40,7 +40,7 @@ const normalizeCommentReferences = ({ documentBody, comments, headers, footers,
|
|
|
40
40
|
normalizeTable(block);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
if (block.type !== "blockSdt") return;
|
|
43
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") return;
|
|
44
44
|
normalizeBlocks(block.content);
|
|
45
45
|
};
|
|
46
46
|
const normalizeBlocks = (blocks) => {
|
|
@@ -25,7 +25,7 @@ const eachParagraph = (blocks, visit) => {
|
|
|
25
25
|
for (const row of block.rows ?? []) for (const cell of row.cells ?? []) eachParagraph(cell.content ?? [], visit);
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
if (block.type !== "blockSdt") continue;
|
|
28
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
29
29
|
eachParagraph(block.content ?? [], visit);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -42,6 +42,24 @@ const commentParentedReplies = (comments) => {
|
|
|
42
42
|
const commentIds = new Set(comments.map((comment) => comment.id));
|
|
43
43
|
return comments.filter((comment) => comment.parentId !== void 0 && commentIds.has(comment.parentId));
|
|
44
44
|
};
|
|
45
|
+
/** Match the order fromProseDoc uses when several ranges share a boundary. */
|
|
46
|
+
const orderCoLocatedRanges = (content) => {
|
|
47
|
+
for (let start = 0; start < content.length;) {
|
|
48
|
+
const type = content[start]?.type;
|
|
49
|
+
if (type !== "commentRangeStart" && type !== "commentRangeEnd") {
|
|
50
|
+
start += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
let end = start + 1;
|
|
54
|
+
while (content[end]?.type === type) end += 1;
|
|
55
|
+
const ordered = content.slice(start, end).toSorted((left, right) => {
|
|
56
|
+
if ((left.type === "commentRangeStart" || left.type === "commentRangeEnd") && (right.type === "commentRangeStart" || right.type === "commentRangeEnd")) return left.id - right.id;
|
|
57
|
+
return 0;
|
|
58
|
+
});
|
|
59
|
+
content.splice(start, end - start, ...ordered);
|
|
60
|
+
start = end;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
45
63
|
const injectIntoParagraph = (paragraph, replyIdsByParent) => {
|
|
46
64
|
const content = paragraph.content ?? [];
|
|
47
65
|
if (!content.some((item) => (item.type === "commentRangeStart" || item.type === "commentRangeEnd" || item.type === "commentReference") && replyIdsByParent.has(item.id))) return 0;
|
|
@@ -68,6 +86,7 @@ const injectIntoParagraph = (paragraph, replyIdsByParent) => {
|
|
|
68
86
|
injected += 1;
|
|
69
87
|
}
|
|
70
88
|
}
|
|
89
|
+
orderCoLocatedRanges(next);
|
|
71
90
|
paragraph.content = next;
|
|
72
91
|
return injected;
|
|
73
92
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { DrawingSafetyClass } from "./imageRawXml.js";
|
|
3
3
|
//#region src/docx/compatibility.d.ts
|
|
4
|
-
type DocxCompatibilityReason = "opaqueDrawing";
|
|
4
|
+
type DocxCompatibilityReason = "opaqueDrawing" | "unsupportedAltChunk";
|
|
5
5
|
type FolioDocxCompatibilityHost = "browser" | "server" | "unknown";
|
|
6
6
|
type FolioDocxCompatibilityProfile = document_d_exports.DocxConformanceClass;
|
|
7
7
|
type DocxCompatibilityContext = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAltChunkMarkup } from "./altChunk.js";
|
|
1
2
|
import { DRAWING_SAFETY_CLASSES, classifyDrawingSafety } from "./imageRawXml.js";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
4
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
@@ -24,17 +25,20 @@ const inspectDocxCompatibility = (doc, options = {}) => {
|
|
|
24
25
|
const record = (drawing) => {
|
|
25
26
|
drawings.push(drawing);
|
|
26
27
|
if (drawing.class !== DRAWING_SAFETY_CLASSES.OPAQUE) return;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
issues.push({
|
|
30
|
-
code,
|
|
28
|
+
recordIssue({
|
|
29
|
+
code: "opaqueDrawing",
|
|
31
30
|
location: drawing.location
|
|
32
31
|
});
|
|
33
32
|
};
|
|
33
|
+
const recordIssue = (issue) => {
|
|
34
|
+
reasons.add(issue.code);
|
|
35
|
+
issues.push(issue);
|
|
36
|
+
};
|
|
34
37
|
inspectBlocks(doc.package.document.content, {
|
|
35
38
|
part: { type: "document" },
|
|
36
39
|
path: "package.document.content",
|
|
37
|
-
record
|
|
40
|
+
record,
|
|
41
|
+
recordIssue
|
|
38
42
|
});
|
|
39
43
|
for (const [relationshipId, header] of doc.package.headers?.entries() ?? []) inspectHeaderFooter(header, {
|
|
40
44
|
part: {
|
|
@@ -42,7 +46,8 @@ const inspectDocxCompatibility = (doc, options = {}) => {
|
|
|
42
46
|
relationshipId
|
|
43
47
|
},
|
|
44
48
|
path: `package.headers.get(${JSON.stringify(relationshipId)}).content`,
|
|
45
|
-
record
|
|
49
|
+
record,
|
|
50
|
+
recordIssue
|
|
46
51
|
});
|
|
47
52
|
for (const [relationshipId, footer] of doc.package.footers?.entries() ?? []) inspectHeaderFooter(footer, {
|
|
48
53
|
part: {
|
|
@@ -50,7 +55,8 @@ const inspectDocxCompatibility = (doc, options = {}) => {
|
|
|
50
55
|
relationshipId
|
|
51
56
|
},
|
|
52
57
|
path: `package.footers.get(${JSON.stringify(relationshipId)}).content`,
|
|
53
|
-
record
|
|
58
|
+
record,
|
|
59
|
+
recordIssue
|
|
54
60
|
});
|
|
55
61
|
for (const footnote of doc.package.footnotes ?? []) inspectBlocks(footnote.content, {
|
|
56
62
|
part: {
|
|
@@ -58,7 +64,8 @@ const inspectDocxCompatibility = (doc, options = {}) => {
|
|
|
58
64
|
id: footnote.id
|
|
59
65
|
},
|
|
60
66
|
path: `package.footnotes[id=${footnote.id}].content`,
|
|
61
|
-
record
|
|
67
|
+
record,
|
|
68
|
+
recordIssue
|
|
62
69
|
});
|
|
63
70
|
for (const endnote of doc.package.endnotes ?? []) inspectBlocks(endnote.content, {
|
|
64
71
|
part: {
|
|
@@ -66,7 +73,8 @@ const inspectDocxCompatibility = (doc, options = {}) => {
|
|
|
66
73
|
id: endnote.id
|
|
67
74
|
},
|
|
68
75
|
path: `package.endnotes[id=${endnote.id}].content`,
|
|
69
|
-
record
|
|
76
|
+
record,
|
|
77
|
+
recordIssue
|
|
70
78
|
});
|
|
71
79
|
return {
|
|
72
80
|
schemaVersion: 2,
|
|
@@ -86,7 +94,8 @@ function inspectBlocks(blocks, context) {
|
|
|
86
94
|
...block.paraId === void 0 ? {} : { blockId: block.paraId },
|
|
87
95
|
part: context.part,
|
|
88
96
|
path: `${blockPath}.content`,
|
|
89
|
-
record: context.record
|
|
97
|
+
record: context.record,
|
|
98
|
+
recordIssue: context.recordIssue
|
|
90
99
|
});
|
|
91
100
|
continue;
|
|
92
101
|
}
|
|
@@ -94,15 +103,27 @@ function inspectBlocks(blocks, context) {
|
|
|
94
103
|
for (const [rowIndex, row] of block.rows.entries()) for (const [cellIndex, cell] of row.cells.entries()) inspectBlocks(cell.content, {
|
|
95
104
|
part: context.part,
|
|
96
105
|
path: `${blockPath}.rows[${rowIndex}].cells[${cellIndex}].content`,
|
|
97
|
-
record: context.record
|
|
106
|
+
record: context.record,
|
|
107
|
+
recordIssue: context.recordIssue
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (block.type === "preservedBlock" && isAltChunkMarkup(block.xml)) {
|
|
112
|
+
context.recordIssue({
|
|
113
|
+
code: "unsupportedAltChunk",
|
|
114
|
+
location: {
|
|
115
|
+
part: context.part,
|
|
116
|
+
path: blockPath
|
|
117
|
+
}
|
|
98
118
|
});
|
|
99
119
|
continue;
|
|
100
120
|
}
|
|
101
|
-
if (block.type !== "blockSdt") continue;
|
|
121
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
102
122
|
inspectBlocks(block.content, {
|
|
103
123
|
part: context.part,
|
|
104
124
|
path: `${blockPath}.content`,
|
|
105
|
-
record: context.record
|
|
125
|
+
record: context.record,
|
|
126
|
+
recordIssue: context.recordIssue
|
|
106
127
|
});
|
|
107
128
|
}
|
|
108
129
|
}
|
|
@@ -28,7 +28,7 @@ declare const CONTAINER_CHILDREN: {
|
|
|
28
28
|
readonly "w:comment": readonly ["altChunk", "bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "del", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "p", "permEnd", "permStart", "proofErr", "sdt", "tbl"];
|
|
29
29
|
readonly "run-level-content": readonly ["bdo", "bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "customXmlPr", "del", "dir", "fldSimple", "hyperlink", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "pPr", "permEnd", "permStart", "proofErr", "r", "sdt", "smartTag", "smartTagPr", "subDoc"];
|
|
30
30
|
readonly "table-content": readonly ["bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "customXmlPr", "del", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "permEnd", "permStart", "proofErr", "sdt", "tblGrid", "tblPr", "tr"];
|
|
31
|
-
readonly "row-content": readonly ["bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "del", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "permEnd", "permStart", "proofErr", "sdt", "tblPrEx", "tc", "tr", "trPr"];
|
|
31
|
+
readonly "row-content": readonly ["bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "customXmlPr", "del", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "permEnd", "permStart", "proofErr", "sdt", "tblPrEx", "tc", "tr", "trPr"];
|
|
32
32
|
readonly "w:fonts": readonly ["font"];
|
|
33
33
|
readonly "w:font": readonly ["altName", "charset", "embedBold", "embedBoldItalic", "embedItalic", "embedRegular", "family", "notTrueType", "panose1", "pitch", "sig"];
|
|
34
34
|
readonly "w:hyperlink": readonly ["bdo", "bookmarkEnd", "bookmarkStart", "commentRangeEnd", "commentRangeStart", "customXml", "customXmlDelRangeEnd", "customXmlDelRangeStart", "customXmlInsRangeEnd", "customXmlInsRangeStart", "customXmlMoveFromRangeEnd", "customXmlMoveFromRangeStart", "customXmlMoveToRangeEnd", "customXmlMoveToRangeStart", "del", "dir", "fldSimple", "hyperlink", "ins", "moveFrom", "moveFromRangeEnd", "moveFromRangeStart", "moveTo", "moveToRangeEnd", "moveToRangeStart", "permEnd", "permStart", "proofErr", "r", "sdt", "smartTag", "subDoc"];
|