@adeu/core 1.18.1 → 1.18.2

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.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.comments_manager.deleteComment(c_id);
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(([start, length]) => [
4019
- start,
4020
- start + length
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,
@@ -4185,7 +4209,10 @@ var RedlineEngine = class {
4185
4209
  _process_batch_internal(changes, dry_run_mode = false) {
4186
4210
  for (const c of changes) {
4187
4211
  if (c && typeof c === "object" && c.type === "modify" && c.target_text && c.new_text) {
4188
- const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(c.target_text, c.new_text);
4212
+ const [strippedTarget, strippedNew] = stripMatchingHeadingHashes(
4213
+ c.target_text,
4214
+ c.new_text
4215
+ );
4189
4216
  c.target_text = strippedTarget;
4190
4217
  c.new_text = strippedNew;
4191
4218
  }
@@ -4201,10 +4228,7 @@ var RedlineEngine = class {
4201
4228
  const action_errors = actions.length > 0 ? this.validate_review_actions(actions) : [];
4202
4229
  const validate_edits_now = edits.length > 0 && action_errors.length > 0;
4203
4230
  const edit_errors = validate_edits_now ? this.validate_edits(edits) : [];
4204
- const all_errors = [
4205
- ...action_errors,
4206
- ...edit_errors
4207
- ];
4231
+ const all_errors = [...action_errors, ...edit_errors];
4208
4232
  if (all_errors.length > 0) {
4209
4233
  throw new BatchValidationError(all_errors);
4210
4234
  }
@@ -4320,9 +4344,7 @@ var RedlineEngine = class {
4320
4344
  this.clean_mapper = null;
4321
4345
  throw err;
4322
4346
  }
4323
- applied_edits = edits.filter(
4324
- (e) => e._applied_status
4325
- ).length;
4347
+ applied_edits = edits.filter((e) => e._applied_status).length;
4326
4348
  skipped_edits = edits.length - applied_edits;
4327
4349
  for (const edit of edits) {
4328
4350
  const success = edit._applied_status || false;
@@ -4363,7 +4385,7 @@ var RedlineEngine = class {
4363
4385
  skipped_details: this.skipped_details,
4364
4386
  edits: edits_reports,
4365
4387
  engine: "node",
4366
- version: "1.10.0"
4388
+ version: "1.18.2"
4367
4389
  };
4368
4390
  }
4369
4391
  apply_edits(edits, page_offsets = []) {
@@ -4807,7 +4829,10 @@ var RedlineEngine = class {
4807
4829
  const t_seg = target_segs[k];
4808
4830
  const n_seg = new_segs[k];
4809
4831
  if (t_seg !== n_seg) {
4810
- const [seg_prefix, seg_suffix] = trim_common_context(t_seg, n_seg);
4832
+ const [seg_prefix, seg_suffix] = trim_common_context(
4833
+ t_seg,
4834
+ n_seg
4835
+ );
4811
4836
  const seg_target = t_seg.substring(
4812
4837
  seg_prefix,
4813
4838
  t_seg.length - seg_suffix
@@ -5218,7 +5243,11 @@ var RedlineEngine = class {
5218
5243
  if (is_inline_first) {
5219
5244
  const del_parent = last_del.parentNode;
5220
5245
  if (del_parent && del_parent.tagName === "w:ins") {
5221
- this._insert_and_split_ins(del_parent, last_del, result.first_node);
5246
+ this._insert_and_split_ins(
5247
+ del_parent,
5248
+ last_del,
5249
+ result.first_node
5250
+ );
5222
5251
  } else {
5223
5252
  insertAfter(result.first_node, last_del);
5224
5253
  }