@ai-matrx/office 0.8.24 → 0.8.26
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/{chunk-TRA2BTPL.js → chunk-CAWDEHVL.js} +20 -6
- package/dist/chunk-CAWDEHVL.js.map +1 -0
- package/dist/{chunk-ZDZCCOUB.cjs → chunk-IJNET5TT.cjs} +20 -6
- package/dist/chunk-IJNET5TT.cjs.map +1 -0
- package/dist/{chunk-JMVPAJJA.cjs → chunk-LHTG72LS.cjs} +20 -6
- package/dist/chunk-LHTG72LS.cjs.map +1 -0
- package/dist/{chunk-WKBWRG7N.js → chunk-RREOARR4.js} +20 -6
- package/dist/chunk-RREOARR4.js.map +1 -0
- package/dist/docs-host.cjs.map +1 -1
- package/dist/docs-host.d.cts +8 -0
- package/dist/docs-host.d.ts +8 -0
- package/dist/docs-host.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 +9 -1
- package/dist/docs.d.ts +9 -1
- package/dist/docs.js +1 -1
- package/dist/sheets-xlsx.cjs +6 -6
- package/dist/sheets-xlsx.js +1 -1
- package/dist/sheets.cjs +3 -3
- package/dist/sheets.d.cts +9 -1
- package/dist/sheets.d.ts +9 -1
- package/dist/sheets.js +1 -1
- package/dist/univer-collab.cjs +66 -6
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +8 -0
- package/dist/univer-collab.d.ts +8 -0
- package/dist/univer-collab.js +66 -6
- package/dist/univer-collab.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-JMVPAJJA.cjs.map +0 -1
- package/dist/chunk-TRA2BTPL.js.map +0 -1
- package/dist/chunk-WKBWRG7N.js.map +0 -1
- package/dist/chunk-ZDZCCOUB.cjs.map +0 -1
package/dist/docs-io.js
CHANGED
package/dist/docs.cjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkLHTG72LScjs = require('./chunk-LHTG72LS.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
var _chunkNSU6EVJKcjs = require('./chunk-NSU6EVJK.cjs');
|
|
@@ -1075,5 +1075,5 @@ function removeCommentAnchorActions(documentDataModel, anchorId) {
|
|
|
1075
1075
|
|
|
1076
1076
|
|
|
1077
1077
|
|
|
1078
|
-
exports.CARET_HEARTBEAT_MS = CARET_HEARTBEAT_MS; exports.CARET_MAX_RANGES = CARET_MAX_RANGES; exports.CARET_STALE_MS = CARET_STALE_MS; exports.COMMENT_ANCHOR_LABEL_MAX = COMMENT_ANCHOR_LABEL_MAX; exports.COMMENT_ANCHOR_PART_PREFIX = COMMENT_ANCHOR_PART_PREFIX; exports.COMMENT_ANCHOR_RANGE_TYPE = COMMENT_ANCHOR_RANGE_TYPE; exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.RemoteCaretBook = RemoteCaretBook; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.addCommentAnchorActions = addCommentAnchorActions; exports.anchorIdOfPartAnchor = anchorIdOfPartAnchor; exports.bodyTextOf = bodyTextOf; exports.commentAnchorPartKey = commentAnchorPartKey; exports.commentAnchorsOf = commentAnchorsOf; exports.commentPartAnchor = commentPartAnchor; exports.configureDocsHost =
|
|
1078
|
+
exports.CARET_HEARTBEAT_MS = CARET_HEARTBEAT_MS; exports.CARET_MAX_RANGES = CARET_MAX_RANGES; exports.CARET_STALE_MS = CARET_STALE_MS; exports.COMMENT_ANCHOR_LABEL_MAX = COMMENT_ANCHOR_LABEL_MAX; exports.COMMENT_ANCHOR_PART_PREFIX = COMMENT_ANCHOR_PART_PREFIX; exports.COMMENT_ANCHOR_RANGE_TYPE = COMMENT_ANCHOR_RANGE_TYPE; exports.DOCUMENT_BODY_MAX_LENGTH = DOCUMENT_BODY_MAX_LENGTH; exports.DOCUMENT_DESCRIPTION_MAX_LENGTH = DOCUMENT_DESCRIPTION_MAX_LENGTH; exports.DOCUMENT_NAME_MAX_LENGTH = DOCUMENT_NAME_MAX_LENGTH; exports.DOCUMENT_SAVE_DELAY_MS = DOCUMENT_SAVE_DELAY_MS; exports.DocumentModel = DocumentModel; exports.EMOJI_GROUPS = EMOJI_GROUPS; exports.MIN_FIT_ZOOM = MIN_FIT_ZOOM; exports.RemoteCaretBook = RemoteCaretBook; exports.SPECIAL_GROUPS = SPECIAL_GROUPS; exports.addCommentAnchorActions = addCommentAnchorActions; exports.anchorIdOfPartAnchor = anchorIdOfPartAnchor; exports.bodyTextOf = bodyTextOf; exports.commentAnchorPartKey = commentAnchorPartKey; exports.commentAnchorsOf = commentAnchorsOf; exports.commentPartAnchor = commentPartAnchor; exports.configureDocsHost = _chunkLHTG72LScjs.configureDocsHost; exports.copyDocument = _chunkLHTG72LScjs.copyDocument; exports.createDocument = _chunkLHTG72LScjs.createDocument; exports.deleteDocument = _chunkLHTG72LScjs.deleteDocument; exports.discardFailedDocument = _chunkLHTG72LScjs.discardFailedDocument; exports.documentBodyWriteHandler = documentBodyWriteHandler; exports.documentSourceLabel = documentSourceLabel; exports.fitZoomRatio = fitZoomRatio; exports.getDocsHost = _chunkLHTG72LScjs.getDocsHost; exports.getDocument = _chunkLHTG72LScjs.getDocument; exports.getLatestDocumentSnapshot = _chunkLHTG72LScjs.getLatestDocumentSnapshot; exports.listAccessibleDocuments = _chunkLHTG72LScjs.listAccessibleDocuments; exports.listDocumentSnapshots = _chunkLHTG72LScjs.listDocumentSnapshots; exports.listTrashedDocuments = _chunkLHTG72LScjs.listTrashedDocuments; exports.moveDocument = _chunkLHTG72LScjs.moveDocument; exports.movePeerRangesThroughBodyEdit = movePeerRangesThroughBodyEdit; exports.moveRangesThroughBodyEdit = moveRangesThroughBodyEdit; exports.newCommentAnchorId = newCommentAnchorId; exports.planBodyEdit = planBodyEdit; exports.publishedCaretFromSelection = publishedCaretFromSelection; exports.removeCommentAnchorActions = removeCommentAnchorActions; exports.renameDocument = _chunkLHTG72LScjs.renameDocument; exports.restoreDocument = _chunkLHTG72LScjs.restoreDocument; exports.sanitizeUniverDocSnapshot = _chunkLHTG72LScjs.sanitizeUniverDocSnapshot; exports.saveDocumentSnapshot = _chunkLHTG72LScjs.saveDocumentSnapshot; exports.searchSymbols = searchSymbols; exports.updateDocumentDescription = _chunkLHTG72LScjs.updateDocumentDescription; exports.validateDocumentBody = validateDocumentBody; exports.validateDocumentDescription = validateDocumentDescription; exports.validateDocumentName = validateDocumentName; exports.writeBodyText = writeBodyText;
|
|
1079
1079
|
//# sourceMappingURL=docs.cjs.map
|
package/dist/docs.d.cts
CHANGED
|
@@ -25,6 +25,14 @@ interface DocsHostPorts {
|
|
|
25
25
|
method: "POST";
|
|
26
26
|
body: FormData;
|
|
27
27
|
}): Promise<Response>;
|
|
28
|
+
/**
|
|
29
|
+
* The record's CURRENT content, including what people are typing in a live co-editing room and have not saved
|
|
30
|
+
* (the app folds the room; the package owns no server). Optional: a host without co-editing leaves it out and
|
|
31
|
+
* a copy takes the newest saved snapshot. It may throw; the copy then fails with its message, never silently.
|
|
32
|
+
*/
|
|
33
|
+
readCurrentSnapshot?(documentId: string): Promise<{
|
|
34
|
+
snapshot: unknown | null;
|
|
35
|
+
}>;
|
|
28
36
|
}
|
|
29
37
|
declare function configureDocsHost(ports: DocsHostPorts): void;
|
|
30
38
|
declare function getDocsHost(): DocsHostPorts;
|
|
@@ -145,7 +153,7 @@ type SaveDocumentSnapshotArgs = {
|
|
|
145
153
|
};
|
|
146
154
|
declare function saveDocumentSnapshot(args: SaveDocumentSnapshotArgs): Promise<ServiceResult<DocumentSnapshot>>;
|
|
147
155
|
/**
|
|
148
|
-
* An independent copy of a document: its own row, with the
|
|
156
|
+
* An independent copy of a document: its own row, with the CURRENT content copied over (the live room when people are co-editing), so editing the copy never
|
|
149
157
|
* touches the original. The copy lives in the original's organization and project. Used by a board-template use.
|
|
150
158
|
*/
|
|
151
159
|
declare function copyDocument(documentId: string, name?: string): Promise<ServiceResult<DocumentRow>>;
|
package/dist/docs.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ interface DocsHostPorts {
|
|
|
25
25
|
method: "POST";
|
|
26
26
|
body: FormData;
|
|
27
27
|
}): Promise<Response>;
|
|
28
|
+
/**
|
|
29
|
+
* The record's CURRENT content, including what people are typing in a live co-editing room and have not saved
|
|
30
|
+
* (the app folds the room; the package owns no server). Optional: a host without co-editing leaves it out and
|
|
31
|
+
* a copy takes the newest saved snapshot. It may throw; the copy then fails with its message, never silently.
|
|
32
|
+
*/
|
|
33
|
+
readCurrentSnapshot?(documentId: string): Promise<{
|
|
34
|
+
snapshot: unknown | null;
|
|
35
|
+
}>;
|
|
28
36
|
}
|
|
29
37
|
declare function configureDocsHost(ports: DocsHostPorts): void;
|
|
30
38
|
declare function getDocsHost(): DocsHostPorts;
|
|
@@ -145,7 +153,7 @@ type SaveDocumentSnapshotArgs = {
|
|
|
145
153
|
};
|
|
146
154
|
declare function saveDocumentSnapshot(args: SaveDocumentSnapshotArgs): Promise<ServiceResult<DocumentSnapshot>>;
|
|
147
155
|
/**
|
|
148
|
-
* An independent copy of a document: its own row, with the
|
|
156
|
+
* An independent copy of a document: its own row, with the CURRENT content copied over (the live room when people are co-editing), so editing the copy never
|
|
149
157
|
* touches the original. The copy lives in the original's organization and project. Used by a board-template use.
|
|
150
158
|
*/
|
|
151
159
|
declare function copyDocument(documentId: string, name?: string): Promise<ServiceResult<DocumentRow>>;
|
package/dist/docs.js
CHANGED
package/dist/sheets-xlsx.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIJNET5TTcjs = require('./chunk-IJNET5TT.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -455,7 +455,7 @@ function unsupportedFileReason(file) {
|
|
|
455
455
|
return `"${file.name}" isn't a spreadsheet file. Supported: .xlsx, .xls, .csv. For a Google Sheet, use Import from Google Sheets.`;
|
|
456
456
|
}
|
|
457
457
|
async function importWorkbookFile(file, organizationId) {
|
|
458
|
-
const capturedOrganizationId = await
|
|
458
|
+
const capturedOrganizationId = await _chunkIJNET5TTcjs.getSheetsHost.call(void 0, ).ensureOrgId(organizationId);
|
|
459
459
|
const { xlsxToUniverWorkbook: xlsxToUniverWorkbook2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./xlsx-to-univer-NWCHAWJC.cjs")));
|
|
460
460
|
const droppedOnImport = [];
|
|
461
461
|
const { uploadImportedImage } = await Promise.resolve().then(() => _interopRequireWildcard(require("./matrxImagePorts-46SGQTLN.cjs")));
|
|
@@ -465,7 +465,7 @@ async function importWorkbookFile(file, organizationId) {
|
|
|
465
465
|
});
|
|
466
466
|
let originalFileId;
|
|
467
467
|
try {
|
|
468
|
-
const uploaded = await
|
|
468
|
+
const uploaded = await _chunkIJNET5TTcjs.getSheetsHost.call(void 0, ).uploadOriginalFile(file, { folderPath: "Workbooks/Imports" });
|
|
469
469
|
originalFileId = uploaded.fileId;
|
|
470
470
|
} catch (uploadErr) {
|
|
471
471
|
console.warn(
|
|
@@ -474,7 +474,7 @@ async function importWorkbookFile(file, organizationId) {
|
|
|
474
474
|
);
|
|
475
475
|
}
|
|
476
476
|
const cleanName = file.name.replace(/\.[^.]+$/, "") || "Imported workbook";
|
|
477
|
-
const created = await
|
|
477
|
+
const created = await _chunkIJNET5TTcjs.createWorkbook.call(void 0, {
|
|
478
478
|
name: cleanName,
|
|
479
479
|
description: `Imported from ${file.name}`,
|
|
480
480
|
source: file.name.toLowerCase().endsWith(".csv") ? "imported_csv" : "imported_xlsx",
|
|
@@ -482,14 +482,14 @@ async function importWorkbookFile(file, organizationId) {
|
|
|
482
482
|
...originalFileId ? { originalFileId } : {}
|
|
483
483
|
});
|
|
484
484
|
if (_core.isServiceFailure.call(void 0, created)) throw new Error(created.error);
|
|
485
|
-
const saved = await
|
|
485
|
+
const saved = await _chunkIJNET5TTcjs.saveSnapshot.call(void 0, {
|
|
486
486
|
workbookId: created.data.id,
|
|
487
487
|
snapshot,
|
|
488
488
|
origin: "imported",
|
|
489
489
|
label: file.name
|
|
490
490
|
});
|
|
491
491
|
if (_core.isServiceFailure.call(void 0, saved)) {
|
|
492
|
-
await
|
|
492
|
+
await _chunkIJNET5TTcjs.discardFailedWorkbook.call(void 0, created.data.id);
|
|
493
493
|
throw new Error(saved.error);
|
|
494
494
|
}
|
|
495
495
|
return { id: created.data.id, name: cleanName, notCarried: droppedOnImport };
|
package/dist/sheets-xlsx.js
CHANGED
package/dist/sheets.cjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkIJNET5TTcjs = require('./chunk-IJNET5TT.cjs');
|
|
20
20
|
|
|
21
21
|
// src/sheets/univer-snapshot-rows.ts
|
|
22
22
|
function univerSheetIds(snapshot) {
|
|
@@ -658,7 +658,7 @@ function planSheetPrint(rows, setup, frozen = { rows: 0, cols: 0 }) {
|
|
|
658
658
|
|
|
659
659
|
// src/sheets/sheet-page-setup-service.ts
|
|
660
660
|
var _db = require('@ai-matrx/data/db');
|
|
661
|
-
var db = () =>
|
|
661
|
+
var db = () => _chunkIJNET5TTcjs.getSheetsHost.call(void 0, ).getSupabase();
|
|
662
662
|
async function readSheetPageSetup(workbookId) {
|
|
663
663
|
const { data, error } = await db().schema("workbench").from("udt_workbooks").select("metadata").eq("id", workbookId).maybeSingle();
|
|
664
664
|
if (error) return { ok: false, error: error.message };
|
|
@@ -917,5 +917,5 @@ function readWorkbookScopeSource(workbookId) {
|
|
|
917
917
|
|
|
918
918
|
|
|
919
919
|
|
|
920
|
-
exports.DEFAULT_SHEET_PAGE_SETUP = DEFAULT_SHEET_PAGE_SETUP; exports.GRID_MAX_COLUMNS = GRID_MAX_COLUMNS; exports.GRID_MAX_ROWS = GRID_MAX_ROWS; exports.MARGIN_PRESET_INCHES = MARGIN_PRESET_INCHES; exports.PRINT_ROW_HEIGHT = PRINT_ROW_HEIGHT; exports.SHEET_MARGIN_PRESETS = SHEET_MARGIN_PRESETS; exports.SHEET_PRINT_SCOPES = SHEET_PRINT_SCOPES; exports.SHEET_SCALES = SHEET_SCALES; exports.THUMB_HEIGHT = THUMB_HEIGHT; exports.THUMB_WIDTH = THUMB_WIDTH; exports.buildSheetPrintDocument = buildSheetPrintDocument; exports.cfMatch = cfMatch; exports.collectPrintSheets = collectPrintSheets; exports.configureSheetsHost =
|
|
920
|
+
exports.DEFAULT_SHEET_PAGE_SETUP = DEFAULT_SHEET_PAGE_SETUP; exports.GRID_MAX_COLUMNS = GRID_MAX_COLUMNS; exports.GRID_MAX_ROWS = GRID_MAX_ROWS; exports.MARGIN_PRESET_INCHES = MARGIN_PRESET_INCHES; exports.PRINT_ROW_HEIGHT = PRINT_ROW_HEIGHT; exports.SHEET_MARGIN_PRESETS = SHEET_MARGIN_PRESETS; exports.SHEET_PRINT_SCOPES = SHEET_PRINT_SCOPES; exports.SHEET_SCALES = SHEET_SCALES; exports.THUMB_HEIGHT = THUMB_HEIGHT; exports.THUMB_WIDTH = THUMB_WIDTH; exports.buildSheetPrintDocument = buildSheetPrintDocument; exports.cfMatch = cfMatch; exports.collectPrintSheets = collectPrintSheets; exports.configureSheetsHost = _chunkIJNET5TTcjs.configureSheetsHost; exports.copyWorkbook = _chunkIJNET5TTcjs.copyWorkbook; exports.createWorkbook = _chunkIJNET5TTcjs.createWorkbook; exports.deleteWorkbook = _chunkIJNET5TTcjs.deleteWorkbook; exports.discardFailedWorkbook = _chunkIJNET5TTcjs.discardFailedWorkbook; exports.documentPreviewSvg = documentPreviewSvg; exports.downloadSheetAsCsv = downloadSheetAsCsv; exports.downloadSheetAsHtml = downloadSheetAsHtml; exports.downloadSheetAsPdf = downloadSheetAsPdf; exports.downloadSheetAsTsv = downloadSheetAsTsv; exports.formatCellValue = formatCellValue; exports.getLatestSnapshot = _chunkIJNET5TTcjs.getLatestSnapshot; exports.getSheetsHost = _chunkIJNET5TTcjs.getSheetsHost; exports.getWorkbook = _chunkIJNET5TTcjs.getWorkbook; exports.listAccessibleWorkbooks = _chunkIJNET5TTcjs.listAccessibleWorkbooks; exports.listSnapshots = _chunkIJNET5TTcjs.listSnapshots; exports.listTrashedWorkbooks = _chunkIJNET5TTcjs.listTrashedWorkbooks; exports.moveWorkbook = _chunkIJNET5TTcjs.moveWorkbook; exports.normalizeSheetPageSetup = normalizeSheetPageSetup; exports.pageSetupFromMetadata = pageSetupFromMetadata; exports.parseResource = parseResource; exports.planSheetPrint = planSheetPrint; exports.printColumnWidths = printColumnWidths; exports.printDocumentHtml = printDocumentHtml; exports.printGeometry = printGeometry; exports.printSheet = printSheet; exports.readSheetPageSetup = readSheetPageSetup; exports.readWorkbookScopeSource = readWorkbookScopeSource; exports.registerWorkbookScopeSource = registerWorkbookScopeSource; exports.renameWorkbook = _chunkIJNET5TTcjs.renameWorkbook; exports.restoreWorkbook = _chunkIJNET5TTcjs.restoreWorkbook; exports.saveSnapshot = _chunkIJNET5TTcjs.saveSnapshot; exports.sheetGridToCsv = sheetGridToCsv; exports.sheetGridToMarkdownTable = sheetGridToMarkdownTable; exports.snapshotPreviewSvg = snapshotPreviewSvg; exports.snapshotToGridSheets = snapshotToGridSheets; exports.univerSheetIds = univerSheetIds; exports.univerSnapshotToRows = univerSnapshotToRows; exports.updateWorkbookDescription = _chunkIJNET5TTcjs.updateWorkbookDescription; exports.workbookPreviewSvg = workbookPreviewSvg; exports.workbookSourceLabel = _chunkIJNET5TTcjs.workbookSourceLabel; exports.writeSheetPageSetup = writeSheetPageSetup;
|
|
921
921
|
//# sourceMappingURL=sheets.cjs.map
|
package/dist/sheets.d.cts
CHANGED
|
@@ -25,6 +25,14 @@ interface SheetsHostPorts {
|
|
|
25
25
|
}): Promise<{
|
|
26
26
|
fileId: string;
|
|
27
27
|
}>;
|
|
28
|
+
/**
|
|
29
|
+
* The record's CURRENT content, including what people are typing in a live co-editing room and have not saved
|
|
30
|
+
* (the app folds the room; the package owns no server). Optional: a host without co-editing leaves it out and
|
|
31
|
+
* a copy takes the newest saved snapshot. It may throw; the copy then fails with its message, never silently.
|
|
32
|
+
*/
|
|
33
|
+
readCurrentSnapshot?(workbookId: string): Promise<{
|
|
34
|
+
snapshot: unknown | null;
|
|
35
|
+
}>;
|
|
28
36
|
}
|
|
29
37
|
declare function configureSheetsHost(ports: SheetsHostPorts): void;
|
|
30
38
|
declare function getSheetsHost(): SheetsHostPorts;
|
|
@@ -143,7 +151,7 @@ declare function restoreWorkbook(workbookId: string): Promise<ServiceResult<true
|
|
|
143
151
|
declare function listTrashedWorkbooks(): Promise<ServiceResult<Workbook$1[]>>;
|
|
144
152
|
/**
|
|
145
153
|
* An independent copy of a workbook: its own row in the original's organization
|
|
146
|
-
* and project, with the
|
|
154
|
+
* and project, with the CURRENT content copied over (the live room when people are co-editing). Editing the copy never
|
|
147
155
|
* touches the original.
|
|
148
156
|
*/
|
|
149
157
|
declare function copyWorkbook(workbookId: string, name?: string): Promise<ServiceResult<Workbook$1>>;
|
package/dist/sheets.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ interface SheetsHostPorts {
|
|
|
25
25
|
}): Promise<{
|
|
26
26
|
fileId: string;
|
|
27
27
|
}>;
|
|
28
|
+
/**
|
|
29
|
+
* The record's CURRENT content, including what people are typing in a live co-editing room and have not saved
|
|
30
|
+
* (the app folds the room; the package owns no server). Optional: a host without co-editing leaves it out and
|
|
31
|
+
* a copy takes the newest saved snapshot. It may throw; the copy then fails with its message, never silently.
|
|
32
|
+
*/
|
|
33
|
+
readCurrentSnapshot?(workbookId: string): Promise<{
|
|
34
|
+
snapshot: unknown | null;
|
|
35
|
+
}>;
|
|
28
36
|
}
|
|
29
37
|
declare function configureSheetsHost(ports: SheetsHostPorts): void;
|
|
30
38
|
declare function getSheetsHost(): SheetsHostPorts;
|
|
@@ -143,7 +151,7 @@ declare function restoreWorkbook(workbookId: string): Promise<ServiceResult<true
|
|
|
143
151
|
declare function listTrashedWorkbooks(): Promise<ServiceResult<Workbook$1[]>>;
|
|
144
152
|
/**
|
|
145
153
|
* An independent copy of a workbook: its own row in the original's organization
|
|
146
|
-
* and project, with the
|
|
154
|
+
* and project, with the CURRENT content copied over (the live room when people are co-editing). Editing the copy never
|
|
147
155
|
* touches the original.
|
|
148
156
|
*/
|
|
149
157
|
declare function copyWorkbook(workbookId: string, name?: string): Promise<ServiceResult<Workbook$1>>;
|
package/dist/sheets.js
CHANGED
package/dist/univer-collab.cjs
CHANGED
|
@@ -3564,17 +3564,65 @@ function rebaseSheetUndoStack(items, remote, unitId) {
|
|
|
3564
3564
|
function createSheetsOtAdapter(port, hooks = {}) {
|
|
3565
3565
|
let queue = [];
|
|
3566
3566
|
let draining = false;
|
|
3567
|
+
const lazy = typeof port.beforeUndo === "function";
|
|
3568
|
+
let pending = [];
|
|
3569
|
+
let pendingBase = 0;
|
|
3570
|
+
let applied = 0;
|
|
3571
|
+
let currentAt = /* @__PURE__ */ new WeakMap();
|
|
3572
|
+
const PENDING_CAP = 2e3;
|
|
3573
|
+
const now = () => typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
3574
|
+
const stacksOfTargets = () => port.undoTargets().flatMap((t) => {
|
|
3575
|
+
const stacks = undoStacksOf2(t.service);
|
|
3576
|
+
return stacks ? [stacks.undo, stacks.redo].map((map) => ({ items: map.get(t.unitId), unitId: t.unitId, isUndo: map === stacks.undo })) : [];
|
|
3577
|
+
});
|
|
3578
|
+
const markNew = (items) => {
|
|
3579
|
+
for (let i = items.length - 1; i >= 0 && !currentAt.has(items[i]); i--) currentAt.set(items[i], applied);
|
|
3580
|
+
};
|
|
3581
|
+
const catchUpItem = (item, unitId) => {
|
|
3582
|
+
const from = currentAt.get(item) ?? applied;
|
|
3583
|
+
for (let k = from - pendingBase; k < pending.length; k++) if (rebaseSheetUndoStack([item], pending[k], unitId) > 0) return false;
|
|
3584
|
+
currentAt.set(item, applied);
|
|
3585
|
+
return true;
|
|
3586
|
+
};
|
|
3587
|
+
const catchUp = () => {
|
|
3588
|
+
if (!pending.length) return;
|
|
3589
|
+
const t0 = now();
|
|
3590
|
+
let dropped = 0;
|
|
3591
|
+
for (const { items, unitId } of stacksOfTargets()) {
|
|
3592
|
+
if (!items?.length) continue;
|
|
3593
|
+
for (let i = items.length - 1; i >= 0; i--)
|
|
3594
|
+
if (!catchUpItem(items[i], unitId)) {
|
|
3595
|
+
items.splice(i, 1);
|
|
3596
|
+
dropped++;
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
pending = [];
|
|
3600
|
+
pendingBase = applied;
|
|
3601
|
+
hooks.onUndoWork?.(now() - t0, "catch_up");
|
|
3602
|
+
if (dropped) hooks.onUndoRebased?.(dropped);
|
|
3603
|
+
};
|
|
3604
|
+
if (lazy) port.beforeUndo(catchUp);
|
|
3567
3605
|
const applyNow = (op) => {
|
|
3568
3606
|
for (const m of op) port.applyRemote(m);
|
|
3607
|
+
const t0 = now();
|
|
3569
3608
|
let dropped = 0;
|
|
3570
|
-
|
|
3571
|
-
const
|
|
3572
|
-
|
|
3573
|
-
for (const
|
|
3574
|
-
|
|
3575
|
-
|
|
3609
|
+
if (!lazy) {
|
|
3610
|
+
for (const { items, unitId } of stacksOfTargets()) if (items?.length) dropped += rebaseSheetUndoStack(items, op, unitId);
|
|
3611
|
+
} else if (!isNoopSheetOp(op)) {
|
|
3612
|
+
for (const { items, unitId, isUndo } of stacksOfTargets()) {
|
|
3613
|
+
if (!items?.length) continue;
|
|
3614
|
+
markNew(items);
|
|
3615
|
+
const top = items[items.length - 1];
|
|
3616
|
+
if (isUndo && (!catchUpItem(top, unitId) || rebaseSheetUndoStack([top], op, unitId) > 0)) {
|
|
3617
|
+
items.pop();
|
|
3618
|
+
dropped++;
|
|
3619
|
+
} else if (isUndo) currentAt.set(top, applied + 1);
|
|
3576
3620
|
}
|
|
3621
|
+
pending.push(op);
|
|
3622
|
+
applied++;
|
|
3623
|
+
if (pending.length > PENDING_CAP) catchUp();
|
|
3577
3624
|
}
|
|
3625
|
+
hooks.onUndoWork?.(now() - t0, "remote");
|
|
3578
3626
|
hooks.onUndoRebased?.(dropped);
|
|
3579
3627
|
port.markDirty();
|
|
3580
3628
|
};
|
|
@@ -3612,6 +3660,9 @@ function createSheetsOtAdapter(port, hooks = {}) {
|
|
|
3612
3660
|
stacks?.undo.delete(t.unitId);
|
|
3613
3661
|
stacks?.redo.delete(t.unitId);
|
|
3614
3662
|
}
|
|
3663
|
+
pending = [];
|
|
3664
|
+
pendingBase = applied;
|
|
3665
|
+
currentAt = /* @__PURE__ */ new WeakMap();
|
|
3615
3666
|
},
|
|
3616
3667
|
snapshot: () => port.snapshot(),
|
|
3617
3668
|
async hash() {
|
|
@@ -3799,6 +3850,8 @@ var REMOVE_MERGE = "sheet.mutation.remove-worksheet-merge";
|
|
|
3799
3850
|
var SHEET_NAME = "sheet.mutation.set-worksheet-name";
|
|
3800
3851
|
var INSERT_SHEET = "sheet.mutation.insert-sheet";
|
|
3801
3852
|
var RESHAPE = /* @__PURE__ */ new Set(["sheet.mutation.set-worksheet-row-count", "sheet.mutation.set-worksheet-column-count", "sheet.mutation.remove-sheet", INSERT_SHEET]);
|
|
3853
|
+
var UNDO = "univer.command.undo";
|
|
3854
|
+
var REDO = "univer.command.redo";
|
|
3802
3855
|
var DEPTH_GUARD = /* @__PURE__ */ Symbol.for("ai-matrx.office.sheets.command-depth-guard");
|
|
3803
3856
|
var json = (v) => v === void 0 ? v : JSON.parse(JSON.stringify(v));
|
|
3804
3857
|
var flagged = (options) => {
|
|
@@ -3808,6 +3861,7 @@ var flagged = (options) => {
|
|
|
3808
3861
|
function univerSheetsOtPort(o) {
|
|
3809
3862
|
const cs = o.commandService;
|
|
3810
3863
|
const listeners = /* @__PURE__ */ new Set();
|
|
3864
|
+
const undoWatchers = /* @__PURE__ */ new Set();
|
|
3811
3865
|
const idle = [];
|
|
3812
3866
|
const pre = /* @__PURE__ */ new WeakMap();
|
|
3813
3867
|
const tracker = { stack: [], settle: () => settle() };
|
|
@@ -3864,6 +3918,7 @@ function univerSheetsOtPort(o) {
|
|
|
3864
3918
|
if (tracker.stack.length === 0 && !group) for (const fn of idle.splice(0)) fn();
|
|
3865
3919
|
}
|
|
3866
3920
|
const before = cs.beforeCommandExecuted((info, options) => {
|
|
3921
|
+
if (info.id === UNDO || info.id === REDO) for (const fn of [...undoWatchers]) fn();
|
|
3867
3922
|
if (info.type === COMMAND) {
|
|
3868
3923
|
if (tracker.stack.length === 0 && !group) group = openGroup(info.id);
|
|
3869
3924
|
tracker.stack.push(info.id);
|
|
@@ -4121,8 +4176,13 @@ function univerSheetsOtPort(o) {
|
|
|
4121
4176
|
const service = o.undoRedo?.();
|
|
4122
4177
|
return u && service ? [{ service, unitId: u }] : [];
|
|
4123
4178
|
},
|
|
4179
|
+
beforeUndo(fn) {
|
|
4180
|
+
undoWatchers.add(fn);
|
|
4181
|
+
return () => void undoWatchers.delete(fn);
|
|
4182
|
+
},
|
|
4124
4183
|
markDirty: () => o.markDirty(),
|
|
4125
4184
|
dispose() {
|
|
4185
|
+
undoWatchers.clear();
|
|
4126
4186
|
before.dispose();
|
|
4127
4187
|
after.dispose();
|
|
4128
4188
|
collab.dispose();
|