@atlaskit/editor-plugin-collab-edit 1.0.2 → 1.1.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,11 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  ### Patch Changes
@@ -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,17 +18,19 @@ 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.firstChangeAfterInitAt;
33
+ var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
31
34
  if (!shouldCheckDocument) {
32
35
  return prevPluginState;
33
36
  }
@@ -39,9 +42,16 @@ var createPlugin = exports.createPlugin = function createPlugin() {
39
42
  return prevPluginState;
40
43
  }
41
44
  if (transaction.docChanged && !transaction.doc.eq(oldState.doc)) {
45
+ // For analytics purposes, inline comment annotations are not considered as edits to the document body
46
+ // Transaction may contain other steps, but we know that they won't be user-generated (non synthetic) steps
47
+ var isAnnotationStep = !!transaction.steps.find(function (step) {
48
+ var _step$mark;
49
+ 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';
50
+ });
42
51
  return {
43
52
  collabInitialisedAt: prevPluginState.collabInitialisedAt,
44
- firstChangeAfterInitAt: Date.now()
53
+ firstChangeAfterInitAt: Date.now(),
54
+ firstContentBodyChangeAfterInitAt: !isAnnotationStep ? Date.now() : prevPluginState.firstContentBodyChangeAfterInitAt
45
55
  };
46
56
  }
47
57
  return prevPluginState;
@@ -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,17 +10,19 @@ 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.firstChangeAfterInitAt;
25
+ const shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
23
26
  if (!shouldCheckDocument) {
24
27
  return prevPluginState;
25
28
  }
@@ -31,9 +34,16 @@ export const createPlugin = () => {
31
34
  return prevPluginState;
32
35
  }
33
36
  if (transaction.docChanged && !transaction.doc.eq(oldState.doc)) {
37
+ // For analytics purposes, inline comment annotations are not considered as edits to the document body
38
+ // Transaction may contain other steps, but we know that they won't be user-generated (non synthetic) steps
39
+ const isAnnotationStep = !!transaction.steps.find(step => {
40
+ var _step$mark, _step$mark$type;
41
+ 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';
42
+ });
34
43
  return {
35
44
  collabInitialisedAt: prevPluginState.collabInitialisedAt,
36
- firstChangeAfterInitAt: Date.now()
45
+ firstChangeAfterInitAt: Date.now(),
46
+ firstContentBodyChangeAfterInitAt: !isAnnotationStep ? Date.now() : prevPluginState.firstContentBodyChangeAfterInitAt
37
47
  };
38
48
  }
39
49
  return prevPluginState;
@@ -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,17 +11,19 @@ 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.firstChangeAfterInitAt;
26
+ var shouldCheckDocument = prevPluginState.collabInitialisedAt && !prevPluginState.firstContentBodyChangeAfterInitAt;
24
27
  if (!shouldCheckDocument) {
25
28
  return prevPluginState;
26
29
  }
@@ -32,9 +35,16 @@ export var createPlugin = function createPlugin() {
32
35
  return prevPluginState;
33
36
  }
34
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
+ var isAnnotationStep = !!transaction.steps.find(function (step) {
41
+ var _step$mark;
42
+ 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';
43
+ });
35
44
  return {
36
45
  collabInitialisedAt: prevPluginState.collabInitialisedAt,
37
- firstChangeAfterInitAt: Date.now()
46
+ firstChangeAfterInitAt: Date.now(),
47
+ firstContentBodyChangeAfterInitAt: !isAnnotationStep ? Date.now() : prevPluginState.firstContentBodyChangeAfterInitAt
38
48
  };
39
49
  }
40
50
  return prevPluginState;
@@ -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.0.2",
3
+ "version": "1.1.0",
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.0.0",
35
+ "@atlaskit/editor-common": "^78.1.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",