@atlaskit/editor-plugin-annotation 2.9.1 → 2.9.3

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 (30) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/editor-commands/index.js +40 -30
  3. package/dist/cjs/editor-commands/transform.js +33 -1
  4. package/dist/cjs/pm-plugins/annotation-manager-hooks.js +2 -3
  5. package/dist/cjs/pm-plugins/inline-comment.js +33 -35
  6. package/dist/cjs/pm-plugins/plugin-factory.js +5 -3
  7. package/dist/cjs/pm-plugins/reducer.js +2 -2
  8. package/dist/cjs/pm-plugins/toolbar.js +30 -26
  9. package/dist/cjs/ui/InlineCommentView.js +1 -2
  10. package/dist/es2019/editor-commands/index.js +13 -7
  11. package/dist/es2019/editor-commands/transform.js +27 -1
  12. package/dist/es2019/pm-plugins/annotation-manager-hooks.js +2 -3
  13. package/dist/es2019/pm-plugins/inline-comment.js +22 -25
  14. package/dist/es2019/pm-plugins/plugin-factory.js +5 -3
  15. package/dist/es2019/pm-plugins/reducer.js +2 -2
  16. package/dist/es2019/pm-plugins/toolbar.js +30 -26
  17. package/dist/esm/editor-commands/index.js +40 -30
  18. package/dist/esm/editor-commands/transform.js +33 -1
  19. package/dist/esm/pm-plugins/annotation-manager-hooks.js +2 -3
  20. package/dist/esm/pm-plugins/inline-comment.js +33 -35
  21. package/dist/esm/pm-plugins/plugin-factory.js +5 -3
  22. package/dist/esm/pm-plugins/reducer.js +2 -2
  23. package/dist/esm/pm-plugins/toolbar.js +30 -26
  24. package/dist/types/editor-commands/index.d.ts +2 -2
  25. package/dist/types/editor-commands/transform.d.ts +2 -0
  26. package/dist/types/pm-plugins/types.d.ts +4 -0
  27. package/dist/types-ts4.5/editor-commands/index.d.ts +2 -2
  28. package/dist/types-ts4.5/editor-commands/transform.d.ts +2 -0
  29. package/dist/types-ts4.5/pm-plugins/types.d.ts +4 -0
  30. package/package.json +3 -6
@@ -31,7 +31,7 @@ export default (function (pluginState, action) {
31
31
  isOpeningMediaCommentFromToolbar: false
32
32
  }, fg('platform_editor_annotation_selected_annotation') && {
33
33
  selectedAnnotations: []
34
- }), fg('platform_editor_comments_api_manager_select') && {
34
+ }), pluginState.isAnnotationManagerEnabled && {
35
35
  selectedAnnotations: []
36
36
  });
37
37
  case ACTIONS.ADD_INLINE_COMMENT:
@@ -41,7 +41,7 @@ export default (function (pluginState, action) {
41
41
  annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
42
42
  isInlineCommentViewClosed: false,
43
43
  selectAnnotationMethod: undefined
44
- }, fg('platform_editor_comments_api_manager_select') && {
44
+ }, pluginState.isAnnotationManagerEnabled && {
45
45
  skipSelectionHandling: true
46
46
  });
47
47
  case ACTIONS.INLINE_COMMENT_SET_VISIBLE:
@@ -116,25 +116,17 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
116
116
  }
117
117
  },
118
118
  onClick: function onClick(state, dispatch) {
119
- if (editorAnalyticsAPI) {
120
- editorAnalyticsAPI.fireAnalyticsEvent({
121
- action: ACTION.CLICKED,
122
- actionSubject: ACTION_SUBJECT.BUTTON,
123
- actionSubjectId: ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
124
- eventType: EVENT_TYPE.UI,
125
- attributes: {
126
- source: 'highlightActionsMenu',
127
- pageMode: 'edit'
128
- }
129
- });
130
- }
131
- if (fg('platform_editor_comments_api_manager')) {
132
- if (!annotationManager) {
133
- // TODO: EDITOR-595 - If we've reached here and the manager is not initialized, we should
134
- // dispatch an analytics event to indicate that the user has clicked the button but
135
- // the action was not completed.
136
- return false;
119
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
120
+ action: ACTION.CLICKED,
121
+ actionSubject: ACTION_SUBJECT.BUTTON,
122
+ actionSubjectId: ACTION_SUBJECT_ID.CREATE_INLINE_COMMENT_FROM_HIGHLIGHT_ACTIONS_MENU,
123
+ eventType: EVENT_TYPE.UI,
124
+ attributes: {
125
+ source: 'highlightActionsMenu',
126
+ pageMode: 'edit'
137
127
  }
128
+ });
129
+ if (annotationManager) {
138
130
  annotationManager.checkPreemptiveGate().then(function (canStartDraft) {
139
131
  if (canStartDraft) {
140
132
  createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
@@ -145,18 +137,30 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
145
137
  });
146
138
  createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.initExperience.start();
147
139
  var result = annotationManager.startDraft();
148
- if (result.success) {
149
- // TODO: EDITOR-595 - Ensure and anlytic is fired to indicate that the user has started a draft.
150
- } else {
151
- // TODO: EDITOR-595 - Fire an analytics event to indicate that the user has clicked the button
140
+ if (!result.success) {
141
+ // Fire an analytics event to indicate that the user has clicked the button
152
142
  // but the action was not completed, the result should contain a reason.
143
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
144
+ action: ACTION.ERROR,
145
+ actionSubject: ACTION_SUBJECT.ANNOTATION,
146
+ actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
147
+ eventType: EVENT_TYPE.OPERATIONAL,
148
+ attributes: {
149
+ errorReason: "toolbar-start-draft-failed/".concat(result.reason)
150
+ }
151
+ });
153
152
  }
154
- } else {
155
- // TODO: EDITOR-595 - Track the toolbar comment button was clicked but the preemptive gate
156
- // check returned false and the draft cannot be started.
157
153
  }
158
154
  }).catch(function () {
159
- // TODO: EDITOR-595 - Handle preemptive gate check error. Something went very wrong in the gate.
155
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.fireAnalyticsEvent({
156
+ action: ACTION.ERROR,
157
+ actionSubject: ACTION_SUBJECT.ANNOTATION,
158
+ actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
159
+ eventType: EVENT_TYPE.OPERATIONAL,
160
+ attributes: {
161
+ errorReason: "toolbar-start-draft-preemptive-gate-error"
162
+ }
163
+ });
160
164
  });
161
165
  return true;
162
166
  } else {
@@ -9,10 +9,10 @@ import type { 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
- export declare const flushPendingSelections: (canSetAsSelectedAnnotations: boolean) => Command;
12
+ export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
13
13
  export declare const setPendingSelectedAnnotation: (id: string) => Command;
14
14
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
15
- export declare const removeInlineCommentFromDoc: (id: string, supportedNodes?: string[]) => Command;
15
+ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[]) => Command;
16
16
  /**
17
17
  * Show active inline comments for a given block node, otherwise,
18
18
  * return false if the node has no comments or no unresolved comments.
@@ -18,5 +18,7 @@ declare const _default: {
18
18
  addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
19
19
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
20
20
  addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
21
+ addPreemptiveGateErrorAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (errorReason?: string | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
22
+ addDeleteAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
21
23
  };
22
24
  export default _default;
@@ -162,4 +162,8 @@ export type InlineCommentPluginState = {
162
162
  * if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
163
163
  */
164
164
  pendingSelectedAnnotationsUpdateCount: number;
165
+ /**
166
+ * A simple toggle to indicate if the annotation manager is enabled.
167
+ */
168
+ isAnnotationManagerEnabled: boolean;
165
169
  };
@@ -9,10 +9,10 @@ import type { 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
- export declare const flushPendingSelections: (canSetAsSelectedAnnotations: boolean) => Command;
12
+ export declare const flushPendingSelections: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (canSetAsSelectedAnnotations: boolean, errorReason?: string) => Command;
13
13
  export declare const setPendingSelectedAnnotation: (id: string) => Command;
14
14
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
15
- export declare const removeInlineCommentFromDoc: (id: string, supportedNodes?: string[]) => Command;
15
+ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (id: string, supportedNodes?: string[]) => Command;
16
16
  /**
17
17
  * Show active inline comments for a given block node, otherwise,
18
18
  * return false if the node has no comments or no unresolved comments.
@@ -18,5 +18,7 @@ declare const _default: {
18
18
  addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
19
19
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
20
20
  addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
21
+ addPreemptiveGateErrorAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (errorReason?: string | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
22
+ addDeleteAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
21
23
  };
22
24
  export default _default;
@@ -162,4 +162,8 @@ export type InlineCommentPluginState = {
162
162
  * if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
163
163
  */
164
164
  pendingSelectedAnnotationsUpdateCount: number;
165
+ /**
166
+ * A simple toggle to indicate if the annotation manager is enabled.
167
+ */
168
+ isAnnotationManagerEnabled: boolean;
165
169
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
35
  "@atlaskit/analytics-next": "^11.0.0",
36
- "@atlaskit/editor-common": "^106.0.0",
36
+ "@atlaskit/editor-common": "^106.1.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
38
38
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/icon": "^26.4.0",
43
43
  "@atlaskit/onboarding": "^14.2.0",
44
44
  "@atlaskit/platform-feature-flags": "^1.1.0",
45
- "@atlaskit/tmp-editor-statsig": "^5.2.0",
45
+ "@atlaskit/tmp-editor-statsig": "^5.7.0",
46
46
  "@babel/runtime": "^7.0.0"
47
47
  },
48
48
  "peerDependencies": {
@@ -97,9 +97,6 @@
97
97
  "platform_editor_comments_api_manager": {
98
98
  "type": "boolean"
99
99
  },
100
- "platform_editor_comments_api_manager_select": {
101
- "type": "boolean"
102
- },
103
100
  "editor_inline_comments_on_inline_nodes": {
104
101
  "type": "boolean"
105
102
  },