@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 +20 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/engine.ts +15 -7
- package/src/mapper.ts +21 -1
- package/src/repro.insertion-anchor.test.ts +91 -0
package/dist/index.js
CHANGED
|
@@ -1890,7 +1890,16 @@ ${header}`;
|
|
|
1890
1890
|
if (preceding[i].run) return [preceding[i].run, preceding[i].paragraph];
|
|
1891
1891
|
}
|
|
1892
1892
|
for (let i = preceding.length - 1; i >= 0; i--) {
|
|
1893
|
-
|
|
1893
|
+
const para = preceding[i].paragraph;
|
|
1894
|
+
if (para) {
|
|
1895
|
+
for (let j = this.spans.length - 1; j >= 0; j--) {
|
|
1896
|
+
const prev = this.spans[j];
|
|
1897
|
+
if (prev.end <= index && prev.run !== null && prev.paragraph === para) {
|
|
1898
|
+
return [prev.run, prev.paragraph];
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return [null, para];
|
|
1902
|
+
}
|
|
1894
1903
|
}
|
|
1895
1904
|
}
|
|
1896
1905
|
const containing = this.spans.filter(
|
|
@@ -3034,9 +3043,8 @@ var RedlineEngine = class {
|
|
|
3034
3043
|
let raw_sub_edits = [];
|
|
3035
3044
|
try {
|
|
3036
3045
|
raw_sub_edits = generate_edits_from_text(target_str, new_str);
|
|
3037
|
-
console.log("_word_diff_sub_edits RAW_SUB_EDITS:", JSON.stringify(raw_sub_edits, null, 2));
|
|
3038
3046
|
} catch (e) {
|
|
3039
|
-
console.
|
|
3047
|
+
console.error("generate_edits_from_text failed, falling back to wholesale edit", e);
|
|
3040
3048
|
raw_sub_edits = [];
|
|
3041
3049
|
}
|
|
3042
3050
|
if (!raw_sub_edits || raw_sub_edits.length === 0) {
|
|
@@ -5309,19 +5317,24 @@ var RedlineEngine = class {
|
|
|
5309
5317
|
const is_inline_first = result.first_node.tagName === "w:ins";
|
|
5310
5318
|
if (is_inline_first) {
|
|
5311
5319
|
if (anchor_run) {
|
|
5312
|
-
|
|
5320
|
+
let anchor_el = anchor_run._element;
|
|
5321
|
+
let anchor_parent = anchor_el.parentNode;
|
|
5322
|
+
if (anchor_parent && anchor_parent.tagName === "w:del") {
|
|
5323
|
+
anchor_el = anchor_parent;
|
|
5324
|
+
anchor_parent = anchor_el.parentNode;
|
|
5325
|
+
}
|
|
5313
5326
|
const before_anchor = start_idx === 0;
|
|
5314
5327
|
if (anchor_parent && anchor_parent.tagName === "w:ins") {
|
|
5315
5328
|
this._insert_and_split_ins(
|
|
5316
5329
|
anchor_parent,
|
|
5317
|
-
|
|
5330
|
+
anchor_el,
|
|
5318
5331
|
result.first_node,
|
|
5319
5332
|
before_anchor
|
|
5320
5333
|
);
|
|
5321
5334
|
} else if (before_anchor && anchor_parent) {
|
|
5322
|
-
anchor_parent.insertBefore(result.first_node,
|
|
5335
|
+
anchor_parent.insertBefore(result.first_node, anchor_el);
|
|
5323
5336
|
} else {
|
|
5324
|
-
insertAfter(result.first_node,
|
|
5337
|
+
insertAfter(result.first_node, anchor_el);
|
|
5325
5338
|
}
|
|
5326
5339
|
} else if (anchor_para) {
|
|
5327
5340
|
const para_el = anchor_para._element;
|