@atlaskit/editor-plugin-collab-edit 0.1.11 → 0.1.12

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,13 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 0.1.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#69825](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69825) [`e2363da4f6a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e2363da4f6a1) - [No Issue] Replace View Mode API for annotations
8
+ - [#69825](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69825) [`e2363da4f6a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e2363da4f6a1) - [No Issue] Replace View Mode API for annotations
9
+ - [#69825](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69825) [`e2363da4f6a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e2363da4f6a1) - [No Issue] Replace View Mode API for annotations
10
+
3
11
  ## 0.1.11
4
12
 
5
13
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.collabEditPlugin = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _transform = require("@atlaskit/editor-prosemirror/transform");
11
12
  var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
12
13
  var _analytics = require("./analytics");
13
14
  var _sendTransaction = require("./events/send-transaction");
@@ -56,10 +57,25 @@ var providerBuilder = function providerBuilder(collabEditProviderPromise) {
56
57
  };
57
58
  }();
58
59
  };
59
- var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref2) {
60
+ var createAddInlineCommentMark = function createAddInlineCommentMark(providerPromise) {
61
+ return function (_ref2) {
62
+ var from = _ref2.from,
63
+ to = _ref2.to,
64
+ mark = _ref2.mark;
65
+ providerPromise.then(function (provider) {
66
+ var _provider$api;
67
+ var commentMark = new _transform.AddMarkStep(Math.min(from, to), Math.max(from, to), mark);
68
+
69
+ // @ts-expect-error 2339: Property 'api' does not exist on type 'CollabEditProvider<CollabEvents>'.
70
+ (_provider$api = provider.api) === null || _provider$api === void 0 || _provider$api.addComment([commentMark]);
71
+ });
72
+ return false;
73
+ };
74
+ };
75
+ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref3) {
60
76
  var _api$featureFlags;
61
- var options = _ref2.config,
62
- api = _ref2.api;
77
+ var options = _ref3.config,
78
+ api = _ref3.api;
63
79
  var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
64
80
  var providerResolver = function providerResolver() {};
65
81
  var collabEditProviderPromise = new Promise(function (_providerResolver) {
@@ -91,14 +107,15 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
91
107
  };
92
108
  },
93
109
  actions: {
94
- getAvatarColor: _utils.getAvatarColor
110
+ getAvatarColor: _utils.getAvatarColor,
111
+ addInlineCommentMark: createAddInlineCommentMark(collabEditProviderPromise)
95
112
  },
96
113
  pmPlugins: function pmPlugins() {
97
- var _ref3 = options || {},
98
- _ref3$useNativePlugin = _ref3.useNativePlugin,
99
- useNativePlugin = _ref3$useNativePlugin === void 0 ? false : _ref3$useNativePlugin,
100
- _ref3$userId = _ref3.userId,
101
- userId = _ref3$userId === void 0 ? null : _ref3$userId;
114
+ var _ref4 = options || {},
115
+ _ref4$useNativePlugin = _ref4.useNativePlugin,
116
+ useNativePlugin = _ref4$useNativePlugin === void 0 ? false : _ref4$useNativePlugin,
117
+ _ref4$userId = _ref4.userId,
118
+ userId = _ref4$userId === void 0 ? null : _ref4$userId;
102
119
  return [].concat((0, _toConsumableArray2.default)(useNativePlugin ? [{
103
120
  name: 'pmCollab',
104
121
  plugin: function plugin() {
@@ -115,9 +132,9 @@ var collabEditPlugin = exports.collabEditPlugin = function collabEditPlugin(_ref
115
132
  }
116
133
  }] : []), [{
117
134
  name: 'collab',
118
- plugin: function plugin(_ref4) {
119
- var dispatch = _ref4.dispatch,
120
- providerFactory = _ref4.providerFactory;
135
+ plugin: function plugin(_ref5) {
136
+ var dispatch = _ref5.dispatch,
137
+ providerFactory = _ref5.providerFactory;
121
138
  return (0, _main.createPlugin)(dispatch, providerFactory, providerResolver, executeProviderCode, options, featureFlags, api);
122
139
  }
123
140
  }, {
@@ -1,3 +1,4 @@
1
+ import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
1
2
  import { collab } from '@atlaskit/prosemirror-collab';
2
3
  import { addSynchronyErrorAnalytics } from './analytics';
3
4
  import { sendTransaction } from './events/send-transaction';
@@ -21,6 +22,20 @@ const providerBuilder = collabEditProviderPromise => async (codeToExecute, onErr
21
22
  }
22
23
  }
23
24
  };
25
+ const createAddInlineCommentMark = providerPromise => ({
26
+ from,
27
+ to,
28
+ mark
29
+ }) => {
30
+ providerPromise.then(provider => {
31
+ var _provider$api;
32
+ const commentMark = new AddMarkStep(Math.min(from, to), Math.max(from, to), mark);
33
+
34
+ // @ts-expect-error 2339: Property 'api' does not exist on type 'CollabEditProvider<CollabEvents>'.
35
+ (_provider$api = provider.api) === null || _provider$api === void 0 ? void 0 : _provider$api.addComment([commentMark]);
36
+ });
37
+ return false;
38
+ };
24
39
  export const collabEditPlugin = ({
25
40
  config: options,
26
41
  api
@@ -57,7 +72,8 @@ export const collabEditPlugin = ({
57
72
  };
58
73
  },
59
74
  actions: {
60
- getAvatarColor
75
+ getAvatarColor,
76
+ addInlineCommentMark: createAddInlineCommentMark(collabEditProviderPromise)
61
77
  },
62
78
  pmPlugins() {
63
79
  const {
@@ -1,6 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
4
5
  import { collab } from '@atlaskit/prosemirror-collab';
5
6
  import { addSynchronyErrorAnalytics } from './analytics';
6
7
  import { sendTransaction } from './events/send-transaction';
@@ -49,10 +50,25 @@ var providerBuilder = function providerBuilder(collabEditProviderPromise) {
49
50
  };
50
51
  }();
51
52
  };
52
- export var collabEditPlugin = function collabEditPlugin(_ref2) {
53
+ var createAddInlineCommentMark = function createAddInlineCommentMark(providerPromise) {
54
+ return function (_ref2) {
55
+ var from = _ref2.from,
56
+ to = _ref2.to,
57
+ mark = _ref2.mark;
58
+ providerPromise.then(function (provider) {
59
+ var _provider$api;
60
+ var commentMark = new AddMarkStep(Math.min(from, to), Math.max(from, to), mark);
61
+
62
+ // @ts-expect-error 2339: Property 'api' does not exist on type 'CollabEditProvider<CollabEvents>'.
63
+ (_provider$api = provider.api) === null || _provider$api === void 0 || _provider$api.addComment([commentMark]);
64
+ });
65
+ return false;
66
+ };
67
+ };
68
+ export var collabEditPlugin = function collabEditPlugin(_ref3) {
53
69
  var _api$featureFlags;
54
- var options = _ref2.config,
55
- api = _ref2.api;
70
+ var options = _ref3.config,
71
+ api = _ref3.api;
56
72
  var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
57
73
  var providerResolver = function providerResolver() {};
58
74
  var collabEditProviderPromise = new Promise(function (_providerResolver) {
@@ -84,14 +100,15 @@ export var collabEditPlugin = function collabEditPlugin(_ref2) {
84
100
  };
85
101
  },
86
102
  actions: {
87
- getAvatarColor: getAvatarColor
103
+ getAvatarColor: getAvatarColor,
104
+ addInlineCommentMark: createAddInlineCommentMark(collabEditProviderPromise)
88
105
  },
89
106
  pmPlugins: function pmPlugins() {
90
- var _ref3 = options || {},
91
- _ref3$useNativePlugin = _ref3.useNativePlugin,
92
- useNativePlugin = _ref3$useNativePlugin === void 0 ? false : _ref3$useNativePlugin,
93
- _ref3$userId = _ref3.userId,
94
- userId = _ref3$userId === void 0 ? null : _ref3$userId;
107
+ var _ref4 = options || {},
108
+ _ref4$useNativePlugin = _ref4.useNativePlugin,
109
+ useNativePlugin = _ref4$useNativePlugin === void 0 ? false : _ref4$useNativePlugin,
110
+ _ref4$userId = _ref4.userId,
111
+ userId = _ref4$userId === void 0 ? null : _ref4$userId;
95
112
  return [].concat(_toConsumableArray(useNativePlugin ? [{
96
113
  name: 'pmCollab',
97
114
  plugin: function plugin() {
@@ -108,9 +125,9 @@ export var collabEditPlugin = function collabEditPlugin(_ref2) {
108
125
  }
109
126
  }] : []), [{
110
127
  name: 'collab',
111
- plugin: function plugin(_ref4) {
112
- var dispatch = _ref4.dispatch,
113
- providerFactory = _ref4.providerFactory;
128
+ plugin: function plugin(_ref5) {
129
+ var dispatch = _ref5.dispatch,
130
+ providerFactory = _ref5.providerFactory;
114
131
  return createPlugin(dispatch, providerFactory, providerResolver, executeProviderCode, options, featureFlags, api);
115
132
  }
116
133
  }, {
@@ -2,6 +2,7 @@ import type { CollabEditOptions, CollabEditProvider, CollabParticipant, Color, S
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
5
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
5
6
  export type { InviteToEditComponentProps, InviteToEditButtonProps, CollabInviteToEditProps, CollabAnalyticsProps, } from '@atlaskit/editor-common/collab';
6
7
  export type PrivateCollabEditOptions = CollabEditOptions & {
7
8
  sanitizePrivateContent?: boolean;
@@ -35,5 +36,10 @@ export type CollabEditPlugin = NextEditorPlugin<'collabEdit', {
35
36
  index: number;
36
37
  color: Color;
37
38
  };
39
+ addInlineCommentMark: (props: {
40
+ from: number;
41
+ to: number;
42
+ mark: Mark;
43
+ }) => boolean;
38
44
  };
39
45
  }>;
@@ -2,6 +2,7 @@ import type { CollabEditOptions, CollabEditProvider, CollabParticipant, Color, S
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
4
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
5
+ import type { Mark } from '@atlaskit/editor-prosemirror/model';
5
6
  export type { InviteToEditComponentProps, InviteToEditButtonProps, CollabInviteToEditProps, CollabAnalyticsProps, } from '@atlaskit/editor-common/collab';
6
7
  export type PrivateCollabEditOptions = CollabEditOptions & {
7
8
  sanitizePrivateContent?: boolean;
@@ -35,5 +36,10 @@ export type CollabEditPlugin = NextEditorPlugin<'collabEdit', {
35
36
  index: number;
36
37
  color: Color;
37
38
  };
39
+ addInlineCommentMark: (props: {
40
+ from: number;
41
+ to: number;
42
+ mark: Mark;
43
+ }) => boolean;
38
44
  };
39
45
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/editor-common": "^77.3.0",
35
+ "@atlaskit/editor-common": "^77.4.0",
36
36
  "@atlaskit/editor-plugin-analytics": "0.4.7",
37
37
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",
38
38
  "@atlaskit/editor-prosemirror": "3.0.0",