@atlaskit/editor-plugin-annotation 23.0.0 → 23.0.2

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,26 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 23.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d61565965ce82`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d61565965ce82) -
8
+ Clean up experiment `platform_editor_annotations_sync_on_docchange`
9
+ - Updated dependencies
10
+
11
+ ## 23.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`45cf8c5ab1b31`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/45cf8c5ab1b31) -
16
+ Enable gated comments on MAUI charts in the Confluence editor, including the editor draft flow for
17
+ native-embed extension nodes. With `cc_maui_annotations_on_extensions` enabled, eligible extension
18
+ block selections can start a draft even when whitespace-only text comments are disallowed. The
19
+ extension-only DOM anchor fallback also requires this gate; existing text/media and gate-off
20
+ anchor behavior is preserved. The native-embed toolbar uses the same gate for its block-comment
21
+ opening hint.
22
+ - Updated dependencies
23
+
3
24
  ## 23.0.0
4
25
 
5
26
  ### Patch Changes
@@ -97,11 +97,11 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
97
97
  stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
98
98
  applyInlineCommentDraft: function applyInlineCommentDraft(annotationId) {
99
99
  var _api$analytics;
100
- return (0, _editorCommands.createAnnotation)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, _annotation.AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes);
100
+ return (0, _editorCommands.createAnnotation)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, _annotation.AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
101
101
  },
102
102
  removeInlineCommentAnnotation: function removeInlineCommentAnnotation(annotationId) {
103
103
  var _api$analytics2, _annotationProviders$;
104
- return (0, _editorCommands.removeInlineCommentFromDoc)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : []);
104
+ return (0, _editorCommands.removeInlineCommentFromDoc)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
105
105
  },
106
106
  setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
107
107
  showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
@@ -9,20 +9,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _utils = require("@atlaskit/editor-common/utils");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _view = require("@atlaskit/editor-prosemirror/view");
12
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
12
  var _reducer = _interopRequireDefault(require("./reducer"));
14
13
  var _utils2 = require("./utils");
15
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
- var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
18
- if (!tr.getMeta('replaceDocument')) {
19
- return getSelectionChangedHandler(false)(tr, prevPluginState);
20
- }
21
- return _objectSpread(_objectSpread({}, prevPluginState), {}, {
22
- dirtyAnnotations: true
23
- });
24
- };
25
-
26
16
  /**
27
17
  * Creates a handleDocChanged function with its own deleted annotations cache.
28
18
  * This ensures each editor instance has its own cache, avoiding cross-contamination.
@@ -208,16 +198,9 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
208
198
 
209
199
  // Create the handler with cache once at module level
210
200
  var handleDocChangedWithSync = createHandleDocChanged();
211
- var getDocChangedHandler = function getDocChangedHandler(tr, prevPluginState) {
212
- // Check feature flag at runtime to support test variants
213
- if ((0, _expValEquals.expValEquals)('platform_editor_annotations_sync_on_docchange', 'isEnabled', true)) {
214
- return handleDocChangedWithSync(tr, prevPluginState);
215
- }
216
- return handleDocChanged(tr, prevPluginState);
217
- };
218
201
  var dest = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _reducer.default, {
219
202
  onSelectionChanged: getSelectionChangedHandler(true),
220
- onDocChanged: getDocChangedHandler,
203
+ onDocChanged: handleDocChangedWithSync,
221
204
  mapping: function mapping(tr, pluginState, editorState) {
222
205
  var draftDecorationSet = pluginState.draftDecorationSet,
223
206
  bookmark = pluginState.bookmark;
@@ -331,7 +331,11 @@ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(stat
331
331
  if (containsInvalidNodes) {
332
332
  return _types.AnnotationSelectionType.DISABLED;
333
333
  }
334
- if (disallowOnWhitespace && hasInvalidWhitespaceNode(selection, state.schema)) {
334
+
335
+ // Extension content lives outside the editor document, so an eligible whole-block
336
+ // selection must not be rejected for having no commentable text descendants.
337
+ var isSupportedExtensionSelection = (0, _fg.fg)('cc_maui_annotations_on_extensions') && isSupportedBlockNodeSelection && selection instanceof _state.NodeSelection && selection.node.type.name === 'extension';
338
+ if (disallowOnWhitespace && !isSupportedExtensionSelection && hasInvalidWhitespaceNode(selection, state.schema)) {
335
339
  return _types.AnnotationSelectionType.INVALID;
336
340
  }
337
341
  if (!(selection instanceof _state.NodeSelection) && (0, _utils.isEmptyTextSelection)(selection, state.schema)) {
@@ -13,7 +13,9 @@ var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
16
+ var _state = require("@atlaskit/editor-prosemirror/state");
16
17
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
18
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
17
19
  var _editorCommands = require("../editor-commands");
18
20
  var _utils3 = require("../pm-plugins/utils");
19
21
  var _types = require("../types");
@@ -69,14 +71,36 @@ function InlineCommentView(_ref) {
69
71
  var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
70
72
  var selection = (0, _utils3.getSelectionPositions)(state, bookmark);
71
73
  var position = findPosForDOM(selection);
74
+ var isExtensionSelection = selection instanceof _state.NodeSelection && selection.node.type.name === 'extension';
72
75
  var dom;
76
+ var domLookupError;
73
77
  try {
74
- // Ignored via go/ees005
75
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
76
- dom = (0, _utils2.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
78
+ var domRef = (0, _utils2.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
79
+ if ((0, _fg.fg)('cc_maui_annotations_on_extensions') && isExtensionSelection) {
80
+ if (domRef instanceof HTMLElement) {
81
+ dom = domRef;
82
+ }
83
+ } else {
84
+ // Preserve the existing text/media and gate-off anchor lookup.
85
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
86
+ dom = domRef;
87
+ }
77
88
  } catch (error) {
89
+ domLookupError = error;
90
+ }
91
+
92
+ // Native embed extension nodes are rendered by a node view. Depending on
93
+ // the wrapper, domAtPos can return no element (or throw) even though
94
+ // EditorView.nodeDOM can. Use that direct lookup as a block-comment anchor.
95
+ if ((0, _fg.fg)('cc_maui_annotations_on_extensions') && !dom && isExtensionSelection) {
96
+ var nodeDom = editorView.nodeDOM(selection.from);
97
+ if (nodeDom instanceof HTMLElement) {
98
+ dom = nodeDom;
99
+ }
100
+ }
101
+ if (!dom && domLookupError) {
78
102
  // eslint-disable-next-line no-console
79
- console.warn(error);
103
+ console.warn(domLookupError);
80
104
  if (dispatchAnalyticsEvent) {
81
105
  var payload = {
82
106
  action: _analytics.ACTION.ERRORED,
@@ -87,7 +111,7 @@ function InlineCommentView(_ref) {
87
111
  selection: selection.toJSON(),
88
112
  position: position,
89
113
  docSize: editorView.state.doc.nodeSize,
90
- error: error.toString()
114
+ error: domLookupError.toString()
91
115
  }
92
116
  };
93
117
  dispatchAnalyticsEvent(payload);
@@ -65,11 +65,11 @@ export const annotationPlugin = ({
65
65
  stripNonExistingAnnotations,
66
66
  applyInlineCommentDraft: annotationId => {
67
67
  var _api$analytics;
68
- return createAnnotation(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes);
68
+ return createAnnotation(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
69
69
  },
70
70
  removeInlineCommentAnnotation: annotationId => {
71
71
  var _api$analytics2, _annotationProviders$;
72
- return removeInlineCommentFromDoc(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : []);
72
+ return removeInlineCommentFromDoc(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
73
73
  },
74
74
  setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
75
75
  showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
@@ -1,18 +1,8 @@
1
1
  import { pluginFactory } from '@atlaskit/editor-common/utils';
2
2
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
4
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
4
  import reducer from './reducer';
6
5
  import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from './utils';
7
- const handleDocChanged = (tr, prevPluginState) => {
8
- if (!tr.getMeta('replaceDocument')) {
9
- return getSelectionChangedHandler(false)(tr, prevPluginState);
10
- }
11
- return {
12
- ...prevPluginState,
13
- dirtyAnnotations: true
14
- };
15
- };
16
6
 
17
7
  /**
18
8
  * Creates a handleDocChanged function with its own deleted annotations cache.
@@ -207,16 +197,9 @@ getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
207
197
 
208
198
  // Create the handler with cache once at module level
209
199
  const handleDocChangedWithSync = createHandleDocChanged();
210
- const getDocChangedHandler = (tr, prevPluginState) => {
211
- // Check feature flag at runtime to support test variants
212
- if (expValEquals('platform_editor_annotations_sync_on_docchange', 'isEnabled', true)) {
213
- return handleDocChangedWithSync(tr, prevPluginState);
214
- }
215
- return handleDocChanged(tr, prevPluginState);
216
- };
217
200
  const dest = pluginFactory(inlineCommentPluginKey, reducer, {
218
201
  onSelectionChanged: getSelectionChangedHandler(true),
219
- onDocChanged: getDocChangedHandler,
202
+ onDocChanged: handleDocChangedWithSync,
220
203
  mapping: (tr, pluginState, editorState) => {
221
204
  const {
222
205
  draftDecorationSet,
@@ -295,7 +295,11 @@ export const isSelectionValid = (state, supportedBlockNodes = [], isBlockNodeSup
295
295
  if (containsInvalidNodes) {
296
296
  return AnnotationSelectionType.DISABLED;
297
297
  }
298
- if (disallowOnWhitespace && hasInvalidWhitespaceNode(selection, state.schema)) {
298
+
299
+ // Extension content lives outside the editor document, so an eligible whole-block
300
+ // selection must not be rejected for having no commentable text descendants.
301
+ const isSupportedExtensionSelection = fg('cc_maui_annotations_on_extensions') && isSupportedBlockNodeSelection && selection instanceof NodeSelection && selection.node.type.name === 'extension';
302
+ if (disallowOnWhitespace && !isSupportedExtensionSelection && hasInvalidWhitespaceNode(selection, state.schema)) {
299
303
  return AnnotationSelectionType.INVALID;
300
304
  }
301
305
  if (!(selection instanceof NodeSelection) && isEmptyTextSelection(selection, state.schema)) {
@@ -5,7 +5,9 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
5
5
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
6
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
7
7
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
8
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
9
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
10
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
9
11
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
10
12
  import { getAllAnnotations, getAnnotationViewKey, getSelectionPositions } from '../pm-plugins/utils';
11
13
  import { AnnotationTestIds } from '../types';
@@ -69,14 +71,36 @@ export function InlineCommentView({
69
71
  const annotationsList = getAllAnnotations(editorView.state.doc);
70
72
  const selection = getSelectionPositions(state, bookmark);
71
73
  const position = findPosForDOM(selection);
74
+ const isExtensionSelection = selection instanceof NodeSelection && selection.node.type.name === 'extension';
72
75
  let dom;
76
+ let domLookupError;
73
77
  try {
74
- // Ignored via go/ees005
75
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
76
- dom = findDomRefAtPos(position, editorView.domAtPos.bind(editorView));
78
+ const domRef = findDomRefAtPos(position, editorView.domAtPos.bind(editorView));
79
+ if (fg('cc_maui_annotations_on_extensions') && isExtensionSelection) {
80
+ if (domRef instanceof HTMLElement) {
81
+ dom = domRef;
82
+ }
83
+ } else {
84
+ // Preserve the existing text/media and gate-off anchor lookup.
85
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
86
+ dom = domRef;
87
+ }
77
88
  } catch (error) {
89
+ domLookupError = error;
90
+ }
91
+
92
+ // Native embed extension nodes are rendered by a node view. Depending on
93
+ // the wrapper, domAtPos can return no element (or throw) even though
94
+ // EditorView.nodeDOM can. Use that direct lookup as a block-comment anchor.
95
+ if (fg('cc_maui_annotations_on_extensions') && !dom && isExtensionSelection) {
96
+ const nodeDom = editorView.nodeDOM(selection.from);
97
+ if (nodeDom instanceof HTMLElement) {
98
+ dom = nodeDom;
99
+ }
100
+ }
101
+ if (!dom && domLookupError) {
78
102
  // eslint-disable-next-line no-console
79
- console.warn(error);
103
+ console.warn(domLookupError);
80
104
  if (dispatchAnalyticsEvent) {
81
105
  const payload = {
82
106
  action: ACTION.ERRORED,
@@ -87,7 +111,7 @@ export function InlineCommentView({
87
111
  selection: selection.toJSON(),
88
112
  position,
89
113
  docSize: editorView.state.doc.nodeSize,
90
- error: error.toString()
114
+ error: domLookupError.toString()
91
115
  }
92
116
  };
93
117
  dispatchAnalyticsEvent(payload);
@@ -90,11 +90,11 @@ export var annotationPlugin = function annotationPlugin(_ref) {
90
90
  stripNonExistingAnnotations: stripNonExistingAnnotations,
91
91
  applyInlineCommentDraft: function applyInlineCommentDraft(annotationId) {
92
92
  var _api$analytics;
93
- return createAnnotation(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes);
93
+ return createAnnotation(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
94
94
  },
95
95
  removeInlineCommentAnnotation: function removeInlineCommentAnnotation(annotationId) {
96
96
  var _api$analytics2, _annotationProviders$;
97
- return removeInlineCommentFromDoc(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : []);
97
+ return removeInlineCommentFromDoc(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
98
98
  },
99
99
  setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
100
100
  showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
@@ -4,17 +4,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  import { pluginFactory } from '@atlaskit/editor-common/utils';
5
5
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
7
  import reducer from './reducer';
9
8
  import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from './utils';
10
- var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
11
- if (!tr.getMeta('replaceDocument')) {
12
- return getSelectionChangedHandler(false)(tr, prevPluginState);
13
- }
14
- return _objectSpread(_objectSpread({}, prevPluginState), {}, {
15
- dirtyAnnotations: true
16
- });
17
- };
18
9
 
19
10
  /**
20
11
  * Creates a handleDocChanged function with its own deleted annotations cache.
@@ -201,16 +192,9 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
201
192
 
202
193
  // Create the handler with cache once at module level
203
194
  var handleDocChangedWithSync = createHandleDocChanged();
204
- var getDocChangedHandler = function getDocChangedHandler(tr, prevPluginState) {
205
- // Check feature flag at runtime to support test variants
206
- if (expValEquals('platform_editor_annotations_sync_on_docchange', 'isEnabled', true)) {
207
- return handleDocChangedWithSync(tr, prevPluginState);
208
- }
209
- return handleDocChanged(tr, prevPluginState);
210
- };
211
195
  var dest = pluginFactory(inlineCommentPluginKey, reducer, {
212
196
  onSelectionChanged: getSelectionChangedHandler(true),
213
- onDocChanged: getDocChangedHandler,
197
+ onDocChanged: handleDocChangedWithSync,
214
198
  mapping: function mapping(tr, pluginState, editorState) {
215
199
  var draftDecorationSet = pluginState.draftDecorationSet,
216
200
  bookmark = pluginState.bookmark;
@@ -314,7 +314,11 @@ export var isSelectionValid = function isSelectionValid(state) {
314
314
  if (containsInvalidNodes) {
315
315
  return AnnotationSelectionType.DISABLED;
316
316
  }
317
- if (disallowOnWhitespace && hasInvalidWhitespaceNode(selection, state.schema)) {
317
+
318
+ // Extension content lives outside the editor document, so an eligible whole-block
319
+ // selection must not be rejected for having no commentable text descendants.
320
+ var isSupportedExtensionSelection = fg('cc_maui_annotations_on_extensions') && isSupportedBlockNodeSelection && selection instanceof NodeSelection && selection.node.type.name === 'extension';
321
+ if (disallowOnWhitespace && !isSupportedExtensionSelection && hasInvalidWhitespaceNode(selection, state.schema)) {
318
322
  return AnnotationSelectionType.INVALID;
319
323
  }
320
324
  if (!(selection instanceof NodeSelection) && isEmptyTextSelection(selection, state.schema)) {
@@ -6,7 +6,9 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
6
6
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
7
7
  import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
8
8
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
9
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
11
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
10
12
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
11
13
  import { getAllAnnotations, getAnnotationViewKey, getSelectionPositions } from '../pm-plugins/utils';
12
14
  import { AnnotationTestIds } from '../types';
@@ -62,14 +64,36 @@ export function InlineCommentView(_ref) {
62
64
  var annotationsList = getAllAnnotations(editorView.state.doc);
63
65
  var selection = getSelectionPositions(state, bookmark);
64
66
  var position = findPosForDOM(selection);
67
+ var isExtensionSelection = selection instanceof NodeSelection && selection.node.type.name === 'extension';
65
68
  var dom;
69
+ var domLookupError;
66
70
  try {
67
- // Ignored via go/ees005
68
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
69
- dom = findDomRefAtPos(position, editorView.domAtPos.bind(editorView));
71
+ var domRef = findDomRefAtPos(position, editorView.domAtPos.bind(editorView));
72
+ if (fg('cc_maui_annotations_on_extensions') && isExtensionSelection) {
73
+ if (domRef instanceof HTMLElement) {
74
+ dom = domRef;
75
+ }
76
+ } else {
77
+ // Preserve the existing text/media and gate-off anchor lookup.
78
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
79
+ dom = domRef;
80
+ }
70
81
  } catch (error) {
82
+ domLookupError = error;
83
+ }
84
+
85
+ // Native embed extension nodes are rendered by a node view. Depending on
86
+ // the wrapper, domAtPos can return no element (or throw) even though
87
+ // EditorView.nodeDOM can. Use that direct lookup as a block-comment anchor.
88
+ if (fg('cc_maui_annotations_on_extensions') && !dom && isExtensionSelection) {
89
+ var nodeDom = editorView.nodeDOM(selection.from);
90
+ if (nodeDom instanceof HTMLElement) {
91
+ dom = nodeDom;
92
+ }
93
+ }
94
+ if (!dom && domLookupError) {
71
95
  // eslint-disable-next-line no-console
72
- console.warn(error);
96
+ console.warn(domLookupError);
73
97
  if (dispatchAnalyticsEvent) {
74
98
  var payload = {
75
99
  action: ACTION.ERRORED,
@@ -80,7 +104,7 @@ export function InlineCommentView(_ref) {
80
104
  selection: selection.toJSON(),
81
105
  position: position,
82
106
  docSize: editorView.state.doc.nodeSize,
83
- error: error.toString()
107
+ error: domLookupError.toString()
84
108
  }
85
109
  };
86
110
  dispatchAnalyticsEvent(payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "23.0.0",
3
+ "version": "23.0.2",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,11 +31,11 @@
31
31
  "@atlaskit/editor-toolbar-model": "^1.2.0",
32
32
  "@atlaskit/icon": "^38.0.0",
33
33
  "@atlaskit/platform-feature-flags": "^2.2.0",
34
- "@atlaskit/tmp-editor-statsig": "^219.0.0",
34
+ "@atlaskit/tmp-editor-statsig": "^220.0.0",
35
35
  "@babel/runtime": "^7.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^127.0.0",
38
+ "@atlaskit/editor-common": "^127.2.0",
39
39
  "react": "^18.2.0 || ^19.2.0",
40
40
  "react-dom": "^18.2.0 || ^19.2.0",
41
41
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"