@atlaskit/editor-plugin-annotation 1.24.1 → 1.25.1

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 (69) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/{plugin.js → annotationPlugin.js} +5 -5
  3. package/dist/cjs/annotationPluginType.js +5 -0
  4. package/dist/cjs/{commands → editor-commands}/index.js +13 -2
  5. package/dist/cjs/{commands → editor-commands}/transform.js +1 -1
  6. package/dist/cjs/index.js +2 -2
  7. package/dist/cjs/nodeviews/index.js +8 -2
  8. package/dist/cjs/pm-plugins/inline-comment.js +32 -17
  9. package/dist/cjs/pm-plugins/keymap.js +2 -2
  10. package/dist/cjs/pm-plugins/plugin-factory.js +1 -1
  11. package/dist/cjs/pm-plugins/reducer.js +7 -1
  12. package/dist/cjs/{toolbar.js → pm-plugins/toolbar.js} +3 -3
  13. package/dist/cjs/pm-plugins/types.js +1 -0
  14. package/dist/cjs/{utils.js → pm-plugins/utils.js} +1 -1
  15. package/dist/cjs/ui/InlineCommentView.js +7 -7
  16. package/dist/es2019/{plugin.js → annotationPlugin.js} +3 -3
  17. package/dist/es2019/annotationPluginType.js +1 -0
  18. package/dist/es2019/{commands → editor-commands}/index.js +10 -1
  19. package/dist/es2019/{commands → editor-commands}/transform.js +1 -1
  20. package/dist/es2019/index.js +1 -1
  21. package/dist/es2019/nodeviews/index.js +8 -2
  22. package/dist/es2019/pm-plugins/inline-comment.js +21 -8
  23. package/dist/es2019/pm-plugins/keymap.js +1 -1
  24. package/dist/es2019/pm-plugins/plugin-factory.js +1 -1
  25. package/dist/es2019/pm-plugins/reducer.js +8 -1
  26. package/dist/es2019/{toolbar.js → pm-plugins/toolbar.js} +2 -2
  27. package/dist/es2019/pm-plugins/types.js +1 -0
  28. package/dist/es2019/{utils.js → pm-plugins/utils.js} +1 -1
  29. package/dist/es2019/ui/InlineCommentView.js +2 -2
  30. package/dist/esm/{plugin.js → annotationPlugin.js} +3 -3
  31. package/dist/esm/annotationPluginType.js +1 -0
  32. package/dist/esm/{commands → editor-commands}/index.js +12 -1
  33. package/dist/esm/{commands → editor-commands}/transform.js +1 -1
  34. package/dist/esm/index.js +1 -1
  35. package/dist/esm/nodeviews/index.js +8 -2
  36. package/dist/esm/pm-plugins/inline-comment.js +23 -8
  37. package/dist/esm/pm-plugins/keymap.js +1 -1
  38. package/dist/esm/pm-plugins/plugin-factory.js +1 -1
  39. package/dist/esm/pm-plugins/reducer.js +7 -1
  40. package/dist/esm/{toolbar.js → pm-plugins/toolbar.js} +2 -2
  41. package/dist/esm/pm-plugins/types.js +1 -0
  42. package/dist/esm/{utils.js → pm-plugins/utils.js} +1 -1
  43. package/dist/esm/ui/InlineCommentView.js +2 -2
  44. package/dist/types/{plugin.d.ts → annotationPlugin.d.ts} +2 -1
  45. package/dist/types/annotationPluginType.d.ts +35 -0
  46. package/dist/types/{commands → editor-commands}/index.d.ts +3 -1
  47. package/dist/types/index.d.ts +3 -2
  48. package/dist/types/nodeviews/index.d.ts +1 -1
  49. package/dist/{types-ts4.5 → types/pm-plugins}/toolbar.d.ts +1 -1
  50. package/dist/types/pm-plugins/types.d.ts +9 -1
  51. package/dist/types/{utils.d.ts → pm-plugins/utils.d.ts} +3 -3
  52. package/dist/{types-ts4.5/types.d.ts → types/types/index.d.ts} +0 -33
  53. package/dist/types/ui/InlineCommentView.d.ts +2 -1
  54. package/dist/types-ts4.5/{plugin.d.ts → annotationPlugin.d.ts} +2 -1
  55. package/dist/types-ts4.5/annotationPluginType.d.ts +35 -0
  56. package/dist/types-ts4.5/{commands → editor-commands}/index.d.ts +3 -1
  57. package/dist/types-ts4.5/index.d.ts +3 -2
  58. package/dist/types-ts4.5/nodeviews/index.d.ts +1 -1
  59. package/dist/{types → types-ts4.5/pm-plugins}/toolbar.d.ts +1 -1
  60. package/dist/types-ts4.5/pm-plugins/types.d.ts +9 -1
  61. package/dist/types-ts4.5/{utils.d.ts → pm-plugins/utils.d.ts} +3 -3
  62. package/dist/{types/types.d.ts → types-ts4.5/types/index.d.ts} +0 -33
  63. package/dist/types-ts4.5/ui/InlineCommentView.d.ts +2 -1
  64. package/package.json +7 -4
  65. /package/dist/cjs/{types.js → types/index.js} +0 -0
  66. /package/dist/es2019/{types.js → types/index.js} +0 -0
  67. /package/dist/esm/{types.js → types/index.js} +0 -0
  68. /package/dist/types/{commands → editor-commands}/transform.d.ts +0 -0
  69. /package/dist/types-ts4.5/{commands → editor-commands}/transform.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.25.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#167498](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/167498)
8
+ [`e275b9ee8b698`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e275b9ee8b698) -
9
+ ED-25805: refactors plugins to meet folder standards
10
+ - Updated dependencies
11
+
12
+ ## 1.25.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#167231](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/167231)
17
+ [`335a373081eaf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/335a373081eaf) -
18
+ [ux] Added hoveredAnnotation for the renderer and the editor to accomodate the newly implemented
19
+ comment's panel
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 1.24.1
4
26
 
5
27
  ### Patch Changes
@@ -15,12 +15,12 @@ var _react = _interopRequireDefault(require("react"));
15
15
  var _adfSchema = require("@atlaskit/adf-schema");
16
16
  var _annotation = require("@atlaskit/editor-common/annotation");
17
17
  var _hooks = require("@atlaskit/editor-common/hooks");
18
- var _commands = require("./commands");
18
+ var _editorCommands = require("./editor-commands");
19
19
  var _inlineComment = require("./pm-plugins/inline-comment");
20
20
  var _keymap = require("./pm-plugins/keymap");
21
- var _toolbar = require("./toolbar");
21
+ var _toolbar = require("./pm-plugins/toolbar");
22
+ var _utils = require("./pm-plugins/utils");
22
23
  var _InlineCommentView = require("./ui/InlineCommentView");
23
- var _utils = require("./utils");
24
24
  var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref) {
25
25
  var _api$featureFlags, _api$analytics;
26
26
  var annotationProviders = _ref.config,
@@ -36,8 +36,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
36
36
  },
37
37
  actions: {
38
38
  stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
39
- setInlineCommentDraftState: (0, _commands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
40
- showCommentForBlockNode: (0, _commands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
39
+ setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
40
+ showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
41
41
  },
42
42
  getSharedState: function getSharedState(editorState) {
43
43
  if (!editorState) {
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -4,15 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.showInlineCommentForBlockNode = exports.setSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.removeInlineCommentNearSelection = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
7
+ exports.updateMouseState = exports.updateInlineCommentResolvedState = exports.showInlineCommentForBlockNode = exports.setSelectedAnnotation = exports.setInlineCommentsVisibility = exports.setInlineCommentDraftState = exports.setHoveredAnnotation = exports.removeInlineCommentNearSelection = exports.createAnnotation = exports.closeComponent = exports.clearDirtyMark = exports.addInlineComment = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
10
  var _analytics = require("@atlaskit/editor-common/analytics");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _pluginFactory = require("../pm-plugins/plugin-factory");
13
13
  var _types = require("../pm-plugins/types");
14
+ var _utils = require("../pm-plugins/utils");
14
15
  var _types2 = require("../types");
15
- var _utils = require("../utils");
16
16
  var _transform = _interopRequireDefault(require("./transform"));
17
17
  var updateInlineCommentResolvedState = exports.updateInlineCommentResolvedState = function updateInlineCommentResolvedState(editorAnalyticsAPI) {
18
18
  return function (partialNewState, resolveMethod) {
@@ -223,6 +223,17 @@ var setSelectedAnnotation = exports.setSelectedAnnotation = function setSelected
223
223
  }
224
224
  });
225
225
  };
226
+ var setHoveredAnnotation = exports.setHoveredAnnotation = function setHoveredAnnotation(id) {
227
+ return (0, _pluginFactory.createCommand)({
228
+ type: _types.ACTIONS.SET_HOVERED_ANNOTATION,
229
+ data: {
230
+ hoveredAnnotations: [{
231
+ id: id,
232
+ type: _adfSchema.AnnotationTypes.INLINE_COMMENT
233
+ }]
234
+ }
235
+ });
236
+ };
226
237
  var createAnnotation = exports.createAnnotation = function createAnnotation(editorAnalyticsAPI, editorAPI) {
227
238
  return function (id) {
228
239
  var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _adfSchema.AnnotationTypes.INLINE_COMMENT;
@@ -10,7 +10,7 @@ var _mark = require("@atlaskit/editor-common/mark");
10
10
  var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
- var _utils2 = require("../utils");
13
+ var _utils2 = require("../pm-plugins/utils");
14
14
  var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
15
15
  return function (transaction, state) {
16
16
  var inlineCommentState = (0, _utils2.getPluginState)(state);
package/dist/cjs/index.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "annotationPlugin", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _plugin.annotationPlugin;
9
+ return _annotationPlugin.annotationPlugin;
10
10
  }
11
11
  });
12
- var _plugin = require("./plugin");
12
+ var _annotationPlugin = require("./annotationPlugin");
@@ -51,11 +51,17 @@ var AnnotationNodeView = exports.AnnotationNodeView = /*#__PURE__*/function (_Re
51
51
  }]);
52
52
  return AnnotationNodeView;
53
53
  }(_reactNodeView.default);
54
- var getAnnotationViewClassname = exports.getAnnotationViewClassname = function getAnnotationViewClassname(isUnresolved, hasFocus) {
54
+ var getAnnotationViewClassname = exports.getAnnotationViewClassname = function getAnnotationViewClassname(isUnresolved, hasFocus, isHovered) {
55
55
  if (!isUnresolved) {
56
56
  return;
57
57
  }
58
- return hasFocus ? _styles.AnnotationSharedClassNames.focus : _styles.AnnotationSharedClassNames.blur;
58
+ if (hasFocus) {
59
+ return _styles.AnnotationSharedClassNames.focus;
60
+ }
61
+ if (isHovered) {
62
+ return _styles.AnnotationSharedClassNames.hover;
63
+ }
64
+ return _styles.AnnotationSharedClassNames.blur;
59
65
  };
60
66
  var getBlockAnnotationViewClassname = exports.getBlockAnnotationViewClassname = function getBlockAnnotationViewClassname(isUnresolved, hasFocus) {
61
67
  if (!isUnresolved) {
@@ -13,10 +13,10 @@ var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
14
14
  var _view = require("@atlaskit/editor-prosemirror/view");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
- var _commands = require("../commands");
16
+ var _editorCommands = require("../editor-commands");
17
17
  var _nodeviews = require("../nodeviews");
18
- var _utils = require("../utils");
19
18
  var _pluginFactory = require("./plugin-factory");
19
+ var _utils = require("./utils");
20
20
  var fetchProviderStates = /*#__PURE__*/function () {
21
21
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(provider, annotationIds) {
22
22
  var data, result;
@@ -64,7 +64,7 @@ var fetchState = /*#__PURE__*/function () {
64
64
  case 4:
65
65
  inlineCommentStates = _context2.sent;
66
66
  if (editorView.dispatch) {
67
- (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
67
+ (0, _editorCommands.updateInlineCommentResolvedState)(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
68
68
  }
69
69
  case 6:
70
70
  case "end":
@@ -82,6 +82,7 @@ var initialState = function initialState() {
82
82
  return {
83
83
  annotations: {},
84
84
  selectedAnnotations: [],
85
+ hoveredAnnotations: [],
85
86
  mouseData: {
86
87
  isSelecting: false
87
88
  },
@@ -95,7 +96,7 @@ var initialState = function initialState() {
95
96
  };
96
97
  var hideToolbar = function hideToolbar(state, dispatch) {
97
98
  return function () {
98
- (0, _commands.updateMouseState)({
99
+ (0, _editorCommands.updateMouseState)({
99
100
  isSelecting: true
100
101
  })(state, dispatch);
101
102
  };
@@ -105,14 +106,14 @@ var hideToolbar = function hideToolbar(state, dispatch) {
105
106
  var onResolve = function onResolve(editorAnalyticsAPI) {
106
107
  return function (state, dispatch) {
107
108
  return function (annotationId) {
108
- (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, annotationId, true), _analytics.RESOLVE_METHOD.CONSUMER)(state, dispatch);
109
+ (0, _editorCommands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, annotationId, true), _analytics.RESOLVE_METHOD.CONSUMER)(state, dispatch);
109
110
  };
110
111
  };
111
112
  };
112
113
  var onUnResolve = function onUnResolve(editorAnalyticsAPI) {
113
114
  return function (state, dispatch) {
114
115
  return function (annotationId) {
115
- (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, annotationId, false))(state, dispatch);
116
+ (0, _editorCommands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, annotationId, false))(state, dispatch);
116
117
  };
117
118
  };
118
119
  };
@@ -121,7 +122,7 @@ var onMouseUp = function onMouseUp(state, dispatch) {
121
122
  var _ref3 = (0, _utils.getPluginState)(state) || {},
122
123
  mouseData = _ref3.mouseData;
123
124
  if (mouseData !== null && mouseData !== void 0 && mouseData.isSelecting) {
124
- (0, _commands.updateMouseState)({
125
+ (0, _editorCommands.updateMouseState)({
125
126
  isSelecting: false
126
127
  })(state, dispatch);
127
128
  }
@@ -131,7 +132,7 @@ var onSetVisibility = function onSetVisibility(view) {
131
132
  return function (isVisible) {
132
133
  var state = view.state,
133
134
  dispatch = view.dispatch;
134
- (0, _commands.setInlineCommentsVisibility)(isVisible)(state, dispatch);
135
+ (0, _editorCommands.setInlineCommentsVisibility)(isVisible)(state, dispatch);
135
136
  if (isVisible) {
136
137
  // PM retains focus when we click away from the editor.
137
138
  // This will restore the visual aspect of the selection,
@@ -167,14 +168,24 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
167
168
  };
168
169
  var setSelectedAnnotationFn = function setSelectedAnnotationFn(annotationId) {
169
170
  if (!annotationId) {
170
- (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
171
+ (0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
171
172
  } else {
172
- (0, _commands.setSelectedAnnotation)(annotationId)(editorView.state, editorView.dispatch);
173
+ (0, _editorCommands.setSelectedAnnotation)(annotationId)(editorView.state, editorView.dispatch);
173
174
  }
174
175
  };
176
+ var setHoveredAnnotationFn = function setHoveredAnnotationFn(annotationId) {
177
+ if (!annotationId) {
178
+ (0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
179
+ } else {
180
+ (0, _editorCommands.setHoveredAnnotation)(annotationId)(editorView.state, editorView.dispatch);
181
+ }
182
+ };
183
+ var removeHoveredannotationFn = function removeHoveredannotationFn() {
184
+ (0, _editorCommands.setHoveredAnnotation)('')(editorView.state, editorView.dispatch);
185
+ };
175
186
  var updateSubscriber = provider.updateSubscriber;
176
187
  if (updateSubscriber) {
177
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn);
188
+ updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn);
178
189
  }
179
190
 
180
191
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -186,14 +197,14 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
186
197
  if (!dirtyAnnotations) {
187
198
  return;
188
199
  }
189
- (0, _commands.clearDirtyMark)()(view.state, view.dispatch);
200
+ (0, _editorCommands.clearDirtyMark)()(view.state, view.dispatch);
190
201
  fetchState(provider, (0, _utils.getAllAnnotations)(view.state.doc), view, options.editorAnalyticsAPI);
191
202
  },
192
203
  destroy: function destroy() {
193
204
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
194
205
  editorView.root.removeEventListener('mouseup', mouseUp);
195
206
  if (updateSubscriber) {
196
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn);
207
+ updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn);
197
208
  }
198
209
  }
199
210
  };
@@ -226,7 +237,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
226
237
  annotations = _ref5.annotations,
227
238
  selectedAnnotations = _ref5.selectedAnnotations,
228
239
  isVisible = _ref5.isVisible,
229
- isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed;
240
+ isInlineCommentViewClosed = _ref5.isInlineCommentViewClosed,
241
+ hoveredAnnotations = _ref5.hoveredAnnotations;
230
242
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
231
243
  var focusDecorations = [];
232
244
  state.doc.descendants(function (node, pos) {
@@ -245,6 +257,9 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
245
257
  var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
246
258
  return selectedAnnotation.id === mark.attrs.id;
247
259
  }));
260
+ var isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(function (hoveredAnnotation) {
261
+ return hoveredAnnotation.id === mark.attrs.id;
262
+ }));
248
263
  if (isSupportedBlockNode) {
249
264
  focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
250
265
  class: "".concat((0, _nodeviews.getBlockAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
@@ -255,19 +270,19 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
255
270
  if ((0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')) {
256
271
  if (node.isText) {
257
272
  focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
258
- class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
273
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected, isHovered), " ").concat(isUnresolved),
259
274
  nodeName: 'span'
260
275
  }));
261
276
  } else {
262
277
  focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
263
- class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
278
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected, isHovered), " ").concat(isUnresolved)
264
279
  }, {
265
280
  key: _utils.decorationKey.block
266
281
  }));
267
282
  }
268
283
  } else {
269
284
  focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
270
- class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
285
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected, isHovered), " ").concat(isUnresolved),
271
286
  nodeName: 'span'
272
287
  }));
273
288
  }
@@ -7,9 +7,9 @@ exports.keymapPlugin = keymapPlugin;
7
7
  var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
10
- var _commands = require("../commands");
10
+ var _editorCommands = require("../editor-commands");
11
11
  function keymapPlugin(editorAnalyticsAPI) {
12
12
  var list = {};
13
- (0, _keymaps.bindKeymapWithCommand)(_keymaps.addInlineComment.common, (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(true, _analytics.INPUT_METHOD.SHORTCUT), list);
13
+ (0, _keymaps.bindKeymapWithCommand)(_keymaps.addInlineComment.common, (0, _editorCommands.setInlineCommentDraftState)(editorAnalyticsAPI)(true, _analytics.INPUT_METHOD.SHORTCUT), list);
14
14
  return (0, _keymap.keymap)(list);
15
15
  }
@@ -9,8 +9,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
- var _utils2 = require("../utils");
13
12
  var _reducer = _interopRequireDefault(require("./reducer"));
13
+ var _utils2 = require("./utils");
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
@@ -8,8 +8,8 @@ exports.default = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _view = require("@atlaskit/editor-prosemirror/view");
11
- var _utils = require("../utils");
12
11
  var _types = require("./types");
12
+ var _utils = require("./utils");
13
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
15
  var _default = exports.default = function _default(pluginState, action) {
@@ -60,6 +60,12 @@ var _default = exports.default = function _default(pluginState, action) {
60
60
  isInlineCommentViewClosed: false,
61
61
  isOpeningMediaCommentFromToolbar: action.data.isOpeningMediaCommentFromToolbar
62
62
  });
63
+ case _types.ACTIONS.SET_HOVERED_ANNOTATION:
64
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
65
+ hoveredAnnotations: (0, _toConsumableArray2.default)(action.data.hoveredAnnotations),
66
+ skipSelectionHandling: true,
67
+ isInlineCommentViewClosed: false
68
+ });
63
69
  default:
64
70
  return pluginState;
65
71
  }
@@ -15,8 +15,8 @@ var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
15
15
  var _comment2 = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
17
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
- var _commands = require("./commands");
19
- var _types = require("./types");
18
+ var _editorCommands = require("../editor-commands");
19
+ var _types = require("../types");
20
20
  var _utils2 = require("./utils");
21
21
  var INLINE_COMMENT_ON_INLINE_NODE_SPOTLIGHT_EP_MESSAGE_ID = 'inline-comments-on-inline-node-spotlight';
22
22
  var createSpotlightConfig = function createSpotlightConfig(_ref) {
@@ -138,7 +138,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
138
138
  }
139
139
  });
140
140
  }
141
- return (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(true)(state, dispatch);
141
+ return (0, _editorCommands.setInlineCommentDraftState)(editorAnalyticsAPI)(true)(state, dispatch);
142
142
  },
143
143
  supportsViewMode: true,
144
144
  // TODO: MODES-3950 Clean up this floating toolbar view mode logic,
@@ -13,5 +13,6 @@ var ACTIONS = exports.ACTIONS = /*#__PURE__*/function (ACTIONS) {
13
13
  ACTIONS[ACTIONS["INLINE_COMMENT_SET_VISIBLE"] = 5] = "INLINE_COMMENT_SET_VISIBLE";
14
14
  ACTIONS[ACTIONS["CLOSE_COMPONENT"] = 6] = "CLOSE_COMPONENT";
15
15
  ACTIONS[ACTIONS["SET_SELECTED_ANNOTATION"] = 7] = "SET_SELECTED_ANNOTATION";
16
+ ACTIONS[ACTIONS["SET_HOVERED_ANNOTATION"] = 8] = "SET_HOVERED_ANNOTATION";
16
17
  return ACTIONS;
17
18
  }({});
@@ -34,7 +34,7 @@ var _utils = require("@atlaskit/editor-common/utils");
34
34
  var _state = require("@atlaskit/editor-prosemirror/state");
35
35
  var _view = require("@atlaskit/editor-prosemirror/view");
36
36
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
37
- var _types = require("./types");
37
+ var _types = require("../types");
38
38
  function sum(arr, f) {
39
39
  return arr.reduce(function (val, x) {
40
40
  return val + f(x);
@@ -11,9 +11,9 @@ var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
- var _commands = require("../commands");
14
+ var _editorCommands = require("../editor-commands");
15
+ var _utils3 = require("../pm-plugins/utils");
15
16
  var _types = require("../types");
16
- var _utils3 = require("../utils");
17
17
  var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
18
18
  var findPosForDOM = function findPosForDOM(sel) {
19
19
  var $from = sel.$from,
@@ -98,11 +98,11 @@ function InlineCommentView(_ref) {
98
98
  dom: dom,
99
99
  textSelection: textSelection,
100
100
  onCreate: function onCreate(id) {
101
- (0, _commands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
101
+ (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
102
102
  !editorView.hasFocus() && editorView.focus();
103
103
  },
104
104
  onClose: function onClose() {
105
- (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
105
+ (0, _editorCommands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
106
106
  !editorView.hasFocus() && editorView.focus();
107
107
  },
108
108
  inlineNodeTypes: inlineNodeTypes,
@@ -160,13 +160,13 @@ function InlineCommentView(_ref) {
160
160
  getInlineNodeTypes: getInlineNodeTypes,
161
161
  dom: dom,
162
162
  onDelete: function onDelete(id) {
163
- return (0, _commands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
163
+ return (0, _editorCommands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
164
164
  },
165
165
  onResolve: function onResolve(id) {
166
- return (0, _commands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, id, true), _analytics.RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
166
+ return (0, _editorCommands.updateInlineCommentResolvedState)(editorAnalyticsAPI)((0, _defineProperty2.default)({}, id, true), _analytics.RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch);
167
167
  },
168
168
  onClose: function onClose() {
169
- (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
169
+ (0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
170
170
  },
171
171
  isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
172
172
  }));
@@ -2,12 +2,12 @@ import React from 'react';
2
2
  import { annotation } from '@atlaskit/adf-schema';
3
3
  import { AnnotationUpdateEmitter } from '@atlaskit/editor-common/annotation';
4
4
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
5
- import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './commands';
5
+ import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
6
6
  import { inlineCommentPlugin } from './pm-plugins/inline-comment';
7
7
  import { keymapPlugin } from './pm-plugins/keymap';
8
- import { buildToolbar } from './toolbar';
8
+ import { buildToolbar } from './pm-plugins/toolbar';
9
+ import { getPluginState, stripNonExistingAnnotations } from './pm-plugins/utils';
9
10
  import { InlineCommentView } from './ui/InlineCommentView';
10
- import { getPluginState, stripNonExistingAnnotations } from './utils';
11
11
  export const annotationPlugin = ({
12
12
  config: annotationProviders,
13
13
  api
@@ -0,0 +1 @@
1
+ export {};
@@ -3,8 +3,8 @@ import { INPUT_METHOD, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics'
3
3
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { createCommand } from '../pm-plugins/plugin-factory';
5
5
  import { ACTIONS } from '../pm-plugins/types';
6
+ import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../pm-plugins/utils';
6
7
  import { AnnotationSelectionType } from '../types';
7
- import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../utils';
8
8
  import transform from './transform';
9
9
  export const updateInlineCommentResolvedState = editorAnalyticsAPI => (partialNewState, resolveMethod) => {
10
10
  const command = {
@@ -185,6 +185,15 @@ export const setSelectedAnnotation = id => createCommand({
185
185
  }]
186
186
  }
187
187
  });
188
+ export const setHoveredAnnotation = id => createCommand({
189
+ type: ACTIONS.SET_HOVERED_ANNOTATION,
190
+ data: {
191
+ hoveredAnnotations: [{
192
+ id,
193
+ type: AnnotationTypes.INLINE_COMMENT
194
+ }]
195
+ }
196
+ });
188
197
  export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotationType = AnnotationTypes.INLINE_COMMENT, supportedBlockNodes) => (state, dispatch) => {
189
198
  // don't try to add if there are is no temp highlight bookmarked
190
199
  const {
@@ -4,7 +4,7 @@ import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
4
4
  import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
5
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../utils';
7
+ import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../pm-plugins/utils';
8
8
  const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
9
9
  const inlineCommentState = getPluginState(state);
10
10
  const {
@@ -1 +1 @@
1
- export { annotationPlugin } from './plugin';
1
+ export { annotationPlugin } from './annotationPlugin';
@@ -23,11 +23,17 @@ export class AnnotationNodeView extends ReactNodeView {
23
23
  );
24
24
  }
25
25
  }
26
- export const getAnnotationViewClassname = (isUnresolved, hasFocus) => {
26
+ export const getAnnotationViewClassname = (isUnresolved, hasFocus, isHovered) => {
27
27
  if (!isUnresolved) {
28
28
  return;
29
29
  }
30
- return hasFocus ? AnnotationSharedClassNames.focus : AnnotationSharedClassNames.blur;
30
+ if (hasFocus) {
31
+ return AnnotationSharedClassNames.focus;
32
+ }
33
+ if (isHovered) {
34
+ return AnnotationSharedClassNames.hover;
35
+ }
36
+ return AnnotationSharedClassNames.blur;
31
37
  };
32
38
  export const getBlockAnnotationViewClassname = (isUnresolved, hasFocus) => {
33
39
  if (!isUnresolved) {
@@ -3,10 +3,10 @@ import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { fg } from '@atlaskit/platform-feature-flags';
6
- import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
6
+ import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../editor-commands';
7
7
  import { AnnotationNodeView, getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
8
- import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
9
8
  import { createPluginState } from './plugin-factory';
9
+ import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
10
10
  const fetchProviderStates = async (provider, annotationIds) => {
11
11
  const data = await provider.getState(annotationIds);
12
12
  let result = {};
@@ -33,6 +33,7 @@ const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) =>
33
33
  return {
34
34
  annotations: {},
35
35
  selectedAnnotations: [],
36
+ hoveredAnnotations: [],
36
37
  mouseData: {
37
38
  isSelecting: false
38
39
  },
@@ -110,11 +111,21 @@ export const inlineCommentPlugin = options => {
110
111
  setSelectedAnnotation(annotationId)(editorView.state, editorView.dispatch);
111
112
  }
112
113
  };
114
+ const setHoveredAnnotationFn = annotationId => {
115
+ if (!annotationId) {
116
+ closeComponent()(editorView.state, editorView.dispatch);
117
+ } else {
118
+ setHoveredAnnotation(annotationId)(editorView.state, editorView.dispatch);
119
+ }
120
+ };
121
+ const removeHoveredannotationFn = () => {
122
+ setHoveredAnnotation('')(editorView.state, editorView.dispatch);
123
+ };
113
124
  const {
114
125
  updateSubscriber
115
126
  } = provider;
116
127
  if (updateSubscriber) {
117
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn);
128
+ updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn);
118
129
  }
119
130
 
120
131
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -134,7 +145,7 @@ export const inlineCommentPlugin = options => {
134
145
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
135
146
  editorView.root.removeEventListener('mouseup', mouseUp);
136
147
  if (updateSubscriber) {
137
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn);
148
+ updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn);
138
149
  }
139
150
  }
140
151
  };
@@ -165,7 +176,8 @@ export const inlineCommentPlugin = options => {
165
176
  annotations,
166
177
  selectedAnnotations,
167
178
  isVisible,
168
- isInlineCommentViewClosed
179
+ isInlineCommentViewClosed,
180
+ hoveredAnnotations
169
181
  } = getPluginState(state) || {};
170
182
  let decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
171
183
  const focusDecorations = [];
@@ -181,6 +193,7 @@ export const inlineCommentPlugin = options => {
181
193
  if (isVisible) {
182
194
  const isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
183
195
  const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
196
+ const isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(hoveredAnnotation => hoveredAnnotation.id === mark.attrs.id));
184
197
  if (isSupportedBlockNode) {
185
198
  focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
186
199
  class: `${getBlockAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`
@@ -191,19 +204,19 @@ export const inlineCommentPlugin = options => {
191
204
  if (fg('editor_inline_comments_on_inline_nodes')) {
192
205
  if (node.isText) {
193
206
  focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
194
- class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
207
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected, isHovered)} ${isUnresolved}`,
195
208
  nodeName: 'span'
196
209
  }));
197
210
  } else {
198
211
  focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
199
- class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`
212
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected, isHovered)} ${isUnresolved}`
200
213
  }, {
201
214
  key: decorationKey.block
202
215
  }));
203
216
  }
204
217
  } else {
205
218
  focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
206
- class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
219
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected, isHovered)} ${isUnresolved}`,
207
220
  nodeName: 'span'
208
221
  }));
209
222
  }
@@ -1,7 +1,7 @@
1
1
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import { addInlineComment, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
3
3
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
4
- import { setInlineCommentDraftState } from '../commands';
4
+ import { setInlineCommentDraftState } from '../editor-commands';
5
5
  export function keymapPlugin(editorAnalyticsAPI) {
6
6
  const list = {};
7
7
  bindKeymapWithCommand(addInlineComment.common, setInlineCommentDraftState(editorAnalyticsAPI)(true, INPUT_METHOD.SHORTCUT), list);