@atlaskit/editor-plugin-collab-edit 2.0.1 → 2.0.2

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/collabEditPlugin.js +21 -2
  3. package/dist/cjs/pm-plugins/actions.js +14 -2
  4. package/dist/cjs/pm-plugins/analytics.js +6 -1
  5. package/dist/cjs/pm-plugins/events/handlers.js +12 -1
  6. package/dist/cjs/pm-plugins/events/initialize.js +4 -1
  7. package/dist/cjs/pm-plugins/main/index.js +13 -1
  8. package/dist/cjs/pm-plugins/main/plugin-state.js +11 -0
  9. package/dist/cjs/pm-plugins/mergeUnconfirmed.js +85 -0
  10. package/dist/cjs/pm-plugins/utils.js +38 -8
  11. package/dist/es2019/collabEditPlugin.js +20 -2
  12. package/dist/es2019/pm-plugins/actions.js +12 -2
  13. package/dist/es2019/pm-plugins/analytics.js +6 -1
  14. package/dist/es2019/pm-plugins/events/handlers.js +13 -1
  15. package/dist/es2019/pm-plugins/events/initialize.js +4 -1
  16. package/dist/es2019/pm-plugins/main/index.js +13 -1
  17. package/dist/es2019/pm-plugins/main/plugin-state.js +14 -0
  18. package/dist/es2019/pm-plugins/mergeUnconfirmed.js +66 -0
  19. package/dist/es2019/pm-plugins/utils.js +39 -10
  20. package/dist/esm/collabEditPlugin.js +21 -2
  21. package/dist/esm/pm-plugins/actions.js +12 -2
  22. package/dist/esm/pm-plugins/analytics.js +6 -1
  23. package/dist/esm/pm-plugins/events/handlers.js +13 -1
  24. package/dist/esm/pm-plugins/events/initialize.js +4 -1
  25. package/dist/esm/pm-plugins/main/index.js +13 -1
  26. package/dist/esm/pm-plugins/main/plugin-state.js +11 -0
  27. package/dist/esm/pm-plugins/mergeUnconfirmed.js +78 -0
  28. package/dist/esm/pm-plugins/utils.js +39 -10
  29. package/dist/types/pm-plugins/mergeUnconfirmed.d.ts +24 -0
  30. package/dist/types-ts4.5/pm-plugins/mergeUnconfirmed.d.ts +24 -0
  31. package/package.json +6 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#97210](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97210)
8
+ [`c1744e14e854d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c1744e14e854d) -
9
+ Use transformUnconfirmed from collab prosemirror plugin to merge unconfirmed steps while offline
10
+ to reduce payload.
11
+ - Updated dependencies
12
+
3
13
  ## 2.0.1
4
14
 
5
15
  ### Patch Changes
@@ -12,11 +12,13 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
14
14
  var _transform = require("@atlaskit/editor-prosemirror/transform");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
16
17
  var _analytics2 = require("./pm-plugins/analytics");
17
18
  var _sendTransaction = require("./pm-plugins/events/send-transaction");
18
19
  var _main = require("./pm-plugins/main");
19
20
  var _pluginKey = require("./pm-plugins/main/plugin-key");
21
+ var _mergeUnconfirmed = require("./pm-plugins/mergeUnconfirmed");
20
22
  var _nativeCollabProviderPlugin = require("./pm-plugins/native-collab-provider-plugin");
21
23
  var _trackAndFilterSpammingSteps = require("./pm-plugins/track-and-filter-spamming-steps");
22
24
  var _trackLastOrganicChange = require("./pm-plugins/track-last-organic-change");
@@ -151,16 +153,32 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
151
153
  },
152
154
  getCurrentCollabState: function getCurrentCollabState() {
153
155
  var _getCollabState;
156
+ // Ignored via go/ees005
157
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
154
158
  var adfDocument = new _editorJsonTransformer.JSONTransformer().encode(editorViewRef.current.state.doc);
155
159
  return {
156
160
  content: adfDocument,
161
+ // Ignored via go/ees005
162
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157
163
  version: ((_getCollabState = (0, _prosemirrorCollab.getCollabState)(editorViewRef.current.state)) === null || _getCollabState === void 0 ? void 0 : _getCollabState.version) || 0,
164
+ // Ignored via go/ees005
165
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
158
166
  sendableSteps: (0, _prosemirrorCollab.sendableSteps)(editorViewRef.current.state)
159
167
  };
160
168
  },
169
+ // Ignored via go/ees005
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
161
171
  validatePMJSONDocument: function validatePMJSONDocument(doc) {
172
+ // Ignored via go/ees005
173
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
174
  var content = (doc.content || []).map(function (child) {
163
- return editorViewRef.current.state.schema.nodeFromJSON(child);
175
+ return (
176
+ // Ignored via go/ees005
177
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
178
+ // Ignored via go/ees005
179
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
180
+ editorViewRef.current.state.schema.nodeFromJSON(child)
181
+ );
164
182
  });
165
183
  return content.every(function (node) {
166
184
  try {
@@ -182,7 +200,8 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
182
200
  name: 'pmCollab',
183
201
  plugin: function plugin() {
184
202
  return (0, _prosemirrorCollab.collab)({
185
- clientID: userId
203
+ clientID: userId,
204
+ transformUnconfirmed: (0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps') ? _mergeUnconfirmed.mergeUnconfirmedSteps : undefined
186
205
  });
187
206
  }
188
207
  }, {
@@ -13,6 +13,12 @@ var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
13
13
  var _utils = require("./utils");
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ // Ignored via go/ees005
17
+ // eslint-disable-next-line import/no-namespace
18
+
19
+ // Ignored via go/ees005
20
+ // eslint-disable-next-line import/no-namespace
21
+
16
22
  /*
17
23
  * This is a non-op function to force ProseMirror to load and register all custom steps in the same bundle
18
24
  */
@@ -20,7 +26,10 @@ var registerAllCustomSteps = exports.registerAllCustomSteps = function registerA
20
26
  Object.entries(allAtlaskitCustomSteps).forEach(function () {});
21
27
  Object.entries(allAdfSchemaSteps).forEach(function () {});
22
28
  };
23
- var handleInit = exports.handleInit = function handleInit(initData, view, options, editorAnalyticsApi) {
29
+ var handleInit = exports.handleInit = function handleInit(initData, view, options, editorAnalyticsApi
30
+ // Ignored via go/ees005
31
+ // eslint-disable-next-line @typescript-eslint/max-params
32
+ ) {
24
33
  var doc = initData.doc,
25
34
  json = initData.json,
26
35
  version = initData.version,
@@ -75,7 +84,10 @@ var applyRemoteData = exports.applyRemoteData = function applyRemoteData(remoteD
75
84
  applyRemoteSteps(json, view, userIds, options);
76
85
  }
77
86
  };
78
- var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json, view, userIds, options) {
87
+ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json, view, userIds, options
88
+ // Ignored via go/ees005
89
+ // eslint-disable-next-line @typescript-eslint/max-params
90
+ ) {
79
91
  if (!json || !json.length) {
80
92
  return;
81
93
  }
@@ -7,7 +7,10 @@ exports.addSynchronyErrorAnalytics = exports.addSynchronyEntityAnalytics = void
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
- var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function addSynchronyErrorAnalytics(state, tr, featureFlags, editorAnalyticsApi) {
10
+ var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function addSynchronyErrorAnalytics(state, tr, featureFlags, editorAnalyticsApi
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line @typescript-eslint/max-params
13
+ ) {
11
14
  return function (error) {
12
15
  var browserExtensions = (0, _utils.sniffUserBrowserExtensions)({
13
16
  extensions: ['grammarly']
@@ -22,6 +25,8 @@ var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function a
22
25
  }
23
26
  };
24
27
  if (featureFlags.synchronyErrorDocStructure) {
28
+ // Ignored via go/ees005
29
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
30
  payload.attributes.docStructure = (0, _coreUtils.getDocStructure)(state.doc, {
26
31
  compact: true
27
32
  });
@@ -6,6 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.subscribe = void 0;
7
7
  var _actions = require("../actions");
8
8
  var _analytics = require("../analytics");
9
+ // Ignored via go/ees005
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+
12
+ // Ignored via go/ees005
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
17
  var effect = function effect(fn, eq) {
10
18
  var previousDeps;
11
19
  var cleanup;
@@ -21,7 +29,10 @@ var effect = function effect(fn, eq) {
21
29
  return cleanup;
22
30
  };
23
31
  };
24
- var subscribe = exports.subscribe = effect(function (view, provider, options, featureFlags, _providerFactory, editorAnalyticsApi) {
32
+ var subscribe = exports.subscribe = effect(
33
+ // Ignored via go/ees005
34
+ // eslint-disable-next-line @typescript-eslint/max-params
35
+ function (view, provider, options, featureFlags, _providerFactory, editorAnalyticsApi) {
25
36
  var entityRef;
26
37
  var entityHandlers = {
27
38
  disconnectedHandler: function disconnectedHandler() {
@@ -18,7 +18,10 @@ var initCollab = function initCollab(collabEditProvider, view) {
18
18
  });
19
19
  }
20
20
  };
21
- var initNewCollab = function initNewCollab(collabEditProvider, view, editorApi, onSyncUpError) {
21
+ var initNewCollab = function initNewCollab(collabEditProvider, view, editorApi, onSyncUpError
22
+ // Ignored via go/ees005
23
+ // eslint-disable-next-line @typescript-eslint/max-params
24
+ ) {
22
25
  collabEditProvider.setup({
23
26
  getState: function getState() {
24
27
  return view.state;
@@ -18,7 +18,12 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
19
  // It is important to get all steps in that package
20
20
 
21
+ // Ignored via go/ees005
22
+ // eslint-disable-next-line import/no-namespace
23
+
21
24
  // It is important to get all steps in that package
25
+ // Ignored via go/ees005
26
+ // eslint-disable-next-line import/no-namespace
22
27
 
23
28
  var enforceCustomStepRegisters = function enforceCustomStepRegisters() {
24
29
  var tryToRegisterStep = function tryToRegisterStep(obj) {
@@ -49,14 +54,21 @@ var enforceCustomStepRegisters = function enforceCustomStepRegisters() {
49
54
  // @ts-expect-error
50
55
  tryToRegisterStep(adfCustomSteps);
51
56
  };
52
- var createPlugin = exports.createPlugin = function createPlugin(dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi) {
57
+ var createPlugin = exports.createPlugin = function createPlugin(dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi
58
+ // Ignored via go/ees005
59
+ // eslint-disable-next-line @typescript-eslint/max-params
60
+ ) {
53
61
  enforceCustomStepRegisters();
54
62
  return new _safePlugin.SafePlugin({
55
63
  key: _pluginKey.pluginKey,
56
64
  state: {
65
+ // Ignored via go/ees005
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
67
  init: function init(config) {
58
68
  return _pluginState.PluginState.init(config);
59
69
  },
70
+ // Ignored via go/ees005
71
+ // eslint-disable-next-line @typescript-eslint/max-params
60
72
  apply: function apply(transaction, prevPluginState, _oldEditorState, _newEditorState) {
61
73
  var pluginState = prevPluginState.apply(transaction);
62
74
  dispatch(_pluginKey.pluginKey, pluginState);
@@ -29,6 +29,8 @@ var getValidPos = exports.getValidPos = function getValidPos(tr, pos) {
29
29
  return endOfDocPos;
30
30
  };
31
31
  var PluginState = exports.PluginState = /*#__PURE__*/function () {
32
+ // Ignored via go/ees005
33
+ // eslint-disable-next-line @typescript-eslint/max-params
32
34
  function PluginState(decorations, participants, sessionId) {
33
35
  var collabInitalised = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
34
36
  var onError = arguments.length > 4 ? arguments[4] : undefined;
@@ -157,9 +159,13 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
157
159
  // Remove any selection decoration within the change range,
158
160
  // takes care of the issue when after pasting we end up with a dead selection
159
161
  tr.steps.filter(_utils.isReplaceStep).forEach(function (s) {
162
+ // Ignored via go/ees005
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
160
164
  var _ref2 = s,
161
165
  from = _ref2.from,
162
166
  to = _ref2.to;
167
+ // Ignored via go/ees005
168
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
169
  _this.decorationSet.find(from, to).forEach(function (deco) {
164
170
  // `type` is private, `from` and `to` are public in latest version
165
171
  // `from` != `to` means it's a selection
@@ -170,6 +176,8 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
170
176
  });
171
177
  }
172
178
  var selection = tr.selection;
179
+ // Ignored via go/ees005
180
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
173
181
  this.decorationSet.find().forEach(function (deco) {
174
182
  if (deco.type.toDOM) {
175
183
  var hasTelepointerDimClass = deco.type.toDOM.classList.contains(_collab.TELEPOINTER_DIM_CLASS);
@@ -218,6 +226,9 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
218
226
  value: function eq(a, b) {
219
227
  return a.participants === b.participants && a.sessionId === b.sessionId && a.isReady === b.isReady;
220
228
  }
229
+
230
+ // Ignored via go/ees005
231
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
221
232
  }, {
222
233
  key: "init",
223
234
  value: function init(config) {
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.mergeUnconfirmedSteps = mergeUnconfirmedSteps;
8
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
9
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
10
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
14
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
15
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
16
+ function isLockable(step) {
17
+ return (step === null || step === void 0 ? void 0 : step.lockStep) !== undefined;
18
+ }
19
+ var createLockableProseMirrorStep = function createLockableProseMirrorStep(step) {
20
+ var stepIsLocked = false;
21
+ if (isLockable(step)) {
22
+ return step;
23
+ }
24
+ return new Proxy(step, {
25
+ get: function get(target, prop, receiver) {
26
+ if (prop === 'lockStep') {
27
+ return function () {
28
+ stepIsLocked = true;
29
+ };
30
+ } else if (prop === 'isLocked') {
31
+ return function () {
32
+ return stepIsLocked;
33
+ };
34
+ }
35
+ return Reflect.get(target, prop, receiver);
36
+ }
37
+ });
38
+ };
39
+
40
+ // Based on: `packages/editor/prosemirror-collab/src/index.ts`
41
+ var LockableRebaseable = /*#__PURE__*/(0, _createClass2.default)(function LockableRebaseable(step, inverted, origin) {
42
+ (0, _classCallCheck2.default)(this, LockableRebaseable);
43
+ this.step = step;
44
+ this.inverted = inverted;
45
+ this.origin = origin;
46
+ });
47
+ var LockableProseMirrorStep = /*#__PURE__*/function (_ProseMirrorStep) {
48
+ function LockableProseMirrorStep() {
49
+ (0, _classCallCheck2.default)(this, LockableProseMirrorStep);
50
+ return _callSuper(this, LockableProseMirrorStep, arguments);
51
+ }
52
+ (0, _inherits2.default)(LockableProseMirrorStep, _ProseMirrorStep);
53
+ return (0, _createClass2.default)(LockableProseMirrorStep);
54
+ }(_transform.Step);
55
+ /**
56
+ * Merge a set of steps together to reduce the total number of steps stored in memory.
57
+ *
58
+ * All steps passing through here should be "lockable" (ie. can be locked by the document service)
59
+ * so that it can be indicated they have already been sent (or are about to be sent) to the backend
60
+ * and cannot be merged.
61
+ *
62
+ * @param steps Rebaseable steps
63
+ * @returns Rebaseable steps
64
+ */
65
+ function mergeUnconfirmedSteps(steps) {
66
+ var mergedSteps = steps.reduce(function (acc, rebaseable) {
67
+ var _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
68
+ var lastStep = acc[acc.length - 1];
69
+ if (lastStep && ((_lastStep$step$isLock = (_lastStep$step = lastStep.step).isLocked) === null || _lastStep$step$isLock === void 0 ? void 0 : _lastStep$step$isLock.call(_lastStep$step)) !== true && ((_rebaseable$step$isLo = (_rebaseable$step = rebaseable.step).isLocked) === null || _rebaseable$step$isLo === void 0 ? void 0 : _rebaseable$step$isLo.call(_rebaseable$step)) !== true) {
70
+ var mergedStep = lastStep.step.merge(rebaseable.step);
71
+ var _inverted = rebaseable.inverted.merge(lastStep.inverted);
72
+ // Always take the origin of the new step.
73
+ // We use this in packages/editor/collab-provider/src/document/document-service.ts:commitUnconfirmedSteps
74
+ // to confirm that the last transaction has been sent. Since we're taking the latest this still works as expected
75
+ // As we want to wait until all the transactions have been pushed through
76
+ var _origin = lastStep.origin;
77
+ if (mergedStep && _inverted) {
78
+ acc[acc.length - 1] = new LockableRebaseable(createLockableProseMirrorStep(mergedStep), _inverted, _origin);
79
+ return acc;
80
+ }
81
+ }
82
+ return acc.concat(new LockableRebaseable(createLockableProseMirrorStep(rebaseable.step), rebaseable.inverted, rebaseable.origin));
83
+ }, []);
84
+ return mergedSteps;
85
+ }
@@ -18,7 +18,10 @@ var _view = require("@atlaskit/editor-prosemirror/view");
18
18
  var _consts = require("@atlaskit/editor-shared-styles/consts");
19
19
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
20
20
  var findPointers = exports.findPointers = function findPointers(id, decorations) {
21
- return decorations.find().reduce(function (arr, deco) {
21
+ return decorations.find()
22
+ // Ignored via go/ees005
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ .reduce(function (arr, deco) {
22
25
  return deco.spec.pointer.sessionId === id ? arr.concat(deco) : arr;
23
26
  }, []);
24
27
  };
@@ -40,13 +43,19 @@ function getAvatarColor(str) {
40
43
  color: _consts.avatarColors[index]
41
44
  };
42
45
  }
43
- var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial) {
46
+ var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial
47
+ // Ignored via go/ees005
48
+ // eslint-disable-next-line @typescript-eslint/max-params
49
+ ) {
44
50
  var decorations = [];
45
51
  var avatarColor = getAvatarColor(sessionId);
46
52
  var color = avatarColor.index.toString();
47
53
  if (isSelection) {
48
54
  var className = "telepointer color-".concat(color, " telepointer-selection");
49
- decorations.push(_view.Decoration.inline(from, to, {
55
+ decorations.push(
56
+ // Ignored via go/ees005
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ _view.Decoration.inline(from, to, {
50
59
  class: className,
51
60
  'data-initial': initial
52
61
  }, {
@@ -66,24 +75,36 @@ var createTelepointers = exports.createTelepointers = function createTelepointer
66
75
  color: avatarColor.color
67
76
  }), ";");
68
77
  cursor.setAttribute('data-initial', initial);
69
- return decorations.concat(_view.Decoration.widget(to, spaceJoinerAfter, {
78
+ return decorations.concat(
79
+ // Ignored via go/ees005
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ _view.Decoration.widget(to, spaceJoinerAfter, {
70
82
  pointer: {
71
83
  sessionId: sessionId
72
84
  },
73
85
  key: "telepointer-".concat(sessionId, "-zero")
74
- })).concat(_view.Decoration.widget(to, cursor, {
86
+ })).concat(
87
+ // Ignored via go/ees005
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ _view.Decoration.widget(to, cursor, {
75
90
  pointer: {
76
91
  sessionId: sessionId
77
92
  },
78
93
  key: "telepointer-".concat(sessionId)
79
- })).concat(_view.Decoration.widget(to, spaceJoinerBefore, {
94
+ })).concat(
95
+ // Ignored via go/ees005
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ _view.Decoration.widget(to, spaceJoinerBefore, {
80
98
  pointer: {
81
99
  sessionId: sessionId
82
100
  },
83
101
  key: "telepointer-".concat(sessionId, "-zero")
84
102
  }));
85
103
  };
86
- var replaceDocument = exports.replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI) {
104
+ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI
105
+ // Ignored via go/ees005
106
+ // eslint-disable-next-line @typescript-eslint/max-params
107
+ ) {
87
108
  var schema = state.schema,
88
109
  tr = state.tr;
89
110
  var hasContent;
@@ -93,6 +114,8 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
93
114
  hasContent = !!(parsedDoc !== null && parsedDoc !== void 0 && parsedDoc.childCount);
94
115
  content = parsedDoc === null || parsedDoc === void 0 ? void 0 : parsedDoc.content;
95
116
  } else {
117
+ // Ignored via go/ees005
118
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
119
  content = (doc.content || []).map(function (child) {
97
120
  return schema.nodeFromJSON(child);
98
121
  });
@@ -100,6 +123,8 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
100
123
  }
101
124
  if (hasContent) {
102
125
  tr.setMeta('addToHistory', false);
126
+ // Ignored via go/ees005
127
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
103
128
  tr.replaceWith(0, state.doc.nodeSize - 2, content);
104
129
  var selection = state.selection;
105
130
  if (reserveCursor) {
@@ -125,7 +150,10 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
125
150
  }
126
151
  return tr;
127
152
  };
128
- var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI) {
153
+ var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI
154
+ // Ignored via go/ees005
155
+ // eslint-disable-next-line @typescript-eslint/max-params
156
+ ) {
129
157
  var selectedUser = participants[index];
130
158
  if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
131
159
  var state = editorView.state;
@@ -146,6 +174,8 @@ var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToColla
146
174
  };
147
175
  var getPositionOfTelepointer = exports.getPositionOfTelepointer = function getPositionOfTelepointer(sessionId, decorationSet) {
148
176
  var scrollPosition;
177
+ // Ignored via go/ees005
178
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
179
  decorationSet.find().forEach(function (deco) {
150
180
  if (deco.type.spec.pointer.sessionId === sessionId) {
151
181
  scrollPosition = deco.from;
@@ -1,11 +1,13 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
3
  import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
4
+ import { fg } from '@atlaskit/platform-feature-flags';
4
5
  import { collab, getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
5
6
  import { addSynchronyErrorAnalytics } from './pm-plugins/analytics';
6
7
  import { sendTransaction } from './pm-plugins/events/send-transaction';
7
8
  import { createPlugin } from './pm-plugins/main';
8
9
  import { pluginKey as mainPluginKey } from './pm-plugins/main/plugin-key';
10
+ import { mergeUnconfirmedSteps } from './pm-plugins/mergeUnconfirmed';
9
11
  import { nativeCollabProviderPlugin } from './pm-plugins/native-collab-provider-plugin';
10
12
  import { sanitizeFilteredStep, createPlugin as trackSpammingStepsPlugin } from './pm-plugins/track-and-filter-spamming-steps';
11
13
  import { createPlugin as createLastOrganicChangePlugin, trackLastOrganicChangePluginKey } from './pm-plugins/track-last-organic-change';
@@ -110,15 +112,30 @@ export const collabEditPlugin = ({
110
112
  isRemoteReplaceDocumentTransaction: tr => tr.getMeta('isRemote') && tr.getMeta('replaceDocument'),
111
113
  getCurrentCollabState: () => {
112
114
  var _getCollabState;
115
+ // Ignored via go/ees005
116
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
113
117
  const adfDocument = new JSONTransformer().encode(editorViewRef.current.state.doc);
114
118
  return {
115
119
  content: adfDocument,
120
+ // Ignored via go/ees005
121
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
116
122
  version: ((_getCollabState = getCollabState(editorViewRef.current.state)) === null || _getCollabState === void 0 ? void 0 : _getCollabState.version) || 0,
123
+ // Ignored via go/ees005
124
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117
125
  sendableSteps: sendableSteps(editorViewRef.current.state)
118
126
  };
119
127
  },
128
+ // Ignored via go/ees005
129
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
130
  validatePMJSONDocument: doc => {
121
- const content = (doc.content || []).map(child => editorViewRef.current.state.schema.nodeFromJSON(child));
131
+ // Ignored via go/ees005
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
+ const content = (doc.content || []).map(child =>
134
+ // Ignored via go/ees005
135
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
136
+ // Ignored via go/ees005
137
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
138
+ editorViewRef.current.state.schema.nodeFromJSON(child));
122
139
  return content.every(node => {
123
140
  try {
124
141
  node.check(); // this will throw an error if the node is invalid
@@ -137,7 +154,8 @@ export const collabEditPlugin = ({
137
154
  const plugins = [...(useNativePlugin ? [{
138
155
  name: 'pmCollab',
139
156
  plugin: () => collab({
140
- clientID: userId
157
+ clientID: userId,
158
+ transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? mergeUnconfirmedSteps : undefined
141
159
  })
142
160
  }, {
143
161
  name: 'nativeCollabProviderPlugin',
@@ -1,4 +1,8 @@
1
+ // Ignored via go/ees005
2
+ // eslint-disable-next-line import/no-namespace
1
3
  import * as allAdfSchemaSteps from '@atlaskit/adf-schema/steps';
4
+ // Ignored via go/ees005
5
+ // eslint-disable-next-line import/no-namespace
2
6
  import * as allAtlaskitCustomSteps from '@atlaskit/custom-steps';
3
7
  import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
8
  import { Step } from '@atlaskit/editor-prosemirror/transform';
@@ -12,7 +16,10 @@ export const registerAllCustomSteps = () => {
12
16
  Object.entries(allAtlaskitCustomSteps).forEach(() => {});
13
17
  Object.entries(allAdfSchemaSteps).forEach(() => {});
14
18
  };
15
- export const handleInit = (initData, view, options, editorAnalyticsApi) => {
19
+ export const handleInit = (initData, view, options, editorAnalyticsApi
20
+ // Ignored via go/ees005
21
+ // eslint-disable-next-line @typescript-eslint/max-params
22
+ ) => {
16
23
  const {
17
24
  doc,
18
25
  json,
@@ -80,7 +87,10 @@ export const applyRemoteData = (remoteData, view, options) => {
80
87
  applyRemoteSteps(json, view, userIds, options);
81
88
  }
82
89
  };
83
- export const applyRemoteSteps = (json, view, userIds, options) => {
90
+ export const applyRemoteSteps = (json, view, userIds, options
91
+ // Ignored via go/ees005
92
+ // eslint-disable-next-line @typescript-eslint/max-params
93
+ ) => {
84
94
  if (!json || !json.length) {
85
95
  return;
86
96
  }
@@ -1,7 +1,10 @@
1
1
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { getDocStructure } from '@atlaskit/editor-common/core-utils';
3
3
  import { sniffUserBrowserExtensions } from '@atlaskit/editor-common/utils';
4
- export const addSynchronyErrorAnalytics = (state, tr, featureFlags, editorAnalyticsApi) => {
4
+ export const addSynchronyErrorAnalytics = (state, tr, featureFlags, editorAnalyticsApi
5
+ // Ignored via go/ees005
6
+ // eslint-disable-next-line @typescript-eslint/max-params
7
+ ) => {
5
8
  return error => {
6
9
  const browserExtensions = sniffUserBrowserExtensions({
7
10
  extensions: ['grammarly']
@@ -16,6 +19,8 @@ export const addSynchronyErrorAnalytics = (state, tr, featureFlags, editorAnalyt
16
19
  }
17
20
  };
18
21
  if (featureFlags.synchronyErrorDocStructure) {
22
+ // Ignored via go/ees005
23
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
24
  payload.attributes.docStructure = getDocStructure(state.doc, {
20
25
  compact: true
21
26
  });
@@ -1,5 +1,14 @@
1
1
  import { applyRemoteData, handleActivityAck, handleActivityJoin, handleConnection, handleInit, handlePresence, handleTelePointer } from '../actions';
2
2
  import { addSynchronyEntityAnalytics, addSynchronyErrorAnalytics } from '../analytics';
3
+
4
+ // Ignored via go/ees005
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+
7
+ // Ignored via go/ees005
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+
10
+ // Ignored via go/ees005
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
12
  const effect = (fn, eq) => {
4
13
  let previousDeps;
5
14
  let cleanup;
@@ -12,7 +21,10 @@ const effect = (fn, eq) => {
12
21
  return cleanup;
13
22
  };
14
23
  };
15
- export const subscribe = effect((view, provider, options, featureFlags, _providerFactory, editorAnalyticsApi) => {
24
+ export const subscribe = effect(
25
+ // Ignored via go/ees005
26
+ // eslint-disable-next-line @typescript-eslint/max-params
27
+ (view, provider, options, featureFlags, _providerFactory, editorAnalyticsApi) => {
16
28
  let entityRef;
17
29
  const entityHandlers = {
18
30
  disconnectedHandler: () => {
@@ -7,7 +7,10 @@ const initCollab = (collabEditProvider, view) => {
7
7
  collabEditProvider.initialize(() => view.state, json => Step.fromJSON(view.state.schema, json));
8
8
  }
9
9
  };
10
- const initNewCollab = (collabEditProvider, view, editorApi, onSyncUpError) => {
10
+ const initNewCollab = (collabEditProvider, view, editorApi, onSyncUpError
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line @typescript-eslint/max-params
13
+ ) => {
11
14
  collabEditProvider.setup({
12
15
  getState: () => view.state,
13
16
  editorApi,
@@ -1,6 +1,11 @@
1
1
  // It is important to get all steps in that package
2
+
3
+ // Ignored via go/ees005
4
+ // eslint-disable-next-line import/no-namespace
2
5
  import * as adfCustomSteps from '@atlaskit/adf-schema/steps';
3
6
  // It is important to get all steps in that package
7
+ // Ignored via go/ees005
8
+ // eslint-disable-next-line import/no-namespace
4
9
  import * as atlaskKitCustomSteps from '@atlaskit/custom-steps';
5
10
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '@atlaskit/editor-common/analytics';
6
11
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
@@ -37,14 +42,21 @@ const enforceCustomStepRegisters = () => {
37
42
  // @ts-expect-error
38
43
  tryToRegisterStep(adfCustomSteps);
39
44
  };
40
- export const createPlugin = (dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi) => {
45
+ export const createPlugin = (dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi
46
+ // Ignored via go/ees005
47
+ // eslint-disable-next-line @typescript-eslint/max-params
48
+ ) => {
41
49
  enforceCustomStepRegisters();
42
50
  return new SafePlugin({
43
51
  key: pluginKey,
44
52
  state: {
53
+ // Ignored via go/ees005
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
55
  init(config) {
46
56
  return PluginState.init(config);
47
57
  },
58
+ // Ignored via go/ees005
59
+ // eslint-disable-next-line @typescript-eslint/max-params
48
60
  apply(transaction, prevPluginState, _oldEditorState, _newEditorState) {
49
61
  const pluginState = prevPluginState.apply(transaction);
50
62
  dispatch(pluginKey, pluginState);