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(facade): make facade sync (#4482)
zhangw447f9911508f
diff --git a/packages/sheets-thread-comment/src/facade/f-range.ts b/packages/sheets-thread-comment/src/facade/f-range.tsindex d4b78267bc..ee40061ba0 100644--- a/packages/sheets-thread-comment/src/facade/f-range.ts+++ b/packages/sheets-thread-comment/src/facade/f-range.ts@@ -33,24 +33,35 @@ export interface IFRangeCommentMixin {* @returns {FThreadComment[]} The comments in the current range.*/getComments(): FThreadComment[];-/**- * Add a comment to the start cell in the current range.- * @param content The content of the comment.- * @returns Whether the comment is added successfully.+ * @deprecated use `addCommentAsync` as instead.*/addComment(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;+ /**+ * Add a comment to the start cell in the current range.+ * @param content The content of the comment.+ * @returns Whether the comment is added successfully.+ */+ addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean>;+/**- * Clear the comment of the start cell in the current range.- * @returns Whether the comment is cleared successfully.+ * @deprecated use `clearCommentAsync` as instead.*/clearComment(): Promise<boolean>;-+ /**+ * Clear the comment of the start cell in the current range.+ * @returns Whether the comment is cleared successfully.+ */+ clearCommentAsync(): Promise<boolean>;+ /**+ * @deprecated use `clearComments` as instead.+ */+ clearComments(): Promise<boolean>;/*** Clear all of the comments in the current range.* @returns Whether the comments are cleared successfully.*/- clearComments(): Promise<boolean>;+ clearCommentsAsync(): Promise<boolean>;}export class FRangeCommentMixin extends FRange implements IFRangeCommentMixin {@@ -145,6 +156,18 @@ export class FRangeCommentMixin extends FRange implements IFRangeCommentMixin {return Promise.all(promises).then(() => true);}++ override addCommentAsync(content: IDocumentBody | FTheadCommentBuilder): Promise<boolean> {+ return this.addComment(content);+ }++ override clearCommentAsync(): Promise<boolean> {+ return this.clearComment();+ }++ override clearCommentsAsync(): Promise<boolean> {+ return this.clearComments();+ }}FRange.extend(FRangeCommentMixin);diff --git a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.tsindex 74b16124de..860aff5cb4 100644--- a/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts+++ b/packages/sheets/src/commands/commands/remove-worksheet-merge.command.ts@@ -40,7 +40,7 @@ export const RemoveWorksheetMergeCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.remove-worksheet-merge',// eslint-disable-next-line max-lines-per-function- handler: async (accessor: IAccessor, params: IRemoveWorksheetMergeCommandParams) => {+ handler: (accessor: IAccessor, params: IRemoveWorksheetMergeCommandParams) => {const selectionManagerService = accessor.get(SheetsSelectionsService);const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);diff --git a/packages/sheets/src/commands/commands/split-text-to-columns.command.ts b/packages/sheets/src/commands/commands/split-text-to-columns.command.tsindex c2219986b9..43deaf40a7 100644--- a/packages/sheets/src/commands/commands/split-text-to-columns.command.ts+++ b/packages/sheets/src/commands/commands/split-text-to-columns.command.ts@@ -38,7 +38,7 @@ export const SplitTextToColumnsCommand = {type: CommandType.COMMAND,id: 'sheet.command.split-text-to-columns',// eslint-disable-next-line max-lines-per-function- handler: async (accessor: IAccessor, params: ISplitTextToColumnsCommandParams) => {+ handler: (accessor: IAccessor, params: ISplitTextToColumnsCommandParams) => {const { unitId, subUnitId, range, delimiter, customDelimiter, treatMultipleDelimitersAsOne } = params;const commandService = accessor.get(ICommandService);diff --git a/packages/sheets/src/commands/commands/toggle-gridlines.command.ts b/packages/sheets/src/commands/commands/toggle-gridlines.command.tsindex 479264d7bb..13d6bef719 100644--- a/packages/sheets/src/commands/commands/toggle-gridlines.command.ts+++ b/packages/sheets/src/commands/commands/toggle-gridlines.command.ts@@ -29,7 +29,7 @@ export interface IToggleGridlinesCommandParams {export const ToggleGridlinesCommand: ICommand = {type: CommandType.COMMAND,id: 'sheet.command.toggle-gridlines',- handler: async (accessor: IAccessor, params?: IToggleGridlinesCommandParams) => {+ handler: (accessor: IAccessor, params?: IToggleGridlinesCommandParams) => {const commandService = accessor.get(ICommandService);const undoRedoService = accessor.get(IUndoRedoService);const univerInstanceService = accessor.get(IUniverInstanceService);diff --git a/packages/sheets/src/facade/f-permission.ts b/packages/sheets/src/facade/f-permission.tsindex e7ac1b47e9..e6122524a5 100644--- a/packages/sheets/src/facade/f-permission.ts+++ b/packages/sheets/src/facade/f-permission.ts@@ -154,7 +154,7 @@ export class FPermission extends FBase {scope: undefined,},});- this._commandService.executeCommand(SetWorksheetPermissionPointsMutation.id, { unitId, subUnitId, permissionId });+ this._commandService.syncExecuteCommand(SetWorksheetPermissionPointsMutation.id, { unitId, subUnitId, permissionId });} else {permissionId = rule.permissionId;}diff --git a/packages/sheets/src/facade/f-range.ts b/packages/sheets/src/facade/f-range.tsindex 5ee057dcb3..a940d40aeb 100644--- a/packages/sheets/src/facade/f-range.ts+++ b/packages/sheets/src/facade/f-range.ts@@ -813,7 +813,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);return this;}@@ -854,7 +854,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);return this;}@@ -920,7 +920,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);}/**@@ -940,7 +940,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);}/**@@ -967,7 +967,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);return this;}@@ -996,7 +996,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);return this;}@@ -1027,7 +1027,7 @@ export class FRange extends FBaseInitialable {style,};- this._commandService.executeCommand(SetStyleCommand.id, setStyleParams);+ this._commandService.syncExecuteCommand(SetStyleCommand.id, setStyleParams);return this;}@@ -1144,7 +1144,7 @@ export class FRange extends FBaseInitialable {* ```*/breakApart(): FRange {- this._commandService.executeCommand(RemoveWorksheetMergeCommand.id, { ranges: [this._range] });+ this._commandService.syncExecuteCommand(RemoveWorksheetMergeCommand.id, { ranges: [this._range] });return this;}@@ -1285,7 +1285,7 @@ export class FRange extends FBaseInitialable {* // 4 | 5 | 6*/splitTextToColumns(treatMultipleDelimitersAsOne?: boolean, delimiter?: SplitDelimiterEnum, customDelimiter?: string): void {- this._commandService.executeCommand(SplitTextToColumnsCommand.id, {+ this._commandService.syncExecuteCommand(SplitTextToColumnsCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),range: this._range,@@ -1313,7 +1313,7 @@ export class FRange extends FBaseInitialable {this.removeThemeStyle(usedThemeName);}} else {- this._commandService.executeCommand(SetWorksheetRangeThemeStyleCommand.id, {+ this._commandService.syncExecuteCommand(SetWorksheetRangeThemeStyleCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),range: this._range,@@ -1334,7 +1334,7 @@ export class FRange extends FBaseInitialable {* ```*/removeThemeStyle(themeName: string): void {- this._commandService.executeCommand(DeleteWorksheetRangeThemeStyleCommand.id, {+ this._commandService.syncExecuteCommand(DeleteWorksheetRangeThemeStyleCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),range: this._range,diff --git a/packages/sheets/src/facade/f-worksheet.ts b/packages/sheets/src/facade/f-worksheet.tsindex 142d79326b..2e97b20818 100644--- a/packages/sheets/src/facade/f-worksheet.ts+++ b/packages/sheets/src/facade/f-worksheet.ts@@ -1290,7 +1290,7 @@ export class FWorksheet extends FBaseInitialable {* ```*/setHiddenGridlines(hidden: boolean): FWorksheet {- this._commandService.executeCommand(ToggleGridlinesCommand.id, {+ this._commandService.syncExecuteCommand(ToggleGridlinesCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),showGridlines: hidden ? BooleanNumber.FALSE : BooleanNumber.TRUE,@@ -1340,7 +1340,7 @@ export class FWorksheet extends FBaseInitialable {* ```*/setTabColor(color: string): FWorksheet {- this._commandService.executeCommand(SetTabColorCommand.id, {+ this._commandService.syncExecuteCommand(SetTabColorCommand.id, {unitId: this._workbook.getUnitId(),subUnitId: this._worksheet.getSheetId(),color,diff --git a/packages/ui/src/facade/f-univer.ts b/packages/ui/src/facade/f-univer.tsindex 1e44b372ec..3e93c561aa 100644--- a/packages/ui/src/facade/f-univer.ts+++ b/packages/ui/src/facade/f-univer.ts@@ -152,11 +152,11 @@ export class FUniverUIMixin extends FUniver implements IFUniverUIMixin {}override copy(): Promise<boolean> {- return this._commandService.executeCommand(CopyCommand.id);+ return this._commandService.syncExecuteCommand(CopyCommand.id);}override paste(): Promise<boolean> {- return this._commandService.executeCommand(PasteCommand.id);+ return this._commandService.syncExecuteCommand(PasteCommand.id);}override createMenu(menuItem: IFacadeMenuItem): FMenu {diff --git a/packages/ui/src/services/clipboard/clipboard.command.ts b/packages/ui/src/services/clipboard/clipboard.command.tsindex f6be3ea337..6cfd32334a 100644--- a/packages/ui/src/services/clipboard/clipboard.command.ts+++ b/packages/ui/src/services/clipboard/clipboard.command.ts@@ -25,7 +25,7 @@ export const CopyCommand: IMultiCommand = {priority: 0,type: CommandType.COMMAND,preconditions: () => false,- handler: async () => true,+ handler: () => true,};const CutCommandName = 'univer.command.cut';@@ -47,7 +47,7 @@ export const PasteCommand: IMultiCommand = {priority: 0,type: CommandType.COMMAND,preconditions: () => false,- handler: async () => true,+ handler: () => true,};export const SheetPasteShortKeyCommandName = 'sheet.command.paste-by-short-key';