@atlaskit/editor-plugin-annotation 1.9.5 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#109969](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109969)
8
+ [`52590a0b562ef`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/52590a0b562ef) -
9
+ ED-23690 Adds an attribute to annotation analytic events with the name of nodes inside the
10
+ annotation range
11
+ - [#109932](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109932)
12
+ [`a973fd903870a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a973fd903870a) -
13
+ ED-23649 fixes a variety of issues such as inline nodes not being fully interactive, and missing
14
+ selection visuals when inside an annotation.
15
+ - Updated dependencies
16
+
17
+ ## 1.10.0
18
+
19
+ ### Minor Changes
20
+
21
+ - [#108623](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108623)
22
+ [`c01339668ebde`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c01339668ebde) -
23
+ [ux] ED-23617 Add support in editor for comments on status, emoji, date and mention nodes
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies
28
+
3
29
  ## 1.9.5
4
30
 
5
31
  ### Patch Changes
@@ -7,18 +7,20 @@ exports.default = void 0;
7
7
  var _adfSchema = require("@atlaskit/adf-schema");
8
8
  var _analytics = require("@atlaskit/editor-common/analytics");
9
9
  var _mark = require("@atlaskit/editor-common/mark");
10
+ var _utils = require("@atlaskit/editor-common/utils");
10
11
  var _state = require("@atlaskit/editor-prosemirror/state");
11
- var _utils = require("../utils");
12
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
+ var _utils2 = require("../utils");
12
14
  var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
13
15
  return function (transaction, state) {
14
- var inlineCommentState = (0, _utils.getPluginState)(state);
16
+ var inlineCommentState = (0, _utils2.getPluginState)(state);
15
17
  var _ref = inlineCommentState || {},
16
18
  bookmark = _ref.bookmark;
17
19
  var annotationMark = state.schema.marks.annotation.create({
18
20
  id: id,
19
21
  type: _adfSchema.AnnotationTypes.INLINE_COMMENT
20
22
  });
21
- var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(state, bookmark, supportedBlockNodes),
23
+ var _resolveDraftBookmark = (0, _utils2.resolveDraftBookmark)(state, bookmark, supportedBlockNodes),
22
24
  from = _resolveDraftBookmark.from,
23
25
  to = _resolveDraftBookmark.to,
24
26
  head = _resolveDraftBookmark.head,
@@ -56,7 +58,7 @@ var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
56
58
  return function (drafting) {
57
59
  var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
58
60
  return function (transaction, state) {
59
- var draftingPayload = (0, _utils.getDraftCommandAnalyticsPayload)(drafting, method)(state);
61
+ var draftingPayload = (0, _utils2.getDraftCommandAnalyticsPayload)(drafting, method)(state);
60
62
  editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(draftingPayload)(transaction);
61
63
  return transaction;
62
64
  };
@@ -64,13 +66,26 @@ var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
64
66
  };
65
67
  var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
66
68
  return function (transaction, state) {
67
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
69
+ var analyticsEvent = {
68
70
  action: _analytics.ACTION.INSERTED,
69
71
  actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
70
72
  eventType: _analytics.EVENT_TYPE.TRACK,
71
73
  actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
72
74
  attributes: {}
73
- })(transaction);
75
+ };
76
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
77
+ var _ref2 = (0, _utils2.getPluginState)(state) || {},
78
+ bookmark = _ref2.bookmark;
79
+
80
+ // When this FF is removed we can move the analytics event creation inside of the
81
+ // attachAnalyticsEvent and get type inference for the attributes.
82
+ // @ts-ignore
83
+ analyticsEvent.attributes.inlineNodeNames = (0, _utils.getRangeInlineNodeNames)({
84
+ doc: state.doc,
85
+ pos: (0, _utils2.resolveDraftBookmark)(state, bookmark)
86
+ });
87
+ }
88
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(analyticsEvent)(transaction);
74
89
  return transaction;
75
90
  };
76
91
  };
@@ -12,6 +12,7 @@ var _adfSchema = require("@atlaskit/adf-schema");
12
12
  var _analytics = require("@atlaskit/editor-common/analytics");
13
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
14
14
  var _view = require("@atlaskit/editor-prosemirror/view");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _commands = require("../commands");
16
17
  var _nodeviews = require("../nodeviews");
17
18
  var _utils = require("../utils");
@@ -248,10 +249,25 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
248
249
  key: _utils.decorationKey.block
249
250
  }));
250
251
  } else {
251
- focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
252
- class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
253
- nodeName: 'span'
254
- }));
252
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
253
+ if (node.isText) {
254
+ focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
255
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
256
+ nodeName: 'span'
257
+ }));
258
+ } else {
259
+ focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
260
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
261
+ }, {
262
+ key: _utils.decorationKey.block
263
+ }));
264
+ }
265
+ } else {
266
+ focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
267
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
268
+ nodeName: 'span'
269
+ }));
270
+ }
255
271
  }
256
272
  }
257
273
  });
package/dist/cjs/utils.js CHANGED
@@ -289,6 +289,14 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
289
289
  overlap: getAnnotationsInSelectionCount(state)
290
290
  };
291
291
  }
292
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
293
+ var _ref3 = getPluginState(state) || {},
294
+ bookmark = _ref3.bookmark;
295
+ attributes.inlineNodeNames = (0, _utils.getRangeInlineNodeNames)({
296
+ doc: state.doc,
297
+ pos: resolveDraftBookmark(state, bookmark)
298
+ });
299
+ }
292
300
  return {
293
301
  action: drafting ? _analytics.ACTION.OPENED : _analytics.ACTION.CLOSED,
294
302
  actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
@@ -303,8 +311,8 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
303
311
  var _currentMediaNodeWith;
304
312
  var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
305
313
  var selection = state.selection;
306
- var _ref3 = getPluginState(state) || {},
307
- disallowOnWhitespace = _ref3.disallowOnWhitespace;
314
+ var _ref4 = getPluginState(state) || {},
315
+ disallowOnWhitespace = _ref4.disallowOnWhitespace;
308
316
 
309
317
  // Allow media so that it can enter draft mode
310
318
  if (isCommentOnMediaOn && (_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
@@ -375,30 +383,52 @@ var isSupportedBlockNode = exports.isSupportedBlockNode = function isSupportedBl
375
383
  function hasInvalidWhitespaceNode(selection, schema) {
376
384
  var foundInvalidWhitespace = false;
377
385
  var content = selection.content().content;
386
+ var hasCommentableInlineNodeDescendants = false;
387
+ var hasCommentableTextNodeDescendants = false;
378
388
  content.descendants(function (node) {
389
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
390
+ var isAllowedInlineNode = ['emoji', 'status', 'date', 'mention', 'inlineCard'].includes(node.type.name);
391
+ if (isAllowedInlineNode) {
392
+ hasCommentableInlineNodeDescendants = true;
393
+ return false;
394
+ }
395
+ }
379
396
  if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes') && node.type === schema.nodes.inlineCard) {
380
397
  return false;
381
398
  }
382
399
  if ((0, _utils.isText)(node, schema)) {
400
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
401
+ if (node.textContent.trim() !== '') {
402
+ hasCommentableTextNodeDescendants = true;
403
+ }
404
+ }
383
405
  return false;
384
406
  }
385
- if (node.textContent.trim() === '') {
386
- // Trailing new lines do not result in the annotation spanning into
387
- // the trailing new line so can be ignored when looking for invalid
388
- // whitespace nodes.
389
- var nodeIsTrailingNewLine =
390
- // it is the final node
391
- node.eq(content.lastChild) &&
392
- // and there are multiple nodes
393
- !node.eq(content.firstChild) &&
394
- // and it is a paragraph node
395
- (0, _utils.isParagraph)(node, schema);
396
- if (!nodeIsTrailingNewLine) {
397
- foundInvalidWhitespace = true;
407
+ if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
408
+ if (node.textContent.trim() === '') {
409
+ // Trailing new lines do not result in the annotation spanning into
410
+ // the trailing new line so can be ignored when looking for invalid
411
+ // whitespace nodes.
412
+ var nodeIsTrailingNewLine =
413
+ // it is the final node
414
+ node.eq(content.lastChild) &&
415
+ // and there are multiple nodes
416
+ !node.eq(content.firstChild) &&
417
+ // and it is a paragraph node
418
+ (0, _utils.isParagraph)(node, schema);
419
+ if (!nodeIsTrailingNewLine) {
420
+ foundInvalidWhitespace = true;
421
+ }
398
422
  }
399
423
  }
400
424
  return !foundInvalidWhitespace;
401
425
  });
426
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
427
+ if (hasCommentableInlineNodeDescendants) {
428
+ return false;
429
+ }
430
+ return !hasCommentableTextNodeDescendants;
431
+ }
402
432
  return foundInvalidWhitespace;
403
433
  }
404
434
 
@@ -1,7 +1,9 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
4
+ import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
4
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
7
  import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../utils';
6
8
  const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
7
9
  const inlineCommentState = getPluginState(state);
@@ -48,13 +50,27 @@ const addOpenCloseAnalytics = editorAnalyticsAPI => (drafting, method = INPUT_ME
48
50
  return transaction;
49
51
  };
50
52
  const addInsertAnalytics = editorAnalyticsAPI => (transaction, state) => {
51
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
53
+ const analyticsEvent = {
52
54
  action: ACTION.INSERTED,
53
55
  actionSubject: ACTION_SUBJECT.ANNOTATION,
54
56
  eventType: EVENT_TYPE.TRACK,
55
57
  actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
56
58
  attributes: {}
57
- })(transaction);
59
+ };
60
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
61
+ const {
62
+ bookmark
63
+ } = getPluginState(state) || {};
64
+
65
+ // When this FF is removed we can move the analytics event creation inside of the
66
+ // attachAnalyticsEvent and get type inference for the attributes.
67
+ // @ts-ignore
68
+ analyticsEvent.attributes.inlineNodeNames = getRangeInlineNodeNames({
69
+ doc: state.doc,
70
+ pos: resolveDraftBookmark(state, bookmark)
71
+ });
72
+ }
73
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(analyticsEvent)(transaction);
58
74
  return transaction;
59
75
  };
60
76
  const addResolveAnalytics = editorAnalyticsAPI => method => (transaction, state) => {
@@ -2,6 +2,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
6
  import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
6
7
  import { AnnotationNodeView, getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
7
8
  import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
@@ -184,10 +185,25 @@ export const inlineCommentPlugin = options => {
184
185
  key: decorationKey.block
185
186
  }));
186
187
  } else {
187
- focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
188
- class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
189
- nodeName: 'span'
190
- }));
188
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
189
+ if (node.isText) {
190
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
191
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
192
+ nodeName: 'span'
193
+ }));
194
+ } else {
195
+ focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
196
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`
197
+ }, {
198
+ key: decorationKey.block
199
+ }));
200
+ }
201
+ } else {
202
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
203
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
204
+ nodeName: 'span'
205
+ }));
206
+ }
191
207
  }
192
208
  }
193
209
  });
@@ -2,7 +2,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
4
4
  import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
5
- import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
5
+ import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
6
6
  import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -251,6 +251,15 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
251
251
  overlap: getAnnotationsInSelectionCount(state)
252
252
  };
253
253
  }
254
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
255
+ const {
256
+ bookmark
257
+ } = getPluginState(state) || {};
258
+ attributes.inlineNodeNames = getRangeInlineNodeNames({
259
+ doc: state.doc,
260
+ pos: resolveDraftBookmark(state, bookmark)
261
+ });
262
+ }
254
263
  return {
255
264
  action: drafting ? ACTION.OPENED : ACTION.CLOSED,
256
265
  actionSubject: ACTION_SUBJECT.ANNOTATION,
@@ -341,30 +350,52 @@ export const isSupportedBlockNode = (node, supportedBlockNodes = []) => {
341
350
  export function hasInvalidWhitespaceNode(selection, schema) {
342
351
  let foundInvalidWhitespace = false;
343
352
  const content = selection.content().content;
353
+ let hasCommentableInlineNodeDescendants = false;
354
+ let hasCommentableTextNodeDescendants = false;
344
355
  content.descendants(node => {
356
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
357
+ const isAllowedInlineNode = ['emoji', 'status', 'date', 'mention', 'inlineCard'].includes(node.type.name);
358
+ if (isAllowedInlineNode) {
359
+ hasCommentableInlineNodeDescendants = true;
360
+ return false;
361
+ }
362
+ }
345
363
  if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes') && node.type === schema.nodes.inlineCard) {
346
364
  return false;
347
365
  }
348
366
  if (isText(node, schema)) {
367
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
368
+ if (node.textContent.trim() !== '') {
369
+ hasCommentableTextNodeDescendants = true;
370
+ }
371
+ }
349
372
  return false;
350
373
  }
351
- if (node.textContent.trim() === '') {
352
- // Trailing new lines do not result in the annotation spanning into
353
- // the trailing new line so can be ignored when looking for invalid
354
- // whitespace nodes.
355
- const nodeIsTrailingNewLine =
356
- // it is the final node
357
- node.eq(content.lastChild) &&
358
- // and there are multiple nodes
359
- !node.eq(content.firstChild) &&
360
- // and it is a paragraph node
361
- isParagraph(node, schema);
362
- if (!nodeIsTrailingNewLine) {
363
- foundInvalidWhitespace = true;
374
+ if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
375
+ if (node.textContent.trim() === '') {
376
+ // Trailing new lines do not result in the annotation spanning into
377
+ // the trailing new line so can be ignored when looking for invalid
378
+ // whitespace nodes.
379
+ const nodeIsTrailingNewLine =
380
+ // it is the final node
381
+ node.eq(content.lastChild) &&
382
+ // and there are multiple nodes
383
+ !node.eq(content.firstChild) &&
384
+ // and it is a paragraph node
385
+ isParagraph(node, schema);
386
+ if (!nodeIsTrailingNewLine) {
387
+ foundInvalidWhitespace = true;
388
+ }
364
389
  }
365
390
  }
366
391
  return !foundInvalidWhitespace;
367
392
  });
393
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
394
+ if (hasCommentableInlineNodeDescendants) {
395
+ return false;
396
+ }
397
+ return !hasCommentableTextNodeDescendants;
398
+ }
368
399
  return foundInvalidWhitespace;
369
400
  }
370
401
 
@@ -1,7 +1,9 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
4
+ import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
4
5
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
7
  import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../utils';
6
8
  var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
7
9
  return function (transaction, state) {
@@ -58,13 +60,26 @@ var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
58
60
  };
59
61
  var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
60
62
  return function (transaction, state) {
61
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
63
+ var analyticsEvent = {
62
64
  action: ACTION.INSERTED,
63
65
  actionSubject: ACTION_SUBJECT.ANNOTATION,
64
66
  eventType: EVENT_TYPE.TRACK,
65
67
  actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
66
68
  attributes: {}
67
- })(transaction);
69
+ };
70
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
71
+ var _ref2 = getPluginState(state) || {},
72
+ bookmark = _ref2.bookmark;
73
+
74
+ // When this FF is removed we can move the analytics event creation inside of the
75
+ // attachAnalyticsEvent and get type inference for the attributes.
76
+ // @ts-ignore
77
+ analyticsEvent.attributes.inlineNodeNames = getRangeInlineNodeNames({
78
+ doc: state.doc,
79
+ pos: resolveDraftBookmark(state, bookmark)
80
+ });
81
+ }
82
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(analyticsEvent)(transaction);
68
83
  return transaction;
69
84
  };
70
85
  };
@@ -5,6 +5,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
5
5
  import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
9
10
  import { AnnotationNodeView, getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
10
11
  import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
@@ -241,10 +242,25 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
241
242
  key: decorationKey.block
242
243
  }));
243
244
  } else {
244
- focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
245
- class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
246
- nodeName: 'span'
247
- }));
245
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
246
+ if (node.isText) {
247
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
248
+ class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
249
+ nodeName: 'span'
250
+ }));
251
+ } else {
252
+ focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
253
+ class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved)
254
+ }, {
255
+ key: decorationKey.block
256
+ }));
257
+ }
258
+ } else {
259
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
260
+ class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
261
+ nodeName: 'span'
262
+ }));
263
+ }
248
264
  }
249
265
  }
250
266
  });
package/dist/esm/utils.js CHANGED
@@ -2,7 +2,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
3
  import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
4
4
  import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
5
- import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
5
+ import { canApplyAnnotationOnRange, containsAnyAnnotations, getAnnotationIdsFromRange, getRangeInlineNodeNames, hasAnnotationMark, isParagraph, isText } from '@atlaskit/editor-common/utils';
6
6
  import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
@@ -262,6 +262,14 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
262
262
  overlap: getAnnotationsInSelectionCount(state)
263
263
  };
264
264
  }
265
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
266
+ var _ref3 = getPluginState(state) || {},
267
+ bookmark = _ref3.bookmark;
268
+ attributes.inlineNodeNames = getRangeInlineNodeNames({
269
+ doc: state.doc,
270
+ pos: resolveDraftBookmark(state, bookmark)
271
+ });
272
+ }
265
273
  return {
266
274
  action: drafting ? ACTION.OPENED : ACTION.CLOSED,
267
275
  actionSubject: ACTION_SUBJECT.ANNOTATION,
@@ -276,8 +284,8 @@ export var isSelectionValid = function isSelectionValid(state, isCommentOnMediaO
276
284
  var _currentMediaNodeWith;
277
285
  var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
278
286
  var selection = state.selection;
279
- var _ref3 = getPluginState(state) || {},
280
- disallowOnWhitespace = _ref3.disallowOnWhitespace;
287
+ var _ref4 = getPluginState(state) || {},
288
+ disallowOnWhitespace = _ref4.disallowOnWhitespace;
281
289
 
282
290
  // Allow media so that it can enter draft mode
283
291
  if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
@@ -348,30 +356,52 @@ export var isSupportedBlockNode = function isSupportedBlockNode(node) {
348
356
  export function hasInvalidWhitespaceNode(selection, schema) {
349
357
  var foundInvalidWhitespace = false;
350
358
  var content = selection.content().content;
359
+ var hasCommentableInlineNodeDescendants = false;
360
+ var hasCommentableTextNodeDescendants = false;
351
361
  content.descendants(function (node) {
362
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
363
+ var isAllowedInlineNode = ['emoji', 'status', 'date', 'mention', 'inlineCard'].includes(node.type.name);
364
+ if (isAllowedInlineNode) {
365
+ hasCommentableInlineNodeDescendants = true;
366
+ return false;
367
+ }
368
+ }
352
369
  if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes') && node.type === schema.nodes.inlineCard) {
353
370
  return false;
354
371
  }
355
372
  if (isText(node, schema)) {
373
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
374
+ if (node.textContent.trim() !== '') {
375
+ hasCommentableTextNodeDescendants = true;
376
+ }
377
+ }
356
378
  return false;
357
379
  }
358
- if (node.textContent.trim() === '') {
359
- // Trailing new lines do not result in the annotation spanning into
360
- // the trailing new line so can be ignored when looking for invalid
361
- // whitespace nodes.
362
- var nodeIsTrailingNewLine =
363
- // it is the final node
364
- node.eq(content.lastChild) &&
365
- // and there are multiple nodes
366
- !node.eq(content.firstChild) &&
367
- // and it is a paragraph node
368
- isParagraph(node, schema);
369
- if (!nodeIsTrailingNewLine) {
370
- foundInvalidWhitespace = true;
380
+ if (!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
381
+ if (node.textContent.trim() === '') {
382
+ // Trailing new lines do not result in the annotation spanning into
383
+ // the trailing new line so can be ignored when looking for invalid
384
+ // whitespace nodes.
385
+ var nodeIsTrailingNewLine =
386
+ // it is the final node
387
+ node.eq(content.lastChild) &&
388
+ // and there are multiple nodes
389
+ !node.eq(content.firstChild) &&
390
+ // and it is a paragraph node
391
+ isParagraph(node, schema);
392
+ if (!nodeIsTrailingNewLine) {
393
+ foundInvalidWhitespace = true;
394
+ }
371
395
  }
372
396
  }
373
397
  return !foundInvalidWhitespace;
374
398
  });
399
+ if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
400
+ if (hasCommentableInlineNodeDescendants) {
401
+ return false;
402
+ }
403
+ return !hasCommentableTextNodeDescendants;
404
+ }
375
405
  return foundInvalidWhitespace;
376
406
  }
377
407
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.9.5",
3
+ "version": "1.10.1",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^36.10.7",
36
- "@atlaskit/editor-common": "^82.0.0",
36
+ "@atlaskit/editor-common": "^82.3.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.2.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.1.0",
@@ -96,6 +96,9 @@
96
96
  "platform.editor.allow-inline-comments-for-inline-nodes": {
97
97
  "type": "boolean"
98
98
  },
99
+ "platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz": {
100
+ "type": "boolean"
101
+ },
99
102
  "platform.editor.comments-on-media.bug.preserve-draft_i3vqb": {
100
103
  "type": "boolean"
101
104
  }