@atlaskit/editor-plugin-annotation 19.0.3 → 19.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/annotationPlugin.js +23 -14
  3. package/dist/cjs/editor-commands/index.js +22 -14
  4. package/dist/cjs/editor-commands/transform.js +4 -4
  5. package/dist/cjs/pm-plugins/annotation-manager-hooks.js +5 -5
  6. package/dist/cjs/pm-plugins/inline-comment.js +2 -3
  7. package/dist/cjs/pm-plugins/reducer.js +3 -3
  8. package/dist/cjs/pm-plugins/utils.js +10 -5
  9. package/dist/cjs/ui/InlineCommentView.js +3 -3
  10. package/dist/es2019/annotationPlugin.js +19 -10
  11. package/dist/es2019/editor-commands/index.js +20 -18
  12. package/dist/es2019/editor-commands/transform.js +4 -4
  13. package/dist/es2019/pm-plugins/annotation-manager-hooks.js +5 -5
  14. package/dist/es2019/pm-plugins/inline-comment.js +3 -4
  15. package/dist/es2019/pm-plugins/reducer.js +3 -3
  16. package/dist/es2019/pm-plugins/utils.js +9 -7
  17. package/dist/es2019/ui/InlineCommentView.js +3 -3
  18. package/dist/esm/annotationPlugin.js +24 -15
  19. package/dist/esm/editor-commands/index.js +22 -14
  20. package/dist/esm/editor-commands/transform.js +4 -4
  21. package/dist/esm/pm-plugins/annotation-manager-hooks.js +5 -5
  22. package/dist/esm/pm-plugins/inline-comment.js +3 -4
  23. package/dist/esm/pm-plugins/reducer.js +3 -3
  24. package/dist/esm/pm-plugins/utils.js +10 -5
  25. package/dist/esm/ui/InlineCommentView.js +3 -3
  26. package/dist/types/annotationPluginType.d.ts +12 -0
  27. package/dist/types/editor-commands/index.d.ts +7 -7
  28. package/dist/types/editor-commands/transform.d.ts +3 -3
  29. package/dist/types/pm-plugins/annotation-manager-hooks.d.ts +1 -1
  30. package/dist/types/pm-plugins/types.d.ts +1 -0
  31. package/dist/types/pm-plugins/utils.d.ts +4 -4
  32. package/dist/types/types/index.d.ts +9 -0
  33. package/package.json +6 -2
@@ -22,7 +22,7 @@ var domRefFromPos = function domRefFromPos(view, position) {
22
22
  }
23
23
  return dom;
24
24
  };
25
- export var allowAnnotation = function allowAnnotation(editorView, _options) {
25
+ export var allowAnnotation = function allowAnnotation(editorView, options) {
26
26
  return function () {
27
27
  var _ref = inlineCommentPluginKey.getState(editorView.state) || {},
28
28
  isDrafting = _ref.isDrafting,
@@ -36,7 +36,7 @@ export var allowAnnotation = function allowAnnotation(editorView, _options) {
36
36
  if (!!(decoration !== null && decoration !== void 0 && decoration.length)) {
37
37
  return false;
38
38
  }
39
- return isSelectionValid(editorView.state) === AnnotationSelectionType.VALID;
39
+ return isSelectionValid(editorView.state, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported) === AnnotationSelectionType.VALID;
40
40
  };
41
41
  };
42
42
  export var startDraft = function startDraft(editorView, options) {
@@ -69,7 +69,7 @@ export var startDraft = function startDraft(editorView, options) {
69
69
  });
70
70
  });
71
71
  }
72
- setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(true)(editorView.state, editorView.dispatch);
72
+ setInlineCommentDraftState(options.editorAnalyticsAPI, options.provider.supportedBlockNodes, options.api, options.provider.isBlockNodeSupported)(true)(editorView.state, editorView.dispatch);
73
73
  var _ref3 = inlineCommentPluginKey.getState(editorView.state) || {},
74
74
  draftDecorationSet = _ref3.draftDecorationSet;
75
75
  var decorations = draftDecorationSet === null || draftDecorationSet === void 0 ? void 0 : draftDecorationSet.find();
@@ -153,7 +153,7 @@ export var applyDraft = function applyDraft(editorView, options) {
153
153
  };
154
154
  }
155
155
  var from = decorations[0].from;
156
- createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
156
+ createAnnotation(options.editorAnalyticsAPI, options.api)(id, AnnotationTypes.INLINE_COMMENT, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
157
157
  !editorView.hasFocus() && editorView.focus();
158
158
 
159
159
  // Using the original decoration from position we should be able to locate the new target element.
@@ -337,7 +337,7 @@ export var clearAnnotation = function clearAnnotation(editorView, options) {
337
337
  reason: ERROR_REASON_ID_INVALID
338
338
  };
339
339
  }
340
- removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes)(editorView.state, editorView.dispatch);
340
+ removeInlineCommentFromDoc(options.editorAnalyticsAPI)(id, options.provider.supportedBlockNodes, options.provider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
341
341
  return {
342
342
  success: true,
343
343
  actionResult: undefined
@@ -13,7 +13,7 @@ import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../
13
13
  import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
14
14
  import { createPluginState } from './plugin-factory';
15
15
  import { shouldSuppressFloatingToolbar } from './toolbar';
16
- import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
16
+ import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey, isSupportedBlockNode } from './utils';
17
17
  var fetchProviderStates = /*#__PURE__*/function () {
18
18
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
19
19
  var data, result;
@@ -460,13 +460,12 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
460
460
  // everytime we need to update the decorations. This handler will be called alot. We should be caching
461
461
  // the decorations in plugin state and only updating them when required.
462
462
  state.doc.descendants(function (node, pos) {
463
- var _provider$supportedBl;
464
463
  // Inline comment on mediaInline is not supported as part of comments on media project
465
464
  // Thus, we skip the decoration for mediaInline node
466
465
  if (node.type.name === 'mediaInline') {
467
466
  return false;
468
467
  }
469
- var isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
468
+ var isSupportedBlock = node.isBlock && isSupportedBlockNode(node, provider.supportedBlockNodes, provider.isBlockNodeSupported);
470
469
  node.marks.filter(function (mark) {
471
470
  return mark.type === state.schema.marks.annotation;
472
471
  }).forEach(function (mark) {
@@ -478,7 +477,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
478
477
  var isHovered = !isInlineCommentViewClosed && !!(hoveredAnnotations !== null && hoveredAnnotations !== void 0 && hoveredAnnotations.some(function (hoveredAnnotation) {
479
478
  return hoveredAnnotation.id === mark.attrs.id;
480
479
  }));
481
- if (isSupportedBlockNode) {
480
+ if (isSupportedBlock) {
482
481
  focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
483
482
  class: "".concat(getBlockAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved)
484
483
  }, {
@@ -22,7 +22,7 @@ export default (function (pluginState, action) {
22
22
  mouseData: mouseData
23
23
  });
24
24
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
25
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
25
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.isBlockNodeSupported, action.data.targetNodeId, action.data.isOpeningMediaCommentFromToolbar);
26
26
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
27
27
  return _objectSpread(_objectSpread({}, pluginState), {}, {
28
28
  dirtyAnnotations: false,
@@ -84,7 +84,7 @@ export default (function (pluginState, action) {
84
84
  return pluginState;
85
85
  }
86
86
  });
87
- function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId, isOpeningMediaCommentFromToolbar) {
87
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, isBlockNodeSupported, targetNodeId, isOpeningMediaCommentFromToolbar) {
88
88
  var draftDecorationSet = pluginState.draftDecorationSet;
89
89
  if (!draftDecorationSet || !drafting) {
90
90
  draftDecorationSet = DecorationSet.empty;
@@ -97,7 +97,7 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, suppor
97
97
  newState.bookmark = undefined;
98
98
  if (drafting && editorState) {
99
99
  newState.bookmark = editorState.selection.getBookmark();
100
- var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes),
100
+ var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes, isBlockNodeSupported),
101
101
  from = _resolveDraftBookmark.from,
102
102
  to = _resolveDraftBookmark.to;
103
103
  var draftDecoration = addDraftDecoration(from, to, targetType);
@@ -185,6 +185,7 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
185
185
  };
186
186
  export var resolveDraftBookmark = function resolveDraftBookmark(editorState, bookmark) {
187
187
  var supportedBlockNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
188
+ var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
188
189
  var doc = editorState.doc;
189
190
  var resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
190
191
  var from = resolvedBookmark.from,
@@ -206,7 +207,8 @@ export var resolveDraftBookmark = function resolveDraftBookmark(editorState, boo
206
207
  return false;
207
208
  }
208
209
  var nodeEndsAt = pos + node.nodeSize;
209
- if (supportedBlockNodes.includes(node.type.name)) {
210
+ var isLegacyMediaSingleWrapper = node.type.name === 'mediaSingle' && supportedBlockNodes.includes('media') && !supportedBlockNodes.includes('mediaSingle');
211
+ if (isSupportedBlockNode(node, supportedBlockNodes, isBlockNodeSupported) && !isLegacyMediaSingleWrapper) {
210
212
  draftBookmark = {
211
213
  from: pos,
212
214
  to: nodeEndsAt,
@@ -283,14 +285,16 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
283
285
  };
284
286
  export var isSelectionValid = function isSelectionValid(state) {
285
287
  var _currentMediaNodeWith;
286
- var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
288
+ var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
289
+ var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
287
290
  var selection = state.selection;
288
291
  var _ref3 = getPluginState(state) || {},
289
292
  disallowOnWhitespace = _ref3.disallowOnWhitespace;
290
293
  var allowedInlineNodes = ['emoji', 'status', 'date', 'mention', 'inlineCard'];
291
294
  var isSelectionEmpty = selection.empty;
292
295
  var isTextOrAllSelection = selection instanceof TextSelection || selection instanceof AllSelection;
293
- var isValidNodeSelection = selection instanceof NodeSelection && allowedInlineNodes.includes(selection.node.type.name);
296
+ var isSupportedBlockNodeSelection = selection instanceof NodeSelection && isSupportedBlockNode(selection.node, supportedBlockNodes, isBlockNodeSupported);
297
+ var isValidNodeSelection = selection instanceof NodeSelection && (allowedInlineNodes.includes(selection.node.type.name) || isSupportedBlockNodeSelection);
294
298
  var isValidSelection = isTextOrAllSelection || isValidNodeSelection;
295
299
 
296
300
  // Allow media so that it can enter draft mode
@@ -300,7 +304,7 @@ export var isSelectionValid = function isSelectionValid(state) {
300
304
  if (isSelectionEmpty || !isValidSelection) {
301
305
  return AnnotationSelectionType.INVALID;
302
306
  }
303
- var containsInvalidNodes = hasInvalidNodes(state);
307
+ var containsInvalidNodes = !isSupportedBlockNodeSelection && hasInvalidNodes(state);
304
308
 
305
309
  // A selection that only covers 1 pos, and is an invalid node
306
310
  // e.g. a text selection over a mention
@@ -329,7 +333,8 @@ export var hasInvalidNodes = function hasInvalidNodes(state) {
329
333
  };
330
334
  export var isSupportedBlockNode = function isSupportedBlockNode(node) {
331
335
  var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
332
- return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0;
336
+ var isBlockNodeSupported = arguments.length > 2 ? arguments[2] : undefined;
337
+ return supportedBlockNodes.indexOf(node.type.name) >= 0 || node.type.name === 'mediaSingle' && supportedBlockNodes.indexOf('media') >= 0 || fg('cc_maui_annotations_on_extensions') && (isBlockNodeSupported === null || isBlockNodeSupported === void 0 ? void 0 : isBlockNodeSupported(node)) === true;
333
338
  };
334
339
 
335
340
  /**
@@ -115,7 +115,7 @@ export function InlineCommentView(_ref) {
115
115
  ,
116
116
  onCreate: function onCreate(id) {
117
117
  if (!isAnnotationManagerEnabled) {
118
- var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
118
+ var createAnnotationResult = createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch);
119
119
  !editorView.hasFocus() && editorView.focus();
120
120
  if (!createAnnotationResult) {
121
121
  throw new Error('Failed to create annotation');
@@ -128,7 +128,7 @@ export function InlineCommentView(_ref) {
128
128
  return (
129
129
  // This is called when optimistic create inline comment encounters an error,
130
130
  // in which case the optimistically added annotation must be removed.
131
- removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch)
131
+ removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, editorView.dispatch)
132
132
  );
133
133
  }
134
134
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
@@ -197,7 +197,7 @@ export function InlineCommentView(_ref) {
197
197
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
198
198
  ,
199
199
  onDelete: function onDelete(id) {
200
- return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(editorView.state, dispatch);
200
+ return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes, inlineCommentProvider.isBlockNodeSupported)(editorView.state, dispatch);
201
201
  }
202
202
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
203
203
  ,
@@ -27,7 +27,19 @@ export type AnnotationPluginDependencies = [
27
27
  export type AnnotationPluginOptions = AnnotationProviders;
28
28
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
29
29
  actions: {
30
+ /**
31
+ * Applies the current inline-comment draft as an annotation mark on the
32
+ * bookmarked selection. Callers must start a draft first via
33
+ * `setInlineCommentDraftState`.
34
+ * @returns A command that returns true when the draft is applied.
35
+ */
36
+ applyInlineCommentDraft: (annotationId: string) => Command;
30
37
  hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
38
+ /**
39
+ * Removes an inline-comment annotation mark from the document by id.
40
+ * @returns A command that returns true when the remove transaction is dispatched.
41
+ */
42
+ removeInlineCommentAnnotation: (annotationId: string) => Command;
31
43
  /**
32
44
  * Requests that the active inline comment or comment draft be closed.
33
45
  * Runs the provider's close guard before closing when one is configured.
@@ -5,26 +5,26 @@ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types
5
5
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
6
  import type { AnnotationPlugin } from '../annotationPluginType';
7
7
  import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
8
- import type { InlineCommentInputMethod, TargetType } from '../types';
8
+ import type { InlineCommentAnnotationProvider, InlineCommentInputMethod, TargetType } from '../types';
9
9
  export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
10
10
  export declare const closeComponent: () => Command;
11
11
  export declare const clearDirtyMark: () => Command;
12
12
  export declare const setInlineCommentsFetched: () => Command;
13
13
  export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
14
14
  export declare const setPendingSelectedAnnotation: (id: string) => Command;
15
- export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
16
- export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[]) => Command;
15
+ export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
16
+ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
17
17
  /**
18
18
  * Show active inline comments for a given block node, otherwise,
19
19
  * return false if the node has no comments or no unresolved comments.
20
20
  * @param supportedBlockNodes
21
21
  * @example
22
22
  */
23
- export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
24
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
25
- export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
23
+ export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
24
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>, isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
25
+ export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
26
26
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
27
27
  export declare const setSelectedAnnotation: (id: string) => Command;
28
28
  export declare const setHoveredAnnotation: (id: string) => Command;
29
- export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[]) => Command;
29
+ export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
30
30
  export declare const setInlineCommentsVisibility: (isVisible: boolean) => Command;
@@ -2,11 +2,11 @@ import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common
2
2
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { AnnotationPlugin } from '../annotationPluginType';
5
- import type { InlineCommentInputMethod } from '../types';
5
+ import type { InlineCommentAnnotationProvider, InlineCommentInputMethod } from '../types';
6
6
  declare const _default_1: {
7
- addAnnotationMark: (id: string, supportedBlockNodes?: string[]) => (transaction: Transaction, state: EditorState) => Transaction;
7
+ addAnnotationMark: (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (transaction: Transaction, state: EditorState) => Transaction;
8
8
  addDeleteAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
9
- addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => (transaction: Transaction, state: EditorState) => Transaction;
9
+ addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (transaction: Transaction, state: EditorState) => Transaction;
10
10
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
11
11
  addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
12
12
  addPreemptiveGateErrorAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (errorReason?: string) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -2,7 +2,7 @@ import { type AnnotationId } from '@atlaskit/adf-schema/annotation';
2
2
  import type { ApplyDraftResult, ClearAnnotationResult, ClearDraftResult, GetDraftResult, HoverAnnotationResult, SelectAnnotationResult, StartDraftResult } from '@atlaskit/editor-common/annotation';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { InlineCommentPluginOptions } from './types';
5
- export declare const allowAnnotation: (editorView: EditorView, _options: InlineCommentPluginOptions) => () => boolean;
5
+ export declare const allowAnnotation: (editorView: EditorView, options: InlineCommentPluginOptions) => () => boolean;
6
6
  export declare const startDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => () => StartDraftResult;
7
7
  export declare const clearDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => () => ClearDraftResult;
8
8
  export declare const applyDraft: (editorView: EditorView, options: InlineCommentPluginOptions) => (id: AnnotationId) => ApplyDraftResult;
@@ -43,6 +43,7 @@ export type InlineCommentAction = {
43
43
  data: {
44
44
  drafting: boolean;
45
45
  editorState: EditorState;
46
+ isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported'];
46
47
  isOpeningMediaCommentFromToolbar?: boolean;
47
48
  supportedBlockNodes?: string[];
48
49
  targetNodeId?: string;
@@ -3,7 +3,7 @@ import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-pr
3
3
  import type { EditorState, Selection, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
4
4
  import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { Decoration } from '@atlaskit/editor-prosemirror/view';
6
- import type { AnnotationInfo, DraftBookmark, InlineCommentInputMethod, TargetType } from '../types';
6
+ import type { AnnotationInfo, DraftBookmark, InlineCommentAnnotationProvider, InlineCommentInputMethod, TargetType } from '../types';
7
7
  import { AnnotationSelectionType } from '../types';
8
8
  import type { InlineCommentPluginState } from './types';
9
9
  /**
@@ -19,7 +19,7 @@ export declare const decorationKey: {
19
19
  export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration;
20
20
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
21
21
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
22
- export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
22
+ export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => DraftBookmark;
23
23
  /**
24
24
  * get selection from position to apply new comment for
25
25
  * @returns bookmarked positions if they exists, otherwise current selection positions
@@ -31,9 +31,9 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
31
31
  * get payload for the open/close analytics event
32
32
  */
33
33
  export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
34
- export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType;
34
+ export declare const isSelectionValid: (state: EditorState, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => AnnotationSelectionType;
35
35
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
36
- export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean;
36
+ export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => boolean;
37
37
  /**
38
38
  * Checks if any of the nodes in a given selection are completely whitespace
39
39
  * This is to conform to Confluence annotation specifications
@@ -2,6 +2,7 @@ import type React from 'react';
2
2
  import type { AnnotationTypes } from '@atlaskit/adf-schema/annotation';
3
3
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import type { AnnotationUpdateEmitter, AnnotationManager } from '@atlaskit/editor-common/annotation';
5
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
5
6
  /**
6
7
  * type of target that annotation apply to.
7
8
  * This is used to apply correct decoration to a draft comment
@@ -99,6 +100,14 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
99
100
  contentType?: string;
100
101
  createComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentCreateComponentProps>>;
101
102
  getCanAddComments?: () => boolean;
103
+ /**
104
+ * @experimental Still under development. Do not use.
105
+ *
106
+ * Determines whether a specific block node supports inline comments.
107
+ * This is additive to `supportedBlockNodes`; a node is supported when either configuration
108
+ * matches it.
109
+ */
110
+ isBlockNodeSupported?: (node: PMNode) => boolean;
102
111
  isToolbarAbove?: boolean;
103
112
  onCommentButtonMount?: () => void;
104
113
  /** Checks whether the active inline comment can be safely closed. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "19.0.3",
3
+ "version": "19.2.0",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "@babel/runtime": "^7.0.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^123.5.0",
38
+ "@atlaskit/editor-common": "^123.7.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"
@@ -48,6 +48,10 @@
48
48
  "wait-for-expect": "^1.2.0"
49
49
  },
50
50
  "platform-feature-flags": {
51
+ "cc_maui_annotations_on_extensions": {
52
+ "type": "boolean",
53
+ "referenceOnly": true
54
+ },
51
55
  "platform_editor_comments_api_manager": {
52
56
  "type": "boolean",
53
57
  "referenceOnly": true