@adeu/core 1.19.0 → 1.20.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/index.cjs CHANGED
@@ -1941,7 +1941,16 @@ ${header}`;
1941
1941
  if (preceding[i].run) return [preceding[i].run, preceding[i].paragraph];
1942
1942
  }
1943
1943
  for (let i = preceding.length - 1; i >= 0; i--) {
1944
- if (preceding[i].paragraph) return [null, preceding[i].paragraph];
1944
+ const para = preceding[i].paragraph;
1945
+ if (para) {
1946
+ for (let j = this.spans.length - 1; j >= 0; j--) {
1947
+ const prev = this.spans[j];
1948
+ if (prev.end <= index && prev.run !== null && prev.paragraph === para) {
1949
+ return [prev.run, prev.paragraph];
1950
+ }
1951
+ }
1952
+ return [null, para];
1953
+ }
1945
1954
  }
1946
1955
  }
1947
1956
  const containing = this.spans.filter(
@@ -3085,9 +3094,8 @@ var RedlineEngine = class {
3085
3094
  let raw_sub_edits = [];
3086
3095
  try {
3087
3096
  raw_sub_edits = generate_edits_from_text(target_str, new_str);
3088
- console.log("_word_diff_sub_edits RAW_SUB_EDITS:", JSON.stringify(raw_sub_edits, null, 2));
3089
3097
  } catch (e) {
3090
- console.warn("generate_edits_from_text failed, falling back to wholesale edit", e);
3098
+ console.error("generate_edits_from_text failed, falling back to wholesale edit", e);
3091
3099
  raw_sub_edits = [];
3092
3100
  }
3093
3101
  if (!raw_sub_edits || raw_sub_edits.length === 0) {
@@ -5360,19 +5368,24 @@ var RedlineEngine = class {
5360
5368
  const is_inline_first = result.first_node.tagName === "w:ins";
5361
5369
  if (is_inline_first) {
5362
5370
  if (anchor_run) {
5363
- const anchor_parent = anchor_run._element.parentNode;
5371
+ let anchor_el = anchor_run._element;
5372
+ let anchor_parent = anchor_el.parentNode;
5373
+ if (anchor_parent && anchor_parent.tagName === "w:del") {
5374
+ anchor_el = anchor_parent;
5375
+ anchor_parent = anchor_el.parentNode;
5376
+ }
5364
5377
  const before_anchor = start_idx === 0;
5365
5378
  if (anchor_parent && anchor_parent.tagName === "w:ins") {
5366
5379
  this._insert_and_split_ins(
5367
5380
  anchor_parent,
5368
- anchor_run._element,
5381
+ anchor_el,
5369
5382
  result.first_node,
5370
5383
  before_anchor
5371
5384
  );
5372
5385
  } else if (before_anchor && anchor_parent) {
5373
- anchor_parent.insertBefore(result.first_node, anchor_run._element);
5386
+ anchor_parent.insertBefore(result.first_node, anchor_el);
5374
5387
  } else {
5375
- insertAfter(result.first_node, anchor_run._element);
5388
+ insertAfter(result.first_node, anchor_el);
5376
5389
  }
5377
5390
  } else if (anchor_para) {
5378
5391
  const para_el = anchor_para._element;