[]
To support collaboration features, the Common module of SpreadJS introduces the UserManager concept, defining users as IUser to facilitate user management. It also provides configuration options for user access permissions to documents. This document gives a detailed explanation of the user-related features in collaboration.
SpreadJS currently provides related function to User:
Set the current user: Binds the current user to use their identity.
Get the current user: Get the specified user info.
setPresences: Synchronizes the presence status of other collaborative users.
getPresences: Get the current presences.
The GC.Spread.Common.UserManager.current method binds a user to the current enviornment, enabling the use of that user’s identity.
const loginUserId = 'userID1';
GC.Spread.Common.UserManager.current(loginUserId);Description: By calling the UserManager.current method, you can set a user as the active user for the current enviornment. This operation determines the user’s identity, suitable for multi-user collaborative editing scenarios. After binding, the user’s id, name, and color properties may be used to identify the source of operations or display user status in the interface.
The GC.Spread.Common.UserManager.get method retrieves the specified user information by user ID, used together with the UserManager.current method, it allows you to obtain information about the currently active user.
const currentUserID = GC.Spread.Common.UserManager.current();
const currentUserInfo = await GC.Spread.Common.UserManager.get(currentUserID);The setPresences/getPresences method is primarily used in multi-user collaboration to display the real-time presence status of other users (e.g., cursor position, selection areas).
For details, see Presence.