@stll/folio-core 0.75.0 → 0.77.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/dist/ai-edits/headless.d.ts +8 -5
- package/dist/ai-edits/headless.js +49 -26
- package/dist/ai-edits/pending-suggestions.d.ts +9 -0
- package/dist/ai-edits/pending-suggestions.js +13 -3
- package/dist/ai-edits/read.js +33 -4
- package/dist/ai-edits/table-geometry.js +12 -4
- package/dist/ai-edits/types.d.ts +9 -4
- package/dist/canonical/batchCommentReferences.js +2 -1
- package/dist/canonical/canonicalBatchReview.js +5 -8
- package/dist/canonical/canonicalComments.js +8 -2
- package/dist/canonical/canonicalCompilerRefusal.d.ts +2 -4
- package/dist/canonical/canonicalCompilerRefusal.js +20 -14
- package/dist/canonical/canonicalInlineProjection.d.ts +2 -2
- package/dist/canonical/canonicalInlineProjection.js +2 -2
- package/dist/canonical/canonicalProjectionBlocks.d.ts +10 -1
- package/dist/canonical/canonicalPublicOperations.js +214 -107
- package/dist/canonical/canonicalSeedContent.d.ts +18 -3
- package/dist/canonical/canonicalSeedContent.js +28 -15
- package/dist/canonical/canonicalSession.d.ts +22 -12
- package/dist/canonical/canonicalSession.js +181 -187
- package/dist/controller/canonicalClipboard.d.ts +3 -2
- package/dist/controller/canonicalClipboard.js +377 -58
- package/dist/controller/canonicalComposition.js +67 -14
- package/dist/controller/canonicalContentControlValue.js +7 -7
- package/dist/controller/canonicalReview.d.ts +21 -0
- package/dist/controller/canonicalReview.js +44 -9
- package/dist/controller/canonicalStoryEditor.js +2 -0
- package/dist/controller/canonicalStructure.d.ts +1 -2
- package/dist/controller/canonicalStructure.js +51 -24
- package/dist/controller/fontReadiness.js +50 -23
- package/dist/controller/hiddenEditorManager.js +7 -20
- package/dist/docx/bulletMarkers.d.ts +8 -0
- package/dist/docx/bulletMarkers.js +9 -1
- package/dist/docx/canonicalSessionInput.js +25 -11
- package/dist/docx/ensureParaIds.d.ts +31 -0
- package/dist/docx/ensureParaIds.js +57 -32
- package/dist/docx/ensureUniqueControlIds.d.ts +13 -0
- package/dist/docx/ensureUniqueControlIds.js +47 -29
- package/dist/docx/ensureUniqueRevisionIds.d.ts +13 -0
- package/dist/docx/ensureUniqueRevisionIds.js +52 -29
- package/dist/docx/importedIdCollisions.js +29 -4
- package/dist/docx/server/templatePlan/apply.js +108 -9
- package/dist/docx/server/templatePlan/blocks.d.ts +77 -5
- package/dist/docx/server/templatePlan/blocks.js +281 -14
- package/dist/docx/server/templatePlan/builders.d.ts +22 -1
- package/dist/docx/server/templatePlan/builders.js +37 -3
- package/dist/docx/server/templatePlan/effects.d.ts +27 -0
- package/dist/docx/server/templatePlan/effects.js +188 -0
- package/dist/docx/server/templatePlan/emit.d.ts +4 -1
- package/dist/docx/server/templatePlan/emit.js +152 -8
- package/dist/docx/server/templatePlan/inspect.js +21 -1
- package/dist/docx/server/templatePlan/labels.js +16 -1
- package/dist/docx/server/templatePlan/plan.d.ts +35 -3
- package/dist/docx/server/templatePlan/plan.js +197 -20
- package/dist/docx/server/templatePlan/planShape.js +58 -22
- package/dist/docx/server/templatePlan/revisions.d.ts +101 -0
- package/dist/docx/server/templatePlan/revisions.js +681 -0
- package/dist/docx/server/templatePlan/story.d.ts +61 -2
- package/dist/docx/server/templatePlan/story.js +175 -13
- package/dist/docx/server/templatePlan/types.d.ts +313 -1
- package/dist/docx/server/templatePlan/verify.js +175 -12
- package/dist/docx/server/templatePlan/xml.d.ts +3 -0
- package/dist/docx/server/templatePlan/xml.js +4 -1
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
- package/dist/docx/tableGridXml.d.ts +3 -7
- package/dist/docx/tableGridXml.js +5 -13
- package/dist/layout-bridge/convert/footnoteLayout.js +34 -8
- package/dist/prosemirror/canonicalMarkupDocument.d.ts +20 -0
- package/dist/prosemirror/canonicalMarkupDocument.js +73 -0
- package/dist/prosemirror/canonicalTableCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +1 -3
- package/dist/prosemirror/commands/comments.d.ts +6 -234
- package/dist/prosemirror/commands/comments.js +5 -2464
- package/dist/prosemirror/commands/index.d.ts +4 -2
- package/dist/prosemirror/commands/index.js +4 -2
- package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
- package/dist/prosemirror/conversion/markupViewSource.js +11 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +3 -0
- package/dist/prosemirror/conversion/toProseDoc.js +31 -14
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +6 -8
- package/dist/prosemirror/hyperlinkRemoval.d.ts +11 -8
- package/dist/prosemirror/hyperlinkRemoval.js +24 -15
- package/dist/prosemirror/independentMarkupProjection.d.ts +27 -0
- package/dist/prosemirror/independentMarkupProjection.js +147 -0
- package/dist/prosemirror/markupViewNotes.d.ts +1 -1
- package/dist/prosemirror/markupViewNotes.js +24 -27
- package/dist/prosemirror/markupViewPositionMap.d.ts +16 -0
- package/dist/prosemirror/markupViewPositionMap.js +316 -0
- package/dist/prosemirror/markupViewProjection.d.ts +3 -46
- package/dist/prosemirror/markupViewProjection.js +90 -17
- package/dist/prosemirror/paraIds.d.ts +1 -14
- package/dist/prosemirror/paraIds.js +1 -14
- package/dist/prosemirror/paragraphMarkJoin.d.ts +0 -16
- package/dist/prosemirror/paragraphMarkJoin.js +3 -46
- package/dist/prosemirror/projectionReview.d.ts +49 -0
- package/dist/prosemirror/projectionReview.js +292 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -13
- package/dist/prosemirror/rebaseParagraphRunFormatting.js +1 -16
- package/dist/prosemirror/replacedAnnotations.d.ts +6 -83
- package/dist/prosemirror/replacedAnnotations.js +11 -203
- package/dist/prosemirror/revisionCarriers.d.ts +9 -1
- package/dist/prosemirror/revisionCarriers.js +15 -1
- package/dist/prosemirror/revisionRangeQueries.d.ts +32 -0
- package/dist/prosemirror/revisionRangeQueries.js +76 -0
- package/dist/prosemirror/runFormattingMarkNames.d.ts +1 -1
- package/dist/prosemirror/runFormattingMarkNames.js +1 -1
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
- package/dist/prosemirror/styles/styleResolver.js +4 -1
- package/dist/prosemirror/suggestionQueries.d.ts +114 -0
- package/dist/prosemirror/suggestionQueries.js +320 -0
- package/dist/prosemirror/tableGridMutation.d.ts +1 -16
- package/dist/prosemirror/tableGridMutation.js +1 -78
- package/dist/prosemirror/tableRowRevisionOwnership.d.ts +18 -0
- package/dist/prosemirror/tableRowRevisionOwnership.js +7 -0
- package/dist/prosemirror/utils/extractTrackedChanges.js +14 -4
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +4 -35
- package/dist/types/canonicalCapabilities.js +4 -33
- package/package.json +2 -2
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +0 -3
- package/dist/internal/headlessRevisionResolutionGuard.js +0 -18
- package/dist/internal/revisionResolutionEdits.d.ts +0 -11
- package/dist/internal/revisionResolutionEdits.js +0 -18
- package/dist/internal/revisionResolutionInline.d.ts +0 -24
- package/dist/internal/revisionResolutionInline.js +0 -302
- package/dist/internal/revisionResolutionStep.d.ts +0 -32
- package/dist/internal/revisionResolutionStep.js +0 -282
- package/dist/internal/revisionResolutionTracking.d.ts +0 -9
- package/dist/internal/revisionResolutionTracking.js +0 -124
- package/dist/internal/wholeStoryRevisionResolution.d.ts +0 -56
- package/dist/internal/wholeStoryRevisionResolution.js +0 -783
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +0 -38
- package/dist/prosemirror/commands/resolveAllTableChanges.js +0 -642
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +0 -13
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +0 -45
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -18
- package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -207
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +0 -60
- package/dist/prosemirror/commands/tableMergeFoldDecisions.js +0 -78
- package/dist/prosemirror/rejoinRunCarriers.d.ts +0 -42
- package/dist/prosemirror/rejoinRunCarriers.js +0 -65
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +0 -15
- package/dist/prosemirror/runPropertyChangeResolution.js +0 -34
|
@@ -477,7 +477,8 @@ export declare class FolioDocxReviewer {
|
|
|
477
477
|
* the anchor map the apply layer resolves operations against.
|
|
478
478
|
*/
|
|
479
479
|
snapshot(): FolioAIEditSnapshot;
|
|
480
|
-
|
|
480
|
+
private pendingSuggestionIdsForStory;
|
|
481
|
+
/** Every suggestion id the document's editable stories still carry. */
|
|
481
482
|
private activeSuggestionIds;
|
|
482
483
|
/** Export staged AI operations for storage by the host, outside the DOCX. */
|
|
483
484
|
exportPendingSuggestions(): FolioPendingSuggestionRecord[];
|
|
@@ -544,7 +545,8 @@ export declare class FolioDocxReviewer {
|
|
|
544
545
|
/**
|
|
545
546
|
* Resolve one editable story to its original or final state, its staged
|
|
546
547
|
* suggestions with its other changes. A suggestion that reaches another
|
|
547
|
-
* story resolves only
|
|
548
|
+
* story resolves only in this one: its part in the others stays pending,
|
|
549
|
+
* for their own story resolution or the suggestion methods. A lock that
|
|
548
550
|
* prevents any target change from resolving refuses before mutation.
|
|
549
551
|
*/
|
|
550
552
|
resolveReviewedStory({ story, view }: FolioResolveReviewedStoryOptions): boolean;
|
|
@@ -721,7 +723,8 @@ export declare class FolioDocxReviewer {
|
|
|
721
723
|
/**
|
|
722
724
|
* One pending suggestion through the session's suggestion intent: rejected
|
|
723
725
|
* with the comments it proposes, or adopted as ordinary tracked changes by
|
|
724
|
-
* `author`. All stories belonging to the proposal publish together
|
|
726
|
+
* `author`. All stories belonging to the proposal publish together, or
|
|
727
|
+
* only its part in `story`.
|
|
725
728
|
*/
|
|
726
729
|
private resolveSuggestionOnSession;
|
|
727
730
|
/**
|
|
@@ -763,8 +766,8 @@ export declare class FolioDocxReviewer {
|
|
|
763
766
|
* A story holding staged suggestions resolved to `view`: its suggestions
|
|
764
767
|
* resolve with its other changes, on a fork, and the fork's operations
|
|
765
768
|
* land here as one commit, so a refusal leaves this reviewer as it was. A
|
|
766
|
-
* suggestion that reaches another story resolves only
|
|
767
|
-
*
|
|
769
|
+
* suggestion that reaches another story resolves here only in this story:
|
|
770
|
+
* its records in the others stay pending.
|
|
768
771
|
*/
|
|
769
772
|
private resolveStoryWithSuggestions;
|
|
770
773
|
/**
|
|
@@ -18,7 +18,6 @@ import { getCachedNumberingMap } from "../docx/numberingParser.js";
|
|
|
18
18
|
import { cloneDocumentWithParagraphPropertySources } from "../docx/paragraphPropertySource.js";
|
|
19
19
|
import { getEndnoteText, getFootnoteText, getHeaderFooterText } from "../docx/storyPlainText.js";
|
|
20
20
|
import { expectCharacterStyleMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
21
|
-
import { getSuggestions, suggestionIdOfRevision, suggestionOwnersByRevision } from "../prosemirror/commands/comments.js";
|
|
22
21
|
import { createCommentIdAllocator, seedCommentAllocator } from "../prosemirror/commentIdAllocator.js";
|
|
23
22
|
import { commentThreadIds } from "../prosemirror/commentRecords.js";
|
|
24
23
|
import { paragraphListReferences } from "../prosemirror/listInstanceReferences.js";
|
|
@@ -31,7 +30,8 @@ import { createDocumentStyleContextPlugin } from "../prosemirror/plugins/documen
|
|
|
31
30
|
import { getFolioNodeRevisionCarriers } from "../prosemirror/revisionCarriers.js";
|
|
32
31
|
import { schema } from "../prosemirror/schema/index.js";
|
|
33
32
|
import { sectionPropertiesOf } from "../prosemirror/sectionCarrier.js";
|
|
34
|
-
import {
|
|
33
|
+
import { getSuggestions } from "../prosemirror/suggestionQueries.js";
|
|
34
|
+
import { CANONICAL_CONDITION, CANONICAL_GAP, CANONICAL_RULE } from "../types/canonicalCapabilities.js";
|
|
35
35
|
import { readModel } from "../types/documentModel.js";
|
|
36
36
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
37
37
|
import { buildAnnotatedBlockTextWithNoteReferences } from "./clean-text.js";
|
|
@@ -45,7 +45,7 @@ import { matchTableGeometryOperations } from "./table-geometry.js";
|
|
|
45
45
|
import { tableTemplateCanCrossPackageLosslessly } from "./table-template.js";
|
|
46
46
|
import { TaggedError, panic } from "better-result";
|
|
47
47
|
import { CONTENT_CONTROL_LOCK, lockedControlMessage, numberingLevelEntries } from "@stll/docx-core/model";
|
|
48
|
-
import { DOCUMENT_OP_TYPES, OP_STORIES, captureStoryParts, freshCommentId, packageResourcesOpOf, pendingSuggestionIdsIn, reconcileDocumentPartRelationships, resolveSectionChange, resolveSectionChanges, sectionResolutionPatch, withoutPendingSuggestions } from "@stll/docx-core/ops";
|
|
48
|
+
import { DOCUMENT_OP_TYPES, OP_STORIES, captureStoryParts, freshCommentId, packageResourcesOpOf, pendingSuggestionIdsIn, reconcileDocumentPartRelationships, resolveSectionChange, resolveSectionChanges, sectionResolutionPatch, suggestionOwnersInStory, withoutPendingSuggestions } from "@stll/docx-core/ops";
|
|
49
49
|
import { ZipArchive } from "@stll/docx-core/zip";
|
|
50
50
|
import { EditorState, Selection, TextSelection } from "prosemirror-state";
|
|
51
51
|
// src/ai-edits/headless.ts
|
|
@@ -123,12 +123,21 @@ const canonicalOpStory = (story) => {
|
|
|
123
123
|
default: return panic("Unknown reviewer story", { story });
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* The refusal of a canonical reviewer for a staged suggestion the session
|
|
128
|
+
* left pending: the suggestion's resolution refused without stating why.
|
|
129
|
+
*/
|
|
127
130
|
const canonicalReviewerRefusal = (action) => new CanonicalSessionError({
|
|
128
131
|
ground: { gap: CANONICAL_GAP.publicHeadlessSession },
|
|
129
132
|
reason: "refused",
|
|
130
133
|
message: `A canonical headless reviewer cannot ${action} yet.`
|
|
131
134
|
});
|
|
135
|
+
/** A reviewer request under one of the session's conditions. */
|
|
136
|
+
const canonicalReviewerConditionRefusal = (condition, message) => new CanonicalSessionError({
|
|
137
|
+
ground: { condition },
|
|
138
|
+
reason: "refused",
|
|
139
|
+
message
|
|
140
|
+
});
|
|
132
141
|
const FOLIO_REVIEWED_VIEWS = Object.freeze([
|
|
133
142
|
"original",
|
|
134
143
|
"current-markup",
|
|
@@ -775,8 +784,8 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
775
784
|
return copy;
|
|
776
785
|
}
|
|
777
786
|
canonicalComparisonAccess() {
|
|
778
|
-
const
|
|
779
|
-
throw
|
|
787
|
+
const missingNoteLabels = () => {
|
|
788
|
+
throw canonicalReviewerConditionRefusal(CANONICAL_CONDITION.invalidRequest, "Inline atoms are matched with the comparison's note reference labels.");
|
|
780
789
|
};
|
|
781
790
|
return Object.freeze({
|
|
782
791
|
stageTerminalTableReviewCarrier: () => false,
|
|
@@ -792,7 +801,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
792
801
|
story: canonicalOpStory(targetStory),
|
|
793
802
|
snapshot: targetSnapshot
|
|
794
803
|
},
|
|
795
|
-
noteReferenceLabels: noteReferenceLabels ??
|
|
804
|
+
noteReferenceLabels: noteReferenceLabels ?? missingNoteLabels(),
|
|
796
805
|
author: this.author
|
|
797
806
|
});
|
|
798
807
|
if (result.status !== "matched") return result;
|
|
@@ -873,7 +882,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
873
882
|
for (const handle of handles) {
|
|
874
883
|
const state = copy.getEditableStoryState(handle);
|
|
875
884
|
if (!state) continue;
|
|
876
|
-
if (
|
|
885
|
+
if (copy.pendingSuggestionIdsForStory(handle, state).size > 0) throw canonicalReviewerRefusal("project a story holding a suggestion the session will not accept");
|
|
877
886
|
if (mode === "with-revision-census") {
|
|
878
887
|
const stats = getTrackedChangeStatsFromDoc(state.doc);
|
|
879
888
|
for (const id of stats.ids) ids.add(id);
|
|
@@ -1041,7 +1050,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1041
1050
|
const story = canonicalOpStory(handle);
|
|
1042
1051
|
const listed = listedRevisionGroups(state.doc);
|
|
1043
1052
|
if (listed.length === 0) return [];
|
|
1044
|
-
const owners =
|
|
1053
|
+
const owners = suggestionOwnersInStory(this.baseDocument, story);
|
|
1045
1054
|
const changes = listed.flatMap(({ id, groupIds }) => {
|
|
1046
1055
|
const suggestionId = owners.get(id) ?? null;
|
|
1047
1056
|
return resolution === "accept" && suggestionId !== null ? [] : [{
|
|
@@ -1165,13 +1174,19 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1165
1174
|
snapshot() {
|
|
1166
1175
|
return this.snapshotOf(this.state);
|
|
1167
1176
|
}
|
|
1168
|
-
|
|
1177
|
+
pendingSuggestionIdsForStory(story, state) {
|
|
1178
|
+
const ids = new Set(getSuggestions(state).map(({ suggestionId }) => suggestionId));
|
|
1179
|
+
for (const suggestionId of suggestionOwnersInStory(this.baseDocument, canonicalOpStory(story)).values()) ids.add(suggestionId);
|
|
1180
|
+
return ids;
|
|
1181
|
+
}
|
|
1182
|
+
/** Every suggestion id the document's editable stories still carry. */
|
|
1169
1183
|
activeSuggestionIds() {
|
|
1170
|
-
const active = new Set(
|
|
1184
|
+
const active = /* @__PURE__ */ new Set();
|
|
1185
|
+
if (pendingSuggestionIdsIn(this.baseDocument).size === 0) return active;
|
|
1171
1186
|
for (const handle of this.listStoryHandlesInternal()) {
|
|
1172
|
-
if (handle.type === "main") continue;
|
|
1173
1187
|
const state = this.getEditableStoryState(handle);
|
|
1174
|
-
|
|
1188
|
+
if (state === null) continue;
|
|
1189
|
+
for (const id of this.pendingSuggestionIdsForStory(handle, state)) active.add(id);
|
|
1175
1190
|
}
|
|
1176
1191
|
return active;
|
|
1177
1192
|
}
|
|
@@ -1330,7 +1345,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1330
1345
|
idSeed: revisionStamp.idSeed
|
|
1331
1346
|
}
|
|
1332
1347
|
});
|
|
1333
|
-
if (matched.status === "unaddressable") throw
|
|
1348
|
+
if (matched.status === "unaddressable") throw canonicalReviewerConditionRefusal(CANONICAL_CONDITION.internal, "A paired table cell holds no paragraph to address it by.");
|
|
1334
1349
|
if (matched.operations.length > 0) this.commitOpsOnSession(matched.operations);
|
|
1335
1350
|
return matched.nextRevisionId;
|
|
1336
1351
|
}
|
|
@@ -1358,7 +1373,8 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1358
1373
|
/**
|
|
1359
1374
|
* Resolve one editable story to its original or final state, its staged
|
|
1360
1375
|
* suggestions with its other changes. A suggestion that reaches another
|
|
1361
|
-
* story resolves only
|
|
1376
|
+
* story resolves only in this one: its part in the others stays pending,
|
|
1377
|
+
* for their own story resolution or the suggestion methods. A lock that
|
|
1362
1378
|
* prevents any target change from resolving refuses before mutation.
|
|
1363
1379
|
*/
|
|
1364
1380
|
resolveReviewedStory({ story = MAIN_STORY, view }) {
|
|
@@ -1685,7 +1701,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1685
1701
|
const document = readModel(session.document);
|
|
1686
1702
|
if (!(document.package.document.comments ?? []).some(({ id }) => id === parentId)) return null;
|
|
1687
1703
|
const id = freshCommentId(document, session.idLease);
|
|
1688
|
-
if (id.isErr()) throw
|
|
1704
|
+
if (id.isErr()) throw canonicalReviewerConditionRefusal(CANONICAL_CONDITION.idSpace, "No comment id is left to give the reply.");
|
|
1689
1705
|
const author = input.author ?? this.author;
|
|
1690
1706
|
const date = input.date ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1691
1707
|
this.commitCommentOnSession(session, {
|
|
@@ -1813,7 +1829,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1813
1829
|
resolveChangeOnSession(target, resolution) {
|
|
1814
1830
|
const { session } = this.engine;
|
|
1815
1831
|
const id = revisionIdOf(target);
|
|
1816
|
-
const suggestionId =
|
|
1832
|
+
const suggestionId = suggestionOwnersInStory(this.baseDocument, OP_STORIES.MAIN).get(id) ?? null;
|
|
1817
1833
|
if (suggestionId !== null) {
|
|
1818
1834
|
const adopted = this.resolveSuggestionOnSession(session, suggestionId, resolution, this.author);
|
|
1819
1835
|
if (!adopted || resolution === "reject") return adopted;
|
|
@@ -1834,15 +1850,17 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1834
1850
|
/**
|
|
1835
1851
|
* One pending suggestion through the session's suggestion intent: rejected
|
|
1836
1852
|
* with the comments it proposes, or adopted as ordinary tracked changes by
|
|
1837
|
-
* `author`. All stories belonging to the proposal publish together
|
|
1853
|
+
* `author`. All stories belonging to the proposal publish together, or
|
|
1854
|
+
* only its part in `story`.
|
|
1838
1855
|
*/
|
|
1839
|
-
resolveSuggestionOnSession(session, suggestionId, resolution, author) {
|
|
1856
|
+
resolveSuggestionOnSession(session, suggestionId, resolution, author, story) {
|
|
1840
1857
|
if (!this.activeSuggestionIds().has(suggestionId)) return false;
|
|
1841
1858
|
const prepared = session.prepareSuggestion(this.state, {
|
|
1842
1859
|
suggestionId,
|
|
1843
1860
|
resolution,
|
|
1844
1861
|
author,
|
|
1845
|
-
date: (/* @__PURE__ */ new Date()).toISOString()
|
|
1862
|
+
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1863
|
+
...story === void 0 ? {} : { story }
|
|
1846
1864
|
});
|
|
1847
1865
|
if (prepared.isErr() && prepared.error.reason === "refused") return false;
|
|
1848
1866
|
return this.resolveOnSession(prepared).resolved;
|
|
@@ -1976,15 +1994,16 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1976
1994
|
* A story holding staged suggestions resolved to `view`: its suggestions
|
|
1977
1995
|
* resolve with its other changes, on a fork, and the fork's operations
|
|
1978
1996
|
* land here as one commit, so a refusal leaves this reviewer as it was. A
|
|
1979
|
-
* suggestion that reaches another story resolves only
|
|
1980
|
-
*
|
|
1997
|
+
* suggestion that reaches another story resolves here only in this story:
|
|
1998
|
+
* its records in the others stay pending.
|
|
1981
1999
|
*/
|
|
1982
2000
|
resolveStoryWithSuggestions({ story, view, staged }) {
|
|
1983
2001
|
const key = editableStoryKey(story);
|
|
2002
|
+
const reaching = /* @__PURE__ */ new Set();
|
|
1984
2003
|
for (const handle of this.listStoryHandlesInternal()) {
|
|
1985
2004
|
if (editableStoryKey(handle) === key) continue;
|
|
1986
2005
|
const other = this.getEditableStoryState(handle);
|
|
1987
|
-
|
|
2006
|
+
for (const suggestionId of other ? this.pendingSuggestionIdsForStory(handle, other) : []) if (staged.has(suggestionId)) reaching.add(suggestionId);
|
|
1988
2007
|
}
|
|
1989
2008
|
const copy = this.fork();
|
|
1990
2009
|
const { session } = copy.engine;
|
|
@@ -1992,14 +2011,18 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
1992
2011
|
const unsubscribe = session.onCommitted(({ ops }) => operations.push(...ops));
|
|
1993
2012
|
let resolved;
|
|
1994
2013
|
try {
|
|
1995
|
-
for (const suggestionId of staged) copy.resolveSuggestionOnSession(session, suggestionId, view === "final" ? "accept" : "reject", this.author);
|
|
2014
|
+
for (const suggestionId of staged) copy.resolveSuggestionOnSession(session, suggestionId, view === "final" ? "accept" : "reject", this.author, reaching.has(suggestionId) ? canonicalOpStory(story) : void 0);
|
|
1996
2015
|
const after = copy.getEditableStoryState(story);
|
|
1997
|
-
if (after &&
|
|
2016
|
+
if (after && copy.pendingSuggestionIdsForStory(story, after).size > 0) throw canonicalReviewerRefusal("resolve a story holding a suggestion the session will not resolve");
|
|
1998
2017
|
resolved = copy.resolveStoryOnSession(session, story, view);
|
|
1999
2018
|
} finally {
|
|
2000
2019
|
unsubscribe();
|
|
2001
2020
|
}
|
|
2002
2021
|
if (operations.length > 0) this.commitOpsOnSession(operations);
|
|
2022
|
+
this.pendingSuggestions.forgetStoryRecords({
|
|
2023
|
+
story,
|
|
2024
|
+
suggestionIds: reaching
|
|
2025
|
+
});
|
|
2003
2026
|
return resolved;
|
|
2004
2027
|
}
|
|
2005
2028
|
/**
|
|
@@ -2013,7 +2036,7 @@ var FolioDocxReviewer = class FolioDocxReviewer {
|
|
|
2013
2036
|
});
|
|
2014
2037
|
const state = this.getEditableStoryState(story);
|
|
2015
2038
|
if (!state) return false;
|
|
2016
|
-
const staged =
|
|
2039
|
+
const staged = this.pendingSuggestionIdsForStory(story, state);
|
|
2017
2040
|
if (staged.size > 0) return this.resolveStoryWithSuggestions({
|
|
2018
2041
|
story,
|
|
2019
2042
|
view,
|
|
@@ -99,6 +99,15 @@ export declare class FolioPendingSuggestionRegistry {
|
|
|
99
99
|
clone(): FolioPendingSuggestionRegistry;
|
|
100
100
|
/** Every suggestion id a record names. */
|
|
101
101
|
suggestionIds(): Set<string>;
|
|
102
|
+
/**
|
|
103
|
+
* Forget a story's records of suggestions resolved in that story alone.
|
|
104
|
+
* Their records in other stories stay, and so does a record that is the
|
|
105
|
+
* last one its suggestion has.
|
|
106
|
+
*/
|
|
107
|
+
forgetStoryRecords({ story, suggestionIds }: {
|
|
108
|
+
story: FolioDocumentStoryHandle;
|
|
109
|
+
suggestionIds: ReadonlySet<string>;
|
|
110
|
+
}): void;
|
|
102
111
|
/**
|
|
103
112
|
* Anchor every live record whose paragraph is gone from its story, a
|
|
104
113
|
* resolution or an edit having removed it, where a save keeps its
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { parseFolioDocumentOperationBatch } from "../document-operations.js";
|
|
2
2
|
import { expectParagraphAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
3
|
-
import { getSuggestions } from "../prosemirror/commands/comments.js";
|
|
4
3
|
import { storyConversionOptions } from "../prosemirror/conversion/storyConversionOptions.js";
|
|
5
4
|
import { toProseDoc } from "../prosemirror/conversion/toProseDoc.js";
|
|
6
5
|
import { getDocumentStyleResolver } from "../prosemirror/plugins/documentStyleState.js";
|
|
7
6
|
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
7
|
+
import { getSuggestionRanges } from "../prosemirror/suggestionQueries.js";
|
|
8
8
|
import { getFolioParaIdFromBlockId } from "../types/block-id.js";
|
|
9
9
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
10
10
|
import { persistedBlock } from "./block-identity.js";
|
|
@@ -562,6 +562,17 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
562
562
|
return new Set([...this.records.values()].map(({ suggestionId }) => suggestionId));
|
|
563
563
|
}
|
|
564
564
|
/**
|
|
565
|
+
* Forget a story's records of suggestions resolved in that story alone.
|
|
566
|
+
* Their records in other stories stay, and so does a record that is the
|
|
567
|
+
* last one its suggestion has.
|
|
568
|
+
*/
|
|
569
|
+
forgetStoryRecords({ story, suggestionIds }) {
|
|
570
|
+
const storyKey = canonicalJson(story);
|
|
571
|
+
const recordedElsewhere = new Set([...this.records.values()].flatMap(({ suggestionId, story: other }) => canonicalJson(other) === storyKey ? [] : [suggestionId]));
|
|
572
|
+
for (const [key, record] of this.records) if (canonicalJson(record.story) === storyKey && suggestionIds.has(record.suggestionId) && recordedElsewhere.has(record.suggestionId)) this.records.delete(key);
|
|
573
|
+
if (![...this.records.values()].some((record) => canonicalJson(record.story) === storyKey)) this.sourceFingerprints.delete(storyKey);
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
565
576
|
* Anchor every live record whose paragraph is gone from its story, a
|
|
566
577
|
* resolution or an edit having removed it, where a save keeps its
|
|
567
578
|
* suggestion: a split at its own paragraph mark, text proposals over the
|
|
@@ -615,12 +626,11 @@ var FolioPendingSuggestionRegistry = class FolioPendingSuggestionRegistry {
|
|
|
615
626
|
continue;
|
|
616
627
|
}
|
|
617
628
|
}
|
|
618
|
-
const ranges = getSuggestions(view.state).find((entry) => entry.suggestionId === suggestionId)?.ranges ?? [];
|
|
619
629
|
const placed = saved === null ? null : placedRecord({
|
|
620
630
|
record,
|
|
621
631
|
live: view.live,
|
|
622
632
|
saved,
|
|
623
|
-
ranges
|
|
633
|
+
ranges: getSuggestionRanges(view.state, suggestionId)
|
|
624
634
|
});
|
|
625
635
|
this.records.set(key, placed ?? retiredRecord(record));
|
|
626
636
|
}
|
package/dist/ai-edits/read.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { expectParagraphAttrs, expectRunPropertyChangeMarkAttrs, expectTrackedChangeMarkAttrs } from "../prosemirror/attrs/index.js";
|
|
2
|
-
import { getFolioNodeRevisionCarriers } from "../prosemirror/revisionCarriers.js";
|
|
2
|
+
import { getFolioNodeRevisionCarriers, propertyRevisionMetadata } from "../prosemirror/revisionCarriers.js";
|
|
3
3
|
import { expandRunFormattingCarrier, runFormattingCarrierReviewText, runFormattingInlineAtomCleanText, runFormattingInlineAtomDisposition, runFormattingInlineAtomResultText } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
4
4
|
import { getTableCellMergeChange } from "../prosemirror/tableCellMergeRevision.js";
|
|
5
|
+
import { isTableRowRevisionCompanion } from "../prosemirror/tableRowRevisionOwnership.js";
|
|
5
6
|
import { enclosingInsertionAncestors, trackedRevisionLayerOf } from "../prosemirror/trackedRevisionPath.js";
|
|
6
7
|
import { commentAnchorIdsForNode } from "./comment-lifecycle.js";
|
|
7
8
|
import { readerTextOf } from "./note-references.js";
|
|
@@ -64,7 +65,6 @@ const firstBlockIdWithin = ({ node, nodePos, blockStarts }) => {
|
|
|
64
65
|
});
|
|
65
66
|
return blockId;
|
|
66
67
|
};
|
|
67
|
-
const belongsToRowRevision = (scope, revision) => revision.id === scope.change.id || revision.author === scope.change.author && revision.date === scope.change.date;
|
|
68
68
|
/**
|
|
69
69
|
* The paragraph-mark revision a marked row writes on its cells' paragraphs:
|
|
70
70
|
* a row deletion deletes each cell paragraph's mark with it, an insertion
|
|
@@ -207,7 +207,10 @@ const getTrackedChangeGroupsFromProjectedDoc = (doc, blockStarts, revisionRanges
|
|
|
207
207
|
to: carrier.to
|
|
208
208
|
});
|
|
209
209
|
const rowScope = rowRevisionScopes.at(-1);
|
|
210
|
-
if (rowScope !== void 0 && ROW_PARAGRAPH_MARK_CARRIERS[rowScope.kind] === carrier.type &&
|
|
210
|
+
if (rowScope !== void 0 && ROW_PARAGRAPH_MARK_CARRIERS[rowScope.kind] === carrier.type && isTableRowRevisionCompanion({
|
|
211
|
+
row: rowScope.change,
|
|
212
|
+
candidate: carrier
|
|
213
|
+
})) {
|
|
211
214
|
fold(rowScope.key, [carrier.id]);
|
|
212
215
|
return;
|
|
213
216
|
}
|
|
@@ -320,6 +323,29 @@ const getTrackedChangeGroupsFromProjectedDoc = (doc, blockStarts, revisionRanges
|
|
|
320
323
|
const change = getTableCellMergeChange(continuationCell);
|
|
321
324
|
if (!change) {
|
|
322
325
|
if (!isRecord(continuationCell)) continue;
|
|
326
|
+
const properties = continuationCell["propertyChanges"];
|
|
327
|
+
if (Array.isArray(properties)) for (const property of properties) {
|
|
328
|
+
if (!isRecord(property)) continue;
|
|
329
|
+
const metadata = propertyRevisionMetadata(property["info"]);
|
|
330
|
+
if (metadata === null || continuationRevisionsOwnedByRows.has(metadata.id)) continue;
|
|
331
|
+
const type = "cellPropertiesChanged";
|
|
332
|
+
revisionRanges?.push({
|
|
333
|
+
type,
|
|
334
|
+
author: metadata.author,
|
|
335
|
+
from: pos,
|
|
336
|
+
to: pos + node.nodeSize
|
|
337
|
+
});
|
|
338
|
+
grouped.set(`continuation:${String(pos)}:${metadata.id}`, {
|
|
339
|
+
...metadata,
|
|
340
|
+
type,
|
|
341
|
+
text: "",
|
|
342
|
+
blockId: firstBlockIdWithin({
|
|
343
|
+
node,
|
|
344
|
+
nodePos: pos,
|
|
345
|
+
blockStarts
|
|
346
|
+
})
|
|
347
|
+
});
|
|
348
|
+
}
|
|
323
349
|
const structuralChange = continuationCell["structuralChange"];
|
|
324
350
|
if (!isRecord(structuralChange)) continue;
|
|
325
351
|
const kind = structuralChange["type"];
|
|
@@ -430,7 +456,10 @@ const getTrackedChangeGroupsFromProjectedDoc = (doc, blockStarts, revisionRanges
|
|
|
430
456
|
for (const [layerIndex, { kind: layerKind, revision }] of layers.entries()) {
|
|
431
457
|
if (deletedFieldScopes.some(({ layers: enclosingLayers }) => enclosingLayers.some((layer) => layer.kind === layerKind && layer.revision.id === revision.id))) continue;
|
|
432
458
|
const rowScope = rowRevisionScopes.at(-1);
|
|
433
|
-
if (rowScope?.kind === layerKind &&
|
|
459
|
+
if (rowScope?.kind === layerKind && isTableRowRevisionCompanion({
|
|
460
|
+
row: rowScope.change,
|
|
461
|
+
candidate: revision
|
|
462
|
+
})) {
|
|
434
463
|
fold(rowScope.key, [revision.id]);
|
|
435
464
|
continue;
|
|
436
465
|
}
|
|
@@ -176,12 +176,20 @@ const propertyChangeFor = ({ base, target, position, scope, anchorParaId }) => {
|
|
|
176
176
|
anchorParaId
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* The paragraph id of the last paragraph in a cell, through the block content
|
|
181
|
+
* controls and other wrappers around it but outside any nested table: a
|
|
182
|
+
* table operation addressed by a paragraph selects the innermost table that
|
|
183
|
+
* holds it, even through block wrappers.
|
|
184
|
+
*/
|
|
180
185
|
const cellAnchorParaId = (cell) => {
|
|
181
186
|
let paraId;
|
|
182
|
-
cell.
|
|
183
|
-
|
|
184
|
-
if (
|
|
187
|
+
cell.descendants((node) => {
|
|
188
|
+
if (node.type.name === "table") return false;
|
|
189
|
+
if (node.type.name !== "paragraph") return true;
|
|
190
|
+
const id = node.attrs["paraId"];
|
|
191
|
+
if (typeof id === "string") paraId = id;
|
|
192
|
+
return false;
|
|
185
193
|
});
|
|
186
194
|
return paraId;
|
|
187
195
|
};
|
package/dist/ai-edits/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FolioContentBlock, FolioContentBlockIdentity, FolioContentInlineBooleanProperty, FolioContentInlineFormatting, FolioContentInlineFormattingPatch, FolioContentListReference, FolioContentParagraphIndentation, FolioContentParagraphKind, FolioContentParagraphSpacing, FolioContentRun, FolioContentSnapshot, FolioContentStatedNumbering, FolioContentTableLocation } from "../compare/content-types.js";
|
|
2
2
|
import { ListKind } from "../docx/listNumberingInstances.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
4
4
|
import { document_d_exports } from "../types/document.js";
|
|
5
5
|
export type FolioAIBlockKind = FolioContentParagraphKind | "diagnostic";
|
|
6
6
|
/** Boolean run properties supported by snapshots and range-formatting mutations. */
|
|
@@ -762,9 +762,14 @@ export type FolioAIEditParagraphIdentity = {
|
|
|
762
762
|
export type FolioAIEditSkippedOperation = {
|
|
763
763
|
id: string;
|
|
764
764
|
reason: FolioAIEditSkipReason;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
765
|
+
/**
|
|
766
|
+
* Why the canonical session refused it: a capability it does not have yet
|
|
767
|
+
* (`gap`), a rule the document states (`rule`), or a condition of the
|
|
768
|
+
* session or the request (`condition`), as `canonicalRefusalNotice` reads
|
|
769
|
+
* them. Absent where the reason alone says it, as the default engine
|
|
770
|
+
* reports the skip.
|
|
771
|
+
*/
|
|
772
|
+
canonicalRefusal?: CanonicalRefusalGround;
|
|
768
773
|
/**
|
|
769
774
|
* What exactly was wrong when the reason alone does not say: the values a
|
|
770
775
|
* `payloadDoesNotFit` skip could not place, the earlier operation an
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { anchoredCommentIdsInBlocks } from "../ai-edits/comment-lifecycle.js";
|
|
2
2
|
import { getTrackedChangeGroupsForIds, getTrackedChangeStatsFromDoc } from "../ai-edits/read.js";
|
|
3
|
-
import { pendingSuggestionRevisionIds } from "../prosemirror/commands/comments.js";
|
|
4
3
|
import { lockedControlSpans } from "../prosemirror/lockedControls.js";
|
|
5
4
|
import { lockViolationBetween } from "./canonicalLockGuard.js";
|
|
6
5
|
import { canonicalRevisionLocks } from "./canonicalRevisionLocks.js";
|
|
7
6
|
import { preservePropertySources } from "./propertySourcePreservation.js";
|
|
8
|
-
import { DOCUMENT_OP_TYPES, applyDocumentOps, findStoryBody } from "@stll/docx-core/ops";
|
|
9
|
-
import { EditorState } from "prosemirror-state";
|
|
7
|
+
import { DOCUMENT_OP_TYPES, applyDocumentOps, findStoryBody, suggestionOwnersInStory } from "@stll/docx-core/ops";
|
|
10
8
|
// src/canonical/canonicalBatchReview.ts
|
|
11
|
-
const revisionIdsOf = (
|
|
12
|
-
const { ids } = getTrackedChangeStatsFromDoc(
|
|
9
|
+
const revisionIdsOf = (version, story) => {
|
|
10
|
+
const { ids } = getTrackedChangeStatsFromDoc(version.projection);
|
|
13
11
|
if (ids.length === 0) return {
|
|
14
12
|
all: ids,
|
|
15
13
|
ordinary: ids
|
|
16
14
|
};
|
|
17
|
-
const
|
|
18
|
-
const suggested = pendingSuggestionRevisionIds(state);
|
|
15
|
+
const suggested = suggestionOwnersInStory(version.document, story);
|
|
19
16
|
return {
|
|
20
17
|
all: ids,
|
|
21
18
|
ordinary: suggested.size === 0 ? ids : ids.filter((id) => !suggested.has(id))
|
|
@@ -99,7 +96,7 @@ const resolveStoryPair = ({ before, after, story, decision, restores }) => {
|
|
|
99
96
|
const createCanonicalBatchReview = ({ before, after, story }) => {
|
|
100
97
|
let beforeIds;
|
|
101
98
|
let afterIds;
|
|
102
|
-
const revisions = (side) => side === "before" ? beforeIds ??= revisionIdsOf(before
|
|
99
|
+
const revisions = (side) => side === "before" ? beforeIds ??= revisionIdsOf(before, story) : afterIds ??= revisionIdsOf(after, story);
|
|
103
100
|
let accepted;
|
|
104
101
|
const accept = () => {
|
|
105
102
|
if (accepted !== void 0) return accepted;
|
|
@@ -3,6 +3,7 @@ import { cloneParagraphWithPropertySource } from "../docx/paragraphPropertySourc
|
|
|
3
3
|
import { threadedCommentIds } from "../docx/serializer/commentSerializer.js";
|
|
4
4
|
import { CANONICAL_CONDITION } from "../types/canonicalCapabilities.js";
|
|
5
5
|
import { canonicalJson } from "../utils/canonicalJson.js";
|
|
6
|
+
import { groundForDocumentOpRefusal } from "./canonicalRefusalGrounds.js";
|
|
6
7
|
import { Result, TaggedError } from "better-result";
|
|
7
8
|
import { DOCUMENT_OP_TYPES, ID_KIND_LIMITS, ID_LEASE_KINDS, allocateCommentAnchorIds, applyDocumentOps, formatParaId, freshLeasedIds, packageParagraphIds } from "@stll/docx-core/ops";
|
|
8
9
|
// src/canonical/canonicalComments.ts
|
|
@@ -17,6 +18,11 @@ const refuse = (message, condition = CANONICAL_CONDITION.invalidRequest) => Resu
|
|
|
17
18
|
message,
|
|
18
19
|
ground: { condition }
|
|
19
20
|
}));
|
|
21
|
+
/** A refusal the document operations stated, under its reason's ground. */
|
|
22
|
+
const refuseOp = ({ reason, message }) => Result.err(new CanonicalCommentError({
|
|
23
|
+
message,
|
|
24
|
+
ground: groundForDocumentOpRefusal(reason)
|
|
25
|
+
}));
|
|
20
26
|
const compileCanonicalComments = ({ document, command, idLease }) => {
|
|
21
27
|
const current = document.package.document.comments ?? [];
|
|
22
28
|
const byId = new Map(current.map((comment) => [comment.id, comment]));
|
|
@@ -131,9 +137,9 @@ const compileCanonicalComments = ({ document, command, idLease }) => {
|
|
|
131
137
|
newIds: allocation.value
|
|
132
138
|
});
|
|
133
139
|
})();
|
|
134
|
-
if (materialized.isErr()) return
|
|
140
|
+
if (materialized.isErr()) return refuseOp(materialized.error);
|
|
135
141
|
const applied = applyDocumentOps(draft, [materialized.value]);
|
|
136
|
-
if (applied.isErr()) return
|
|
142
|
+
if (applied.isErr()) return refuseOp(applied.error);
|
|
137
143
|
compiled.push(materialized.value);
|
|
138
144
|
draft = applied.value.document;
|
|
139
145
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { FolioAIEditSkipReason } from "../ai-edits/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CanonicalRefusalGround } from "../types/canonicalCapabilities.js";
|
|
3
3
|
import { DocumentOpRefusal } from "@stll/docx-core/ops";
|
|
4
4
|
type CompilerRefusalSkip = {
|
|
5
5
|
reason: FolioAIEditSkipReason;
|
|
6
6
|
message: string;
|
|
7
|
-
refusal?:
|
|
8
|
-
gap: CanonicalGap;
|
|
9
|
-
};
|
|
7
|
+
refusal?: CanonicalRefusalGround;
|
|
10
8
|
};
|
|
11
9
|
/** The skip a refused compilation reports. */
|
|
12
10
|
export declare const compilerRefusalSkip: ({ reason, message }: DocumentOpRefusal) => CompilerRefusalSkip;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { groundForDocumentOpRefusal } from "./canonicalRefusalGrounds.js";
|
|
2
2
|
import { DOCUMENT_OP_REFUSAL_REASONS } from "@stll/docx-core/ops";
|
|
3
3
|
// src/canonical/canonicalCompilerRefusal.ts
|
|
4
4
|
const typed = (reason) => ({
|
|
5
5
|
type: "typed",
|
|
6
6
|
reason
|
|
7
7
|
});
|
|
8
|
-
const
|
|
8
|
+
const grounded = (reason) => ({
|
|
9
|
+
type: "grounded",
|
|
10
|
+
reason
|
|
11
|
+
});
|
|
12
|
+
const UNSUPPORTED = grounded("unsupportedBlock");
|
|
9
13
|
const R = DOCUMENT_OP_REFUSAL_REASONS;
|
|
10
14
|
/**
|
|
11
15
|
* Every compiler refusal reason's public disposition. A deliberate refusal
|
|
12
|
-
* names its own reason, as the legacy engine reports one
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
+
* names its own reason, as the legacy engine reports one, and so does a
|
|
17
|
+
* change that would change nothing. A document that moved on is a stale
|
|
18
|
+
* range, and an offset inside a character splits it. Every other reason
|
|
19
|
+
* reports its ground besides: `untrackable` the shapes the tracked-change
|
|
20
|
+
* records do not express yet, `unrecordableLinkSuggestion` the rule the
|
|
21
|
+
* review records state, and the rest a request the document does not allow.
|
|
16
22
|
*/
|
|
17
23
|
const COMPILER_REFUSAL_DISPOSITIONS = {
|
|
18
24
|
[R.PENDING_RUN_PROPERTY_CHANGE]: typed("pendingRunPropertyChange"),
|
|
@@ -25,13 +31,13 @@ const COMPILER_REFUSAL_DISPOSITIONS = {
|
|
|
25
31
|
[R.PENDING_PARAGRAPH_MARK_INSERTION]: typed("pendingParagraphMarkInsertion"),
|
|
26
32
|
[R.PENDING_PARAGRAPH_JOIN]: typed("pendingParagraphMarkDeletion"),
|
|
27
33
|
[R.UNSUPPORTED_SCHEMA]: UNSUPPORTED,
|
|
28
|
-
[R.BLOCK_NOT_FOUND]:
|
|
34
|
+
[R.BLOCK_NOT_FOUND]: grounded("missingBlock"),
|
|
29
35
|
[R.INVALID_OPERATION]: UNSUPPORTED,
|
|
30
|
-
[R.NO_CHANGE]:
|
|
36
|
+
[R.NO_CHANGE]: typed("noopOperation"),
|
|
31
37
|
[R.DEPENDENT_RECORDS]: UNSUPPORTED,
|
|
32
38
|
[R.INVALID_OFFSET]: UNSUPPORTED,
|
|
33
39
|
[R.CROSS_BLOCK_RANGE]: UNSUPPORTED,
|
|
34
|
-
[R.SPLITS_SURROGATE_PAIR]:
|
|
40
|
+
[R.SPLITS_SURROGATE_PAIR]: grounded("splitsCharacter"),
|
|
35
41
|
[R.INVALID_TEXT]: UNSUPPORTED,
|
|
36
42
|
[R.INVALID_BLOCK_ID]: UNSUPPORTED,
|
|
37
43
|
[R.ID_COLLISION]: UNSUPPORTED,
|
|
@@ -41,7 +47,7 @@ const COMPILER_REFUSAL_DISPOSITIONS = {
|
|
|
41
47
|
[R.NEEDS_NEW_IDS]: UNSUPPORTED,
|
|
42
48
|
[R.INVALID_NEW_ID]: UNSUPPORTED,
|
|
43
49
|
[R.SHARED_ID]: UNSUPPORTED,
|
|
44
|
-
[R.STALE]:
|
|
50
|
+
[R.STALE]: grounded("staleRange"),
|
|
45
51
|
[R.STRUCTURE_MISMATCH]: UNSUPPORTED,
|
|
46
52
|
[R.EMPTY_CONTENT]: UNSUPPORTED,
|
|
47
53
|
[R.EMPTY_BLOCK_LIST]: UNSUPPORTED,
|
|
@@ -53,7 +59,7 @@ const COMPILER_REFUSAL_DISPOSITIONS = {
|
|
|
53
59
|
[R.MISSING_BLOCK_ID]: UNSUPPORTED,
|
|
54
60
|
[R.DUPLICATE_BLOCK_ID]: UNSUPPORTED,
|
|
55
61
|
[R.DUPLICATE_RECORD_ID]: UNSUPPORTED,
|
|
56
|
-
[R.SECTIONS_OUT_OF_STEP]:
|
|
62
|
+
[R.SECTIONS_OUT_OF_STEP]: grounded("staleRange"),
|
|
57
63
|
[R.EMPTY_RECORD]: UNSUPPORTED
|
|
58
64
|
};
|
|
59
65
|
/** The skip a refused compilation reports. */
|
|
@@ -64,10 +70,10 @@ const compilerRefusalSkip = ({ reason, message }) => {
|
|
|
64
70
|
reason: disposition.reason,
|
|
65
71
|
message
|
|
66
72
|
};
|
|
67
|
-
case "
|
|
68
|
-
reason:
|
|
73
|
+
case "grounded": return {
|
|
74
|
+
reason: disposition.reason,
|
|
69
75
|
message,
|
|
70
|
-
refusal:
|
|
76
|
+
refusal: groundForDocumentOpRefusal(reason)
|
|
71
77
|
};
|
|
72
78
|
default: return disposition;
|
|
73
79
|
}
|
|
@@ -63,7 +63,7 @@ export declare const CANONICAL_NATIVE_INLINE_POLICIES: {
|
|
|
63
63
|
readonly sdt: "control";
|
|
64
64
|
};
|
|
65
65
|
declare const InlineProjectionErrorBase: TaggedErrorClass<"InlineProjectionError">;
|
|
66
|
-
declare class InlineProjectionError extends InlineProjectionErrorBase<{
|
|
66
|
+
export declare class InlineProjectionError extends InlineProjectionErrorBase<{
|
|
67
67
|
message: string;
|
|
68
68
|
}> {}
|
|
69
69
|
/** Every source variant makes a decision before conversion can discard its positions. */
|
|
@@ -109,7 +109,7 @@ export type CanonicalInlineCommentContext = {
|
|
|
109
109
|
/** The comment ranges open where the paragraph starts. */
|
|
110
110
|
openIds: ReadonlySet<number>;
|
|
111
111
|
};
|
|
112
|
-
type CanonicalInlineProjectionArgs = {
|
|
112
|
+
export type CanonicalInlineProjectionArgs = {
|
|
113
113
|
source: document_d_exports.Paragraph;
|
|
114
114
|
paragraph: Node;
|
|
115
115
|
pairedBookmarkIds: StoryIdMembership;
|