@stll/folio-core 0.75.0 → 0.76.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 +2 -1
- package/dist/ai-edits/headless.js +18 -12
- package/dist/ai-edits/pending-suggestions.js +2 -3
- package/dist/ai-edits/read.js +9 -3
- 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/canonicalPublicOperations.js +203 -71
- package/dist/canonical/canonicalSession.js +3 -1
- package/dist/controller/canonicalClipboard.d.ts +1 -1
- package/dist/controller/canonicalClipboard.js +71 -17
- 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/canonicalStructure.d.ts +1 -2
- package/dist/controller/canonicalStructure.js +51 -24
- package/dist/controller/fontReadiness.js +50 -23
- package/dist/controller/hiddenEditorManager.js +5 -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/server/templatePlan/apply.js +62 -8
- package/dist/docx/server/templatePlan/blocks.d.ts +55 -3
- package/dist/docx/server/templatePlan/blocks.js +182 -6
- package/dist/docx/server/templatePlan/builders.d.ts +16 -1
- package/dist/docx/server/templatePlan/builders.js +31 -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 +2 -1
- package/dist/docx/server/templatePlan/emit.js +44 -2
- 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 +12 -3
- package/dist/docx/server/templatePlan/plan.js +36 -12
- package/dist/docx/server/templatePlan/planShape.js +47 -22
- package/dist/docx/server/templatePlan/revisions.d.ts +46 -0
- package/dist/docx/server/templatePlan/revisions.js +407 -0
- package/dist/docx/server/templatePlan/story.d.ts +15 -1
- package/dist/docx/server/templatePlan/story.js +50 -2
- package/dist/docx/server/templatePlan/types.d.ts +217 -1
- package/dist/docx/server/templatePlan/verify.js +117 -8
- package/dist/docx/server/templatePlan/xml.d.ts +3 -0
- package/dist/docx/server/templatePlan/xml.js +4 -1
- package/dist/internal/revisionResolutionStep.d.ts +2 -31
- package/dist/internal/revisionResolutionStep.js +2 -171
- 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/commands/tableCellMergeResolution.d.ts +1 -11
- package/dist/prosemirror/commands/tableCellMergeResolution.js +3 -154
- 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/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 +2 -5
- package/dist/prosemirror/replacedAnnotations.js +1 -10
- 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/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 +1 -25
- package/dist/types/canonicalCapabilities.js +1 -23
- package/package.json +2 -2
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +0 -3
- package/dist/internal/headlessRevisionResolutionGuard.js +0 -18
|
@@ -2,10 +2,22 @@ import { parseFieldType } from "../../fieldParser.js";
|
|
|
2
2
|
import { readParagraphNumbering } from "../../numberingReference.js";
|
|
3
3
|
import { paraIdAttribute } from "../../paraIdAttribute.js";
|
|
4
4
|
import { getLocalName } from "../../xmlParser.js";
|
|
5
|
-
import { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, relationshipAttr, wAttr, wChild, wChildVal, wName } from "./xml.js";
|
|
5
|
+
import { MARKUP_COMPATIBILITY_NAMESPACE, MATH_NAMESPACE, elementChildren, relationshipAttr, twipsOrNull, wAttr, wChild, wChildVal, wName } from "./xml.js";
|
|
6
6
|
// src/docx/server/templatePlan/story.ts
|
|
7
7
|
/** The mark a footnote or endnote reference leaves in a block's text. */
|
|
8
8
|
const NOTE_REFERENCE_MARK = "";
|
|
9
|
+
/**
|
|
10
|
+
* Fields that print a number counted when the document is laid out and
|
|
11
|
+
* that hold no result: the number is text of the document that no cached
|
|
12
|
+
* text stands for, so the field itself is the content.
|
|
13
|
+
*/
|
|
14
|
+
const SELF_NUMBERING_FIELDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"AUTONUM",
|
|
16
|
+
"AUTONUMLGL",
|
|
17
|
+
"AUTONUMOUT"
|
|
18
|
+
]);
|
|
19
|
+
/** Whether a field kind prints a number of its own and caches no text. */
|
|
20
|
+
const isSelfNumberingField = (kind) => SELF_NUMBERING_FIELDS.has(kind);
|
|
9
21
|
const createStoryState = () => ({
|
|
10
22
|
fields: [],
|
|
11
23
|
open: [],
|
|
@@ -24,6 +36,21 @@ const endStory = (state) => {
|
|
|
24
36
|
state.strayFieldEnds += state.open.length;
|
|
25
37
|
state.open = [];
|
|
26
38
|
};
|
|
39
|
+
/** The sides of `w:ind` that count in characters of the document grid. */
|
|
40
|
+
const CHARACTER_INDENTS = [
|
|
41
|
+
"leftChars",
|
|
42
|
+
"startChars",
|
|
43
|
+
"hangingChars",
|
|
44
|
+
"firstLineChars"
|
|
45
|
+
];
|
|
46
|
+
/** The sides a `w:ind` states; a hanging indent is a negative first line. */
|
|
47
|
+
const ownIndent = (indent) => {
|
|
48
|
+
const hanging = twipsOrNull(wAttr(indent, "hanging"));
|
|
49
|
+
return {
|
|
50
|
+
left: twipsOrNull(wAttr(indent, "left") ?? wAttr(indent, "start")),
|
|
51
|
+
firstLine: hanging === null ? twipsOrNull(wAttr(indent, "firstLine")) : -hanging
|
|
52
|
+
};
|
|
53
|
+
};
|
|
27
54
|
const TOGGLE_OFF = /* @__PURE__ */ new Set([
|
|
28
55
|
"0",
|
|
29
56
|
"false",
|
|
@@ -241,6 +268,14 @@ const readRun = (run, walk, { link }) => {
|
|
|
241
268
|
top.field.kind = fieldKindOf(top.field.instruction);
|
|
242
269
|
top.field.endParagraphOrdinal = read.ordinal;
|
|
243
270
|
top.field.closed = true;
|
|
271
|
+
if (top.phase === "code" && isSelfNumberingField(top.field.kind)) pushAtom(walk, {
|
|
272
|
+
kind: "selfNumber",
|
|
273
|
+
text: "",
|
|
274
|
+
runProperties,
|
|
275
|
+
link,
|
|
276
|
+
element: null,
|
|
277
|
+
instruction: top.field.instruction.trim()
|
|
278
|
+
});
|
|
244
279
|
}
|
|
245
280
|
}
|
|
246
281
|
break;
|
|
@@ -298,6 +333,14 @@ const readInline = (container, walk, context) => {
|
|
|
298
333
|
readInline(child, walk, context);
|
|
299
334
|
state.open.pop();
|
|
300
335
|
field.closed = true;
|
|
336
|
+
if (field.result === "" && isSelfNumberingField(field.kind)) pushAtom(walk, {
|
|
337
|
+
kind: "selfNumber",
|
|
338
|
+
text: "",
|
|
339
|
+
runProperties: null,
|
|
340
|
+
link: context.link,
|
|
341
|
+
element: null,
|
|
342
|
+
instruction: field.instruction.trim()
|
|
343
|
+
});
|
|
301
344
|
} else if (REVISION_INCLUDED.has(name)) {
|
|
302
345
|
state.trackedChanges += 1;
|
|
303
346
|
readInline(child, walk, context);
|
|
@@ -345,6 +388,11 @@ const readParagraph = (element, state) => {
|
|
|
345
388
|
hasSectionBreak: wChild(properties, "sectPr") !== null,
|
|
346
389
|
pageBreakBefore: toggleOf(wChild(properties, "pageBreakBefore")),
|
|
347
390
|
alignment: wChildVal(properties, "jc"),
|
|
391
|
+
indent: ownIndent(wChild(properties, "ind")),
|
|
392
|
+
indentInCharacters: CHARACTER_INDENTS.some((name) => {
|
|
393
|
+
const value = wAttr(wChild(properties, "ind"), name);
|
|
394
|
+
return value !== null && !/^[+-]?0*$/u.test(value.trim());
|
|
395
|
+
}),
|
|
348
396
|
hasTrackedMark
|
|
349
397
|
};
|
|
350
398
|
state.paragraphOrdinal += 1;
|
|
@@ -447,4 +495,4 @@ const walkBlocks = (container, visitor, depth = 0) => {
|
|
|
447
495
|
} else if (name === null || !IGNORED_BLOCK_CHILDREN.has(name)) visitor.unread(child);
|
|
448
496
|
}
|
|
449
497
|
};
|
|
450
|
-
export { NOTE_REFERENCE_MARK, createStoryState, endStory, readParagraph, toggleOf, walkBlocks };
|
|
498
|
+
export { NOTE_REFERENCE_MARK, createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks };
|
|
@@ -17,6 +17,17 @@ export type DocxBlockNumbering = {
|
|
|
17
17
|
numId: number;
|
|
18
18
|
ilvl: number;
|
|
19
19
|
abstractNumId: number;
|
|
20
|
+
/**
|
|
21
|
+
* The level prints a bullet: its label is a mark, whatever character
|
|
22
|
+
* stands for it (a font's `o` as much as a dot), and no designator.
|
|
23
|
+
*/
|
|
24
|
+
bullet?: true;
|
|
25
|
+
/**
|
|
26
|
+
* The text face a bullet's mark is a character of, when the level names
|
|
27
|
+
* one: set in another face the mark is another shape, so a level that
|
|
28
|
+
* prints it elsewhere needs the face too.
|
|
29
|
+
*/
|
|
30
|
+
bulletFont?: string;
|
|
20
31
|
};
|
|
21
32
|
export type DocxTableCell = {
|
|
22
33
|
row: number;
|
|
@@ -55,6 +66,13 @@ export type DocxBlock = {
|
|
|
55
66
|
* without text can hold one: it is then all that starts the next page.
|
|
56
67
|
*/
|
|
57
68
|
pageBreaks?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Offsets in `text` at which the paragraph holds a field that numbers
|
|
71
|
+
* itself (`AUTONUM`, `AUTONUMLGL`, `AUTONUMOUT`), when it holds any. The
|
|
72
|
+
* number such a field prints is in no text: `Annex - Summary` with one at
|
|
73
|
+
* offset 6 reads `Annex 1 - Summary` on the page.
|
|
74
|
+
*/
|
|
75
|
+
selfNumbers?: number[];
|
|
58
76
|
/**
|
|
59
77
|
* The paragraph starts on a new page by its own formatting or its
|
|
60
78
|
* style's (`w:pageBreakBefore`). A plan carries it over with an item's
|
|
@@ -73,6 +91,19 @@ export type DocxBlock = {
|
|
|
73
91
|
* Absent when neither states one.
|
|
74
92
|
*/
|
|
75
93
|
alignment?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The paragraph's indent in effect, in twentieths of a point: `left` is
|
|
96
|
+
* where its lines start, `firstLine` what its first line adds to that
|
|
97
|
+
* (negative for a hanging indent). Each side is the paragraph's own, else
|
|
98
|
+
* its list level's and its style's with inheritance resolved: the
|
|
99
|
+
* level's first where the paragraph names its list itself, the style's
|
|
100
|
+
* first where the style brings the list. Absent when none of them states
|
|
101
|
+
* an indent.
|
|
102
|
+
*/
|
|
103
|
+
indent?: {
|
|
104
|
+
left: number;
|
|
105
|
+
firstLine: number;
|
|
106
|
+
};
|
|
76
107
|
/** Table only: its cells in row order. */
|
|
77
108
|
cells?: DocxTableCell[];
|
|
78
109
|
/** Table only: every block inside the table in document order. */
|
|
@@ -131,8 +162,44 @@ export type DocxBlockManifest = {
|
|
|
131
162
|
comments: number;
|
|
132
163
|
/** Tracked insertions, deletions and moves in the main story and its notes. */
|
|
133
164
|
trackedChanges: number;
|
|
165
|
+
/**
|
|
166
|
+
* What the document tracks, when it tracks anything: for a caller that
|
|
167
|
+
* has to choose a view. Absent from a manifest read in a chosen view,
|
|
168
|
+
* which tracks nothing any more.
|
|
169
|
+
*/
|
|
170
|
+
revisions?: DocxTrackedChanges;
|
|
171
|
+
/**
|
|
172
|
+
* The view the manifest was read in and what was resolved for it, when
|
|
173
|
+
* the caller chose one: every block, label and hash is that view's.
|
|
174
|
+
*/
|
|
175
|
+
trackedChangesResolved?: DocxTrackedChanges & {
|
|
176
|
+
view: TemplatePlanTrackedView;
|
|
177
|
+
};
|
|
134
178
|
warnings: string[];
|
|
135
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* One of the two texts a document with tracked changes holds: with every
|
|
182
|
+
* change accepted, or with every change rejected.
|
|
183
|
+
*/
|
|
184
|
+
export type TemplatePlanTrackedView = "accept" | "reject";
|
|
185
|
+
/** The tracked changes of a document's main story and notes, by kind. */
|
|
186
|
+
export type DocxTrackedChanges = {
|
|
187
|
+
insertions: number;
|
|
188
|
+
deletions: number;
|
|
189
|
+
/** Move sources and destinations. */
|
|
190
|
+
moves: number;
|
|
191
|
+
/** Paragraph marks the chosen view removes, each joining two paragraphs;
|
|
192
|
+
* counted for the accepted view where none was chosen. */
|
|
193
|
+
paragraphMarks: number;
|
|
194
|
+
/** Table rows the view removes. */
|
|
195
|
+
tableRows: number;
|
|
196
|
+
/** Recorded changes of formatting. */
|
|
197
|
+
formattingChanges: number;
|
|
198
|
+
authors: string[];
|
|
199
|
+
/** The earliest and the latest date a change states, as written. */
|
|
200
|
+
first: string | null;
|
|
201
|
+
last: string | null;
|
|
202
|
+
};
|
|
136
203
|
export type DocxTemplateStyle = {
|
|
137
204
|
styleId: string;
|
|
138
205
|
name: string | null;
|
|
@@ -149,6 +216,29 @@ export type DocxTemplateStyle = {
|
|
|
149
216
|
* null when neither the style nor one it is based on states one.
|
|
150
217
|
*/
|
|
151
218
|
alignment: string | null;
|
|
219
|
+
/**
|
|
220
|
+
* Whether the style sets its text in bold (`w:b`), inheritance and the
|
|
221
|
+
* document's defaults resolved.
|
|
222
|
+
*/
|
|
223
|
+
bold: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* The font size the style gives its text, in half-points (`w:sz`),
|
|
226
|
+
* inheritance and the document's defaults resolved; null when none of
|
|
227
|
+
* them states one.
|
|
228
|
+
*/
|
|
229
|
+
size: number | null;
|
|
230
|
+
/**
|
|
231
|
+
* Whether the style keeps its paragraph on the page of the next one
|
|
232
|
+
* (`w:keepNext`), inheritance and the document's defaults resolved.
|
|
233
|
+
*/
|
|
234
|
+
keepNext: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* The left indent the style gives its paragraphs, in twentieths of a
|
|
237
|
+
* point (`w:ind`), inheritance and the document's defaults resolved; null
|
|
238
|
+
* when none of them states one. A style bound to a list takes the indent
|
|
239
|
+
* of its level where it states none itself.
|
|
240
|
+
*/
|
|
241
|
+
indentLeft: number | null;
|
|
152
242
|
isDefault: boolean;
|
|
153
243
|
};
|
|
154
244
|
export type DocxTemplateNumberingLevel = {
|
|
@@ -206,6 +296,31 @@ export type DocxTemplateSection = DocxSection & {
|
|
|
206
296
|
part: string | null;
|
|
207
297
|
}[];
|
|
208
298
|
};
|
|
299
|
+
/**
|
|
300
|
+
* A text effect of the `w14` extension. One whose values show nothing can still change
|
|
301
|
+
* how a consumer treats the text: a run with a 3-D scene, even the default
|
|
302
|
+
* one, is drawn as a picture.
|
|
303
|
+
*/
|
|
304
|
+
export type DocxTextEffect = "glow" | "shadow" | "reflection" | "textOutline" | "textFill" | "scene3d" | "props3d";
|
|
305
|
+
/** What the run properties an effect stands in belong to. */
|
|
306
|
+
export type DocxTextEffectOwner = {
|
|
307
|
+
kind: "level";
|
|
308
|
+
abstractNumId: number | null;
|
|
309
|
+
ilvl: number | null;
|
|
310
|
+
} | {
|
|
311
|
+
kind: "style";
|
|
312
|
+
styleId: string | null;
|
|
313
|
+
} | {
|
|
314
|
+
kind: "defaults";
|
|
315
|
+
} | {
|
|
316
|
+
kind: "text";
|
|
317
|
+
};
|
|
318
|
+
/** A text effect of a template whose values show nothing. */
|
|
319
|
+
export type DocxTemplateInvisibleEffect = {
|
|
320
|
+
part: string;
|
|
321
|
+
effect: DocxTextEffect;
|
|
322
|
+
owner: DocxTextEffectOwner;
|
|
323
|
+
};
|
|
209
324
|
export type DocxTemplateBookmark = {
|
|
210
325
|
name: string;
|
|
211
326
|
id: string;
|
|
@@ -217,6 +332,12 @@ export type DocxTemplateInspection = Omit<DocxBlockManifest, "sections"> & {
|
|
|
217
332
|
fields: DocxTemplateField[];
|
|
218
333
|
sections: DocxTemplateSection[];
|
|
219
334
|
bookmarks: DocxTemplateBookmark[];
|
|
335
|
+
/**
|
|
336
|
+
* Text effects that show nothing, in the document, its numbering, its
|
|
337
|
+
* styles, its headers and its footers. A plan's output is written without
|
|
338
|
+
* them unless the plan says otherwise.
|
|
339
|
+
*/
|
|
340
|
+
invisibleEffects: DocxTemplateInvisibleEffect[];
|
|
220
341
|
};
|
|
221
342
|
export type TemplatePlanOmitReason = "empty" | "sourceToc" | "pageArtifact" | "duplicateLabel";
|
|
222
343
|
/**
|
|
@@ -235,6 +356,16 @@ export type TemplatePlanNumbering = {
|
|
|
235
356
|
group?: string;
|
|
236
357
|
};
|
|
237
358
|
export type TemplatePlanMerge = "lineBreak" | "space" | "none";
|
|
359
|
+
/**
|
|
360
|
+
* A paragraph's own indent, in twentieths of a point (`w:ind`). A side left
|
|
361
|
+
* out stays what the style or the list level gives; a hanging indent and a
|
|
362
|
+
* first-line indent exclude each other.
|
|
363
|
+
*/
|
|
364
|
+
export type TemplatePlanIndent = {
|
|
365
|
+
left?: number;
|
|
366
|
+
hanging?: number;
|
|
367
|
+
firstLine?: number;
|
|
368
|
+
};
|
|
238
369
|
export type TemplatePlanNestedParagraph = {
|
|
239
370
|
blockId: string;
|
|
240
371
|
styleId?: string;
|
|
@@ -242,7 +373,17 @@ export type TemplatePlanNestedParagraph = {
|
|
|
242
373
|
stripLabel?: string;
|
|
243
374
|
/** As on a source item. */
|
|
244
375
|
labelAsText?: boolean;
|
|
376
|
+
/** As on a source item. */
|
|
377
|
+
keepNext?: boolean;
|
|
378
|
+
/** As on a source item. */
|
|
379
|
+
indent?: TemplatePlanIndent;
|
|
380
|
+
/** As on a source item. */
|
|
381
|
+
tabStops?: number[];
|
|
382
|
+
/** As on a source item. */
|
|
383
|
+
alignment?: TemplatePlanAlignment;
|
|
245
384
|
};
|
|
385
|
+
/** How a paragraph's lines are set between the margins (`w:jc`). */
|
|
386
|
+
export type TemplatePlanAlignment = "left" | "center" | "right" | "both";
|
|
246
387
|
/** A page other than the template's, in twentieths of a point. */
|
|
247
388
|
export type TemplatePlanSectionPage = {
|
|
248
389
|
orientation: "portrait" | "landscape";
|
|
@@ -280,6 +421,14 @@ export type TemplatePlanSourceItem = {
|
|
|
280
421
|
numbering?: TemplatePlanNumbering | null;
|
|
281
422
|
/** The manual label at the start of the block to remove, with the space after it. */
|
|
282
423
|
stripLabel?: string;
|
|
424
|
+
/**
|
|
425
|
+
* With `stripLabel`: a line break that follows the label goes with it,
|
|
426
|
+
* and the space around that break. For a heading the source breaks behind
|
|
427
|
+
* its number where the template sets number and title on one line: the
|
|
428
|
+
* list then parts the two as its level says. Left out, a line break
|
|
429
|
+
* behind the label stays the first character of the paragraph.
|
|
430
|
+
*/
|
|
431
|
+
stripLabelBreak?: boolean;
|
|
283
432
|
/**
|
|
284
433
|
* Write the block's automatic label as text at the start of its text, with
|
|
285
434
|
* the tab or space its list puts after it: for a label no list of the
|
|
@@ -302,6 +451,34 @@ export type TemplatePlanSourceItem = {
|
|
|
302
451
|
* Verification compares what the paragraph states for itself.
|
|
303
452
|
*/
|
|
304
453
|
pageBreakBefore?: boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Keep the paragraph on the page of the one after it (`w:keepNext`): for
|
|
456
|
+
* a line that heads what follows in a style that does not say so. Not
|
|
457
|
+
* for a table, and not for a block that joins the paragraph before it.
|
|
458
|
+
* `false` is the same as leaving it out.
|
|
459
|
+
*/
|
|
460
|
+
keepNext?: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* The paragraph's own indent, over its style's and its list level's:
|
|
463
|
+
* for a number written as text that hangs the way the list's would. Not
|
|
464
|
+
* for a table, and not for a block that joins the paragraph before it.
|
|
465
|
+
*/
|
|
466
|
+
indent?: TemplatePlanIndent;
|
|
467
|
+
/**
|
|
468
|
+
* The paragraph's own left tab stops, in twentieths of a point from the
|
|
469
|
+
* left margin and in ascending order (`w:tabs`): for a line of a label, a
|
|
470
|
+
* tab and a value whose values are to start at one position. They are
|
|
471
|
+
* added to the stops of the paragraph's style, as tab stops are in the
|
|
472
|
+
* format: a stop the style sets in front of them still ends a tab. Not
|
|
473
|
+
* for a table.
|
|
474
|
+
*/
|
|
475
|
+
tabStops?: number[];
|
|
476
|
+
/**
|
|
477
|
+
* The paragraph's own alignment (`w:jc`), over the one its style states:
|
|
478
|
+
* for a line the document sets by itself, such as the text of a table
|
|
479
|
+
* cell or a centred line under a title. Not for a table.
|
|
480
|
+
*/
|
|
481
|
+
alignment?: TemplatePlanAlignment;
|
|
305
482
|
/**
|
|
306
483
|
* The paragraph is the last of a section, described here: for a part of
|
|
307
484
|
* the document whose page is another than the template's, such as a
|
|
@@ -330,6 +507,11 @@ export type TemplatePlanNumberingPatch = {
|
|
|
330
507
|
lvlText?: string;
|
|
331
508
|
start?: number;
|
|
332
509
|
suff?: "tab" | "space" | "nothing";
|
|
510
|
+
/**
|
|
511
|
+
* The face the level's label is set in. Whatever else the level's run
|
|
512
|
+
* properties state is kept.
|
|
513
|
+
*/
|
|
514
|
+
font?: string;
|
|
333
515
|
/**
|
|
334
516
|
* The paragraph indent the level gives, in twentieths of a point. A value
|
|
335
517
|
* left out keeps what the level states; `hanging` and `firstLine` exclude
|
|
@@ -393,6 +575,27 @@ export type TemplatePlan = {
|
|
|
393
575
|
* stands.
|
|
394
576
|
*/
|
|
395
577
|
lastSection?: TemplatePlanSection;
|
|
578
|
+
/**
|
|
579
|
+
* The view of a source with tracked changes the plan is made for: its
|
|
580
|
+
* text with every change accepted, or with every change rejected. The
|
|
581
|
+
* blocks and hashes the plan names are that view's, the output carries
|
|
582
|
+
* no revision, and verification holds it to that view. Left out, a
|
|
583
|
+
* source with tracked changes is refused.
|
|
584
|
+
*/
|
|
585
|
+
trackedChanges?: TemplatePlanTrackedView;
|
|
586
|
+
/**
|
|
587
|
+
* What becomes of text effects whose values show nothing, in the parts
|
|
588
|
+
* the output takes from the template: its document, numbering, styles,
|
|
589
|
+
* headers and footers. `normalize`, the default, leaves them out, so text
|
|
590
|
+
* that looked plain is written as text everywhere; an effect that shows
|
|
591
|
+
* anything is never touched. `keep` writes those parts as they are.
|
|
592
|
+
*/
|
|
593
|
+
textEffects?: "normalize" | "keep";
|
|
594
|
+
};
|
|
595
|
+
export type TemplatePlanEffectCount = {
|
|
596
|
+
part: string;
|
|
597
|
+
effect: DocxTextEffect;
|
|
598
|
+
count: number;
|
|
396
599
|
};
|
|
397
600
|
export type TemplatePlanBlockResult = {
|
|
398
601
|
/** The source block. */
|
|
@@ -453,7 +656,7 @@ export type TemplatePlanFieldLeftover = {
|
|
|
453
656
|
count: number;
|
|
454
657
|
};
|
|
455
658
|
export type TemplatePlanIssue = {
|
|
456
|
-
code: "text-mismatch" | "emphasis-mismatch" | "note-mismatch" | "block-missing" | "reference-broken" | "bookmark-dangling" | "field-unbalanced" | "relationship-dangling" | "note-dangling" | "numbering-dangling" | "style-dangling" | "style-mismatch" | "numbering-mismatch" | "page-start-mismatch" | "section-mismatch" | "template-mismatch" | "prompting-field-left" | "field-not-frozen" | "update-fields-mismatch" | "compat-mismatch" | "conformance";
|
|
659
|
+
code: "text-mismatch" | "emphasis-mismatch" | "note-mismatch" | "block-missing" | "reference-broken" | "bookmark-dangling" | "field-unbalanced" | "relationship-dangling" | "note-dangling" | "numbering-dangling" | "style-dangling" | "style-mismatch" | "numbering-mismatch" | "page-start-mismatch" | "paragraph-format-mismatch" | "revision-left" | "section-mismatch" | "template-mismatch" | "prompting-field-left" | "field-not-frozen" | "update-fields-mismatch" | "compat-mismatch" | "conformance";
|
|
457
660
|
message: string;
|
|
458
661
|
blockId?: string;
|
|
459
662
|
part?: string;
|
|
@@ -465,6 +668,11 @@ export type TemplatePlanReport = {
|
|
|
465
668
|
sourceSha256: string;
|
|
466
669
|
templateSha256: string;
|
|
467
670
|
outputSha256: string;
|
|
671
|
+
/** The view the plan chose of a source with tracked changes, and what
|
|
672
|
+
* was resolved for it. */
|
|
673
|
+
trackedChanges?: DocxTrackedChanges & {
|
|
674
|
+
view: TemplatePlanTrackedView;
|
|
675
|
+
};
|
|
468
676
|
/** One entry per block of the source, nested ones included, in document order. */
|
|
469
677
|
blocks: TemplatePlanBlockResult[];
|
|
470
678
|
counts: {
|
|
@@ -530,6 +738,14 @@ export type TemplatePlanReport = {
|
|
|
530
738
|
internalHyperlinks: number;
|
|
531
739
|
sectionBreaks: number;
|
|
532
740
|
};
|
|
741
|
+
/**
|
|
742
|
+
* Text effects that show nothing: those of the template the output does
|
|
743
|
+
* not carry, and those it still does.
|
|
744
|
+
*/
|
|
745
|
+
textEffects: {
|
|
746
|
+
removed: TemplatePlanEffectCount[];
|
|
747
|
+
left: TemplatePlanEffectCount[];
|
|
748
|
+
};
|
|
533
749
|
updateFields: "set" | "cleared" | "unchanged";
|
|
534
750
|
conformance: {
|
|
535
751
|
status: "conformant" | "invalid" | "indeterminate";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isNumberingReference } from "../../numberingReference.js";
|
|
2
2
|
import { parseSettings } from "../../settingsParser.js";
|
|
3
3
|
import { validateDocxConformance } from "../validateDocxConformance.js";
|
|
4
|
-
import { analyzeDocument } from "./blocks.js";
|
|
4
|
+
import { analyzeDocument, analyzeSource, viewOf } from "./blocks.js";
|
|
5
5
|
import { applyRefCaseFormat, fieldBookmarkOf, keepsShiftReturnSpacing, refCaseFormat } from "./builders.js";
|
|
6
|
+
import { countEffects, findInvisibleEffects } from "./effects.js";
|
|
6
7
|
import { linkAddress, linkAddressKey, templateCharacterStyles } from "./emit.js";
|
|
7
8
|
import { emphasisSignature, readDirectEmphasis, signatureHighlight, signatureWithoutHighlight } from "./emphasis.js";
|
|
8
9
|
import { partFields, readHeaderFooterParts } from "./inspect.js";
|
|
@@ -10,8 +11,8 @@ import { styleNumbering } from "./labels.js";
|
|
|
10
11
|
import { guarded, readPartText } from "./package.js";
|
|
11
12
|
import { hyperlinkFieldLink, paragraphPieces, piecesContent, resolvePlan, segmentPieces } from "./plan.js";
|
|
12
13
|
import { objectFingerprint, objectTargets, readStoryResources, relationshipIdsOf } from "./resources.js";
|
|
13
|
-
import { createStoryState, endStory, readParagraph, toggleOf, walkBlocks } from "./story.js";
|
|
14
|
-
import { integerOrNull, isW, readRawPart, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
14
|
+
import { createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks } from "./story.js";
|
|
15
|
+
import { integerOrNull, isW, rangeOf, readRawPart, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
15
16
|
import { Result } from "better-result";
|
|
16
17
|
// src/docx/server/templatePlan/verify.ts
|
|
17
18
|
/**
|
|
@@ -46,7 +47,7 @@ const emptyContent = () => ({
|
|
|
46
47
|
links: [],
|
|
47
48
|
marks: []
|
|
48
49
|
});
|
|
49
|
-
const appendUnit = (content, { kind, text, signature, link, element, origin }, resources) => {
|
|
50
|
+
const appendUnit = (content, { kind, text, signature, link, element, instruction, origin }, resources) => {
|
|
50
51
|
content.text += text;
|
|
51
52
|
for (let unit = 0; unit < text.length; unit += 1) {
|
|
52
53
|
content.signatures.push(signature);
|
|
@@ -54,6 +55,7 @@ const appendUnit = (content, { kind, text, signature, link, element, origin }, r
|
|
|
54
55
|
}
|
|
55
56
|
const at = content.text.length - text.length;
|
|
56
57
|
if (kind === "pageBreak") content.marks.push(`${at}:break:${wAttr(element, "type") ?? "page"}`);
|
|
58
|
+
else if (kind === "selfNumber") content.marks.push(`${at}:number:${instruction ?? ""}`);
|
|
57
59
|
else if (kind === "object" && element !== null) content.marks.push(`${at}:object:${objectFingerprint(element)}:${objectTargets(element, origin, resources).join(",")}`);
|
|
58
60
|
};
|
|
59
61
|
/** A paragraph break inside a note. */
|
|
@@ -70,6 +72,7 @@ const expectedContent = (pieces, resources, content = emptyContent()) => {
|
|
|
70
72
|
signature: piece.signature,
|
|
71
73
|
link: linkAddressKey(linkAddress(piece.link, resources.relationships[piece.origin])),
|
|
72
74
|
element: piece.atom?.element ?? null,
|
|
75
|
+
instruction: piece.atom?.instruction ?? null,
|
|
73
76
|
origin: piece.origin
|
|
74
77
|
}, resources);
|
|
75
78
|
return content;
|
|
@@ -95,6 +98,7 @@ const outputContent = ({ read, origin, resources, styles, content = emptyContent
|
|
|
95
98
|
signature: styleId === null || styleId === expectedStyle ? stated : `${stated};rStyle=${styleId}`,
|
|
96
99
|
link,
|
|
97
100
|
element: atom.element,
|
|
101
|
+
instruction: atom.instruction ?? null,
|
|
98
102
|
origin
|
|
99
103
|
}, resources);
|
|
100
104
|
}
|
|
@@ -198,14 +202,37 @@ const CONFORMANCE_RANK = {
|
|
|
198
202
|
invalid: 0
|
|
199
203
|
};
|
|
200
204
|
const NUMBER_SWITCH = /\\[nrw]\b/u;
|
|
205
|
+
const tabStopsKey = (tabs) => tabs === null ? null : wChildren(tabs, "tab").map((tab) => `${wAttr(tab, "val") ?? ""}@${String(twipsOrNull(wAttr(tab, "pos")) ?? wAttr(tab, "pos"))}${wAttr(tab, "leader") === null ? "" : `;${wAttr(tab, "leader") ?? ""}`}`).join(",");
|
|
206
|
+
const indentKey = (left, hanging, firstLine) => [
|
|
207
|
+
left,
|
|
208
|
+
hanging,
|
|
209
|
+
firstLine
|
|
210
|
+
].map((side) => side ?? "").join(":");
|
|
211
|
+
/** The sides of an indent counted in characters: they override the
|
|
212
|
+
* measured ones, so a paragraph that states one is another paragraph. */
|
|
213
|
+
const CHARACTER_INDENTS = [
|
|
214
|
+
"leftChars",
|
|
215
|
+
"startChars",
|
|
216
|
+
"hangingChars",
|
|
217
|
+
"firstLineChars"
|
|
218
|
+
];
|
|
219
|
+
const characterIndentKey = (indent) => CHARACTER_INDENTS.flatMap((name) => {
|
|
220
|
+
const value = wAttr(indent, name);
|
|
221
|
+
return value === null ? [] : [`;${name}=${value}`];
|
|
222
|
+
}).join("");
|
|
201
223
|
const statedProperties = (paragraph) => {
|
|
202
224
|
const properties = wChild(paragraph, "pPr");
|
|
203
225
|
const numbering = wChild(properties, "numPr");
|
|
226
|
+
const indent = wChild(properties, "ind");
|
|
204
227
|
return {
|
|
205
228
|
styleId: wChildVal(properties, "pStyle"),
|
|
206
229
|
numId: integerOrNull(wChildVal(numbering, "numId")),
|
|
207
230
|
ilvl: integerOrNull(wChildVal(numbering, "ilvl")),
|
|
208
231
|
pageBreakBefore: toggleOf(wChild(properties, "pageBreakBefore")) === true,
|
|
232
|
+
keepNext: toggleOf(wChild(properties, "keepNext")) === true,
|
|
233
|
+
indent: indent === null ? null : `${indentKey(twipsOrNull(wAttr(indent, "left") ?? wAttr(indent, "start")), twipsOrNull(wAttr(indent, "hanging")), twipsOrNull(wAttr(indent, "firstLine")))}${characterIndentKey(indent)}`,
|
|
234
|
+
tabStops: tabStopsKey(wChild(properties, "tabs")),
|
|
235
|
+
alignment: wChildVal(properties, "jc"),
|
|
209
236
|
endsSection: wChild(properties, "sectPr") !== null
|
|
210
237
|
};
|
|
211
238
|
};
|
|
@@ -228,6 +255,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
228
255
|
if (Result.isError(analyzedOutput)) return analyzedOutput;
|
|
229
256
|
const out = analyzedOutput.value;
|
|
230
257
|
const issues = [];
|
|
258
|
+
if (source.manifest.trackedChangesResolved !== void 0 && out.manifest.trackedChanges > 0) issues.push({
|
|
259
|
+
code: "revision-left",
|
|
260
|
+
message: `The output holds ${String(out.manifest.trackedChanges)} tracked change(s).`
|
|
261
|
+
});
|
|
231
262
|
const warnings = [...source.manifest.warnings.map((warning) => `Source: ${warning}`), ...out.story.warnings];
|
|
232
263
|
const sourceResourcesRead = await readStoryResources(source);
|
|
233
264
|
if (Result.isError(sourceResourcesRead)) return sourceResourcesRead;
|
|
@@ -246,13 +277,19 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
246
277
|
const plannedProperties = (paragraph) => {
|
|
247
278
|
const slot = slotBlocks.get(paragraph);
|
|
248
279
|
if (slot !== void 0) return statedProperties(slot.element);
|
|
249
|
-
const { styleId, numbering, pageBreakBefore } = paragraph;
|
|
280
|
+
const { styleId, numbering, pageBreakBefore, keepNext, alignment } = paragraph;
|
|
250
281
|
const endsSection = paragraph.endsSection !== null;
|
|
282
|
+
const indent = paragraph.indent === null ? null : indentKey(paragraph.indent.left, paragraph.indent.hanging, paragraph.indent.firstLine);
|
|
283
|
+
const tabStops = paragraph.tabStops === null ? null : paragraph.tabStops.map((stop) => `left@${String(stop)}`).join(",");
|
|
251
284
|
if (numbering.kind === "direct") return {
|
|
252
285
|
styleId,
|
|
253
286
|
numId: numbering.numId,
|
|
254
287
|
ilvl: numbering.ilvl,
|
|
255
288
|
pageBreakBefore,
|
|
289
|
+
keepNext,
|
|
290
|
+
indent,
|
|
291
|
+
tabStops,
|
|
292
|
+
alignment,
|
|
256
293
|
endsSection
|
|
257
294
|
};
|
|
258
295
|
return {
|
|
@@ -260,6 +297,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
260
297
|
numId: numbering.kind === "none" && styleNumbering(styleId ?? template.defaultStyleId, template.styles, template.numbering)?.kind === "reference" ? 0 : null,
|
|
261
298
|
ilvl: null,
|
|
262
299
|
pageBreakBefore,
|
|
300
|
+
keepNext,
|
|
301
|
+
indent,
|
|
302
|
+
tabStops,
|
|
303
|
+
alignment,
|
|
263
304
|
endsSection
|
|
264
305
|
};
|
|
265
306
|
};
|
|
@@ -279,6 +320,11 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
279
320
|
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.`,
|
|
280
321
|
blockId
|
|
281
322
|
});
|
|
323
|
+
if (stated.keepNext !== planned.keepNext || stated.indent !== planned.indent || stated.tabStops !== planned.tabStops || stated.alignment !== planned.alignment) issues.push({
|
|
324
|
+
code: "paragraph-format-mismatch",
|
|
325
|
+
message: `Block ${blockId} does not carry the keep-with-next, the indent, the tab stops or the alignment the plan gives it.`,
|
|
326
|
+
blockId
|
|
327
|
+
});
|
|
282
328
|
if (stated.endsSection !== planned.endsSection) issues.push({
|
|
283
329
|
code: "section-mismatch",
|
|
284
330
|
message: planned.endsSection ? `Block ${blockId} does not end the section the plan gives it.` : `Block ${blockId} ends a section the plan does not give it.`,
|
|
@@ -360,7 +406,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
360
406
|
resources: outputResources,
|
|
361
407
|
styles: characterStyles
|
|
362
408
|
});
|
|
363
|
-
return before.styleId === after.styleId && before.pageBreakBefore === after.pageBreakBefore && before.endsSection === after.endsSection && before.numId === after.numId && before.ilvl === after.ilvl && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
409
|
+
return 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.endsSection === after.endsSection && before.numId === after.numId && before.ilvl === after.ilvl && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
364
410
|
}))) issues.push({
|
|
365
411
|
code: "template-mismatch",
|
|
366
412
|
message: `Template block ${item.block.block.id} does not read as the template has it.`,
|
|
@@ -631,6 +677,18 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
631
677
|
lvlText: patch.lvlText
|
|
632
678
|
};
|
|
633
679
|
for (const [name, value] of Object.entries(planned)) if (value !== void 0 && wChildVal(level, name) !== value) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} does not carry the planned ${name}.`);
|
|
680
|
+
const fonts = wChild(wChild(level, "rPr"), "rFonts");
|
|
681
|
+
if (patch.font !== void 0 && ([
|
|
682
|
+
"ascii",
|
|
683
|
+
"hAnsi",
|
|
684
|
+
"eastAsia",
|
|
685
|
+
"cs"
|
|
686
|
+
].some((name) => wAttr(fonts, name) !== patch.font) || [
|
|
687
|
+
"asciiTheme",
|
|
688
|
+
"hAnsiTheme",
|
|
689
|
+
"eastAsiaTheme",
|
|
690
|
+
"cstheme"
|
|
691
|
+
].some((name) => wAttr(fonts, name) !== null))) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} is not set in the planned face.`);
|
|
634
692
|
const indent = wChild(wChild(level, "pPr"), "ind");
|
|
635
693
|
for (const [name, value] of Object.entries(patch.indent ?? {})) if (twipsOrNull(wAttr(indent, name)) !== value) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} does not carry the planned ${name} indent.`);
|
|
636
694
|
for (const [stated, other] of [["hanging", "firstLine"], ["firstLine", "hanging"]]) if (patch.indent?.[stated] !== void 0 && wAttr(indent, other) !== null) numberingMismatch(`Level ${patch.ilvl} of list definition ${patch.abstractNumId} keeps a ${other} indent beside the planned ${stated} one.`);
|
|
@@ -791,6 +849,55 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
791
849
|
if (Result.isError(templateHeadersAndFooters)) return templateHeadersAndFooters;
|
|
792
850
|
for (const part of templateHeadersAndFooters.value) frozenFields.push(...countByKind(part.path, frozenIn(partFields(part))));
|
|
793
851
|
}
|
|
852
|
+
const effectsOf = (path, xml) => {
|
|
853
|
+
const part = path === null || xml === null ? null : readRawPart(path, xml);
|
|
854
|
+
return part === null ? [] : findInvisibleEffects(part);
|
|
855
|
+
};
|
|
856
|
+
const keptRanges = [...resolved.keptTemplateBlocks.map(({ element }) => element), ...resolved.items.flatMap((item) => item.kind === "slot" ? [item.templateBlock.element] : [])].flatMap((element) => {
|
|
857
|
+
const range = rangeOf(element);
|
|
858
|
+
return range === null ? [] : [range];
|
|
859
|
+
});
|
|
860
|
+
const templateHeaderFooterParts = await readHeaderFooterParts(template);
|
|
861
|
+
if (Result.isError(templateHeaderFooterParts)) return templateHeaderFooterParts;
|
|
862
|
+
const effectParts = [
|
|
863
|
+
{
|
|
864
|
+
part: out.pkg.documentPath,
|
|
865
|
+
before: findInvisibleEffects(template.document).filter(({ range }) => keptRanges.some((kept) => range.start >= kept.start && range.end <= kept.end)),
|
|
866
|
+
after: findInvisibleEffects(out.document)
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
part: template.numberingPath,
|
|
870
|
+
before: effectsOf(template.numberingPath, template.numberingXml),
|
|
871
|
+
after: effectsOf(out.numberingPath, out.numberingXml)
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
part: template.stylesPath,
|
|
875
|
+
before: effectsOf(template.stylesPath, template.stylesXml),
|
|
876
|
+
after: effectsOf(out.stylesPath, out.stylesXml)
|
|
877
|
+
},
|
|
878
|
+
...templateHeaderFooterParts.value.map((part) => ({
|
|
879
|
+
part: part.path,
|
|
880
|
+
before: findInvisibleEffects(part),
|
|
881
|
+
after: findInvisibleEffects(outputHeadersAndFooters.value.find(({ path }) => path === part.path) ?? part)
|
|
882
|
+
}))
|
|
883
|
+
];
|
|
884
|
+
const textEffects = {
|
|
885
|
+
removed: [],
|
|
886
|
+
left: []
|
|
887
|
+
};
|
|
888
|
+
for (const { part, before, after } of effectParts) {
|
|
889
|
+
if (part === null) continue;
|
|
890
|
+
const left = countEffects(part, after);
|
|
891
|
+
textEffects.left.push(...left);
|
|
892
|
+
for (const { effect, count } of countEffects(part, before)) {
|
|
893
|
+
const kept = left.find((entry) => entry.effect === effect)?.count ?? 0;
|
|
894
|
+
if (count > kept) textEffects.removed.push({
|
|
895
|
+
part,
|
|
896
|
+
effect,
|
|
897
|
+
count: count - kept
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
794
901
|
const filler = [];
|
|
795
902
|
const documentText = out.story.order.flatMap(({ read }) => read === null ? [] : [read.text]).join("\n");
|
|
796
903
|
for (const text of options?.fillerStrings ?? []) for (const { part, text: haystack } of [{
|
|
@@ -908,7 +1015,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
908
1015
|
for (const read of placedReads) {
|
|
909
1016
|
for (const index of read.fieldIndices) {
|
|
910
1017
|
const field = source.story.state.fields[index];
|
|
911
|
-
if (field !== void 0 && hyperlinkFieldLink(field) === null) droppedFields.set(field.kind, (droppedFields.get(field.kind) ?? 0) + 1);
|
|
1018
|
+
if (field !== void 0 && hyperlinkFieldLink(field) === null && !isSelfNumberingField(field.kind)) droppedFields.set(field.kind, (droppedFields.get(field.kind) ?? 0) + 1);
|
|
912
1019
|
}
|
|
913
1020
|
let previous = null;
|
|
914
1021
|
for (const { link } of read.atoms) {
|
|
@@ -946,6 +1053,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
946
1053
|
sourceSha256: source.manifest.sha256,
|
|
947
1054
|
templateSha256: template.manifest.sha256,
|
|
948
1055
|
outputSha256: out.manifest.sha256,
|
|
1056
|
+
...source.manifest.trackedChangesResolved === void 0 ? {} : { trackedChanges: source.manifest.trackedChangesResolved },
|
|
949
1057
|
blocks,
|
|
950
1058
|
counts,
|
|
951
1059
|
footnotes,
|
|
@@ -982,6 +1090,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
982
1090
|
internalHyperlinks,
|
|
983
1091
|
sectionBreaks
|
|
984
1092
|
},
|
|
1093
|
+
textEffects,
|
|
985
1094
|
updateFields,
|
|
986
1095
|
conformance: {
|
|
987
1096
|
status: conformance.status,
|
|
@@ -993,7 +1102,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
993
1102
|
});
|
|
994
1103
|
};
|
|
995
1104
|
const verifyUnguarded = async ({ source, template, output, plan, options }) => {
|
|
996
|
-
const analyzedSource = await
|
|
1105
|
+
const analyzedSource = await analyzeSource(source, viewOf(plan));
|
|
997
1106
|
if (Result.isError(analyzedSource)) return analyzedSource;
|
|
998
1107
|
const analyzedTemplate = await analyzeDocument(template);
|
|
999
1108
|
if (Result.isError(analyzedTemplate)) return analyzedTemplate;
|