@stll/folio-core 0.76.0 → 0.78.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 +6 -4
- package/dist/ai-edits/headless.js +32 -15
- package/dist/ai-edits/pending-suggestions.d.ts +9 -0
- package/dist/ai-edits/pending-suggestions.js +11 -0
- package/dist/ai-edits/read.js +24 -1
- package/dist/ai-edits/table-geometry.js +12 -4
- package/dist/canonical/canonicalBatchReview.js +7 -6
- 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 +19 -40
- 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 +190 -194
- package/dist/compare/inline-provenance.js +8 -1
- package/dist/controller/canonicalClipboard.d.ts +2 -1
- package/dist/controller/canonicalClipboard.js +312 -47
- package/dist/controller/canonicalComposition.js +67 -14
- package/dist/controller/canonicalStoryEditor.js +2 -0
- package/dist/controller/hiddenEditorManager.js +2 -0
- package/dist/docx/importedIdCollisions.js +29 -4
- package/dist/docx/paragraphParser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +2 -0
- package/dist/docx/reviewResolutionProvenance.js +22 -2
- package/dist/docx/server/templatePlan/apply.js +47 -2
- package/dist/docx/server/templatePlan/blocks.d.ts +34 -7
- package/dist/docx/server/templatePlan/blocks.js +190 -13
- package/dist/docx/server/templatePlan/builders.d.ts +8 -1
- package/dist/docx/server/templatePlan/builders.js +21 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +108 -6
- package/dist/docx/server/templatePlan/plan.d.ts +26 -1
- package/dist/docx/server/templatePlan/plan.js +181 -21
- package/dist/docx/server/templatePlan/planShape.js +15 -3
- package/dist/docx/server/templatePlan/revisions.d.ts +55 -0
- package/dist/docx/server/templatePlan/revisions.js +276 -2
- package/dist/docx/server/templatePlan/story.d.ts +58 -1
- package/dist/docx/server/templatePlan/story.js +176 -12
- package/dist/docx/server/templatePlan/types.d.ts +153 -1
- package/dist/docx/server/templatePlan/verify.js +58 -15
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
- package/dist/docx/tableGridXml.d.ts +3 -7
- package/dist/docx/tableGridXml.js +23 -15
- package/dist/docx/tableParser.js +3 -1
- 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 +7 -9
- package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
- package/dist/prosemirror/conversion/markupViewSource.js +11 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +8 -0
- package/dist/prosemirror/conversion/toProseDoc.js +43 -19
- 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/replacedAnnotations.d.ts +4 -78
- package/dist/prosemirror/replacedAnnotations.js +11 -194
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
- package/dist/prosemirror/styles/styleResolver.js +4 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +3 -10
- package/dist/types/canonicalCapabilities.js +3 -10
- package/package.json +2 -2
- 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 -3
- package/dist/internal/revisionResolutionStep.js +0 -113
- 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 -8
- package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -56
- 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
|
@@ -45,6 +45,8 @@ export type ToProseDocOptions = {
|
|
|
45
45
|
* {@link createProjectionBlockCache}.
|
|
46
46
|
*/
|
|
47
47
|
blockCache?: ProjectionBlockCache;
|
|
48
|
+
/** A canonical projection displays the cells that are still pending deletion. */
|
|
49
|
+
tableReviewGeometry?: "physical";
|
|
48
50
|
/**
|
|
49
51
|
* The salt of minted text-box anchor ids. Each conversion draws its own;
|
|
50
52
|
* a block cache keeps one for every projection it serves, and a caller
|
|
@@ -79,8 +81,10 @@ declare const CONVERSION_CONTEXT_DEPENDENCY: {
|
|
|
79
81
|
readonly theme: "package";
|
|
80
82
|
readonly pageBreakRunSourceDescendants: "package";
|
|
81
83
|
readonly warnPageBreakProjection: "package";
|
|
84
|
+
readonly tableReviewGeometry: "package";
|
|
82
85
|
readonly createMark: "package";
|
|
83
86
|
readonly nextTextBoxGroupId: "story";
|
|
87
|
+
readonly placedTextBoxGroup: "story";
|
|
84
88
|
readonly nextHyperlinkInstanceIndex: "story";
|
|
85
89
|
readonly nextNoteReferenceOccurrenceId: "story";
|
|
86
90
|
readonly pairedBookmarkIds: "story";
|
|
@@ -111,6 +115,7 @@ type ProjectionPackageInputs = {
|
|
|
111
115
|
theme: DeepReadonly<document_d_exports.Theme> | null;
|
|
112
116
|
numbering: document_d_exports.NumberingDefinitions | undefined;
|
|
113
117
|
warn: ParseContext["warn"] | undefined;
|
|
118
|
+
tableReviewGeometry: ToProseDocOptions["tableReviewGeometry"];
|
|
114
119
|
};
|
|
115
120
|
/**
|
|
116
121
|
* Converted blocks kept across projections of one story.
|
|
@@ -172,6 +177,8 @@ type TableConversionContext = {
|
|
|
172
177
|
numbering: NumberingMap | undefined;
|
|
173
178
|
theme: DeepReadonly<document_d_exports.Theme> | null | undefined;
|
|
174
179
|
nextTextBoxGroupId: () => string;
|
|
180
|
+
/** Told when a paragraph puts the group id it drew on what it converts. */
|
|
181
|
+
placedTextBoxGroup?: () => void;
|
|
175
182
|
nextHyperlinkInstanceIndex: HyperlinkInstanceIndexAllocator;
|
|
176
183
|
nextNoteReferenceOccurrenceId: () => string;
|
|
177
184
|
pairedBookmarkIds: IdMembership;
|
|
@@ -179,6 +186,7 @@ type TableConversionContext = {
|
|
|
179
186
|
/** Comments the story opens a range for, for the point-comment question. */
|
|
180
187
|
storyRangedCommentIds: IdMembership;
|
|
181
188
|
warnPageBreakProjection: PageBreakProjectionWarn;
|
|
189
|
+
tableReviewGeometry: ToProseDocOptions["tableReviewGeometry"];
|
|
182
190
|
/** Shares one mark instance per distinct run formatting across the conversion. */
|
|
183
191
|
createMark: MarkFactory;
|
|
184
192
|
/**
|
|
@@ -64,10 +64,11 @@ import { assertValidProseMirrorDocument, assertValidProseMirrorDocumentKeeping }
|
|
|
64
64
|
import { resolveEffectiveTableCellFormatting } from "./effectiveTableCellFormatting.js";
|
|
65
65
|
import { HYPHEN_ELEMENT_MARK_NAME, HYPHEN_TEXT_CARRIERS } from "./hyphenTextCarriers.js";
|
|
66
66
|
import { createMarkInterner } from "./markInterner.js";
|
|
67
|
+
import { markupViewSources } from "./markupViewSource.js";
|
|
67
68
|
import { hasSinkChildren } from "./preservedSinkCarriers.js";
|
|
68
69
|
import { sdtAttrsFromProperties } from "./sdtAttrs.js";
|
|
69
70
|
import { panic } from "better-result";
|
|
70
|
-
import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES } from "@stll/docx-core/model";
|
|
71
|
+
import { DRAWING_RAW_XML_MODES, PARSE_WARNING_CODES, tableWithPhysicalColumns } from "@stll/docx-core/model";
|
|
71
72
|
import { preservedCommentRangeMarkersAt } from "@stll/docx-core/ops";
|
|
72
73
|
// src/prosemirror/conversion/toProseDoc.ts
|
|
73
74
|
const DETACHED_WATERMARK_HOST = Symbol.for("stll.detachedWatermarkHost");
|
|
@@ -401,7 +402,7 @@ var ProjectionBlockCache = class {
|
|
|
401
402
|
/** The package context for these inputs, the cache started over if they changed. */
|
|
402
403
|
packageContext(inputs) {
|
|
403
404
|
const current = this.inputs;
|
|
404
|
-
if (this.context !== void 0 && current !== void 0 && current.styles === inputs.styles && current.theme === inputs.theme && current.numbering === inputs.numbering && current.warn === inputs.warn) return this.context;
|
|
405
|
+
if (this.context !== void 0 && current !== void 0 && current.styles === inputs.styles && current.theme === inputs.theme && current.numbering === inputs.numbering && current.warn === inputs.warn && current.tableReviewGeometry === inputs.tableReviewGeometry) return this.context;
|
|
405
406
|
this.inputs = inputs;
|
|
406
407
|
this.blocks = /* @__PURE__ */ new WeakMap();
|
|
407
408
|
this.context = {
|
|
@@ -411,6 +412,7 @@ var ProjectionBlockCache = class {
|
|
|
411
412
|
theme: inputs.theme,
|
|
412
413
|
pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex([]),
|
|
413
414
|
warnPageBreakProjection: pageBreakProjectionWarn(inputs.warn),
|
|
415
|
+
tableReviewGeometry: inputs.tableReviewGeometry,
|
|
414
416
|
createMark: createMarkInterner(schema)
|
|
415
417
|
};
|
|
416
418
|
return this.context;
|
|
@@ -428,7 +430,8 @@ var ProjectionBlockCache = class {
|
|
|
428
430
|
const context = this.context ?? panic("A block cache converts after its package context");
|
|
429
431
|
const textBoxGroups = {
|
|
430
432
|
start: state.textBoxGroups.value,
|
|
431
|
-
taken: 0
|
|
433
|
+
taken: 0,
|
|
434
|
+
used: false
|
|
432
435
|
};
|
|
433
436
|
const hyperlinks = {
|
|
434
437
|
start: state.hyperlinks.value,
|
|
@@ -446,6 +449,9 @@ var ProjectionBlockCache = class {
|
|
|
446
449
|
textBoxGroups.taken += 1;
|
|
447
450
|
return `${this.salt}:${state.textBoxGroups.value++}`;
|
|
448
451
|
},
|
|
452
|
+
placedTextBoxGroup: () => {
|
|
453
|
+
textBoxGroups.used = true;
|
|
454
|
+
},
|
|
449
455
|
nextHyperlinkInstanceIndex: () => {
|
|
450
456
|
hyperlinks.taken += 1;
|
|
451
457
|
return state.hyperlinks.value++;
|
|
@@ -464,15 +470,12 @@ var ProjectionBlockCache = class {
|
|
|
464
470
|
theme: context.theme,
|
|
465
471
|
pageBreakRunSourceDescendants: context.pageBreakRunSourceDescendants,
|
|
466
472
|
warnPageBreakProjection: context.warnPageBreakProjection,
|
|
473
|
+
tableReviewGeometry: context.tableReviewGeometry,
|
|
467
474
|
createMark: context.createMark,
|
|
468
475
|
...story
|
|
469
476
|
});
|
|
470
|
-
const saltMark = `"${this.salt}:`;
|
|
471
477
|
const reads = {
|
|
472
|
-
textBoxGroups: {
|
|
473
|
-
...textBoxGroups,
|
|
474
|
-
used: nodes.some((node) => JSON.stringify(node.toJSON()).includes(saltMark))
|
|
475
|
-
},
|
|
478
|
+
textBoxGroups: { ...textBoxGroups },
|
|
476
479
|
hyperlinks,
|
|
477
480
|
noteOccurrences,
|
|
478
481
|
pairedBookmarkIds: setReadsOf(pairedBookmarkIds),
|
|
@@ -504,7 +507,8 @@ function toProseDoc(document, options) {
|
|
|
504
507
|
styles: options?.styles ?? document.package.styles,
|
|
505
508
|
theme: options?.theme ?? document.package.theme ?? null,
|
|
506
509
|
numbering: document.package.numbering,
|
|
507
|
-
warn: options?.warn
|
|
510
|
+
warn: options?.warn,
|
|
511
|
+
tableReviewGeometry: options?.tableReviewGeometry
|
|
508
512
|
};
|
|
509
513
|
const shared = cache?.packageContext(packageInputs);
|
|
510
514
|
shared?.pageBreakRunSourceDescendants.include(paragraphs);
|
|
@@ -534,7 +538,8 @@ function toProseDoc(document, options) {
|
|
|
534
538
|
storyRangedCommentIds: story.storyRangedCommentIds,
|
|
535
539
|
openCommentIds: story.openCommentIds,
|
|
536
540
|
warnPageBreakProjection: shared?.warnPageBreakProjection ?? pageBreakProjectionWarn(options?.warn),
|
|
537
|
-
createMark: shared?.createMark ?? createMarkInterner(schema)
|
|
541
|
+
createMark: shared?.createMark ?? createMarkInterner(schema),
|
|
542
|
+
tableReviewGeometry: packageInputs.tableReviewGeometry
|
|
538
543
|
};
|
|
539
544
|
const convertBodyBlocks = (blocks) => {
|
|
540
545
|
const out = [];
|
|
@@ -594,6 +599,15 @@ function toProseDoc(document, options) {
|
|
|
594
599
|
const invalid = "Document conversion produced an invalid ProseMirror document";
|
|
595
600
|
if (cache === void 0) assertValidProseMirrorDocument(pmDoc, invalid);
|
|
596
601
|
else cache.validated = assertValidProseMirrorDocumentKeeping(pmDoc, invalid, cache.validated);
|
|
602
|
+
markupViewSources.set(pmDoc, {
|
|
603
|
+
document,
|
|
604
|
+
options: {
|
|
605
|
+
...packageInputs.styles === void 0 ? {} : { styles: packageInputs.styles },
|
|
606
|
+
theme: packageInputs.theme,
|
|
607
|
+
...cache === void 0 ? {} : { blockCache: cache },
|
|
608
|
+
textBoxGroupSalt: salt
|
|
609
|
+
}
|
|
610
|
+
});
|
|
597
611
|
return pmDoc;
|
|
598
612
|
}
|
|
599
613
|
/** The comments pending suggestions propose, by comment id. */
|
|
@@ -808,7 +822,7 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
808
822
|
let bookmarksArr;
|
|
809
823
|
let emptyHyperlinks;
|
|
810
824
|
let wrapperStack = [];
|
|
811
|
-
let
|
|
825
|
+
let paragraphKeepsBoundaryNodes = false;
|
|
812
826
|
const emitInlineNodes = (nodes, commentsAlreadyApplied = false) => {
|
|
813
827
|
if (nodes.length === 0) return;
|
|
814
828
|
const wrappedNodes = withInlineWrapperMark(nodes, wrapperStack);
|
|
@@ -843,11 +857,11 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
843
857
|
historical: getHistoricalRunFormatting
|
|
844
858
|
};
|
|
845
859
|
const emitTrackedChange = (change, markType, moveKind) => {
|
|
846
|
-
emitInlineNodes(convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runScope, trackedRunFormattingResolvers, styleResolver, moveKind, textBoxAnchors, wrapperStack, openCommentIds, { preserveSdtBoundaryOccurrences:
|
|
860
|
+
emitInlineNodes(convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runScope, trackedRunFormattingResolvers, styleResolver, moveKind, textBoxAnchors, wrapperStack, openCommentIds, { preserveSdtBoundaryOccurrences: paragraphKeepsBoundaryNodes }), true);
|
|
847
861
|
};
|
|
848
862
|
const stacked = withInlineWrapperStacks(withFieldWrapperCaptures(withLinkedPiecesInWrappers(paragraph.content)));
|
|
849
863
|
visitInlineContentSlots(paragraph, ({ item }) => {
|
|
850
|
-
if (item
|
|
864
|
+
if (keepsCommentBoundaryNodes(item)) paragraphKeepsBoundaryNodes = true;
|
|
851
865
|
});
|
|
852
866
|
const emptyRanges = planEmptyRanges(stacked.map((item) => item.content), stacked.map(({ stack }) => stack));
|
|
853
867
|
for (const [index, { content, stack }] of stacked.entries()) {
|
|
@@ -861,11 +875,11 @@ function convertParagraph(paragraph, styleResolver, context, extraRunFormatting,
|
|
|
861
875
|
switch (content.type) {
|
|
862
876
|
case "commentRangeStart":
|
|
863
877
|
openCommentIds.add(content.id);
|
|
864
|
-
if (
|
|
878
|
+
if (paragraphKeepsBoundaryNodes) emitInlineNodes([schema.node(COMMENT_RANGE_BOUNDARY_NODE_NAME, { marker: content })], true);
|
|
865
879
|
break;
|
|
866
880
|
case "commentRangeEnd":
|
|
867
881
|
openCommentIds.delete(content.id);
|
|
868
|
-
if (
|
|
882
|
+
if (paragraphKeepsBoundaryNodes) emitInlineNodes([schema.node(COMMENT_RANGE_BOUNDARY_NODE_NAME, { marker: content })], true);
|
|
869
883
|
break;
|
|
870
884
|
case "commentReference":
|
|
871
885
|
if (!storyRangedCommentIds.has(content.id)) anchorPointComment(inlineNodes, content.id);
|
|
@@ -1050,6 +1064,12 @@ const runPropertyChangeMark = (changes) => {
|
|
|
1050
1064
|
} : {}
|
|
1051
1065
|
});
|
|
1052
1066
|
};
|
|
1067
|
+
/**
|
|
1068
|
+
* A content control, or a link holding a comment boundary, writes its comment
|
|
1069
|
+
* boundaries as nodes. Every comment boundary beside it does too, so a range
|
|
1070
|
+
* ending outside such an item still runs between two nodes.
|
|
1071
|
+
*/
|
|
1072
|
+
const keepsCommentBoundaryNodes = (item) => item.type === "inlineSdt" || item.type === "hyperlink" && withInlineWrapperStacks(item.children).some(({ content }) => content.type === "commentRangeStart" || content.type === "commentRangeEnd");
|
|
1053
1073
|
function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runScope, runFormattingResolvers, styleResolver, moveKind, textBoxAnchors, wrappedBy, openCommentIds, options = {}) {
|
|
1054
1074
|
const nodes = [];
|
|
1055
1075
|
const preserveParentBoundaryOwnership = options.preserveParentBoundaryOwnership ?? true;
|
|
@@ -1069,11 +1089,11 @@ function convertTrackedChange(change, markType, nextHyperlinkInstanceIndex, runS
|
|
|
1069
1089
|
};
|
|
1070
1090
|
const getTrackedRunFormatting = markType === "deletion" ? runFormattingResolvers.historical : runFormattingResolvers.current;
|
|
1071
1091
|
const stacked = withInlineWrapperStacks(change.content);
|
|
1072
|
-
let
|
|
1092
|
+
let keepsBoundaryNodes = false;
|
|
1073
1093
|
if (options.preserveSdtBoundaryOccurrences === void 0) visitInlineContentSlotsInContent(change.content, ({ item }) => {
|
|
1074
|
-
if (item
|
|
1094
|
+
if (keepsCommentBoundaryNodes(item)) keepsBoundaryNodes = true;
|
|
1075
1095
|
});
|
|
1076
|
-
const preserveBoundaryOccurrences = options.preserveSdtBoundaryOccurrences ??
|
|
1096
|
+
const preserveBoundaryOccurrences = options.preserveSdtBoundaryOccurrences ?? keepsBoundaryNodes;
|
|
1077
1097
|
const emptyRanges = planEmptyRanges(stacked.map(({ content }) => content), stacked.map(({ stack }) => stack));
|
|
1078
1098
|
for (const [index, { content: item, stack }] of stacked.entries()) {
|
|
1079
1099
|
if (!isTrackedChangeWrapperChild(item)) continue;
|
|
@@ -1352,7 +1372,8 @@ function resolveTextFormatting(formatting, styleResolver) {
|
|
|
1352
1372
|
const styleFormatting = styleResolver.resolveRunStyle(formatting.styleId);
|
|
1353
1373
|
return mergeTextFormatting(styleFormatting, formatting);
|
|
1354
1374
|
}
|
|
1355
|
-
function convertTable(
|
|
1375
|
+
function convertTable(source, styleResolver, context) {
|
|
1376
|
+
const table = context.tableReviewGeometry === "physical" ? tableWithPhysicalColumns(source) : source;
|
|
1356
1377
|
for (const row of table.rows) for (const cell of row.cells) {
|
|
1357
1378
|
if (isCellMergeContinuation(cell) && context.pageBreakRunSourceDescendants.containsPageBreakRun(cell.content)) {
|
|
1358
1379
|
context.warnPageBreakProjection("A page break inside a vertically merged table cell paginates with the merged row");
|
|
@@ -1774,6 +1795,7 @@ function standaloneTableCellToProseMirror(cell, nodeType) {
|
|
|
1774
1795
|
storyRangedCommentIds: rangedCommentIds(cell.content),
|
|
1775
1796
|
openCommentIds: /* @__PURE__ */ new Set(),
|
|
1776
1797
|
warnPageBreakProjection: noPageBreakProjectionWarning,
|
|
1798
|
+
tableReviewGeometry: void 0,
|
|
1777
1799
|
createMark: createMarkInterner(schema)
|
|
1778
1800
|
},
|
|
1779
1801
|
isHeader: nodeType === "tableHeader",
|
|
@@ -2981,6 +3003,7 @@ function convertShape(shape, runFormatting) {
|
|
|
2981
3003
|
}
|
|
2982
3004
|
function convertParagraphWithTextBoxes(block, styleResolver, { textBoxGroupId, context, extraRunFormatting, preserveEmptyWrapper, tableParagraphOverlay }) {
|
|
2983
3005
|
const { textBoxes, textBoxAnchors } = extractTextBoxesFromParagraph(block, textBoxGroupId);
|
|
3006
|
+
if (textBoxes.length > 0) context.placedTextBoxGroup?.();
|
|
2984
3007
|
const pmParagraph = convertParagraph(block, styleResolver, context, extraRunFormatting, tableParagraphOverlay, textBoxAnchors);
|
|
2985
3008
|
const nodes = [];
|
|
2986
3009
|
const isEmptyAfterExtraction = textBoxes.length > 0 && !hasContentBesidesTextBoxAnchors(pmParagraph);
|
|
@@ -3346,6 +3369,7 @@ function headerFooterToProseDoc(content, options) {
|
|
|
3346
3369
|
storyRangedCommentIds: rangedCommentIds(content),
|
|
3347
3370
|
openCommentIds: /* @__PURE__ */ new Set(),
|
|
3348
3371
|
warnPageBreakProjection: pageBreakProjectionWarn(options?.warn),
|
|
3372
|
+
tableReviewGeometry: options?.tableReviewGeometry,
|
|
3349
3373
|
createMark: createMarkInterner(schema)
|
|
3350
3374
|
};
|
|
3351
3375
|
const convertBlocks = (blocks) => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { ResolvedMarkupDocumentView, RevisionDecision } from "@stll/docx-core/ops";
|
|
3
|
+
import { StepMap } from "prosemirror-transform";
|
|
4
|
+
type InlineChanges = NonNullable<ResolvedMarkupDocumentView["independentInline"]>;
|
|
5
|
+
type PositionRange = {
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
export type IndependentMarkupProjection = {
|
|
10
|
+
doc: Node;
|
|
11
|
+
positionMap: StepMap;
|
|
12
|
+
changeBarRanges: readonly PositionRange[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The native resolver supplies exactly which text ranges disappeared. Keep the
|
|
16
|
+
* original formatting and addresses of the rest, without converting standing
|
|
17
|
+
* blocks or reconstructing their run styles.
|
|
18
|
+
*/
|
|
19
|
+
export declare const projectIndependentMarkup: ({ doc, changes, indices }: {
|
|
20
|
+
doc: Node;
|
|
21
|
+
changes: InlineChanges;
|
|
22
|
+
/** For a detached source, where the inspected paragraphs originally stood. */
|
|
23
|
+
indices?: readonly number[];
|
|
24
|
+
}) => IndependentMarkupProjection | undefined;
|
|
25
|
+
/** Project a detached text story after canonical resolution of its text carriers. */
|
|
26
|
+
export declare const projectDetachedText: (doc: Node, decision: RevisionDecision) => IndependentMarkupProjection | undefined;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { expectTrackedChangeMarkAttrs } from "./attrs/index.js";
|
|
2
|
+
import "./extensions/marks/InlineWrapperExtension.js";
|
|
3
|
+
import { getFolioNodeRevisionCarriers } from "./revisionCarriers.js";
|
|
4
|
+
import { resolvedMarkupDocumentView } from "@stll/docx-core/ops";
|
|
5
|
+
import { Fragment } from "prosemirror-model";
|
|
6
|
+
import { StepMap } from "prosemirror-transform";
|
|
7
|
+
// src/prosemirror/independentMarkupProjection.ts
|
|
8
|
+
const isInlineRevision = (name) => name === "insertion" || name === "deletion";
|
|
9
|
+
const projectedText = (paragraph, { omitted }) => {
|
|
10
|
+
const nodes = [];
|
|
11
|
+
let cutIndex = 0;
|
|
12
|
+
for (let index = 0, start = 0; index < paragraph.childCount; index += 1) {
|
|
13
|
+
const node = paragraph.child(index);
|
|
14
|
+
if (!node.isText) return void 0;
|
|
15
|
+
const end = start + node.nodeSize;
|
|
16
|
+
const marks = node.marks.filter(({ type }) => !isInlineRevision(type.name));
|
|
17
|
+
let at = start;
|
|
18
|
+
for (let cut = omitted[cutIndex]; cut !== void 0 && cut.from < end;) {
|
|
19
|
+
if (cut.from > at) nodes.push(node.cut(at - start, cut.from - start).mark(marks));
|
|
20
|
+
at = Math.max(at, cut.to);
|
|
21
|
+
if (cut.to > end) break;
|
|
22
|
+
cutIndex += 1;
|
|
23
|
+
cut = omitted[cutIndex];
|
|
24
|
+
}
|
|
25
|
+
if (at < end) nodes.push(node.cut(at - start).mark(marks));
|
|
26
|
+
start = end;
|
|
27
|
+
}
|
|
28
|
+
return Fragment.fromArray(nodes);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The native resolver supplies exactly which text ranges disappeared. Keep the
|
|
32
|
+
* original formatting and addresses of the rest, without converting standing
|
|
33
|
+
* blocks or reconstructing their run styles.
|
|
34
|
+
*/
|
|
35
|
+
const projectIndependentMarkup = ({ doc, changes, indices }) => {
|
|
36
|
+
if (changes.length === 0) return {
|
|
37
|
+
doc,
|
|
38
|
+
positionMap: StepMap.empty,
|
|
39
|
+
changeBarRanges: []
|
|
40
|
+
};
|
|
41
|
+
const children = [];
|
|
42
|
+
const ranges = [];
|
|
43
|
+
const changeBarRanges = [];
|
|
44
|
+
let previous = 0;
|
|
45
|
+
let changeIndex = 0;
|
|
46
|
+
let removed = 0;
|
|
47
|
+
let last = -1;
|
|
48
|
+
for (let index = 0, position = 0; index < doc.childCount; index += 1) {
|
|
49
|
+
const original = doc.child(index);
|
|
50
|
+
const change = changes[changeIndex];
|
|
51
|
+
const target = change === void 0 ? void 0 : indices?.[change.index] ?? change.index;
|
|
52
|
+
if (change === void 0 || target !== index) {
|
|
53
|
+
children.push(original);
|
|
54
|
+
position += original.nodeSize;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (original.type.name !== "paragraph" || original.content.size !== change.sourceLength) return void 0;
|
|
58
|
+
const content = projectedText(original, change);
|
|
59
|
+
if (content === void 0) return void 0;
|
|
60
|
+
const paragraph = original.copy(content);
|
|
61
|
+
const from = position - removed;
|
|
62
|
+
changeBarRanges.push({
|
|
63
|
+
from,
|
|
64
|
+
to: from + paragraph.nodeSize
|
|
65
|
+
});
|
|
66
|
+
children.push(paragraph);
|
|
67
|
+
for (const { from: first, to } of change.omitted) {
|
|
68
|
+
const start = position + 1 + first;
|
|
69
|
+
const width = to - first;
|
|
70
|
+
if (start === last) ranges[previous + 1] = (ranges[previous + 1] ?? 0) + width;
|
|
71
|
+
else {
|
|
72
|
+
previous = ranges.length;
|
|
73
|
+
ranges.push(start, width, 0);
|
|
74
|
+
}
|
|
75
|
+
last = start + width;
|
|
76
|
+
removed += width;
|
|
77
|
+
}
|
|
78
|
+
position += original.nodeSize;
|
|
79
|
+
changeIndex += 1;
|
|
80
|
+
}
|
|
81
|
+
if (changeIndex !== changes.length) return void 0;
|
|
82
|
+
return {
|
|
83
|
+
doc: doc.copy(Fragment.fromArray(children)),
|
|
84
|
+
positionMap: new StepMap(ranges),
|
|
85
|
+
changeBarRanges
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** Project a detached text story after canonical resolution of its text carriers. */
|
|
89
|
+
const projectDetachedText = (doc, decision) => {
|
|
90
|
+
const changed = [];
|
|
91
|
+
const indices = [];
|
|
92
|
+
for (let index = 0, position = 0; index < doc.childCount; index += 1) {
|
|
93
|
+
const paragraph = doc.child(index);
|
|
94
|
+
if (paragraph.type.name !== "paragraph" || paragraph.attrs["_suggestedInsert"] != null || getFolioNodeRevisionCarriers(paragraph, position).length > 0) return void 0;
|
|
95
|
+
let revised = false;
|
|
96
|
+
const content = [];
|
|
97
|
+
for (let childIndex = 0; childIndex < paragraph.childCount; childIndex += 1) {
|
|
98
|
+
const child = paragraph.child(childIndex);
|
|
99
|
+
if (!child.isText || child.text === void 0) return void 0;
|
|
100
|
+
let wrapper;
|
|
101
|
+
const run = {
|
|
102
|
+
type: "run",
|
|
103
|
+
content: [{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: child.text
|
|
106
|
+
}]
|
|
107
|
+
};
|
|
108
|
+
for (const mark of child.marks) {
|
|
109
|
+
const type = mark.type.name;
|
|
110
|
+
if (type === "comment" || type === "hyperlink" || type === "runPropertyChange" || type === "inlineWrapper") return void 0;
|
|
111
|
+
if (type !== "insertion" && type !== "deletion") continue;
|
|
112
|
+
const attrs = expectTrackedChangeMarkAttrs(mark);
|
|
113
|
+
if (wrapper !== void 0 || attrs.moveKind != null || attrs._docxResolutionJoins != null || (attrs._docxRevisionAncestors?.length ?? 0) > 0) return void 0;
|
|
114
|
+
wrapper = {
|
|
115
|
+
type,
|
|
116
|
+
info: {
|
|
117
|
+
id: attrs.revisionId,
|
|
118
|
+
author: attrs.author
|
|
119
|
+
},
|
|
120
|
+
content: [run]
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
revised ||= wrapper !== void 0;
|
|
124
|
+
content.push(wrapper ?? run);
|
|
125
|
+
}
|
|
126
|
+
if (revised) {
|
|
127
|
+
changed.push({
|
|
128
|
+
type: "paragraph",
|
|
129
|
+
content
|
|
130
|
+
});
|
|
131
|
+
indices.push(index);
|
|
132
|
+
}
|
|
133
|
+
position += paragraph.nodeSize;
|
|
134
|
+
}
|
|
135
|
+
if (changed.length === 0) return {
|
|
136
|
+
doc,
|
|
137
|
+
positionMap: StepMap.empty,
|
|
138
|
+
changeBarRanges: []
|
|
139
|
+
};
|
|
140
|
+
const resolved = resolvedMarkupDocumentView({ package: { document: { content: changed } } }, decision);
|
|
141
|
+
return resolved.independentInline === void 0 ? void 0 : projectIndependentMarkup({
|
|
142
|
+
doc,
|
|
143
|
+
changes: resolved.independentInline,
|
|
144
|
+
indices
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
export { projectDetachedText, projectIndependentMarkup };
|
|
@@ -12,4 +12,4 @@ import { DisplayMode } from "../managers/EditorModeManager.js";
|
|
|
12
12
|
import { document_d_exports } from "../types/document.js";
|
|
13
13
|
import { EditorState } from "prosemirror-state";
|
|
14
14
|
/** The footnotes or endnotes as `view` shows them. */
|
|
15
|
-
export declare const markupViewNotes: <TNote extends document_d_exports.Footnote | document_d_exports.Endnote>(notes: TNote[] | undefined, view: DisplayMode,
|
|
15
|
+
export declare const markupViewNotes: <TNote extends document_d_exports.Footnote | document_d_exports.Endnote>(notes: TNote[] | undefined, view: DisplayMode, _state: EditorState, document: document_d_exports.Document | null) => TNote[] | undefined;
|
|
@@ -1,46 +1,43 @@
|
|
|
1
|
-
import { resolveWholeStory } from "../internal/wholeStoryRevisionResolution.js";
|
|
2
|
-
import { proseDocToBlocks } from "./conversion/fromProseDoc.js";
|
|
3
|
-
import { footnoteToProseDoc } from "./conversion/toProseDoc.js";
|
|
4
1
|
import { markupViewResolutionMode } from "./markupViewProjection.js";
|
|
5
|
-
import {
|
|
6
|
-
import { getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
2
|
+
import { findStoryBody, resolvedMarkupDocumentView } from "@stll/docx-core/ops";
|
|
7
3
|
// src/prosemirror/markupViewNotes.ts
|
|
8
4
|
const resolvedNotes = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
const resolvedNote = (note,
|
|
10
|
-
const
|
|
11
|
-
const cached =
|
|
12
|
-
if (cached
|
|
13
|
-
const
|
|
14
|
-
|
|
5
|
+
const resolvedNote = (note, decision, { styles, theme, numbering }) => {
|
|
6
|
+
const byDecision = resolvedNotes.get(note) ?? /* @__PURE__ */ new Map();
|
|
7
|
+
const cached = byDecision.get(decision);
|
|
8
|
+
if (cached !== void 0 && cached.styles === styles && cached.theme === theme && cached.numbering === numbering) return cached.note;
|
|
9
|
+
const source = { package: {
|
|
10
|
+
document: { content: [] },
|
|
11
|
+
...note.type === "footnote" ? { footnotes: [note] } : { endnotes: [note] },
|
|
15
12
|
...styles !== void 0 && { styles },
|
|
16
13
|
...theme !== void 0 && { theme },
|
|
17
14
|
...numbering !== void 0 && { numbering }
|
|
15
|
+
} };
|
|
16
|
+
const view = resolvedMarkupDocumentView(source, decision);
|
|
17
|
+
const body = findStoryBody(view.document, {
|
|
18
|
+
kind: note.type,
|
|
19
|
+
id: note.id
|
|
18
20
|
});
|
|
19
|
-
const
|
|
20
|
-
doc,
|
|
21
|
-
mode,
|
|
22
|
-
styleResolver,
|
|
23
|
-
numbering: getDocumentNumbering(state)
|
|
24
|
-
});
|
|
25
|
-
const resolved = result.failed || result.resolved.eq(doc) ? note : {
|
|
21
|
+
const resolved = body === void 0 || body.content === note.content ? note : {
|
|
26
22
|
...note,
|
|
27
|
-
content:
|
|
23
|
+
content: body.content
|
|
28
24
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
byDecision.set(decision, {
|
|
26
|
+
...styles !== void 0 && { styles },
|
|
27
|
+
...theme !== void 0 && { theme },
|
|
28
|
+
...numbering !== void 0 && { numbering },
|
|
32
29
|
note: resolved
|
|
33
30
|
});
|
|
34
|
-
resolvedNotes.set(note,
|
|
31
|
+
resolvedNotes.set(note, byDecision);
|
|
35
32
|
return resolved;
|
|
36
33
|
};
|
|
37
34
|
/** The footnotes or endnotes as `view` shows them. */
|
|
38
|
-
const markupViewNotes = (notes, view,
|
|
39
|
-
const
|
|
40
|
-
if (!notes || !
|
|
35
|
+
const markupViewNotes = (notes, view, _state, document) => {
|
|
36
|
+
const decision = markupViewResolutionMode(view);
|
|
37
|
+
if (!notes || !decision || !document) return notes;
|
|
41
38
|
let changed = false;
|
|
42
39
|
const shown = notes.map((note) => {
|
|
43
|
-
const resolved = resolvedNote(note,
|
|
40
|
+
const resolved = resolvedNote(note, decision, document.package);
|
|
44
41
|
changed ||= resolved !== note;
|
|
45
42
|
return resolved;
|
|
46
43
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { RevisionDecision } from "@stll/docx-core/ops";
|
|
3
|
+
import { StepMap } from "prosemirror-transform";
|
|
4
|
+
type MarkupViewPositionMapOptions = {
|
|
5
|
+
before: Node;
|
|
6
|
+
after: Node;
|
|
7
|
+
decision: RevisionDecision;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Match positions between authored and resolved projections. A surviving
|
|
11
|
+
* paragraph's closing edge anchors the region: on a join, preceding content
|
|
12
|
+
* can move into that paragraph, before its original opening edge. PM
|
|
13
|
+
* positions outside monotone matches are replacement ranges.
|
|
14
|
+
*/
|
|
15
|
+
export declare const markupViewPositionMap: ({ before, after, decision }: MarkupViewPositionMapOptions) => StepMap;
|
|
16
|
+
export {};
|