@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,14 +1,48 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
3
|
//#region src/docx/sdtProperties.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* One preserved `w:sdtPr` child by local name, as the source wrote it.
|
|
6
|
+
*
|
|
7
|
+
* The name is resolved, never a spelling: a producer may bind the w14 URI to
|
|
8
|
+
* any prefix, and the local name is what tells `w14:checkbox` from a run's
|
|
9
|
+
* `w:color`, because `CT_SdtPr` declares neither name twice.
|
|
10
|
+
*/
|
|
11
|
+
declare const preservedSdtChild: (preserved: document_d_exports.PreservedMarkup | undefined, localName: string) => string | undefined;
|
|
12
|
+
/** The same set without that child, or `undefined` when nothing is left. */
|
|
13
|
+
declare const withoutPreservedSdtChild: (preserved: document_d_exports.PreservedMarkup | undefined, localName: string) => document_d_exports.PreservedMarkup | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Whether one preserved child is the element that states the control kind.
|
|
16
|
+
*
|
|
17
|
+
* The writer synthesises a kind marker only when the sink holds none, so a
|
|
18
|
+
* control folio parsed keeps the one its author wrote and a control built in
|
|
19
|
+
* code still gets one; and it is this child, not the whole set, that the
|
|
20
|
+
* modelled interactive state is written back into.
|
|
21
|
+
*/
|
|
22
|
+
declare const statesControlKind: (xml: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Direct children of `w:sdt` that sit outside `w:sdtContent`, split by side.
|
|
25
|
+
*
|
|
26
|
+
* Word writes range markers there. A same-named element from another
|
|
27
|
+
* namespace is not one of the structural WordprocessingML children, so it is
|
|
28
|
+
* captured rather than mistaken for `w:sdtPr`, `w:sdtEndPr`, or
|
|
29
|
+
* `w:sdtContent`.
|
|
30
|
+
*/
|
|
31
|
+
declare const captureSdtSiblingMarkers: (sdt: XmlElement) => {
|
|
32
|
+
before: string;
|
|
33
|
+
after: string;
|
|
34
|
+
};
|
|
4
35
|
/**
|
|
5
36
|
* Parse `<w:sdtPr>` (and optional `<w:sdtEndPr>`) into {@link SdtProperties}.
|
|
6
37
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
38
|
+
* Modelled fields drive addressing and template tooling. Everything else —
|
|
39
|
+
* the control-kind element, `w:dataBinding`, `w:label`, `w:tabIndex`,
|
|
40
|
+
* `w:temporary`, `w:rPr`, and every extension-namespace child — lands in
|
|
41
|
+
* {@link SdtProperties.preserved} at its schema ordinal. A modelled child
|
|
42
|
+
* whose value the reader refuses lands there too: `keptUnless` decides by the
|
|
43
|
+
* outcome, because a map keyed by name cannot list the values a reader will
|
|
44
|
+
* not admit.
|
|
11
45
|
*/
|
|
12
46
|
declare function parseSdtProperties(sdtPr: XmlElement | null | undefined, sdtEndPr?: XmlElement | null | undefined): document_d_exports.SdtProperties;
|
|
13
47
|
//#endregion
|
|
14
|
-
export { parseSdtProperties };
|
|
48
|
+
export { captureSdtSiblingMarkers, parseSdtProperties, preservedSdtChild, statesControlKind, withoutPreservedSdtChild };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { CAPTURE, dispatchChildren, keptUnless, sequencePositions } from "./containerChildren.js";
|
|
1
2
|
import { SdtLockSchema, narrowEnum } from "./parserEnums.js";
|
|
3
|
+
import { RUN_PROPERTY_OWNERS, parseRunProperties } from "./runParser.js";
|
|
2
4
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
3
|
-
import { findChild, getAttributeAnyPrefix, getLocalName, parseBooleanElement } from "./xmlParser.js";
|
|
5
|
+
import { WORDPROCESSINGML_NAMESPACE_URIS, findChild, findChildByLocalName, getAttributeAnyPrefix, getLocalName, parseBooleanElement } from "./xmlParser.js";
|
|
4
6
|
//#region src/docx/sdtProperties.ts
|
|
5
7
|
function parseListItems(el) {
|
|
6
8
|
const items = [];
|
|
@@ -192,100 +194,219 @@ function rewriteOpenTagAttrPrefixes(raw, canonical, local) {
|
|
|
192
194
|
return pieces.join("");
|
|
193
195
|
}
|
|
194
196
|
/**
|
|
197
|
+
* The `w:sdtPr` children that state which kind of control this is.
|
|
198
|
+
*
|
|
199
|
+
* They are the choice that closes `CT_SdtPr`, so at most one may appear, and
|
|
200
|
+
* every one of them is kept as bytes rather than rebuilt: `w:date` carries a
|
|
201
|
+
* calendar and a locale, `w:docPartObj` a gallery and a category, `w:text` a
|
|
202
|
+
* `@w:multiLine`, and `w14:checkbox` its two glyph elements — none of which
|
|
203
|
+
* {@link SdtProperties} has a field for. The handler reads the projection
|
|
204
|
+
* folio does model off the element and hands the element itself back, so the
|
|
205
|
+
* kind survives an edit whole.
|
|
206
|
+
*
|
|
207
|
+
* `checkbox` is `w14:` and the Transitional graph does not declare it, so it
|
|
208
|
+
* is listed separately: the dispatcher reaches it through `undeclared` and it
|
|
209
|
+
* cannot be bound to the generated child set.
|
|
210
|
+
*/
|
|
211
|
+
const CONTROL_KIND_CHILDREN = [
|
|
212
|
+
"equation",
|
|
213
|
+
"comboBox",
|
|
214
|
+
"date",
|
|
215
|
+
"docPartObj",
|
|
216
|
+
"docPartList",
|
|
217
|
+
"dropDownList",
|
|
218
|
+
"picture",
|
|
219
|
+
"richText",
|
|
220
|
+
"text",
|
|
221
|
+
"citation",
|
|
222
|
+
"group",
|
|
223
|
+
"bibliography"
|
|
224
|
+
];
|
|
225
|
+
const CHECKBOX_CHILD = "checkbox";
|
|
226
|
+
/**
|
|
227
|
+
* The local name of a captured fragment's root element.
|
|
228
|
+
*
|
|
229
|
+
* The fragments in the sink are folio's own output — `captureVerbatimXml`
|
|
230
|
+
* serialises one element and materialises its namespace bindings — so the
|
|
231
|
+
* start tag is the first thing in the string and reading its name off the
|
|
232
|
+
* front is exact rather than a guess about arbitrary markup.
|
|
233
|
+
*/
|
|
234
|
+
const capturedRootName = (xml) => /^<(?:[\w.-]+:)?(?<local>[\w.-]+)/u.exec(xml)?.groups?.["local"];
|
|
235
|
+
/**
|
|
236
|
+
* One preserved `w:sdtPr` child by local name, as the source wrote it.
|
|
237
|
+
*
|
|
238
|
+
* The name is resolved, never a spelling: a producer may bind the w14 URI to
|
|
239
|
+
* any prefix, and the local name is what tells `w14:checkbox` from a run's
|
|
240
|
+
* `w:color`, because `CT_SdtPr` declares neither name twice.
|
|
241
|
+
*/
|
|
242
|
+
const preservedSdtChild = (preserved, localName) => preserved?.children?.find(({ xml }) => capturedRootName(xml) === localName)?.xml;
|
|
243
|
+
/** The same set without that child, or `undefined` when nothing is left. */
|
|
244
|
+
const withoutPreservedSdtChild = (preserved, localName) => {
|
|
245
|
+
const children = (preserved?.children ?? []).filter(({ xml }) => capturedRootName(xml) !== localName);
|
|
246
|
+
return children.length === 0 ? void 0 : { children };
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Whether one preserved child is the element that states the control kind.
|
|
250
|
+
*
|
|
251
|
+
* The writer synthesises a kind marker only when the sink holds none, so a
|
|
252
|
+
* control folio parsed keeps the one its author wrote and a control built in
|
|
253
|
+
* code still gets one; and it is this child, not the whole set, that the
|
|
254
|
+
* modelled interactive state is written back into.
|
|
255
|
+
*/
|
|
256
|
+
const statesControlKind = (xml) => {
|
|
257
|
+
const root = capturedRootName(xml);
|
|
258
|
+
return root !== void 0 && (root === CHECKBOX_CHILD || CONTROL_KIND_CHILDREN.some((name) => name === root));
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Direct children of `w:sdt` that sit outside `w:sdtContent`, split by side.
|
|
262
|
+
*
|
|
263
|
+
* Word writes range markers there. A same-named element from another
|
|
264
|
+
* namespace is not one of the structural WordprocessingML children, so it is
|
|
265
|
+
* captured rather than mistaken for `w:sdtPr`, `w:sdtEndPr`, or
|
|
266
|
+
* `w:sdtContent`.
|
|
267
|
+
*/
|
|
268
|
+
const captureSdtSiblingMarkers = (sdt) => {
|
|
269
|
+
const beforeParts = [];
|
|
270
|
+
const afterParts = [];
|
|
271
|
+
let sawContent = false;
|
|
272
|
+
for (const child of sdt.elements ?? []) {
|
|
273
|
+
if (child.type !== "element" || !child.name) continue;
|
|
274
|
+
const local = getLocalName(child.name);
|
|
275
|
+
const isWordprocessingChild = WORDPROCESSINGML_NAMESPACE_URIS.has(child.namespaceUri ?? "");
|
|
276
|
+
if (isWordprocessingChild && (local === "sdtPr" || local === "sdtEndPr")) continue;
|
|
277
|
+
if (isWordprocessingChild && local === "sdtContent") {
|
|
278
|
+
sawContent = true;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const xml = captureVerbatimXml(child);
|
|
282
|
+
if (sawContent) afterParts.push(xml);
|
|
283
|
+
else beforeParts.push(xml);
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
before: beforeParts.join(""),
|
|
287
|
+
after: afterParts.join("")
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
195
291
|
* Parse `<w:sdtPr>` (and optional `<w:sdtEndPr>`) into {@link SdtProperties}.
|
|
196
292
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
293
|
+
* Modelled fields drive addressing and template tooling. Everything else —
|
|
294
|
+
* the control-kind element, `w:dataBinding`, `w:label`, `w:tabIndex`,
|
|
295
|
+
* `w:temporary`, `w:rPr`, and every extension-namespace child — lands in
|
|
296
|
+
* {@link SdtProperties.preserved} at its schema ordinal. A modelled child
|
|
297
|
+
* whose value the reader refuses lands there too: `keptUnless` decides by the
|
|
298
|
+
* outcome, because a map keyed by name cannot list the values a reader will
|
|
299
|
+
* not admit.
|
|
201
300
|
*/
|
|
202
301
|
function parseSdtProperties(sdtPr, sdtEndPr) {
|
|
203
302
|
const props = { sdtType: "richText" };
|
|
204
303
|
if (sdtPr) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
props.
|
|
244
|
-
|
|
245
|
-
|
|
304
|
+
/** Read a projection off a control-kind element, and keep the element. */
|
|
305
|
+
const kind = (read) => (element) => {
|
|
306
|
+
read(element);
|
|
307
|
+
return CAPTURE;
|
|
308
|
+
};
|
|
309
|
+
const preserved = dispatchChildren({
|
|
310
|
+
element: sdtPr,
|
|
311
|
+
container: "content-control-properties",
|
|
312
|
+
handlers: {
|
|
313
|
+
rPr: CAPTURE,
|
|
314
|
+
alias: (element) => {
|
|
315
|
+
const value = getAttributeAnyPrefix(element, "val");
|
|
316
|
+
if (value !== null) props.alias = value;
|
|
317
|
+
return keptUnless(value !== null);
|
|
318
|
+
},
|
|
319
|
+
tag: (element) => {
|
|
320
|
+
const value = getAttributeAnyPrefix(element, "val");
|
|
321
|
+
if (value !== null) props.tag = value;
|
|
322
|
+
return keptUnless(value !== null);
|
|
323
|
+
},
|
|
324
|
+
id: (element) => {
|
|
325
|
+
const raw = getAttributeAnyPrefix(element, "val");
|
|
326
|
+
const value = raw === null ? NaN : Number.parseInt(raw, 10);
|
|
327
|
+
if (!Number.isNaN(value)) props.id = value;
|
|
328
|
+
return keptUnless(!Number.isNaN(value));
|
|
329
|
+
},
|
|
330
|
+
lock: (element) => {
|
|
331
|
+
const value = narrowEnum(getAttributeAnyPrefix(element, "val"), SdtLockSchema);
|
|
332
|
+
if (value !== void 0) props.lock = value;
|
|
333
|
+
return keptUnless(value !== void 0);
|
|
334
|
+
},
|
|
335
|
+
placeholder: (element) => {
|
|
336
|
+
const value = getAttributeAnyPrefix(findChild(element, "w", "docPart"), "val");
|
|
337
|
+
if (value !== null) props.placeholder = value;
|
|
338
|
+
return keptUnless(value !== null);
|
|
339
|
+
},
|
|
340
|
+
temporary: CAPTURE,
|
|
341
|
+
showingPlcHdr: (element) => {
|
|
342
|
+
props.showingPlaceholder = parseBooleanElement(element, "w");
|
|
343
|
+
},
|
|
344
|
+
dataBinding: CAPTURE,
|
|
345
|
+
label: CAPTURE,
|
|
346
|
+
tabIndex: CAPTURE,
|
|
347
|
+
equation: kind(() => {}),
|
|
348
|
+
comboBox: kind((element) => {
|
|
349
|
+
props.sdtType = "comboBox";
|
|
350
|
+
props.listItems = parseListItems(element);
|
|
351
|
+
readLastValue(element, props);
|
|
352
|
+
}),
|
|
353
|
+
date: kind((element) => {
|
|
246
354
|
props.sdtType = "date";
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
if (fmt !== null) props.dateFormat = fmt;
|
|
251
|
-
}
|
|
252
|
-
const fullDate = getAttributeAnyPrefix(el, "fullDate");
|
|
355
|
+
const format = getAttributeAnyPrefix(findChild(element, "w", "dateFormat"), "val");
|
|
356
|
+
if (format !== null) props.dateFormat = format;
|
|
357
|
+
const fullDate = getAttributeAnyPrefix(element, "fullDate");
|
|
253
358
|
if (fullDate !== null) props.dateValueISO = fullDate;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
props.listItems = parseListItems(el);
|
|
260
|
-
const lastValue = getAttributeAnyPrefix(el, "lastValue");
|
|
261
|
-
if (lastValue !== null) props.dropdownLastValue = lastValue;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
case "checkbox": {
|
|
265
|
-
props.sdtType = "checkbox";
|
|
266
|
-
const checked14 = findChild(el, "w14", "checked");
|
|
267
|
-
const checkedW = findChild(el, "w", "checked");
|
|
268
|
-
if (checked14) props.checked = parseBooleanElement(checked14, "w14");
|
|
269
|
-
else if (checkedW) props.checked = parseBooleanElement(checkedW, "w");
|
|
270
|
-
else props.checked = false;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
case "picture":
|
|
274
|
-
props.sdtType = "picture";
|
|
275
|
-
break;
|
|
276
|
-
case "docPartObj":
|
|
277
|
-
case "docPartList":
|
|
359
|
+
}),
|
|
360
|
+
docPartObj: kind(() => {
|
|
361
|
+
props.sdtType = "buildingBlockGallery";
|
|
362
|
+
}),
|
|
363
|
+
docPartList: kind(() => {
|
|
278
364
|
props.sdtType = "buildingBlockGallery";
|
|
279
|
-
|
|
280
|
-
|
|
365
|
+
}),
|
|
366
|
+
dropDownList: kind((element) => {
|
|
367
|
+
props.sdtType = "dropdown";
|
|
368
|
+
props.listItems = parseListItems(element);
|
|
369
|
+
readLastValue(element, props);
|
|
370
|
+
}),
|
|
371
|
+
picture: kind(() => {
|
|
372
|
+
props.sdtType = "picture";
|
|
373
|
+
}),
|
|
374
|
+
richText: kind(() => {}),
|
|
375
|
+
text: kind(() => {
|
|
376
|
+
props.sdtType = "plainText";
|
|
377
|
+
}),
|
|
378
|
+
citation: kind(() => {}),
|
|
379
|
+
group: kind(() => {
|
|
281
380
|
props.sdtType = "group";
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
381
|
+
}),
|
|
382
|
+
bibliography: kind(() => {})
|
|
383
|
+
},
|
|
384
|
+
capturePosition: sequencePositions("content-control-properties", sdtPr),
|
|
385
|
+
undeclared: { [CHECKBOX_CHILD]: kind((element) => {
|
|
386
|
+
props.sdtType = "checkbox";
|
|
387
|
+
const state = findChild(element, "w14", "checked") ?? findChild(element, "w", "checked");
|
|
388
|
+
props.checked = state === null ? false : parseBooleanElement(state, "w14");
|
|
389
|
+
}) }
|
|
390
|
+
});
|
|
391
|
+
if (preserved !== void 0) props.preserved = preserved;
|
|
392
|
+
}
|
|
393
|
+
if (sdtEndPr) {
|
|
394
|
+
props.rawEndPropertiesXml = normalizeWordPrefix(captureVerbatimXml(sdtEndPr), sdtEndPr);
|
|
395
|
+
const runProperties = parseRunProperties(findChildByLocalName(sdtEndPr, "rPr"), null, RUN_PROPERTY_OWNERS.standalone);
|
|
396
|
+
props.endProperties = runProperties === void 0 ? {} : { runProperties };
|
|
286
397
|
}
|
|
287
|
-
if (sdtEndPr) props.rawEndPropertiesXml = normalizeWordPrefix(captureVerbatimXml(sdtEndPr), sdtEndPr);
|
|
288
398
|
return props;
|
|
289
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* The value a producer last chose, from the list element's `@w:lastValue`.
|
|
402
|
+
*
|
|
403
|
+
* `""` is a value a producer can author, so presence is the test rather than
|
|
404
|
+
* truthiness: "never selected", "cleared" and "selected" are three states and
|
|
405
|
+
* the body's display text is evidence for none of them.
|
|
406
|
+
*/
|
|
407
|
+
function readLastValue(element, props) {
|
|
408
|
+
const lastValue = getAttributeAnyPrefix(element, "lastValue");
|
|
409
|
+
if (lastValue !== null) props.dropdownLastValue = lastValue;
|
|
410
|
+
}
|
|
290
411
|
//#endregion
|
|
291
|
-
export { parseSdtProperties };
|
|
412
|
+
export { captureSdtSiblingMarkers, parseSdtProperties, preservedSdtChild, statesControlKind, withoutPreservedSdtChild };
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
//#region src/docx/sdtPropertiesPatch.d.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* properties (checked / dateFormat / fullDate / lastValue / showingPlcHdr)
|
|
6
|
-
* agree with the raw XML before it is replayed by the serializer.
|
|
4
|
+
* The control-kind element with the modelled interactive state written in.
|
|
7
5
|
*
|
|
8
|
-
* Pure: returns a new string; the input is not modified.
|
|
6
|
+
* Pure: returns a new string; the input is not modified. A kind the model
|
|
7
|
+
* states nothing interactive about comes back unchanged.
|
|
9
8
|
*/
|
|
10
|
-
declare
|
|
11
|
-
dateFullDate?: string;
|
|
12
|
-
dropdownLastValue?: string;
|
|
13
|
-
}): string;
|
|
9
|
+
declare const withModelledControlState: (xml: string, props: document_d_exports.SdtProperties) => string;
|
|
14
10
|
//#endregion
|
|
15
|
-
export {
|
|
11
|
+
export { withModelledControlState };
|
|
@@ -1,39 +1,32 @@
|
|
|
1
1
|
import { escapeXmlAttribute } from "@stll/docx-core";
|
|
2
2
|
//#region src/docx/sdtPropertiesPatch.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The modelled interactive state, written into the control-kind element.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* `w14:checked w14:val="0"` already encoded by the source DOCX stays
|
|
14
|
-
* in `rawPropertiesXml` and gets written back on save — Word reopens
|
|
15
|
-
* the document with the user's interactive change discarded.
|
|
6
|
+
* `w:date`, `w:dropDownList`, `w:comboBox` and `w14:checkbox` are kept as
|
|
7
|
+
* bytes: each carries children and attributes {@link SdtProperties} has no
|
|
8
|
+
* field for — a calendar and a locale, a gallery, the two checkbox glyphs —
|
|
9
|
+
* and rebuilding one from the model would drop them. But four of their values
|
|
10
|
+
* *are* modelled, because a user changes them: the checkbox state, the bound
|
|
11
|
+
* date, the display format and the chosen list value. The model wins for
|
|
12
|
+
* those four; the element keeps everything else.
|
|
16
13
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* model, rewrites the matching element in the raw string. Unmodeled
|
|
20
|
-
* markers are untouched, so dataBinding / repeatingSection round-trip
|
|
21
|
-
* stays lossless even after the user has mutated the control.
|
|
22
|
-
*
|
|
23
|
-
* Picked up from upstream eigenpal/docx-editor#661.
|
|
14
|
+
* This is the one place the two halves meet, and it runs inside the one
|
|
15
|
+
* `w:sdtPr` writer rather than beside it.
|
|
24
16
|
*/
|
|
25
17
|
/**
|
|
26
|
-
* Drop
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* scan
|
|
30
|
-
*
|
|
31
|
-
* binds the Word namespace under
|
|
32
|
-
*
|
|
33
|
-
*
|
|
18
|
+
* Drop one attribute by local name (any namespace prefix, or unprefixed) from
|
|
19
|
+
* an attribute-list string, leaving every other attribute alone.
|
|
20
|
+
*
|
|
21
|
+
* A scan rather than one greedy regex, which lint flags as backtracking-risky.
|
|
22
|
+
* Two things make the rest of the list worth keeping rather than rebuilding:
|
|
23
|
+
* a source that binds the Word namespace under `ns0` writes `ns0:lastValue`,
|
|
24
|
+
* and keeping it beside a freshly emitted one would leave the element with
|
|
25
|
+
* two; and a captured element carries the `xmlns:*` declarations that make it
|
|
26
|
+
* replayable on its own, which a rebuilt attribute list would throw away.
|
|
34
27
|
*/
|
|
35
|
-
function
|
|
36
|
-
const SUFFIX =
|
|
28
|
+
function withoutAttr(attrs, localName) {
|
|
29
|
+
const SUFFIX = `${localName}=`;
|
|
37
30
|
let out = attrs;
|
|
38
31
|
let searchFrom = 0;
|
|
39
32
|
while (searchFrom < out.length) {
|
|
@@ -46,13 +39,13 @@ function stripLastValueAttr(attrs) {
|
|
|
46
39
|
while (nameStart > 0 && /[A-Za-z0-9_-]/u.test(out[nameStart - 1] ?? "")) nameStart -= 1;
|
|
47
40
|
}
|
|
48
41
|
if (nameStart === 0 || !/\s/u.test(out[nameStart - 1] ?? "")) {
|
|
49
|
-
searchFrom = hitIdx +
|
|
42
|
+
searchFrom = hitIdx + SUFFIX.length;
|
|
50
43
|
continue;
|
|
51
44
|
}
|
|
52
|
-
const quoteIdx = hitIdx +
|
|
45
|
+
const quoteIdx = hitIdx + SUFFIX.length;
|
|
53
46
|
const quote = out[quoteIdx];
|
|
54
47
|
if (quote !== "\"" && quote !== "'") {
|
|
55
|
-
searchFrom = hitIdx +
|
|
48
|
+
searchFrom = hitIdx + SUFFIX.length;
|
|
56
49
|
continue;
|
|
57
50
|
}
|
|
58
51
|
const closeIdx = out.indexOf(quote, quoteIdx + 1);
|
|
@@ -62,89 +55,52 @@ function stripLastValueAttr(attrs) {
|
|
|
62
55
|
}
|
|
63
56
|
return out;
|
|
64
57
|
}
|
|
58
|
+
const withCheckedState = (xml, checked) => {
|
|
59
|
+
const val = checked ? "1" : "0";
|
|
60
|
+
const opened = /<(?<prefix>\w+):checked\b[^>]*>[\s\S]*?<\/\w+:checked>/giu;
|
|
61
|
+
if (/<\w+:checked\b[^>]*>[\s\S]*?<\/\w+:checked>/iu.test(xml)) return xml.replaceAll(opened, (_match, prefix) => `<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
62
|
+
if (/<\w+:checked\b[^>]*\/>/iu.test(xml)) return xml.replaceAll(/<(?<prefix>\w+):checked\b[^>]*\/>/giu, (_match, prefix) => `<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
63
|
+
return xml.replace(/<(?<prefix>\w+):checkbox\b[^>]*>/iu, (match, prefix) => `${match}<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
64
|
+
};
|
|
65
|
+
const withDateState = (xml, props) => {
|
|
66
|
+
const fullDate = props.dateValueISO;
|
|
67
|
+
const format = props.dateFormat;
|
|
68
|
+
if (fullDate === void 0 && format === void 0) return xml;
|
|
69
|
+
const attributes = (prefix, matched) => fullDate === void 0 ? matched : `${withoutAttr(matched, "fullDate")} ${prefix}:fullDate="${escapeXmlAttribute(fullDate)}"`;
|
|
70
|
+
const formatChild = (prefix) => format === void 0 ? "" : `<${prefix}:dateFormat ${prefix}:val="${escapeXmlAttribute(format)}"/>`;
|
|
71
|
+
const opened = /<(?<prefix>\w+):date\b(?<attrs>[^>]*)>(?<inner>[\s\S]*?)<\/\w+:date>/iu;
|
|
72
|
+
if (opened.test(xml)) return xml.replace(opened, (_match, prefix, matchedAttrs, inner) => {
|
|
73
|
+
const body = inner.replaceAll(/<\w+:dateFormat\b[^>]*(?:\/>|>[\s\S]*?<\/\w+:dateFormat>)/giu, "");
|
|
74
|
+
return `<${prefix}:date${attributes(prefix, matchedAttrs)}>${formatChild(prefix)}${body}</${prefix}:date>`;
|
|
75
|
+
});
|
|
76
|
+
return xml.replace(/<(?<prefix>\w+):date\b(?<attrs>[^/>]*)\/>/iu, (_match, prefix, matchedAttrs) => `<${prefix}:date${attributes(prefix, matchedAttrs)}>${formatChild(prefix)}</${prefix}:date>`);
|
|
77
|
+
};
|
|
78
|
+
const withLastValue = (xml, lastValue) => {
|
|
79
|
+
const escaped = escapeXmlAttribute(lastValue);
|
|
80
|
+
const opened = /<(?<prefix>\w+):(?<name>dropDownList|comboBox)\b(?<attrs>[^>]*)>(?<inner>[\s\S]*?)<\/\w+:(?:dropDownList|comboBox)>/iu;
|
|
81
|
+
if (opened.test(xml)) return xml.replace(opened, (_match, prefix, name, attrs, inner) => `<${prefix}:${name}${withoutAttr(attrs, "lastValue")} ${prefix}:lastValue="${escaped}">${inner}</${prefix}:${name}>`);
|
|
82
|
+
return xml.replace(/<(?<prefix>\w+):(?<name>dropDownList|comboBox)\b(?<attrs>[^/>]*)\/>/iu, (_match, prefix, name, attrs) => `<${prefix}:${name}${withoutAttr(attrs, "lastValue")} ${prefix}:lastValue="${escaped}"/>`);
|
|
83
|
+
};
|
|
65
84
|
/**
|
|
66
|
-
*
|
|
85
|
+
* The control-kind element with the modelled interactive state written in.
|
|
67
86
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* from the caller).
|
|
71
|
-
* - Otherwise `replacement` is injected just before `</w:sdtPr>` so the
|
|
72
|
-
* element ends up as a child of sdtPr, not after it.
|
|
87
|
+
* Pure: returns a new string; the input is not modified. A kind the model
|
|
88
|
+
* states nothing interactive about comes back unchanged.
|
|
73
89
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (selfClosingPr.test(raw)) return raw.replace(selfClosingPr, (_match, prefix, attrs) => `<${prefix}:sdtPr${attrs}>${replacement}</${prefix}:sdtPr>`);
|
|
88
|
-
return raw;
|
|
89
|
-
}
|
|
90
|
-
function setOrRemove(raw, localName, replacementWhenSet) {
|
|
91
|
-
if (replacementWhenSet === null) {
|
|
92
|
-
const escaped = localName.replaceAll(/[$()*+./?[\\\]^{|}]/gu, "\\$&");
|
|
93
|
-
const selfClosing = new RegExp(`<\\w+:${escaped}\\b[^>]*\\/>`, "igu");
|
|
94
|
-
const opened = new RegExp(`<\\w+:${escaped}\\b[^>]*>[\\s\\S]*?<\\/\\w+:${escaped}>`, "igu");
|
|
95
|
-
return raw.replaceAll(selfClosing, "").replaceAll(opened, "");
|
|
90
|
+
const withModelledControlState = (xml, props) => {
|
|
91
|
+
switch (props.sdtType) {
|
|
92
|
+
case "checkbox": return typeof props.checked === "boolean" ? withCheckedState(xml, props.checked) : xml;
|
|
93
|
+
case "date": return withDateState(xml, props);
|
|
94
|
+
case "dropdown":
|
|
95
|
+
case "comboBox": return props.dropdownLastValue === void 0 ? xml : withLastValue(xml, props.dropdownLastValue);
|
|
96
|
+
case "richText":
|
|
97
|
+
case "plainText":
|
|
98
|
+
case "picture":
|
|
99
|
+
case "buildingBlockGallery":
|
|
100
|
+
case "group":
|
|
101
|
+
case "unknown": return xml;
|
|
102
|
+
default: return props.sdtType;
|
|
96
103
|
}
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Rewrite the relevant child elements of `<w:sdtPr>` so the modeled
|
|
101
|
-
* properties (checked / dateFormat / fullDate / lastValue / showingPlcHdr)
|
|
102
|
-
* agree with the raw XML before it is replayed by the serializer.
|
|
103
|
-
*
|
|
104
|
-
* Pure: returns a new string; the input is not modified.
|
|
105
|
-
*/
|
|
106
|
-
function reconcileRawSdtPr(raw, props, options = {}) {
|
|
107
|
-
let next = raw;
|
|
108
|
-
if (props.showingPlaceholder === true) next = setOrRemove(next, "showingPlcHdr", "<w:showingPlcHdr/>");
|
|
109
|
-
else if (props.showingPlaceholder === false) next = setOrRemove(next, "showingPlcHdr", null);
|
|
110
|
-
if (props.sdtType === "checkbox" && typeof props.checked === "boolean") {
|
|
111
|
-
const val = props.checked ? "1" : "0";
|
|
112
|
-
const checkedOpened = /<(?:\w+):checked\b[^>]*>[\s\S]*?<\/\w+:checked>/iu;
|
|
113
|
-
const checkedSelfClosing = /<(?:\w+):checked\b[^>]*\/>/iu;
|
|
114
|
-
if (checkedOpened.test(next)) next = next.replaceAll(/<(?<prefix>\w+):checked\b[^>]*>[\s\S]*?<\/\w+:checked>/giu, (_match, prefix) => `<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
115
|
-
else if (checkedSelfClosing.test(next)) next = next.replaceAll(/<(?<prefix>\w+):checked\b[^>]*\/>/giu, (_match, prefix) => `<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
116
|
-
else if (/<\w+:checkbox\b[^>]*>/iu.test(next)) next = next.replace(/<(?<prefix>\w+):checkbox\b[^>]*>/iu, (match, prefix) => `${match}<${prefix}:checked ${prefix}:val="${val}"/>`);
|
|
117
|
-
else next = upsertSdtPrChild(next, "checkbox", `<w14:checkbox><w14:checked w14:val="${val}"/></w14:checkbox>`);
|
|
118
|
-
}
|
|
119
|
-
if (props.sdtType === "date") {
|
|
120
|
-
const fullDate = options.dateFullDate;
|
|
121
|
-
const dateFormat = props.dateFormat;
|
|
122
|
-
if (fullDate !== void 0 || dateFormat !== void 0) {
|
|
123
|
-
const wDate = /<(?<prefix>\w+):date\b(?<attrs>[^>]*)>(?<inner>[\s\S]*?)<\/\w+:date>/iu;
|
|
124
|
-
const wDateSelf = /<(?<prefix>\w+):date\b(?<attrs>[^/>]*)\/>/iu;
|
|
125
|
-
const fullDateAttr = fullDate !== void 0 ? ` w:fullDate="${escapeXmlAttribute(fullDate)}"` : "";
|
|
126
|
-
const formatChild = dateFormat !== void 0 ? `<w:dateFormat w:val="${escapeXmlAttribute(dateFormat)}"/>` : "";
|
|
127
|
-
if (wDate.test(next)) next = next.replace(wDate, (_match, prefix, matchedAttrs, inner) => {
|
|
128
|
-
let body = inner.replaceAll(/<\w+:dateFormat\b[^>]*(?:\/>|>[\s\S]*?<\/\w+:dateFormat>)/giu, "");
|
|
129
|
-
if (formatChild) body = `${formatChild}${body}`;
|
|
130
|
-
return `<${prefix}:date${fullDate !== void 0 ? fullDateAttr : matchedAttrs}>${body}</${prefix}:date>`;
|
|
131
|
-
});
|
|
132
|
-
else if (wDateSelf.test(next)) next = next.replace(wDateSelf, (_match, prefix) => `<${prefix}:date${fullDateAttr}>${formatChild}</${prefix}:date>`);
|
|
133
|
-
else next = upsertSdtPrChild(next, "date", `<w:date${fullDateAttr}>${formatChild}</w:date>`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if ((props.sdtType === "dropdown" || props.sdtType === "comboBox") && options.dropdownLastValue !== void 0) {
|
|
137
|
-
const escapedValue = escapeXmlAttribute(options.dropdownLastValue);
|
|
138
|
-
const opened = /<(?<prefix>\w+):(?<name>dropDownList|comboBox)\b(?<attrs>[^>]*)>(?<inner>[\s\S]*?)<\/\w+:(?:dropDownList|comboBox)>/iu;
|
|
139
|
-
const selfClosing = /<(?<prefix>\w+):(?<name>dropDownList|comboBox)\b(?<attrs>[^/>]*)\/>/iu;
|
|
140
|
-
if (opened.test(next)) next = next.replace(opened, (_match, prefix, name, attrs, inner) => {
|
|
141
|
-
return `<${prefix}:${name}${stripLastValueAttr(attrs)} ${prefix}:lastValue="${escapedValue}">${inner}</${prefix}:${name}>`;
|
|
142
|
-
});
|
|
143
|
-
else if (selfClosing.test(next)) next = next.replace(selfClosing, (_match, prefix, name, attrs) => {
|
|
144
|
-
return `<${prefix}:${name}${stripLastValueAttr(attrs)} ${prefix}:lastValue="${escapedValue}"/>`;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return next;
|
|
148
|
-
}
|
|
104
|
+
};
|
|
149
105
|
//#endregion
|
|
150
|
-
export {
|
|
106
|
+
export { withModelledControlState };
|
|
@@ -2,7 +2,6 @@ import { document_d_exports } from "../types/document.js";
|
|
|
2
2
|
import { ParseContext } from "./parseContext.js";
|
|
3
3
|
import { XmlElement } from "./xmlParser.js";
|
|
4
4
|
//#region src/docx/sectionParser.d.ts
|
|
5
|
-
declare function getUnserializedSectionPropertyChildNames(props: document_d_exports.SectionProperties): readonly string[] | undefined;
|
|
6
5
|
/**
|
|
7
6
|
* Parse section properties (w:sectPr)
|
|
8
7
|
*
|
|
@@ -92,4 +91,4 @@ declare function getDefaultSectionProperties(): document_d_exports.SectionProper
|
|
|
92
91
|
*/
|
|
93
92
|
declare function mergeSectionProperties(base: document_d_exports.SectionProperties, override: document_d_exports.SectionProperties): document_d_exports.SectionProperties;
|
|
94
93
|
//#endregion
|
|
95
|
-
export { getColumnCount, getContentHeightPixels, getContentWidthPixels, getDefaultSectionProperties, getMarginsPixels, getPageHeightPixels, getPageWidthPixels,
|
|
94
|
+
export { getColumnCount, getContentHeightPixels, getContentWidthPixels, getDefaultSectionProperties, getMarginsPixels, getPageHeightPixels, getPageWidthPixels, hasDifferentFirstPage, hasDifferentOddEven, hasLineNumbers, hasPageBorders, isLandscape, mergeSectionProperties, parseSectionProperties };
|