@atlaskit/editor-plugin-collab-edit 2.0.0 → 2.0.2

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/collabEditPlugin.js +21 -2
  3. package/dist/cjs/pm-plugins/actions.js +14 -2
  4. package/dist/cjs/pm-plugins/analytics.js +6 -1
  5. package/dist/cjs/pm-plugins/events/handlers.js +12 -1
  6. package/dist/cjs/pm-plugins/events/initialize.js +4 -1
  7. package/dist/cjs/pm-plugins/main/index.js +13 -1
  8. package/dist/cjs/pm-plugins/main/plugin-state.js +11 -0
  9. package/dist/cjs/pm-plugins/mergeUnconfirmed.js +85 -0
  10. package/dist/cjs/pm-plugins/utils.js +38 -8
  11. package/dist/es2019/collabEditPlugin.js +20 -2
  12. package/dist/es2019/pm-plugins/actions.js +12 -2
  13. package/dist/es2019/pm-plugins/analytics.js +6 -1
  14. package/dist/es2019/pm-plugins/events/handlers.js +13 -1
  15. package/dist/es2019/pm-plugins/events/initialize.js +4 -1
  16. package/dist/es2019/pm-plugins/main/index.js +13 -1
  17. package/dist/es2019/pm-plugins/main/plugin-state.js +14 -0
  18. package/dist/es2019/pm-plugins/mergeUnconfirmed.js +66 -0
  19. package/dist/es2019/pm-plugins/utils.js +39 -10
  20. package/dist/esm/collabEditPlugin.js +21 -2
  21. package/dist/esm/pm-plugins/actions.js +12 -2
  22. package/dist/esm/pm-plugins/analytics.js +6 -1
  23. package/dist/esm/pm-plugins/events/handlers.js +13 -1
  24. package/dist/esm/pm-plugins/events/initialize.js +4 -1
  25. package/dist/esm/pm-plugins/main/index.js +13 -1
  26. package/dist/esm/pm-plugins/main/plugin-state.js +11 -0
  27. package/dist/esm/pm-plugins/mergeUnconfirmed.js +78 -0
  28. package/dist/esm/pm-plugins/utils.js +39 -10
  29. package/dist/types/pm-plugins/mergeUnconfirmed.d.ts +24 -0
  30. package/dist/types-ts4.5/pm-plugins/mergeUnconfirmed.d.ts +24 -0
  31. package/package.json +7 -4
@@ -3,14 +3,16 @@ import { AnalyticsStep, SetAttrsStep } from '@atlaskit/adf-schema/steps';
3
3
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
4
4
  import { processRawValueWithoutValidation } from '@atlaskit/editor-common/process-raw-value';
5
5
  import { ZERO_WIDTH_JOINER } from '@atlaskit/editor-common/whitespace';
6
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
7
- import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { Transaction, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
8
7
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
9
8
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
10
9
  import { avatarColors } from '@atlaskit/editor-shared-styles/consts';
11
10
  import { fg } from '@atlaskit/platform-feature-flags';
12
11
  export var findPointers = function findPointers(id, decorations) {
13
- return decorations.find().reduce(function (arr, deco) {
12
+ return decorations.find()
13
+ // Ignored via go/ees005
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ .reduce(function (arr, deco) {
14
16
  return deco.spec.pointer.sessionId === id ? arr.concat(deco) : arr;
15
17
  }, []);
16
18
  };
@@ -32,13 +34,19 @@ export function getAvatarColor(str) {
32
34
  color: avatarColors[index]
33
35
  };
34
36
  }
35
- export var createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial) {
37
+ export var createTelepointers = function createTelepointers(from, to, sessionId, isSelection, initial
38
+ // Ignored via go/ees005
39
+ // eslint-disable-next-line @typescript-eslint/max-params
40
+ ) {
36
41
  var decorations = [];
37
42
  var avatarColor = getAvatarColor(sessionId);
38
43
  var color = avatarColor.index.toString();
39
44
  if (isSelection) {
40
45
  var className = "telepointer color-".concat(color, " telepointer-selection");
41
- decorations.push(Decoration.inline(from, to, {
46
+ decorations.push(
47
+ // Ignored via go/ees005
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ Decoration.inline(from, to, {
42
50
  class: className,
43
51
  'data-initial': initial
44
52
  }, {
@@ -58,24 +66,36 @@ export var createTelepointers = function createTelepointers(from, to, sessionId,
58
66
  color: avatarColor.color
59
67
  }), ";");
60
68
  cursor.setAttribute('data-initial', initial);
61
- return decorations.concat(Decoration.widget(to, spaceJoinerAfter, {
69
+ return decorations.concat(
70
+ // Ignored via go/ees005
71
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ Decoration.widget(to, spaceJoinerAfter, {
62
73
  pointer: {
63
74
  sessionId: sessionId
64
75
  },
65
76
  key: "telepointer-".concat(sessionId, "-zero")
66
- })).concat(Decoration.widget(to, cursor, {
77
+ })).concat(
78
+ // Ignored via go/ees005
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ Decoration.widget(to, cursor, {
67
81
  pointer: {
68
82
  sessionId: sessionId
69
83
  },
70
84
  key: "telepointer-".concat(sessionId)
71
- })).concat(Decoration.widget(to, spaceJoinerBefore, {
85
+ })).concat(
86
+ // Ignored via go/ees005
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
+ Decoration.widget(to, spaceJoinerBefore, {
72
89
  pointer: {
73
90
  sessionId: sessionId
74
91
  },
75
92
  key: "telepointer-".concat(sessionId, "-zero")
76
93
  }));
77
94
  };
78
- export var replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI) {
95
+ export var replaceDocument = function replaceDocument(doc, state, version, options, reserveCursor, editorAnalyticsAPI
96
+ // Ignored via go/ees005
97
+ // eslint-disable-next-line @typescript-eslint/max-params
98
+ ) {
79
99
  var schema = state.schema,
80
100
  tr = state.tr;
81
101
  var hasContent;
@@ -85,6 +105,8 @@ export var replaceDocument = function replaceDocument(doc, state, version, optio
85
105
  hasContent = !!(parsedDoc !== null && parsedDoc !== void 0 && parsedDoc.childCount);
86
106
  content = parsedDoc === null || parsedDoc === void 0 ? void 0 : parsedDoc.content;
87
107
  } else {
108
+ // Ignored via go/ees005
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
110
  content = (doc.content || []).map(function (child) {
89
111
  return schema.nodeFromJSON(child);
90
112
  });
@@ -92,6 +114,8 @@ export var replaceDocument = function replaceDocument(doc, state, version, optio
92
114
  }
93
115
  if (hasContent) {
94
116
  tr.setMeta('addToHistory', false);
117
+ // Ignored via go/ees005
118
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
95
119
  tr.replaceWith(0, state.doc.nodeSize - 2, content);
96
120
  var selection = state.selection;
97
121
  if (reserveCursor) {
@@ -117,7 +141,10 @@ export var replaceDocument = function replaceDocument(doc, state, version, optio
117
141
  }
118
142
  return tr;
119
143
  };
120
- export var scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI) {
144
+ export var scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI
145
+ // Ignored via go/ees005
146
+ // eslint-disable-next-line @typescript-eslint/max-params
147
+ ) {
121
148
  var selectedUser = participants[index];
122
149
  if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
123
150
  var state = editorView.state;
@@ -138,6 +165,8 @@ export var scrollToCollabCursor = function scrollToCollabCursor(editorView, part
138
165
  };
139
166
  export var getPositionOfTelepointer = function getPositionOfTelepointer(sessionId, decorationSet) {
140
167
  var scrollPosition;
168
+ // Ignored via go/ees005
169
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
170
  decorationSet.find().forEach(function (deco) {
142
171
  if (deco.type.spec.pointer.sessionId === sessionId) {
143
172
  scrollPosition = deco.from;
@@ -0,0 +1,24 @@
1
+ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
2
+ import type { Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
3
+ declare class LockableRebaseable {
4
+ readonly step: LockableProseMirrorStep;
5
+ readonly inverted: ProseMirrorStep;
6
+ readonly origin: ProseMirrorTransform;
7
+ constructor(step: LockableProseMirrorStep, inverted: ProseMirrorStep, origin: ProseMirrorTransform);
8
+ }
9
+ declare abstract class LockableProseMirrorStep extends ProseMirrorStep {
10
+ lockStep?: () => void;
11
+ isLocked?: () => boolean;
12
+ }
13
+ /**
14
+ * Merge a set of steps together to reduce the total number of steps stored in memory.
15
+ *
16
+ * All steps passing through here should be "lockable" (ie. can be locked by the document service)
17
+ * so that it can be indicated they have already been sent (or are about to be sent) to the backend
18
+ * and cannot be merged.
19
+ *
20
+ * @param steps Rebaseable steps
21
+ * @returns Rebaseable steps
22
+ */
23
+ export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[]): LockableRebaseable[];
24
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
2
+ import type { Transform as ProseMirrorTransform } from '@atlaskit/editor-prosemirror/transform';
3
+ declare class LockableRebaseable {
4
+ readonly step: LockableProseMirrorStep;
5
+ readonly inverted: ProseMirrorStep;
6
+ readonly origin: ProseMirrorTransform;
7
+ constructor(step: LockableProseMirrorStep, inverted: ProseMirrorStep, origin: ProseMirrorTransform);
8
+ }
9
+ declare abstract class LockableProseMirrorStep extends ProseMirrorStep {
10
+ lockStep?: () => void;
11
+ isLocked?: () => boolean;
12
+ }
13
+ /**
14
+ * Merge a set of steps together to reduce the total number of steps stored in memory.
15
+ *
16
+ * All steps passing through here should be "lockable" (ie. can be locked by the document service)
17
+ * so that it can be indicated they have already been sent (or are about to be sent) to the backend
18
+ * and cannot be merged.
19
+ *
20
+ * @param steps Rebaseable steps
21
+ * @returns Rebaseable steps
22
+ */
23
+ export declare function mergeUnconfirmedSteps(steps: LockableRebaseable[]): LockableRebaseable[];
24
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,15 +33,15 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^46.1.0",
35
35
  "@atlaskit/custom-steps": "^0.9.0",
36
- "@atlaskit/editor-common": "^96.5.0",
36
+ "@atlaskit/editor-common": "^97.2.0",
37
37
  "@atlaskit/editor-json-transformer": "^8.21.0",
38
- "@atlaskit/editor-plugin-analytics": "1.10.8",
38
+ "@atlaskit/editor-plugin-analytics": "1.10.9",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
40
40
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
41
41
  "@atlaskit/editor-prosemirror": "6.2.1",
42
42
  "@atlaskit/editor-shared-styles": "^3.2.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
44
- "@atlaskit/prosemirror-collab": "^0.10.0",
44
+ "@atlaskit/prosemirror-collab": "^0.11.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "memoize-one": "^6.0.0"
47
47
  },
@@ -104,6 +104,9 @@
104
104
  "platform-feature-flags": {
105
105
  "platform_editor_use_nested_table_pm_nodes": {
106
106
  "type": "boolean"
107
+ },
108
+ "platform_editor_merge_unconfirmed_steps": {
109
+ "type": "boolean"
107
110
  }
108
111
  }
109
112
  }