@atlaskit/editor-plugin-annotation 1.23.2 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/commands/index.js +10 -9
  3. package/dist/cjs/plugin.js +0 -1
  4. package/dist/cjs/pm-plugins/plugin-factory.js +13 -17
  5. package/dist/cjs/pm-plugins/reducer.js +10 -7
  6. package/dist/cjs/toolbar.js +4 -5
  7. package/dist/cjs/ui/InlineCommentView.js +6 -3
  8. package/dist/cjs/utils.js +3 -3
  9. package/dist/es2019/commands/index.js +9 -8
  10. package/dist/es2019/plugin.js +0 -1
  11. package/dist/es2019/pm-plugins/plugin-factory.js +12 -16
  12. package/dist/es2019/pm-plugins/reducer.js +8 -5
  13. package/dist/es2019/toolbar.js +4 -5
  14. package/dist/es2019/ui/InlineCommentView.js +6 -3
  15. package/dist/es2019/utils.js +2 -2
  16. package/dist/esm/commands/index.js +10 -9
  17. package/dist/esm/plugin.js +0 -1
  18. package/dist/esm/pm-plugins/plugin-factory.js +13 -17
  19. package/dist/esm/pm-plugins/reducer.js +10 -7
  20. package/dist/esm/toolbar.js +4 -5
  21. package/dist/esm/ui/InlineCommentView.js +6 -3
  22. package/dist/esm/utils.js +3 -3
  23. package/dist/types/commands/index.d.ts +2 -2
  24. package/dist/types/commands/transform.d.ts +2 -2
  25. package/dist/types/pm-plugins/types.d.ts +4 -2
  26. package/dist/types/toolbar.d.ts +1 -1
  27. package/dist/types/types.d.ts +9 -3
  28. package/dist/types/utils.d.ts +1 -1
  29. package/dist/types-ts4.5/commands/index.d.ts +2 -2
  30. package/dist/types-ts4.5/commands/transform.d.ts +2 -2
  31. package/dist/types-ts4.5/pm-plugins/types.d.ts +4 -2
  32. package/dist/types-ts4.5/toolbar.d.ts +1 -1
  33. package/dist/types-ts4.5/types.d.ts +9 -3
  34. package/dist/types-ts4.5/utils.d.ts +1 -1
  35. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#161814](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/161814)
8
+ [`6ff956fe6b784`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6ff956fe6b784) -
9
+ [ux] Add a new property to annotation state to know whether or not we're opening the comment box
10
+ from the media toolbar so we can scroll it into view from Confluence side
11
+
12
+ ## 1.23.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#158723](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158723)
17
+ [`8ff5b01b0d37f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8ff5b01b0d37f) -
18
+ [ED-24682] Cleanup feature flag for commenting on media in the renderer
19
+
20
+ **@atlaskit/editor-plugin-media**: Add optional checks for the api in Comment Badges on media
21
+
22
+ - Updated dependencies
23
+
3
24
  ## 1.23.2
4
25
 
5
26
  ### Patch Changes
@@ -112,10 +112,10 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
112
112
  return true;
113
113
  };
114
114
  };
115
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
115
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) {
116
116
  return function (editorState) {
117
117
  // validate selection only when entering draft mode
118
- if (drafting && (0, _utils.isSelectionValid)(editorState, isCommentOnMediaOn) !== _types2.AnnotationSelectionType.VALID) {
118
+ if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
119
119
  return false;
120
120
  }
121
121
  return {
@@ -124,9 +124,9 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
124
124
  drafting: drafting,
125
125
  editorState: editorState,
126
126
  targetType: targetType,
127
- isCommentOnMediaOn: isCommentOnMediaOn,
128
127
  supportedBlockNodes: supportedBlockNodes,
129
- targetNodeId: targetNodeId
128
+ targetNodeId: targetNodeId,
129
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
130
130
  }
131
131
  };
132
132
  };
@@ -138,7 +138,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
138
138
  */
139
139
  var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
140
140
  var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
141
- return function (node, viewMethod) {
141
+ return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
142
142
  return function (state, dispatch) {
143
143
  var pluginState = (0, _utils.getPluginState)(state);
144
144
  var annotation = state.schema.marks.annotation;
@@ -160,7 +160,8 @@ var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = func
160
160
  type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
161
161
  data: {
162
162
  selectedAnnotations: unresolvedAnnotationMarks,
163
- selectAnnotationMethod: viewMethod
163
+ selectAnnotationMethod: viewMethod,
164
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
164
165
  }
165
166
  }));
166
167
  return true;
@@ -176,9 +177,9 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
176
177
  return function (drafting) {
177
178
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
178
179
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
179
- var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
180
- var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
181
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
180
+ var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
181
+ var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
182
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
182
183
  return (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
183
184
  };
184
185
  };
@@ -92,7 +92,6 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
92
92
  state: state,
93
93
  intl: intl,
94
94
  isToolbarAbove: isToolbarAbove,
95
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
96
95
  api: api
97
96
  });
98
97
  }
@@ -55,7 +55,6 @@ var shouldClearBookMarkCheck = exports.shouldClearBookMarkCheck = function shoul
55
55
  };
56
56
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
57
57
  return function (tr, pluginState) {
58
- var _pluginState$featureF;
59
58
  if (pluginState.skipSelectionHandling) {
60
59
  return _objectSpread(_objectSpread({}, pluginState), {}, {
61
60
  skipSelectionHandling: false
@@ -63,7 +62,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
63
62
  isInlineCommentViewClosed: false
64
63
  });
65
64
  }
66
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
65
+ if (
67
66
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
68
67
  // we keep it as it is so that we can show comment view component with the newly created comment
69
68
  (0, _utils2.isBlockNodeAnnotationsSelected)(tr.selection, pluginState.selectedAnnotations)) {
@@ -99,28 +98,25 @@ var _pluginFactory = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _
99
98
  onDocChanged: handleDocChanged,
100
99
  mapping: function mapping(tr, pluginState, editorState) {
101
100
  var draftDecorationSet = pluginState.draftDecorationSet,
102
- bookmark = pluginState.bookmark,
103
- featureFlagsPluginState = pluginState.featureFlagsPluginState;
101
+ bookmark = pluginState.bookmark;
104
102
  var mappedDecorationSet = _view.DecorationSet.empty,
105
103
  mappedBookmark;
106
104
  var hasMappedDecorations = false;
107
105
  if (draftDecorationSet) {
108
106
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
109
107
  }
110
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
111
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
112
- return Object.values(_utils2.decorationKey).includes(spec.key);
113
- }).length > 0;
108
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
109
+ return Object.values(_utils2.decorationKey).includes(spec.key);
110
+ }).length > 0;
114
111
 
115
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
116
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
117
- // We only perform this change when document selection has changed.
118
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
119
- return _objectSpread(_objectSpread({}, pluginState), {}, {
120
- draftDecorationSet: mappedDecorationSet,
121
- bookmark: undefined
122
- });
123
- }
112
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
113
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
114
+ // We only perform this change when document selection has changed.
115
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
116
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
117
+ draftDecorationSet: mappedDecorationSet,
118
+ bookmark: undefined
119
+ });
124
120
  }
125
121
  if (bookmark) {
126
122
  mappedBookmark = bookmark.map(tr.mapping);
@@ -24,7 +24,7 @@ var _default = exports.default = function _default(pluginState, action) {
24
24
  mouseData: mouseData
25
25
  });
26
26
  case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
27
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
27
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
28
28
  case _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
29
29
  return _objectSpread(_objectSpread({}, pluginState), {}, {
30
30
  dirtyAnnotations: false,
@@ -33,7 +33,8 @@ var _default = exports.default = function _default(pluginState, action) {
33
33
  case _types.ACTIONS.CLOSE_COMPONENT:
34
34
  return _objectSpread(_objectSpread({}, pluginState), {}, {
35
35
  isInlineCommentViewClosed: true,
36
- isDrafting: false
36
+ isDrafting: false,
37
+ isOpeningMediaCommentFromToolbar: false
37
38
  });
38
39
  case _types.ACTIONS.ADD_INLINE_COMMENT:
39
40
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -56,13 +57,14 @@ var _default = exports.default = function _default(pluginState, action) {
56
57
  selectedAnnotations: (0, _toConsumableArray2.default)(action.data.selectedAnnotations),
57
58
  selectAnnotationMethod: action.data.selectAnnotationMethod,
58
59
  skipSelectionHandling: true,
59
- isInlineCommentViewClosed: false
60
+ isInlineCommentViewClosed: false,
61
+ isOpeningMediaCommentFromToolbar: action.data.isOpeningMediaCommentFromToolbar
60
62
  });
61
63
  default:
62
64
  return pluginState;
63
65
  }
64
66
  };
65
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
67
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
66
68
  var draftDecorationSet = pluginState.draftDecorationSet;
67
69
  if (!draftDecorationSet || !drafting) {
68
70
  draftDecorationSet = _view.DecorationSet.empty;
@@ -75,11 +77,12 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
75
77
  newState.bookmark = undefined;
76
78
  if (drafting && editorState) {
77
79
  newState.bookmark = editorState.selection.getBookmark();
78
- var _ref = isCommentOnMediaOn ? (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc),
79
- from = _ref.from,
80
- to = _ref.to;
80
+ var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes),
81
+ from = _resolveDraftBookmark.from,
82
+ to = _resolveDraftBookmark.to;
81
83
  var draftDecoration = (0, _utils.addDraftDecoration)(from, to, targetType);
82
84
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
83
85
  }
86
+ newState.isOpeningMediaCommentFromToolbar = isOpeningMediaCommentFromToolbar;
84
87
  return newState;
85
88
  }
@@ -55,13 +55,12 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
55
55
  intl = _ref2.intl,
56
56
  _ref2$isToolbarAbove = _ref2.isToolbarAbove,
57
57
  isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
58
- isCommentOnMediaOn = _ref2.isCommentOnMediaOn,
59
58
  _ref2$_supportedNodes = _ref2._supportedNodes,
60
59
  _supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
61
60
  api = _ref2.api;
62
61
  var schema = state.schema;
63
- var selectionValid = (0, _utils2.isSelectionValid)(state, isCommentOnMediaOn);
64
- var isMediaSelected = isCommentOnMediaOn && (0, _mediaSingle.currentMediaNodeWithPos)(state);
62
+ var selectionValid = (0, _utils2.isSelectionValid)(state);
63
+ var isMediaSelected = (0, _mediaSingle.currentMediaNodeWithPos)(state);
65
64
 
66
65
  // comments on media can only be added via media floating toolbar
67
66
  if (isMediaSelected || selectionValid === _types.AnnotationSelectionType.INVALID) {
@@ -108,9 +107,9 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
108
107
  }
109
108
 
110
109
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
111
- * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
110
+ * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
112
111
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
113
- */
112
+ */
114
113
  if (isNonTextInlineNodeInludedInComment && selectionValid === _types.AnnotationSelectionType.VALID && (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes_spotlight')) {
115
114
  var _api$engagementPlatfo3;
116
115
  api === null || api === void 0 || (_api$engagementPlatfo3 = api.engagementPlatform) === null || _api$engagementPlatfo3 === void 0 || _api$engagementPlatfo3.actions.startMessage('inline-comments-on-inline-node-spotlight');
@@ -48,7 +48,8 @@ function InlineCommentView(_ref) {
48
48
  bookmark = _ref2.bookmark,
49
49
  selectedAnnotations = _ref2.selectedAnnotations,
50
50
  annotations = _ref2.annotations,
51
- isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed;
51
+ isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed,
52
+ isOpeningMediaCommentFromToolbar = _ref2.isOpeningMediaCommentFromToolbar;
52
53
  var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
53
54
  var selection = (0, _utils3.getSelectionPositions)(state, inlineCommentState);
54
55
  var position = findPosForDOM(selection);
@@ -104,7 +105,8 @@ function InlineCommentView(_ref) {
104
105
  (0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
105
106
  !editorView.hasFocus() && editorView.focus();
106
107
  },
107
- inlineNodeTypes: inlineNodeTypes
108
+ inlineNodeTypes: inlineNodeTypes,
109
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
108
110
  }));
109
111
  }
110
112
 
@@ -165,6 +167,7 @@ function InlineCommentView(_ref) {
165
167
  },
166
168
  onClose: function onClose() {
167
169
  (0, _commands.closeComponent)()(editorView.state, editorView.dispatch);
168
- }
170
+ },
171
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
169
172
  }));
170
173
  }
package/dist/cjs/utils.js CHANGED
@@ -315,15 +315,15 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
315
315
  };
316
316
  return payload;
317
317
  };
318
- var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
318
+ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state) {
319
319
  var _currentMediaNodeWith;
320
- var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
320
+ var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
321
321
  var selection = state.selection;
322
322
  var _ref4 = getPluginState(state) || {},
323
323
  disallowOnWhitespace = _ref4.disallowOnWhitespace;
324
324
 
325
325
  // Allow media so that it can enter draft mode
326
- if (isCommentOnMediaOn && (_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
326
+ if ((_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
327
327
  return _types.AnnotationSelectionType.VALID;
328
328
  }
329
329
  if (selection.empty || !(selection instanceof _state.TextSelection || selection instanceof _state.AllSelection)) {
@@ -94,10 +94,10 @@ export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (st
94
94
  }
95
95
  return true;
96
96
  };
97
- const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) => {
97
+ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) => {
98
98
  return editorState => {
99
99
  // validate selection only when entering draft mode
100
- if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
100
+ if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
101
101
  return false;
102
102
  }
103
103
  return {
@@ -106,9 +106,9 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMe
106
106
  drafting,
107
107
  editorState,
108
108
  targetType,
109
- isCommentOnMediaOn,
110
109
  supportedBlockNodes,
111
- targetNodeId
110
+ targetNodeId,
111
+ isOpeningMediaCommentFromToolbar
112
112
  }
113
113
  };
114
114
  };
@@ -118,7 +118,7 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMe
118
118
  * Show active inline comments for a given block node, otherwise,
119
119
  * return false if the node has no comments or no unresolved comments.
120
120
  */
121
- export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node, viewMethod) => (state, dispatch) => {
121
+ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node, viewMethod, isOpeningMediaCommentFromToolbar) => (state, dispatch) => {
122
122
  const pluginState = getPluginState(state);
123
123
  const {
124
124
  annotation
@@ -137,7 +137,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
137
137
  type: ACTIONS.SET_SELECTED_ANNOTATION,
138
138
  data: {
139
139
  selectedAnnotations: unresolvedAnnotationMarks,
140
- selectAnnotationMethod: viewMethod
140
+ selectAnnotationMethod: viewMethod,
141
+ isOpeningMediaCommentFromToolbar
141
142
  }
142
143
  }));
143
144
  return true;
@@ -146,8 +147,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
146
147
  }
147
148
  return false;
148
149
  };
149
- export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false, targetNodeId = undefined) => {
150
- const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
150
+ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
151
+ const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
151
152
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
152
153
  };
153
154
  export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
@@ -81,7 +81,6 @@ export const annotationPlugin = ({
81
81
  state,
82
82
  intl,
83
83
  isToolbarAbove,
84
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
85
84
  api
86
85
  });
87
86
  }
@@ -45,7 +45,6 @@ export const shouldClearBookMarkCheck = (tr, editorState, bookmark) => {
45
45
  return true;
46
46
  };
47
47
  const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
48
- var _pluginState$featureF;
49
48
  if (pluginState.skipSelectionHandling) {
50
49
  return {
51
50
  ...pluginState,
@@ -55,7 +54,7 @@ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
55
54
  })
56
55
  };
57
56
  }
58
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
57
+ if (
59
58
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
60
59
  // we keep it as it is so that we can show comment view component with the newly created comment
61
60
  isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
@@ -102,8 +101,7 @@ export const {
102
101
  mapping: (tr, pluginState, editorState) => {
103
102
  let {
104
103
  draftDecorationSet,
105
- bookmark,
106
- featureFlagsPluginState
104
+ bookmark
107
105
  } = pluginState;
108
106
  let mappedDecorationSet = DecorationSet.empty,
109
107
  mappedBookmark;
@@ -111,19 +109,17 @@ export const {
111
109
  if (draftDecorationSet) {
112
110
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
113
111
  }
114
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
115
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, spec => Object.values(decorationKey).includes(spec.key)).length > 0;
112
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, spec => Object.values(decorationKey).includes(spec.key)).length > 0;
116
113
 
117
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
118
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
119
- // We only perform this change when document selection has changed.
120
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
121
- return {
122
- ...pluginState,
123
- draftDecorationSet: mappedDecorationSet,
124
- bookmark: undefined
125
- };
126
- }
114
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
115
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
116
+ // We only perform this change when document selection has changed.
117
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
118
+ return {
119
+ ...pluginState,
120
+ draftDecorationSet: mappedDecorationSet,
121
+ bookmark: undefined
122
+ };
127
123
  }
128
124
  if (bookmark) {
129
125
  mappedBookmark = bookmark.map(tr.mapping);
@@ -18,7 +18,7 @@ export default ((pluginState, action) => {
18
18
  mouseData
19
19
  };
20
20
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
21
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
21
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
22
22
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
23
23
  return {
24
24
  ...pluginState,
@@ -29,7 +29,8 @@ export default ((pluginState, action) => {
29
29
  return {
30
30
  ...pluginState,
31
31
  isInlineCommentViewClosed: true,
32
- isDrafting: false
32
+ isDrafting: false,
33
+ isOpeningMediaCommentFromToolbar: false
33
34
  };
34
35
  case ACTIONS.ADD_INLINE_COMMENT:
35
36
  const updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -60,13 +61,14 @@ export default ((pluginState, action) => {
60
61
  selectedAnnotations: [...action.data.selectedAnnotations],
61
62
  selectAnnotationMethod: action.data.selectAnnotationMethod,
62
63
  skipSelectionHandling: true,
63
- isInlineCommentViewClosed: false
64
+ isInlineCommentViewClosed: false,
65
+ isOpeningMediaCommentFromToolbar: action.data.isOpeningMediaCommentFromToolbar
64
66
  };
65
67
  default:
66
68
  return pluginState;
67
69
  }
68
70
  });
69
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
71
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
70
72
  let {
71
73
  draftDecorationSet
72
74
  } = pluginState;
@@ -85,9 +87,10 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
85
87
  const {
86
88
  from,
87
89
  to
88
- } = isCommentOnMediaOn ? resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc);
90
+ } = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes);
89
91
  const draftDecoration = addDraftDecoration(from, to, targetType);
90
92
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
91
93
  }
94
+ newState.isOpeningMediaCommentFromToolbar = isOpeningMediaCommentFromToolbar;
92
95
  return newState;
93
96
  }
@@ -45,15 +45,14 @@ export const buildToolbar = editorAnalyticsAPI => ({
45
45
  state,
46
46
  intl,
47
47
  isToolbarAbove = false,
48
- isCommentOnMediaOn,
49
48
  _supportedNodes = [],
50
49
  api
51
50
  }) => {
52
51
  const {
53
52
  schema
54
53
  } = state;
55
- const selectionValid = isSelectionValid(state, isCommentOnMediaOn);
56
- const isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
54
+ const selectionValid = isSelectionValid(state);
55
+ const isMediaSelected = currentMediaNodeWithPos(state);
57
56
 
58
57
  // comments on media can only be added via media floating toolbar
59
58
  if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
@@ -98,9 +97,9 @@ export const buildToolbar = editorAnalyticsAPI => ({
98
97
  }
99
98
 
100
99
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
101
- * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
100
+ * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
102
101
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
103
- */
102
+ */
104
103
  if (isNonTextInlineNodeInludedInComment && selectionValid === AnnotationSelectionType.VALID && fg('editor_inline_comments_on_inline_nodes_spotlight')) {
105
104
  var _api$engagementPlatfo4;
106
105
  api === null || api === void 0 ? void 0 : (_api$engagementPlatfo4 = api.engagementPlatform) === null || _api$engagementPlatfo4 === void 0 ? void 0 : _api$engagementPlatfo4.actions.startMessage('inline-comments-on-inline-node-spotlight');
@@ -47,7 +47,8 @@ export function InlineCommentView({
47
47
  bookmark,
48
48
  selectedAnnotations,
49
49
  annotations,
50
- isInlineCommentViewClosed
50
+ isInlineCommentViewClosed,
51
+ isOpeningMediaCommentFromToolbar
51
52
  } = inlineCommentState || {};
52
53
  const annotationsList = getAllAnnotations(editorView.state.doc);
53
54
  const selection = getSelectionPositions(state, inlineCommentState);
@@ -104,7 +105,8 @@ export function InlineCommentView({
104
105
  setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
105
106
  !editorView.hasFocus() && editorView.focus();
106
107
  },
107
- inlineNodeTypes: inlineNodeTypes
108
+ inlineNodeTypes: inlineNodeTypes,
109
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
108
110
  }));
109
111
  }
110
112
 
@@ -160,6 +162,7 @@ export function InlineCommentView({
160
162
  }, RESOLVE_METHOD.COMPONENT)(editorView.state, editorView.dispatch),
161
163
  onClose: () => {
162
164
  closeComponent()(editorView.state, editorView.dispatch);
163
- }
165
+ },
166
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
164
167
  }));
165
168
  }
@@ -278,7 +278,7 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
278
278
  };
279
279
  return payload;
280
280
  };
281
- export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []) => {
281
+ export const isSelectionValid = (state, _supportedNodes = []) => {
282
282
  var _currentMediaNodeWith;
283
283
  const {
284
284
  selection
@@ -288,7 +288,7 @@ export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []
288
288
  } = getPluginState(state) || {};
289
289
 
290
290
  // Allow media so that it can enter draft mode
291
- if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
291
+ if ((_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
292
292
  return AnnotationSelectionType.VALID;
293
293
  }
294
294
  if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
@@ -105,10 +105,10 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
105
105
  return true;
106
106
  };
107
107
  };
108
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
108
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) {
109
109
  return function (editorState) {
110
110
  // validate selection only when entering draft mode
111
- if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
111
+ if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
112
112
  return false;
113
113
  }
114
114
  return {
@@ -117,9 +117,9 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
117
117
  drafting: drafting,
118
118
  editorState: editorState,
119
119
  targetType: targetType,
120
- isCommentOnMediaOn: isCommentOnMediaOn,
121
120
  supportedBlockNodes: supportedBlockNodes,
122
- targetNodeId: targetNodeId
121
+ targetNodeId: targetNodeId,
122
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
123
123
  }
124
124
  };
125
125
  };
@@ -131,7 +131,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
131
131
  */
132
132
  export var showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
133
133
  var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
134
- return function (node, viewMethod) {
134
+ return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
135
135
  return function (state, dispatch) {
136
136
  var pluginState = getPluginState(state);
137
137
  var annotation = state.schema.marks.annotation;
@@ -153,7 +153,8 @@ export var showInlineCommentForBlockNode = function showInlineCommentForBlockNod
153
153
  type: ACTIONS.SET_SELECTED_ANNOTATION,
154
154
  data: {
155
155
  selectedAnnotations: unresolvedAnnotationMarks,
156
- selectAnnotationMethod: viewMethod
156
+ selectAnnotationMethod: viewMethod,
157
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
157
158
  }
158
159
  }));
159
160
  return true;
@@ -169,9 +170,9 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
169
170
  return function (drafting) {
170
171
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
171
172
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
172
- var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
173
- var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
174
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
173
+ var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
174
+ var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
175
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
175
176
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
176
177
  };
177
178
  };
@@ -79,7 +79,6 @@ export var annotationPlugin = function annotationPlugin(_ref) {
79
79
  state: state,
80
80
  intl: intl,
81
81
  isToolbarAbove: isToolbarAbove,
82
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
83
82
  api: api
84
83
  });
85
84
  }
@@ -48,7 +48,6 @@ export var shouldClearBookMarkCheck = function shouldClearBookMarkCheck(tr, edit
48
48
  };
49
49
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
50
50
  return function (tr, pluginState) {
51
- var _pluginState$featureF;
52
51
  if (pluginState.skipSelectionHandling) {
53
52
  return _objectSpread(_objectSpread({}, pluginState), {}, {
54
53
  skipSelectionHandling: false
@@ -56,7 +55,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
56
55
  isInlineCommentViewClosed: false
57
56
  });
58
57
  }
59
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
58
+ if (
60
59
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
61
60
  // we keep it as it is so that we can show comment view component with the newly created comment
62
61
  isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
@@ -92,28 +91,25 @@ var _pluginFactory = pluginFactory(inlineCommentPluginKey, reducer, {
92
91
  onDocChanged: handleDocChanged,
93
92
  mapping: function mapping(tr, pluginState, editorState) {
94
93
  var draftDecorationSet = pluginState.draftDecorationSet,
95
- bookmark = pluginState.bookmark,
96
- featureFlagsPluginState = pluginState.featureFlagsPluginState;
94
+ bookmark = pluginState.bookmark;
97
95
  var mappedDecorationSet = DecorationSet.empty,
98
96
  mappedBookmark;
99
97
  var hasMappedDecorations = false;
100
98
  if (draftDecorationSet) {
101
99
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
102
100
  }
103
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
104
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
105
- return Object.values(decorationKey).includes(spec.key);
106
- }).length > 0;
101
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
102
+ return Object.values(decorationKey).includes(spec.key);
103
+ }).length > 0;
107
104
 
108
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
109
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
110
- // We only perform this change when document selection has changed.
111
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
112
- return _objectSpread(_objectSpread({}, pluginState), {}, {
113
- draftDecorationSet: mappedDecorationSet,
114
- bookmark: undefined
115
- });
116
- }
105
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
106
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
107
+ // We only perform this change when document selection has changed.
108
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
109
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
110
+ draftDecorationSet: mappedDecorationSet,
111
+ bookmark: undefined
112
+ });
117
113
  }
118
114
  if (bookmark) {
119
115
  mappedBookmark = bookmark.map(tr.mapping);
@@ -17,7 +17,7 @@ export default (function (pluginState, action) {
17
17
  mouseData: mouseData
18
18
  });
19
19
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
20
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
20
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
21
21
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
22
22
  return _objectSpread(_objectSpread({}, pluginState), {}, {
23
23
  dirtyAnnotations: false,
@@ -26,7 +26,8 @@ export default (function (pluginState, action) {
26
26
  case ACTIONS.CLOSE_COMPONENT:
27
27
  return _objectSpread(_objectSpread({}, pluginState), {}, {
28
28
  isInlineCommentViewClosed: true,
29
- isDrafting: false
29
+ isDrafting: false,
30
+ isOpeningMediaCommentFromToolbar: false
30
31
  });
31
32
  case ACTIONS.ADD_INLINE_COMMENT:
32
33
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -49,13 +50,14 @@ export default (function (pluginState, action) {
49
50
  selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations),
50
51
  selectAnnotationMethod: action.data.selectAnnotationMethod,
51
52
  skipSelectionHandling: true,
52
- isInlineCommentViewClosed: false
53
+ isInlineCommentViewClosed: false,
54
+ isOpeningMediaCommentFromToolbar: action.data.isOpeningMediaCommentFromToolbar
53
55
  });
54
56
  default:
55
57
  return pluginState;
56
58
  }
57
59
  });
58
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
60
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
59
61
  var draftDecorationSet = pluginState.draftDecorationSet;
60
62
  if (!draftDecorationSet || !drafting) {
61
63
  draftDecorationSet = DecorationSet.empty;
@@ -68,11 +70,12 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
68
70
  newState.bookmark = undefined;
69
71
  if (drafting && editorState) {
70
72
  newState.bookmark = editorState.selection.getBookmark();
71
- var _ref = isCommentOnMediaOn ? resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc),
72
- from = _ref.from,
73
- to = _ref.to;
73
+ var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes),
74
+ from = _resolveDraftBookmark.from,
75
+ to = _resolveDraftBookmark.to;
74
76
  var draftDecoration = addDraftDecoration(from, to, targetType);
75
77
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
76
78
  }
79
+ newState.isOpeningMediaCommentFromToolbar = isOpeningMediaCommentFromToolbar;
77
80
  return newState;
78
81
  }
@@ -48,13 +48,12 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
48
48
  intl = _ref2.intl,
49
49
  _ref2$isToolbarAbove = _ref2.isToolbarAbove,
50
50
  isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
51
- isCommentOnMediaOn = _ref2.isCommentOnMediaOn,
52
51
  _ref2$_supportedNodes = _ref2._supportedNodes,
53
52
  _supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
54
53
  api = _ref2.api;
55
54
  var schema = state.schema;
56
- var selectionValid = isSelectionValid(state, isCommentOnMediaOn);
57
- var isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
55
+ var selectionValid = isSelectionValid(state);
56
+ var isMediaSelected = currentMediaNodeWithPos(state);
58
57
 
59
58
  // comments on media can only be added via media floating toolbar
60
59
  if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
@@ -101,9 +100,9 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
101
100
  }
102
101
 
103
102
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
104
- * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
103
+ * Attempt to fire a spotlight to guide the user to create an inline comment on the inline node.
105
104
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
106
- */
105
+ */
107
106
  if (isNonTextInlineNodeInludedInComment && selectionValid === AnnotationSelectionType.VALID && fg('editor_inline_comments_on_inline_nodes_spotlight')) {
108
107
  var _api$engagementPlatfo3;
109
108
  api === null || api === void 0 || (_api$engagementPlatfo3 = api.engagementPlatform) === null || _api$engagementPlatfo3 === void 0 || _api$engagementPlatfo3.actions.startMessage('inline-comments-on-inline-node-spotlight');
@@ -41,7 +41,8 @@ export function InlineCommentView(_ref) {
41
41
  bookmark = _ref2.bookmark,
42
42
  selectedAnnotations = _ref2.selectedAnnotations,
43
43
  annotations = _ref2.annotations,
44
- isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed;
44
+ isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed,
45
+ isOpeningMediaCommentFromToolbar = _ref2.isOpeningMediaCommentFromToolbar;
45
46
  var annotationsList = getAllAnnotations(editorView.state.doc);
46
47
  var selection = getSelectionPositions(state, inlineCommentState);
47
48
  var position = findPosForDOM(selection);
@@ -97,7 +98,8 @@ export function InlineCommentView(_ref) {
97
98
  setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
98
99
  !editorView.hasFocus() && editorView.focus();
99
100
  },
100
- inlineNodeTypes: inlineNodeTypes
101
+ inlineNodeTypes: inlineNodeTypes,
102
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
101
103
  }));
102
104
  }
103
105
 
@@ -158,6 +160,7 @@ export function InlineCommentView(_ref) {
158
160
  },
159
161
  onClose: function onClose() {
160
162
  closeComponent()(editorView.state, editorView.dispatch);
161
- }
163
+ },
164
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
162
165
  }));
163
166
  }
package/dist/esm/utils.js CHANGED
@@ -288,15 +288,15 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
288
288
  };
289
289
  return payload;
290
290
  };
291
- export var isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
291
+ export var isSelectionValid = function isSelectionValid(state) {
292
292
  var _currentMediaNodeWith;
293
- var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
293
+ var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
294
294
  var selection = state.selection;
295
295
  var _ref4 = getPluginState(state) || {},
296
296
  disallowOnWhitespace = _ref4.disallowOnWhitespace;
297
297
 
298
298
  // Allow media so that it can enter draft mode
299
- if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
299
+ if ((_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
300
300
  return AnnotationSelectionType.VALID;
301
301
  }
302
302
  if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
@@ -13,8 +13,8 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
13
13
  * Show active inline comments for a given block node, otherwise,
14
14
  * return false if the node has no comments or no unresolved comments.
15
15
  */
16
- export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD) => Command;
17
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
16
+ export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
17
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
18
18
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
19
19
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
20
20
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -112,8 +112,8 @@ declare const _default: {
112
112
  }, import("@atlaskit/editor-plugin-engagement-platform").EngagementPlatformPluginConfig>>];
113
113
  actions: {
114
114
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
115
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
116
- showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined) => import("@atlaskit/editor-common/types").Command;
115
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
116
+ showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
117
117
  };
118
118
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
119
119
  handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -1,6 +1,6 @@
1
1
  import type { EditorAnalyticsAPI, VIEW_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
- import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
4
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
5
5
  import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
@@ -38,9 +38,9 @@ export type InlineCommentAction = {
38
38
  drafting: boolean;
39
39
  editorState: EditorState;
40
40
  targetType?: TargetType;
41
- isCommentOnMediaOn?: boolean;
42
41
  supportedBlockNodes?: string[];
43
42
  targetNodeId?: string;
43
+ isOpeningMediaCommentFromToolbar?: boolean;
44
44
  };
45
45
  } | {
46
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -69,6 +69,7 @@ export type InlineCommentAction = {
69
69
  data: {
70
70
  selectedAnnotations: AnnotationInfo[];
71
71
  selectAnnotationMethod?: VIEW_METHOD;
72
+ isOpeningMediaCommentFromToolbar?: boolean;
72
73
  };
73
74
  };
74
75
  export type InlineCommentPluginState = {
@@ -86,4 +87,5 @@ export type InlineCommentPluginState = {
86
87
  isDrafting: boolean;
87
88
  targetNodeId?: string;
88
89
  selectAnnotationMethod?: VIEW_METHOD;
90
+ isOpeningMediaCommentFromToolbar?: boolean;
89
91
  };
@@ -11,5 +11,5 @@ interface BuildToolbarOptions {
11
11
  _supportedNodes?: string[];
12
12
  api?: ExtractInjectionAPI<AnnotationPlugin>;
13
13
  }
14
- export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, isCommentOnMediaOn, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
14
+ export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
15
15
  export {};
@@ -23,9 +23,7 @@ export type TargetType = 'block' | 'inline';
23
23
  export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
24
24
  type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
25
25
  /** @default 'inline' */
26
- targetType?: TargetType,
27
- /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
28
- isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string, isOpeningMediaCommentFromToolbar?: boolean) => Command;
29
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
30
28
  pluginConfiguration: AnnotationProviders | undefined;
31
29
  sharedState: InlineCommentPluginState | undefined;
@@ -71,6 +69,10 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
71
69
  onCreate: (id: string) => void;
72
70
  /** List of inline node types, which are wrapped by the annotation. */
73
71
  inlineNodeTypes: string[] | undefined;
72
+ /**
73
+ * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
74
+ */
75
+ isOpeningMediaCommentFromToolbar?: boolean;
74
76
  };
75
77
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
76
78
  /**
@@ -100,6 +102,10 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
100
102
  * `editor_inline_comments_on_inline_nodes` is removed.
101
103
  */
102
104
  getInlineNodeTypes: (annotationId: string) => string[] | undefined;
105
+ /**
106
+ * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
107
+ */
108
+ isOpeningMediaCommentFromToolbar?: boolean;
103
109
  };
104
110
  export interface AnnotationState<Type, State> {
105
111
  annotationType: Type;
@@ -34,7 +34,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
34
34
  * get payload for the open/close analytics event
35
35
  */
36
36
  export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
37
- export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
37
+ export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType;
38
38
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
39
39
  export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean;
40
40
  /**
@@ -13,8 +13,8 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
13
13
  * Show active inline comments for a given block node, otherwise,
14
14
  * return false if the node has no comments or no unresolved comments.
15
15
  */
16
- export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD) => Command;
17
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
16
+ export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
17
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
18
18
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
19
19
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
20
20
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -134,8 +134,8 @@ declare const _default: {
134
134
  ];
135
135
  actions: {
136
136
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
137
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
138
- showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined) => import("@atlaskit/editor-common/types").Command;
137
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
138
+ showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
139
139
  };
140
140
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
141
141
  handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -1,6 +1,6 @@
1
1
  import type { EditorAnalyticsAPI, VIEW_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
- import { type PortalProviderAPI } from '@atlaskit/editor-common/src/portal';
3
+ import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
4
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
5
5
  import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
6
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
@@ -38,9 +38,9 @@ export type InlineCommentAction = {
38
38
  drafting: boolean;
39
39
  editorState: EditorState;
40
40
  targetType?: TargetType;
41
- isCommentOnMediaOn?: boolean;
42
41
  supportedBlockNodes?: string[];
43
42
  targetNodeId?: string;
43
+ isOpeningMediaCommentFromToolbar?: boolean;
44
44
  };
45
45
  } | {
46
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -69,6 +69,7 @@ export type InlineCommentAction = {
69
69
  data: {
70
70
  selectedAnnotations: AnnotationInfo[];
71
71
  selectAnnotationMethod?: VIEW_METHOD;
72
+ isOpeningMediaCommentFromToolbar?: boolean;
72
73
  };
73
74
  };
74
75
  export type InlineCommentPluginState = {
@@ -86,4 +87,5 @@ export type InlineCommentPluginState = {
86
87
  isDrafting: boolean;
87
88
  targetNodeId?: string;
88
89
  selectAnnotationMethod?: VIEW_METHOD;
90
+ isOpeningMediaCommentFromToolbar?: boolean;
89
91
  };
@@ -11,5 +11,5 @@ interface BuildToolbarOptions {
11
11
  _supportedNodes?: string[];
12
12
  api?: ExtractInjectionAPI<AnnotationPlugin>;
13
13
  }
14
- export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, isCommentOnMediaOn, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
14
+ export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
15
15
  export {};
@@ -23,9 +23,7 @@ export type TargetType = 'block' | 'inline';
23
23
  export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
24
24
  type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
25
25
  /** @default 'inline' */
26
- targetType?: TargetType,
27
- /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
28
- isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string, isOpeningMediaCommentFromToolbar?: boolean) => Command;
29
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
30
28
  pluginConfiguration: AnnotationProviders | undefined;
31
29
  sharedState: InlineCommentPluginState | undefined;
@@ -71,6 +69,10 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
71
69
  onCreate: (id: string) => void;
72
70
  /** List of inline node types, which are wrapped by the annotation. */
73
71
  inlineNodeTypes: string[] | undefined;
72
+ /**
73
+ * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
74
+ */
75
+ isOpeningMediaCommentFromToolbar?: boolean;
74
76
  };
75
77
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
76
78
  /**
@@ -100,6 +102,10 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
100
102
  * `editor_inline_comments_on_inline_nodes` is removed.
101
103
  */
102
104
  getInlineNodeTypes: (annotationId: string) => string[] | undefined;
105
+ /**
106
+ * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
107
+ */
108
+ isOpeningMediaCommentFromToolbar?: boolean;
103
109
  };
104
110
  export interface AnnotationState<Type, State> {
105
111
  annotationType: Type;
@@ -34,7 +34,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
34
34
  * get payload for the open/close analytics event
35
35
  */
36
36
  export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
37
- export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
37
+ export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType;
38
38
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
39
39
  export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean;
40
40
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.23.2",
3
+ "version": "1.24.0",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -10,7 +10,7 @@
10
10
  "atlassian": {
11
11
  "team": "Editor: AI",
12
12
  "singleton": true,
13
- "runReact18": false
13
+ "runReact18": true
14
14
  },
15
15
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
16
16
  "main": "dist/cjs/index.js",
@@ -32,16 +32,16 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^44.2.0",
35
- "@atlaskit/editor-common": "^94.9.0",
35
+ "@atlaskit/editor-common": "^94.21.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
37
37
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^1.1.0",
38
38
  "@atlaskit/editor-plugin-engagement-platform": "^2.1.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.2.0",
40
40
  "@atlaskit/editor-prosemirror": "6.0.0",
41
41
  "@atlaskit/icon": "^22.24.0",
42
- "@atlaskit/onboarding": "^12.0.0",
42
+ "@atlaskit/onboarding": "^12.1.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
44
- "@atlaskit/tmp-editor-statsig": "^2.10.0",
44
+ "@atlaskit/tmp-editor-statsig": "^2.16.0",
45
45
  "@babel/runtime": "^7.0.0"
46
46
  },
47
47
  "peerDependencies": {