@atlaskit/editor-plugin-collab-edit
Version:
Collab Edit plugin for @atlaskit/editor-core
22 lines • 1.37 kB
JavaScript
import _typeof from "@babel/runtime/helpers/typeof";
import { pluginKey } from './plugin-key';
var isAgentRemoteStep = function isAgentRemoteStep(step) {
return _typeof(step) === 'object' && step !== null && typeof step.agentType === 'string';
};
export var getAgentEditRequester = function getAgentEditRequester(json, view) {
var _collabPluginState$ac;
var agentStep = json.find(isAgentRemoteStep);
if (!agentStep) {
return null;
}
var actorUserId = typeof agentStep.userId === 'string' ? agentStep.userId : undefined;
var collabPluginState = pluginKey.getState(view.state);
var localSessionId = collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId;
var localUserId = localSessionId ? collabPluginState === null || collabPluginState === void 0 || (_collabPluginState$ac = collabPluginState.activeParticipants) === null || _collabPluginState$ac === void 0 || (_collabPluginState$ac = _collabPluginState$ac.get(localSessionId)) === null || _collabPluginState$ac === void 0 ? void 0 : _collabPluginState$ac.userId : undefined;
return {
agentId: typeof agentStep.agentId === 'string' ? agentStep.agentId : undefined,
agentType: agentStep.agentType,
actorUserId: actorUserId,
isLocalUserRequester: actorUserId !== undefined && localUserId !== undefined && actorUserId === localUserId
};
};