docx-diff-editor 1.0.27 → 1.0.28
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.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -185,6 +185,18 @@ function getMarksAtPosition(spans, pos) {
|
|
|
185
185
|
}
|
|
186
186
|
return [];
|
|
187
187
|
}
|
|
188
|
+
function hasDefinedAttributes(marks) {
|
|
189
|
+
if (!marks || marks.length === 0) return false;
|
|
190
|
+
for (const mark of marks) {
|
|
191
|
+
if (!mark.attrs) continue;
|
|
192
|
+
for (const value of Object.values(mark.attrs)) {
|
|
193
|
+
if (value !== void 0 && value !== null) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return marks.some((m) => !m.attrs);
|
|
199
|
+
}
|
|
188
200
|
function detectFormatChanges(spansA, spansB, segments) {
|
|
189
201
|
const formatChanges = [];
|
|
190
202
|
let posA = 0;
|
|
@@ -208,13 +220,17 @@ function detectFormatChanges(spansA, spansB, segments) {
|
|
|
208
220
|
break;
|
|
209
221
|
}
|
|
210
222
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
if (hasDefinedAttributes(startMarksB) || hasDefinedAttributes(startMarksA)) {
|
|
224
|
+
if (hasDefinedAttributes(startMarksB)) {
|
|
225
|
+
formatChanges.push({
|
|
226
|
+
from: posA + startI,
|
|
227
|
+
to: posA + i,
|
|
228
|
+
text: segment.text.substring(startI, i),
|
|
229
|
+
before: startMarksA,
|
|
230
|
+
after: startMarksB
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
218
234
|
} else {
|
|
219
235
|
i++;
|
|
220
236
|
}
|