@atlaskit/editor-plugin-annotation 2.6.0 → 2.7.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,17 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#143244](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/143244)
8
+ [`569fc7473a725`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/569fc7473a725) -
9
+ adding event to platform to close inline comment in editor
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 2.6.0
4
16
 
5
17
  ### Minor Changes
@@ -40,13 +40,9 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
40
40
 
41
41
  // The mark may not be applied to the current "head" of the bookmark so determine what was applied
42
42
  // above and use that instead
43
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_missing_selected_annotations')) {
44
- var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
45
- var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
46
- _tr.setSelection(_state.TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
47
- } else {
48
- _tr.setSelection(_state.TextSelection.create(_tr.doc, head));
49
- }
43
+ var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
44
+ var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
45
+ _tr.setSelection(_state.TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
50
46
  }
51
47
  return tr;
52
48
  };
@@ -216,9 +216,12 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
216
216
  var removeHoveredannotationFn = function removeHoveredannotationFn() {
217
217
  (0, _editorCommands.setHoveredAnnotation)('')(editorView.state, editorView.dispatch);
218
218
  };
219
+ var closeInlineCommentFn = function closeInlineCommentFn() {
220
+ (0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
221
+ };
219
222
  var updateSubscriber = provider.updateSubscriber;
220
223
  if (updateSubscriber) {
221
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn);
224
+ updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn).on('closeinlinecomment', closeInlineCommentFn);
222
225
  }
223
226
 
224
227
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -251,7 +254,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
251
254
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
252
255
  editorView.root.removeEventListener('mouseup', mouseUp);
253
256
  if (updateSubscriber) {
254
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn);
257
+ updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
255
258
  }
256
259
  }
257
260
  };
@@ -189,25 +189,17 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
189
189
  var annotationMark = doc.type.schema.marks.annotation;
190
190
  var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
191
191
  var marks = [];
192
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_missing_selected_annotations')) {
193
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
194
- marks = anchorAnnotationMarks;
195
- }
196
- if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
197
- var _marks;
198
- var existingMarkIds = marks.map(function (m) {
199
- return m.attrs.id;
200
- });
201
- marks = (_marks = marks).concat.apply(_marks, (0, _toConsumableArray2.default)(nodeBefore.marks.filter(function (m) {
202
- return !existingMarkIds.includes(m.attrs.id);
203
- })));
204
- }
205
- } else {
206
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
207
- marks = anchorAnnotationMarks;
208
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
209
- marks = nodeBefore.marks;
210
- }
192
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
193
+ marks = anchorAnnotationMarks;
194
+ }
195
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
196
+ var _marks;
197
+ var existingMarkIds = marks.map(function (m) {
198
+ return m.attrs.id;
199
+ });
200
+ marks = (_marks = marks).concat.apply(_marks, (0, _toConsumableArray2.default)(nodeBefore.marks.filter(function (m) {
201
+ return !existingMarkIds.includes(m.attrs.id);
202
+ })));
211
203
  }
212
204
  var annotations = marks.filter(function (mark) {
213
205
  return mark.type.name === 'annotation';
@@ -102,8 +102,11 @@ function InlineCommentView(_ref) {
102
102
  textSelection: textSelection,
103
103
  onCreate: function onCreate(id) {
104
104
  if (!(0, _platformFeatureFlags.fg)('platform_editor_comments_api_manager')) {
105
- (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
105
+ var createAnnotationResult = (0, _editorCommands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
106
106
  !editorView.hasFocus() && editorView.focus();
107
+ if (!createAnnotationResult && (0, _platformFeatureFlags.fg)('confluence_frontend_handle_annotation_error')) {
108
+ throw new Error('Failed to create annotation');
109
+ }
107
110
  }
108
111
  },
109
112
  onClose: function onClose() {
@@ -33,13 +33,9 @@ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
33
33
 
34
34
  // The mark may not be applied to the current "head" of the bookmark so determine what was applied
35
35
  // above and use that instead
36
- if (fg('platform_editor_fix_missing_selected_annotations')) {
37
- const annotationMarkStep = tr.steps.reverse().find(isAnnotationStep);
38
- const headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
39
- tr.setSelection(TextSelection.create(tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
40
- } else {
41
- tr.setSelection(TextSelection.create(tr.doc, head));
42
- }
36
+ const annotationMarkStep = tr.steps.reverse().find(isAnnotationStep);
37
+ const headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
38
+ tr.setSelection(TextSelection.create(tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
43
39
  }
44
40
  return tr;
45
41
  };
@@ -148,11 +148,14 @@ export const inlineCommentPlugin = options => {
148
148
  const removeHoveredannotationFn = () => {
149
149
  setHoveredAnnotation('')(editorView.state, editorView.dispatch);
150
150
  };
151
+ const closeInlineCommentFn = () => {
152
+ closeComponent()(editorView.state, editorView.dispatch);
153
+ };
151
154
  const {
152
155
  updateSubscriber
153
156
  } = provider;
154
157
  if (updateSubscriber) {
155
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn);
158
+ updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn).on('closeinlinecomment', closeInlineCommentFn);
156
159
  }
157
160
 
158
161
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -188,7 +191,7 @@ export const inlineCommentPlugin = options => {
188
191
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
189
192
  editorView.root.removeEventListener('mouseup', mouseUp);
190
193
  if (updateSubscriber) {
191
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn);
194
+ updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
192
195
  }
193
196
  }
194
197
  };
@@ -159,20 +159,12 @@ export const findAnnotationsInSelection = (selection, doc) => {
159
159
  const annotationMark = doc.type.schema.marks.annotation;
160
160
  const anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
161
161
  let marks = [];
162
- if (fg('platform_editor_fix_missing_selected_annotations')) {
163
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
164
- marks = anchorAnnotationMarks;
165
- }
166
- if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
167
- const existingMarkIds = marks.map(m => m.attrs.id);
168
- marks = marks.concat(...nodeBefore.marks.filter(m => !existingMarkIds.includes(m.attrs.id)));
169
- }
170
- } else {
171
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
172
- marks = anchorAnnotationMarks;
173
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
174
- marks = nodeBefore.marks;
175
- }
162
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
163
+ marks = anchorAnnotationMarks;
164
+ }
165
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
166
+ const existingMarkIds = marks.map(m => m.attrs.id);
167
+ marks = marks.concat(...nodeBefore.marks.filter(m => !existingMarkIds.includes(m.attrs.id)));
176
168
  }
177
169
  const annotations = marks.filter(mark => mark.type.name === 'annotation').map(mark => ({
178
170
  id: mark.attrs.id,
@@ -102,8 +102,11 @@ export function InlineCommentView({
102
102
  textSelection: textSelection,
103
103
  onCreate: id => {
104
104
  if (!fg('platform_editor_comments_api_manager')) {
105
- createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
105
+ const createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
106
106
  !editorView.hasFocus() && editorView.focus();
107
+ if (!createAnnotationResult && fg('confluence_frontend_handle_annotation_error')) {
108
+ throw new Error('Failed to create annotation');
109
+ }
107
110
  }
108
111
  },
109
112
  onClose: () => {
@@ -34,13 +34,9 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
34
34
 
35
35
  // The mark may not be applied to the current "head" of the bookmark so determine what was applied
36
36
  // above and use that instead
37
- if (fg('platform_editor_fix_missing_selected_annotations')) {
38
- var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
39
- var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
40
- _tr.setSelection(TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
41
- } else {
42
- _tr.setSelection(TextSelection.create(_tr.doc, head));
43
- }
37
+ var annotationMarkStep = _tr.steps.reverse().find(isAnnotationStep);
38
+ var headBasedOnMark = from === head ? annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.from : annotationMarkStep === null || annotationMarkStep === void 0 ? void 0 : annotationMarkStep.to;
39
+ _tr.setSelection(TextSelection.create(_tr.doc, headBasedOnMark !== null && headBasedOnMark !== void 0 ? headBasedOnMark : head));
44
40
  }
45
41
  return tr;
46
42
  };
@@ -209,9 +209,12 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
209
209
  var removeHoveredannotationFn = function removeHoveredannotationFn() {
210
210
  setHoveredAnnotation('')(editorView.state, editorView.dispatch);
211
211
  };
212
+ var closeInlineCommentFn = function closeInlineCommentFn() {
213
+ closeComponent()(editorView.state, editorView.dispatch);
214
+ };
212
215
  var updateSubscriber = provider.updateSubscriber;
213
216
  if (updateSubscriber) {
214
- updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn);
217
+ updateSubscriber.on('resolve', resolve).on('delete', resolve).on('unresolve', unResolve).on('create', unResolve).on('setvisibility', setVisibility).on('setselectedannotation', setSelectedAnnotationFn).on('sethoveredannotation', setHoveredAnnotationFn).on('removehoveredannotation', removeHoveredannotationFn).on('closeinlinecomment', closeInlineCommentFn);
215
218
  }
216
219
 
217
220
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
@@ -244,7 +247,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
244
247
  // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
245
248
  editorView.root.removeEventListener('mouseup', mouseUp);
246
249
  if (updateSubscriber) {
247
- updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn);
250
+ updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
248
251
  }
249
252
  }
250
253
  };
@@ -172,25 +172,17 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
172
172
  var annotationMark = doc.type.schema.marks.annotation;
173
173
  var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
174
174
  var marks = [];
175
- if (fg('platform_editor_fix_missing_selected_annotations')) {
176
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
177
- marks = anchorAnnotationMarks;
178
- }
179
- if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
180
- var _marks;
181
- var existingMarkIds = marks.map(function (m) {
182
- return m.attrs.id;
183
- });
184
- marks = (_marks = marks).concat.apply(_marks, _toConsumableArray(nodeBefore.marks.filter(function (m) {
185
- return !existingMarkIds.includes(m.attrs.id);
186
- })));
187
- }
188
- } else {
189
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
190
- marks = anchorAnnotationMarks;
191
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
192
- marks = nodeBefore.marks;
193
- }
175
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
176
+ marks = anchorAnnotationMarks;
177
+ }
178
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
179
+ var _marks;
180
+ var existingMarkIds = marks.map(function (m) {
181
+ return m.attrs.id;
182
+ });
183
+ marks = (_marks = marks).concat.apply(_marks, _toConsumableArray(nodeBefore.marks.filter(function (m) {
184
+ return !existingMarkIds.includes(m.attrs.id);
185
+ })));
194
186
  }
195
187
  var annotations = marks.filter(function (mark) {
196
188
  return mark.type.name === 'annotation';
@@ -95,8 +95,11 @@ export function InlineCommentView(_ref) {
95
95
  textSelection: textSelection,
96
96
  onCreate: function onCreate(id) {
97
97
  if (!fg('platform_editor_comments_api_manager')) {
98
- createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
98
+ var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
99
99
  !editorView.hasFocus() && editorView.focus();
100
+ if (!createAnnotationResult && fg('confluence_frontend_handle_annotation_error')) {
101
+ throw new Error('Failed to create annotation');
102
+ }
100
103
  }
101
104
  },
102
105
  onClose: function onClose() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
- "@atlaskit/editor-common": "^103.9.0",
35
+ "@atlaskit/editor-common": "^103.11.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
37
37
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/icon": "^25.6.0",
42
42
  "@atlaskit/onboarding": "^14.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^4.11.0",
44
+ "@atlaskit/tmp-editor-statsig": "^4.12.0",
45
45
  "@babel/runtime": "^7.0.0"
46
46
  },
47
47
  "peerDependencies": {
@@ -99,9 +99,6 @@
99
99
  "editor_inline_comments_on_inline_nodes": {
100
100
  "type": "boolean"
101
101
  },
102
- "platform_editor_fix_missing_selected_annotations": {
103
- "type": "boolean"
104
- },
105
102
  "use_comments_data_annotation_updater": {
106
103
  "type": "boolean"
107
104
  },
@@ -119,6 +116,9 @@
119
116
  },
120
117
  "confluence_comments_select_comment_experience": {
121
118
  "type": "boolean"
119
+ },
120
+ "confluence_frontend_handle_annotation_error": {
121
+ "type": "boolean"
122
122
  }
123
123
  }
124
124
  }