@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
package/dist/docx/runParser.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { parseHorizontalScalePercent } from "../utils/horizontalScale.js";
|
|
2
|
+
import { NO_MODELLED_ATTRIBUTES, attributeRemainder } from "./attributeRemainder.js";
|
|
3
|
+
import { CAPTURE, dispatchChildren, keptUnless, ownedElsewhere, sequencePositions } from "./containerChildren.js";
|
|
2
4
|
import { parseDiagramPreview } from "./diagramPreview.js";
|
|
5
|
+
import { parseFieldState } from "./fieldState.js";
|
|
3
6
|
import { isGroupDrawing, parseGroupDrawing } from "./groupDrawingParser.js";
|
|
4
7
|
import { parseImage } from "./imageParser.js";
|
|
5
8
|
import { imageRawXmlFingerprint } from "./imageRawXml.js";
|
|
6
|
-
import { EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, PositionalTabAlignmentSchema, PositionalTabLeaderSchema, PositionalTabRelativeToSchema, TextEffectSchema,
|
|
9
|
+
import { EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, PositionalTabAlignmentSchema, PositionalTabLeaderSchema, PositionalTabRelativeToSchema, TextEffectSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
10
|
+
import { preserveRunChild } from "./preservedRunContent.js";
|
|
7
11
|
import { parseShading } from "./shadingParser.js";
|
|
8
12
|
import { parseShapeFromDrawing, shouldPreserveRawShapeDrawing } from "./shapeParser.js";
|
|
9
13
|
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
14
|
+
import { parseThemeColorAttribute } from "./themeColorAttribute.js";
|
|
10
15
|
import { resolveThemeFontRef } from "./themeParser.js";
|
|
11
16
|
import { parsePropertyChangeInfo } from "./trackedChangeInfo.js";
|
|
12
17
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
13
18
|
import { parseVmlImageContent, shouldPreserveRawVmlPict } from "./vmlImageParser.js";
|
|
14
|
-
import { cloneWithXmlnsDeclarations, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getLocalName, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute,
|
|
19
|
+
import { WORDPROCESSINGML_NAMESPACE_URIS, cloneWithXmlnsDeclarations, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getLocalName, getNamespaceUri, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, selectAlternateContentBranch } from "./xmlParser.js";
|
|
15
20
|
import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
|
|
16
21
|
//#region src/docx/runParser.ts
|
|
17
22
|
/**
|
|
@@ -22,124 +27,113 @@ import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
|
|
|
22
27
|
*/
|
|
23
28
|
const MAX_LANGUAGE_TAG_LENGTH = 35;
|
|
24
29
|
const truncateLanguageTag = (value) => value === void 0 ? void 0 : value.slice(0, MAX_LANGUAGE_TAG_LENGTH);
|
|
25
|
-
|
|
26
|
-
* Parse color value from attributes
|
|
27
|
-
*/
|
|
28
|
-
function parseColorValue(rgb, themeColor, themeTint, themeShade) {
|
|
30
|
+
function parseColorValue({ rgb, themeColor, themeTint, themeShade, element }) {
|
|
29
31
|
const color = {};
|
|
30
32
|
if (rgb && rgb !== "auto") color.rgb = rgb;
|
|
31
33
|
else if (rgb === "auto") color.auto = true;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
+
const parsedThemeColor = parseThemeColorAttribute({
|
|
35
|
+
raw: themeColor,
|
|
36
|
+
element
|
|
37
|
+
});
|
|
38
|
+
if (parsedThemeColor !== void 0) color.themeColor = parsedThemeColor;
|
|
34
39
|
if (themeTint) color.themeTint = themeTint;
|
|
35
40
|
if (themeShade) color.themeShade = themeShade;
|
|
36
41
|
return color;
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
break;
|
|
130
|
-
case "vanish":
|
|
131
|
-
children.vanish ??= child;
|
|
132
|
-
break;
|
|
133
|
-
case "vertAlign":
|
|
134
|
-
children.vertAlign ??= child;
|
|
135
|
-
break;
|
|
136
|
-
case "w":
|
|
137
|
-
children.w ??= child;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
43
|
+
/**
|
|
44
|
+
* Which record beside this `w:rPr` reads children out of it.
|
|
45
|
+
*
|
|
46
|
+
* The four owners of a run property set share one handler map, because they
|
|
47
|
+
* share one content model: `CT_RPr` is `EG_RPrBase` plus `w:rPrChange`, and
|
|
48
|
+
* `CT_ParaRPr` opens that with `EG_ParaRPrTrackChanges`. They differ only in
|
|
49
|
+
* which children a *sibling* record has already claimed, and a child claimed
|
|
50
|
+
* twice is written twice. Naming the owner states that once, at the call site
|
|
51
|
+
* that knows it, instead of leaving it to whichever reader ran first.
|
|
52
|
+
*/
|
|
53
|
+
const RUN_PROPERTY_OWNERS = {
|
|
54
|
+
/** A `w:r`'s own properties: `Run.propertyChanges` reads the `w:rPrChange`. */
|
|
55
|
+
run: "run",
|
|
56
|
+
/**
|
|
57
|
+
* `w:pPr/w:rPr`. The paragraph's record reads the mark's revision
|
|
58
|
+
* (`ParagraphMarkChange`) and its `w:specVanish`
|
|
59
|
+
* (`ParagraphFormatting.runInWithNext`).
|
|
60
|
+
*/
|
|
61
|
+
paragraphMark: "paragraphMark",
|
|
62
|
+
/**
|
|
63
|
+
* A style, a numbering level, a comment's reference mark, the snapshot
|
|
64
|
+
* inside a `w:rPrChange`: nothing beside it reads any of its children.
|
|
65
|
+
*/
|
|
66
|
+
standalone: "standalone"
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The children each owner's sibling record claims.
|
|
70
|
+
*
|
|
71
|
+
* Not the decision map: that one is total over the schema and lives in
|
|
72
|
+
* {@link parseRunProperties}. This names only the children a given owner reads
|
|
73
|
+
* somewhere else, so both cannot write the same element.
|
|
74
|
+
*/
|
|
75
|
+
const OWNED_BY_A_SIBLING_RECORD = {
|
|
76
|
+
run: { rPrChange: ownedElsewhere({
|
|
77
|
+
container: "run-properties",
|
|
78
|
+
child: "rPrChange",
|
|
79
|
+
reader: "runParser#parseRun"
|
|
80
|
+
}) },
|
|
81
|
+
paragraphMark: {
|
|
82
|
+
ins: ownedElsewhere({
|
|
83
|
+
container: "run-properties",
|
|
84
|
+
child: "ins",
|
|
85
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
86
|
+
}),
|
|
87
|
+
del: ownedElsewhere({
|
|
88
|
+
container: "run-properties",
|
|
89
|
+
child: "del",
|
|
90
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
91
|
+
}),
|
|
92
|
+
moveFrom: ownedElsewhere({
|
|
93
|
+
container: "run-properties",
|
|
94
|
+
child: "moveFrom",
|
|
95
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
96
|
+
}),
|
|
97
|
+
moveTo: ownedElsewhere({
|
|
98
|
+
container: "run-properties",
|
|
99
|
+
child: "moveTo",
|
|
100
|
+
reader: "paragraphProperties#parseParagraphProperties"
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
standalone: {}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* A property stated twice in one `w:rPr` resolves to the last statement.
|
|
107
|
+
*
|
|
108
|
+
* `EG_RPrBase` is an `xsd:choice` referenced `maxOccurs="unbounded"`, so a
|
|
109
|
+
* repeat is valid markup rather than a malformed file with no defined answer,
|
|
110
|
+
* and producers write them: 44 of the 5299 packages in the public corpus hold
|
|
111
|
+
* one, almost all from LibreOffice, and `w:b`, `w:i` and `w:sz` are the names
|
|
112
|
+
* that repeat. 3131 of the 3132 repeats state the same value twice and settle
|
|
113
|
+
* nothing; the one that disagrees is `<w:sz w:val="24"/><w:sz w:val="26"/>` on
|
|
114
|
+
* an Arabic run whose `w:szCs` is 26, so the size that was meant is the later
|
|
115
|
+
* one. That is also the rule folio's style parser already applied, and the two
|
|
116
|
+
* readers now answer alike.
|
|
117
|
+
*
|
|
118
|
+
* The statements the last one beat are not kept. The writer puts a modelled
|
|
119
|
+
* child at its own place in the canonical order, so a kept earlier occurrence
|
|
120
|
+
* would come back *after* the value that beat it and invert what a consumer
|
|
121
|
+
* resolves. Dropping it also settles the ambiguity for everyone downstream:
|
|
122
|
+
* the saved element states the property once, and a reader that takes the
|
|
123
|
+
* first and a reader that takes the last then read the same value.
|
|
124
|
+
*
|
|
125
|
+
* The name comes off the child rather than from the map key, so the guard
|
|
126
|
+
* cannot name a property the handler does not read.
|
|
127
|
+
*/
|
|
128
|
+
const readLastOccurrenceOnly = (rPr) => {
|
|
129
|
+
const winner = /* @__PURE__ */ new Map();
|
|
130
|
+
for (const child of getChildElements(rPr)) {
|
|
131
|
+
const namespace = getNamespaceUri(child);
|
|
132
|
+
if (namespace !== void 0 && !WORDPROCESSINGML_NAMESPACE_URIS.has(namespace)) continue;
|
|
133
|
+
winner.set(getLocalName(child.name), child);
|
|
140
134
|
}
|
|
141
|
-
return
|
|
142
|
-
}
|
|
135
|
+
return (read) => (child) => winner.get(getLocalName(child.name)) === child ? read(child) : void 0;
|
|
136
|
+
};
|
|
143
137
|
/**
|
|
144
138
|
* `w:vertAlign` `baseline` is the reserved value that means "no vertical
|
|
145
139
|
* offset", not a third offset beside `superscript` and `subscript`. It is
|
|
@@ -148,191 +142,283 @@ function collectFirstRunPropertyChildren(rPr) {
|
|
|
148
142
|
*/
|
|
149
143
|
const isBaselineVertAlign = (vertAlign) => vertAlign === "baseline";
|
|
150
144
|
/**
|
|
151
|
-
*
|
|
145
|
+
* Read `w:rFonts` into `fontFamily`, resolving each theme slot to the font the
|
|
146
|
+
* theme names when the element did not spell one out.
|
|
152
147
|
*
|
|
153
|
-
*
|
|
154
|
-
* - w:b (bold), w:i (italic), w:u (underline with style)
|
|
155
|
-
* - w:strike (strikethrough), w:dstrike (double strike)
|
|
156
|
-
* - w:vertAlign (superscript/subscript)
|
|
157
|
-
* - w:smallCaps, w:caps (capitalization)
|
|
158
|
-
* - w:highlight (text highlight color)
|
|
159
|
-
* - w:shd (character shading)
|
|
160
|
-
* - w:color (text color with theme resolution)
|
|
161
|
-
* - w:sz (font size in half-points)
|
|
162
|
-
* - w:rFonts (font family with theme resolution)
|
|
163
|
-
* - w:spacing (character spacing)
|
|
164
|
-
* - w:effect (text effects)
|
|
165
|
-
* - And more...
|
|
148
|
+
* @returns whether the element stated any font at all.
|
|
166
149
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const themeColor = getAttribute(u, "w", "themeColor");
|
|
186
|
-
if (colorVal || themeColor) formatting.underline.color = parseColorValue(colorVal, themeColor, getAttribute(u, "w", "themeTint"), getAttribute(u, "w", "themeShade"));
|
|
150
|
+
const readFontFamily = (rFonts, theme, formatting) => {
|
|
151
|
+
const fontFamily = {};
|
|
152
|
+
const ascii = getAttribute(rFonts, "w", "ascii");
|
|
153
|
+
if (ascii) fontFamily.ascii = ascii;
|
|
154
|
+
const hAnsi = getAttribute(rFonts, "w", "hAnsi");
|
|
155
|
+
if (hAnsi) fontFamily.hAnsi = hAnsi;
|
|
156
|
+
const eastAsia = getAttribute(rFonts, "w", "eastAsia");
|
|
157
|
+
if (eastAsia) fontFamily.eastAsia = eastAsia;
|
|
158
|
+
const csFont = getAttribute(rFonts, "w", "cs");
|
|
159
|
+
if (csFont) fontFamily.cs = csFont;
|
|
160
|
+
const hint = narrowEnum(getAttribute(rFonts, "w", "hint"), FontHintSchema);
|
|
161
|
+
if (hint) fontFamily.hint = hint;
|
|
162
|
+
const asciiTheme = narrowEnum(getAttribute(rFonts, "w", "asciiTheme"), FontThemeSchema);
|
|
163
|
+
if (asciiTheme) {
|
|
164
|
+
fontFamily.asciiTheme = asciiTheme;
|
|
165
|
+
if (theme && !fontFamily.ascii) {
|
|
166
|
+
const resolved = resolveThemeFontRef(theme, asciiTheme);
|
|
167
|
+
if (resolved) fontFamily.ascii = resolved;
|
|
187
168
|
}
|
|
188
169
|
}
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const val = getAttribute(vertAlign, "w", "val");
|
|
196
|
-
if (val === "superscript" || val === "subscript" || val === "baseline") formatting.vertAlign = val;
|
|
197
|
-
}
|
|
198
|
-
const smallCaps = propertyChildren.smallCaps;
|
|
199
|
-
if (smallCaps) formatting.smallCaps = parseBooleanElement(smallCaps);
|
|
200
|
-
const caps = propertyChildren.caps;
|
|
201
|
-
if (caps) formatting.allCaps = parseBooleanElement(caps);
|
|
202
|
-
const vanish = propertyChildren.vanish;
|
|
203
|
-
if (vanish) formatting.hidden = parseBooleanElement(vanish);
|
|
204
|
-
const noProof = propertyChildren.noProof;
|
|
205
|
-
if (noProof) formatting.noProof = parseBooleanElement(noProof);
|
|
206
|
-
const color = propertyChildren.color;
|
|
207
|
-
if (color) formatting.color = parseColorValue(getAttribute(color, "w", "val"), getAttribute(color, "w", "themeColor"), getAttribute(color, "w", "themeTint"), getAttribute(color, "w", "themeShade"));
|
|
208
|
-
const highlight = propertyChildren.highlight;
|
|
209
|
-
if (highlight) {
|
|
210
|
-
const val = narrowEnum(getAttribute(highlight, "w", "val"), HighlightColorSchema);
|
|
211
|
-
if (val) formatting.highlight = val;
|
|
212
|
-
}
|
|
213
|
-
const shd = propertyChildren.shd;
|
|
214
|
-
if (shd) {
|
|
215
|
-
const shadingResult = parseShading(shd);
|
|
216
|
-
if (shadingResult) formatting.shading = shadingResult;
|
|
217
|
-
}
|
|
218
|
-
const sz = propertyChildren.sz;
|
|
219
|
-
if (sz) {
|
|
220
|
-
const val = parseNumericAttribute(sz, "w", "val");
|
|
221
|
-
if (val !== void 0) formatting.fontSize = val;
|
|
222
|
-
}
|
|
223
|
-
const szCs = propertyChildren.szCs;
|
|
224
|
-
if (szCs) {
|
|
225
|
-
const val = parseNumericAttribute(szCs, "w", "val");
|
|
226
|
-
if (val !== void 0) formatting.fontSizeCs = val;
|
|
227
|
-
}
|
|
228
|
-
const rFonts = propertyChildren.rFonts;
|
|
229
|
-
if (rFonts) {
|
|
230
|
-
const fontFamily = {};
|
|
231
|
-
const ascii = getAttribute(rFonts, "w", "ascii");
|
|
232
|
-
if (ascii) fontFamily.ascii = ascii;
|
|
233
|
-
const hAnsi = getAttribute(rFonts, "w", "hAnsi");
|
|
234
|
-
if (hAnsi) fontFamily.hAnsi = hAnsi;
|
|
235
|
-
const eastAsia = getAttribute(rFonts, "w", "eastAsia");
|
|
236
|
-
if (eastAsia) fontFamily.eastAsia = eastAsia;
|
|
237
|
-
const csFont = getAttribute(rFonts, "w", "cs");
|
|
238
|
-
if (csFont) fontFamily.cs = csFont;
|
|
239
|
-
const hint = narrowEnum(getAttribute(rFonts, "w", "hint"), FontHintSchema);
|
|
240
|
-
if (hint) fontFamily.hint = hint;
|
|
241
|
-
const asciiTheme = narrowEnum(getAttribute(rFonts, "w", "asciiTheme"), FontThemeSchema);
|
|
242
|
-
if (asciiTheme) {
|
|
243
|
-
fontFamily.asciiTheme = asciiTheme;
|
|
244
|
-
if (theme && !fontFamily.ascii) {
|
|
245
|
-
const resolved = resolveThemeFontRef(theme, asciiTheme);
|
|
246
|
-
if (resolved) fontFamily.ascii = resolved;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const hAnsiTheme = narrowEnum(getAttribute(rFonts, "w", "hAnsiTheme"), FontThemeSchema);
|
|
250
|
-
if (hAnsiTheme) {
|
|
251
|
-
fontFamily.hAnsiTheme = hAnsiTheme;
|
|
252
|
-
if (theme && !fontFamily.hAnsi) {
|
|
253
|
-
const resolved = resolveThemeFontRef(theme, hAnsiTheme);
|
|
254
|
-
if (resolved) fontFamily.hAnsi = resolved;
|
|
255
|
-
}
|
|
170
|
+
const hAnsiTheme = narrowEnum(getAttribute(rFonts, "w", "hAnsiTheme"), FontThemeSchema);
|
|
171
|
+
if (hAnsiTheme) {
|
|
172
|
+
fontFamily.hAnsiTheme = hAnsiTheme;
|
|
173
|
+
if (theme && !fontFamily.hAnsi) {
|
|
174
|
+
const resolved = resolveThemeFontRef(theme, hAnsiTheme);
|
|
175
|
+
if (resolved) fontFamily.hAnsi = resolved;
|
|
256
176
|
}
|
|
257
|
-
const eastAsiaTheme = narrowEnum(getAttribute(rFonts, "w", "eastAsiaTheme"), FontThemeSchema);
|
|
258
|
-
if (eastAsiaTheme) {
|
|
259
|
-
fontFamily.eastAsiaTheme = eastAsiaTheme;
|
|
260
|
-
if (theme && !fontFamily.eastAsia) {
|
|
261
|
-
const resolved = resolveThemeFontRef(theme, eastAsiaTheme);
|
|
262
|
-
if (resolved) fontFamily.eastAsia = resolved;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
const csTheme = narrowEnum(getAttribute(rFonts, "w", "cstheme"), FontThemeSchema);
|
|
266
|
-
if (csTheme) {
|
|
267
|
-
fontFamily.csTheme = csTheme;
|
|
268
|
-
if (theme && !fontFamily.cs) {
|
|
269
|
-
const resolved = resolveThemeFontRef(theme, csTheme);
|
|
270
|
-
if (resolved) fontFamily.cs = resolved;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
formatting.fontFamily = fontFamily;
|
|
274
177
|
}
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
...eastAsia ? { eastAsia } : {},
|
|
283
|
-
...bidi ? { bidi } : {}
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
const spacing = propertyChildren.spacing;
|
|
287
|
-
if (spacing) {
|
|
288
|
-
const val = parseNumericAttribute(spacing, "w", "val");
|
|
289
|
-
if (val !== void 0) formatting.spacing = val;
|
|
290
|
-
}
|
|
291
|
-
const position = propertyChildren.position;
|
|
292
|
-
if (position) {
|
|
293
|
-
const val = parseNumericAttribute(position, "w", "val");
|
|
294
|
-
if (val !== void 0) formatting.position = val;
|
|
295
|
-
}
|
|
296
|
-
const w = propertyChildren.w;
|
|
297
|
-
if (w) {
|
|
298
|
-
const val = parseHorizontalScalePercent(getAttribute(w, "w", "val"));
|
|
299
|
-
if (val !== void 0) formatting.scale = val;
|
|
300
|
-
}
|
|
301
|
-
const kern = propertyChildren.kern;
|
|
302
|
-
if (kern) {
|
|
303
|
-
const val = parseNumericAttribute(kern, "w", "val");
|
|
304
|
-
if (val !== void 0) formatting.kerning = val;
|
|
305
|
-
}
|
|
306
|
-
const effect = propertyChildren.effect;
|
|
307
|
-
if (effect) {
|
|
308
|
-
const val = narrowEnum(getAttribute(effect, "w", "val"), TextEffectSchema);
|
|
309
|
-
if (val) formatting.effect = val;
|
|
310
|
-
}
|
|
311
|
-
const em = propertyChildren.em;
|
|
312
|
-
if (em) {
|
|
313
|
-
const val = narrowEnum(getAttribute(em, "w", "val"), EmphasisMarkSchema);
|
|
314
|
-
if (val) formatting.emphasisMark = val;
|
|
178
|
+
const eastAsiaTheme = narrowEnum(getAttribute(rFonts, "w", "eastAsiaTheme"), FontThemeSchema);
|
|
179
|
+
if (eastAsiaTheme) {
|
|
180
|
+
fontFamily.eastAsiaTheme = eastAsiaTheme;
|
|
181
|
+
if (theme && !fontFamily.eastAsia) {
|
|
182
|
+
const resolved = resolveThemeFontRef(theme, eastAsiaTheme);
|
|
183
|
+
if (resolved) fontFamily.eastAsia = resolved;
|
|
184
|
+
}
|
|
315
185
|
}
|
|
316
|
-
const
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (shadow) formatting.shadow = parseBooleanElement(shadow);
|
|
324
|
-
const rtl = propertyChildren.rtl;
|
|
325
|
-
if (rtl) formatting.rtl = parseBooleanElement(rtl);
|
|
326
|
-
const cs = propertyChildren.cs;
|
|
327
|
-
if (cs) formatting.cs = parseBooleanElement(cs);
|
|
328
|
-
const rStyle = propertyChildren.rStyle;
|
|
329
|
-
if (rStyle) {
|
|
330
|
-
const val = getAttribute(rStyle, "w", "val");
|
|
331
|
-
if (val) formatting.styleId = val;
|
|
186
|
+
const csTheme = narrowEnum(getAttribute(rFonts, "w", "cstheme"), FontThemeSchema);
|
|
187
|
+
if (csTheme) {
|
|
188
|
+
fontFamily.csTheme = csTheme;
|
|
189
|
+
if (theme && !fontFamily.cs) {
|
|
190
|
+
const resolved = resolveThemeFontRef(theme, csTheme);
|
|
191
|
+
if (resolved) fontFamily.cs = resolved;
|
|
192
|
+
}
|
|
332
193
|
}
|
|
333
|
-
|
|
194
|
+
if (Object.keys(fontFamily).length === 0) return false;
|
|
195
|
+
formatting.fontFamily = fontFamily;
|
|
196
|
+
return true;
|
|
197
|
+
};
|
|
198
|
+
/** @returns whether `w:u` named an underline style the model admits. */
|
|
199
|
+
const readUnderline = (u, formatting) => {
|
|
200
|
+
const style = narrowEnum(getAttribute(u, "w", "val"), UnderlineStyleSchema);
|
|
201
|
+
if (!style) return false;
|
|
202
|
+
formatting.underline = { style };
|
|
203
|
+
const colorVal = getAttribute(u, "w", "color");
|
|
204
|
+
const themeColor = getAttribute(u, "w", "themeColor");
|
|
205
|
+
if (colorVal || themeColor) formatting.underline.color = parseColorValue({
|
|
206
|
+
rgb: colorVal,
|
|
207
|
+
themeColor,
|
|
208
|
+
themeTint: getAttribute(u, "w", "themeTint"),
|
|
209
|
+
themeShade: getAttribute(u, "w", "themeShade"),
|
|
210
|
+
element: u.name ?? "w:u"
|
|
211
|
+
});
|
|
212
|
+
return true;
|
|
213
|
+
};
|
|
214
|
+
/** @returns whether `w:lang` named a tag for any of the three scripts. */
|
|
215
|
+
const readLanguage = (lang, formatting) => {
|
|
216
|
+
const val = truncateLanguageTag(getAttribute(lang, "w", "val") || void 0);
|
|
217
|
+
const eastAsia = truncateLanguageTag(getAttribute(lang, "w", "eastAsia") || void 0);
|
|
218
|
+
const bidi = truncateLanguageTag(getAttribute(lang, "w", "bidi") || void 0);
|
|
219
|
+
if (!val && !eastAsia && !bidi) return false;
|
|
220
|
+
formatting.language = {
|
|
221
|
+
...val ? { val } : {},
|
|
222
|
+
...eastAsia ? { eastAsia } : {},
|
|
223
|
+
...bidi ? { bidi } : {}
|
|
224
|
+
};
|
|
225
|
+
return true;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* The one reader of a run property set (`w:rPr`).
|
|
229
|
+
*
|
|
230
|
+
* Every owner reads through here — a run, the paragraph mark, a style, a
|
|
231
|
+
* numbering level, a comment's reference mark and the snapshot inside either
|
|
232
|
+
* kind of `w:rPrChange` — so none of them can grow its own idea of which
|
|
233
|
+
* children exist, which values it admits, or which of two statements of one
|
|
234
|
+
* property wins. The style parser used to keep a copy of this function, and
|
|
235
|
+
* the copies had drifted on all three.
|
|
236
|
+
*
|
|
237
|
+
* Every child the content model declares carries a decision: a handler that
|
|
238
|
+
* reads it into {@link TextFormatting}, `ownedElsewhere` when the owner's
|
|
239
|
+
* sibling record reads it, or `CAPTURE` for markup folio models nothing for.
|
|
240
|
+
* A handler that looked and took nothing answers `CAPTURE` as well — `<w:sz/>`
|
|
241
|
+
* states no size and `<w:highlight w:val="chartreuse"/>` states a value the
|
|
242
|
+
* reader's enumeration does not admit, and neither can be decided by the
|
|
243
|
+
* child's name. What no reader took goes to `TextFormatting.preserved` at its
|
|
244
|
+
* schema ordinal, so a rebuild puts it back between the same two siblings.
|
|
245
|
+
*
|
|
246
|
+
* A property stated twice resolves to the last statement; see
|
|
247
|
+
* {@link readLastOccurrenceOnly} for the evidence and for why the statements
|
|
248
|
+
* it beat are not kept.
|
|
249
|
+
*
|
|
250
|
+
* An element that states nothing at all still yields a record: `undefined` here
|
|
251
|
+
* means the owner carried no `w:rPr`, never that the one it carried was empty.
|
|
252
|
+
*/
|
|
253
|
+
function parseRunProperties(rPr, theme, owner) {
|
|
254
|
+
if (!rPr) return;
|
|
255
|
+
const formatting = {};
|
|
256
|
+
const wins = readLastOccurrenceOnly(rPr);
|
|
257
|
+
const preserved = dispatchChildren({
|
|
258
|
+
element: rPr,
|
|
259
|
+
container: "run-properties",
|
|
260
|
+
handlers: {
|
|
261
|
+
ins: CAPTURE,
|
|
262
|
+
del: CAPTURE,
|
|
263
|
+
moveFrom: CAPTURE,
|
|
264
|
+
moveTo: CAPTURE,
|
|
265
|
+
rStyle: wins((child) => {
|
|
266
|
+
const val = getAttribute(child, "w", "val");
|
|
267
|
+
if (val) formatting.styleId = val;
|
|
268
|
+
return keptUnless(Boolean(val));
|
|
269
|
+
}),
|
|
270
|
+
rFonts: wins((child) => keptUnless(readFontFamily(child, theme, formatting))),
|
|
271
|
+
b: wins((child) => {
|
|
272
|
+
formatting.bold = parseBooleanElement(child);
|
|
273
|
+
}),
|
|
274
|
+
bCs: wins((child) => {
|
|
275
|
+
formatting.boldCs = parseBooleanElement(child);
|
|
276
|
+
}),
|
|
277
|
+
i: wins((child) => {
|
|
278
|
+
formatting.italic = parseBooleanElement(child);
|
|
279
|
+
}),
|
|
280
|
+
iCs: wins((child) => {
|
|
281
|
+
formatting.italicCs = parseBooleanElement(child);
|
|
282
|
+
}),
|
|
283
|
+
caps: wins((child) => {
|
|
284
|
+
formatting.allCaps = parseBooleanElement(child);
|
|
285
|
+
}),
|
|
286
|
+
smallCaps: wins((child) => {
|
|
287
|
+
formatting.smallCaps = parseBooleanElement(child);
|
|
288
|
+
}),
|
|
289
|
+
strike: wins((child) => {
|
|
290
|
+
formatting.strike = parseBooleanElement(child);
|
|
291
|
+
}),
|
|
292
|
+
dstrike: wins((child) => {
|
|
293
|
+
formatting.doubleStrike = parseBooleanElement(child);
|
|
294
|
+
}),
|
|
295
|
+
outline: wins((child) => {
|
|
296
|
+
formatting.outline = parseBooleanElement(child);
|
|
297
|
+
}),
|
|
298
|
+
shadow: wins((child) => {
|
|
299
|
+
formatting.shadow = parseBooleanElement(child);
|
|
300
|
+
}),
|
|
301
|
+
emboss: wins((child) => {
|
|
302
|
+
formatting.emboss = parseBooleanElement(child);
|
|
303
|
+
}),
|
|
304
|
+
imprint: wins((child) => {
|
|
305
|
+
formatting.imprint = parseBooleanElement(child);
|
|
306
|
+
}),
|
|
307
|
+
noProof: wins((child) => {
|
|
308
|
+
formatting.noProof = parseBooleanElement(child);
|
|
309
|
+
}),
|
|
310
|
+
vanish: wins((child) => {
|
|
311
|
+
formatting.hidden = parseBooleanElement(child);
|
|
312
|
+
}),
|
|
313
|
+
rtl: wins((child) => {
|
|
314
|
+
formatting.rtl = parseBooleanElement(child);
|
|
315
|
+
}),
|
|
316
|
+
cs: wins((child) => {
|
|
317
|
+
formatting.cs = parseBooleanElement(child);
|
|
318
|
+
}),
|
|
319
|
+
/** Whether the run follows the section's document grid; no layout slot. */
|
|
320
|
+
snapToGrid: CAPTURE,
|
|
321
|
+
/** Web-view-only hiding, distinct from `w:vanish`; nothing reads it. */
|
|
322
|
+
webHidden: CAPTURE,
|
|
323
|
+
color: wins((child) => {
|
|
324
|
+
const color = parseColorValue({
|
|
325
|
+
rgb: getAttribute(child, "w", "val"),
|
|
326
|
+
themeColor: getAttribute(child, "w", "themeColor"),
|
|
327
|
+
themeTint: getAttribute(child, "w", "themeTint"),
|
|
328
|
+
themeShade: getAttribute(child, "w", "themeShade"),
|
|
329
|
+
element: child.name ?? "w:color"
|
|
330
|
+
});
|
|
331
|
+
if (Object.keys(color).length === 0) return CAPTURE;
|
|
332
|
+
formatting.color = color;
|
|
333
|
+
}),
|
|
334
|
+
spacing: wins((child) => {
|
|
335
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
336
|
+
if (val !== void 0) formatting.spacing = val;
|
|
337
|
+
return keptUnless(val !== void 0);
|
|
338
|
+
}),
|
|
339
|
+
w: wins((child) => {
|
|
340
|
+
const val = parseHorizontalScalePercent(getAttribute(child, "w", "val"));
|
|
341
|
+
if (val !== void 0) formatting.scale = val;
|
|
342
|
+
return keptUnless(val !== void 0);
|
|
343
|
+
}),
|
|
344
|
+
kern: wins((child) => {
|
|
345
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
346
|
+
if (val !== void 0) formatting.kerning = val;
|
|
347
|
+
return keptUnless(val !== void 0);
|
|
348
|
+
}),
|
|
349
|
+
position: wins((child) => {
|
|
350
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
351
|
+
if (val !== void 0) formatting.position = val;
|
|
352
|
+
return keptUnless(val !== void 0);
|
|
353
|
+
}),
|
|
354
|
+
sz: wins((child) => {
|
|
355
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
356
|
+
if (val !== void 0) formatting.fontSize = val;
|
|
357
|
+
return keptUnless(val !== void 0);
|
|
358
|
+
}),
|
|
359
|
+
szCs: wins((child) => {
|
|
360
|
+
const val = parseNumericAttribute(child, "w", "val");
|
|
361
|
+
if (val !== void 0) formatting.fontSizeCs = val;
|
|
362
|
+
return keptUnless(val !== void 0);
|
|
363
|
+
}),
|
|
364
|
+
highlight: wins((child) => {
|
|
365
|
+
const val = narrowEnum(getAttribute(child, "w", "val"), HighlightColorSchema);
|
|
366
|
+
if (val) formatting.highlight = val;
|
|
367
|
+
return keptUnless(Boolean(val));
|
|
368
|
+
}),
|
|
369
|
+
u: wins((child) => keptUnless(readUnderline(child, formatting))),
|
|
370
|
+
effect: wins((child) => {
|
|
371
|
+
const val = narrowEnum(getAttribute(child, "w", "val"), TextEffectSchema);
|
|
372
|
+
if (val) formatting.effect = val;
|
|
373
|
+
return keptUnless(Boolean(val));
|
|
374
|
+
}),
|
|
375
|
+
/** A text border around the run; `BorderSpec` is a paragraph/table slot. */
|
|
376
|
+
bdr: CAPTURE,
|
|
377
|
+
shd: wins((child) => {
|
|
378
|
+
const shading = parseShading(child);
|
|
379
|
+
if (shading) formatting.shading = shading;
|
|
380
|
+
return keptUnless(shading !== void 0);
|
|
381
|
+
}),
|
|
382
|
+
/** Compress the run's text into a fixed width; no layout slot holds it. */
|
|
383
|
+
fitText: CAPTURE,
|
|
384
|
+
vertAlign: wins((child) => {
|
|
385
|
+
const val = getAttribute(child, "w", "val");
|
|
386
|
+
if (val === "superscript" || val === "subscript" || val === "baseline") {
|
|
387
|
+
formatting.vertAlign = val;
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
return CAPTURE;
|
|
391
|
+
}),
|
|
392
|
+
em: wins((child) => {
|
|
393
|
+
const val = narrowEnum(getAttribute(child, "w", "val"), EmphasisMarkSchema);
|
|
394
|
+
if (val) formatting.emphasisMark = val;
|
|
395
|
+
return keptUnless(Boolean(val));
|
|
396
|
+
}),
|
|
397
|
+
lang: wins((child) => keptUnless(readLanguage(child, formatting))),
|
|
398
|
+
/** East Asian two-lines-in-one and horizontal-in-vertical typesetting. */
|
|
399
|
+
eastAsianLayout: CAPTURE,
|
|
400
|
+
/**
|
|
401
|
+
* The run-in heading marker. On a paragraph mark the paragraph's record
|
|
402
|
+
* reads it (`runInWithNext`); under a run the schema declares it and folio
|
|
403
|
+
* models nothing for it.
|
|
404
|
+
*/
|
|
405
|
+
specVanish: owner === RUN_PROPERTY_OWNERS.paragraphMark ? wins(() => void 0) : CAPTURE,
|
|
406
|
+
/** The run is part of an equation; folio has no run-level maths slot. */
|
|
407
|
+
oMath: CAPTURE,
|
|
408
|
+
/**
|
|
409
|
+
* The tracked property change. A run's record reads it into
|
|
410
|
+
* `Run.propertyChanges`; a paragraph mark has no such record, so its
|
|
411
|
+
* snapshot is kept whole rather than dropped with the revision.
|
|
412
|
+
*/
|
|
413
|
+
rPrChange: CAPTURE,
|
|
414
|
+
...OWNED_BY_A_SIBLING_RECORD[owner]
|
|
415
|
+
},
|
|
416
|
+
capturePosition: sequencePositions("run-properties", rPr)
|
|
417
|
+
});
|
|
418
|
+
if (preserved) formatting.preserved = preserved;
|
|
419
|
+
return formatting;
|
|
334
420
|
}
|
|
335
|
-
function parseRunPropertyChanges(rPr, theme,
|
|
421
|
+
function parseRunPropertyChanges(rPr, theme, currentFormatting) {
|
|
336
422
|
if (!rPr) return;
|
|
337
423
|
const changes = findChildren(rPr, "w", "rPrChange").map((changeElement) => {
|
|
338
424
|
const previousRPr = findChild(changeElement, "w", "rPr");
|
|
@@ -340,11 +426,11 @@ function parseRunPropertyChanges(rPr, theme, styles, currentFormatting) {
|
|
|
340
426
|
type: "runPropertyChange",
|
|
341
427
|
info: parsePropertyChangeInfo(changeElement)
|
|
342
428
|
};
|
|
343
|
-
const previousFormatting = parseRunProperties(previousRPr, theme,
|
|
429
|
+
const previousFormatting = parseRunProperties(previousRPr, theme, RUN_PROPERTY_OWNERS.standalone);
|
|
344
430
|
if (previousFormatting) change.previousFormatting = previousFormatting;
|
|
345
431
|
if (currentFormatting) change.currentFormatting = currentFormatting;
|
|
346
432
|
return change;
|
|
347
|
-
})
|
|
433
|
+
});
|
|
348
434
|
return changes.length > 0 ? changes : void 0;
|
|
349
435
|
}
|
|
350
436
|
/**
|
|
@@ -419,17 +505,14 @@ function parseEndnoteReference(element) {
|
|
|
419
505
|
*/
|
|
420
506
|
function parseFieldChar(element) {
|
|
421
507
|
const fldCharType = getAttribute(element, "w", "fldCharType");
|
|
422
|
-
const fldLock = parseOnOffAttribute(element, "w", "fldLock") === true;
|
|
423
|
-
const dirty = parseOnOffAttribute(element, "w", "dirty") === true;
|
|
424
508
|
let charType = "begin";
|
|
425
509
|
if (fldCharType === "separate") charType = "separate";
|
|
426
510
|
else if (fldCharType === "end") charType = "end";
|
|
427
511
|
const content = {
|
|
428
512
|
type: "fieldChar",
|
|
429
|
-
charType
|
|
513
|
+
charType,
|
|
514
|
+
...parseFieldState(element)
|
|
430
515
|
};
|
|
431
|
-
if (fldLock) content.fldLock = true;
|
|
432
|
-
if (dirty) content.dirty = true;
|
|
433
516
|
const numberingChange = findChild(element, "w", "numberingChange");
|
|
434
517
|
if (numberingChange) {
|
|
435
518
|
const original = getAttribute(numberingChange, "w", "original");
|
|
@@ -576,10 +659,11 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
576
659
|
}
|
|
577
660
|
case "object": {
|
|
578
661
|
const objectPreview = parseVmlImageContent(child, rels, media, rootXmlns);
|
|
579
|
-
|
|
662
|
+
contents.push(objectPreview ?? preserveRunChild(child));
|
|
580
663
|
break;
|
|
581
664
|
}
|
|
582
665
|
case "rPr": break;
|
|
666
|
+
case "commentReference": break;
|
|
583
667
|
case "lastRenderedPageBreak":
|
|
584
668
|
contents.push({ type: "renderedPageBreak" });
|
|
585
669
|
break;
|
|
@@ -637,11 +721,9 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
637
721
|
if (contents.length === contentsBeforeAlternate && !hasTextBoxBranch) contents.push(preserveOnlyDrawing(captureVerbatimXml(cloneWithXmlnsDeclarations(child, rootXmlns))));
|
|
638
722
|
break;
|
|
639
723
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
case "continuationSeparator": break;
|
|
644
|
-
default: break;
|
|
724
|
+
default:
|
|
725
|
+
contents.push(preserveRunChild(child));
|
|
726
|
+
break;
|
|
645
727
|
}
|
|
646
728
|
return contents;
|
|
647
729
|
}
|
|
@@ -649,25 +731,31 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
649
731
|
* Parse a run element (w:r)
|
|
650
732
|
*
|
|
651
733
|
* @param node - The w:r XML element
|
|
652
|
-
* @param
|
|
734
|
+
* @param _styles - Unread: a run's properties are parsed as the source wrote
|
|
735
|
+
* them, and style resolution happens above this parser
|
|
653
736
|
* @param theme - Theme for resolving theme colors/fonts
|
|
654
737
|
* @param rels - Relationship map for resolving image references
|
|
655
738
|
* @param media - Media files map for image data
|
|
656
739
|
* @returns Parsed Run object
|
|
657
740
|
*/
|
|
658
|
-
function parseRun(node,
|
|
741
|
+
function parseRun(node, _styles, theme, rels = null, media = null, rootXmlns = {}) {
|
|
659
742
|
const run = {
|
|
660
743
|
type: "run",
|
|
661
744
|
content: []
|
|
662
745
|
};
|
|
663
746
|
const rPr = findChild(node, "w", "rPr");
|
|
664
747
|
if (rPr) {
|
|
665
|
-
const formattingResult = parseRunProperties(rPr, theme,
|
|
748
|
+
const formattingResult = parseRunProperties(rPr, theme, RUN_PROPERTY_OWNERS.run);
|
|
666
749
|
if (formattingResult) run.formatting = formattingResult;
|
|
667
|
-
const propertyChangesResult = parseRunPropertyChanges(rPr, theme,
|
|
750
|
+
const propertyChangesResult = parseRunPropertyChanges(rPr, theme, run.formatting);
|
|
668
751
|
if (propertyChangesResult) run.propertyChanges = propertyChangesResult;
|
|
669
752
|
}
|
|
670
753
|
run.content = parseRunContents(node, rels, media, mergeXmlnsDeclarations(rootXmlns, node));
|
|
754
|
+
const remainder = attributeRemainder({
|
|
755
|
+
element: node,
|
|
756
|
+
modelled: NO_MODELLED_ATTRIBUTES
|
|
757
|
+
});
|
|
758
|
+
if (remainder) run.preservedAttributes = remainder;
|
|
671
759
|
return run;
|
|
672
760
|
}
|
|
673
761
|
/**
|
|
@@ -732,4 +820,4 @@ function getFieldCharType(run) {
|
|
|
732
820
|
return run.content.find((c) => c.type === "fieldChar")?.charType ?? null;
|
|
733
821
|
}
|
|
734
822
|
//#endregion
|
|
735
|
-
export { getFieldCharType, getImages, getRunText, hasContent, hasFieldChar, hasImage, isBaselineVertAlign, parseRun, parseRunProperties };
|
|
823
|
+
export { RUN_PROPERTY_OWNERS, getFieldCharType, getImages, getRunText, hasContent, hasFieldChar, hasImage, isBaselineVertAlign, parseRun, parseRunProperties };
|