@stll/folio-core 0.46.0 → 0.47.1
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.d.ts +17 -1
- package/dist/ai-edits/apply.js +31 -27
- package/dist/ai-edits/headless.d.ts +9 -2
- package/dist/ai-edits/headless.js +5 -3
- 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 -1
- package/dist/compare/content-alignment.js +192 -46
- 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.d.ts +9 -2
- package/dist/document-operations.js +5 -3
- 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
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ParagraphContent } from "../types/content.js";
|
|
2
|
+
//#region src/prosemirror/emptyRangeAnchor.d.ts
|
|
3
|
+
/** A marker that opens a range the editor otherwise projects as a mark. */
|
|
4
|
+
type RangeStartType = Extract<ParagraphContent["type"], `${string}RangeStart`>;
|
|
5
|
+
/**
|
|
6
|
+
* Which end closes which start.
|
|
7
|
+
*
|
|
8
|
+
* Both sides are derived from the model's own content union rather than
|
|
9
|
+
* listed, so a `…RangeStart` added to `ParagraphContent` fails this
|
|
10
|
+
* `satisfies` until somebody has said what closes it.
|
|
11
|
+
*/
|
|
12
|
+
declare const RANGE_END_FOR_START: {
|
|
13
|
+
readonly commentRangeStart: "commentRangeEnd";
|
|
14
|
+
readonly moveFromRangeStart: "moveFromRangeEnd";
|
|
15
|
+
readonly moveToRangeStart: "moveToRangeEnd";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The `rangeAnchor` node's attributes: a start and the end that closes it,
|
|
19
|
+
* with nothing between them.
|
|
20
|
+
*
|
|
21
|
+
* Distributing over the start types pairs each start with exactly its own end,
|
|
22
|
+
* so a comment start holding a move end is not a value this type has.
|
|
23
|
+
*/
|
|
24
|
+
type RangeAnchorAttrs = { [Start in RangeStartType]: {
|
|
25
|
+
start: Extract<ParagraphContent, {
|
|
26
|
+
type: Start;
|
|
27
|
+
}>;
|
|
28
|
+
end: Extract<ParagraphContent, {
|
|
29
|
+
type: (typeof RANGE_END_FOR_START)[Start];
|
|
30
|
+
}>;
|
|
31
|
+
}; }[RangeStartType];
|
|
32
|
+
/** Whether this content is one of the six range markers, either half. */
|
|
33
|
+
declare const isRangeMarker: (content: ParagraphContent) => boolean;
|
|
34
|
+
type EmptyRangePlan = {
|
|
35
|
+
/** The anchor to emit in place of the marker at this index. */
|
|
36
|
+
anchorAt: ReadonlyMap<number, RangeAnchorAttrs>;
|
|
37
|
+
/** An index whose marker an anchor at an earlier index already holds. */
|
|
38
|
+
closedAt: ReadonlySet<number>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The empty ranges in one inline sequence, by the index each one's start sits
|
|
42
|
+
* at.
|
|
43
|
+
*
|
|
44
|
+
* The window a pair may close within is a maximal run of range markers and
|
|
45
|
+
* nothing else, which is what "spans no content" means once the transparent
|
|
46
|
+
* wrappers are lifted. Nesting inside such a run is not meaningful — neither
|
|
47
|
+
* order covers anything — so the pairs are taken nearest first and each anchor
|
|
48
|
+
* stays at its own start's index. A start whose end is outside the run is a
|
|
49
|
+
* range over content and keeps the mark path; so does an end with no start.
|
|
50
|
+
*/
|
|
51
|
+
declare const planEmptyRanges: (content: readonly ParagraphContent[]) => EmptyRangePlan;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { EmptyRangePlan, RANGE_END_FOR_START, RangeAnchorAttrs, isRangeMarker, planEmptyRanges };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
//#region src/prosemirror/emptyRangeAnchor.ts
|
|
3
|
+
/**
|
|
4
|
+
* A comment or tracked-move range that spans no content, carried across the
|
|
5
|
+
* editor projection as one zero-width atom.
|
|
6
|
+
*
|
|
7
|
+
* A reviewer who comments at an insertion point rather than over a selection
|
|
8
|
+
* gets `w:commentRangeStart` immediately followed by `w:commentRangeEnd`, and
|
|
9
|
+
* then the `w:commentReference` run. The editor spells a comment as a `comment`
|
|
10
|
+
* mark over the inline content its range covers, and a range over nothing has
|
|
11
|
+
* no leaf to mark, so the projection dropped both markers. The comment still
|
|
12
|
+
* listed — the reference survives as its own atom — but its anchor position was
|
|
13
|
+
* gone, and the save wrote a reference with no range at all. A tracked move
|
|
14
|
+
* whose range spans nothing loses its `w:name` the same way, and with it the
|
|
15
|
+
* only thing binding the move's source to its destination.
|
|
16
|
+
*
|
|
17
|
+
* The pair is one thing rather than two, so it is one node. Two adjacent
|
|
18
|
+
* boundary nodes, which is what the bookmark precedent would suggest, would
|
|
19
|
+
* leave a position between them for a caret to sit in; typing there would turn
|
|
20
|
+
* a point comment into a range the reviewer never drew.
|
|
21
|
+
*
|
|
22
|
+
* What the node holds is the model's own markers, not a copy of their fields:
|
|
23
|
+
* an attribute added to `CT_MoveBookmark` is carried without being named here.
|
|
24
|
+
*
|
|
25
|
+
* A range that spans a bookmark boundary, a comment reference or captured
|
|
26
|
+
* markup is not in this class and needs no anchor: each of those is an inline
|
|
27
|
+
* node that carries a mark, so the mark path already keeps the range. Only a
|
|
28
|
+
* range with nothing whatever between its two markers has no carrier.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Which end closes which start.
|
|
32
|
+
*
|
|
33
|
+
* Both sides are derived from the model's own content union rather than
|
|
34
|
+
* listed, so a `…RangeStart` added to `ParagraphContent` fails this
|
|
35
|
+
* `satisfies` until somebody has said what closes it.
|
|
36
|
+
*/
|
|
37
|
+
const RANGE_END_FOR_START = {
|
|
38
|
+
commentRangeStart: "commentRangeEnd",
|
|
39
|
+
moveFromRangeStart: "moveFromRangeEnd",
|
|
40
|
+
moveToRangeStart: "moveToRangeEnd"
|
|
41
|
+
};
|
|
42
|
+
const RANGE_MARKER_TYPES = /* @__PURE__ */ new Set([...Object.keys(RANGE_END_FOR_START), ...Object.values(RANGE_END_FOR_START)]);
|
|
43
|
+
/** Whether this content is one of the six range markers, either half. */
|
|
44
|
+
const isRangeMarker = (content) => RANGE_MARKER_TYPES.has(content.type);
|
|
45
|
+
const isRangeStart = (content) => content.type in RANGE_END_FOR_START;
|
|
46
|
+
const isRangeEnd = (content) => content.type === "commentRangeEnd" || content.type === "moveFromRangeEnd" || content.type === "moveToRangeEnd";
|
|
47
|
+
const NO_EMPTY_RANGES = {
|
|
48
|
+
anchorAt: /* @__PURE__ */ new Map(),
|
|
49
|
+
closedAt: /* @__PURE__ */ new Set()
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The empty ranges in one inline sequence, by the index each one's start sits
|
|
53
|
+
* at.
|
|
54
|
+
*
|
|
55
|
+
* The window a pair may close within is a maximal run of range markers and
|
|
56
|
+
* nothing else, which is what "spans no content" means once the transparent
|
|
57
|
+
* wrappers are lifted. Nesting inside such a run is not meaningful — neither
|
|
58
|
+
* order covers anything — so the pairs are taken nearest first and each anchor
|
|
59
|
+
* stays at its own start's index. A start whose end is outside the run is a
|
|
60
|
+
* range over content and keeps the mark path; so does an end with no start.
|
|
61
|
+
*/
|
|
62
|
+
const planEmptyRanges = (content) => {
|
|
63
|
+
const anchorAt = /* @__PURE__ */ new Map();
|
|
64
|
+
const closedAt = /* @__PURE__ */ new Set();
|
|
65
|
+
let index = 0;
|
|
66
|
+
while (index < content.length) {
|
|
67
|
+
const item = content[index];
|
|
68
|
+
if (item === void 0 || !isRangeMarker(item)) {
|
|
69
|
+
index += 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
let runEnd = index;
|
|
73
|
+
while (runEnd < content.length) {
|
|
74
|
+
const candidate = content[runEnd];
|
|
75
|
+
if (candidate === void 0 || !isRangeMarker(candidate)) break;
|
|
76
|
+
runEnd += 1;
|
|
77
|
+
}
|
|
78
|
+
pairWithinRun({
|
|
79
|
+
content,
|
|
80
|
+
from: index,
|
|
81
|
+
to: runEnd,
|
|
82
|
+
anchorAt,
|
|
83
|
+
closedAt
|
|
84
|
+
});
|
|
85
|
+
index = runEnd;
|
|
86
|
+
}
|
|
87
|
+
if (anchorAt.size === 0) return NO_EMPTY_RANGES;
|
|
88
|
+
return {
|
|
89
|
+
anchorAt,
|
|
90
|
+
closedAt
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The two markers as one anchor, or `null` when the closer does not close this
|
|
95
|
+
* start.
|
|
96
|
+
*
|
|
97
|
+
* The branches restate no pairing: `RangeAnchorAttrs` is derived from
|
|
98
|
+
* {@link RANGE_END_FOR_START}, so a branch that named the wrong end would not
|
|
99
|
+
* be assignable, and a start type the model gains fails the exhaustiveness
|
|
100
|
+
* check below.
|
|
101
|
+
*/
|
|
102
|
+
const pairedAnchor = (opener, closer) => {
|
|
103
|
+
switch (opener.type) {
|
|
104
|
+
case "commentRangeStart": return closer.type === "commentRangeEnd" && closer.id === opener.id ? {
|
|
105
|
+
start: opener,
|
|
106
|
+
end: closer
|
|
107
|
+
} : null;
|
|
108
|
+
case "moveFromRangeStart": return closer.type === "moveFromRangeEnd" && closer.id === opener.id ? {
|
|
109
|
+
start: opener,
|
|
110
|
+
end: closer
|
|
111
|
+
} : null;
|
|
112
|
+
case "moveToRangeStart": return closer.type === "moveToRangeEnd" && closer.id === opener.id ? {
|
|
113
|
+
start: opener,
|
|
114
|
+
end: closer
|
|
115
|
+
} : null;
|
|
116
|
+
default: panic(`Unsupported range start: ${JSON.stringify(opener)}`);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const pairWithinRun = ({ content, from, to, anchorAt, closedAt }) => {
|
|
120
|
+
const endIndexesByTypeAndId = /* @__PURE__ */ new Map();
|
|
121
|
+
for (let end = from; end < to; end += 1) {
|
|
122
|
+
const closer = content[end];
|
|
123
|
+
if (closer === void 0 || !isRangeEnd(closer)) continue;
|
|
124
|
+
const key = rangeKey(closer.type, closer.id);
|
|
125
|
+
const indexes = endIndexesByTypeAndId.get(key);
|
|
126
|
+
if (indexes === void 0) {
|
|
127
|
+
endIndexesByTypeAndId.set(key, [end]);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
indexes.push(end);
|
|
131
|
+
}
|
|
132
|
+
const nextEndByTypeAndId = /* @__PURE__ */ new Map();
|
|
133
|
+
for (let start = from; start < to; start += 1) {
|
|
134
|
+
const opener = content[start];
|
|
135
|
+
if (opener === void 0 || closedAt.has(start) || !isRangeStart(opener)) continue;
|
|
136
|
+
const key = rangeKey(RANGE_END_FOR_START[opener.type], opener.id);
|
|
137
|
+
const indexes = endIndexesByTypeAndId.get(key);
|
|
138
|
+
if (indexes === void 0) continue;
|
|
139
|
+
let nextEnd = nextEndByTypeAndId.get(key) ?? 0;
|
|
140
|
+
while (nextEnd < indexes.length && (indexes[nextEnd] ?? -1) <= start) nextEnd += 1;
|
|
141
|
+
const end = indexes[nextEnd];
|
|
142
|
+
if (end === void 0) {
|
|
143
|
+
nextEndByTypeAndId.set(key, nextEnd);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
nextEndByTypeAndId.set(key, nextEnd + 1);
|
|
147
|
+
const closer = content[end];
|
|
148
|
+
if (closer === void 0) continue;
|
|
149
|
+
const anchor = pairedAnchor(opener, closer);
|
|
150
|
+
if (anchor === null) continue;
|
|
151
|
+
anchorAt.set(start, anchor);
|
|
152
|
+
closedAt.add(start);
|
|
153
|
+
closedAt.add(end);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const rangeKey = (type, id) => `${type}:${id}`;
|
|
157
|
+
//#endregion
|
|
158
|
+
export { RANGE_END_FOR_START, isRangeMarker, planEmptyRanges };
|
|
@@ -17,7 +17,8 @@ import { ParagraphChangeTrackerExtension } from "./features/ParagraphChangeTrack
|
|
|
17
17
|
import { PasteCleanupExtension } from "./features/PasteCleanupExtension.js";
|
|
18
18
|
import { PasteStyleInlinerExtension } from "./features/PasteStyleInlinerExtension.js";
|
|
19
19
|
import { SelectionTrackerExtension } from "./features/SelectionTrackerExtension.js";
|
|
20
|
-
import { MARK_EXTENSIONS } from "./markRegistry.js";
|
|
20
|
+
import { MARK_EXTENSIONS, MARK_NESTING_ORDER } from "./markRegistry.js";
|
|
21
|
+
import { BlockBookmarkBoundaryExtension } from "./nodes/BlockBookmarkBoundaryExtension.js";
|
|
21
22
|
import { BlockSdtExtension } from "./nodes/BlockSdtExtension.js";
|
|
22
23
|
import { BookmarkBoundaryExtension } from "./nodes/BookmarkBoundaryExtension.js";
|
|
23
24
|
import { CommentReferenceExtension } from "./nodes/CommentReferenceExtension.js";
|
|
@@ -26,10 +27,12 @@ import { HardBreakExtension } from "./nodes/HardBreakExtension.js";
|
|
|
26
27
|
import { HorizontalRuleExtension } from "./nodes/HorizontalRuleExtension.js";
|
|
27
28
|
import { ImageExtension } from "./nodes/ImageExtension.js";
|
|
28
29
|
import { MathExtension } from "./nodes/MathExtension.js";
|
|
30
|
+
import { MoveRangeBoundaryExtension } from "./nodes/MoveRangeBoundaryExtension.js";
|
|
29
31
|
import { PageBreakExtension } from "./nodes/PageBreakExtension.js";
|
|
30
32
|
import { PageBreakRunExtension } from "./nodes/PageBreakRunExtension.js";
|
|
31
33
|
import { PreservedBlockExtension } from "./nodes/PreservedBlockExtension.js";
|
|
32
34
|
import { PreservedXmlExtension } from "./nodes/PreservedXmlExtension.js";
|
|
35
|
+
import { RangeAnchorExtension } from "./nodes/RangeAnchorExtension.js";
|
|
33
36
|
import { RenderedPageBreakExtension } from "./nodes/RenderedPageBreakExtension.js";
|
|
34
37
|
import { SdtExtension } from "./nodes/SdtExtension.js";
|
|
35
38
|
import { ShapeExtension } from "./nodes/ShapeExtension.js";
|
|
@@ -60,9 +63,12 @@ function createStarterKit(options = {}) {
|
|
|
60
63
|
...options.historyDepth !== void 0 ? { depth: options.historyDepth } : {},
|
|
61
64
|
...options.historyNewGroupDelay !== void 0 ? { newGroupDelay: options.historyNewGroupDelay } : {}
|
|
62
65
|
}));
|
|
63
|
-
for (const
|
|
66
|
+
for (const name of MARK_NESTING_ORDER) add(name, MARK_EXTENSIONS[name]());
|
|
64
67
|
add("bookmarkBoundary", BookmarkBoundaryExtension({ getInternalClipboardToken }));
|
|
68
|
+
add("blockBookmarkBoundary", BlockBookmarkBoundaryExtension());
|
|
65
69
|
add("commentReference", CommentReferenceExtension({ getInternalClipboardToken }));
|
|
70
|
+
add("moveRangeBoundary", MoveRangeBoundaryExtension({ getInternalClipboardToken }));
|
|
71
|
+
add("rangeAnchor", RangeAnchorExtension({ getInternalClipboardToken }));
|
|
66
72
|
add("hardBreak", HardBreakExtension());
|
|
67
73
|
add("tab", TabExtension());
|
|
68
74
|
add("symbol", SymbolExtension());
|
|
@@ -13,7 +13,7 @@ const DocExtension = createNodeExtension({
|
|
|
13
13
|
_finalSectionStart: { default: null },
|
|
14
14
|
_adjustLineHeightInTable: { default: false }
|
|
15
15
|
},
|
|
16
|
-
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | preservedBlock)+"
|
|
16
|
+
content: "(paragraph | horizontalRule | pageBreak | table | textBox | blockSdt | preservedBlock | blockBookmarkBoundary)+"
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
//#endregion
|
|
@@ -6,12 +6,15 @@ import { collectHeadings } from "../../../utils/headingCollector.js";
|
|
|
6
6
|
import { tableOfContentsStyleLevel } from "../../../utils/tableOfContentsStyle.js";
|
|
7
7
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
8
8
|
import { autospacingMatchesBase } from "../../autospacingBase.js";
|
|
9
|
+
import { removeSectionBreakAtSelection, setSectionBreakType } from "../../commands/sectionBreak.js";
|
|
9
10
|
import { directParagraphAlignment } from "../../paragraphAlignment.js";
|
|
10
11
|
import { directionIsRtl } from "../../paragraphDirection.js";
|
|
11
12
|
import { withDirectParagraphSpacing } from "../../paragraphSpacing.js";
|
|
12
13
|
import { getDocumentBuiltInStyles } from "../../plugins/documentStyles.js";
|
|
14
|
+
import { mintSectionProperties, parseSectionBreakType, sectionBreakTypeOf } from "../../sectionCarrier.js";
|
|
13
15
|
import { listAttrsFromResolvedStyle, paragraphAttrsFromResolvedStyle } from "../../styles/resolvedStyleAttrs.js";
|
|
14
16
|
import { createNodeExtension } from "../create.js";
|
|
17
|
+
import { headingOutlineLevel, paragraphNumberingLevel, paragraphNumberingReferenceId } from "@stll/docx-core/model";
|
|
15
18
|
import { Fragment } from "prosemirror-model";
|
|
16
19
|
//#region src/prosemirror/extensions/core/ParagraphExtension.ts
|
|
17
20
|
/**
|
|
@@ -24,7 +27,7 @@ import { Fragment } from "prosemirror-model";
|
|
|
24
27
|
function paragraphAttrsToDOMStyle(attrs) {
|
|
25
28
|
const rawIndentLeft = Reflect.get(attrs, "indentLeft");
|
|
26
29
|
let indentLeft = typeof rawIndentLeft === "number" ? rawIndentLeft : void 0;
|
|
27
|
-
if (attrs.numPr
|
|
30
|
+
if (paragraphNumberingReferenceId(attrs.numPr) !== void 0 && (rawIndentLeft === null || rawIndentLeft === void 0)) indentLeft = ((paragraphNumberingLevel(attrs.numPr) ?? 0) + 1) * 720;
|
|
28
31
|
const style = paragraphToStyle({
|
|
29
32
|
...attrs.alignment !== void 0 ? { alignment: attrs.alignment } : {},
|
|
30
33
|
...attrs.spaceBefore !== void 0 ? { spaceBefore: attrs.spaceBefore } : {},
|
|
@@ -60,8 +63,8 @@ function numFmtToClass(numFmt) {
|
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
function getListClass(numPr, listIsBullet, listNumFmt) {
|
|
63
|
-
if (
|
|
64
|
-
const level = numPr
|
|
66
|
+
if (paragraphNumberingReferenceId(numPr) === void 0) return "";
|
|
67
|
+
const level = paragraphNumberingLevel(numPr) ?? 0;
|
|
65
68
|
if (listIsBullet) return `docx-list-bullet docx-list-level-${level}`;
|
|
66
69
|
return `docx-list-numbered ${numFmtToClass(listNumFmt)} docx-list-level-${level}`;
|
|
67
70
|
}
|
|
@@ -92,11 +95,11 @@ function cssLengthToTwips(value) {
|
|
|
92
95
|
*/
|
|
93
96
|
function cssTextAlignToAlignment(value) {
|
|
94
97
|
switch (value.trim().toLowerCase()) {
|
|
95
|
-
case "left":
|
|
96
|
-
case "start": return "
|
|
98
|
+
case "left": return "left";
|
|
99
|
+
case "start": return "start";
|
|
97
100
|
case "center": return "center";
|
|
98
|
-
case "right":
|
|
99
|
-
case "end": return "
|
|
101
|
+
case "right": return "right";
|
|
102
|
+
case "end": return "end";
|
|
100
103
|
case "justify": return "both";
|
|
101
104
|
default: return;
|
|
102
105
|
}
|
|
@@ -244,7 +247,6 @@ const paragraphNodeSpec = {
|
|
|
244
247
|
runInWithNext: { default: null },
|
|
245
248
|
defaultTextFormatting: { default: null },
|
|
246
249
|
_tableRunFormatting: { default: void 0 },
|
|
247
|
-
sectionBreakType: { default: null },
|
|
248
250
|
direction: { default: null },
|
|
249
251
|
outlineLevel: { default: null },
|
|
250
252
|
bookmarks: { default: null },
|
|
@@ -269,14 +271,14 @@ const paragraphNodeSpec = {
|
|
|
269
271
|
const alignmentFromStyle = parseParagraphAlignment(element.dataset["alignmentFromStyle"]);
|
|
270
272
|
const styleId = element.dataset["styleId"];
|
|
271
273
|
const tableOfContentsLevel = Number(element.dataset["tableOfContentsLevel"]);
|
|
272
|
-
const sectionBreakType = element.dataset["sectionBreak"];
|
|
274
|
+
const sectionBreakType = parseSectionBreakType(element.dataset["sectionBreak"]);
|
|
273
275
|
const attrs = {
|
|
274
276
|
...paraId ? { paraId } : {},
|
|
275
277
|
...alignment ? { alignment } : {},
|
|
276
278
|
...alignmentFromStyle ? { alignmentFromStyle } : {},
|
|
277
279
|
...styleId ? { styleId } : {},
|
|
278
280
|
...Number.isSafeInteger(tableOfContentsLevel) && tableOfContentsLevel > 0 ? { _tableOfContentsLevel: tableOfContentsLevel } : {},
|
|
279
|
-
...sectionBreakType ? { sectionBreakType } : {}
|
|
281
|
+
...sectionBreakType ? { _sectionProperties: mintSectionProperties(sectionBreakType) } : {}
|
|
280
282
|
};
|
|
281
283
|
const styleAttrs = extractParagraphAttrsFromStyle(element);
|
|
282
284
|
const mergedAlignment = attrs.alignment || styleAttrs.alignment;
|
|
@@ -304,11 +306,12 @@ const paragraphNodeSpec = {
|
|
|
304
306
|
getAttrs(dom) {
|
|
305
307
|
const level = Number.parseInt(tag.charAt(1), 10);
|
|
306
308
|
const styleAttrs = extractParagraphAttrsFromStyle(dom);
|
|
309
|
+
const outlineLevel = headingOutlineLevel(level - 1);
|
|
307
310
|
return {
|
|
308
311
|
...styleAttrs,
|
|
309
312
|
...styleAttrs.alignment ? { _originalFormatting: { alignment: styleAttrs.alignment } } : {},
|
|
310
313
|
styleId: `Heading${level}`,
|
|
311
|
-
outlineLevel:
|
|
314
|
+
...outlineLevel === void 0 ? {} : { outlineLevel }
|
|
312
315
|
};
|
|
313
316
|
}
|
|
314
317
|
}))],
|
|
@@ -328,8 +331,9 @@ const paragraphNodeSpec = {
|
|
|
328
331
|
if (typeof attrs._tableOfContentsLevel === "number") domAttrs["data-table-of-contents-level"] = String(attrs._tableOfContentsLevel);
|
|
329
332
|
if (attrs.listMarker) domAttrs["data-list-marker"] = attrs.listMarker;
|
|
330
333
|
if (directionIsRtl(attrs.direction)) domAttrs["dir"] = "rtl";
|
|
331
|
-
|
|
332
|
-
|
|
334
|
+
const sectionBreakType = sectionBreakTypeOf(attrs._sectionProperties);
|
|
335
|
+
if (sectionBreakType) {
|
|
336
|
+
domAttrs["data-section-break"] = sectionBreakType;
|
|
333
337
|
domAttrs["class"] = `${domAttrs["class"] ? `${domAttrs["class"]} ` : ""}docx-section-break`;
|
|
334
338
|
}
|
|
335
339
|
return [
|
|
@@ -604,8 +608,8 @@ const ParagraphExtension = createNodeExtension({
|
|
|
604
608
|
styleId: null,
|
|
605
609
|
_tableOfContentsLevel: null
|
|
606
610
|
}),
|
|
607
|
-
insertSectionBreak: (breakType) =>
|
|
608
|
-
removeSectionBreak: () =>
|
|
611
|
+
insertSectionBreak: (breakType) => setSectionBreakType(breakType),
|
|
612
|
+
removeSectionBreak: () => removeSectionBreakAtSelection,
|
|
609
613
|
generateTOC: ({ title }) => (state, dispatch) => {
|
|
610
614
|
const builtInStyles = getDocumentBuiltInStyles(state);
|
|
611
615
|
const headings = collectHeadings(state.doc, builtInStyles);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergeTextFormatting } from "../../../utils/textFormattingMerge.js";
|
|
2
2
|
import { expectCharacterStyleMarkAttrs, expectRunFormattingOverrideMarkAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { keepSectionBreaksOnSurvivingMarks } from "../../commands/sectionBreak.js";
|
|
3
4
|
import { getDocumentStyleResolver } from "../../plugins/documentStyles.js";
|
|
4
5
|
import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
|
|
5
6
|
import { authoredRunFormattingFromAttrs } from "../../runFormattingProvenance.js";
|
|
@@ -185,8 +186,8 @@ const BaseKeymapExtension = createExtension({
|
|
|
185
186
|
return { keyboardShortcuts: {
|
|
186
187
|
...baseKeymap,
|
|
187
188
|
Enter: splitBlockClearBorders,
|
|
188
|
-
Backspace: chainCommands(deleteSelection, clearIndentOnBackspace, joinBackward),
|
|
189
|
-
Delete: chainCommands(deleteSelection, joinForward),
|
|
189
|
+
Backspace: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, clearIndentOnBackspace, joinBackward)),
|
|
190
|
+
Delete: keepSectionBreaksOnSurvivingMarks(chainCommands(deleteSelection, joinForward)),
|
|
190
191
|
"Mod-a": selectAll,
|
|
191
192
|
Escape: selectParentNode
|
|
192
193
|
} };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBulletLevel } from "../../../docx/numberingParser.js";
|
|
2
|
+
import { NO_PARAGRAPH_NUMBERING, paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId } from "../../../docx/numberingReference.js";
|
|
2
3
|
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
3
4
|
import { PPR_CHANGE_SCOPED_ATTR_KEYS, hasSerializableParagraphPropertyChange } from "../../commands/propertyChangeScope.js";
|
|
4
5
|
import { CLEARED_LIST_RENDERING_ATTRS } from "../../listMarker.js";
|
|
5
6
|
import { LIST_RENDERING_ATTR_KEYS } from "../../listRenderingAttrs.js";
|
|
7
|
+
import { resolveListState } from "../../listState.js";
|
|
8
|
+
import { paragraphNumberingAttr } from "../../numberingAttr.js";
|
|
6
9
|
import { getDocumentNumbering } from "../../plugins/documentNumbering.js";
|
|
7
10
|
import { SUGGESTION_META, makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
8
11
|
import { listLevelAttrPatch } from "../../styles/resolvedStyleAttrs.js";
|
|
@@ -49,11 +52,7 @@ function getPreviousListFormatting(attrs) {
|
|
|
49
52
|
return previousFormatting;
|
|
50
53
|
}
|
|
51
54
|
function clearListAttrs(attrs) {
|
|
52
|
-
const
|
|
53
|
-
const numPr = isNumberingReference(styleNumPr?.numId) ? {
|
|
54
|
-
numId: 0,
|
|
55
|
-
ilvl: attrs.numPr?.ilvl ?? styleNumPr?.ilvl ?? 0
|
|
56
|
-
} : null;
|
|
55
|
+
const numPr = paragraphNumberingReferenceId(attrs.numPrFromStyle) === void 0 ? null : paragraphNumberingAttr(NO_PARAGRAPH_NUMBERING);
|
|
57
56
|
return {
|
|
58
57
|
...attrs,
|
|
59
58
|
numPr,
|
|
@@ -61,14 +60,31 @@ function clearListAttrs(attrs) {
|
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
62
|
function hasActiveListNumbering(attrs) {
|
|
64
|
-
return
|
|
63
|
+
return attrs.numPr?.kind === "reference";
|
|
65
64
|
}
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The numbering instances Folio mints for its own toolbar lists. They are the
|
|
67
|
+
* ids the autoformat rules and the list buttons create; a document Folio did
|
|
68
|
+
* not create numbers its lists however its author did, which is why nothing
|
|
69
|
+
* reads a list's kind off its id any more.
|
|
70
|
+
*/
|
|
71
|
+
const FOLIO_BULLET_NUM_ID = 1;
|
|
72
|
+
const FOLIO_NUMBERED_NUM_ID = 2;
|
|
73
|
+
const targetNumIdForIntent = (numbering, preferredNumId, ilvl, intent) => {
|
|
74
|
+
const matchesIntent = (numId) => {
|
|
75
|
+
const level = numbering?.getLevel(numId, ilvl) ?? null;
|
|
76
|
+
return level !== null && (isBulletLevel(level) ? "bullet" : "numbered") === intent;
|
|
77
|
+
};
|
|
78
|
+
if (matchesIntent(preferredNumId)) return preferredNumId;
|
|
79
|
+
return numbering?.definitions.nums.find(({ numId }) => matchesIntent(numId))?.numId ?? preferredNumId;
|
|
80
|
+
};
|
|
81
|
+
function toggleList(numId, intent) {
|
|
67
82
|
return (state, dispatch) => {
|
|
68
83
|
const { $from, $to } = state.selection;
|
|
69
84
|
const paragraph = $from.parent;
|
|
70
85
|
if (paragraph.type.name !== "paragraph") return false;
|
|
71
|
-
const
|
|
86
|
+
const numbering = getDocumentNumbering(state);
|
|
87
|
+
const isInSameList = resolveListState(numbering, expectParagraphAttrs(paragraph).numPr).type === intent;
|
|
72
88
|
const rev = makeRevisionInfo(state);
|
|
73
89
|
if (rev) {
|
|
74
90
|
let hasPendingChange = false;
|
|
@@ -89,16 +105,19 @@ function toggleList(numId) {
|
|
|
89
105
|
let nextAttrs;
|
|
90
106
|
if (isInSameList) nextAttrs = clearListAttrs(expectParagraphAttrs(node));
|
|
91
107
|
else {
|
|
92
|
-
const
|
|
108
|
+
const ilvl = paragraphNumberingLevel(expectParagraphAttrs(node).numPr) ?? 0;
|
|
109
|
+
const targetNumId = targetNumIdForIntent(numbering, numId, ilvl, intent);
|
|
110
|
+
const definition = numbering?.getLevel(targetNumId, ilvl) ?? null;
|
|
111
|
+
const isBullet = definition === null ? intent === "bullet" : isBulletLevel(definition);
|
|
93
112
|
nextAttrs = {
|
|
94
113
|
...node.attrs,
|
|
95
114
|
...CLEARED_LIST_RENDERING_ATTRS,
|
|
96
|
-
numPr: {
|
|
97
|
-
numId,
|
|
98
|
-
ilvl
|
|
99
|
-
},
|
|
115
|
+
numPr: paragraphNumberingAttr(paragraphNumberingReference({
|
|
116
|
+
numId: targetNumId,
|
|
117
|
+
ilvl
|
|
118
|
+
})),
|
|
100
119
|
listIsBullet: isBullet,
|
|
101
|
-
listNumFmt: isBullet ? null : "decimal"
|
|
120
|
+
listNumFmt: isBullet ? null : definition?.numFmt ?? "decimal"
|
|
102
121
|
};
|
|
103
122
|
}
|
|
104
123
|
if (rev) {
|
|
@@ -113,8 +132,8 @@ function toggleList(numId) {
|
|
|
113
132
|
return true;
|
|
114
133
|
};
|
|
115
134
|
}
|
|
116
|
-
const toggleBulletList = (state, dispatch) => toggleList(
|
|
117
|
-
const toggleNumberedList = (state, dispatch) => toggleList(
|
|
135
|
+
const toggleBulletList = (state, dispatch) => toggleList(FOLIO_BULLET_NUM_ID, "bullet")(state, dispatch);
|
|
136
|
+
const toggleNumberedList = (state, dispatch) => toggleList(FOLIO_NUMBERED_NUM_ID, "numbered")(state, dispatch);
|
|
118
137
|
const attrsForListLevel = (state, attrs, level) => {
|
|
119
138
|
if (!hasActiveListNumbering(attrs)) panic("Cannot change the level of a list without a numbering id");
|
|
120
139
|
return {
|
|
@@ -131,7 +150,7 @@ const increaseListLevel = (state, dispatch) => {
|
|
|
131
150
|
if (paragraph.type.name !== "paragraph") return false;
|
|
132
151
|
const attrs = expectParagraphAttrs(paragraph);
|
|
133
152
|
if (!hasActiveListNumbering(attrs)) return false;
|
|
134
|
-
const currentLevel = attrs.numPr.ilvl
|
|
153
|
+
const currentLevel = attrs.numPr.ilvl ?? 0;
|
|
135
154
|
if (currentLevel >= 8) return false;
|
|
136
155
|
if (!dispatch) return true;
|
|
137
156
|
const paragraphPos = $from.before($from.depth);
|
|
@@ -144,7 +163,7 @@ const decreaseListLevel = (state, dispatch) => {
|
|
|
144
163
|
if (paragraph.type.name !== "paragraph") return false;
|
|
145
164
|
const attrs = expectParagraphAttrs(paragraph);
|
|
146
165
|
if (!hasActiveListNumbering(attrs)) return false;
|
|
147
|
-
const currentLevel = attrs.numPr.ilvl
|
|
166
|
+
const currentLevel = attrs.numPr.ilvl ?? 0;
|
|
148
167
|
if (!dispatch) return true;
|
|
149
168
|
const paragraphPos = $from.before($from.depth);
|
|
150
169
|
if (currentLevel <= 0) dispatch(state.tr.setNodeMarkup(paragraphPos, void 0, {
|
|
@@ -184,7 +203,7 @@ function getListInfo(state) {
|
|
|
184
203
|
if (!hasActiveListNumbering(attrs)) return null;
|
|
185
204
|
return {
|
|
186
205
|
numId: attrs.numPr.numId,
|
|
187
|
-
ilvl: attrs.numPr.ilvl
|
|
206
|
+
ilvl: attrs.numPr.ilvl ?? 0
|
|
188
207
|
};
|
|
189
208
|
}
|
|
190
209
|
function exitListOnEmptyEnter() {
|
|
@@ -240,7 +259,7 @@ function increaseListIndent() {
|
|
|
240
259
|
if (node.type.name === "paragraph") {
|
|
241
260
|
const attrs = expectParagraphAttrs(node);
|
|
242
261
|
if (!hasActiveListNumbering(attrs)) return;
|
|
243
|
-
if ((attrs.numPr
|
|
262
|
+
if ((attrs.numPr.ilvl ?? 0) < 8) positions.push({
|
|
244
263
|
pos,
|
|
245
264
|
attrs
|
|
246
265
|
});
|
|
@@ -249,7 +268,7 @@ function increaseListIndent() {
|
|
|
249
268
|
if (positions.length === 0) return false;
|
|
250
269
|
if (dispatch) {
|
|
251
270
|
let tr = state.tr;
|
|
252
|
-
for (const { pos, attrs } of positions) tr = tr.setNodeMarkup(pos, void 0, attrsForListLevel(state, attrs, (attrs.numPr
|
|
271
|
+
for (const { pos, attrs } of positions) tr = tr.setNodeMarkup(pos, void 0, attrsForListLevel(state, attrs, (attrs.numPr.ilvl ?? 0) + 1));
|
|
253
272
|
dispatch(tr);
|
|
254
273
|
}
|
|
255
274
|
return true;
|
|
@@ -272,7 +291,7 @@ function decreaseListIndent() {
|
|
|
272
291
|
if (dispatch) {
|
|
273
292
|
let tr = state.tr;
|
|
274
293
|
for (const { pos, attrs } of positions) {
|
|
275
|
-
const currentLevel = attrs.numPr
|
|
294
|
+
const currentLevel = attrs.numPr.ilvl ?? 0;
|
|
276
295
|
if (currentLevel <= 0) tr = tr.setNodeMarkup(pos, void 0, {
|
|
277
296
|
...clearListAttrs(attrs),
|
|
278
297
|
indentLeft: null,
|
|
@@ -318,7 +337,7 @@ const listAutoformat = (marker, toggleCommand) => new InputRule(marker, (state,
|
|
|
318
337
|
const { $from } = state.selection;
|
|
319
338
|
if ($from.parent.type.name !== "paragraph") return null;
|
|
320
339
|
if (start !== $from.start()) return null;
|
|
321
|
-
if (expectParagraphAttrs($from.parent).numPr
|
|
340
|
+
if (paragraphNumberingReferenceId(expectParagraphAttrs($from.parent).numPr) !== void 0) return null;
|
|
322
341
|
if (makeRevisionInfo(state)) return null;
|
|
323
342
|
const toggled = captureTransaction(toggleCommand, state);
|
|
324
343
|
if (!toggled) return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { canonicalJson } from "../../../utils/canonicalJson.js";
|
|
2
|
+
import { sectionPropertiesOf } from "../../sectionCarrier.js";
|
|
2
3
|
import { createExtension } from "../create.js";
|
|
3
4
|
import { AddMarkStep, AddNodeMarkStep, AttrStep, RemoveMarkStep, RemoveNodeMarkStep } from "prosemirror-transform";
|
|
4
5
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
@@ -22,13 +23,13 @@ function countDocumentStructure(doc) {
|
|
|
22
23
|
parent.forEach((node, _offset, index) => {
|
|
23
24
|
if (node.type.name === "paragraph") {
|
|
24
25
|
paragraphs++;
|
|
25
|
-
|
|
26
|
+
const sectionProperties = sectionPropertiesOf(node);
|
|
27
|
+
if (sectionProperties !== null) {
|
|
26
28
|
sectionEndpoints++;
|
|
27
29
|
endpointRecords.push({
|
|
28
30
|
path: parentPath.length === 0 ? `${index}` : `${parentPath}.${index}`,
|
|
29
31
|
paraId: node.attrs["paraId"] ?? null,
|
|
30
|
-
|
|
31
|
-
sectionProperties: node.attrs["_sectionProperties"] ?? null
|
|
32
|
+
sectionProperties
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
return;
|
|
@@ -11,9 +11,9 @@ import { Extension } from "../types.js";
|
|
|
11
11
|
* default clipboard parser; ProseMirror chains every plugin's
|
|
12
12
|
* `transformPastedHTML`, so this cooperates with the inliner rather than
|
|
13
13
|
* replacing it, and `<style>` blocks are left intact for it to resolve.
|
|
14
|
-
* 2. `transformPasted` — drops unpaired bookmark boundaries,
|
|
15
|
-
* pasted headings at the open document's own heading style
|
|
16
|
-
* {@link retargetPastedHeadingStyles}).
|
|
14
|
+
* 2. `transformPasted` — drops unpaired bookmark and move-range boundaries,
|
|
15
|
+
* then points pasted headings at the open document's own heading style
|
|
16
|
+
* (see {@link retargetPastedHeadingStyles}).
|
|
17
17
|
* 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
|
|
18
18
|
* the source formatting stripped (see {@link pasteWithoutFormatting}).
|
|
19
19
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pasteWithoutFormatting } from "../../commands/pastePlainText.js";
|
|
2
2
|
import { createExtension } from "../create.js";
|
|
3
3
|
import { Priority } from "../types.js";
|
|
4
|
-
import { cleanPastedHtml, removeUnpairedBookmarkBoundaries } from "./pasteCleanup.js";
|
|
4
|
+
import { cleanPastedHtml, removeUnpairedBookmarkBoundaries, removeUnpairedMoveRangeBoundaries } from "./pasteCleanup.js";
|
|
5
5
|
import { retargetPastedHeadingStyles } from "./pastedHeadingStyles.js";
|
|
6
6
|
import { Plugin } from "prosemirror-state";
|
|
7
7
|
//#region src/prosemirror/extensions/features/PasteCleanupExtension.ts
|
|
@@ -16,9 +16,9 @@ import { Plugin } from "prosemirror-state";
|
|
|
16
16
|
* default clipboard parser; ProseMirror chains every plugin's
|
|
17
17
|
* `transformPastedHTML`, so this cooperates with the inliner rather than
|
|
18
18
|
* replacing it, and `<style>` blocks are left intact for it to resolve.
|
|
19
|
-
* 2. `transformPasted` — drops unpaired bookmark boundaries,
|
|
20
|
-
* pasted headings at the open document's own heading style
|
|
21
|
-
* {@link retargetPastedHeadingStyles}).
|
|
19
|
+
* 2. `transformPasted` — drops unpaired bookmark and move-range boundaries,
|
|
20
|
+
* then points pasted headings at the open document's own heading style
|
|
21
|
+
* (see {@link retargetPastedHeadingStyles}).
|
|
22
22
|
* 3. `Mod-Alt-v` — "paste without formatting", inserting clipboard text with
|
|
23
23
|
* the source formatting stripped (see {@link pasteWithoutFormatting}).
|
|
24
24
|
*/
|
|
@@ -32,7 +32,7 @@ const PasteCleanupExtension = createExtension({
|
|
|
32
32
|
const internalClipboardToken = options.getInternalClipboardToken?.();
|
|
33
33
|
return cleanPastedHtml(html, { ...internalClipboardToken ? { internalClipboardToken } : {} });
|
|
34
34
|
},
|
|
35
|
-
transformPasted: (slice, view) => retargetPastedHeadingStyles(removeUnpairedBookmarkBoundaries(slice), view)
|
|
35
|
+
transformPasted: (slice, view) => retargetPastedHeadingStyles(removeUnpairedMoveRangeBoundaries(removeUnpairedBookmarkBoundaries(slice)), view)
|
|
36
36
|
} })],
|
|
37
37
|
keyboardShortcuts: { "Mod-Alt-v": pasteWithoutFormatting }
|
|
38
38
|
};
|
|
@@ -14,5 +14,7 @@ type CleanPastedHtmlOptions = {
|
|
|
14
14
|
declare function cleanPastedHtml(html: string, options?: CleanPastedHtmlOptions): string;
|
|
15
15
|
/** Remove incomplete or duplicate bookmark pairs at copied slice edges. */
|
|
16
16
|
declare function removeUnpairedBookmarkBoundaries(slice: Slice): Slice;
|
|
17
|
+
/** Remove incomplete, duplicate, or reversed tracked-move pairs at copied slice edges. */
|
|
18
|
+
declare function removeUnpairedMoveRangeBoundaries(slice: Slice): Slice;
|
|
17
19
|
//#endregion
|
|
18
|
-
export { cleanPastedHtml, removeUnpairedBookmarkBoundaries };
|
|
20
|
+
export { cleanPastedHtml, removeUnpairedBookmarkBoundaries, removeUnpairedMoveRangeBoundaries };
|