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: should not close editor when collab edits happen (#782)
Wenzhao Huffb94c9941f2
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.tsindex b18bfb9403..b82d113b05 100644--- a/packages/core/src/services/command/command.service.ts+++ b/packages/core/src/services/command/command.service.ts@@ -119,11 +119,10 @@ export interface IOperationInfo<T extends object = object> {}export interface IExecutionOptions {- /** This mutation should only be executed on the local machine. */- // TODO@wzhudev: remove to `onlyLocal`- local?: boolean;+ /** This mutation should only be executed on the local machine, and not synced to replicas. */+ onlyLocal?: boolean;- /** From collaboration peers. */+ /** This command is from collaboration peers. */fromCollab?: boolean;[key: PropertyKey]: string | number | boolean | undefined;diff --git a/packages/engine-formula/src/controller/calculate.controller.ts b/packages/engine-formula/src/controller/calculate.controller.tsindex 8bc1e64b57..0a260214e9 100644--- a/packages/engine-formula/src/controller/calculate.controller.ts+++ b/packages/engine-formula/src/controller/calculate.controller.ts@@ -144,7 +144,7 @@ export class CalculateController extends Disposable {functionsExecutedState,},{- local: true,+ onlyLocal: true,});});@@ -179,7 +179,7 @@ export class CalculateController extends Disposable {stageInfo: data,},{- local: true,+ onlyLocal: true,});});@@ -210,7 +210,7 @@ export class CalculateController extends Disposable {arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData(),},{- local: true,+ onlyLocal: true,});}@@ -222,7 +222,7 @@ export class CalculateController extends Disposable {unitOtherData,},{- local: true,+ onlyLocal: true,});}diff --git a/packages/rpc/src/services/remote-instance/remote-instance.service.ts b/packages/rpc/src/services/remote-instance/remote-instance.service.tsindex c5dadb2d96..afbc20d16b 100644--- a/packages/rpc/src/services/remote-instance/remote-instance.service.ts+++ b/packages/rpc/src/services/remote-instance/remote-instance.service.ts@@ -19,7 +19,7 @@ import { DocumentType, ICommandService, IUniverInstanceService } from '@univerjsimport { createIdentifier } from '@wendellhu/redi';export interface IRemoteSyncMutationOptions extends IExecutionOptions {- /** If this mutation is executed after it was sent from the peer univer instance. */+ /** If this mutation is executed after it was sent from the peer univer instance (e.g. in a web worker). */fromSync?: boolean;}@@ -38,7 +38,7 @@ export class RemoteSyncPrimaryService implements IRemoteSyncService {async syncMutation(params: { mutationInfo: IMutationInfo }): Promise<boolean> {return this._commandService.syncExecuteCommand(params.mutationInfo.id, params.mutationInfo.params, {- local: true,+ onlyLocal: true,fromSync: true,});}@@ -65,7 +65,7 @@ export class RemoteInstanceReplicaService implements IRemoteInstanceService {async syncMutation(params: { mutationInfo: IMutationInfo }): Promise<boolean> {return this._commandService.syncExecuteCommand(params.mutationInfo.id, params.mutationInfo.params, {- local: true,+ onlyLocal: true,fromSync: true,});}diff --git a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.tsindex 4d499e5de1..69b2116e9b 100644--- a/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts+++ b/packages/sheets-ui/src/controllers/active-worksheet/active-worksheet.controller.ts@@ -69,7 +69,7 @@ export class ActiveWorksheetController extends Disposable {}// It is a mutation that we comes from the collaboration peer so we should not handle them.- if (options?.local) {+ if (options?.fromCollab) {return;}diff --git a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts b/packages/sheets-ui/src/controllers/editor-bridge.controller.tsindex 2a8350cd19..f456d30bc0 100644--- a/packages/sheets-ui/src/controllers/editor-bridge.controller.ts+++ b/packages/sheets-ui/src/controllers/editor-bridge.controller.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { ICommandInfo, Nullable } from '@univerjs/core';+import type { ICommandInfo, IExecutionOptions, Nullable } from '@univerjs/core';import {Disposable,DOCS_NORMAL_EDITOR_UNIT_ID_KEY,@@ -269,7 +269,11 @@ export class EditorBridgeController extends Disposable {const updateCommandList = COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(- this._commandService.onCommandExecuted((command: ICommandInfo) => {+ this._commandService.onCommandExecuted((command: ICommandInfo, options?: IExecutionOptions) => {+ if (options?.fromCollab) {+ return;+ }+if (command.id === SetWorksheetActiveOperation.id) {this._keepVisibleHideEditor();} else if (updateCommandList.includes(command.id)) {diff --git a/packages/sheets/src/controllers/calculate-result-apply.controller.ts b/packages/sheets/src/controllers/calculate-result-apply.controller.tsindex ff272137cf..27c6752998 100644--- a/packages/sheets/src/controllers/calculate-result-apply.controller.ts+++ b/packages/sheets/src/controllers/calculate-result-apply.controller.ts@@ -78,7 +78,7 @@ export class CalculateResultApplyController extends Disposable {const result = redoMutationsInfo.every((m) =>this._commandService.executeCommand(m.id, m.params, {- local: true,+ onlyLocal: true,}));return result;