@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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { mintListInstance } from "../../../docx/listNumberingInstances.js";
|
|
2
|
+
import { createNumberingMap } from "../../../docx/numberingParser.js";
|
|
3
|
+
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
4
|
+
import { completeNumberingForDoc } from "../../listInstanceReferences.js";
|
|
5
|
+
import { listItemAttrs } from "../../listNumbering.js";
|
|
6
|
+
import { getPackageNumberingDefinitions } from "../../plugins/documentNumbering.js";
|
|
7
|
+
import { panic } from "better-result";
|
|
8
|
+
import { Fragment, Slice } from "prosemirror-model";
|
|
9
|
+
//#region src/prosemirror/extensions/features/pastedHtmlLists.ts
|
|
10
|
+
/** Convert browser list markup into the editor's numbered-paragraph model. */
|
|
11
|
+
const isList = (element) => element.localName === "ul" || element.localName === "ol";
|
|
12
|
+
const hasListHint = (node) => node?.type.name === "paragraph" && Boolean(expectParagraphAttrs(node)._pastedHtmlList);
|
|
13
|
+
/**
|
|
14
|
+
* Flatten only list containers. Other HTML remains in place for the normal
|
|
15
|
+
* clipboard parser, including tables and inline formatting inside list items.
|
|
16
|
+
*/
|
|
17
|
+
const flattenPastedHtmlLists = (html) => {
|
|
18
|
+
if (!/<(?:ul|ol)\b/iu.test(html)) return html;
|
|
19
|
+
const host = document.createElement("div");
|
|
20
|
+
host.innerHTML = html;
|
|
21
|
+
let nextGroup = 0;
|
|
22
|
+
const flatten = (list, level) => {
|
|
23
|
+
const fragment = document.createDocumentFragment();
|
|
24
|
+
const group = ++nextGroup;
|
|
25
|
+
const kind = list.localName === "ul" ? "bullet" : "numbered";
|
|
26
|
+
const rawStart = Number(list.getAttribute("start"));
|
|
27
|
+
const start = Number.isSafeInteger(rawStart) && rawStart > 0 ? rawStart : void 0;
|
|
28
|
+
for (const item of Array.from(list.children)) {
|
|
29
|
+
if (item.localName !== "li") continue;
|
|
30
|
+
let paragraph = document.createElement("p");
|
|
31
|
+
let emitted = false;
|
|
32
|
+
const mark = (element) => {
|
|
33
|
+
element.setAttribute("data-folio-list-group", String(group));
|
|
34
|
+
element.setAttribute("data-folio-list-level", String(Math.min(level, 8)));
|
|
35
|
+
element.setAttribute("data-folio-list-kind", kind);
|
|
36
|
+
if (start !== void 0) element.setAttribute("data-folio-list-start", String(start));
|
|
37
|
+
};
|
|
38
|
+
const flush = () => {
|
|
39
|
+
if (!paragraph.hasChildNodes()) return;
|
|
40
|
+
mark(paragraph);
|
|
41
|
+
fragment.append(paragraph);
|
|
42
|
+
paragraph = document.createElement("p");
|
|
43
|
+
emitted = true;
|
|
44
|
+
};
|
|
45
|
+
for (const child of Array.from(item.childNodes)) if (child instanceof Element && isList(child)) {
|
|
46
|
+
flush();
|
|
47
|
+
fragment.append(flatten(child, level + 1));
|
|
48
|
+
} else if (child instanceof Element && child.localName === "p") {
|
|
49
|
+
flush();
|
|
50
|
+
mark(child);
|
|
51
|
+
fragment.append(child);
|
|
52
|
+
emitted = true;
|
|
53
|
+
} else if (child.nodeType !== Node.TEXT_NODE || child.textContent?.trim()) paragraph.append(child);
|
|
54
|
+
flush();
|
|
55
|
+
if (!emitted) {
|
|
56
|
+
mark(paragraph);
|
|
57
|
+
fragment.append(paragraph);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return fragment;
|
|
61
|
+
};
|
|
62
|
+
for (const list of Array.from(host.querySelectorAll("ul,ol"))) {
|
|
63
|
+
if (!list.parentNode || list.parentElement?.closest("ul,ol")) continue;
|
|
64
|
+
list.replaceWith(flatten(list, 0));
|
|
65
|
+
}
|
|
66
|
+
return host.innerHTML;
|
|
67
|
+
};
|
|
68
|
+
/** Resolve clipboard-only list hints against fresh document numbering ids. */
|
|
69
|
+
const numberPastedHtmlLists = (slice, view) => {
|
|
70
|
+
let hasList = false;
|
|
71
|
+
slice.content.descendants((node) => {
|
|
72
|
+
if (hasListHint(node)) {
|
|
73
|
+
hasList = true;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return !hasList;
|
|
77
|
+
});
|
|
78
|
+
if (!hasList) return slice;
|
|
79
|
+
const startsWithList = hasListHint(slice.content.firstChild);
|
|
80
|
+
const endsWithList = hasListHint(slice.content.lastChild);
|
|
81
|
+
let definitions = completeNumberingForDoc(getPackageNumberingDefinitions(view.state) ?? void 0, view.state.doc);
|
|
82
|
+
let numbering = null;
|
|
83
|
+
const groups = /* @__PURE__ */ new Map();
|
|
84
|
+
let changed = false;
|
|
85
|
+
const convert = (node) => {
|
|
86
|
+
let result = node;
|
|
87
|
+
if (node.type.name === "paragraph") {
|
|
88
|
+
const attrs = expectParagraphAttrs(node);
|
|
89
|
+
const hint = attrs._pastedHtmlList;
|
|
90
|
+
if (hint) {
|
|
91
|
+
let group = groups.get(hint.group);
|
|
92
|
+
if (!group || group.kind !== hint.kind) {
|
|
93
|
+
const minted = mintListInstance(definitions, {
|
|
94
|
+
kind: hint.kind,
|
|
95
|
+
...hint.start === void 0 ? {} : { start: hint.start }
|
|
96
|
+
});
|
|
97
|
+
definitions = minted.definitions;
|
|
98
|
+
numbering = createNumberingMap(definitions);
|
|
99
|
+
group = {
|
|
100
|
+
numId: minted.numId,
|
|
101
|
+
kind: hint.kind
|
|
102
|
+
};
|
|
103
|
+
groups.set(hint.group, group);
|
|
104
|
+
}
|
|
105
|
+
if (!numbering) panic("Pasted list group has no numbering definition");
|
|
106
|
+
const { _pastedHtmlList: _consumed, ...unhinted } = attrs;
|
|
107
|
+
result = node.type.create(listItemAttrs(unhinted, {
|
|
108
|
+
numId: group.numId,
|
|
109
|
+
ilvl: hint.level
|
|
110
|
+
}, numbering), node.content, node.marks);
|
|
111
|
+
changed = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (result.childCount === 0) return result;
|
|
115
|
+
const children = [];
|
|
116
|
+
result.forEach((child) => children.push(convert(child)));
|
|
117
|
+
return result.copy(Fragment.fromArray(children));
|
|
118
|
+
};
|
|
119
|
+
const children = [];
|
|
120
|
+
slice.content.forEach((node) => children.push(convert(node)));
|
|
121
|
+
return changed ? new Slice(Fragment.fromArray(children), startsWithList ? 0 : slice.openStart, endsWithList ? 0 : slice.openEnd) : slice;
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
export { flattenPastedHtmlLists, numberPastedHtmlLists };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { expectFootnoteRefMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { suggestRangeDeletion, suggestionModeKey } from "../../plugins/suggestionMode.js";
|
|
2
3
|
import { createMarkExtension } from "../create.js";
|
|
4
|
+
import { expandNoteReferenceDeletionRange, noteReferenceRanges } from "./noteReferenceDeletion.js";
|
|
3
5
|
import { panic } from "better-result";
|
|
4
6
|
//#region src/prosemirror/extensions/marks/FootnoteRefExtension.ts
|
|
5
7
|
/**
|
|
@@ -57,11 +59,19 @@ const FootnoteRefExtension = createMarkExtension({
|
|
|
57
59
|
];
|
|
58
60
|
}
|
|
59
61
|
},
|
|
60
|
-
onSchemaReady(
|
|
61
|
-
const
|
|
62
|
+
onSchemaReady() {
|
|
63
|
+
const deleteWholeNoteReference = (direction) => (state, dispatch) => {
|
|
64
|
+
if (suggestionModeKey.getState(state)?.active) return false;
|
|
65
|
+
const { from, to, empty } = state.selection;
|
|
66
|
+
const range = expandNoteReferenceDeletionRange(state.doc, empty && direction === "backward" ? Math.max(0, from - 1) : from, empty && direction === "forward" ? Math.min(state.doc.content.size, to + 1) : to);
|
|
67
|
+
if (!range) return false;
|
|
68
|
+
dispatch?.(state.tr.delete(range.from, range.to).scrollIntoView());
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
62
71
|
function makeInsertNote(noteType) {
|
|
63
72
|
return (id) => (state, dispatch) => {
|
|
64
73
|
if (!dispatch) return true;
|
|
74
|
+
const { schema } = state;
|
|
65
75
|
const footnoteRefType = schema.marks["footnoteRef"];
|
|
66
76
|
if (!footnoteRefType) panic("Missing mark type: footnoteRef");
|
|
67
77
|
const mark = footnoteRefType.create({
|
|
@@ -74,20 +84,32 @@ const FootnoteRefExtension = createMarkExtension({
|
|
|
74
84
|
return true;
|
|
75
85
|
};
|
|
76
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Delete the note references the selection touches (the one beside a
|
|
89
|
+
* caret), each whole: tracked as a deletion of the reference run when
|
|
90
|
+
* suggesting, removed outright otherwise.
|
|
91
|
+
*/
|
|
77
92
|
const deleteNoteRef = (state, dispatch) => {
|
|
78
|
-
const {
|
|
93
|
+
const { from, to, empty } = state.selection;
|
|
94
|
+
const references = noteReferenceRanges(state.doc, empty ? Math.max(0, from - 1) : from, empty ? Math.min(state.doc.content.size, to + 1) : to);
|
|
95
|
+
if (references.length === 0) return false;
|
|
79
96
|
if (!dispatch) return true;
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
tr = tr.removeMark($from.pos, $to.pos, markType);
|
|
97
|
+
const tr = state.tr;
|
|
98
|
+
for (const reference of references.toReversed()) if (!suggestRangeDeletion(state, tr, reference.from, reference.to)) tr.delete(reference.from, reference.to);
|
|
83
99
|
dispatch(tr.scrollIntoView());
|
|
84
100
|
return true;
|
|
85
101
|
};
|
|
86
|
-
return {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
102
|
+
return {
|
|
103
|
+
keyboardShortcuts: {
|
|
104
|
+
Backspace: deleteWholeNoteReference("backward"),
|
|
105
|
+
Delete: deleteWholeNoteReference("forward")
|
|
106
|
+
},
|
|
107
|
+
commands: {
|
|
108
|
+
insertFootnote: makeInsertNote("footnote"),
|
|
109
|
+
insertEndnote: makeInsertNote("endnote"),
|
|
110
|
+
deleteNoteRef: () => deleteNoteRef
|
|
111
|
+
}
|
|
112
|
+
};
|
|
91
113
|
}
|
|
92
114
|
});
|
|
93
115
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { anchorTargetAttrs, normalizeUserUrl, sanitizeExternalUrl } from "../../../utils/urlSecurity.js";
|
|
2
2
|
import { expectHyperlinkMarkAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { removeHyperlinkInRange } from "../../hyperlinkRemoval.js";
|
|
3
4
|
import { createMarkExtension } from "../create.js";
|
|
4
5
|
import { isMarkActive } from "./markUtils.js";
|
|
5
6
|
import { panic } from "better-result";
|
|
@@ -118,9 +119,10 @@ const HyperlinkExtension = createMarkExtension({
|
|
|
118
119
|
}
|
|
119
120
|
},
|
|
120
121
|
onSchemaReady(ctx) {
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
if (!ctx.schema.marks["hyperlink"]) panic("Missing mark type: hyperlink");
|
|
123
|
+
const documentHyperlinkType = (state) => state.schema.marks["hyperlink"] ?? panic("Missing mark type: hyperlink");
|
|
123
124
|
const setHyperlink = (href, tooltip) => (state, dispatch) => {
|
|
125
|
+
const hlType = documentHyperlinkType(state);
|
|
124
126
|
const { from, to, empty } = state.selection;
|
|
125
127
|
if (empty) return false;
|
|
126
128
|
if (dispatch) {
|
|
@@ -136,6 +138,7 @@ const HyperlinkExtension = createMarkExtension({
|
|
|
136
138
|
return true;
|
|
137
139
|
};
|
|
138
140
|
const removeHyperlink = (state, dispatch) => {
|
|
141
|
+
const hlType = documentHyperlinkType(state);
|
|
139
142
|
const { from, to, empty } = state.selection;
|
|
140
143
|
if (empty) {
|
|
141
144
|
const $pos = state.selection.$from;
|
|
@@ -154,13 +157,14 @@ const HyperlinkExtension = createMarkExtension({
|
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
});
|
|
157
|
-
if (dispatch) dispatch(state.tr
|
|
160
|
+
if (dispatch) dispatch(removeHyperlinkInRange(state, state.tr, start, end).scrollIntoView());
|
|
158
161
|
return true;
|
|
159
162
|
}
|
|
160
|
-
if (dispatch) dispatch(state.tr
|
|
163
|
+
if (dispatch) dispatch(removeHyperlinkInRange(state, state.tr, from, to).scrollIntoView());
|
|
161
164
|
return true;
|
|
162
165
|
};
|
|
163
166
|
const insertHyperlink = (text, href, tooltip) => (state, dispatch) => {
|
|
167
|
+
const hlType = documentHyperlinkType(state);
|
|
164
168
|
if (dispatch) {
|
|
165
169
|
const mark = hlType.create({
|
|
166
170
|
href: normalizeHyperlinkInput(href),
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { MarkExtension } from "../types.js";
|
|
2
|
+
import { Transaction } from "prosemirror-state";
|
|
2
3
|
//#region src/prosemirror/extensions/marks/RunIdentityExtension.d.ts
|
|
4
|
+
type InsertedRange = {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
};
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
5
|
-
* carried which no formatting mark holds.
|
|
9
|
+
* Every range `transactions` inserted, in the document they produced.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* A step map reports each replacement as an old span and the new span it
|
|
12
|
+
* became; a new span longer than nothing is content the step put there, which
|
|
13
|
+
* is exactly the text that may not claim an authored run. Each range is then
|
|
14
|
+
* carried through the steps that followed it — the rest of its own
|
|
15
|
+
* transaction, then every later one — so a batch applied together reports
|
|
16
|
+
* positions in the document this hook is looking at rather than in an
|
|
17
|
+
* intermediate one.
|
|
13
18
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* never write a session id it did not read. Typed text becomes its own run
|
|
21
|
-
* with no attributes instead, and `w:rsidRDefault` on the parent `w:p`
|
|
22
|
-
* supplies the session the format itself says such a run belongs to.
|
|
19
|
+
* An undo is not an insertion: it puts back what an edit took away, identity
|
|
20
|
+
* included, and stripping that would leave the restored text claiming no run
|
|
21
|
+
* it came from. `skip` names the transactions to pass over; they still carry
|
|
22
|
+
* the ranges of the others forward.
|
|
23
|
+
*
|
|
24
|
+
* @internal Exported for the per-step equivalence test.
|
|
23
25
|
*/
|
|
26
|
+
declare const insertedRanges: (transactions: readonly Transaction[], skip?: (transaction: Transaction) => boolean) => InsertedRange[];
|
|
24
27
|
declare const RunIdentityExtension: (options?: Partial<Record<string, unknown>> | undefined) => MarkExtension;
|
|
25
28
|
//#endregion
|
|
26
|
-
export { RunIdentityExtension };
|
|
29
|
+
export { RunIdentityExtension, insertedRanges };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { expectRunIdentityMarkAttrs } from "../../attrs/index.js";
|
|
2
|
+
import { nodesBetweenIndexed } from "../../indexedNodeLookup.js";
|
|
3
|
+
import { sweepPositions } from "../../positionSweep.js";
|
|
2
4
|
import { RUN_IDENTITY_ATTRIBUTE, RUN_IDENTITY_MARK_NAME, runIdentityAttrs } from "../../runIdentity.js";
|
|
3
5
|
import { createMarkExtension } from "../create.js";
|
|
4
6
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
7
|
+
import { isHistoryTransaction, undoDepth } from "prosemirror-history";
|
|
5
8
|
//#region src/prosemirror/extensions/marks/RunIdentityExtension.ts
|
|
6
9
|
/**
|
|
7
10
|
* Editor-side identity for one authored `w:r`, and the payload that element
|
|
@@ -36,27 +39,43 @@ const runIdentityStripKey = new PluginKey("runIdentityStrip");
|
|
|
36
39
|
* transaction, then every later one — so a batch applied together reports
|
|
37
40
|
* positions in the document this hook is looking at rather than in an
|
|
38
41
|
* intermediate one.
|
|
42
|
+
*
|
|
43
|
+
* An undo is not an insertion: it puts back what an edit took away, identity
|
|
44
|
+
* included, and stripping that would leave the restored text claiming no run
|
|
45
|
+
* it came from. `skip` names the transactions to pass over; they still carry
|
|
46
|
+
* the ranges of the others forward.
|
|
47
|
+
*
|
|
48
|
+
* @internal Exported for the per-step equivalence test.
|
|
39
49
|
*/
|
|
40
|
-
const insertedRanges = (transactions) => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return mapped;
|
|
48
|
-
};
|
|
50
|
+
const insertedRanges = (transactions, skip = () => false) => {
|
|
51
|
+
const queries = [];
|
|
52
|
+
let stepOffset = 0;
|
|
53
|
+
for (const transaction of transactions) {
|
|
54
|
+
const offset = stepOffset;
|
|
55
|
+
stepOffset += transaction.mapping.maps.length;
|
|
56
|
+
if (skip(transaction)) continue;
|
|
49
57
|
transaction.mapping.maps.forEach((stepMap, stepIndex) => {
|
|
50
|
-
const
|
|
58
|
+
const from = offset + stepIndex + 1;
|
|
51
59
|
stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
52
60
|
if (newEnd <= newStart) return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
queries.push({
|
|
62
|
+
pos: newStart,
|
|
63
|
+
assoc: -1,
|
|
64
|
+
from
|
|
65
|
+
}, {
|
|
66
|
+
pos: newEnd,
|
|
67
|
+
assoc: 1,
|
|
68
|
+
from
|
|
56
69
|
});
|
|
57
70
|
});
|
|
58
71
|
});
|
|
59
72
|
}
|
|
73
|
+
const mapped = sweepPositions(transactions.map((transaction) => transaction.mapping), queries);
|
|
74
|
+
const ranges = [];
|
|
75
|
+
for (let index = 0; index < mapped.length; index += 2) ranges.push({
|
|
76
|
+
from: mapped[index].pos,
|
|
77
|
+
to: mapped[index + 1].pos
|
|
78
|
+
});
|
|
60
79
|
return ranges;
|
|
61
80
|
};
|
|
62
81
|
/**
|
|
@@ -69,11 +88,12 @@ const insertedRanges = (transactions) => {
|
|
|
69
88
|
*/
|
|
70
89
|
const createRunIdentityStripPlugin = () => new Plugin({
|
|
71
90
|
key: runIdentityStripKey,
|
|
72
|
-
appendTransaction(transactions,
|
|
91
|
+
appendTransaction(transactions, oldState, newState) {
|
|
73
92
|
if (!transactions.some((transaction) => transaction.docChanged)) return null;
|
|
74
93
|
const markType = newState.schema.marks[RUN_IDENTITY_MARK_NAME];
|
|
75
94
|
if (markType === void 0) return null;
|
|
76
|
-
const
|
|
95
|
+
const undoing = undoDepth(newState) < undoDepth(oldState);
|
|
96
|
+
const ranges = insertedRanges(transactions, (transaction) => undoing && isHistoryTransaction(transaction));
|
|
77
97
|
if (ranges.length === 0) return null;
|
|
78
98
|
const tr = newState.tr;
|
|
79
99
|
const stripRange = ({ from, to }) => {
|
|
@@ -81,7 +101,7 @@ const createRunIdentityStripPlugin = () => new Plugin({
|
|
|
81
101
|
const clampedFrom = Math.min(from, clampedTo);
|
|
82
102
|
if (clampedFrom === clampedTo) return false;
|
|
83
103
|
let rangeStripped = false;
|
|
84
|
-
newState.doc
|
|
104
|
+
nodesBetweenIndexed(newState.doc, clampedFrom, clampedTo, (node, pos) => {
|
|
85
105
|
if (!node.isInline || !markType.isInSet(node.marks)) return true;
|
|
86
106
|
tr.removeMark(Math.max(pos, clampedFrom), Math.min(pos + node.nodeSize, clampedTo), markType);
|
|
87
107
|
rangeStripped = true;
|
|
@@ -132,4 +152,4 @@ const RunIdentityExtension = createMarkExtension({
|
|
|
132
152
|
}
|
|
133
153
|
});
|
|
134
154
|
//#endregion
|
|
135
|
-
export { RunIdentityExtension };
|
|
155
|
+
export { RunIdentityExtension, insertedRanges };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMarkExtension } from "../create.js";
|
|
2
|
+
import { toggleDocumentMark } from "./markUtils.js";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
|
-
import { toggleMark } from "prosemirror-commands";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/StrikeExtension.ts
|
|
5
5
|
/**
|
|
6
6
|
* Strikethrough Mark Extension
|
|
@@ -26,7 +26,7 @@ const StrikeExtension = createMarkExtension({
|
|
|
26
26
|
onSchemaReady(ctx) {
|
|
27
27
|
const strikeType = ctx.schema.marks["strike"];
|
|
28
28
|
if (!strikeType) panic("Missing mark type: strike");
|
|
29
|
-
return { commands: { toggleStrike: () =>
|
|
29
|
+
return { commands: { toggleStrike: () => toggleDocumentMark(strikeType) } };
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMarkExtension } from "../create.js";
|
|
2
|
+
import { toggleDocumentMark } from "./markUtils.js";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
|
-
import { toggleMark } from "prosemirror-commands";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/SubscriptExtension.ts
|
|
5
5
|
/**
|
|
6
6
|
* Subscript Mark Extension
|
|
@@ -18,7 +18,7 @@ const SubscriptExtension = createMarkExtension({
|
|
|
18
18
|
onSchemaReady(ctx) {
|
|
19
19
|
const subscriptType = ctx.schema.marks["subscript"];
|
|
20
20
|
if (!subscriptType) panic("Missing mark type: subscript");
|
|
21
|
-
return { commands: { toggleSubscript: () =>
|
|
21
|
+
return { commands: { toggleSubscript: () => toggleDocumentMark(subscriptType) } };
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMarkExtension } from "../create.js";
|
|
2
|
+
import { toggleDocumentMark } from "./markUtils.js";
|
|
2
3
|
import { panic } from "better-result";
|
|
3
|
-
import { toggleMark } from "prosemirror-commands";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/SuperscriptExtension.ts
|
|
5
5
|
/**
|
|
6
6
|
* Superscript Mark Extension
|
|
@@ -18,7 +18,7 @@ const SuperscriptExtension = createMarkExtension({
|
|
|
18
18
|
onSchemaReady(ctx) {
|
|
19
19
|
const superscriptType = ctx.schema.marks["superscript"];
|
|
20
20
|
if (!superscriptType) panic("Missing mark type: superscript");
|
|
21
|
-
return { commands: { toggleSuperscript: () =>
|
|
21
|
+
return { commands: { toggleSuperscript: () => toggleDocumentMark(superscriptType) } };
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
//#endregion
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { textToStyle } from "../../../utils/formatToStyle.js";
|
|
2
2
|
import { expectTextColorMarkAttrs } from "../../attrs/index.js";
|
|
3
|
+
import { clearRunColor } from "../../clearRunColor.js";
|
|
3
4
|
import { createMarkExtension } from "../create.js";
|
|
4
|
-
import {
|
|
5
|
+
import { setMark } from "./markUtils.js";
|
|
5
6
|
import { panic } from "better-result";
|
|
6
7
|
//#region src/prosemirror/extensions/marks/TextColorExtension.ts
|
|
7
8
|
/**
|
|
@@ -39,10 +40,10 @@ const TextColorExtension = createMarkExtension({
|
|
|
39
40
|
if (!textColorType) panic("Missing mark type: textColor");
|
|
40
41
|
return { commands: {
|
|
41
42
|
setTextColor: (attrs) => {
|
|
42
|
-
if (!attrs.rgb && !attrs.themeColor) return
|
|
43
|
+
if (!attrs.rgb && !attrs.themeColor) return clearRunColor();
|
|
43
44
|
return setMark(textColorType, attrs);
|
|
44
45
|
},
|
|
45
|
-
clearTextColor: () =>
|
|
46
|
+
clearTextColor: () => clearRunColor()
|
|
46
47
|
} };
|
|
47
48
|
}
|
|
48
49
|
});
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { document_d_exports } from "../../../types/document.js";
|
|
2
|
-
import { Command, EditorState } from "prosemirror-state";
|
|
3
2
|
import { Attrs, Mark, MarkType, Schema } from "prosemirror-model";
|
|
3
|
+
import { Command, EditorState } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/extensions/marks/markUtils.d.ts
|
|
5
5
|
type MarkAttrs = Record<string, unknown>;
|
|
6
6
|
declare function marksToTextFormatting(marks: readonly Mark[]): document_d_exports.TextFormatting;
|
|
7
|
-
declare function setMark(
|
|
7
|
+
declare function setMark(type: MarkType, attrs: MarkAttrs): Command;
|
|
8
8
|
type PairedToggleProperty = "bold" | "italic";
|
|
9
|
+
/** `toggleMark` for the document's own counterpart of `type`. */
|
|
10
|
+
declare const toggleDocumentMark: (type: MarkType) => Command;
|
|
9
11
|
/** UI toggle whose direct-formatting contract explicitly targets both script families. */
|
|
10
|
-
declare const toggleMarkForAllScripts: (
|
|
12
|
+
declare const toggleMarkForAllScripts: (type: MarkType, property: PairedToggleProperty) => Command;
|
|
11
13
|
/** UI size command whose direct-formatting contract explicitly targets both script families. */
|
|
12
14
|
declare const setFontSizeForAllScripts: (markType: MarkType, size: number) => Command;
|
|
13
15
|
/** Clears both ordinary and complex-script direct size through the UI command boundary. */
|
|
14
16
|
declare const clearFontSizeForAllScripts: (markType: MarkType) => Command;
|
|
15
17
|
declare function toggleUnderlineMark(markType: MarkType): Command;
|
|
16
|
-
declare function removeMark(
|
|
18
|
+
declare function removeMark(type: MarkType): Command;
|
|
17
19
|
/**
|
|
18
20
|
* Check if a mark is active in the current selection
|
|
19
21
|
*/
|
|
20
|
-
declare function isMarkActive(state: EditorState,
|
|
22
|
+
declare function isMarkActive(state: EditorState, type: MarkType, attrs?: Record<string, unknown>): boolean;
|
|
21
23
|
/**
|
|
22
24
|
* Get the current value of a mark attribute
|
|
23
25
|
*/
|
|
24
|
-
declare function getMarkAttr(state: EditorState,
|
|
26
|
+
declare function getMarkAttr(state: EditorState, type: MarkType, attr: string): unknown;
|
|
25
27
|
type AuthoredRunFormattingCarrier = "preserve" | "reconstruct";
|
|
26
28
|
/** Builds a mark by type name; a conversion passes one that shares equal marks. */
|
|
27
29
|
type MarkFactory = (type: string, attrs?: Attrs | null) => Mark;
|
|
@@ -39,7 +41,12 @@ type TextFormattingToMarksOptions = {
|
|
|
39
41
|
};
|
|
40
42
|
declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting | undefined, schema: Schema, options?: TextFormattingToMarksOptions): Mark[];
|
|
41
43
|
/**
|
|
42
|
-
* Clear
|
|
44
|
+
* Clear character formatting from the selection.
|
|
45
|
+
*
|
|
46
|
+
* Only the marks that carry run formatting go. A comment anchor, a hyperlink,
|
|
47
|
+
* a note reference, a tracked insertion or deletion and a run's identity are
|
|
48
|
+
* not formatting, and removing them deleted the comment's range, unlinked the
|
|
49
|
+
* text, orphaned the note and silently resolved the revision.
|
|
43
50
|
*/
|
|
44
51
|
declare const clearFormatting: Command;
|
|
45
52
|
/**
|
|
@@ -51,4 +58,4 @@ declare function createSetMarkCommand(markType: MarkType, attrs?: Record<string,
|
|
|
51
58
|
*/
|
|
52
59
|
declare function createRemoveMarkCommand(markType: MarkType): Command;
|
|
53
60
|
//#endregion
|
|
54
|
-
export { AuthoredRunFormattingCarrier, MarkFactory, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
61
|
+
export { AuthoredRunFormattingCarrier, MarkFactory, clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleDocumentMark, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -3,7 +3,9 @@ import { mergeFontFamily } from "../../../utils/fontFamilyMerge.js";
|
|
|
3
3
|
import { normalizeHorizontalScalePercent } from "../../../utils/horizontalScale.js";
|
|
4
4
|
import { expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectEmphasisMarkAttrs, expectFontFamilyMarkAttrs, expectRunFormattingOverrideMarkAttrs, expectRunShadingMarkAttrs, expectStrikeMarkAttrs, expectTextEffectMarkAttrs } from "../../attrs/index.js";
|
|
5
5
|
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "../../conversion/runShadingMark.js";
|
|
6
|
+
import { documentMarkType } from "../../documentSchema.js";
|
|
6
7
|
import { selectRunFormattingCarrierRepresentations } from "../../runFormattingInlineCarriers.js";
|
|
8
|
+
import { RUN_FORMATTING_MARK_NAMES } from "../../runFormattingMarkNames.js";
|
|
7
9
|
import { hasRunFormattingOverrideAttrs } from "../../runFormattingProvenance.js";
|
|
8
10
|
import { COMPLEX_SCRIPT_RUN_PROPERTY_KEYS } from "../../schema/marks.js";
|
|
9
11
|
import { applyRunFormattingOverrideMark, buildRunFormattingOverrideAttrs } from "./RunFormattingOverrideExtension.js";
|
|
@@ -177,8 +179,9 @@ function createMarkWithMergedAttrs(markType, currentMark, nextAttrs) {
|
|
|
177
179
|
if (!markRequiresAttrMerge(markType)) return markType.create(nextAttrs);
|
|
178
180
|
return markType.create(mergeMarkAttrs(markType, currentMark, nextAttrs));
|
|
179
181
|
}
|
|
180
|
-
function setMark(
|
|
182
|
+
function setMark(type, attrs) {
|
|
181
183
|
return (state, dispatch) => {
|
|
184
|
+
const markType = documentMarkType(state, type);
|
|
182
185
|
const { from, to, empty } = state.selection;
|
|
183
186
|
if (empty) {
|
|
184
187
|
if (dispatch) {
|
|
@@ -200,7 +203,8 @@ function setMark(markType, attrs) {
|
|
|
200
203
|
if (!node.isText) return;
|
|
201
204
|
const start = Math.max(from, pos);
|
|
202
205
|
const end = Math.min(to, pos + node.nodeSize);
|
|
203
|
-
const
|
|
206
|
+
const currentMark = markType.isInSet(node.marks);
|
|
207
|
+
const mark = createMarkWithMergedAttrs(markType, currentMark, attrs);
|
|
204
208
|
tr = tr.addMark(start, end, mark);
|
|
205
209
|
});
|
|
206
210
|
dispatch(tr.scrollIntoView());
|
|
@@ -282,8 +286,11 @@ const updateRunFormattingOverride = (state, tr, update) => {
|
|
|
282
286
|
const withRunFormattingOverride = (command, update) => (state, dispatch) => command(state, dispatch ? (tr) => {
|
|
283
287
|
dispatch(updateRunFormattingOverride(state, tr, update));
|
|
284
288
|
} : void 0);
|
|
289
|
+
/** `toggleMark` for the document's own counterpart of `type`. */
|
|
290
|
+
const toggleDocumentMark = (type) => (state, dispatch, view) => toggleMark(documentMarkType(state, type))(state, dispatch, view);
|
|
285
291
|
/** UI toggle whose direct-formatting contract explicitly targets both script families. */
|
|
286
|
-
const toggleMarkForAllScripts = (
|
|
292
|
+
const toggleMarkForAllScripts = (type, property) => (state, dispatch) => {
|
|
293
|
+
const markType = documentMarkType(state, type);
|
|
287
294
|
const enabled = !isMarkActive(state, markType);
|
|
288
295
|
return withRunFormattingOverride(toggleMark(markType), (attrs) => updatePairedToggleAttrs(attrs, property, enabled))(state, dispatch);
|
|
289
296
|
};
|
|
@@ -310,10 +317,11 @@ function selectionHasVisibleUnderline(state, markType) {
|
|
|
310
317
|
return hasVisibleUnderline;
|
|
311
318
|
}
|
|
312
319
|
function toggleUnderlineMark(markType) {
|
|
313
|
-
return (state, dispatch) => setMark(markType, { style: selectionHasVisibleUnderline(state, markType) ? "none" : "single" })(state, dispatch);
|
|
320
|
+
return (state, dispatch) => setMark(markType, { style: selectionHasVisibleUnderline(state, documentMarkType(state, markType)) ? "none" : "single" })(state, dispatch);
|
|
314
321
|
}
|
|
315
|
-
function removeMark(
|
|
322
|
+
function removeMark(type) {
|
|
316
323
|
return (state, dispatch) => {
|
|
324
|
+
const markType = documentMarkType(state, type);
|
|
317
325
|
const { from, to, empty } = state.selection;
|
|
318
326
|
if (empty) {
|
|
319
327
|
if (dispatch) dispatchStoredMarks(state, dispatch, (state.storedMarks ?? state.selection.$from.marks()).filter((m) => m.type !== markType));
|
|
@@ -326,7 +334,8 @@ function removeMark(markType) {
|
|
|
326
334
|
/**
|
|
327
335
|
* Check if a mark is active in the current selection
|
|
328
336
|
*/
|
|
329
|
-
function isMarkActive(state,
|
|
337
|
+
function isMarkActive(state, type, attrs) {
|
|
338
|
+
const markType = documentMarkType(state, type);
|
|
330
339
|
const { from, to, empty } = state.selection;
|
|
331
340
|
if (empty) return (state.storedMarks ?? state.selection.$from.marks()).some((mark) => {
|
|
332
341
|
if (mark.type !== markType) return false;
|
|
@@ -355,7 +364,8 @@ function isMarkActive(state, markType, attrs) {
|
|
|
355
364
|
/**
|
|
356
365
|
* Get the current value of a mark attribute
|
|
357
366
|
*/
|
|
358
|
-
function getMarkAttr(state,
|
|
367
|
+
function getMarkAttr(state, type, attr) {
|
|
368
|
+
const markType = documentMarkType(state, type);
|
|
359
369
|
const { empty, $from, from, to } = state.selection;
|
|
360
370
|
if (empty) {
|
|
361
371
|
const marks = state.storedMarks ?? $from.marks();
|
|
@@ -480,7 +490,12 @@ function textFormattingToMarks(formatting, schema, options) {
|
|
|
480
490
|
return marks;
|
|
481
491
|
}
|
|
482
492
|
/**
|
|
483
|
-
* Clear
|
|
493
|
+
* Clear character formatting from the selection.
|
|
494
|
+
*
|
|
495
|
+
* Only the marks that carry run formatting go. A comment anchor, a hyperlink,
|
|
496
|
+
* a note reference, a tracked insertion or deletion and a run's identity are
|
|
497
|
+
* not formatting, and removing them deleted the comment's range, unlinked the
|
|
498
|
+
* text, orphaned the note and silently resolved the revision.
|
|
484
499
|
*/
|
|
485
500
|
const clearFormatting = (state, dispatch) => {
|
|
486
501
|
const { from, to, empty } = state.selection;
|
|
@@ -498,7 +513,7 @@ const clearFormatting = (state, dispatch) => {
|
|
|
498
513
|
if (node.isText && node.marks.length > 0) {
|
|
499
514
|
const start = Math.max(from, pos);
|
|
500
515
|
const end = Math.min(to, pos + node.nodeSize);
|
|
501
|
-
for (const mark of node.marks) tr = tr.removeMark(start, end, mark.type);
|
|
516
|
+
for (const mark of node.marks) if (RUN_FORMATTING_MARK_NAMES.has(mark.type.name)) tr = tr.removeMark(start, end, mark.type);
|
|
502
517
|
}
|
|
503
518
|
});
|
|
504
519
|
dispatch(tr.scrollIntoView());
|
|
@@ -518,4 +533,4 @@ function createRemoveMarkCommand(markType) {
|
|
|
518
533
|
return removeMark(markType);
|
|
519
534
|
}
|
|
520
535
|
//#endregion
|
|
521
|
-
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
536
|
+
export { clearFontSizeForAllScripts, clearFormatting, createRemoveMarkCommand, createSetMarkCommand, getMarkAttr, isMarkActive, marksToTextFormatting, removeMark, setFontSizeForAllScripts, setMark, textFormattingToMarks, toggleDocumentMark, toggleMarkForAllScripts, toggleUnderlineMark };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
//#region src/prosemirror/extensions/marks/noteReferenceDeletion.d.ts
|
|
3
|
+
type DeletionRange = {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
};
|
|
7
|
+
/** Keep the text carrying one OOXML note reference together during deletion. */
|
|
8
|
+
declare const expandNoteReferenceDeletionRange: (doc: Node, from: number, to: number) => DeletionRange | null;
|
|
9
|
+
/** Each whole note reference [`from`, `to`) of `doc` touches, in document order. */
|
|
10
|
+
declare const noteReferenceRanges: (doc: Node, from: number, to: number) => DeletionRange[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { expandNoteReferenceDeletionRange, noteReferenceRanges };
|