@ai-matrx/office 0.8.54 → 0.8.55
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 -0
- package/dist/collab-sheets-transform.cjs +60 -5
- package/dist/collab-sheets-transform.cjs.map +1 -1
- package/dist/collab-sheets-transform.js +60 -5
- package/dist/collab-sheets-transform.js.map +1 -1
- package/dist/univer-collab.cjs +156 -43
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +15 -1
- package/dist/univer-collab.d.ts +15 -1
- package/dist/univer-collab.js +156 -43
- package/dist/univer-collab.js.map +1 -1
- package/package.json +6 -6
package/dist/univer-collab.d.cts
CHANGED
|
@@ -646,6 +646,12 @@ interface SheetsOtPort {
|
|
|
646
646
|
beforeUndo?(fn: () => void): () => void;
|
|
647
647
|
/** Ask for a save (the record's one coalesced save). */
|
|
648
648
|
markDirty(): void;
|
|
649
|
+
/** The cell this seat is on now (its primary selection), for its chip on the other seats; null when unknown. */
|
|
650
|
+
cursor?(): {
|
|
651
|
+
sheetId: string;
|
|
652
|
+
row: number;
|
|
653
|
+
col: number;
|
|
654
|
+
} | null;
|
|
649
655
|
}
|
|
650
656
|
/**
|
|
651
657
|
* `resynced`: this seat's workbook disagreed with the room's (a peer's quiet hash, a save's hash or an ack) and the
|
|
@@ -1017,9 +1023,17 @@ interface WorkbookOtRoomHandle {
|
|
|
1017
1023
|
}): void;
|
|
1018
1024
|
stop(): void;
|
|
1019
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* This seat's awareness as it joins: who it is and the cell it is on now. A peer's chip draws at a cell, so a seat that
|
|
1028
|
+
* joined with no cell had no chip on the others' screens until its person clicked one (the gate's F3: minutes, while
|
|
1029
|
+
* that person deleted a sheet). The port's current cell (Univer always has one, A1 at load) is there from the start.
|
|
1030
|
+
*/
|
|
1031
|
+
declare function joiningAwareness(o: Pick<WorkbookOtRoomOptions, "uid" | "clientId" | "displayName" | "avatarUrl">, port: Pick<SheetsOtPort, "cursor">): Omit<AwarenessState, "color"> & {
|
|
1032
|
+
clientId: string;
|
|
1033
|
+
};
|
|
1020
1034
|
/** Join the workbook's ordered-log room with the editor's port (`univerSheetsOtPort`). */
|
|
1021
1035
|
declare function startWorkbookOtRoom(port: SheetsOtPort & {
|
|
1022
1036
|
dispose?: () => void;
|
|
1023
1037
|
}, o: WorkbookOtRoomOptions): Promise<WorkbookOtRoomHandle>;
|
|
1024
1038
|
|
|
1025
|
-
export { COLLAB_COVERED_KEY, type CollabBase, type CollabMutationInfo, type CollabProviderLike, type CommandServiceLike, DOCS_COLLAB_PROTO, DOCS_TRANSFORM_VERSION, DOC_LOCAL_KEYS, type DocsLocalMutation, type DocsLost, type DocsOp, type DocsOtNotice, type DocsOtPort, type DocsOtRoom, type DocsTransformResult, type DocumentOtFactoryOptions, type DocumentRestoreDeps, type DocumentRestoreResult, type EditedCell, type EditorBridgeLike, type FilterRangeLike, type FilterServiceLike, type OpenDocsOtRoomOptions, type OpenSheetsOtRoomOptions, type OtRoomsKnob, REDO_COMMAND, RICH_TEXT_EDITING, SENDER_VIEW_PARAMS, SHEETS_COLLAB_PROTO, SHEETS_EDIT_GROUP, SHEETS_READABLE_PROTOS, SHEET_ROOM_EDITOR_PRESETS, SHEET_ROOM_PLUGIN_PACKAGES, type SheetOp, type SheetSelection, type SheetsCommandService, type SheetsLocalEvent, type SheetsLocalGroup, type SheetsNotShared, type SheetsOtAdapter, type SheetsOtAdapterHooks, type SheetsOtNotice, type SheetsOtPort, type SheetsOtRoom, type SheetsWorkbookLike, type SheetsWorksheetLike, UNDO_COMMAND, type UniverSheetsOtPortOptions, WorkbookCollabSession, type WorkbookCollabSessionOptions, type WorkbookOtRoomHandle, type WorkbookOtRoomOptions, type WorkbookOtRoomsKnob, applyDocsOp, asLoadedDocsSnapshot, canonicalDocsSnapshot, canonicalDocsString, canonicalKeys, canonicalSheet, canonicalSheetString, composeDocsOps, createSheetsOtAdapter, decodeSheetOp, docsStateHash, documentOtFactory, documentUsesOrderedRoom, dropEmptyStyleRetains, editorBridgeCell, encodeSheetOp, filterServiceRange, invertDocsOp, isCellEditorScratch, isNoopDocsOp, moveSelectionsThrough, normalizeDocsOp, offlineTextOfGroups, openDocsOtRoom, openSheetsOtRoom, rebaseSheetUndoStack, rebaseUndoStack, restoreDocumentSnapshot, sheetsStateHash, stampCovered, stampDeterministicIds, startWorkbookOtRoom, stripSenderView, takeCovered, touchesEditedCell, transformDocsOp, transformSheetOp, transformTextX, undoStacksOf, univerSheetsOtPort, workbookUsesOrderedRoom };
|
|
1039
|
+
export { COLLAB_COVERED_KEY, type CollabBase, type CollabMutationInfo, type CollabProviderLike, type CommandServiceLike, DOCS_COLLAB_PROTO, DOCS_TRANSFORM_VERSION, DOC_LOCAL_KEYS, type DocsLocalMutation, type DocsLost, type DocsOp, type DocsOtNotice, type DocsOtPort, type DocsOtRoom, type DocsTransformResult, type DocumentOtFactoryOptions, type DocumentRestoreDeps, type DocumentRestoreResult, type EditedCell, type EditorBridgeLike, type FilterRangeLike, type FilterServiceLike, type OpenDocsOtRoomOptions, type OpenSheetsOtRoomOptions, type OtRoomsKnob, REDO_COMMAND, RICH_TEXT_EDITING, SENDER_VIEW_PARAMS, SHEETS_COLLAB_PROTO, SHEETS_EDIT_GROUP, SHEETS_READABLE_PROTOS, SHEET_ROOM_EDITOR_PRESETS, SHEET_ROOM_PLUGIN_PACKAGES, type SheetOp, type SheetSelection, type SheetsCommandService, type SheetsLocalEvent, type SheetsLocalGroup, type SheetsNotShared, type SheetsOtAdapter, type SheetsOtAdapterHooks, type SheetsOtNotice, type SheetsOtPort, type SheetsOtRoom, type SheetsWorkbookLike, type SheetsWorksheetLike, UNDO_COMMAND, type UniverSheetsOtPortOptions, WorkbookCollabSession, type WorkbookCollabSessionOptions, type WorkbookOtRoomHandle, type WorkbookOtRoomOptions, type WorkbookOtRoomsKnob, applyDocsOp, asLoadedDocsSnapshot, canonicalDocsSnapshot, canonicalDocsString, canonicalKeys, canonicalSheet, canonicalSheetString, composeDocsOps, createSheetsOtAdapter, decodeSheetOp, docsStateHash, documentOtFactory, documentUsesOrderedRoom, dropEmptyStyleRetains, editorBridgeCell, encodeSheetOp, filterServiceRange, invertDocsOp, isCellEditorScratch, isNoopDocsOp, joiningAwareness, moveSelectionsThrough, normalizeDocsOp, offlineTextOfGroups, openDocsOtRoom, openSheetsOtRoom, rebaseSheetUndoStack, rebaseUndoStack, restoreDocumentSnapshot, sheetsStateHash, stampCovered, stampDeterministicIds, startWorkbookOtRoom, stripSenderView, takeCovered, touchesEditedCell, transformDocsOp, transformSheetOp, transformTextX, undoStacksOf, univerSheetsOtPort, workbookUsesOrderedRoom };
|
package/dist/univer-collab.d.ts
CHANGED
|
@@ -646,6 +646,12 @@ interface SheetsOtPort {
|
|
|
646
646
|
beforeUndo?(fn: () => void): () => void;
|
|
647
647
|
/** Ask for a save (the record's one coalesced save). */
|
|
648
648
|
markDirty(): void;
|
|
649
|
+
/** The cell this seat is on now (its primary selection), for its chip on the other seats; null when unknown. */
|
|
650
|
+
cursor?(): {
|
|
651
|
+
sheetId: string;
|
|
652
|
+
row: number;
|
|
653
|
+
col: number;
|
|
654
|
+
} | null;
|
|
649
655
|
}
|
|
650
656
|
/**
|
|
651
657
|
* `resynced`: this seat's workbook disagreed with the room's (a peer's quiet hash, a save's hash or an ack) and the
|
|
@@ -1017,9 +1023,17 @@ interface WorkbookOtRoomHandle {
|
|
|
1017
1023
|
}): void;
|
|
1018
1024
|
stop(): void;
|
|
1019
1025
|
}
|
|
1026
|
+
/**
|
|
1027
|
+
* This seat's awareness as it joins: who it is and the cell it is on now. A peer's chip draws at a cell, so a seat that
|
|
1028
|
+
* joined with no cell had no chip on the others' screens until its person clicked one (the gate's F3: minutes, while
|
|
1029
|
+
* that person deleted a sheet). The port's current cell (Univer always has one, A1 at load) is there from the start.
|
|
1030
|
+
*/
|
|
1031
|
+
declare function joiningAwareness(o: Pick<WorkbookOtRoomOptions, "uid" | "clientId" | "displayName" | "avatarUrl">, port: Pick<SheetsOtPort, "cursor">): Omit<AwarenessState, "color"> & {
|
|
1032
|
+
clientId: string;
|
|
1033
|
+
};
|
|
1020
1034
|
/** Join the workbook's ordered-log room with the editor's port (`univerSheetsOtPort`). */
|
|
1021
1035
|
declare function startWorkbookOtRoom(port: SheetsOtPort & {
|
|
1022
1036
|
dispose?: () => void;
|
|
1023
1037
|
}, o: WorkbookOtRoomOptions): Promise<WorkbookOtRoomHandle>;
|
|
1024
1038
|
|
|
1025
|
-
export { COLLAB_COVERED_KEY, type CollabBase, type CollabMutationInfo, type CollabProviderLike, type CommandServiceLike, DOCS_COLLAB_PROTO, DOCS_TRANSFORM_VERSION, DOC_LOCAL_KEYS, type DocsLocalMutation, type DocsLost, type DocsOp, type DocsOtNotice, type DocsOtPort, type DocsOtRoom, type DocsTransformResult, type DocumentOtFactoryOptions, type DocumentRestoreDeps, type DocumentRestoreResult, type EditedCell, type EditorBridgeLike, type FilterRangeLike, type FilterServiceLike, type OpenDocsOtRoomOptions, type OpenSheetsOtRoomOptions, type OtRoomsKnob, REDO_COMMAND, RICH_TEXT_EDITING, SENDER_VIEW_PARAMS, SHEETS_COLLAB_PROTO, SHEETS_EDIT_GROUP, SHEETS_READABLE_PROTOS, SHEET_ROOM_EDITOR_PRESETS, SHEET_ROOM_PLUGIN_PACKAGES, type SheetOp, type SheetSelection, type SheetsCommandService, type SheetsLocalEvent, type SheetsLocalGroup, type SheetsNotShared, type SheetsOtAdapter, type SheetsOtAdapterHooks, type SheetsOtNotice, type SheetsOtPort, type SheetsOtRoom, type SheetsWorkbookLike, type SheetsWorksheetLike, UNDO_COMMAND, type UniverSheetsOtPortOptions, WorkbookCollabSession, type WorkbookCollabSessionOptions, type WorkbookOtRoomHandle, type WorkbookOtRoomOptions, type WorkbookOtRoomsKnob, applyDocsOp, asLoadedDocsSnapshot, canonicalDocsSnapshot, canonicalDocsString, canonicalKeys, canonicalSheet, canonicalSheetString, composeDocsOps, createSheetsOtAdapter, decodeSheetOp, docsStateHash, documentOtFactory, documentUsesOrderedRoom, dropEmptyStyleRetains, editorBridgeCell, encodeSheetOp, filterServiceRange, invertDocsOp, isCellEditorScratch, isNoopDocsOp, moveSelectionsThrough, normalizeDocsOp, offlineTextOfGroups, openDocsOtRoom, openSheetsOtRoom, rebaseSheetUndoStack, rebaseUndoStack, restoreDocumentSnapshot, sheetsStateHash, stampCovered, stampDeterministicIds, startWorkbookOtRoom, stripSenderView, takeCovered, touchesEditedCell, transformDocsOp, transformSheetOp, transformTextX, undoStacksOf, univerSheetsOtPort, workbookUsesOrderedRoom };
|
|
1039
|
+
export { COLLAB_COVERED_KEY, type CollabBase, type CollabMutationInfo, type CollabProviderLike, type CommandServiceLike, DOCS_COLLAB_PROTO, DOCS_TRANSFORM_VERSION, DOC_LOCAL_KEYS, type DocsLocalMutation, type DocsLost, type DocsOp, type DocsOtNotice, type DocsOtPort, type DocsOtRoom, type DocsTransformResult, type DocumentOtFactoryOptions, type DocumentRestoreDeps, type DocumentRestoreResult, type EditedCell, type EditorBridgeLike, type FilterRangeLike, type FilterServiceLike, type OpenDocsOtRoomOptions, type OpenSheetsOtRoomOptions, type OtRoomsKnob, REDO_COMMAND, RICH_TEXT_EDITING, SENDER_VIEW_PARAMS, SHEETS_COLLAB_PROTO, SHEETS_EDIT_GROUP, SHEETS_READABLE_PROTOS, SHEET_ROOM_EDITOR_PRESETS, SHEET_ROOM_PLUGIN_PACKAGES, type SheetOp, type SheetSelection, type SheetsCommandService, type SheetsLocalEvent, type SheetsLocalGroup, type SheetsNotShared, type SheetsOtAdapter, type SheetsOtAdapterHooks, type SheetsOtNotice, type SheetsOtPort, type SheetsOtRoom, type SheetsWorkbookLike, type SheetsWorksheetLike, UNDO_COMMAND, type UniverSheetsOtPortOptions, WorkbookCollabSession, type WorkbookCollabSessionOptions, type WorkbookOtRoomHandle, type WorkbookOtRoomOptions, type WorkbookOtRoomsKnob, applyDocsOp, asLoadedDocsSnapshot, canonicalDocsSnapshot, canonicalDocsString, canonicalKeys, canonicalSheet, canonicalSheetString, composeDocsOps, createSheetsOtAdapter, decodeSheetOp, docsStateHash, documentOtFactory, documentUsesOrderedRoom, dropEmptyStyleRetains, editorBridgeCell, encodeSheetOp, filterServiceRange, invertDocsOp, isCellEditorScratch, isNoopDocsOp, joiningAwareness, moveSelectionsThrough, normalizeDocsOp, offlineTextOfGroups, openDocsOtRoom, openSheetsOtRoom, rebaseSheetUndoStack, rebaseUndoStack, restoreDocumentSnapshot, sheetsStateHash, stampCovered, stampDeterministicIds, startWorkbookOtRoom, stripSenderView, takeCovered, touchesEditedCell, transformDocsOp, transformSheetOp, transformTextX, undoStacksOf, univerSheetsOtPort, workbookUsesOrderedRoom };
|
package/dist/univer-collab.js
CHANGED
|
@@ -1802,6 +1802,12 @@ var SHEET_MUTATIONS = {
|
|
|
1802
1802
|
"sheet.mutation.set-worksheet-row-is-auto-height": covered("size", "ranges", "autoHeightInfo"),
|
|
1803
1803
|
"sheet.mutation.set-worksheet-row-auto-height": covered("size", "rowsAutoHeightInfo"),
|
|
1804
1804
|
"sheet.mutation.set-worksheet-col-width": covered("size", "ranges", "colWidth"),
|
|
1805
|
+
// a row or column's hidden flag (`hd`): per index like a size, the later of two wins (the gate's F5: Make table
|
|
1806
|
+
// hides its Record ID column, which was rolled back as "not shared" in a room)
|
|
1807
|
+
"sheet.mutation.set-row-hidden": covered("size", "ranges"),
|
|
1808
|
+
"sheet.mutation.set-row-visible": covered("size", "ranges"),
|
|
1809
|
+
"sheet.mutation.set-col-hidden": covered("size", "ranges"),
|
|
1810
|
+
"sheet.mutation.set-col-visible": covered("size", "ranges"),
|
|
1805
1811
|
"sheet.mutation.set-worksheet-name": covered("name", "name"),
|
|
1806
1812
|
// ── covered (C5c) ────────────────────────────────────────────────────────────────────────────────
|
|
1807
1813
|
"sheet.mutation.set.numfmt": covered("numfmt", "values", "refMap"),
|
|
@@ -1858,10 +1864,6 @@ var SHEET_MUTATIONS = {
|
|
|
1858
1864
|
"sheet.mutation.set-frozen": barrier("X", "absolute frozen indices: not in C5a"),
|
|
1859
1865
|
"sheet.mutation.set-row-data": barrier("X", "row properties by index: not in C5a"),
|
|
1860
1866
|
"sheet.mutation.set-col-data": barrier("X", "column properties by index: not in C5a"),
|
|
1861
|
-
"sheet.mutation.set-row-hidden": barrier("X", "row visibility: not in C5a"),
|
|
1862
|
-
"sheet.mutation.set-row-visible": barrier("X", "row visibility: not in C5a"),
|
|
1863
|
-
"sheet.mutation.set-col-hidden": barrier("X", "column visibility: not in C5a"),
|
|
1864
|
-
"sheet.mutation.set-col-visible": barrier("X", "column visibility: not in C5a"),
|
|
1865
1867
|
"sheet.mutation.add-range-protection": barrier("X", "permissions: not in C5a"),
|
|
1866
1868
|
"sheet.mutation.set-range-protection": barrier("X", "permissions: not in C5a"),
|
|
1867
1869
|
"sheet.mutation.delete-range-protection": barrier("X", "permissions: not in C5a"),
|
|
@@ -2545,6 +2547,10 @@ var ID = {
|
|
|
2545
2547
|
rowIsAuto: "sheet.mutation.set-worksheet-row-is-auto-height",
|
|
2546
2548
|
rowAutoHeight: "sheet.mutation.set-worksheet-row-auto-height",
|
|
2547
2549
|
colWidth: "sheet.mutation.set-worksheet-col-width",
|
|
2550
|
+
colHidden: "sheet.mutation.set-col-hidden",
|
|
2551
|
+
colVisible: "sheet.mutation.set-col-visible",
|
|
2552
|
+
rowHidden: "sheet.mutation.set-row-hidden",
|
|
2553
|
+
rowVisible: "sheet.mutation.set-row-visible",
|
|
2548
2554
|
name: "sheet.mutation.set-worksheet-name",
|
|
2549
2555
|
setName: "formula.mutation.set-defined-name",
|
|
2550
2556
|
removeName: "formula.mutation.remove-defined-name",
|
|
@@ -2843,7 +2849,8 @@ function transformCell(X, Y4, side) {
|
|
|
2843
2849
|
out.s = { ...outS && typeof outS === "object" ? outS : {}, n: null };
|
|
2844
2850
|
} else if (side === "right" && outS && typeof outS === "object" && "n" in outS) {
|
|
2845
2851
|
const rest = withoutStyleKeys(outS, /* @__PURE__ */ new Set(["n"]));
|
|
2846
|
-
if (
|
|
2852
|
+
if (!has(Y4.s) && Y4.s !== null) out.s = { ...rest ?? {}, n: null };
|
|
2853
|
+
else if (rest) out.s = rest;
|
|
2847
2854
|
else delete out.s;
|
|
2848
2855
|
xLost = true;
|
|
2849
2856
|
}
|
|
@@ -2881,6 +2888,34 @@ function transformCellsOverCells(x, y, side) {
|
|
|
2881
2888
|
const op = passes.filter((p) => !isEmptyMatrix(p)).map((p) => cellsMutation(x, p));
|
|
2882
2889
|
return ok2(op, lost, dropped);
|
|
2883
2890
|
}
|
|
2891
|
+
var coveredByMerge = (ranges, r, c) => ranges.some((q) => q.startRow <= r && r <= q.endRow && q.startColumn <= c && c <= q.endColumn && !(r === q.startRow && c === q.startColumn));
|
|
2892
|
+
var EMPTY_CONTENT = Object.fromEntries(CONTENT_KEYS.filter((k) => k !== "t").map((k) => [k, null]));
|
|
2893
|
+
function valuesUnderMerge(x, y) {
|
|
2894
|
+
const ranges = mergeRanges(y);
|
|
2895
|
+
const out = {};
|
|
2896
|
+
const dropped = [];
|
|
2897
|
+
let changed = false;
|
|
2898
|
+
forEachCell(cellsOf(x), (r, c, v) => {
|
|
2899
|
+
if (v === null || !hasContent(v) || !coveredByMerge(ranges, r, c)) return putCell(out, r, c, v);
|
|
2900
|
+
changed = true;
|
|
2901
|
+
if (!isDerived(x)) dropped.push(cellRef(sheetOf(x), r, c));
|
|
2902
|
+
if ("s" in v) putCell(out, r, c, { s: v.s });
|
|
2903
|
+
});
|
|
2904
|
+
if (!changed) return ok2([x]);
|
|
2905
|
+
return ok2(isEmptyMatrix(out) ? [] : [cellsMutation(x, out)], [], dropped);
|
|
2906
|
+
}
|
|
2907
|
+
function mergeOverValues(x, y) {
|
|
2908
|
+
const ranges = mergeRanges(x);
|
|
2909
|
+
const clear = {};
|
|
2910
|
+
const lost = [];
|
|
2911
|
+
forEachCell(cellsOf(y), (r, c, v) => {
|
|
2912
|
+
if (v === null || !hasContent(v) || !coveredByMerge(ranges, r, c)) return;
|
|
2913
|
+
putCell(clear, r, c, { ...EMPTY_CONTENT });
|
|
2914
|
+
if (!isDerived(y)) lost.push(cellRef(sheetOf(y), r, c));
|
|
2915
|
+
});
|
|
2916
|
+
if (isEmptyMatrix(clear)) return ok2([x]);
|
|
2917
|
+
return ok2([x, { id: ID.values, params: { subUnitId: sheetOf(x), cellValue: clear, derived: true } }], lost);
|
|
2918
|
+
}
|
|
2884
2919
|
var SIDE_CAR_PARAMS = ["refSheets", "previousName", "derived", "sheetIndex", "sheetsLeft"];
|
|
2885
2920
|
var isDerived = (m) => m.params.derived === true;
|
|
2886
2921
|
function derivedSide(x, y, side) {
|
|
@@ -3097,9 +3132,21 @@ function annotateFormulas(group, sheets, definedNames) {
|
|
|
3097
3132
|
return m;
|
|
3098
3133
|
});
|
|
3099
3134
|
}
|
|
3135
|
+
var HIDE_SHOW = {
|
|
3136
|
+
[ID.colHidden]: { axis: "col", hidden: true },
|
|
3137
|
+
[ID.colVisible]: { axis: "col", hidden: false },
|
|
3138
|
+
[ID.rowHidden]: { axis: "row", hidden: true },
|
|
3139
|
+
[ID.rowVisible]: { axis: "row", hidden: false }
|
|
3140
|
+
};
|
|
3100
3141
|
function sizeOf(m) {
|
|
3101
3142
|
const p = m.params;
|
|
3102
3143
|
const values = /* @__PURE__ */ new Map();
|
|
3144
|
+
const hs = HIDE_SHOW[m.id];
|
|
3145
|
+
if (hs) {
|
|
3146
|
+
const [a02, a12] = S(hs.axis);
|
|
3147
|
+
for (const r of p.ranges ?? []) for (let i = r[a02]; i <= r[a12]; i++) values.set(i, hs.hidden);
|
|
3148
|
+
return { axis: hs.axis, attr: "hd", values };
|
|
3149
|
+
}
|
|
3103
3150
|
if (m.id === ID.rowAutoHeight) {
|
|
3104
3151
|
for (const { row, autoHeight } of p.rowsAutoHeightInfo ?? []) values.set(row, autoHeight);
|
|
3105
3152
|
return { axis: "row", attr: "ah", values };
|
|
@@ -3119,6 +3166,12 @@ function sizeOf(m) {
|
|
|
3119
3166
|
function buildSize(template, values) {
|
|
3120
3167
|
if (values.size === 0) return null;
|
|
3121
3168
|
const p = template.params;
|
|
3169
|
+
const hs = HIDE_SHOW[template.id];
|
|
3170
|
+
if (hs) {
|
|
3171
|
+
const [a02, a12] = S(hs.axis);
|
|
3172
|
+
const first2 = (p.ranges ?? [])[0] ?? { startRow: 0, endRow: 0, startColumn: 0, endColumn: 0 };
|
|
3173
|
+
return { id: template.id, params: { ...p, ranges: runs(values.keys()).map((r) => ({ ...first2, [a02]: r.start, [a12]: r.start + r.count - 1 })) } };
|
|
3174
|
+
}
|
|
3122
3175
|
if (template.id === ID.rowAutoHeight)
|
|
3123
3176
|
return { id: template.id, params: { ...p, rowsAutoHeightInfo: [...values].sort((a, b) => a[0] - b[0]).map(([row, autoHeight]) => ({ row, autoHeight })) } };
|
|
3124
3177
|
const axis = template.id === ID.colWidth ? "col" : "row";
|
|
@@ -3664,6 +3717,8 @@ function transformMutation(x, y, side) {
|
|
|
3664
3717
|
return ok2([...pre, x, ...mid, ...add.length ? [mergeMutation(ID.addMerge, sheet, add)] : []], lostMerges);
|
|
3665
3718
|
}
|
|
3666
3719
|
if (fx === "cell" && fy === "cell") return transformCellsOverCells(x, y, side);
|
|
3720
|
+
if (x.id === ID.values && y.id === ID.addMerge) return valuesUnderMerge(x, y);
|
|
3721
|
+
if (x.id === ID.addMerge && y.id === ID.values) return mergeOverValues(x, y);
|
|
3667
3722
|
if (fx === "merge" && fy === "merge") {
|
|
3668
3723
|
const xr = mergeRanges(x);
|
|
3669
3724
|
const yr = mergeRanges(y);
|
|
@@ -4276,6 +4331,8 @@ var REMOVE_SHEET2 = "sheet.mutation.remove-sheet";
|
|
|
4276
4331
|
var FILTER_RANGE = "sheet.mutation.set-filter-range";
|
|
4277
4332
|
var RESHAPE = /* @__PURE__ */ new Set(["sheet.mutation.set-worksheet-row-count", "sheet.mutation.set-worksheet-column-count", "sheet.mutation.remove-sheet", INSERT_SHEET]);
|
|
4278
4333
|
var UNDO = "univer.command.undo";
|
|
4334
|
+
var KEYBOARD_EVENT = 4;
|
|
4335
|
+
var ESC_KEY = 27;
|
|
4279
4336
|
var REDO = "univer.command.redo";
|
|
4280
4337
|
var DEPTH_GUARD = /* @__PURE__ */ Symbol.for("ai-matrx.office.sheets.command-depth-guard");
|
|
4281
4338
|
var json = (v) => v === void 0 ? v : JSON.parse(JSON.stringify(v));
|
|
@@ -4300,6 +4357,16 @@ function univerSheetsOtPort(o) {
|
|
|
4300
4357
|
return null;
|
|
4301
4358
|
}
|
|
4302
4359
|
};
|
|
4360
|
+
const closeCellEditor = () => {
|
|
4361
|
+
const u = unitId();
|
|
4362
|
+
if (!u || !edited()) return;
|
|
4363
|
+
editorHold = false;
|
|
4364
|
+
try {
|
|
4365
|
+
cs.syncExecuteCommand("sheet.operation.set-cell-edit-visible", { eventType: KEYBOARD_EVENT, keycode: ESC_KEY, visible: false, unitId: u });
|
|
4366
|
+
} catch (err) {
|
|
4367
|
+
console.warn("[sheets-ot] could not close the cell editor before reloading the workbook", err);
|
|
4368
|
+
}
|
|
4369
|
+
};
|
|
4303
4370
|
const holding = () => {
|
|
4304
4371
|
if (editorHold && !edited()) editorHold = false;
|
|
4305
4372
|
return editorHold;
|
|
@@ -4348,38 +4415,55 @@ function univerSheetsOtPort(o) {
|
|
|
4348
4415
|
}
|
|
4349
4416
|
}
|
|
4350
4417
|
};
|
|
4418
|
+
const removedSheetRefs = (gone) => {
|
|
4419
|
+
const wb = o.workbook();
|
|
4420
|
+
const names = sheetNames();
|
|
4421
|
+
const name = names[gone];
|
|
4422
|
+
if (!wb || !name) return [];
|
|
4423
|
+
const refSheets = {};
|
|
4424
|
+
for (const [id, n] of Object.entries(names)) refSheets[n] = id;
|
|
4425
|
+
const owed = [];
|
|
4426
|
+
for (const ws of wb.getSheets()) {
|
|
4427
|
+
const sheet = ws.getSheetId();
|
|
4428
|
+
if (sheet === gone) continue;
|
|
4429
|
+
ws.getCellMatrix?.().forValue((r, c, cell) => {
|
|
4430
|
+
const f = cell?.f;
|
|
4431
|
+
if (typeof f !== "string" || !f.includes(name)) return;
|
|
4432
|
+
const out = rewriteFormula(f, { ownSheet: sheet, refSheets }, { kind: "remove-sheet", sheet: gone });
|
|
4433
|
+
if (typeof out !== "string" && out.changed) owed.push({ sheet, row: r, col: c, f: out.text });
|
|
4434
|
+
});
|
|
4435
|
+
}
|
|
4436
|
+
return owed;
|
|
4437
|
+
};
|
|
4351
4438
|
const sweepRemovedSheetRefs = (g) => {
|
|
4352
|
-
const removed = g.mutations.filter((m) => m.id === REMOVE_SHEET2).map((m) => String(m.params.subUnitId ?? ""));
|
|
4353
4439
|
const wb = o.workbook();
|
|
4354
4440
|
const u = unitId();
|
|
4355
|
-
if (!
|
|
4356
|
-
const
|
|
4357
|
-
for (const
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
if (!name) continue;
|
|
4361
|
-
for (const ws of wb.getSheets()) {
|
|
4362
|
-
const sheet = ws.getSheetId();
|
|
4363
|
-
const cells = {};
|
|
4364
|
-
ws.getCellMatrix?.().forValue((r, c, cell) => {
|
|
4365
|
-
const f = cell?.f;
|
|
4366
|
-
if (typeof f !== "string" || !f.includes(name)) return;
|
|
4367
|
-
const out = rewriteFormula(f, { ownSheet: sheet, refSheets }, { kind: "remove-sheet", sheet: gone });
|
|
4368
|
-
if (typeof out !== "string" && out.changed) (cells[r] ??= {})[c] = { f: out.text, si: null };
|
|
4369
|
-
});
|
|
4370
|
-
if (!Object.keys(cells).length) continue;
|
|
4371
|
-
applying = true;
|
|
4372
|
-
try {
|
|
4373
|
-
cs.syncExecuteCommand(VALUES, { unitId: u, subUnitId: sheet, cellValue: json(cells) });
|
|
4374
|
-
} finally {
|
|
4375
|
-
applying = false;
|
|
4376
|
-
}
|
|
4377
|
-
const done = {};
|
|
4378
|
-
for (const r of Object.keys(cells))
|
|
4379
|
-
for (const c of Object.keys(cells[r])) (done[r] ??= {})[c] = completeCellContent(cells[r][c], json(ws.getCellRaw(Number(r), Number(c)) ?? null));
|
|
4380
|
-
g.mutations.push({ id: VALUES, params: { subUnitId: sheet, cellValue: done } });
|
|
4381
|
-
g.inverses.push(void 0);
|
|
4441
|
+
if (!g.owedRefs?.length || !wb || !u) return;
|
|
4442
|
+
const written = /* @__PURE__ */ new Set();
|
|
4443
|
+
for (const m of g.mutations)
|
|
4444
|
+
if (m.id === VALUES) {
|
|
4445
|
+
for (const [r, row] of Object.entries(m.params.cellValue ?? {})) for (const [c, v] of Object.entries(row ?? {})) if (v && "f" in v) written.add(`${m.params.subUnitId}:${r}:${c}`);
|
|
4382
4446
|
}
|
|
4447
|
+
const bySheet = /* @__PURE__ */ new Map();
|
|
4448
|
+
for (const x of g.owedRefs) {
|
|
4449
|
+
if (written.has(`${x.sheet}:${x.row}:${x.col}`) || !wb.getSheetBySheetId(x.sheet)) continue;
|
|
4450
|
+
const cells = bySheet.get(x.sheet) ?? {};
|
|
4451
|
+
(cells[x.row] ??= {})[x.col] = { f: x.f, si: null };
|
|
4452
|
+
bySheet.set(x.sheet, cells);
|
|
4453
|
+
}
|
|
4454
|
+
for (const [sheet, cells] of bySheet) {
|
|
4455
|
+
const ws = wb.getSheetBySheetId(sheet);
|
|
4456
|
+
applying = true;
|
|
4457
|
+
try {
|
|
4458
|
+
cs.syncExecuteCommand(VALUES, { unitId: u, subUnitId: sheet, cellValue: json(cells) });
|
|
4459
|
+
} finally {
|
|
4460
|
+
applying = false;
|
|
4461
|
+
}
|
|
4462
|
+
const done = {};
|
|
4463
|
+
for (const r of Object.keys(cells))
|
|
4464
|
+
for (const c of Object.keys(cells[r])) (done[r] ??= {})[c] = completeCellContent(cells[r][c], json(ws.getCellRaw(Number(r), Number(c)) ?? null));
|
|
4465
|
+
g.mutations.push({ id: VALUES, params: { subUnitId: sheet, cellValue: done } });
|
|
4466
|
+
g.inverses.push(void 0);
|
|
4383
4467
|
}
|
|
4384
4468
|
};
|
|
4385
4469
|
const flush = () => {
|
|
@@ -4426,6 +4510,7 @@ function univerSheetsOtPort(o) {
|
|
|
4426
4510
|
record.filter = filterOf(String(p.subUnitId ?? ""));
|
|
4427
4511
|
}
|
|
4428
4512
|
if (info.id === SHEET_NAME) record.name = ws.getName();
|
|
4513
|
+
if (info.id === REMOVE_SHEET2) record.owedRefs = removedSheetRefs(String(p.subUnitId ?? ""));
|
|
4429
4514
|
pre.set(p, record);
|
|
4430
4515
|
const owed = isStructuralMutation({ id: info.id, params: p }) ? mergeFixupsOwed({ id: info.id, params: p }, record.merges ?? []) : null;
|
|
4431
4516
|
if (owed) {
|
|
@@ -4578,6 +4663,8 @@ function univerSheetsOtPort(o) {
|
|
|
4578
4663
|
g.mutations.push(r.m);
|
|
4579
4664
|
g.inverses.push(r.inverse);
|
|
4580
4665
|
}
|
|
4666
|
+
const owedRefs = info.id === REMOVE_SHEET2 ? pre.get(info.params)?.owedRefs : void 0;
|
|
4667
|
+
if (owedRefs?.length) (g.owedRefs ??= []).push(...owedRefs);
|
|
4581
4668
|
const was = info.id === VALUES ? pre.get(info.params)?.filter : void 0;
|
|
4582
4669
|
if (was && !g.notShared) {
|
|
4583
4670
|
const sheet = String(info.params.subUnitId ?? "");
|
|
@@ -4694,6 +4781,7 @@ function univerSheetsOtPort(o) {
|
|
|
4694
4781
|
group = null;
|
|
4695
4782
|
applying = true;
|
|
4696
4783
|
try {
|
|
4784
|
+
closeCellEditor();
|
|
4697
4785
|
const u = unitId();
|
|
4698
4786
|
if (u) releaseUnitPluginState(cs, u, o.saveUnit?.(u) ?? null);
|
|
4699
4787
|
o.load(snapshot);
|
|
@@ -4711,6 +4799,21 @@ function univerSheetsOtPort(o) {
|
|
|
4711
4799
|
return () => void undoWatchers.delete(fn);
|
|
4712
4800
|
},
|
|
4713
4801
|
markDirty: () => o.markDirty(),
|
|
4802
|
+
cursor() {
|
|
4803
|
+
const sel = o.selections;
|
|
4804
|
+
if (!sel) return null;
|
|
4805
|
+
try {
|
|
4806
|
+
const sheetId = sel.sheetId();
|
|
4807
|
+
if (!sheetId) return null;
|
|
4808
|
+
const first = sel.get()?.[0];
|
|
4809
|
+
const p = first?.primary;
|
|
4810
|
+
const row = p?.actualRow ?? p?.startRow ?? first?.range.startRow ?? 0;
|
|
4811
|
+
const col = p?.actualColumn ?? p?.startColumn ?? first?.range.startColumn ?? 0;
|
|
4812
|
+
return { sheetId, row: Number.isFinite(row) ? row : 0, col: Number.isFinite(col) ? col : 0 };
|
|
4813
|
+
} catch {
|
|
4814
|
+
return null;
|
|
4815
|
+
}
|
|
4816
|
+
},
|
|
4714
4817
|
dispose() {
|
|
4715
4818
|
undoWatchers.clear();
|
|
4716
4819
|
before.dispose();
|
|
@@ -4994,6 +5097,24 @@ async function workbookUsesOrderedRoom(workbookId, knob, isNewWorkbook, offlineK
|
|
|
4994
5097
|
if (knob === "new") return isNewWorkbook();
|
|
4995
5098
|
return false;
|
|
4996
5099
|
}
|
|
5100
|
+
function joiningAwareness(o, port) {
|
|
5101
|
+
let at = null;
|
|
5102
|
+
try {
|
|
5103
|
+
at = port.cursor?.() ?? null;
|
|
5104
|
+
} catch {
|
|
5105
|
+
at = null;
|
|
5106
|
+
}
|
|
5107
|
+
return {
|
|
5108
|
+
uid: o.uid,
|
|
5109
|
+
clientId: o.clientId,
|
|
5110
|
+
name: o.displayName || "Someone",
|
|
5111
|
+
...o.avatarUrl ? { avatarUrl: o.avatarUrl } : {},
|
|
5112
|
+
sheetId: at?.sheetId ?? null,
|
|
5113
|
+
row: at?.row ?? null,
|
|
5114
|
+
col: at?.col ?? null,
|
|
5115
|
+
ts: Date.now()
|
|
5116
|
+
};
|
|
5117
|
+
}
|
|
4997
5118
|
async function startWorkbookOtRoom(port, o) {
|
|
4998
5119
|
const latest = await getLatestSnapshot(o.workbookId);
|
|
4999
5120
|
if (!latest.success) throw new Error(latest.error);
|
|
@@ -5006,16 +5127,7 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
5006
5127
|
}
|
|
5007
5128
|
const doc = new Y3.Doc();
|
|
5008
5129
|
const awareness = new Awareness3(doc);
|
|
5009
|
-
awareness.setLocalState(
|
|
5010
|
-
uid: o.uid,
|
|
5011
|
-
clientId: o.clientId,
|
|
5012
|
-
name: o.displayName || "Someone",
|
|
5013
|
-
...o.avatarUrl ? { avatarUrl: o.avatarUrl } : {},
|
|
5014
|
-
sheetId: null,
|
|
5015
|
-
row: null,
|
|
5016
|
-
col: null,
|
|
5017
|
-
ts: Date.now()
|
|
5018
|
-
});
|
|
5130
|
+
awareness.setLocalState(joiningAwareness(o, port));
|
|
5019
5131
|
const stopColor = claimCollaboratorColor3(awareness, { uid: o.uid, clientId: o.clientId });
|
|
5020
5132
|
const publishAwareness = () => o.onAwareness?.(new Map(awareness.getStates()));
|
|
5021
5133
|
awareness.on("change", publishAwareness);
|
|
@@ -5110,6 +5222,7 @@ export {
|
|
|
5110
5222
|
invertDocsOp,
|
|
5111
5223
|
isCellEditorScratch,
|
|
5112
5224
|
isNoopDocsOp,
|
|
5225
|
+
joiningAwareness,
|
|
5113
5226
|
moveSelectionsThrough,
|
|
5114
5227
|
normalizeDocsOp,
|
|
5115
5228
|
offlineTextOfGroups,
|