@atlaskit/editor-plugin-collab-edit 1.1.2 → 1.1.3

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.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#79350](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79350) [`ba4e64dca012`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ba4e64dca012) - Add FF to enable mapSelectionBackward to fix the cursor position
8
+
3
9
  ## 1.1.2
4
10
 
5
11
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.handleTelePointer = exports.handlePresence = exports.handleInit = export
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var _transform = require("@atlaskit/editor-prosemirror/transform");
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
12
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
12
13
  var _utils = require("./utils");
13
14
  var handleInit = exports.handleInit = function handleInit(initData, view, options) {
@@ -51,7 +52,16 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
51
52
  });
52
53
  var tr;
53
54
  if (options && options.useNativePlugin && userIds) {
54
- tr = (0, _prosemirrorCollab.receiveTransaction)(state, steps, userIds);
55
+ /**
56
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
57
+ */
58
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-map-selection-backward')) {
59
+ tr = (0, _prosemirrorCollab.receiveTransaction)(state, steps, userIds, {
60
+ mapSelectionBackward: true
61
+ });
62
+ } else {
63
+ tr = (0, _prosemirrorCollab.receiveTransaction)(state, steps, userIds);
64
+ }
55
65
  } else {
56
66
  tr = state.tr;
57
67
  steps.forEach(function (step) {
@@ -77,12 +87,17 @@ var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json
77
87
  }
78
88
 
79
89
  /**
80
- * If the cursor is a the same position as the first step in
81
- * the remote data, we need to manually set it back again
82
- * in order to prevent the cursor from moving.
90
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
83
91
  */
84
- if (from === firstStep.from && to === firstStep.to) {
85
- tr.setSelection(state.selection.map(tr.doc, tr.mapping));
92
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.enable-map-selection-backward')) {
93
+ /**
94
+ * If the cursor is a the same position as the first step in
95
+ * the remote data, we need to manually set it back again
96
+ * in order to prevent the cursor from moving.
97
+ */
98
+ if (from === firstStep.from && to === firstStep.to) {
99
+ tr.setSelection(state.selection.map(tr.doc, tr.mapping));
100
+ }
86
101
  }
87
102
  view.dispatch(tr);
88
103
  }
@@ -1,5 +1,6 @@
1
1
  import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { Step } from '@atlaskit/editor-prosemirror/transform';
3
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
4
  import { receiveTransaction } from '@atlaskit/prosemirror-collab';
4
5
  import { replaceDocument } from './utils';
5
6
  export const handleInit = (initData, view, options) => {
@@ -58,7 +59,16 @@ export const applyRemoteSteps = (json, view, userIds, options) => {
58
59
  const steps = json.map(step => Step.fromJSON(schema, step));
59
60
  let tr;
60
61
  if (options && options.useNativePlugin && userIds) {
61
- tr = receiveTransaction(state, steps, userIds);
62
+ /**
63
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
64
+ */
65
+ if (getBooleanFF('platform.editor.enable-map-selection-backward')) {
66
+ tr = receiveTransaction(state, steps, userIds, {
67
+ mapSelectionBackward: true
68
+ });
69
+ } else {
70
+ tr = receiveTransaction(state, steps, userIds);
71
+ }
62
72
  } else {
63
73
  tr = state.tr;
64
74
  steps.forEach(step => tr.step(step));
@@ -82,12 +92,17 @@ export const applyRemoteSteps = (json, view, userIds, options) => {
82
92
  }
83
93
 
84
94
  /**
85
- * If the cursor is a the same position as the first step in
86
- * the remote data, we need to manually set it back again
87
- * in order to prevent the cursor from moving.
95
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
88
96
  */
89
- if (from === firstStep.from && to === firstStep.to) {
90
- tr.setSelection(state.selection.map(tr.doc, tr.mapping));
97
+ if (!getBooleanFF('platform.editor.enable-map-selection-backward')) {
98
+ /**
99
+ * If the cursor is a the same position as the first step in
100
+ * the remote data, we need to manually set it back again
101
+ * in order to prevent the cursor from moving.
102
+ */
103
+ if (from === firstStep.from && to === firstStep.to) {
104
+ tr.setSelection(state.selection.map(tr.doc, tr.mapping));
105
+ }
91
106
  }
92
107
  view.dispatch(tr);
93
108
  }
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { Step } from '@atlaskit/editor-prosemirror/transform';
4
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
4
5
  import { receiveTransaction } from '@atlaskit/prosemirror-collab';
5
6
  import { replaceDocument } from './utils';
6
7
  export var handleInit = function handleInit(initData, view, options) {
@@ -44,7 +45,16 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
44
45
  });
45
46
  var tr;
46
47
  if (options && options.useNativePlugin && userIds) {
47
- tr = receiveTransaction(state, steps, userIds);
48
+ /**
49
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
50
+ */
51
+ if (getBooleanFF('platform.editor.enable-map-selection-backward')) {
52
+ tr = receiveTransaction(state, steps, userIds, {
53
+ mapSelectionBackward: true
54
+ });
55
+ } else {
56
+ tr = receiveTransaction(state, steps, userIds);
57
+ }
48
58
  } else {
49
59
  tr = state.tr;
50
60
  steps.forEach(function (step) {
@@ -70,12 +80,17 @@ export var applyRemoteSteps = function applyRemoteSteps(json, view, userIds, opt
70
80
  }
71
81
 
72
82
  /**
73
- * If the cursor is a the same position as the first step in
74
- * the remote data, we need to manually set it back again
75
- * in order to prevent the cursor from moving.
83
+ * https://switcheroo.atlassian.com/changes/confluence/platform.editor.enable-map-selection-backward
76
84
  */
77
- if (from === firstStep.from && to === firstStep.to) {
78
- tr.setSelection(state.selection.map(tr.doc, tr.mapping));
85
+ if (!getBooleanFF('platform.editor.enable-map-selection-backward')) {
86
+ /**
87
+ * If the cursor is a the same position as the first step in
88
+ * the remote data, we need to manually set it back again
89
+ * in order to prevent the cursor from moving.
90
+ */
91
+ if (from === firstStep.from && to === firstStep.to) {
92
+ tr.setSelection(state.selection.map(tr.doc, tr.mapping));
93
+ }
79
94
  }
80
95
  view.dispatch(tr);
81
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,10 +32,11 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/editor-common": "^78.10.0",
35
+ "@atlaskit/editor-common": "^78.11.0",
36
36
  "@atlaskit/editor-plugin-analytics": "1.0.3",
37
37
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
38
38
  "@atlaskit/editor-prosemirror": "3.0.0",
39
+ "@atlaskit/platform-feature-flags": "^0.2.5",
39
40
  "@atlaskit/prosemirror-collab": "^0.2.0",
40
41
  "@babel/runtime": "^7.0.0",
41
42
  "memoize-one": "^6.0.0"
@@ -51,7 +52,7 @@
51
52
  "@atlaskit/editor-plugin-text-formatting": "^1.2.0",
52
53
  "@atlaskit/editor-plugin-type-ahead": "^1.0.0",
53
54
  "@atlaskit/editor-plugin-unsupported-content": "^1.0.0",
54
- "@atlaskit/editor-test-helpers": "^18.18.0",
55
+ "@atlaskit/editor-test-helpers": "^18.19.0",
55
56
  "@atlaskit/ssr": "*",
56
57
  "@atlaskit/synchrony-test-helpers": "^2.3.0",
57
58
  "@atlaskit/util-data-test": "^17.9.0",
@@ -98,5 +99,10 @@
98
99
  ]
99
100
  }
100
101
  },
101
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
102
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
103
+ "platform-feature-flags": {
104
+ "platform.editor.enable-map-selection-backward": {
105
+ "type": "boolean"
106
+ }
107
+ }
102
108
  }