@atlaskit/editor-plugin-collab-edit 3.2.4 → 3.3.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,20 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#136936](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/136936)
8
+ [`505147cb14bae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/505147cb14bae) -
9
+ [ux] [ED-27431] Do not transmit telecursor position on initial load of non-empty live pages when
10
+ hideTelecursorOnLoad is set.
11
+
12
+ ## 3.2.5
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 3.2.4
4
19
 
5
20
  ### Patch Changes
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
+ var _utils = require("@atlaskit/editor-common/utils");
13
14
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
14
15
  var _transform = require("@atlaskit/editor-prosemirror/transform");
15
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
@@ -25,7 +26,7 @@ var _trackLastOrganicChange = require("./pm-plugins/track-last-organic-change");
25
26
  var _trackNcsInitialization = require("./pm-plugins/track-ncs-initialization");
26
27
  var _trackReconnectionConflict = require("./pm-plugins/track-reconnection-conflict");
27
28
  var _trackSteps = require("./pm-plugins/track-steps");
28
- var _utils = require("./pm-plugins/utils");
29
+ var _utils2 = require("./pm-plugins/utils");
29
30
  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; }
30
31
  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; }
31
32
  var providerBuilder = function providerBuilder(collabEditProviderPromise) {
@@ -149,7 +150,7 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
149
150
  };
150
151
  },
151
152
  actions: {
152
- getAvatarColor: _utils.getAvatarColor,
153
+ getAvatarColor: _utils2.getAvatarColor,
153
154
  addInlineCommentMark: createAddInlineCommentMark(collabEditProviderPromise),
154
155
  addInlineCommentNodeMark: createAddInlineCommentNodeMark(collabEditProviderPromise),
155
156
  isRemoteReplaceDocumentTransaction: function isRemoteReplaceDocumentTransaction(tr) {
@@ -260,15 +261,17 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
260
261
  return plugins;
261
262
  },
262
263
  onEditorViewStateUpdated: function onEditorViewStateUpdated(props) {
263
- var _api$analytics2, _api$editorViewMode, _options$useNativePlu;
264
+ var _api$analytics2, _api$editorViewMode, _options$useNativePlu, _options$hideTelecurs;
264
265
  var addErrorAnalytics = (0, _analytics2.addSynchronyErrorAnalytics)(props.newEditorState, props.newEditorState.tr, featureFlags, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
266
+ var isEmptyDoc = (0, _utils.isEmptyDocument)(props.newEditorState.doc);
265
267
  var viewMode = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode;
266
268
  executeProviderCode((0, _sendTransaction.sendTransaction)({
267
269
  originalTransaction: props.originalTransaction,
268
270
  transactions: props.transactions,
269
271
  oldEditorState: props.oldEditorState,
270
272
  newEditorState: props.newEditorState,
271
- useNativePlugin: (_options$useNativePlu = options === null || options === void 0 ? void 0 : options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
273
+ useNativePlugin: (_options$useNativePlu = options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
274
+ hideTelecursorOnLoad: !isEmptyDoc && ((_options$hideTelecurs = options.hideTelecursorOnLoad) !== null && _options$hideTelecurs !== void 0 ? _options$hideTelecurs : false),
272
275
  viewMode: viewMode
273
276
  }), addErrorAnalytics);
274
277
  (0, _trackSteps.track)(_objectSpread(_objectSpread({}, props), {}, {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.sendTransaction = void 0;
7
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
7
8
  var _actions = require("../actions");
8
9
  var _pluginKey = require("../main/plugin-key");
9
10
  var sendTransaction = exports.sendTransaction = function sendTransaction(_ref) {
@@ -12,7 +13,8 @@ var sendTransaction = exports.sendTransaction = function sendTransaction(_ref) {
12
13
  oldEditorState = _ref.oldEditorState,
13
14
  newEditorState = _ref.newEditorState,
14
15
  useNativePlugin = _ref.useNativePlugin,
15
- viewMode = _ref.viewMode;
16
+ viewMode = _ref.viewMode,
17
+ hideTelecursorOnLoad = _ref.hideTelecursorOnLoad;
16
18
  return function (provider) {
17
19
  var docChangedTransaction = transactions.find(function (tr) {
18
20
  return tr.docChanged;
@@ -35,7 +37,7 @@ var sendTransaction = exports.sendTransaction = function sendTransaction(_ref) {
35
37
  sessionId = currentPluginState.sessionId;
36
38
  var selectionChanged = !oldEditorState.selection.eq(newEditorState.selection);
37
39
  var participantsChanged = prevActiveParticipants && !prevActiveParticipants.eq(activeParticipants);
38
- if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || participantsChanged)) {
40
+ if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || ((0, _platformFeatureFlags.fg)('platform_editor_no_telecursor_on_live_doc_init') ? participantsChanged && !hideTelecursorOnLoad : participantsChanged))) {
39
41
  var selection = (0, _actions.getSendableSelection)(newEditorState.selection);
40
42
  var message = {
41
43
  type: 'telepointer',
@@ -74,6 +74,37 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
74
74
  decorations: function decorations(state) {
75
75
  var _pluginKey$getState;
76
76
  return (_pluginKey$getState = _pluginKey.pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorations;
77
+ },
78
+ handleDOMEvents: {
79
+ click: function click(view, event) {
80
+ var _pluginKey$getState2, _pluginInjectionApi$a, _pluginInjectionApi$a2;
81
+ if (!(event.target instanceof HTMLElement)) {
82
+ return false;
83
+ }
84
+ if (!view.state.selection.empty) {
85
+ return false;
86
+ }
87
+ var pos = view.state.tr.selection.$from.pos;
88
+ if (!pos) {
89
+ return false;
90
+ }
91
+
92
+ // check if the pos is the same pos as a telepointer decoration
93
+ var decorations = (_pluginKey$getState2 = _pluginKey.pluginKey.getState(view.state)) === null || _pluginKey$getState2 === void 0 || (_pluginKey$getState2 = _pluginKey$getState2.decorations) === null || _pluginKey$getState2 === void 0 ? void 0 : _pluginKey$getState2.find(pos, pos);
94
+ if (!(decorations !== null && decorations !== void 0 && decorations.length)) {
95
+ return false;
96
+ }
97
+ // analytics to track telepointer clicks as they sometimes cause broken selections
98
+ var fireAnalyticsCallback = (0, _analytics.fireAnalyticsEvent)((_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 || (_pluginInjectionApi$a2 = _pluginInjectionApi$a2.sharedState.currentState()) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.createAnalyticsEvent) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : undefined);
99
+ fireAnalyticsCallback({
100
+ payload: {
101
+ action: _analytics.ACTION.CLICKED,
102
+ actionSubject: _analytics.ACTION_SUBJECT.TELEPOINTER,
103
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.TELEPOINTER,
104
+ eventType: _analytics.EVENT_TYPE.TRACK
105
+ }
106
+ });
107
+ }
77
108
  }
78
109
  },
79
110
  filterTransaction: function filterTransaction(tr, state) {
@@ -91,11 +122,11 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
91
122
  return true;
92
123
  },
93
124
  view: function view(_view) {
94
- var _pluginInjectionApi$a, _pluginInjectionApi$a4;
95
- var addErrorAnalytics = (0, _analytics2.addSynchronyErrorAnalytics)(_view.state, _view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
125
+ var _pluginInjectionApi$a3, _pluginInjectionApi$a6;
126
+ var addErrorAnalytics = (0, _analytics2.addSynchronyErrorAnalytics)(_view.state, _view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions);
96
127
  var onSyncUpError = function onSyncUpError(attributes) {
97
- var _pluginInjectionApi$a2, _pluginInjectionApi$a3;
98
- var fireAnalyticsCallback = (0, _analytics.fireAnalyticsEvent)((_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
128
+ var _pluginInjectionApi$a4, _pluginInjectionApi$a5;
129
+ var fireAnalyticsCallback = (0, _analytics.fireAnalyticsEvent)((_pluginInjectionApi$a4 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || (_pluginInjectionApi$a5 = _pluginInjectionApi$a5.sharedState.currentState()) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.createAnalyticsEvent) !== null && _pluginInjectionApi$a4 !== void 0 ? _pluginInjectionApi$a4 : undefined);
99
130
  fireAnalyticsCallback({
100
131
  payload: {
101
132
  action: _analytics.ACTION.NEW_COLLAB_SYNC_UP_ERROR_NO_STEPS,
@@ -112,7 +143,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, provid
112
143
  providerFactory: providerFactory,
113
144
  featureFlags: featureFlags,
114
145
  pluginInjectionApi: pluginInjectionApi,
115
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions
146
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions
116
147
  }), addErrorAnalytics);
117
148
  providerFactory && providerFactory.subscribe('collabEditProvider', function (_name, providerPromise) {
118
149
  if (providerPromise) {
@@ -27,7 +27,7 @@ var findPointers = exports.findPointers = function findPointers(id, decorations)
27
27
  };
28
28
  function style(options) {
29
29
  var color = options && options.color || 'black';
30
- return "border-right: 2px solid ".concat(color, "; margin-right: -2px;");
30
+ return "border-right: 2px solid ".concat(color, "; margin-right: -2px; z-index: 1");
31
31
  }
32
32
  function getAvatarColor(str) {
33
33
  var participantColor = (0, _editorSharedStyles.getParticipantColor)(str);
@@ -1,4 +1,5 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
2
3
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
4
  import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -206,15 +207,17 @@ export const collabEditPlugin = ({
206
207
  return plugins;
207
208
  },
208
209
  onEditorViewStateUpdated(props) {
209
- var _api$analytics2, _api$editorViewMode, _api$editorViewMode$s, _options$useNativePlu;
210
+ var _api$analytics2, _api$editorViewMode, _api$editorViewMode$s, _options$useNativePlu, _options$hideTelecurs;
210
211
  const addErrorAnalytics = addSynchronyErrorAnalytics(props.newEditorState, props.newEditorState.tr, featureFlags, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
212
+ const isEmptyDoc = isEmptyDocument(props.newEditorState.doc);
211
213
  const viewMode = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode;
212
214
  executeProviderCode(sendTransaction({
213
215
  originalTransaction: props.originalTransaction,
214
216
  transactions: props.transactions,
215
217
  oldEditorState: props.oldEditorState,
216
218
  newEditorState: props.newEditorState,
217
- useNativePlugin: (_options$useNativePlu = options === null || options === void 0 ? void 0 : options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
219
+ useNativePlugin: (_options$useNativePlu = options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
220
+ hideTelecursorOnLoad: !isEmptyDoc && ((_options$hideTelecurs = options.hideTelecursorOnLoad) !== null && _options$hideTelecurs !== void 0 ? _options$hideTelecurs : false),
218
221
  viewMode
219
222
  }), addErrorAnalytics);
220
223
  track({
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { getSendableSelection } from '../actions';
2
3
  import { pluginKey } from '../main/plugin-key';
3
4
  export const sendTransaction = ({
@@ -6,7 +7,8 @@ export const sendTransaction = ({
6
7
  oldEditorState,
7
8
  newEditorState,
8
9
  useNativePlugin,
9
- viewMode
10
+ viewMode,
11
+ hideTelecursorOnLoad
10
12
  }) => provider => {
11
13
  const docChangedTransaction = transactions.find(tr => tr.docChanged);
12
14
  const currentPluginState = pluginKey.getState(newEditorState);
@@ -30,7 +32,7 @@ export const sendTransaction = ({
30
32
  } = currentPluginState;
31
33
  const selectionChanged = !oldEditorState.selection.eq(newEditorState.selection);
32
34
  const participantsChanged = prevActiveParticipants && !prevActiveParticipants.eq(activeParticipants);
33
- if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || participantsChanged)) {
35
+ if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || (fg('platform_editor_no_telecursor_on_live_doc_init') ? participantsChanged && !hideTelecursorOnLoad : participantsChanged))) {
34
36
  const selection = getSendableSelection(newEditorState.selection);
35
37
  const message = {
36
38
  type: 'telepointer',
@@ -7,7 +7,7 @@ import * as adfCustomSteps from '@atlaskit/adf-schema/steps';
7
7
  // Ignored via go/ees005
8
8
  // eslint-disable-next-line import/no-namespace
9
9
  import * as atlaskKitCustomSteps from '@atlaskit/custom-steps';
10
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
10
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
11
11
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
12
12
  import { Step } from '@atlaskit/editor-prosemirror/transform';
13
13
  import { addSynchronyErrorAnalytics } from '../analytics';
@@ -62,6 +62,39 @@ export const createPlugin = (dispatch, providerFactory, providerResolver, collab
62
62
  decorations(state) {
63
63
  var _pluginKey$getState;
64
64
  return (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorations;
65
+ },
66
+ handleDOMEvents: {
67
+ click(view, event) {
68
+ var _pluginKey$getState2, _pluginKey$getState2$, _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3;
69
+ if (!(event.target instanceof HTMLElement)) {
70
+ return false;
71
+ }
72
+ if (!view.state.selection.empty) {
73
+ return false;
74
+ }
75
+ const {
76
+ pos
77
+ } = view.state.tr.selection.$from;
78
+ if (!pos) {
79
+ return false;
80
+ }
81
+
82
+ // check if the pos is the same pos as a telepointer decoration
83
+ const decorations = (_pluginKey$getState2 = pluginKey.getState(view.state)) === null || _pluginKey$getState2 === void 0 ? void 0 : (_pluginKey$getState2$ = _pluginKey$getState2.decorations) === null || _pluginKey$getState2$ === void 0 ? void 0 : _pluginKey$getState2$.find(pos, pos);
84
+ if (!(decorations !== null && decorations !== void 0 && decorations.length)) {
85
+ return false;
86
+ }
87
+ // analytics to track telepointer clicks as they sometimes cause broken selections
88
+ const fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : (_pluginInjectionApi$a3 = _pluginInjectionApi$a2.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : undefined);
89
+ fireAnalyticsCallback({
90
+ payload: {
91
+ action: ACTION.CLICKED,
92
+ actionSubject: ACTION_SUBJECT.TELEPOINTER,
93
+ actionSubjectId: ACTION_SUBJECT_ID.TELEPOINTER,
94
+ eventType: EVENT_TYPE.TRACK
95
+ }
96
+ });
97
+ }
65
98
  }
66
99
  },
67
100
  filterTransaction(tr, state) {
@@ -79,11 +112,11 @@ export const createPlugin = (dispatch, providerFactory, providerResolver, collab
79
112
  return true;
80
113
  },
81
114
  view(view) {
82
- var _pluginInjectionApi$a, _pluginInjectionApi$a5;
83
- const addErrorAnalytics = addSynchronyErrorAnalytics(view.state, view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
115
+ var _pluginInjectionApi$a4, _pluginInjectionApi$a8;
116
+ const addErrorAnalytics = addSynchronyErrorAnalytics(view.state, view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions);
84
117
  const onSyncUpError = attributes => {
85
- var _pluginInjectionApi$a2, _pluginInjectionApi$a3, _pluginInjectionApi$a4;
86
- const fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : (_pluginInjectionApi$a4 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
118
+ var _pluginInjectionApi$a5, _pluginInjectionApi$a6, _pluginInjectionApi$a7;
119
+ const fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a5 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : (_pluginInjectionApi$a7 = _pluginInjectionApi$a6.sharedState.currentState()) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.createAnalyticsEvent) !== null && _pluginInjectionApi$a5 !== void 0 ? _pluginInjectionApi$a5 : undefined);
87
120
  fireAnalyticsCallback({
88
121
  payload: {
89
122
  action: ACTION.NEW_COLLAB_SYNC_UP_ERROR_NO_STEPS,
@@ -100,7 +133,7 @@ export const createPlugin = (dispatch, providerFactory, providerResolver, collab
100
133
  providerFactory,
101
134
  featureFlags,
102
135
  pluginInjectionApi,
103
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions
136
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions
104
137
  }), addErrorAnalytics);
105
138
  providerFactory && providerFactory.subscribe('collabEditProvider', (_name, providerPromise) => {
106
139
  if (providerPromise) {
@@ -13,7 +13,7 @@ export const findPointers = (id, decorations) => decorations.find()
13
13
  .reduce((arr, deco) => deco.spec.pointer.sessionId === id ? arr.concat(deco) : arr, []);
14
14
  function style(options) {
15
15
  const color = options && options.color || 'black';
16
- return `border-right: 2px solid ${color}; margin-right: -2px;`;
16
+ return `border-right: 2px solid ${color}; margin-right: -2px; z-index: 1`;
17
17
  }
18
18
  export function getAvatarColor(str) {
19
19
  const participantColor = getParticipantColor(str);
@@ -5,6 +5,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
5
5
  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; }
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
7
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
8
+ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
8
9
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
9
10
  import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -253,15 +254,17 @@ export var collabEditPlugin = function collabEditPlugin(_ref4) {
253
254
  return plugins;
254
255
  },
255
256
  onEditorViewStateUpdated: function onEditorViewStateUpdated(props) {
256
- var _api$analytics2, _api$editorViewMode, _options$useNativePlu;
257
+ var _api$analytics2, _api$editorViewMode, _options$useNativePlu, _options$hideTelecurs;
257
258
  var addErrorAnalytics = addSynchronyErrorAnalytics(props.newEditorState, props.newEditorState.tr, featureFlags, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions);
259
+ var isEmptyDoc = isEmptyDocument(props.newEditorState.doc);
258
260
  var viewMode = api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode;
259
261
  executeProviderCode(sendTransaction({
260
262
  originalTransaction: props.originalTransaction,
261
263
  transactions: props.transactions,
262
264
  oldEditorState: props.oldEditorState,
263
265
  newEditorState: props.newEditorState,
264
- useNativePlugin: (_options$useNativePlu = options === null || options === void 0 ? void 0 : options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
266
+ useNativePlugin: (_options$useNativePlu = options.useNativePlugin) !== null && _options$useNativePlu !== void 0 ? _options$useNativePlu : false,
267
+ hideTelecursorOnLoad: !isEmptyDoc && ((_options$hideTelecurs = options.hideTelecursorOnLoad) !== null && _options$hideTelecurs !== void 0 ? _options$hideTelecurs : false),
265
268
  viewMode: viewMode
266
269
  }), addErrorAnalytics);
267
270
  track(_objectSpread(_objectSpread({}, props), {}, {
@@ -1,3 +1,4 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import { getSendableSelection } from '../actions';
2
3
  import { pluginKey } from '../main/plugin-key';
3
4
  export var sendTransaction = function sendTransaction(_ref) {
@@ -6,7 +7,8 @@ export var sendTransaction = function sendTransaction(_ref) {
6
7
  oldEditorState = _ref.oldEditorState,
7
8
  newEditorState = _ref.newEditorState,
8
9
  useNativePlugin = _ref.useNativePlugin,
9
- viewMode = _ref.viewMode;
10
+ viewMode = _ref.viewMode,
11
+ hideTelecursorOnLoad = _ref.hideTelecursorOnLoad;
10
12
  return function (provider) {
11
13
  var docChangedTransaction = transactions.find(function (tr) {
12
14
  return tr.docChanged;
@@ -29,7 +31,7 @@ export var sendTransaction = function sendTransaction(_ref) {
29
31
  sessionId = currentPluginState.sessionId;
30
32
  var selectionChanged = !oldEditorState.selection.eq(newEditorState.selection);
31
33
  var participantsChanged = prevActiveParticipants && !prevActiveParticipants.eq(activeParticipants);
32
- if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || participantsChanged)) {
34
+ if (sessionId && viewMode === 'edit' && (selectionChanged && !docChangedTransaction || (fg('platform_editor_no_telecursor_on_live_doc_init') ? participantsChanged && !hideTelecursorOnLoad : participantsChanged))) {
33
35
  var selection = getSendableSelection(newEditorState.selection);
34
36
  var message = {
35
37
  type: 'telepointer',
@@ -7,7 +7,7 @@ import * as adfCustomSteps from '@atlaskit/adf-schema/steps';
7
7
  // Ignored via go/ees005
8
8
  // eslint-disable-next-line import/no-namespace
9
9
  import * as atlaskKitCustomSteps from '@atlaskit/custom-steps';
10
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
10
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
11
11
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
12
12
  import { Step } from '@atlaskit/editor-prosemirror/transform';
13
13
  import { addSynchronyErrorAnalytics } from '../analytics';
@@ -63,6 +63,37 @@ export var createPlugin = function createPlugin(dispatch, providerFactory, provi
63
63
  decorations: function decorations(state) {
64
64
  var _pluginKey$getState;
65
65
  return (_pluginKey$getState = pluginKey.getState(state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.decorations;
66
+ },
67
+ handleDOMEvents: {
68
+ click: function click(view, event) {
69
+ var _pluginKey$getState2, _pluginInjectionApi$a, _pluginInjectionApi$a2;
70
+ if (!(event.target instanceof HTMLElement)) {
71
+ return false;
72
+ }
73
+ if (!view.state.selection.empty) {
74
+ return false;
75
+ }
76
+ var pos = view.state.tr.selection.$from.pos;
77
+ if (!pos) {
78
+ return false;
79
+ }
80
+
81
+ // check if the pos is the same pos as a telepointer decoration
82
+ var decorations = (_pluginKey$getState2 = pluginKey.getState(view.state)) === null || _pluginKey$getState2 === void 0 || (_pluginKey$getState2 = _pluginKey$getState2.decorations) === null || _pluginKey$getState2 === void 0 ? void 0 : _pluginKey$getState2.find(pos, pos);
83
+ if (!(decorations !== null && decorations !== void 0 && decorations.length)) {
84
+ return false;
85
+ }
86
+ // analytics to track telepointer clicks as they sometimes cause broken selections
87
+ var fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 || (_pluginInjectionApi$a2 = _pluginInjectionApi$a2.sharedState.currentState()) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.createAnalyticsEvent) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : undefined);
88
+ fireAnalyticsCallback({
89
+ payload: {
90
+ action: ACTION.CLICKED,
91
+ actionSubject: ACTION_SUBJECT.TELEPOINTER,
92
+ actionSubjectId: ACTION_SUBJECT_ID.TELEPOINTER,
93
+ eventType: EVENT_TYPE.TRACK
94
+ }
95
+ });
96
+ }
66
97
  }
67
98
  },
68
99
  filterTransaction: function filterTransaction(tr, state) {
@@ -80,11 +111,11 @@ export var createPlugin = function createPlugin(dispatch, providerFactory, provi
80
111
  return true;
81
112
  },
82
113
  view: function view(_view) {
83
- var _pluginInjectionApi$a, _pluginInjectionApi$a4;
84
- var addErrorAnalytics = addSynchronyErrorAnalytics(_view.state, _view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions);
114
+ var _pluginInjectionApi$a3, _pluginInjectionApi$a6;
115
+ var addErrorAnalytics = addSynchronyErrorAnalytics(_view.state, _view.state.tr, featureFlags, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions);
85
116
  var onSyncUpError = function onSyncUpError(attributes) {
86
- var _pluginInjectionApi$a2, _pluginInjectionApi$a3;
87
- var fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a2 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 || (_pluginInjectionApi$a3 = _pluginInjectionApi$a3.sharedState.currentState()) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.createAnalyticsEvent) !== null && _pluginInjectionApi$a2 !== void 0 ? _pluginInjectionApi$a2 : undefined);
117
+ var _pluginInjectionApi$a4, _pluginInjectionApi$a5;
118
+ var fireAnalyticsCallback = fireAnalyticsEvent((_pluginInjectionApi$a4 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || (_pluginInjectionApi$a5 = _pluginInjectionApi$a5.sharedState.currentState()) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.createAnalyticsEvent) !== null && _pluginInjectionApi$a4 !== void 0 ? _pluginInjectionApi$a4 : undefined);
88
119
  fireAnalyticsCallback({
89
120
  payload: {
90
121
  action: ACTION.NEW_COLLAB_SYNC_UP_ERROR_NO_STEPS,
@@ -101,7 +132,7 @@ export var createPlugin = function createPlugin(dispatch, providerFactory, provi
101
132
  providerFactory: providerFactory,
102
133
  featureFlags: featureFlags,
103
134
  pluginInjectionApi: pluginInjectionApi,
104
- editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions
135
+ editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions
105
136
  }), addErrorAnalytics);
106
137
  providerFactory && providerFactory.subscribe('collabEditProvider', function (_name, providerPromise) {
107
138
  if (providerPromise) {
@@ -18,7 +18,7 @@ export var findPointers = function findPointers(id, decorations) {
18
18
  };
19
19
  function style(options) {
20
20
  var color = options && options.color || 'black';
21
- return "border-right: 2px solid ".concat(color, "; margin-right: -2px;");
21
+ return "border-right: 2px solid ".concat(color, "; margin-right: -2px; z-index: 1");
22
22
  }
23
23
  export function getAvatarColor(str) {
24
24
  var participantColor = getParticipantColor(str);
@@ -1,4 +1,5 @@
1
1
  import type { CollabEditProvider } from '@atlaskit/editor-common/collab';
2
+ import { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  type Props = {
4
5
  originalTransaction: Readonly<Transaction>;
@@ -6,7 +7,8 @@ type Props = {
6
7
  oldEditorState: EditorState;
7
8
  newEditorState: EditorState;
8
9
  useNativePlugin: boolean;
9
- viewMode?: 'view' | 'edit';
10
+ hideTelecursorOnLoad: boolean;
11
+ viewMode?: ViewMode;
10
12
  };
11
- export declare const sendTransaction: ({ originalTransaction, transactions, oldEditorState, newEditorState, useNativePlugin, viewMode, }: Props) => (provider: CollabEditProvider) => void;
13
+ export declare const sendTransaction: ({ originalTransaction, transactions, oldEditorState, newEditorState, useNativePlugin, viewMode, hideTelecursorOnLoad, }: Props) => (provider: CollabEditProvider) => void;
12
14
  export {};
@@ -4,6 +4,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export type PrivateCollabEditOptions = CollabEditOptions & {
5
5
  sanitizePrivateContent?: boolean;
6
6
  onSyncUpError?: SyncUpErrorFunction;
7
+ hideTelecursorOnLoad?: boolean;
7
8
  };
8
9
  export type ProviderCallback = <ReturnType>(codeToExecute: (provider: CollabEditProvider) => ReturnType | undefined, onError?: (err: Error) => void) => Promise<ReturnType | undefined> | undefined;
9
10
  export type ProviderBuilder = (collabEditProviderPromise: Promise<CollabEditProvider>) => ProviderCallback;
@@ -1,4 +1,5 @@
1
1
  import type { CollabEditProvider } from '@atlaskit/editor-common/collab';
2
+ import { ViewMode } from '@atlaskit/editor-plugin-editor-viewmode';
2
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
4
  type Props = {
4
5
  originalTransaction: Readonly<Transaction>;
@@ -6,7 +7,8 @@ type Props = {
6
7
  oldEditorState: EditorState;
7
8
  newEditorState: EditorState;
8
9
  useNativePlugin: boolean;
9
- viewMode?: 'view' | 'edit';
10
+ hideTelecursorOnLoad: boolean;
11
+ viewMode?: ViewMode;
10
12
  };
11
- export declare const sendTransaction: ({ originalTransaction, transactions, oldEditorState, newEditorState, useNativePlugin, viewMode, }: Props) => (provider: CollabEditProvider) => void;
13
+ export declare const sendTransaction: ({ originalTransaction, transactions, oldEditorState, newEditorState, useNativePlugin, viewMode, hideTelecursorOnLoad, }: Props) => (provider: CollabEditProvider) => void;
12
14
  export {};
@@ -4,6 +4,7 @@ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  export type PrivateCollabEditOptions = CollabEditOptions & {
5
5
  sanitizePrivateContent?: boolean;
6
6
  onSyncUpError?: SyncUpErrorFunction;
7
+ hideTelecursorOnLoad?: boolean;
7
8
  };
8
9
  export type ProviderCallback = <ReturnType>(codeToExecute: (provider: CollabEditProvider) => ReturnType | undefined, onError?: (err: Error) => void) => Promise<ReturnType | undefined> | undefined;
9
10
  export type ProviderBuilder = (collabEditProviderPromise: Promise<CollabEditProvider>) => ProviderCallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
35
  "@atlaskit/custom-steps": "^0.11.0",
36
- "@atlaskit/editor-common": "^102.13.0",
36
+ "@atlaskit/editor-common": "^103.0.0",
37
37
  "@atlaskit/editor-json-transformer": "^8.24.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
@@ -53,9 +53,9 @@
53
53
  "devDependencies": {
54
54
  "@af/integration-testing": "^0.5.0",
55
55
  "@af/visual-regression": "^1.3.0",
56
- "@atlaskit/editor-plugin-mentions": "^4.1.0",
56
+ "@atlaskit/editor-plugin-mentions": "^4.3.0",
57
57
  "@atlaskit/editor-plugin-text-formatting": "^2.1.0",
58
- "@atlaskit/editor-plugin-type-ahead": "^2.2.0",
58
+ "@atlaskit/editor-plugin-type-ahead": "^2.3.0",
59
59
  "@atlaskit/editor-plugin-unsupported-content": "^2.1.0",
60
60
  "@atlaskit/editor-test-helpers": "^22.1.0",
61
61
  "@atlaskit/ssr": "^0.4.0",
@@ -114,6 +114,9 @@
114
114
  },
115
115
  "platform_editor_selection_without_left_shift": {
116
116
  "type": "boolean"
117
+ },
118
+ "platform_editor_no_telecursor_on_live_doc_init": {
119
+ "type": "boolean"
117
120
  }
118
121
  }
119
122
  }