@atlaskit/editor-plugin-mentions 8.0.3 → 8.2.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 +22 -0
- package/dist/cjs/pm-plugins/main.js +59 -2
- package/dist/es2019/pm-plugins/main.js +57 -2
- package/dist/esm/pm-plugins/main.js +59 -2
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 8.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
|
|
8
|
+
[EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 8.1.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`03153a278b044`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/03153a278b044) -
|
|
19
|
+
Add new mentions detection logic
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 8.0.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -10,9 +10,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
+
var _insm = require("@atlaskit/insm");
|
|
13
14
|
var _resource = require("@atlaskit/mention/resource");
|
|
14
15
|
var _types = require("@atlaskit/mention/types");
|
|
15
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
18
|
var _mentionNodeView = require("../nodeviews/mentionNodeView");
|
|
17
19
|
var _types2 = require("../types");
|
|
18
20
|
var _key = require("./key");
|
|
@@ -23,7 +25,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
23
25
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
24
26
|
};
|
|
25
27
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
26
|
-
var PACKAGE_VERSION = "
|
|
28
|
+
var PACKAGE_VERSION = "8.1.0";
|
|
27
29
|
var setProvider = function setProvider(provider) {
|
|
28
30
|
return function (state, dispatch) {
|
|
29
31
|
if (dispatch) {
|
|
@@ -93,6 +95,61 @@ function createMentionPlugin(_ref) {
|
|
|
93
95
|
if (hasNewPluginState) {
|
|
94
96
|
pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
|
|
95
97
|
}
|
|
98
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
99
|
+
var _insm$session, _insm$session2;
|
|
100
|
+
(_insm$session = _insm.insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('mentionDeletionDetection');
|
|
101
|
+
var mentionSchema = newState.schema.nodes.mention;
|
|
102
|
+
var mentionsRemoved = new Map();
|
|
103
|
+
tr.steps.forEach(function (step) {
|
|
104
|
+
step.getMap().forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
105
|
+
var oldSlice = oldState.doc.slice(oldStart, oldEnd);
|
|
106
|
+
var newSlice = newState.doc.slice(newStart, newEnd);
|
|
107
|
+
var mentionsBefore = new Map();
|
|
108
|
+
var mentionsAfter = new Map();
|
|
109
|
+
oldSlice.content.descendants(function (node) {
|
|
110
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
111
|
+
mentionsBefore.set(node.attrs.localId, {
|
|
112
|
+
id: node.attrs.id,
|
|
113
|
+
localId: node.attrs.localId
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
newSlice.content.descendants(function (node) {
|
|
118
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
119
|
+
mentionsAfter.set(node.attrs.localId, {
|
|
120
|
+
id: node.attrs.id,
|
|
121
|
+
localId: node.attrs.localId
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Determine which mentions were removed in this step
|
|
127
|
+
mentionsBefore.forEach(function (mention, localId) {
|
|
128
|
+
if (!mentionsAfter.has(localId)) {
|
|
129
|
+
mentionsRemoved.set(localId, mention);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Adjust mentionsRemoved by removing any that reappear
|
|
134
|
+
mentionsAfter.forEach(function (_, localId) {
|
|
135
|
+
if (mentionsRemoved.has(localId)) {
|
|
136
|
+
mentionsRemoved.delete(localId);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
if (mentionsRemoved.size > 0) {
|
|
142
|
+
var changes = Array.from(mentionsRemoved.values()).map(function (mention) {
|
|
143
|
+
return {
|
|
144
|
+
id: mention.id,
|
|
145
|
+
localId: mention.localId,
|
|
146
|
+
type: 'deleted'
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
options.handleMentionsChanged(changes);
|
|
150
|
+
}
|
|
151
|
+
(_insm$session2 = _insm.insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
|
|
152
|
+
}
|
|
96
153
|
return newPluginState;
|
|
97
154
|
}
|
|
98
155
|
},
|
|
@@ -163,7 +220,7 @@ function createMentionPlugin(_ref) {
|
|
|
163
220
|
},
|
|
164
221
|
update: function update(view, prevState) {
|
|
165
222
|
var newState = view.state;
|
|
166
|
-
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
223
|
+
if (!(0, _expValEquals.expValEquals)('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
167
224
|
var mentionSchema = newState.schema.nodes.mention;
|
|
168
225
|
var mentionNodesBefore = (0, _utils.findChildrenByType)(prevState.doc, mentionSchema);
|
|
169
226
|
var mentionLocalIdsAfter = new Set((0, _utils.findChildrenByType)(newState.doc, mentionSchema).map(function (_ref3) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { insm } from '@atlaskit/insm';
|
|
4
5
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
|
|
5
6
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
6
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
9
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
8
10
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
9
11
|
import { mentionPluginKey } from './key';
|
|
@@ -12,7 +14,7 @@ export const ACTIONS = {
|
|
|
12
14
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
13
15
|
};
|
|
14
16
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
15
|
-
const PACKAGE_VERSION = "
|
|
17
|
+
const PACKAGE_VERSION = "8.1.0";
|
|
16
18
|
const setProvider = provider => (state, dispatch) => {
|
|
17
19
|
if (dispatch) {
|
|
18
20
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -85,6 +87,59 @@ export function createMentionPlugin({
|
|
|
85
87
|
if (hasNewPluginState) {
|
|
86
88
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
87
89
|
}
|
|
90
|
+
if (expValEquals('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
91
|
+
var _insm$session, _insm$session2;
|
|
92
|
+
(_insm$session = insm.session) === null || _insm$session === void 0 ? void 0 : _insm$session.startFeature('mentionDeletionDetection');
|
|
93
|
+
const mentionSchema = newState.schema.nodes.mention;
|
|
94
|
+
const mentionsRemoved = new Map();
|
|
95
|
+
tr.steps.forEach(step => {
|
|
96
|
+
step.getMap().forEach((oldStart, oldEnd, newStart, newEnd) => {
|
|
97
|
+
const oldSlice = oldState.doc.slice(oldStart, oldEnd);
|
|
98
|
+
const newSlice = newState.doc.slice(newStart, newEnd);
|
|
99
|
+
const mentionsBefore = new Map();
|
|
100
|
+
const mentionsAfter = new Map();
|
|
101
|
+
oldSlice.content.descendants(node => {
|
|
102
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
103
|
+
mentionsBefore.set(node.attrs.localId, {
|
|
104
|
+
id: node.attrs.id,
|
|
105
|
+
localId: node.attrs.localId
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
newSlice.content.descendants(node => {
|
|
110
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
111
|
+
mentionsAfter.set(node.attrs.localId, {
|
|
112
|
+
id: node.attrs.id,
|
|
113
|
+
localId: node.attrs.localId
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Determine which mentions were removed in this step
|
|
119
|
+
mentionsBefore.forEach((mention, localId) => {
|
|
120
|
+
if (!mentionsAfter.has(localId)) {
|
|
121
|
+
mentionsRemoved.set(localId, mention);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Adjust mentionsRemoved by removing any that reappear
|
|
126
|
+
mentionsAfter.forEach((_, localId) => {
|
|
127
|
+
if (mentionsRemoved.has(localId)) {
|
|
128
|
+
mentionsRemoved.delete(localId);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
if (mentionsRemoved.size > 0) {
|
|
134
|
+
const changes = Array.from(mentionsRemoved.values()).map(mention => ({
|
|
135
|
+
id: mention.id,
|
|
136
|
+
localId: mention.localId,
|
|
137
|
+
type: 'deleted'
|
|
138
|
+
}));
|
|
139
|
+
options.handleMentionsChanged(changes);
|
|
140
|
+
}
|
|
141
|
+
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 ? void 0 : _insm$session2.endFeature('mentionDeletionDetection');
|
|
142
|
+
}
|
|
88
143
|
return newPluginState;
|
|
89
144
|
}
|
|
90
145
|
},
|
|
@@ -155,7 +210,7 @@ export function createMentionPlugin({
|
|
|
155
210
|
},
|
|
156
211
|
update(view, prevState) {
|
|
157
212
|
const newState = view.state;
|
|
158
|
-
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
213
|
+
if (!expValEquals('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
159
214
|
const mentionSchema = newState.schema.nodes.mention;
|
|
160
215
|
const mentionNodesBefore = findChildrenByType(prevState.doc, mentionSchema);
|
|
161
216
|
const mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(({
|
|
@@ -4,9 +4,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import { findChildrenByType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { insm } from '@atlaskit/insm';
|
|
7
8
|
import { SLI_EVENT_TYPE, SMART_EVENT_TYPE } from '@atlaskit/mention/resource';
|
|
8
9
|
import { ComponentNames } from '@atlaskit/mention/types';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
12
|
import { MentionNodeView } from '../nodeviews/mentionNodeView';
|
|
11
13
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
12
14
|
import { mentionPluginKey } from './key';
|
|
@@ -15,7 +17,7 @@ export var ACTIONS = {
|
|
|
15
17
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
16
18
|
};
|
|
17
19
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
18
|
-
var PACKAGE_VERSION = "
|
|
20
|
+
var PACKAGE_VERSION = "8.1.0";
|
|
19
21
|
var setProvider = function setProvider(provider) {
|
|
20
22
|
return function (state, dispatch) {
|
|
21
23
|
if (dispatch) {
|
|
@@ -85,6 +87,61 @@ export function createMentionPlugin(_ref) {
|
|
|
85
87
|
if (hasNewPluginState) {
|
|
86
88
|
pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
|
|
87
89
|
}
|
|
90
|
+
if (expValEquals('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged && tr.docChanged) {
|
|
91
|
+
var _insm$session, _insm$session2;
|
|
92
|
+
(_insm$session = insm.session) === null || _insm$session === void 0 || _insm$session.startFeature('mentionDeletionDetection');
|
|
93
|
+
var mentionSchema = newState.schema.nodes.mention;
|
|
94
|
+
var mentionsRemoved = new Map();
|
|
95
|
+
tr.steps.forEach(function (step) {
|
|
96
|
+
step.getMap().forEach(function (oldStart, oldEnd, newStart, newEnd) {
|
|
97
|
+
var oldSlice = oldState.doc.slice(oldStart, oldEnd);
|
|
98
|
+
var newSlice = newState.doc.slice(newStart, newEnd);
|
|
99
|
+
var mentionsBefore = new Map();
|
|
100
|
+
var mentionsAfter = new Map();
|
|
101
|
+
oldSlice.content.descendants(function (node) {
|
|
102
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
103
|
+
mentionsBefore.set(node.attrs.localId, {
|
|
104
|
+
id: node.attrs.id,
|
|
105
|
+
localId: node.attrs.localId
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
newSlice.content.descendants(function (node) {
|
|
110
|
+
if (node.type.name === mentionSchema.name && node.attrs.localId) {
|
|
111
|
+
mentionsAfter.set(node.attrs.localId, {
|
|
112
|
+
id: node.attrs.id,
|
|
113
|
+
localId: node.attrs.localId
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Determine which mentions were removed in this step
|
|
119
|
+
mentionsBefore.forEach(function (mention, localId) {
|
|
120
|
+
if (!mentionsAfter.has(localId)) {
|
|
121
|
+
mentionsRemoved.set(localId, mention);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Adjust mentionsRemoved by removing any that reappear
|
|
126
|
+
mentionsAfter.forEach(function (_, localId) {
|
|
127
|
+
if (mentionsRemoved.has(localId)) {
|
|
128
|
+
mentionsRemoved.delete(localId);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
if (mentionsRemoved.size > 0) {
|
|
134
|
+
var changes = Array.from(mentionsRemoved.values()).map(function (mention) {
|
|
135
|
+
return {
|
|
136
|
+
id: mention.id,
|
|
137
|
+
localId: mention.localId,
|
|
138
|
+
type: 'deleted'
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
options.handleMentionsChanged(changes);
|
|
142
|
+
}
|
|
143
|
+
(_insm$session2 = insm.session) === null || _insm$session2 === void 0 || _insm$session2.endFeature('mentionDeletionDetection');
|
|
144
|
+
}
|
|
88
145
|
return newPluginState;
|
|
89
146
|
}
|
|
90
147
|
},
|
|
@@ -155,7 +212,7 @@ export function createMentionPlugin(_ref) {
|
|
|
155
212
|
},
|
|
156
213
|
update: function update(view, prevState) {
|
|
157
214
|
var newState = view.state;
|
|
158
|
-
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
215
|
+
if (!expValEquals('platform_editor_new_mentions_detection_logic', 'isEnabled', true) && options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
159
216
|
var mentionSchema = newState.schema.nodes.mention;
|
|
160
217
|
var mentionNodesBefore = findChildrenByType(prevState.doc, mentionSchema);
|
|
161
218
|
var mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(function (_ref3) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,15 +29,16 @@
|
|
|
29
29
|
],
|
|
30
30
|
"atlaskit:src": "src/index.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/adf-schema": "^51.
|
|
32
|
+
"@atlaskit/adf-schema": "^51.3.0",
|
|
33
33
|
"@atlaskit/css": "^0.15.0",
|
|
34
|
-
"@atlaskit/editor-plugin-analytics": "^6.
|
|
35
|
-
"@atlaskit/editor-plugin-base": "^7.
|
|
34
|
+
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
35
|
+
"@atlaskit/editor-plugin-base": "^7.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-context-identifier": "^6.0.0",
|
|
37
37
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
38
|
-
"@atlaskit/editor-plugin-type-ahead": "^6.
|
|
38
|
+
"@atlaskit/editor-plugin-type-ahead": "^6.5.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/icon": "^28.5.0",
|
|
41
|
+
"@atlaskit/insm": "^0.1.0",
|
|
41
42
|
"@atlaskit/link": "^3.2.0",
|
|
42
43
|
"@atlaskit/mention": "^24.3.0",
|
|
43
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"uuid": "^3.1.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"@atlaskit/editor-common": "^110.
|
|
58
|
+
"@atlaskit/editor-common": "^110.14.0",
|
|
58
59
|
"react": "^18.2.0",
|
|
59
60
|
"react-dom": "^18.2.0",
|
|
60
61
|
"react-intl-next": "npm:react-intl@^5.18.1"
|