@stll/folio-core 0.52.0 → 0.54.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1779 -141
- package/dist/ai-edits/batch-claims.d.ts +145 -0
- package/dist/ai-edits/batch-claims.js +275 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +91 -7
- package/dist/ai-edits/headless.js +520 -51
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +6 -4
- package/dist/ai-edits/read.js +113 -50
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/revisionStretches.d.ts +17 -0
- package/dist/ai-edits/revisionStretches.js +80 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +180 -25
- package/dist/ai-edits/table-cell-mutations.d.ts +4 -2
- package/dist/ai-edits/table-cell-mutations.js +6 -2
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +44 -17
- package/dist/ai-edits/table-row-column-mutations.js +86 -34
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.d.ts +5 -1
- package/dist/compare/content-alignment.js +52 -34
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/inline-provenance.js +1 -1
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +65 -11
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/archiveInflation.d.ts +127 -0
- package/dist/docx/archiveInflation.js +181 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/metadataPrivacy.js +24 -1
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/noteReferenceMark.d.ts +15 -0
- package/dist/docx/noteReferenceMark.js +48 -0
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +96 -27
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +10 -2
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +175 -22
- package/dist/docx/rezip.js +31 -7
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.d.ts +3 -1
- package/dist/docx/selectiveXmlPatch.js +186 -39
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/boundedArchive.d.ts +8 -13
- package/dist/docx/server/boundedArchive.js +70 -59
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/server/extractDocxText.d.ts +8 -2
- package/dist/docx/server/extractDocxText.js +2 -2
- package/dist/docx/server/validateDocxConformance.d.ts +1 -1
- package/dist/docx/server/validateDocxConformance.js +1 -0
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +20 -2
- package/dist/docx/unzip.js +136 -25
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/fonts/embeddedFonts.js +1 -1
- package/dist/i18n/messages/catalogs.gen.d.ts +170 -34
- package/dist/i18n/messages/catalogs.gen.js +187 -51
- package/dist/i18n/messages/messages.gen.d.ts +10 -2
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +600 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureParagraph.js +2 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/measure/paragraphMeasureShared.d.ts +12 -1
- package/dist/layout-engine/measure/paragraphMeasureShared.js +14 -1
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/escape.d.ts +2 -2
- package/dist/markdown/escape.js +4 -5
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +121 -25
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.d.ts +10 -1
- package/dist/markdown/renderRuns.js +323 -69
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/clearRunColor.d.ts +6 -0
- package/dist/prosemirror/clearRunColor.js +46 -0
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +281 -212
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.js +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/hyperlink.js +2 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +3 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +24 -3
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +620 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +73 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +15 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +23 -7
- package/dist/prosemirror/containerFinalParagraph.d.ts +11 -5
- package/dist/prosemirror/containerFinalParagraph.js +7 -6
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +177 -605
- package/dist/prosemirror/conversion/toProseDoc.d.ts +4 -11
- package/dist/prosemirror/conversion/toProseDoc.js +70 -154
- package/dist/prosemirror/documentSchema.d.ts +8 -0
- package/dist/prosemirror/documentSchema.js +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +5 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +116 -63
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +4 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +24 -3
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.js +43 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +167 -128
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +124 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +33 -11
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +8 -4
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +2 -2
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +4 -3
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +15 -8
- package/dist/prosemirror/extensions/marks/markUtils.js +25 -10
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +46 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +2 -2
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +5 -3
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +121 -226
- package/dist/prosemirror/extensions/types.d.ts +11 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/hyperlinkRemoval.d.ts +9 -0
- package/dist/prosemirror/hyperlinkRemoval.js +129 -0
- package/dist/prosemirror/index.d.ts +5 -3
- package/dist/prosemirror/index.js +5 -3
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +92 -0
- package/dist/prosemirror/listNumbering.js +330 -0
- package/dist/prosemirror/listRendering.d.ts +27 -0
- package/dist/prosemirror/listRendering.js +27 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewNotes.d.ts +8 -0
- package/dist/prosemirror/markupViewNotes.js +49 -0
- package/dist/prosemirror/markupViewProjection.d.ts +97 -0
- package/dist/prosemirror/markupViewProjection.js +88 -0
- package/dist/prosemirror/noteReferenceReview.d.ts +77 -0
- package/dist/prosemirror/noteReferenceReview.js +332 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +32 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +21 -0
- package/dist/prosemirror/paragraphMarkJoin.js +26 -0
- package/dist/prosemirror/paragraphPropertyCarry.d.ts +64 -0
- package/dist/prosemirror/paragraphPropertyCarry.js +158 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyleState.d.ts +26 -0
- package/dist/prosemirror/plugins/documentStyleState.js +32 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +3 -13
- package/dist/prosemirror/plugins/documentStyles.js +67 -17
- package/dist/prosemirror/plugins/index.d.ts +2 -1
- package/dist/prosemirror/plugins/index.js +2 -1
- package/dist/prosemirror/plugins/paragraphStyleResolution.d.ts +15 -0
- package/dist/prosemirror/plugins/paragraphStyleResolution.js +230 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +27 -3
- package/dist/prosemirror/plugins/suggestionMode.js +490 -63
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +23 -3
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +39 -13
- package/dist/prosemirror/rebaseParagraphRuns.d.ts +36 -0
- package/dist/prosemirror/rebaseParagraphRuns.js +99 -0
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingFromMarks.d.ts +18 -0
- package/dist/prosemirror/runFormattingFromMarks.js +567 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/runFormattingReconciliation.js +10 -9
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +44 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.d.ts +59 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +145 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +21 -2
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +38 -1
- package/dist/prosemirror/styles/tableStyleRegions.d.ts +31 -0
- package/dist/prosemirror/styles/tableStyleRegions.js +55 -0
- package/dist/prosemirror/tableCellPaste.d.ts +74 -0
- package/dist/prosemirror/tableCellPaste.js +525 -0
- package/dist/prosemirror/tableGridMutation.d.ts +87 -2
- package/dist/prosemirror/tableGridMutation.js +255 -2
- package/dist/prosemirror/tableRunIn.d.ts +51 -0
- package/dist/prosemirror/tableRunIn.js +165 -0
- package/dist/prosemirror/textInput.js +11 -2
- package/dist/prosemirror/trackedRevisionPath.d.ts +17 -0
- package/dist/prosemirror/trackedRevisionPath.js +32 -0
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/server.d.ts +2 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +6 -5
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -56,6 +56,8 @@ type PreservedXmlAttrs = {
|
|
|
56
56
|
type PreservedBlockAttrs = {
|
|
57
57
|
/** Replayable markup, as `captureVerbatimXml` wrote it. */
|
|
58
58
|
xml: string;
|
|
59
|
+
/** Plain text safely extracted from a related w:altChunk part, when available. */
|
|
60
|
+
readerText?: string;
|
|
59
61
|
};
|
|
60
62
|
type BookmarkBoundaryAttrs = {
|
|
61
63
|
type: "start";
|
|
@@ -118,6 +120,13 @@ type ParagraphAttrs = {
|
|
|
118
120
|
* `paragraphNumberingAttr`, so a model value cannot land here unconverted.
|
|
119
121
|
*/
|
|
120
122
|
numPr?: ParagraphNumberingAttr;
|
|
123
|
+
/** Clipboard-only hint, replaced with a numbered paragraph before insertion. */
|
|
124
|
+
_pastedHtmlList?: {
|
|
125
|
+
group: number;
|
|
126
|
+
level: number;
|
|
127
|
+
kind: "bullet" | "numbered";
|
|
128
|
+
start?: number;
|
|
129
|
+
};
|
|
121
130
|
/**
|
|
122
131
|
* The style-sourced numPr value when `numPr` came from the paragraph
|
|
123
132
|
* style rather than direct formatting. While `numPr` still equals this,
|
|
@@ -526,7 +535,7 @@ type ImageAttrs = {
|
|
|
526
535
|
/**
|
|
527
536
|
* Field node attributes
|
|
528
537
|
*/
|
|
529
|
-
type
|
|
538
|
+
type CommonFieldAttrs = {
|
|
530
539
|
/** Field type: PAGE, NUMPAGES, DATE, MERGEFIELD, etc. */
|
|
531
540
|
fieldType: document_d_exports.FieldType;
|
|
532
541
|
/** Full field instruction (e.g. "PAGE \\* MERGEFORMAT") */
|
|
@@ -535,20 +544,30 @@ type FieldAttrs = {
|
|
|
535
544
|
displayText: string;
|
|
536
545
|
/** Imported cache that proved numbered REF resolution for this field. */
|
|
537
546
|
_numberedRefBaseline?: string;
|
|
538
|
-
/** Whether the field came from w:fldSimple or a complex fldChar range */
|
|
539
|
-
fieldKind: "simple" | "complex";
|
|
540
547
|
/** Field is locked */
|
|
541
548
|
fldLock?: boolean;
|
|
542
549
|
/** Field is dirty and should be recalculated by the host application */
|
|
543
550
|
dirty?: boolean;
|
|
544
|
-
/**
|
|
545
|
-
|
|
546
|
-
* `FORMCHECKBOX` with no cached result run), not authored content. A save
|
|
547
|
-
* omits it from the field's result so an unedited field keeps its
|
|
548
|
-
* original, resultless bytes. See `ComplexField.fieldResultIsFallback`.
|
|
549
|
-
*/
|
|
550
|
-
fieldResultIsFallback?: boolean;
|
|
551
|
+
/** Authored empty result runs, which have no visible ProseMirror children. */
|
|
552
|
+
_docxEmptyResultRuns?: document_d_exports.Run[];
|
|
551
553
|
};
|
|
554
|
+
type FieldAttrs = CommonFieldAttrs & ({
|
|
555
|
+
fieldKind: "simple";
|
|
556
|
+
fieldResultIsFallback?: never;
|
|
557
|
+
formFieldDataXml?: never;
|
|
558
|
+
_docxFieldCode?: never;
|
|
559
|
+
} | {
|
|
560
|
+
fieldKind: "complex";
|
|
561
|
+
/** Synthesized display text that must not become an authored result run. */
|
|
562
|
+
fieldResultIsFallback?: boolean;
|
|
563
|
+
/** Captured `w:ffData` on a complex field's begin character. */
|
|
564
|
+
formFieldDataXml?: string;
|
|
565
|
+
/** Source code runs; valid only while the instruction still matches. */
|
|
566
|
+
_docxFieldCode?: {
|
|
567
|
+
instruction: string;
|
|
568
|
+
runs: document_d_exports.Run[];
|
|
569
|
+
};
|
|
570
|
+
});
|
|
552
571
|
/**
|
|
553
572
|
* Math equation node attributes
|
|
554
573
|
*/
|
|
@@ -649,6 +668,12 @@ type BlockSdtAttrs = {
|
|
|
649
668
|
/** Verbatim XML for sdt siblings after sdtContent (range markers). */
|
|
650
669
|
rawSdtChildrenAfterContent?: string;
|
|
651
670
|
};
|
|
671
|
+
/** Verbatim shell retained around editable block custom XML content. */
|
|
672
|
+
type BlockCustomXmlAttrs = {
|
|
673
|
+
openingXml: string;
|
|
674
|
+
closingXml: string;
|
|
675
|
+
_originallyEmpty: boolean;
|
|
676
|
+
};
|
|
652
677
|
/**
|
|
653
678
|
* The `mc:AlternateContent` a shape or text box was read from, with a
|
|
654
679
|
* fingerprint of the node it was attached to. `fromProseDoc` hands the element
|
|
@@ -992,6 +1017,8 @@ type TableAttrs = {
|
|
|
992
1017
|
* none and a copy does not inherit one.
|
|
993
1018
|
*/
|
|
994
1019
|
_preserved?: document_d_exports.TablePreservedMarkup;
|
|
1020
|
+
/** Transparent table-level custom-XML wrappers, outermost first. */
|
|
1021
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
995
1022
|
/**
|
|
996
1023
|
* Marks this whole table as a *suggested* insertion (AI proposal). The table
|
|
997
1024
|
* is dropped from serialized DOCX until accepted; because OOXML has no tracked
|
|
@@ -1003,6 +1030,8 @@ type TableAttrs = {
|
|
|
1003
1030
|
* Table row attributes
|
|
1004
1031
|
*/
|
|
1005
1032
|
type TableRowAttrs = {
|
|
1033
|
+
/** Transaction-local cleanup state; cleared before dispatch or continuation capture. */
|
|
1034
|
+
_batchRowCleanup?: "pending" | null;
|
|
1006
1035
|
/** Row height (in twips) */
|
|
1007
1036
|
height?: number;
|
|
1008
1037
|
/** Height rule ('auto', 'exact', 'atLeast') */
|
|
@@ -1054,6 +1083,8 @@ type TableRowAttrs = {
|
|
|
1054
1083
|
* name the same control. See `TableRow.contentControls`.
|
|
1055
1084
|
*/
|
|
1056
1085
|
contentControls?: document_d_exports.SdtProperties[];
|
|
1086
|
+
/** Transparent row-level custom-XML wrappers, outermost first. */
|
|
1087
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
1057
1088
|
/**
|
|
1058
1089
|
* Markup the authored `w:tr` carried beside its cells, with the cell count
|
|
1059
1090
|
* that places it back between the same two cells. Follows the record the
|
|
@@ -1219,10 +1250,12 @@ type TableCellAttrs = {
|
|
|
1219
1250
|
* outermost first. The row's twin, one level down.
|
|
1220
1251
|
*/
|
|
1221
1252
|
contentControls?: document_d_exports.SdtProperties[];
|
|
1253
|
+
/** Transparent row-level custom-XML wrappers, outermost first. */
|
|
1254
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
1222
1255
|
/** Preserve a DOCX vMerge restart even when PM cannot model it as a rowspan. */
|
|
1223
1256
|
_preserveVMergeRestart?: boolean;
|
|
1224
1257
|
/** Original DOCX vMerge continuation cells skipped into this PM rowspan. */
|
|
1225
1258
|
_docxVMergeContinuationCells?: unknown;
|
|
1226
1259
|
};
|
|
1227
1260
|
//#endregion
|
|
1228
|
-
export { AlternateContentAttrs, AuthoredEmuAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, CommentReferenceAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PRESERVED_XML_LEVELS, PageBreakRunAttrs, ParagraphAttrs, ParagraphAttrsPatch, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
1261
|
+
export { AlternateContentAttrs, AuthoredEmuAttrs, BlockCustomXmlAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, CommentReferenceAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PRESERVED_XML_LEVELS, PageBreakRunAttrs, ParagraphAttrs, ParagraphAttrsPatch, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/sectionMarkEdits.d.ts
|
|
5
|
+
type SectionMarkEdits = {
|
|
6
|
+
/** Section records whose paragraph mark a replacement deleted. */
|
|
7
|
+
deletedMarks: ReadonlySet<document_d_exports.SectionProperties>;
|
|
8
|
+
/**
|
|
9
|
+
* Paragraphs of the final document, by position, and the section record
|
|
10
|
+
* each must hold because of the mark it now ends with.
|
|
11
|
+
*/
|
|
12
|
+
carriers: readonly {
|
|
13
|
+
position: number;
|
|
14
|
+
record: document_d_exports.SectionProperties | null;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
/** Read `transactions`, applied in order and ending at `finalDoc`. */
|
|
18
|
+
declare const sectionMarkEditsOf: (transactions: readonly Transaction[], finalDoc: Node) => SectionMarkEdits;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SectionMarkEdits, sectionMarkEditsOf };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { sectionPropertiesOf } from "./sectionCarrier.js";
|
|
2
|
+
import { Mapping, ReplaceStep } from "prosemirror-transform";
|
|
3
|
+
//#region src/prosemirror/sectionMarkEdits.ts
|
|
4
|
+
const isParagraph = (node) => node.type.name === "paragraph";
|
|
5
|
+
/** Read `transactions`, applied in order and ending at `finalDoc`. */
|
|
6
|
+
const sectionMarkEditsOf = (transactions, finalDoc) => {
|
|
7
|
+
const deletedMarks = /* @__PURE__ */ new Set();
|
|
8
|
+
const carriers = [];
|
|
9
|
+
const replacements = [];
|
|
10
|
+
const mapping = new Mapping();
|
|
11
|
+
for (const transaction of transactions) for (const [index, step] of transaction.steps.entries()) {
|
|
12
|
+
const doc = transaction.docs[index];
|
|
13
|
+
if (step instanceof ReplaceStep && step.from < step.to && doc) replacements.push({
|
|
14
|
+
step,
|
|
15
|
+
doc,
|
|
16
|
+
mapIndex: mapping.maps.length
|
|
17
|
+
});
|
|
18
|
+
const map = transaction.mapping.maps[index];
|
|
19
|
+
if (map) mapping.appendMap(map);
|
|
20
|
+
}
|
|
21
|
+
for (const { step, doc, mapIndex } of replacements) {
|
|
22
|
+
const { from, to } = step;
|
|
23
|
+
doc.nodesBetween(from, to, (node, position) => {
|
|
24
|
+
if (!isParagraph(node)) return true;
|
|
25
|
+
const record = sectionPropertiesOf(node);
|
|
26
|
+
const markFrom = position + node.nodeSize - 1;
|
|
27
|
+
if (record && markFrom >= from && markFrom + 1 <= to) deletedMarks.add(record);
|
|
28
|
+
return false;
|
|
29
|
+
});
|
|
30
|
+
const $from = doc.resolve(from);
|
|
31
|
+
const $to = doc.resolve(to);
|
|
32
|
+
if (!isParagraph($from.parent) || !isParagraph($to.parent) || $from.start() === $to.start()) continue;
|
|
33
|
+
const leftRecord = sectionPropertiesOf($from.parent);
|
|
34
|
+
const rightRecord = sectionPropertiesOf($to.parent);
|
|
35
|
+
if (leftRecord === null && rightRecord === null) continue;
|
|
36
|
+
const after = mapping.slice(mapIndex);
|
|
37
|
+
const left = after.mapResult(from, -1);
|
|
38
|
+
const right = after.mapResult(to, 1);
|
|
39
|
+
if (right.deleted) continue;
|
|
40
|
+
const $right = finalDoc.resolve(right.pos);
|
|
41
|
+
if (!isParagraph($right.parent)) continue;
|
|
42
|
+
carriers.push({
|
|
43
|
+
position: $right.before(),
|
|
44
|
+
record: rightRecord
|
|
45
|
+
});
|
|
46
|
+
if (left.deleted) continue;
|
|
47
|
+
const $left = finalDoc.resolve(left.pos);
|
|
48
|
+
if (isParagraph($left.parent) && $left.start() !== $right.start()) carriers.push({
|
|
49
|
+
position: $left.before(),
|
|
50
|
+
record: null
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
deletedMarks,
|
|
55
|
+
carriers
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { sectionMarkEditsOf };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { EditorState } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/storyListNumbering.d.ts
|
|
5
|
+
type StoryListNumbering = {
|
|
6
|
+
/** The story with every colliding list moved to its own ids. */
|
|
7
|
+
doc: Node;
|
|
8
|
+
/** `numbering` plus the lists the story defines. */
|
|
9
|
+
numbering: document_d_exports.NumberingDefinitions | undefined;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The story in `state` as it should be written into a package whose numbering
|
|
13
|
+
* is now `numbering`, and that numbering completed with the story's lists.
|
|
14
|
+
*/
|
|
15
|
+
declare const storyListNumbering: (state: EditorState, numbering: document_d_exports.NumberingDefinitions | undefined) => StoryListNumbering;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { storyListNumbering };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getCachedNumberingMap, isBulletLevel } from "../docx/numberingParser.js";
|
|
2
|
+
import { paragraphNumberingLevel, paragraphNumberingReference, paragraphNumberingReferenceId } from "../docx/numberingReference.js";
|
|
3
|
+
import { expectParagraphAttrs } from "./attrs/index.js";
|
|
4
|
+
import { completeNumberingForDoc, paragraphListReferences } from "./listInstanceReferences.js";
|
|
5
|
+
import { paragraphNumberingAttr } from "./numberingAttr.js";
|
|
6
|
+
import { getPackageNumberingDefinitions } from "./plugins/documentNumbering.js";
|
|
7
|
+
import { Transform } from "prosemirror-transform";
|
|
8
|
+
//#region src/prosemirror/storyListNumbering.ts
|
|
9
|
+
const remappedNumPr = (numPr, numIds) => {
|
|
10
|
+
const numId = paragraphNumberingReferenceId(numPr ?? void 0);
|
|
11
|
+
const next = numId === void 0 ? void 0 : numIds.get(numId);
|
|
12
|
+
if (next === void 0) return numPr;
|
|
13
|
+
const ilvl = paragraphNumberingLevel(numPr ?? void 0);
|
|
14
|
+
return paragraphNumberingAttr(paragraphNumberingReference(ilvl === void 0 ? { numId: next } : {
|
|
15
|
+
numId: next,
|
|
16
|
+
ilvl
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
const remappedAbstractNumId = (abstractNumId, remap) => {
|
|
20
|
+
if (abstractNumId === null || abstractNumId === void 0 || remap.baseAbstractNumIds.has(abstractNumId)) return abstractNumId;
|
|
21
|
+
let next = remap.abstractNumIds.get(abstractNumId);
|
|
22
|
+
if (next === void 0) {
|
|
23
|
+
next = remap.nextAbstractNumId++;
|
|
24
|
+
remap.abstractNumIds.set(abstractNumId, next);
|
|
25
|
+
}
|
|
26
|
+
return next;
|
|
27
|
+
};
|
|
28
|
+
const maxOf = (ids, floor) => {
|
|
29
|
+
let max = floor;
|
|
30
|
+
for (const id of ids) max = Math.max(max, id);
|
|
31
|
+
return max;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The story in `state` as it should be written into a package whose numbering
|
|
35
|
+
* is now `numbering`, and that numbering completed with the story's lists.
|
|
36
|
+
*/
|
|
37
|
+
const storyListNumbering = (state, numbering) => {
|
|
38
|
+
const packageDefinitions = getPackageNumberingDefinitions(state);
|
|
39
|
+
const storyBase = new Set((packageDefinitions?.nums ?? []).map(({ numId }) => numId));
|
|
40
|
+
const defined = new Set((numbering?.nums ?? []).map(({ numId }) => numId));
|
|
41
|
+
const definedMap = numbering ? getCachedNumberingMap(numbering) : null;
|
|
42
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
43
|
+
const colliding = /* @__PURE__ */ new Set();
|
|
44
|
+
state.doc.descendants((node) => {
|
|
45
|
+
if (node.type.name !== "paragraph") return true;
|
|
46
|
+
for (const numId of paragraphListReferences(node)) referenced.add(numId);
|
|
47
|
+
const attrs = expectParagraphAttrs(node);
|
|
48
|
+
const numId = paragraphNumberingReferenceId(attrs.numPr);
|
|
49
|
+
if (numId !== void 0 && !storyBase.has(numId) && definedMap?.hasNumbering(numId)) {
|
|
50
|
+
const level = definedMap.getLevel(numId, paragraphNumberingLevel(attrs.numPr) ?? 0);
|
|
51
|
+
if (!(level !== null && isBulletLevel(level) === (attrs.listIsBullet === true) && (attrs.listAbstractNumId ?? void 0) === (definedMap.getAbstractNumId(numId) ?? void 0))) colliding.add(numId);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
});
|
|
55
|
+
if (colliding.size === 0) return {
|
|
56
|
+
doc: state.doc,
|
|
57
|
+
numbering: completeNumberingForDoc(numbering, state.doc)
|
|
58
|
+
};
|
|
59
|
+
let nextNumId = maxOf([...defined, ...referenced], 0) + 1;
|
|
60
|
+
const remap = {
|
|
61
|
+
numIds: new Map([...colliding].map((numId) => [numId, nextNumId++])),
|
|
62
|
+
baseAbstractNumIds: new Set((packageDefinitions?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId)),
|
|
63
|
+
abstractNumIds: /* @__PURE__ */ new Map(),
|
|
64
|
+
nextAbstractNumId: maxOf((numbering?.abstractNums ?? []).map(({ abstractNumId }) => abstractNumId), -1) + 1
|
|
65
|
+
};
|
|
66
|
+
const tr = new Transform(state.doc);
|
|
67
|
+
state.doc.descendants((node, pos) => {
|
|
68
|
+
if (node.type.name !== "paragraph") return true;
|
|
69
|
+
const attrs = expectParagraphAttrs(node);
|
|
70
|
+
const numId = paragraphNumberingReferenceId(attrs.numPr);
|
|
71
|
+
const moves = numId !== void 0 && remap.numIds.has(numId);
|
|
72
|
+
const changes = attrs._propertyChanges?.map((change) => {
|
|
73
|
+
const previous = change.previousFormatting;
|
|
74
|
+
const previousNumId = paragraphNumberingReferenceId(previous?.numPr ?? void 0);
|
|
75
|
+
if (!previous || previousNumId === void 0 || !remap.numIds.has(previousNumId)) return change;
|
|
76
|
+
return {
|
|
77
|
+
...change,
|
|
78
|
+
previousFormatting: {
|
|
79
|
+
...previous,
|
|
80
|
+
numPr: remappedNumPr(previous.numPr, remap.numIds),
|
|
81
|
+
listAbstractNumId: remappedAbstractNumId(previous.listAbstractNumId, remap) ?? void 0
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
const changesMoved = changes?.some((change, index) => change !== attrs._propertyChanges?.[index]);
|
|
86
|
+
if (moves || changesMoved) tr.setNodeMarkup(pos, void 0, {
|
|
87
|
+
...node.attrs,
|
|
88
|
+
...moves ? {
|
|
89
|
+
numPr: remappedNumPr(attrs.numPr, remap.numIds),
|
|
90
|
+
listAbstractNumId: remappedAbstractNumId(attrs.listAbstractNumId, remap) ?? null
|
|
91
|
+
} : {},
|
|
92
|
+
...changesMoved ? { _propertyChanges: changes } : {}
|
|
93
|
+
});
|
|
94
|
+
return false;
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
doc: tr.doc,
|
|
98
|
+
numbering: completeNumberingForDoc(numbering, tr.doc)
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
export { storyListNumbering };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { ParagraphAttrs } from "../schema/nodes.js";
|
|
3
|
+
import { TableCellParagraphSpacingOverlay } from "./styleResolver.js";
|
|
4
|
+
import { StyleEngine } from "../../style-engine/styleEngine.js";
|
|
5
|
+
import "../../style-engine/index.js";
|
|
6
|
+
import { TableStyleRegion } from "./tableStyleRegions.js";
|
|
7
|
+
//#region src/prosemirror/styles/paragraphStyleCascade.d.ts
|
|
8
|
+
/** The resolver surface the paragraph cascade reads. */
|
|
9
|
+
type ParagraphCascadeResolver = Pick<StyleEngine, "getStyle" | "getDocDefaults" | "getDefaultParagraphStyle" | "getDefaultCharacterStyle" | "getRunStyleOwnProperties" | "resolveParagraphStyleInTable">;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve an embedded character-style reference without importing
|
|
12
|
+
* `docDefaults`. The caller already has the paragraph cascade, including
|
|
13
|
+
* document defaults, and will layer these own properties over it.
|
|
14
|
+
*/
|
|
15
|
+
type ParagraphDefaultFormattingResolver = Pick<StyleEngine, "getStyle" | "getDocDefaults" | "getDefaultParagraphStyle" | "getDefaultCharacterStyle" | "getRunStyleOwnProperties">;
|
|
16
|
+
declare function resolveRunFormattingWithoutDefaults(formatting: document_d_exports.TextFormatting | undefined, styleResolver: ParagraphDefaultFormattingResolver | null): document_d_exports.TextFormatting | undefined;
|
|
17
|
+
/** @internal Recompute a paragraph's inherited run defaults from authored package state. */
|
|
18
|
+
declare function resolveParagraphDefaultTextFormatting(styleId: string | undefined, formatting: document_d_exports.Paragraph["formatting"] | undefined, styleResolver: ParagraphDefaultFormattingResolver, options?: {
|
|
19
|
+
includeParagraphMarkRunProperties?: boolean;
|
|
20
|
+
}): document_d_exports.TextFormatting | undefined;
|
|
21
|
+
type ParagraphStyleCascadeInput = {
|
|
22
|
+
styleId: string | undefined;
|
|
23
|
+
/** What the paragraph states itself; each stated field wins over the cascade. */
|
|
24
|
+
formatting: document_d_exports.ParagraphFormatting | undefined;
|
|
25
|
+
styleResolver: ParagraphCascadeResolver;
|
|
26
|
+
/**
|
|
27
|
+
* The enclosing table style's modeled paragraph fields, layered between
|
|
28
|
+
* docDefaults and the paragraph's own style chain (cell paragraphs only).
|
|
29
|
+
*/
|
|
30
|
+
tableParagraphOverlay?: TableCellParagraphSpacingOverlay | undefined;
|
|
31
|
+
/** Whether the paragraph mark's own run properties join the run defaults. */
|
|
32
|
+
includeParagraphMarkRunProperties: boolean;
|
|
33
|
+
};
|
|
34
|
+
type ParagraphStyleCascade = {
|
|
35
|
+
/** The effective attrs, with the provenance a save needs to keep inherited values out of `w:pPr`. */
|
|
36
|
+
attrs: ParagraphAttrs;
|
|
37
|
+
/** The resolved style cascade the attrs were read from. */
|
|
38
|
+
stylePpr: document_d_exports.ParagraphFormatting | undefined;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Project a paragraph's style cascade onto its editor attrs: each field the
|
|
42
|
+
* paragraph states wins, every other field reads the cascade, and the
|
|
43
|
+
* provenance attrs record which is which.
|
|
44
|
+
*/
|
|
45
|
+
declare function paragraphStyleCascadeAttrs({ styleId, formatting, styleResolver, tableParagraphOverlay, includeParagraphMarkRunProperties }: ParagraphStyleCascadeInput): ParagraphStyleCascade;
|
|
46
|
+
/**
|
|
47
|
+
* Pick the modeled paragraph fields out of a table style's (or conditional
|
|
48
|
+
* region's) `w:pPr` for use as the cell-paragraph cascade overlay.
|
|
49
|
+
*/
|
|
50
|
+
declare function extractTableParagraphOverlay(pPr: document_d_exports.ParagraphFormatting | undefined): TableCellParagraphSpacingOverlay | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* The paragraph overlay a table style gives one cell's paragraphs: its base
|
|
53
|
+
* `w:pPr`, then each applicable region's (`regions`, lowest precedence first,
|
|
54
|
+
* from `tableCellStyleRegions`). A table naming no style, or a style the part
|
|
55
|
+
* does not define, reads the default table style (ECMA-376 §17.7.6).
|
|
56
|
+
*/
|
|
57
|
+
declare function tableCellParagraphOverlay(styleResolver: Pick<StyleEngine, "getStyle" | "getDefaultTableStyle">, tableStyleId: string | null | undefined, regions: readonly TableStyleRegion[]): TableCellParagraphSpacingOverlay | undefined;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ParagraphCascadeResolver, ParagraphStyleCascade, ParagraphStyleCascadeInput, extractTableParagraphOverlay, paragraphStyleCascadeAttrs, resolveParagraphDefaultTextFormatting, resolveRunFormattingWithoutDefaults, tableCellParagraphOverlay };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { mergeParagraphNumbering, paragraphNumberingReferenceId } from "../../docx/numberingReference.js";
|
|
2
|
+
import { mergeParagraphFormatting, mergeParagraphTabStops } from "../../utils/paragraphFormattingMerge.js";
|
|
3
|
+
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
4
|
+
import { paragraphNumberingAttr } from "../numberingAttr.js";
|
|
5
|
+
import { directionFromBidi } from "../paragraphDirection.js";
|
|
6
|
+
import { styleResolvedParagraphFormatting } from "../paragraphFormattingProvenance.js";
|
|
7
|
+
import { lineSpacingProvenanceFromSpacing } from "../paragraphSpacing.js";
|
|
8
|
+
import { stripParagraphMarkOnlyFormatting } from "../runStyleFormatting.js";
|
|
9
|
+
import { cascadeStyleTextFormatting } from "./styleToggleCascade.js";
|
|
10
|
+
//#region src/prosemirror/styles/paragraphStyleCascade.ts
|
|
11
|
+
function resolveRunFormattingWithoutDefaults(formatting, styleResolver) {
|
|
12
|
+
if (!formatting || !styleResolver) return formatting;
|
|
13
|
+
return cascadeStyleTextFormatting([{
|
|
14
|
+
formatting: formatting.styleId ? styleResolver.getRunStyleOwnProperties(formatting.styleId) : void 0,
|
|
15
|
+
type: "style"
|
|
16
|
+
}, {
|
|
17
|
+
formatting,
|
|
18
|
+
type: "direct"
|
|
19
|
+
}]).formatting;
|
|
20
|
+
}
|
|
21
|
+
/** @internal Recompute a paragraph's inherited run defaults from authored package state. */
|
|
22
|
+
function resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver, options = {}) {
|
|
23
|
+
const style = styleId ? styleResolver.getStyle(styleId) ?? styleResolver.getDefaultParagraphStyle() : styleResolver.getDefaultParagraphStyle();
|
|
24
|
+
const paragraphStyleRpr = style?.type === "paragraph" ? style.rPr : void 0;
|
|
25
|
+
const rawParagraphMarkRpr = options.includeParagraphMarkRunProperties === false ? void 0 : formatting?.runProperties;
|
|
26
|
+
const paragraphRunProperties = rawParagraphMarkRpr ? stripParagraphMarkOnlyFormatting(resolveRunFormattingWithoutDefaults(rawParagraphMarkRpr, styleResolver) ?? {}) : void 0;
|
|
27
|
+
const orderedBodyToggleFormatting = cascadeStyleTextFormatting([
|
|
28
|
+
{
|
|
29
|
+
formatting: styleResolver.getDocDefaults()?.rPr,
|
|
30
|
+
type: "defaults"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
formatting: paragraphStyleRpr,
|
|
34
|
+
type: "style"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
formatting: styleResolver.getDefaultCharacterStyle()?.rPr,
|
|
38
|
+
type: "style"
|
|
39
|
+
}
|
|
40
|
+
], { ordinaryFormatting: mergeTextFormatting(mergeTextFormatting(styleResolver.getDocDefaults()?.rPr, styleResolver.getDefaultCharacterStyle()?.rPr), paragraphStyleRpr) });
|
|
41
|
+
const bodyRunDefaults = orderedBodyToggleFormatting.formatting;
|
|
42
|
+
return cascadeStyleTextFormatting([{
|
|
43
|
+
cascade: orderedBodyToggleFormatting,
|
|
44
|
+
type: "carried"
|
|
45
|
+
}, {
|
|
46
|
+
formatting: paragraphRunProperties,
|
|
47
|
+
type: "direct"
|
|
48
|
+
}], { ordinaryFormatting: mergeTextFormatting(bodyRunDefaults, paragraphRunProperties) }).formatting;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Project a paragraph's style cascade onto its editor attrs: each field the
|
|
52
|
+
* paragraph states wins, every other field reads the cascade, and the
|
|
53
|
+
* provenance attrs record which is which.
|
|
54
|
+
*/
|
|
55
|
+
function paragraphStyleCascadeAttrs({ styleId, formatting, styleResolver, tableParagraphOverlay, includeParagraphMarkRunProperties }) {
|
|
56
|
+
const attrs = {};
|
|
57
|
+
const set = (key, val) => {
|
|
58
|
+
if (val !== void 0) attrs[key] = val;
|
|
59
|
+
};
|
|
60
|
+
const stylePpr = styleResolver.resolveParagraphStyleInTable(styleId, tableParagraphOverlay).paragraphFormatting;
|
|
61
|
+
const resolvedFormatting = styleResolvedParagraphFormatting(stylePpr);
|
|
62
|
+
if (resolvedFormatting) attrs._resolvedFormatting = resolvedFormatting;
|
|
63
|
+
set("alignment", formatting?.alignment ?? stylePpr?.alignment);
|
|
64
|
+
set("alignmentFromStyle", stylePpr?.alignment);
|
|
65
|
+
set("spaceBefore", formatting?.spaceBefore ?? stylePpr?.spaceBefore);
|
|
66
|
+
set("spaceAfter", formatting?.spaceAfter ?? stylePpr?.spaceAfter);
|
|
67
|
+
set("lineSpacing", formatting?.lineSpacing ?? stylePpr?.lineSpacing);
|
|
68
|
+
set("lineSpacingRule", formatting?.lineSpacingRule ?? stylePpr?.lineSpacingRule);
|
|
69
|
+
set("lineSpacingExplicit", lineSpacingProvenanceFromSpacing(formatting));
|
|
70
|
+
set("snapToGrid", formatting?.snapToGrid ?? stylePpr?.snapToGrid);
|
|
71
|
+
set("spacingExplicit", formatting?.spacingExplicit);
|
|
72
|
+
const paragraphStyle = styleId ? styleResolver.getStyle(styleId) ?? styleResolver.getDefaultParagraphStyle() : styleResolver.getDefaultParagraphStyle();
|
|
73
|
+
const docDefaultSpacing = styleResolver.getDocDefaults()?.pPr;
|
|
74
|
+
const spacingFromStyle = {};
|
|
75
|
+
if (formatting?.spaceBefore === void 0 && stylePpr?.spaceBefore !== void 0) spacingFromStyle.before = true;
|
|
76
|
+
if (formatting?.spaceAfter === void 0 && stylePpr?.spaceAfter !== void 0) spacingFromStyle.after = true;
|
|
77
|
+
if (spacingFromStyle.before || spacingFromStyle.after) attrs.spacingFromImplicitDefaultStyle = spacingFromStyle;
|
|
78
|
+
const spacingFromDocDefaults = {};
|
|
79
|
+
if (formatting?.spaceBefore === void 0 && tableParagraphOverlay?.spaceBefore === void 0 && paragraphStyle?.pPr?.spaceBefore === void 0 && docDefaultSpacing?.spaceBefore !== void 0) spacingFromDocDefaults.before = true;
|
|
80
|
+
if (formatting?.spaceAfter === void 0 && tableParagraphOverlay?.spaceAfter === void 0 && paragraphStyle?.pPr?.spaceAfter === void 0 && docDefaultSpacing?.spaceAfter !== void 0) spacingFromDocDefaults.after = true;
|
|
81
|
+
if (spacingFromDocDefaults.before || spacingFromDocDefaults.after) attrs.spacingFromDocDefaults = spacingFromDocDefaults;
|
|
82
|
+
const effectiveIndent = mergeParagraphFormatting(formatting?.numPr?.kind === "none" && paragraphNumberingReferenceId(stylePpr?.numPr) !== void 0 ? void 0 : stylePpr, formatting);
|
|
83
|
+
set("indentLeft", effectiveIndent?.indentLeft);
|
|
84
|
+
set("indentRight", formatting?.indentRight ?? stylePpr?.indentRight);
|
|
85
|
+
set("indentFirstLine", effectiveIndent?.indentFirstLine);
|
|
86
|
+
set("hangingIndent", effectiveIndent?.hangingIndent);
|
|
87
|
+
set("borders", formatting?.borders ?? stylePpr?.borders);
|
|
88
|
+
set("shading", formatting?.shading ?? stylePpr?.shading);
|
|
89
|
+
set("tabs", mergeParagraphTabStops(stylePpr?.tabs, formatting?.tabs));
|
|
90
|
+
set("kinsoku", formatting?.kinsoku ?? stylePpr?.kinsoku);
|
|
91
|
+
set("overflowPunctuation", formatting?.overflowPunctuation ?? stylePpr?.overflowPunctuation);
|
|
92
|
+
set("suppressAutoHyphens", formatting?.suppressAutoHyphens ?? stylePpr?.suppressAutoHyphens);
|
|
93
|
+
set("pageBreakBefore", formatting?.pageBreakBefore ?? stylePpr?.pageBreakBefore);
|
|
94
|
+
set("keepNext", formatting?.keepNext ?? stylePpr?.keepNext);
|
|
95
|
+
set("keepLines", formatting?.keepLines ?? stylePpr?.keepLines);
|
|
96
|
+
set("widowControl", formatting?.widowControl ?? stylePpr?.widowControl);
|
|
97
|
+
set("contextualSpacing", formatting?.contextualSpacing ?? stylePpr?.contextualSpacing);
|
|
98
|
+
set("runInWithNext", formatting?.runInWithNext ?? stylePpr?.runInWithNext);
|
|
99
|
+
set("outlineLevel", formatting?.outlineLevel ?? stylePpr?.outlineLevel);
|
|
100
|
+
set("direction", directionFromBidi(formatting?.bidi ?? stylePpr?.bidi));
|
|
101
|
+
set("defaultTextFormatting", resolveParagraphDefaultTextFormatting(styleId, formatting, styleResolver, { includeParagraphMarkRunProperties }));
|
|
102
|
+
const styleNumbering = stylePpr?.numPr;
|
|
103
|
+
if (styleNumbering?.kind === "reference" && (formatting?.numPr === void 0 || formatting.numPr.kind === "levelOnly")) {
|
|
104
|
+
const merged = mergeParagraphNumbering(styleNumbering, formatting?.numPr);
|
|
105
|
+
if (merged !== void 0) attrs.numPr = paragraphNumberingAttr(merged);
|
|
106
|
+
attrs.numPrFromStyle = paragraphNumberingAttr(styleNumbering);
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
attrs,
|
|
110
|
+
stylePpr
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Pick the modeled paragraph fields out of a table style's (or conditional
|
|
115
|
+
* region's) `w:pPr` for use as the cell-paragraph cascade overlay.
|
|
116
|
+
*/
|
|
117
|
+
function extractTableParagraphOverlay(pPr) {
|
|
118
|
+
if (!pPr) return;
|
|
119
|
+
const overlay = {};
|
|
120
|
+
if (pPr.spaceBefore !== void 0) overlay.spaceBefore = pPr.spaceBefore;
|
|
121
|
+
if (pPr.spaceAfter !== void 0) overlay.spaceAfter = pPr.spaceAfter;
|
|
122
|
+
if (pPr.lineSpacing !== void 0) overlay.lineSpacing = pPr.lineSpacing;
|
|
123
|
+
if (pPr.lineSpacingRule !== void 0) overlay.lineSpacingRule = pPr.lineSpacingRule;
|
|
124
|
+
if (pPr.contextualSpacing !== void 0) overlay.contextualSpacing = pPr.contextualSpacing;
|
|
125
|
+
if (pPr.frame !== void 0) overlay.frame = pPr.frame;
|
|
126
|
+
return Object.keys(overlay).length > 0 ? overlay : void 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The paragraph overlay a table style gives one cell's paragraphs: its base
|
|
130
|
+
* `w:pPr`, then each applicable region's (`regions`, lowest precedence first,
|
|
131
|
+
* from `tableCellStyleRegions`). A table naming no style, or a style the part
|
|
132
|
+
* does not define, reads the default table style (ECMA-376 §17.7.6).
|
|
133
|
+
*/
|
|
134
|
+
function tableCellParagraphOverlay(styleResolver, tableStyleId, regions) {
|
|
135
|
+
const style = (tableStyleId ? styleResolver.getStyle(tableStyleId) : void 0) ?? styleResolver.getDefaultTableStyle();
|
|
136
|
+
if (!style) return;
|
|
137
|
+
let overlay = extractTableParagraphOverlay(style.pPr);
|
|
138
|
+
for (const region of regions) {
|
|
139
|
+
const conditional = style.tblStylePr?.find(({ type }) => type === region);
|
|
140
|
+
overlay = mergeParagraphFormatting(overlay, extractTableParagraphOverlay(conditional?.pPr));
|
|
141
|
+
}
|
|
142
|
+
return overlay;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { extractTableParagraphOverlay, paragraphStyleCascadeAttrs, resolveParagraphDefaultTextFormatting, resolveRunFormattingWithoutDefaults, tableCellParagraphOverlay };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ParagraphAttrsPatch } from "../schema/nodes.js";
|
|
1
|
+
import { ParagraphAttrs, ParagraphAttrsPatch } from "../schema/nodes.js";
|
|
2
2
|
import { ResolvedParagraphStyle } from "./styleResolver.js";
|
|
3
3
|
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
4
|
+
import { DirectParagraphIndentation } from "../paragraphIndentation.js";
|
|
4
5
|
//#region src/prosemirror/styles/resolvedStyleAttrs.d.ts
|
|
5
6
|
type ResolvedStyleIdentity = {
|
|
6
7
|
styleId: string;
|
|
@@ -37,6 +38,24 @@ declare function listAttrsFromNumbering(numPr: {
|
|
|
37
38
|
numId: number;
|
|
38
39
|
ilvl: number;
|
|
39
40
|
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
41
|
+
/**
|
|
42
|
+
* The numbering level's indentation a directly numbered paragraph reads as its
|
|
43
|
+
* own where it states none: the load path folds the level's `w:ind` into the
|
|
44
|
+
* paragraph (a direct `w:ind` wins per group, left vs first line/hanging), so
|
|
45
|
+
* a paragraph a command numbers carries it too, and the save writes it where a
|
|
46
|
+
* reopen reads it back.
|
|
47
|
+
*/
|
|
48
|
+
declare function listLevelIndentAttrPatch(stated: DirectParagraphIndentation | undefined, numPr: {
|
|
49
|
+
numId: number;
|
|
50
|
+
ilvl: number;
|
|
51
|
+
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
52
|
+
/**
|
|
53
|
+
* The indentation a paragraph leaving its list keeps: the level's indentation
|
|
54
|
+
* it only read from its numbering goes with the numbering, back to what its
|
|
55
|
+
* style gives, while an indentation of its own stays. The inverse of
|
|
56
|
+
* {@link listLevelIndentAttrPatch}.
|
|
57
|
+
*/
|
|
58
|
+
declare function listLevelIndentRemovalPatch(attrs: Readonly<ParagraphAttrs>, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
40
59
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
41
60
|
declare function listLevelAttrPatch(attrs: {
|
|
42
61
|
listImplicitChildLevelAdvances?: number | null;
|
|
@@ -45,4 +64,4 @@ declare function listLevelAttrPatch(attrs: {
|
|
|
45
64
|
ilvl: number;
|
|
46
65
|
}, numbering: NumberingMap | null | undefined): ParagraphAttrsPatch;
|
|
47
66
|
//#endregion
|
|
48
|
-
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, paragraphAttrsFromResolvedStyle };
|
|
67
|
+
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, listLevelIndentAttrPatch, listLevelIndentRemovalPatch, paragraphAttrsFromResolvedStyle };
|
|
@@ -112,6 +112,43 @@ function listAttrsFromNumbering(numPr, numbering) {
|
|
|
112
112
|
...rendering && listRenderingAttrPatch(rendering)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The numbering level's indentation a directly numbered paragraph reads as its
|
|
117
|
+
* own where it states none: the load path folds the level's `w:ind` into the
|
|
118
|
+
* paragraph (a direct `w:ind` wins per group, left vs first line/hanging), so
|
|
119
|
+
* a paragraph a command numbers carries it too, and the save writes it where a
|
|
120
|
+
* reopen reads it back.
|
|
121
|
+
*/
|
|
122
|
+
function listLevelIndentAttrPatch(stated, numPr, numbering) {
|
|
123
|
+
const level = numbering?.getLevel(numPr.numId, numPr.ilvl);
|
|
124
|
+
if (!level?.pPr) return {};
|
|
125
|
+
const patch = {};
|
|
126
|
+
if (stated?.indentLeft === void 0 && level.pPr.indentLeft !== void 0) patch.indentLeft = level.pPr.indentLeft;
|
|
127
|
+
if (stated?.indentFirstLine === void 0 && numberingLevelHasMarkerSlot(level)) {
|
|
128
|
+
if (level.pPr.indentFirstLine !== void 0) patch.indentFirstLine = level.pPr.indentFirstLine;
|
|
129
|
+
if (level.pPr.hangingIndent !== void 0) patch.hangingIndent = level.pPr.hangingIndent;
|
|
130
|
+
}
|
|
131
|
+
return patch;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The indentation a paragraph leaving its list keeps: the level's indentation
|
|
135
|
+
* it only read from its numbering goes with the numbering, back to what its
|
|
136
|
+
* style gives, while an indentation of its own stays. The inverse of
|
|
137
|
+
* {@link listLevelIndentAttrPatch}.
|
|
138
|
+
*/
|
|
139
|
+
function listLevelIndentRemovalPatch(attrs, numbering) {
|
|
140
|
+
if (attrs.numPr?.kind !== "reference") return {};
|
|
141
|
+
const level = numbering?.getLevel(attrs.numPr.numId, attrs.numPr.ilvl ?? 0);
|
|
142
|
+
if (!level?.pPr) return {};
|
|
143
|
+
const resolved = attrs.numPrFromStyle != null ? void 0 : attrs._resolvedFormatting;
|
|
144
|
+
const patch = {};
|
|
145
|
+
if (level.pPr.indentLeft !== void 0 && attrs.indentLeft === level.pPr.indentLeft) patch.indentLeft = resolved?.indentLeft ?? null;
|
|
146
|
+
if (level.pPr.indentFirstLine !== void 0 && attrs.indentFirstLine === level.pPr.indentFirstLine && attrs.hangingIndent === (level.pPr.hangingIndent ?? false)) {
|
|
147
|
+
patch.indentFirstLine = resolved?.indentFirstLine ?? null;
|
|
148
|
+
patch.hangingIndent = resolved?.hangingIndent ?? false;
|
|
149
|
+
}
|
|
150
|
+
return patch;
|
|
151
|
+
}
|
|
115
152
|
/** Recompute every level-dependent attr when a paragraph changes list level. */
|
|
116
153
|
function listLevelAttrPatch(attrs, numPr, numbering) {
|
|
117
154
|
const level = numbering?.getLevel(numPr.numId, numPr.ilvl);
|
|
@@ -125,4 +162,4 @@ function listLevelAttrPatch(attrs, numPr, numbering) {
|
|
|
125
162
|
};
|
|
126
163
|
}
|
|
127
164
|
//#endregion
|
|
128
|
-
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, paragraphAttrsFromResolvedStyle };
|
|
165
|
+
export { listAttrsFromNumbering, listAttrsFromResolvedStyle, listLevelAttrPatch, listLevelIndentAttrPatch, listLevelIndentRemovalPatch, paragraphAttrsFromResolvedStyle };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import "../../types/index.js";
|
|
3
|
+
import { ResolvedTableLook } from "../../docx/tableLook.js";
|
|
4
|
+
//#region src/prosemirror/styles/tableStyleRegions.d.ts
|
|
5
|
+
type TableStyleRegion = "wholeTable" | "band1Horz" | "band2Horz" | "band1Vert" | "band2Vert" | "firstCol" | "lastCol" | "firstRow" | "lastRow" | "nwCell" | "neCell" | "swCell" | "seCell";
|
|
6
|
+
/**
|
|
7
|
+
* The horizontal band a row takes by position: every row but a styled first
|
|
8
|
+
* or last row alternates, starting with band 1.
|
|
9
|
+
*/
|
|
10
|
+
declare const tableRowBand: (look: ResolvedTableLook, rowIndex: number, totalRows: number) => "band1Horz" | "band2Horz" | undefined;
|
|
11
|
+
type TableCellPlacement = {
|
|
12
|
+
look: ResolvedTableLook;
|
|
13
|
+
rowIndex: number;
|
|
14
|
+
totalRows: number;
|
|
15
|
+
/** The first grid column the cell covers. */
|
|
16
|
+
column: number;
|
|
17
|
+
colspan: number;
|
|
18
|
+
totalColumns: number;
|
|
19
|
+
/** The band `tableRowBand` gives the cell's row. */
|
|
20
|
+
rowBand: "band1Horz" | "band2Horz" | undefined;
|
|
21
|
+
rowConditionalFormat?: document_d_exports.ConditionalFormatStyle | undefined;
|
|
22
|
+
cellConditionalFormat?: document_d_exports.ConditionalFormatStyle | undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The regions that apply to one cell, lowest precedence first: the whole
|
|
26
|
+
* table, banding, columns, rows, then corners (ECMA-376 §17.7.6). A cell's or
|
|
27
|
+
* row's `w:cnfStyle` overrides what its position implies.
|
|
28
|
+
*/
|
|
29
|
+
declare const tableCellStyleRegions: ({ look, rowIndex, totalRows, column, colspan, totalColumns, rowBand, rowConditionalFormat: rowCnf, cellConditionalFormat: cellCnf }: TableCellPlacement) => TableStyleRegion[];
|
|
30
|
+
//#endregion
|
|
31
|
+
export { TableCellPlacement, TableStyleRegion, tableCellStyleRegions, tableRowBand };
|