@atlaskit/editor-plugin-annotation 3.3.9 → 3.3.10

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,13 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 3.3.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`265c1bf0cefa4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/265c1bf0cefa4) -
8
+ Sorted type and interface props to improve Atlaskit docs
9
+ - Updated dependencies
10
+
3
11
  ## 3.3.9
4
12
 
5
13
  ### Patch Changes
@@ -24,11 +24,8 @@ export type AnnotationPluginDependencies = [
24
24
  ];
25
25
  export type AnnotationPluginOptions = AnnotationProviders;
26
26
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
27
- pluginConfiguration: AnnotationPluginOptions | undefined;
28
- sharedState: InlineCommentPluginState | undefined;
29
- dependencies: AnnotationPluginDependencies;
30
27
  actions: {
31
- stripNonExistingAnnotations: StripNonExistingAnnotations;
28
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
32
29
  setInlineCommentDraftState: SetInlineCommentDraftState;
33
30
  /**
34
31
  * This function attempts to display the inline comment popup for a given node.
@@ -36,8 +33,11 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
36
33
  * otherwise, it will return false.
37
34
  */
38
35
  showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
39
- hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
36
+ stripNonExistingAnnotations: StripNonExistingAnnotations;
40
37
  };
38
+ dependencies: AnnotationPluginDependencies;
39
+ pluginConfiguration: AnnotationPluginOptions | undefined;
40
+ sharedState: InlineCommentPluginState | undefined;
41
41
  }>;
42
42
  export type AnnotationPluginInjectionAPI = ExtractInjectionAPI<AnnotationPlugin> | undefined;
43
43
  export {};
@@ -8,21 +8,21 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import type { AnnotationPlugin } from '../annotationPluginType';
9
9
  import { type AnnotationProviders } from '../types';
10
10
  interface BuildToolbarOptions {
11
- state: EditorState;
12
- intl: IntlShape;
13
- isToolbarAbove?: boolean;
14
- isCommentOnMediaOn?: boolean;
15
11
  _supportedNodes?: string[];
12
+ annotationManager?: AnnotationProviders['annotationManager'];
16
13
  api?: ExtractInjectionAPI<AnnotationPlugin>;
14
+ contentType?: string;
17
15
  createCommentExperience?: AnnotationProviders['createCommentExperience'];
18
- annotationManager?: AnnotationProviders['annotationManager'];
19
- onCommentButtonMount?: () => void;
20
16
  getCanAddComments?: () => boolean;
21
- contentType?: string;
17
+ intl: IntlShape;
18
+ isCommentOnMediaOn?: boolean;
19
+ isToolbarAbove?: boolean;
20
+ onCommentButtonMount?: () => void;
21
+ state: EditorState;
22
22
  }
23
23
  type ShouldSuppressFloatingToolbarOptions = {
24
- state: EditorState;
25
24
  bookmark?: SelectionBookmark;
25
+ state: EditorState;
26
26
  };
27
27
  /**
28
28
  * Should suppress toolbars when the user is creating an inline comment
@@ -42,9 +42,9 @@ export declare const buildSuppressedToolbar: (state: EditorState) => {
42
42
  __suppressAllToolbars: boolean;
43
43
  };
44
44
  export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, onCommentButtonMount, getCanAddComments, contentType, }: BuildToolbarOptions) => {
45
- title: string;
46
- nodeType: NodeType[];
47
45
  items: FloatingToolbarButton<Command>[];
46
+ nodeType: NodeType[];
48
47
  onPositionCalculated: (editorView: EditorView, nextPos: PopupPosition) => PopupPosition;
48
+ title: string;
49
49
  } | undefined;
50
50
  export {};
@@ -20,14 +20,14 @@ export declare enum ACTIONS {
20
20
  SET_PENDING_SELECTIONS = 10
21
21
  }
22
22
  export interface InlineCommentPluginOptions {
23
+ annotationManager?: AnnotationManager;
24
+ api?: AnnotationPluginInjectionAPI;
23
25
  dispatch: Dispatch;
24
- provider: InlineCommentAnnotationProvider;
25
26
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
26
27
  featureFlagsPluginState?: FeatureFlags;
28
+ provider: InlineCommentAnnotationProvider;
27
29
  selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
28
30
  viewInlineCommentTraceUFOPress?: AnnotationProviders['viewInlineCommentTraceUFOPress'];
29
- annotationManager?: AnnotationManager;
30
- api?: AnnotationPluginInjectionAPI;
31
31
  }
32
32
  export interface InlineCommentMouseData {
33
33
  isSelecting: boolean;
@@ -36,63 +36,63 @@ export type InlineCommentMap = {
36
36
  [key: string]: boolean;
37
37
  };
38
38
  export type InlineCommentAction = {
39
- type: ACTIONS.UPDATE_INLINE_COMMENT_STATE;
40
39
  data: InlineCommentMap;
40
+ type: ACTIONS.UPDATE_INLINE_COMMENT_STATE;
41
41
  } | {
42
- type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE;
43
42
  data: {
44
43
  drafting: boolean;
45
44
  editorState: EditorState;
46
- targetType?: TargetType;
45
+ isOpeningMediaCommentFromToolbar?: boolean;
47
46
  supportedBlockNodes?: string[];
48
47
  targetNodeId?: string;
49
- isOpeningMediaCommentFromToolbar?: boolean;
48
+ targetType?: TargetType;
50
49
  };
50
+ type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE;
51
51
  } | {
52
- type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
53
52
  data: {
54
53
  mouseData: InlineCommentMouseData;
55
54
  };
55
+ type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
56
56
  } | {
57
57
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK;
58
58
  } | {
59
59
  type: ACTIONS.CLOSE_COMPONENT;
60
60
  } | {
61
- type: ACTIONS.ADD_INLINE_COMMENT;
62
61
  data: {
63
62
  drafting: boolean;
64
- inlineComments: InlineCommentMap;
65
63
  editorState: EditorState;
64
+ inlineComments: InlineCommentMap;
66
65
  selectedAnnotations: AnnotationInfo[];
67
66
  };
67
+ type: ACTIONS.ADD_INLINE_COMMENT;
68
68
  } | {
69
- type: ACTIONS.INLINE_COMMENT_SET_VISIBLE;
70
69
  data: {
71
70
  isVisible: boolean;
72
71
  };
72
+ type: ACTIONS.INLINE_COMMENT_SET_VISIBLE;
73
73
  } | {
74
- type: ACTIONS.SET_SELECTED_ANNOTATION;
75
74
  data: {
76
- selectedAnnotations: AnnotationInfo[];
77
- selectAnnotationMethod?: VIEW_METHOD;
78
75
  isOpeningMediaCommentFromToolbar?: boolean;
76
+ selectAnnotationMethod?: VIEW_METHOD;
77
+ selectedAnnotations: AnnotationInfo[];
79
78
  };
79
+ type: ACTIONS.SET_SELECTED_ANNOTATION;
80
80
  } | {
81
- type: ACTIONS.SET_HOVERED_ANNOTATION;
82
81
  data: {
83
82
  hoveredAnnotations: AnnotationInfo[];
84
83
  selectAnnotationMethod?: VIEW_METHOD;
85
84
  };
85
+ type: ACTIONS.SET_HOVERED_ANNOTATION;
86
86
  } | {
87
- type: ACTIONS.FLUSH_PENDING_SELECTIONS;
88
87
  data: {
89
88
  canSetAsSelectedAnnotations: boolean;
90
89
  };
90
+ type: ACTIONS.FLUSH_PENDING_SELECTIONS;
91
91
  } | {
92
- type: ACTIONS.SET_PENDING_SELECTIONS;
93
92
  data: {
94
93
  selectedAnnotations: AnnotationInfo[];
95
94
  };
95
+ type: ACTIONS.SET_PENDING_SELECTIONS;
96
96
  };
97
97
  export type InlineCommentPluginState = {
98
98
  /**
@@ -116,22 +116,16 @@ export type InlineCommentPluginState = {
116
116
  * ```
117
117
  */
118
118
  annotations: InlineCommentMap;
119
- /**
120
- * A list of the annotations at the current selection.
121
- *
122
- * While this is a list, consumers only make use of the first element, and from the
123
- * user perspective, there is only one annotation selected at a time.
124
- */
125
- selectedAnnotations: AnnotationInfo[];
119
+ bookmark?: SelectionBookmark;
126
120
  /**
127
121
  * Indicates the document has annotations which it does not currently know the resolved state of.
128
122
  * This can happen when the annotations are loaded via ncs, and the editor has not received the
129
123
  * resolved state of the annotations yet (as the resolved state comes from a separate service).
130
124
  */
131
125
  dirtyAnnotations?: boolean;
132
- mouseData: InlineCommentMouseData;
126
+ disallowOnWhitespace: boolean;
133
127
  draftDecorationSet?: DecorationSet;
134
- bookmark?: SelectionBookmark;
128
+ featureFlagsPluginState?: FeatureFlags;
135
129
  /**
136
130
  * Warning: This is not the state of annotations which are currently being hovered over,
137
131
  * but rather the annotations which have been given a selected like visual state from an
@@ -140,16 +134,15 @@ export type InlineCommentPluginState = {
140
134
  * a "hovered" state on the annotation, while the comment is hovered in the sidebar.
141
135
  */
142
136
  hoveredAnnotations?: AnnotationInfo[];
143
- disallowOnWhitespace: boolean;
144
- isInlineCommentViewClosed: boolean;
145
- isVisible: boolean;
146
- skipSelectionHandling: boolean;
147
- featureFlagsPluginState?: FeatureFlags;
137
+ /**
138
+ * A simple toggle to indicate if the annotation manager is enabled.
139
+ */
140
+ isAnnotationManagerEnabled: boolean;
148
141
  isDrafting: boolean;
149
- targetNodeId?: string;
150
- selectAnnotationMethod?: VIEW_METHOD;
142
+ isInlineCommentViewClosed: boolean;
151
143
  isOpeningMediaCommentFromToolbar?: boolean;
152
- selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
144
+ isVisible: boolean;
145
+ mouseData: InlineCommentMouseData;
153
146
  /**
154
147
  * This is a list of annotations which are to be selected. This is updated all the time when the selection changes, and
155
148
  * are periodically flushed to selectedAnnotations. This flush event results in the annotations being selected in the editor.
@@ -163,8 +156,15 @@ export type InlineCommentPluginState = {
163
156
  * if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
164
157
  */
165
158
  pendingSelectedAnnotationsUpdateCount: number;
159
+ selectAnnotationMethod?: VIEW_METHOD;
160
+ selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
166
161
  /**
167
- * A simple toggle to indicate if the annotation manager is enabled.
162
+ * A list of the annotations at the current selection.
163
+ *
164
+ * While this is a list, consumers only make use of the first element, and from the
165
+ * user perspective, there is only one annotation selected at a time.
168
166
  */
169
- isAnnotationManagerEnabled: boolean;
167
+ selectedAnnotations: AnnotationInfo[];
168
+ skipSelectionHandling: boolean;
169
+ targetNodeId?: string;
170
170
  };
@@ -16,34 +16,34 @@ export type AnnotationInfo = {
16
16
  type: AnnotationTypes.INLINE_COMMENT;
17
17
  };
18
18
  type AnnotationComponentProps = {
19
- /**
20
- * Selected text (can be used when creating a comment)
21
- */
22
- textSelection?: string;
23
19
  /**
24
20
  * DOM element around selected text (for positioning)
25
21
  */
26
22
  dom?: HTMLElement;
23
+ /**
24
+ * Indicates whether the comment UI is offline and should be disabled
25
+ */
26
+ isOffline?: boolean;
27
27
  /**
28
28
  * Indicates that a draft comment was discarded/cancelled
29
29
  */
30
30
  onClose?: () => void;
31
31
  /**
32
- * Indicates whether the comment UI is offline and should be disabled
32
+ * Selected text (can be used when creating a comment)
33
33
  */
34
- isOffline?: boolean;
34
+ textSelection?: string;
35
35
  };
36
36
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
37
- /**
38
- * Creates an annotation mark in the document with the given id.
39
- */
40
- onCreate: (id: string) => void;
41
37
  /** List of inline node types, which are wrapped by the annotation. */
42
38
  inlineNodeTypes: string[] | undefined;
43
39
  /**
44
40
  * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
45
41
  */
46
42
  isOpeningMediaCommentFromToolbar?: boolean;
43
+ /**
44
+ * Creates an annotation mark in the document with the given id.
45
+ */
46
+ onCreate: (id: string) => void;
47
47
  wasNewAnnotationSelected?: boolean;
48
48
  };
49
49
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
@@ -52,14 +52,6 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
52
52
  * These are provided in order, inner-most first.
53
53
  */
54
54
  annotations: Array<AnnotationInfo>;
55
- /**
56
- * Resolves an annotation with the given ID around the selection.
57
- */
58
- onResolve: (id: string) => void;
59
- /**
60
- * Removes the annotation from the document
61
- */
62
- onDelete?: (id: string) => void;
63
55
  /**
64
56
  * Ordered list of annotation ids as shown in the document
65
57
  */
@@ -78,6 +70,14 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
78
70
  * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
79
71
  */
80
72
  isOpeningMediaCommentFromToolbar?: boolean;
73
+ /**
74
+ * Removes the annotation from the document
75
+ */
76
+ onDelete?: (id: string) => void;
77
+ /**
78
+ * Resolves an annotation with the given ID around the selection.
79
+ */
80
+ onResolve: (id: string) => void;
81
81
  };
82
82
  export interface AnnotationState<Type, State> {
83
83
  annotationType: Type;
@@ -85,17 +85,19 @@ export interface AnnotationState<Type, State> {
85
85
  state: State;
86
86
  }
87
87
  export interface AnnotationTypeProvider<Type, State> {
88
+ disallowOnWhitespace?: boolean;
88
89
  getState: (annotationIds: string[]) => Promise<AnnotationState<Type, State>[]>;
89
90
  updateSubscriber?: AnnotationUpdateEmitter;
90
- disallowOnWhitespace?: boolean;
91
91
  }
92
92
  export type InlineCommentState = {
93
93
  resolved: boolean;
94
94
  };
95
95
  export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationTypes.INLINE_COMMENT, InlineCommentState> & {
96
+ contentType?: string;
96
97
  createComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentCreateComponentProps>>;
97
- viewComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentViewComponentProps>>;
98
+ getCanAddComments?: () => boolean;
98
99
  isToolbarAbove?: boolean;
100
+ onCommentButtonMount?: () => void;
99
101
  /**
100
102
  * @experimental Still under development. Do not use.
101
103
  *
@@ -106,38 +108,36 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
106
108
  * Note 2: text is supported by default.
107
109
  */
108
110
  supportedBlockNodes?: string[];
109
- onCommentButtonMount?: () => void;
110
- getCanAddComments?: () => boolean;
111
- contentType?: string;
111
+ viewComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentViewComponentProps>>;
112
112
  };
113
113
  export interface AnnotationProviders {
114
- inlineComment: InlineCommentAnnotationProvider;
114
+ annotationManager?: AnnotationManager;
115
115
  createCommentExperience?: {
116
+ initExperience: {
117
+ start: () => void;
118
+ };
116
119
  start: (_: {
117
120
  attributes: {
118
- pageClass: 'editor';
119
- commentType: 'inline';
120
121
  annotationId?: undefined;
122
+ commentType: 'inline';
121
123
  entryPoint?: 'highlightActions';
122
- } | {
123
124
  pageClass: 'editor';
124
- commentType: 'block';
125
- blockType: 'media';
125
+ } | {
126
126
  annotationId?: undefined;
127
+ blockType: 'media';
128
+ commentType: 'block';
127
129
  entryPoint?: 'highlightActions';
130
+ pageClass: 'editor';
128
131
  };
129
132
  }) => void;
130
- initExperience: {
131
- start: () => void;
132
- };
133
133
  };
134
+ inlineComment: InlineCommentAnnotationProvider;
134
135
  selectCommentExperience?: {
135
136
  selectAnnotation: {
136
137
  complete: (annotationId: string) => void;
137
138
  };
138
139
  };
139
140
  viewInlineCommentTraceUFOPress?: () => void;
140
- annotationManager?: AnnotationManager;
141
141
  }
142
142
  export declare enum AnnotationSelectionType {
143
143
  INVALID = "invalid",// Annotation should not be created, toolbar should not be shown
@@ -152,15 +152,15 @@ export declare const AnnotationTestIds: {
152
152
  componentClose: string;
153
153
  };
154
154
  export type CoordsAtPos = {
155
- top: number;
156
155
  bottom: number;
157
156
  left: number;
158
157
  right: number;
158
+ top: number;
159
159
  };
160
160
  export type DraftBookmark = {
161
161
  from: number;
162
- to: number;
163
162
  head: number;
164
163
  isBlockNode?: boolean;
164
+ to: number;
165
165
  };
166
166
  export {};
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  type AnnotationViewWrapperProps = {
3
+ annotationText?: string;
3
4
  children: React.ReactNode;
4
5
  onViewed?: () => void;
5
- annotationText?: string;
6
6
  };
7
7
  export declare class AnnotationViewWrapper extends React.PureComponent<AnnotationViewWrapperProps> {
8
8
  componentDidMount(): void;
@@ -3,8 +3,8 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { AnnotationPlugin } from '../../annotationPluginType';
4
4
  import { type AnnotationProviders } from '../../types';
5
5
  type CommentButtonProps = {
6
- api?: ExtractInjectionAPI<AnnotationPlugin>;
7
6
  annotationProviders?: AnnotationProviders;
7
+ api?: ExtractInjectionAPI<AnnotationPlugin>;
8
8
  };
9
9
  export declare const CommentButton: ({ api, annotationProviders }: CommentButtonProps) => React.JSX.Element | null;
10
10
  export {};
@@ -4,9 +4,9 @@ import type { AnnotationPlugin } from '../../annotationPluginType';
4
4
  import type { AnnotationSelectionType } from '../../types';
5
5
  import { type AnnotationProviders } from '../../types';
6
6
  export declare const useCommentButtonMount: ({ state, annotationProviders, api, annotationSelectionType, bookmark, }: {
7
- state: EditorState | null;
8
7
  annotationProviders?: AnnotationProviders;
9
- api?: ExtractInjectionAPI<AnnotationPlugin>;
10
8
  annotationSelectionType: AnnotationSelectionType;
9
+ api?: ExtractInjectionAPI<AnnotationPlugin>;
11
10
  bookmark?: SelectionBookmark;
11
+ state: EditorState | null;
12
12
  }) => void;
@@ -4,25 +4,25 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { AnnotationPlugin } from '../../annotationPluginType';
5
5
  import { AnnotationSelectionType, type AnnotationProviders } from '../../types';
6
6
  export declare const isButtonDisabled: ({ state, api, }: {
7
- state: EditorState | null;
8
7
  api?: ExtractInjectionAPI<AnnotationPlugin>;
8
+ state: EditorState | null;
9
9
  }) => boolean;
10
10
  export declare const shouldShowCommentButton: ({ state, isVisible, annotationSelectionType, }: {
11
- state: EditorState | null;
12
- isVisible?: boolean;
13
11
  annotationSelectionType: AnnotationSelectionType;
12
+ isVisible?: boolean;
13
+ state: EditorState | null;
14
14
  }) => boolean;
15
15
  export declare const fireOnClickAnalyticsEvent: ({ api, }: {
16
16
  api: ExtractInjectionAPI<AnnotationPlugin>;
17
17
  }) => void;
18
18
  export declare const fireCommentButtonViewedAnalyticsEvent: ({ api, isNonTextInlineNodeInludedInComment, annotationSelectionType, }: {
19
+ annotationSelectionType: AnnotationSelectionType;
19
20
  api?: ExtractInjectionAPI<AnnotationPlugin>;
20
21
  isNonTextInlineNodeInludedInComment: boolean;
21
- annotationSelectionType: AnnotationSelectionType;
22
22
  }) => void;
23
23
  export declare const startCommentExperience: ({ annotationProviders, api, state, dispatch, }: {
24
24
  annotationProviders: AnnotationProviders;
25
25
  api: ExtractInjectionAPI<AnnotationPlugin>;
26
- state: EditorState;
27
26
  dispatch: EditorView["dispatch"];
27
+ state: EditorState;
28
28
  }) => boolean;
@@ -5,11 +5,11 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { AnnotationPlugin } from '../annotationPluginType';
6
6
  import { type AnnotationProviders } from '../types';
7
7
  interface InlineCommentViewProps {
8
- providers: AnnotationProviders;
9
- editorView: EditorView;
8
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
10
9
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
11
10
  editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined;
12
- dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
11
+ editorView: EditorView;
12
+ providers: AnnotationProviders;
13
13
  }
14
14
  export declare function InlineCommentView({ providers, editorView, editorAnalyticsAPI, editorAPI, dispatchAnalyticsEvent, }: InlineCommentViewProps): React.JSX.Element | null;
15
15
  export {};
@@ -24,11 +24,8 @@ export type AnnotationPluginDependencies = [
24
24
  ];
25
25
  export type AnnotationPluginOptions = AnnotationProviders;
26
26
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
27
- pluginConfiguration: AnnotationPluginOptions | undefined;
28
- sharedState: InlineCommentPluginState | undefined;
29
- dependencies: AnnotationPluginDependencies;
30
27
  actions: {
31
- stripNonExistingAnnotations: StripNonExistingAnnotations;
28
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
32
29
  setInlineCommentDraftState: SetInlineCommentDraftState;
33
30
  /**
34
31
  * This function attempts to display the inline comment popup for a given node.
@@ -36,8 +33,11 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
36
33
  * otherwise, it will return false.
37
34
  */
38
35
  showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
39
- hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
36
+ stripNonExistingAnnotations: StripNonExistingAnnotations;
40
37
  };
38
+ dependencies: AnnotationPluginDependencies;
39
+ pluginConfiguration: AnnotationPluginOptions | undefined;
40
+ sharedState: InlineCommentPluginState | undefined;
41
41
  }>;
42
42
  export type AnnotationPluginInjectionAPI = ExtractInjectionAPI<AnnotationPlugin> | undefined;
43
43
  export {};
@@ -8,21 +8,21 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
8
8
  import type { AnnotationPlugin } from '../annotationPluginType';
9
9
  import { type AnnotationProviders } from '../types';
10
10
  interface BuildToolbarOptions {
11
- state: EditorState;
12
- intl: IntlShape;
13
- isToolbarAbove?: boolean;
14
- isCommentOnMediaOn?: boolean;
15
11
  _supportedNodes?: string[];
12
+ annotationManager?: AnnotationProviders['annotationManager'];
16
13
  api?: ExtractInjectionAPI<AnnotationPlugin>;
14
+ contentType?: string;
17
15
  createCommentExperience?: AnnotationProviders['createCommentExperience'];
18
- annotationManager?: AnnotationProviders['annotationManager'];
19
- onCommentButtonMount?: () => void;
20
16
  getCanAddComments?: () => boolean;
21
- contentType?: string;
17
+ intl: IntlShape;
18
+ isCommentOnMediaOn?: boolean;
19
+ isToolbarAbove?: boolean;
20
+ onCommentButtonMount?: () => void;
21
+ state: EditorState;
22
22
  }
23
23
  type ShouldSuppressFloatingToolbarOptions = {
24
- state: EditorState;
25
24
  bookmark?: SelectionBookmark;
25
+ state: EditorState;
26
26
  };
27
27
  /**
28
28
  * Should suppress toolbars when the user is creating an inline comment
@@ -42,9 +42,9 @@ export declare const buildSuppressedToolbar: (state: EditorState) => {
42
42
  __suppressAllToolbars: boolean;
43
43
  };
44
44
  export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, onCommentButtonMount, getCanAddComments, contentType, }: BuildToolbarOptions) => {
45
- title: string;
46
- nodeType: NodeType[];
47
45
  items: FloatingToolbarButton<Command>[];
46
+ nodeType: NodeType[];
48
47
  onPositionCalculated: (editorView: EditorView, nextPos: PopupPosition) => PopupPosition;
48
+ title: string;
49
49
  } | undefined;
50
50
  export {};
@@ -20,14 +20,14 @@ export declare enum ACTIONS {
20
20
  SET_PENDING_SELECTIONS = 10
21
21
  }
22
22
  export interface InlineCommentPluginOptions {
23
+ annotationManager?: AnnotationManager;
24
+ api?: AnnotationPluginInjectionAPI;
23
25
  dispatch: Dispatch;
24
- provider: InlineCommentAnnotationProvider;
25
26
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
26
27
  featureFlagsPluginState?: FeatureFlags;
28
+ provider: InlineCommentAnnotationProvider;
27
29
  selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
28
30
  viewInlineCommentTraceUFOPress?: AnnotationProviders['viewInlineCommentTraceUFOPress'];
29
- annotationManager?: AnnotationManager;
30
- api?: AnnotationPluginInjectionAPI;
31
31
  }
32
32
  export interface InlineCommentMouseData {
33
33
  isSelecting: boolean;
@@ -36,63 +36,63 @@ export type InlineCommentMap = {
36
36
  [key: string]: boolean;
37
37
  };
38
38
  export type InlineCommentAction = {
39
- type: ACTIONS.UPDATE_INLINE_COMMENT_STATE;
40
39
  data: InlineCommentMap;
40
+ type: ACTIONS.UPDATE_INLINE_COMMENT_STATE;
41
41
  } | {
42
- type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE;
43
42
  data: {
44
43
  drafting: boolean;
45
44
  editorState: EditorState;
46
- targetType?: TargetType;
45
+ isOpeningMediaCommentFromToolbar?: boolean;
47
46
  supportedBlockNodes?: string[];
48
47
  targetNodeId?: string;
49
- isOpeningMediaCommentFromToolbar?: boolean;
48
+ targetType?: TargetType;
50
49
  };
50
+ type: ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE;
51
51
  } | {
52
- type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
53
52
  data: {
54
53
  mouseData: InlineCommentMouseData;
55
54
  };
55
+ type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
56
56
  } | {
57
57
  type: ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK;
58
58
  } | {
59
59
  type: ACTIONS.CLOSE_COMPONENT;
60
60
  } | {
61
- type: ACTIONS.ADD_INLINE_COMMENT;
62
61
  data: {
63
62
  drafting: boolean;
64
- inlineComments: InlineCommentMap;
65
63
  editorState: EditorState;
64
+ inlineComments: InlineCommentMap;
66
65
  selectedAnnotations: AnnotationInfo[];
67
66
  };
67
+ type: ACTIONS.ADD_INLINE_COMMENT;
68
68
  } | {
69
- type: ACTIONS.INLINE_COMMENT_SET_VISIBLE;
70
69
  data: {
71
70
  isVisible: boolean;
72
71
  };
72
+ type: ACTIONS.INLINE_COMMENT_SET_VISIBLE;
73
73
  } | {
74
- type: ACTIONS.SET_SELECTED_ANNOTATION;
75
74
  data: {
76
- selectedAnnotations: AnnotationInfo[];
77
- selectAnnotationMethod?: VIEW_METHOD;
78
75
  isOpeningMediaCommentFromToolbar?: boolean;
76
+ selectAnnotationMethod?: VIEW_METHOD;
77
+ selectedAnnotations: AnnotationInfo[];
79
78
  };
79
+ type: ACTIONS.SET_SELECTED_ANNOTATION;
80
80
  } | {
81
- type: ACTIONS.SET_HOVERED_ANNOTATION;
82
81
  data: {
83
82
  hoveredAnnotations: AnnotationInfo[];
84
83
  selectAnnotationMethod?: VIEW_METHOD;
85
84
  };
85
+ type: ACTIONS.SET_HOVERED_ANNOTATION;
86
86
  } | {
87
- type: ACTIONS.FLUSH_PENDING_SELECTIONS;
88
87
  data: {
89
88
  canSetAsSelectedAnnotations: boolean;
90
89
  };
90
+ type: ACTIONS.FLUSH_PENDING_SELECTIONS;
91
91
  } | {
92
- type: ACTIONS.SET_PENDING_SELECTIONS;
93
92
  data: {
94
93
  selectedAnnotations: AnnotationInfo[];
95
94
  };
95
+ type: ACTIONS.SET_PENDING_SELECTIONS;
96
96
  };
97
97
  export type InlineCommentPluginState = {
98
98
  /**
@@ -116,22 +116,16 @@ export type InlineCommentPluginState = {
116
116
  * ```
117
117
  */
118
118
  annotations: InlineCommentMap;
119
- /**
120
- * A list of the annotations at the current selection.
121
- *
122
- * While this is a list, consumers only make use of the first element, and from the
123
- * user perspective, there is only one annotation selected at a time.
124
- */
125
- selectedAnnotations: AnnotationInfo[];
119
+ bookmark?: SelectionBookmark;
126
120
  /**
127
121
  * Indicates the document has annotations which it does not currently know the resolved state of.
128
122
  * This can happen when the annotations are loaded via ncs, and the editor has not received the
129
123
  * resolved state of the annotations yet (as the resolved state comes from a separate service).
130
124
  */
131
125
  dirtyAnnotations?: boolean;
132
- mouseData: InlineCommentMouseData;
126
+ disallowOnWhitespace: boolean;
133
127
  draftDecorationSet?: DecorationSet;
134
- bookmark?: SelectionBookmark;
128
+ featureFlagsPluginState?: FeatureFlags;
135
129
  /**
136
130
  * Warning: This is not the state of annotations which are currently being hovered over,
137
131
  * but rather the annotations which have been given a selected like visual state from an
@@ -140,16 +134,15 @@ export type InlineCommentPluginState = {
140
134
  * a "hovered" state on the annotation, while the comment is hovered in the sidebar.
141
135
  */
142
136
  hoveredAnnotations?: AnnotationInfo[];
143
- disallowOnWhitespace: boolean;
144
- isInlineCommentViewClosed: boolean;
145
- isVisible: boolean;
146
- skipSelectionHandling: boolean;
147
- featureFlagsPluginState?: FeatureFlags;
137
+ /**
138
+ * A simple toggle to indicate if the annotation manager is enabled.
139
+ */
140
+ isAnnotationManagerEnabled: boolean;
148
141
  isDrafting: boolean;
149
- targetNodeId?: string;
150
- selectAnnotationMethod?: VIEW_METHOD;
142
+ isInlineCommentViewClosed: boolean;
151
143
  isOpeningMediaCommentFromToolbar?: boolean;
152
- selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
144
+ isVisible: boolean;
145
+ mouseData: InlineCommentMouseData;
153
146
  /**
154
147
  * This is a list of annotations which are to be selected. This is updated all the time when the selection changes, and
155
148
  * are periodically flushed to selectedAnnotations. This flush event results in the annotations being selected in the editor.
@@ -163,8 +156,15 @@ export type InlineCommentPluginState = {
163
156
  * if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
164
157
  */
165
158
  pendingSelectedAnnotationsUpdateCount: number;
159
+ selectAnnotationMethod?: VIEW_METHOD;
160
+ selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
166
161
  /**
167
- * A simple toggle to indicate if the annotation manager is enabled.
162
+ * A list of the annotations at the current selection.
163
+ *
164
+ * While this is a list, consumers only make use of the first element, and from the
165
+ * user perspective, there is only one annotation selected at a time.
168
166
  */
169
- isAnnotationManagerEnabled: boolean;
167
+ selectedAnnotations: AnnotationInfo[];
168
+ skipSelectionHandling: boolean;
169
+ targetNodeId?: string;
170
170
  };
@@ -16,34 +16,34 @@ export type AnnotationInfo = {
16
16
  type: AnnotationTypes.INLINE_COMMENT;
17
17
  };
18
18
  type AnnotationComponentProps = {
19
- /**
20
- * Selected text (can be used when creating a comment)
21
- */
22
- textSelection?: string;
23
19
  /**
24
20
  * DOM element around selected text (for positioning)
25
21
  */
26
22
  dom?: HTMLElement;
23
+ /**
24
+ * Indicates whether the comment UI is offline and should be disabled
25
+ */
26
+ isOffline?: boolean;
27
27
  /**
28
28
  * Indicates that a draft comment was discarded/cancelled
29
29
  */
30
30
  onClose?: () => void;
31
31
  /**
32
- * Indicates whether the comment UI is offline and should be disabled
32
+ * Selected text (can be used when creating a comment)
33
33
  */
34
- isOffline?: boolean;
34
+ textSelection?: string;
35
35
  };
36
36
  export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
37
- /**
38
- * Creates an annotation mark in the document with the given id.
39
- */
40
- onCreate: (id: string) => void;
41
37
  /** List of inline node types, which are wrapped by the annotation. */
42
38
  inlineNodeTypes: string[] | undefined;
43
39
  /**
44
40
  * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
45
41
  */
46
42
  isOpeningMediaCommentFromToolbar?: boolean;
43
+ /**
44
+ * Creates an annotation mark in the document with the given id.
45
+ */
46
+ onCreate: (id: string) => void;
47
47
  wasNewAnnotationSelected?: boolean;
48
48
  };
49
49
  export type InlineCommentViewComponentProps = AnnotationComponentProps & {
@@ -52,14 +52,6 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
52
52
  * These are provided in order, inner-most first.
53
53
  */
54
54
  annotations: Array<AnnotationInfo>;
55
- /**
56
- * Resolves an annotation with the given ID around the selection.
57
- */
58
- onResolve: (id: string) => void;
59
- /**
60
- * Removes the annotation from the document
61
- */
62
- onDelete?: (id: string) => void;
63
55
  /**
64
56
  * Ordered list of annotation ids as shown in the document
65
57
  */
@@ -78,6 +70,14 @@ export type InlineCommentViewComponentProps = AnnotationComponentProps & {
78
70
  * Indicates whether we're opening the media comment box from the media toolbar so we can scroll the media into view
79
71
  */
80
72
  isOpeningMediaCommentFromToolbar?: boolean;
73
+ /**
74
+ * Removes the annotation from the document
75
+ */
76
+ onDelete?: (id: string) => void;
77
+ /**
78
+ * Resolves an annotation with the given ID around the selection.
79
+ */
80
+ onResolve: (id: string) => void;
81
81
  };
82
82
  export interface AnnotationState<Type, State> {
83
83
  annotationType: Type;
@@ -85,17 +85,19 @@ export interface AnnotationState<Type, State> {
85
85
  state: State;
86
86
  }
87
87
  export interface AnnotationTypeProvider<Type, State> {
88
+ disallowOnWhitespace?: boolean;
88
89
  getState: (annotationIds: string[]) => Promise<AnnotationState<Type, State>[]>;
89
90
  updateSubscriber?: AnnotationUpdateEmitter;
90
- disallowOnWhitespace?: boolean;
91
91
  }
92
92
  export type InlineCommentState = {
93
93
  resolved: boolean;
94
94
  };
95
95
  export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationTypes.INLINE_COMMENT, InlineCommentState> & {
96
+ contentType?: string;
96
97
  createComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentCreateComponentProps>>;
97
- viewComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentViewComponentProps>>;
98
+ getCanAddComments?: () => boolean;
98
99
  isToolbarAbove?: boolean;
100
+ onCommentButtonMount?: () => void;
99
101
  /**
100
102
  * @experimental Still under development. Do not use.
101
103
  *
@@ -106,38 +108,36 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
106
108
  * Note 2: text is supported by default.
107
109
  */
108
110
  supportedBlockNodes?: string[];
109
- onCommentButtonMount?: () => void;
110
- getCanAddComments?: () => boolean;
111
- contentType?: string;
111
+ viewComponent?: React.ComponentType<React.PropsWithChildren<InlineCommentViewComponentProps>>;
112
112
  };
113
113
  export interface AnnotationProviders {
114
- inlineComment: InlineCommentAnnotationProvider;
114
+ annotationManager?: AnnotationManager;
115
115
  createCommentExperience?: {
116
+ initExperience: {
117
+ start: () => void;
118
+ };
116
119
  start: (_: {
117
120
  attributes: {
118
- pageClass: 'editor';
119
- commentType: 'inline';
120
121
  annotationId?: undefined;
122
+ commentType: 'inline';
121
123
  entryPoint?: 'highlightActions';
122
- } | {
123
124
  pageClass: 'editor';
124
- commentType: 'block';
125
- blockType: 'media';
125
+ } | {
126
126
  annotationId?: undefined;
127
+ blockType: 'media';
128
+ commentType: 'block';
127
129
  entryPoint?: 'highlightActions';
130
+ pageClass: 'editor';
128
131
  };
129
132
  }) => void;
130
- initExperience: {
131
- start: () => void;
132
- };
133
133
  };
134
+ inlineComment: InlineCommentAnnotationProvider;
134
135
  selectCommentExperience?: {
135
136
  selectAnnotation: {
136
137
  complete: (annotationId: string) => void;
137
138
  };
138
139
  };
139
140
  viewInlineCommentTraceUFOPress?: () => void;
140
- annotationManager?: AnnotationManager;
141
141
  }
142
142
  export declare enum AnnotationSelectionType {
143
143
  INVALID = "invalid",// Annotation should not be created, toolbar should not be shown
@@ -152,15 +152,15 @@ export declare const AnnotationTestIds: {
152
152
  componentClose: string;
153
153
  };
154
154
  export type CoordsAtPos = {
155
- top: number;
156
155
  bottom: number;
157
156
  left: number;
158
157
  right: number;
158
+ top: number;
159
159
  };
160
160
  export type DraftBookmark = {
161
161
  from: number;
162
- to: number;
163
162
  head: number;
164
163
  isBlockNode?: boolean;
164
+ to: number;
165
165
  };
166
166
  export {};
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  type AnnotationViewWrapperProps = {
3
+ annotationText?: string;
3
4
  children: React.ReactNode;
4
5
  onViewed?: () => void;
5
- annotationText?: string;
6
6
  };
7
7
  export declare class AnnotationViewWrapper extends React.PureComponent<AnnotationViewWrapperProps> {
8
8
  componentDidMount(): void;
@@ -3,8 +3,8 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
3
  import type { AnnotationPlugin } from '../../annotationPluginType';
4
4
  import { type AnnotationProviders } from '../../types';
5
5
  type CommentButtonProps = {
6
- api?: ExtractInjectionAPI<AnnotationPlugin>;
7
6
  annotationProviders?: AnnotationProviders;
7
+ api?: ExtractInjectionAPI<AnnotationPlugin>;
8
8
  };
9
9
  export declare const CommentButton: ({ api, annotationProviders }: CommentButtonProps) => React.JSX.Element | null;
10
10
  export {};
@@ -4,9 +4,9 @@ import type { AnnotationPlugin } from '../../annotationPluginType';
4
4
  import type { AnnotationSelectionType } from '../../types';
5
5
  import { type AnnotationProviders } from '../../types';
6
6
  export declare const useCommentButtonMount: ({ state, annotationProviders, api, annotationSelectionType, bookmark, }: {
7
- state: EditorState | null;
8
7
  annotationProviders?: AnnotationProviders;
9
- api?: ExtractInjectionAPI<AnnotationPlugin>;
10
8
  annotationSelectionType: AnnotationSelectionType;
9
+ api?: ExtractInjectionAPI<AnnotationPlugin>;
11
10
  bookmark?: SelectionBookmark;
11
+ state: EditorState | null;
12
12
  }) => void;
@@ -4,25 +4,25 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  import type { AnnotationPlugin } from '../../annotationPluginType';
5
5
  import { AnnotationSelectionType, type AnnotationProviders } from '../../types';
6
6
  export declare const isButtonDisabled: ({ state, api, }: {
7
- state: EditorState | null;
8
7
  api?: ExtractInjectionAPI<AnnotationPlugin>;
8
+ state: EditorState | null;
9
9
  }) => boolean;
10
10
  export declare const shouldShowCommentButton: ({ state, isVisible, annotationSelectionType, }: {
11
- state: EditorState | null;
12
- isVisible?: boolean;
13
11
  annotationSelectionType: AnnotationSelectionType;
12
+ isVisible?: boolean;
13
+ state: EditorState | null;
14
14
  }) => boolean;
15
15
  export declare const fireOnClickAnalyticsEvent: ({ api, }: {
16
16
  api: ExtractInjectionAPI<AnnotationPlugin>;
17
17
  }) => void;
18
18
  export declare const fireCommentButtonViewedAnalyticsEvent: ({ api, isNonTextInlineNodeInludedInComment, annotationSelectionType, }: {
19
+ annotationSelectionType: AnnotationSelectionType;
19
20
  api?: ExtractInjectionAPI<AnnotationPlugin>;
20
21
  isNonTextInlineNodeInludedInComment: boolean;
21
- annotationSelectionType: AnnotationSelectionType;
22
22
  }) => void;
23
23
  export declare const startCommentExperience: ({ annotationProviders, api, state, dispatch, }: {
24
24
  annotationProviders: AnnotationProviders;
25
25
  api: ExtractInjectionAPI<AnnotationPlugin>;
26
- state: EditorState;
27
26
  dispatch: EditorView["dispatch"];
27
+ state: EditorState;
28
28
  }) => boolean;
@@ -5,11 +5,11 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { AnnotationPlugin } from '../annotationPluginType';
6
6
  import { type AnnotationProviders } from '../types';
7
7
  interface InlineCommentViewProps {
8
- providers: AnnotationProviders;
9
- editorView: EditorView;
8
+ dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
10
9
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
11
10
  editorAPI: ExtractInjectionAPI<AnnotationPlugin> | undefined;
12
- dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
11
+ editorView: EditorView;
12
+ providers: AnnotationProviders;
13
13
  }
14
14
  export declare function InlineCommentView({ providers, editorView, editorAnalyticsAPI, editorAPI, dispatchAnalyticsEvent, }: InlineCommentViewProps): React.JSX.Element | null;
15
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "3.3.9",
3
+ "version": "3.3.10",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -56,7 +56,6 @@
56
56
  "@af/integration-testing": "workspace:^",
57
57
  "@af/visual-regression": "workspace:^",
58
58
  "@atlaskit/ssr": "workspace:^",
59
- "@atlaskit/visual-regression": "workspace:^",
60
59
  "@testing-library/react": "^13.4.0",
61
60
  "wait-for-expect": "^1.2.0"
62
61
  },