@atlaskit/editor-plugin-annotation 26.0.4 → 26.0.5

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 (62) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/annotationPlugin.js +4 -4
  3. package/dist/cjs/editor-commands/index.js +4 -3
  4. package/dist/cjs/editor-commands/transform.js +32 -32
  5. package/dist/cjs/nodeviews/index.js +5 -5
  6. package/dist/cjs/pm-plugins/annotation-manager-hooks.js +21 -21
  7. package/dist/cjs/pm-plugins/inline-comment.js +27 -27
  8. package/dist/cjs/pm-plugins/keymap.js +2 -2
  9. package/dist/cjs/pm-plugins/plugin-factory.js +9 -9
  10. package/dist/cjs/pm-plugins/toolbar.js +35 -33
  11. package/dist/cjs/pm-plugins/utils.js +17 -16
  12. package/dist/cjs/ui/CommentButton/CommentButton.js +16 -14
  13. package/dist/cjs/ui/CommentButton/hooks.js +6 -6
  14. package/dist/cjs/ui/CommentButton/utils.js +18 -17
  15. package/dist/cjs/ui/InlineCommentView.js +26 -25
  16. package/dist/cjs/ui/toolbar-components.js +16 -15
  17. package/dist/es2019/annotationPlugin.js +2 -2
  18. package/dist/es2019/editor-commands/index.js +2 -1
  19. package/dist/es2019/editor-commands/transform.js +3 -3
  20. package/dist/es2019/nodeviews/index.js +1 -1
  21. package/dist/es2019/pm-plugins/annotation-manager-hooks.js +1 -1
  22. package/dist/es2019/pm-plugins/inline-comment.js +2 -2
  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/toolbar.js +6 -4
  26. package/dist/es2019/pm-plugins/utils.js +4 -3
  27. package/dist/es2019/ui/CommentButton/CommentButton.js +6 -4
  28. package/dist/es2019/ui/CommentButton/hooks.js +1 -1
  29. package/dist/es2019/ui/CommentButton/utils.js +3 -2
  30. package/dist/es2019/ui/InlineCommentView.js +6 -5
  31. package/dist/es2019/ui/toolbar-components.js +2 -1
  32. package/dist/esm/annotationPlugin.js +2 -2
  33. package/dist/esm/editor-commands/index.js +2 -1
  34. package/dist/esm/editor-commands/transform.js +3 -3
  35. package/dist/esm/nodeviews/index.js +1 -1
  36. package/dist/esm/pm-plugins/annotation-manager-hooks.js +1 -1
  37. package/dist/esm/pm-plugins/inline-comment.js +2 -2
  38. package/dist/esm/pm-plugins/keymap.js +1 -1
  39. package/dist/esm/pm-plugins/plugin-factory.js +1 -1
  40. package/dist/esm/pm-plugins/toolbar.js +6 -4
  41. package/dist/esm/pm-plugins/utils.js +4 -3
  42. package/dist/esm/ui/CommentButton/CommentButton.js +6 -4
  43. package/dist/esm/ui/CommentButton/hooks.js +1 -1
  44. package/dist/esm/ui/CommentButton/utils.js +3 -2
  45. package/dist/esm/ui/InlineCommentView.js +6 -5
  46. package/dist/esm/ui/toolbar-components.js +2 -1
  47. package/dist/types/annotationPluginType.d.ts +9 -8
  48. package/dist/types/editor-commands/index.d.ts +4 -3
  49. package/dist/types/editor-commands/transform.d.ts +3 -2
  50. package/dist/types/editor-commands/utils.d.ts +1 -1
  51. package/dist/types/pm-plugins/keymap.d.ts +1 -1
  52. package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
  53. package/dist/types/pm-plugins/toolbar.d.ts +5 -3
  54. package/dist/types/pm-plugins/types.d.ts +3 -2
  55. package/dist/types/pm-plugins/utils.d.ts +1 -1
  56. package/dist/types/types/index.d.ts +1 -1
  57. package/dist/types/ui/CommentButton/CommentButton.d.ts +1 -1
  58. package/dist/types/ui/CommentButton/hooks.d.ts +1 -1
  59. package/dist/types/ui/CommentButton/utils.d.ts +1 -1
  60. package/dist/types/ui/InlineCommentView.d.ts +3 -2
  61. package/dist/types/ui/toolbar-components.d.ts +2 -2
  62. package/package.json +2 -2
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.keymapPlugin = keymapPlugin;
7
- var _analytics = require("@atlaskit/editor-common/analytics");
7
+ var _enums = require("@atlaskit/editor-common/analytics/types/enums");
8
8
  var _keymaps = require("@atlaskit/editor-common/keymaps");
9
9
  var _keymap = require("@atlaskit/editor-prosemirror/keymap");
10
10
  var _editorCommands = require("../editor-commands");
@@ -14,6 +14,6 @@ function keymapPlugin(api) {
14
14
  (0, _keymaps.bindKeymapWithCommand)(
15
15
  // Ignored via go/ees005
16
16
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
- _keymaps.addInlineComment.common, (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, undefined, api)(true, _analytics.INPUT_METHOD.SHORTCUT), list);
17
+ _keymaps.addInlineComment.common, (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, undefined, api)(true, _enums.INPUT_METHOD.SHORTCUT), list);
18
18
  return (0, _keymap.keymap)(list);
19
19
  }
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.shouldClearBookMarkCheck = exports.createPluginState = exports.createCommand = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _utils = require("@atlaskit/editor-common/utils");
9
+ var _pluginStateFactory = require("@atlaskit/editor-common/utils/plugin-state-factory");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
12
  var _reducer = _interopRequireDefault(require("./reducer"));
13
- var _utils2 = require("./utils");
13
+ var _utils = 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
  /**
@@ -119,12 +119,12 @@ var getSelectionChangeHandlerOld = function getSelectionChangeHandlerOld(reopenC
119
119
  if (
120
120
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
121
121
  // we keep it as it is so that we can show comment view component with the newly created comment
122
- (0, _utils2.isBlockNodeAnnotationsSelected)(tr.selection, pluginState.selectedAnnotations)) {
122
+ (0, _utils.isBlockNodeAnnotationsSelected)(tr.selection, pluginState.selectedAnnotations)) {
123
123
  return _objectSpread(_objectSpread({}, pluginState), reopenCommentView && {
124
124
  isInlineCommentViewClosed: false
125
125
  });
126
126
  }
127
- var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
127
+ var selectedAnnotations = (0, _utils.findAnnotationsInSelection)(tr.selection, tr.doc);
128
128
  if (selectedAnnotations.length === 0) {
129
129
  return _objectSpread(_objectSpread({}, pluginState), {}, {
130
130
  selectedAnnotations: selectedAnnotations,
@@ -132,7 +132,7 @@ var getSelectionChangeHandlerOld = function getSelectionChangeHandlerOld(reopenC
132
132
  selectAnnotationMethod: undefined
133
133
  });
134
134
  }
135
- if ((0, _utils2.isSelectedAnnotationsChanged)(selectedAnnotations, pluginState.selectedAnnotations)) {
135
+ if ((0, _utils.isSelectedAnnotationsChanged)(selectedAnnotations, pluginState.selectedAnnotations)) {
136
136
  return _objectSpread(_objectSpread({}, pluginState), {}, {
137
137
  selectedAnnotations: selectedAnnotations,
138
138
  selectAnnotationMethod: undefined
@@ -156,7 +156,7 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
156
156
  isInlineCommentViewClosed: false
157
157
  });
158
158
  }
159
- var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
159
+ var selectedAnnotations = (0, _utils.findAnnotationsInSelection)(tr.selection, tr.doc);
160
160
 
161
161
  // NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
162
162
  // if the selection is empty. If this is no longer needed, we can remove this code.
@@ -171,7 +171,7 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
171
171
  // };
172
172
  // }
173
173
 
174
- if ((0, _utils2.isSelectedAnnotationsChanged)(selectedAnnotations, pluginState.pendingSelectedAnnotations)) {
174
+ if ((0, _utils.isSelectedAnnotationsChanged)(selectedAnnotations, pluginState.pendingSelectedAnnotations)) {
175
175
  return _objectSpread(_objectSpread({}, pluginState), {}, {
176
176
  pendingSelectedAnnotations: selectedAnnotations,
177
177
  pendingSelectedAnnotationsUpdateCount: pluginState.pendingSelectedAnnotationsUpdateCount + 1
@@ -198,7 +198,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
198
198
 
199
199
  // Create the handler with cache once at module level
200
200
  var handleDocChangedWithSync = createHandleDocChanged();
201
- var dest = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _reducer.default, {
201
+ var dest = (0, _pluginStateFactory.pluginFactory)(_utils.inlineCommentPluginKey, _reducer.default, {
202
202
  onSelectionChanged: getSelectionChangedHandler(true),
203
203
  onDocChanged: handleDocChangedWithSync,
204
204
  mapping: function mapping(tr, pluginState, editorState) {
@@ -211,7 +211,7 @@ var dest = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _reducer.de
211
211
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
212
212
  }
213
213
  hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
214
- return Object.values(_utils2.decorationKey).includes(spec.key);
214
+ return Object.values(_utils.decorationKey).includes(spec.key);
215
215
  }).length > 0;
216
216
 
217
217
  // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
@@ -6,17 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.shouldSuppressFloatingToolbar = exports.buildToolbar = exports.buildSuppressedToolbar = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _analytics = require("@atlaskit/editor-common/analytics");
9
+ var _enums = require("@atlaskit/editor-common/analytics/types/enums");
10
+ var _generalEvents = require("@atlaskit/editor-common/analytics/types/general-events");
11
+ var _isOfflineMode = require("@atlaskit/editor-common/connectivity/isOfflineMode");
10
12
  var _keymaps = require("@atlaskit/editor-common/keymaps");
11
13
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
12
- var _messages = require("@atlaskit/editor-common/messages");
13
- var _utils = require("@atlaskit/editor-common/utils");
14
- var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
14
+ var _annotation = require("@atlaskit/editor-common/messages/annotation");
15
+ var _annotation2 = require("@atlaskit/editor-common/utils/annotation");
16
+ var _calculateToolbarPosition = require("@atlaskit/editor-common/utils/calculate-toolbar-position");
15
17
  var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
16
18
  var _fg = require("@atlaskit/platform-feature-flags/fg");
17
19
  var _editorCommands = require("../editor-commands");
18
20
  var _types = require("../types");
19
- var _utils2 = require("./utils");
21
+ var _utils = require("./utils");
20
22
  var getValidNodes = function getValidNodes(state) {
21
23
  var schema = state.schema;
22
24
  var annotation = schema.marks.annotation;
@@ -74,24 +76,24 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
74
76
  return true;
75
77
  } : _ref2$getCanAddCommen,
76
78
  contentType = _ref2.contentType;
77
- var selectionValid = (0, _utils2.isSelectionValid)(state);
79
+ var selectionValid = (0, _utils.isSelectionValid)(state);
78
80
  var isMediaSelected = (0, _mediaSingle.currentMediaNodeWithPos)(state);
79
81
 
80
82
  // comments on media can only be added via media floating toolbar
81
83
  if (isMediaSelected || selectionValid === _types.AnnotationSelectionType.INVALID) {
82
84
  return undefined;
83
85
  }
84
- var createCommentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
85
- var commentDisabledMessage = intl.formatMessage((0, _fg.fg)('editor_inline_comments_on_inline_nodes') ? _messages.annotationMessages.createCommentDisabled : _messages.annotationMessages.createCommentInvalid);
86
+ var createCommentMessage = intl.formatMessage(_annotation.annotationMessages.createComment);
87
+ var commentDisabledMessage = intl.formatMessage((0, _fg.fg)('editor_inline_comments_on_inline_nodes') ? _annotation.annotationMessages.createCommentDisabled : _annotation.annotationMessages.createCommentInvalid);
86
88
  var canAddComments = getCanAddComments();
87
89
  var isCommentButtonDisabled = !canAddComments || selectionValid === _types.AnnotationSelectionType.DISABLED;
88
- var disabledTooltipContent = !canAddComments ? intl.formatMessage(_messages.annotationMessages.noPermissionToAddComment, {
90
+ var disabledTooltipContent = !canAddComments ? intl.formatMessage(_annotation.annotationMessages.noPermissionToAddComment, {
89
91
  contentType: contentType
90
92
  }) : commentDisabledMessage;
91
93
  var createComment = {
92
94
  type: 'button',
93
95
  showTitle: true,
94
- disabled: isCommentButtonDisabled || (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode),
96
+ disabled: isCommentButtonDisabled || (0, _isOfflineMode.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode),
95
97
  testId: _types.AnnotationTestIds.floatingToolbarCreateButton,
96
98
  interactionName: 'start-inline-comment-action',
97
99
  icon: _comment.default,
@@ -106,35 +108,35 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
106
108
  onCommentButtonMount && onCommentButtonMount();
107
109
 
108
110
  // Check if the selection includes an non-text inline node
109
- var inlineCommentPluginState = (0, _utils2.getPluginState)(state);
110
- var inlineNodeNames = (_getRangeInlineNodeNa = (0, _utils.getRangeInlineNodeNames)({
111
+ var inlineCommentPluginState = (0, _utils.getPluginState)(state);
112
+ var inlineNodeNames = (_getRangeInlineNodeNa = (0, _annotation2.getRangeInlineNodeNames)({
111
113
  doc: state.doc,
112
- pos: (0, _utils2.resolveDraftBookmark)(state, inlineCommentPluginState === null || inlineCommentPluginState === void 0 ? void 0 : inlineCommentPluginState.bookmark)
114
+ pos: (0, _utils.resolveDraftBookmark)(state, inlineCommentPluginState === null || inlineCommentPluginState === void 0 ? void 0 : inlineCommentPluginState.bookmark)
113
115
  })) !== null && _getRangeInlineNodeNa !== void 0 ? _getRangeInlineNodeNa : [];
114
116
  var isNonTextInlineNodeInludedInComment = inlineNodeNames.filter(function (nodeName) {
115
117
  return nodeName !== 'text';
116
118
  }).length > 0;
117
119
  if (editorAnalyticsAPI) {
118
120
  editorAnalyticsAPI.fireAnalyticsEvent({
119
- action: _analytics.ACTION.VIEWED,
120
- actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
121
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
122
- eventType: _analytics.EVENT_TYPE.UI,
121
+ action: _enums.ACTION.VIEWED,
122
+ actionSubject: _enums.ACTION_SUBJECT.BUTTON,
123
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
124
+ eventType: _enums.EVENT_TYPE.UI,
123
125
  attributes: {
124
126
  isNonTextInlineNodeInludedInComment: isNonTextInlineNodeInludedInComment,
125
127
  isDisabled: selectionValid === _types.AnnotationSelectionType.DISABLED,
126
- inputMethod: _analytics.INPUT_METHOD.FLOATING_TB,
127
- mode: _analytics.MODE.EDITOR
128
+ inputMethod: _enums.INPUT_METHOD.FLOATING_TB,
129
+ mode: _generalEvents.MODE.EDITOR
128
130
  }
129
131
  });
130
132
  }
131
133
  },
132
134
  onClick: function onClick(state, dispatch) {
133
135
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
134
- action: _analytics.ACTION.CLICKED,
135
- actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
136
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
137
- eventType: _analytics.EVENT_TYPE.UI,
136
+ action: _enums.ACTION.CLICKED,
137
+ actionSubject: _enums.ACTION_SUBJECT.BUTTON,
138
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
139
+ eventType: _enums.EVENT_TYPE.UI,
138
140
  attributes: {
139
141
  source: 'highlightActionsMenu',
140
142
  pageMode: 'edit'
@@ -156,10 +158,10 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
156
158
  // Fire an analytics event to indicate that the user has clicked the button
157
159
  // but the action was not completed, the result should contain a reason.
158
160
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
159
- action: _analytics.ACTION.ERROR,
160
- actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
161
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
162
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
161
+ action: _enums.ACTION.ERROR,
162
+ actionSubject: _enums.ACTION_SUBJECT.ANNOTATION,
163
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
164
+ eventType: _enums.EVENT_TYPE.OPERATIONAL,
163
165
  attributes: {
164
166
  errorReason: "toolbar-start-draft-failed/".concat(result.reason)
165
167
  }
@@ -168,10 +170,10 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
168
170
  }
169
171
  }).catch(function () {
170
172
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
171
- action: _analytics.ACTION.ERROR,
172
- actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
173
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
174
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
173
+ action: _enums.ACTION.ERROR,
174
+ actionSubject: _enums.ACTION_SUBJECT.ANNOTATION,
175
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
176
+ eventType: _enums.EVENT_TYPE.OPERATIONAL,
175
177
  attributes: {
176
178
  errorReason: "toolbar-start-draft-preemptive-gate-error"
177
179
  }
@@ -192,8 +194,8 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
192
194
  },
193
195
  supportsViewMode: true // TODO: MODES-3950 - Clean up this floating toolbar view mode logic,
194
196
  };
195
- var toolbarTitle = intl.formatMessage(_messages.annotationMessages.toolbar);
196
- var calcToolbarPosition = isToolbarAbove ? _utils.calculateToolbarPositionAboveSelection : _utils.calculateToolbarPositionTrackHead;
197
+ var toolbarTitle = intl.formatMessage(_annotation.annotationMessages.toolbar);
198
+ var calcToolbarPosition = isToolbarAbove ? _calculateToolbarPosition.calculateToolbarPositionAboveSelection : _calculateToolbarPosition.calculateToolbarPositionTrackHead;
197
199
  var onPositionCalculated = calcToolbarPosition(toolbarTitle);
198
200
  return {
199
201
  title: toolbarTitle,
@@ -17,10 +17,11 @@ exports.stripNonExistingAnnotations = stripNonExistingAnnotations;
17
17
  exports.surroundingMarks = void 0;
18
18
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
19
  var _annotation = require("@atlaskit/adf-schema/annotation");
20
- var _analytics = require("@atlaskit/editor-common/analytics");
20
+ var _enums = require("@atlaskit/editor-common/analytics/types/enums");
21
21
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
22
- var _styles = require("@atlaskit/editor-common/styles");
23
- var _utils = require("@atlaskit/editor-common/utils");
22
+ var _annotation2 = require("@atlaskit/editor-common/styles/annotation");
23
+ var _annotation3 = require("@atlaskit/editor-common/utils/annotation");
24
+ var _nodes = require("@atlaskit/editor-common/utils/nodes");
24
25
  var _state = require("@atlaskit/editor-prosemirror/state");
25
26
  var _view = require("@atlaskit/editor-prosemirror/view");
26
27
  var _fg = require("@atlaskit/platform-feature-flags/fg");
@@ -128,13 +129,13 @@ var addDraftDecoration = exports.addDraftDecoration = function addDraftDecoratio
128
129
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
129
130
  if (targetType === 'block') {
130
131
  return _view.Decoration.node(start, end, {
131
- class: "".concat(_styles.BlockAnnotationSharedClassNames.draft)
132
+ class: "".concat(_annotation2.BlockAnnotationSharedClassNames.draft)
132
133
  }, {
133
134
  key: decorationKey.block
134
135
  });
135
136
  }
136
137
  return _view.Decoration.inline(start, end, {
137
- class: "".concat(_styles.AnnotationSharedClassNames.draft)
138
+ class: "".concat(_annotation2.AnnotationSharedClassNames.draft)
138
139
  }, {
139
140
  key: decorationKey.inline
140
141
  });
@@ -268,7 +269,7 @@ var getAnnotationsInSelectionCount = function getAnnotationsInSelectionCount(sta
268
269
  var _state$selection = state.selection,
269
270
  from = _state$selection.from,
270
271
  to = _state$selection.to;
271
- var annotations = (0, _utils.getAnnotationIdsFromRange)({
272
+ var annotations = (0, _annotation3.getAnnotationIdsFromRange)({
272
273
  from: from,
273
274
  to: to
274
275
  }, state.doc, state.schema);
@@ -290,16 +291,16 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
290
291
  if ((0, _fg.fg)('editor_inline_comments_on_inline_nodes')) {
291
292
  var _ref2 = getPluginState(state) || {},
292
293
  bookmark = _ref2.bookmark;
293
- attributes.inlineNodeNames = (0, _utils.getRangeInlineNodeNames)({
294
+ attributes.inlineNodeNames = (0, _annotation3.getRangeInlineNodeNames)({
294
295
  doc: state.doc,
295
296
  pos: resolveDraftBookmark(state, bookmark)
296
297
  });
297
298
  }
298
299
  return {
299
- action: drafting ? _analytics.ACTION.OPENED : _analytics.ACTION.CLOSED,
300
- actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
301
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
302
- eventType: _analytics.EVENT_TYPE.TRACK,
300
+ action: drafting ? _enums.ACTION.OPENED : _enums.ACTION.CLOSED,
301
+ actionSubject: _enums.ACTION_SUBJECT.ANNOTATION,
302
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
303
+ eventType: _enums.EVENT_TYPE.TRACK,
303
304
  attributes: attributes
304
305
  };
305
306
  };
@@ -343,7 +344,7 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
343
344
  if (disallowOnWhitespace && !isSupportedExtensionSelection && hasInvalidWhitespaceNode(selection, state.schema)) {
344
345
  return _types.AnnotationSelectionType.INVALID;
345
346
  }
346
- if (!(selection instanceof _state.NodeSelection) && (0, _utils.isEmptyTextSelection)(selection, state.schema)) {
347
+ if (!(selection instanceof _state.NodeSelection) && (0, _annotation3.isEmptyTextSelection)(selection, state.schema)) {
347
348
  return _types.AnnotationSelectionType.INVALID;
348
349
  }
349
350
  return _types.AnnotationSelectionType.VALID;
@@ -352,7 +353,7 @@ var hasInvalidNodes = exports.hasInvalidNodes = function hasInvalidNodes(state)
352
353
  var selection = state.selection,
353
354
  doc = state.doc,
354
355
  schema = state.schema;
355
- return !(0, _utils.canApplyAnnotationOnRange)({
356
+ return !(0, _annotation3.canApplyAnnotationOnRange)({
356
357
  from: selection.from,
357
358
  to: selection.to
358
359
  }, doc, schema);
@@ -383,7 +384,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
383
384
  if (node.type === schema.nodes.inlineCard && (0, _fg.fg)('editor_inline_comments_on_inline_nodes')) {
384
385
  return false;
385
386
  }
386
- if ((0, _utils.isText)(node, schema)) {
387
+ if ((0, _nodes.isText)(node, schema)) {
387
388
  if ((0, _fg.fg)('editor_inline_comments_on_inline_nodes')) {
388
389
  if (node.textContent.trim() !== '') {
389
390
  hasCommentableTextNodeDescendants = true;
@@ -406,7 +407,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
406
407
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
407
408
  !node.eq(content.firstChild) &&
408
409
  // and it is a paragraph node
409
- (0, _utils.isParagraph)(node, schema);
410
+ (0, _nodes.isParagraph)(node, schema);
410
411
  if (!nodeIsTrailingNewLine) {
411
412
  foundInvalidWhitespace = true;
412
413
  }
@@ -452,7 +453,7 @@ function stripNonExistingAnnotations(slice, state) {
452
453
  * from node
453
454
  */
454
455
  function stripNonExistingAnnotationsFromNode(node, state) {
455
- if ((0, _utils.hasAnnotationMark)(node, state)) {
456
+ if ((0, _annotation3.hasAnnotationMark)(node, state)) {
456
457
  node.marks = node.marks.filter(function (mark) {
457
458
  if (mark.type.name === 'annotation') {
458
459
  return annotationExists(mark.attrs.id, state);
@@ -7,21 +7,23 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.CommentButton = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntl = require("react-intl");
10
- var _hooks = require("@atlaskit/editor-common/hooks");
11
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
12
- var _messages = require("@atlaskit/editor-common/messages");
13
- var _toolbar = require("@atlaskit/editor-common/toolbar");
14
- var _editorToolbar = require("@atlaskit/editor-toolbar");
11
+ var _annotation = require("@atlaskit/editor-common/messages/annotation");
12
+ var _context = require("@atlaskit/editor-common/toolbar/context");
13
+ var _useSharedPluginStateWithSelector = require("@atlaskit/editor-common/useSharedPluginStateWithSelector");
14
+ var _commentIcon = require("@atlaskit/editor-toolbar/comment-icon");
15
+ var _toolbarButton = require("@atlaskit/editor-toolbar/toolbar-button");
16
+ var _toolbarTooltip = require("@atlaskit/editor-toolbar/toolbar-tooltip");
15
17
  var _fg = require("@atlaskit/platform-feature-flags/fg");
16
18
  var _utils = require("../../pm-plugins/utils");
17
19
  var _types = require("../../types");
18
- var _hooks2 = require("./hooks");
20
+ var _hooks = require("./hooks");
19
21
  var _utils2 = require("./utils");
20
22
  var CommentButton = exports.CommentButton = function CommentButton(_ref) {
21
23
  var _annotationProviders$;
22
24
  var api = _ref.api,
23
25
  annotationProviders = _ref.annotationProviders;
24
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], function (states) {
26
+ var _useSharedPluginState = (0, _useSharedPluginStateWithSelector.useSharedPluginStateWithSelector)(api, ['annotation'], function (states) {
25
27
  var _states$annotationSta, _states$annotationSta2;
26
28
  return {
27
29
  isVisible: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.isVisible,
@@ -30,13 +32,13 @@ var CommentButton = exports.CommentButton = function CommentButton(_ref) {
30
32
  }),
31
33
  isVisible = _useSharedPluginState.isVisible,
32
34
  bookmark = _useSharedPluginState.bookmark;
33
- var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
35
+ var _useEditorToolbar = (0, _context.useEditorToolbar)(),
34
36
  editorView = _useEditorToolbar.editorView;
35
37
  var annotationSelectionType = editorView !== null && editorView !== void 0 && editorView.state ? (0, _utils.isSelectionValid)(editorView.state) : _types.AnnotationSelectionType.INVALID;
36
38
  var _ref2 = (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : {},
37
39
  getCanAddComments = _ref2.getCanAddComments,
38
40
  contentType = _ref2.contentType;
39
- (0, _hooks2.useCommentButtonMount)({
41
+ (0, _hooks.useCommentButtonMount)({
40
42
  state: editorView === null || editorView === void 0 ? void 0 : editorView.state,
41
43
  annotationProviders: annotationProviders,
42
44
  api: api,
@@ -66,9 +68,9 @@ var CommentButton = exports.CommentButton = function CommentButton(_ref) {
66
68
  return null;
67
69
  }
68
70
  var canAddComments = getCanAddComments ? getCanAddComments() : true;
69
- var commentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
70
- var commentDisabledMessage = intl.formatMessage((0, _fg.fg)('editor_inline_comments_on_inline_nodes') ? _messages.annotationMessages.createCommentDisabled : _messages.annotationMessages.createCommentInvalid);
71
- var noPermissionToAddCommentMessage = intl.formatMessage(_messages.annotationMessages.noPermissionToAddComment, {
71
+ var commentMessage = intl.formatMessage(_annotation.annotationMessages.createComment);
72
+ var commentDisabledMessage = intl.formatMessage((0, _fg.fg)('editor_inline_comments_on_inline_nodes') ? _annotation.annotationMessages.createCommentDisabled : _annotation.annotationMessages.createCommentInvalid);
73
+ var noPermissionToAddCommentMessage = intl.formatMessage(_annotation.annotationMessages.noPermissionToAddComment, {
72
74
  contentType: contentType
73
75
  });
74
76
  var _isButtonDisabled = (0, _utils2.isButtonDisabled)({
@@ -88,13 +90,13 @@ var CommentButton = exports.CommentButton = function CommentButton(_ref) {
88
90
  return undefined;
89
91
  }
90
92
  };
91
- return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
93
+ return /*#__PURE__*/_react.default.createElement(_toolbarTooltip.ToolbarTooltip, {
92
94
  content: isDisabled ? tooltipContentWhenDisabled() : /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
93
95
  description: commentMessage,
94
96
  keymap: _keymaps.addInlineComment
95
97
  })
96
- }, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButton, {
97
- iconBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.CommentIcon, {
98
+ }, /*#__PURE__*/_react.default.createElement(_toolbarButton.ToolbarButton, {
99
+ iconBefore: /*#__PURE__*/_react.default.createElement(_commentIcon.CommentIcon, {
98
100
  label: "",
99
101
  size: "small"
100
102
  }),
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useCommentButtonMount = void 0;
7
7
  var _react = require("react");
8
- var _utils = require("@atlaskit/editor-common/utils");
9
- var _utils2 = require("../../pm-plugins/utils");
10
- var _utils3 = require("./utils");
8
+ var _annotation = require("@atlaskit/editor-common/utils/annotation");
9
+ var _utils = require("../../pm-plugins/utils");
10
+ var _utils2 = require("./utils");
11
11
  // oxlint-disable-next-line import/no-duplicates
12
12
 
13
13
  var useCommentButtonMount = exports.useCommentButtonMount = function useCommentButtonMount(_ref) {
@@ -26,16 +26,16 @@ var useCommentButtonMount = exports.useCommentButtonMount = function useCommentB
26
26
  (_annotationProviders$ = (_annotationProviders$2 = annotationProviders.inlineComment).onCommentButtonMount) === null || _annotationProviders$ === void 0 || _annotationProviders$.call(_annotationProviders$2);
27
27
  }
28
28
  // Check if the selection includes an non-text inline node
29
- var inlineNodeNames = (_getRangeInlineNodeNa = (0, _utils.getRangeInlineNodeNames)({
29
+ var inlineNodeNames = (_getRangeInlineNodeNa = (0, _annotation.getRangeInlineNodeNames)({
30
30
  doc: state.doc,
31
- pos: (0, _utils2.resolveDraftBookmark)(state, bookmark)
31
+ pos: (0, _utils.resolveDraftBookmark)(state, bookmark)
32
32
  })) !== null && _getRangeInlineNodeNa !== void 0 ? _getRangeInlineNodeNa : [];
33
33
  var isNonTextInlineNodeInludedInComment =
34
34
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
35
35
  inlineNodeNames.filter(function (nodeName) {
36
36
  return nodeName !== 'text';
37
37
  }).length > 0;
38
- (0, _utils3.fireCommentButtonViewedAnalyticsEvent)({
38
+ (0, _utils2.fireCommentButtonViewedAnalyticsEvent)({
39
39
  api: api,
40
40
  isNonTextInlineNodeInludedInComment: isNonTextInlineNodeInludedInComment,
41
41
  annotationSelectionType: annotationSelectionType
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.startCommentExperience = exports.shouldShowCommentButton = exports.isButtonDisabled = exports.fireOnClickAnalyticsEvent = exports.fireCommentButtonViewedAnalyticsEvent = void 0;
7
- var _analytics = require("@atlaskit/editor-common/analytics");
7
+ var _enums = require("@atlaskit/editor-common/analytics/types/enums");
8
+ var _generalEvents = require("@atlaskit/editor-common/analytics/types/general-events");
9
+ var _isOfflineMode = require("@atlaskit/editor-common/connectivity/isOfflineMode");
8
10
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
9
- var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
10
11
  var _editorCommands = require("../../editor-commands");
11
12
  var _utils = require("../../pm-plugins/utils");
12
13
  var _types = require("../../types");
@@ -17,7 +18,7 @@ var isButtonDisabled = exports.isButtonDisabled = function isButtonDisabled(_ref
17
18
  canAddComments = _ref.canAddComments;
18
19
  var annotationSelectionType = state ? (0, _utils.isSelectionValid)(state) : _types.AnnotationSelectionType.INVALID;
19
20
  var isAnnotationSelectionInvalid = annotationSelectionType === _types.AnnotationSelectionType.DISABLED;
20
- var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode);
21
+ var isOffline = (0, _isOfflineMode.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode);
21
22
  return {
22
23
  isAnnotationSelectionInvalid: isAnnotationSelectionInvalid,
23
24
  isOffline: isOffline,
@@ -46,10 +47,10 @@ var fireOnClickAnalyticsEvent = exports.fireOnClickAnalyticsEvent = function fir
46
47
  var _api$analytics;
47
48
  var api = _ref3.api;
48
49
  (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent({
49
- action: _analytics.ACTION.CLICKED,
50
- actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
51
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
52
- eventType: _analytics.EVENT_TYPE.UI,
50
+ action: _enums.ACTION.CLICKED,
51
+ actionSubject: _enums.ACTION_SUBJECT.BUTTON,
52
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
53
+ eventType: _enums.EVENT_TYPE.UI,
53
54
  attributes: {
54
55
  source: 'highlightActionsMenu',
55
56
  pageMode: 'edit'
@@ -61,10 +62,10 @@ var fireAnnotationErrorAnalyticsEvent = function fireAnnotationErrorAnalyticsEve
61
62
  var api = _ref4.api,
62
63
  errorReason = _ref4.errorReason;
63
64
  (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
64
- action: _analytics.ACTION.ERROR,
65
- actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
66
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
67
- eventType: _analytics.EVENT_TYPE.OPERATIONAL,
65
+ action: _enums.ACTION.ERROR,
66
+ actionSubject: _enums.ACTION_SUBJECT.ANNOTATION,
67
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
68
+ eventType: _enums.EVENT_TYPE.OPERATIONAL,
68
69
  attributes: {
69
70
  errorReason: errorReason
70
71
  }
@@ -76,15 +77,15 @@ var fireCommentButtonViewedAnalyticsEvent = exports.fireCommentButtonViewedAnaly
76
77
  isNonTextInlineNodeInludedInComment = _ref5.isNonTextInlineNodeInludedInComment,
77
78
  annotationSelectionType = _ref5.annotationSelectionType;
78
79
  api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
79
- action: _analytics.ACTION.VIEWED,
80
- actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
81
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
82
- eventType: _analytics.EVENT_TYPE.UI,
80
+ action: _enums.ACTION.VIEWED,
81
+ actionSubject: _enums.ACTION_SUBJECT.BUTTON,
82
+ actionSubjectId: _enums.ACTION_SUBJECT_ID.INLINE_COMMENT,
83
+ eventType: _enums.EVENT_TYPE.UI,
83
84
  attributes: {
84
85
  isNonTextInlineNodeInludedInComment: isNonTextInlineNodeInludedInComment,
85
86
  isDisabled: annotationSelectionType === _types.AnnotationSelectionType.DISABLED,
86
- inputMethod: _analytics.INPUT_METHOD.FLOATING_TB,
87
- mode: _analytics.MODE.EDITOR
87
+ inputMethod: _enums.INPUT_METHOD.FLOATING_TB,
88
+ mode: _generalEvents.MODE.EDITOR
88
89
  }
89
90
  });
90
91
  };