Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: remove table not found throw error (#6068)
wpxp123456127f9ef83fb6
diff --git a/packages/engine-render/src/components/docs/layout/block/table.ts b/packages/engine-render/src/components/docs/layout/block/table.tsindex eedc8c2dce..c768385f25 100644--- a/packages/engine-render/src/components/docs/layout/block/table.ts+++ b/packages/engine-render/src/components/docs/layout/block/table.ts@@ -28,11 +28,12 @@ export function createTableSkeleton(viewModel: DocumentViewModel,tableNode: DataStreamTreeNode,sectionBreakConfig: ISectionBreakConfig-): IDocumentSkeletonTable {+): Nullable<IDocumentSkeletonTable> {const { startIndex, endIndex, children: rowNodes } = tableNode;const table = viewModel.getTableByStartIndex(startIndex)?.tableSource;if (table == null) {- throw new Error('Table not found');+ console.warn('Table not found when creating table skeleton');+ return null;}const tableSkeleton = getNullTableSkeleton(startIndex, endIndex, table);@@ -173,7 +174,11 @@ export function createTableSkeletons(const table = viewModel.getTableByStartIndex(startIndex)?.tableSource;if (table == null) {- throw new Error('Table not found when creating table skeletons');+ console.warn('Table not found when creating table skeletons');+ return {+ skeTables,+ fromCurrentPage: false,+ };}const needRepeatHeader = table.tableRows[0].repeatHeaderRow === BooleanNumber.TRUE;diff --git a/packages/sheets-table/src/commands/commands/delete-sheet-table.command.ts b/packages/sheets-table/src/commands/commands/delete-sheet-table.command.tsindex 68c2f6acf4..b89589e59a 100644--- a/packages/sheets-table/src/commands/commands/delete-sheet-table.command.ts+++ b/packages/sheets-table/src/commands/commands/delete-sheet-table.command.ts@@ -16,7 +16,7 @@import type { ICommand, IMutationInfo } from '@univerjs/core';import type { IDeleteSheetTableParams } from '../mutations/delete-sheet-table.mutation';-import { CommandType, ICommandService, IUndoRedoService, sequenceExecute } from '@univerjs/core';+import { CommandType, ICommandService, ILogService, IUndoRedoService, sequenceExecute } from '@univerjs/core';import { TableManager } from '../../model/table-manager';import { AddSheetTableMutation } from '../mutations/add-sheet-table.mutation';@@ -32,6 +32,7 @@ export const DeleteSheetTableCommand: ICommand<IDeleteSheetTableParams> = {const undoRedoService = accessor.get(IUndoRedoService);const commandService = accessor.get(ICommandService);const sheetTableManager = accessor.get(TableManager);+ const logService = accessor.get(ILogService);const redos: IMutationInfo[] = [];const undos: IMutationInfo[] = [];@@ -40,7 +41,8 @@ export const DeleteSheetTableCommand: ICommand<IDeleteSheetTableParams> = {const tableConfig = tableInstance?.toJSON();if (!tableConfig) {- throw new Error('[TableManager]: Table not found');+ logService.error('[TableManager]: Table not found');+ return false;}redos.push({ id: DeleteSheetTableMutation.id, params: { ...params } });