@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.cjs
CHANGED
|
@@ -3873,6 +3873,27 @@ var RedlineEngine = class {
|
|
|
3873
3873
|
ref_run.appendChild(ref);
|
|
3874
3874
|
insertAfter(ref_run, new_end);
|
|
3875
3875
|
}
|
|
3876
|
+
/**
|
|
3877
|
+
* Read a comment's author directly from the comments part. Used by
|
|
3878
|
+
* _clean_wrapping_comments to decide whether a wrapping comment belongs to
|
|
3879
|
+
* another author (and must be preserved when its anchored change is
|
|
3880
|
+
* accepted/rejected) or to us (safe to delete). Reads the part rather than
|
|
3881
|
+
* the mapper because the mapper's comments_map is not rebuilt between review
|
|
3882
|
+
* actions, so it can be stale mid-batch. Returns null if not found.
|
|
3883
|
+
*/
|
|
3884
|
+
_get_comment_author(c_id) {
|
|
3885
|
+
const part = this.doc.pkg.parts.find(
|
|
3886
|
+
(p) => p.contentType === "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"
|
|
3887
|
+
);
|
|
3888
|
+
if (!part) return null;
|
|
3889
|
+
const comments = findAllDescendants(part._element, "w:comment");
|
|
3890
|
+
for (const c of comments) {
|
|
3891
|
+
if (c.getAttribute("w:id") === c_id) {
|
|
3892
|
+
return c.getAttribute("w:author");
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
return null;
|
|
3896
|
+
}
|
|
3876
3897
|
_clean_wrapping_comments(element) {
|
|
3877
3898
|
let first_node = element;
|
|
3878
3899
|
while (true) {
|
|
@@ -3937,7 +3958,11 @@ var RedlineEngine = class {
|
|
|
3937
3958
|
for (const s of starts_to_remove) {
|
|
3938
3959
|
const c_id = s.getAttribute("w:id");
|
|
3939
3960
|
if (c_id && end_ids.has(c_id)) {
|
|
3940
|
-
this.
|
|
3961
|
+
const author = this._get_comment_author(c_id);
|
|
3962
|
+
const is_own = author !== null && author === this.author;
|
|
3963
|
+
if (is_own) {
|
|
3964
|
+
this.comments_manager.deleteComment(c_id);
|
|
3965
|
+
}
|
|
3941
3966
|
if (s.parentNode) s.parentNode.removeChild(s);
|
|
3942
3967
|
for (const e of ends_to_remove) {
|
|
3943
3968
|
let e_id = null;
|
|
@@ -4066,10 +4091,9 @@ var RedlineEngine = class {
|
|
|
4066
4091
|
if (edit.target_text.includes("|")) {
|
|
4067
4092
|
matches = matches.slice(0, 1);
|
|
4068
4093
|
} else {
|
|
4069
|
-
const positions = matches.map(
|
|
4070
|
-
start,
|
|
4071
|
-
|
|
4072
|
-
]);
|
|
4094
|
+
const positions = matches.map(
|
|
4095
|
+
([start, length]) => [start, start + length]
|
|
4096
|
+
);
|
|
4073
4097
|
errors.push(
|
|
4074
4098
|
format_ambiguity_error(
|
|
4075
4099
|
i + 1 + index_offset,
|
|
@@ -4146,17 +4170,18 @@ var RedlineEngine = class {
|
|
|
4146
4170
|
}
|
|
4147
4171
|
}
|
|
4148
4172
|
}
|
|
4149
|
-
if (insAuthors.size > 0
|
|
4150
|
-
const fullyWithinForeignIns =
|
|
4151
|
-
if ((match_mode === "strict" || match_mode === "first") && fullyWithinForeignIns) {
|
|
4173
|
+
if (insAuthors.size > 0) {
|
|
4174
|
+
const fullyWithinForeignIns = !hasNonForeignRealText;
|
|
4175
|
+
if (!((match_mode === "strict" || match_mode === "first") && fullyWithinForeignIns)) {
|
|
4176
|
+
errors.push(
|
|
4177
|
+
`- 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.`
|
|
4178
|
+
);
|
|
4152
4179
|
continue;
|
|
4153
4180
|
}
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
...commentAuthors
|
|
4157
|
-
]);
|
|
4181
|
+
}
|
|
4182
|
+
if (commentAuthors.size > 0 && match_mode === "all") {
|
|
4158
4183
|
errors.push(
|
|
4159
|
-
`- Edit ${i + 1 + index_offset} Failed:
|
|
4184
|
+
`- 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.`
|
|
4160
4185
|
);
|
|
4161
4186
|
}
|
|
4162
4187
|
}
|
|
@@ -4236,7 +4261,10 @@ var RedlineEngine = class {
|
|
|
4236
4261
|
_process_batch_internal(changes, dry_run_mode = false) {
|
|
4237
4262
|
for (const c of changes) {
|
|
4238
4263
|
if (c && typeof c === "object" && c.type === "modify" && c.target_text && c.new_text) {
|
|
4239
|
-
const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(
|
|
4264
|
+
const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(
|
|
4265
|
+
c.target_text,
|
|
4266
|
+
c.new_text
|
|
4267
|
+
);
|
|
4240
4268
|
c.target_text = strippedTarget;
|
|
4241
4269
|
c.new_text = strippedNew;
|
|
4242
4270
|
}
|
|
@@ -4252,10 +4280,7 @@ var RedlineEngine = class {
|
|
|
4252
4280
|
const action_errors = actions.length > 0 ? this.validate_review_actions(actions) : [];
|
|
4253
4281
|
const validate_edits_now = edits.length > 0 && action_errors.length > 0;
|
|
4254
4282
|
const edit_errors = validate_edits_now ? this.validate_edits(edits) : [];
|
|
4255
|
-
const all_errors = [
|
|
4256
|
-
...action_errors,
|
|
4257
|
-
...edit_errors
|
|
4258
|
-
];
|
|
4283
|
+
const all_errors = [...action_errors, ...edit_errors];
|
|
4259
4284
|
if (all_errors.length > 0) {
|
|
4260
4285
|
throw new BatchValidationError(all_errors);
|
|
4261
4286
|
}
|
|
@@ -4371,9 +4396,7 @@ var RedlineEngine = class {
|
|
|
4371
4396
|
this.clean_mapper = null;
|
|
4372
4397
|
throw err;
|
|
4373
4398
|
}
|
|
4374
|
-
applied_edits = edits.filter(
|
|
4375
|
-
(e) => e._applied_status
|
|
4376
|
-
).length;
|
|
4399
|
+
applied_edits = edits.filter((e) => e._applied_status).length;
|
|
4377
4400
|
skipped_edits = edits.length - applied_edits;
|
|
4378
4401
|
for (const edit of edits) {
|
|
4379
4402
|
const success = edit._applied_status || false;
|
|
@@ -4414,7 +4437,7 @@ var RedlineEngine = class {
|
|
|
4414
4437
|
skipped_details: this.skipped_details,
|
|
4415
4438
|
edits: edits_reports,
|
|
4416
4439
|
engine: "node",
|
|
4417
|
-
version: "1.
|
|
4440
|
+
version: "1.18.2"
|
|
4418
4441
|
};
|
|
4419
4442
|
}
|
|
4420
4443
|
apply_edits(edits, page_offsets = []) {
|
|
@@ -4858,7 +4881,10 @@ var RedlineEngine = class {
|
|
|
4858
4881
|
const t_seg = target_segs[k];
|
|
4859
4882
|
const n_seg = new_segs[k];
|
|
4860
4883
|
if (t_seg !== n_seg) {
|
|
4861
|
-
const [seg_prefix, seg_suffix] = trim_common_context(
|
|
4884
|
+
const [seg_prefix, seg_suffix] = trim_common_context(
|
|
4885
|
+
t_seg,
|
|
4886
|
+
n_seg
|
|
4887
|
+
);
|
|
4862
4888
|
const seg_target = t_seg.substring(
|
|
4863
4889
|
seg_prefix,
|
|
4864
4890
|
t_seg.length - seg_suffix
|
|
@@ -5269,7 +5295,11 @@ var RedlineEngine = class {
|
|
|
5269
5295
|
if (is_inline_first) {
|
|
5270
5296
|
const del_parent = last_del.parentNode;
|
|
5271
5297
|
if (del_parent && del_parent.tagName === "w:ins") {
|
|
5272
|
-
this._insert_and_split_ins(
|
|
5298
|
+
this._insert_and_split_ins(
|
|
5299
|
+
del_parent,
|
|
5300
|
+
last_del,
|
|
5301
|
+
result.first_node
|
|
5302
|
+
);
|
|
5273
5303
|
} else {
|
|
5274
5304
|
insertAfter(result.first_node, last_del);
|
|
5275
5305
|
}
|