Skip to Content
ClassesFCollaboration

类: FCollaboration

The Facade API object for the Collaboration module. It provides methods to interact with the Univer Collaboration backend server, such as loading Univer Sheets and subscribing to collaborators.

继承

  • FBase

方法

getCollaborationStatus()

getCollaborationStatus(): CollaborationStatus

Get the synchronization status of the currently focused unit (workbook or document).

返回

CollaborationStatus

The current synchronization status of the focused unit. Returns CollaborationStatus.NOT_COLLAB if no unit is focused or collaboration is not enabled.

Possible status values:

  • NOT_COLLAB: Not in collaboration mode
  • SYNCED: All changes are synchronized
  • PENDING: Local changes waiting to be sent
  • AWAITING: Changes sent, waiting for server acknowledgement
  • AWAITING_WITH_PENDING: Awaiting acknowledgement with new local changes
  • FETCH_MISS: Fetching missing changesets from server
  • CONFLICT: Conflict detected and being resolved
  • OFFLINE: Network is offline

示例

const collaboration = univerAPI.getCollaboration(); const status = collaboration.getCollaborationStatus(); // Check if synchronized if (status === univerAPI.Enum.CollaborationStatus.SYNCED) { console.log('All changes are synced!'); }

loadActiveSheet()

loadActiveSheet(): Promise<FWorkbook>

返回

Promise<FWorkbook>

The FWorkbook or null if the active Univer Sheet cannot be loaded.

已被弃用

Use loadActiveSheetAsync instead.


loadActiveSheetAsync()

loadActiveSheetAsync(): Promise<FWorkbook>

Load the active Univer Sheet. It should be associated with the Uniscript Node.js Runtime.

返回

Promise<FWorkbook>

The FWorkbook or null if the active Univer Sheet cannot be loaded.

抛出

If the method is not overridden.

示例

const collaboration = univerAPI.getCollaboration(); const workbook = await collaboration.loadActiveSheetAsync();

loadSheet()

loadSheet(unitId): Promise<FWorkbook>

参数

参数类型描述
unitIdstringThe Id of the Univer Sheet that you would like to load.

返回

Promise<FWorkbook>

The FWorkbook or null if the Univer Sheet cannot be loaded.

已被弃用

Use loadSheetAsync instead.


loadSheetAsync()

loadSheetAsync(unitId, context?): Promise<FWorkbook>

Load a Univer Sheet from the server with a unit ID.

参数

参数类型描述
unitIdstringID of the Univer Sheet that you would like to load.
context?ILogContext$1Optional context.

返回

Promise<FWorkbook>

The FWorkbook or null if ID cannot be associated with a Univer Sheet.

示例

const collaboration = univerAPI.getCollaboration(); const workbook = await collaboration.loadSheetAsync('your-unit-id');

subscribeCollaborators()

subscribeCollaborators(unitId, callback): IDisposable

Subscribe collaborators of a Univer file.

参数

参数类型描述
unitIdstringID of the Univer file.
callback(members) => voidA callback function that will be called when the collaborators change.

返回

IDisposable

A handler to dispose the subscription.

示例

const collaboration = univerAPI.getCollaboration(); collaboration.subscribeCollaborators('your-unit-id', (members) => { console.log(members); });