@atlaskit/editor-plugin-annotation 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#84685](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84685) [`8884904b3f36`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8884904b3f36) - fix insert annotation analytics to include selectionType and nodeLocation
8
+
9
+ ## 1.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#83942](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83942) [`210a84148721`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/210a84148721) - [ED-22547] Publish draft comment for media node when saving
14
+
3
15
  ## 1.5.0
4
16
 
5
17
  ### Minor Changes
@@ -152,7 +152,7 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
152
152
  };
153
153
  };
154
154
  var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
155
- return function (id) {
155
+ return function (id, supportedBlockNodes) {
156
156
  var commandAction = function commandAction(editorState) {
157
157
  return {
158
158
  type: _types.ACTIONS.ADD_INLINE_COMMENT,
@@ -169,7 +169,7 @@ var addInlineComment = exports.addInlineComment = function addInlineComment(edit
169
169
  }
170
170
  };
171
171
  };
172
- return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id));
172
+ return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
173
173
  };
174
174
  };
175
175
  var updateMouseState = exports.updateMouseState = function updateMouseState(mouseData) {
@@ -194,6 +194,7 @@ var setSelectedAnnotation = exports.setSelectedAnnotation = function setSelected
194
194
  var createAnnotation = exports.createAnnotation = function createAnnotation(editorAnalyticsAPI, editorAPI) {
195
195
  return function (id) {
196
196
  var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _adfSchema.AnnotationTypes.INLINE_COMMENT;
197
+ var supportedBlockNodes = arguments.length > 2 ? arguments[2] : undefined;
197
198
  return function (state, dispatch) {
198
199
  // don't try to add if there are is no temp highlight bookmarked
199
200
  var _ref = (0, _utils.getPluginState)(state) || {},
@@ -202,7 +203,7 @@ var createAnnotation = exports.createAnnotation = function createAnnotation(edit
202
203
  return false;
203
204
  }
204
205
  if (annotationType === _adfSchema.AnnotationTypes.INLINE_COMMENT) {
205
- return addInlineComment(editorAnalyticsAPI, editorAPI)(id)(state, dispatch);
206
+ return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
206
207
  }
207
208
  return false;
208
209
  };
@@ -9,29 +9,39 @@ var _analytics = require("@atlaskit/editor-common/analytics");
9
9
  var _mark = require("@atlaskit/editor-common/mark");
10
10
  var _state = require("@atlaskit/editor-prosemirror/state");
11
11
  var _utils = require("../utils");
12
- var addAnnotationMark = function addAnnotationMark(id) {
12
+ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
13
13
  return function (transaction, state) {
14
14
  var inlineCommentState = (0, _utils.getPluginState)(state);
15
- var _getSelectionPosition = (0, _utils.getSelectionPositions)(state, inlineCommentState),
16
- from = _getSelectionPosition.from,
17
- to = _getSelectionPosition.to,
18
- head = _getSelectionPosition.head;
15
+ var _ref = inlineCommentState || {},
16
+ bookmark = _ref.bookmark;
19
17
  var annotationMark = state.schema.marks.annotation.create({
20
18
  id: id,
21
19
  type: _adfSchema.AnnotationTypes.INLINE_COMMENT
22
20
  });
23
- // Apply the mark only to text node in the range.
24
- var tr = (0, _mark.applyMarkOnRange)(from, to, false, annotationMark, transaction);
25
- // set selection back to the end of annotation once annotation mark is applied
26
- tr.setSelection(_state.TextSelection.create(tr.doc, head));
21
+ var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(state, bookmark, supportedBlockNodes),
22
+ from = _resolveDraftBookmark.from,
23
+ to = _resolveDraftBookmark.to,
24
+ head = _resolveDraftBookmark.head,
25
+ isBlockNode = _resolveDraftBookmark.isBlockNode;
26
+ var tr = transaction;
27
+ if (isBlockNode) {
28
+ tr = tr.addNodeMark(from, annotationMark);
29
+ // Set selection on the node so that we can display view component
30
+ tr.setSelection(_state.NodeSelection.create(tr.doc, from));
31
+ } else {
32
+ // Apply the mark only to text node in the range.
33
+ var _tr = (0, _mark.applyMarkOnRange)(from, to, false, annotationMark, transaction);
34
+ // set selection back to the end of annotation once annotation mark is applied
35
+ _tr.setSelection(_state.TextSelection.create(_tr.doc, head));
36
+ }
27
37
  return tr;
28
38
  };
29
39
  };
30
40
  var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
31
- return function (id) {
41
+ return function (id, supportedBlockNodes) {
32
42
  return function (transaction, state) {
33
43
  var _editorAPI$editorView;
34
- var tr = addAnnotationMark(id)(transaction, state);
44
+ var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
35
45
  editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
36
46
 
37
47
  // add insert analytics step to transaction
@@ -58,7 +68,8 @@ var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
58
68
  action: _analytics.ACTION.INSERTED,
59
69
  actionSubject: _analytics.ACTION_SUBJECT.ANNOTATION,
60
70
  eventType: _analytics.EVENT_TYPE.TRACK,
61
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT
71
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.INLINE_COMMENT,
72
+ attributes: {}
62
73
  })(transaction);
63
74
  return transaction;
64
75
  };
@@ -22,6 +22,7 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
22
22
  };
23
23
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
24
24
  return function (tr, pluginState) {
25
+ var _pluginState$featureF;
25
26
  if (pluginState.skipSelectionHandling) {
26
27
  return _objectSpread(_objectSpread({}, pluginState), {}, {
27
28
  skipSelectionHandling: false
@@ -29,11 +30,14 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
29
30
  isInlineCommentViewClosed: false
30
31
  });
31
32
  }
32
-
33
- /**
34
- * Default we only handle caret selections.
35
- * Node selection will be handled separately.
36
- */
33
+ if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
34
+ // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
35
+ // we keep it as it is so that we can show comment view component with the newly created comment
36
+ (0, _utils2.isBlockNodeAnnotationsSelected)(tr.selection, pluginState.selectedAnnotations)) {
37
+ return _objectSpread(_objectSpread({}, pluginState), reopenCommentView && {
38
+ isInlineCommentViewClosed: false
39
+ });
40
+ }
37
41
  var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
38
42
  if (selectedAnnotations.length === 0) {
39
43
  return _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.InlineCommentView = InlineCommentView;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
+ var _adfSchema = require("@atlaskit/adf-schema");
10
11
  var _analytics = require("@atlaskit/editor-common/analytics");
11
12
  var _utils = require("@atlaskit/editor-prosemirror/utils");
12
13
  var _commands = require("../commands");
@@ -91,7 +92,7 @@ function InlineCommentView(_ref) {
91
92
  dom: dom,
92
93
  textSelection: textSelection,
93
94
  onCreate: function onCreate(id) {
94
- (0, _commands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id)(editorView.state, editorView.dispatch);
95
+ (0, _commands.createAnnotation)(editorAnalyticsAPI, editorAPI)(id, _adfSchema.AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
95
96
  !editorView.hasFocus() && editorView.focus();
96
97
  },
97
98
  onClose: function onClose() {
package/dist/cjs/utils.js CHANGED
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "hasAnnotationMark", {
21
21
  });
22
22
  exports.hasInvalidNodes = void 0;
23
23
  exports.hasInvalidWhitespaceNode = hasInvalidWhitespaceNode;
24
- exports.isCurrentBlockNodeSelected = exports.inlineCommentPluginKey = void 0;
24
+ exports.isCurrentBlockNodeSelected = exports.isBlockNodeAnnotationsSelected = exports.inlineCommentPluginKey = void 0;
25
25
  exports.isSelectedAnnotationsChanged = isSelectedAnnotationsChanged;
26
26
  exports.resolveDraftBookmark = exports.isSupportedBlockNode = exports.isSelectionValid = void 0;
27
27
  exports.stripNonExistingAnnotations = stripNonExistingAnnotations;
@@ -202,14 +202,15 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
202
202
  var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftBookmark(editorState, bookmark) {
203
203
  var supportedBlockNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
204
204
  var doc = editorState.doc;
205
- var resolvedBookmark = bookmark.resolve(doc);
205
+ var resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
206
206
  var from = resolvedBookmark.from,
207
207
  to = resolvedBookmark.to,
208
208
  head = resolvedBookmark.head;
209
209
  var draftBookmark = {
210
210
  from: from,
211
211
  to: to,
212
- head: head
212
+ head: head,
213
+ isBlockNode: false
213
214
  };
214
215
  if (resolvedBookmark instanceof _state.NodeSelection) {
215
216
  // It's possible that annotation is only allowed in child node instead parent (e.g. mediaSingle vs media),
@@ -225,7 +226,8 @@ var resolveDraftBookmark = exports.resolveDraftBookmark = function resolveDraftB
225
226
  draftBookmark = {
226
227
  from: pos,
227
228
  to: nodeEndsAt,
228
- head: nodeEndsAt
229
+ head: nodeEndsAt,
230
+ isBlockNode: node.isBlock
229
231
  };
230
232
  nodeFound = true;
231
233
  return false;
@@ -444,4 +446,24 @@ function isSelectedAnnotationsChanged(oldSelectedAnnotations, newSelectedAnnotat
444
446
  return annotation.id === pluginStateAnnotation.id && annotation.type === pluginStateAnnotation.type;
445
447
  });
446
448
  });
447
- }
449
+ }
450
+
451
+ /**
452
+ * Checks if the selectedAnnotations are the same as the annotations on the selected block node
453
+ */
454
+ var isBlockNodeAnnotationsSelected = exports.isBlockNodeAnnotationsSelected = function isBlockNodeAnnotationsSelected(selection) {
455
+ var selectedAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
456
+ if (selectedAnnotations.length && selection instanceof _state.NodeSelection) {
457
+ var node = selection.node.type.name === 'mediaSingle' ? selection.node.firstChild : selection.node;
458
+ var annotationMarks = (node === null || node === void 0 ? void 0 : node.marks.filter(function (mark) {
459
+ return mark.type.name === 'annotation';
460
+ }).map(function (mark) {
461
+ return {
462
+ id: mark.attrs.id,
463
+ type: mark.attrs.annotationType
464
+ };
465
+ })) || [];
466
+ return !isSelectedAnnotationsChanged(selectedAnnotations, annotationMarks);
467
+ }
468
+ return false;
469
+ };
@@ -124,7 +124,7 @@ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNod
124
124
  const commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
125
125
  return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
126
126
  };
127
- export const addInlineComment = (editorAnalyticsAPI, editorAPI) => id => {
127
+ export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
128
128
  const commandAction = editorState => ({
129
129
  type: ACTIONS.ADD_INLINE_COMMENT,
130
130
  data: {
@@ -141,7 +141,7 @@ export const addInlineComment = (editorAnalyticsAPI, editorAPI) => id => {
141
141
  editorState
142
142
  }
143
143
  });
144
- return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id));
144
+ return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
145
145
  };
146
146
  export const updateMouseState = mouseData => createCommand({
147
147
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE,
@@ -158,7 +158,7 @@ export const setSelectedAnnotation = id => createCommand({
158
158
  }]
159
159
  }
160
160
  });
161
- export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotationType = AnnotationTypes.INLINE_COMMENT) => (state, dispatch) => {
161
+ export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotationType = AnnotationTypes.INLINE_COMMENT, supportedBlockNodes) => (state, dispatch) => {
162
162
  // don't try to add if there are is no temp highlight bookmarked
163
163
  const {
164
164
  bookmark
@@ -167,7 +167,7 @@ export const createAnnotation = (editorAnalyticsAPI, editorAPI) => (id, annotati
167
167
  return false;
168
168
  }
169
169
  if (annotationType === AnnotationTypes.INLINE_COMMENT) {
170
- return addInlineComment(editorAnalyticsAPI, editorAPI)(id)(state, dispatch);
170
+ return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
171
171
  }
172
172
  return false;
173
173
  };
@@ -1,28 +1,39 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
4
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
- import { getDraftCommandAnalyticsPayload, getPluginState, getSelectionPositions } from '../utils';
6
- const addAnnotationMark = id => (transaction, state) => {
4
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../utils';
6
+ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
7
7
  const inlineCommentState = getPluginState(state);
8
8
  const {
9
- from,
10
- to,
11
- head
12
- } = getSelectionPositions(state, inlineCommentState);
9
+ bookmark
10
+ } = inlineCommentState || {};
13
11
  const annotationMark = state.schema.marks.annotation.create({
14
12
  id,
15
13
  type: AnnotationTypes.INLINE_COMMENT
16
14
  });
17
- // Apply the mark only to text node in the range.
18
- let tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
19
- // set selection back to the end of annotation once annotation mark is applied
20
- tr.setSelection(TextSelection.create(tr.doc, head));
15
+ const {
16
+ from,
17
+ to,
18
+ head,
19
+ isBlockNode
20
+ } = resolveDraftBookmark(state, bookmark, supportedBlockNodes);
21
+ let tr = transaction;
22
+ if (isBlockNode) {
23
+ tr = tr.addNodeMark(from, annotationMark);
24
+ // Set selection on the node so that we can display view component
25
+ tr.setSelection(NodeSelection.create(tr.doc, from));
26
+ } else {
27
+ // Apply the mark only to text node in the range.
28
+ let tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
29
+ // set selection back to the end of annotation once annotation mark is applied
30
+ tr.setSelection(TextSelection.create(tr.doc, head));
31
+ }
21
32
  return tr;
22
33
  };
23
- const addInlineComment = (editorAnalyticsAPI, editorAPI) => id => (transaction, state) => {
34
+ const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => (transaction, state) => {
24
35
  var _editorAPI$editorView;
25
- let tr = addAnnotationMark(id)(transaction, state);
36
+ let tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
26
37
  editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 ? void 0 : _editorAPI$editorView.actions.applyViewModeStepAt(tr);
27
38
 
28
39
  // add insert analytics step to transaction
@@ -41,7 +52,8 @@ const addInsertAnalytics = editorAnalyticsAPI => (transaction, state) => {
41
52
  action: ACTION.INSERTED,
42
53
  actionSubject: ACTION_SUBJECT.ANNOTATION,
43
54
  eventType: EVENT_TYPE.TRACK,
44
- actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT
55
+ actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
56
+ attributes: {}
45
57
  })(transaction);
46
58
  return transaction;
47
59
  };
@@ -1,6 +1,6 @@
1
1
  import { pluginFactory } from '@atlaskit/editor-common/utils';
2
2
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
3
- import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isSelectedAnnotationsChanged } from '../utils';
3
+ import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from '../utils';
4
4
  import reducer from './reducer';
5
5
  const handleDocChanged = (tr, prevPluginState) => {
6
6
  if (!tr.getMeta('replaceDocument')) {
@@ -12,6 +12,7 @@ const handleDocChanged = (tr, prevPluginState) => {
12
12
  };
13
13
  };
14
14
  const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
15
+ var _pluginState$featureF;
15
16
  if (pluginState.skipSelectionHandling) {
16
17
  return {
17
18
  ...pluginState,
@@ -21,11 +22,17 @@ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
21
22
  })
22
23
  };
23
24
  }
24
-
25
- /**
26
- * Default we only handle caret selections.
27
- * Node selection will be handled separately.
28
- */
25
+ if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
26
+ // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
27
+ // we keep it as it is so that we can show comment view component with the newly created comment
28
+ isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
29
+ return {
30
+ ...pluginState,
31
+ ...(reopenCommentView && {
32
+ isInlineCommentViewClosed: false
33
+ })
34
+ };
35
+ }
29
36
  const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
30
37
  if (selectedAnnotations.length === 0) {
31
38
  return {
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { AnnotationTypes } from '@atlaskit/adf-schema';
2
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
4
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
4
5
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
@@ -91,7 +92,7 @@ export function InlineCommentView({
91
92
  dom: dom,
92
93
  textSelection: textSelection,
93
94
  onCreate: id => {
94
- createAnnotation(editorAnalyticsAPI, editorAPI)(id)(editorView.state, editorView.dispatch);
95
+ createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
95
96
  !editorView.hasFocus() && editorView.focus();
96
97
  },
97
98
  onClose: () => {
@@ -162,7 +162,7 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
162
162
  const {
163
163
  doc
164
164
  } = editorState;
165
- const resolvedBookmark = bookmark.resolve(doc);
165
+ const resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
166
166
  const {
167
167
  from,
168
168
  to,
@@ -171,7 +171,8 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
171
171
  let draftBookmark = {
172
172
  from,
173
173
  to,
174
- head
174
+ head,
175
+ isBlockNode: false
175
176
  };
176
177
  if (resolvedBookmark instanceof NodeSelection) {
177
178
  // It's possible that annotation is only allowed in child node instead parent (e.g. mediaSingle vs media),
@@ -187,7 +188,8 @@ export const resolveDraftBookmark = (editorState, bookmark, supportedBlockNodes
187
188
  draftBookmark = {
188
189
  from: pos,
189
190
  to: nodeEndsAt,
190
- head: nodeEndsAt
191
+ head: nodeEndsAt,
192
+ isBlockNode: node.isBlock
191
193
  };
192
194
  nodeFound = true;
193
195
  return false;
@@ -408,4 +410,19 @@ export function isSelectedAnnotationsChanged(oldSelectedAnnotations, newSelected
408
410
  return newSelectedAnnotations.length !== oldSelectedAnnotations.length ||
409
411
  // assuming annotations have unique id's for simplicity
410
412
  newSelectedAnnotations.some(annotation => !oldSelectedAnnotations.find(pluginStateAnnotation => annotation.id === pluginStateAnnotation.id && annotation.type === pluginStateAnnotation.type));
411
- }
413
+ }
414
+
415
+ /**
416
+ * Checks if the selectedAnnotations are the same as the annotations on the selected block node
417
+ */
418
+ export const isBlockNodeAnnotationsSelected = (selection, selectedAnnotations = []) => {
419
+ if (selectedAnnotations.length && selection instanceof NodeSelection) {
420
+ const node = selection.node.type.name === 'mediaSingle' ? selection.node.firstChild : selection.node;
421
+ const annotationMarks = (node === null || node === void 0 ? void 0 : node.marks.filter(mark => mark.type.name === 'annotation').map(mark => ({
422
+ id: mark.attrs.id,
423
+ type: mark.attrs.annotationType
424
+ }))) || [];
425
+ return !isSelectedAnnotationsChanged(selectedAnnotations, annotationMarks);
426
+ }
427
+ return false;
428
+ };
@@ -145,7 +145,7 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
145
145
  };
146
146
  };
147
147
  export var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
148
- return function (id) {
148
+ return function (id, supportedBlockNodes) {
149
149
  var commandAction = function commandAction(editorState) {
150
150
  return {
151
151
  type: ACTIONS.ADD_INLINE_COMMENT,
@@ -162,7 +162,7 @@ export var addInlineComment = function addInlineComment(editorAnalyticsAPI, edit
162
162
  }
163
163
  };
164
164
  };
165
- return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id));
165
+ return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
166
166
  };
167
167
  };
168
168
  export var updateMouseState = function updateMouseState(mouseData) {
@@ -187,6 +187,7 @@ export var setSelectedAnnotation = function setSelectedAnnotation(id) {
187
187
  export var createAnnotation = function createAnnotation(editorAnalyticsAPI, editorAPI) {
188
188
  return function (id) {
189
189
  var annotationType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AnnotationTypes.INLINE_COMMENT;
190
+ var supportedBlockNodes = arguments.length > 2 ? arguments[2] : undefined;
190
191
  return function (state, dispatch) {
191
192
  // don't try to add if there are is no temp highlight bookmarked
192
193
  var _ref = getPluginState(state) || {},
@@ -195,7 +196,7 @@ export var createAnnotation = function createAnnotation(editorAnalyticsAPI, edit
195
196
  return false;
196
197
  }
197
198
  if (annotationType === AnnotationTypes.INLINE_COMMENT) {
198
- return addInlineComment(editorAnalyticsAPI, editorAPI)(id)(state, dispatch);
199
+ return addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state, dispatch);
199
200
  }
200
201
  return false;
201
202
  };
@@ -1,31 +1,41 @@
1
1
  import { AnnotationTypes } from '@atlaskit/adf-schema';
2
2
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
4
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
- import { getDraftCommandAnalyticsPayload, getPluginState, getSelectionPositions } from '../utils';
6
- var addAnnotationMark = function addAnnotationMark(id) {
4
+ import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { getDraftCommandAnalyticsPayload, getPluginState, resolveDraftBookmark } from '../utils';
6
+ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
7
7
  return function (transaction, state) {
8
8
  var inlineCommentState = getPluginState(state);
9
- var _getSelectionPosition = getSelectionPositions(state, inlineCommentState),
10
- from = _getSelectionPosition.from,
11
- to = _getSelectionPosition.to,
12
- head = _getSelectionPosition.head;
9
+ var _ref = inlineCommentState || {},
10
+ bookmark = _ref.bookmark;
13
11
  var annotationMark = state.schema.marks.annotation.create({
14
12
  id: id,
15
13
  type: AnnotationTypes.INLINE_COMMENT
16
14
  });
17
- // Apply the mark only to text node in the range.
18
- var tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
19
- // set selection back to the end of annotation once annotation mark is applied
20
- tr.setSelection(TextSelection.create(tr.doc, head));
15
+ var _resolveDraftBookmark = resolveDraftBookmark(state, bookmark, supportedBlockNodes),
16
+ from = _resolveDraftBookmark.from,
17
+ to = _resolveDraftBookmark.to,
18
+ head = _resolveDraftBookmark.head,
19
+ isBlockNode = _resolveDraftBookmark.isBlockNode;
20
+ var tr = transaction;
21
+ if (isBlockNode) {
22
+ tr = tr.addNodeMark(from, annotationMark);
23
+ // Set selection on the node so that we can display view component
24
+ tr.setSelection(NodeSelection.create(tr.doc, from));
25
+ } else {
26
+ // Apply the mark only to text node in the range.
27
+ var _tr = applyMarkOnRange(from, to, false, annotationMark, transaction);
28
+ // set selection back to the end of annotation once annotation mark is applied
29
+ _tr.setSelection(TextSelection.create(_tr.doc, head));
30
+ }
21
31
  return tr;
22
32
  };
23
33
  };
24
34
  var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
25
- return function (id) {
35
+ return function (id, supportedBlockNodes) {
26
36
  return function (transaction, state) {
27
37
  var _editorAPI$editorView;
28
- var tr = addAnnotationMark(id)(transaction, state);
38
+ var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
29
39
  editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
30
40
 
31
41
  // add insert analytics step to transaction
@@ -52,7 +62,8 @@ var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
52
62
  action: ACTION.INSERTED,
53
63
  actionSubject: ACTION_SUBJECT.ANNOTATION,
54
64
  eventType: EVENT_TYPE.TRACK,
55
- actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT
65
+ actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
66
+ attributes: {}
56
67
  })(transaction);
57
68
  return transaction;
58
69
  };
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { pluginFactory } from '@atlaskit/editor-common/utils';
5
5
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
- import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isSelectedAnnotationsChanged } from '../utils';
6
+ import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from '../utils';
7
7
  import reducer from './reducer';
8
8
  var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
9
9
  if (!tr.getMeta('replaceDocument')) {
@@ -15,6 +15,7 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
15
15
  };
16
16
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
17
17
  return function (tr, pluginState) {
18
+ var _pluginState$featureF;
18
19
  if (pluginState.skipSelectionHandling) {
19
20
  return _objectSpread(_objectSpread({}, pluginState), {}, {
20
21
  skipSelectionHandling: false
@@ -22,11 +23,14 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
22
23
  isInlineCommentViewClosed: false
23
24
  });
24
25
  }
25
-
26
- /**
27
- * Default we only handle caret selections.
28
- * Node selection will be handled separately.
29
- */
26
+ if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
27
+ // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
28
+ // we keep it as it is so that we can show comment view component with the newly created comment
29
+ isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
30
+ return _objectSpread(_objectSpread({}, pluginState), reopenCommentView && {
31
+ isInlineCommentViewClosed: false
32
+ });
33
+ }
30
34
  var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
31
35
  if (selectedAnnotations.length === 0) {
32
36
  return _objectSpread(_objectSpread({}, pluginState), {}, {
@@ -1,5 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
+ import { AnnotationTypes } from '@atlaskit/adf-schema';
3
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
4
5
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
5
6
  import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
@@ -84,7 +85,7 @@ export function InlineCommentView(_ref) {
84
85
  dom: dom,
85
86
  textSelection: textSelection,
86
87
  onCreate: function onCreate(id) {
87
- createAnnotation(editorAnalyticsAPI, editorAPI)(id)(editorView.state, editorView.dispatch);
88
+ createAnnotation(editorAnalyticsAPI, editorAPI)(id, AnnotationTypes.INLINE_COMMENT, inlineCommentProvider.supportedBlockNodes)(editorView.state, editorView.dispatch);
88
89
  !editorView.hasFocus() && editorView.focus();
89
90
  },
90
91
  onClose: function onClose() {
package/dist/esm/utils.js CHANGED
@@ -175,14 +175,15 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
175
175
  export var resolveDraftBookmark = function resolveDraftBookmark(editorState, bookmark) {
176
176
  var supportedBlockNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
177
177
  var doc = editorState.doc;
178
- var resolvedBookmark = bookmark.resolve(doc);
178
+ var resolvedBookmark = bookmark ? bookmark.resolve(doc) : editorState.selection;
179
179
  var from = resolvedBookmark.from,
180
180
  to = resolvedBookmark.to,
181
181
  head = resolvedBookmark.head;
182
182
  var draftBookmark = {
183
183
  from: from,
184
184
  to: to,
185
- head: head
185
+ head: head,
186
+ isBlockNode: false
186
187
  };
187
188
  if (resolvedBookmark instanceof NodeSelection) {
188
189
  // It's possible that annotation is only allowed in child node instead parent (e.g. mediaSingle vs media),
@@ -198,7 +199,8 @@ export var resolveDraftBookmark = function resolveDraftBookmark(editorState, boo
198
199
  draftBookmark = {
199
200
  from: pos,
200
201
  to: nodeEndsAt,
201
- head: nodeEndsAt
202
+ head: nodeEndsAt,
203
+ isBlockNode: node.isBlock
202
204
  };
203
205
  nodeFound = true;
204
206
  return false;
@@ -417,4 +419,24 @@ export function isSelectedAnnotationsChanged(oldSelectedAnnotations, newSelected
417
419
  return annotation.id === pluginStateAnnotation.id && annotation.type === pluginStateAnnotation.type;
418
420
  });
419
421
  });
420
- }
422
+ }
423
+
424
+ /**
425
+ * Checks if the selectedAnnotations are the same as the annotations on the selected block node
426
+ */
427
+ export var isBlockNodeAnnotationsSelected = function isBlockNodeAnnotationsSelected(selection) {
428
+ var selectedAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
429
+ if (selectedAnnotations.length && selection instanceof NodeSelection) {
430
+ var node = selection.node.type.name === 'mediaSingle' ? selection.node.firstChild : selection.node;
431
+ var annotationMarks = (node === null || node === void 0 ? void 0 : node.marks.filter(function (mark) {
432
+ return mark.type.name === 'annotation';
433
+ }).map(function (mark) {
434
+ return {
435
+ id: mark.attrs.id,
436
+ type: mark.attrs.annotationType
437
+ };
438
+ })) || [];
439
+ return !isSelectedAnnotationsChanged(selectedAnnotations, annotationMarks);
440
+ }
441
+ return false;
442
+ };
@@ -10,8 +10,8 @@ export declare const clearDirtyMark: () => Command;
10
10
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
11
11
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command | undefined;
12
12
  export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
13
- export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
13
+ export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
14
14
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
15
15
  export declare const setSelectedAnnotation: (id: string) => Command;
16
- export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes) => Command;
16
+ export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[]) => Command;
17
17
  export declare const setInlineCommentsVisibility: (isVisible: boolean) => Command;
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { InlineCommentInputMethod } from '../types';
4
4
  declare const _default: {
5
- addAnnotationMark: (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
5
+ addAnnotationMark: (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
6
6
  addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: import("@atlaskit/editor-common/types").PublicPluginAPI<[import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"annotation", {
7
7
  pluginConfiguration: import("../types").AnnotationProviders | undefined;
8
8
  sharedState: import("..").InlineCommentPluginState | undefined;
@@ -130,7 +130,7 @@ declare const _default: {
130
130
  } | undefined>>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
131
131
  pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
132
132
  sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
133
- }, import("@atlaskit/editor-common/types").FeatureFlags>>]> | undefined) => (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
133
+ }, import("@atlaskit/editor-common/types").FeatureFlags>>]> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
134
134
  addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
135
135
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
136
136
  addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -140,5 +140,6 @@ export type DraftBookmark = {
140
140
  from: number;
141
141
  to: number;
142
142
  head: number;
143
+ isBlockNode?: boolean;
143
144
  };
144
145
  export {};
@@ -22,7 +22,7 @@ export declare const addDraftDecoration: (start: number, end: number, targetType
22
22
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
23
23
  export declare const isCurrentBlockNodeSelected: (state: EditorState, node: Node) => boolean;
24
24
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
25
- export declare const resolveDraftBookmark: (editorState: EditorState, bookmark: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
25
+ export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
26
26
  /**
27
27
  * get selection from position to apply new comment for
28
28
  * @return bookmarked positions if they exists, otherwise current selection positions
@@ -49,3 +49,7 @@ export declare function stripNonExistingAnnotations(slice: Slice, state: EditorS
49
49
  * This function assumes annotations will have unique id's for simplicity
50
50
  */
51
51
  export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: AnnotationInfo[], newSelectedAnnotations: AnnotationInfo[]): boolean;
52
+ /**
53
+ * Checks if the selectedAnnotations are the same as the annotations on the selected block node
54
+ */
55
+ export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
@@ -10,8 +10,8 @@ export declare const clearDirtyMark: () => Command;
10
10
  export declare const removeInlineCommentNearSelection: (id: string, supportedNodes?: string[]) => Command;
11
11
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command | undefined;
12
12
  export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
13
- export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string) => Command;
13
+ export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
14
14
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
15
15
  export declare const setSelectedAnnotation: (id: string) => Command;
16
- export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes) => Command;
16
+ export declare const createAnnotation: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, annotationType?: AnnotationTypes, supportedBlockNodes?: string[]) => Command;
17
17
  export declare const setInlineCommentsVisibility: (isVisible: boolean) => Command;
@@ -2,7 +2,7 @@ import type { EditorAnalyticsAPI, RESOLVE_METHOD } from '@atlaskit/editor-common
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { InlineCommentInputMethod } from '../types';
4
4
  declare const _default: {
5
- addAnnotationMark: (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
5
+ addAnnotationMark: (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
6
6
  addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI: import("@atlaskit/editor-common/types").PublicPluginAPI<[
7
7
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"annotation", {
8
8
  pluginConfiguration: import("../types").AnnotationProviders | undefined;
@@ -157,7 +157,7 @@ declare const _default: {
157
157
  pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
158
158
  sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
159
159
  }, import("@atlaskit/editor-common/types").FeatureFlags>>
160
- ]> | undefined) => (id: string) => (transaction: Transaction, state: EditorState) => Transaction;
160
+ ]> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
161
161
  addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
162
162
  addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
163
163
  addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -140,5 +140,6 @@ export type DraftBookmark = {
140
140
  from: number;
141
141
  to: number;
142
142
  head: number;
143
+ isBlockNode?: boolean;
143
144
  };
144
145
  export {};
@@ -22,7 +22,7 @@ export declare const addDraftDecoration: (start: number, end: number, targetType
22
22
  export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string;
23
23
  export declare const isCurrentBlockNodeSelected: (state: EditorState, node: Node) => boolean;
24
24
  export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[];
25
- export declare const resolveDraftBookmark: (editorState: EditorState, bookmark: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
25
+ export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark;
26
26
  /**
27
27
  * get selection from position to apply new comment for
28
28
  * @return bookmarked positions if they exists, otherwise current selection positions
@@ -49,3 +49,7 @@ export declare function stripNonExistingAnnotations(slice: Slice, state: EditorS
49
49
  * This function assumes annotations will have unique id's for simplicity
50
50
  */
51
51
  export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: AnnotationInfo[], newSelectedAnnotations: AnnotationInfo[]): boolean;
52
+ /**
53
+ * Checks if the selectedAnnotations are the same as the annotations on the selected block node
54
+ */
55
+ export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
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
  },
34
34
  "dependencies": {
35
35
  "@atlaskit/adf-schema": "^35.7.0",
36
- "@atlaskit/editor-common": "^78.18.0",
36
+ "@atlaskit/editor-common": "^78.20.0",
37
37
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode": "^1.0.0",
39
39
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",