@stll/folio-core 0.52.0 → 0.53.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 +1519 -105
- package/dist/ai-edits/batch-claims.d.ts +130 -0
- package/dist/ai-edits/batch-claims.js +244 -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 +71 -7
- package/dist/ai-edits/headless.js +381 -41
- 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 +1 -1
- package/dist/ai-edits/read.js +56 -43
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +177 -23
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +4 -1
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +38 -16
- package/dist/ai-edits/table-row-column-mutations.js +61 -26
- 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.js +13 -2
- 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/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 +62 -9
- 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/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/normalizeBaseDirection.js +2 -1
- 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 +91 -24
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +173 -20
- package/dist/docx/rezip.js +27 -5
- 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.js +106 -37
- 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/createBilingualDocument.js +3 -3
- 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 +2 -1
- package/dist/docx/unzip.js +1 -1
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +136 -0
- package/dist/i18n/messages/catalogs.gen.js +153 -17
- package/dist/i18n/messages/messages.gen.d.ts +8 -0
- 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 +530 -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/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/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/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +39 -9
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.js +3 -10
- 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/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +241 -207
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -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/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +615 -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 +59 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +181 -31
- package/dist/prosemirror/conversion/toProseDoc.js +39 -4
- 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 +3 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +161 -123
- 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/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +126 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +21 -5
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +7 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +8 -2
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +35 -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/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- 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 +19 -18
- package/dist/prosemirror/extensions/types.d.ts +4 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -2
- package/dist/prosemirror/index.js +3 -2
- 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 +110 -0
- package/dist/prosemirror/listNumbering.js +345 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewProjection.d.ts +95 -0
- package/dist/prosemirror/markupViewProjection.js +83 -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 +29 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +19 -0
- package/dist/prosemirror/paragraphMarkJoin.js +24 -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/documentStyles.d.ts +10 -1
- package/dist/prosemirror/plugins/documentStyles.js +14 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +16 -2
- package/dist/prosemirror/plugins/suggestionMode.js +116 -52
- 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 +1 -1
- 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/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +42 -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/tableGridMutation.d.ts +48 -2
- package/dist/prosemirror/tableGridMutation.js +106 -1
- 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/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 +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from "../types.js";
|
|
2
|
-
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
3
2
|
import { Node } from "prosemirror-model";
|
|
3
|
+
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts
|
|
5
5
|
type ParagraphPropertySourceSeed = {
|
|
6
6
|
contract: string | null;
|
|
@@ -20,6 +20,23 @@ declare const paraIdAllocatorKey: PluginKey<ParagraphPropertySourceSeed>;
|
|
|
20
20
|
declare const deterministicParaIdSeedKey: PluginKey<string>;
|
|
21
21
|
/** Ask the allocator to mint reproducible ids for the paragraphs `tr` creates. */
|
|
22
22
|
declare const requestDeterministicParaIds: (tr: Transaction, seed: string) => Transaction;
|
|
23
|
+
type ParagraphPropertySourceKeeper = {
|
|
24
|
+
status: "ambiguous";
|
|
25
|
+
} | {
|
|
26
|
+
pos: number;
|
|
27
|
+
status: "deleted" | "mapped";
|
|
28
|
+
};
|
|
29
|
+
type MappedParagraphKeepers = {
|
|
30
|
+
paraIds: Map<string, number>;
|
|
31
|
+
sourceTokens: Map<string, ParagraphPropertySourceKeeper>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Where each id's and each seeded source token's owner went: the first
|
|
35
|
+
* occurrence that survives the batch keeps an id.
|
|
36
|
+
*
|
|
37
|
+
* @internal Exported for the per-step equivalence test.
|
|
38
|
+
*/
|
|
39
|
+
declare const mapParagraphKeepers: (oldDoc: Node, transactions: readonly Transaction[], sourceSeed: ParagraphPropertySourceSeed) => MappedParagraphKeepers;
|
|
23
40
|
/**
|
|
24
41
|
* Allocate initial paragraph IDs before constructing editor state.
|
|
25
42
|
*
|
|
@@ -31,4 +48,4 @@ declare const ensureParaIdsInDoc: (doc: Node) => Node;
|
|
|
31
48
|
declare const ensureParaIdsInState: (state: EditorState) => EditorState;
|
|
32
49
|
declare const ParaIdAllocatorExtension: (options?: Partial<{}> | undefined) => Extension;
|
|
33
50
|
//#endregion
|
|
34
|
-
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
51
|
+
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, mapParagraphKeepers, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PROSE_PARAGRAPH_SOURCE_TOKEN_ATTR, getExplicitParagraphPropertySourceTransfers, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, setProseParagraphMarkupWithPropertySource, transferProseParagraphPropertySource } from "../../../docx/paragraphPropertySource.js";
|
|
2
2
|
import { deterministicHexId, generateHexId } from "../../../utils/hexId.js";
|
|
3
|
+
import { sweepPositions } from "../../positionSweep.js";
|
|
3
4
|
import { createExtension } from "../create.js";
|
|
4
5
|
import { ignoreTrackedChanges } from "./ParagraphChangeTrackerExtension.js";
|
|
5
6
|
import { panic } from "better-result";
|
|
@@ -92,33 +93,45 @@ const collectParagraphPropertySourceSeed = (doc) => {
|
|
|
92
93
|
tokens: new Set([...counts].filter(([, count]) => count === 1).map(([token]) => token))
|
|
93
94
|
};
|
|
94
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Where each id's and each seeded source token's owner went: the first
|
|
98
|
+
* occurrence that survives the batch keeps an id.
|
|
99
|
+
*
|
|
100
|
+
* @internal Exported for the per-step equivalence test.
|
|
101
|
+
*/
|
|
95
102
|
const mapParagraphKeepers = (oldDoc, transactions, sourceSeed) => {
|
|
96
|
-
const
|
|
97
|
-
const sourceTokens = /* @__PURE__ */ new Map();
|
|
103
|
+
const paragraphs = [];
|
|
98
104
|
oldDoc.descendants((node, pos) => {
|
|
99
105
|
if (node.type.name !== "paragraph") return true;
|
|
100
106
|
const id = node.attrs["paraId"];
|
|
101
107
|
const token = getProseParagraphPropertySourceToken(node);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let mappedInterior = pos + 1;
|
|
107
|
-
let deleted = false;
|
|
108
|
-
for (const transaction of transactions) {
|
|
109
|
-
const ownerResult = transaction.mapping.mapResult(mapped);
|
|
110
|
-
const interiorResult = transaction.mapping.mapResult(mappedInterior, -1);
|
|
111
|
-
deleted ||= interiorResult.deletedAcross;
|
|
112
|
-
mapped = ownerResult.pos;
|
|
113
|
-
mappedInterior = interiorResult.pos;
|
|
114
|
-
}
|
|
115
|
-
if (mapsParaId && !deleted) paraIds.set(id, mapped);
|
|
116
|
-
if (mapsSourceToken) sourceTokens.set(token, sourceTokens.has(token) ? { status: "ambiguous" } : {
|
|
117
|
-
pos: mapped,
|
|
118
|
-
status: deleted ? "deleted" : "mapped"
|
|
108
|
+
if (isUsableParaId(id) || typeof token === "string" && sourceSeed.tokens.has(token)) paragraphs.push({
|
|
109
|
+
pos,
|
|
110
|
+
id,
|
|
111
|
+
token
|
|
119
112
|
});
|
|
120
113
|
return false;
|
|
121
114
|
});
|
|
115
|
+
const swept = sweepPositions(transactions.map((transaction) => transaction.mapping), paragraphs.flatMap(({ pos }) => [{
|
|
116
|
+
pos,
|
|
117
|
+
assoc: 1,
|
|
118
|
+
from: 0
|
|
119
|
+
}, {
|
|
120
|
+
pos: pos + 1,
|
|
121
|
+
assoc: -1,
|
|
122
|
+
from: 0
|
|
123
|
+
}]));
|
|
124
|
+
const paraIds = /* @__PURE__ */ new Map();
|
|
125
|
+
const sourceTokens = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const [index, { id, token }] of paragraphs.entries()) {
|
|
127
|
+
const mapped = swept[2 * index].pos;
|
|
128
|
+
const deleted = swept[2 * index + 1].deletedAcross;
|
|
129
|
+
if (isUsableParaId(id) && !paraIds.has(id) && !deleted) paraIds.set(id, mapped);
|
|
130
|
+
if (typeof token === "string" && sourceSeed.tokens.has(token)) sourceTokens.set(token, sourceTokens.has(token) ? { status: "ambiguous" } : {
|
|
131
|
+
pos: mapped,
|
|
132
|
+
status: deleted ? "deleted" : "mapped"
|
|
133
|
+
});
|
|
134
|
+
}
|
|
122
135
|
return {
|
|
123
136
|
paraIds,
|
|
124
137
|
sourceTokens
|
|
@@ -334,4 +347,4 @@ const ParaIdAllocatorExtension = createExtension({
|
|
|
334
347
|
}
|
|
335
348
|
});
|
|
336
349
|
//#endregion
|
|
337
|
-
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
350
|
+
export { ParaIdAllocatorExtension, deterministicParaIdSeedKey, ensureParaIdsInDoc, ensureParaIdsInState, mapParagraphKeepers, paraIdAllocatorKey, requestDeterministicParaIds };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { document_d_exports } from "../../../types/document.js";
|
|
1
2
|
import { Extension } from "../types.js";
|
|
2
3
|
import { RemovedSectionReference, TrackedSectionEndpointRemoval } from "../../../internal/sectionEndpointResolution.js";
|
|
3
|
-
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
4
4
|
import { Node } from "prosemirror-model";
|
|
5
|
+
import { EditorState, PluginKey, Transaction } from "prosemirror-state";
|
|
5
6
|
//#region src/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts
|
|
6
7
|
declare const paragraphChangeTrackerKey: PluginKey<InternalParagraphChangeTrackerState>;
|
|
7
8
|
type ParagraphChangeTrackerState = {
|
|
@@ -26,6 +27,8 @@ type InternalParagraphChangeTrackerState = ParagraphChangeTrackerState & {
|
|
|
26
27
|
/** Editing an already unidentified source paragraph cannot become selective. */
|
|
27
28
|
hasUntrackedSourceChanges: boolean;
|
|
28
29
|
blockStructureFingerprint: string;
|
|
30
|
+
/** The section records themselves, by identity. */
|
|
31
|
+
sectionRecords: ReadonlySet<document_d_exports.SectionProperties>;
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
31
34
|
* Get the change tracker state from an EditorState
|
|
@@ -45,6 +48,24 @@ declare function hasStructuralChanges(state: EditorState): boolean;
|
|
|
45
48
|
declare function hasUntrackedChanges(state: EditorState): boolean;
|
|
46
49
|
/** Exact section-count transition authorized by tracked paragraph-mark resolution. */
|
|
47
50
|
declare function getTrackedSectionEndpointRemoval(state: EditorState): TrackedSectionEndpointRemoval | null;
|
|
51
|
+
type RepackWithEditorSectionRemovalsOptions<T> = {
|
|
52
|
+
/** The editor state the document was built from. */
|
|
53
|
+
state: EditorState;
|
|
54
|
+
/** The exact document object `repack` hands to `repackDocx`. */
|
|
55
|
+
document: document_d_exports.Document;
|
|
56
|
+
repack: () => Promise<T>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Run an editor save's full repack with the section removals the editor's own
|
|
60
|
+
* edits made.
|
|
61
|
+
*
|
|
62
|
+
* A save refuses a package with fewer sections than its source unless it is
|
|
63
|
+
* told which removals were meant: deleting the paragraph that ends a section,
|
|
64
|
+
* or accepting its tracked deletion, removes that section on purpose. The
|
|
65
|
+
* tracker records exactly those removals; without them the repack throws and
|
|
66
|
+
* the edit cannot be saved.
|
|
67
|
+
*/
|
|
68
|
+
declare const repackWithEditorSectionRemovals: <T>({ state, document, repack }: RepackWithEditorSectionRemovalsOptions<T>) => Promise<T>;
|
|
48
69
|
type MarkTrackedSectionEndpointRemovalOptions = {
|
|
49
70
|
sourceDoc: Node;
|
|
50
71
|
removedEndpointCount: number;
|
|
@@ -52,6 +73,13 @@ type MarkTrackedSectionEndpointRemovalOptions = {
|
|
|
52
73
|
};
|
|
53
74
|
/** Record only a complete, internally consistent endpoint-removal transition. */
|
|
54
75
|
declare function markTrackedSectionEndpointRemoval(tr: Transaction, { sourceDoc, removedEndpointCount, removedReferences }: MarkTrackedSectionEndpointRemovalOptions): Transaction;
|
|
76
|
+
/**
|
|
77
|
+
* Record that `tr` removed section breaks on purpose: a command whose job is
|
|
78
|
+
* to remove the break (not to delete its paragraph mark, which the tracker
|
|
79
|
+
* reads for itself). Only a plain removal is recorded; a transaction that also
|
|
80
|
+
* adds or replaces a record is left as it is.
|
|
81
|
+
*/
|
|
82
|
+
declare function markSectionBreakRemoval(tr: Transaction, sourceDoc: Node): Transaction;
|
|
55
83
|
/**
|
|
56
84
|
* Create a transaction that clears the change tracker
|
|
57
85
|
*/
|
|
@@ -64,9 +92,10 @@ type MarkChangedParagraphRangesOptions = {
|
|
|
64
92
|
to: number;
|
|
65
93
|
}[];
|
|
66
94
|
mappingFrom: number;
|
|
95
|
+
replacesStepMapAt?: number;
|
|
67
96
|
};
|
|
68
97
|
/** Record mark-only paragraph changes whose replacement step has a granular map. */
|
|
69
98
|
declare function markChangedParagraphRanges(tr: Transaction, batch: MarkChangedParagraphRangesOptions): Transaction;
|
|
70
99
|
declare const ParagraphChangeTrackerExtension: (options?: Partial<{}> | undefined) => Extension;
|
|
71
100
|
//#endregion
|
|
72
|
-
export { ParagraphChangeTrackerExtension, ParagraphChangeTrackerState, clearTrackedChanges, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey };
|
|
101
|
+
export { ParagraphChangeTrackerExtension, ParagraphChangeTrackerState, clearTrackedChanges, getChangeTrackerState, getChangedParagraphIds, getTrackedSectionEndpointRemoval, hasStructuralChanges, hasUntrackedChanges, ignoreTrackedChanges, markChangedParagraphRanges, markSectionBreakRemoval, markStructuralChange, markTrackedSectionEndpointRemoval, paragraphChangeTrackerKey, repackWithEditorSectionRemovals };
|