@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
|
@@ -5,10 +5,13 @@ import { isValidHexColor, resolveColor } from "../../../utils/colorResolver.js";
|
|
|
5
5
|
import { resolveTablePlacementAlignment } from "../../../utils/tablePlacement.js";
|
|
6
6
|
import { textFlowCss } from "../../../utils/textDirectionFlow.js";
|
|
7
7
|
import { expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs } from "../../attrs/index.js";
|
|
8
|
+
import { makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
9
|
+
import { pasteTableCells, pastedSliceWithNewTableCells } from "../../tableCellPaste.js";
|
|
10
|
+
import { insertTableColumn, removeTableColumns, removeTableRow } from "../../tableGridMutation.js";
|
|
8
11
|
import { createExtension, createNodeExtension } from "../create.js";
|
|
9
12
|
import { panic } from "better-result";
|
|
10
13
|
import { statesNoBorder } from "@stll/docx-core/model";
|
|
11
|
-
import { CellSelection, TableMap, columnResizing, mergeCells,
|
|
14
|
+
import { CellSelection, TableMap, columnResizing, mergeCells, selectedRect, splitCell, tableEditing, tableNodeTypes } from "prosemirror-tables";
|
|
12
15
|
import { Plugin, PluginKey, Selection, TextSelection } from "prosemirror-state";
|
|
13
16
|
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
14
17
|
//#region src/prosemirror/extensions/nodes/TableExtension.ts
|
|
@@ -233,6 +236,7 @@ const tableSpec = {
|
|
|
233
236
|
tblPrChange: { default: null },
|
|
234
237
|
_bookmarks: { default: null },
|
|
235
238
|
_preserved: { default: null },
|
|
239
|
+
carrierStack: { default: null },
|
|
236
240
|
_suggestedInsert: { default: null }
|
|
237
241
|
},
|
|
238
242
|
parseDOM: [{
|
|
@@ -275,6 +279,7 @@ const tableRowSpec = {
|
|
|
275
279
|
heightRule: { default: null },
|
|
276
280
|
isHeader: { default: false },
|
|
277
281
|
hidden: { default: null },
|
|
282
|
+
_batchRowCleanup: { default: null },
|
|
278
283
|
_resolvedJustification: { default: null },
|
|
279
284
|
_originalFormatting: { default: null },
|
|
280
285
|
_tablePropertyExceptions: { default: null },
|
|
@@ -283,6 +288,7 @@ const tableRowSpec = {
|
|
|
283
288
|
_preservedAttributes: { default: null },
|
|
284
289
|
_bookmarks: { default: null },
|
|
285
290
|
contentControls: { default: null },
|
|
291
|
+
carrierStack: { default: null },
|
|
286
292
|
_preserved: { default: null },
|
|
287
293
|
trIns: { default: null },
|
|
288
294
|
trDel: { default: null }
|
|
@@ -367,7 +373,7 @@ const statedCellWidth = (value, type) => ({
|
|
|
367
373
|
}
|
|
368
374
|
});
|
|
369
375
|
const tableCellSpec = {
|
|
370
|
-
content: "(paragraph | table | textBox | blockSdt | preservedBlock | blockBookmarkBoundary)+",
|
|
376
|
+
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary)+",
|
|
371
377
|
tableRole: "cell",
|
|
372
378
|
isolating: true,
|
|
373
379
|
attrs: {
|
|
@@ -393,6 +399,7 @@ const tableCellSpec = {
|
|
|
393
399
|
tcPrChange: { default: null },
|
|
394
400
|
cellMarker: { default: null },
|
|
395
401
|
contentControls: { default: null },
|
|
402
|
+
carrierStack: { default: null },
|
|
396
403
|
_preserveVMergeRestart: { default: null },
|
|
397
404
|
_docxVMergeContinuationCells: { default: null }
|
|
398
405
|
},
|
|
@@ -436,7 +443,7 @@ const tableCellSpec = {
|
|
|
436
443
|
}
|
|
437
444
|
};
|
|
438
445
|
const tableHeaderSpec = {
|
|
439
|
-
content: "(paragraph | table | textBox | blockSdt | preservedBlock | blockBookmarkBoundary)+",
|
|
446
|
+
content: "(paragraph | table | textBox | blockSdt | blockCustomXml | preservedBlock | blockBookmarkBoundary)+",
|
|
440
447
|
tableRole: "header_cell",
|
|
441
448
|
isolating: true,
|
|
442
449
|
attrs: {
|
|
@@ -462,6 +469,7 @@ const tableHeaderSpec = {
|
|
|
462
469
|
tcPrChange: { default: null },
|
|
463
470
|
cellMarker: { default: null },
|
|
464
471
|
contentControls: { default: null },
|
|
472
|
+
carrierStack: { default: null },
|
|
465
473
|
_preserveVMergeRestart: { default: null },
|
|
466
474
|
_docxVMergeContinuationCells: { default: null }
|
|
467
475
|
},
|
|
@@ -513,12 +521,12 @@ function getTableContext(state) {
|
|
|
513
521
|
let rowIndex;
|
|
514
522
|
let columnIndex;
|
|
515
523
|
let cellNode;
|
|
524
|
+
let cellPos;
|
|
516
525
|
for (let d = $from.depth; d > 0; d--) {
|
|
517
526
|
const node = $from.node(d);
|
|
518
527
|
if (node.type.name === "tableCell" || node.type.name === "tableHeader") {
|
|
519
528
|
cellNode = node;
|
|
520
|
-
|
|
521
|
-
if (rowNode.type.name === "tableRow") columnIndex = getColumnIndex(rowNode, $from.index(d - 1));
|
|
529
|
+
cellPos = $from.before(d);
|
|
522
530
|
} else if (node.type.name === "tableRow") {
|
|
523
531
|
if ($from.node(d - 1).type.name === "table") rowIndex = $from.index(d - 1);
|
|
524
532
|
} else if (node.type.name === "table") {
|
|
@@ -528,18 +536,10 @@ function getTableContext(state) {
|
|
|
528
536
|
}
|
|
529
537
|
}
|
|
530
538
|
if (!table) return { isInTable: false };
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
rowCount++;
|
|
536
|
-
let cols = 0;
|
|
537
|
-
row.forEach((cell) => {
|
|
538
|
-
cols += Number(cell.attrs["colspan"]) || 1;
|
|
539
|
-
});
|
|
540
|
-
columnCount = Math.max(columnCount, cols);
|
|
541
|
-
}
|
|
542
|
-
});
|
|
539
|
+
const map = TableMap.get(table);
|
|
540
|
+
const rowCount = table.childCount;
|
|
541
|
+
const columnCount = map.width;
|
|
542
|
+
if (cellPos !== void 0 && tablePos !== void 0) columnIndex = map.findCell(cellPos - tablePos - 1).left;
|
|
543
543
|
const canSplitCell = cellNode !== void 0 && ((Number(cellNode.attrs["colspan"]) || 1) > 1 || (Number(cellNode.attrs["rowspan"]) || 1) > 1);
|
|
544
544
|
let cellBorderColor;
|
|
545
545
|
let cellBackgroundColor;
|
|
@@ -574,19 +574,6 @@ function getTableContext(state) {
|
|
|
574
574
|
...cellBackgroundColor !== void 0 ? { cellBackgroundColor } : {}
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
|
-
const getColumnIndex = (rowNode, targetIndex) => {
|
|
578
|
-
let columnIndex = 0;
|
|
579
|
-
let foundColumnIndex;
|
|
580
|
-
rowNode.forEach((child, _offset, index) => {
|
|
581
|
-
if (foundColumnIndex !== void 0) return;
|
|
582
|
-
if (index === targetIndex) {
|
|
583
|
-
foundColumnIndex = columnIndex;
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
columnIndex += Number(child.attrs["colspan"]) || 1;
|
|
587
|
-
});
|
|
588
|
-
return foundColumnIndex;
|
|
589
|
-
};
|
|
590
577
|
function isInTableCell(state) {
|
|
591
578
|
const { $from } = state.selection;
|
|
592
579
|
for (let d = $from.depth; d > 0; d--) {
|
|
@@ -684,10 +671,12 @@ const TablePluginExtension = createExtension({
|
|
|
684
671
|
if (!schema.nodes["tableCell"]) panic("Missing node type: tableCell");
|
|
685
672
|
if (!schema.nodes["tableRow"]) panic("Missing node type: tableRow");
|
|
686
673
|
if (!schema.nodes["table"]) panic("Missing node type: table");
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
674
|
+
const documentTableTypes = (documentSchema) => ({
|
|
675
|
+
paragraph: documentSchema.nodes["paragraph"] ?? panic("Missing node type: paragraph"),
|
|
676
|
+
tableCell: documentSchema.nodes["tableCell"] ?? panic("Missing node type: tableCell"),
|
|
677
|
+
tableRow: documentSchema.nodes["tableRow"] ?? panic("Missing node type: tableRow"),
|
|
678
|
+
table: documentSchema.nodes["table"] ?? panic("Missing node type: table")
|
|
679
|
+
});
|
|
691
680
|
function chainCommands(...commands) {
|
|
692
681
|
return (state, dispatch, view) => {
|
|
693
682
|
for (const cmd of commands) if (cmd(state, dispatch, view)) return true;
|
|
@@ -712,7 +701,8 @@ const TablePluginExtension = createExtension({
|
|
|
712
701
|
...overrides
|
|
713
702
|
};
|
|
714
703
|
}
|
|
715
|
-
function createTable(rows, cols, borderColor = "000000", contentWidthTwips = 9360) {
|
|
704
|
+
function createTable(documentSchema, rows, cols, borderColor = "000000", contentWidthTwips = 9360) {
|
|
705
|
+
const types = documentTableTypes(documentSchema);
|
|
716
706
|
const tableRows = [];
|
|
717
707
|
const colWidthTwips = Math.floor(contentWidthTwips / cols);
|
|
718
708
|
const defaultRowHeightTwips = 360;
|
|
@@ -731,22 +721,22 @@ const TablePluginExtension = createExtension({
|
|
|
731
721
|
for (let r = 0; r < rows; r++) {
|
|
732
722
|
const cells = [];
|
|
733
723
|
for (let c = 0; c < cols; c++) {
|
|
734
|
-
const paragraph =
|
|
724
|
+
const paragraph = types.paragraph.create();
|
|
735
725
|
const cellAttrs = {
|
|
736
726
|
colspan: 1,
|
|
737
727
|
rowspan: 1,
|
|
738
728
|
borders: defaultBorders,
|
|
739
729
|
...statedCellWidth(colWidthTwips, "dxa")
|
|
740
730
|
};
|
|
741
|
-
cells.push(
|
|
731
|
+
cells.push(types.tableCell.create(cellAttrs, paragraph));
|
|
742
732
|
}
|
|
743
|
-
tableRows.push(
|
|
733
|
+
tableRows.push(types.tableRow.create({
|
|
744
734
|
height: defaultRowHeightTwips,
|
|
745
735
|
heightRule: defaultRowHeightRule
|
|
746
736
|
}, cells));
|
|
747
737
|
}
|
|
748
738
|
const columnWidths = Array.from({ length: cols }, () => colWidthTwips);
|
|
749
|
-
return
|
|
739
|
+
return types.table.create({
|
|
750
740
|
columnWidths,
|
|
751
741
|
width: contentWidthTwips,
|
|
752
742
|
widthType: "dxa"
|
|
@@ -779,8 +769,31 @@ const TablePluginExtension = createExtension({
|
|
|
779
769
|
break;
|
|
780
770
|
}
|
|
781
771
|
}
|
|
782
|
-
|
|
783
|
-
|
|
772
|
+
let table = createTable(state.schema, rows, cols, borderColor, contentWidthTwips);
|
|
773
|
+
let emptyParagraph = documentTableTypes(state.schema).paragraph.create();
|
|
774
|
+
const revision = makeRevisionInfo(state);
|
|
775
|
+
if (revision) {
|
|
776
|
+
const rowRevision = {
|
|
777
|
+
revisionId: revision.id,
|
|
778
|
+
author: revision.author,
|
|
779
|
+
date: revision.date
|
|
780
|
+
};
|
|
781
|
+
const rowsWithRevision = [];
|
|
782
|
+
table.forEach((row) => {
|
|
783
|
+
rowsWithRevision.push(row.type.create({
|
|
784
|
+
...row.attrs,
|
|
785
|
+
trIns: rowRevision
|
|
786
|
+
}, row.content));
|
|
787
|
+
});
|
|
788
|
+
table = table.type.create(table.attrs, rowsWithRevision);
|
|
789
|
+
emptyParagraph = emptyParagraph.type.create({
|
|
790
|
+
...emptyParagraph.attrs,
|
|
791
|
+
pPrMark: {
|
|
792
|
+
kind: "ins",
|
|
793
|
+
info: revision
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
784
797
|
const needsLeadingParagraph = state.doc.resolve(insertPos).nodeBefore?.type.name === "table";
|
|
785
798
|
const insertContent = needsLeadingParagraph ? [
|
|
786
799
|
emptyParagraph,
|
|
@@ -816,11 +829,13 @@ const TablePluginExtension = createExtension({
|
|
|
816
829
|
const context = getTableContext(state);
|
|
817
830
|
if (!context.isInTable || context.rowIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
|
|
818
831
|
if (!dispatch) return true;
|
|
819
|
-
const { table, tablePos
|
|
820
|
-
const
|
|
821
|
-
const
|
|
832
|
+
const { table, tablePos } = context;
|
|
833
|
+
const rect = selectedRect(state);
|
|
834
|
+
const boundaryRow = boundaryOffset === 0 ? rect.top : rect.bottom;
|
|
835
|
+
const { map } = rect;
|
|
822
836
|
const tableStart = tablePos + 1;
|
|
823
837
|
const tr = state.tr;
|
|
838
|
+
const paragraphType = state.schema.nodes["paragraph"];
|
|
824
839
|
const cells = [];
|
|
825
840
|
const extended = /* @__PURE__ */ new Set();
|
|
826
841
|
let lastTemplatePos = -1;
|
|
@@ -841,10 +856,11 @@ const TablePluginExtension = createExtension({
|
|
|
841
856
|
const templatePos = below ?? above;
|
|
842
857
|
if (templatePos === void 0 || templatePos === lastTemplatePos) continue;
|
|
843
858
|
lastTemplatePos = templatePos;
|
|
844
|
-
|
|
859
|
+
const template = table.nodeAt(templatePos);
|
|
860
|
+
cells.push((template?.type ?? tableNodeTypes(state.schema).cell).create(buildCellAttrsFromTemplate(template), paragraphType?.create() ?? null));
|
|
845
861
|
}
|
|
846
|
-
const rowNode = table.child(
|
|
847
|
-
const newRow =
|
|
862
|
+
const rowNode = table.child(boundaryOffset === 0 ? rect.top : rect.bottom - 1);
|
|
863
|
+
const newRow = rowNode.type.create({
|
|
848
864
|
height: rowNode.attrs["height"] ?? 360,
|
|
849
865
|
heightRule: rowNode.attrs["heightRule"] ?? "atLeast"
|
|
850
866
|
}, cells);
|
|
@@ -893,7 +909,7 @@ const TablePluginExtension = createExtension({
|
|
|
893
909
|
}
|
|
894
910
|
const rect = selectedRect(state);
|
|
895
911
|
for (let row = lastRow; row >= firstRow; row--) {
|
|
896
|
-
|
|
912
|
+
removeTableRow(tr, rect, row);
|
|
897
913
|
if (row > firstRow) {
|
|
898
914
|
const updated = tr.doc.nodeAt(rect.tableStart - 1);
|
|
899
915
|
if (updated) {
|
|
@@ -906,176 +922,58 @@ const TablePluginExtension = createExtension({
|
|
|
906
922
|
}
|
|
907
923
|
return true;
|
|
908
924
|
}
|
|
909
|
-
|
|
925
|
+
/**
|
|
926
|
+
* Insert a column beside the selected cells: left of the first column
|
|
927
|
+
* they cover, or right of the last. The table map places the new cells,
|
|
928
|
+
* so a row whose cell in that column is held by a merge from a row above
|
|
929
|
+
* still gains its cell at the right grid column, and `w:tblGrid` gains
|
|
930
|
+
* one column the width of its neighbour instead of being rebuilt.
|
|
931
|
+
*/
|
|
932
|
+
function insertColumnBeside(state, dispatch, side) {
|
|
910
933
|
const context = getTableContext(state);
|
|
911
934
|
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
|
|
912
935
|
if (dispatch) {
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
const
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
rowspan: 1
|
|
927
|
-
});
|
|
928
|
-
Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
|
|
929
|
-
const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
|
|
930
|
-
tr = tr.insert(tr.mapping.map(cellPos), newCell);
|
|
931
|
-
}
|
|
932
|
-
cellPos += cell.nodeSize;
|
|
933
|
-
colIdx += Number(cell.attrs["colspan"]) || 1;
|
|
936
|
+
const rect = selectedRect(state);
|
|
937
|
+
const tr = state.tr;
|
|
938
|
+
const paragraphType = state.schema.nodes["paragraph"];
|
|
939
|
+
insertTableColumn({
|
|
940
|
+
tr,
|
|
941
|
+
tablePosition: rect.tableStart - 1,
|
|
942
|
+
column: side === "left" ? rect.left : rect.right,
|
|
943
|
+
templateColumn: side === "left" ? rect.left : rect.right - 1,
|
|
944
|
+
createCell: (template) => {
|
|
945
|
+
const cellType = template?.type ?? tableNodeTypes(state.schema).cell;
|
|
946
|
+
const attrs = buildCellAttrsFromTemplate(template && (Number(template.attrs["colspan"]) || 1) === 1 ? template : null, {
|
|
947
|
+
colspan: 1,
|
|
948
|
+
rowspan: 1
|
|
934
949
|
});
|
|
935
|
-
|
|
936
|
-
const paragraph = nodeTypeParagraph.create();
|
|
937
|
-
const cellAttrs = buildCellAttrsFromTemplate(row.child(row.childCount - 1), {
|
|
938
|
-
colspan: 1,
|
|
939
|
-
rowspan: 1
|
|
940
|
-
});
|
|
941
|
-
Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
|
|
942
|
-
const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
|
|
943
|
-
tr = tr.insert(tr.mapping.map(cellPos), newCell);
|
|
944
|
-
}
|
|
950
|
+
return cellType.create(attrs, paragraphType?.create() ?? null);
|
|
945
951
|
}
|
|
946
|
-
rowPos += row.nodeSize;
|
|
947
952
|
});
|
|
948
|
-
const updatedTable = tr.doc.nodeAt(context.tablePos);
|
|
949
|
-
if (updatedTable && updatedTable.type.name === "table") {
|
|
950
|
-
const firstRow = updatedTable.child(0);
|
|
951
|
-
if (firstRow.type.name === "tableRow") {
|
|
952
|
-
let cellPos = context.tablePos + 2;
|
|
953
|
-
firstRow.forEach((cell) => {
|
|
954
|
-
if (cell.type.name === "tableCell" || cell.type.name === "tableHeader") tr = tr.setNodeMarkup(cellPos, void 0, mergeTableCellAttrs(cell, {
|
|
955
|
-
width: newColWidthPercent,
|
|
956
|
-
widthType: "pct"
|
|
957
|
-
}));
|
|
958
|
-
cellPos += cell.nodeSize;
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
const colCount = firstRow.childCount;
|
|
962
|
-
const tableWidthTwips = expectTableAttrs(updatedTable).width ?? 9360;
|
|
963
|
-
const colWidthTwips = Math.floor(tableWidthTwips / Math.max(1, colCount));
|
|
964
|
-
tr = tr.setNodeMarkup(context.tablePos, void 0, mergeTableAttrs(updatedTable, { columnWidths: Array.from({ length: colCount }, () => colWidthTwips) }));
|
|
965
|
-
}
|
|
966
953
|
dispatch(tr.scrollIntoView());
|
|
967
954
|
}
|
|
968
955
|
return true;
|
|
969
956
|
}
|
|
957
|
+
function addColumnLeft(state, dispatch) {
|
|
958
|
+
return insertColumnBeside(state, dispatch, "left");
|
|
959
|
+
}
|
|
970
960
|
function addColumnRight(state, dispatch) {
|
|
971
|
-
|
|
972
|
-
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || hasOmittedGridSlots(context.table)) return false;
|
|
973
|
-
if (dispatch) {
|
|
974
|
-
let tr = state.tr;
|
|
975
|
-
const newColumnCount = (context.columnCount ?? 1) + 1;
|
|
976
|
-
const newColWidthPercent = Math.floor(100 / newColumnCount);
|
|
977
|
-
let rowPos = context.tablePos + 1;
|
|
978
|
-
context.table.forEach((row) => {
|
|
979
|
-
if (row.type.name === "tableRow") {
|
|
980
|
-
let cellPos = rowPos + 1;
|
|
981
|
-
let colIdx = 0;
|
|
982
|
-
let insertedCount = 0;
|
|
983
|
-
row.forEach((cell) => {
|
|
984
|
-
cellPos += cell.nodeSize;
|
|
985
|
-
colIdx += Number(cell.attrs["colspan"]) || 1;
|
|
986
|
-
if (insertedCount === 0 && context.columnIndex !== void 0 && colIdx > context.columnIndex) {
|
|
987
|
-
const paragraph = nodeTypeParagraph.create();
|
|
988
|
-
const cellAttrs = buildCellAttrsFromTemplate(cell, {
|
|
989
|
-
colspan: 1,
|
|
990
|
-
rowspan: 1
|
|
991
|
-
});
|
|
992
|
-
Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
|
|
993
|
-
const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
|
|
994
|
-
tr = tr.insert(tr.mapping.map(cellPos), newCell);
|
|
995
|
-
insertedCount += 1;
|
|
996
|
-
}
|
|
997
|
-
});
|
|
998
|
-
if (insertedCount === 0) {
|
|
999
|
-
const paragraph = nodeTypeParagraph.create();
|
|
1000
|
-
const cellAttrs = buildCellAttrsFromTemplate(row.child(row.childCount - 1), {
|
|
1001
|
-
colspan: 1,
|
|
1002
|
-
rowspan: 1
|
|
1003
|
-
});
|
|
1004
|
-
Object.assign(cellAttrs, statedCellWidth(newColWidthPercent, "pct"));
|
|
1005
|
-
const newCell = nodeTypeTableCell.create(cellAttrs, paragraph);
|
|
1006
|
-
tr = tr.insert(tr.mapping.map(cellPos), newCell);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
rowPos += row.nodeSize;
|
|
1010
|
-
});
|
|
1011
|
-
const updatedTable = tr.doc.nodeAt(context.tablePos);
|
|
1012
|
-
if (updatedTable && updatedTable.type.name === "table") {
|
|
1013
|
-
const firstRow = updatedTable.child(0);
|
|
1014
|
-
if (firstRow.type.name === "tableRow") {
|
|
1015
|
-
let cellPos = context.tablePos + 2;
|
|
1016
|
-
firstRow.forEach((cell) => {
|
|
1017
|
-
if (cell.type.name === "tableCell" || cell.type.name === "tableHeader") tr = tr.setNodeMarkup(cellPos, void 0, mergeTableCellAttrs(cell, {
|
|
1018
|
-
width: newColWidthPercent,
|
|
1019
|
-
widthType: "pct"
|
|
1020
|
-
}));
|
|
1021
|
-
cellPos += cell.nodeSize;
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
const colCount = firstRow.childCount;
|
|
1025
|
-
const tableWidthTwips = expectTableAttrs(updatedTable).width ?? 9360;
|
|
1026
|
-
const colWidthTwips = Math.floor(tableWidthTwips / Math.max(1, colCount));
|
|
1027
|
-
tr = tr.setNodeMarkup(context.tablePos, void 0, mergeTableAttrs(updatedTable, { columnWidths: Array.from({ length: colCount }, () => colWidthTwips) }));
|
|
1028
|
-
}
|
|
1029
|
-
dispatch(tr.scrollIntoView());
|
|
1030
|
-
}
|
|
1031
|
-
return true;
|
|
961
|
+
return insertColumnBeside(state, dispatch, "right");
|
|
1032
962
|
}
|
|
963
|
+
/**
|
|
964
|
+
* Delete the columns the selected cells cover. The table map finds each
|
|
965
|
+
* row's cell in them, a merged cell reaching past them narrows, a row
|
|
966
|
+
* left with no cell of its own goes, and `w:tblGrid` loses exactly those
|
|
967
|
+
* columns.
|
|
968
|
+
*/
|
|
1033
969
|
function deleteColumn(state, dispatch) {
|
|
1034
970
|
const context = getTableContext(state);
|
|
1035
971
|
if (!context.isInTable || context.columnIndex === void 0 || !context.table || context.tablePos === void 0 || (context.columnCount ?? 0) <= 1 || hasOmittedGridSlots(context.table)) return false;
|
|
972
|
+
const rect = selectedRect(state);
|
|
973
|
+
if (rect.right - rect.left >= rect.map.width) return false;
|
|
1036
974
|
if (dispatch) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
const newColWidthPercent = Math.floor(100 / newColumnCount);
|
|
1040
|
-
const deleteOps = [];
|
|
1041
|
-
let rowPos = context.tablePos + 1;
|
|
1042
|
-
context.table.forEach((row) => {
|
|
1043
|
-
if (row.type.name === "tableRow") {
|
|
1044
|
-
let cellPos = rowPos + 1;
|
|
1045
|
-
let colIdx = 0;
|
|
1046
|
-
row.forEach((cell) => {
|
|
1047
|
-
const cellStart = cellPos;
|
|
1048
|
-
const cellEnd = cellPos + cell.nodeSize;
|
|
1049
|
-
const cellColspan = Number(cell.attrs["colspan"]) || 1;
|
|
1050
|
-
if (context.columnIndex !== void 0 && colIdx <= context.columnIndex && context.columnIndex < colIdx + cellColspan) deleteOps.push({
|
|
1051
|
-
start: cellStart,
|
|
1052
|
-
end: cellEnd
|
|
1053
|
-
});
|
|
1054
|
-
cellPos = cellEnd;
|
|
1055
|
-
colIdx += cellColspan;
|
|
1056
|
-
});
|
|
1057
|
-
}
|
|
1058
|
-
rowPos += row.nodeSize;
|
|
1059
|
-
});
|
|
1060
|
-
for (const { start, end } of deleteOps.toReversed()) tr = tr.delete(start, end);
|
|
1061
|
-
const updatedTable = tr.doc.nodeAt(context.tablePos);
|
|
1062
|
-
if (updatedTable && updatedTable.type.name === "table") {
|
|
1063
|
-
const firstRow = updatedTable.child(0);
|
|
1064
|
-
if (firstRow.type.name === "tableRow") {
|
|
1065
|
-
let cellPos = context.tablePos + 2;
|
|
1066
|
-
firstRow.forEach((cell) => {
|
|
1067
|
-
if (cell.type.name === "tableCell" || cell.type.name === "tableHeader") tr = tr.setNodeMarkup(cellPos, void 0, mergeTableCellAttrs(cell, {
|
|
1068
|
-
width: newColWidthPercent,
|
|
1069
|
-
widthType: "pct"
|
|
1070
|
-
}));
|
|
1071
|
-
cellPos += cell.nodeSize;
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
const colCount = firstRow.childCount;
|
|
1075
|
-
const tableWidthTwips = expectTableAttrs(updatedTable).width ?? 9360;
|
|
1076
|
-
const colWidthTwips = Math.floor(tableWidthTwips / Math.max(1, colCount));
|
|
1077
|
-
tr = tr.setNodeMarkup(context.tablePos, void 0, mergeTableAttrs(updatedTable, { columnWidths: Array.from({ length: colCount }, () => colWidthTwips) }));
|
|
1078
|
-
}
|
|
975
|
+
const tr = state.tr;
|
|
976
|
+
removeTableColumns(tr, rect.tableStart - 1, rect.left, rect.right);
|
|
1079
977
|
dispatch(tr.scrollIntoView());
|
|
1080
978
|
}
|
|
1081
979
|
return true;
|
|
@@ -1095,10 +993,11 @@ const TablePluginExtension = createExtension({
|
|
|
1095
993
|
if (!context.isInTable || context.tablePos === void 0 || !context.table) return false;
|
|
1096
994
|
if (dispatch) {
|
|
1097
995
|
const tableStart = context.tablePos + 1;
|
|
1098
|
-
const
|
|
1099
|
-
const
|
|
1100
|
-
const
|
|
1101
|
-
|
|
996
|
+
const { map } = TableMap.get(context.table);
|
|
997
|
+
const first = map.at(0);
|
|
998
|
+
const last = map.at(-1);
|
|
999
|
+
if (first === void 0 || last === void 0) return false;
|
|
1000
|
+
dispatch(state.tr.setSelection(CellSelection.create(state.doc, tableStart + first, tableStart + last)));
|
|
1102
1001
|
}
|
|
1103
1002
|
return true;
|
|
1104
1003
|
}
|
|
@@ -1106,16 +1005,11 @@ const TablePluginExtension = createExtension({
|
|
|
1106
1005
|
const context = getTableContext(state);
|
|
1107
1006
|
if (!context.isInTable || context.tablePos === void 0 || !context.table || context.rowIndex === void 0) return false;
|
|
1108
1007
|
if (dispatch) {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
const row = context.table.child(context.rowIndex);
|
|
1115
|
-
const firstCellPos = rowPos + 1;
|
|
1116
|
-
const lastCellPos = rowPos + row.nodeSize - 2;
|
|
1117
|
-
const cellSel = CellSelection.create(state.doc, firstCellPos, lastCellPos);
|
|
1118
|
-
dispatch(state.tr.setSelection(cellSel));
|
|
1008
|
+
const tableStart = context.tablePos + 1;
|
|
1009
|
+
const tableMap = TableMap.get(context.table);
|
|
1010
|
+
const firstCell = tableMap.map[context.rowIndex * tableMap.width];
|
|
1011
|
+
if (firstCell === void 0) return false;
|
|
1012
|
+
dispatch(state.tr.setSelection(CellSelection.rowSelection(state.doc.resolve(tableStart + firstCell))));
|
|
1119
1013
|
}
|
|
1120
1014
|
return true;
|
|
1121
1015
|
}
|
|
@@ -1124,16 +1018,9 @@ const TablePluginExtension = createExtension({
|
|
|
1124
1018
|
if (!context.isInTable || context.tablePos === void 0 || !context.table || context.columnIndex === void 0) return false;
|
|
1125
1019
|
if (dispatch) {
|
|
1126
1020
|
const tableStart = context.tablePos + 1;
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
for (let c = 0; c < context.columnIndex && c < firstRow.childCount; c++) firstCellPos += firstRow.child(c).nodeSize;
|
|
1131
|
-
let lastRowPos = tableStart;
|
|
1132
|
-
for (let r = 0; r < context.table.childCount - 1; r++) lastRowPos += context.table.child(r).nodeSize;
|
|
1133
|
-
let lastCellPos = lastRowPos + 1;
|
|
1134
|
-
for (let c = 0; c < context.columnIndex && c < lastRow.childCount; c++) lastCellPos += lastRow.child(c).nodeSize;
|
|
1135
|
-
const cellSel = CellSelection.create(state.doc, firstCellPos, lastCellPos);
|
|
1136
|
-
dispatch(state.tr.setSelection(cellSel));
|
|
1021
|
+
const firstCell = TableMap.get(context.table).map[context.columnIndex];
|
|
1022
|
+
if (firstCell === void 0) return false;
|
|
1023
|
+
dispatch(state.tr.setSelection(CellSelection.colSelection(state.doc.resolve(tableStart + firstCell))));
|
|
1137
1024
|
}
|
|
1138
1025
|
return true;
|
|
1139
1026
|
}
|
|
@@ -2016,6 +1903,13 @@ const TablePluginExtension = createExtension({
|
|
|
2016
1903
|
return DecorationSet.empty;
|
|
2017
1904
|
} }
|
|
2018
1905
|
});
|
|
1906
|
+
const tableCellPastePlugin = new Plugin({
|
|
1907
|
+
key: new PluginKey("tableCellPaste"),
|
|
1908
|
+
props: {
|
|
1909
|
+
transformPasted: (slice) => pastedSliceWithNewTableCells(slice),
|
|
1910
|
+
handlePaste: (view, _event, slice) => pasteTableCells(view.state, slice, view.dispatch)
|
|
1911
|
+
}
|
|
1912
|
+
});
|
|
2019
1913
|
return {
|
|
2020
1914
|
plugins: [
|
|
2021
1915
|
columnResizing({
|
|
@@ -2023,6 +1917,7 @@ const TablePluginExtension = createExtension({
|
|
|
2023
1917
|
cellMinWidth: 25,
|
|
2024
1918
|
lastColumnResizable: true
|
|
2025
1919
|
}),
|
|
1920
|
+
tableCellPastePlugin,
|
|
2026
1921
|
tableEditing(),
|
|
2027
1922
|
activeCellPlugin
|
|
2028
1923
|
],
|
|
@@ -5,8 +5,8 @@ import { TablePropertiesCommand } from "../../utils/tableOperations.js";
|
|
|
5
5
|
import { SectionBreakType } from "../sectionCarrier.js";
|
|
6
6
|
import { GenerateTableOfContentsOptions, ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
|
|
7
7
|
import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
|
|
8
|
-
import { Command, Plugin } from "prosemirror-state";
|
|
9
8
|
import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
|
|
9
|
+
import { Command, Plugin } from "prosemirror-state";
|
|
10
10
|
//#region src/prosemirror/extensions/types.d.ts
|
|
11
11
|
/**
|
|
12
12
|
* A border a host asks folio to apply.
|
|
@@ -63,6 +63,13 @@ declare const Priority: {
|
|
|
63
63
|
readonly Lowest: 200;
|
|
64
64
|
};
|
|
65
65
|
type ExtensionContext = {
|
|
66
|
+
/**
|
|
67
|
+
* The schema this runtime was built with. The documents the runtime edits
|
|
68
|
+
* may be of another instance of it (header, footer and note editors each
|
|
69
|
+
* build a runtime, and every document is parsed into the shared schema), so
|
|
70
|
+
* commands, key bindings and plugins build and compare nodes and marks with
|
|
71
|
+
* the types of the state they act on, never with types taken from here.
|
|
72
|
+
*/
|
|
66
73
|
schema: Schema;
|
|
67
74
|
};
|
|
68
75
|
type FolioCommandArguments = {
|
|
@@ -103,6 +110,9 @@ type FolioCommandArguments = {
|
|
|
103
110
|
increaseListLevel: [];
|
|
104
111
|
decreaseListLevel: [];
|
|
105
112
|
removeList: [];
|
|
113
|
+
restartNumbering: [];
|
|
114
|
+
continueNumbering: [];
|
|
115
|
+
setNumberingValue: [value: number];
|
|
106
116
|
setSpaceBefore: [twips: number];
|
|
107
117
|
setSpaceAfter: [twips: number];
|
|
108
118
|
applyStyle: [styleId: string, resolvedAttrs?: ResolvedStyleAttrs];
|
|
@@ -51,7 +51,7 @@ function forEachSearchParagraph(doc, visit) {
|
|
|
51
51
|
if (!visit(child, childPos, paragraphIndex)) return false;
|
|
52
52
|
paragraphIndex++;
|
|
53
53
|
} else if (child.type.name === "table" && !walkTable(child, childPos)) return false;
|
|
54
|
-
else if (child.type.name === "blockSdt" && !walkBlocks(child, childPos + 1)) return false;
|
|
54
|
+
else if ((child.type.name === "blockSdt" || child.type.name === "blockCustomXml") && !walkBlocks(child, childPos + 1)) return false;
|
|
55
55
|
offset += child.nodeSize;
|
|
56
56
|
}
|
|
57
57
|
return true;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EditorState, Transaction } from "prosemirror-state";
|
|
2
|
+
//#region src/prosemirror/hyperlinkRemoval.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Remove the hyperlinks from [`from`, `to`) of `tr.doc`: directly, or, with
|
|
5
|
+
* suggestions on, as a tracked replacement of the linked text by plain text.
|
|
6
|
+
*/
|
|
7
|
+
declare const removeHyperlinkInRange: (state: EditorState, tr: Transaction, from: number, to: number) => Transaction;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { removeHyperlinkInRange };
|