@stll/docx-core 0.45.1 → 0.46.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/docx_kernel_bg.wasm +0 -0
- package/dist/ops/documentOps.d.ts +11 -2
- package/dist/ops/documentOps.js +41 -45
- package/package.json +1 -1
package/dist/docx_kernel_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1522,7 +1522,11 @@ export declare class DocumentOpRefusal extends DocumentOpRefusalBase<{
|
|
|
1522
1522
|
message: string;
|
|
1523
1523
|
reason: DocumentOpRefusalReason;
|
|
1524
1524
|
opType: DocumentOpType | undefined;
|
|
1525
|
-
/**
|
|
1525
|
+
/**
|
|
1526
|
+
* Paragraph-mark revision whose resolution the document blocks: it would
|
|
1527
|
+
* move text across a standing range boundary, or leave its container
|
|
1528
|
+
* without a final paragraph.
|
|
1529
|
+
*/
|
|
1526
1530
|
blockedParagraphMarkRevisionId?: number;
|
|
1527
1531
|
}> {}
|
|
1528
1532
|
/**
|
|
@@ -2018,13 +2022,18 @@ export declare const captureDocumentOp: (op: DocumentOp) => DocumentOp;
|
|
|
2018
2022
|
* one suggestion. A reply is removed with the comment it answers.
|
|
2019
2023
|
*/
|
|
2020
2024
|
export declare const suggestedCommentIds: (document: Document, suggestionId?: string) => number[];
|
|
2025
|
+
type PendingSuggestionProjectionOptions = {
|
|
2026
|
+
/** Host receipts also identify comments belonging to a pending proposal. */
|
|
2027
|
+
commentIds?: ReadonlySet<number>;
|
|
2028
|
+
onAbsorptions?: (story: OpStory, absorptions: readonly ParagraphAbsorption[]) => void;
|
|
2029
|
+
};
|
|
2021
2030
|
/**
|
|
2022
2031
|
* The document as a save writes it: every pending suggestion rejected. A
|
|
2023
2032
|
* suggestion is a proposal the host holds, not a change in the file, so the
|
|
2024
2033
|
* file reads as if it had never been made; ordinary tracked changes stay. A
|
|
2025
2034
|
* comment a suggestion proposes is left out with it.
|
|
2026
2035
|
*/
|
|
2027
|
-
export declare const withoutPendingSuggestions: (document: Document) => Result<Document, DocumentOpRefusal>;
|
|
2036
|
+
export declare const withoutPendingSuggestions: (document: Document, { commentIds, onAbsorptions }?: PendingSuggestionProjectionOptions) => Result<Document, DocumentOpRefusal>;
|
|
2028
2037
|
/**
|
|
2029
2038
|
* The revisions of one pending suggestion in a story, one info per revision
|
|
2030
2039
|
* id, in document order.
|
package/dist/ops/documentOps.js
CHANGED
|
@@ -9498,13 +9498,17 @@ const deleteBlocks = ({ document, op, applyOps }) => {
|
|
|
9498
9498
|
}]);
|
|
9499
9499
|
if (rejected.isErr()) return refuse(rejected.error.reason, rejected.error.message);
|
|
9500
9500
|
const { document: retracted, inverse, touched } = rejected.value;
|
|
9501
|
-
if ((broken.propertyChanges?.length ?? 0) === 0) return Result.ok({
|
|
9502
|
-
document: retracted,
|
|
9503
|
-
inverse,
|
|
9504
|
-
touched
|
|
9505
|
-
});
|
|
9506
9501
|
const survivor = storyParagraphs(storyBody$1(retracted, op.story)).find(({ paragraph }) => idKey(paragraph.paraId ?? "") === idKey(broken.paraId ?? ""))?.paragraph ?? panic("A taken-back insertion lost the paragraph it broke.");
|
|
9507
9502
|
const { pPrMark: _addedMark, ...restyle } = reviewFieldsOf(broken);
|
|
9503
|
+
if (!broken.propertyChanges?.length) {
|
|
9504
|
+
const recorded = last.paragraph.propertyChanges?.[0];
|
|
9505
|
+
if (!recorded || sameParagraphProperties(survivor.formatting, broken.formatting)) return Result.ok({
|
|
9506
|
+
document: retracted,
|
|
9507
|
+
inverse,
|
|
9508
|
+
touched
|
|
9509
|
+
});
|
|
9510
|
+
restyle.propertyChanges = [paragraphPropertyChange$1(recorded.info, survivor, restyle.formatting)];
|
|
9511
|
+
}
|
|
9508
9512
|
const kept = applyOps(retracted, [{
|
|
9509
9513
|
type: DOCUMENT_OP_TYPES.SET_PARAGRAPH_REVIEW,
|
|
9510
9514
|
story: op.story,
|
|
@@ -19103,7 +19107,7 @@ const joinOps = (document, { op, story, paraId, revisionId, added, depth, holder
|
|
|
19103
19107
|
...paragraph,
|
|
19104
19108
|
content: [...joining, paragraph].flatMap(({ content }) => content)
|
|
19105
19109
|
};
|
|
19106
|
-
const goesBeforeBlock = follows === "block" && added &&
|
|
19110
|
+
const goesBeforeBlock = follows === "block" && added && blocks.some((block) => block.type === "paragraph" && block !== paragraph && !joining.includes(block));
|
|
19107
19111
|
const outcome = paragraphMarkOutcome({
|
|
19108
19112
|
follows,
|
|
19109
19113
|
holdsContent: paragraphHoldsContent(chained),
|
|
@@ -19120,7 +19124,12 @@ const joinOps = (document, { op, story, paraId, revisionId, added, depth, holder
|
|
|
19120
19124
|
emptyInsertedTableBoundary: tableBoundary?.type === "blocked" && tableBoundary.reason === "review" ? "pendingReview" : "unavailable",
|
|
19121
19125
|
precededByBlock: location.index > 0
|
|
19122
19126
|
});
|
|
19123
|
-
if (outcome.kind === "refuse") return Result.err(
|
|
19127
|
+
if (outcome.kind === "refuse") return Result.err(new DocumentOpRefusal({
|
|
19128
|
+
opType: op.type,
|
|
19129
|
+
reason: outcome.reason,
|
|
19130
|
+
message: `Resolving the mark of ${paraId} would leave its container without a final paragraph.`,
|
|
19131
|
+
blockedParagraphMarkRevisionId: revisionId
|
|
19132
|
+
}));
|
|
19124
19133
|
const tableOutcome = outcome.kind === "remove" && runInReceiver !== void 0 && paragraph.content.length > 0 && ranInto.has(idKey(runInReceiver.paraId ?? "")) ? "run-in" : outcome.kind;
|
|
19125
19134
|
if (standing.length > 0 && tableOutcome === "run-in" && !followsBlock) return Result.err(new DocumentOpRefusal({
|
|
19126
19135
|
opType: op.type,
|
|
@@ -19297,7 +19306,7 @@ const removeEmptiedHolder = ({ document, story, paraId, applyOps }) => {
|
|
|
19297
19306
|
if (paragraph.content.length > 0 || paragraph.pPrMark !== void 0 || paragraph.sectionProperties !== void 0) return Result.ok(void 0);
|
|
19298
19307
|
const anchor = blocks.find((block, position) => position !== index && block.type === "paragraph");
|
|
19299
19308
|
const endsControl = index > 0 && index === blocks.length - 1 && list.at(-1)?.kind === "blockSdt" && !endsItsContainer(body, location);
|
|
19300
|
-
const standsBeforeBlock = anchor !== void 0 && isOpaqueFollower(blockFollower(blocks, index).block)
|
|
19309
|
+
const standsBeforeBlock = anchor !== void 0 && isOpaqueFollower(blockFollower(blocks, index).block);
|
|
19301
19310
|
if (!endsControl && !standsBeforeBlock && !opensSectionBeforeTrailingBoundaries(blocks, index)) return Result.ok(void 0);
|
|
19302
19311
|
const removed = applyOps(document, [anchor === void 0 ? {
|
|
19303
19312
|
type: DOCUMENT_OP_TYPES.REPLACE_BLOCKS,
|
|
@@ -25658,21 +25667,16 @@ const inspectDocumentOps = (document, ops) => applyDocumentOpsForPurpose({
|
|
|
25658
25667
|
purpose: "inspect-inverse"
|
|
25659
25668
|
});
|
|
25660
25669
|
// src/ops/suggestions.ts
|
|
25661
|
-
|
|
25662
|
-
* The ids of the revisions in a value that belong to a pending suggestion:
|
|
25663
|
-
* tracked insertions and deletions, moves, property changes and paragraph
|
|
25664
|
-
* mark revisions, at any depth.
|
|
25665
|
-
*/
|
|
25666
|
-
const suggestedRevisionIdsIn = (value, out) => {
|
|
25670
|
+
const visitSuggestionRevisions = (value, visit) => {
|
|
25667
25671
|
if (typeof value !== "object" || value === null) return;
|
|
25668
25672
|
if (Array.isArray(value)) {
|
|
25669
|
-
for (const item of value)
|
|
25673
|
+
for (const item of value) visitSuggestionRevisions(item, visit);
|
|
25670
25674
|
return;
|
|
25671
25675
|
}
|
|
25672
25676
|
const record = value;
|
|
25673
25677
|
const info = record["info"];
|
|
25674
|
-
if (typeof info === "object" && info !== null && typeof info
|
|
25675
|
-
for (const child of Object.values(record))
|
|
25678
|
+
if (typeof info === "object" && info !== null && typeof info.suggestionId === "string" && typeof info.id === "number") visit(info);
|
|
25679
|
+
for (const child of Object.values(record)) visitSuggestionRevisions(child, visit);
|
|
25676
25680
|
};
|
|
25677
25681
|
/**
|
|
25678
25682
|
* The ids of the comments pending suggestions propose: every one, or those of
|
|
@@ -25699,13 +25703,18 @@ const withoutSuggestedComments = (document, ids) => {
|
|
|
25699
25703
|
* file reads as if it had never been made; ordinary tracked changes stay. A
|
|
25700
25704
|
* comment a suggestion proposes is left out with it.
|
|
25701
25705
|
*/
|
|
25702
|
-
const withoutPendingSuggestions = (document) => {
|
|
25703
|
-
const
|
|
25706
|
+
const withoutPendingSuggestions = (document, { commentIds, onAbsorptions } = {}) => {
|
|
25707
|
+
const proposedComments = new Set(suggestedCommentIds(document));
|
|
25708
|
+
if (commentIds !== void 0) {
|
|
25709
|
+
for (const { id } of document.package.document.comments ?? []) if (commentIds.has(id)) proposedComments.add(id);
|
|
25710
|
+
}
|
|
25711
|
+
const uncommented = withoutSuggestedComments(document, [...proposedComments]);
|
|
25704
25712
|
if (uncommented.isErr()) return uncommented;
|
|
25705
25713
|
let current = uncommented.value;
|
|
25714
|
+
const receipts = [];
|
|
25706
25715
|
for (const story of documentStories(current)) {
|
|
25707
25716
|
const ids = /* @__PURE__ */ new Set();
|
|
25708
|
-
|
|
25717
|
+
visitSuggestionRevisions(storyBody$1(current, story), ({ id }) => ids.add(id));
|
|
25709
25718
|
if (ids.size === 0) continue;
|
|
25710
25719
|
const rejected = applyDocumentOp(current, {
|
|
25711
25720
|
type: DOCUMENT_OP_TYPES.RESOLVE_REVISION,
|
|
@@ -25714,8 +25723,14 @@ const withoutPendingSuggestions = (document) => {
|
|
|
25714
25723
|
decision: REVISION_DECISIONS.REJECT
|
|
25715
25724
|
});
|
|
25716
25725
|
if (rejected.isErr()) return Result.err(rejected.error);
|
|
25726
|
+
const absorbed = rejected.value.touched.absorbed;
|
|
25727
|
+
if (onAbsorptions !== void 0 && absorbed !== void 0 && absorbed.length > 0) receipts.push({
|
|
25728
|
+
story,
|
|
25729
|
+
absorbed
|
|
25730
|
+
});
|
|
25717
25731
|
current = rejected.value.document;
|
|
25718
25732
|
}
|
|
25733
|
+
for (const { story, absorbed } of receipts) onAbsorptions?.(story, absorbed);
|
|
25719
25734
|
return Result.ok(current);
|
|
25720
25735
|
};
|
|
25721
25736
|
/**
|
|
@@ -25724,20 +25739,12 @@ const withoutPendingSuggestions = (document) => {
|
|
|
25724
25739
|
*/
|
|
25725
25740
|
const suggestionRevisionInfos = (document, story, suggestionId) => {
|
|
25726
25741
|
const out = /* @__PURE__ */ new Map();
|
|
25727
|
-
const visit = (value) => {
|
|
25728
|
-
if (typeof value !== "object" || value === null) return;
|
|
25729
|
-
if (Array.isArray(value)) {
|
|
25730
|
-
for (const item of value) visit(item);
|
|
25731
|
-
return;
|
|
25732
|
-
}
|
|
25733
|
-
const record = value;
|
|
25734
|
-
const info = record["info"];
|
|
25735
|
-
if (typeof info === "object" && info !== null && info.suggestionId === suggestionId && typeof info.id === "number" && !out.has(info.id)) out.set(info.id, info);
|
|
25736
|
-
for (const child of Object.values(record)) visit(child);
|
|
25737
|
-
};
|
|
25738
25742
|
const body = storyBody$1(document, story);
|
|
25739
|
-
|
|
25740
|
-
|
|
25743
|
+
const add = (info) => {
|
|
25744
|
+
if (info.suggestionId === suggestionId && !out.has(info.id)) out.set(info.id, info);
|
|
25745
|
+
};
|
|
25746
|
+
visitSuggestionRevisions(body.content, add);
|
|
25747
|
+
for (const { info } of body.finalSectionProperties?.propertyChanges ?? []) add(info);
|
|
25741
25748
|
return [...out.values()];
|
|
25742
25749
|
};
|
|
25743
25750
|
/**
|
|
@@ -25747,20 +25754,9 @@ const suggestionRevisionInfos = (document, story, suggestionId) => {
|
|
|
25747
25754
|
const pendingSuggestionIdsIn = (document) => {
|
|
25748
25755
|
const out = /* @__PURE__ */ new Set();
|
|
25749
25756
|
for (const comment of document.package.document.comments ?? []) if (comment.suggestionId !== void 0) out.add(comment.suggestionId);
|
|
25750
|
-
const visit = (value) => {
|
|
25751
|
-
if (typeof value !== "object" || value === null) return;
|
|
25752
|
-
if (Array.isArray(value)) {
|
|
25753
|
-
for (const item of value) visit(item);
|
|
25754
|
-
return;
|
|
25755
|
-
}
|
|
25756
|
-
const record = value;
|
|
25757
|
-
const info = record["info"];
|
|
25758
|
-
if (typeof info === "object" && info !== null && typeof info.suggestionId === "string") out.add(info.suggestionId);
|
|
25759
|
-
for (const child of Object.values(record)) visit(child);
|
|
25760
|
-
};
|
|
25761
25757
|
for (const story of documentStories(document)) {
|
|
25762
25758
|
const body = storyBody$1(document, story);
|
|
25763
|
-
|
|
25759
|
+
visitSuggestionRevisions(body.content, ({ suggestionId }) => out.add(suggestionId));
|
|
25764
25760
|
for (const { info } of body.finalSectionProperties?.propertyChanges ?? []) if (info.suggestionId !== void 0) out.add(info.suggestionId);
|
|
25765
25761
|
}
|
|
25766
25762
|
return out;
|
package/package.json
CHANGED