@atlaskit/editor-shared-styles 4.3.12 → 4.3.13

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,14 @@
1
1
  # @atlaskit/editor-shared-styles
2
2
 
3
+ ## 4.3.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5ea393c04c702`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5ea393c04c702) -
8
+ [ux] Reserve red for deleted content: telepointers and collab avatars now skip the red participant
9
+ palette slots. Behind `confluence_ncs_step_diffing_version_history`.
10
+ - Updated dependencies
11
+
3
12
  ## 4.3.12
4
13
 
5
14
  ### Patch Changes
package/dist/cjs/utils.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getHashCode = getHashCode;
7
7
  exports.getParticipantColor = getParticipantColor;
8
8
  var _getAgentColor = require("@atlaskit/agent-color/get-agent-color");
9
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
9
10
  var _consts = require("./consts");
10
11
  /**
11
12
  * Agent types with a fixed participant colour instead of an identity-derived colour.
@@ -26,6 +27,20 @@ var AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX = {
26
27
  blue: 1
27
28
  };
28
29
 
30
+ /** The two red palette slots. Red reads as "deleted", so it never identifies a participant. */
31
+ var RESERVED_PARTICIPANT_COLOR_INDEXES = new Set([0, 11]);
32
+
33
+ /** Advances past a reserved slot, wrapping around the palette. */
34
+ var getAssignableIndex = function getAssignableIndex(index) {
35
+ for (var offset = 0; offset < _consts.participantColors.length; offset++) {
36
+ var candidate = (index + offset) % _consts.participantColors.length;
37
+ if (!RESERVED_PARTICIPANT_COLOR_INDEXES.has(candidate)) {
38
+ return candidate;
39
+ }
40
+ }
41
+ return index;
42
+ };
43
+
29
44
  /**
30
45
  * Generates a hash code for a given string.
31
46
  *
@@ -49,6 +64,9 @@ function getHashCode(str) {
49
64
  /**
50
65
  * Returns a fixed agent brand colour, an Agent Studio palette preference, or a hashed identity.
51
66
  *
67
+ * Under `confluence_ncs_step_diffing_version_history` the red slots are skipped. Fixed brand
68
+ * slots are exempt because none of them is red.
69
+ *
52
70
  * @param str - The input string used to determine the participant color.
53
71
  * @param agentType - Optional agent type supplied by agent-aware callers.
54
72
  * @returns The palette colour and index; `isFixed` prevents callers from reallocating brand colours.
@@ -66,7 +84,8 @@ function getParticipantColor(str, agentType) {
66
84
  var agentColor = agentType ? (0, _getAgentColor.getAgentColor)({
67
85
  agentId: str
68
86
  }) : undefined;
69
- var index = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % _consts.participantColors.length;
87
+ var preferredIndex = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % _consts.participantColors.length;
88
+ var index = (0, _fg.fg)('confluence_ncs_step_diffing_version_history') ? getAssignableIndex(preferredIndex) : preferredIndex;
70
89
  return {
71
90
  index: index,
72
91
  color: _consts.participantColors[index]
@@ -1,4 +1,5 @@
1
1
  import { getAgentColor } from '@atlaskit/agent-color/get-agent-color';
2
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
2
3
  import { participantColors } from './consts';
3
4
 
4
5
  /**
@@ -20,6 +21,20 @@ const AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX = {
20
21
  blue: 1
21
22
  };
22
23
 
24
+ /** The two red palette slots. Red reads as "deleted", so it never identifies a participant. */
25
+ const RESERVED_PARTICIPANT_COLOR_INDEXES = new Set([0, 11]);
26
+
27
+ /** Advances past a reserved slot, wrapping around the palette. */
28
+ const getAssignableIndex = index => {
29
+ for (let offset = 0; offset < participantColors.length; offset++) {
30
+ const candidate = (index + offset) % participantColors.length;
31
+ if (!RESERVED_PARTICIPANT_COLOR_INDEXES.has(candidate)) {
32
+ return candidate;
33
+ }
34
+ }
35
+ return index;
36
+ };
37
+
23
38
  /**
24
39
  * Generates a hash code for a given string.
25
40
  *
@@ -43,6 +58,9 @@ export function getHashCode(str) {
43
58
  /**
44
59
  * Returns a fixed agent brand colour, an Agent Studio palette preference, or a hashed identity.
45
60
  *
61
+ * Under `confluence_ncs_step_diffing_version_history` the red slots are skipped. Fixed brand
62
+ * slots are exempt because none of them is red.
63
+ *
46
64
  * @param str - The input string used to determine the participant color.
47
65
  * @param agentType - Optional agent type supplied by agent-aware callers.
48
66
  * @returns The palette colour and index; `isFixed` prevents callers from reallocating brand colours.
@@ -60,7 +78,8 @@ export function getParticipantColor(str, agentType) {
60
78
  const agentColor = agentType ? getAgentColor({
61
79
  agentId: str
62
80
  }) : undefined;
63
- const index = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % participantColors.length;
81
+ const preferredIndex = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % participantColors.length;
82
+ const index = fg('confluence_ncs_step_diffing_version_history') ? getAssignableIndex(preferredIndex) : preferredIndex;
64
83
  return {
65
84
  index,
66
85
  color: participantColors[index]
package/dist/esm/utils.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getAgentColor } from '@atlaskit/agent-color/get-agent-color';
2
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
2
3
  import { participantColors } from './consts';
3
4
 
4
5
  /**
@@ -20,6 +21,20 @@ var AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX = {
20
21
  blue: 1
21
22
  };
22
23
 
24
+ /** The two red palette slots. Red reads as "deleted", so it never identifies a participant. */
25
+ var RESERVED_PARTICIPANT_COLOR_INDEXES = new Set([0, 11]);
26
+
27
+ /** Advances past a reserved slot, wrapping around the palette. */
28
+ var getAssignableIndex = function getAssignableIndex(index) {
29
+ for (var offset = 0; offset < participantColors.length; offset++) {
30
+ var candidate = (index + offset) % participantColors.length;
31
+ if (!RESERVED_PARTICIPANT_COLOR_INDEXES.has(candidate)) {
32
+ return candidate;
33
+ }
34
+ }
35
+ return index;
36
+ };
37
+
23
38
  /**
24
39
  * Generates a hash code for a given string.
25
40
  *
@@ -43,6 +58,9 @@ export function getHashCode(str) {
43
58
  /**
44
59
  * Returns a fixed agent brand colour, an Agent Studio palette preference, or a hashed identity.
45
60
  *
61
+ * Under `confluence_ncs_step_diffing_version_history` the red slots are skipped. Fixed brand
62
+ * slots are exempt because none of them is red.
63
+ *
46
64
  * @param str - The input string used to determine the participant color.
47
65
  * @param agentType - Optional agent type supplied by agent-aware callers.
48
66
  * @returns The palette colour and index; `isFixed` prevents callers from reallocating brand colours.
@@ -60,7 +78,8 @@ export function getParticipantColor(str, agentType) {
60
78
  var agentColor = agentType ? getAgentColor({
61
79
  agentId: str
62
80
  }) : undefined;
63
- var index = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % participantColors.length;
81
+ var preferredIndex = agentColor ? AGENT_COLOR_TO_PARTICIPANT_COLOR_INDEX[agentColor] : getHashCode(str) % participantColors.length;
82
+ var index = fg('confluence_ncs_step_diffing_version_history') ? getAssignableIndex(preferredIndex) : preferredIndex;
64
83
  return {
65
84
  index: index,
66
85
  color: participantColors[index]
@@ -12,6 +12,9 @@ export declare function getHashCode(str: string): number;
12
12
  /**
13
13
  * Returns a fixed agent brand colour, an Agent Studio palette preference, or a hashed identity.
14
14
  *
15
+ * Under `confluence_ncs_step_diffing_version_history` the red slots are skipped. Fixed brand
16
+ * slots are exempt because none of them is red.
17
+ *
15
18
  * @param str - The input string used to determine the participant color.
16
19
  * @param agentType - Optional agent type supplied by agent-aware callers.
17
20
  * @returns The palette colour and index; `isFixed` prevents callers from reallocating brand colours.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-shared-styles",
3
- "version": "4.3.12",
3
+ "version": "4.3.13",
4
4
  "description": "Style values used in the editor/renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -20,16 +20,23 @@
20
20
  "team": "Editor: Lego"
21
21
  },
22
22
  "platform-feature-flags": {
23
+ "confluence_ncs_step_diffing_version_history": {
24
+ "type": "boolean",
25
+ "referenceOnly": true
26
+ },
23
27
  "platform_editor_ai_aifc_streaming": {
24
28
  "type": "boolean"
25
29
  }
26
30
  },
27
31
  "dependencies": {
28
- "@atlaskit/agent-color": "^0.1.0",
32
+ "@atlaskit/agent-color": "^0.2.0",
29
33
  "@atlaskit/platform-feature-flags": "^2.2.0",
30
34
  "@atlaskit/tmp-editor-statsig": "^199.0.0",
31
- "@atlaskit/tokens": "^18.0.0",
35
+ "@atlaskit/tokens": "^18.1.0",
32
36
  "@babel/runtime": "^7.0.0",
33
37
  "@emotion/react": "^11.7.1"
38
+ },
39
+ "devDependencies": {
40
+ "@atlassian/feature-flags-test-utils": "^1.3.0"
34
41
  }
35
42
  }