@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
|
@@ -1,49 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sweepPositions } from "../prosemirror/positionSweep.js";
|
|
2
2
|
import { AddMarkStep, RemoveMarkStep } from "prosemirror-transform";
|
|
3
3
|
//#region src/paged-layout/transactionDirtyRange.ts
|
|
4
4
|
function getTransactionDirtyRange(transaction) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let combinedRange = null;
|
|
16
|
-
for (let index = 0; index < transactions.length; index += 1) {
|
|
17
|
-
const transaction = transactions[index];
|
|
18
|
-
if (!transaction) continue;
|
|
19
|
-
const range = getTransactionDirtyRange(transaction);
|
|
20
|
-
if (!range) continue;
|
|
21
|
-
let from = range.from;
|
|
22
|
-
let to = range.to;
|
|
23
|
-
for (const followingTransaction of transactions.slice(index + 1)) {
|
|
24
|
-
from = followingTransaction.mapping.map(from, -1);
|
|
25
|
-
to = followingTransaction.mapping.map(to, 1);
|
|
26
|
-
}
|
|
27
|
-
combinedRange = mergeDirtyRanges(combinedRange, {
|
|
28
|
-
from,
|
|
29
|
-
to
|
|
5
|
+
const queries = [];
|
|
6
|
+
const extend = (newStart, newEnd, from) => {
|
|
7
|
+
queries.push({
|
|
8
|
+
pos: newStart,
|
|
9
|
+
assoc: -1,
|
|
10
|
+
from
|
|
11
|
+
}, {
|
|
12
|
+
pos: newEnd,
|
|
13
|
+
assoc: 1,
|
|
14
|
+
from
|
|
30
15
|
});
|
|
16
|
+
};
|
|
17
|
+
for (let stepIndex = 0; stepIndex < transaction.mapping.maps.length; stepIndex += 1) {
|
|
18
|
+
const map = transaction.mapping.maps[stepIndex];
|
|
19
|
+
if (!map) continue;
|
|
20
|
+
map.forEach((_oldStart, _oldEnd, newStart, newEnd) => extend(newStart, newEnd, stepIndex + 1));
|
|
21
|
+
const step = transaction.steps[stepIndex];
|
|
22
|
+
if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) extend(step.from, step.to, stepIndex + 1);
|
|
31
23
|
}
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
dirtyRange.to = Math.max(dirtyRange.to, finalStart, finalEnd);
|
|
24
|
+
if (queries.length === 0) return null;
|
|
25
|
+
let from = Number.POSITIVE_INFINITY;
|
|
26
|
+
let to = Number.NEGATIVE_INFINITY;
|
|
27
|
+
for (const { pos } of sweepPositions([transaction.mapping], queries)) {
|
|
28
|
+
from = Math.min(from, pos);
|
|
29
|
+
to = Math.max(to, pos);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
from,
|
|
33
|
+
to
|
|
43
34
|
};
|
|
44
|
-
map.forEach((_oldStart, _oldEnd, newStart, newEnd) => extend(newStart, newEnd));
|
|
45
|
-
const step = transaction.steps[stepIndex];
|
|
46
|
-
if (step instanceof AddMarkStep || step instanceof RemoveMarkStep) extend(step.from, step.to);
|
|
47
35
|
}
|
|
48
36
|
//#endregion
|
|
49
|
-
export { getTransactionDirtyRange
|
|
37
|
+
export { getTransactionDirtyRange };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//#region src/panel-layout.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* One layout model for the editor's side panels: the page is centred between
|
|
4
|
+
* a start track (the document outline) and an end track (the comments).
|
|
5
|
+
*
|
|
6
|
+
* The editor measures the width it has once, and this module decides how
|
|
7
|
+
* each panel is presented. Every track the page shares the row with is
|
|
8
|
+
* counted here, so the page, the outline and the comments cannot overlap:
|
|
9
|
+
* a panel either gets a track of its own or becomes a drawer the user opens
|
|
10
|
+
* on purpose. A drawer takes no track.
|
|
11
|
+
*
|
|
12
|
+
* Space goes to the page first, then the outline rail, then the comments
|
|
13
|
+
* column, then the full outline column:
|
|
14
|
+
*
|
|
15
|
+
* - comments: a column when the page, the comments and the outline rail fit;
|
|
16
|
+
* otherwise a drawer.
|
|
17
|
+
* - outline: a column when it fits beside the page and the comments column;
|
|
18
|
+
* otherwise a rail of heading ticks when that fits; otherwise a drawer.
|
|
19
|
+
*
|
|
20
|
+
* The tier names the result: `wide` when every panel has its full column,
|
|
21
|
+
* `medium` when the outline is a rail, `narrow` when a panel is a drawer.
|
|
22
|
+
* The thresholds derive from the page width (at the current zoom) and the
|
|
23
|
+
* panel widths below, never from fixed breakpoints: a zoomed-out page or a
|
|
24
|
+
* landscape section moves them.
|
|
25
|
+
*/
|
|
26
|
+
/** Widths, in CSS pixels, every tier is derived from. */
|
|
27
|
+
declare const PANEL_METRICS: {
|
|
28
|
+
/** The outline column in the `wide` tier, border included. */
|
|
29
|
+
readonly outlineColumnWidth: 256;
|
|
30
|
+
/** The outline rail in the `medium` tier, border included. */
|
|
31
|
+
readonly outlineRailWidth: 32;
|
|
32
|
+
/** A comment card column. */
|
|
33
|
+
readonly commentsWidth: 280;
|
|
34
|
+
/** Space between the page edge and the comment cards, and after them. */
|
|
35
|
+
readonly commentsGap: 12;
|
|
36
|
+
/** Canvas kept clear on either side of the page. */
|
|
37
|
+
readonly pageMargin: 20;
|
|
38
|
+
/** An outline or comments drawer, capped by the width it opens over. */
|
|
39
|
+
readonly drawerWidth: 304;
|
|
40
|
+
};
|
|
41
|
+
/** Width the comments take beside the page: gap, cards, gap. */
|
|
42
|
+
declare const COMMENTS_TRACK_WIDTH: number;
|
|
43
|
+
type PanelLayoutTier = "wide" | "medium" | "narrow";
|
|
44
|
+
/** How the outline is shown: a column, a rail of ticks, a drawer, or not at all. */
|
|
45
|
+
type OutlinePresentation = "none" | "column" | "rail" | "drawer";
|
|
46
|
+
/** How the comments are shown: a column beside the page, a drawer, or not at all. */
|
|
47
|
+
type CommentsPresentation = "hidden" | "column" | "drawer";
|
|
48
|
+
type PanelLayoutInput = {
|
|
49
|
+
/** Width of the row the outline track and the scroll viewport share, scrollbar excluded. */
|
|
50
|
+
availableWidth: number;
|
|
51
|
+
/** Width of the widest page at the current zoom. */
|
|
52
|
+
pageWidth: number;
|
|
53
|
+
/** Whether the document has an outline to show. */
|
|
54
|
+
outline: "absent" | "available";
|
|
55
|
+
/** Whether the user (or the auto-open) wants the comments shown. */
|
|
56
|
+
comments: "closed" | "open";
|
|
57
|
+
};
|
|
58
|
+
type PanelLayout = {
|
|
59
|
+
tier: PanelLayoutTier;
|
|
60
|
+
outline: OutlinePresentation;
|
|
61
|
+
comments: CommentsPresentation;
|
|
62
|
+
/** Width of the outline track at the page's start (outside the scroll viewport). */
|
|
63
|
+
outlineTrackWidth: number;
|
|
64
|
+
/** Width reserved after the page inside the scroll viewport for the comments. */
|
|
65
|
+
commentsGutter: number;
|
|
66
|
+
/** Smallest available width for each tier, for the same page and panels. */
|
|
67
|
+
thresholds: {
|
|
68
|
+
wide: number;
|
|
69
|
+
medium: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The smallest available width for each tier with the comments wanted as
|
|
74
|
+
* given: `wide` fits every column, `medium` fits the outline rail and the
|
|
75
|
+
* comments column.
|
|
76
|
+
*/
|
|
77
|
+
declare const panelLayoutThresholds: ({ pageWidth, outline, comments }: Omit<PanelLayoutInput, "availableWidth">) => PanelLayout["thresholds"];
|
|
78
|
+
/** Decide each panel's presentation for the width the editor has. */
|
|
79
|
+
declare const computePanelLayout: (input: PanelLayoutInput) => PanelLayout;
|
|
80
|
+
/** Which drawer is open over the page: at most one at a time. */
|
|
81
|
+
type PanelOverlay = "none" | "outline" | "comments";
|
|
82
|
+
//#endregion
|
|
83
|
+
export { COMMENTS_TRACK_WIDTH, CommentsPresentation, OutlinePresentation, PANEL_METRICS, PanelLayout, PanelLayoutInput, PanelLayoutTier, PanelOverlay, computePanelLayout, panelLayoutThresholds };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/panel-layout.ts
|
|
2
|
+
/**
|
|
3
|
+
* One layout model for the editor's side panels: the page is centred between
|
|
4
|
+
* a start track (the document outline) and an end track (the comments).
|
|
5
|
+
*
|
|
6
|
+
* The editor measures the width it has once, and this module decides how
|
|
7
|
+
* each panel is presented. Every track the page shares the row with is
|
|
8
|
+
* counted here, so the page, the outline and the comments cannot overlap:
|
|
9
|
+
* a panel either gets a track of its own or becomes a drawer the user opens
|
|
10
|
+
* on purpose. A drawer takes no track.
|
|
11
|
+
*
|
|
12
|
+
* Space goes to the page first, then the outline rail, then the comments
|
|
13
|
+
* column, then the full outline column:
|
|
14
|
+
*
|
|
15
|
+
* - comments: a column when the page, the comments and the outline rail fit;
|
|
16
|
+
* otherwise a drawer.
|
|
17
|
+
* - outline: a column when it fits beside the page and the comments column;
|
|
18
|
+
* otherwise a rail of heading ticks when that fits; otherwise a drawer.
|
|
19
|
+
*
|
|
20
|
+
* The tier names the result: `wide` when every panel has its full column,
|
|
21
|
+
* `medium` when the outline is a rail, `narrow` when a panel is a drawer.
|
|
22
|
+
* The thresholds derive from the page width (at the current zoom) and the
|
|
23
|
+
* panel widths below, never from fixed breakpoints: a zoomed-out page or a
|
|
24
|
+
* landscape section moves them.
|
|
25
|
+
*/
|
|
26
|
+
/** Widths, in CSS pixels, every tier is derived from. */
|
|
27
|
+
const PANEL_METRICS = {
|
|
28
|
+
/** The outline column in the `wide` tier, border included. */
|
|
29
|
+
outlineColumnWidth: 256,
|
|
30
|
+
/** The outline rail in the `medium` tier, border included. */
|
|
31
|
+
outlineRailWidth: 32,
|
|
32
|
+
/** A comment card column. */
|
|
33
|
+
commentsWidth: 280,
|
|
34
|
+
/** Space between the page edge and the comment cards, and after them. */
|
|
35
|
+
commentsGap: 12,
|
|
36
|
+
/** Canvas kept clear on either side of the page. */
|
|
37
|
+
pageMargin: 20,
|
|
38
|
+
/** An outline or comments drawer, capped by the width it opens over. */
|
|
39
|
+
drawerWidth: 304
|
|
40
|
+
};
|
|
41
|
+
/** Width the comments take beside the page: gap, cards, gap. */
|
|
42
|
+
const COMMENTS_TRACK_WIDTH = PANEL_METRICS.commentsWidth + 2 * PANEL_METRICS.commentsGap;
|
|
43
|
+
const pageTrackWidth = (pageWidth) => pageWidth + 2 * PANEL_METRICS.pageMargin;
|
|
44
|
+
/**
|
|
45
|
+
* The smallest available width for each tier with the comments wanted as
|
|
46
|
+
* given: `wide` fits every column, `medium` fits the outline rail and the
|
|
47
|
+
* comments column.
|
|
48
|
+
*/
|
|
49
|
+
const panelLayoutThresholds = ({ pageWidth, outline, comments }) => {
|
|
50
|
+
const page = pageTrackWidth(pageWidth);
|
|
51
|
+
const commentsTrack = comments === "open" ? COMMENTS_TRACK_WIDTH : 0;
|
|
52
|
+
const hasOutline = outline === "available";
|
|
53
|
+
return {
|
|
54
|
+
wide: page + commentsTrack + (hasOutline ? PANEL_METRICS.outlineColumnWidth : 0),
|
|
55
|
+
medium: page + commentsTrack + (hasOutline ? PANEL_METRICS.outlineRailWidth : 0)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const OUTLINE_TRACK_WIDTH = {
|
|
59
|
+
none: 0,
|
|
60
|
+
column: PANEL_METRICS.outlineColumnWidth,
|
|
61
|
+
rail: PANEL_METRICS.outlineRailWidth,
|
|
62
|
+
drawer: 0
|
|
63
|
+
};
|
|
64
|
+
const tierFor = (outline, comments) => {
|
|
65
|
+
if (outline === "drawer" || comments === "drawer") return "narrow";
|
|
66
|
+
if (outline === "rail") return "medium";
|
|
67
|
+
return "wide";
|
|
68
|
+
};
|
|
69
|
+
/** Decide each panel's presentation for the width the editor has. */
|
|
70
|
+
const computePanelLayout = (input) => {
|
|
71
|
+
const { availableWidth } = input;
|
|
72
|
+
const thresholds = panelLayoutThresholds(input);
|
|
73
|
+
const page = pageTrackWidth(input.pageWidth);
|
|
74
|
+
const comments = (() => {
|
|
75
|
+
if (input.comments === "closed") return "hidden";
|
|
76
|
+
return availableWidth >= thresholds.medium ? "column" : "drawer";
|
|
77
|
+
})();
|
|
78
|
+
const commentsGutter = comments === "column" ? COMMENTS_TRACK_WIDTH : 0;
|
|
79
|
+
const outline = (() => {
|
|
80
|
+
if (input.outline === "absent") return "none";
|
|
81
|
+
const beside = page + commentsGutter;
|
|
82
|
+
if (availableWidth >= thresholds.wide) return "column";
|
|
83
|
+
if (availableWidth >= beside + PANEL_METRICS.outlineRailWidth) return "rail";
|
|
84
|
+
return "drawer";
|
|
85
|
+
})();
|
|
86
|
+
return {
|
|
87
|
+
tier: tierFor(outline, comments),
|
|
88
|
+
outline,
|
|
89
|
+
comments,
|
|
90
|
+
outlineTrackWidth: OUTLINE_TRACK_WIDTH[outline],
|
|
91
|
+
commentsGutter,
|
|
92
|
+
thresholds
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { COMMENTS_TRACK_WIDTH, PANEL_METRICS, computePanelLayout, panelLayoutThresholds };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Transaction } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/anchoredTextBoxes.d.ts
|
|
4
|
+
/** The id a text box anchor names, or `undefined` for anything else. */
|
|
5
|
+
declare const textBoxAnchorIdOf: (node: Node) => string | undefined;
|
|
6
|
+
/** The anchor ids of the text boxes drawn in `node`. */
|
|
7
|
+
declare const textBoxAnchorIdsIn: (node: Node) => Set<string>;
|
|
8
|
+
/** The anchor id of a text box block drawn in a paragraph, or `undefined`. */
|
|
9
|
+
declare const anchoredTextBoxId: (node: Node) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Where the paragraph at `position` ends together with the text boxes drawn
|
|
12
|
+
* in it that follow it: the place for a block inserted after the paragraph.
|
|
13
|
+
*/
|
|
14
|
+
declare const endOfParagraphWithItsTextBoxes: (doc: Node, position: number) => number;
|
|
15
|
+
/** Anchor ids `before` holds and `after` does not. */
|
|
16
|
+
declare const droppedTextBoxAnchorIds: (before: Node, after: Node) => Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Delete the text box blocks whose anchors are in `anchorIds`. Returns whether
|
|
19
|
+
* any went.
|
|
20
|
+
*/
|
|
21
|
+
declare const deleteTextBoxesAnchoredAt: (tr: Transaction, anchorIds: ReadonlySet<string>) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Put every text box drawn in the paragraph at `position` right after it,
|
|
24
|
+
* keeping the boxes' order. For a paragraph just split: the boxes follow the
|
|
25
|
+
* second half, and those anchored in the first half move up to it.
|
|
26
|
+
*/
|
|
27
|
+
declare const gatherTextBoxesAfterParagraph: (tr: Transaction, position: number) => void;
|
|
28
|
+
/** The anchor ids of the text boxes drawn between `from` and `to`. */
|
|
29
|
+
declare const textBoxAnchorIdsBetween: (doc: Node, from: number, to: number) => Set<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Before the paragraph at `position` joins the one after it: move the text
|
|
32
|
+
* boxes drawn in it, which stand between the two, past that paragraph, where
|
|
33
|
+
* they follow the joined one. Returns whether any moved.
|
|
34
|
+
*/
|
|
35
|
+
declare const moveTextBoxesPastNextParagraph: (tr: Transaction, position: number) => boolean;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { anchoredTextBoxId, deleteTextBoxesAnchoredAt, droppedTextBoxAnchorIds, endOfParagraphWithItsTextBoxes, gatherTextBoxesAfterParagraph, moveTextBoxesPastNextParagraph, textBoxAnchorIdOf, textBoxAnchorIdsBetween, textBoxAnchorIdsIn };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { expectTextBoxAttrs } from "./attrs/index.js";
|
|
2
|
+
import "./extensions/nodes/TextBoxAnchorExtension.js";
|
|
3
|
+
import { readTextBoxAnchorAttrs } from "./textBoxAnchorAttrs.js";
|
|
4
|
+
import { Fragment } from "prosemirror-model";
|
|
5
|
+
//#region src/prosemirror/anchoredTextBoxes.ts
|
|
6
|
+
/**
|
|
7
|
+
* A text box and the paragraph it is drawn in.
|
|
8
|
+
*
|
|
9
|
+
* In DOCX a text box is run content: a `w:drawing` in a run of its paragraph.
|
|
10
|
+
* The editor lifts it out into a `textBox` block after that paragraph and
|
|
11
|
+
* leaves a zero-width `textBoxAnchor` where the run was; the save puts the box
|
|
12
|
+
* back at its anchor, wherever the block has ended up. So the anchor, not the
|
|
13
|
+
* block's position, says which paragraph owns the box, and two rules follow:
|
|
14
|
+
*
|
|
15
|
+
* - The box follows its anchor. A paragraph deleted, or its anchor deleted,
|
|
16
|
+
* takes the box with it: a drawing is content of the paragraph it is in.
|
|
17
|
+
* Left behind, the block was saved into whatever paragraph came before it.
|
|
18
|
+
* - The box sits right after its paragraph. The reader lists the box's
|
|
19
|
+
* paragraphs where the block is, and a reopened package puts the block
|
|
20
|
+
* right after the paragraph holding its anchor, so a block written between
|
|
21
|
+
* the two is read in a different order once saved.
|
|
22
|
+
*
|
|
23
|
+
* Only a box placed `inlineWithPrevious` has an anchor: a `standalone` one
|
|
24
|
+
* stands in for a paragraph that held nothing else.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Add the anchor id of `node`, when it is an anchor that names one. An anchor
|
|
28
|
+
* naming none ties no box to its paragraph.
|
|
29
|
+
*/
|
|
30
|
+
const collectAnchorId = (node, ids) => {
|
|
31
|
+
const anchorId = textBoxAnchorIdOf(node);
|
|
32
|
+
if (anchorId !== void 0) ids.add(anchorId);
|
|
33
|
+
};
|
|
34
|
+
/** The id a text box anchor names, or `undefined` for anything else. */
|
|
35
|
+
const textBoxAnchorIdOf = (node) => {
|
|
36
|
+
if (node.type.name !== "textBoxAnchor") return;
|
|
37
|
+
const attrs = readTextBoxAnchorAttrs(node);
|
|
38
|
+
return attrs.ok ? attrs.value.anchorId : void 0;
|
|
39
|
+
};
|
|
40
|
+
/** The anchor ids of the text boxes drawn in `node`. */
|
|
41
|
+
const textBoxAnchorIdsIn = (node) => {
|
|
42
|
+
const ids = /* @__PURE__ */ new Set();
|
|
43
|
+
node.descendants((child) => {
|
|
44
|
+
collectAnchorId(child, ids);
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
return ids;
|
|
48
|
+
};
|
|
49
|
+
/** The anchor id of a text box block drawn in a paragraph, or `undefined`. */
|
|
50
|
+
const anchoredTextBoxId = (node) => {
|
|
51
|
+
if (node.type.name !== "textBox") return;
|
|
52
|
+
const attrs = expectTextBoxAttrs(node);
|
|
53
|
+
return attrs._docxPlacement === "inlineWithPrevious" ? attrs._docxAnchorId : void 0;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Where the paragraph at `position` ends together with the text boxes drawn
|
|
57
|
+
* in it that follow it: the place for a block inserted after the paragraph.
|
|
58
|
+
*/
|
|
59
|
+
const endOfParagraphWithItsTextBoxes = (doc, position) => {
|
|
60
|
+
const paragraph = doc.nodeAt(position);
|
|
61
|
+
if (!paragraph) return position;
|
|
62
|
+
let end = position + paragraph.nodeSize;
|
|
63
|
+
const anchors = textBoxAnchorIdsIn(paragraph);
|
|
64
|
+
if (anchors.size === 0) return end;
|
|
65
|
+
const after = doc.resolve(end);
|
|
66
|
+
for (let index = after.index(); index < after.parent.childCount; index += 1) {
|
|
67
|
+
const sibling = after.parent.child(index);
|
|
68
|
+
const anchorId = anchoredTextBoxId(sibling);
|
|
69
|
+
if (anchorId === void 0 || !anchors.has(anchorId)) break;
|
|
70
|
+
end += sibling.nodeSize;
|
|
71
|
+
}
|
|
72
|
+
return end;
|
|
73
|
+
};
|
|
74
|
+
/** Anchor ids `before` holds and `after` does not. */
|
|
75
|
+
const droppedTextBoxAnchorIds = (before, after) => {
|
|
76
|
+
const dropped = textBoxAnchorIdsIn(before);
|
|
77
|
+
if (dropped.size === 0) return dropped;
|
|
78
|
+
for (const anchorId of textBoxAnchorIdsIn(after)) dropped.delete(anchorId);
|
|
79
|
+
return dropped;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Delete the text box blocks whose anchors are in `anchorIds`. Returns whether
|
|
83
|
+
* any went.
|
|
84
|
+
*/
|
|
85
|
+
const deleteTextBoxesAnchoredAt = (tr, anchorIds) => {
|
|
86
|
+
if (anchorIds.size === 0) return false;
|
|
87
|
+
const ranges = [];
|
|
88
|
+
tr.doc.descendants((node, position) => {
|
|
89
|
+
const anchorId = anchoredTextBoxId(node);
|
|
90
|
+
if (anchorId !== void 0 && anchorIds.has(anchorId)) {
|
|
91
|
+
ranges.push({
|
|
92
|
+
from: position,
|
|
93
|
+
to: position + node.nodeSize
|
|
94
|
+
});
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return !node.isTextblock;
|
|
98
|
+
});
|
|
99
|
+
for (const { from, to } of ranges.toReversed()) tr.delete(from, to);
|
|
100
|
+
return ranges.length > 0;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Put every text box drawn in the paragraph at `position` right after it,
|
|
104
|
+
* keeping the boxes' order. For a paragraph just split: the boxes follow the
|
|
105
|
+
* second half, and those anchored in the first half move up to it.
|
|
106
|
+
*/
|
|
107
|
+
const gatherTextBoxesAfterParagraph = (tr, position) => {
|
|
108
|
+
const paragraph = tr.doc.nodeAt(position);
|
|
109
|
+
if (!paragraph) return;
|
|
110
|
+
const anchors = textBoxAnchorIdsIn(paragraph);
|
|
111
|
+
if (anchors.size === 0) return;
|
|
112
|
+
const boxesEnd = endOfParagraphWithItsTextBoxes(tr.doc, position);
|
|
113
|
+
const at = tr.doc.resolve(boxesEnd);
|
|
114
|
+
const moved = [];
|
|
115
|
+
let offset = boxesEnd;
|
|
116
|
+
for (let index = at.index(); index < at.parent.childCount; index += 1) {
|
|
117
|
+
const sibling = at.parent.child(index);
|
|
118
|
+
const anchorId = anchoredTextBoxId(sibling);
|
|
119
|
+
if (anchorId !== void 0 && anchors.has(anchorId)) moved.push({
|
|
120
|
+
node: sibling,
|
|
121
|
+
from: offset
|
|
122
|
+
});
|
|
123
|
+
offset += sibling.nodeSize;
|
|
124
|
+
}
|
|
125
|
+
if (moved.length === 0) return;
|
|
126
|
+
for (const { node, from } of moved.toReversed()) tr.delete(from, from + node.nodeSize);
|
|
127
|
+
tr.insert(boxesEnd, Fragment.fromArray(moved.map(({ node }) => node)));
|
|
128
|
+
};
|
|
129
|
+
/** The anchor ids of the text boxes drawn between `from` and `to`. */
|
|
130
|
+
const textBoxAnchorIdsBetween = (doc, from, to) => {
|
|
131
|
+
const ids = /* @__PURE__ */ new Set();
|
|
132
|
+
doc.nodesBetween(from, to, (node) => {
|
|
133
|
+
collectAnchorId(node, ids);
|
|
134
|
+
return true;
|
|
135
|
+
});
|
|
136
|
+
return ids;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Before the paragraph at `position` joins the one after it: move the text
|
|
140
|
+
* boxes drawn in it, which stand between the two, past that paragraph, where
|
|
141
|
+
* they follow the joined one. Returns whether any moved.
|
|
142
|
+
*/
|
|
143
|
+
const moveTextBoxesPastNextParagraph = (tr, position) => {
|
|
144
|
+
const paragraph = tr.doc.nodeAt(position);
|
|
145
|
+
if (!paragraph) return false;
|
|
146
|
+
const paragraphEnd = position + paragraph.nodeSize;
|
|
147
|
+
const boxesEnd = endOfParagraphWithItsTextBoxes(tr.doc, position);
|
|
148
|
+
const next = boxesEnd > paragraphEnd ? tr.doc.nodeAt(boxesEnd) : null;
|
|
149
|
+
if (!next || next.type !== paragraph.type) return false;
|
|
150
|
+
const boxes = tr.doc.slice(paragraphEnd, boxesEnd).content;
|
|
151
|
+
tr.delete(paragraphEnd, boxesEnd);
|
|
152
|
+
tr.insert(paragraphEnd + next.nodeSize, boxes);
|
|
153
|
+
return true;
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { anchoredTextBoxId, deleteTextBoxesAnchoredAt, droppedTextBoxAnchorIds, endOfParagraphWithItsTextBoxes, gatherTextBoxesAfterParagraph, moveTextBoxesPastNextParagraph, textBoxAnchorIdOf, textBoxAnchorIdsBetween, textBoxAnchorIdsIn };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperLayer, LanguageAttrs, RunFormattingOverrideAttrs, RunIdentityMarkAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedRevisionAncestor, UnderlineAttrs } from "../schema/marks.js";
|
|
2
|
-
import { BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, PreservedBlockAttrs, PreservedXmlAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
2
|
+
import { BlockCustomXmlAttrs, BlockSdtAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, PreservedBlockAttrs, PreservedXmlAttrs, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "../schema/nodes.js";
|
|
3
3
|
import "../schema/index.js";
|
|
4
4
|
import { Mark, Node } from "prosemirror-model";
|
|
5
5
|
//#region src/prosemirror/attrs/index.d.ts
|
|
@@ -36,12 +36,16 @@ declare const readTableCellAttrs: (node: Node) => ReadProseMirrorAttrsResult<Tab
|
|
|
36
36
|
declare const expectTableCellAttrs: (node: Node) => TableCellAttrs;
|
|
37
37
|
declare const readImageAttrs: (node: Node) => ReadProseMirrorAttrsResult<ImageAttrs>;
|
|
38
38
|
declare const expectImageAttrs: (node: Node) => ImageAttrs;
|
|
39
|
+
declare const isValidEmptyFieldResultRuns: (value: unknown) => value is NonNullable<FieldAttrs["_docxEmptyResultRuns"]>;
|
|
40
|
+
declare const isValidFieldCode: (value: unknown) => value is NonNullable<FieldAttrs["_docxFieldCode"]>;
|
|
39
41
|
declare const readFieldAttrs: (node: Node) => ReadProseMirrorAttrsResult<FieldAttrs>;
|
|
40
42
|
declare const expectFieldAttrs: (node: Node) => FieldAttrs;
|
|
41
43
|
declare const readMathAttrs: (node: Node) => ReadProseMirrorAttrsResult<MathAttrs>;
|
|
42
44
|
declare const expectMathAttrs: (node: Node) => MathAttrs;
|
|
43
45
|
declare const readSdtAttrs: (node: Node) => ReadProseMirrorAttrsResult<SdtAttrs>;
|
|
44
46
|
declare const expectSdtAttrs: (node: Node) => SdtAttrs;
|
|
47
|
+
declare const readBlockCustomXmlAttrs: (node: Node) => ReadProseMirrorAttrsResult<BlockCustomXmlAttrs>;
|
|
48
|
+
declare const expectBlockCustomXmlAttrs: (node: Node) => BlockCustomXmlAttrs;
|
|
45
49
|
declare const readBlockSdtAttrs: (node: Node) => ReadProseMirrorAttrsResult<BlockSdtAttrs>;
|
|
46
50
|
declare const expectBlockSdtAttrs: (node: Node) => BlockSdtAttrs;
|
|
47
51
|
declare const readShapeAttrs: (node: Node) => ReadProseMirrorAttrsResult<ShapeAttrs>;
|
|
@@ -119,4 +123,4 @@ declare const mergeTableRowAttrs: (node: Node, patch: NodeAttrPatch<TableRowAttr
|
|
|
119
123
|
*/
|
|
120
124
|
declare const mergeTableCellAttrs: (node: Node, patch: NodeAttrPatch<TableCellAttrs>) => TableCellAttrs;
|
|
121
125
|
//#endregion
|
|
122
|
-
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, isTrackedRevisionAncestorArray, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|
|
126
|
+
export { ProseMirrorAttrIssue, ReadProseMirrorAttrsResult, expectBlockCustomXmlAttrs, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs, isTrackedRevisionAncestorArray, isValidEmptyFieldResultRuns, isValidFieldCode, mergeImageAttrs, mergeParagraphAttrs, mergeTableAttrs, mergeTableCellAttrs, mergeTableRowAttrs, readBlockCustomXmlAttrs, readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readInlineWrapperMarkAttrs, readInlineWrapperStack, readLanguageMarkAttrs, readMathAttrs, readPageBreakRunAttrs, readParagraphAttrs, readPreservedBlockAttrs, readPreservedXmlAttrs, readRunFormattingOverrideMarkAttrs, readRunIdentityMarkAttrs, readRunPropertyChangeMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readSymbolAttrs, readTabAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs };
|