@atlaskit/editor-plugin-annotation 2.1.5 → 2.1.7

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,24 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 2.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#128761](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/128761)
8
+ [`917104463449c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/917104463449c) -
9
+ Ensure the selected annotation state accounts for selections that are in between two annotations.
10
+ - Updated dependencies
11
+
12
+ ## 2.1.6
13
+
14
+ ### Patch Changes
15
+
16
+ - [#127441](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/127441)
17
+ [`f2f4b5971e0b2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2f4b5971e0b2) -
18
+ [ux] Updates Text Formatting toolbar separators, active option style and removes range selection
19
+ when the toolbar is docked to top.
20
+ - Updated dependencies
21
+
3
22
  ## 2.1.5
4
23
 
5
24
  ### Patch Changes
@@ -32,6 +32,7 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
32
32
  }];
33
33
  },
34
34
  actions: {
35
+ hasAnyUnResolvedAnnotationInPage: _utils.hasAnyUnResolvedAnnotationInPage,
35
36
  stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
36
37
  setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
37
38
  showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
@@ -107,7 +107,8 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
107
107
  title: toolbarTitle,
108
108
  nodeType: validNodes,
109
109
  items: [createComment],
110
- onPositionCalculated: onPositionCalculated
110
+ onPositionCalculated: onPositionCalculated,
111
+ pluginName: 'annotation'
111
112
  };
112
113
  };
113
114
  };
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -7,13 +8,14 @@ exports.addDraftDecoration = void 0;
7
8
  exports.annotationExists = annotationExists;
8
9
  exports.getPluginState = exports.getDraftCommandAnalyticsPayload = exports.getAnnotationViewKey = exports.getAllAnnotations = exports.findAnnotationsInSelection = exports.decorationKey = void 0;
9
10
  exports.getSelectionPositions = getSelectionPositions;
10
- exports.hasInvalidNodes = void 0;
11
+ exports.hasInvalidNodes = exports.hasAnyUnResolvedAnnotationInPage = void 0;
11
12
  exports.hasInvalidWhitespaceNode = hasInvalidWhitespaceNode;
12
13
  exports.isCurrentBlockNodeSelected = exports.isBlockNodeAnnotationsSelected = exports.inlineCommentPluginKey = void 0;
13
14
  exports.isSelectedAnnotationsChanged = isSelectedAnnotationsChanged;
14
15
  exports.resolveDraftBookmark = exports.isSupportedBlockNode = exports.isSelectionValid = void 0;
15
16
  exports.stripNonExistingAnnotations = stripNonExistingAnnotations;
16
17
  exports.surroundingMarks = void 0;
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
19
  var _adfSchema = require("@atlaskit/adf-schema");
18
20
  var _analytics = require("@atlaskit/editor-common/analytics");
19
21
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
@@ -187,10 +189,25 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
187
189
  var annotationMark = doc.type.schema.marks.annotation;
188
190
  var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
189
191
  var marks = [];
190
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
191
- marks = anchorAnnotationMarks;
192
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
193
- marks = nodeBefore.marks;
192
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_missing_selected_annotations')) {
193
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
194
+ marks = anchorAnnotationMarks;
195
+ }
196
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
197
+ var _marks;
198
+ var existingMarkIds = marks.map(function (m) {
199
+ return m.attrs.id;
200
+ });
201
+ marks = (_marks = marks).concat.apply(_marks, (0, _toConsumableArray2.default)(nodeBefore.marks.filter(function (m) {
202
+ return !existingMarkIds.includes(m.attrs.id);
203
+ })));
204
+ }
205
+ } else {
206
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
207
+ marks = anchorAnnotationMarks;
208
+ } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
209
+ marks = nodeBefore.marks;
210
+ }
194
211
  }
195
212
  var annotations = marks.filter(function (mark) {
196
213
  return mark.type.name === 'annotation';
@@ -490,4 +507,23 @@ var isBlockNodeAnnotationsSelected = exports.isBlockNodeAnnotationsSelected = fu
490
507
  });
491
508
  }
492
509
  return false;
510
+ };
511
+ var hasAnyUnResolvedAnnotationInPage = exports.hasAnyUnResolvedAnnotationInPage = function hasAnyUnResolvedAnnotationInPage(state) {
512
+ var _getPluginState;
513
+ var annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
514
+ if (annotations) {
515
+ /**
516
+ * annotations type is { [key: string]: boolean };
517
+ * Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
518
+ * When value is false, it means it is unresolved annotation.
519
+ *
520
+ * But sometimes annotation map has entry with key undefined somehow.
521
+ * And it is not valid mark attribute id, so it won't be presented anywhere in the document.
522
+ */
523
+ var unresolvedAnnotationKeys = Object.keys(annotations).filter(function (key) {
524
+ return key !== 'undefined' && annotations[key] === false;
525
+ });
526
+ return unresolvedAnnotationKeys.length > 0;
527
+ }
528
+ return false;
493
529
  };
@@ -6,7 +6,7 @@ import { annotationWithToDOMFix } from './nodeviews/annotationMark';
6
6
  import { inlineCommentPlugin } from './pm-plugins/inline-comment';
7
7
  import { keymapPlugin } from './pm-plugins/keymap';
8
8
  import { buildToolbar } from './pm-plugins/toolbar';
9
- import { getPluginState, stripNonExistingAnnotations } from './pm-plugins/utils';
9
+ import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
10
10
  import { InlineCommentView } from './ui/InlineCommentView';
11
11
  export const annotationPlugin = ({
12
12
  config: annotationProviders,
@@ -23,6 +23,7 @@ export const annotationPlugin = ({
23
23
  }];
24
24
  },
25
25
  actions: {
26
+ hasAnyUnResolvedAnnotationInPage,
26
27
  stripNonExistingAnnotations,
27
28
  setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
28
29
  showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
@@ -100,6 +100,7 @@ export const buildToolbar = editorAnalyticsAPI => ({
100
100
  title: toolbarTitle,
101
101
  nodeType: validNodes,
102
102
  items: [createComment],
103
- onPositionCalculated
103
+ onPositionCalculated,
104
+ pluginName: 'annotation'
104
105
  };
105
106
  };
@@ -159,10 +159,20 @@ export const findAnnotationsInSelection = (selection, doc) => {
159
159
  const annotationMark = doc.type.schema.marks.annotation;
160
160
  const anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
161
161
  let marks = [];
162
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
163
- marks = anchorAnnotationMarks;
164
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
165
- marks = nodeBefore.marks;
162
+ if (fg('platform_editor_fix_missing_selected_annotations')) {
163
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
164
+ marks = anchorAnnotationMarks;
165
+ }
166
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
167
+ const existingMarkIds = marks.map(m => m.attrs.id);
168
+ marks = marks.concat(...nodeBefore.marks.filter(m => !existingMarkIds.includes(m.attrs.id)));
169
+ }
170
+ } else {
171
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
172
+ marks = anchorAnnotationMarks;
173
+ } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
174
+ marks = nodeBefore.marks;
175
+ }
166
176
  }
167
177
  const annotations = marks.filter(mark => mark.type.name === 'annotation').map(mark => ({
168
178
  id: mark.attrs.id,
@@ -454,4 +464,21 @@ export const isBlockNodeAnnotationsSelected = (selection, selectedAnnotations =
454
464
  return !selectedAnnotations.some(annotation => !annotationMarks.find(existingAnnotation => existingAnnotation.id === annotation.id && existingAnnotation.type === annotation.type));
455
465
  }
456
466
  return false;
467
+ };
468
+ export const hasAnyUnResolvedAnnotationInPage = state => {
469
+ var _getPluginState;
470
+ const annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
471
+ if (annotations) {
472
+ /**
473
+ * annotations type is { [key: string]: boolean };
474
+ * Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
475
+ * When value is false, it means it is unresolved annotation.
476
+ *
477
+ * But sometimes annotation map has entry with key undefined somehow.
478
+ * And it is not valid mark attribute id, so it won't be presented anywhere in the document.
479
+ */
480
+ const unresolvedAnnotationKeys = Object.keys(annotations).filter(key => key !== 'undefined' && annotations[key] === false);
481
+ return unresolvedAnnotationKeys.length > 0;
482
+ }
483
+ return false;
457
484
  };
@@ -9,7 +9,7 @@ import { annotationWithToDOMFix } from './nodeviews/annotationMark';
9
9
  import { inlineCommentPlugin } from './pm-plugins/inline-comment';
10
10
  import { keymapPlugin } from './pm-plugins/keymap';
11
11
  import { buildToolbar } from './pm-plugins/toolbar';
12
- import { getPluginState, stripNonExistingAnnotations } from './pm-plugins/utils';
12
+ import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
13
13
  import { InlineCommentView } from './ui/InlineCommentView';
14
14
  export var annotationPlugin = function annotationPlugin(_ref) {
15
15
  var _api$featureFlags, _api$analytics;
@@ -25,6 +25,7 @@ export var annotationPlugin = function annotationPlugin(_ref) {
25
25
  }];
26
26
  },
27
27
  actions: {
28
+ hasAnyUnResolvedAnnotationInPage: hasAnyUnResolvedAnnotationInPage,
28
29
  stripNonExistingAnnotations: stripNonExistingAnnotations,
29
30
  setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes),
30
31
  showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes)
@@ -100,7 +100,8 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
100
100
  title: toolbarTitle,
101
101
  nodeType: validNodes,
102
102
  items: [createComment],
103
- onPositionCalculated: onPositionCalculated
103
+ onPositionCalculated: onPositionCalculated,
104
+ pluginName: 'annotation'
104
105
  };
105
106
  };
106
107
  };
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
3
4
  import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
@@ -171,10 +172,25 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
171
172
  var annotationMark = doc.type.schema.marks.annotation;
172
173
  var anchorAnnotationMarks = (node === null || node === void 0 ? void 0 : node.marks) || [];
173
174
  var marks = [];
174
- if (annotationMark.isInSet(anchorAnnotationMarks)) {
175
- marks = anchorAnnotationMarks;
176
- } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
177
- marks = nodeBefore.marks;
175
+ if (fg('platform_editor_fix_missing_selected_annotations')) {
176
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
177
+ marks = anchorAnnotationMarks;
178
+ }
179
+ if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
180
+ var _marks;
181
+ var existingMarkIds = marks.map(function (m) {
182
+ return m.attrs.id;
183
+ });
184
+ marks = (_marks = marks).concat.apply(_marks, _toConsumableArray(nodeBefore.marks.filter(function (m) {
185
+ return !existingMarkIds.includes(m.attrs.id);
186
+ })));
187
+ }
188
+ } else {
189
+ if (annotationMark.isInSet(anchorAnnotationMarks)) {
190
+ marks = anchorAnnotationMarks;
191
+ } else if (nodeBefore && annotationMark.isInSet(nodeBefore.marks)) {
192
+ marks = nodeBefore.marks;
193
+ }
178
194
  }
179
195
  var annotations = marks.filter(function (mark) {
180
196
  return mark.type.name === 'annotation';
@@ -474,4 +490,23 @@ export var isBlockNodeAnnotationsSelected = function isBlockNodeAnnotationsSelec
474
490
  });
475
491
  }
476
492
  return false;
493
+ };
494
+ export var hasAnyUnResolvedAnnotationInPage = function hasAnyUnResolvedAnnotationInPage(state) {
495
+ var _getPluginState;
496
+ var annotations = (_getPluginState = getPluginState(state)) === null || _getPluginState === void 0 ? void 0 : _getPluginState.annotations;
497
+ if (annotations) {
498
+ /**
499
+ * annotations type is { [key: string]: boolean };
500
+ * Here, key represents mark.attr.id and it is used to find where annotation to be presented in the document.
501
+ * When value is false, it means it is unresolved annotation.
502
+ *
503
+ * But sometimes annotation map has entry with key undefined somehow.
504
+ * And it is not valid mark attribute id, so it won't be presented anywhere in the document.
505
+ */
506
+ var unresolvedAnnotationKeys = Object.keys(annotations).filter(function (key) {
507
+ return key !== 'undefined' && annotations[key] === false;
508
+ });
509
+ return unresolvedAnnotationKeys.length > 0;
510
+ }
511
+ return false;
477
512
  };
@@ -33,6 +33,7 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
33
33
  * otherwise, it will return false.
34
34
  */
35
35
  showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
36
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
36
37
  };
37
38
  }>;
38
39
  export {};
@@ -11,6 +11,7 @@ declare const _default: {
11
11
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
12
12
  setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
13
13
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
14
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
14
15
  };
15
16
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
16
17
  handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -51,3 +51,4 @@ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: Ann
51
51
  * Checks if the selectedAnnotations are the same as the annotations on the selected block node
52
52
  */
53
53
  export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
54
+ export declare const hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
@@ -33,6 +33,7 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
33
33
  * otherwise, it will return false.
34
34
  */
35
35
  showCommentForBlockNode: ReturnType<typeof showInlineCommentForBlockNode>;
36
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
36
37
  };
37
38
  }>;
38
39
  export {};
@@ -11,6 +11,7 @@ declare const _default: {
11
11
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
12
12
  setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
13
13
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined, isOpeningMediaCommentFromToolbar?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
14
+ hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
14
15
  };
15
16
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
16
17
  handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -51,3 +51,4 @@ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: Ann
51
51
  * Checks if the selectedAnnotations are the same as the annotations on the selected block node
52
52
  */
53
53
  export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
54
+ export declare const hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
- "@atlaskit/editor-common": "^102.8.0",
35
+ "@atlaskit/editor-common": "^102.11.0",
36
36
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
37
37
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/icon": "^25.0.0",
42
42
  "@atlaskit/onboarding": "^13.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^4.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^4.1.0",
45
45
  "@babel/runtime": "^7.0.0"
46
46
  },
47
47
  "peerDependencies": {
@@ -99,6 +99,9 @@
99
99
  "platform_inline_node_as_valid_annotation_selection": {
100
100
  "type": "boolean"
101
101
  },
102
+ "platform_editor_fix_missing_selected_annotations": {
103
+ "type": "boolean"
104
+ },
102
105
  "use_comments_data_annotation_updater": {
103
106
  "type": "boolean"
104
107
  }