@ai-matrx/office 0.8.17 → 0.8.18
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 +12 -3
- package/dist/{chunk-HX5TXQIX.cjs → chunk-JMVPAJJA.cjs} +6 -5
- package/dist/chunk-JMVPAJJA.cjs.map +1 -0
- package/dist/{chunk-2X3KR6Y4.js → chunk-TRA2BTPL.js} +6 -5
- package/dist/{chunk-2X3KR6Y4.js.map → chunk-TRA2BTPL.js.map} +1 -1
- package/dist/docs-io.cjs +6 -6
- package/dist/docs-io.js +1 -1
- package/dist/docs.cjs +2 -2
- package/dist/docs.d.cts +5 -1
- package/dist/docs.d.ts +5 -1
- package/dist/docs.js +1 -1
- package/dist/univer-collab.cjs +142 -34
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +7 -12
- package/dist/univer-collab.d.ts +7 -12
- package/dist/univer-collab.js +124 -15
- package/dist/univer-collab.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-HX5TXQIX.cjs.map +0 -1
package/dist/univer-collab.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(collab_exports, {
|
|
|
41
41
|
SHEETS_EDIT_GROUP: () => SHEETS_EDIT_GROUP,
|
|
42
42
|
WorkbookCollabSession: () => WorkbookCollabSession,
|
|
43
43
|
applyDocsOp: () => applyDocsOp,
|
|
44
|
+
asLoadedDocsSnapshot: () => asLoadedDocsSnapshot,
|
|
44
45
|
canonicalDocsSnapshot: () => canonicalDocsSnapshot,
|
|
45
46
|
canonicalDocsString: () => canonicalDocsString,
|
|
46
47
|
canonicalKeys: () => canonicalKeys,
|
|
@@ -949,6 +950,104 @@ function invertDocsOp(op, preDoc) {
|
|
|
949
950
|
}
|
|
950
951
|
var DOCS_TRANSFORM_VERSION = "univer-1.0.4+docs-ot-r6";
|
|
951
952
|
|
|
953
|
+
// src/univer/collab/docs-ot/state-hash.ts
|
|
954
|
+
var import_core4 = require("@univerjs/core");
|
|
955
|
+
|
|
956
|
+
// src/docs/sanitize-univer-doc-snapshot.ts
|
|
957
|
+
var import_core2 = require("@univerjs/core");
|
|
958
|
+
|
|
959
|
+
// src/core/document-page-style.ts
|
|
960
|
+
var TRADITIONAL = 1;
|
|
961
|
+
var PORTRAIT = 0;
|
|
962
|
+
var PX_PER_INCH = 96;
|
|
963
|
+
var DEFAULT_DOCUMENT_PAGE_STYLE = {
|
|
964
|
+
pageSize: { width: 816, height: 1056 },
|
|
965
|
+
documentFlavor: TRADITIONAL,
|
|
966
|
+
pageOrient: PORTRAIT,
|
|
967
|
+
marginTop: PX_PER_INCH,
|
|
968
|
+
marginBottom: PX_PER_INCH,
|
|
969
|
+
marginLeft: PX_PER_INCH,
|
|
970
|
+
marginRight: PX_PER_INCH,
|
|
971
|
+
// Univer applies no paragraph spacing to a paginated page by itself; without this every paragraph
|
|
972
|
+
// runs into the next (Google Docs' own default: 1.15 lines, 10px after).
|
|
973
|
+
defaultParagraphStyle: { spaceAbove: { v: 0 }, spaceBelow: { v: 10 }, lineSpacing: 1.15 }
|
|
974
|
+
};
|
|
975
|
+
function defaultDocumentPageStyle() {
|
|
976
|
+
return {
|
|
977
|
+
...DEFAULT_DOCUMENT_PAGE_STYLE,
|
|
978
|
+
pageSize: { ...DEFAULT_DOCUMENT_PAGE_STYLE.pageSize },
|
|
979
|
+
defaultParagraphStyle: { ...DEFAULT_DOCUMENT_PAGE_STYLE.defaultParagraphStyle }
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
function isLegacySqueezedPageStyle(style) {
|
|
983
|
+
const size = style?.pageSize;
|
|
984
|
+
return !!size && size.width === 595 && size.height === 842 && style?.marginLeft === 90 && style?.marginRight === 90 && style?.marginTop === 72 && style?.marginBottom === 72;
|
|
985
|
+
}
|
|
986
|
+
var PAGE_COLORS = ["#ffffff", "#fff8e7", "#f3f3f3", "#e8f0fe", "#e6f4ea", "#fef7e0"];
|
|
987
|
+
var DEFAULT_PAGE_COLOR = PAGE_COLORS[0];
|
|
988
|
+
|
|
989
|
+
// src/docs/sanitize-univer-doc-snapshot.ts
|
|
990
|
+
var NAMED_STYLE_STRING_TO_NUMBER = Object.fromEntries(
|
|
991
|
+
Object.entries(import_core2.NamedStyleType).filter(([key, val]) => typeof val === "number" && isNaN(Number(key))).map(([key, val]) => [key, val])
|
|
992
|
+
);
|
|
993
|
+
function sanitizeUniverDocSnapshot(snapshot, docId, opts = {}) {
|
|
994
|
+
restorePageStyle(snapshot, docId, opts.quiet === true);
|
|
995
|
+
ensureTextRuns(snapshot);
|
|
996
|
+
const paragraphs = snapshot?.body?.paragraphs;
|
|
997
|
+
if (!Array.isArray(paragraphs)) return snapshot;
|
|
998
|
+
let fixed = 0;
|
|
999
|
+
for (const paragraph of paragraphs) {
|
|
1000
|
+
const style = paragraph?.paragraphStyle;
|
|
1001
|
+
const value = style?.namedStyleType;
|
|
1002
|
+
if (typeof value === "string") {
|
|
1003
|
+
const numeric = NAMED_STYLE_STRING_TO_NUMBER[value];
|
|
1004
|
+
if (numeric !== void 0) {
|
|
1005
|
+
style.namedStyleType = numeric;
|
|
1006
|
+
fixed += 1;
|
|
1007
|
+
} else {
|
|
1008
|
+
delete style.namedStyleType;
|
|
1009
|
+
fixed += 1;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (fixed > 0 && opts.quiet !== true) {
|
|
1014
|
+
console.warn(
|
|
1015
|
+
`[data-tables] RECOVERY: sanitized ${fixed} string namedStyleType value(s) to numeric NamedStyleType in document snapshot${docId ? ` ${docId}` : ""}. The snapshot was written with the wrong enum encoding (string instead of number) and would have crashed Univer's <ParagraphMenu>. Fix the snapshot writer to emit numeric NamedStyleType values.`
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
return snapshot;
|
|
1019
|
+
}
|
|
1020
|
+
function restorePageStyle(snapshot, docId, quiet = false) {
|
|
1021
|
+
if (!snapshot || typeof snapshot !== "object") return;
|
|
1022
|
+
const style = snapshot.documentStyle;
|
|
1023
|
+
if (style?.pageSize?.width && isLegacySqueezedPageStyle(style)) {
|
|
1024
|
+
const page = defaultDocumentPageStyle();
|
|
1025
|
+
snapshot.documentStyle = { ...style, ...page, defaultParagraphStyle: style.defaultParagraphStyle ?? page.defaultParagraphStyle };
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
if (style?.pageSize?.width) {
|
|
1029
|
+
if (!style.documentFlavor) {
|
|
1030
|
+
const page = defaultDocumentPageStyle();
|
|
1031
|
+
Object.assign(style, { documentFlavor: page.documentFlavor });
|
|
1032
|
+
if (page.defaultParagraphStyle) style.defaultParagraphStyle ??= page.defaultParagraphStyle;
|
|
1033
|
+
}
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
snapshot.documentStyle = {
|
|
1037
|
+
...defaultDocumentPageStyle(),
|
|
1038
|
+
...snapshot.documentStyle ?? {},
|
|
1039
|
+
pageSize: defaultDocumentPageStyle().pageSize
|
|
1040
|
+
};
|
|
1041
|
+
if (quiet) return;
|
|
1042
|
+
console.warn(
|
|
1043
|
+
`[data-tables] RECOVERY: document snapshot${docId ? ` ${docId}` : ""} had no documentStyle.pageSize \u2014 restored the default Letter page geometry. Without a page box Univer lays the body out unbounded: text does not wrap and the viewport has no scrollable extent, so the document appears frozen. Fix the snapshot writer (agent/markdown converters must stamp DEFAULT_DOCUMENT_PAGE_STYLE).`
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
function ensureTextRuns(snapshot) {
|
|
1047
|
+
const body = snapshot?.body;
|
|
1048
|
+
if (body && typeof body === "object" && !Array.isArray(body.textRuns)) body.textRuns = [];
|
|
1049
|
+
}
|
|
1050
|
+
|
|
952
1051
|
// src/univer/collab/docs-ot/state-hash.ts
|
|
953
1052
|
var DOC_LOCAL_KEYS = ["rev", "__matrxCollabCovered", "__collab", "disabled", "layoutState", "textRanges", "selections"];
|
|
954
1053
|
function sortDeep(v) {
|
|
@@ -1008,6 +1107,7 @@ function canonicalBody(body) {
|
|
|
1008
1107
|
const b = { ...body };
|
|
1009
1108
|
b.textRuns = canonicalRuns(b.textRuns);
|
|
1010
1109
|
if (Array.isArray(b.paragraphs)) b.paragraphs = b.paragraphs.map(({ paragraphId: _p, ...p }) => p);
|
|
1110
|
+
if (Array.isArray(b.sectionBreaks)) b.sectionBreaks = b.sectionBreaks.map(({ sectionId: _s, ...x }) => x);
|
|
1011
1111
|
b.customRanges = foldPieces(b.customRanges, (r) => JSON.stringify([rootId(r.rangeId), r.rangeType, sortDeep(r.properties ?? {})])).map((r) => ({
|
|
1012
1112
|
...r,
|
|
1013
1113
|
rangeId: rootId(r.rangeId)
|
|
@@ -1022,8 +1122,20 @@ function canonicalBody(body) {
|
|
|
1022
1122
|
}
|
|
1023
1123
|
return b;
|
|
1024
1124
|
}
|
|
1125
|
+
function asLoadedDocsSnapshot(snapshot) {
|
|
1126
|
+
const s = stampDeterministicIds(structuredClone(snapshot ?? {}));
|
|
1127
|
+
delete s.id;
|
|
1128
|
+
for (const k of DOC_LOCAL_KEYS) delete s[k];
|
|
1129
|
+
sanitizeUniverDocSnapshot(s, void 0, { quiet: true });
|
|
1130
|
+
const model = new import_core4.DocumentDataModel(s);
|
|
1131
|
+
try {
|
|
1132
|
+
return structuredClone(model.getSnapshot());
|
|
1133
|
+
} finally {
|
|
1134
|
+
model.dispose();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1025
1137
|
function canonicalDocsSnapshot(snapshot) {
|
|
1026
|
-
const s =
|
|
1138
|
+
const s = asLoadedDocsSnapshot(snapshot);
|
|
1027
1139
|
delete s.id;
|
|
1028
1140
|
for (const k of DOC_LOCAL_KEYS) delete s[k];
|
|
1029
1141
|
s.body = canonicalBody(s.body);
|
|
@@ -1232,7 +1344,10 @@ function openDocsOtRoom(o) {
|
|
|
1232
1344
|
queue = next.filter((q) => !isNoopDocsOp(q));
|
|
1233
1345
|
if (isNoopDocsOp(op)) return;
|
|
1234
1346
|
}
|
|
1235
|
-
if (!session.local(op, { ...inverse !== void 0 ? { inverse } : {}, label: m.cmd ?? RICH_TEXT_EDITING }))
|
|
1347
|
+
if (!session.local(op, { ...inverse !== void 0 ? { inverse } : {}, label: m.cmd ?? RICH_TEXT_EDITING })) {
|
|
1348
|
+
notice({ kind: "not_live" });
|
|
1349
|
+
session.rebuild("not_live");
|
|
1350
|
+
}
|
|
1236
1351
|
};
|
|
1237
1352
|
const unsubLocal = port.onLocal(onLocal);
|
|
1238
1353
|
const target = o.compositionTarget === void 0 ? typeof document !== "undefined" ? document : null : o.compositionTarget;
|
|
@@ -1294,7 +1409,7 @@ var import_awareness2 = require("y-protocols/awareness");
|
|
|
1294
1409
|
var import_collab3 = require("@ai-matrx/data/realtime/collab");
|
|
1295
1410
|
|
|
1296
1411
|
// src/docs/remote-carets.ts
|
|
1297
|
-
var
|
|
1412
|
+
var import_core5 = require("@univerjs/core");
|
|
1298
1413
|
var CARET_HEARTBEAT_MS = 2e3;
|
|
1299
1414
|
var CARET_STALE_MS = 12e3;
|
|
1300
1415
|
var CARET_MAX_RANGES = 4;
|
|
@@ -1312,8 +1427,8 @@ function movePeerRangesThroughBodyEdit(ranges, actions) {
|
|
|
1312
1427
|
const e = sub.e;
|
|
1313
1428
|
return ranges.map((r) => {
|
|
1314
1429
|
const collapsed = r.start === r.end;
|
|
1315
|
-
const start =
|
|
1316
|
-
return { start, end: collapsed ? start :
|
|
1430
|
+
const start = import_core5.TextX.transformPosition(e, r.start, false);
|
|
1431
|
+
return { start, end: collapsed ? start : import_core5.TextX.transformPosition(e, r.end, true) };
|
|
1317
1432
|
});
|
|
1318
1433
|
}
|
|
1319
1434
|
var sameRanges = (a, b) => a.length === b.length && a.every((r, i) => r.start === b[i].start && r.end === b[i].end);
|
|
@@ -1451,15 +1566,6 @@ async function documentUsesOrderedRoom(documentId, knob, isNewDocument) {
|
|
|
1451
1566
|
if (knob === "new") return isNewDocument();
|
|
1452
1567
|
return false;
|
|
1453
1568
|
}
|
|
1454
|
-
function pickColor2(uid) {
|
|
1455
|
-
const palette = ["#ef4444", "#f59e0b", "#10b981", "#3b82f6", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"];
|
|
1456
|
-
let h = 2166136261;
|
|
1457
|
-
for (let i = 0; i < uid.length; i++) {
|
|
1458
|
-
h ^= uid.charCodeAt(i);
|
|
1459
|
-
h = Math.imul(h, 16777619);
|
|
1460
|
-
}
|
|
1461
|
-
return palette[Math.abs(h) % palette.length] ?? "#ec4899";
|
|
1462
|
-
}
|
|
1463
1569
|
function documentOtFactory(o) {
|
|
1464
1570
|
return async (basePort, onAwareness) => {
|
|
1465
1571
|
const latest = await getLatestDocumentSnapshot(o.documentId);
|
|
@@ -1473,7 +1579,8 @@ function documentOtFactory(o) {
|
|
|
1473
1579
|
}
|
|
1474
1580
|
const doc = new Y2.Doc();
|
|
1475
1581
|
const awareness = new import_awareness2.Awareness(doc);
|
|
1476
|
-
awareness.setLocalState({ uid: o.uid, clientId: o.clientId, name: o.displayName ?? o.uid.slice(0, 8),
|
|
1582
|
+
awareness.setLocalState({ uid: o.uid, clientId: o.clientId, name: o.displayName ?? o.uid.slice(0, 8), ts: Date.now() });
|
|
1583
|
+
const stopColor = (0, import_collab3.claimCollaboratorColor)(awareness, { uid: o.uid, clientId: o.clientId });
|
|
1477
1584
|
const carets = new RemoteCaretBook(awareness.clientID);
|
|
1478
1585
|
const emit = () => onAwareness({ states: new Map(awareness.getStates()), selfUid: o.uid, carets: carets.list() });
|
|
1479
1586
|
const publishAwareness = () => {
|
|
@@ -1559,6 +1666,7 @@ function documentOtFactory(o) {
|
|
|
1559
1666
|
replace: (snapshot) => room.replace(snapshot),
|
|
1560
1667
|
stop: () => {
|
|
1561
1668
|
clearInterval(caretTimer);
|
|
1669
|
+
stopColor();
|
|
1562
1670
|
room.stop();
|
|
1563
1671
|
awareness.off("change", publishAwareness);
|
|
1564
1672
|
provider.disconnect();
|
|
@@ -1880,7 +1988,7 @@ function transformAxis(x, y, side) {
|
|
|
1880
1988
|
}
|
|
1881
1989
|
|
|
1882
1990
|
// src/collab/sheets/transform/formula.ts
|
|
1883
|
-
var
|
|
1991
|
+
var import_core6 = require("@univerjs/core");
|
|
1884
1992
|
var import_engine_formula = require("@univerjs/engine-formula");
|
|
1885
1993
|
var import_sheets = require("@univerjs/sheets");
|
|
1886
1994
|
var REF_ERROR = "#REF!";
|
|
@@ -1932,8 +2040,8 @@ function referencedSheetNames(text) {
|
|
|
1932
2040
|
}
|
|
1933
2041
|
return [...out];
|
|
1934
2042
|
}
|
|
1935
|
-
var fullRowsRange = (start, count) => ({ startRow: start, endRow: start + count - 1, startColumn: 0, endColumn: FULL, rangeType:
|
|
1936
|
-
var fullColsRange = (start, count) => ({ startRow: 0, endRow: FULL, startColumn: start, endColumn: start + count - 1, rangeType:
|
|
2043
|
+
var fullRowsRange = (start, count) => ({ startRow: start, endRow: start + count - 1, startColumn: 0, endColumn: FULL, rangeType: import_core6.RANGE_TYPE.ROW });
|
|
2044
|
+
var fullColsRange = (start, count) => ({ startRow: 0, endRow: FULL, startColumn: start, endColumn: start + count - 1, rangeType: import_core6.RANGE_TYPE.COLUMN });
|
|
1937
2045
|
var startV = (v) => Number.isNaN(v) || v == null ? -Infinity : v;
|
|
1938
2046
|
var endV = (v) => Number.isNaN(v) || v == null ? Infinity : v;
|
|
1939
2047
|
function startEnd(r) {
|
|
@@ -1942,9 +2050,9 @@ function startEnd(r) {
|
|
|
1942
2050
|
function checkMoveEdge(origin, from) {
|
|
1943
2051
|
const startRow = startV(origin.startRow), endRow = endV(origin.endRow), startColumn = startV(origin.startColumn), endColumn = endV(origin.endColumn);
|
|
1944
2052
|
const fromStartRow = startV(from.startRow), fromEndRow = endV(from.endRow), fromStartColumn = startV(from.startColumn), fromEndColumn = endV(from.endColumn);
|
|
1945
|
-
const rowsCover = () => origin.rangeType ===
|
|
1946
|
-
const columnsCover = () => origin.rangeType ===
|
|
1947
|
-
const allCover = () => origin.rangeType ===
|
|
2053
|
+
const rowsCover = () => origin.rangeType === import_core6.RANGE_TYPE.COLUMN && from.rangeType === import_core6.RANGE_TYPE.COLUMN || startRow >= fromStartRow && endRow <= fromEndRow;
|
|
2054
|
+
const columnsCover = () => origin.rangeType === import_core6.RANGE_TYPE.ROW && from.rangeType === import_core6.RANGE_TYPE.ROW || startColumn >= fromStartColumn && endColumn <= fromEndColumn;
|
|
2055
|
+
const allCover = () => origin.rangeType === import_core6.RANGE_TYPE.ALL && from.rangeType === import_core6.RANGE_TYPE.ALL;
|
|
1948
2056
|
if (rowsCover() && columnsCover() || allCover()) return 4;
|
|
1949
2057
|
if (columnsCover() && startRow >= fromStartRow && startRow <= fromEndRow && endRow > fromEndRow) return 0;
|
|
1950
2058
|
if (columnsCover() && endRow >= fromStartRow && endRow <= fromEndRow && startRow < fromStartRow) return 1;
|
|
@@ -1955,14 +2063,14 @@ function checkMoveEdge(origin, from) {
|
|
|
1955
2063
|
function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
|
|
1956
2064
|
const { startRow, endRow, startColumn, endColumn, rangeType } = startEnd(result);
|
|
1957
2065
|
const f = startEnd(from);
|
|
1958
|
-
const fromRangeType = from.rangeType ??
|
|
2066
|
+
const fromRangeType = from.rangeType ?? import_core6.RANGE_TYPE.NORMAL;
|
|
1959
2067
|
const t = startEnd(to);
|
|
1960
2068
|
const rm = startEnd(remain);
|
|
1961
2069
|
const o = startEnd(origin);
|
|
1962
|
-
const originRangeType = origin.rangeType ??
|
|
2070
|
+
const originRangeType = origin.rangeType ?? import_core6.RANGE_TYPE.NORMAL;
|
|
1963
2071
|
const newRange = { ...origin };
|
|
1964
|
-
const rowsCover = () => rangeType ===
|
|
1965
|
-
const columnsCover = () => rangeType ===
|
|
2072
|
+
const rowsCover = () => rangeType === import_core6.RANGE_TYPE.COLUMN && originRangeType === import_core6.RANGE_TYPE.COLUMN || startColumn >= o.startColumn && endColumn <= o.endColumn;
|
|
2073
|
+
const columnsCover = () => rangeType === import_core6.RANGE_TYPE.ROW && originRangeType === import_core6.RANGE_TYPE.ROW || startRow >= o.startRow && endRow <= o.endRow;
|
|
1966
2074
|
if (moveEdge === 0) {
|
|
1967
2075
|
if (!rowsCover()) return void 0;
|
|
1968
2076
|
if (startRow < o.startRow) newRange.startRow = startRow;
|
|
@@ -1985,7 +2093,7 @@ function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
|
|
|
1985
2093
|
else return void 0;
|
|
1986
2094
|
} else if (moveEdge === 4) {
|
|
1987
2095
|
Object.assign(newRange, { startRow, startColumn, endRow, endColumn });
|
|
1988
|
-
} else if (f.startColumn <= o.startColumn && f.endColumn >= o.endColumn || fromRangeType ===
|
|
2096
|
+
} else if (f.startColumn <= o.startColumn && f.endColumn >= o.endColumn || fromRangeType === import_core6.RANGE_TYPE.ROW && originRangeType === import_core6.RANGE_TYPE.ROW) {
|
|
1989
2097
|
const n = f.endRow - f.startRow + 1;
|
|
1990
2098
|
if (from.endRow < o.startRow) {
|
|
1991
2099
|
if (t.startRow >= o.startRow) newRange.startRow -= n;
|
|
@@ -1997,7 +2105,7 @@ function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
|
|
|
1997
2105
|
if (t.startRow <= o.startRow) newRange.startRow += n;
|
|
1998
2106
|
else if (t.startRow >= o.endRow) newRange.endRow -= n;
|
|
1999
2107
|
}
|
|
2000
|
-
} else if (f.startRow <= o.startRow && f.endRow >= o.endRow || fromRangeType ===
|
|
2108
|
+
} else if (f.startRow <= o.startRow && f.endRow >= o.endRow || fromRangeType === import_core6.RANGE_TYPE.COLUMN && originRangeType === import_core6.RANGE_TYPE.COLUMN) {
|
|
2001
2109
|
const n = f.endColumn - f.startColumn + 1;
|
|
2002
2110
|
if (from.endColumn < o.startColumn) {
|
|
2003
2111
|
if (t.startColumn >= o.startColumn) newRange.startColumn -= n;
|
|
@@ -2019,7 +2127,7 @@ function moveRange(range, axis, op) {
|
|
|
2019
2127
|
const isRow = axis === "row";
|
|
2020
2128
|
if (op.kind === "insert") {
|
|
2021
2129
|
const r = isRow ? fullRowsRange(op.at, op.count) : fullColsRange(op.at, op.count);
|
|
2022
|
-
const ops2 = isRow ? (0, import_sheets.handleInsertRow)({ id: import_sheets.EffectRefRangId.InsertRowCommandId, params: { range: r, unitId: "", subUnitId: "", direction:
|
|
2130
|
+
const ops2 = isRow ? (0, import_sheets.handleInsertRow)({ id: import_sheets.EffectRefRangId.InsertRowCommandId, params: { range: r, unitId: "", subUnitId: "", direction: import_core6.Direction.DOWN } }, range) : (0, import_sheets.handleInsertCol)({ id: import_sheets.EffectRefRangId.InsertColCommandId, params: { range: r, unitId: "", subUnitId: "", direction: import_core6.Direction.RIGHT } }, range);
|
|
2023
2131
|
const res2 = (0, import_sheets.runRefRangeMutations)(ops2, range);
|
|
2024
2132
|
return res2 == null ? void 0 : { ...range, ...res2 };
|
|
2025
2133
|
}
|
|
@@ -2032,11 +2140,11 @@ function moveRange(range, axis, op) {
|
|
|
2032
2140
|
const from = isRow ? fullRowsRange(op.from, op.count) : fullColsRange(op.from, op.count);
|
|
2033
2141
|
const to = isRow ? fullRowsRange(op.to, op.count) : fullColsRange(op.to, op.count);
|
|
2034
2142
|
const moveEdge = checkMoveEdge(range, from);
|
|
2035
|
-
let remain = (0,
|
|
2143
|
+
let remain = (0, import_core6.getIntersectRange)(range, from);
|
|
2036
2144
|
if (isRow) {
|
|
2037
2145
|
if (remain == null && (from.endRow < range.startRow && to.endRow <= range.startRow || from.startRow > range.endRow && to.startRow > range.endRow)) return void 0;
|
|
2038
2146
|
} else if (remain == null && (from.endColumn < range.startColumn && to.endColumn <= range.startColumn || from.startColumn > range.endColumn && to.startColumn > range.endColumn)) return void 0;
|
|
2039
|
-
remain ??= { startRow: range.startRow, endRow: range.endRow, startColumn: range.startColumn, endColumn: range.endColumn, rangeType:
|
|
2147
|
+
remain ??= { startRow: range.startRow, endRow: range.endRow, startColumn: range.startColumn, endColumn: range.endColumn, rangeType: import_core6.RANGE_TYPE.NORMAL };
|
|
2040
2148
|
const ops = isRow ? (0, import_sheets.handleMoveRows)({ id: import_sheets.EffectRefRangId.MoveRowsCommandId, params: { toRange: to, fromRange: from } }, remain) : (0, import_sheets.handleMoveCols)({ id: import_sheets.EffectRefRangId.MoveColsCommandId, params: { toRange: to, fromRange: from } }, remain);
|
|
2041
2149
|
const res = (0, import_sheets.runRefRangeMutations)(ops, remain);
|
|
2042
2150
|
if (res == null) return REF_ERROR;
|
|
@@ -2067,7 +2175,7 @@ function rewriteFormula(text, ctx, change) {
|
|
|
2067
2175
|
if (!sheetName) continue;
|
|
2068
2176
|
token = (0, import_engine_formula.serializeRangeToRefString)({ range, sheetName: change.name, unitId });
|
|
2069
2177
|
} else {
|
|
2070
|
-
const moved = moveRange(
|
|
2178
|
+
const moved = moveRange(import_core6.Rectangle.moveOffset(range, 0, 0), change.axis, change.op);
|
|
2071
2179
|
if (moved === void 0) continue;
|
|
2072
2180
|
token = moved === REF_ERROR ? REF_ERROR : (0, import_engine_formula.serializeRangeToRefString)({ range: moved, sheetName: target === ctx.ownSheet && !ctx.keepQualifier ? "" : sheetName, unitId });
|
|
2073
2181
|
}
|
|
@@ -3338,7 +3446,7 @@ function univerSheetsOtPort(o) {
|
|
|
3338
3446
|
const a = forApply(m);
|
|
3339
3447
|
applying = true;
|
|
3340
3448
|
try {
|
|
3341
|
-
const ok2 = cs.syncExecuteCommand(a.id, { ...json(a.params), unitId: u }, {
|
|
3449
|
+
const ok2 = cs.syncExecuteCommand(a.id, { ...json(a.params), unitId: u }, { fromCollab: true });
|
|
3342
3450
|
if (ok2 === false) throw new Error(`"${m.id}" was refused by the editor`);
|
|
3343
3451
|
} finally {
|
|
3344
3452
|
applying = false;
|
|
@@ -3512,7 +3620,7 @@ async function workbookUsesOrderedRoom(workbookId, knob, isNewWorkbook) {
|
|
|
3512
3620
|
if (knob === "new") return isNewWorkbook();
|
|
3513
3621
|
return false;
|
|
3514
3622
|
}
|
|
3515
|
-
function
|
|
3623
|
+
function pickColor2(uid) {
|
|
3516
3624
|
const palette = ["#ef4444", "#f59e0b", "#10b981", "#3b82f6", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"];
|
|
3517
3625
|
let h = 2166136261;
|
|
3518
3626
|
for (let i = 0; i < uid.length; i++) {
|
|
@@ -3537,7 +3645,7 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
3537
3645
|
uid: o.uid,
|
|
3538
3646
|
clientId: o.clientId,
|
|
3539
3647
|
name: o.displayName ?? o.uid.slice(0, 8),
|
|
3540
|
-
color:
|
|
3648
|
+
color: pickColor2(o.uid),
|
|
3541
3649
|
sheetId: null,
|
|
3542
3650
|
row: null,
|
|
3543
3651
|
col: null,
|