@ai-matrx/office 0.8.35 → 0.8.36
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 +19 -1
- package/dist/collab-sheets-transform.cjs +103 -6
- package/dist/collab-sheets-transform.cjs.map +1 -1
- package/dist/collab-sheets-transform.d.cts +2 -2
- package/dist/collab-sheets-transform.d.ts +2 -2
- package/dist/collab-sheets-transform.js +103 -6
- package/dist/collab-sheets-transform.js.map +1 -1
- package/dist/sheets-comment-anchors.cjs.map +1 -1
- package/dist/sheets-comment-anchors.d.cts +15 -0
- package/dist/sheets-comment-anchors.d.ts +15 -0
- package/dist/sheets-comment-anchors.js.map +1 -1
- package/dist/univer-collab.cjs +105 -8
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +1 -1
- package/dist/univer-collab.d.ts +1 -1
- package/dist/univer-collab.js +105 -8
- package/dist/univer-collab.js.map +1 -1
- package/package.json +3 -3
package/dist/univer-collab.d.cts
CHANGED
|
@@ -569,7 +569,7 @@ type SheetOp = SheetMutation[] | null;
|
|
|
569
569
|
* The room's protocol (§6.4): Univer 1.0.4 + transformer `SHEET_TRANSFORMER_VERSION`. Any Univer or transformer
|
|
570
570
|
* change raises it; a room at another proto opens read-only for this build.
|
|
571
571
|
*/
|
|
572
|
-
declare const SHEETS_COLLAB_PROTO =
|
|
572
|
+
declare const SHEETS_COLLAB_PROTO = 4;
|
|
573
573
|
/**
|
|
574
574
|
* Every Sheets protocol this package still reads (the fold, the server): each proto's transforms are a superset of
|
|
575
575
|
* the one before, so a room still at an older protocol folds here. Raising the proto appends, never replaces.
|
package/dist/univer-collab.d.ts
CHANGED
|
@@ -569,7 +569,7 @@ type SheetOp = SheetMutation[] | null;
|
|
|
569
569
|
* The room's protocol (§6.4): Univer 1.0.4 + transformer `SHEET_TRANSFORMER_VERSION`. Any Univer or transformer
|
|
570
570
|
* change raises it; a room at another proto opens read-only for this build.
|
|
571
571
|
*/
|
|
572
|
-
declare const SHEETS_COLLAB_PROTO =
|
|
572
|
+
declare const SHEETS_COLLAB_PROTO = 4;
|
|
573
573
|
/**
|
|
574
574
|
* Every Sheets protocol this package still reads (the fold, the server): each proto's transforms are a superset of
|
|
575
575
|
* the one before, so a room still at an older protocol folds here. Raising the proto appends, never replaces.
|
package/dist/univer-collab.js
CHANGED
|
@@ -1824,6 +1824,10 @@ var SHEET_MUTATIONS = {
|
|
|
1824
1824
|
"data-validation.mutation.updateRule": covered("dv", "ruleId", "payload", "source", "derived"),
|
|
1825
1825
|
"data-validation.mutation.removeRule": covered("dv", "ruleId", "source", "derived"),
|
|
1826
1826
|
"sheet.mutation.set-filter-range": covered("filter", "range", "derived"),
|
|
1827
|
+
// C5f: Univer's cell notes, keyed by note id, anchored to one cell (their transform: comment-anchor-transform.ts)
|
|
1828
|
+
"sheet.mutation.update-note": covered("note", "sheetId", "row", "col", "note", "silent", "derived"),
|
|
1829
|
+
"sheet.mutation.remove-note": covered("note", "sheetId", "noteId", "row", "col", "silent", "derived"),
|
|
1830
|
+
"sheet.mutation.update-note-position": covered("note", "sheetId", "noteId", "row", "col", "newPosition", "silent", "derived"),
|
|
1827
1831
|
"sheet.mutation.set-filter-criteria": covered("filter", "col", "criteria", "reCalc", "derived"),
|
|
1828
1832
|
"sheet.mutation.remove-filter": covered("filter", "derived"),
|
|
1829
1833
|
"sheet.mutation.add-table": barrier("C5c", RESOURCE),
|
|
@@ -1836,9 +1840,6 @@ var SHEET_MUTATIONS = {
|
|
|
1836
1840
|
"sheets.mutation.update-hyper-link": barrier("C5c", RESOURCE),
|
|
1837
1841
|
"sheets.mutation.update-hyper-link-ref": barrier("C5c", RESOURCE),
|
|
1838
1842
|
"sheets.mutation.update-rich-hyper-link": barrier("C5c", RESOURCE),
|
|
1839
|
-
"sheet.mutation.update-note": barrier("C5c", RESOURCE),
|
|
1840
|
-
"sheet.mutation.remove-note": barrier("C5c", RESOURCE),
|
|
1841
|
-
"sheet.mutation.update-note-position": barrier("C5c", RESOURCE),
|
|
1842
1843
|
"sheet.mutation.set-drawing-apply": barrier("C5c", RESOURCE),
|
|
1843
1844
|
"sheet.mutation.set-worksheet-background-image": barrier("C5c", RESOURCE),
|
|
1844
1845
|
"sheet.mutation.add-range-theme": barrier("C5c", RESOURCE),
|
|
@@ -2262,7 +2263,88 @@ var label = (m) => {
|
|
|
2262
2263
|
const c = cellOf(m);
|
|
2263
2264
|
return `${String(m.params.subUnitId ?? "")}!${c ? sheetCellName(c) : "?"} comment`;
|
|
2264
2265
|
};
|
|
2266
|
+
var UPDATE_NOTE = "sheet.mutation.update-note";
|
|
2267
|
+
var REMOVE_NOTE = "sheet.mutation.remove-note";
|
|
2268
|
+
var UPDATE_NOTE_POSITION = "sheet.mutation.update-note-position";
|
|
2269
|
+
var NOTE_IDS = /* @__PURE__ */ new Set([UPDATE_NOTE, REMOVE_NOTE, UPDATE_NOTE_POSITION]);
|
|
2270
|
+
var isNoteMutation = (id) => NOTE_IDS.has(id);
|
|
2271
|
+
var cellAt = (row, col) => typeof row === "number" && typeof col === "number" ? { row, col } : null;
|
|
2272
|
+
function noteRef(m) {
|
|
2273
|
+
const p = m.params;
|
|
2274
|
+
const sheet = String(p.sheetId ?? "");
|
|
2275
|
+
if (m.id === UPDATE_NOTE) return { role: "write", sheet, id: p.note?.id ? String(p.note.id) : null, cell: cellAt(p.row, p.col) };
|
|
2276
|
+
if (m.id === UPDATE_NOTE_POSITION) return { role: "move", sheet, id: p.noteId ? String(p.noteId) : null, cell: cellAt(p.newPosition?.row, p.newPosition?.col) };
|
|
2277
|
+
return { role: "remove", sheet, id: p.noteId ? String(p.noteId) : null, cell: p.noteId ? null : cellAt(p.row, p.col) };
|
|
2278
|
+
}
|
|
2279
|
+
var noteDerived = (m) => m.params.derived === true;
|
|
2280
|
+
var noteLabel = (n) => `${n.sheet}!${n.cell ? sheetCellName(n.cell) : "?"} note`;
|
|
2281
|
+
var tellNote = (m, n) => noteDerived(m) ? [] : [noteLabel(n)];
|
|
2282
|
+
var noteBarrier = (reason) => ({ barrier: true, reason: `note: ${reason}` });
|
|
2283
|
+
var removeNoteOf = (sheet, id) => ({ id: REMOVE_NOTE, params: { sheetId: sheet, noteId: id, derived: true } });
|
|
2284
|
+
var moveNoteTo = (sheet, id, cell) => ({
|
|
2285
|
+
id: UPDATE_NOTE_POSITION,
|
|
2286
|
+
params: { sheetId: sheet, noteId: id, newPosition: { row: cell.row, col: cell.col }, derived: true }
|
|
2287
|
+
});
|
|
2288
|
+
var onSheet = (m, sheet) => String(m.params.subUnitId ?? "") === sheet;
|
|
2289
|
+
function transformCellNote(x, y, side) {
|
|
2290
|
+
const xn = isNoteMutation(x.id);
|
|
2291
|
+
const yn = isNoteMutation(y.id);
|
|
2292
|
+
if (!xn && !yn) return null;
|
|
2293
|
+
if (!xn) {
|
|
2294
|
+
const n2 = noteRef(y);
|
|
2295
|
+
if (n2.role === "remove" || !n2.cell || !onSheet(x, n2.sheet)) return ok([x]);
|
|
2296
|
+
if (x.id === REMOVE_SHEET) return n2.id ? ok([removeNoteOf(n2.sheet, n2.id), x]) : ok([x]);
|
|
2297
|
+
if (!structuralAxisOp(x.id, x.params)) return ok([x]);
|
|
2298
|
+
if (!n2.id) return noteBarrier("a note without an id against a row or column change");
|
|
2299
|
+
const moved = moveSheetAnchorCell(n2.cell, n2.sheet, x.id, x.params);
|
|
2300
|
+
if (!moved) return ok([x, removeNoteOf(n2.sheet, n2.id)]);
|
|
2301
|
+
return moved === n2.cell ? ok([x]) : ok([x, moveNoteTo(n2.sheet, n2.id, moved)]);
|
|
2302
|
+
}
|
|
2303
|
+
const n = noteRef(x);
|
|
2304
|
+
if (!yn) {
|
|
2305
|
+
if (!onSheet(y, n.sheet)) return ok([x]);
|
|
2306
|
+
if (y.id === REMOVE_SHEET) return ok([], [], tellNote(x, n));
|
|
2307
|
+
if (!structuralAxisOp(y.id, y.params)) return ok([x]);
|
|
2308
|
+
if (n.role === "write" && !n.id) return noteBarrier("a note without an id against a row or column change");
|
|
2309
|
+
const p = x.params;
|
|
2310
|
+
const from = cellAt(p.row, p.col);
|
|
2311
|
+
const fromMoved = from ? moveSheetAnchorCell(from, n.sheet, y.id, y.params) : null;
|
|
2312
|
+
if (n.role === "remove") {
|
|
2313
|
+
if (n.id) return ok([x]);
|
|
2314
|
+
return fromMoved ? ok([{ id: x.id, params: { ...p, row: fromMoved.row, col: fromMoved.col } }]) : ok([]);
|
|
2315
|
+
}
|
|
2316
|
+
const moved = n.cell ? moveSheetAnchorCell(n.cell, n.sheet, y.id, y.params) : null;
|
|
2317
|
+
if (n.role === "write") {
|
|
2318
|
+
if (!moved) return ok([], [], tellNote(x, n));
|
|
2319
|
+
return ok([moved === n.cell ? x : { id: x.id, params: { ...p, row: moved.row, col: moved.col } }]);
|
|
2320
|
+
}
|
|
2321
|
+
if (!moved) return n.id ? ok([removeNoteOf(n.sheet, n.id)], [], tellNote(x, n)) : ok([], [], tellNote(x, n));
|
|
2322
|
+
const params = { ...p, newPosition: { ...p.newPosition, row: moved.row, col: moved.col } };
|
|
2323
|
+
if (fromMoved) Object.assign(params, { row: fromMoved.row, col: fromMoved.col });
|
|
2324
|
+
return ok([{ id: x.id, params }]);
|
|
2325
|
+
}
|
|
2326
|
+
const m = noteRef(y);
|
|
2327
|
+
if (n.sheet !== m.sheet) return ok([x]);
|
|
2328
|
+
if (!n.id || !m.id) return noteBarrier("a note change addressed by cell against another note change on its sheet");
|
|
2329
|
+
if (n.id !== m.id) {
|
|
2330
|
+
const sameCell = n.cell && m.cell && n.cell.row === m.cell.row && n.cell.col === m.cell.col;
|
|
2331
|
+
return sameCell ? noteBarrier("two notes written to one cell at once") : ok([x]);
|
|
2332
|
+
}
|
|
2333
|
+
if (n.role === "remove") return ok([x]);
|
|
2334
|
+
if (m.role === "remove") return ok([], [], tellNote(x, n));
|
|
2335
|
+
if (n.role === "write" && m.role === "move") {
|
|
2336
|
+
return m.cell ? ok([{ id: x.id, params: { ...x.params, row: m.cell.row, col: m.cell.col } }]) : ok([x]);
|
|
2337
|
+
}
|
|
2338
|
+
if (n.role === "move" && m.role === "write") return ok([x]);
|
|
2339
|
+
const dx = noteDerived(x);
|
|
2340
|
+
const dy = noteDerived(y);
|
|
2341
|
+
if (dx && dy) return ok([x]);
|
|
2342
|
+
const xWins = dx !== dy ? !dx : side === "left";
|
|
2343
|
+
return xWins ? ok([x], tellNote(y, m)) : ok([], [], tellNote(x, n));
|
|
2344
|
+
}
|
|
2265
2345
|
function transformCommentAnchor(x, y, side) {
|
|
2346
|
+
const note = transformCellNote(x, y, side);
|
|
2347
|
+
if (note) return note;
|
|
2266
2348
|
const xa = x.id === SET_SHEET_COMMENT_ANCHOR;
|
|
2267
2349
|
const ya = y.id === SET_SHEET_COMMENT_ANCHOR;
|
|
2268
2350
|
if (!xa && !ya) return null;
|
|
@@ -2383,7 +2465,7 @@ registerRangedResource({
|
|
|
2383
2465
|
});
|
|
2384
2466
|
|
|
2385
2467
|
// src/collab/sheets/transform/transform.ts
|
|
2386
|
-
var SHEET_TRANSFORMER_VERSION = "
|
|
2468
|
+
var SHEET_TRANSFORMER_VERSION = "c5f-1";
|
|
2387
2469
|
var ID = {
|
|
2388
2470
|
values: "sheet.mutation.set-range-values",
|
|
2389
2471
|
insertRow: "sheet.mutation.insert-row",
|
|
@@ -2472,6 +2554,21 @@ function buildStructural(template, axis, op) {
|
|
|
2472
2554
|
const start = op.kind === "insert" ? op.at : op.start;
|
|
2473
2555
|
return { id: template.id, params: { ...p, range: { ...p.range, [a0]: start, [a1]: start + op.count - 1 } } };
|
|
2474
2556
|
}
|
|
2557
|
+
function crossThrough(x, sy) {
|
|
2558
|
+
const [a0, a1] = S(sy.axis);
|
|
2559
|
+
const p = x.params;
|
|
2560
|
+
const params = { ...p };
|
|
2561
|
+
for (const k of ["range", "sourceRange", "targetRange"]) {
|
|
2562
|
+
const r = p[k];
|
|
2563
|
+
if (!r || typeof r[a0] !== "number" || typeof r[a1] !== "number") continue;
|
|
2564
|
+
const spans = spanThrough(sy.op, r[a0], r[a1]);
|
|
2565
|
+
if (!spans.length) continue;
|
|
2566
|
+
const lo = r[a0] === 0 ? 0 : Math.min(...spans.map(([l]) => l));
|
|
2567
|
+
const hi = Math.max(...spans.map(([, h]) => h));
|
|
2568
|
+
params[k] = { ...r, [a0]: lo, [a1]: hi };
|
|
2569
|
+
}
|
|
2570
|
+
return { id: x.id, params };
|
|
2571
|
+
}
|
|
2475
2572
|
function univerMutationInfo(axis, op) {
|
|
2476
2573
|
const FULL2 = { startRow: 0, endRow: Number.MAX_SAFE_INTEGER, startColumn: 0, endColumn: Number.MAX_SAFE_INTEGER };
|
|
2477
2574
|
const start = op.kind === "insert" ? op.at : op.start;
|
|
@@ -3195,7 +3292,7 @@ function annotateSheetOpsInOrder(group, sheetOrder) {
|
|
|
3195
3292
|
let structural = false;
|
|
3196
3293
|
return group.map((m0) => {
|
|
3197
3294
|
if (structuralOf(m0)) structural = true;
|
|
3198
|
-
const m = structural && rangedSpecOf(m0.id) && !isDerived(m0) ? { id: m0.id, params: { ...m0.params, derived: true } } : m0;
|
|
3295
|
+
const m = structural && (rangedSpecOf(m0.id) || isNoteMutation(m0.id)) && !isDerived(m0) ? { id: m0.id, params: { ...m0.params, derived: true } } : m0;
|
|
3199
3296
|
if (m.id === ID.insertSheet) {
|
|
3200
3297
|
const index = typeof m.params.index === "number" ? Math.min(m.params.index, order.length) : order.length;
|
|
3201
3298
|
order.splice(index, 0, sheetIdOf(m));
|
|
@@ -3442,7 +3539,7 @@ function transformMutation(x, y, side) {
|
|
|
3442
3539
|
const np = numfmtPair(x, y, side, sx, sy);
|
|
3443
3540
|
if (np) return np;
|
|
3444
3541
|
if (sx && sy) {
|
|
3445
|
-
if (sx.axis !== sy.axis) return ok2([x]);
|
|
3542
|
+
if (sx.axis !== sy.axis) return ok2([crossThrough(x, sy)]);
|
|
3446
3543
|
const out = transformAxis(sx.op, sy.op, side);
|
|
3447
3544
|
if (!out) return barrier2(`${x.id} over ${y.id}: moved blocks overlap in part, or the block would split`);
|
|
3448
3545
|
const dropped = out.length === 0 && sx.op.kind === "move" ? [`${sheetOf(x)}: moved ${sx.axis}s`] : [];
|
|
@@ -3664,8 +3761,8 @@ async function sheetsStateHash(snapshot) {
|
|
|
3664
3761
|
}
|
|
3665
3762
|
|
|
3666
3763
|
// src/univer/collab/sheets-ot/room.ts
|
|
3667
|
-
var SHEETS_COLLAB_PROTO =
|
|
3668
|
-
var SHEETS_READABLE_PROTOS = [2, SHEETS_COLLAB_PROTO];
|
|
3764
|
+
var SHEETS_COLLAB_PROTO = 4;
|
|
3765
|
+
var SHEETS_READABLE_PROTOS = [2, 3, SHEETS_COLLAB_PROTO];
|
|
3669
3766
|
var SHEETS_EDIT_GROUP = "sheets.edit";
|
|
3670
3767
|
var flip2 = (side) => side === "left" ? "right" : "left";
|
|
3671
3768
|
var isNoopSheetOp = (op) => op == null || op.length === 0;
|