@ai-matrx/office 0.8.37 → 0.8.38
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/CHANGELOG.md +15 -2
- package/dist/docs.cjs +34 -22
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.cts +20 -4
- package/dist/docs.d.ts +20 -4
- package/dist/docs.js +13 -1
- package/dist/docs.js.map +1 -1
- package/dist/univer-collab.cjs +34 -24
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +22 -6
- package/dist/univer-collab.d.ts +22 -6
- package/dist/univer-collab.js +34 -24
- package/dist/univer-collab.js.map +1 -1
- package/package.json +2 -2
package/dist/univer-collab.cjs
CHANGED
|
@@ -1225,29 +1225,38 @@ function undoStacksOf(service) {
|
|
|
1225
1225
|
if (!s || !(s._undoStacks instanceof Map) || !(s._redoStacks instanceof Map)) return null;
|
|
1226
1226
|
return { undo: s._undoStacks, redo: s._redoStacks };
|
|
1227
1227
|
}
|
|
1228
|
-
function
|
|
1228
|
+
function threadThrough(list, remote) {
|
|
1229
|
+
if (!list?.length || isNoopDocsOp(remote)) return { next: null, after: remote };
|
|
1230
|
+
let R = remote;
|
|
1231
|
+
let changed = false;
|
|
1232
|
+
const next = list.map((m) => {
|
|
1233
|
+
if (m.id !== RICH_TEXT_EDITING || isNoopDocsOp(R)) return m;
|
|
1234
|
+
const own = m.params.actions;
|
|
1235
|
+
if (touchesPageSetup(own) && touchesPageSetup(R)) throw new Error("page setup");
|
|
1236
|
+
const x = transformDocsOp(own, R, "left");
|
|
1237
|
+
if (isNoopDocsOp(x.op)) throw new Error("emptied");
|
|
1238
|
+
R = transformDocsOp(R, own, "right").op;
|
|
1239
|
+
changed = true;
|
|
1240
|
+
const params = { ...m.params, actions: x.op };
|
|
1241
|
+
delete params.textRanges;
|
|
1242
|
+
delete params.layoutState;
|
|
1243
|
+
return { ...m, params };
|
|
1244
|
+
});
|
|
1245
|
+
return { next: changed ? next : null, after: R };
|
|
1246
|
+
}
|
|
1247
|
+
function rebaseUndoStack(items, remote, stack) {
|
|
1248
|
+
if (isNoopDocsOp(remote)) return 0;
|
|
1249
|
+
const first = stack === "undo" ? "undoMutations" : "redoMutations";
|
|
1250
|
+
const second = stack === "undo" ? "redoMutations" : "undoMutations";
|
|
1229
1251
|
let dropped = 0;
|
|
1230
1252
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
1231
1253
|
const item = items[i];
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
const r = transformDocsOp(m.params.actions, remote, "left");
|
|
1239
|
-
if (isNoopDocsOp(r.op)) ok3 = false;
|
|
1240
|
-
else {
|
|
1241
|
-
m.params = { ...m.params, actions: r.op };
|
|
1242
|
-
delete m.params.textRanges;
|
|
1243
|
-
delete m.params.layoutState;
|
|
1244
|
-
}
|
|
1245
|
-
} catch {
|
|
1246
|
-
ok3 = false;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
}
|
|
1250
|
-
if (!ok3) {
|
|
1254
|
+
try {
|
|
1255
|
+
const a = threadThrough(item[first], remote);
|
|
1256
|
+
const b = threadThrough(item[second], a.after);
|
|
1257
|
+
if (a.next) item[first] = a.next;
|
|
1258
|
+
if (b.next) item[second] = b.next;
|
|
1259
|
+
} catch {
|
|
1251
1260
|
items.splice(i, 1);
|
|
1252
1261
|
dropped++;
|
|
1253
1262
|
}
|
|
@@ -1268,6 +1277,7 @@ function openDocsOtRoom(o) {
|
|
|
1268
1277
|
}
|
|
1269
1278
|
};
|
|
1270
1279
|
const applyNow = (op) => {
|
|
1280
|
+
for (const t of port.undoTargets()) t.flushHistory?.();
|
|
1271
1281
|
for (const b of branches(op)) {
|
|
1272
1282
|
const params = { segmentId: segmentOf(b), actions: b };
|
|
1273
1283
|
port.applyRemote(RICH_TEXT_EDITING, params);
|
|
@@ -1275,10 +1285,10 @@ function openDocsOtRoom(o) {
|
|
|
1275
1285
|
for (const t of port.undoTargets()) {
|
|
1276
1286
|
const stacks = undoStacksOf(t.service);
|
|
1277
1287
|
if (!stacks) continue;
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1288
|
+
const undo = stacks.undo.get(t.unitId);
|
|
1289
|
+
if (undo?.length) rebaseUndoStack(undo, op, "undo");
|
|
1290
|
+
const redo = stacks.redo.get(t.unitId);
|
|
1291
|
+
if (redo?.length) rebaseUndoStack(redo, op, "redo");
|
|
1282
1292
|
}
|
|
1283
1293
|
port.markDirty();
|
|
1284
1294
|
};
|