@ai-matrx/office 0.8.15 → 0.8.16
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 +1 -1
- package/dist/docs.cjs +17 -4
- package/dist/docs.cjs.map +1 -1
- package/dist/docs.d.cts +8 -1
- package/dist/docs.d.ts +8 -1
- package/dist/docs.js +16 -3
- package/dist/docs.js.map +1 -1
- package/dist/univer-collab.cjs +56 -44
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.js +56 -44
- package/dist/univer-collab.js.map +1 -1
- package/package.json +5 -5
package/dist/univer-collab.cjs
CHANGED
|
@@ -1292,37 +1292,8 @@ var Y2 = __toESM(require("yjs"), 1);
|
|
|
1292
1292
|
var import_awareness2 = require("y-protocols/awareness");
|
|
1293
1293
|
var import_collab3 = require("@ai-matrx/data/realtime/collab");
|
|
1294
1294
|
|
|
1295
|
-
// src/docs/document-model.ts
|
|
1296
|
-
var import_core2 = require("@univerjs/core");
|
|
1297
|
-
|
|
1298
|
-
// src/univer/openEditorContent.ts
|
|
1299
|
-
var replacers = /* @__PURE__ */ new Map();
|
|
1300
|
-
var keyOf = (kind, recordId) => `${kind}:${recordId}`;
|
|
1301
|
-
function hasOpenEditorContent(kind, recordId) {
|
|
1302
|
-
return replacers.has(keyOf(kind, recordId));
|
|
1303
|
-
}
|
|
1304
|
-
async function showSavedSnapshot(kind, recordId, row) {
|
|
1305
|
-
const replace = replacers.get(keyOf(kind, recordId));
|
|
1306
|
-
if (!replace) return false;
|
|
1307
|
-
await replace(row);
|
|
1308
|
-
return true;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
// src/docs/document-model.ts
|
|
1312
|
-
function moveRangesThroughBodyEdit(ranges, actions) {
|
|
1313
|
-
const a = actions;
|
|
1314
|
-
if (!Array.isArray(a) || a[0] !== "body") return null;
|
|
1315
|
-
const sub = a[1];
|
|
1316
|
-
if (!sub || sub.et !== "text-x" || !Array.isArray(sub.e)) return null;
|
|
1317
|
-
const e = sub.e;
|
|
1318
|
-
return ranges.map((r) => {
|
|
1319
|
-
const collapsed = r.startOffset === r.endOffset;
|
|
1320
|
-
const startOffset = import_core2.TextX.transformPosition(e, r.startOffset, collapsed);
|
|
1321
|
-
return { startOffset, endOffset: collapsed ? startOffset : import_core2.TextX.transformPosition(e, r.endOffset, true) };
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
1295
|
// src/docs/remote-carets.ts
|
|
1296
|
+
var import_core2 = require("@univerjs/core");
|
|
1326
1297
|
var CARET_HEARTBEAT_MS = 2e3;
|
|
1327
1298
|
var CARET_STALE_MS = 12e3;
|
|
1328
1299
|
var CARET_MAX_RANGES = 4;
|
|
@@ -1332,6 +1303,18 @@ function publishedCaretFromSelection(sel, now) {
|
|
|
1332
1303
|
const ranges = sel.slice(0, CARET_MAX_RANGES).map((r) => ({ start: Math.min(r.startOffset, r.endOffset), end: Math.max(r.startOffset, r.endOffset) }));
|
|
1333
1304
|
return { ranges, at: now };
|
|
1334
1305
|
}
|
|
1306
|
+
function movePeerRangesThroughBodyEdit(ranges, actions) {
|
|
1307
|
+
const a = actions;
|
|
1308
|
+
if (!Array.isArray(a) || a[0] !== "body") return null;
|
|
1309
|
+
const sub = a[1];
|
|
1310
|
+
if (!sub || sub.et !== "text-x" || !Array.isArray(sub.e)) return null;
|
|
1311
|
+
const e = sub.e;
|
|
1312
|
+
return ranges.map((r) => {
|
|
1313
|
+
const collapsed = r.start === r.end;
|
|
1314
|
+
const start = import_core2.TextX.transformPosition(e, r.start, false);
|
|
1315
|
+
return { start, end: collapsed ? start : import_core2.TextX.transformPosition(e, r.end, true) };
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1335
1318
|
var sameRanges = (a, b) => a.length === b.length && a.every((r, i) => r.start === b[i].start && r.end === b[i].end);
|
|
1336
1319
|
function readCaret(raw) {
|
|
1337
1320
|
const c = raw?.caret;
|
|
@@ -1383,9 +1366,8 @@ var RemoteCaretBook = class {
|
|
|
1383
1366
|
shiftThrough(actions) {
|
|
1384
1367
|
let moved = false;
|
|
1385
1368
|
for (const c of this.carets.values()) {
|
|
1386
|
-
const
|
|
1387
|
-
if (!
|
|
1388
|
-
const ranges = next.map((r) => ({ start: r.startOffset, end: r.endOffset }));
|
|
1369
|
+
const ranges = movePeerRangesThroughBodyEdit(c.ranges, actions);
|
|
1370
|
+
if (!ranges) return false;
|
|
1389
1371
|
if (!sameRanges(ranges, c.ranges)) {
|
|
1390
1372
|
c.ranges = ranges;
|
|
1391
1373
|
moved = true;
|
|
@@ -1588,6 +1570,21 @@ function documentOtFactory(o) {
|
|
|
1588
1570
|
|
|
1589
1571
|
// src/docs/document-restore.ts
|
|
1590
1572
|
var import_collab4 = require("@ai-matrx/data/realtime/collab");
|
|
1573
|
+
|
|
1574
|
+
// src/univer/openEditorContent.ts
|
|
1575
|
+
var replacers = /* @__PURE__ */ new Map();
|
|
1576
|
+
var keyOf = (kind, recordId) => `${kind}:${recordId}`;
|
|
1577
|
+
function hasOpenEditorContent(kind, recordId) {
|
|
1578
|
+
return replacers.has(keyOf(kind, recordId));
|
|
1579
|
+
}
|
|
1580
|
+
async function showSavedSnapshot(kind, recordId, row) {
|
|
1581
|
+
const replace = replacers.get(keyOf(kind, recordId));
|
|
1582
|
+
if (!replace) return false;
|
|
1583
|
+
await replace(row);
|
|
1584
|
+
return true;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// src/docs/document-restore.ts
|
|
1591
1588
|
var defaultDeps = {
|
|
1592
1589
|
client: () => getDocsHost().getSupabase(),
|
|
1593
1590
|
roomExists: import_collab4.collabRoomExists,
|
|
@@ -3187,21 +3184,36 @@ function univerSheetsOtPort(o) {
|
|
|
3187
3184
|
settle();
|
|
3188
3185
|
});
|
|
3189
3186
|
const guarded = cs;
|
|
3190
|
-
if (!guarded[DEPTH_GUARD]
|
|
3187
|
+
if (!guarded[DEPTH_GUARD]) {
|
|
3191
3188
|
const trackers = /* @__PURE__ */ new Set();
|
|
3192
3189
|
guarded[DEPTH_GUARD] = trackers;
|
|
3193
|
-
const
|
|
3194
|
-
|
|
3195
|
-
|
|
3190
|
+
const restore = (depths) => {
|
|
3191
|
+
for (const [t, d] of depths) {
|
|
3192
|
+
if (t.stack.length > d) {
|
|
3193
|
+
t.stack.length = d;
|
|
3194
|
+
t.settle();
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
};
|
|
3198
|
+
const depthsNow = () => new Map([...trackers].map((t) => [t, t.stack.length]));
|
|
3199
|
+
if (typeof cs.executeCommand === "function") {
|
|
3200
|
+
const original = cs.executeCommand.bind(cs);
|
|
3201
|
+
cs.executeCommand = async (id, params, options) => {
|
|
3202
|
+
const depths = depthsNow();
|
|
3203
|
+
try {
|
|
3204
|
+
return await original(id, params, options);
|
|
3205
|
+
} finally {
|
|
3206
|
+
restore(depths);
|
|
3207
|
+
}
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
const originalSync = cs.syncExecuteCommand.bind(cs);
|
|
3211
|
+
cs.syncExecuteCommand = (id, params, options) => {
|
|
3212
|
+
const depths = depthsNow();
|
|
3196
3213
|
try {
|
|
3197
|
-
return
|
|
3214
|
+
return originalSync(id, params, options);
|
|
3198
3215
|
} finally {
|
|
3199
|
-
|
|
3200
|
-
if (t.stack.length > d) {
|
|
3201
|
-
t.stack.length = d;
|
|
3202
|
-
t.settle();
|
|
3203
|
-
}
|
|
3204
|
-
}
|
|
3216
|
+
restore(depths);
|
|
3205
3217
|
}
|
|
3206
3218
|
};
|
|
3207
3219
|
}
|