@atlaskit/editor-plugin-collab-edit 31.0.6 → 32.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 32.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`88f6eda39f497`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/88f6eda39f497) -
8
+ Resolve agent telepointer colours from supplied display names and stable named IDs instead of
9
+ machine types. Under `confluence_ncs_step_diffing_version_history`, collab-provider carries
10
+ `agentId`, `agentName` and `agentNamedId` from received steps into local agent presence, retaining
11
+ known metadata when later steps omit it. This path uses no profile lookups. Missing presentation
12
+ metadata uses the generic agent palette; human participants keep their existing colours.
13
+
14
+ Telepointers identify agent participants from these explicit identity fields rather than
15
+ `agentType` or a human participant's display name.
16
+
17
+ `getParticipantColor(id, agentName?, agentNamedId?)` and
18
+ `collabEdit.actions.getAvatarColor(id, agentName?, agentNamedId?)` now accept a resolved display
19
+ name in the second argument. Callers previously passing a machine type should supply the agent's
20
+ name instead, and pass stable named IDs in the third argument. With
21
+ `confluence_ncs_step_diffing_version_history` enabled, named brand metadata takes precedence over
22
+ the display name. With the gate off, brand lookup is disabled. Human callers should continue to
23
+ omit agent metadata.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+
3
29
  ## 31.0.6
4
30
 
5
31
  ### Patch Changes
@@ -29,6 +29,13 @@ var getValidPos = exports.getValidPos = function getValidPos(tr, pos) {
29
29
  }
30
30
  return endOfDocPos;
31
31
  };
32
+ var getAgentName = function getAgentName(participant) {
33
+ var _participant$agentNam;
34
+ return (
35
+ // Explicit agent identity selects the agent palette without classifying human display names.
36
+ participant !== null && participant !== void 0 && participant.agentName || participant !== null && participant !== void 0 && participant.agentNamedId || participant !== null && participant !== void 0 && participant.agentId ? ((_participant$agentNam = participant.agentName) === null || _participant$agentNam === void 0 ? void 0 : _participant$agentNam.trim()) || participant.name.trim() || 'Agent' : undefined
37
+ );
38
+ };
32
39
  var PluginState = exports.PluginState = /*#__PURE__*/function () {
33
40
  function PluginState(decorations, participants, sessionId) {
34
41
  var collabInitalised = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -152,7 +159,7 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
152
159
  } catch (err) {
153
160
  this.onError(err);
154
161
  }
155
- add = add.concat((0, _utils.createTelepointers)(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), (0, _utils.hasExistingNudge)(sessionId, this.nudgeAnimations), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentType));
162
+ add = add.concat((0, _utils.createTelepointers)(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), (0, _utils.hasExistingNudge)(sessionId, this.nudgeAnimations), getAgentName(participants.get(sessionId)), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentNamedId));
156
163
  }
157
164
  }
158
165
  if (tr.docChanged) {
@@ -172,7 +179,7 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
172
179
  size = _ref.slice.content.size,
173
180
  _from = _ref.from;
174
181
  var pos = getValidPos(tr, size ? Math.min(_from + size, tr.doc.nodeSize - 3) : Math.max(_from, 1));
175
- add = add.concat((0, _utils.createTelepointers)(pos, pos, _sessionId, false, _this.getInitial(_sessionId), presenceId, _this.getFullName(_sessionId), (0, _utils.hasExistingNudge)(_sessionId, _this.nudgeAnimations), (_participants$get2 = participants.get(_sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentType));
182
+ add = add.concat((0, _utils.createTelepointers)(pos, pos, _sessionId, false, _this.getInitial(_sessionId), presenceId, _this.getFullName(_sessionId), (0, _utils.hasExistingNudge)(_sessionId, _this.nudgeAnimations), getAgentName(participants.get(_sessionId)), (_participants$get2 = participants.get(_sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentNamedId));
176
183
  }
177
184
  }
178
185
  }
@@ -35,17 +35,17 @@ function style(options) {
35
35
  var borderWidth = "var(--ds-border-width-focused, 2px)";
36
36
  return "border-right: ".concat(borderWidth, " solid ").concat(color, "; margin-right: calc(-1 * ").concat(borderWidth, "); z-index: 1");
37
37
  }
38
- function getAvatarColor(str, agentType) {
39
- var participantColor = (0, _utils.getParticipantColor)(str, (0, _fg.fg)('confluence_ncs_step_diffing_version_history') ? agentType : undefined);
38
+ function getAvatarColor(str, agentName, agentNamedId) {
39
+ var participantColor = (0, _utils.getParticipantColor)(str, (0, _fg.fg)('confluence_ncs_step_diffing_version_history') ? agentName : undefined, (0, _fg.fg)('confluence_ncs_step_diffing_version_history') ? agentNamedId : undefined);
40
40
  return {
41
41
  index: participantColor.index,
42
42
  backgroundColor: participantColor.color.backgroundColor,
43
43
  textColor: participantColor.color.textColor
44
44
  };
45
45
  }
46
- var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentType) {
46
+ var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentName, agentNamedId) {
47
47
  var decorations = [];
48
- var avatarColor = getAvatarColor(presenceId, agentType);
48
+ var avatarColor = getAvatarColor(presenceId, agentName, agentNamedId);
49
49
  var color = avatarColor.index.toString();
50
50
  if (isSelection) {
51
51
  var className = "telepointer color-".concat(color, " telepointer-selection");
@@ -21,6 +21,13 @@ export const getValidPos = (tr, pos) => {
21
21
  }
22
22
  return endOfDocPos;
23
23
  };
24
+ const getAgentName = participant => {
25
+ var _participant$agentNam;
26
+ return (
27
+ // Explicit agent identity selects the agent palette without classifying human display names.
28
+ participant !== null && participant !== void 0 && participant.agentName || participant !== null && participant !== void 0 && participant.agentNamedId || participant !== null && participant !== void 0 && participant.agentId ? ((_participant$agentNam = participant.agentName) === null || _participant$agentNam === void 0 ? void 0 : _participant$agentNam.trim()) || participant.name.trim() || 'Agent' : undefined
29
+ );
30
+ };
24
31
  export class PluginState {
25
32
  get decorations() {
26
33
  return this.decorationSet;
@@ -126,7 +133,7 @@ export class PluginState {
126
133
  } catch (err) {
127
134
  this.onError(err);
128
135
  }
129
- add = add.concat(createTelepointers(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentType));
136
+ add = add.concat(createTelepointers(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), getAgentName(participants.get(sessionId)), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentNamedId));
130
137
  }
131
138
  }
132
139
  if (tr.docChanged) {
@@ -154,7 +161,7 @@ export class PluginState {
154
161
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
155
162
  } = step;
156
163
  const pos = getValidPos(tr, size ? Math.min(from + size, tr.doc.nodeSize - 3) : Math.max(from, 1));
157
- add = add.concat(createTelepointers(pos, pos, sessionId, false, this.getInitial(sessionId), presenceId, this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), (_participants$get2 = participants.get(sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentType));
164
+ add = add.concat(createTelepointers(pos, pos, sessionId, false, this.getInitial(sessionId), presenceId, this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), getAgentName(participants.get(sessionId)), (_participants$get2 = participants.get(sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentNamedId));
158
165
  }
159
166
  }
160
167
  }
@@ -23,17 +23,17 @@ function style(options) {
23
23
  const borderWidth = "var(--ds-border-width-focused, 2px)";
24
24
  return `border-right: ${borderWidth} solid ${color}; margin-right: calc(-1 * ${borderWidth}); z-index: 1`;
25
25
  }
26
- export function getAvatarColor(str, agentType) {
27
- const participantColor = getParticipantColor(str, fg('confluence_ncs_step_diffing_version_history') ? agentType : undefined);
26
+ export function getAvatarColor(str, agentName, agentNamedId) {
27
+ const participantColor = getParticipantColor(str, fg('confluence_ncs_step_diffing_version_history') ? agentName : undefined, fg('confluence_ncs_step_diffing_version_history') ? agentNamedId : undefined);
28
28
  return {
29
29
  index: participantColor.index,
30
30
  backgroundColor: participantColor.color.backgroundColor,
31
31
  textColor: participantColor.color.textColor
32
32
  };
33
33
  }
34
- export const createTelepointers = (from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentType) => {
34
+ export const createTelepointers = (from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentName, agentNamedId) => {
35
35
  const decorations = [];
36
- const avatarColor = getAvatarColor(presenceId, agentType);
36
+ const avatarColor = getAvatarColor(presenceId, agentName, agentNamedId);
37
37
  const color = avatarColor.index.toString();
38
38
  if (isSelection) {
39
39
  const className = `telepointer color-${color} telepointer-selection`;
@@ -23,6 +23,13 @@ export var getValidPos = function getValidPos(tr, pos) {
23
23
  }
24
24
  return endOfDocPos;
25
25
  };
26
+ var getAgentName = function getAgentName(participant) {
27
+ var _participant$agentNam;
28
+ return (
29
+ // Explicit agent identity selects the agent palette without classifying human display names.
30
+ participant !== null && participant !== void 0 && participant.agentName || participant !== null && participant !== void 0 && participant.agentNamedId || participant !== null && participant !== void 0 && participant.agentId ? ((_participant$agentNam = participant.agentName) === null || _participant$agentNam === void 0 ? void 0 : _participant$agentNam.trim()) || participant.name.trim() || 'Agent' : undefined
31
+ );
32
+ };
26
33
  export var PluginState = /*#__PURE__*/function () {
27
34
  function PluginState(decorations, participants, sessionId) {
28
35
  var collabInitalised = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -146,7 +153,7 @@ export var PluginState = /*#__PURE__*/function () {
146
153
  } catch (err) {
147
154
  this.onError(err);
148
155
  }
149
- add = add.concat(createTelepointers(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentType));
156
+ add = add.concat(createTelepointers(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId), this.getFullName(sessionId), hasExistingNudge(sessionId, this.nudgeAnimations), getAgentName(participants.get(sessionId)), (_participants$get = participants.get(sessionId)) === null || _participants$get === void 0 ? void 0 : _participants$get.agentNamedId));
150
157
  }
151
158
  }
152
159
  if (tr.docChanged) {
@@ -166,7 +173,7 @@ export var PluginState = /*#__PURE__*/function () {
166
173
  size = _ref.slice.content.size,
167
174
  _from = _ref.from;
168
175
  var pos = getValidPos(tr, size ? Math.min(_from + size, tr.doc.nodeSize - 3) : Math.max(_from, 1));
169
- add = add.concat(createTelepointers(pos, pos, _sessionId, false, _this.getInitial(_sessionId), presenceId, _this.getFullName(_sessionId), hasExistingNudge(_sessionId, _this.nudgeAnimations), (_participants$get2 = participants.get(_sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentType));
176
+ add = add.concat(createTelepointers(pos, pos, _sessionId, false, _this.getInitial(_sessionId), presenceId, _this.getFullName(_sessionId), hasExistingNudge(_sessionId, _this.nudgeAnimations), getAgentName(participants.get(_sessionId)), (_participants$get2 = participants.get(_sessionId)) === null || _participants$get2 === void 0 ? void 0 : _participants$get2.agentNamedId));
170
177
  }
171
178
  }
172
179
  }
@@ -26,17 +26,17 @@ function style(options) {
26
26
  var borderWidth = "var(--ds-border-width-focused, 2px)";
27
27
  return "border-right: ".concat(borderWidth, " solid ").concat(color, "; margin-right: calc(-1 * ").concat(borderWidth, "); z-index: 1");
28
28
  }
29
- export function getAvatarColor(str, agentType) {
30
- var participantColor = getParticipantColor(str, fg('confluence_ncs_step_diffing_version_history') ? agentType : undefined);
29
+ export function getAvatarColor(str, agentName, agentNamedId) {
30
+ var participantColor = getParticipantColor(str, fg('confluence_ncs_step_diffing_version_history') ? agentName : undefined, fg('confluence_ncs_step_diffing_version_history') ? agentNamedId : undefined);
31
31
  return {
32
32
  index: participantColor.index,
33
33
  backgroundColor: participantColor.color.backgroundColor,
34
34
  textColor: participantColor.color.textColor
35
35
  };
36
36
  }
37
- export var createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentType) {
37
+ export var createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial, presenceId, fullName, isNudged, agentName, agentNamedId) {
38
38
  var decorations = [];
39
- var avatarColor = getAvatarColor(presenceId, agentType);
39
+ var avatarColor = getAvatarColor(presenceId, agentName, agentNamedId);
40
40
  var color = avatarColor.index.toString();
41
41
  if (isSelection) {
42
42
  var className = "telepointer color-".concat(color, " telepointer-selection");
@@ -26,7 +26,7 @@ export type CollabEditPlugin = NextEditorPlugin<'collabEdit', {
26
26
  mark: Mark;
27
27
  pos: number;
28
28
  }) => boolean;
29
- getAvatarColor: (str: string, agentType?: string) => {
29
+ getAvatarColor: (str: string, agentName?: string, agentNamedId?: string) => {
30
30
  backgroundColor: string;
31
31
  index: number;
32
32
  textColor: string;
@@ -7,12 +7,12 @@ import type { Step } from '@atlaskit/editor-prosemirror/transform-override';
7
7
  import type { DecorationSet, EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
9
9
  export declare const findPointers: (id: string, decorations: DecorationSet) => Decoration[];
10
- export declare function getAvatarColor(str: string, agentType?: string): {
10
+ export declare function getAvatarColor(str: string, agentName?: string, agentNamedId?: string): {
11
11
  backgroundColor: string;
12
12
  index: number;
13
13
  textColor: string;
14
14
  };
15
- export declare const createTelepointers: (from: number, to: number, sessionId: string, isSelection: boolean, initial: string, presenceId: string, fullName: string, isNudged: boolean, agentType?: string) => Decoration[];
15
+ export declare const createTelepointers: (from: number, to: number, sessionId: string, isSelection: boolean, initial: string, presenceId: string, fullName: string, isNudged: boolean, agentName?: string, agentNamedId?: string) => Decoration[];
16
16
  export declare const replaceDocument: (doc: any, state: EditorState, version?: number, options?: CollabEditOptions, reserveCursor?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI) => Transaction;
17
17
  export declare const scrollToCollabCursor: (editorView: EditorView, participants: CollabParticipant[], sessionId: string | undefined, index: number, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => void;
18
18
  export declare const getPositionOfTelepointer: (sessionId: string, decorationSet: DecorationSet) => undefined | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "31.0.6",
3
+ "version": "32.0.0",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "@atlaskit/editor-plugin-editor-viewmode": "^32.0.0",
28
28
  "@atlaskit/editor-plugin-feature-flags": "^29.0.0",
29
29
  "@atlaskit/editor-prosemirror": "^9.0.0",
30
- "@atlaskit/editor-shared-styles": "^4.6.0",
30
+ "@atlaskit/editor-shared-styles": "^5.0.0",
31
31
  "@atlaskit/platform-feature-experiments": "^0.3.0",
32
32
  "@atlaskit/platform-feature-flags": "^2.2.0",
33
33
  "@atlaskit/prosemirror-collab": "^1.1.0",
@@ -37,7 +37,7 @@
37
37
  "memoize-one": "^6.0.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@atlaskit/editor-common": "^134.3.0",
40
+ "@atlaskit/editor-common": "^134.4.0",
41
41
  "react": "^18.2.0 || ^19.2.0",
42
42
  "react-dom": "^18.2.0 || ^19.2.0"
43
43
  },