@stll/folio-core 0.76.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 +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/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 +13 -38
- 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 +178 -186
- 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/server/templatePlan/apply.js +47 -2
- package/dist/docx/server/templatePlan/blocks.d.ts +27 -7
- package/dist/docx/server/templatePlan/blocks.js +103 -12
- package/dist/docx/server/templatePlan/builders.d.ts +6 -0
- package/dist/docx/server/templatePlan/builders.js +7 -1
- 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 +24 -1
- package/dist/docx/server/templatePlan/plan.js +165 -12
- package/dist/docx/server/templatePlan/planShape.js +13 -2
- 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 +46 -1
- package/dist/docx/server/templatePlan/story.js +125 -11
- package/dist/docx/server/templatePlan/types.d.ts +97 -1
- package/dist/docx/server/templatePlan/verify.js +63 -9
- 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/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/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
|
@@ -35,6 +35,22 @@ export type DocxTableCell = {
|
|
|
35
35
|
/** Ids of the blocks directly inside the cell, in order. */
|
|
36
36
|
blockIds: string[];
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* A tracked change inside a paragraph, by where it sits in the paragraph's
|
|
40
|
+
* `text`. An insertion spans the text it added. A deletion takes no place
|
|
41
|
+
* in a text read with the changes accepted: its `start` and `end` are the
|
|
42
|
+
* one offset it was made at. A change of the paragraph mark sits at the
|
|
43
|
+
* offset the mark stands or stood at.
|
|
44
|
+
*/
|
|
45
|
+
export type DocxBlockRevision = {
|
|
46
|
+
kind: "insertion" | "deletion";
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
author: string;
|
|
50
|
+
date: string | null;
|
|
51
|
+
/** The change is of a paragraph mark, not of text. */
|
|
52
|
+
paragraphMark?: true;
|
|
53
|
+
};
|
|
38
54
|
/**
|
|
39
55
|
* One block of the main story. `text` is the visible text: `\t` for a tab,
|
|
40
56
|
* `\n` for a line break, U+FFFC for a footnote or endnote reference mark;
|
|
@@ -73,6 +89,13 @@ export type DocxBlock = {
|
|
|
73
89
|
* offset 6 reads `Annex 1 - Summary` on the page.
|
|
74
90
|
*/
|
|
75
91
|
selfNumbers?: number[];
|
|
92
|
+
/**
|
|
93
|
+
* The tracked changes the paragraph holds, in a manifest read with the
|
|
94
|
+
* changes kept (`trackedChanges: "keep"`), in the order they stand. A
|
|
95
|
+
* plan takes care around them: a label is not stripped across one and a
|
|
96
|
+
* reference is not placed on one.
|
|
97
|
+
*/
|
|
98
|
+
revisions?: DocxBlockRevision[];
|
|
76
99
|
/**
|
|
77
100
|
* The paragraph starts on a new page by its own formatting or its
|
|
78
101
|
* style's (`w:pageBreakBefore`). A plan carries it over with an item's
|
|
@@ -91,6 +114,13 @@ export type DocxBlock = {
|
|
|
91
114
|
* Absent when neither states one.
|
|
92
115
|
*/
|
|
93
116
|
alignment?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The space the paragraph states for itself in front of and behind it
|
|
119
|
+
* (`w:spacing`, `before` and `after`), in twentieths of a point. A side
|
|
120
|
+
* it does not state is left out; absent when it states neither. What its
|
|
121
|
+
* style gives is not here: this is what the document set by hand.
|
|
122
|
+
*/
|
|
123
|
+
spacing?: TemplatePlanSpacing;
|
|
94
124
|
/**
|
|
95
125
|
* The paragraph's indent in effect, in twentieths of a point: `left` is
|
|
96
126
|
* where its lines start, `firstLine` what its first line adds to that
|
|
@@ -175,6 +205,11 @@ export type DocxBlockManifest = {
|
|
|
175
205
|
trackedChangesResolved?: DocxTrackedChanges & {
|
|
176
206
|
view: TemplatePlanTrackedView;
|
|
177
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* What the document tracks, on a manifest read for a plan that keeps its
|
|
210
|
+
* tracked changes: the blocks are the accepted view's.
|
|
211
|
+
*/
|
|
212
|
+
trackedChangesKept?: DocxTrackedChanges;
|
|
178
213
|
warnings: string[];
|
|
179
214
|
};
|
|
180
215
|
/**
|
|
@@ -182,6 +217,16 @@ export type DocxBlockManifest = {
|
|
|
182
217
|
* change accepted, or with every change rejected.
|
|
183
218
|
*/
|
|
184
219
|
export type TemplatePlanTrackedView = "accept" | "reject";
|
|
220
|
+
/**
|
|
221
|
+
* What a plan does with the tracked changes of its source: formats one view
|
|
222
|
+
* of them, or keeps them (`keep`). A plan that keeps them is made for the
|
|
223
|
+
* accepted view's blocks; the output shows the same insertions and
|
|
224
|
+
* deletions, by the same authors, and tracks nothing new. So far only
|
|
225
|
+
* changes inside paragraphs are kept: a source with an inserted or deleted
|
|
226
|
+
* paragraph mark, table row or cell, or a move, is refused as
|
|
227
|
+
* `tracked-changes`.
|
|
228
|
+
*/
|
|
229
|
+
export type TemplatePlanTrackedChanges = TemplatePlanTrackedView | "keep";
|
|
185
230
|
/** The tracked changes of a document's main story and notes, by kind. */
|
|
186
231
|
export type DocxTrackedChanges = {
|
|
187
232
|
insertions: number;
|
|
@@ -381,9 +426,19 @@ export type TemplatePlanNestedParagraph = {
|
|
|
381
426
|
tabStops?: number[];
|
|
382
427
|
/** As on a source item. */
|
|
383
428
|
alignment?: TemplatePlanAlignment;
|
|
429
|
+
/** As on a source item. */
|
|
430
|
+
spacing?: TemplatePlanSpacing;
|
|
384
431
|
};
|
|
385
432
|
/** How a paragraph's lines are set between the margins (`w:jc`). */
|
|
386
433
|
export type TemplatePlanAlignment = "left" | "center" | "right" | "both";
|
|
434
|
+
/**
|
|
435
|
+
* The space in front of a paragraph and behind it (`w:spacing`), in
|
|
436
|
+
* twentieths of a point: at least one side. A side left out is the style's.
|
|
437
|
+
*/
|
|
438
|
+
export type TemplatePlanSpacing = {
|
|
439
|
+
before?: number;
|
|
440
|
+
after?: number;
|
|
441
|
+
};
|
|
387
442
|
/** A page other than the template's, in twentieths of a point. */
|
|
388
443
|
export type TemplatePlanSectionPage = {
|
|
389
444
|
orientation: "portrait" | "landscape";
|
|
@@ -479,6 +534,12 @@ export type TemplatePlanSourceItem = {
|
|
|
479
534
|
* cell or a centred line under a title. Not for a table.
|
|
480
535
|
*/
|
|
481
536
|
alignment?: TemplatePlanAlignment;
|
|
537
|
+
/**
|
|
538
|
+
* The paragraph's own space in front of it and behind it (`w:spacing`),
|
|
539
|
+
* over what its style states: for a line the document sets tight or
|
|
540
|
+
* apart by itself, such as the rows of a table. Not for a table.
|
|
541
|
+
*/
|
|
542
|
+
spacing?: TemplatePlanSpacing;
|
|
482
543
|
/**
|
|
483
544
|
* The paragraph is the last of a section, described here: for a part of
|
|
484
545
|
* the document whose page is another than the template's, such as a
|
|
@@ -499,6 +560,20 @@ export type TemplatePlanItem = {
|
|
|
499
560
|
kind: "slot";
|
|
500
561
|
templateBlockId: string;
|
|
501
562
|
sourceBlockIds: string[];
|
|
563
|
+
/**
|
|
564
|
+
* A lead of the first source block that the slot does not take: the
|
|
565
|
+
* name of a field the template shows itself (`To:` in front of an
|
|
566
|
+
* addressee, where the template has a cell that says so). The block
|
|
567
|
+
* must start with `text`. It and the blanks behind it are dropped;
|
|
568
|
+
* what follows is placed word for word and must be something.
|
|
569
|
+
* `shownByTemplateBlockId` names the paragraph of the template that
|
|
570
|
+
* shows the field: one the plan keeps as it is, with text. The report
|
|
571
|
+
* names every lead dropped.
|
|
572
|
+
*/
|
|
573
|
+
dropLead?: {
|
|
574
|
+
text: string;
|
|
575
|
+
shownByTemplateBlockId: string;
|
|
576
|
+
};
|
|
502
577
|
};
|
|
503
578
|
export type TemplatePlanNumberingPatch = {
|
|
504
579
|
abstractNumId: number;
|
|
@@ -575,6 +650,14 @@ export type TemplatePlan = {
|
|
|
575
650
|
* stands.
|
|
576
651
|
*/
|
|
577
652
|
lastSection?: TemplatePlanSection;
|
|
653
|
+
/**
|
|
654
|
+
* Paragraphs inside kept template tables that are written without their
|
|
655
|
+
* text: a sample line of a header cell the document has nothing for (the
|
|
656
|
+
* third line of an address). The paragraph keeps its place and its
|
|
657
|
+
* properties. Each is a paragraph nested in a table the plan keeps, and
|
|
658
|
+
* none is filled by a slot.
|
|
659
|
+
*/
|
|
660
|
+
emptyTemplateBlockIds?: string[];
|
|
578
661
|
/**
|
|
579
662
|
* The view of a source with tracked changes the plan is made for: its
|
|
580
663
|
* text with every change accepted, or with every change rejected. The
|
|
@@ -582,7 +665,7 @@ export type TemplatePlan = {
|
|
|
582
665
|
* no revision, and verification holds it to that view. Left out, a
|
|
583
666
|
* source with tracked changes is refused.
|
|
584
667
|
*/
|
|
585
|
-
trackedChanges?:
|
|
668
|
+
trackedChanges?: TemplatePlanTrackedChanges;
|
|
586
669
|
/**
|
|
587
670
|
* What becomes of text effects whose values show nothing, in the parts
|
|
588
671
|
* the output takes from the template: its document, numbering, styles,
|
|
@@ -607,6 +690,14 @@ export type TemplatePlanBlockResult = {
|
|
|
607
690
|
emphasis: "identical" | "mismatch" | "omitted";
|
|
608
691
|
/** What `stripLabel` removed, the following space included. */
|
|
609
692
|
strippedPrefix?: string;
|
|
693
|
+
/**
|
|
694
|
+
* The lead a slot's `dropLead` took off the block, the blanks behind it
|
|
695
|
+
* included, and the kept paragraph of the template that shows the field.
|
|
696
|
+
*/
|
|
697
|
+
droppedLead?: {
|
|
698
|
+
text: string;
|
|
699
|
+
shownByTemplateBlockId: string;
|
|
700
|
+
};
|
|
610
701
|
/** The automatic label `labelAsText` wrote as text, without what follows it. */
|
|
611
702
|
labelAsText?: string;
|
|
612
703
|
/** The label the source showed: its automatic label, else the stripped one. */
|
|
@@ -673,6 +764,11 @@ export type TemplatePlanReport = {
|
|
|
673
764
|
trackedChanges?: DocxTrackedChanges & {
|
|
674
765
|
view: TemplatePlanTrackedView;
|
|
675
766
|
};
|
|
767
|
+
/**
|
|
768
|
+
* What the source tracks, when the plan kept its tracked changes: the
|
|
769
|
+
* output shows the same insertions and deletions by the same authors.
|
|
770
|
+
*/
|
|
771
|
+
trackedChangesKept?: DocxTrackedChanges;
|
|
676
772
|
/** One entry per block of the source, nested ones included, in document order. */
|
|
677
773
|
blocks: TemplatePlanBlockResult[];
|
|
678
774
|
counts: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNumberingReference } from "../../numberingReference.js";
|
|
2
2
|
import { parseSettings } from "../../settingsParser.js";
|
|
3
3
|
import { validateDocxConformance } from "../validateDocxConformance.js";
|
|
4
|
-
import { analyzeDocument, analyzeSource, viewOf } from "./blocks.js";
|
|
4
|
+
import { analyzeDocument, analyzeKeptForm, analyzeSource, viewOf } from "./blocks.js";
|
|
5
5
|
import { applyRefCaseFormat, fieldBookmarkOf, keepsShiftReturnSpacing, refCaseFormat } from "./builders.js";
|
|
6
6
|
import { countEffects, findInvisibleEffects } from "./effects.js";
|
|
7
7
|
import { linkAddress, linkAddressKey, templateCharacterStyles } from "./emit.js";
|
|
@@ -11,6 +11,7 @@ import { styleNumbering } from "./labels.js";
|
|
|
11
11
|
import { guarded, readPartText } from "./package.js";
|
|
12
12
|
import { hyperlinkFieldLink, paragraphPieces, piecesContent, resolvePlan, segmentPieces } from "./plan.js";
|
|
13
13
|
import { objectFingerprint, objectTargets, readStoryResources, relationshipIdsOf } from "./resources.js";
|
|
14
|
+
import { tableRowRevisions } from "./revisions.js";
|
|
14
15
|
import { createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks } from "./story.js";
|
|
15
16
|
import { integerOrNull, isW, rangeOf, readRawPart, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
16
17
|
import { Result } from "better-result";
|
|
@@ -47,13 +48,30 @@ const emptyContent = () => ({
|
|
|
47
48
|
links: [],
|
|
48
49
|
marks: []
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
/**
|
|
52
|
+
* A kept tracked change as marks of a content: an insertion marks every
|
|
53
|
+
* unit of its text (or its place, for content without text), a deletion its
|
|
54
|
+
* place and what was deleted, a paragraph mark its place; each with its
|
|
55
|
+
* author and date. Two contents
|
|
56
|
+
* that read the same then show the same changes by the same hands.
|
|
57
|
+
*/
|
|
58
|
+
const revisionMarks = ({ kind, author, date, deleted, mark, within }, at, length) => {
|
|
59
|
+
const by = `${author}:${date ?? ""}`;
|
|
60
|
+
if (kind === "del") {
|
|
61
|
+
const inside = within === void 0 ? "" : `:in:${within.author}:${within.date ?? ""}`;
|
|
62
|
+
return [`${at}:del:${by}:${deleted ?? ""}${inside}`];
|
|
63
|
+
}
|
|
64
|
+
if (mark === true) return [`${at}:mark:${by}`];
|
|
65
|
+
return Array.from({ length: Math.max(length, 1) }, (_unused, offset) => `${at + offset}:ins:${by}`);
|
|
66
|
+
};
|
|
67
|
+
const appendUnit = (content, { kind, text, signature, link, element, instruction, revision, origin }, resources) => {
|
|
51
68
|
content.text += text;
|
|
52
69
|
for (let unit = 0; unit < text.length; unit += 1) {
|
|
53
70
|
content.signatures.push(signature);
|
|
54
71
|
content.links.push(link);
|
|
55
72
|
}
|
|
56
73
|
const at = content.text.length - text.length;
|
|
74
|
+
if (revision !== null) content.marks.push(...revisionMarks(revision, at, text.length));
|
|
57
75
|
if (kind === "pageBreak") content.marks.push(`${at}:break:${wAttr(element, "type") ?? "page"}`);
|
|
58
76
|
else if (kind === "selfNumber") content.marks.push(`${at}:number:${instruction ?? ""}`);
|
|
59
77
|
else if (kind === "object" && element !== null) content.marks.push(`${at}:object:${objectFingerprint(element)}:${objectTargets(element, origin, resources).join(",")}`);
|
|
@@ -73,6 +91,7 @@ const expectedContent = (pieces, resources, content = emptyContent()) => {
|
|
|
73
91
|
link: linkAddressKey(linkAddress(piece.link, resources.relationships[piece.origin])),
|
|
74
92
|
element: piece.atom?.element ?? null,
|
|
75
93
|
instruction: piece.atom?.instruction ?? null,
|
|
94
|
+
revision: piece.atom?.revision ?? null,
|
|
76
95
|
origin: piece.origin
|
|
77
96
|
}, resources);
|
|
78
97
|
return content;
|
|
@@ -99,6 +118,7 @@ const outputContent = ({ read, origin, resources, styles, content = emptyContent
|
|
|
99
118
|
link,
|
|
100
119
|
element: atom.element,
|
|
101
120
|
instruction: atom.instruction ?? null,
|
|
121
|
+
revision: atom.revision ?? null,
|
|
102
122
|
origin
|
|
103
123
|
}, resources);
|
|
104
124
|
}
|
|
@@ -208,6 +228,7 @@ const indentKey = (left, hanging, firstLine) => [
|
|
|
208
228
|
hanging,
|
|
209
229
|
firstLine
|
|
210
230
|
].map((side) => side ?? "").join(":");
|
|
231
|
+
const spacingKey = (before, after) => before === null && after === null ? null : `${before === null ? "" : String(before)}:${after === null ? "" : String(after)}`;
|
|
211
232
|
/** The sides of an indent counted in characters: they override the
|
|
212
233
|
* measured ones, so a paragraph that states one is another paragraph. */
|
|
213
234
|
const CHARACTER_INDENTS = [
|
|
@@ -233,14 +254,25 @@ const statedProperties = (paragraph) => {
|
|
|
233
254
|
indent: indent === null ? null : `${indentKey(twipsOrNull(wAttr(indent, "left") ?? wAttr(indent, "start")), twipsOrNull(wAttr(indent, "hanging")), twipsOrNull(wAttr(indent, "firstLine")))}${characterIndentKey(indent)}`,
|
|
234
255
|
tabStops: tabStopsKey(wChild(properties, "tabs")),
|
|
235
256
|
alignment: wChildVal(properties, "jc"),
|
|
257
|
+
spacing: spacingKey(twipsOrNull(wAttr(wChild(properties, "spacing"), "before")), twipsOrNull(wAttr(wChild(properties, "spacing"), "after"))),
|
|
236
258
|
endsSection: wChild(properties, "sectPr") !== null
|
|
237
259
|
};
|
|
238
260
|
};
|
|
239
|
-
/** Whether a
|
|
261
|
+
/** Whether a kept paragraph states what the template's states. */
|
|
262
|
+
const sameStated = (before, after) => before.styleId === after.styleId && before.pageBreakBefore === after.pageBreakBefore && before.keepNext === after.keepNext && before.indent === after.indent && before.tabStops === after.tabStops && before.alignment === after.alignment && before.spacing === after.spacing && before.endsSection === after.endsSection && before.numId === after.numId && before.ilvl === after.ilvl;
|
|
263
|
+
/**
|
|
264
|
+
* Whether a bookmark of `read` holds all of the paragraph's content. In a
|
|
265
|
+
* reading that keeps tracked changes the paragraph's own content begins
|
|
266
|
+
* behind the last paragraph mark deleted in it (what stands in front is the
|
|
267
|
+
* paragraph the mark ended) and ends in front of a mark somebody inserted.
|
|
268
|
+
*/
|
|
240
269
|
const bookmarkEncloses = (read, name) => {
|
|
241
270
|
const start = read?.bookmarks.find((bookmark) => bookmark.name === name);
|
|
242
271
|
const end = start === void 0 ? void 0 : read?.bookmarkEnds.find(({ id }) => id === start.id);
|
|
243
|
-
|
|
272
|
+
if (read === null || start === void 0 || end === void 0) return false;
|
|
273
|
+
const own = read.atoms.findLastIndex(({ revision }) => revision?.deleted === "") + 1;
|
|
274
|
+
const marked = read.atoms.at(-1)?.revision?.mark === true ? 1 : 0;
|
|
275
|
+
return start.atomIndex === own && end.atomIndex === read.atoms.length - marked;
|
|
244
276
|
};
|
|
245
277
|
const segmentLength = (segment) => piecesContent(segment.kind === "piece" ? [segment.piece] : segment.pieces).text.length;
|
|
246
278
|
/** The rows and cells of a table, without the ids of what they hold. */
|
|
@@ -251,10 +283,16 @@ const tableShape = (block) => JSON.stringify((block.block.cells ?? []).map(({ ro
|
|
|
251
283
|
]));
|
|
252
284
|
/** Read `output` back and report how it compares with the resolved plan. */
|
|
253
285
|
const reportTemplatePlanOutput = async ({ source, template, output, plan, resolved, options }) => {
|
|
254
|
-
const
|
|
286
|
+
const keepsRevisions = source.manifest.trackedChangesKept !== void 0;
|
|
287
|
+
const analyzedOutput = keepsRevisions ? await analyzeKeptForm(output) : await analyzeDocument(output);
|
|
255
288
|
if (Result.isError(analyzedOutput)) return analyzedOutput;
|
|
256
289
|
const out = analyzedOutput.value;
|
|
257
290
|
const issues = [];
|
|
291
|
+
const leftUntagged = out.story.state.formattingRevisions + out.story.state.untaggedRevisions + out.footnotes.state.formattingRevisions + out.footnotes.state.untaggedRevisions + out.endnotes.state.formattingRevisions + out.endnotes.state.untaggedRevisions;
|
|
292
|
+
if (keepsRevisions && leftUntagged > 0) issues.push({
|
|
293
|
+
code: "revision-left",
|
|
294
|
+
message: `The output holds ${String(leftUntagged)} tracked change(s) the source's kept changes do not account for.`
|
|
295
|
+
});
|
|
258
296
|
if (source.manifest.trackedChangesResolved !== void 0 && out.manifest.trackedChanges > 0) issues.push({
|
|
259
297
|
code: "revision-left",
|
|
260
298
|
message: `The output holds ${String(out.manifest.trackedChanges)} tracked change(s).`
|
|
@@ -274,10 +312,13 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
274
312
|
for (const item of resolved.items) if (item.kind === "slot") slotBlocks.set(item.paragraph, item.templateBlock);
|
|
275
313
|
for (const slot of resolved.nestedSlots) slotBlocks.set(slot.paragraph, slot.templateBlock);
|
|
276
314
|
const slottedTemplateBlocks = new Set(slotBlocks.values());
|
|
315
|
+
const emptiedTemplateBlocks = new Set(resolved.emptied);
|
|
316
|
+
const { emptiedContents } = resolved;
|
|
277
317
|
const plannedProperties = (paragraph) => {
|
|
278
318
|
const slot = slotBlocks.get(paragraph);
|
|
279
319
|
if (slot !== void 0) return statedProperties(slot.element);
|
|
280
320
|
const { styleId, numbering, pageBreakBefore, keepNext, alignment } = paragraph;
|
|
321
|
+
const spacing = paragraph.spacing === null ? null : spacingKey(paragraph.spacing.before ?? null, paragraph.spacing.after ?? null);
|
|
281
322
|
const endsSection = paragraph.endsSection !== null;
|
|
282
323
|
const indent = paragraph.indent === null ? null : indentKey(paragraph.indent.left, paragraph.indent.hanging, paragraph.indent.firstLine);
|
|
283
324
|
const tabStops = paragraph.tabStops === null ? null : paragraph.tabStops.map((stop) => `left@${String(stop)}`).join(",");
|
|
@@ -290,6 +331,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
290
331
|
indent,
|
|
291
332
|
tabStops,
|
|
292
333
|
alignment,
|
|
334
|
+
spacing,
|
|
293
335
|
endsSection
|
|
294
336
|
};
|
|
295
337
|
return {
|
|
@@ -301,6 +343,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
301
343
|
indent,
|
|
302
344
|
tabStops,
|
|
303
345
|
alignment,
|
|
346
|
+
spacing,
|
|
304
347
|
endsSection
|
|
305
348
|
};
|
|
306
349
|
};
|
|
@@ -320,9 +363,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
320
363
|
message: planned.pageBreakBefore ? `Block ${blockId} does not start the new page the plan gives it.` : `Block ${blockId} starts a new page the plan does not give it.`,
|
|
321
364
|
blockId
|
|
322
365
|
});
|
|
323
|
-
if (stated.keepNext !== planned.keepNext || stated.indent !== planned.indent || stated.tabStops !== planned.tabStops || stated.alignment !== planned.alignment) issues.push({
|
|
366
|
+
if (stated.keepNext !== planned.keepNext || stated.indent !== planned.indent || stated.tabStops !== planned.tabStops || stated.alignment !== planned.alignment || stated.spacing !== planned.spacing) issues.push({
|
|
324
367
|
code: "paragraph-format-mismatch",
|
|
325
|
-
message: `Block ${blockId} does not carry the keep-with-next, the indent, the tab stops or the
|
|
368
|
+
message: `Block ${blockId} does not carry the keep-with-next, the indent, the tab stops, the alignment or the spacing the plan gives it.`,
|
|
326
369
|
blockId
|
|
327
370
|
});
|
|
328
371
|
if (stated.endsSection !== planned.endsSection) issues.push({
|
|
@@ -351,6 +394,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
351
394
|
const mapTable = (cells, sourceTable, outputTable) => {
|
|
352
395
|
const tableId = sourceTable.block.id;
|
|
353
396
|
tableOutputs.set(tableId, outputTable.block.id);
|
|
397
|
+
if (!sameList(tableRowRevisions(sourceTable.element), tableRowRevisions(outputTable.element))) {
|
|
398
|
+
missing(`Source table ${tableId} does not keep its inserted and deleted rows.`);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
354
401
|
const sourceCells = sourceTable.block.cells ?? [];
|
|
355
402
|
const outputCells = outputTable.block.cells ?? [];
|
|
356
403
|
if (sourceCells.length !== outputCells.length || sourceCells.some(({ row, col }, index) => outputCells[index]?.row !== row || outputCells[index]?.col !== col)) {
|
|
@@ -392,8 +439,11 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
392
439
|
const outputParagraph = outputNested[index];
|
|
393
440
|
if (outputParagraph === void 0 || templateParagraph.read === null || outputParagraph.read === null) return false;
|
|
394
441
|
if (slottedTemplateBlocks.has(templateParagraph)) return true;
|
|
442
|
+
if (emptiedTemplateBlocks.has(templateParagraph)) return outputParagraph.read.text === "" && outputParagraph.read.inlineObjects === 0;
|
|
395
443
|
const before = statedProperties(templateParagraph.element);
|
|
396
444
|
const after = statedProperties(outputParagraph.element);
|
|
445
|
+
const textKept = emptiedContents.get(templateParagraph);
|
|
446
|
+
if (textKept !== void 0) return sameStated(before, after) && outputParagraph.read.text === templateParagraph.read.text.slice(0, textKept);
|
|
397
447
|
const was = outputContent({
|
|
398
448
|
read: templateParagraph.read,
|
|
399
449
|
origin: "document",
|
|
@@ -406,7 +456,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
406
456
|
resources: outputResources,
|
|
407
457
|
styles: characterStyles
|
|
408
458
|
});
|
|
409
|
-
return before
|
|
459
|
+
return sameStated(before, after) && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
410
460
|
}))) issues.push({
|
|
411
461
|
code: "template-mismatch",
|
|
412
462
|
message: `Template block ${item.block.block.id} does not read as the template has it.`,
|
|
@@ -837,7 +887,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
837
887
|
if (bookmark !== null && !bookmarkNames.has(bookmark)) warnings.push(`A kept ${field.kind} field points at the bookmark ${bookmark}, which the output does not hold; its cached text is stale until fields update.`);
|
|
838
888
|
}
|
|
839
889
|
const keptToc = templateFields.filter(({ kind }) => kind === "TOC").length;
|
|
840
|
-
|
|
890
|
+
const emptiedToc = Math.min(keptToc, resolved.emptiedContents.size);
|
|
891
|
+
if (emptiedToc > 0) warnings.push(`${emptiedToc} table of contents field(s) show no entries until fields update: the template's cached entries were taken out.`);
|
|
892
|
+
if (keptToc > emptiedToc) warnings.push(`${keptToc - emptiedToc} table of contents field(s) keep the template's cached entries until fields update.`);
|
|
841
893
|
const keptTemplateIds = new Set(resolved.keptTemplateBlocks.map(({ block }) => block.id));
|
|
842
894
|
const frozenFields = [];
|
|
843
895
|
if (resolved.freezeKinds.size > 0) {
|
|
@@ -1001,6 +1053,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1001
1053
|
text,
|
|
1002
1054
|
emphasis,
|
|
1003
1055
|
...part === void 0 || part.strippedPrefix === "" ? {} : { strippedPrefix: part.strippedPrefix },
|
|
1056
|
+
...part === void 0 || part.droppedLead === null ? {} : { droppedLead: part.droppedLead },
|
|
1004
1057
|
...labelAsText === null ? {} : { labelAsText },
|
|
1005
1058
|
sourceLabel,
|
|
1006
1059
|
outputLabel
|
|
@@ -1054,6 +1107,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1054
1107
|
templateSha256: template.manifest.sha256,
|
|
1055
1108
|
outputSha256: out.manifest.sha256,
|
|
1056
1109
|
...source.manifest.trackedChangesResolved === void 0 ? {} : { trackedChanges: source.manifest.trackedChangesResolved },
|
|
1110
|
+
...source.manifest.trackedChangesKept === void 0 ? {} : { trackedChangesKept: source.manifest.trackedChangesKept },
|
|
1057
1111
|
blocks,
|
|
1058
1112
|
counts,
|
|
1059
1113
|
footnotes,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The on/off children of `w:settings` a caller may set without re-serializing the part. */
|
|
2
|
-
export type SettingsOnOffChild = "evenAndOddHeaders" | "updateFields";
|
|
2
|
+
export type SettingsOnOffChild = "evenAndOddHeaders" | "trackRevisions" | "updateFields";
|
|
3
3
|
/**
|
|
4
4
|
* Set (`true`), clear (`false`) or remove (`undefined`) one on/off child of
|
|
5
5
|
* `w:settings`, at its place in the schema's child order; the rest of the part
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
* grid differs from it, so a table without one reads back as it was written.
|
|
5
5
|
*/
|
|
6
6
|
import { document_d_exports } from "../types/document.js";
|
|
7
|
-
|
|
8
|
-
* The most grid columns a table declares. Far above what any editor lays out,
|
|
9
|
-
* it bounds a grid built from a source's skipped-column
|
|
10
|
-
* and span counts, which a file can state at any size.
|
|
11
|
-
*/
|
|
12
|
-
export declare const MAX_GRID_COLUMNS = 4096;
|
|
7
|
+
import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS } from "@stll/docx-core/model";
|
|
13
8
|
/**
|
|
14
9
|
* Columns the grid has to declare: the widest row's total of skipped columns
|
|
15
10
|
* and spans, because a grid narrower than a row leaves cells with no column
|
|
@@ -27,4 +22,5 @@ export declare const gridColumnCount: (table: document_d_exports.Table) => numbe
|
|
|
27
22
|
* accepts the reviewer's change without saying so. The schema declares it
|
|
28
23
|
* after every `w:gridCol`, so it is appended.
|
|
29
24
|
*/
|
|
30
|
-
export declare const modelTableGrid: (table: document_d_exports.Table) => string;
|
|
25
|
+
export declare const modelTableGrid: (table: document_d_exports.Table) => string;
|
|
26
|
+
export { MAX_GRID_COLUMNS };
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { intAttr } from "./serializer/xmlUtils.js";
|
|
2
|
+
import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS, gridColumnsInRows } from "@stll/docx-core/model";
|
|
2
3
|
// src/docx/tableGridXml.ts
|
|
3
4
|
/**
|
|
4
|
-
* The
|
|
5
|
-
* it
|
|
6
|
-
*
|
|
5
|
+
* The `w:tblGrid` a table's model writes when no capture stands in for it.
|
|
6
|
+
* The serializer writes it; the parser keeps a capture only when the source
|
|
7
|
+
* grid differs from it, so a table without one reads back as it was written.
|
|
7
8
|
*/
|
|
8
|
-
const MAX_GRID_COLUMNS = 4096;
|
|
9
9
|
/**
|
|
10
10
|
* Columns the grid has to declare: the widest row's total of skipped columns
|
|
11
11
|
* and spans, because a grid narrower than a row leaves cells with no column
|
|
12
12
|
* to sit in. At most {@link MAX_GRID_COLUMNS}.
|
|
13
13
|
*/
|
|
14
|
-
const gridColumnCount = (table) =>
|
|
15
|
-
let widest = 0;
|
|
16
|
-
for (const row of table.rows) {
|
|
17
|
-
let columns = (row.formatting?.gridBefore ?? 0) + (row.formatting?.gridAfter ?? 0);
|
|
18
|
-
for (const cell of row.cells) columns += cell.formatting?.gridSpan ?? 1;
|
|
19
|
-
widest = Math.max(widest, columns);
|
|
20
|
-
}
|
|
21
|
-
return Math.min(widest, MAX_GRID_COLUMNS);
|
|
22
|
-
};
|
|
14
|
+
const gridColumnCount = (table) => Math.min(gridColumnsInRows(table.rows), MAX_GRID_COLUMNS);
|
|
23
15
|
/**
|
|
24
16
|
* Serialize `w:tblGridChange`: the grid a reviewer replaced, from the change's
|
|
25
17
|
* own record rather than from the bytes it arrived as.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expectNoteMarkerAttrs } from "../../internal/noteMarkerAttrs.js";
|
|
1
2
|
import { measureParagraph } from "../../layout-engine/measure/measureParagraph.js";
|
|
2
3
|
import { getExactTableRowBottomMargins } from "../../layout-engine/measure/tableCellGrid.js";
|
|
3
4
|
import { layoutTextBoxContent } from "../../layout-engine/measure/textBoxParagraphLayout.js";
|
|
4
5
|
import { DEFAULT_TEXTBOX_MARGINS, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, isFloatingImageRun, resolveTableWidthPx } from "../../layout-engine/types.js";
|
|
6
|
+
import { markupViewSources } from "../../prosemirror/conversion/markupViewSource.js";
|
|
5
7
|
import { footnoteToProseDoc } from "../../prosemirror/conversion/toProseDoc.js";
|
|
6
8
|
import { projectStoryMarkupView } from "../../prosemirror/markupViewProjection.js";
|
|
7
9
|
import { remapMarkupViewBlocks } from "./markupViewFlow.js";
|
|
@@ -229,14 +231,38 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
229
231
|
if (options.justificationCompatibility) flowOptions.justificationCompatibility = options.justificationCompatibility;
|
|
230
232
|
if (options.tableIndentCompatibility) flowOptions.tableIndentCompatibility = options.tableIndentCompatibility;
|
|
231
233
|
if (options.automaticHyphenation) flowOptions.automaticHyphenation = options.automaticHyphenation;
|
|
234
|
+
const markupView = options.markupView ?? "all-markup";
|
|
235
|
+
const kind = noteReferenceKind(pmDoc);
|
|
236
|
+
if (markupView !== "all-markup" && kind !== void 0) {
|
|
237
|
+
const id = 0;
|
|
238
|
+
markupViewSources.set(pmDoc, {
|
|
239
|
+
document: { package: {
|
|
240
|
+
document: { content: [] },
|
|
241
|
+
...kind === "footnote" ? { footnotes: [{
|
|
242
|
+
type: kind,
|
|
243
|
+
id,
|
|
244
|
+
content
|
|
245
|
+
}] } : { endnotes: [{
|
|
246
|
+
type: kind,
|
|
247
|
+
id,
|
|
248
|
+
content
|
|
249
|
+
}] }
|
|
250
|
+
} },
|
|
251
|
+
story: {
|
|
252
|
+
kind,
|
|
253
|
+
id
|
|
254
|
+
},
|
|
255
|
+
options: proseOptions
|
|
256
|
+
});
|
|
257
|
+
}
|
|
232
258
|
const projection = projectStoryMarkupView({
|
|
233
259
|
doc: pmDoc,
|
|
234
|
-
markupView
|
|
260
|
+
markupView,
|
|
235
261
|
styles: options.styles,
|
|
236
262
|
numbering: options.numbering
|
|
237
263
|
});
|
|
238
264
|
const viewDoc = projection.type === "resolved" ? projection.doc : pmDoc;
|
|
239
|
-
const hasReferenceMark =
|
|
265
|
+
const hasReferenceMark = (viewDoc === pmDoc ? kind : noteReferenceKind(viewDoc)) !== void 0;
|
|
240
266
|
if (hasReferenceMark && referenceMarkText !== void 0) flowOptions.noteReferenceMarkText = referenceMarkText;
|
|
241
267
|
const converted = toFlowBlocks(viewDoc, flowOptions);
|
|
242
268
|
return {
|
|
@@ -244,14 +270,14 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
244
270
|
hasReferenceMark
|
|
245
271
|
};
|
|
246
272
|
}
|
|
247
|
-
function
|
|
248
|
-
let
|
|
273
|
+
function noteReferenceKind(doc) {
|
|
274
|
+
let kind;
|
|
249
275
|
doc.descendants((node) => {
|
|
250
|
-
if (
|
|
251
|
-
if (node.type.name === "noteMarker")
|
|
252
|
-
return
|
|
276
|
+
if (kind !== void 0) return false;
|
|
277
|
+
if (node.type.name === "noteMarker") kind = expectNoteMarkerAttrs(node).kind;
|
|
278
|
+
return kind === void 0;
|
|
253
279
|
});
|
|
254
|
-
return
|
|
280
|
+
return kind;
|
|
255
281
|
}
|
|
256
282
|
/** Restore an authored footnote line that the body-only terminal-table policy collapsed. */
|
|
257
283
|
function preserveAuthoredFootnoteTerminalParagraph(blocks) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { RevisionDecision } from "@stll/docx-core/ops";
|
|
4
|
+
import { StepMap } from "prosemirror-transform";
|
|
5
|
+
type CanonicalMarkupDocumentOptions = {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
decision: RevisionDecision;
|
|
8
|
+
};
|
|
9
|
+
type CanonicalMarkupDocument = {
|
|
10
|
+
doc: Node;
|
|
11
|
+
partial: boolean;
|
|
12
|
+
positionMap?: StepMap;
|
|
13
|
+
changeBarRanges?: readonly {
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
/** Resolve a copy of the authored model and project the selected review view. */
|
|
19
|
+
export declare const canonicalMarkupDocument: ({ state, decision }: CanonicalMarkupDocumentOptions) => CanonicalMarkupDocument;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { writableCopy } from "../types/documentModel.js";
|
|
2
|
+
import { proseDocToBlocks } from "./conversion/fromProseDoc.js";
|
|
3
|
+
import { markupViewSources, markupViewStateSources } from "./conversion/markupViewSource.js";
|
|
4
|
+
import { storyConversionOptions } from "./conversion/storyConversionOptions.js";
|
|
5
|
+
import { footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
6
|
+
import { projectDetachedText, projectIndependentMarkup } from "./independentMarkupProjection.js";
|
|
7
|
+
import { getStatedDocumentNumbering } from "./plugins/documentNumbering.js";
|
|
8
|
+
import { getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
9
|
+
import { styleResolverSource } from "./styles/styleResolver.js";
|
|
10
|
+
import { OP_STORIES, findStoryBody, resolvedMarkupDocumentView, sameStory } from "@stll/docx-core/ops";
|
|
11
|
+
// src/prosemirror/canonicalMarkupDocument.ts
|
|
12
|
+
const detachedModel = (state) => {
|
|
13
|
+
const numbering = getStatedDocumentNumbering(state);
|
|
14
|
+
const resolver = getDocumentStyleResolver(state);
|
|
15
|
+
const definitions = resolver === null ? void 0 : styleResolverSource(resolver);
|
|
16
|
+
const styles = definitions === void 0 ? void 0 : writableCopy(definitions);
|
|
17
|
+
return { package: {
|
|
18
|
+
document: { content: proseDocToBlocks(state.doc, void 0, styles) },
|
|
19
|
+
...numbering === null ? {} : { numbering },
|
|
20
|
+
...styles === void 0 ? {} : { styles }
|
|
21
|
+
} };
|
|
22
|
+
};
|
|
23
|
+
/** Resolve a copy of the authored model and project the selected review view. */
|
|
24
|
+
const canonicalMarkupDocument = ({ state, decision }) => {
|
|
25
|
+
const converted = markupViewStateSources.get(state) ?? markupViewSources.get(state.doc);
|
|
26
|
+
const authoritative = converted?.document;
|
|
27
|
+
if (authoritative === void 0) {
|
|
28
|
+
const detached = projectDetachedText(state.doc, decision);
|
|
29
|
+
if (detached !== void 0) return {
|
|
30
|
+
...detached,
|
|
31
|
+
partial: false
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const source = authoritative ?? detachedModel(state);
|
|
35
|
+
const resolved = resolvedMarkupDocumentView(source, decision);
|
|
36
|
+
const story = converted?.story ?? OP_STORIES.MAIN;
|
|
37
|
+
const partial = resolved.unresolved.some((unresolved) => sameStory(unresolved, story));
|
|
38
|
+
if (resolved.document === source) return {
|
|
39
|
+
doc: state.doc,
|
|
40
|
+
partial
|
|
41
|
+
};
|
|
42
|
+
if (story === OP_STORIES.MAIN) {
|
|
43
|
+
const projected = resolved.independentInline === void 0 ? void 0 : projectIndependentMarkup({
|
|
44
|
+
doc: state.doc,
|
|
45
|
+
changes: resolved.independentInline
|
|
46
|
+
});
|
|
47
|
+
if (projected !== void 0) return {
|
|
48
|
+
...projected,
|
|
49
|
+
partial
|
|
50
|
+
};
|
|
51
|
+
const projectedDoc = toProseDoc(resolved.document, converted?.options);
|
|
52
|
+
return {
|
|
53
|
+
doc: authoritative === void 0 ? state.doc.type.create(state.doc.attrs, projectedDoc.content) : projectedDoc,
|
|
54
|
+
partial
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const body = findStoryBody(resolved.document, story);
|
|
58
|
+
if (body === void 0) return {
|
|
59
|
+
doc: state.doc,
|
|
60
|
+
partial: true
|
|
61
|
+
};
|
|
62
|
+
const { styles: storyStyles, theme, numbering: storyNumbering } = resolved.document.package;
|
|
63
|
+
const options = converted?.options ?? storyConversionOptions({
|
|
64
|
+
styles: storyStyles,
|
|
65
|
+
theme,
|
|
66
|
+
numbering: storyNumbering
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
doc: story.kind === "header" || story.kind === "footer" ? headerFooterToProseDoc(body.content, options) : footnoteToProseDoc(body.content, options),
|
|
70
|
+
partial
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export { canonicalMarkupDocument };
|
|
@@ -19,7 +19,7 @@ export declare const withCanonicalTableAttributeCommand: (command: Command) => C
|
|
|
19
19
|
* command that would change the document has no such description.
|
|
20
20
|
*/
|
|
21
21
|
export declare const withCanonicalSelectionCommand: (command: Command) => Command;
|
|
22
|
-
/** A paragraph
|
|
22
|
+
/** A paragraph in a cell with a slot outside the columns being removed. */
|
|
23
23
|
export declare const tableAnchor: (rect: TableRect, avoid?: {
|
|
24
24
|
left: number;
|
|
25
25
|
right: number;
|
|
@@ -154,7 +154,7 @@ const withCanonicalSelectionCommand = (command) => withCanonicalCommand(command,
|
|
|
154
154
|
}) || transaction === void 0 || transaction.docChanged) return void 0;
|
|
155
155
|
return [{ type: "selection" }];
|
|
156
156
|
});
|
|
157
|
-
/** A paragraph
|
|
157
|
+
/** A paragraph in a cell with a slot outside the columns being removed. */
|
|
158
158
|
const tableAnchor = (rect, avoid = {
|
|
159
159
|
left: 0,
|
|
160
160
|
right: 0
|
|
@@ -166,8 +166,6 @@ const tableAnchor = (rect, avoid = {
|
|
|
166
166
|
if (offset === void 0) continue;
|
|
167
167
|
const cell = table.nodeAt(offset);
|
|
168
168
|
if (cell === null || cell.attrs["_omittedGridSlot"] != null) continue;
|
|
169
|
-
const cellRect = map.findCell(offset);
|
|
170
|
-
if (cellRect.left < avoid.right && cellRect.right > avoid.left) continue;
|
|
171
169
|
const at = firstParagraphPosition(cell, tableStart + offset);
|
|
172
170
|
if (at !== void 0) return at;
|
|
173
171
|
}
|