@stll/folio-core 0.45.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-edits/apply.js +85 -43
- package/dist/ai-edits/headless.js +2 -2
- package/dist/ai-edits/read.d.ts +1 -0
- package/dist/ai-edits/read.js +1 -0
- package/dist/ai-edits/snapshot.js +32 -27
- package/dist/ai-edits/table-cell-mutations.js +15 -7
- package/dist/ai-edits/table-geometry.js +21 -18
- package/dist/ai-edits/table-template.js +2 -2
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +108 -12
- package/dist/compare/content-types.d.ts +8 -2
- package/dist/compare/content.js +2 -11
- package/dist/compare/plan.js +7 -4
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/section-boundary-properties.js +1 -2
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +17 -0
- package/dist/content-controls/checkboxDisplay.js +46 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +57 -43
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -18
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +113 -14
- package/dist/display-list/build/previewPrimitives.d.ts +10 -0
- package/dist/display-list/build/previewPrimitives.js +89 -0
- package/dist/display-list/build/strokes.d.ts +177 -8
- package/dist/display-list/build/strokes.js +167 -47
- package/dist/display-list/build/tablePrimitives.js +4 -2
- package/dist/display-list/build/textBoxPrimitives.js +6 -4
- package/dist/display-list/build/textDecorations.d.ts +15 -1
- package/dist/display-list/build/textDecorations.js +15 -1
- package/dist/display-list/dom/renderDisplayListToDom.js +11 -21
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +76 -0
- package/dist/docx/attributeRemainder.js +111 -0
- package/dist/docx/blockContentParser.d.ts +3 -1
- package/dist/docx/blockContentParser.js +102 -106
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +3 -0
- package/dist/docx/borderParser.js +26 -11
- package/dist/docx/builtInStyles.d.ts +8 -16
- package/dist/docx/builtInStyles.js +54 -17
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +56 -39
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +3 -1
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/compatibility.js +56 -41
- package/dist/docx/containerChildren.d.ts +208 -0
- package/dist/docx/containerChildren.gen.d.ts +43 -0
- package/dist/docx/containerChildren.gen.js +263 -0
- package/dist/docx/containerChildren.js +153 -0
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +7 -4
- package/dist/docx/drawingAnchor.d.ts +87 -0
- package/dist/docx/drawingAnchor.js +201 -0
- package/dist/docx/drawingUtils.d.ts +43 -38
- package/dist/docx/drawingUtils.js +205 -118
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +66 -9
- package/dist/docx/hyperlinkParser.js +153 -26
- package/dist/docx/imageParser.js +160 -115
- package/dist/docx/index.d.ts +2 -1
- package/dist/docx/index.js +2 -1
- package/dist/docx/inlineContentRemovals.d.ts +28 -0
- package/dist/docx/inlineContentRemovals.js +46 -0
- package/dist/docx/inlineWrapperContent.d.ts +166 -0
- package/dist/docx/inlineWrapperContent.js +165 -0
- package/dist/docx/inlineWrapperParser.d.ts +11 -0
- package/dist/docx/inlineWrapperParser.js +60 -0
- package/dist/docx/nonVisualDrawingProps.d.ts +5 -13
- package/dist/docx/normalizeBaseDirection.js +12 -1
- package/dist/docx/numberingParser.d.ts +25 -2
- package/dist/docx/numberingParser.js +264 -361
- package/dist/docx/numberingReference.d.ts +9 -16
- package/dist/docx/numberingReference.js +17 -16
- package/dist/docx/numberingReferenceNormalization.js +7 -7
- package/dist/docx/ooxmlCounterFormatter.d.ts +1 -1
- package/dist/docx/ooxmlCounterFormatter.js +4 -1
- package/dist/docx/paraIdAttribute.d.ts +111 -0
- package/dist/docx/paraIdAttribute.js +142 -0
- package/dist/docx/paragraphParser.d.ts +10 -25
- package/dist/docx/paragraphParser.js +421 -496
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +3 -2
- package/dist/docx/paragraphTextBoxEnrichment.js +20 -59
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +53 -52
- package/dist/docx/parseWarningMessage.js +5 -1
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +96 -0
- package/dist/docx/previewBudget.d.ts +44 -23
- package/dist/docx/previewBudget.js +61 -30
- package/dist/docx/propertyElementAttributes.d.ts +178 -0
- package/dist/docx/propertyElementAttributes.js +114 -0
- package/dist/docx/renderedPageBreakNormalization.js +4 -6
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +152 -27
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +55 -19
- package/dist/docx/runParser.js +394 -306
- package/dist/docx/runPayload.d.ts +5 -0
- package/dist/docx/runPayload.js +4 -0
- package/dist/docx/sdtProperties.d.ts +39 -5
- package/dist/docx/sdtProperties.js +205 -84
- package/dist/docx/sdtPropertiesPatch.d.ts +5 -9
- package/dist/docx/sdtPropertiesPatch.js +68 -112
- package/dist/docx/sectionParser.d.ts +1 -2
- package/dist/docx/sectionParser.js +241 -238
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +66 -3
- package/dist/docx/selectiveXmlPatch.js +276 -133
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +12 -10
- package/dist/docx/serializer/commentSerializer.js +5 -7
- package/dist/docx/serializer/documentSerializer.js +11 -11
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +10 -9
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +11 -8
- package/dist/docx/serializer/numberingSerializer.d.ts +1 -6
- package/dist/docx/serializer/numberingSerializer.js +81 -79
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -9
- package/dist/docx/serializer/paragraphSerializer.js +156 -236
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +134 -75
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +42 -49
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +283 -105
- package/dist/docx/serializer/textFormattingSerializer.d.ts +28 -4
- package/dist/docx/serializer/textFormattingSerializer.js +111 -101
- package/dist/docx/serializer/xmlUtils.d.ts +1 -1
- package/dist/docx/serializer/xmlUtils.js +1 -1
- package/dist/docx/server/createBilingualDocument.js +20 -16
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/settingsParser.js +7 -4
- package/dist/docx/shadingParser.d.ts +2 -1
- package/dist/docx/shadingParser.js +43 -7
- package/dist/docx/shapeParser.js +13 -8
- package/dist/docx/strictNames.d.ts +11 -0
- package/dist/docx/strictNames.gen.d.ts +45 -0
- package/dist/docx/strictNames.gen.js +50 -0
- package/dist/docx/strictNames.js +43 -0
- package/dist/docx/strictValueEncodings.gen.js +133 -131
- package/dist/docx/styleParser.js +17 -349
- package/dist/docx/tableParser.d.ts +11 -2
- package/dist/docx/tableParser.js +665 -220
- package/dist/docx/textBoxParser.d.ts +28 -3
- package/dist/docx/textBoxParser.js +69 -9
- package/dist/docx/themeColorAttribute.d.ts +13 -0
- package/dist/docx/themeColorAttribute.js +24 -0
- package/dist/docx/trackedMoveRangeNormalization.js +2 -1
- package/dist/docx/unzip.js +5 -4
- package/dist/docx/vmlImageParser.d.ts +30 -5
- package/dist/docx/vmlImageParser.js +91 -32
- package/dist/docx/vmlPreview.js +2 -2
- package/dist/docx/wrapPolygon.d.ts +30 -0
- package/dist/docx/wrapPolygon.js +70 -0
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +23 -1
- package/dist/docx/xmlParser.js +31 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +12 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +68 -0
- package/dist/i18n/messages/catalogs.gen.js +102 -34
- package/dist/i18n/messages/messages.gen.d.ts +4 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +7 -2
- package/dist/internal/paragraphFormattingSerialization.d.ts +20 -9
- package/dist/internal/paragraphFormattingSerialization.js +118 -83
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +1 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +2 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +17 -12
- package/dist/layout-bridge/convert/toFlowBlocks.js +267 -101
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +53 -17
- package/dist/layout-engine/measure/measureBlocks.d.ts +3 -0
- package/dist/layout-engine/measure/measureBlocks.js +6 -10
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/measure/tableCellGrid.js +2 -1
- package/dist/layout-engine/measure/tableFragmentBorderGeometry.js +2 -1
- package/dist/layout-engine/measure/tableInlinePlacement.js +2 -5
- package/dist/layout-engine/paragraphSequence.js +3 -2
- package/dist/layout-engine/renderedBreakReconciliation.js +2 -1
- package/dist/layout-engine/section-breaks.d.ts +49 -2
- package/dist/layout-engine/section-breaks.js +55 -4
- package/dist/layout-engine/types.d.ts +69 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +10 -3
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +10 -4
- package/dist/layout-painter/renderParagraph.d.ts +14 -1
- package/dist/layout-painter/renderParagraph.js +34 -28
- package/dist/layout-painter/renderTable.d.ts +4 -1
- package/dist/layout-painter/renderTable.js +22 -22
- package/dist/layout-painter/renderTextBox.js +5 -3
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +12 -4
- package/dist/markdown/renderBlock.js +3 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +34 -6
- package/dist/markdown/renderTable.js +24 -6
- package/dist/markdown/trailers.js +4 -1
- package/dist/model.d.ts +3 -3
- package/dist/model.js +2 -2
- package/dist/paged-layout/sectionBlockWidths.d.ts +3 -0
- package/dist/paged-layout/sectionBlockWidths.js +26 -4
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +34 -5
- package/dist/prosemirror/attrs/index.js +639 -48
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +9 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +22 -3
- package/dist/prosemirror/commands/comments.js +68 -53
- package/dist/prosemirror/commands/contentControls.js +33 -20
- package/dist/prosemirror/commands/image.d.ts +10 -3
- package/dist/prosemirror/commands/image.js +46 -29
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commands/paragraph.d.ts +2 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +12 -4
- package/dist/prosemirror/commands/propertyChangeScope.js +22 -4
- package/dist/prosemirror/commands/sectionBreak.d.ts +33 -1
- package/dist/prosemirror/commands/sectionBreak.js +187 -11
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +17 -12
- package/dist/prosemirror/conversion/fromProseDoc.js +553 -207
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/preservedSinkCarriers.d.ts +39 -0
- package/dist/prosemirror/conversion/preservedSinkCarriers.js +19 -0
- package/dist/prosemirror/conversion/runShadingMark.js +14 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +10 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +19 -5
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +801 -411
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +14 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +21 -16
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +48 -29
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +4 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +5 -5
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +3 -1
- package/dist/prosemirror/extensions/features/pasteCleanup.js +56 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +5 -4
- package/dist/prosemirror/extensions/markRegistry.d.ts +65 -0
- package/dist/prosemirror/extensions/markRegistry.js +138 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +77 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +26 -0
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +2 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +12 -18
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +49 -5
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.d.ts +29 -0
- package/dist/prosemirror/extensions/nodes/BlockBookmarkBoundaryExtension.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +18 -13
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +28 -53
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +97 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +24 -1
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/MoveRangeBoundaryExtension.js +43 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/RangeAnchorExtension.js +65 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +3 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +22 -16
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +7 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +142 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +9 -1
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.d.ts +23 -0
- package/dist/prosemirror/extensions/nodes/bookmarkBoundaryDom.js +57 -0
- package/dist/prosemirror/extensions/types.d.ts +12 -3
- package/dist/prosemirror/index.d.ts +4 -2
- package/dist/prosemirror/index.js +2 -1
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +92 -0
- package/dist/prosemirror/listMarker.d.ts +2 -2
- package/dist/prosemirror/listMarker.js +7 -8
- package/dist/prosemirror/listRenderingAttrs.js +11 -1
- package/dist/prosemirror/listState.d.ts +62 -0
- package/dist/prosemirror/listState.js +49 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.d.ts +13 -0
- package/dist/prosemirror/moveRangeBoundaryAttrs.js +114 -0
- package/dist/prosemirror/numberedRefFields.js +4 -4
- package/dist/prosemirror/numberingAttr.d.ts +55 -0
- package/dist/prosemirror/numberingAttr.js +74 -0
- package/dist/prosemirror/outlineLevelAttr.d.ts +29 -0
- package/dist/prosemirror/outlineLevelAttr.js +42 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +9 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +4 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +3 -6
- package/dist/prosemirror/plugins/selectionTracker.js +3 -10
- package/dist/prosemirror/rangeAnchorAttrs.d.ts +14 -0
- package/dist/prosemirror/rangeAnchorAttrs.js +101 -0
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +183 -0
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +5 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +7 -1
- package/dist/prosemirror/runIdentity.d.ts +28 -0
- package/dist/prosemirror/runIdentity.js +36 -0
- package/dist/prosemirror/runStyleFormatting.js +1 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +47 -4
- package/dist/prosemirror/schema/nodes.d.ts +309 -26
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/sectionCarrier.d.ts +37 -0
- package/dist/prosemirror/sectionCarrier.js +40 -0
- package/dist/prosemirror/selectionState.d.ts +3 -0
- package/dist/prosemirror/selectionState.js +4 -1
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +5 -4
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +15 -13
- package/dist/prosemirror/tableResize.js +5 -6
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +4 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +4 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +31 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +592 -0
- package/dist/prosemirror/zeroWidthAnchors.js +6 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/style-sets/extract.js +4 -4
- package/dist/style-sets/stellaStyle.js +36 -23
- package/dist/types/colors.d.ts +2 -2
- package/dist/types/content.d.ts +2 -2
- package/dist/types/documentEnumValues.d.ts +53 -26
- package/dist/types/documentEnumValues.js +72 -174
- package/dist/types/formatting.d.ts +2 -2
- package/dist/types/index.d.ts +9 -2
- package/dist/utils/borderCss.d.ts +246 -0
- package/dist/utils/borderCss.js +325 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +27 -1
- package/dist/utils/colorResolver.d.ts +4 -3
- package/dist/utils/colorResolver.js +45 -76
- package/dist/utils/createDocument.js +24 -6
- package/dist/utils/findReplace.js +52 -10
- package/dist/utils/formatToStyle.d.ts +84 -2
- package/dist/utils/formatToStyle.js +133 -52
- package/dist/utils/headingCollector.js +3 -2
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +12 -20
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/tableOperations.d.ts +5 -3
- package/dist/utils/tableOperations.js +14 -1
- package/dist/utils/tablePlacement.d.ts +7 -0
- package/dist/utils/tablePlacement.js +14 -0
- package/dist/utils/textDirectionFlow.d.ts +15 -0
- package/dist/utils/textDirectionFlow.js +38 -0
- package/dist/utils/textFormattingMerge.js +16 -4
- package/package.json +10 -10
- package/dist/ai-edits/__fixtures__/paragraphs.d.ts +0 -17
- package/dist/ai-edits/__fixtures__/paragraphs.js +0 -33
- package/dist/compare/__fixtures__/body-sequence.d.ts +0 -119
- package/dist/compare/__fixtures__/body-sequence.js +0 -225
- package/dist/compare/__fixtures__/nested-table.d.ts +0 -16
- package/dist/compare/__fixtures__/nested-table.js +0 -50
- package/dist/compare/__fixtures__/numbered-list.d.ts +0 -34
- package/dist/compare/__fixtures__/numbered-list.js +0 -85
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/docx/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -50
- package/dist/fonts/embeddedFontTable.d.ts +0 -45
- package/dist/fonts/embeddedFontTable.js +0 -80
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.d.ts +0 -13
- package/dist/prosemirror/extensions/marks/PageBreakRunOwnerExtension.js +0 -39
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WORDPROCESSING_DRAWING_NAMESPACE_URIS } from "./drawingAnchor.js";
|
|
2
|
+
import { ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, narrowEnum } from "./parserEnums.js";
|
|
2
3
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
|
-
import {
|
|
4
|
+
import { findChildByLocalName, findChildByNamespaceUri, findChildrenByLocalName, getAttribute, getChildElements, getLocalName, getNamespaceUri, getTextContent, parseNumericAttribute, parseOnOffValue } from "./xmlParser.js";
|
|
5
|
+
import { PARSE_WARNING_CODES, THEME_COLOR_BY_SCHEME_COLOR_VALUE, isPresetLineDashVal, isSchemeColorValue, presetLineDashFrom, themeColorSlot } from "@stll/docx-core/model";
|
|
4
6
|
//#region src/docx/drawingUtils.ts
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
+
* Shared DrawingML Parsing Utilities
|
|
9
|
+
*
|
|
10
|
+
* Common functions used by imageParser and textBoxParser
|
|
11
|
+
* for parsing DrawingML elements (positions, wrapping, colors, fills, outlines).
|
|
8
12
|
*/
|
|
9
|
-
const SCHEME_TO_THEME_COLOR = {
|
|
10
|
-
accent1: "accent1",
|
|
11
|
-
accent2: "accent2",
|
|
12
|
-
accent3: "accent3",
|
|
13
|
-
accent4: "accent4",
|
|
14
|
-
accent5: "accent5",
|
|
15
|
-
accent6: "accent6",
|
|
16
|
-
dk1: "dk1",
|
|
17
|
-
lt1: "lt1",
|
|
18
|
-
dk2: "dk2",
|
|
19
|
-
lt2: "lt2",
|
|
20
|
-
tx1: "text1",
|
|
21
|
-
tx2: "text2",
|
|
22
|
-
bg1: "background1",
|
|
23
|
-
bg2: "background2",
|
|
24
|
-
hlink: "hlink",
|
|
25
|
-
folHlink: "folHlink"
|
|
26
|
-
};
|
|
27
13
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
14
|
+
* `a:schemeClr/@val` as a WordprocessingML theme colour, for the one DrawingML
|
|
15
|
+
* reference a document part carries inline.
|
|
16
|
+
*
|
|
17
|
+
* Both directions live in `@stll/docx-core/model`, total over their schema
|
|
18
|
+
* enumerations, so neither can omit a token.
|
|
30
19
|
*/
|
|
31
|
-
const
|
|
32
|
-
dk1: "dk1",
|
|
33
|
-
lt1: "lt1",
|
|
34
|
-
dk2: "dk2",
|
|
35
|
-
lt2: "lt2",
|
|
36
|
-
accent1: "accent1",
|
|
37
|
-
accent2: "accent2",
|
|
38
|
-
accent3: "accent3",
|
|
39
|
-
accent4: "accent4",
|
|
40
|
-
accent5: "accent5",
|
|
41
|
-
accent6: "accent6",
|
|
42
|
-
hlink: "hlink",
|
|
43
|
-
folHlink: "folHlink",
|
|
44
|
-
background1: "bg1",
|
|
45
|
-
text1: "tx1",
|
|
46
|
-
background2: "bg2",
|
|
47
|
-
text2: "tx2"
|
|
48
|
-
};
|
|
20
|
+
const schemeColorToThemeColor = (value) => isSchemeColorValue(value) ? THEME_COLOR_BY_SCHEME_COLOR_VALUE[value] ?? void 0 : void 0;
|
|
49
21
|
/**
|
|
50
22
|
* sRGB hex per OOXML (ST_HexColorRGB): exactly six hex digits, case-insensitive.
|
|
51
23
|
* Anything else is rejected so untrusted DOCX input cannot smuggle markup through
|
|
@@ -101,8 +73,8 @@ function parseColorElement(element) {
|
|
|
101
73
|
}
|
|
102
74
|
const schemeClr = children.find((el) => el.name === "a:schemeClr");
|
|
103
75
|
if (schemeClr) {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
76
|
+
const themeColor = schemeColorToThemeColor(getAttribute(schemeClr, null, "val") ?? "");
|
|
77
|
+
if (themeColor !== void 0) return applyColorModifiers({ themeColor }, schemeClr);
|
|
106
78
|
}
|
|
107
79
|
const sysClr = children.find((el) => el.name === "a:sysClr");
|
|
108
80
|
if (sysClr) {
|
|
@@ -174,7 +146,7 @@ function parseGradientFill(gradientFill) {
|
|
|
174
146
|
/**
|
|
175
147
|
* Parse outline from shape properties (a:ln).
|
|
176
148
|
*/
|
|
177
|
-
function parseOutline(spPr) {
|
|
149
|
+
function parseOutline(spPr, context) {
|
|
178
150
|
const ln = spPr ? findChildByLocalName(spPr, "ln") : null;
|
|
179
151
|
if (!ln) return;
|
|
180
152
|
if (findChildByLocalName(ln, "noFill")) return;
|
|
@@ -197,9 +169,14 @@ function parseOutline(spPr) {
|
|
|
197
169
|
if (color !== void 0) outline.color = color;
|
|
198
170
|
}
|
|
199
171
|
const prstDash = findChildByLocalName(ln, "prstDash");
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
172
|
+
const rawDash = prstDash ? getAttribute(prstDash, null, "val") : null;
|
|
173
|
+
if (rawDash) {
|
|
174
|
+
if (!isPresetLineDashVal(rawDash)) context?.warn({
|
|
175
|
+
code: PARSE_WARNING_CODES.outlineDashOutsideEnum,
|
|
176
|
+
element: prstDash?.name ?? "a:prstDash",
|
|
177
|
+
value: rawDash
|
|
178
|
+
});
|
|
179
|
+
outline.dash = presetLineDashFrom(rawDash);
|
|
203
180
|
}
|
|
204
181
|
const headEnd = findChildByLocalName(ln, "headEnd");
|
|
205
182
|
if (headEnd) outline.headEnd = parseLineEnd(headEnd);
|
|
@@ -231,10 +208,12 @@ function parseLineEnd(element) {
|
|
|
231
208
|
/**
|
|
232
209
|
* Parse horizontal position from wp:positionH element.
|
|
233
210
|
*/
|
|
211
|
+
/** A child of a WordprocessingDrawing element, resolved by namespace. */
|
|
212
|
+
const findDrawingChild = (parent, localName) => findChildByNamespaceUri(parent, WORDPROCESSING_DRAWING_NAMESPACE_URIS, localName);
|
|
234
213
|
function parsePositionH(posH) {
|
|
235
214
|
if (!posH) return;
|
|
236
215
|
const relativeTo = narrowEnum(getAttribute(posH, null, "relativeFrom"), ImageHorizontalRelativeToSchema) ?? "column";
|
|
237
|
-
const alignEl =
|
|
216
|
+
const alignEl = findDrawingChild(posH, "align");
|
|
238
217
|
if (alignEl) {
|
|
239
218
|
const alignment = narrowEnum(getTextContent(alignEl), ImageHorizontalAlignmentSchema);
|
|
240
219
|
if (alignment) return {
|
|
@@ -242,7 +221,7 @@ function parsePositionH(posH) {
|
|
|
242
221
|
alignment
|
|
243
222
|
};
|
|
244
223
|
}
|
|
245
|
-
const posOffsetEl =
|
|
224
|
+
const posOffsetEl = findDrawingChild(posH, "posOffset");
|
|
246
225
|
if (posOffsetEl) {
|
|
247
226
|
const text = getTextContent(posOffsetEl);
|
|
248
227
|
const posOffset = Number.parseInt(text, 10);
|
|
@@ -262,7 +241,7 @@ function parsePositionH(posH) {
|
|
|
262
241
|
function parsePositionV(posV) {
|
|
263
242
|
if (!posV) return;
|
|
264
243
|
const relativeTo = narrowEnum(getAttribute(posV, null, "relativeFrom"), ImageVerticalRelativeToSchema) ?? "paragraph";
|
|
265
|
-
const alignEl =
|
|
244
|
+
const alignEl = findDrawingChild(posV, "align");
|
|
266
245
|
if (alignEl) {
|
|
267
246
|
const alignment = narrowEnum(getTextContent(alignEl), ImageVerticalAlignmentSchema);
|
|
268
247
|
if (alignment) return {
|
|
@@ -270,7 +249,7 @@ function parsePositionV(posV) {
|
|
|
270
249
|
alignment
|
|
271
250
|
};
|
|
272
251
|
}
|
|
273
|
-
const posOffsetEl =
|
|
252
|
+
const posOffsetEl = findDrawingChild(posV, "posOffset");
|
|
274
253
|
if (posOffsetEl) {
|
|
275
254
|
const text = getTextContent(posOffsetEl);
|
|
276
255
|
const posOffset = Number.parseInt(text, 10);
|
|
@@ -288,8 +267,8 @@ function parsePositionV(posV) {
|
|
|
288
267
|
* Parse position for anchored drawings (combines positionH + positionV).
|
|
289
268
|
*/
|
|
290
269
|
function parseAnchorPosition(anchor) {
|
|
291
|
-
const positionH =
|
|
292
|
-
const positionV =
|
|
270
|
+
const positionH = findDrawingChild(anchor, "positionH");
|
|
271
|
+
const positionV = findDrawingChild(anchor, "positionV");
|
|
293
272
|
return {
|
|
294
273
|
horizontal: parsePositionH(positionH) ?? {
|
|
295
274
|
relativeTo: "column",
|
|
@@ -301,61 +280,176 @@ function parseAnchorPosition(anchor) {
|
|
|
301
280
|
}
|
|
302
281
|
};
|
|
303
282
|
}
|
|
304
|
-
/**
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
283
|
+
/**
|
|
284
|
+
* `EG_WrapType`'s members, by local name: the `wp` prefix is the producer's
|
|
285
|
+
* choice and a package free to bind the namespace elsewhere writes the same
|
|
286
|
+
* wrap.
|
|
287
|
+
*/
|
|
288
|
+
const WRAP_ELEMENT_LOCAL_NAMES = {
|
|
289
|
+
wrapNone: "inFront",
|
|
290
|
+
wrapSquare: "square",
|
|
291
|
+
wrapTight: "tight",
|
|
292
|
+
wrapThrough: "through",
|
|
293
|
+
wrapTopAndBottom: "topAndBottom"
|
|
294
|
+
};
|
|
295
|
+
/** The `EG_WrapType` child of a `wp:anchor`, resolved by namespace. */
|
|
296
|
+
function findWrapElement(anchor) {
|
|
297
|
+
for (const child of getChildElements(anchor)) if (getLocalName(child.name) in WRAP_ELEMENT_LOCAL_NAMES && WORDPROCESSING_DRAWING_NAMESPACE_URIS.has(getNamespaceUri(child) ?? "")) return child;
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
/** The inset attributes `CT_Inline`, `CT_Anchor` and the wrap children share. */
|
|
301
|
+
const WRAP_DISTANCE_KEYS = [
|
|
302
|
+
"distT",
|
|
303
|
+
"distB",
|
|
304
|
+
"distL",
|
|
305
|
+
"distR"
|
|
311
306
|
];
|
|
312
307
|
/**
|
|
308
|
+
* The insets one element states, or undefined when it states none.
|
|
309
|
+
*
|
|
310
|
+
* A wrap child's type declares a subset — `CT_WrapTight` and `CT_WrapThrough`
|
|
311
|
+
* only `distL`/`distR`, `CT_WrapTopBottom` only `distT`/`distB` — and an
|
|
312
|
+
* attribute the type does not declare cannot be present to read.
|
|
313
|
+
*/
|
|
314
|
+
const parseWrapDistances = (el) => {
|
|
315
|
+
if (!el) return;
|
|
316
|
+
const distances = {};
|
|
317
|
+
let stated = false;
|
|
318
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
319
|
+
const value = parseNumericAttribute(el, null, key);
|
|
320
|
+
if (value !== void 0) {
|
|
321
|
+
distances[key] = value;
|
|
322
|
+
stated = true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return stated ? distances : void 0;
|
|
326
|
+
};
|
|
327
|
+
/** The slot record for a drawing, or undefined when neither element stated an inset. */
|
|
328
|
+
const wrapDistanceSlots = (drawing, wrapChild) => drawing === void 0 && wrapChild === void 0 ? void 0 : {
|
|
329
|
+
...drawing === void 0 ? {} : { drawing },
|
|
330
|
+
...wrapChild === void 0 ? {} : { wrapChild }
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* `wp:effectExtent`'s four sides in EMU, exactly as the element states them.
|
|
334
|
+
*
|
|
335
|
+
* `CT_EffectExtent` requires all four, so a missing one is a malformed element
|
|
336
|
+
* rather than an unstated side, and zero is its own value: an explicit all-zero
|
|
337
|
+
* reservation on a wrap child says "this wrap reserves nothing", which is not
|
|
338
|
+
* what an absent element says.
|
|
339
|
+
*/
|
|
340
|
+
const parseEffectExtent = (el) => el === null ? void 0 : {
|
|
341
|
+
left: parseNumericAttribute(el, null, "l") ?? 0,
|
|
342
|
+
top: parseNumericAttribute(el, null, "t") ?? 0,
|
|
343
|
+
right: parseNumericAttribute(el, null, "r") ?? 0,
|
|
344
|
+
bottom: parseNumericAttribute(el, null, "b") ?? 0
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* The drawing's own `wp:effectExtent`, which is also what `Image.padding` holds.
|
|
348
|
+
*
|
|
349
|
+
* An all-zero reservation is what Word writes on a drawing with no effect, and
|
|
350
|
+
* a rebuild writes zeros for a drawing the record holds none for, so the two
|
|
351
|
+
* are the same document and neither the padding nor the slot keeps it. The wrap
|
|
352
|
+
* child's is read as authored instead: an absent one there inherits the
|
|
353
|
+
* drawing's, so an explicit all-zero says something an absent one does not.
|
|
354
|
+
*/
|
|
355
|
+
const parseDrawingEffectExtent = (el) => {
|
|
356
|
+
const extent = parseEffectExtent(el);
|
|
357
|
+
if (extent === void 0) return;
|
|
358
|
+
return extent.left === 0 && extent.top === 0 && extent.right === 0 && extent.bottom === 0 ? void 0 : extent;
|
|
359
|
+
};
|
|
360
|
+
/** The slot record, or undefined when neither element stated an effect extent. */
|
|
361
|
+
const effectExtentSlots = (drawing, wrapChild) => drawing === void 0 && wrapChild === void 0 ? void 0 : {
|
|
362
|
+
...drawing === void 0 ? {} : { drawing },
|
|
363
|
+
...wrapChild === void 0 ? {} : { wrapChild }
|
|
364
|
+
};
|
|
365
|
+
/** The wrap insets `CT_Inline` carries, read the same way for every graphic. */
|
|
366
|
+
function parseInlineWrap(inlineEl) {
|
|
367
|
+
const wrap = { type: "inline" };
|
|
368
|
+
const drawing = parseWrapDistances(inlineEl);
|
|
369
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
370
|
+
const value = drawing?.[key];
|
|
371
|
+
if (value !== void 0) wrap[key] = value;
|
|
372
|
+
}
|
|
373
|
+
const slots = wrapDistanceSlots(drawing, void 0);
|
|
374
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
375
|
+
const extents = effectExtentSlots(parseDrawingEffectExtent(findDrawingChild(inlineEl, "effectExtent")), void 0);
|
|
376
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
377
|
+
return wrap;
|
|
378
|
+
}
|
|
379
|
+
/** A `CT_Point2D`, which requires both coordinates. */
|
|
380
|
+
const parseWrapPolygonPoint = (el) => {
|
|
381
|
+
const x = parseNumericAttribute(el, null, "x");
|
|
382
|
+
const y = parseNumericAttribute(el, null, "y");
|
|
383
|
+
return x === void 0 || y === void 0 ? void 0 : {
|
|
384
|
+
x,
|
|
385
|
+
y
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* `wp:wrapPolygon`, the outline `wp:wrapTight` and `wp:wrapThrough` require.
|
|
390
|
+
*
|
|
391
|
+
* Undefined when the element is absent or states no `wp:start`, which
|
|
392
|
+
* `CT_WrapPath` requires and a rebuild has nothing to write without. A path
|
|
393
|
+
* with fewer `wp:lineTo` than the type admits is kept as it stands: reading it
|
|
394
|
+
* as no polygon at all would hand the drawing the minted rectangle and move
|
|
395
|
+
* text the source flows through the object.
|
|
396
|
+
*/
|
|
397
|
+
const parseWrapPolygon = (wrapEl) => {
|
|
398
|
+
const polygonEl = findDrawingChild(wrapEl, "wrapPolygon");
|
|
399
|
+
if (!polygonEl) return;
|
|
400
|
+
const startEl = findDrawingChild(polygonEl, "start");
|
|
401
|
+
const start = parseWrapPolygonPoint(startEl);
|
|
402
|
+
if (start === void 0) return;
|
|
403
|
+
const lineTo = getChildElements(polygonEl).filter((child) => getLocalName(child.name) === "lineTo" && WORDPROCESSING_DRAWING_NAMESPACE_URIS.has(getNamespaceUri(child) ?? "")).flatMap((child) => {
|
|
404
|
+
const point = parseWrapPolygonPoint(child);
|
|
405
|
+
return point === void 0 ? [] : [point];
|
|
406
|
+
});
|
|
407
|
+
const edited = parseOnOffValue(getAttribute(polygonEl, null, "edited"));
|
|
408
|
+
return {
|
|
409
|
+
...edited === void 0 ? {} : { edited },
|
|
410
|
+
start,
|
|
411
|
+
lineTo
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
313
415
|
* Parse wrap settings from a wrap element.
|
|
314
416
|
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
417
|
+
* Both the insets and the effect extent are declared twice over — on the
|
|
418
|
+
* drawing and on the wrap child — and each is kept in the slot that stated it.
|
|
419
|
+
* The insets differ in that the wrap child's take priority as the value in
|
|
420
|
+
* force; the two effect extents are two values (the object's own reservation
|
|
421
|
+
* and the one the text flow is computed against), so neither overrides the
|
|
422
|
+
* other.
|
|
318
423
|
*/
|
|
319
|
-
function parseWrapElement(wrapEl, behindDoc, anchorDistances) {
|
|
424
|
+
function parseWrapElement({ wrapEl, behindDoc, anchorDistances, anchorEffectExtent }) {
|
|
425
|
+
const drawingDistances = anchorDistances !== void 0 && WRAP_DISTANCE_KEYS.some((key) => anchorDistances[key] != null) ? anchorDistances : void 0;
|
|
320
426
|
if (!wrapEl) {
|
|
321
427
|
const wrap = { type: behindDoc ? "behind" : "inFront" };
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
428
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
429
|
+
const value = drawingDistances?.[key];
|
|
430
|
+
if (value !== void 0) wrap[key] = value;
|
|
431
|
+
}
|
|
432
|
+
const slots = wrapDistanceSlots(drawingDistances, void 0);
|
|
433
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
434
|
+
const extents = effectExtentSlots(anchorEffectExtent, void 0);
|
|
435
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
326
436
|
return wrap;
|
|
327
437
|
}
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
switch (wrapType) {
|
|
331
|
-
case "wrapNone":
|
|
332
|
-
type = behindDoc ? "behind" : "inFront";
|
|
333
|
-
break;
|
|
334
|
-
case "wrapSquare":
|
|
335
|
-
type = "square";
|
|
336
|
-
break;
|
|
337
|
-
case "wrapTight":
|
|
338
|
-
type = "tight";
|
|
339
|
-
break;
|
|
340
|
-
case "wrapThrough":
|
|
341
|
-
type = "through";
|
|
342
|
-
break;
|
|
343
|
-
case "wrapTopAndBottom":
|
|
344
|
-
type = "topAndBottom";
|
|
345
|
-
break;
|
|
346
|
-
default: type = "square";
|
|
347
|
-
}
|
|
348
|
-
const wrap = { type };
|
|
438
|
+
const named = WRAP_ELEMENT_LOCAL_NAMES[getLocalName(wrapEl.name)] ?? "square";
|
|
439
|
+
const wrap = { type: named === "inFront" && behindDoc ? "behind" : named };
|
|
349
440
|
const wrapText = narrowEnum(getAttribute(wrapEl, null, "wrapText"), ImageWrapTextSchema);
|
|
350
441
|
if (wrapText) wrap.wrapText = wrapText;
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
|
|
442
|
+
const wrapChildDistances = parseWrapDistances(wrapEl);
|
|
443
|
+
for (const key of WRAP_DISTANCE_KEYS) {
|
|
444
|
+
const value = wrapChildDistances?.[key] ?? drawingDistances?.[key];
|
|
445
|
+
if (value !== void 0) wrap[key] = value;
|
|
446
|
+
}
|
|
447
|
+
const slots = wrapDistanceSlots(drawingDistances, wrapChildDistances);
|
|
448
|
+
if (slots !== void 0) wrap.distanceSlots = slots;
|
|
449
|
+
const extents = effectExtentSlots(anchorEffectExtent, parseEffectExtent(findDrawingChild(wrapEl, "effectExtent")));
|
|
450
|
+
if (extents !== void 0) wrap.effectExtentSlots = extents;
|
|
451
|
+
const polygon = parseWrapPolygon(wrapEl);
|
|
452
|
+
if (polygon !== void 0) wrap.polygon = polygon;
|
|
359
453
|
return wrap;
|
|
360
454
|
}
|
|
361
455
|
/**
|
|
@@ -371,20 +465,14 @@ function parseAnchorBehindDoc(anchor) {
|
|
|
371
465
|
return parseOnOffValue(getAttribute(anchor, null, "behindDoc")) ?? false;
|
|
372
466
|
}
|
|
373
467
|
function parseAnchorWrap(anchor) {
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
...distT != null ? { distT } : {},
|
|
383
|
-
...distB != null ? { distB } : {},
|
|
384
|
-
...distL != null ? { distL } : {},
|
|
385
|
-
...distR != null ? { distR } : {}
|
|
386
|
-
};
|
|
387
|
-
return parseWrapElement(wrapEl ?? null, behindDoc, anchorDistances);
|
|
468
|
+
const anchorDistances = parseWrapDistances(anchor);
|
|
469
|
+
const anchorEffectExtent = parseDrawingEffectExtent(findDrawingChild(anchor, "effectExtent"));
|
|
470
|
+
return parseWrapElement({
|
|
471
|
+
wrapEl: findWrapElement(anchor),
|
|
472
|
+
behindDoc: parseAnchorBehindDoc(anchor),
|
|
473
|
+
...anchorDistances === void 0 ? {} : { anchorDistances },
|
|
474
|
+
...anchorEffectExtent === void 0 ? {} : { anchorEffectExtent }
|
|
475
|
+
});
|
|
388
476
|
}
|
|
389
477
|
/**
|
|
390
478
|
* Default theme color fallbacks (Office 2016 defaults).
|
|
@@ -401,10 +489,6 @@ const DEFAULT_THEME_COLOR_HEX = {
|
|
|
401
489
|
lt1: "FFFFFF",
|
|
402
490
|
dk2: "1F497D",
|
|
403
491
|
lt2: "EEECE1",
|
|
404
|
-
text1: "000000",
|
|
405
|
-
text2: "1F497D",
|
|
406
|
-
background1: "FFFFFF",
|
|
407
|
-
background2: "EEECE1",
|
|
408
492
|
hlink: "0563C1",
|
|
409
493
|
folHlink: "954F72"
|
|
410
494
|
};
|
|
@@ -415,7 +499,10 @@ const DEFAULT_THEME_COLOR_HEX = {
|
|
|
415
499
|
function resolveColorValueToHex(color) {
|
|
416
500
|
if (!color) return;
|
|
417
501
|
if (color.rgb) return `#${color.rgb}`;
|
|
418
|
-
if (color.themeColor)
|
|
502
|
+
if (color.themeColor) {
|
|
503
|
+
const slot = themeColorSlot(color.themeColor);
|
|
504
|
+
return `#${slot === void 0 ? "000000" : DEFAULT_THEME_COLOR_HEX[slot]}`;
|
|
505
|
+
}
|
|
419
506
|
}
|
|
420
507
|
//#endregion
|
|
421
|
-
export {
|
|
508
|
+
export { findWrapElement, parseAnchorBehindDoc, parseAnchorPosition, parseAnchorWrap, parseColorElement, parseDrawingEffectExtent, parseEffectExtent, parseFill, parseInlineWrap, parseOutline, parsePositionH, parsePositionV, parseWrapElement, resolveColorValueToHex };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deterministicHexId } from "../utils/hexId.js";
|
|
2
|
-
import { isXmlNameBoundary } from "./selectiveXmlPatch.js";
|
|
2
|
+
import { isXmlNameBoundary, spliceXml } from "./selectiveXmlPatch.js";
|
|
3
3
|
import { loadDocxArchive } from "./server/boundedArchive.js";
|
|
4
4
|
import { TaggedError } from "better-result";
|
|
5
5
|
import JSZip from "jszip";
|
|
@@ -97,11 +97,21 @@ const OPEN_TAG_TEXT_ID_PATTERN = /\sw(?:14)?:textId=(?<quote>["'])(?<id>[\s\S]*?
|
|
|
97
97
|
const XMLNS_W14_PATTERN = /\sxmlns:w14=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
|
|
98
98
|
const XMLNS_MC_PATTERN = /\sxmlns:mc=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
|
|
99
99
|
const MC_IGNORABLE_PATTERN = /\smc:Ignorable=(?<quote>["'])(?<value>[\s\S]*?)\k<quote>/u;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Stamp the edits into the part through the splice owner, which refuses a
|
|
102
|
+
* result that would leave a comment range with only one half. These edits
|
|
103
|
+
* rewrite `<w:p …>` open tags and the root element's attributes, so they
|
|
104
|
+
* should never cut across a range marker; the owner is what makes that
|
|
105
|
+
* structural rather than a reading of the scanner.
|
|
106
|
+
*/
|
|
107
|
+
const applySplices = (xml, edits, partPath) => {
|
|
108
|
+
const patched = spliceXml(xml, edits.map(({ start, end, text }) => ({
|
|
109
|
+
start,
|
|
110
|
+
end,
|
|
111
|
+
newXml: text
|
|
112
|
+
})));
|
|
113
|
+
if (patched === null) throw createEnsureParaIdsError(`Stamping paragraph ids into ${partPath} broke a comment range`);
|
|
114
|
+
return patched;
|
|
105
115
|
};
|
|
106
116
|
const createEnsureParaIdsError = (message, cause) => new EnsureParaIdsError({
|
|
107
117
|
message,
|
|
@@ -382,7 +392,7 @@ const ensureParaIdsInternal = async (docx, options) => {
|
|
|
382
392
|
if (scan.edits.length === 0) continue;
|
|
383
393
|
assigned += scan.assigned;
|
|
384
394
|
deduplicated += scan.deduplicated;
|
|
385
|
-
updates.set(partPath, applySplices(xml, [...scan.edits, ...ensureRootNamespaces(xml, partPath)]));
|
|
395
|
+
updates.set(partPath, applySplices(xml, [...scan.edits, ...ensureRootNamespaces(xml, partPath)], partPath));
|
|
386
396
|
}
|
|
387
397
|
if (updates.size === 0) return {
|
|
388
398
|
docx: toUint8Array(docx),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import { StyleMap } from "./styleParser.js";
|
|
3
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
|
+
import { StyleMap } from "./styleParser.js";
|
|
4
4
|
//#region src/docx/fieldParser.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* All known field types from OOXML specification
|
package/dist/docx/fieldParser.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { parseFieldState } from "./fieldState.js";
|
|
1
2
|
import { formatOoxmlCounter } from "./ooxmlCounterFormatter.js";
|
|
2
3
|
import { FieldTypeSchema, narrowEnum } from "./parserEnums.js";
|
|
3
4
|
import { parseRun } from "./runParser.js";
|
|
4
|
-
import { findChildren, getAttribute
|
|
5
|
+
import { findChildren, getAttribute } from "./xmlParser.js";
|
|
5
6
|
//#region src/docx/fieldParser.ts
|
|
6
7
|
/**
|
|
7
8
|
* All known field types from OOXML specification
|
|
@@ -162,10 +163,9 @@ function parseSimpleField(node, styles, theme) {
|
|
|
162
163
|
type: "simpleField",
|
|
163
164
|
instruction,
|
|
164
165
|
fieldType: parseFieldType(instruction),
|
|
165
|
-
content: []
|
|
166
|
+
content: [],
|
|
167
|
+
...parseFieldState(node)
|
|
166
168
|
};
|
|
167
|
-
if (parseOnOffAttribute(node, "w", "fldLock") === true) field.fldLock = true;
|
|
168
|
-
if (parseOnOffAttribute(node, "w", "dirty") === true) field.dirty = true;
|
|
169
169
|
const children = findChildren(node, "w", "r");
|
|
170
170
|
for (const child of children) {
|
|
171
171
|
const run = parseRun(child, styles, theme);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/fieldState.d.ts
|
|
3
|
+
/** What a field element states about its lock and dirty flags. */
|
|
4
|
+
type FieldState = {
|
|
5
|
+
fldLock?: boolean;
|
|
6
|
+
dirty?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** Read both attributes off a `w:fldSimple` or `w:fldChar`, keeping an explicit off. */
|
|
9
|
+
declare const parseFieldState: (element: XmlElement) => FieldState;
|
|
10
|
+
/**
|
|
11
|
+
* The stated flags of a field, without the rest of it.
|
|
12
|
+
*
|
|
13
|
+
* The complex-field assembly carries the begin `w:fldChar`'s state across the
|
|
14
|
+
* runs between `begin` and `end`, and this is the one place that knows which
|
|
15
|
+
* fields that state is made of.
|
|
16
|
+
*/
|
|
17
|
+
declare const fieldStateOf: ({ fldLock, dirty }: FieldState) => FieldState;
|
|
18
|
+
/**
|
|
19
|
+
* The attributes to write for a field's stated flags, in schema order.
|
|
20
|
+
*
|
|
21
|
+
* `1`/`0` is what Word writes and what the table, section and border
|
|
22
|
+
* serializers write.
|
|
23
|
+
*/
|
|
24
|
+
declare const fieldStateAttributes: ({ fldLock, dirty }: FieldState) => string[];
|
|
25
|
+
//#endregion
|
|
26
|
+
export { FieldState, fieldStateAttributes, fieldStateOf, parseFieldState };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseOnOffAttribute } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/fieldState.ts
|
|
3
|
+
/**
|
|
4
|
+
* `@w:fldLock` and `@w:dirty`, the two `ST_OnOff` attributes every field form
|
|
5
|
+
* carries.
|
|
6
|
+
*
|
|
7
|
+
* A simple field states them on `<w:fldSimple>`; a complex field states them on
|
|
8
|
+
* the `<w:fldChar w:fldCharType="begin"/>` that opens it, and folio hoists them
|
|
9
|
+
* from there onto the assembled `ComplexField`. Neither attribute has an XSD
|
|
10
|
+
* default, so a field states one of three things about each: nothing, an
|
|
11
|
+
* explicit off, an explicit on. `w:dirty="0"` on a field inside a `TOC` result
|
|
12
|
+
* is the case that matters: it says "do not recompute this", which is not what
|
|
13
|
+
* an absent attribute says.
|
|
14
|
+
*
|
|
15
|
+
* Three readers and three writers had drifted into the same `=== true` /
|
|
16
|
+
* truthiness collapse, so both directions live here instead.
|
|
17
|
+
*/
|
|
18
|
+
/** Read both attributes off a `w:fldSimple` or `w:fldChar`, keeping an explicit off. */
|
|
19
|
+
const parseFieldState = (element) => {
|
|
20
|
+
const state = {};
|
|
21
|
+
const fldLock = parseOnOffAttribute(element, "w", "fldLock");
|
|
22
|
+
if (fldLock !== void 0) state.fldLock = fldLock;
|
|
23
|
+
const dirty = parseOnOffAttribute(element, "w", "dirty");
|
|
24
|
+
if (dirty !== void 0) state.dirty = dirty;
|
|
25
|
+
return state;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The stated flags of a field, without the rest of it.
|
|
29
|
+
*
|
|
30
|
+
* The complex-field assembly carries the begin `w:fldChar`'s state across the
|
|
31
|
+
* runs between `begin` and `end`, and this is the one place that knows which
|
|
32
|
+
* fields that state is made of.
|
|
33
|
+
*/
|
|
34
|
+
const fieldStateOf = ({ fldLock, dirty }) => {
|
|
35
|
+
const state = {};
|
|
36
|
+
if (fldLock !== void 0) state.fldLock = fldLock;
|
|
37
|
+
if (dirty !== void 0) state.dirty = dirty;
|
|
38
|
+
return state;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The attributes to write for a field's stated flags, in schema order.
|
|
42
|
+
*
|
|
43
|
+
* `1`/`0` is what Word writes and what the table, section and border
|
|
44
|
+
* serializers write.
|
|
45
|
+
*/
|
|
46
|
+
const fieldStateAttributes = ({ fldLock, dirty }) => {
|
|
47
|
+
const attrs = [];
|
|
48
|
+
if (fldLock !== void 0) attrs.push(`w:fldLock="${fldLock ? "1" : "0"}"`);
|
|
49
|
+
if (dirty !== void 0) attrs.push(`w:dirty="${dirty ? "1" : "0"}"`);
|
|
50
|
+
return attrs;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { fieldStateAttributes, fieldStateOf, parseFieldState };
|