@atlaskit/prosemirror-collab 0.11.0 → 0.11.1

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/prosemirror-collab
2
2
 
3
+ ## 0.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 0.11.0
4
10
 
5
11
  ### Minor Changes
package/dist/cjs/index.js CHANGED
@@ -13,6 +13,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
13
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
14
  var _uuid = require("uuid");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var Rebaseable = /*#__PURE__*/(0, _createClass2.default)(function Rebaseable(step, inverted, origin) {
17
18
  (0, _classCallCheck2.default)(this, Rebaseable);
18
19
  this.step = step;
@@ -99,7 +100,11 @@ function collab() {
99
100
  apply: function apply(tr, collab) {
100
101
  var newState = tr.getMeta(collabKey);
101
102
  if (newState) {
102
- return newState;
103
+ if ((0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps')) {
104
+ return new CollabState(newState.version, transformUnconfirmed(newState.unconfirmed));
105
+ } else {
106
+ return newState;
107
+ }
103
108
  }
104
109
  if (tr.docChanged) {
105
110
  return new CollabState(collab.version, transformUnconfirmed(collab.unconfirmed.concat(unconfirmedFrom(tr))));
@@ -117,8 +122,6 @@ function collab() {
117
122
  /// Create a transaction that represents a set of new steps received from
118
123
  /// the authority. Applying this transaction moves the state forward to
119
124
  /// adjust to the authority's view of the document.
120
- // Ignored via go/ees005
121
- // eslint-disable-next-line @typescript-eslint/max-params
122
125
  function receiveTransaction(state, steps, clientIDs) {
123
126
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
124
127
  // Pushes a set of steps (received from the central authority) into
@@ -1,5 +1,6 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
2
  import { Plugin, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
3
+ import { fg } from '@atlaskit/platform-feature-flags';
3
4
  class Rebaseable {
4
5
  constructor(step, inverted, origin) {
5
6
  this.step = step;
@@ -17,9 +18,9 @@ export function rebaseSteps(steps, over, transform) {
17
18
  for (let i = 0; i < over.length; i++) {
18
19
  transform.step(over[i]);
19
20
  }
20
- let result = [];
21
+ const result = [];
21
22
  for (let i = 0, mapFrom = steps.length; i < steps.length; i++) {
22
- let mapped = steps[i].step.map(transform.mapping.slice(mapFrom));
23
+ const mapped = steps[i].step.map(transform.mapping.slice(mapFrom));
23
24
  mapFrom--;
24
25
  if (mapped && !transform.maybeStep(mapped).failed) {
25
26
  // Open ticket for setMirror https://github.com/ProseMirror/prosemirror/issues/869
@@ -51,7 +52,7 @@ class CollabState {
51
52
  }
52
53
  }
53
54
  function unconfirmedFrom(transform) {
54
- let result = [];
55
+ const result = [];
55
56
  for (let i = 0; i < transform.steps.length; i++) {
56
57
  // Filter out the analytics steps, they don't need to be sent to the collab service
57
58
  // Commented out because it broke undo behaviour
@@ -69,7 +70,7 @@ const collabKey = new PluginKey('collab');
69
70
  /// for the editor.
70
71
  export function collab(config = {}) {
71
72
  var _config$transformUnco;
72
- let conf = {
73
+ const conf = {
73
74
  version: config.version || 0,
74
75
  clientID:
75
76
  // eslint-disable-next-line eqeqeq
@@ -83,9 +84,13 @@ export function collab(config = {}) {
83
84
  state: {
84
85
  init: () => new CollabState(conf.version, []),
85
86
  apply(tr, collab) {
86
- let newState = tr.getMeta(collabKey);
87
+ const newState = tr.getMeta(collabKey);
87
88
  if (newState) {
88
- return newState;
89
+ if (fg('platform_editor_merge_unconfirmed_steps')) {
90
+ return new CollabState(newState.version, transformUnconfirmed(newState.unconfirmed));
91
+ } else {
92
+ return newState;
93
+ }
89
94
  }
90
95
  if (tr.docChanged) {
91
96
  return new CollabState(collab.version, transformUnconfirmed(collab.unconfirmed.concat(unconfirmedFrom(tr))));
@@ -103,19 +108,17 @@ export function collab(config = {}) {
103
108
  /// Create a transaction that represents a set of new steps received from
104
109
  /// the authority. Applying this transaction moves the state forward to
105
110
  /// adjust to the authority's view of the document.
106
- // Ignored via go/ees005
107
- // eslint-disable-next-line @typescript-eslint/max-params
108
111
  export function receiveTransaction(state, steps, clientIDs, options = {}) {
109
112
  // Pushes a set of steps (received from the central authority) into
110
113
  // the editor state (which should have the collab plugin enabled).
111
114
  // Will recognize its own changes, and confirm unconfirmed steps as
112
115
  // appropriate. Remaining unconfirmed steps will be rebased over
113
116
  // remote steps.
114
- let collabState = collabKey.getState(state);
115
- let version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
117
+ const collabState = collabKey.getState(state);
118
+ const version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
116
119
  // Ignored via go/ees005
117
120
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-explicit-any
118
- let ourID = collabKey.get(state).spec.config.clientID;
121
+ const ourID = collabKey.get(state).spec.config.clientID;
119
122
 
120
123
  // Find out which prefix of the steps originated with us
121
124
  let ours = 0;
@@ -130,8 +133,8 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
130
133
  if (!steps.length) {
131
134
  return state.tr.setMeta(collabKey, new CollabState(version, unconfirmed));
132
135
  }
133
- let nUnconfirmed = unconfirmed.length;
134
- let tr = state.tr;
136
+ const nUnconfirmed = unconfirmed.length;
137
+ const tr = state.tr;
135
138
  if (nUnconfirmed) {
136
139
  unconfirmed = rebaseSteps(unconfirmed, steps, tr);
137
140
  } else {
@@ -140,7 +143,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
140
143
  }
141
144
  unconfirmed = [];
142
145
  }
143
- let newCollabState = new CollabState(version, unconfirmed);
146
+ const newCollabState = new CollabState(version, unconfirmed);
144
147
  if (options && options.mapSelectionBackward && state.selection instanceof TextSelection) {
145
148
  tr.setSelection(TextSelection.between(tr.doc.resolve(tr.mapping.map(state.selection.anchor, -1)), tr.doc.resolve(tr.mapping.map(state.selection.head, -1)), -1));
146
149
  // Ignored via go/ees005
@@ -160,7 +163,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
160
163
  /// rebased, whereas the origin transactions are still the old,
161
164
  /// unchanged objects.
162
165
  export function sendableSteps(state) {
163
- let collabState = collabKey.getState(state);
166
+ const collabState = collabKey.getState(state);
164
167
  if (!collabState) {
165
168
  return null;
166
169
  }
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import { Plugin, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
5
6
  var Rebaseable = /*#__PURE__*/_createClass(function Rebaseable(step, inverted, origin) {
6
7
  _classCallCheck(this, Rebaseable);
7
8
  this.step = step;
@@ -88,7 +89,11 @@ export function collab() {
88
89
  apply: function apply(tr, collab) {
89
90
  var newState = tr.getMeta(collabKey);
90
91
  if (newState) {
91
- return newState;
92
+ if (fg('platform_editor_merge_unconfirmed_steps')) {
93
+ return new CollabState(newState.version, transformUnconfirmed(newState.unconfirmed));
94
+ } else {
95
+ return newState;
96
+ }
92
97
  }
93
98
  if (tr.docChanged) {
94
99
  return new CollabState(collab.version, transformUnconfirmed(collab.unconfirmed.concat(unconfirmedFrom(tr))));
@@ -106,8 +111,6 @@ export function collab() {
106
111
  /// Create a transaction that represents a set of new steps received from
107
112
  /// the authority. Applying this transaction moves the state forward to
108
113
  /// adjust to the authority's view of the document.
109
- // Ignored via go/ees005
110
- // eslint-disable-next-line @typescript-eslint/max-params
111
114
  export function receiveTransaction(state, steps, clientIDs) {
112
115
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
113
116
  // Pushes a set of steps (received from the central authority) into
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Collaborative editing for ProseMirror - Atlassian Fork",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@atlaskit/editor-prosemirror": "6.2.1",
34
+ "@atlaskit/platform-feature-flags": "^1.0.0",
34
35
  "@babel/runtime": "^7.0.0",
35
36
  "uuid": "^3.1.0"
36
37
  },
@@ -52,5 +53,10 @@
52
53
  "emotion"
53
54
  ]
54
55
  }
56
+ },
57
+ "platform-feature-flags": {
58
+ "platform_editor_merge_unconfirmed_steps": {
59
+ "type": "boolean"
60
+ }
55
61
  }
56
62
  }