@stll/folio-core 0.77.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/canonical/canonicalBatchReview.js +7 -6
- package/dist/canonical/canonicalPublicOperations.js +14 -10
- package/dist/canonical/canonicalSession.js +12 -8
- package/dist/compare/inline-provenance.js +8 -1
- 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/blocks.d.ts +7 -0
- package/dist/docx/server/templatePlan/blocks.js +88 -2
- package/dist/docx/server/templatePlan/builders.d.ts +2 -1
- package/dist/docx/server/templatePlan/builders.js +14 -4
- package/dist/docx/server/templatePlan/plan.d.ts +2 -0
- package/dist/docx/server/templatePlan/plan.js +17 -10
- package/dist/docx/server/templatePlan/planShape.js +3 -2
- package/dist/docx/server/templatePlan/story.d.ts +12 -0
- package/dist/docx/server/templatePlan/story.js +51 -1
- package/dist/docx/server/templatePlan/types.d.ts +56 -0
- package/dist/docx/server/templatePlan/verify.js +6 -17
- package/dist/docx/tableGridXml.js +19 -3
- package/dist/docx/tableParser.js +3 -1
- package/dist/prosemirror/canonicalTableCommands.js +6 -6
- package/dist/prosemirror/conversion/toProseDoc.d.ts +5 -0
- package/dist/prosemirror/conversion/toProseDoc.js +12 -5
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +1 -1
- package/dist/types/canonicalCapabilities.js +1 -1
- package/package.json +2 -2
|
@@ -59,10 +59,11 @@ const resolveStory = ({ version: { document, projection }, story, ids, decision,
|
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Both sides of a batch resolved the same way. A revision the document held
|
|
62
|
-
* before the batch that blocks its own resolution
|
|
63
|
-
*
|
|
64
|
-
* changes, and a blocker the batch did not make
|
|
65
|
-
* of a document that holds one
|
|
62
|
+
* before the batch that blocks its own resolution alone there, and blocks it
|
|
63
|
+
* the same way after the batch or no longer does, stays pending on both: the
|
|
64
|
+
* proof is about what the batch changes, and a blocker the batch did not make
|
|
65
|
+
* must not refuse every edit of a document that holds one, such as a
|
|
66
|
+
* paragraph the batch puts beside it.
|
|
66
67
|
*/
|
|
67
68
|
const resolveStoryPair = ({ before, after, story, decision, restores }) => {
|
|
68
69
|
let beforeIds = before.ids;
|
|
@@ -85,9 +86,9 @@ const resolveStoryPair = ({ before, after, story, decision, restores }) => {
|
|
|
85
86
|
original: original.content,
|
|
86
87
|
edited: edited.content
|
|
87
88
|
};
|
|
88
|
-
if (original?.type !== "refused" || edited
|
|
89
|
+
if (original?.type !== "refused" || edited === void 0) return void 0;
|
|
89
90
|
const id = original.error.blockedParagraphMarkRevisionId;
|
|
90
|
-
if (id === void 0 || edited.
|
|
91
|
+
if (id === void 0 || edited.type === "refused" && (edited.error.blockedParagraphMarkRevisionId !== id || edited.error.reason !== original.error.reason) || !beforeIds.includes(id) || !afterIds.includes(id) || getTrackedChangeGroupsForIds(before.version.projection, [id]).at(0)?.length !== 1 || getTrackedChangeGroupsForIds(after.version.projection, [id]).at(0)?.length !== 1) return void 0;
|
|
91
92
|
beforeIds = beforeIds.filter((revisionId) => revisionId !== id);
|
|
92
93
|
afterIds = afterIds.filter((revisionId) => revisionId !== id);
|
|
93
94
|
}
|
|
@@ -2017,6 +2017,19 @@ const mergesDownOverEmptyCells = (table, map, rectangle) => {
|
|
|
2017
2017
|
}
|
|
2018
2018
|
return true;
|
|
2019
2019
|
};
|
|
2020
|
+
/** A merge across one row can absorb empty cells without moving blocks. */
|
|
2021
|
+
const mergesAcrossEmptyCells = (table, map, rectangle) => {
|
|
2022
|
+
if (rectangle.bottom - rectangle.top !== 1) return false;
|
|
2023
|
+
const cells = new Set(cellsIn(map, rectangle));
|
|
2024
|
+
const owner = map.map[rectangle.top * map.width + rectangle.left];
|
|
2025
|
+
if (owner === void 0) return false;
|
|
2026
|
+
cells.delete(owner);
|
|
2027
|
+
for (const offset of cells) {
|
|
2028
|
+
const cell = table.nodeAt(offset);
|
|
2029
|
+
if (cell?.childCount !== 1 || !cell.firstChild?.isTextblock || cell.firstChild.content.size > 0) return false;
|
|
2030
|
+
}
|
|
2031
|
+
return cells.size > 0;
|
|
2032
|
+
};
|
|
2020
2033
|
const isTableStructureOperation = (operation) => operation.type === "deleteTable" || operation.type === "insertTableRow" || operation.type === "deleteTableRow" || operation.type === "insertTableColumn" || operation.type === "deleteTableColumn" || operation.type === "mergeTableCells" || operation.type === "splitTableCell";
|
|
2021
2034
|
/**
|
|
2022
2035
|
* A table, row or column change, addressed through the paragraph the
|
|
@@ -2107,14 +2120,6 @@ const resolveTableStructure = ({ operation, paragraph, projection, story, refusa
|
|
|
2107
2120
|
left: cell.leftColumnIndex,
|
|
2108
2121
|
right: cell.leftColumnIndex + 1
|
|
2109
2122
|
};
|
|
2110
|
-
if (tracked) {
|
|
2111
|
-
const spans = Array.from({ length: map.height }, (_, rowIndex) => {
|
|
2112
|
-
const position = map.map[rowIndex * map.width + column.left];
|
|
2113
|
-
const node = position === void 0 ? null : row.table.nodeAt(position);
|
|
2114
|
-
return node === null || node.attrs["_omittedGridSlot"] != null ? 0 : Number(node.attrs["colspan"] ?? 1);
|
|
2115
|
-
});
|
|
2116
|
-
if (spans.includes(1) && spans.some((span) => span > 1)) return skipTracked("A suggested column deletion cannot narrow a cell that spans other columns.");
|
|
2117
|
-
}
|
|
2118
2123
|
const at = tableAnchor({
|
|
2119
2124
|
map,
|
|
2120
2125
|
table: row.table,
|
|
@@ -2204,7 +2209,7 @@ const resolveTableStructure = ({ operation, paragraph, projection, story, refusa
|
|
|
2204
2209
|
if (rectangle.right - rectangle.left === 1 && rectangle.bottom - rectangle.top === 1) return skipAlike("noopOperation", "A merge of one cell changes nothing.");
|
|
2205
2210
|
if (tableRectangleCutsMergedCell(map, rectangle) || holdsOmittedSlot(row.table, map, rectangle)) return skipAlike("unsupportedBlock", "The merge would cut a merged cell or a slot its row omits.");
|
|
2206
2211
|
if (new Set(cellsIn(map, rectangle)).size < 2) return skipAlike("unsupportedBlock", "The merge covers a single merged cell.");
|
|
2207
|
-
if (tracked && !mergesDownOverEmptyCells(row.table, map, rectangle)) return skipTracked("A suggested merge
|
|
2212
|
+
if (tracked && !mergesDownOverEmptyCells(row.table, map, rectangle) && !mergesAcrossEmptyCells(row.table, map, rectangle)) return skipTracked("A suggested merge can absorb only empty cells in one row or column.");
|
|
2208
2213
|
const blockId = tableBlockAddress(projection, row, deleted);
|
|
2209
2214
|
if (blockId === void 0) return refusal("unsupportedBlock", void 0, INVALID_REQUEST);
|
|
2210
2215
|
return resolved({
|
|
@@ -2221,7 +2226,6 @@ const resolveTableStructure = ({ operation, paragraph, projection, story, refusa
|
|
|
2221
2226
|
const cell = findEnclosingTableCell(doc, blockFrom);
|
|
2222
2227
|
if (cell === null) return notInTable();
|
|
2223
2228
|
if (cell.rightColumnIndex - cell.leftColumnIndex === 1 && cell.bottomRowIndex - cell.topRowIndex === 1) return skipAlike("noopOperation", "A one-row, one-column cell has nothing to split.");
|
|
2224
|
-
if (tracked && cell.rightColumnIndex - cell.leftColumnIndex !== 1) return skipTracked("A suggested split takes a cell merged down one column.");
|
|
2225
2229
|
return resolved({
|
|
2226
2230
|
type: "table",
|
|
2227
2231
|
operation: {
|
|
@@ -37,7 +37,7 @@ import { controlEdgesAt } from "./controlEdges.js";
|
|
|
37
37
|
import { ownedSourceCopies, preservePropertySources, preservePropertySourcesWholeStories } from "./propertySourcePreservation.js";
|
|
38
38
|
import { Result, TaggedError, panic } from "better-result";
|
|
39
39
|
import { hasIllegalXmlCharacters } from "@stll/docx-core";
|
|
40
|
-
import { lockedControlMessage } from "@stll/docx-core/model";
|
|
40
|
+
import { lockedControlMessage, tableWithPhysicalColumns } from "@stll/docx-core/model";
|
|
41
41
|
import { DOCUMENT_OP_REFUSAL_REASONS, DOCUMENT_OP_TYPES, ID_LEASE_KINDS, OP_STORIES, applyDocumentOp, applyDocumentOps, combineEdits, combineRecordedRevisions, compileEditorIntent, createEditorIntentIdAllocator, documentStories, editorParagraphGroups, findStoryBody, formatParaId, freshLeasedIds, inverseMeetingDocument, isBlockBoundary, normalizeForOps, packageParagraphIds, paragraphIdsIn, paragraphsThroughTextBoxes, sameStory, suggestedCommentIds, suggestionRevisionInfos, survivingComments, validateOpsDocument, withParagraphCopies } from "@stll/docx-core/ops";
|
|
42
42
|
import { AllSelection, NodeSelection, Selection, TextSelection } from "prosemirror-state";
|
|
43
43
|
import { CellSelection } from "prosemirror-tables";
|
|
@@ -602,8 +602,9 @@ const visitBlockSources = (block, container, visit, insideSkippedContinuation) =
|
|
|
602
602
|
return;
|
|
603
603
|
}
|
|
604
604
|
if (block.type !== "table") return;
|
|
605
|
-
const
|
|
606
|
-
|
|
605
|
+
const display = tableWithPhysicalColumns(block);
|
|
606
|
+
const rowSpans = calculateRowSpans(display);
|
|
607
|
+
for (const [rowIndex, row] of display.rows.entries()) {
|
|
607
608
|
let column = row.formatting?.gridBefore ?? 0;
|
|
608
609
|
for (const cell of row.cells) {
|
|
609
610
|
const skippedContinuation = isCellMergeContinuation(cell) && (rowSpans.get(`${rowIndex}-${column}`)?.skip ?? false);
|
|
@@ -1047,11 +1048,14 @@ const project = ({ document, styles, story = OP_STORIES.MAIN, caches, previous,
|
|
|
1047
1048
|
const body = findStoryBody(document, story);
|
|
1048
1049
|
if (!body) return refuse("The canonical story no longer exists.", STALE);
|
|
1049
1050
|
const currentStyles = Object.hasOwn(document.package, "styles") ? document.package.styles : styles;
|
|
1050
|
-
const options =
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1051
|
+
const options = {
|
|
1052
|
+
...storyConversionOptions({
|
|
1053
|
+
styles: currentStyles,
|
|
1054
|
+
theme: document.package.theme,
|
|
1055
|
+
numbering: document.package.numbering
|
|
1056
|
+
}),
|
|
1057
|
+
tableReviewGeometry: "physical"
|
|
1058
|
+
};
|
|
1055
1059
|
const converted = Result.try({
|
|
1056
1060
|
try: () => {
|
|
1057
1061
|
if (story === OP_STORIES.MAIN) return toProseDoc(document, caches === void 0 ? options : {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sourceDocumentOf, styleResolverOf } from "../ai-edits/snapshot.js";
|
|
2
2
|
import { addTrackedDeletionMark } from "../prosemirror/addTrackedDeletionMark.js";
|
|
3
|
-
import { expectHyperlinkMarkAttrs, expectRunPropertyChangeMarkAttrs, expectTableCellAttrs } from "../prosemirror/attrs/index.js";
|
|
3
|
+
import { expectHyperlinkMarkAttrs, expectRunPropertyChangeMarkAttrs, expectTableCellAttrs, expectTableRowAttrs } from "../prosemirror/attrs/index.js";
|
|
4
4
|
import { getDocumentStyleResolver } from "../prosemirror/plugins/documentStyleState.js";
|
|
5
5
|
import { applyMarksToRunFormattingRepresentation, expandRunFormattingCarrier, runFormattingCarrierReviewText } from "../prosemirror/runFormattingInlineCarriers.js";
|
|
6
6
|
import { readAuthoredRunFormatting, reconcileRunFormattingMarks } from "../prosemirror/runFormattingReconciliation.js";
|
|
@@ -75,6 +75,13 @@ const collectCarriers = ({ doc, targetSnapshot }) => {
|
|
|
75
75
|
node,
|
|
76
76
|
end: position + node.nodeSize
|
|
77
77
|
});
|
|
78
|
+
if (node.type.name === "table" && node.childCount > 0) {
|
|
79
|
+
let retainedRows = node.childCount;
|
|
80
|
+
node.forEach((row) => {
|
|
81
|
+
if (expectTableRowAttrs(row).trDel != null) retainedRows--;
|
|
82
|
+
});
|
|
83
|
+
if (retainedRows === 0) return false;
|
|
84
|
+
}
|
|
78
85
|
if ((node.type.name === "tableCell" || node.type.name === "tableHeader") && !isTableCellRetainedInReviewView(expectTableCellAttrs(node).cellMarker?.kind, "final")) return false;
|
|
79
86
|
if (!node.isInline) return true;
|
|
80
87
|
const carrier = expandRunFormattingCarrier(node, position);
|
|
@@ -428,8 +428,8 @@ const linkedRevisionContent = (wrapped, linkOver) => {
|
|
|
428
428
|
};
|
|
429
429
|
const hoistRevision = (wrapper) => (child, { styles, theme, rels, media, previews, inScopeXmlns, items, linkOver }) => {
|
|
430
430
|
const wrapped = parseParagraphContents(child, styles, theme, null, rels, media, previews, TRACKED_CHANGE_PARSE_CONTEXT[wrapper], inScopeXmlns, "hyperlink");
|
|
431
|
-
const content = linkedRevisionContent(wrapped, linkOver);
|
|
432
431
|
const split = parseSplitResolutionPiece(child);
|
|
432
|
+
const content = wrapped.length === 0 && split !== void 0 ? [linkOver([])] : linkedRevisionContent(wrapped, linkOver);
|
|
433
433
|
const resolutionJoins = parseResolutionJoins(child);
|
|
434
434
|
items.push({
|
|
435
435
|
type: "hoistedRevision",
|
|
@@ -73,6 +73,8 @@ export declare const serializeSplitResolutionPiece: (value: SplitResolutionPiece
|
|
|
73
73
|
*/
|
|
74
74
|
export declare const parseParagraphPropertyChangeOwner: (node: XmlElement) => Pick<document_d_exports.ParagraphPropertyChange, "resolvesWith">;
|
|
75
75
|
export declare const serializeParagraphPropertyChangeOwner: (change: document_d_exports.ParagraphPropertyChange) => string;
|
|
76
|
+
export declare const parseTableGeometryChange: (node: XmlElement) => Pick<document_d_exports.TableGridChange, "geometryChange">;
|
|
77
|
+
export declare const serializeTableGeometryChange: (change: document_d_exports.TableGridChange) => string;
|
|
76
78
|
/**
|
|
77
79
|
* Why the reader drops a provenance attribute's value, or `undefined` when it
|
|
78
80
|
* reads it (or does not read that attribute at all).
|
|
@@ -490,6 +490,25 @@ const serializeParagraphPropertyChangeOwner = (change) => serializeAttribute({
|
|
|
490
490
|
value: change.resolvesWith,
|
|
491
491
|
valid: isRevisionId
|
|
492
492
|
});
|
|
493
|
+
const TABLE_GEOMETRY_CHANGE = "tableGeometryChange";
|
|
494
|
+
const isTableGeometryChange = (value) => {
|
|
495
|
+
if (!record(value) || value["type"] !== "deleteColumn" && value["type"] !== "mergeCells" || Object.keys(value).some((key) => key !== "type" && key !== "revisionIds")) return false;
|
|
496
|
+
const ids = value["revisionIds"];
|
|
497
|
+
return Array.isArray(ids) && ids.length > 0 && ids.every(isRevisionId) && new Set(ids).size === ids.length;
|
|
498
|
+
};
|
|
499
|
+
const parseTableGeometryChange = (node) => {
|
|
500
|
+
const geometryChange = parseAttribute({
|
|
501
|
+
node,
|
|
502
|
+
attribute: TABLE_GEOMETRY_CHANGE,
|
|
503
|
+
valid: isTableGeometryChange
|
|
504
|
+
});
|
|
505
|
+
return geometryChange === void 0 ? {} : { geometryChange };
|
|
506
|
+
};
|
|
507
|
+
const serializeTableGeometryChange = (change) => serializeAttribute({
|
|
508
|
+
attribute: TABLE_GEOMETRY_CHANGE,
|
|
509
|
+
value: change.geometryChange,
|
|
510
|
+
valid: isTableGeometryChange
|
|
511
|
+
});
|
|
493
512
|
/** Every provenance attribute folio reads, with the shape its value must have. */
|
|
494
513
|
const PROVENANCE_VALUE_SHAPES = {
|
|
495
514
|
resolutionJoins: isStoredJoinsOf,
|
|
@@ -501,7 +520,8 @@ const PROVENANCE_VALUE_SHAPES = {
|
|
|
501
520
|
[ENCLOSING_ATTRIBUTE]: enclosingHandoffs,
|
|
502
521
|
[PARAGRAPH_MARK_FIELDS.survivor.attribute]: isParagraphMarkSurvivor,
|
|
503
522
|
[PARAGRAPH_MARK_FIELDS.splitDate.attribute]: isParagraphMarkSplitDate,
|
|
504
|
-
resolvesWith: isRevisionId
|
|
523
|
+
resolvesWith: isRevisionId,
|
|
524
|
+
[TABLE_GEOMETRY_CHANGE]: isTableGeometryChange
|
|
505
525
|
};
|
|
506
526
|
/**
|
|
507
527
|
* Why the reader drops a provenance attribute's value, or `undefined` when it
|
|
@@ -513,4 +533,4 @@ const reviewProvenanceIssue = (attribute, encoded) => {
|
|
|
513
533
|
const decoded = decodeProvenance(encoded, shape);
|
|
514
534
|
return decoded.status === "dropped" ? decoded.reason : void 0;
|
|
515
535
|
};
|
|
516
|
-
export { REVIEW_HISTORY_VERSION, ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, isSplitResolutionPiece, legacyKeptCutPiece, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseKeptCut, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, reviewProvenanceIssue, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeKeptCut, serializeParagraphMarkResolutionJoin, serializeParagraphPropertyChangeOwner, serializeResolutionJoins, serializeSplitResolutionPiece, versionOneKeptMarkers };
|
|
536
|
+
export { REVIEW_HISTORY_VERSION, ReviewResolutionProvenanceError, isBoundaryJoins, isParagraphMarkResolutionJoin, isResolutionJoins, isSplitResolutionPiece, legacyKeptCutPiece, paragraphMarkResolutionJoinAttributes, parseBoundaryJoins, parseCopyOriginAncestors, parseKeptCut, parseParagraphMarkResolutionJoin, parseParagraphPropertyChangeOwner, parseResolutionJoins, parseSplitResolutionPiece, parseTableGeometryChange, reviewProvenanceIssue, serializeBoundaryJoins, serializeCopyOriginAncestors, serializeKeptCut, serializeParagraphMarkResolutionJoin, serializeParagraphPropertyChangeOwner, serializeResolutionJoins, serializeSplitResolutionPiece, serializeTableGeometryChange, versionOneKeptMarkers };
|
|
@@ -95,6 +95,13 @@ export declare const styleLook: (styleId: string | null, styles: StyleMap, { sty
|
|
|
95
95
|
* properties of its own still ends in a section, which states nothing.
|
|
96
96
|
*/
|
|
97
97
|
export declare const storySections: ({ sections, hasBodySection }: AnalyzedStory) => DocxSection[];
|
|
98
|
+
/**
|
|
99
|
+
* Whether a bookmark of `read` holds all of the paragraph's content. In a
|
|
100
|
+
* reading that keeps tracked changes the paragraph's own content begins
|
|
101
|
+
* behind the last paragraph mark deleted in it (what stands in front is the
|
|
102
|
+
* paragraph the mark ended) and ends in front of a mark somebody inserted.
|
|
103
|
+
*/
|
|
104
|
+
export declare const bookmarkEncloses: (read: ParagraphRead | null, name: string) => boolean;
|
|
98
105
|
type AnalyzeStoryOptions = {
|
|
99
106
|
container: XmlElement;
|
|
100
107
|
resources: StoryResources;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseNumbering } from "../../numberingParser.js";
|
|
2
2
|
import { parseSectionProperties } from "../../sectionParser.js";
|
|
3
3
|
import { parseStylesPackage } from "../../styleParser.js";
|
|
4
|
-
import { keepsShiftReturnSpacing } from "./builders.js";
|
|
4
|
+
import { fieldBookmarkOf, keepsShiftReturnSpacing } from "./builders.js";
|
|
5
5
|
import { defaultsBaseline } from "./emphasis.js";
|
|
6
6
|
import { createLabelCounter } from "./labels.js";
|
|
7
7
|
import { guarded, loadPackage, readPartText, sha256Hex } from "./package.js";
|
|
@@ -211,6 +211,74 @@ const selfNumbersOf = ({ atoms }) => {
|
|
|
211
211
|
return offsets;
|
|
212
212
|
};
|
|
213
213
|
/**
|
|
214
|
+
* Whether a bookmark of `read` holds all of the paragraph's content. In a
|
|
215
|
+
* reading that keeps tracked changes the paragraph's own content begins
|
|
216
|
+
* behind the last paragraph mark deleted in it (what stands in front is the
|
|
217
|
+
* paragraph the mark ended) and ends in front of a mark somebody inserted.
|
|
218
|
+
*/
|
|
219
|
+
const bookmarkEncloses = (read, name) => {
|
|
220
|
+
const start = read?.bookmarks.find((bookmark) => bookmark.name === name);
|
|
221
|
+
const end = start === void 0 ? void 0 : read?.bookmarkEnds.find(({ id }) => id === start.id);
|
|
222
|
+
if (read === null || start === void 0 || end === void 0) return false;
|
|
223
|
+
const own = read.atoms.findLastIndex(({ revision }) => revision?.deleted === "") + 1;
|
|
224
|
+
const marked = read.atoms.at(-1)?.revision?.mark === true ? 1 : 0;
|
|
225
|
+
return start.atomIndex === own && end.atomIndex === read.atoms.length - marked;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* The `REF` fields of a paragraph whose result stands in its text: begun
|
|
229
|
+
* and ended in it, in the code of no field and in the result of no other.
|
|
230
|
+
*/
|
|
231
|
+
const crossReferencesOf = (read, state) => {
|
|
232
|
+
const spans = /* @__PURE__ */ new Map();
|
|
233
|
+
let at = 0;
|
|
234
|
+
for (const { text, fields } of read.atoms) {
|
|
235
|
+
const start = at;
|
|
236
|
+
at += text.length;
|
|
237
|
+
for (const [depth, index] of fields.entries()) {
|
|
238
|
+
const span = spans.get(index);
|
|
239
|
+
if (span === void 0) spans.set(index, {
|
|
240
|
+
start,
|
|
241
|
+
end: at,
|
|
242
|
+
outermost: depth === 0
|
|
243
|
+
});
|
|
244
|
+
else {
|
|
245
|
+
span.end = at;
|
|
246
|
+
span.outermost &&= depth === 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const found = [];
|
|
251
|
+
for (const [index, { start, end, outermost }] of spans) {
|
|
252
|
+
const field = state.fields[index];
|
|
253
|
+
const bookmark = field === void 0 ? null : fieldBookmarkOf(field.instruction);
|
|
254
|
+
if (field === void 0 || bookmark === null || field.kind !== "REF" || !field.closed || field.nestedInCode || !outermost || start === end || field.paragraphOrdinal !== read.ordinal || field.endParagraphOrdinal !== read.ordinal) continue;
|
|
255
|
+
found.push({
|
|
256
|
+
start,
|
|
257
|
+
end,
|
|
258
|
+
instruction: field.instruction,
|
|
259
|
+
bookmark
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return found;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Where each bookmark of a story stands: the paragraph it starts and ends
|
|
266
|
+
* in, and whether it holds all of its content. Null for one that ends in
|
|
267
|
+
* another paragraph or not at all. The first bookmark of a name counts.
|
|
268
|
+
*/
|
|
269
|
+
const bookmarkTargetsOf = (story) => {
|
|
270
|
+
const targets = /* @__PURE__ */ new Map();
|
|
271
|
+
for (const { block, read } of story.order) for (const start of read?.bookmarks ?? []) {
|
|
272
|
+
if (targets.has(start.name)) continue;
|
|
273
|
+
const end = read?.bookmarkEnds.find(({ id }) => id === start.id);
|
|
274
|
+
targets.set(start.name, end === void 0 || end.atomIndex < start.atomIndex ? null : {
|
|
275
|
+
blockId: block.id,
|
|
276
|
+
whole: bookmarkEncloses(read, start.name)
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return targets;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
214
282
|
* The tracked changes a paragraph read with them kept holds, by where they
|
|
215
283
|
* sit in its text. Neighbouring pieces of one change are one entry.
|
|
216
284
|
*/
|
|
@@ -257,6 +325,7 @@ const analyzeStory = ({ container, resources, counter = createLabelCounter(resou
|
|
|
257
325
|
let index = 0;
|
|
258
326
|
let sectionIndex = 0;
|
|
259
327
|
const unread = /* @__PURE__ */ new Map();
|
|
328
|
+
const fieldsToBookmarks = /* @__PURE__ */ new Map();
|
|
260
329
|
const register = (analyzed) => {
|
|
261
330
|
story.order.push(analyzed);
|
|
262
331
|
story.byId.set(analyzed.block.id, analyzed);
|
|
@@ -297,12 +366,15 @@ const analyzeStory = ({ container, resources, counter = createLabelCounter(resou
|
|
|
297
366
|
...read.paraId === null ? {} : { paraId: read.paraId },
|
|
298
367
|
inlineObjects: read.inlineObjects
|
|
299
368
|
};
|
|
369
|
+
if (read.pageShapes > 0) block.pageShapes = read.pageShapes;
|
|
300
370
|
const pageBreaks = pageBreaksOf(read);
|
|
301
371
|
if (pageBreaks > 0) block.pageBreaks = pageBreaks;
|
|
302
372
|
const selfNumbers = selfNumbersOf(read);
|
|
303
373
|
if (selfNumbers.length > 0) block.selfNumbers = selfNumbers;
|
|
304
374
|
const revisions = revisionsOf(read);
|
|
305
375
|
if (revisions.length > 0) block.revisions = revisions;
|
|
376
|
+
const references = crossReferencesOf(read, state);
|
|
377
|
+
if (references.length > 0) fieldsToBookmarks.set(block, references);
|
|
306
378
|
if (read.pageBreakBefore ?? style?.pPr?.pageBreakBefore === true) block.pageBreakBefore = true;
|
|
307
379
|
if (read.hasSectionBreak) block.endsSection = true;
|
|
308
380
|
const alignment = read.alignment ?? (resources.alignments === void 0 ? null : styleAlignment(styleId ?? resources.defaultStyleId, resources.styles, resources.alignments));
|
|
@@ -409,6 +481,20 @@ const analyzeStory = ({ container, resources, counter = createLabelCounter(resou
|
|
|
409
481
|
state.trackedChanges += 1;
|
|
410
482
|
}
|
|
411
483
|
});
|
|
484
|
+
if (fieldsToBookmarks.size > 0) {
|
|
485
|
+
const targets = bookmarkTargetsOf(story);
|
|
486
|
+
for (const [block, references] of fieldsToBookmarks) block.crossReferences = references.map(({ start, end, instruction, bookmark }) => {
|
|
487
|
+
const target = targets.get(bookmark) ?? null;
|
|
488
|
+
return {
|
|
489
|
+
start,
|
|
490
|
+
end,
|
|
491
|
+
instruction,
|
|
492
|
+
bookmark,
|
|
493
|
+
targetBlockId: target?.blockId ?? null,
|
|
494
|
+
targetWhole: target?.whole ?? false
|
|
495
|
+
};
|
|
496
|
+
});
|
|
497
|
+
}
|
|
412
498
|
const bodySection = wChild(container, "sectPr");
|
|
413
499
|
if (bodySection !== null) {
|
|
414
500
|
story.sections.push(bodySection);
|
|
@@ -705,4 +791,4 @@ const analyzeSource = async (bytes, view) => {
|
|
|
705
791
|
* document as it stands, or the refusal a plan that keeps them would get.
|
|
706
792
|
*/
|
|
707
793
|
const analyzeDocxBlocks = async (docx, options = {}) => await guarded(async () => (await analyzeSource(docx, options.trackedChanges)).map(({ manifest }) => manifest));
|
|
708
|
-
export { analyzeDocument, analyzeDocxBlocks, analyzeKeptForm, analyzeSource, analyzeStory, blockHash, statedAlignments, statedLooks, storySections, styleAlignment, styleLook, styleOutlineLevel, viewOf };
|
|
794
|
+
export { analyzeDocument, analyzeDocxBlocks, analyzeKeptForm, analyzeSource, analyzeStory, blockHash, bookmarkEncloses, statedAlignments, statedLooks, storySections, styleAlignment, styleLook, styleOutlineLevel, viewOf };
|
|
@@ -47,7 +47,8 @@ export declare const applyRefCaseFormat: (text: string, format: ReturnType<typeo
|
|
|
47
47
|
/**
|
|
48
48
|
* The field code of a REF to `bookmark` with `switches` (`\n \t \h`,
|
|
49
49
|
* `\n \* lower \h`). Null when the switches hold anything but
|
|
50
|
-
* single-letter switches
|
|
50
|
+
* single-letter switches, one letter-case format and one format that
|
|
51
|
+
* keeps the result's look.
|
|
51
52
|
*/
|
|
52
53
|
export declare const refFieldInstruction: (bookmark: string, switches: string) => string | null;
|
|
53
54
|
/** The bookmark a REF, PAGEREF or NOTEREF instruction names. */
|
|
@@ -93,6 +93,12 @@ const REF_SWITCH = /^\\[fhnprtw]$/u;
|
|
|
93
93
|
/** The general format switch and the letter cases it may name. */
|
|
94
94
|
const FORMAT_SWITCH = "\\*";
|
|
95
95
|
const CASE_FORMAT = /^(?:lower|upper|firstcap)$/iu;
|
|
96
|
+
/**
|
|
97
|
+
* What else the general format switch may name: that an update keeps the
|
|
98
|
+
* look of the previous result (ECMA-376 Part 1, 17.16.4.3), so a field
|
|
99
|
+
* set in a face of its own stays so once its result is recalculated.
|
|
100
|
+
*/
|
|
101
|
+
const LOOK_FORMAT = /^(?:mergeformat|charformat)$/iu;
|
|
96
102
|
/** The letter case a REF instruction asks for its result in, or null. */
|
|
97
103
|
const refCaseFormat = (instruction) => {
|
|
98
104
|
const name = /\\\*\s*(?<name>lower|upper|firstcap)\b/iu.exec(instruction)?.groups?.["name"]?.toLowerCase();
|
|
@@ -118,16 +124,20 @@ const applyRefCaseFormat = (text, format) => {
|
|
|
118
124
|
/**
|
|
119
125
|
* The field code of a REF to `bookmark` with `switches` (`\n \t \h`,
|
|
120
126
|
* `\n \* lower \h`). Null when the switches hold anything but
|
|
121
|
-
* single-letter switches
|
|
127
|
+
* single-letter switches, one letter-case format and one format that
|
|
128
|
+
* keeps the result's look.
|
|
122
129
|
*/
|
|
123
130
|
const refFieldInstruction = (bookmark, switches) => {
|
|
124
131
|
const parts = switches.trim().split(/\s+/u).filter(Boolean);
|
|
125
|
-
let
|
|
132
|
+
let cases = 0;
|
|
133
|
+
let looks = 0;
|
|
126
134
|
for (const [index, part] of parts.entries()) {
|
|
127
135
|
const afterFormat = parts[index - 1] === FORMAT_SWITCH;
|
|
128
136
|
if (part === FORMAT_SWITCH) {
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
const format = parts[index + 1] ?? "";
|
|
138
|
+
cases += CASE_FORMAT.test(format) ? 1 : 0;
|
|
139
|
+
looks += LOOK_FORMAT.test(format) ? 1 : 0;
|
|
140
|
+
if (cases > 1 || looks > 1 || !(CASE_FORMAT.test(format) || LOOK_FORMAT.test(format))) return null;
|
|
131
141
|
} else if (!afterFormat && !REF_SWITCH.test(part)) return null;
|
|
132
142
|
}
|
|
133
143
|
return ` REF ${bookmark} ${parts.join(" ")}${parts.length === 0 ? "" : " "}`;
|
|
@@ -53,6 +53,8 @@ export type ResolvedNumbering = {
|
|
|
53
53
|
export type ResolvedPart = {
|
|
54
54
|
block: AnalyzedBlock;
|
|
55
55
|
strippedPrefix: string;
|
|
56
|
+
/** Drawn shapes fixed to the page the part is written without. */
|
|
57
|
+
droppedPageShapes: number;
|
|
56
58
|
/** The lead a slot dropped off the part and the template paragraph that
|
|
57
59
|
* shows the field, or null. */
|
|
58
60
|
droppedLead: {
|
|
@@ -6,6 +6,7 @@ import { emphasisDeviation, emphasisSignature, paragraphBaseline, readDirectEmph
|
|
|
6
6
|
import { styleNumbering } from "./labels.js";
|
|
7
7
|
import { PLAN_HIGHLIGHT_COLORS, planShapeIssue } from "./planShape.js";
|
|
8
8
|
import "./revisions.js";
|
|
9
|
+
import { isPageShape } from "./story.js";
|
|
9
10
|
import { TemplatePlanError } from "./types.js";
|
|
10
11
|
import { elementChildren, isW, maxOf, wAttr, wChild, wChildVal, wName, walkElements } from "./xml.js";
|
|
11
12
|
import { Result } from "better-result";
|
|
@@ -608,14 +609,16 @@ const resolvePlan = (source, template, plan) => {
|
|
|
608
609
|
shownByTemplateBlockId: planned.dropLead.shownByTemplateBlockId
|
|
609
610
|
};
|
|
610
611
|
}
|
|
612
|
+
const every = paragraphPieces({
|
|
613
|
+
read: block.read,
|
|
614
|
+
context: source,
|
|
615
|
+
origin: "document",
|
|
616
|
+
fields: source.story.state.fields
|
|
617
|
+
});
|
|
618
|
+
const kept = planned.dropPageShapes === true ? every.filter(({ kind, atom }) => !(kind === "object" && atom?.element !== null && atom?.element !== void 0 && isPageShape(atom.element))) : every;
|
|
611
619
|
const part = partSegments({
|
|
612
620
|
block,
|
|
613
|
-
pieces:
|
|
614
|
-
read: block.read,
|
|
615
|
-
context: source,
|
|
616
|
-
origin: "document",
|
|
617
|
-
fields: source.story.state.fields
|
|
618
|
-
}),
|
|
621
|
+
pieces: kept,
|
|
619
622
|
strippedLength: droppedLead === null ? strippedPrefix.length : droppedLead.text.length,
|
|
620
623
|
strippedBreak: stripLabelBreak === true,
|
|
621
624
|
references: referencesByBlock.get(id) ?? [],
|
|
@@ -646,6 +649,7 @@ const resolvePlan = (source, template, plan) => {
|
|
|
646
649
|
resolvedParts.push({
|
|
647
650
|
block,
|
|
648
651
|
strippedPrefix,
|
|
652
|
+
droppedPageShapes: every.length - kept.length,
|
|
649
653
|
droppedLead,
|
|
650
654
|
labelAsText: written?.label ?? null
|
|
651
655
|
});
|
|
@@ -690,7 +694,7 @@ const resolvePlan = (source, template, plan) => {
|
|
|
690
694
|
};
|
|
691
695
|
const resolveTable = (block, item, tableOrdinal) => {
|
|
692
696
|
const { id } = block.block;
|
|
693
|
-
if (item.mergeNext !== void 0 || item.stripLabel !== void 0 || item.stripLabelBreak !== void 0 || item.labelAsText !== void 0 || item.pageBreakBefore !== void 0 || item.keepNext !== void 0 || item.indent !== void 0 || item.tabStops !== void 0 || item.alignment !== void 0 || item.spacing !== void 0 || item.endsSection !== void 0 || item.numbering !== void 0) return invalid(`Table ${id} takes a style and nested placements only.`);
|
|
697
|
+
if (item.mergeNext !== void 0 || item.stripLabel !== void 0 || item.stripLabelBreak !== void 0 || item.labelAsText !== void 0 || item.dropPageShapes !== void 0 || item.pageBreakBefore !== void 0 || item.keepNext !== void 0 || item.indent !== void 0 || item.tabStops !== void 0 || item.alignment !== void 0 || item.spacing !== void 0 || item.endsSection !== void 0 || item.numbering !== void 0) return invalid(`Table ${id} takes a style and nested placements only.`);
|
|
694
698
|
if (item.styleId !== void 0 && template.styles.get(item.styleId)?.type !== "table") return Result.err(refuse({
|
|
695
699
|
code: "style-unknown",
|
|
696
700
|
message: `The template has no table style ${item.styleId}.`,
|
|
@@ -713,7 +717,8 @@ const resolvePlan = (source, template, plan) => {
|
|
|
713
717
|
parts: [{
|
|
714
718
|
block: nested,
|
|
715
719
|
stripLabel: override?.stripLabel,
|
|
716
|
-
labelAsText: override?.labelAsText === true
|
|
720
|
+
labelAsText: override?.labelAsText === true,
|
|
721
|
+
dropPageShapes: override?.dropPageShapes === true
|
|
717
722
|
}],
|
|
718
723
|
separators: [],
|
|
719
724
|
styleId: override?.styleId ?? item.cellStyleId,
|
|
@@ -795,7 +800,8 @@ const resolvePlan = (source, template, plan) => {
|
|
|
795
800
|
block: block.value,
|
|
796
801
|
stripLabel: item.stripLabel,
|
|
797
802
|
stripLabelBreak: item.stripLabelBreak === true,
|
|
798
|
-
labelAsText: item.labelAsText === true
|
|
803
|
+
labelAsText: item.labelAsText === true,
|
|
804
|
+
dropPageShapes: item.dropPageShapes === true
|
|
799
805
|
}];
|
|
800
806
|
const separators = [];
|
|
801
807
|
let merge = item.mergeNext;
|
|
@@ -822,7 +828,8 @@ const resolvePlan = (source, template, plan) => {
|
|
|
822
828
|
block: nextBlock.value,
|
|
823
829
|
stripLabel: next.stripLabel,
|
|
824
830
|
stripLabelBreak: next.stripLabelBreak === true,
|
|
825
|
-
labelAsText: next.labelAsText === true
|
|
831
|
+
labelAsText: next.labelAsText === true,
|
|
832
|
+
dropPageShapes: next.dropPageShapes === true
|
|
826
833
|
});
|
|
827
834
|
merge = next.mergeNext;
|
|
828
835
|
index += 1;
|
|
@@ -142,7 +142,8 @@ const sourceItemIssue = (item, where) => {
|
|
|
142
142
|
"labelAsText",
|
|
143
143
|
"pageBreakBefore",
|
|
144
144
|
"keepNext",
|
|
145
|
-
"stripLabelBreak"
|
|
145
|
+
"stripLabelBreak",
|
|
146
|
+
"dropPageShapes"
|
|
146
147
|
]) if (!isOptionalBoolean(item[key])) return `${where} carries a malformed ${key}.`;
|
|
147
148
|
if (item["indent"] !== void 0 && !isIndent(item["indent"])) return `${where} carries a malformed indent.`;
|
|
148
149
|
if (item["tabStops"] !== void 0 && !isTabStops(item["tabStops"])) return `${where} carries malformed tab stops.`;
|
|
@@ -162,7 +163,7 @@ const sourceItemIssue = (item, where) => {
|
|
|
162
163
|
if (!isObject(entry) || !isString(entry["blockId"])) return `${where} carries a nested placement without a block.`;
|
|
163
164
|
if (seen.has(entry["blockId"])) return `${where} places nested block ${entry["blockId"]} twice.`;
|
|
164
165
|
seen.add(entry["blockId"]);
|
|
165
|
-
if (!isOptionalString(entry["styleId"]) || !isOptionalString(entry["stripLabel"]) || !isOptionalBoolean(entry["labelAsText"]) || !isOptionalBoolean(entry["keepNext"]) || entry["indent"] !== void 0 && !isIndent(entry["indent"]) || entry["tabStops"] !== void 0 && !isTabStops(entry["tabStops"]) || entry["alignment"] !== void 0 && !isAlignment(entry["alignment"]) || entry["spacing"] !== void 0 && !isSpacing(entry["spacing"])) return `${where} carries a malformed nested placement.`;
|
|
166
|
+
if (!isOptionalString(entry["styleId"]) || !isOptionalString(entry["stripLabel"]) || !isOptionalBoolean(entry["labelAsText"]) || !isOptionalBoolean(entry["keepNext"]) || !isOptionalBoolean(entry["dropPageShapes"]) || entry["indent"] !== void 0 && !isIndent(entry["indent"]) || entry["tabStops"] !== void 0 && !isTabStops(entry["tabStops"]) || entry["alignment"] !== void 0 && !isAlignment(entry["alignment"]) || entry["spacing"] !== void 0 && !isSpacing(entry["spacing"])) return `${where} carries a malformed nested placement.`;
|
|
166
167
|
const nestedNumbering = numberingIssue(entry["numbering"], where);
|
|
167
168
|
if (nestedNumbering !== null) return nestedNumbering;
|
|
168
169
|
}
|
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { XmlElement } from "../../xmlParser.js";
|
|
7
7
|
import { ParagraphNumberingOverride } from "@stll/docx-core/model";
|
|
8
|
+
/**
|
|
9
|
+
* Whether an object of a paragraph is a drawn shape fixed to the page: a
|
|
10
|
+
* single shape without a picture and without text of its own (a rule, a
|
|
11
|
+
* dot, a line), floating, with its horizontal place counted from the page
|
|
12
|
+
* or a margin. Such a mark belongs to the layout of the page it was drawn
|
|
13
|
+
* on: when the text around it is set anew it stands where that page had it.
|
|
14
|
+
* A picture, a text box, a group, a chart, an inline drawing and a shape
|
|
15
|
+
* that follows its column, character or paragraph are none.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isPageShape: (object: XmlElement) => boolean;
|
|
8
18
|
/** The mark a footnote or endnote reference leaves in a block's text. */
|
|
9
19
|
export declare const NOTE_REFERENCE_MARK = "";
|
|
10
20
|
export type AtomKind = "text" | "tab" | "lineBreak" | "pageBreak" | "noBreakHyphen" | "softHyphen" | "symbol" | "footnoteReference" | "endnoteReference" | "selfNumber" | "object";
|
|
@@ -146,6 +156,8 @@ export type ParagraphRead = {
|
|
|
146
156
|
bookmarks: ParagraphBookmark[];
|
|
147
157
|
bookmarkEnds: ParagraphBookmarkEnd[];
|
|
148
158
|
inlineObjects: number;
|
|
159
|
+
/** How many of them are drawn shapes fixed to the page. */
|
|
160
|
+
pageShapes: number;
|
|
149
161
|
/** Names of content the reader has no text for and the transfer cannot carry. */
|
|
150
162
|
unsupported: string[];
|
|
151
163
|
hasSectionBreak: boolean;
|
|
@@ -4,6 +4,54 @@ import { paraIdAttribute } from "../../paraIdAttribute.js";
|
|
|
4
4
|
import { getLocalName } from "../../xmlParser.js";
|
|
5
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
|
+
/** What a horizontal position is counted from when it is fixed to the page
|
|
8
|
+
* rather than to the text the drawing is anchored in. */
|
|
9
|
+
const PAGE_FIXED = /* @__PURE__ */ new Set([
|
|
10
|
+
"page",
|
|
11
|
+
"margin",
|
|
12
|
+
"leftMargin",
|
|
13
|
+
"rightMargin",
|
|
14
|
+
"insideMargin",
|
|
15
|
+
"outsideMargin"
|
|
16
|
+
]);
|
|
17
|
+
const SHAPE_GRAPHIC = "wordprocessingShape";
|
|
18
|
+
/** What makes a drawing more than a mark: a picture, text of its own. */
|
|
19
|
+
const SHAPE_CONTENT = /* @__PURE__ */ new Set([
|
|
20
|
+
"pic",
|
|
21
|
+
"blip",
|
|
22
|
+
"txbx",
|
|
23
|
+
"txbxContent",
|
|
24
|
+
"linkedTxbx"
|
|
25
|
+
]);
|
|
26
|
+
/**
|
|
27
|
+
* Whether an object of a paragraph is a drawn shape fixed to the page: a
|
|
28
|
+
* single shape without a picture and without text of its own (a rule, a
|
|
29
|
+
* dot, a line), floating, with its horizontal place counted from the page
|
|
30
|
+
* or a margin. Such a mark belongs to the layout of the page it was drawn
|
|
31
|
+
* on: when the text around it is set anew it stands where that page had it.
|
|
32
|
+
* A picture, a text box, a group, a chart, an inline drawing and a shape
|
|
33
|
+
* that follows its column, character or paragraph are none.
|
|
34
|
+
*/
|
|
35
|
+
const isPageShape = (object) => {
|
|
36
|
+
let anchors = 0;
|
|
37
|
+
let fixed = false;
|
|
38
|
+
let plain = true;
|
|
39
|
+
let shapes = 0;
|
|
40
|
+
const stack = [object];
|
|
41
|
+
for (let element = stack.pop(); element !== void 0; element = stack.pop()) {
|
|
42
|
+
const local = getLocalName(element.name);
|
|
43
|
+
if (local === "Fallback") continue;
|
|
44
|
+
if (local === "anchor") anchors += 1;
|
|
45
|
+
else if (local === "inline") plain = false;
|
|
46
|
+
else if (local === "positionH") fixed = PAGE_FIXED.has(String(element.attributes?.["relativeFrom"] ?? ""));
|
|
47
|
+
else if (local === "graphicData") {
|
|
48
|
+
shapes += 1;
|
|
49
|
+
plain &&= String(element.attributes?.["uri"] ?? "").endsWith(SHAPE_GRAPHIC);
|
|
50
|
+
} else if (SHAPE_CONTENT.has(local)) plain = false;
|
|
51
|
+
stack.push(...elementChildren(element));
|
|
52
|
+
}
|
|
53
|
+
return anchors === 1 && shapes === 1 && fixed && plain;
|
|
54
|
+
};
|
|
7
55
|
/** The mark a footnote or endnote reference leaves in a block's text. */
|
|
8
56
|
const NOTE_REFERENCE_MARK = "";
|
|
9
57
|
/**
|
|
@@ -262,6 +310,7 @@ const readRun = (run, walk, context) => {
|
|
|
262
310
|
const object = (element) => {
|
|
263
311
|
if (inCode(state)) return;
|
|
264
312
|
read.inlineObjects += 1;
|
|
313
|
+
read.pageShapes += isPageShape(element) ? 1 : 0;
|
|
265
314
|
const inside = countContentRevisions(element);
|
|
266
315
|
state.trackedChanges += inside;
|
|
267
316
|
state.untaggedRevisions += state.keepsRevisions ? inside : 0;
|
|
@@ -496,6 +545,7 @@ const readParagraph = (element, state) => {
|
|
|
496
545
|
bookmarks: [],
|
|
497
546
|
bookmarkEnds: [],
|
|
498
547
|
inlineObjects: 0,
|
|
548
|
+
pageShapes: 0,
|
|
499
549
|
unsupported: [],
|
|
500
550
|
hasSectionBreak: wChild(properties, "sectPr") !== null,
|
|
501
551
|
pageBreakBefore: toggleOf(wChild(properties, "pageBreakBefore")),
|
|
@@ -609,4 +659,4 @@ const walkBlocks = (container, visitor, depth = 0) => {
|
|
|
609
659
|
} else if (name === null || !IGNORED_BLOCK_CHILDREN.has(name)) visitor.unread(child);
|
|
610
660
|
}
|
|
611
661
|
};
|
|
612
|
-
export { NOTE_REFERENCE_MARK, createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks };
|
|
662
|
+
export { NOTE_REFERENCE_MARK, createStoryState, endStory, isPageShape, isSelfNumberingField, readParagraph, toggleOf, walkBlocks };
|
|
@@ -29,6 +29,35 @@ export type DocxBlockNumbering = {
|
|
|
29
29
|
*/
|
|
30
30
|
bulletFont?: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* A `REF` field of a paragraph (ECMA-376 Part 1, 17.16.5.52). Without a
|
|
34
|
+
* number switch it shows the content of the bookmark it names; with one,
|
|
35
|
+
* the number of the paragraph the bookmark stands in. A plan that places
|
|
36
|
+
* the paragraph the bookmark marks can keep the field a field: a
|
|
37
|
+
* `TemplatePlanReference` over its span to that paragraph, with its
|
|
38
|
+
* switches and its result.
|
|
39
|
+
*/
|
|
40
|
+
export type DocxBlockCrossReference = {
|
|
41
|
+
/** The span of the paragraph's `text` the field's result takes. */
|
|
42
|
+
start: number;
|
|
43
|
+
end: number;
|
|
44
|
+
/** The field's code as the document states it, e.g. ` REF Annex3 \h `. */
|
|
45
|
+
instruction: string;
|
|
46
|
+
/** The bookmark the field names. */
|
|
47
|
+
bookmark: string;
|
|
48
|
+
/**
|
|
49
|
+
* The paragraph of the main story the bookmark starts and ends in. Null
|
|
50
|
+
* when no bookmark of that name does both in one paragraph: it spans
|
|
51
|
+
* paragraphs, stands between blocks, or is not there.
|
|
52
|
+
*/
|
|
53
|
+
targetBlockId: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the bookmark holds all of that paragraph's content, so that a
|
|
56
|
+
* field without a number switch shows the paragraph's text, which is
|
|
57
|
+
* what a plan's own bookmark on the paragraph holds.
|
|
58
|
+
*/
|
|
59
|
+
targetWhole: boolean;
|
|
60
|
+
};
|
|
32
61
|
export type DocxTableCell = {
|
|
33
62
|
row: number;
|
|
34
63
|
col: number;
|
|
@@ -77,6 +106,14 @@ export type DocxBlock = {
|
|
|
77
106
|
paraId?: string;
|
|
78
107
|
/** Drawings, pictures, embedded objects and equations anchored in the block. */
|
|
79
108
|
inlineObjects: number;
|
|
109
|
+
/**
|
|
110
|
+
* How many of them are drawn shapes fixed to the page, when the block
|
|
111
|
+
* holds any: a single floating shape without a picture and without text
|
|
112
|
+
* of its own (a rule, a dot, a line) whose horizontal place is counted
|
|
113
|
+
* from the page or a margin. Such a mark belongs to the layout of the
|
|
114
|
+
* page it was drawn on; a plan may leave it out (`dropPageShapes`).
|
|
115
|
+
*/
|
|
116
|
+
pageShapes?: number;
|
|
80
117
|
/**
|
|
81
118
|
* Page breaks among the paragraph's runs, when it holds any. A paragraph
|
|
82
119
|
* without text can hold one: it is then all that starts the next page.
|
|
@@ -96,6 +133,12 @@ export type DocxBlock = {
|
|
|
96
133
|
* reference is not placed on one.
|
|
97
134
|
*/
|
|
98
135
|
revisions?: DocxBlockRevision[];
|
|
136
|
+
/**
|
|
137
|
+
* The cross-reference fields of the paragraph, in the order they stand:
|
|
138
|
+
* each `REF` field whose result lies in the paragraph's text and in no
|
|
139
|
+
* other field. Absent without one.
|
|
140
|
+
*/
|
|
141
|
+
crossReferences?: DocxBlockCrossReference[];
|
|
99
142
|
/**
|
|
100
143
|
* The paragraph starts on a new page by its own formatting or its
|
|
101
144
|
* style's (`w:pageBreakBefore`). A plan carries it over with an item's
|
|
@@ -419,6 +462,8 @@ export type TemplatePlanNestedParagraph = {
|
|
|
419
462
|
/** As on a source item. */
|
|
420
463
|
labelAsText?: boolean;
|
|
421
464
|
/** As on a source item. */
|
|
465
|
+
dropPageShapes?: boolean;
|
|
466
|
+
/** As on a source item. */
|
|
422
467
|
keepNext?: boolean;
|
|
423
468
|
/** As on a source item. */
|
|
424
469
|
indent?: TemplatePlanIndent;
|
|
@@ -493,6 +538,14 @@ export type TemplatePlanSourceItem = {
|
|
|
493
538
|
* bullet glyph and not a number a language spells.
|
|
494
539
|
*/
|
|
495
540
|
labelAsText?: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Write the paragraph without its drawn shapes that are fixed to the page
|
|
543
|
+
* (`pageShapes` of the block): marks of the page the source was laid out
|
|
544
|
+
* on, which would stand at that page's places in the output. Everything
|
|
545
|
+
* else the paragraph holds is placed as it is. The report counts what was
|
|
546
|
+
* left out.
|
|
547
|
+
*/
|
|
548
|
+
dropPageShapes?: boolean;
|
|
496
549
|
/** Join the next item of the plan, a source paragraph, into this paragraph. */
|
|
497
550
|
mergeNext?: TemplatePlanMerge;
|
|
498
551
|
/**
|
|
@@ -833,6 +886,9 @@ export type TemplatePlanReport = {
|
|
|
833
886
|
}[];
|
|
834
887
|
internalHyperlinks: number;
|
|
835
888
|
sectionBreaks: number;
|
|
889
|
+
/** Drawn shapes fixed to the page that placed paragraphs were written
|
|
890
|
+
* without, as their items asked (`dropPageShapes`). */
|
|
891
|
+
pageShapes: number;
|
|
836
892
|
};
|
|
837
893
|
/**
|
|
838
894
|
* Text effects that show nothing: those of the template the output does
|
|
@@ -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, analyzeKeptForm, analyzeSource, viewOf } from "./blocks.js";
|
|
4
|
+
import { analyzeDocument, analyzeKeptForm, analyzeSource, bookmarkEncloses, 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";
|
|
@@ -260,20 +260,6 @@ const statedProperties = (paragraph) => {
|
|
|
260
260
|
};
|
|
261
261
|
/** Whether a kept paragraph states what the template's states. */
|
|
262
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
|
-
*/
|
|
269
|
-
const bookmarkEncloses = (read, name) => {
|
|
270
|
-
const start = read?.bookmarks.find((bookmark) => bookmark.name === name);
|
|
271
|
-
const end = start === void 0 ? void 0 : read?.bookmarkEnds.find(({ id }) => id === start.id);
|
|
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;
|
|
276
|
-
};
|
|
277
263
|
const segmentLength = (segment) => piecesContent(segment.kind === "piece" ? [segment.piece] : segment.pieces).text.length;
|
|
278
264
|
/** The rows and cells of a table, without the ids of what they hold. */
|
|
279
265
|
const tableShape = (block) => JSON.stringify((block.block.cells ?? []).map(({ row, col, blockIds }) => [
|
|
@@ -670,7 +656,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
670
656
|
const usesNumber = /\\n\b/u.test(entry.reference.instruction);
|
|
671
657
|
let predictedText = null;
|
|
672
658
|
if (targetBlock !== void 0) {
|
|
673
|
-
if (!hasNumberSwitch) predictedText = targetBlock.block.text;
|
|
659
|
+
if (!hasNumberSwitch) predictedText = targetBlock.block.selfNumbers === void 0 ? targetBlock.block.text : null;
|
|
674
660
|
else if (usesNumber) {
|
|
675
661
|
const number = /\\t\b/u.test(entry.reference.instruction) ? targetBlock.label?.numberOnly ?? null : targetBlock.label?.paragraphNumber ?? null;
|
|
676
662
|
predictedText = number === null ? null : applyRefCaseFormat(number, refCaseFormat(entry.reference.instruction));
|
|
@@ -1064,6 +1050,8 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1064
1050
|
if (counts.labelChanged > 0) warnings.push(`${counts.labelChanged} block(s) render a label that differs from the source's.`);
|
|
1065
1051
|
const placedReads = resolvedParagraphs.flatMap(({ parts }) => parts.flatMap(({ block }) => block.read === null ? [] : [block.read]));
|
|
1066
1052
|
const droppedFields = /* @__PURE__ */ new Map();
|
|
1053
|
+
let pageShapes = 0;
|
|
1054
|
+
for (const paragraph of new Set(resolved.byBlockId.values())) for (const part of paragraph.parts) pageShapes += part.droppedPageShapes;
|
|
1067
1055
|
let internalHyperlinks = 0;
|
|
1068
1056
|
for (const read of placedReads) {
|
|
1069
1057
|
for (const index of read.fieldIndices) {
|
|
@@ -1142,7 +1130,8 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1142
1130
|
count
|
|
1143
1131
|
})),
|
|
1144
1132
|
internalHyperlinks,
|
|
1145
|
-
sectionBreaks
|
|
1133
|
+
sectionBreaks,
|
|
1134
|
+
pageShapes
|
|
1146
1135
|
},
|
|
1147
1136
|
textEffects,
|
|
1148
1137
|
updateFields,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { serializeTableGeometryChange } from "./reviewResolutionProvenance.js";
|
|
1
2
|
import { intAttr } from "./serializer/xmlUtils.js";
|
|
2
3
|
import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS, gridColumnsInRows } from "@stll/docx-core/model";
|
|
3
4
|
// src/docx/tableGridXml.ts
|
|
@@ -12,6 +13,20 @@ import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS, gridColumnsInRows } from "@
|
|
|
12
13
|
* to sit in. At most {@link MAX_GRID_COLUMNS}.
|
|
13
14
|
*/
|
|
14
15
|
const gridColumnCount = (table) => Math.min(gridColumnsInRows(table.rows), MAX_GRID_COLUMNS);
|
|
16
|
+
const currentGridColumnCount = (table, change) => {
|
|
17
|
+
const geometry = change?.geometryChange;
|
|
18
|
+
if (change === void 0 || geometry === void 0) return gridColumnCount(table);
|
|
19
|
+
if (geometry.type === "mergeCells") return change.columnWidths.length;
|
|
20
|
+
const ids = new Set(geometry.revisionIds);
|
|
21
|
+
const rows = table.rows.map((row) => ({
|
|
22
|
+
...row,
|
|
23
|
+
cells: row.cells.filter(({ structuralChange }) => structuralChange?.type !== "tableCellDeletion" || !ids.has(structuralChange.info.id))
|
|
24
|
+
}));
|
|
25
|
+
return gridColumnCount({
|
|
26
|
+
...table,
|
|
27
|
+
rows
|
|
28
|
+
});
|
|
29
|
+
};
|
|
15
30
|
/**
|
|
16
31
|
* Serialize `w:tblGridChange`: the grid a reviewer replaced, from the change's
|
|
17
32
|
* own record rather than from the bytes it arrived as.
|
|
@@ -20,9 +35,10 @@ const gridColumnCount = (table) => Math.min(gridColumnsInRows(table.rows), MAX_G
|
|
|
20
35
|
* measure for is written back without one; spelling it as a zero would claim a
|
|
21
36
|
* width the source never stated.
|
|
22
37
|
*/
|
|
23
|
-
const serializeTableGridChange = (
|
|
38
|
+
const serializeTableGridChange = (change) => {
|
|
39
|
+
const { id, columnWidths } = change;
|
|
24
40
|
const columns = columnWidths.map((width) => width === void 0 ? "<w:gridCol/>" : `<w:gridCol w:w="${intAttr(width)}"/>`).join("");
|
|
25
|
-
return `<w:tblGridChange w:id="${intAttr(id)}"><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
|
|
41
|
+
return `<w:tblGridChange w:id="${intAttr(id)}"${serializeTableGeometryChange(change)}><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
|
|
26
42
|
};
|
|
27
43
|
/**
|
|
28
44
|
* `w:tblGrid` from the model.
|
|
@@ -40,7 +56,7 @@ const modelTableGrid = (table) => {
|
|
|
40
56
|
const gridChange = change === void 0 ? "" : serializeTableGridChange(change);
|
|
41
57
|
const columnWidths = table.columnWidths;
|
|
42
58
|
if (columnWidths && columnWidths.length > 0) return `<w:tblGrid>${columnWidths.map((w) => `<w:gridCol w:w="${intAttr(w)}"/>`).join("")}${gridChange}</w:tblGrid>`;
|
|
43
|
-
const columns =
|
|
59
|
+
const columns = currentGridColumnCount(table, change);
|
|
44
60
|
return columns === 0 && gridChange === "" ? "<w:tblGrid/>" : `<w:tblGrid>${"<w:gridCol/>".repeat(columns)}${gridChange}</w:tblGrid>`;
|
|
45
61
|
};
|
|
46
62
|
export { MAX_GRID_COLUMNS, gridColumnCount, modelTableGrid };
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -8,6 +8,7 @@ import { parseParagraph } from "./paragraphParser.js";
|
|
|
8
8
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
9
9
|
import { FloatingTableXSpecSchema, FloatingTableYSpecSchema, TableAlignmentSchema, TextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
10
10
|
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
11
|
+
import { parseTableGeometryChange } from "./reviewResolutionProvenance.js";
|
|
11
12
|
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
12
13
|
import { parseShading } from "./shadingParser.js";
|
|
13
14
|
import { findChildAnySpelling } from "./strictNames.js";
|
|
@@ -1171,6 +1172,7 @@ function parseTableGridChange(gridElement) {
|
|
|
1171
1172
|
const snapshot = findChild(changeElement, "w", "tblGrid");
|
|
1172
1173
|
return {
|
|
1173
1174
|
id: parseTrackedChangeInfo(changeElement).id,
|
|
1175
|
+
...parseTableGeometryChange(changeElement),
|
|
1174
1176
|
columnWidths: (snapshot === null ? [] : findChildren(snapshot, "w", "gridCol")).map((column) => parseNumericAttribute(column, "w", "w"))
|
|
1175
1177
|
};
|
|
1176
1178
|
}
|
|
@@ -1359,7 +1361,7 @@ function parseTable(tblElement, styles, theme, numbering, rels, media, options)
|
|
|
1359
1361
|
if (table.rows.length === 0) return;
|
|
1360
1362
|
if (preservedChildren.length > 0) table.preserved = { children: preservedChildren };
|
|
1361
1363
|
if (bookmarks.length > 0) table.bookmarks = bookmarks;
|
|
1362
|
-
inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
1364
|
+
if (table.formatting?.gridChange?.geometryChange === void 0) inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
1363
1365
|
const captured = table.formatting;
|
|
1364
1366
|
if (captured?.gridSourceXml !== void 0 && captured.gridSourceXml === modelTableGrid(table)) {
|
|
1365
1367
|
const { gridSourceXml: _modelGrid, ...rest } = captured;
|
|
@@ -204,23 +204,23 @@ const insertColumn = (side) => (rect, _state, changed) => {
|
|
|
204
204
|
}
|
|
205
205
|
}];
|
|
206
206
|
};
|
|
207
|
-
/**
|
|
207
|
+
/** One grid change covers the selection, including any spans it narrows. */
|
|
208
208
|
const deleteColumns = (rect) => {
|
|
209
209
|
const at = tableAnchor(rect, {
|
|
210
210
|
left: rect.left,
|
|
211
211
|
right: rect.right
|
|
212
212
|
});
|
|
213
213
|
if (at === void 0) return void 0;
|
|
214
|
-
const
|
|
215
|
-
|
|
214
|
+
const count = rect.right - rect.left;
|
|
215
|
+
return [{
|
|
216
216
|
type: "editTable",
|
|
217
217
|
at,
|
|
218
218
|
edit: {
|
|
219
219
|
type: DOCUMENT_OP_TYPES.DELETE_COLUMN,
|
|
220
|
-
column
|
|
220
|
+
column: rect.left,
|
|
221
|
+
...count > 1 ? { count } : {}
|
|
221
222
|
}
|
|
222
|
-
}
|
|
223
|
-
return intents;
|
|
223
|
+
}];
|
|
224
224
|
};
|
|
225
225
|
const mergeCells = (rect) => {
|
|
226
226
|
const at = tableAnchor(rect);
|
|
@@ -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,6 +81,7 @@ 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";
|
|
84
87
|
readonly placedTextBoxGroup: "story";
|
|
@@ -112,6 +115,7 @@ type ProjectionPackageInputs = {
|
|
|
112
115
|
theme: DeepReadonly<document_d_exports.Theme> | null;
|
|
113
116
|
numbering: document_d_exports.NumberingDefinitions | undefined;
|
|
114
117
|
warn: ParseContext["warn"] | undefined;
|
|
118
|
+
tableReviewGeometry: ToProseDocOptions["tableReviewGeometry"];
|
|
115
119
|
};
|
|
116
120
|
/**
|
|
117
121
|
* Converted blocks kept across projections of one story.
|
|
@@ -182,6 +186,7 @@ type TableConversionContext = {
|
|
|
182
186
|
/** Comments the story opens a range for, for the point-comment question. */
|
|
183
187
|
storyRangedCommentIds: IdMembership;
|
|
184
188
|
warnPageBreakProjection: PageBreakProjectionWarn;
|
|
189
|
+
tableReviewGeometry: ToProseDocOptions["tableReviewGeometry"];
|
|
185
190
|
/** Shares one mark instance per distinct run formatting across the conversion. */
|
|
186
191
|
createMark: MarkFactory;
|
|
187
192
|
/**
|
|
@@ -68,7 +68,7 @@ import { markupViewSources } from "./markupViewSource.js";
|
|
|
68
68
|
import { hasSinkChildren } from "./preservedSinkCarriers.js";
|
|
69
69
|
import { sdtAttrsFromProperties } from "./sdtAttrs.js";
|
|
70
70
|
import { panic } from "better-result";
|
|
71
|
-
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";
|
|
72
72
|
import { preservedCommentRangeMarkersAt } from "@stll/docx-core/ops";
|
|
73
73
|
// src/prosemirror/conversion/toProseDoc.ts
|
|
74
74
|
const DETACHED_WATERMARK_HOST = Symbol.for("stll.detachedWatermarkHost");
|
|
@@ -402,7 +402,7 @@ var ProjectionBlockCache = class {
|
|
|
402
402
|
/** The package context for these inputs, the cache started over if they changed. */
|
|
403
403
|
packageContext(inputs) {
|
|
404
404
|
const current = this.inputs;
|
|
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) 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;
|
|
406
406
|
this.inputs = inputs;
|
|
407
407
|
this.blocks = /* @__PURE__ */ new WeakMap();
|
|
408
408
|
this.context = {
|
|
@@ -412,6 +412,7 @@ var ProjectionBlockCache = class {
|
|
|
412
412
|
theme: inputs.theme,
|
|
413
413
|
pageBreakRunSourceDescendants: buildPageBreakRunSourceDescendantIndex([]),
|
|
414
414
|
warnPageBreakProjection: pageBreakProjectionWarn(inputs.warn),
|
|
415
|
+
tableReviewGeometry: inputs.tableReviewGeometry,
|
|
415
416
|
createMark: createMarkInterner(schema)
|
|
416
417
|
};
|
|
417
418
|
return this.context;
|
|
@@ -469,6 +470,7 @@ var ProjectionBlockCache = class {
|
|
|
469
470
|
theme: context.theme,
|
|
470
471
|
pageBreakRunSourceDescendants: context.pageBreakRunSourceDescendants,
|
|
471
472
|
warnPageBreakProjection: context.warnPageBreakProjection,
|
|
473
|
+
tableReviewGeometry: context.tableReviewGeometry,
|
|
472
474
|
createMark: context.createMark,
|
|
473
475
|
...story
|
|
474
476
|
});
|
|
@@ -505,7 +507,8 @@ function toProseDoc(document, options) {
|
|
|
505
507
|
styles: options?.styles ?? document.package.styles,
|
|
506
508
|
theme: options?.theme ?? document.package.theme ?? null,
|
|
507
509
|
numbering: document.package.numbering,
|
|
508
|
-
warn: options?.warn
|
|
510
|
+
warn: options?.warn,
|
|
511
|
+
tableReviewGeometry: options?.tableReviewGeometry
|
|
509
512
|
};
|
|
510
513
|
const shared = cache?.packageContext(packageInputs);
|
|
511
514
|
shared?.pageBreakRunSourceDescendants.include(paragraphs);
|
|
@@ -535,7 +538,8 @@ function toProseDoc(document, options) {
|
|
|
535
538
|
storyRangedCommentIds: story.storyRangedCommentIds,
|
|
536
539
|
openCommentIds: story.openCommentIds,
|
|
537
540
|
warnPageBreakProjection: shared?.warnPageBreakProjection ?? pageBreakProjectionWarn(options?.warn),
|
|
538
|
-
createMark: shared?.createMark ?? createMarkInterner(schema)
|
|
541
|
+
createMark: shared?.createMark ?? createMarkInterner(schema),
|
|
542
|
+
tableReviewGeometry: packageInputs.tableReviewGeometry
|
|
539
543
|
};
|
|
540
544
|
const convertBodyBlocks = (blocks) => {
|
|
541
545
|
const out = [];
|
|
@@ -1368,7 +1372,8 @@ function resolveTextFormatting(formatting, styleResolver) {
|
|
|
1368
1372
|
const styleFormatting = styleResolver.resolveRunStyle(formatting.styleId);
|
|
1369
1373
|
return mergeTextFormatting(styleFormatting, formatting);
|
|
1370
1374
|
}
|
|
1371
|
-
function convertTable(
|
|
1375
|
+
function convertTable(source, styleResolver, context) {
|
|
1376
|
+
const table = context.tableReviewGeometry === "physical" ? tableWithPhysicalColumns(source) : source;
|
|
1372
1377
|
for (const row of table.rows) for (const cell of row.cells) {
|
|
1373
1378
|
if (isCellMergeContinuation(cell) && context.pageBreakRunSourceDescendants.containsPageBreakRun(cell.content)) {
|
|
1374
1379
|
context.warnPageBreakProjection("A page break inside a vertically merged table cell paginates with the merged row");
|
|
@@ -1790,6 +1795,7 @@ function standaloneTableCellToProseMirror(cell, nodeType) {
|
|
|
1790
1795
|
storyRangedCommentIds: rangedCommentIds(cell.content),
|
|
1791
1796
|
openCommentIds: /* @__PURE__ */ new Set(),
|
|
1792
1797
|
warnPageBreakProjection: noPageBreakProjectionWarning,
|
|
1798
|
+
tableReviewGeometry: void 0,
|
|
1793
1799
|
createMark: createMarkInterner(schema)
|
|
1794
1800
|
},
|
|
1795
1801
|
isHeader: nodeType === "tableHeader",
|
|
@@ -3363,6 +3369,7 @@ function headerFooterToProseDoc(content, options) {
|
|
|
3363
3369
|
storyRangedCommentIds: rangedCommentIds(content),
|
|
3364
3370
|
openCommentIds: /* @__PURE__ */ new Set(),
|
|
3365
3371
|
warnPageBreakProjection: pageBreakProjectionWarn(options?.warn),
|
|
3372
|
+
tableReviewGeometry: options?.tableReviewGeometry,
|
|
3366
3373
|
createMark: createMarkInterner(schema)
|
|
3367
3374
|
};
|
|
3368
3375
|
const convertBlocks = (blocks) => {
|
package/dist/server.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ import { FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_E
|
|
|
36
36
|
import { applyTemplatePlan } from "./docx/server/templatePlan/apply.js";
|
|
37
37
|
import { analyzeDocxBlocks } from "./docx/server/templatePlan/blocks.js";
|
|
38
38
|
import { inspectDocxTemplate } from "./docx/server/templatePlan/inspect.js";
|
|
39
|
-
import { ApplyTemplatePlanArgs, ApplyTemplatePlanOptions, ApplyTemplatePlanResult, DocxBlock, DocxBlockManifest, DocxBlockNumbering, DocxBlockRevision, DocxCompat, DocxNote, DocxSection, DocxTableCell, DocxTemplateBookmark, DocxTemplateField, DocxTemplateInspection, DocxTemplateInvisibleEffect, DocxTemplateNumbering, DocxTemplateNumberingLevel, DocxTemplateSection, DocxTemplateStyle, DocxTextEffect, DocxTextEffectOwner, DocxTrackedChanges, TEMPLATE_PLAN_ERROR_CODES, TemplatePlan, TemplatePlanAlignment, TemplatePlanBlockResult, TemplatePlanEffectCount, TemplatePlanError, TemplatePlanErrorCode, TemplatePlanFieldLeftover, TemplatePlanHighlight, TemplatePlanIndent, TemplatePlanIssue, TemplatePlanItem, TemplatePlanMerge, TemplatePlanNestedParagraph, TemplatePlanNoteCounts, TemplatePlanNumbering, TemplatePlanNumberingPatch, TemplatePlanOmitReason, TemplatePlanReference, TemplatePlanReferenceResult, TemplatePlanReport, TemplatePlanSection, TemplatePlanSectionPage, TemplatePlanSourceItem, TemplatePlanSpacing, TemplatePlanSpanCounts, TemplatePlanTrackedChanges, TemplatePlanTrackedView, VerifyTemplatePlanOutputArgs } from "./docx/server/templatePlan/types.js";
|
|
39
|
+
import { ApplyTemplatePlanArgs, ApplyTemplatePlanOptions, ApplyTemplatePlanResult, DocxBlock, DocxBlockCrossReference, DocxBlockManifest, DocxBlockNumbering, DocxBlockRevision, DocxCompat, DocxNote, DocxSection, DocxTableCell, DocxTemplateBookmark, DocxTemplateField, DocxTemplateInspection, DocxTemplateInvisibleEffect, DocxTemplateNumbering, DocxTemplateNumberingLevel, DocxTemplateSection, DocxTemplateStyle, DocxTextEffect, DocxTextEffectOwner, DocxTrackedChanges, TEMPLATE_PLAN_ERROR_CODES, TemplatePlan, TemplatePlanAlignment, TemplatePlanBlockResult, TemplatePlanEffectCount, TemplatePlanError, TemplatePlanErrorCode, TemplatePlanFieldLeftover, TemplatePlanHighlight, TemplatePlanIndent, TemplatePlanIssue, TemplatePlanItem, TemplatePlanMerge, TemplatePlanNestedParagraph, TemplatePlanNoteCounts, TemplatePlanNumbering, TemplatePlanNumberingPatch, TemplatePlanOmitReason, TemplatePlanReference, TemplatePlanReferenceResult, TemplatePlanReport, TemplatePlanSection, TemplatePlanSectionPage, TemplatePlanSourceItem, TemplatePlanSpacing, TemplatePlanSpanCounts, TemplatePlanTrackedChanges, TemplatePlanTrackedView, VerifyTemplatePlanOutputArgs } from "./docx/server/templatePlan/types.js";
|
|
40
40
|
import { verifyTemplatePlanOutput } from "./docx/server/templatePlan/verify.js";
|
|
41
41
|
import { FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FolioDocxConformanceCheck, FolioDocxConformanceCheckId, FolioDocxConformanceCheckStatus, FolioDocxConformanceIssue, FolioDocxConformanceIssueCode, FolioDocxConformanceReport, FolioDocxConformanceStatus, ValidateDocxConformanceOptions, validateDocxConformance } from "./docx/server/validateDocxConformance.js";
|
|
42
42
|
import { GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, GenerateRedlineDocxResult, GenerateRedlineReferenceWarning, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
|
|
@@ -46,4 +46,4 @@ import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocumentPreset, Do
|
|
|
46
46
|
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
47
47
|
import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
|
|
48
48
|
import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioBlockDiff, FolioBlockProperty, FolioCompareDocxVersionsOptions, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionChangeProperty, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
|
|
49
|
-
export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type ApplyTemplatePlanArgs, type ApplyTemplatePlanOptions, type ApplyTemplatePlanResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type ChangeListFormatOptions, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxBlock, type DocxBlockManifest, type DocxBlockNumbering, type DocxBlockRevision, type DocxCompat, type DocxNote, type DocxParagraphSource, type DocxSection, type DocxTableCell, type DocxTableRowKind, type DocxTableRowPosition, type DocxTemplateBookmark, type DocxTemplateField, type DocxTemplateInspection, type DocxTemplateInvisibleEffect, type DocxTemplateNumbering, type DocxTemplateNumberingLevel, type DocxTemplateSection, type DocxTemplateStyle, type DocxTextEffect, type DocxTextEffectOwner, type DocxTrackedChanges, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractDocxTextOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioAbsorbedBlock, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioContentParagraphKind, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchInput, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewResolution, type FolioReviewResolutionSkip, type FolioReviewedStory, type FolioReviewedView, type FolioReviewerRepackReason, type FolioReviewerSaveOptions, type FolioReviewerSaveResult, type FolioRevisionStamp, FolioRoomJournalError, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, type GenerateRedlineDocxResult, type GenerateRedlineReferenceWarning, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, TEMPLATE_PLAN_ERROR_CODES, type TableCellSpec, type TemplatePlan, type TemplatePlanAlignment, type TemplatePlanBlockResult, type TemplatePlanEffectCount, TemplatePlanError, type TemplatePlanErrorCode, type TemplatePlanFieldLeftover, type TemplatePlanHighlight, type TemplatePlanIndent, type TemplatePlanIssue, type TemplatePlanItem, type TemplatePlanMerge, type TemplatePlanNestedParagraph, type TemplatePlanNoteCounts, type TemplatePlanNumbering, type TemplatePlanNumberingPatch, type TemplatePlanOmitReason, type TemplatePlanReference, type TemplatePlanReferenceResult, type TemplatePlanReport, type TemplatePlanSection, type TemplatePlanSectionPage, type TemplatePlanSourceItem, type TemplatePlanSpacing, type TemplatePlanSpanCounts, type TemplatePlanTrackedChanges, type TemplatePlanTrackedView, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, type VerifyTemplatePlanOutputArgs, analyzeDocxBlocks, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, applyTemplatePlan, assertSupportedFolioDocumentOperationVersion, bookmark, changeListFormat, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedFolioDocumentOperationRemovedBlockIds, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, inspectDocxTemplate, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance, verifyTemplatePlanOutput };
|
|
49
|
+
export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type ApplyTemplatePlanArgs, type ApplyTemplatePlanOptions, type ApplyTemplatePlanResult, BILINGUAL_TABLE_LAYOUTS, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableLayout, type BilingualTableParagraphRef, type ChangeListFormatOptions, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentPropertiesOptions, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxBlock, type DocxBlockCrossReference, type DocxBlockManifest, type DocxBlockNumbering, type DocxBlockRevision, type DocxCompat, type DocxNote, type DocxParagraphSource, type DocxSection, type DocxTableCell, type DocxTableRowKind, type DocxTableRowPosition, type DocxTemplateBookmark, type DocxTemplateField, type DocxTemplateInspection, type DocxTemplateInvisibleEffect, type DocxTemplateNumbering, type DocxTemplateNumberingLevel, type DocxTemplateSection, type DocxTemplateStyle, type DocxTextEffect, type DocxTextEffectOwner, type DocxTrackedChanges, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractDocxTextOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_BATCH_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_EXISTING_REVISION_POLICIES, FOLIO_HIGHLIGHT_COLOR_VALUES, FOLIO_LINE_SPACING_RULE_VALUES, FOLIO_LIST_NUMBER_FORMAT_VALUES, FOLIO_PAGE_BREAK_CLEAR_VALUES, FOLIO_PARAGRAPH_ALIGNMENT_VALUES, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIBlockStructuralBoundary, type FolioAIComment, type FolioAIDiagnosticBlock, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditNormalization, type FolioAIEditNormalizationCode, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineBooleanProperty, type FolioAIInlineFormatting, type FolioAIInlineFormattingPatch, type FolioAIParagraphBlock, type FolioAIParagraphSpacing, type FolioAITextRangeHandle, type FolioAbsorbedBlock, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioBlockProperty, type FolioCompareDocxVersionsOptions, type FolioContentParagraphKind, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationBatchInput, type FolioDocumentOperationBatchPrecondition, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationQueuedOperation, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationResultBase, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewResolution, type FolioReviewResolutionSkip, type FolioReviewedStory, type FolioReviewedView, type FolioReviewerRepackReason, type FolioReviewerSaveOptions, type FolioReviewerSaveResult, type FolioRevisionStamp, FolioRoomJournalError, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionChangeProperty, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type GenerateRedlineDocxOptions, GenerateRedlineDocxResourceImportError, type GenerateRedlineDocxResult, type GenerateRedlineReferenceWarning, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, TEMPLATE_PLAN_ERROR_CODES, type TableCellSpec, type TemplatePlan, type TemplatePlanAlignment, type TemplatePlanBlockResult, type TemplatePlanEffectCount, TemplatePlanError, type TemplatePlanErrorCode, type TemplatePlanFieldLeftover, type TemplatePlanHighlight, type TemplatePlanIndent, type TemplatePlanIssue, type TemplatePlanItem, type TemplatePlanMerge, type TemplatePlanNestedParagraph, type TemplatePlanNoteCounts, type TemplatePlanNumbering, type TemplatePlanNumberingPatch, type TemplatePlanOmitReason, type TemplatePlanReference, type TemplatePlanReferenceResult, type TemplatePlanReport, type TemplatePlanSection, type TemplatePlanSectionPage, type TemplatePlanSourceItem, type TemplatePlanSpacing, type TemplatePlanSpanCounts, type TemplatePlanTrackedChanges, type TemplatePlanTrackedView, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, type VerifyTemplatePlanOutputArgs, analyzeDocxBlocks, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, applyTemplatePlan, assertSupportedFolioDocumentOperationVersion, bookmark, changeListFormat, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOperationRemovedBlockIds, getFolioDocumentOutline, getFolioParaIdFromBlockId, getTrackedFolioDocumentOperationRemovedBlockIds, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, inspectDocxTemplate, isFolioAIContentBlock, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance, verifyTemplatePlanOutput };
|
|
@@ -93,7 +93,7 @@ export declare const CANONICAL_CAPABILITIES: {
|
|
|
93
93
|
readonly owner: "document-operations";
|
|
94
94
|
readonly kind: "refusal";
|
|
95
95
|
readonly adapters: readonly ["react", "vue"];
|
|
96
|
-
readonly summary: "A suggested change whose content the tracked-change records cannot express is refused: paragraph-mark run properties, a
|
|
96
|
+
readonly summary: "A suggested change whose content the tracked-change records cannot express is refused: paragraph-mark run properties, a section-ending mark resolved across a standing range boundary, a change inside a simple field holding content the field cannot hold, content a w:ins or w:del cannot hold, a block content control or custom XML element pasted or moved, an insertion after a pending paragraph mark without its former snapshot, and the removal of a block content control's only paragraph.";
|
|
97
97
|
};
|
|
98
98
|
readonly "publicOps.headlessSession": {
|
|
99
99
|
readonly owner: "document-operations";
|
|
@@ -98,7 +98,7 @@ const CANONICAL_CAPABILITIES = {
|
|
|
98
98
|
owner: "document-operations",
|
|
99
99
|
kind: "refusal",
|
|
100
100
|
adapters: ["react", "vue"],
|
|
101
|
-
summary: "A suggested change whose content the tracked-change records cannot express is refused: paragraph-mark run properties, a
|
|
101
|
+
summary: "A suggested change whose content the tracked-change records cannot express is refused: paragraph-mark run properties, a section-ending mark resolved across a standing range boundary, a change inside a simple field holding content the field cannot hold, content a w:ins or w:del cannot hold, a block content control or custom XML element pasted or moved, an insertion after a pending paragraph mark without its former snapshot, and the removal of a block content control's only paragraph."
|
|
102
102
|
},
|
|
103
103
|
[CANONICAL_GAP.publicHeadlessSession]: {
|
|
104
104
|
owner: "document-operations",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"description": "Headless DOCX engine: reads .docx into a typed OOXML model, applies every edit as a validated operation, paginates it, and writes .docx back with untouched parts byte for byte.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
"perf": "bun scripts/profile-editor.ts"
|
|
174
174
|
},
|
|
175
175
|
"dependencies": {
|
|
176
|
-
"@stll/docx-core": "^0.48.
|
|
176
|
+
"@stll/docx-core": "^0.48.1",
|
|
177
177
|
"@stll/template-conditions": "^0.7.0",
|
|
178
178
|
"@stll/utf8-boundaries": "0.2.0",
|
|
179
179
|
"better-result": "3.0.1",
|