@atlaskit/prosemirror-collab 0.2.3 → 0.2.5

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,17 @@
1
1
  ## 1.3.0 (2022-05-30)
2
2
 
3
+ ## 0.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5f5ba16de66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f5ba16de66) - [ED-13910] Fix prosemirror types
8
+
9
+ ## 0.2.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`73b5128036b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73b5128036b) - [ED-17082] Mark package as a singleton one
14
+
3
15
  ## 0.2.3
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -95,9 +95,7 @@ function collab() {
95
95
  return newState;
96
96
  }
97
97
  if (tr.docChanged) {
98
- return new CollabState(collab.version,
99
- // @ts-expect-error
100
- collab.unconfirmed.concat(unconfirmedFrom(tr)));
98
+ return new CollabState(collab.version, collab.unconfirmed.concat(unconfirmedFrom(tr)));
101
99
  }
102
100
  return collab;
103
101
  }
@@ -121,7 +119,7 @@ function receiveTransaction(state, steps, clientIDs) {
121
119
  // appropriate. Remaining unconfirmed steps will be rebased over
122
120
  // remote steps.
123
121
  var collabState = collabKey.getState(state);
124
- var version = collabState.version + steps.length;
122
+ var version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
125
123
  var ourID = collabKey.get(state).spec.config.clientID;
126
124
 
127
125
  // Find out which prefix of the steps originated with us
@@ -130,7 +128,7 @@ function receiveTransaction(state, steps, clientIDs) {
130
128
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
131
129
  ++ours;
132
130
  }
133
- var unconfirmed = collabState.unconfirmed.slice(ours);
131
+ var unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
134
132
  steps = ours ? steps.slice(ours) : steps;
135
133
 
136
134
  // If all steps originated with us, we're done.
@@ -166,6 +164,10 @@ function receiveTransaction(state, steps, clientIDs) {
166
164
  /// unchanged objects.
167
165
  function sendableSteps(state) {
168
166
  var collabState = collabKey.getState(state);
167
+ if (!collabState) {
168
+ return null;
169
+ }
170
+
169
171
  // eslint-disable-next-line eqeqeq
170
172
  if (collabState.unconfirmed.length == 0) {
171
173
  return null;
@@ -177,7 +179,7 @@ function sendableSteps(state) {
177
179
  }),
178
180
  clientID: collabKey.get(state).spec.config.clientID,
179
181
  get origins() {
180
- return this._origins || (this._origins = collabState.unconfirmed.map(function (s) {
182
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(function (s) {
181
183
  return s.origin;
182
184
  }));
183
185
  }
@@ -187,5 +189,6 @@ function sendableSteps(state) {
187
189
  /// Get the version up to which the collab plugin has synced with the
188
190
  /// central authority.
189
191
  function getVersion(state) {
190
- return collabKey.getState(state).version;
192
+ var _collabKey$getState;
193
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
191
194
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "sideEffects": false
5
5
  }
@@ -83,9 +83,7 @@ export function collab(config = {}) {
83
83
  return newState;
84
84
  }
85
85
  if (tr.docChanged) {
86
- return new CollabState(collab.version,
87
- // @ts-expect-error
88
- collab.unconfirmed.concat(unconfirmedFrom(tr)));
86
+ return new CollabState(collab.version, collab.unconfirmed.concat(unconfirmedFrom(tr)));
89
87
  }
90
88
  return collab;
91
89
  }
@@ -108,7 +106,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
108
106
  // appropriate. Remaining unconfirmed steps will be rebased over
109
107
  // remote steps.
110
108
  let collabState = collabKey.getState(state);
111
- let version = collabState.version + steps.length;
109
+ let version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
112
110
  let ourID = collabKey.get(state).spec.config.clientID;
113
111
 
114
112
  // Find out which prefix of the steps originated with us
@@ -117,7 +115,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
117
115
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
118
116
  ++ours;
119
117
  }
120
- let unconfirmed = collabState.unconfirmed.slice(ours);
118
+ let unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
121
119
  steps = ours ? steps.slice(ours) : steps;
122
120
 
123
121
  // If all steps originated with us, we're done.
@@ -153,6 +151,10 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
153
151
  /// unchanged objects.
154
152
  export function sendableSteps(state) {
155
153
  let collabState = collabKey.getState(state);
154
+ if (!collabState) {
155
+ return null;
156
+ }
157
+
156
158
  // eslint-disable-next-line eqeqeq
157
159
  if (collabState.unconfirmed.length == 0) {
158
160
  return null;
@@ -162,7 +164,7 @@ export function sendableSteps(state) {
162
164
  steps: collabState.unconfirmed.map(s => s.step),
163
165
  clientID: collabKey.get(state).spec.config.clientID,
164
166
  get origins() {
165
- return this._origins || (this._origins = collabState.unconfirmed.map(s => s.origin));
167
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(s => s.origin));
166
168
  }
167
169
  };
168
170
  }
@@ -170,5 +172,6 @@ export function sendableSteps(state) {
170
172
  /// Get the version up to which the collab plugin has synced with the
171
173
  /// central authority.
172
174
  export function getVersion(state) {
173
- return collabKey.getState(state).version;
175
+ var _collabKey$getState;
176
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
174
177
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -84,9 +84,7 @@ export function collab() {
84
84
  return newState;
85
85
  }
86
86
  if (tr.docChanged) {
87
- return new CollabState(collab.version,
88
- // @ts-expect-error
89
- collab.unconfirmed.concat(unconfirmedFrom(tr)));
87
+ return new CollabState(collab.version, collab.unconfirmed.concat(unconfirmedFrom(tr)));
90
88
  }
91
89
  return collab;
92
90
  }
@@ -110,7 +108,7 @@ export function receiveTransaction(state, steps, clientIDs) {
110
108
  // appropriate. Remaining unconfirmed steps will be rebased over
111
109
  // remote steps.
112
110
  var collabState = collabKey.getState(state);
113
- var version = collabState.version + steps.length;
111
+ var version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
114
112
  var ourID = collabKey.get(state).spec.config.clientID;
115
113
 
116
114
  // Find out which prefix of the steps originated with us
@@ -119,7 +117,7 @@ export function receiveTransaction(state, steps, clientIDs) {
119
117
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
120
118
  ++ours;
121
119
  }
122
- var unconfirmed = collabState.unconfirmed.slice(ours);
120
+ var unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
123
121
  steps = ours ? steps.slice(ours) : steps;
124
122
 
125
123
  // If all steps originated with us, we're done.
@@ -155,6 +153,10 @@ export function receiveTransaction(state, steps, clientIDs) {
155
153
  /// unchanged objects.
156
154
  export function sendableSteps(state) {
157
155
  var collabState = collabKey.getState(state);
156
+ if (!collabState) {
157
+ return null;
158
+ }
159
+
158
160
  // eslint-disable-next-line eqeqeq
159
161
  if (collabState.unconfirmed.length == 0) {
160
162
  return null;
@@ -166,7 +168,7 @@ export function sendableSteps(state) {
166
168
  }),
167
169
  clientID: collabKey.get(state).spec.config.clientID,
168
170
  get origins() {
169
- return this._origins || (this._origins = collabState.unconfirmed.map(function (s) {
171
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(function (s) {
170
172
  return s.origin;
171
173
  }));
172
174
  }
@@ -176,5 +178,6 @@ export function sendableSteps(state) {
176
178
  /// Get the version up to which the collab plugin has synced with the
177
179
  /// central authority.
178
180
  export function getVersion(state) {
179
- return collabKey.getState(state).version;
181
+ var _collabKey$getState;
182
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
180
183
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "sideEffects": false
5
5
  }
@@ -14,7 +14,7 @@ type CollabConfig = {
14
14
  export declare function collab(config?: CollabConfig): Plugin;
15
15
  export declare function receiveTransaction(state: EditorState, steps: readonly ProseMirrorStep[], clientIDs: readonly (string | number)[], options?: {
16
16
  mapSelectionBackward?: boolean;
17
- }): Transaction<any>;
17
+ }): Transaction;
18
18
  export declare function sendableSteps(state: EditorState): {
19
19
  version: number;
20
20
  steps: readonly ProseMirrorStep[];
@@ -14,7 +14,7 @@ type CollabConfig = {
14
14
  export declare function collab(config?: CollabConfig): Plugin;
15
15
  export declare function receiveTransaction(state: EditorState, steps: readonly ProseMirrorStep[], clientIDs: readonly (string | number)[], options?: {
16
16
  mapSelectionBackward?: boolean;
17
- }): Transaction<any>;
17
+ }): Transaction;
18
18
  export declare function sendableSteps(state: EditorState): {
19
19
  version: number;
20
20
  steps: readonly ProseMirrorStep[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Collaborative editing for ProseMirror - Atlassian Fork",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -24,8 +24,9 @@
24
24
  "atlaskit:src": "src/index.ts",
25
25
  "atlassian": {
26
26
  "team": "Editor Services",
27
+ "singleton": true,
27
28
  "inPublicMirror": true,
28
- "releaseModel": "scheduled"
29
+ "releaseModel": "continuous"
29
30
  },
30
31
  "af:exports": {
31
32
  ".": "./src/index.ts"
@@ -35,12 +36,9 @@
35
36
  "prosemirror-state": "1.3.4"
36
37
  },
37
38
  "devDependencies": {
38
- "@atlaskit/adf-schema": "^25.6.0",
39
- "@atlaskit/editor-test-helpers": "^18.3.0",
39
+ "@atlaskit/adf-schema": "^26.0.0",
40
+ "@atlaskit/editor-test-helpers": "^18.8.0",
40
41
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
41
- "@types/prosemirror-history": "^1.0.1",
42
- "@types/prosemirror-model": "^1.11.0",
43
- "@types/prosemirror-transform": "^1.1.0",
44
42
  "prosemirror-history": "^1.1.3",
45
43
  "prosemirror-model": "1.16.0",
46
44
  "prosemirror-transform": "1.3.2"
package/report.api.md CHANGED
@@ -59,7 +59,7 @@ export function receiveTransaction(
59
59
  options?: {
60
60
  mapSelectionBackward?: boolean;
61
61
  },
62
- ): Transaction<any>;
62
+ ): Transaction;
63
63
 
64
64
  // @public (undocumented)
65
65
  export function sendableSteps(state: EditorState): null | {
@@ -0,0 +1,54 @@
1
+ ## API Report File for "@atlaskit/prosemirror-collab"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { EditorState } from 'prosemirror-state';
8
+ import { Plugin as Plugin_2 } from 'prosemirror-state';
9
+ import type { Step } from 'prosemirror-transform';
10
+ import { Transaction } from 'prosemirror-state';
11
+ import type { Transform } from 'prosemirror-transform';
12
+
13
+ // @public (undocumented)
14
+ export function collab(config?: CollabConfig): Plugin_2;
15
+
16
+ // @public (undocumented)
17
+ type CollabConfig = {
18
+ version?: number;
19
+ clientID?: null | number | string;
20
+ };
21
+
22
+ // @public (undocumented)
23
+ export function getVersion(state: EditorState): number;
24
+
25
+ // @public (undocumented)
26
+ class Rebaseable {
27
+ constructor(step: Step, inverted: Step, origin: Transform);
28
+ // (undocumented)
29
+ readonly inverted: Step;
30
+ // (undocumented)
31
+ readonly origin: Transform;
32
+ // (undocumented)
33
+ readonly step: Step;
34
+ }
35
+
36
+ // @public (undocumented)
37
+ export function rebaseSteps(steps: readonly Rebaseable[], over: readonly Step[], transform: Transform): Rebaseable[];
38
+
39
+ // @public (undocumented)
40
+ export function receiveTransaction(state: EditorState, steps: readonly Step[], clientIDs: readonly (number | string)[], options?: {
41
+ mapSelectionBackward?: boolean;
42
+ }): Transaction;
43
+
44
+ // @public (undocumented)
45
+ export function sendableSteps(state: EditorState): null | {
46
+ version: number;
47
+ steps: readonly Step[];
48
+ clientID: number | string;
49
+ origins: readonly Transaction[];
50
+ };
51
+
52
+ // (No @packageDocumentation comment for this package)
53
+
54
+ ```