@atlaskit/editor-plugin-collab-edit 3.10.1 → 3.10.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 3.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#173357](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/173357)
8
+ [`f17a667b25b42`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f17a667b25b42) -
9
+ enable merging of prosemirror steps for single player sessions
10
+ - Updated dependencies
11
+
3
12
  ## 3.10.1
4
13
 
5
14
  ### Patch Changes
@@ -14,6 +14,7 @@ var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
15
15
  var _transform = require("@atlaskit/editor-prosemirror/transform");
16
16
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
17
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
18
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
19
  var _analytics2 = require("./pm-plugins/analytics");
19
20
  var _sendTransaction = require("./pm-plugins/events/send-transaction");
@@ -209,7 +210,7 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
209
210
  })) {
210
211
  transformed = (0, _filterAnalytics.filterAnalyticsSteps)(transformed);
211
212
  }
212
- if ((0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true)) {
213
+ if ((0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true) || (0, _expValEquals.expValEquals)('platform_editor_enable_single_player_step_merging', 'isEnabled', true)) {
213
214
  transformed = (0, _mergeUnconfirmed.mergeUnconfirmedSteps)(transformed, api);
214
215
  }
215
216
  return transformed;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.mergeUnconfirmedSteps = mergeUnconfirmedSteps;
7
7
  var _state = require("@atlaskit/editor-prosemirror/state");
8
8
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
9
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
9
10
  var isLocked = function isLocked(step) {
10
11
  if (step.origin instanceof _state.Transaction) {
11
12
  return step.origin.getMeta('mergeIsLocked');
@@ -25,10 +26,13 @@ var isLocked = function isLocked(step) {
25
26
  */
26
27
  function mergeUnconfirmedSteps(steps, api) {
27
28
  var mergedSteps = steps.reduce(function (acc, rebaseable) {
28
- var _api$connectivity;
29
+ var _api$connectivity, _api$collabEdit$share;
29
30
  var lastStep = acc[acc.length - 1];
30
31
  var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
31
- if (isOffline && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
32
+ var activeParticipants = api === null || api === void 0 || (_api$collabEdit$share = api.collabEdit.sharedState.currentState()) === null || _api$collabEdit$share === void 0 || (_api$collabEdit$share = _api$collabEdit$share.activeParticipants) === null || _api$collabEdit$share === void 0 ? void 0 : _api$collabEdit$share.toArray();
33
+ var isSinglePlayer = (0, _expValEquals.expValEquals)('platform_editor_enable_single_player_step_merging', 'isEnabled', true) && activeParticipants && activeParticipants.length === 1;
34
+ var isOfflineOrSinglePlayer = isOffline || isSinglePlayer;
35
+ if (isOfflineOrSinglePlayer && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
32
36
  var mergedStep = lastStep.step.merge(rebaseable.step);
33
37
  var inverted = rebaseable.inverted.merge(lastStep.inverted);
34
38
  // Always take the origin of the new step.
@@ -3,6 +3,7 @@ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
3
3
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
4
4
  import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
5
5
  import { collab, getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
6
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import { addSynchronyErrorAnalytics } from './pm-plugins/analytics';
8
9
  import { sendTransaction } from './pm-plugins/events/send-transaction';
@@ -164,7 +165,7 @@ export const collabEditPlugin = ({
164
165
  })) {
165
166
  transformed = filterAnalyticsSteps(transformed);
166
167
  }
167
- if (editorExperiment('platform_editor_offline_editing_web', true)) {
168
+ if (editorExperiment('platform_editor_offline_editing_web', true) || expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true)) {
168
169
  transformed = mergeUnconfirmedSteps(transformed, api);
169
170
  }
170
171
  return transformed;
@@ -1,5 +1,6 @@
1
1
  import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Rebaseable } from '@atlaskit/prosemirror-collab';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  const isLocked = step => {
4
5
  if (step.origin instanceof Transaction) {
5
6
  return step.origin.getMeta('mergeIsLocked');
@@ -19,10 +20,13 @@ const isLocked = step => {
19
20
  */
20
21
  export function mergeUnconfirmedSteps(steps, api) {
21
22
  const mergedSteps = steps.reduce((acc, rebaseable) => {
22
- var _api$connectivity, _api$connectivity$sha;
23
+ var _api$connectivity, _api$connectivity$sha, _api$collabEdit$share, _api$collabEdit$share2;
23
24
  const lastStep = acc[acc.length - 1];
24
25
  const isOffline = (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode) === 'offline';
25
- if (isOffline && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
26
+ const activeParticipants = api === null || api === void 0 ? void 0 : (_api$collabEdit$share = api.collabEdit.sharedState.currentState()) === null || _api$collabEdit$share === void 0 ? void 0 : (_api$collabEdit$share2 = _api$collabEdit$share.activeParticipants) === null || _api$collabEdit$share2 === void 0 ? void 0 : _api$collabEdit$share2.toArray();
27
+ const isSinglePlayer = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true) && activeParticipants && activeParticipants.length === 1;
28
+ const isOfflineOrSinglePlayer = isOffline || isSinglePlayer;
29
+ if (isOfflineOrSinglePlayer && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
26
30
  const mergedStep = lastStep.step.merge(rebaseable.step);
27
31
  const inverted = rebaseable.inverted.merge(lastStep.inverted);
28
32
  // Always take the origin of the new step.
@@ -9,6 +9,7 @@ import { isEmptyDocument } from '@atlaskit/editor-common/utils';
9
9
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
10
10
  import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
11
11
  import { collab, getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
12
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
14
  import { addSynchronyErrorAnalytics } from './pm-plugins/analytics';
14
15
  import { sendTransaction } from './pm-plugins/events/send-transaction';
@@ -202,7 +203,7 @@ export var collabEditPlugin = function collabEditPlugin(_ref4) {
202
203
  })) {
203
204
  transformed = filterAnalyticsSteps(transformed);
204
205
  }
205
- if (editorExperiment('platform_editor_offline_editing_web', true)) {
206
+ if (editorExperiment('platform_editor_offline_editing_web', true) || expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true)) {
206
207
  transformed = mergeUnconfirmedSteps(transformed, api);
207
208
  }
208
209
  return transformed;
@@ -1,5 +1,6 @@
1
1
  import { Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Rebaseable } from '@atlaskit/prosemirror-collab';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  var isLocked = function isLocked(step) {
4
5
  if (step.origin instanceof Transaction) {
5
6
  return step.origin.getMeta('mergeIsLocked');
@@ -19,10 +20,13 @@ var isLocked = function isLocked(step) {
19
20
  */
20
21
  export function mergeUnconfirmedSteps(steps, api) {
21
22
  var mergedSteps = steps.reduce(function (acc, rebaseable) {
22
- var _api$connectivity;
23
+ var _api$connectivity, _api$collabEdit$share;
23
24
  var lastStep = acc[acc.length - 1];
24
25
  var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
25
- if (isOffline && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
26
+ var activeParticipants = api === null || api === void 0 || (_api$collabEdit$share = api.collabEdit.sharedState.currentState()) === null || _api$collabEdit$share === void 0 || (_api$collabEdit$share = _api$collabEdit$share.activeParticipants) === null || _api$collabEdit$share === void 0 ? void 0 : _api$collabEdit$share.toArray();
27
+ var isSinglePlayer = expValEquals('platform_editor_enable_single_player_step_merging', 'isEnabled', true) && activeParticipants && activeParticipants.length === 1;
28
+ var isOfflineOrSinglePlayer = isOffline || isSinglePlayer;
29
+ if (isOfflineOrSinglePlayer && lastStep && !isLocked(lastStep) && !isLocked(rebaseable)) {
26
30
  var mergedStep = lastStep.step.merge(rebaseable.step);
27
31
  var inverted = rebaseable.inverted.merge(lastStep.inverted);
28
32
  // Always take the origin of the new step.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "3.10.1",
3
+ "version": "3.10.2",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/frontend-utilities": "^3.0.0",
45
45
  "@atlaskit/platform-feature-flags": "^1.1.0",
46
46
  "@atlaskit/prosemirror-collab": "^0.17.0",
47
- "@atlaskit/tmp-editor-statsig": "^7.1.0",
47
+ "@atlaskit/tmp-editor-statsig": "^7.2.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "memoize-one": "^6.0.0"
50
50
  },