@atlaskit/mention 30.9.2 → 30.10.1
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 +24 -0
- package/disabled-state-change-notifier/package.json +10 -0
- package/dist/cjs/components/Mention/PrimitiveMention.js +2 -1
- package/dist/cjs/disabled-state-change-notifier.js +39 -0
- package/dist/cjs/mention-id-change-tracker.js +32 -0
- package/dist/cjs/mention-id-diff.js +60 -0
- package/dist/cjs/util/package-version.js +1 -1
- package/dist/es2019/components/Mention/PrimitiveMention.js +2 -1
- package/dist/es2019/disabled-state-change-notifier.js +19 -0
- package/dist/es2019/mention-id-change-tracker.js +15 -0
- package/dist/es2019/mention-id-diff.js +42 -0
- package/dist/es2019/util/package-version.js +1 -1
- package/dist/esm/components/Mention/PrimitiveMention.js +2 -1
- package/dist/esm/disabled-state-change-notifier.js +32 -0
- package/dist/esm/mention-id-change-tracker.js +26 -0
- package/dist/esm/mention-id-diff.js +54 -0
- package/dist/esm/util/package-version.js +1 -1
- package/dist/types/components/Mention/PrimitiveMention.d.ts +1 -1
- package/dist/types/disabled-state-change-notifier.d.ts +7 -0
- package/dist/types/mention-id-change-tracker.d.ts +8 -0
- package/dist/types/mention-id-diff.d.ts +11 -0
- package/mention-id-change-tracker/package.json +10 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/mention
|
|
2
2
|
|
|
3
|
+
## 30.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 30.10.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`af35384dea82b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/af35384dea82b) -
|
|
14
|
+
Use disabled mention colors for Rovo chips in the editor when
|
|
15
|
+
`platform_editor_mention_rovo_special_visual` is enabled.
|
|
16
|
+
|
|
17
|
+
Share disabled mention state change notifications between Confluence comments and Rovo Chat.
|
|
18
|
+
|
|
19
|
+
Share mention-ID snapshot comparison and tracking between Confluence comments and Rovo Chat
|
|
20
|
+
through the new `@atlaskit/mention/mention-id-change-tracker` utility. Each surface retains its
|
|
21
|
+
own selection rules.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 30.9.2
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/mention/disabled-state-change-notifier",
|
|
3
|
+
"main": "../dist/cjs/disabled-state-change-notifier.js",
|
|
4
|
+
"module": "../dist/esm/disabled-state-change-notifier.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/disabled-state-change-notifier.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/disabled-state-change-notifier.d.ts"
|
|
10
|
+
}
|
|
@@ -11,6 +11,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
11
11
|
var _react = require("react");
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
14
|
+
var _types = require("../../types");
|
|
14
15
|
var _mentionStyle = require("./mention-style");
|
|
15
16
|
var _templateObject;
|
|
16
17
|
var _excluded = ["isAvatarVisible", "isRovoChat", "mentionType"];
|
|
@@ -23,7 +24,7 @@ var _excluded = ["isAvatarVisible", "isRovoChat", "mentionType"];
|
|
|
23
24
|
var getStyle = function getStyle(_ref, property) {
|
|
24
25
|
var mentionType = _ref.mentionType,
|
|
25
26
|
isRovoChat = _ref.isRovoChat;
|
|
26
|
-
var isRovoChatEnabled = isRovoChat && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_rovo_special_visual');
|
|
27
|
+
var isRovoChatEnabled = mentionType !== _types.MentionType.DISABLED && isRovoChat && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_mention_rovo_special_visual');
|
|
27
28
|
if (isRovoChatEnabled) {
|
|
28
29
|
if (property === 'text') {
|
|
29
30
|
return "var(--ds-text-inverse, #FFFFFF)";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MentionDisabledStateChangeNotifier = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
/** Notifies mention chips when a provider's disabled-state inputs change. */
|
|
12
|
+
var MentionDisabledStateChangeNotifier = exports.MentionDisabledStateChangeNotifier = /*#__PURE__*/function () {
|
|
13
|
+
function MentionDisabledStateChangeNotifier() {
|
|
14
|
+
(0, _classCallCheck2.default)(this, MentionDisabledStateChangeNotifier);
|
|
15
|
+
(0, _defineProperty2.default)(this, "listeners", new Set());
|
|
16
|
+
}
|
|
17
|
+
return (0, _createClass2.default)(MentionDisabledStateChangeNotifier, [{
|
|
18
|
+
key: "subscribe",
|
|
19
|
+
value: function subscribe(listener) {
|
|
20
|
+
var _this = this;
|
|
21
|
+
this.listeners.add(listener);
|
|
22
|
+
return function () {
|
|
23
|
+
_this.listeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "notify",
|
|
28
|
+
value: function notify() {
|
|
29
|
+
this.listeners.forEach(function (listener) {
|
|
30
|
+
return listener();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "clear",
|
|
35
|
+
value: function clear() {
|
|
36
|
+
this.listeners.clear();
|
|
37
|
+
}
|
|
38
|
+
}]);
|
|
39
|
+
}();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.MentionIdChangeTracker = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _mentionIdDiff = require("./mention-id-diff");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
/** Remembers one editor draft's mention IDs between document snapshots. */
|
|
16
|
+
var MentionIdChangeTracker = exports.MentionIdChangeTracker = /*#__PURE__*/function () {
|
|
17
|
+
function MentionIdChangeTracker() {
|
|
18
|
+
(0, _classCallCheck2.default)(this, MentionIdChangeTracker);
|
|
19
|
+
}
|
|
20
|
+
return (0, _createClass2.default)(MentionIdChangeTracker, [{
|
|
21
|
+
key: "reconcile",
|
|
22
|
+
value: function reconcile(nextIds) {
|
|
23
|
+
var _this$previousIds;
|
|
24
|
+
var isInitial = this.previousIds === undefined;
|
|
25
|
+
var changes = (0, _mentionIdDiff.diffMentionIds)((_this$previousIds = this.previousIds) !== null && _this$previousIds !== void 0 ? _this$previousIds : [], nextIds);
|
|
26
|
+
this.previousIds = (0, _toConsumableArray2.default)(nextIds);
|
|
27
|
+
return _objectSpread({
|
|
28
|
+
isInitial: isInitial
|
|
29
|
+
}, changes);
|
|
30
|
+
}
|
|
31
|
+
}]);
|
|
32
|
+
}();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.diffMentionIds = void 0;
|
|
7
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
+
/** Changes in mention occurrences between two document snapshots, in document order. */
|
|
11
|
+
|
|
12
|
+
var countIds = function countIds(ids) {
|
|
13
|
+
var counts = new Map();
|
|
14
|
+
var _iterator = _createForOfIteratorHelper(ids),
|
|
15
|
+
_step;
|
|
16
|
+
try {
|
|
17
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
18
|
+
var _counts$get;
|
|
19
|
+
var id = _step.value;
|
|
20
|
+
counts.set(id, ((_counts$get = counts.get(id)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
_iterator.e(err);
|
|
24
|
+
} finally {
|
|
25
|
+
_iterator.f();
|
|
26
|
+
}
|
|
27
|
+
return counts;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Compare mention IDs from two document snapshots. Each occurrence counts: adding a
|
|
32
|
+
* second mention of the same ID is an addition, while moving one is not.
|
|
33
|
+
* Consumers decide what an added or removed occurrence means for selection.
|
|
34
|
+
*/
|
|
35
|
+
var diffMentionIds = exports.diffMentionIds = function diffMentionIds(previousIds, nextIds) {
|
|
36
|
+
var remainingPrevious = countIds(previousIds);
|
|
37
|
+
var remainingNext = countIds(nextIds);
|
|
38
|
+
var addedIds = nextIds.filter(function (id) {
|
|
39
|
+
var _remainingPrevious$ge;
|
|
40
|
+
var count = (_remainingPrevious$ge = remainingPrevious.get(id)) !== null && _remainingPrevious$ge !== void 0 ? _remainingPrevious$ge : 0;
|
|
41
|
+
if (count === 0) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
remainingPrevious.set(id, count - 1);
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
47
|
+
var removedIds = previousIds.filter(function (id) {
|
|
48
|
+
var _remainingNext$get;
|
|
49
|
+
var count = (_remainingNext$get = remainingNext.get(id)) !== null && _remainingNext$get !== void 0 ? _remainingNext$get : 0;
|
|
50
|
+
if (count === 0) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
remainingNext.set(id, count - 1);
|
|
54
|
+
return false;
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
addedIds: addedIds,
|
|
58
|
+
removedIds: removedIds
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -9,12 +9,13 @@ import { forwardRef } from 'react';
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import { jsx, css } from '@emotion/react';
|
|
11
11
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
12
|
+
import { MentionType } from '../../types';
|
|
12
13
|
import { mentionStyle } from './mention-style';
|
|
13
14
|
const getStyle = ({
|
|
14
15
|
mentionType,
|
|
15
16
|
isRovoChat
|
|
16
17
|
}, property) => {
|
|
17
|
-
const isRovoChatEnabled = isRovoChat && isExperimentEnabled('platform_editor_mention_rovo_special_visual');
|
|
18
|
+
const isRovoChatEnabled = mentionType !== MentionType.DISABLED && isRovoChat && isExperimentEnabled('platform_editor_mention_rovo_special_visual');
|
|
18
19
|
if (isRovoChatEnabled) {
|
|
19
20
|
if (property === 'text') {
|
|
20
21
|
return "var(--ds-text-inverse, #FFFFFF)";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
/** Notifies mention chips when a provider's disabled-state inputs change. */
|
|
3
|
+
export class MentionDisabledStateChangeNotifier {
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "listeners", new Set());
|
|
6
|
+
}
|
|
7
|
+
subscribe(listener) {
|
|
8
|
+
this.listeners.add(listener);
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(listener);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
notify() {
|
|
14
|
+
this.listeners.forEach(listener => listener());
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.listeners.clear();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { diffMentionIds } from './mention-id-diff';
|
|
2
|
+
|
|
3
|
+
/** Remembers one editor draft's mention IDs between document snapshots. */
|
|
4
|
+
export class MentionIdChangeTracker {
|
|
5
|
+
reconcile(nextIds) {
|
|
6
|
+
var _this$previousIds;
|
|
7
|
+
const isInitial = this.previousIds === undefined;
|
|
8
|
+
const changes = diffMentionIds((_this$previousIds = this.previousIds) !== null && _this$previousIds !== void 0 ? _this$previousIds : [], nextIds);
|
|
9
|
+
this.previousIds = [...nextIds];
|
|
10
|
+
return {
|
|
11
|
+
isInitial,
|
|
12
|
+
...changes
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Changes in mention occurrences between two document snapshots, in document order. */
|
|
2
|
+
|
|
3
|
+
const countIds = ids => {
|
|
4
|
+
const counts = new Map();
|
|
5
|
+
for (const id of ids) {
|
|
6
|
+
var _counts$get;
|
|
7
|
+
counts.set(id, ((_counts$get = counts.get(id)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);
|
|
8
|
+
}
|
|
9
|
+
return counts;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Compare mention IDs from two document snapshots. Each occurrence counts: adding a
|
|
14
|
+
* second mention of the same ID is an addition, while moving one is not.
|
|
15
|
+
* Consumers decide what an added or removed occurrence means for selection.
|
|
16
|
+
*/
|
|
17
|
+
export const diffMentionIds = (previousIds, nextIds) => {
|
|
18
|
+
const remainingPrevious = countIds(previousIds);
|
|
19
|
+
const remainingNext = countIds(nextIds);
|
|
20
|
+
const addedIds = nextIds.filter(id => {
|
|
21
|
+
var _remainingPrevious$ge;
|
|
22
|
+
const count = (_remainingPrevious$ge = remainingPrevious.get(id)) !== null && _remainingPrevious$ge !== void 0 ? _remainingPrevious$ge : 0;
|
|
23
|
+
if (count === 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
remainingPrevious.set(id, count - 1);
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
const removedIds = previousIds.filter(id => {
|
|
30
|
+
var _remainingNext$get;
|
|
31
|
+
const count = (_remainingNext$get = remainingNext.get(id)) !== null && _remainingNext$get !== void 0 ? _remainingNext$get : 0;
|
|
32
|
+
if (count === 0) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
remainingNext.set(id, count - 1);
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
addedIds,
|
|
40
|
+
removedIds
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageVersion = "30.
|
|
1
|
+
export const packageVersion = "30.10.0";
|
|
@@ -13,11 +13,12 @@ import { forwardRef } from 'react';
|
|
|
13
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
14
14
|
import { jsx, css } from '@emotion/react';
|
|
15
15
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
16
|
+
import { MentionType } from '../../types';
|
|
16
17
|
import { mentionStyle } from './mention-style';
|
|
17
18
|
var getStyle = function getStyle(_ref, property) {
|
|
18
19
|
var mentionType = _ref.mentionType,
|
|
19
20
|
isRovoChat = _ref.isRovoChat;
|
|
20
|
-
var isRovoChatEnabled = isRovoChat && isExperimentEnabled('platform_editor_mention_rovo_special_visual');
|
|
21
|
+
var isRovoChatEnabled = mentionType !== MentionType.DISABLED && isRovoChat && isExperimentEnabled('platform_editor_mention_rovo_special_visual');
|
|
21
22
|
if (isRovoChatEnabled) {
|
|
22
23
|
if (property === 'text') {
|
|
23
24
|
return "var(--ds-text-inverse, #FFFFFF)";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
/** Notifies mention chips when a provider's disabled-state inputs change. */
|
|
5
|
+
export var MentionDisabledStateChangeNotifier = /*#__PURE__*/function () {
|
|
6
|
+
function MentionDisabledStateChangeNotifier() {
|
|
7
|
+
_classCallCheck(this, MentionDisabledStateChangeNotifier);
|
|
8
|
+
_defineProperty(this, "listeners", new Set());
|
|
9
|
+
}
|
|
10
|
+
return _createClass(MentionDisabledStateChangeNotifier, [{
|
|
11
|
+
key: "subscribe",
|
|
12
|
+
value: function subscribe(listener) {
|
|
13
|
+
var _this = this;
|
|
14
|
+
this.listeners.add(listener);
|
|
15
|
+
return function () {
|
|
16
|
+
_this.listeners.delete(listener);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
key: "notify",
|
|
21
|
+
value: function notify() {
|
|
22
|
+
this.listeners.forEach(function (listener) {
|
|
23
|
+
return listener();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "clear",
|
|
28
|
+
value: function clear() {
|
|
29
|
+
this.listeners.clear();
|
|
30
|
+
}
|
|
31
|
+
}]);
|
|
32
|
+
}();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { diffMentionIds } from './mention-id-diff';
|
|
8
|
+
|
|
9
|
+
/** Remembers one editor draft's mention IDs between document snapshots. */
|
|
10
|
+
export var MentionIdChangeTracker = /*#__PURE__*/function () {
|
|
11
|
+
function MentionIdChangeTracker() {
|
|
12
|
+
_classCallCheck(this, MentionIdChangeTracker);
|
|
13
|
+
}
|
|
14
|
+
return _createClass(MentionIdChangeTracker, [{
|
|
15
|
+
key: "reconcile",
|
|
16
|
+
value: function reconcile(nextIds) {
|
|
17
|
+
var _this$previousIds;
|
|
18
|
+
var isInitial = this.previousIds === undefined;
|
|
19
|
+
var changes = diffMentionIds((_this$previousIds = this.previousIds) !== null && _this$previousIds !== void 0 ? _this$previousIds : [], nextIds);
|
|
20
|
+
this.previousIds = _toConsumableArray(nextIds);
|
|
21
|
+
return _objectSpread({
|
|
22
|
+
isInitial: isInitial
|
|
23
|
+
}, changes);
|
|
24
|
+
}
|
|
25
|
+
}]);
|
|
26
|
+
}();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
/** Changes in mention occurrences between two document snapshots, in document order. */
|
|
5
|
+
|
|
6
|
+
var countIds = function countIds(ids) {
|
|
7
|
+
var counts = new Map();
|
|
8
|
+
var _iterator = _createForOfIteratorHelper(ids),
|
|
9
|
+
_step;
|
|
10
|
+
try {
|
|
11
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
12
|
+
var _counts$get;
|
|
13
|
+
var id = _step.value;
|
|
14
|
+
counts.set(id, ((_counts$get = counts.get(id)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);
|
|
15
|
+
}
|
|
16
|
+
} catch (err) {
|
|
17
|
+
_iterator.e(err);
|
|
18
|
+
} finally {
|
|
19
|
+
_iterator.f();
|
|
20
|
+
}
|
|
21
|
+
return counts;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Compare mention IDs from two document snapshots. Each occurrence counts: adding a
|
|
26
|
+
* second mention of the same ID is an addition, while moving one is not.
|
|
27
|
+
* Consumers decide what an added or removed occurrence means for selection.
|
|
28
|
+
*/
|
|
29
|
+
export var diffMentionIds = function diffMentionIds(previousIds, nextIds) {
|
|
30
|
+
var remainingPrevious = countIds(previousIds);
|
|
31
|
+
var remainingNext = countIds(nextIds);
|
|
32
|
+
var addedIds = nextIds.filter(function (id) {
|
|
33
|
+
var _remainingPrevious$ge;
|
|
34
|
+
var count = (_remainingPrevious$ge = remainingPrevious.get(id)) !== null && _remainingPrevious$ge !== void 0 ? _remainingPrevious$ge : 0;
|
|
35
|
+
if (count === 0) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
remainingPrevious.set(id, count - 1);
|
|
39
|
+
return false;
|
|
40
|
+
});
|
|
41
|
+
var removedIds = previousIds.filter(function (id) {
|
|
42
|
+
var _remainingNext$get;
|
|
43
|
+
var count = (_remainingNext$get = remainingNext.get(id)) !== null && _remainingNext$get !== void 0 ? _remainingNext$get : 0;
|
|
44
|
+
if (count === 0) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
remainingNext.set(id, count - 1);
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
addedIds: addedIds,
|
|
52
|
+
removedIds: removedIds
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var packageVersion = "30.
|
|
1
|
+
export var packageVersion = "30.10.0";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type ForwardRefExoticComponent, type HTMLAttributes, type RefAttributes } from 'react';
|
|
6
|
-
import
|
|
6
|
+
import { MentionType } from '../../types';
|
|
7
7
|
export interface PrimitiveMentionProps extends HTMLAttributes<HTMLSpanElement> {
|
|
8
8
|
isAvatarVisible?: boolean;
|
|
9
9
|
isRovoChat?: boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MentionIdDiff } from './mention-id-diff';
|
|
2
|
+
/** Remembers one editor draft's mention IDs between document snapshots. */
|
|
3
|
+
export declare class MentionIdChangeTracker {
|
|
4
|
+
private previousIds;
|
|
5
|
+
reconcile(nextIds: readonly string[]): MentionIdDiff & {
|
|
6
|
+
isInitial: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Changes in mention occurrences between two document snapshots, in document order. */
|
|
2
|
+
export type MentionIdDiff = {
|
|
3
|
+
addedIds: string[];
|
|
4
|
+
removedIds: string[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Compare mention IDs from two document snapshots. Each occurrence counts: adding a
|
|
8
|
+
* second mention of the same ID is an addition, while moving one is not.
|
|
9
|
+
* Consumers decide what an added or removed occurrence means for selection.
|
|
10
|
+
*/
|
|
11
|
+
export declare const diffMentionIds: (previousIds: readonly string[], nextIds: readonly string[]) => MentionIdDiff;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/mention/mention-id-change-tracker",
|
|
3
|
+
"main": "../dist/cjs/mention-id-change-tracker.js",
|
|
4
|
+
"module": "../dist/esm/mention-id-change-tracker.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/mention-id-change-tracker.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/mention-id-change-tracker.d.ts"
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/css": "^1.1.0",
|
|
37
37
|
"@atlaskit/focus-ring": "^6.0.0",
|
|
38
38
|
"@atlaskit/heading": "^8.0.0",
|
|
39
|
-
"@atlaskit/icon": "^38.
|
|
39
|
+
"@atlaskit/icon": "^38.1.0",
|
|
40
40
|
"@atlaskit/lozenge": "^17.0.0",
|
|
41
41
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@atlaskit/skeleton": "^4.4.0",
|
|
46
46
|
"@atlaskit/tag": "^17.1.0",
|
|
47
47
|
"@atlaskit/teams-avatar": "^4.2.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
49
|
-
"@atlaskit/tokens": "^20.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^264.0.0",
|
|
49
|
+
"@atlaskit/tokens": "^20.12.0",
|
|
50
50
|
"@atlaskit/tooltip": "^24.4.0",
|
|
51
51
|
"@atlaskit/ufo": "^2.0.0",
|
|
52
52
|
"@atlaskit/user-picker": "^14.8.0",
|
|
@@ -134,5 +134,5 @@
|
|
|
134
134
|
"*.compiled.css"
|
|
135
135
|
],
|
|
136
136
|
"types": "dist/types/index.d.ts",
|
|
137
|
-
"version": "30.
|
|
137
|
+
"version": "30.10.1"
|
|
138
138
|
}
|