@atlaskit/editor-plugin-collab-edit 1.0.2 → 1.1.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 +12 -0
- package/dist/cjs/plugin.js +4 -2
- package/dist/cjs/pm-plugins/track-ncs-initialization.js +17 -5
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/pm-plugins/track-ncs-initialization.js +17 -5
- package/dist/esm/plugin.js +4 -2
- package/dist/esm/pm-plugins/track-ncs-initialization.js +17 -5
- package/dist/types/types.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-collab-edit
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#74185](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74185) [`bdf01577a3b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bdf01577a3b3) - Exclude remote changes from firstContentBodyChange field
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#72920](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72920) [`8fafb6fc0bc6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8fafb6fc0bc6) - Add extra field to collabTrackNCSInitializationPlugin which indicates if the document was changed excluding inline comments
|
|
14
|
+
|
|
3
15
|
## 1.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -89,7 +89,8 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
|
|
|
89
89
|
return {
|
|
90
90
|
initialised: {
|
|
91
91
|
collabInitialisedAt: null,
|
|
92
|
-
firstChangeAfterInitAt: null
|
|
92
|
+
firstChangeAfterInitAt: null,
|
|
93
|
+
firstContentBodyChangeAfterInitAt: null
|
|
93
94
|
},
|
|
94
95
|
activeParticipants: undefined,
|
|
95
96
|
sessionId: undefined
|
|
@@ -102,7 +103,8 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
|
|
|
102
103
|
sessionId: collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId,
|
|
103
104
|
initialised: {
|
|
104
105
|
collabInitialisedAt: (metadata === null || metadata === void 0 ? void 0 : metadata.collabInitialisedAt) || null,
|
|
105
|
-
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null
|
|
106
|
+
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null,
|
|
107
|
+
firstContentBodyChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstContentBodyChangeAfterInitAt) || null
|
|
106
108
|
}
|
|
107
109
|
};
|
|
108
110
|
},
|
|
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _collab = require("@atlaskit/editor-common/collab");
|
|
10
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
12
13
|
var trackNCSInitializationPluginKey = exports.trackNCSInitializationPluginKey = new _state.PluginKey('collabTrackNCSInitializationPlugin');
|
|
13
14
|
var createPlugin = exports.createPlugin = function createPlugin() {
|
|
14
15
|
return new _safePlugin.SafePlugin({
|
|
@@ -17,21 +18,24 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
17
18
|
init: function init() {
|
|
18
19
|
return {
|
|
19
20
|
collabInitialisedAt: null,
|
|
20
|
-
firstChangeAfterInitAt: null
|
|
21
|
+
firstChangeAfterInitAt: null,
|
|
22
|
+
firstContentBodyChangeAfterInitAt: null
|
|
21
23
|
};
|
|
22
24
|
},
|
|
23
25
|
apply: function apply(transaction, prevPluginState, oldState) {
|
|
24
26
|
if (Boolean(transaction.getMeta('collabInitialised'))) {
|
|
25
27
|
return {
|
|
26
28
|
collabInitialisedAt: Date.now(),
|
|
27
|
-
firstChangeAfterInitAt: null
|
|
29
|
+
firstChangeAfterInitAt: null,
|
|
30
|
+
firstContentBodyChangeAfterInitAt: null
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
|
-
var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.
|
|
33
|
+
var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
|
|
31
34
|
if (!shouldCheckDocument) {
|
|
32
35
|
return prevPluginState;
|
|
33
36
|
}
|
|
34
|
-
var
|
|
37
|
+
var isRemote = Boolean(transaction.getMeta('isRemote'));
|
|
38
|
+
var isDocumentReplaceFromRemote = isRemote && Boolean(transaction.getMeta('replaceDocument'));
|
|
35
39
|
if (isDocumentReplaceFromRemote) {
|
|
36
40
|
return prevPluginState;
|
|
37
41
|
}
|
|
@@ -39,9 +43,17 @@ var createPlugin = exports.createPlugin = function createPlugin() {
|
|
|
39
43
|
return prevPluginState;
|
|
40
44
|
}
|
|
41
45
|
if (transaction.docChanged && !transaction.doc.eq(oldState.doc)) {
|
|
46
|
+
// For analytics purposes, inline comment annotations are not considered as edits to the document body
|
|
47
|
+
// Transaction may contain other steps, but we know that they won't be user-generated (non synthetic) steps
|
|
48
|
+
// Additionally, for analytics purposes we do not want to trigger on other participants' changes (i.e. remote changes)
|
|
49
|
+
var isAnnotationStep = !!transaction.steps.find(function (step) {
|
|
50
|
+
var _step$mark;
|
|
51
|
+
return step instanceof _transform.AddMarkStep && ((_step$mark = step.mark) === null || _step$mark === void 0 || (_step$mark = _step$mark.type) === null || _step$mark === void 0 ? void 0 : _step$mark.name) === 'annotation';
|
|
52
|
+
});
|
|
42
53
|
return {
|
|
43
54
|
collabInitialisedAt: prevPluginState.collabInitialisedAt,
|
|
44
|
-
firstChangeAfterInitAt: Date.now()
|
|
55
|
+
firstChangeAfterInitAt: Date.now(),
|
|
56
|
+
firstContentBodyChangeAfterInitAt: isAnnotationStep || isRemote ? prevPluginState.firstContentBodyChangeAfterInitAt : Date.now()
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
59
|
return prevPluginState;
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -54,7 +54,8 @@ export const collabEditPlugin = ({
|
|
|
54
54
|
return {
|
|
55
55
|
initialised: {
|
|
56
56
|
collabInitialisedAt: null,
|
|
57
|
-
firstChangeAfterInitAt: null
|
|
57
|
+
firstChangeAfterInitAt: null,
|
|
58
|
+
firstContentBodyChangeAfterInitAt: null
|
|
58
59
|
},
|
|
59
60
|
activeParticipants: undefined,
|
|
60
61
|
sessionId: undefined
|
|
@@ -67,7 +68,8 @@ export const collabEditPlugin = ({
|
|
|
67
68
|
sessionId: collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId,
|
|
68
69
|
initialised: {
|
|
69
70
|
collabInitialisedAt: (metadata === null || metadata === void 0 ? void 0 : metadata.collabInitialisedAt) || null,
|
|
70
|
-
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null
|
|
71
|
+
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null,
|
|
72
|
+
firstContentBodyChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstContentBodyChangeAfterInitAt) || null
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
5
|
export const trackNCSInitializationPluginKey = new PluginKey('collabTrackNCSInitializationPlugin');
|
|
5
6
|
export const createPlugin = () => {
|
|
6
7
|
return new SafePlugin({
|
|
@@ -9,21 +10,24 @@ export const createPlugin = () => {
|
|
|
9
10
|
init() {
|
|
10
11
|
return {
|
|
11
12
|
collabInitialisedAt: null,
|
|
12
|
-
firstChangeAfterInitAt: null
|
|
13
|
+
firstChangeAfterInitAt: null,
|
|
14
|
+
firstContentBodyChangeAfterInitAt: null
|
|
13
15
|
};
|
|
14
16
|
},
|
|
15
17
|
apply(transaction, prevPluginState, oldState) {
|
|
16
18
|
if (Boolean(transaction.getMeta('collabInitialised'))) {
|
|
17
19
|
return {
|
|
18
20
|
collabInitialisedAt: Date.now(),
|
|
19
|
-
firstChangeAfterInitAt: null
|
|
21
|
+
firstChangeAfterInitAt: null,
|
|
22
|
+
firstContentBodyChangeAfterInitAt: null
|
|
20
23
|
};
|
|
21
24
|
}
|
|
22
|
-
const shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.
|
|
25
|
+
const shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
|
|
23
26
|
if (!shouldCheckDocument) {
|
|
24
27
|
return prevPluginState;
|
|
25
28
|
}
|
|
26
|
-
const
|
|
29
|
+
const isRemote = Boolean(transaction.getMeta('isRemote'));
|
|
30
|
+
const isDocumentReplaceFromRemote = isRemote && Boolean(transaction.getMeta('replaceDocument'));
|
|
27
31
|
if (isDocumentReplaceFromRemote) {
|
|
28
32
|
return prevPluginState;
|
|
29
33
|
}
|
|
@@ -31,9 +35,17 @@ export const createPlugin = () => {
|
|
|
31
35
|
return prevPluginState;
|
|
32
36
|
}
|
|
33
37
|
if (transaction.docChanged && !transaction.doc.eq(oldState.doc)) {
|
|
38
|
+
// For analytics purposes, inline comment annotations are not considered as edits to the document body
|
|
39
|
+
// Transaction may contain other steps, but we know that they won't be user-generated (non synthetic) steps
|
|
40
|
+
// Additionally, for analytics purposes we do not want to trigger on other participants' changes (i.e. remote changes)
|
|
41
|
+
const isAnnotationStep = !!transaction.steps.find(step => {
|
|
42
|
+
var _step$mark, _step$mark$type;
|
|
43
|
+
return step instanceof AddMarkStep && ((_step$mark = step.mark) === null || _step$mark === void 0 ? void 0 : (_step$mark$type = _step$mark.type) === null || _step$mark$type === void 0 ? void 0 : _step$mark$type.name) === 'annotation';
|
|
44
|
+
});
|
|
34
45
|
return {
|
|
35
46
|
collabInitialisedAt: prevPluginState.collabInitialisedAt,
|
|
36
|
-
firstChangeAfterInitAt: Date.now()
|
|
47
|
+
firstChangeAfterInitAt: Date.now(),
|
|
48
|
+
firstContentBodyChangeAfterInitAt: isAnnotationStep || isRemote ? prevPluginState.firstContentBodyChangeAfterInitAt : Date.now()
|
|
37
49
|
};
|
|
38
50
|
}
|
|
39
51
|
return prevPluginState;
|
package/dist/esm/plugin.js
CHANGED
|
@@ -82,7 +82,8 @@ export var collabEditPlugin = function collabEditPlugin(_ref3) {
|
|
|
82
82
|
return {
|
|
83
83
|
initialised: {
|
|
84
84
|
collabInitialisedAt: null,
|
|
85
|
-
firstChangeAfterInitAt: null
|
|
85
|
+
firstChangeAfterInitAt: null,
|
|
86
|
+
firstContentBodyChangeAfterInitAt: null
|
|
86
87
|
},
|
|
87
88
|
activeParticipants: undefined,
|
|
88
89
|
sessionId: undefined
|
|
@@ -95,7 +96,8 @@ export var collabEditPlugin = function collabEditPlugin(_ref3) {
|
|
|
95
96
|
sessionId: collabPluginState === null || collabPluginState === void 0 ? void 0 : collabPluginState.sessionId,
|
|
96
97
|
initialised: {
|
|
97
98
|
collabInitialisedAt: (metadata === null || metadata === void 0 ? void 0 : metadata.collabInitialisedAt) || null,
|
|
98
|
-
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null
|
|
99
|
+
firstChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstChangeAfterInitAt) || null,
|
|
100
|
+
firstContentBodyChangeAfterInitAt: (metadata === null || metadata === void 0 ? void 0 : metadata.firstContentBodyChangeAfterInitAt) || null
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
103
|
},
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { isDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
5
6
|
export var trackNCSInitializationPluginKey = new PluginKey('collabTrackNCSInitializationPlugin');
|
|
6
7
|
export var createPlugin = function createPlugin() {
|
|
7
8
|
return new SafePlugin({
|
|
@@ -10,21 +11,24 @@ export var createPlugin = function createPlugin() {
|
|
|
10
11
|
init: function init() {
|
|
11
12
|
return {
|
|
12
13
|
collabInitialisedAt: null,
|
|
13
|
-
firstChangeAfterInitAt: null
|
|
14
|
+
firstChangeAfterInitAt: null,
|
|
15
|
+
firstContentBodyChangeAfterInitAt: null
|
|
14
16
|
};
|
|
15
17
|
},
|
|
16
18
|
apply: function apply(transaction, prevPluginState, oldState) {
|
|
17
19
|
if (Boolean(transaction.getMeta('collabInitialised'))) {
|
|
18
20
|
return {
|
|
19
21
|
collabInitialisedAt: Date.now(),
|
|
20
|
-
firstChangeAfterInitAt: null
|
|
22
|
+
firstChangeAfterInitAt: null,
|
|
23
|
+
firstContentBodyChangeAfterInitAt: null
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
|
-
var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.
|
|
26
|
+
var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
|
|
24
27
|
if (!shouldCheckDocument) {
|
|
25
28
|
return prevPluginState;
|
|
26
29
|
}
|
|
27
|
-
var
|
|
30
|
+
var isRemote = Boolean(transaction.getMeta('isRemote'));
|
|
31
|
+
var isDocumentReplaceFromRemote = isRemote && Boolean(transaction.getMeta('replaceDocument'));
|
|
28
32
|
if (isDocumentReplaceFromRemote) {
|
|
29
33
|
return prevPluginState;
|
|
30
34
|
}
|
|
@@ -32,9 +36,17 @@ export var createPlugin = function createPlugin() {
|
|
|
32
36
|
return prevPluginState;
|
|
33
37
|
}
|
|
34
38
|
if (transaction.docChanged && !transaction.doc.eq(oldState.doc)) {
|
|
39
|
+
// For analytics purposes, inline comment annotations are not considered as edits to the document body
|
|
40
|
+
// Transaction may contain other steps, but we know that they won't be user-generated (non synthetic) steps
|
|
41
|
+
// Additionally, for analytics purposes we do not want to trigger on other participants' changes (i.e. remote changes)
|
|
42
|
+
var isAnnotationStep = !!transaction.steps.find(function (step) {
|
|
43
|
+
var _step$mark;
|
|
44
|
+
return step instanceof AddMarkStep && ((_step$mark = step.mark) === null || _step$mark === void 0 || (_step$mark = _step$mark.type) === null || _step$mark === void 0 ? void 0 : _step$mark.name) === 'annotation';
|
|
45
|
+
});
|
|
35
46
|
return {
|
|
36
47
|
collabInitialisedAt: prevPluginState.collabInitialisedAt,
|
|
37
|
-
firstChangeAfterInitAt: Date.now()
|
|
48
|
+
firstChangeAfterInitAt: Date.now(),
|
|
49
|
+
firstContentBodyChangeAfterInitAt: isAnnotationStep || isRemote ? prevPluginState.firstContentBodyChangeAfterInitAt : Date.now()
|
|
38
50
|
};
|
|
39
51
|
}
|
|
40
52
|
return prevPluginState;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface ReadOnlyParticipants {
|
|
|
18
18
|
export type CollabInitializedMetadata = {
|
|
19
19
|
collabInitialisedAt: null | number;
|
|
20
20
|
firstChangeAfterInitAt: null | number;
|
|
21
|
+
firstContentBodyChangeAfterInitAt: null | number;
|
|
21
22
|
};
|
|
22
23
|
export type CollabEditPluginSharedState = {
|
|
23
24
|
initialised: CollabInitializedMetadata;
|
|
@@ -18,6 +18,7 @@ export interface ReadOnlyParticipants {
|
|
|
18
18
|
export type CollabInitializedMetadata = {
|
|
19
19
|
collabInitialisedAt: null | number;
|
|
20
20
|
firstChangeAfterInitAt: null | number;
|
|
21
|
+
firstContentBodyChangeAfterInitAt: null | number;
|
|
21
22
|
};
|
|
22
23
|
export type CollabEditPluginSharedState = {
|
|
23
24
|
initialised: CollabInitializedMetadata;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-collab-edit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Collab Edit plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/editor-common": "^78.
|
|
35
|
+
"@atlaskit/editor-common": "^78.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "1.0.2",
|
|
37
37
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "3.0.0",
|