@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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
//#region src/prosemirror/positionSweep.ts
|
|
2
|
+
/** Positions kept per chunk before it splits; small enough to splice cheaply. */
|
|
3
|
+
const CHUNK_SIZE = 128;
|
|
4
|
+
const cursorBefore = (left, right) => left.chunk < right.chunk || left.chunk === right.chunk && left.index < right.index;
|
|
5
|
+
/** Positions sharing one `assoc`, sorted by their current value. */
|
|
6
|
+
var Lane = class {
|
|
7
|
+
chunks = [];
|
|
8
|
+
assoc;
|
|
9
|
+
constructor(assoc) {
|
|
10
|
+
this.assoc = assoc;
|
|
11
|
+
}
|
|
12
|
+
get isEmpty() {
|
|
13
|
+
return this.chunks.length === 0;
|
|
14
|
+
}
|
|
15
|
+
/** Replace an empty lane's contents with `entries`, sorted by value. */
|
|
16
|
+
load(entries) {
|
|
17
|
+
for (let start = 0; start < entries.length; start += CHUNK_SIZE) {
|
|
18
|
+
const slice = entries.slice(start, start + CHUNK_SIZE);
|
|
19
|
+
this.chunks.push({
|
|
20
|
+
shift: 0,
|
|
21
|
+
values: slice.map(([value]) => value),
|
|
22
|
+
ids: slice.map(([, id]) => id)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
insert(value, id) {
|
|
27
|
+
if (!this.chunks.at(-1)) {
|
|
28
|
+
this.chunks.push({
|
|
29
|
+
shift: 0,
|
|
30
|
+
values: [value],
|
|
31
|
+
ids: [id]
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const cursor = this.bound(value, true);
|
|
36
|
+
const chunkIndex = Math.min(cursor.chunk, this.chunks.length - 1);
|
|
37
|
+
const chunk = this.chunks[chunkIndex];
|
|
38
|
+
const index = cursor.chunk === chunkIndex ? cursor.index : chunk.values.length;
|
|
39
|
+
chunk.values.splice(index, 0, value - chunk.shift);
|
|
40
|
+
chunk.ids.splice(index, 0, id);
|
|
41
|
+
if (chunk.values.length > 2 * CHUNK_SIZE) this.chunks.splice(chunkIndex + 1, 0, {
|
|
42
|
+
shift: chunk.shift,
|
|
43
|
+
values: chunk.values.splice(CHUNK_SIZE),
|
|
44
|
+
ids: chunk.ids.splice(CHUNK_SIZE)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The first entry whose value is at least `value` (`strict`: greater than
|
|
49
|
+
* it), or the end of the lane.
|
|
50
|
+
*/
|
|
51
|
+
bound(value, strict) {
|
|
52
|
+
const passes = (candidate) => strict ? candidate > value : candidate >= value;
|
|
53
|
+
let low = 0;
|
|
54
|
+
let high = this.chunks.length;
|
|
55
|
+
while (low < high) {
|
|
56
|
+
const middle = low + high >>> 1;
|
|
57
|
+
const chunk = this.chunks[middle];
|
|
58
|
+
if (passes(chunk.values.at(-1) + chunk.shift)) high = middle;
|
|
59
|
+
else low = middle + 1;
|
|
60
|
+
}
|
|
61
|
+
const chunk = this.chunks[low];
|
|
62
|
+
if (!chunk) return {
|
|
63
|
+
chunk: this.chunks.length,
|
|
64
|
+
index: 0
|
|
65
|
+
};
|
|
66
|
+
let first = 0;
|
|
67
|
+
let last = chunk.values.length;
|
|
68
|
+
while (first < last) {
|
|
69
|
+
const middle = first + last >>> 1;
|
|
70
|
+
if (passes(chunk.values[middle] + chunk.shift)) last = middle;
|
|
71
|
+
else first = middle + 1;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
chunk: low,
|
|
75
|
+
index: first
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Visit every entry from `start` up to, not including, `end`. */
|
|
79
|
+
forEachBetween(start, end, visit) {
|
|
80
|
+
for (let chunkIndex = start.chunk; chunkIndex <= end.chunk; chunkIndex++) {
|
|
81
|
+
const chunk = this.chunks[chunkIndex];
|
|
82
|
+
if (!chunk) return;
|
|
83
|
+
const first = chunkIndex === start.chunk ? start.index : 0;
|
|
84
|
+
const last = chunkIndex === end.chunk ? end.index : chunk.values.length;
|
|
85
|
+
for (let index = first; index < last; index++) visit(chunk, index);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Add `delta` to every entry from `start` to the end of the lane. */
|
|
89
|
+
shiftFrom(start, end, delta) {
|
|
90
|
+
if (delta === 0) return;
|
|
91
|
+
const stop = end ?? {
|
|
92
|
+
chunk: this.chunks.length,
|
|
93
|
+
index: 0
|
|
94
|
+
};
|
|
95
|
+
for (let chunkIndex = start.chunk; chunkIndex <= stop.chunk; chunkIndex++) {
|
|
96
|
+
const chunk = this.chunks[chunkIndex];
|
|
97
|
+
if (!chunk) return;
|
|
98
|
+
const first = chunkIndex === start.chunk ? start.index : 0;
|
|
99
|
+
const last = chunkIndex === stop.chunk ? stop.index : chunk.values.length;
|
|
100
|
+
if (first === 0 && last === chunk.values.length) {
|
|
101
|
+
chunk.shift += delta;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
for (let index = first; index < last; index++) chunk.values[index] += delta;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
apply(map, deletedAcross) {
|
|
108
|
+
if (this.chunks.length === 0) return;
|
|
109
|
+
const ranges = [];
|
|
110
|
+
let previousEnd = {
|
|
111
|
+
chunk: 0,
|
|
112
|
+
index: 0
|
|
113
|
+
};
|
|
114
|
+
map.forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
115
|
+
const lower = this.bound(oldStart, false);
|
|
116
|
+
const start = cursorBefore(lower, previousEnd) ? previousEnd : lower;
|
|
117
|
+
const end = this.bound(oldEnd, true);
|
|
118
|
+
ranges.push({
|
|
119
|
+
start,
|
|
120
|
+
end,
|
|
121
|
+
delta: newEnd - newStart - (oldEnd - oldStart)
|
|
122
|
+
});
|
|
123
|
+
previousEnd = end;
|
|
124
|
+
});
|
|
125
|
+
let cursor = {
|
|
126
|
+
chunk: 0,
|
|
127
|
+
index: 0
|
|
128
|
+
};
|
|
129
|
+
let delta = 0;
|
|
130
|
+
for (const range of ranges) {
|
|
131
|
+
this.shiftFrom(cursor, range.start, delta);
|
|
132
|
+
this.forEachBetween(range.start, range.end, (chunk, index) => {
|
|
133
|
+
const result = map.mapResult(chunk.values[index] + chunk.shift, this.assoc);
|
|
134
|
+
chunk.values[index] = result.pos - chunk.shift;
|
|
135
|
+
if (result.deletedAcross) deletedAcross[chunk.ids[index]] = true;
|
|
136
|
+
});
|
|
137
|
+
delta += range.delta;
|
|
138
|
+
cursor = range.end;
|
|
139
|
+
}
|
|
140
|
+
this.shiftFrom(cursor, null, delta);
|
|
141
|
+
}
|
|
142
|
+
collect(positions) {
|
|
143
|
+
for (const chunk of this.chunks) for (let index = 0; index < chunk.values.length; index++) positions[chunk.ids[index]] = chunk.values[index] + chunk.shift;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const hasMirrors = (mapping) => {
|
|
147
|
+
for (let index = mapping.from; index < mapping.to; index++) if (mapping.getMirror(index) !== void 0) return true;
|
|
148
|
+
return false;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* The per-step walk, kept for mappings that carry mirror pairs (collaborative
|
|
152
|
+
* rebases): a mirrored map recovers a deleted position from its twin, which
|
|
153
|
+
* only a walk through every map can see.
|
|
154
|
+
*/
|
|
155
|
+
const mapPerStep = (mappings, queries) => queries.map(({ pos, assoc, from }) => {
|
|
156
|
+
let mapped = pos;
|
|
157
|
+
let deletedAcross = false;
|
|
158
|
+
let offset = 0;
|
|
159
|
+
for (const mapping of mappings) {
|
|
160
|
+
const length = mapping.to - mapping.from;
|
|
161
|
+
if (from < offset + length) {
|
|
162
|
+
const result = mapping.slice(mapping.from + Math.max(0, from - offset), mapping.to).mapResult(mapped, assoc);
|
|
163
|
+
mapped = result.pos;
|
|
164
|
+
deletedAcross ||= result.deletedAcross;
|
|
165
|
+
}
|
|
166
|
+
offset += length;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
pos: mapped,
|
|
170
|
+
deletedAcross
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
/**
|
|
174
|
+
* Map every query through `mappings` (one per transaction, in order), each
|
|
175
|
+
* entering at its own step. O((positions + steps) x log positions) plus the
|
|
176
|
+
* positions a step's changed ranges actually cover, rather than
|
|
177
|
+
* O(positions x steps).
|
|
178
|
+
*/
|
|
179
|
+
const sweepPositions = (mappings, queries) => {
|
|
180
|
+
if (queries.length === 0) return [];
|
|
181
|
+
if (mappings.some(hasMirrors)) return mapPerStep(mappings, queries);
|
|
182
|
+
const maps = mappings.flatMap((mapping) => mapping.maps.slice(mapping.from, mapping.to));
|
|
183
|
+
const order = queries.map((query, id) => ({
|
|
184
|
+
id,
|
|
185
|
+
from: Math.min(Math.max(query.from, 0), maps.length)
|
|
186
|
+
})).sort((left, right) => left.from - right.from || left.id - right.id);
|
|
187
|
+
const backward = new Lane(-1);
|
|
188
|
+
const forward = new Lane(1);
|
|
189
|
+
const deletedAcross = queries.map(() => false);
|
|
190
|
+
let next = 0;
|
|
191
|
+
const enter = (step) => {
|
|
192
|
+
const entering = /* @__PURE__ */ new Map([[backward, []], [forward, []]]);
|
|
193
|
+
for (; next < order.length && order[next].from === step; next++) {
|
|
194
|
+
const { id } = order[next];
|
|
195
|
+
const query = queries[id];
|
|
196
|
+
entering.get(query.assoc < 0 ? backward : forward).push([query.pos, id]);
|
|
197
|
+
}
|
|
198
|
+
for (const [lane, entries] of entering) {
|
|
199
|
+
if (lane.isEmpty) {
|
|
200
|
+
lane.load(entries.sort((left, right) => left[0] - right[0]));
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
for (const [value, id] of entries) lane.insert(value, id);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
for (let step = 0; step < maps.length; step++) {
|
|
207
|
+
if (next < order.length && order[next].from === step) enter(step);
|
|
208
|
+
const map = maps[step];
|
|
209
|
+
backward.apply(map, deletedAcross);
|
|
210
|
+
forward.apply(map, deletedAcross);
|
|
211
|
+
}
|
|
212
|
+
if (next < order.length) enter(maps.length);
|
|
213
|
+
const positions = queries.map(({ pos }) => pos);
|
|
214
|
+
backward.collect(positions);
|
|
215
|
+
forward.collect(positions);
|
|
216
|
+
return positions.map((pos, id) => ({
|
|
217
|
+
pos,
|
|
218
|
+
deletedAcross: deletedAcross[id] ?? false
|
|
219
|
+
}));
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
222
|
+
export { sweepPositions };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunStyleResolver } from "./runStyleFormatting.js";
|
|
2
|
-
import { Transaction } from "prosemirror-state";
|
|
3
2
|
import { Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/rebaseParagraphRunFormatting.d.ts
|
|
5
5
|
type RebaseParagraphRunFormattingOptions = {
|
|
6
6
|
nextAttrs: Record<string, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParagraphRunStyleContext, RunStyleResolver } from "./runStyleFormatting.js";
|
|
2
|
-
import { Transaction } from "prosemirror-state";
|
|
3
2
|
import { Mark, Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
4
|
//#region src/prosemirror/rejoinRunCarriers.d.ts
|
|
5
5
|
type ContinuedRunMarksOptions = {
|
|
6
6
|
left: Node;
|
|
@@ -48,6 +48,38 @@ type AnnotatedReplacement = {
|
|
|
48
48
|
};
|
|
49
49
|
/** `marks` with the carried marks added, each type's exclusions respected. */
|
|
50
50
|
declare const addCarriedMarks: (marks: readonly Mark[], carried: readonly Mark[]) => readonly Mark[];
|
|
51
|
+
/**
|
|
52
|
+
* The mark sets of a run of text a TRACKED edit inserts at `at` (one set per
|
|
53
|
+
* piece, in order), with the comments that keep every comment one stretch.
|
|
54
|
+
*
|
|
55
|
+
* A tracked replacement keeps the replaced text (as a deletion), and that text
|
|
56
|
+
* keeps its comments, so a comment carried or inherited onto the insertion
|
|
57
|
+
* only CONTINUES its range: it stays when, through the run, it reaches the
|
|
58
|
+
* content directly before or after `at`, and goes otherwise. Between two
|
|
59
|
+
* pieces that have a comment (the neighbours included), every piece takes
|
|
60
|
+
* it, or the run would split it in two.
|
|
61
|
+
*/
|
|
62
|
+
declare const commentsForTrackedInsertion: (doc: Node, at: number, pieces: readonly (readonly Mark[])[]) => (readonly Mark[])[];
|
|
63
|
+
/**
|
|
64
|
+
* Where, within the text a tracked replacement removes (`from` to `to`), each
|
|
65
|
+
* piece of its new text goes, one position per piece and never decreasing.
|
|
66
|
+
*
|
|
67
|
+
* The redline reads the removed text first and the new text after it, so by
|
|
68
|
+
* default every piece goes at `to`. A piece given a comment goes where that
|
|
69
|
+
* comment's stretch of removed text ends instead, next to it; the pieces
|
|
70
|
+
* before it that have no comment go where that stretch begins, and the ones
|
|
71
|
+
* after it follow it. So each comment stays one stretch, holding the removed
|
|
72
|
+
* text it held and exactly the new text given it.
|
|
73
|
+
*/
|
|
74
|
+
declare const placeTrackedInsertion: (doc: Node, from: number, to: number, pieces: readonly (readonly Mark[])[]) => number[];
|
|
75
|
+
/**
|
|
76
|
+
* The comments content inserted at the block boundary `at` must carry: those
|
|
77
|
+
* covering the content on both sides of it. A comment range is two points in
|
|
78
|
+
* document order, so what lands between them is covered whether the range
|
|
79
|
+
* crosses paragraphs, empty paragraphs or a table edge, and the saved package
|
|
80
|
+
* reopens exactly so. A merge's separator lands on such a boundary too.
|
|
81
|
+
*/
|
|
82
|
+
declare const commentsAcrossBlockBoundary: (doc: Node, at: number) => Mark[];
|
|
51
83
|
/** `content` with the surveyed marks on it and the surveyed anchors around it. */
|
|
52
84
|
declare const annotatedReplacement: ({ annotations: { carried, leading, trailing }, content }: AnnotatedReplacementOptions) => AnnotatedReplacement;
|
|
53
85
|
/**
|
|
@@ -56,4 +88,4 @@ declare const annotatedReplacement: ({ annotations: { carried, leading, trailing
|
|
|
56
88
|
*/
|
|
57
89
|
declare const inheritedReplacementMarks: (doc: Node, from: number, to: number) => readonly Mark[];
|
|
58
90
|
//#endregion
|
|
59
|
-
export { NON_INCLUSIVE_MARK_DISPOSITION, ReplacedAnnotations, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
|
|
91
|
+
export { NON_INCLUSIVE_MARK_DISPOSITION, ReplacedAnnotations, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, placeTrackedInsertion, surveyReplacedAnnotations };
|
|
@@ -4,6 +4,7 @@ import { MOVE_RANGE_BOUNDARY_NODE_NAME } from "./extensions/nodes/MoveRangeBound
|
|
|
4
4
|
import { RANGE_ANCHOR_NODE_NAME } from "./extensions/nodes/RangeAnchorExtension.js";
|
|
5
5
|
import { TEXT_BOX_ANCHOR_NODE_NAME } from "./extensions/nodes/TextBoxAnchorExtension.js";
|
|
6
6
|
import { readMoveRangeBoundaryAttrs } from "./moveRangeBoundaryAttrs.js";
|
|
7
|
+
import { isZeroWidthAnchor } from "./zeroWidthAnchors.js";
|
|
7
8
|
import { Fragment, Mark } from "prosemirror-model";
|
|
8
9
|
//#region src/prosemirror/replacedAnnotations.ts
|
|
9
10
|
/**
|
|
@@ -152,6 +153,174 @@ const addCarriedMarks = (marks, carried) => {
|
|
|
152
153
|
for (const mark of carried) next = mark.addToSet(next);
|
|
153
154
|
return next;
|
|
154
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* Invariant: a comment mark covers ONE contiguous stretch of a paragraph. A
|
|
158
|
+
* save writes one range start and one range end per comment, so a comment on
|
|
159
|
+
* two stretches reopens covering the text between them as well.
|
|
160
|
+
*
|
|
161
|
+
* Text an edit inserts is where that breaks: it lands next to the text of a
|
|
162
|
+
* comment, or inside it. These pick the comments inserted text takes so that
|
|
163
|
+
* every comment stays one stretch.
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* The first (`1`) or last (`-1`) inline content inside `node` that is not a
|
|
167
|
+
* zero-width anchor, descending through every container.
|
|
168
|
+
*/
|
|
169
|
+
const innermostEdge = (node, direction) => {
|
|
170
|
+
if (node.isInline) return isZeroWidthAnchor(node) ? null : node;
|
|
171
|
+
for (let index = direction === 1 ? 0 : node.childCount - 1; index >= 0 && index < node.childCount; index += direction) {
|
|
172
|
+
const found = innermostEdge(node.child(index), direction);
|
|
173
|
+
if (found) return found;
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* The inline content nearest the block boundary `at` on one side, in document
|
|
179
|
+
* order: past empty paragraphs, and into and out of tables, the way a saved
|
|
180
|
+
* range's two points read it.
|
|
181
|
+
*/
|
|
182
|
+
const contentBesideBoundary = (doc, at, direction) => {
|
|
183
|
+
const $at = doc.resolve(at);
|
|
184
|
+
for (let depth = $at.depth; depth >= 0; depth--) {
|
|
185
|
+
const parent = $at.node(depth);
|
|
186
|
+
const index = $at.index(depth);
|
|
187
|
+
let child = index + direction;
|
|
188
|
+
if (depth === $at.depth) child = direction === 1 ? index : index - 1;
|
|
189
|
+
for (; child >= 0 && child < parent.childCount; child += direction) {
|
|
190
|
+
const found = innermostEdge(parent.child(child), direction);
|
|
191
|
+
if (found) return found;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* The content either side of `at` in its paragraph, past zero-width anchors
|
|
198
|
+
* (a comment's own reference sits between its text and what follows).
|
|
199
|
+
*/
|
|
200
|
+
const neighboursAt = (doc, at) => {
|
|
201
|
+
const $at = doc.resolve(at);
|
|
202
|
+
const parent = $at.parent;
|
|
203
|
+
const neighbour = (direction) => {
|
|
204
|
+
const adjacent = direction === -1 ? $at.nodeBefore : $at.nodeAfter;
|
|
205
|
+
if (!adjacent || !isZeroWidthAnchor(adjacent)) return adjacent;
|
|
206
|
+
for (let index = direction === -1 ? $at.index() - 2 : $at.index() + 1; index >= 0 && index < parent.childCount; index += direction) {
|
|
207
|
+
const child = parent.child(index);
|
|
208
|
+
if (!isZeroWidthAnchor(child)) return child;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
before: neighbour(-1),
|
|
214
|
+
after: neighbour(1)
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
/** The comments on both `before` and `after`: text between them must carry them. */
|
|
218
|
+
const commentsAround = (before, after) => before && after ? before.marks.filter((mark) => mark.type.name === "comment" && mark.isInSet(after.marks)) : [];
|
|
219
|
+
/**
|
|
220
|
+
* The mark sets of a run of text a TRACKED edit inserts at `at` (one set per
|
|
221
|
+
* piece, in order), with the comments that keep every comment one stretch.
|
|
222
|
+
*
|
|
223
|
+
* A tracked replacement keeps the replaced text (as a deletion), and that text
|
|
224
|
+
* keeps its comments, so a comment carried or inherited onto the insertion
|
|
225
|
+
* only CONTINUES its range: it stays when, through the run, it reaches the
|
|
226
|
+
* content directly before or after `at`, and goes otherwise. Between two
|
|
227
|
+
* pieces that have a comment (the neighbours included), every piece takes
|
|
228
|
+
* it, or the run would split it in two.
|
|
229
|
+
*/
|
|
230
|
+
const commentsForTrackedInsertion = (doc, at, pieces) => {
|
|
231
|
+
const { before, after } = neighboursAt(doc, at);
|
|
232
|
+
const sets = [
|
|
233
|
+
before?.marks ?? [],
|
|
234
|
+
...pieces,
|
|
235
|
+
after?.marks ?? []
|
|
236
|
+
];
|
|
237
|
+
const comments = [];
|
|
238
|
+
for (const set of sets) for (const mark of set) if (mark.type.name === "comment" && !mark.isInSet(comments)) comments.push(mark);
|
|
239
|
+
const result = pieces.map((set) => set.filter((mark) => mark.type.name !== "comment"));
|
|
240
|
+
for (const comment of comments) {
|
|
241
|
+
const covered = sets.flatMap((set, index) => comment.isInSet(set) ? [index] : []);
|
|
242
|
+
const first = covered[0];
|
|
243
|
+
const last = covered.at(-1);
|
|
244
|
+
if (first !== 0 && last !== sets.length - 1) continue;
|
|
245
|
+
for (let index = Math.max(first, 1); index <= Math.min(last, pieces.length); index++) result[index - 1] = comment.addToSet([...result[index - 1]]);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Where, within the text a tracked replacement removes (`from` to `to`), each
|
|
251
|
+
* piece of its new text goes, one position per piece and never decreasing.
|
|
252
|
+
*
|
|
253
|
+
* The redline reads the removed text first and the new text after it, so by
|
|
254
|
+
* default every piece goes at `to`. A piece given a comment goes where that
|
|
255
|
+
* comment's stretch of removed text ends instead, next to it; the pieces
|
|
256
|
+
* before it that have no comment go where that stretch begins, and the ones
|
|
257
|
+
* after it follow it. So each comment stays one stretch, holding the removed
|
|
258
|
+
* text it held and exactly the new text given it.
|
|
259
|
+
*/
|
|
260
|
+
const placeTrackedInsertion = (doc, from, to, pieces) => {
|
|
261
|
+
const stretches = /* @__PURE__ */ new Map();
|
|
262
|
+
doc.nodesBetween(from, to, (node, position) => {
|
|
263
|
+
if (!node.isText) return true;
|
|
264
|
+
for (const mark of node.marks) {
|
|
265
|
+
if (mark.type.name !== "comment") continue;
|
|
266
|
+
const known = [...stretches.keys()].find((other) => other.eq(mark)) ?? mark;
|
|
267
|
+
const start = Math.max(position, from);
|
|
268
|
+
const end = Math.min(position + node.nodeSize, to);
|
|
269
|
+
const stretch = stretches.get(known);
|
|
270
|
+
stretches.set(known, stretch ? {
|
|
271
|
+
start: stretch.start,
|
|
272
|
+
end
|
|
273
|
+
} : {
|
|
274
|
+
start,
|
|
275
|
+
end
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
});
|
|
280
|
+
const stretchOf = (set) => {
|
|
281
|
+
const own = [...stretches].filter(([mark]) => mark.isInSet(set));
|
|
282
|
+
if (own.length === 0) return;
|
|
283
|
+
const start = Math.min(...own.map(([, stretch]) => stretch.start));
|
|
284
|
+
const ascending = (left, right) => left - right;
|
|
285
|
+
const candidates = [...own.map(([, stretch]) => stretch.end).toSorted(ascending), ...own.map(([, stretch]) => stretch.start).toSorted(ascending)];
|
|
286
|
+
for (const position of candidates) {
|
|
287
|
+
const { before, after } = neighboursAt(doc, position);
|
|
288
|
+
if (own.every(([mark]) => Boolean(before && mark.isInSet(before.marks)) || Boolean(after && mark.isInSet(after.marks)))) return {
|
|
289
|
+
start,
|
|
290
|
+
end: position
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
start,
|
|
295
|
+
end: Math.min(...own.map(([, stretch]) => stretch.end))
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
const anchored = pieces.map(stretchOf);
|
|
299
|
+
const positions = [];
|
|
300
|
+
let previous = from;
|
|
301
|
+
for (const [index, stretch] of anchored.entries()) {
|
|
302
|
+
let position;
|
|
303
|
+
if (stretch) position = stretch.end;
|
|
304
|
+
else {
|
|
305
|
+
const next = anchored.slice(index + 1).find((candidate) => candidate !== void 0);
|
|
306
|
+
const placedBefore = anchored.slice(0, index).some((candidate) => candidate !== void 0);
|
|
307
|
+
position = next && !placedBefore ? next.start : to;
|
|
308
|
+
if (placedBefore && next) position = previous;
|
|
309
|
+
}
|
|
310
|
+
position = Math.max(position, previous);
|
|
311
|
+
positions.push(position);
|
|
312
|
+
previous = position;
|
|
313
|
+
}
|
|
314
|
+
return positions;
|
|
315
|
+
};
|
|
316
|
+
/**
|
|
317
|
+
* The comments content inserted at the block boundary `at` must carry: those
|
|
318
|
+
* covering the content on both sides of it. A comment range is two points in
|
|
319
|
+
* document order, so what lands between them is covered whether the range
|
|
320
|
+
* crosses paragraphs, empty paragraphs or a table edge, and the saved package
|
|
321
|
+
* reopens exactly so. A merge's separator lands on such a boundary too.
|
|
322
|
+
*/
|
|
323
|
+
const commentsAcrossBlockBoundary = (doc, at) => commentsAround(contentBesideBoundary(doc, at, -1), contentBesideBoundary(doc, at, 1));
|
|
155
324
|
const withCarriedMarks = (node, carried) => node.mark(addCarriedMarks(node.marks, carried));
|
|
156
325
|
/** `content` with the surveyed marks on it and the surveyed anchors around it. */
|
|
157
326
|
const annotatedReplacement = ({ annotations: { carried, leading, trailing }, content }) => {
|
|
@@ -180,4 +349,4 @@ const inheritedReplacementMarks = (doc, from, to) => {
|
|
|
180
349
|
return (to === from ? $from.marks() : $from.marksAcross(doc.resolve(to))) ?? Mark.none;
|
|
181
350
|
};
|
|
182
351
|
//#endregion
|
|
183
|
-
export { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, surveyReplacedAnnotations };
|
|
352
|
+
export { NON_INCLUSIVE_MARK_DISPOSITION, addCarriedMarks, annotatedReplacement, commentsAcrossBlockBoundary, commentsForTrackedInsertion, hasReplacedAnnotations, inheritedReplacementMarks, nonInclusiveMarkNames, placeTrackedInsertion, surveyReplacedAnnotations };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction } from "prosemirror-state";
|
|
2
1
|
import { Mark, Node } from "prosemirror-model";
|
|
2
|
+
import { Transaction } from "prosemirror-state";
|
|
3
3
|
//#region src/prosemirror/runFormattingInlineCarriers.d.ts
|
|
4
4
|
type RunFormattingInlineAtomDisposition = "break-run" | "field-run" | "not-a-run" | "page-break-carrier" | "preserved-xml-run" | "structured-field" | "symbol-run" | "tab-run" | "text-run";
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CharacterSpacingAttrs, CharacterStyleAttrs, CommentAttrs, EmphasisMarkAttrs, FontFamilyAttrs, FontSizeAttrs, FootnoteRefAttrs, HighlightAttrs, HyperlinkAttrs, InlineWrapperAttrs, InlineWrapperKind, InlineWrapperLayer, LanguageAttrs, RunFormattingOverrideAttrs, RunIdentityMarkAttrs, RunPropertyChangeMarkAttrs, RunShadingAttrs, StrikeAttrs, TextColorAttrs, TextEffectAttrs, TrackedChangeMarkAttrs, TrackedRevisionAncestor, UnderlineAttrs } from "./marks.js";
|
|
2
|
-
import { BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
2
|
+
import { BlockCustomXmlAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PageBreakRunAttrs, ParagraphAttrs, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SymbolAttrs, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAttrs } from "./nodes.js";
|
|
3
3
|
import { ExtensionManager } from "../extensions/ExtensionManager.js";
|
|
4
4
|
//#region src/prosemirror/schema/index.d.ts
|
|
5
5
|
declare const singletonManager: ExtensionManager;
|
|
@@ -11,4 +11,4 @@ type DocxSchema = typeof schema;
|
|
|
11
11
|
type DocxNode = ReturnType<typeof schema.node>;
|
|
12
12
|
type DocxMark = ReturnType<typeof schema.mark>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type InlineWrapperAttrs, type InlineWrapperKind, type InlineWrapperLayer, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type PreservedBlockAttrs, type PreservedXmlAttrs, type PreservedXmlLevel, type RunFormattingOverrideAttrs, type RunIdentityMarkAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type TrackedRevisionAncestor, type UnderlineAttrs, schema, singletonManager };
|
|
14
|
+
export { type BlockCustomXmlAttrs, type BlockSdtAttrs, type BookmarkBoundaryAttrs, type CharacterSpacingAttrs, type CharacterStyleAttrs, type CommentAttrs, DocxMark, DocxNode, DocxSchema, type EmphasisMarkAttrs, type FieldAttrs, type FontFamilyAttrs, type FontSizeAttrs, type FootnoteRefAttrs, type HardBreakAttrs, type HighlightAttrs, type HyperlinkAttrs, type ImageAttrs, type ImagePositionAttrs, type InlineWrapperAttrs, type InlineWrapperKind, type InlineWrapperLayer, type LanguageAttrs, type MathAttrs, type PageBreakRunAttrs, type ParagraphAttrs, type ParagraphPropertyChangeAttrs, type PreservedBlockAttrs, type PreservedXmlAttrs, type PreservedXmlLevel, type RunFormattingOverrideAttrs, type RunIdentityMarkAttrs, type RunPropertyChangeMarkAttrs, type RunShadingAttrs, type SdtAttrs, type ShapeAttrs, type StrikeAttrs, type SymbolAttrs, type TabAttrs, type TableAttrs, type TableCellAttrs, type TableRowAttrs, type TextBoxAttrs, type TextColorAttrs, type TextEffectAttrs, type TrackedChangeMarkAttrs, type TrackedRevisionAncestor, type UnderlineAttrs, schema, singletonManager };
|
|
@@ -56,6 +56,8 @@ type PreservedXmlAttrs = {
|
|
|
56
56
|
type PreservedBlockAttrs = {
|
|
57
57
|
/** Replayable markup, as `captureVerbatimXml` wrote it. */
|
|
58
58
|
xml: string;
|
|
59
|
+
/** Plain text safely extracted from a related w:altChunk part, when available. */
|
|
60
|
+
readerText?: string;
|
|
59
61
|
};
|
|
60
62
|
type BookmarkBoundaryAttrs = {
|
|
61
63
|
type: "start";
|
|
@@ -118,6 +120,13 @@ type ParagraphAttrs = {
|
|
|
118
120
|
* `paragraphNumberingAttr`, so a model value cannot land here unconverted.
|
|
119
121
|
*/
|
|
120
122
|
numPr?: ParagraphNumberingAttr;
|
|
123
|
+
/** Clipboard-only hint, replaced with a numbered paragraph before insertion. */
|
|
124
|
+
_pastedHtmlList?: {
|
|
125
|
+
group: number;
|
|
126
|
+
level: number;
|
|
127
|
+
kind: "bullet" | "numbered";
|
|
128
|
+
start?: number;
|
|
129
|
+
};
|
|
121
130
|
/**
|
|
122
131
|
* The style-sourced numPr value when `numPr` came from the paragraph
|
|
123
132
|
* style rather than direct formatting. While `numPr` still equals this,
|
|
@@ -526,7 +535,7 @@ type ImageAttrs = {
|
|
|
526
535
|
/**
|
|
527
536
|
* Field node attributes
|
|
528
537
|
*/
|
|
529
|
-
type
|
|
538
|
+
type CommonFieldAttrs = {
|
|
530
539
|
/** Field type: PAGE, NUMPAGES, DATE, MERGEFIELD, etc. */
|
|
531
540
|
fieldType: document_d_exports.FieldType;
|
|
532
541
|
/** Full field instruction (e.g. "PAGE \\* MERGEFORMAT") */
|
|
@@ -535,20 +544,30 @@ type FieldAttrs = {
|
|
|
535
544
|
displayText: string;
|
|
536
545
|
/** Imported cache that proved numbered REF resolution for this field. */
|
|
537
546
|
_numberedRefBaseline?: string;
|
|
538
|
-
/** Whether the field came from w:fldSimple or a complex fldChar range */
|
|
539
|
-
fieldKind: "simple" | "complex";
|
|
540
547
|
/** Field is locked */
|
|
541
548
|
fldLock?: boolean;
|
|
542
549
|
/** Field is dirty and should be recalculated by the host application */
|
|
543
550
|
dirty?: boolean;
|
|
544
|
-
/**
|
|
545
|
-
|
|
546
|
-
* `FORMCHECKBOX` with no cached result run), not authored content. A save
|
|
547
|
-
* omits it from the field's result so an unedited field keeps its
|
|
548
|
-
* original, resultless bytes. See `ComplexField.fieldResultIsFallback`.
|
|
549
|
-
*/
|
|
550
|
-
fieldResultIsFallback?: boolean;
|
|
551
|
+
/** Authored empty result runs, which have no visible ProseMirror children. */
|
|
552
|
+
_docxEmptyResultRuns?: document_d_exports.Run[];
|
|
551
553
|
};
|
|
554
|
+
type FieldAttrs = CommonFieldAttrs & ({
|
|
555
|
+
fieldKind: "simple";
|
|
556
|
+
fieldResultIsFallback?: never;
|
|
557
|
+
formFieldDataXml?: never;
|
|
558
|
+
_docxFieldCode?: never;
|
|
559
|
+
} | {
|
|
560
|
+
fieldKind: "complex";
|
|
561
|
+
/** Synthesized display text that must not become an authored result run. */
|
|
562
|
+
fieldResultIsFallback?: boolean;
|
|
563
|
+
/** Captured `w:ffData` on a complex field's begin character. */
|
|
564
|
+
formFieldDataXml?: string;
|
|
565
|
+
/** Source code runs; valid only while the instruction still matches. */
|
|
566
|
+
_docxFieldCode?: {
|
|
567
|
+
instruction: string;
|
|
568
|
+
runs: document_d_exports.Run[];
|
|
569
|
+
};
|
|
570
|
+
});
|
|
552
571
|
/**
|
|
553
572
|
* Math equation node attributes
|
|
554
573
|
*/
|
|
@@ -649,6 +668,12 @@ type BlockSdtAttrs = {
|
|
|
649
668
|
/** Verbatim XML for sdt siblings after sdtContent (range markers). */
|
|
650
669
|
rawSdtChildrenAfterContent?: string;
|
|
651
670
|
};
|
|
671
|
+
/** Verbatim shell retained around editable block custom XML content. */
|
|
672
|
+
type BlockCustomXmlAttrs = {
|
|
673
|
+
openingXml: string;
|
|
674
|
+
closingXml: string;
|
|
675
|
+
_originallyEmpty: boolean;
|
|
676
|
+
};
|
|
652
677
|
/**
|
|
653
678
|
* The `mc:AlternateContent` a shape or text box was read from, with a
|
|
654
679
|
* fingerprint of the node it was attached to. `fromProseDoc` hands the element
|
|
@@ -992,6 +1017,8 @@ type TableAttrs = {
|
|
|
992
1017
|
* none and a copy does not inherit one.
|
|
993
1018
|
*/
|
|
994
1019
|
_preserved?: document_d_exports.TablePreservedMarkup;
|
|
1020
|
+
/** Transparent table-level custom-XML wrappers, outermost first. */
|
|
1021
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
995
1022
|
/**
|
|
996
1023
|
* Marks this whole table as a *suggested* insertion (AI proposal). The table
|
|
997
1024
|
* is dropped from serialized DOCX until accepted; because OOXML has no tracked
|
|
@@ -1054,6 +1081,8 @@ type TableRowAttrs = {
|
|
|
1054
1081
|
* name the same control. See `TableRow.contentControls`.
|
|
1055
1082
|
*/
|
|
1056
1083
|
contentControls?: document_d_exports.SdtProperties[];
|
|
1084
|
+
/** Transparent row-level custom-XML wrappers, outermost first. */
|
|
1085
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
1057
1086
|
/**
|
|
1058
1087
|
* Markup the authored `w:tr` carried beside its cells, with the cell count
|
|
1059
1088
|
* that places it back between the same two cells. Follows the record the
|
|
@@ -1219,10 +1248,12 @@ type TableCellAttrs = {
|
|
|
1219
1248
|
* outermost first. The row's twin, one level down.
|
|
1220
1249
|
*/
|
|
1221
1250
|
contentControls?: document_d_exports.SdtProperties[];
|
|
1251
|
+
/** Transparent row-level custom-XML wrappers, outermost first. */
|
|
1252
|
+
carrierStack?: document_d_exports.TableContentCarrier[];
|
|
1222
1253
|
/** Preserve a DOCX vMerge restart even when PM cannot model it as a rowspan. */
|
|
1223
1254
|
_preserveVMergeRestart?: boolean;
|
|
1224
1255
|
/** Original DOCX vMerge continuation cells skipped into this PM rowspan. */
|
|
1225
1256
|
_docxVMergeContinuationCells?: unknown;
|
|
1226
1257
|
};
|
|
1227
1258
|
//#endregion
|
|
1228
|
-
export { AlternateContentAttrs, AuthoredEmuAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, CommentReferenceAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PRESERVED_XML_LEVELS, PageBreakRunAttrs, ParagraphAttrs, ParagraphAttrsPatch, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
1259
|
+
export { AlternateContentAttrs, AuthoredEmuAttrs, BlockCustomXmlAttrs, BlockSdtAttrs, BookmarkBoundaryAttrs, CommentReferenceAttrs, FieldAttrs, HardBreakAttrs, ImageAttrs, ImagePositionAttrs, MathAttrs, PRESERVED_XML_LEVELS, PageBreakRunAttrs, ParagraphAttrs, ParagraphAttrsPatch, ParagraphPropertyChangeAttrs, PreservedBlockAttrs, PreservedXmlAttrs, PreservedXmlLevel, SdtAttrs, ShapeAttrs, SuggestedStructuralMarker, SymbolAttrs, TEXT_BOX_TEXT_BODY_CONTENT_STATE_TYPES, TabAttrs, TableAttrs, TableCellAttrs, TableRowAttrs, TextBoxAnchorAttrs, TextBoxAttrs, TextBoxTextBodyContentState };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/sectionMarkEdits.d.ts
|
|
5
|
+
type SectionMarkEdits = {
|
|
6
|
+
/** Section records whose paragraph mark a replacement deleted. */
|
|
7
|
+
deletedMarks: ReadonlySet<document_d_exports.SectionProperties>;
|
|
8
|
+
/**
|
|
9
|
+
* Paragraphs of the final document, by position, and the section record
|
|
10
|
+
* each must hold because of the mark it now ends with.
|
|
11
|
+
*/
|
|
12
|
+
carriers: readonly {
|
|
13
|
+
position: number;
|
|
14
|
+
record: document_d_exports.SectionProperties | null;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
/** Read `transactions`, applied in order and ending at `finalDoc`. */
|
|
18
|
+
declare const sectionMarkEditsOf: (transactions: readonly Transaction[], finalDoc: Node) => SectionMarkEdits;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SectionMarkEdits, sectionMarkEditsOf };
|