@atlaskit/editor-plugin-collab-edit 2.1.3 → 2.1.4

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
+ ## 2.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 2.1.3
4
10
 
5
11
  ### Patch Changes
@@ -201,7 +201,9 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
201
201
  plugin: function plugin() {
202
202
  return (0, _prosemirrorCollab.collab)({
203
203
  clientID: userId,
204
- transformUnconfirmed: (0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps') ? _mergeUnconfirmed.mergeUnconfirmedSteps : undefined
204
+ transformUnconfirmed: (0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps') ? function (steps) {
205
+ return (0, _mergeUnconfirmed.mergeUnconfirmedSteps)(steps, api);
206
+ } : undefined
205
207
  });
206
208
  }
207
209
  }, {
@@ -62,11 +62,11 @@ var LockableProseMirrorStep = /*#__PURE__*/function (_ProseMirrorStep) {
62
62
  * @param steps Rebaseable steps
63
63
  * @returns Rebaseable steps
64
64
  */
65
- function mergeUnconfirmedSteps(steps) {
65
+ function mergeUnconfirmedSteps(steps, api) {
66
66
  var mergedSteps = steps.reduce(function (acc, rebaseable) {
67
- var _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
67
+ var _api$connectivity, _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
68
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) {
69
+ if ((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' && 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
70
  var mergedStep = lastStep.step.merge(rebaseable.step);
71
71
  var _inverted = rebaseable.inverted.merge(lastStep.inverted);
72
72
  // Always take the origin of the new step.
@@ -155,7 +155,7 @@ export const collabEditPlugin = ({
155
155
  name: 'pmCollab',
156
156
  plugin: () => collab({
157
157
  clientID: userId,
158
- transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? mergeUnconfirmedSteps : undefined
158
+ transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? steps => mergeUnconfirmedSteps(steps, api) : undefined
159
159
  })
160
160
  }, {
161
161
  name: 'nativeCollabProviderPlugin',
@@ -43,11 +43,11 @@ class LockableProseMirrorStep extends ProseMirrorStep {}
43
43
  * @param steps Rebaseable steps
44
44
  * @returns Rebaseable steps
45
45
  */
46
- export function mergeUnconfirmedSteps(steps) {
46
+ export function mergeUnconfirmedSteps(steps, api) {
47
47
  const mergedSteps = steps.reduce((acc, rebaseable) => {
48
- var _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
48
+ var _api$connectivity, _api$connectivity$sha, _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
49
49
  const lastStep = acc[acc.length - 1];
50
- 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) {
50
+ if ((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' && 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) {
51
51
  const mergedStep = lastStep.step.merge(rebaseable.step);
52
52
  const inverted = rebaseable.inverted.merge(lastStep.inverted);
53
53
  // Always take the origin of the new step.
@@ -194,7 +194,9 @@ export var collabEditPlugin = function collabEditPlugin(_ref4) {
194
194
  plugin: function plugin() {
195
195
  return collab({
196
196
  clientID: userId,
197
- transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? mergeUnconfirmedSteps : undefined
197
+ transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? function (steps) {
198
+ return mergeUnconfirmedSteps(steps, api);
199
+ } : undefined
198
200
  });
199
201
  }
200
202
  }, {
@@ -55,11 +55,11 @@ var LockableProseMirrorStep = /*#__PURE__*/function (_ProseMirrorStep) {
55
55
  * @param steps Rebaseable steps
56
56
  * @returns Rebaseable steps
57
57
  */
58
- export function mergeUnconfirmedSteps(steps) {
58
+ export function mergeUnconfirmedSteps(steps, api) {
59
59
  var mergedSteps = steps.reduce(function (acc, rebaseable) {
60
- var _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
60
+ var _api$connectivity, _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
61
61
  var lastStep = acc[acc.length - 1];
62
- 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) {
62
+ if ((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' && 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) {
63
63
  var mergedStep = lastStep.step.merge(rebaseable.step);
64
64
  var _inverted = rebaseable.inverted.merge(lastStep.inverted);
65
65
  // Always take the origin of the new step.
@@ -1,18 +1,21 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
6
7
  import type { Mark } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { CollabEditPluginSharedState, CollabSendableSteps, PrivateCollabEditOptions } from './types';
10
+ export type CollabEditPluginDependencies = [
11
+ OptionalPlugin<FeatureFlagsPlugin>,
12
+ OptionalPlugin<AnalyticsPlugin>,
13
+ OptionalPlugin<EditorViewModePlugin>,
14
+ OptionalPlugin<ConnectivityPlugin>
15
+ ];
9
16
  export type CollabEditPlugin = NextEditorPlugin<'collabEdit', {
10
17
  pluginConfiguration: PrivateCollabEditOptions;
11
- dependencies: [
12
- OptionalPlugin<FeatureFlagsPlugin>,
13
- OptionalPlugin<AnalyticsPlugin>,
14
- OptionalPlugin<EditorViewModePlugin>
15
- ];
18
+ dependencies: CollabEditPluginDependencies;
16
19
  sharedState: CollabEditPluginSharedState;
17
20
  actions: {
18
21
  getAvatarColor: (str: string) => {
@@ -1,5 +1,7 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
2
3
  import type { Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { CollabEditPlugin } from '../collabEditPluginType';
3
5
  declare class LockableRebaseable {
4
6
  readonly step: LockableProseMirrorStep;
5
7
  readonly inverted: ProseMirrorStep;
@@ -20,5 +22,5 @@ declare abstract class LockableProseMirrorStep extends ProseMirrorStep {
20
22
  * @param steps Rebaseable steps
21
23
  * @returns Rebaseable steps
22
24
  */
23
- export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[]): LockableRebaseable[];
25
+ export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[], api: ExtractInjectionAPI<CollabEditPlugin> | undefined): LockableRebaseable[];
24
26
  export {};
@@ -1,18 +1,21 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
4
5
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
5
6
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
6
7
  import type { Mark } from '@atlaskit/editor-prosemirror/model';
7
8
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
8
9
  import type { CollabEditPluginSharedState, CollabSendableSteps, PrivateCollabEditOptions } from './types';
10
+ export type CollabEditPluginDependencies = [
11
+ OptionalPlugin<FeatureFlagsPlugin>,
12
+ OptionalPlugin<AnalyticsPlugin>,
13
+ OptionalPlugin<EditorViewModePlugin>,
14
+ OptionalPlugin<ConnectivityPlugin>
15
+ ];
9
16
  export type CollabEditPlugin = NextEditorPlugin<'collabEdit', {
10
17
  pluginConfiguration: PrivateCollabEditOptions;
11
- dependencies: [
12
- OptionalPlugin<FeatureFlagsPlugin>,
13
- OptionalPlugin<AnalyticsPlugin>,
14
- OptionalPlugin<EditorViewModePlugin>
15
- ];
18
+ dependencies: CollabEditPluginDependencies;
16
19
  sharedState: CollabEditPluginSharedState;
17
20
  actions: {
18
21
  getAvatarColor: (str: string) => {
@@ -1,5 +1,7 @@
1
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
1
2
  import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
2
3
  import type { Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
4
+ import type { CollabEditPlugin } from '../collabEditPluginType';
3
5
  declare class LockableRebaseable {
4
6
  readonly step: LockableProseMirrorStep;
5
7
  readonly inverted: ProseMirrorStep;
@@ -20,5 +22,5 @@ declare abstract class LockableProseMirrorStep extends ProseMirrorStep {
20
22
  * @param steps Rebaseable steps
21
23
  * @returns Rebaseable steps
22
24
  */
23
- export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[]): LockableRebaseable[];
25
+ export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[], api: ExtractInjectionAPI<CollabEditPlugin> | undefined): LockableRebaseable[];
24
26
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,9 +33,10 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^46.1.0",
35
35
  "@atlaskit/custom-steps": "^0.9.0",
36
- "@atlaskit/editor-common": "^99.0.0",
36
+ "@atlaskit/editor-common": "^99.3.0",
37
37
  "@atlaskit/editor-json-transformer": "^8.21.0",
38
- "@atlaskit/editor-plugin-analytics": "1.10.11",
38
+ "@atlaskit/editor-plugin-analytics": "1.10.12",
39
+ "@atlaskit/editor-plugin-connectivity": "^1.1.0",
39
40
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
40
41
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
41
42
  "@atlaskit/editor-prosemirror": "6.2.1",
@@ -52,7 +53,7 @@
52
53
  "devDependencies": {
53
54
  "@af/integration-testing": "*",
54
55
  "@af/visual-regression": "*",
55
- "@atlaskit/editor-plugin-mentions": "^2.11.0",
56
+ "@atlaskit/editor-plugin-mentions": "^2.13.0",
56
57
  "@atlaskit/editor-plugin-text-formatting": "^1.16.0",
57
58
  "@atlaskit/editor-plugin-type-ahead": "^1.11.0",
58
59
  "@atlaskit/editor-plugin-unsupported-content": "^1.9.0",