@stll/folio-core 0.46.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 +26 -24
- package/dist/ai-edits/headless.js +1 -1
- 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/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/section-boundary-properties.js +1 -2
- package/dist/content-controls/checkboxDisplay.d.ts +8 -2
- package/dist/content-controls/checkboxDisplay.js +11 -5
- package/dist/content-controls/mutateContentControls.js +41 -42
- package/dist/controller/layoutPipeline.js +8 -3
- package/dist/display-list/build/buildDisplayList.js +7 -7
- package/dist/display-list/build/imagePrimitives.d.ts +4 -4
- package/dist/display-list/build/imagePrimitives.js +38 -20
- package/dist/display-list/build/pageBorderPrimitives.js +2 -1
- package/dist/display-list/build/paragraphPrimitives.js +93 -13
- 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 +1 -19
- package/dist/display-list/primitives.d.ts +13 -2
- package/dist/display-list/primitives.js +36 -1
- package/dist/document-operations.js +2 -1
- package/dist/docx/attributeRemainder.d.ts +34 -1
- package/dist/docx/attributeRemainder.js +49 -3
- package/dist/docx/blockContentParser.d.ts +2 -0
- package/dist/docx/blockContentParser.js +39 -67
- package/dist/docx/blockPlainText.js +3 -1
- 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.js +1 -1
- package/dist/docx/commentParser.js +3 -3
- package/dist/docx/commentRangeIntegrity.js +1 -1
- package/dist/docx/commentRangeJoin.js +1 -1
- package/dist/docx/commentReferenceNormalization.js +3 -2
- package/dist/docx/commentReplyMarkers.js +1 -1
- package/dist/docx/compatibility.js +56 -42
- package/dist/docx/containerChildren.d.ts +110 -13
- package/dist/docx/containerChildren.gen.d.ts +16 -1
- package/dist/docx/containerChildren.gen.js +18 -1
- package/dist/docx/containerChildren.js +63 -13
- package/dist/docx/diagramPreview.d.ts +14 -2
- package/dist/docx/diagramPreview.js +81 -169
- package/dist/docx/documentParser.js +4 -1
- 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/fontTableParser.js +102 -41
- package/dist/docx/footnoteParser.js +10 -6
- package/dist/docx/groupDrawingParser.js +4 -3
- package/dist/docx/headerFooterReferenceNormalization.js +1 -1
- package/dist/docx/hyperlinkParser.d.ts +45 -7
- package/dist/docx/hyperlinkParser.js +126 -57
- package/dist/docx/imageParser.js +127 -107
- 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 +84 -3
- package/dist/docx/inlineWrapperContent.js +85 -4
- 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 +4 -2
- 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 +91 -1
- package/dist/docx/paraIdAttribute.js +79 -1
- package/dist/docx/paragraphParser.d.ts +9 -24
- package/dist/docx/paragraphParser.js +212 -396
- package/dist/docx/paragraphProperties.d.ts +23 -0
- package/dist/docx/paragraphProperties.js +279 -0
- package/dist/docx/paragraphPropertySource.js +2 -0
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +2 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +14 -7
- package/dist/docx/paragraphTraversal.d.ts +14 -10
- package/dist/docx/paragraphTraversal.js +47 -49
- package/dist/docx/parseWarningMessage.js +3 -0
- package/dist/docx/parserEnums.d.ts +6 -8
- package/dist/docx/parserEnums.js +4 -6
- package/dist/docx/preservedRunContent.js +16 -6
- 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 +2 -2
- package/dist/docx/rezip.d.ts +28 -2
- package/dist/docx/rezip.js +78 -9
- package/dist/docx/runConsolidator.d.ts +42 -2
- package/dist/docx/runConsolidator.js +60 -6
- package/dist/docx/runParser.d.ts +54 -18
- package/dist/docx/runParser.js +379 -295
- 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 +236 -240
- package/dist/docx/selectiveSave.js +3 -2
- package/dist/docx/selectiveXmlPatch.d.ts +21 -2
- package/dist/docx/selectiveXmlPatch.js +195 -99
- package/dist/docx/serializer/blockSdtSerializer.js +2 -96
- package/dist/docx/serializer/borderSerializer.d.ts +5 -5
- package/dist/docx/serializer/borderSerializer.js +10 -8
- package/dist/docx/serializer/documentSerializer.js +3 -0
- package/dist/docx/serializer/fontTableSerializer.js +31 -3
- package/dist/docx/serializer/headerFooterSerializer.js +3 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +9 -1
- package/dist/docx/serializer/markupRangeAttributes.js +9 -1
- package/dist/docx/serializer/noteSerializer.js +3 -0
- 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 +88 -188
- package/dist/docx/serializer/runSerializer.d.ts +1 -5
- package/dist/docx/serializer/runSerializer.js +109 -59
- package/dist/docx/serializer/sdtPropertiesSerializer.d.ts +26 -0
- package/dist/docx/serializer/sdtPropertiesSerializer.js +111 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +34 -45
- package/dist/docx/serializer/settingsSerializer.js +6 -4
- package/dist/docx/serializer/stylesSerializer.js +8 -11
- package/dist/docx/serializer/tableSerializer.js +268 -100
- 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 +18 -16
- package/dist/docx/server/migrateYjsAttrSchema.js +3 -3
- 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 +8 -3
- 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 +10 -1
- package/dist/docx/tableParser.js +505 -181
- package/dist/docx/textBoxParser.d.ts +3 -1
- package/dist/docx/textBoxParser.js +18 -8
- 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/vmlImageParser.d.ts +13 -4
- package/dist/docx/vmlImageParser.js +74 -31
- 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/xmlParser.d.ts +14 -1
- package/dist/docx/xmlParser.js +18 -2
- package/dist/fonts/embeddedFonts.js +3 -3
- package/dist/headless-layout.js +2 -0
- 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/internal/headlessRevisionResolution.js +9 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +3 -1
- 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 +177 -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/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 +47 -17
- package/dist/layout-engine/types.js +16 -1
- package/dist/layout-painter/borderStroke.d.ts +18 -4
- package/dist/layout-painter/renderPage.js +6 -4
- package/dist/layout-painter/renderParagraph.d.ts +2 -1
- package/dist/layout-painter/renderParagraph.js +13 -26
- 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/markdown/renderBlock.js +3 -1
- package/dist/markdown/renderRuns.js +7 -2
- package/dist/markdown/renderTable.js +2 -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/prosemirror/attrs/index.d.ts +22 -4
- package/dist/prosemirror/attrs/index.js +498 -60
- 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 +24 -19
- package/dist/prosemirror/commands/image.d.ts +1 -1
- package/dist/prosemirror/commands/image.js +4 -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/conversion/fromProseDoc.d.ts +18 -2
- package/dist/prosemirror/conversion/fromProseDoc.js +330 -183
- 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.js +371 -141
- package/dist/prosemirror/emptyRangeAnchor.d.ts +53 -0
- package/dist/prosemirror/emptyRangeAnchor.js +158 -0
- package/dist/prosemirror/extensions/StarterKit.js +8 -2
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +19 -15
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -2
- package/dist/prosemirror/extensions/features/ListExtension.js +43 -24
- 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 +26 -2
- package/dist/prosemirror/extensions/markRegistry.js +73 -10
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +17 -3
- 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.js +2 -1
- 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.js +10 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +8 -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/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 +4 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +141 -123
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +4 -0
- 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.js +20 -3
- 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/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 +1 -1
- package/dist/prosemirror/replacedAnnotations.js +24 -6
- package/dist/prosemirror/revisionCarriers.d.ts +86 -2
- package/dist/prosemirror/revisionCarriers.js +86 -60
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +2 -0
- package/dist/prosemirror/runFormattingInlineCarriers.js +2 -0
- 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 +2 -2
- package/dist/prosemirror/schema/marks.d.ts +23 -4
- package/dist/prosemirror/schema/nodes.d.ts +220 -24
- 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 +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +10 -11
- package/dist/prosemirror/utils/extractTrackedChanges.js +109 -92
- package/dist/prosemirror/validation.js +17 -6
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +2 -2
- package/dist/prosemirror/yjsDocumentMetadata.js +428 -7
- package/dist/prosemirror/zeroWidthAnchors.js +4 -0
- 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/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/mergeDocumentContent.js +5 -3
- package/dist/utils/paragraphFormattingMerge.js +27 -6
- package/dist/utils/replaceText.js +1 -1
- 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/bookmarkPlacement.d.ts +0 -9
- package/dist/docx/bookmarkPlacement.js +0 -52
- 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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DERIVED_PART_ROOT_ATTRIBUTES, attributeRemainder } from "./attributeRemainder.js";
|
|
2
|
+
import { CAPTURE, dispatchChildren } from "./containerChildren.js";
|
|
3
|
+
import { getAttribute, parseXmlDocument } from "./xmlParser.js";
|
|
2
4
|
//#region src/docx/fontTableParser.ts
|
|
3
5
|
const FONT_FAMILIES = [
|
|
4
6
|
"decorative",
|
|
@@ -13,60 +15,119 @@ const FONT_PITCHES = [
|
|
|
13
15
|
"fixed",
|
|
14
16
|
"variable"
|
|
15
17
|
];
|
|
18
|
+
/** `w:font` reads its name; everything else it carries is the remainder's. */
|
|
19
|
+
const MODELLED_FONT_ATTRIBUTES = /* @__PURE__ */ new Set(["name"]);
|
|
16
20
|
const parseFontTable = (xml) => {
|
|
17
21
|
if (!xml) return;
|
|
18
22
|
const root = parseXmlDocument(xml);
|
|
19
23
|
if (!root) return;
|
|
20
24
|
const fonts = [];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const preserved = dispatchChildren({
|
|
26
|
+
element: root,
|
|
27
|
+
container: "w:fonts",
|
|
28
|
+
capturePosition: () => fonts.length,
|
|
29
|
+
handlers: { font: (element) => {
|
|
30
|
+
const font = parseFont(element);
|
|
31
|
+
if (font) fonts.push(font);
|
|
32
|
+
} }
|
|
33
|
+
});
|
|
34
|
+
const preservedAttributes = attributeRemainder({
|
|
35
|
+
element: root,
|
|
36
|
+
modelled: DERIVED_PART_ROOT_ATTRIBUTES
|
|
37
|
+
});
|
|
38
|
+
if (fonts.length === 0 && preserved === void 0 && preservedAttributes === void 0) return;
|
|
39
|
+
return {
|
|
40
|
+
fonts,
|
|
41
|
+
...preserved === void 0 ? {} : { preserved },
|
|
42
|
+
...preservedAttributes === void 0 ? {} : { preservedAttributes }
|
|
43
|
+
};
|
|
26
44
|
};
|
|
27
45
|
const parseFont = (element) => {
|
|
28
46
|
const name = getAttribute(element, "w", "name");
|
|
29
47
|
if (!name) return;
|
|
30
48
|
const font = { name };
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let modelled = 0;
|
|
50
|
+
const read = (key, value) => {
|
|
51
|
+
if (value === void 0) return;
|
|
52
|
+
font[key] = value;
|
|
53
|
+
modelled += 1;
|
|
54
|
+
};
|
|
55
|
+
const preserved = dispatchChildren({
|
|
56
|
+
element,
|
|
57
|
+
container: "w:font",
|
|
58
|
+
capturePosition: () => modelled,
|
|
59
|
+
handlers: {
|
|
60
|
+
altName: (child) => read("altName", value(child)),
|
|
61
|
+
panose1: (child) => read("panose1", value(child)),
|
|
62
|
+
charset: (child) => read("charset", charsetOf(child)),
|
|
63
|
+
family: (child) => read("family", narrow(value(child), FONT_FAMILIES)),
|
|
64
|
+
notTrueType: CAPTURE,
|
|
65
|
+
pitch: (child) => read("pitch", narrow(value(child), FONT_PITCHES)),
|
|
66
|
+
sig: (child) => read("sig", signatureOf(child)),
|
|
67
|
+
embedRegular: (child) => read("embedRegular", embedOf(child)),
|
|
68
|
+
embedBold: (child) => read("embedBold", embedOf(child)),
|
|
69
|
+
embedItalic: (child) => read("embedItalic", embedOf(child)),
|
|
70
|
+
embedBoldItalic: (child) => read("embedBoldItalic", embedOf(child))
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (preserved !== void 0) font.preserved = preserved;
|
|
74
|
+
const preservedAttributes = attributeRemainder({
|
|
75
|
+
element,
|
|
76
|
+
modelled: MODELLED_FONT_ATTRIBUTES
|
|
77
|
+
});
|
|
78
|
+
if (preservedAttributes !== void 0) font.preservedAttributes = preservedAttributes;
|
|
53
79
|
return font;
|
|
54
80
|
};
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
const value = (element) => getAttribute(element, "w", "val") ?? void 0;
|
|
82
|
+
/**
|
|
83
|
+
* An empty `w:charset` is not an absent one.
|
|
84
|
+
*
|
|
85
|
+
* Both of `CT_Charset`'s attributes are optional, so a bare `<w:charset/>` is
|
|
86
|
+
* legal and says the font uses the default code page. Reading it as nothing
|
|
87
|
+
* would write it as nothing, and the document would come back saying something
|
|
88
|
+
* else: the record is what carries the element's presence.
|
|
89
|
+
*/
|
|
90
|
+
const charsetOf = (element) => {
|
|
91
|
+
const val = value(element);
|
|
92
|
+
const characterSet = getAttribute(element, "w", "characterSet") ?? void 0;
|
|
93
|
+
return {
|
|
94
|
+
...val === void 0 ? {} : { val },
|
|
95
|
+
...characterSet === void 0 ? {} : { characterSet }
|
|
96
|
+
};
|
|
62
97
|
};
|
|
63
|
-
|
|
64
|
-
|
|
98
|
+
/**
|
|
99
|
+
* An embedded face with no relationship points at no binary.
|
|
100
|
+
*
|
|
101
|
+
* Writing the element back without one would declare a face nothing can
|
|
102
|
+
* resolve, so the reference is only a reference when it has an `r:id`.
|
|
103
|
+
*/
|
|
104
|
+
const embedOf = (element) => {
|
|
105
|
+
const id = getAttribute(element, "r", "id");
|
|
106
|
+
if (!id) return;
|
|
107
|
+
const fontKey = getAttribute(element, "w", "fontKey") ?? void 0;
|
|
108
|
+
const subsetted = getAttribute(element, "w", "subsetted");
|
|
109
|
+
return {
|
|
110
|
+
id,
|
|
111
|
+
...fontKey === void 0 ? {} : { fontKey },
|
|
112
|
+
...subsetted === null || subsetted === void 0 ? {} : { subsetted: subsetted === "true" || subsetted === "1" || subsetted === "on" }
|
|
113
|
+
};
|
|
65
114
|
};
|
|
66
|
-
const
|
|
67
|
-
|
|
115
|
+
const SIGNATURE_ATTRIBUTES = [
|
|
116
|
+
"usb0",
|
|
117
|
+
"usb1",
|
|
118
|
+
"usb2",
|
|
119
|
+
"usb3",
|
|
120
|
+
"csb0",
|
|
121
|
+
"csb1"
|
|
122
|
+
];
|
|
123
|
+
const signatureOf = (element) => {
|
|
124
|
+
const signature = {};
|
|
125
|
+
for (const attribute of SIGNATURE_ATTRIBUTES) {
|
|
126
|
+
const carried = getAttribute(element, "w", attribute);
|
|
127
|
+
if (carried !== null && carried !== void 0) signature[attribute] = carried;
|
|
128
|
+
}
|
|
129
|
+
return Object.keys(signature).length === 0 ? void 0 : signature;
|
|
68
130
|
};
|
|
69
|
-
const
|
|
70
|
-
const isFontPitch = (value) => FONT_PITCHES.some((pitch) => pitch === value);
|
|
131
|
+
const narrow = (carried, members) => members.find((member) => member === carried);
|
|
71
132
|
//#endregion
|
|
72
133
|
export { parseFontTable };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { blockPlainText } from "./blockPlainText.js";
|
|
2
2
|
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
3
3
|
import { parseParagraph } from "./paragraphParser.js";
|
|
4
|
-
import { parseSdtProperties } from "./sdtProperties.js";
|
|
4
|
+
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
5
5
|
import { parseTable } from "./tableParser.js";
|
|
6
|
-
import {
|
|
6
|
+
import { findChildren, findWordprocessingChild, getAttributes, getChildElements, getLocalName, parseXml } from "./xmlParser.js";
|
|
7
7
|
import { PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
8
8
|
//#region src/docx/footnoteParser.ts
|
|
9
9
|
/**
|
|
@@ -36,12 +36,16 @@ function parseNoteBlockContent(element, styles, theme, numbering, rels, media) {
|
|
|
36
36
|
const table = parseTable(child, styles, theme, numbering, rels, media);
|
|
37
37
|
if (table) blocks.push(table);
|
|
38
38
|
} else if (localName === "sdt") {
|
|
39
|
-
const sdtPr =
|
|
40
|
-
const sdtEndPr =
|
|
41
|
-
const sdtContent =
|
|
39
|
+
const sdtPr = findWordprocessingChild(child, "sdtPr");
|
|
40
|
+
const sdtEndPr = findWordprocessingChild(child, "sdtEndPr");
|
|
41
|
+
const sdtContent = findWordprocessingChild(child, "sdtContent");
|
|
42
|
+
const properties = parseSdtProperties(sdtPr, sdtEndPr);
|
|
43
|
+
const captured = captureSdtSiblingMarkers(child);
|
|
44
|
+
if (captured.before.length > 0) properties.rawSdtChildrenBeforeContent = captured.before;
|
|
45
|
+
if (captured.after.length > 0) properties.rawSdtChildrenAfterContent = captured.after;
|
|
42
46
|
blocks.push({
|
|
43
47
|
type: "blockSdt",
|
|
44
|
-
properties
|
|
48
|
+
properties,
|
|
45
49
|
content: sdtContent ? parseNoteBlockContent(sdtContent, styles, theme, numbering, rels, media) : []
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { emuToPixels } from "../utils/units.js";
|
|
2
2
|
import { parseImage, resolveImageData } from "./imageParser.js";
|
|
3
|
+
import { PREVIEW_KINDS } from "./previewBudget.js";
|
|
3
4
|
import { findAllDeep, findChildByLocalName, findChildrenByLocalName, getAttribute, getChildElements, getLocalName, getTextContent, parseNumericAttribute } from "./xmlParser.js";
|
|
4
5
|
import { escapeXmlAttribute, escapeXmlText } from "@stll/docx-core";
|
|
5
6
|
//#region src/docx/groupDrawingParser.ts
|
|
@@ -182,9 +183,9 @@ const parseGroupDrawing = (drawing, rels, media) => {
|
|
|
182
183
|
if (!image || image.size.width <= 0 || image.size.height <= 0) return null;
|
|
183
184
|
const svg = createSvg(group, image.size.width, image.size.height, rels, media);
|
|
184
185
|
if (!svg || svg.length > MAX_SVG_CHARACTERS) return null;
|
|
185
|
-
image.src =
|
|
186
|
-
image.mimeType =
|
|
187
|
-
image.filename =
|
|
186
|
+
image.src = `${PREVIEW_KINDS.wpGroup.srcPrefix}${encodeURIComponent(svg)}`;
|
|
187
|
+
image.mimeType = PREVIEW_KINDS.wpGroup.mimeType;
|
|
188
|
+
image.filename = PREVIEW_KINDS.wpGroup.filename;
|
|
188
189
|
return image;
|
|
189
190
|
};
|
|
190
191
|
//#endregion
|
|
@@ -38,7 +38,7 @@ const normalizeHeaderFooterReferences = ({ documentBody, headers, footers }) =>
|
|
|
38
38
|
normalizeTable(block);
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
if (block.type
|
|
41
|
+
if (block.type !== "blockSdt") return;
|
|
42
42
|
normalizeBlocks(block.content);
|
|
43
43
|
};
|
|
44
44
|
const normalizeBlocks = (blocks) => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { XmlElement } from "./xmlParser.js";
|
|
3
3
|
import { StyleMap } from "./styleParser.js";
|
|
4
|
-
import { ChildHandlers } from "./containerChildren.js";
|
|
5
4
|
//#region src/docx/hyperlinkParser.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Parse a hyperlink element (w:hyperlink)
|
|
@@ -35,14 +34,49 @@ type HyperlinkChildContext = {
|
|
|
35
34
|
* ranges between its runs; folio models three of the thirty-two names and
|
|
36
35
|
* used to drop the other twenty-nine off the end of a `switch`.
|
|
37
36
|
*
|
|
38
|
-
*
|
|
37
|
+
* Three callers read this one map: {@link parseHyperlink}, the paragraph
|
|
39
38
|
* parser's revision-segmenting walk, which overrides the four
|
|
40
39
|
* `CT_RunTrackChange` wrappers because OOXML nests a revision inside a link
|
|
41
|
-
* and the model nests the link inside the revision
|
|
42
|
-
*
|
|
43
|
-
*
|
|
40
|
+
* and the model nests the link inside the revision, and
|
|
41
|
+
* {@link parseLinkedInlineWrapper}, which walks a transparent wrapper the link
|
|
42
|
+
* holds. Everything else is decided here once, so a child one caller starts
|
|
43
|
+
* recognising is recognised by all of them rather than by whichever list
|
|
44
|
+
* somebody remembered to update.
|
|
44
45
|
*/
|
|
45
|
-
declare const hyperlinkChildHandlers: (
|
|
46
|
+
declare const hyperlinkChildHandlers: (context: HyperlinkChildContext) => {
|
|
47
|
+
r: (child: XmlElement) => void;
|
|
48
|
+
bookmarkStart: (child: XmlElement) => void;
|
|
49
|
+
bookmarkEnd: (child: XmlElement) => void;
|
|
50
|
+
bdo: (child: XmlElement) => void;
|
|
51
|
+
dir: (child: XmlElement) => void;
|
|
52
|
+
customXml: (child: XmlElement) => void;
|
|
53
|
+
smartTag: (child: XmlElement) => void;
|
|
54
|
+
del: "capture";
|
|
55
|
+
ins: "capture";
|
|
56
|
+
moveFrom: "capture";
|
|
57
|
+
moveTo: "capture";
|
|
58
|
+
commentRangeEnd: "capture";
|
|
59
|
+
commentRangeStart: "capture";
|
|
60
|
+
customXmlDelRangeEnd: "capture";
|
|
61
|
+
customXmlDelRangeStart: "capture";
|
|
62
|
+
customXmlInsRangeEnd: "capture";
|
|
63
|
+
customXmlInsRangeStart: "capture";
|
|
64
|
+
customXmlMoveFromRangeEnd: "capture";
|
|
65
|
+
customXmlMoveFromRangeStart: "capture";
|
|
66
|
+
customXmlMoveToRangeEnd: "capture";
|
|
67
|
+
customXmlMoveToRangeStart: "capture";
|
|
68
|
+
fldSimple: (child: XmlElement) => void;
|
|
69
|
+
hyperlink: (child: XmlElement) => void;
|
|
70
|
+
moveFromRangeEnd: "capture";
|
|
71
|
+
moveFromRangeStart: "capture";
|
|
72
|
+
moveToRangeEnd: "capture";
|
|
73
|
+
moveToRangeStart: "capture";
|
|
74
|
+
permEnd: "capture";
|
|
75
|
+
permStart: "capture";
|
|
76
|
+
proofErr: "capture";
|
|
77
|
+
sdt: "capture";
|
|
78
|
+
subDoc: "capture";
|
|
79
|
+
};
|
|
46
80
|
/**
|
|
47
81
|
* Get the display text of a hyperlink
|
|
48
82
|
*
|
|
@@ -85,7 +119,11 @@ declare function getHyperlinkUrl(hyperlink: document_d_exports.Hyperlink): strin
|
|
|
85
119
|
*/
|
|
86
120
|
declare function hasContent(hyperlink: document_d_exports.Hyperlink): boolean;
|
|
87
121
|
/**
|
|
88
|
-
* Get all runs from a hyperlink
|
|
122
|
+
* Get all runs from a hyperlink, including those inside a transparent wrapper
|
|
123
|
+
*
|
|
124
|
+
* A `w:bdo`, `w:dir`, `w:smartTag` or run-level `w:customXml` says how the
|
|
125
|
+
* linked text is laid out or what it is tagged as, never that it is not the
|
|
126
|
+
* link's text, so the walk goes through it.
|
|
89
127
|
*
|
|
90
128
|
* @param hyperlink - Parsed Hyperlink object
|
|
91
129
|
* @returns Array of Run objects
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
2
|
-
import { CAPTURE, dispatchChildren, withPreservedChildren } from "./containerChildren.js";
|
|
2
|
+
import { CAPTURE, dispatchChildren, ownedElsewhere, withPreservedChildren } from "./containerChildren.js";
|
|
3
|
+
import { inlineWrapperOf } from "./inlineWrapperParser.js";
|
|
3
4
|
import { preserveInlineChild, preservedInlineCapture } from "./preservedRunContent.js";
|
|
4
5
|
import { RELATIONSHIP_TYPES, resolveRelationshipIdOfType } from "./relsParser.js";
|
|
5
6
|
import { parseRun } from "./runParser.js";
|
|
7
|
+
import { runHoldsPayload } from "./runPayload.js";
|
|
6
8
|
import { getAttribute, mergeXmlnsDeclarations, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
7
9
|
//#region src/docx/hyperlinkParser.ts
|
|
8
10
|
/**
|
|
@@ -66,7 +68,8 @@ function parseHyperlink(node, rels, styles = null, theme = null, media = null, r
|
|
|
66
68
|
if (tooltip) hyperlink.tooltip = tooltip;
|
|
67
69
|
const tgtFrame = getAttribute(node, "w", "tgtFrame");
|
|
68
70
|
if (tgtFrame) hyperlink.target = tgtFrame;
|
|
69
|
-
|
|
71
|
+
const history = parseOnOffAttribute(node, "w", "history");
|
|
72
|
+
if (history !== void 0) hyperlink.history = history;
|
|
70
73
|
const docLocation = getAttribute(node, "w", "docLocation");
|
|
71
74
|
if (docLocation) hyperlink.docLocation = docLocation;
|
|
72
75
|
const inScopeXmlns = mergeXmlnsDeclarations(rootXmlns, node);
|
|
@@ -74,7 +77,7 @@ function parseHyperlink(node, rels, styles = null, theme = null, media = null, r
|
|
|
74
77
|
hyperlink.children = withPreservedChildren(children, dispatchChildren({
|
|
75
78
|
element: node,
|
|
76
79
|
container: "w:hyperlink",
|
|
77
|
-
|
|
80
|
+
capturePosition: () => children.length,
|
|
78
81
|
handlers: hyperlinkChildHandlers({
|
|
79
82
|
push: (child) => {
|
|
80
83
|
children.push(child);
|
|
@@ -96,58 +99,111 @@ function parseHyperlink(node, rels, styles = null, theme = null, media = null, r
|
|
|
96
99
|
* ranges between its runs; folio models three of the thirty-two names and
|
|
97
100
|
* used to drop the other twenty-nine off the end of a `switch`.
|
|
98
101
|
*
|
|
99
|
-
*
|
|
102
|
+
* Three callers read this one map: {@link parseHyperlink}, the paragraph
|
|
100
103
|
* parser's revision-segmenting walk, which overrides the four
|
|
101
104
|
* `CT_RunTrackChange` wrappers because OOXML nests a revision inside a link
|
|
102
|
-
* and the model nests the link inside the revision
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
+
* and the model nests the link inside the revision, and
|
|
106
|
+
* {@link parseLinkedInlineWrapper}, which walks a transparent wrapper the link
|
|
107
|
+
* holds. Everything else is decided here once, so a child one caller starts
|
|
108
|
+
* recognising is recognised by all of them rather than by whichever list
|
|
109
|
+
* somebody remembered to update.
|
|
105
110
|
*/
|
|
106
|
-
const hyperlinkChildHandlers = (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
111
|
+
const hyperlinkChildHandlers = (context) => {
|
|
112
|
+
const { push, styles, theme, rels, media, inScopeXmlns } = context;
|
|
113
|
+
const wrapper = (element) => (child) => {
|
|
114
|
+
push(parseLinkedInlineWrapper(element, child, context));
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
r: (child) => {
|
|
118
|
+
const run = parseRun(child, styles, theme, rels, media, inScopeXmlns);
|
|
119
|
+
if (runHoldsPayload(run)) push(run);
|
|
120
|
+
},
|
|
121
|
+
bookmarkStart: (child) => {
|
|
122
|
+
push(parseBookmarkStart(child));
|
|
123
|
+
},
|
|
124
|
+
bookmarkEnd: (child) => {
|
|
125
|
+
push(parseBookmarkEnd(child));
|
|
126
|
+
},
|
|
127
|
+
bdo: wrapper("bdo"),
|
|
128
|
+
dir: wrapper("dir"),
|
|
129
|
+
customXml: wrapper("customXml"),
|
|
130
|
+
smartTag: wrapper("smartTag"),
|
|
131
|
+
del: CAPTURE,
|
|
132
|
+
ins: CAPTURE,
|
|
133
|
+
moveFrom: CAPTURE,
|
|
134
|
+
moveTo: CAPTURE,
|
|
135
|
+
commentRangeEnd: CAPTURE,
|
|
136
|
+
commentRangeStart: CAPTURE,
|
|
137
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
138
|
+
customXmlDelRangeStart: CAPTURE,
|
|
139
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
140
|
+
customXmlInsRangeStart: CAPTURE,
|
|
141
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
142
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
143
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
144
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
145
|
+
fldSimple: (child) => {
|
|
146
|
+
push(preserveInlineChild(child));
|
|
147
|
+
},
|
|
148
|
+
hyperlink: (child) => {
|
|
149
|
+
push(preserveInlineChild(child));
|
|
150
|
+
},
|
|
151
|
+
moveFromRangeEnd: CAPTURE,
|
|
152
|
+
moveFromRangeStart: CAPTURE,
|
|
153
|
+
moveToRangeEnd: CAPTURE,
|
|
154
|
+
moveToRangeStart: CAPTURE,
|
|
155
|
+
permEnd: CAPTURE,
|
|
156
|
+
permStart: CAPTURE,
|
|
157
|
+
proofErr: CAPTURE,
|
|
158
|
+
sdt: CAPTURE,
|
|
159
|
+
subDoc: CAPTURE
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
const LINKED_SMART_TAG_PROPERTIES_OWNER = ownedElsewhere({
|
|
163
|
+
container: "run-level-content",
|
|
164
|
+
child: "smartTagPr",
|
|
165
|
+
reader: "inlineWrapperParser#inlineWrapperOf"
|
|
166
|
+
});
|
|
167
|
+
const LINKED_CUSTOM_XML_PROPERTIES_OWNER = ownedElsewhere({
|
|
168
|
+
container: "run-level-content",
|
|
169
|
+
child: "customXmlPr",
|
|
170
|
+
reader: "inlineWrapperParser#inlineWrapperOf"
|
|
149
171
|
});
|
|
150
172
|
/**
|
|
173
|
+
* A transparent wrapper a link holds, with the content the link would hold.
|
|
174
|
+
*
|
|
175
|
+
* `CT_BdoContentRun` and its three siblings are `EG_PContent`, the group
|
|
176
|
+
* `CT_Hyperlink` is, so the wrapper's declared children are run-level content
|
|
177
|
+
* and the decision per child is the link's own map. That is what keeps the two
|
|
178
|
+
* from drifting: a `w:ins` inside a `w:bdo` inside a link is captured for the
|
|
179
|
+
* same reason a `w:ins` directly inside the link is.
|
|
180
|
+
*
|
|
181
|
+
* The wrapper's own `w:smartTagPr` / `w:customXmlPr` is read by
|
|
182
|
+
* {@link inlineWrapperOf}, so it is declared owned here rather than captured a
|
|
183
|
+
* second time by the sink.
|
|
184
|
+
*/
|
|
185
|
+
const parseLinkedInlineWrapper = (element, node, context) => {
|
|
186
|
+
const inScopeXmlns = mergeXmlnsDeclarations(context.inScopeXmlns, node);
|
|
187
|
+
const content = [];
|
|
188
|
+
return inlineWrapperOf(element, node, withPreservedChildren(content, dispatchChildren({
|
|
189
|
+
element: node,
|
|
190
|
+
container: "run-level-content",
|
|
191
|
+
capturePosition: () => content.length,
|
|
192
|
+
handlers: {
|
|
193
|
+
...hyperlinkChildHandlers({
|
|
194
|
+
...context,
|
|
195
|
+
inScopeXmlns,
|
|
196
|
+
push: (child) => {
|
|
197
|
+
content.push(child);
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
customXmlPr: LINKED_CUSTOM_XML_PROPERTIES_OWNER,
|
|
201
|
+
smartTagPr: LINKED_SMART_TAG_PROPERTIES_OWNER,
|
|
202
|
+
pPr: CAPTURE
|
|
203
|
+
}
|
|
204
|
+
}), preservedInlineCapture));
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
151
207
|
* Get the display text of a hyperlink
|
|
152
208
|
*
|
|
153
209
|
* Concatenates text from all child runs.
|
|
@@ -157,10 +213,8 @@ const hyperlinkChildHandlers = ({ push, styles, theme, rels, media, inScopeXmlns
|
|
|
157
213
|
*/
|
|
158
214
|
function getHyperlinkText(hyperlink) {
|
|
159
215
|
let text = "";
|
|
160
|
-
for (const
|
|
161
|
-
|
|
162
|
-
else if (content.type === "tab") text += " ";
|
|
163
|
-
}
|
|
216
|
+
for (const run of getHyperlinkRuns(hyperlink)) for (const content of run.content) if (content.type === "text") text += content.text;
|
|
217
|
+
else if (content.type === "tab") text += " ";
|
|
164
218
|
return text;
|
|
165
219
|
}
|
|
166
220
|
/**
|
|
@@ -202,16 +256,31 @@ function getHyperlinkUrl(hyperlink) {
|
|
|
202
256
|
* @returns true if hyperlink has child runs
|
|
203
257
|
*/
|
|
204
258
|
function hasContent(hyperlink) {
|
|
205
|
-
return hyperlink
|
|
259
|
+
return getHyperlinkRuns(hyperlink).length > 0;
|
|
206
260
|
}
|
|
207
261
|
/**
|
|
208
|
-
* Get all runs from a hyperlink
|
|
262
|
+
* Get all runs from a hyperlink, including those inside a transparent wrapper
|
|
263
|
+
*
|
|
264
|
+
* A `w:bdo`, `w:dir`, `w:smartTag` or run-level `w:customXml` says how the
|
|
265
|
+
* linked text is laid out or what it is tagged as, never that it is not the
|
|
266
|
+
* link's text, so the walk goes through it.
|
|
209
267
|
*
|
|
210
268
|
* @param hyperlink - Parsed Hyperlink object
|
|
211
269
|
* @returns Array of Run objects
|
|
212
270
|
*/
|
|
213
271
|
function getHyperlinkRuns(hyperlink) {
|
|
214
|
-
|
|
272
|
+
const runs = [];
|
|
273
|
+
const collect = (items) => {
|
|
274
|
+
for (const item of items) {
|
|
275
|
+
if (item.type === "run") {
|
|
276
|
+
runs.push(item);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (item.type === "inlineWrapper") collect(item.content);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
collect(hyperlink.children);
|
|
283
|
+
return runs;
|
|
215
284
|
}
|
|
216
285
|
/**
|
|
217
286
|
* Resolve a hyperlink's rId to a URL using a relationship map
|