@atlaskit/prosemirror-collab 0.2.4 → 0.2.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
8
+
9
+ ## 0.2.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5f5ba16de66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f5ba16de66) - [ED-13910] Fix prosemirror types
14
+
3
15
  ## 0.2.4
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -11,7 +11,7 @@ exports.receiveTransaction = receiveTransaction;
11
11
  exports.sendableSteps = sendableSteps;
12
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
13
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
- var _prosemirrorState = require("prosemirror-state");
14
+ var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var Rebaseable = /*#__PURE__*/(0, _createClass2.default)(function Rebaseable(step, inverted, origin) {
16
16
  (0, _classCallCheck2.default)(this, Rebaseable);
17
17
  this.step = step;
@@ -72,7 +72,7 @@ function unconfirmedFrom(transform) {
72
72
  }
73
73
  return result;
74
74
  }
75
- var collabKey = new _prosemirrorState.PluginKey('collab');
75
+ var collabKey = new _state.PluginKey('collab');
76
76
  /// Creates a plugin that enables the collaborative editing framework
77
77
  /// for the editor.
78
78
  function collab() {
@@ -83,7 +83,7 @@ function collab() {
83
83
  // eslint-disable-next-line eqeqeq
84
84
  config.clientID == null ? Math.floor(Math.random() * 0xffffffff) : config.clientID
85
85
  };
86
- return new _prosemirrorState.Plugin({
86
+ return new _state.Plugin({
87
87
  key: collabKey,
88
88
  state: {
89
89
  init: function init() {
@@ -95,14 +95,11 @@ 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
  }
104
102
  },
105
- // @ts-expect-error
106
103
  config: conf,
107
104
  // This is used to notify the history plugin to not merge steps,
108
105
  // so that the history can be rebased.
@@ -121,7 +118,7 @@ function receiveTransaction(state, steps, clientIDs) {
121
118
  // appropriate. Remaining unconfirmed steps will be rebased over
122
119
  // remote steps.
123
120
  var collabState = collabKey.getState(state);
124
- var version = collabState.version + steps.length;
121
+ var version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
125
122
  var ourID = collabKey.get(state).spec.config.clientID;
126
123
 
127
124
  // Find out which prefix of the steps originated with us
@@ -130,7 +127,7 @@ function receiveTransaction(state, steps, clientIDs) {
130
127
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
131
128
  ++ours;
132
129
  }
133
- var unconfirmed = collabState.unconfirmed.slice(ours);
130
+ var unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
134
131
  steps = ours ? steps.slice(ours) : steps;
135
132
 
136
133
  // If all steps originated with us, we're done.
@@ -148,8 +145,8 @@ function receiveTransaction(state, steps, clientIDs) {
148
145
  unconfirmed = [];
149
146
  }
150
147
  var newCollabState = new CollabState(version, unconfirmed);
151
- if (options && options.mapSelectionBackward && state.selection instanceof _prosemirrorState.TextSelection) {
152
- tr.setSelection(_prosemirrorState.TextSelection.between(tr.doc.resolve(tr.mapping.map(state.selection.anchor, -1)), tr.doc.resolve(tr.mapping.map(state.selection.head, -1)), -1));
148
+ if (options && options.mapSelectionBackward && state.selection instanceof _state.TextSelection) {
149
+ tr.setSelection(_state.TextSelection.between(tr.doc.resolve(tr.mapping.map(state.selection.anchor, -1)), tr.doc.resolve(tr.mapping.map(state.selection.head, -1)), -1));
153
150
  tr.updated &= ~1;
154
151
  }
155
152
  return tr.setMeta('rebased', nUnconfirmed).setMeta('addToHistory', false).setMeta(collabKey, newCollabState);
@@ -166,6 +163,10 @@ function receiveTransaction(state, steps, clientIDs) {
166
163
  /// unchanged objects.
167
164
  function sendableSteps(state) {
168
165
  var collabState = collabKey.getState(state);
166
+ if (!collabState) {
167
+ return null;
168
+ }
169
+
169
170
  // eslint-disable-next-line eqeqeq
170
171
  if (collabState.unconfirmed.length == 0) {
171
172
  return null;
@@ -177,7 +178,7 @@ function sendableSteps(state) {
177
178
  }),
178
179
  clientID: collabKey.get(state).spec.config.clientID,
179
180
  get origins() {
180
- return this._origins || (this._origins = collabState.unconfirmed.map(function (s) {
181
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(function (s) {
181
182
  return s.origin;
182
183
  }));
183
184
  }
@@ -187,5 +188,6 @@ function sendableSteps(state) {
187
188
  /// Get the version up to which the collab plugin has synced with the
188
189
  /// central authority.
189
190
  function getVersion(state) {
190
- return collabKey.getState(state).version;
191
+ var _collabKey$getState;
192
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
191
193
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
1
+ import { Plugin, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  class Rebaseable {
3
3
  constructor(step, inverted, origin) {
4
4
  this.step = step;
@@ -83,14 +83,11 @@ 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
  }
92
90
  },
93
- // @ts-expect-error
94
91
  config: conf,
95
92
  // This is used to notify the history plugin to not merge steps,
96
93
  // so that the history can be rebased.
@@ -108,7 +105,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
108
105
  // appropriate. Remaining unconfirmed steps will be rebased over
109
106
  // remote steps.
110
107
  let collabState = collabKey.getState(state);
111
- let version = collabState.version + steps.length;
108
+ let version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
112
109
  let ourID = collabKey.get(state).spec.config.clientID;
113
110
 
114
111
  // Find out which prefix of the steps originated with us
@@ -117,7 +114,7 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
117
114
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
118
115
  ++ours;
119
116
  }
120
- let unconfirmed = collabState.unconfirmed.slice(ours);
117
+ let unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
121
118
  steps = ours ? steps.slice(ours) : steps;
122
119
 
123
120
  // If all steps originated with us, we're done.
@@ -153,6 +150,10 @@ export function receiveTransaction(state, steps, clientIDs, options = {}) {
153
150
  /// unchanged objects.
154
151
  export function sendableSteps(state) {
155
152
  let collabState = collabKey.getState(state);
153
+ if (!collabState) {
154
+ return null;
155
+ }
156
+
156
157
  // eslint-disable-next-line eqeqeq
157
158
  if (collabState.unconfirmed.length == 0) {
158
159
  return null;
@@ -162,7 +163,7 @@ export function sendableSteps(state) {
162
163
  steps: collabState.unconfirmed.map(s => s.step),
163
164
  clientID: collabKey.get(state).spec.config.clientID,
164
165
  get origins() {
165
- return this._origins || (this._origins = collabState.unconfirmed.map(s => s.origin));
166
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(s => s.origin));
166
167
  }
167
168
  };
168
169
  }
@@ -170,5 +171,6 @@ export function sendableSteps(state) {
170
171
  /// Get the version up to which the collab plugin has synced with the
171
172
  /// central authority.
172
173
  export function getVersion(state) {
173
- return collabKey.getState(state).version;
174
+ var _collabKey$getState;
175
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
174
176
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import { Plugin, PluginKey, TextSelection } from 'prosemirror-state';
3
+ import { Plugin, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  var Rebaseable = /*#__PURE__*/_createClass(function Rebaseable(step, inverted, origin) {
5
5
  _classCallCheck(this, Rebaseable);
6
6
  this.step = step;
@@ -84,14 +84,11 @@ 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
  }
93
91
  },
94
- // @ts-expect-error
95
92
  config: conf,
96
93
  // This is used to notify the history plugin to not merge steps,
97
94
  // so that the history can be rebased.
@@ -110,7 +107,7 @@ export function receiveTransaction(state, steps, clientIDs) {
110
107
  // appropriate. Remaining unconfirmed steps will be rebased over
111
108
  // remote steps.
112
109
  var collabState = collabKey.getState(state);
113
- var version = collabState.version + steps.length;
110
+ var version = ((collabState === null || collabState === void 0 ? void 0 : collabState.version) || 0) + steps.length;
114
111
  var ourID = collabKey.get(state).spec.config.clientID;
115
112
 
116
113
  // Find out which prefix of the steps originated with us
@@ -119,7 +116,7 @@ export function receiveTransaction(state, steps, clientIDs) {
119
116
  while (ours < clientIDs.length && clientIDs[ours] == ourID) {
120
117
  ++ours;
121
118
  }
122
- var unconfirmed = collabState.unconfirmed.slice(ours);
119
+ var unconfirmed = (collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.slice(ours)) || [];
123
120
  steps = ours ? steps.slice(ours) : steps;
124
121
 
125
122
  // If all steps originated with us, we're done.
@@ -155,6 +152,10 @@ export function receiveTransaction(state, steps, clientIDs) {
155
152
  /// unchanged objects.
156
153
  export function sendableSteps(state) {
157
154
  var collabState = collabKey.getState(state);
155
+ if (!collabState) {
156
+ return null;
157
+ }
158
+
158
159
  // eslint-disable-next-line eqeqeq
159
160
  if (collabState.unconfirmed.length == 0) {
160
161
  return null;
@@ -166,7 +167,7 @@ export function sendableSteps(state) {
166
167
  }),
167
168
  clientID: collabKey.get(state).spec.config.clientID,
168
169
  get origins() {
169
- return this._origins || (this._origins = collabState.unconfirmed.map(function (s) {
170
+ return this._origins || (this._origins = collabState === null || collabState === void 0 ? void 0 : collabState.unconfirmed.map(function (s) {
170
171
  return s.origin;
171
172
  }));
172
173
  }
@@ -176,5 +177,6 @@ export function sendableSteps(state) {
176
177
  /// Get the version up to which the collab plugin has synced with the
177
178
  /// central authority.
178
179
  export function getVersion(state) {
179
- return collabKey.getState(state).version;
180
+ var _collabKey$getState;
181
+ return ((_collabKey$getState = collabKey.getState(state)) === null || _collabKey$getState === void 0 ? void 0 : _collabKey$getState.version) || 0;
180
182
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/prosemirror-collab",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
- import { type EditorState, Plugin, type Transaction } from 'prosemirror-state';
2
- import type { Step as ProseMirrorStep, Transform as ProseMirrorTransform } from 'prosemirror-transform';
1
+ import { type EditorState, Plugin, type Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Step as ProseMirrorStep, Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
3
3
  declare class Rebaseable {
4
4
  readonly step: ProseMirrorStep;
5
5
  readonly inverted: 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[];
@@ -1,5 +1,5 @@
1
- import { type EditorState, Plugin, type Transaction } from 'prosemirror-state';
2
- import type { Step as ProseMirrorStep, Transform as ProseMirrorTransform } from 'prosemirror-transform';
1
+ import { type EditorState, Plugin, type Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { Step as ProseMirrorStep, Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
3
3
  declare class Rebaseable {
4
4
  readonly step: ProseMirrorStep;
5
5
  readonly inverted: 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.4",
3
+ "version": "0.2.6",
4
4
  "description": "Collaborative editing for ProseMirror - Atlassian Fork",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,19 +32,13 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@babel/runtime": "^7.0.0",
36
- "prosemirror-state": "1.3.4"
35
+ "@atlaskit/editor-prosemirror": "1.0.2",
36
+ "@babel/runtime": "^7.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@atlaskit/adf-schema": "^25.9.0",
40
- "@atlaskit/editor-test-helpers": "^18.7.0",
41
- "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
42
- "@types/prosemirror-history": "^1.0.1",
43
- "@types/prosemirror-model": "^1.11.0",
44
- "@types/prosemirror-transform": "^1.1.0",
45
- "prosemirror-history": "^1.1.3",
46
- "prosemirror-model": "1.16.0",
47
- "prosemirror-transform": "1.3.2"
39
+ "@atlaskit/adf-schema": "^26.4.0",
40
+ "@atlaskit/editor-test-helpers": "^18.10.0",
41
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0"
48
42
  },
49
43
  "techstack": {
50
44
  "@atlassian/frontend": {
package/report.api.md CHANGED
@@ -15,11 +15,11 @@
15
15
  <!--SECTION START: Main Entry Types-->
16
16
 
17
17
  ```ts
18
- import { EditorState } from 'prosemirror-state';
19
- import { Plugin as Plugin_2 } from 'prosemirror-state';
20
- import type { Step } from 'prosemirror-transform';
21
- import { Transaction } from 'prosemirror-state';
22
- import type { Transform } from 'prosemirror-transform';
18
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
19
+ import { Plugin as Plugin_2 } from '@atlaskit/editor-prosemirror/state';
20
+ import type { Step } from '@atlaskit/editor-prosemirror/transform';
21
+ import { Transaction } from '@atlaskit/editor-prosemirror/state';
22
+ import type { Transform } from '@atlaskit/editor-prosemirror/transform';
23
23
 
24
24
  // @public (undocumented)
25
25
  export function collab(config?: CollabConfig): Plugin_2;
@@ -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 | {
@@ -4,11 +4,11 @@
4
4
 
5
5
  ```ts
6
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';
7
+ import { EditorState } from '@atlaskit/editor-prosemirror/state';
8
+ import { Plugin as Plugin_2 } from '@atlaskit/editor-prosemirror/state';
9
+ import type { Step } from '@atlaskit/editor-prosemirror/transform';
10
+ import { Transaction } from '@atlaskit/editor-prosemirror/state';
11
+ import type { Transform } from '@atlaskit/editor-prosemirror/transform';
12
12
 
13
13
  // @public (undocumented)
14
14
  export function collab(config?: CollabConfig): Plugin_2;
@@ -39,7 +39,7 @@ export function rebaseSteps(steps: readonly Rebaseable[], over: readonly Step[],
39
39
  // @public (undocumented)
40
40
  export function receiveTransaction(state: EditorState, steps: readonly Step[], clientIDs: readonly (number | string)[], options?: {
41
41
  mapSelectionBackward?: boolean;
42
- }): Transaction<any>;
42
+ }): Transaction;
43
43
 
44
44
  // @public (undocumented)
45
45
  export function sendableSteps(state: EditorState): null | {