@adeu/core 1.18.1 → 1.18.4
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/index.cjs +54 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +54 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/engine.comment-preservation.test.ts +174 -0
- package/src/engine.ts +99 -41
- package/src/repro.comment-range-modify.test.ts +266 -0
package/dist/index.d.cts
CHANGED
|
@@ -315,6 +315,15 @@ declare class RedlineEngine {
|
|
|
315
315
|
*/
|
|
316
316
|
private _set_paragraph_style;
|
|
317
317
|
private _anchor_reply_comment;
|
|
318
|
+
/**
|
|
319
|
+
* Read a comment's author directly from the comments part. Used by
|
|
320
|
+
* _clean_wrapping_comments to decide whether a wrapping comment belongs to
|
|
321
|
+
* another author (and must be preserved when its anchored change is
|
|
322
|
+
* accepted/rejected) or to us (safe to delete). Reads the part rather than
|
|
323
|
+
* the mapper because the mapper's comments_map is not rebuilt between review
|
|
324
|
+
* actions, so it can be stale mid-batch. Returns null if not found.
|
|
325
|
+
*/
|
|
326
|
+
private _get_comment_author;
|
|
318
327
|
private _clean_wrapping_comments;
|
|
319
328
|
private _delete_comments_in_element;
|
|
320
329
|
validate_edits(edits: any[], index_offset?: number): string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -315,6 +315,15 @@ declare class RedlineEngine {
|
|
|
315
315
|
*/
|
|
316
316
|
private _set_paragraph_style;
|
|
317
317
|
private _anchor_reply_comment;
|
|
318
|
+
/**
|
|
319
|
+
* Read a comment's author directly from the comments part. Used by
|
|
320
|
+
* _clean_wrapping_comments to decide whether a wrapping comment belongs to
|
|
321
|
+
* another author (and must be preserved when its anchored change is
|
|
322
|
+
* accepted/rejected) or to us (safe to delete). Reads the part rather than
|
|
323
|
+
* the mapper because the mapper's comments_map is not rebuilt between review
|
|
324
|
+
* actions, so it can be stale mid-batch. Returns null if not found.
|
|
325
|
+
*/
|
|
326
|
+
private _get_comment_author;
|
|
318
327
|
private _clean_wrapping_comments;
|
|
319
328
|
private _delete_comments_in_element;
|
|
320
329
|
validate_edits(edits: any[], index_offset?: number): string[];
|
package/dist/index.js
CHANGED
|
@@ -3822,6 +3822,27 @@ var RedlineEngine = class {
|
|
|
3822
3822
|
ref_run.appendChild(ref);
|
|
3823
3823
|
insertAfter(ref_run, new_end);
|
|
3824
3824
|
}
|
|
3825
|
+
/**
|
|
3826
|
+
* Read a comment's author directly from the comments part. Used by
|
|
3827
|
+
* _clean_wrapping_comments to decide whether a wrapping comment belongs to
|
|
3828
|
+
* another author (and must be preserved when its anchored change is
|
|
3829
|
+
* accepted/rejected) or to us (safe to delete). Reads the part rather than
|
|
3830
|
+
* the mapper because the mapper's comments_map is not rebuilt between review
|
|
3831
|
+
* actions, so it can be stale mid-batch. Returns null if not found.
|
|
3832
|
+
*/
|
|
3833
|
+
_get_comment_author(c_id) {
|
|
3834
|
+
const part = this.doc.pkg.parts.find(
|
|
3835
|
+
(p) => p.contentType === "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"
|
|
3836
|
+
);
|
|
3837
|
+
if (!part) return null;
|
|
3838
|
+
const comments = findAllDescendants(part._element, "w:comment");
|
|
3839
|
+
for (const c of comments) {
|
|
3840
|
+
if (c.getAttribute("w:id") === c_id) {
|
|
3841
|
+
return c.getAttribute("w:author");
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
return null;
|
|
3845
|
+
}
|
|
3825
3846
|
_clean_wrapping_comments(element) {
|
|
3826
3847
|
let first_node = element;
|
|
3827
3848
|
while (true) {
|
|
@@ -3886,7 +3907,11 @@ var RedlineEngine = class {
|
|
|
3886
3907
|
for (const s of starts_to_remove) {
|
|
3887
3908
|
const c_id = s.getAttribute("w:id");
|
|
3888
3909
|
if (c_id && end_ids.has(c_id)) {
|
|
3889
|
-
this.
|
|
3910
|
+
const author = this._get_comment_author(c_id);
|
|
3911
|
+
const is_own = author !== null && author === this.author;
|
|
3912
|
+
if (is_own) {
|
|
3913
|
+
this.comments_manager.deleteComment(c_id);
|
|
3914
|
+
}
|
|
3890
3915
|
if (s.parentNode) s.parentNode.removeChild(s);
|
|
3891
3916
|
for (const e of ends_to_remove) {
|
|
3892
3917
|
let e_id = null;
|
|
@@ -4015,10 +4040,9 @@ var RedlineEngine = class {
|
|
|
4015
4040
|
if (edit.target_text.includes("|")) {
|
|
4016
4041
|
matches = matches.slice(0, 1);
|
|
4017
4042
|
} else {
|
|
4018
|
-
const positions = matches.map(
|
|
4019
|
-
start,
|
|
4020
|
-
|
|
4021
|
-
]);
|
|
4043
|
+
const positions = matches.map(
|
|
4044
|
+
([start, length]) => [start, start + length]
|
|
4045
|
+
);
|
|
4022
4046
|
errors.push(
|
|
4023
4047
|
format_ambiguity_error(
|
|
4024
4048
|
i + 1 + index_offset,
|
|
@@ -4095,17 +4119,18 @@ var RedlineEngine = class {
|
|
|
4095
4119
|
}
|
|
4096
4120
|
}
|
|
4097
4121
|
}
|
|
4098
|
-
if (insAuthors.size > 0
|
|
4099
|
-
const fullyWithinForeignIns =
|
|
4100
|
-
if ((match_mode === "strict" || match_mode === "first") && fullyWithinForeignIns) {
|
|
4122
|
+
if (insAuthors.size > 0) {
|
|
4123
|
+
const fullyWithinForeignIns = !hasNonForeignRealText;
|
|
4124
|
+
if (!((match_mode === "strict" || match_mode === "first") && fullyWithinForeignIns)) {
|
|
4125
|
+
errors.push(
|
|
4126
|
+
`- Edit ${i + 1 + index_offset} Failed: Modification targets an active insertion from another author (${Array.from(insAuthors).join(", ")}). Accept that change first or scope your edit outside of it.`
|
|
4127
|
+
);
|
|
4101
4128
|
continue;
|
|
4102
4129
|
}
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
...commentAuthors
|
|
4106
|
-
]);
|
|
4130
|
+
}
|
|
4131
|
+
if (commentAuthors.size > 0 && match_mode === "all") {
|
|
4107
4132
|
errors.push(
|
|
4108
|
-
`- Edit ${i + 1 + index_offset} Failed:
|
|
4133
|
+
`- Edit ${i + 1 + index_offset} Failed: match_mode="all" would sweep through a comment range from another author (${Array.from(commentAuthors).join(", ")}). Target the commented text deliberately with match_mode "strict" or "first", or scope your edit outside of it.`
|
|
4109
4134
|
);
|
|
4110
4135
|
}
|
|
4111
4136
|
}
|
|
@@ -4185,7 +4210,10 @@ var RedlineEngine = class {
|
|
|
4185
4210
|
_process_batch_internal(changes, dry_run_mode = false) {
|
|
4186
4211
|
for (const c of changes) {
|
|
4187
4212
|
if (c && typeof c === "object" && c.type === "modify" && c.target_text && c.new_text) {
|
|
4188
|
-
const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(
|
|
4213
|
+
const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(
|
|
4214
|
+
c.target_text,
|
|
4215
|
+
c.new_text
|
|
4216
|
+
);
|
|
4189
4217
|
c.target_text = strippedTarget;
|
|
4190
4218
|
c.new_text = strippedNew;
|
|
4191
4219
|
}
|
|
@@ -4201,10 +4229,7 @@ var RedlineEngine = class {
|
|
|
4201
4229
|
const action_errors = actions.length > 0 ? this.validate_review_actions(actions) : [];
|
|
4202
4230
|
const validate_edits_now = edits.length > 0 && action_errors.length > 0;
|
|
4203
4231
|
const edit_errors = validate_edits_now ? this.validate_edits(edits) : [];
|
|
4204
|
-
const all_errors = [
|
|
4205
|
-
...action_errors,
|
|
4206
|
-
...edit_errors
|
|
4207
|
-
];
|
|
4232
|
+
const all_errors = [...action_errors, ...edit_errors];
|
|
4208
4233
|
if (all_errors.length > 0) {
|
|
4209
4234
|
throw new BatchValidationError(all_errors);
|
|
4210
4235
|
}
|
|
@@ -4320,9 +4345,7 @@ var RedlineEngine = class {
|
|
|
4320
4345
|
this.clean_mapper = null;
|
|
4321
4346
|
throw err;
|
|
4322
4347
|
}
|
|
4323
|
-
applied_edits = edits.filter(
|
|
4324
|
-
(e) => e._applied_status
|
|
4325
|
-
).length;
|
|
4348
|
+
applied_edits = edits.filter((e) => e._applied_status).length;
|
|
4326
4349
|
skipped_edits = edits.length - applied_edits;
|
|
4327
4350
|
for (const edit of edits) {
|
|
4328
4351
|
const success = edit._applied_status || false;
|
|
@@ -4363,7 +4386,7 @@ var RedlineEngine = class {
|
|
|
4363
4386
|
skipped_details: this.skipped_details,
|
|
4364
4387
|
edits: edits_reports,
|
|
4365
4388
|
engine: "node",
|
|
4366
|
-
version: "1.
|
|
4389
|
+
version: "1.18.2"
|
|
4367
4390
|
};
|
|
4368
4391
|
}
|
|
4369
4392
|
apply_edits(edits, page_offsets = []) {
|
|
@@ -4807,7 +4830,10 @@ var RedlineEngine = class {
|
|
|
4807
4830
|
const t_seg = target_segs[k];
|
|
4808
4831
|
const n_seg = new_segs[k];
|
|
4809
4832
|
if (t_seg !== n_seg) {
|
|
4810
|
-
const [seg_prefix, seg_suffix] = trim_common_context(
|
|
4833
|
+
const [seg_prefix, seg_suffix] = trim_common_context(
|
|
4834
|
+
t_seg,
|
|
4835
|
+
n_seg
|
|
4836
|
+
);
|
|
4811
4837
|
const seg_target = t_seg.substring(
|
|
4812
4838
|
seg_prefix,
|
|
4813
4839
|
t_seg.length - seg_suffix
|
|
@@ -5218,7 +5244,11 @@ var RedlineEngine = class {
|
|
|
5218
5244
|
if (is_inline_first) {
|
|
5219
5245
|
const del_parent = last_del.parentNode;
|
|
5220
5246
|
if (del_parent && del_parent.tagName === "w:ins") {
|
|
5221
|
-
this._insert_and_split_ins(
|
|
5247
|
+
this._insert_and_split_ins(
|
|
5248
|
+
del_parent,
|
|
5249
|
+
last_del,
|
|
5250
|
+
result.first_node
|
|
5251
|
+
);
|
|
5222
5252
|
} else {
|
|
5223
5253
|
insertAfter(result.first_node, last_del);
|
|
5224
5254
|
}
|