@atlaskit/editor-plugin-collab-edit 2.0.1 → 2.1.0
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 +24 -0
- package/dist/cjs/collabEditPlugin.js +21 -2
- package/dist/cjs/pm-plugins/actions.js +14 -2
- package/dist/cjs/pm-plugins/analytics.js +6 -1
- package/dist/cjs/pm-plugins/events/handlers.js +12 -1
- package/dist/cjs/pm-plugins/events/initialize.js +4 -1
- package/dist/cjs/pm-plugins/main/index.js +13 -1
- package/dist/cjs/pm-plugins/main/plugin-state.js +24 -4
- package/dist/cjs/pm-plugins/mergeUnconfirmed.js +85 -0
- package/dist/cjs/pm-plugins/utils.js +53 -25
- package/dist/es2019/collabEditPlugin.js +20 -2
- package/dist/es2019/pm-plugins/actions.js +12 -2
- package/dist/es2019/pm-plugins/analytics.js +6 -1
- package/dist/es2019/pm-plugins/events/handlers.js +13 -1
- package/dist/es2019/pm-plugins/events/initialize.js +4 -1
- package/dist/es2019/pm-plugins/main/index.js +13 -1
- package/dist/es2019/pm-plugins/main/plugin-state.js +24 -4
- package/dist/es2019/pm-plugins/mergeUnconfirmed.js +66 -0
- package/dist/es2019/pm-plugins/utils.js +56 -29
- package/dist/esm/collabEditPlugin.js +21 -2
- package/dist/esm/pm-plugins/actions.js +12 -2
- package/dist/esm/pm-plugins/analytics.js +6 -1
- package/dist/esm/pm-plugins/events/handlers.js +13 -1
- package/dist/esm/pm-plugins/events/initialize.js +4 -1
- package/dist/esm/pm-plugins/main/index.js +13 -1
- package/dist/esm/pm-plugins/main/plugin-state.js +24 -4
- package/dist/esm/pm-plugins/mergeUnconfirmed.js +78 -0
- package/dist/esm/pm-plugins/utils.js +54 -27
- package/dist/types/collabEditPluginType.d.ts +2 -2
- package/dist/types/pm-plugins/main/plugin-state.d.ts +1 -0
- package/dist/types/pm-plugins/mergeUnconfirmed.d.ts +24 -0
- package/dist/types/pm-plugins/utils.d.ts +3 -2
- package/dist/types-ts4.5/collabEditPluginType.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main/plugin-state.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/mergeUnconfirmed.d.ts +24 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +3 -2
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-collab-edit
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#98820](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98820)
|
|
8
|
+
[`9f7dc3ba5d256`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9f7dc3ba5d256) -
|
|
9
|
+
[ux] Update the potential list of colors for avatar badges and telepointers within the editor.
|
|
10
|
+
Also add support for using presenceId over sessionId, when presenceId exists, in order to make the
|
|
11
|
+
avatar badge and telepointer color selection.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 2.0.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [#97210](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97210)
|
|
22
|
+
[`c1744e14e854d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c1744e14e854d) -
|
|
23
|
+
Use transformUnconfirmed from collab prosemirror plugin to merge unconfirmed steps while offline
|
|
24
|
+
to reduce payload.
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 2.0.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -12,11 +12,13 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
14
14
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
|
|
16
17
|
var _analytics2 = require("./pm-plugins/analytics");
|
|
17
18
|
var _sendTransaction = require("./pm-plugins/events/send-transaction");
|
|
18
19
|
var _main = require("./pm-plugins/main");
|
|
19
20
|
var _pluginKey = require("./pm-plugins/main/plugin-key");
|
|
21
|
+
var _mergeUnconfirmed = require("./pm-plugins/mergeUnconfirmed");
|
|
20
22
|
var _nativeCollabProviderPlugin = require("./pm-plugins/native-collab-provider-plugin");
|
|
21
23
|
var _trackAndFilterSpammingSteps = require("./pm-plugins/track-and-filter-spamming-steps");
|
|
22
24
|
var _trackLastOrganicChange = require("./pm-plugins/track-last-organic-change");
|
|
@@ -151,16 +153,32 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
|
|
|
151
153
|
},
|
|
152
154
|
getCurrentCollabState: function getCurrentCollabState() {
|
|
153
155
|
var _getCollabState;
|
|
156
|
+
// Ignored via go/ees005
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
154
158
|
var adfDocument = new _editorJsonTransformer.JSONTransformer().encode(editorViewRef.current.state.doc);
|
|
155
159
|
return {
|
|
156
160
|
content: adfDocument,
|
|
161
|
+
// Ignored via go/ees005
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
157
163
|
version: ((_getCollabState = (0, _prosemirrorCollab.getCollabState)(editorViewRef.current.state)) === null || _getCollabState === void 0 ? void 0 : _getCollabState.version) || 0,
|
|
164
|
+
// Ignored via go/ees005
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
158
166
|
sendableSteps: (0, _prosemirrorCollab.sendableSteps)(editorViewRef.current.state)
|
|
159
167
|
};
|
|
160
168
|
},
|
|
169
|
+
// Ignored via go/ees005
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
171
|
validatePMJSONDocument: function validatePMJSONDocument(doc) {
|
|
172
|
+
// Ignored via go/ees005
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
162
174
|
var content = (doc.content || []).map(function (child) {
|
|
163
|
-
return
|
|
175
|
+
return (
|
|
176
|
+
// Ignored via go/ees005
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
178
|
+
// Ignored via go/ees005
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
180
|
+
editorViewRef.current.state.schema.nodeFromJSON(child)
|
|
181
|
+
);
|
|
164
182
|
});
|
|
165
183
|
return content.every(function (node) {
|
|
166
184
|
try {
|
|
@@ -182,7 +200,8 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
|
|
|
182
200
|
name: 'pmCollab',
|
|
183
201
|
plugin: function plugin() {
|
|
184
202
|
return (0, _prosemirrorCollab.collab)({
|
|
185
|
-
clientID: userId
|
|
203
|
+
clientID: userId,
|
|
204
|
+
transformUnconfirmed: (0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps') ? _mergeUnconfirmed.mergeUnconfirmedSteps : undefined
|
|
186
205
|
});
|
|
187
206
|
}
|
|
188
207
|
}, {
|
|
@@ -13,6 +13,12 @@ var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
|
|
|
13
13
|
var _utils = require("./utils");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
// Ignored via go/ees005
|
|
17
|
+
// eslint-disable-next-line import/no-namespace
|
|
18
|
+
|
|
19
|
+
// Ignored via go/ees005
|
|
20
|
+
// eslint-disable-next-line import/no-namespace
|
|
21
|
+
|
|
16
22
|
/*
|
|
17
23
|
* This is a non-op function to force ProseMirror to load and register all custom steps in the same bundle
|
|
18
24
|
*/
|
|
@@ -20,7 +26,10 @@ var registerAllCustomSteps = exports.registerAllCustomSteps = function registerA
|
|
|
20
26
|
Object.entries(allAtlaskitCustomSteps).forEach(function () {});
|
|
21
27
|
Object.entries(allAdfSchemaSteps).forEach(function () {});
|
|
22
28
|
};
|
|
23
|
-
var handleInit = exports.handleInit = function handleInit(initData, view, options, editorAnalyticsApi
|
|
29
|
+
var handleInit = exports.handleInit = function handleInit(initData, view, options, editorAnalyticsApi
|
|
30
|
+
// Ignored via go/ees005
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
|
+
) {
|
|
24
33
|
var doc = initData.doc,
|
|
25
34
|
json = initData.json,
|
|
26
35
|
version = initData.version,
|
|
@@ -75,7 +84,10 @@ var applyRemoteData = exports.applyRemoteData = function applyRemoteData(remoteD
|
|
|
75
84
|
applyRemoteSteps(json, view, userIds, options);
|
|
76
85
|
}
|
|
77
86
|
};
|
|
78
|
-
var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json, view, userIds, options
|
|
87
|
+
var applyRemoteSteps = exports.applyRemoteSteps = function applyRemoteSteps(json, view, userIds, options
|
|
88
|
+
// Ignored via go/ees005
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
90
|
+
) {
|
|
79
91
|
if (!json || !json.length) {
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
@@ -7,7 +7,10 @@ exports.addSynchronyErrorAnalytics = exports.addSynchronyEntityAnalytics = void
|
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
|
-
var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function addSynchronyErrorAnalytics(state, tr, featureFlags, editorAnalyticsApi
|
|
10
|
+
var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function addSynchronyErrorAnalytics(state, tr, featureFlags, editorAnalyticsApi
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
13
|
+
) {
|
|
11
14
|
return function (error) {
|
|
12
15
|
var browserExtensions = (0, _utils.sniffUserBrowserExtensions)({
|
|
13
16
|
extensions: ['grammarly']
|
|
@@ -22,6 +25,8 @@ var addSynchronyErrorAnalytics = exports.addSynchronyErrorAnalytics = function a
|
|
|
22
25
|
}
|
|
23
26
|
};
|
|
24
27
|
if (featureFlags.synchronyErrorDocStructure) {
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
30
|
payload.attributes.docStructure = (0, _coreUtils.getDocStructure)(state.doc, {
|
|
26
31
|
compact: true
|
|
27
32
|
});
|
|
@@ -6,6 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.subscribe = void 0;
|
|
7
7
|
var _actions = require("../actions");
|
|
8
8
|
var _analytics = require("../analytics");
|
|
9
|
+
// Ignored via go/ees005
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
|
|
12
|
+
// Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
17
|
var effect = function effect(fn, eq) {
|
|
10
18
|
var previousDeps;
|
|
11
19
|
var cleanup;
|
|
@@ -21,7 +29,10 @@ var effect = function effect(fn, eq) {
|
|
|
21
29
|
return cleanup;
|
|
22
30
|
};
|
|
23
31
|
};
|
|
24
|
-
var subscribe = exports.subscribe = effect(
|
|
32
|
+
var subscribe = exports.subscribe = effect(
|
|
33
|
+
// Ignored via go/ees005
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
35
|
+
function (view, provider, options, featureFlags, _providerFactory, editorAnalyticsApi) {
|
|
25
36
|
var entityRef;
|
|
26
37
|
var entityHandlers = {
|
|
27
38
|
disconnectedHandler: function disconnectedHandler() {
|
|
@@ -18,7 +18,10 @@ var initCollab = function initCollab(collabEditProvider, view) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
var initNewCollab = function initNewCollab(collabEditProvider, view, editorApi, onSyncUpError
|
|
21
|
+
var initNewCollab = function initNewCollab(collabEditProvider, view, editorApi, onSyncUpError
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
24
|
+
) {
|
|
22
25
|
collabEditProvider.setup({
|
|
23
26
|
getState: function getState() {
|
|
24
27
|
return view.state;
|
|
@@ -18,7 +18,12 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
// It is important to get all steps in that package
|
|
20
20
|
|
|
21
|
+
// Ignored via go/ees005
|
|
22
|
+
// eslint-disable-next-line import/no-namespace
|
|
23
|
+
|
|
21
24
|
// It is important to get all steps in that package
|
|
25
|
+
// Ignored via go/ees005
|
|
26
|
+
// eslint-disable-next-line import/no-namespace
|
|
22
27
|
|
|
23
28
|
var enforceCustomStepRegisters = function enforceCustomStepRegisters() {
|
|
24
29
|
var tryToRegisterStep = function tryToRegisterStep(obj) {
|
|
@@ -49,14 +54,21 @@ var enforceCustomStepRegisters = function enforceCustomStepRegisters() {
|
|
|
49
54
|
// @ts-expect-error
|
|
50
55
|
tryToRegisterStep(adfCustomSteps);
|
|
51
56
|
};
|
|
52
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi
|
|
57
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatch, providerFactory, providerResolver, collabProviderCallback, options, featureFlags, pluginInjectionApi
|
|
58
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
60
|
+
) {
|
|
53
61
|
enforceCustomStepRegisters();
|
|
54
62
|
return new _safePlugin.SafePlugin({
|
|
55
63
|
key: _pluginKey.pluginKey,
|
|
56
64
|
state: {
|
|
65
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
67
|
init: function init(config) {
|
|
58
68
|
return _pluginState.PluginState.init(config);
|
|
59
69
|
},
|
|
70
|
+
// Ignored via go/ees005
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
60
72
|
apply: function apply(transaction, prevPluginState, _oldEditorState, _newEditorState) {
|
|
61
73
|
var pluginState = prevPluginState.apply(transaction);
|
|
62
74
|
dispatch(_pluginKey.pluginKey, pluginState);
|
|
@@ -29,6 +29,8 @@ var getValidPos = exports.getValidPos = function getValidPos(tr, pos) {
|
|
|
29
29
|
return endOfDocPos;
|
|
30
30
|
};
|
|
31
31
|
var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
32
|
+
// Ignored via go/ees005
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
32
34
|
function PluginState(decorations, participants, sessionId) {
|
|
33
35
|
var collabInitalised = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
34
36
|
var onError = arguments.length > 4 ? arguments[4] : undefined;
|
|
@@ -64,6 +66,13 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
64
66
|
var participant = this.participants.get(sessionId);
|
|
65
67
|
return participant ? participant.name.substring(0, 1).toUpperCase() : 'X';
|
|
66
68
|
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "getPresenceId",
|
|
71
|
+
value: function getPresenceId(sessionId) {
|
|
72
|
+
var _participant$presence;
|
|
73
|
+
var participant = this.participants.get(sessionId);
|
|
74
|
+
return (_participant$presence = participant === null || participant === void 0 ? void 0 : participant.presenceId) !== null && _participant$presence !== void 0 ? _participant$presence : sessionId;
|
|
75
|
+
}
|
|
67
76
|
}, {
|
|
68
77
|
key: "apply",
|
|
69
78
|
value: function apply(tr) {
|
|
@@ -104,7 +113,7 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
104
113
|
if (telepointerData) {
|
|
105
114
|
var sessionId = telepointerData.sessionId;
|
|
106
115
|
if (participants.get(sessionId) && sessionId !== sid) {
|
|
107
|
-
var oldPointers = (0, _utils.findPointers)(
|
|
116
|
+
var oldPointers = (0, _utils.findPointers)(sessionId, this.decorationSet);
|
|
108
117
|
if (oldPointers) {
|
|
109
118
|
remove = remove.concat(oldPointers);
|
|
110
119
|
}
|
|
@@ -128,7 +137,7 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
128
137
|
} catch (err) {
|
|
129
138
|
this.onError(err);
|
|
130
139
|
}
|
|
131
|
-
add = add.concat((0, _utils.createTelepointers)(from, to, sessionId, isSelection, this.getInitial(sessionId)));
|
|
140
|
+
add = add.concat((0, _utils.createTelepointers)(from, to, sessionId, isSelection, this.getInitial(sessionId), this.getPresenceId(sessionId)));
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
143
|
if (tr.docChanged) {
|
|
@@ -140,12 +149,14 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
140
149
|
if (spec.pointer && spec.pointer.sessionId && spec.key === "telepointer-".concat(spec.pointer.sessionId)) {
|
|
141
150
|
var step = tr.steps.filter(_utils.isReplaceStep)[0];
|
|
142
151
|
if (step) {
|
|
143
|
-
var
|
|
152
|
+
var _spec$pointer = spec.pointer,
|
|
153
|
+
_sessionId = _spec$pointer.sessionId,
|
|
154
|
+
presenceId = _spec$pointer.presenceId;
|
|
144
155
|
var _ref = step,
|
|
145
156
|
size = _ref.slice.content.size,
|
|
146
157
|
_from = _ref.from;
|
|
147
158
|
var pos = getValidPos(tr, size ? Math.min(_from + size, tr.doc.nodeSize - 3) : Math.max(_from, 1));
|
|
148
|
-
add = add.concat((0, _utils.createTelepointers)(pos, pos, _sessionId, false, _this.getInitial(_sessionId)));
|
|
159
|
+
add = add.concat((0, _utils.createTelepointers)(pos, pos, _sessionId, false, _this.getInitial(_sessionId), presenceId));
|
|
149
160
|
}
|
|
150
161
|
}
|
|
151
162
|
}
|
|
@@ -157,9 +168,13 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
157
168
|
// Remove any selection decoration within the change range,
|
|
158
169
|
// takes care of the issue when after pasting we end up with a dead selection
|
|
159
170
|
tr.steps.filter(_utils.isReplaceStep).forEach(function (s) {
|
|
171
|
+
// Ignored via go/ees005
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
173
|
var _ref2 = s,
|
|
161
174
|
from = _ref2.from,
|
|
162
175
|
to = _ref2.to;
|
|
176
|
+
// Ignored via go/ees005
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
178
|
_this.decorationSet.find(from, to).forEach(function (deco) {
|
|
164
179
|
// `type` is private, `from` and `to` are public in latest version
|
|
165
180
|
// `from` != `to` means it's a selection
|
|
@@ -170,6 +185,8 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
170
185
|
});
|
|
171
186
|
}
|
|
172
187
|
var selection = tr.selection;
|
|
188
|
+
// Ignored via go/ees005
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
190
|
this.decorationSet.find().forEach(function (deco) {
|
|
174
191
|
if (deco.type.toDOM) {
|
|
175
192
|
var hasTelepointerDimClass = deco.type.toDOM.classList.contains(_collab.TELEPOINTER_DIM_CLASS);
|
|
@@ -218,6 +235,9 @@ var PluginState = exports.PluginState = /*#__PURE__*/function () {
|
|
|
218
235
|
value: function eq(a, b) {
|
|
219
236
|
return a.participants === b.participants && a.sessionId === b.sessionId && a.isReady === b.isReady;
|
|
220
237
|
}
|
|
238
|
+
|
|
239
|
+
// Ignored via go/ees005
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
221
241
|
}, {
|
|
222
242
|
key: "init",
|
|
223
243
|
value: function init(config) {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.mergeUnconfirmedSteps = mergeUnconfirmedSteps;
|
|
8
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
9
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
10
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
14
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
15
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
+
function isLockable(step) {
|
|
17
|
+
return (step === null || step === void 0 ? void 0 : step.lockStep) !== undefined;
|
|
18
|
+
}
|
|
19
|
+
var createLockableProseMirrorStep = function createLockableProseMirrorStep(step) {
|
|
20
|
+
var stepIsLocked = false;
|
|
21
|
+
if (isLockable(step)) {
|
|
22
|
+
return step;
|
|
23
|
+
}
|
|
24
|
+
return new Proxy(step, {
|
|
25
|
+
get: function get(target, prop, receiver) {
|
|
26
|
+
if (prop === 'lockStep') {
|
|
27
|
+
return function () {
|
|
28
|
+
stepIsLocked = true;
|
|
29
|
+
};
|
|
30
|
+
} else if (prop === 'isLocked') {
|
|
31
|
+
return function () {
|
|
32
|
+
return stepIsLocked;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return Reflect.get(target, prop, receiver);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Based on: `packages/editor/prosemirror-collab/src/index.ts`
|
|
41
|
+
var LockableRebaseable = /*#__PURE__*/(0, _createClass2.default)(function LockableRebaseable(step, inverted, origin) {
|
|
42
|
+
(0, _classCallCheck2.default)(this, LockableRebaseable);
|
|
43
|
+
this.step = step;
|
|
44
|
+
this.inverted = inverted;
|
|
45
|
+
this.origin = origin;
|
|
46
|
+
});
|
|
47
|
+
var LockableProseMirrorStep = /*#__PURE__*/function (_ProseMirrorStep) {
|
|
48
|
+
function LockableProseMirrorStep() {
|
|
49
|
+
(0, _classCallCheck2.default)(this, LockableProseMirrorStep);
|
|
50
|
+
return _callSuper(this, LockableProseMirrorStep, arguments);
|
|
51
|
+
}
|
|
52
|
+
(0, _inherits2.default)(LockableProseMirrorStep, _ProseMirrorStep);
|
|
53
|
+
return (0, _createClass2.default)(LockableProseMirrorStep);
|
|
54
|
+
}(_transform.Step);
|
|
55
|
+
/**
|
|
56
|
+
* Merge a set of steps together to reduce the total number of steps stored in memory.
|
|
57
|
+
*
|
|
58
|
+
* All steps passing through here should be "lockable" (ie. can be locked by the document service)
|
|
59
|
+
* so that it can be indicated they have already been sent (or are about to be sent) to the backend
|
|
60
|
+
* and cannot be merged.
|
|
61
|
+
*
|
|
62
|
+
* @param steps Rebaseable steps
|
|
63
|
+
* @returns Rebaseable steps
|
|
64
|
+
*/
|
|
65
|
+
function mergeUnconfirmedSteps(steps) {
|
|
66
|
+
var mergedSteps = steps.reduce(function (acc, rebaseable) {
|
|
67
|
+
var _lastStep$step$isLock, _lastStep$step, _rebaseable$step$isLo, _rebaseable$step;
|
|
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) {
|
|
70
|
+
var mergedStep = lastStep.step.merge(rebaseable.step);
|
|
71
|
+
var _inverted = rebaseable.inverted.merge(lastStep.inverted);
|
|
72
|
+
// Always take the origin of the new step.
|
|
73
|
+
// We use this in packages/editor/collab-provider/src/document/document-service.ts:commitUnconfirmedSteps
|
|
74
|
+
// to confirm that the last transaction has been sent. Since we're taking the latest this still works as expected
|
|
75
|
+
// As we want to wait until all the transactions have been pushed through
|
|
76
|
+
var _origin = lastStep.origin;
|
|
77
|
+
if (mergedStep && _inverted) {
|
|
78
|
+
acc[acc.length - 1] = new LockableRebaseable(createLockableProseMirrorStep(mergedStep), _inverted, _origin);
|
|
79
|
+
return acc;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return acc.concat(new LockableRebaseable(createLockableProseMirrorStep(rebaseable.step), rebaseable.inverted, rebaseable.origin));
|
|
83
|
+
}, []);
|
|
84
|
+
return mergedSteps;
|
|
85
|
+
}
|
|
@@ -15,10 +15,13 @@ var _whitespace = require("@atlaskit/editor-common/whitespace");
|
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
17
17
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
18
|
-
var
|
|
18
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
20
|
var findPointers = exports.findPointers = function findPointers(id, decorations) {
|
|
21
|
-
return decorations.find()
|
|
21
|
+
return decorations.find()
|
|
22
|
+
// Ignored via go/ees005
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
.reduce(function (arr, deco) {
|
|
22
25
|
return deco.spec.pointer.sessionId === id ? arr.concat(deco) : arr;
|
|
23
26
|
}, []);
|
|
24
27
|
};
|
|
@@ -27,31 +30,32 @@ function style(options) {
|
|
|
27
30
|
return "border-right: 2px solid ".concat(color, "; margin-right: -2px;");
|
|
28
31
|
}
|
|
29
32
|
function getAvatarColor(str) {
|
|
30
|
-
var
|
|
31
|
-
for (var i = 0; i < str.length; i++) {
|
|
32
|
-
/* eslint-disable no-bitwise */
|
|
33
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
34
|
-
hash = hash & hash;
|
|
35
|
-
/* eslint-enable no-bitwise */
|
|
36
|
-
}
|
|
37
|
-
var index = Math.abs(hash) % _consts.avatarColors.length;
|
|
33
|
+
var participantColor = (0, _editorSharedStyles.getParticipantColor)(str);
|
|
38
34
|
return {
|
|
39
|
-
index: index,
|
|
40
|
-
|
|
35
|
+
index: participantColor.index,
|
|
36
|
+
backgroundColor: participantColor.color.backgroundColor,
|
|
37
|
+
textColor: participantColor.color.textColor
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
|
-
var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial
|
|
40
|
+
var createTelepointers = exports.createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial, presenceId
|
|
41
|
+
// Ignored via go/ees005
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
43
|
+
) {
|
|
44
44
|
var decorations = [];
|
|
45
|
-
var avatarColor = getAvatarColor(
|
|
45
|
+
var avatarColor = getAvatarColor(presenceId);
|
|
46
46
|
var color = avatarColor.index.toString();
|
|
47
47
|
if (isSelection) {
|
|
48
48
|
var className = "telepointer color-".concat(color, " telepointer-selection");
|
|
49
|
-
decorations.push(
|
|
49
|
+
decorations.push(
|
|
50
|
+
// Ignored via go/ees005
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
_view.Decoration.inline(from, to, {
|
|
50
53
|
class: className,
|
|
51
54
|
'data-initial': initial
|
|
52
55
|
}, {
|
|
53
56
|
pointer: {
|
|
54
|
-
sessionId: sessionId
|
|
57
|
+
sessionId: sessionId,
|
|
58
|
+
presenceId: presenceId
|
|
55
59
|
}
|
|
56
60
|
}));
|
|
57
61
|
}
|
|
@@ -63,27 +67,42 @@ var createTelepointers = exports.createTelepointers = function createTelepointer
|
|
|
63
67
|
cursor.textContent = _whitespace.ZERO_WIDTH_JOINER;
|
|
64
68
|
cursor.className = "telepointer color-".concat(color, " telepointer-selection-badge");
|
|
65
69
|
cursor.style.cssText = "".concat(style({
|
|
66
|
-
color: avatarColor.
|
|
70
|
+
color: avatarColor.backgroundColor
|
|
67
71
|
}), ";");
|
|
68
72
|
cursor.setAttribute('data-initial', initial);
|
|
69
|
-
return decorations.concat(
|
|
73
|
+
return decorations.concat(
|
|
74
|
+
// Ignored via go/ees005
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
_view.Decoration.widget(to, spaceJoinerAfter, {
|
|
70
77
|
pointer: {
|
|
71
|
-
sessionId: sessionId
|
|
78
|
+
sessionId: sessionId,
|
|
79
|
+
presenceId: presenceId
|
|
72
80
|
},
|
|
73
81
|
key: "telepointer-".concat(sessionId, "-zero")
|
|
74
|
-
})).concat(
|
|
82
|
+
})).concat(
|
|
83
|
+
// Ignored via go/ees005
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
_view.Decoration.widget(to, cursor, {
|
|
75
86
|
pointer: {
|
|
76
|
-
sessionId: sessionId
|
|
87
|
+
sessionId: sessionId,
|
|
88
|
+
presenceId: presenceId
|
|
77
89
|
},
|
|
78
90
|
key: "telepointer-".concat(sessionId)
|
|
79
|
-
})).concat(
|
|
91
|
+
})).concat(
|
|
92
|
+
// Ignored via go/ees005
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
_view.Decoration.widget(to, spaceJoinerBefore, {
|
|
80
95
|
pointer: {
|
|
81
|
-
sessionId: sessionId
|
|
96
|
+
sessionId: sessionId,
|
|
97
|
+
presenceId: presenceId
|
|
82
98
|
},
|
|
83
99
|
key: "telepointer-".concat(sessionId, "-zero")
|
|
84
100
|
}));
|
|
85
101
|
};
|
|
86
|
-
var replaceDocument = exports.replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI
|
|
102
|
+
var replaceDocument = exports.replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI
|
|
103
|
+
// Ignored via go/ees005
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
105
|
+
) {
|
|
87
106
|
var schema = state.schema,
|
|
88
107
|
tr = state.tr;
|
|
89
108
|
var hasContent;
|
|
@@ -93,6 +112,8 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
|
|
|
93
112
|
hasContent = !!(parsedDoc !== null && parsedDoc !== void 0 && parsedDoc.childCount);
|
|
94
113
|
content = parsedDoc === null || parsedDoc === void 0 ? void 0 : parsedDoc.content;
|
|
95
114
|
} else {
|
|
115
|
+
// Ignored via go/ees005
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
117
|
content = (doc.content || []).map(function (child) {
|
|
97
118
|
return schema.nodeFromJSON(child);
|
|
98
119
|
});
|
|
@@ -100,6 +121,8 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
|
|
|
100
121
|
}
|
|
101
122
|
if (hasContent) {
|
|
102
123
|
tr.setMeta('addToHistory', false);
|
|
124
|
+
// Ignored via go/ees005
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
103
126
|
tr.replaceWith(0, state.doc.nodeSize - 2, content);
|
|
104
127
|
var selection = state.selection;
|
|
105
128
|
if (reserveCursor) {
|
|
@@ -125,7 +148,10 @@ var replaceDocument = exports.replaceDocument = function replaceDocument(doc, st
|
|
|
125
148
|
}
|
|
126
149
|
return tr;
|
|
127
150
|
};
|
|
128
|
-
var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI
|
|
151
|
+
var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI
|
|
152
|
+
// Ignored via go/ees005
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
154
|
+
) {
|
|
129
155
|
var selectedUser = participants[index];
|
|
130
156
|
if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
|
|
131
157
|
var state = editorView.state;
|
|
@@ -146,6 +172,8 @@ var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToColla
|
|
|
146
172
|
};
|
|
147
173
|
var getPositionOfTelepointer = exports.getPositionOfTelepointer = function getPositionOfTelepointer(sessionId, decorationSet) {
|
|
148
174
|
var scrollPosition;
|
|
175
|
+
// Ignored via go/ees005
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
177
|
decorationSet.find().forEach(function (deco) {
|
|
150
178
|
if (deco.type.spec.pointer.sessionId === sessionId) {
|
|
151
179
|
scrollPosition = deco.from;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
3
3
|
import { AddMarkStep, AddNodeMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { collab, getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
5
6
|
import { addSynchronyErrorAnalytics } from './pm-plugins/analytics';
|
|
6
7
|
import { sendTransaction } from './pm-plugins/events/send-transaction';
|
|
7
8
|
import { createPlugin } from './pm-plugins/main';
|
|
8
9
|
import { pluginKey as mainPluginKey } from './pm-plugins/main/plugin-key';
|
|
10
|
+
import { mergeUnconfirmedSteps } from './pm-plugins/mergeUnconfirmed';
|
|
9
11
|
import { nativeCollabProviderPlugin } from './pm-plugins/native-collab-provider-plugin';
|
|
10
12
|
import { sanitizeFilteredStep, createPlugin as trackSpammingStepsPlugin } from './pm-plugins/track-and-filter-spamming-steps';
|
|
11
13
|
import { createPlugin as createLastOrganicChangePlugin, trackLastOrganicChangePluginKey } from './pm-plugins/track-last-organic-change';
|
|
@@ -110,15 +112,30 @@ export const collabEditPlugin = ({
|
|
|
110
112
|
isRemoteReplaceDocumentTransaction: tr => tr.getMeta('isRemote') && tr.getMeta('replaceDocument'),
|
|
111
113
|
getCurrentCollabState: () => {
|
|
112
114
|
var _getCollabState;
|
|
115
|
+
// Ignored via go/ees005
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
117
|
const adfDocument = new JSONTransformer().encode(editorViewRef.current.state.doc);
|
|
114
118
|
return {
|
|
115
119
|
content: adfDocument,
|
|
120
|
+
// Ignored via go/ees005
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
116
122
|
version: ((_getCollabState = getCollabState(editorViewRef.current.state)) === null || _getCollabState === void 0 ? void 0 : _getCollabState.version) || 0,
|
|
123
|
+
// Ignored via go/ees005
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
117
125
|
sendableSteps: sendableSteps(editorViewRef.current.state)
|
|
118
126
|
};
|
|
119
127
|
},
|
|
128
|
+
// Ignored via go/ees005
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
130
|
validatePMJSONDocument: doc => {
|
|
121
|
-
|
|
131
|
+
// Ignored via go/ees005
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
const content = (doc.content || []).map(child =>
|
|
134
|
+
// Ignored via go/ees005
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
|
+
// Ignored via go/ees005
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
138
|
+
editorViewRef.current.state.schema.nodeFromJSON(child));
|
|
122
139
|
return content.every(node => {
|
|
123
140
|
try {
|
|
124
141
|
node.check(); // this will throw an error if the node is invalid
|
|
@@ -137,7 +154,8 @@ export const collabEditPlugin = ({
|
|
|
137
154
|
const plugins = [...(useNativePlugin ? [{
|
|
138
155
|
name: 'pmCollab',
|
|
139
156
|
plugin: () => collab({
|
|
140
|
-
clientID: userId
|
|
157
|
+
clientID: userId,
|
|
158
|
+
transformUnconfirmed: fg('platform_editor_merge_unconfirmed_steps') ? mergeUnconfirmedSteps : undefined
|
|
141
159
|
})
|
|
142
160
|
}, {
|
|
143
161
|
name: 'nativeCollabProviderPlugin',
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
// Ignored via go/ees005
|
|
2
|
+
// eslint-disable-next-line import/no-namespace
|
|
1
3
|
import * as allAdfSchemaSteps from '@atlaskit/adf-schema/steps';
|
|
4
|
+
// Ignored via go/ees005
|
|
5
|
+
// eslint-disable-next-line import/no-namespace
|
|
2
6
|
import * as allAtlaskitCustomSteps from '@atlaskit/custom-steps';
|
|
3
7
|
import { AllSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
8
|
import { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
@@ -12,7 +16,10 @@ export const registerAllCustomSteps = () => {
|
|
|
12
16
|
Object.entries(allAtlaskitCustomSteps).forEach(() => {});
|
|
13
17
|
Object.entries(allAdfSchemaSteps).forEach(() => {});
|
|
14
18
|
};
|
|
15
|
-
export const handleInit = (initData, view, options, editorAnalyticsApi
|
|
19
|
+
export const handleInit = (initData, view, options, editorAnalyticsApi
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
22
|
+
) => {
|
|
16
23
|
const {
|
|
17
24
|
doc,
|
|
18
25
|
json,
|
|
@@ -80,7 +87,10 @@ export const applyRemoteData = (remoteData, view, options) => {
|
|
|
80
87
|
applyRemoteSteps(json, view, userIds, options);
|
|
81
88
|
}
|
|
82
89
|
};
|
|
83
|
-
export const applyRemoteSteps = (json, view, userIds, options
|
|
90
|
+
export const applyRemoteSteps = (json, view, userIds, options
|
|
91
|
+
// Ignored via go/ees005
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
93
|
+
) => {
|
|
84
94
|
if (!json || !json.length) {
|
|
85
95
|
return;
|
|
86
96
|
}
|