@atlaskit/editor-plugin-annotation 1.23.3 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
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
+
3
12
  ## 1.23.3
4
13
 
5
14
  ### Patch Changes
@@ -112,7 +112,7 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
112
112
  return true;
113
113
  };
114
114
  };
115
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, 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
118
  if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
@@ -125,7 +125,8 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
125
125
  editorState: editorState,
126
126
  targetType: targetType,
127
127
  supportedBlockNodes: supportedBlockNodes,
128
- targetNodeId: targetNodeId
128
+ targetNodeId: targetNodeId,
129
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
129
130
  }
130
131
  };
131
132
  };
@@ -137,7 +138,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
137
138
  */
138
139
  var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
139
140
  var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
140
- return function (node, viewMethod) {
141
+ return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
141
142
  return function (state, dispatch) {
142
143
  var pluginState = (0, _utils.getPluginState)(state);
143
144
  var annotation = state.schema.marks.annotation;
@@ -159,7 +160,8 @@ var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = func
159
160
  type: _types.ACTIONS.SET_SELECTED_ANNOTATION,
160
161
  data: {
161
162
  selectedAnnotations: unresolvedAnnotationMarks,
162
- selectAnnotationMethod: viewMethod
163
+ selectAnnotationMethod: viewMethod,
164
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
163
165
  }
164
166
  }));
165
167
  return true;
@@ -176,7 +178,8 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
176
178
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
177
179
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
178
180
  var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
179
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes);
181
+ var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
182
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
180
183
  return (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
181
184
  };
182
185
  };
@@ -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.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, 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;
@@ -81,5 +83,6 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
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
  }
@@ -107,9 +107,9 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
107
107
  }
108
108
 
109
109
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
110
- * 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.
111
111
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
112
- */
112
+ */
113
113
  if (isNonTextInlineNodeInludedInComment && selectionValid === _types.AnnotationSelectionType.VALID && (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes_spotlight')) {
114
114
  var _api$engagementPlatfo3;
115
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
  }
@@ -94,7 +94,7 @@ export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (st
94
94
  }
95
95
  return true;
96
96
  };
97
- const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes) => {
97
+ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar) => {
98
98
  return editorState => {
99
99
  // validate selection only when entering draft mode
100
100
  if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
@@ -107,7 +107,8 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBloc
107
107
  editorState,
108
108
  targetType,
109
109
  supportedBlockNodes,
110
- targetNodeId
110
+ targetNodeId,
111
+ isOpeningMediaCommentFromToolbar
111
112
  }
112
113
  };
113
114
  };
@@ -117,7 +118,7 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBloc
117
118
  * Show active inline comments for a given block node, otherwise,
118
119
  * return false if the node has no comments or no unresolved comments.
119
120
  */
120
- export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node, viewMethod) => (state, dispatch) => {
121
+ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node, viewMethod, isOpeningMediaCommentFromToolbar) => (state, dispatch) => {
121
122
  const pluginState = getPluginState(state);
122
123
  const {
123
124
  annotation
@@ -136,7 +137,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
136
137
  type: ACTIONS.SET_SELECTED_ANNOTATION,
137
138
  data: {
138
139
  selectedAnnotations: unresolvedAnnotationMarks,
139
- selectAnnotationMethod: viewMethod
140
+ selectAnnotationMethod: viewMethod,
141
+ isOpeningMediaCommentFromToolbar
140
142
  }
141
143
  }));
142
144
  return true;
@@ -145,8 +147,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
145
147
  }
146
148
  return false;
147
149
  };
148
- export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined) => {
149
- const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, 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);
150
152
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
151
153
  };
152
154
  export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
@@ -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.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, supportedBlockNodes, targetNodeId) {
71
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
70
72
  let {
71
73
  draftDecorationSet
72
74
  } = pluginState;
@@ -89,5 +91,6 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
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
  }
@@ -97,9 +97,9 @@ export const buildToolbar = editorAnalyticsAPI => ({
97
97
  }
98
98
 
99
99
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
100
- * 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.
101
101
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
102
- */
102
+ */
103
103
  if (isNonTextInlineNodeInludedInComment && selectionValid === AnnotationSelectionType.VALID && fg('editor_inline_comments_on_inline_nodes_spotlight')) {
104
104
  var _api$engagementPlatfo4;
105
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
  }
@@ -105,7 +105,7 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
105
105
  return true;
106
106
  };
107
107
  };
108
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, 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
111
  if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
@@ -118,7 +118,8 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
118
118
  editorState: editorState,
119
119
  targetType: targetType,
120
120
  supportedBlockNodes: supportedBlockNodes,
121
- targetNodeId: targetNodeId
121
+ targetNodeId: targetNodeId,
122
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
122
123
  }
123
124
  };
124
125
  };
@@ -130,7 +131,7 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
130
131
  */
131
132
  export var showInlineCommentForBlockNode = function showInlineCommentForBlockNode() {
132
133
  var supportedBlockNodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
133
- return function (node, viewMethod) {
134
+ return function (node, viewMethod, isOpeningMediaCommentFromToolbar) {
134
135
  return function (state, dispatch) {
135
136
  var pluginState = getPluginState(state);
136
137
  var annotation = state.schema.marks.annotation;
@@ -152,7 +153,8 @@ export var showInlineCommentForBlockNode = function showInlineCommentForBlockNod
152
153
  type: ACTIONS.SET_SELECTED_ANNOTATION,
153
154
  data: {
154
155
  selectedAnnotations: unresolvedAnnotationMarks,
155
- selectAnnotationMethod: viewMethod
156
+ selectAnnotationMethod: viewMethod,
157
+ isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar
156
158
  }
157
159
  }));
158
160
  return true;
@@ -169,7 +171,8 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
169
171
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
170
172
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
171
173
  var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
172
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes);
174
+ var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
175
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
173
176
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
174
177
  };
175
178
  };
@@ -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.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, 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;
@@ -74,5 +76,6 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
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
  }
@@ -100,9 +100,9 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
100
100
  }
101
101
 
102
102
  /* When a user selects a valid range of content that includes non-text inline node (e.g. media, mention, emoji, etc.)
103
- * 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.
104
104
  * The spotlight will only be displayed if the user is a valid EP audience and the feature flag is enabled.
105
- */
105
+ */
106
106
  if (isNonTextInlineNodeInludedInComment && selectionValid === AnnotationSelectionType.VALID && fg('editor_inline_comments_on_inline_nodes_spotlight')) {
107
107
  var _api$engagementPlatfo3;
108
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
  }
@@ -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, 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, 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';
@@ -40,6 +40,7 @@ export type InlineCommentAction = {
40
40
  targetType?: TargetType;
41
41
  supportedBlockNodes?: string[];
42
42
  targetNodeId?: string;
43
+ isOpeningMediaCommentFromToolbar?: boolean;
43
44
  };
44
45
  } | {
45
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -68,6 +69,7 @@ export type InlineCommentAction = {
68
69
  data: {
69
70
  selectedAnnotations: AnnotationInfo[];
70
71
  selectAnnotationMethod?: VIEW_METHOD;
72
+ isOpeningMediaCommentFromToolbar?: boolean;
71
73
  };
72
74
  };
73
75
  export type InlineCommentPluginState = {
@@ -85,4 +87,5 @@ export type InlineCommentPluginState = {
85
87
  isDrafting: boolean;
86
88
  targetNodeId?: string;
87
89
  selectAnnotationMethod?: VIEW_METHOD;
90
+ isOpeningMediaCommentFromToolbar?: boolean;
88
91
  };
@@ -23,7 +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, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string, isOpeningMediaCommentFromToolbar?: boolean) => Command;
27
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
28
28
  pluginConfiguration: AnnotationProviders | undefined;
29
29
  sharedState: InlineCommentPluginState | undefined;
@@ -69,6 +69,10 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
69
69
  onCreate: (id: string) => void;
70
70
  /** List of inline node types, which are wrapped by the annotation. */
71
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;
72
76
  };
73
77
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
74
78
  /**
@@ -98,6 +102,10 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
98
102
  * `editor_inline_comments_on_inline_nodes` is removed.
99
103
  */
100
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;
101
109
  };
102
110
  export interface AnnotationState<Type, State> {
103
111
  annotationType: Type;
@@ -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, 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, 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';
@@ -40,6 +40,7 @@ export type InlineCommentAction = {
40
40
  targetType?: TargetType;
41
41
  supportedBlockNodes?: string[];
42
42
  targetNodeId?: string;
43
+ isOpeningMediaCommentFromToolbar?: boolean;
43
44
  };
44
45
  } | {
45
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -68,6 +69,7 @@ export type InlineCommentAction = {
68
69
  data: {
69
70
  selectedAnnotations: AnnotationInfo[];
70
71
  selectAnnotationMethod?: VIEW_METHOD;
72
+ isOpeningMediaCommentFromToolbar?: boolean;
71
73
  };
72
74
  };
73
75
  export type InlineCommentPluginState = {
@@ -85,4 +87,5 @@ export type InlineCommentPluginState = {
85
87
  isDrafting: boolean;
86
88
  targetNodeId?: string;
87
89
  selectAnnotationMethod?: VIEW_METHOD;
90
+ isOpeningMediaCommentFromToolbar?: boolean;
88
91
  };
@@ -23,7 +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, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string, isOpeningMediaCommentFromToolbar?: boolean) => Command;
27
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
28
28
  pluginConfiguration: AnnotationProviders | undefined;
29
29
  sharedState: InlineCommentPluginState | undefined;
@@ -69,6 +69,10 @@ export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
69
69
  onCreate: (id: string) => void;
70
70
  /** List of inline node types, which are wrapped by the annotation. */
71
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;
72
76
  };
73
77
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
74
78
  /**
@@ -98,6 +102,10 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
98
102
  * `editor_inline_comments_on_inline_nodes` is removed.
99
103
  */
100
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;
101
109
  };
102
110
  export interface AnnotationState<Type, State> {
103
111
  annotationType: Type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.23.3",
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.11.0",
44
+ "@atlaskit/tmp-editor-statsig": "^2.16.0",
45
45
  "@babel/runtime": "^7.0.0"
46
46
  },
47
47
  "peerDependencies": {