@atlaskit/editor-plugin-annotation 1.5.8 → 1.5.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,18 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.5.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#91909](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91909) [`188a4ee3607f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/188a4ee3607f) - Add decoration to annotation marks for block elements to help confluence edit mode identify comments
8
+
9
+ ## 1.5.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [#91106](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91106) [`b6ffa30186b9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b6ffa30186b9) - Bump ADF-schema package to version 35.0.0
14
+ - Updated dependencies
15
+
3
16
  ## 1.5.8
4
17
 
5
18
  ### Patch Changes
@@ -100,7 +100,7 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
100
100
  return true;
101
101
  };
102
102
  };
103
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes) {
103
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
104
104
  return function (editorState) {
105
105
  // validate selection only when entering draft mode
106
106
  if (drafting && (0, _utils.isSelectionValid)(editorState, isCommentOnMediaOn) !== _types2.AnnotationSelectionType.VALID) {
@@ -113,7 +113,8 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
113
113
  editorState: editorState,
114
114
  targetType: targetType,
115
115
  isCommentOnMediaOn: isCommentOnMediaOn,
116
- supportedBlockNodes: supportedBlockNodes
116
+ supportedBlockNodes: supportedBlockNodes,
117
+ targetNodeId: targetNodeId
117
118
  }
118
119
  };
119
120
  };
@@ -163,7 +164,8 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
163
164
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
164
165
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
165
166
  var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
166
- var commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
167
+ var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
168
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
167
169
  return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
168
170
  };
169
171
  };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getAnnotationViewClassname = exports.AnnotationNodeView = void 0;
7
+ exports.getBlockAnnotationViewClassname = exports.getAnnotationViewClassname = exports.AnnotationNodeView = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -56,4 +56,10 @@ var getAnnotationViewClassname = exports.getAnnotationViewClassname = function g
56
56
  return;
57
57
  }
58
58
  return hasFocus ? _styles.AnnotationSharedClassNames.focus : _styles.AnnotationSharedClassNames.blur;
59
+ };
60
+ var getBlockAnnotationViewClassname = exports.getBlockAnnotationViewClassname = function getBlockAnnotationViewClassname(isUnresolved, hasFocus) {
61
+ if (!isUnresolved) {
62
+ return;
63
+ }
64
+ return hasFocus ? _styles.BlockAnnotationSharedClassNames.focus : _styles.BlockAnnotationSharedClassNames.blur;
59
65
  };
@@ -88,7 +88,8 @@ var initialState = function initialState() {
88
88
  isInlineCommentViewClosed: false,
89
89
  isVisible: true,
90
90
  skipSelectionHandling: false,
91
- featureFlagsPluginState: featureFlagsPluginState
91
+ featureFlagsPluginState: featureFlagsPluginState,
92
+ isDrafting: false
92
93
  };
93
94
  };
94
95
  var hideToolbar = function hideToolbar(state, dispatch) {
@@ -223,6 +224,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
223
224
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
224
225
  var focusDecorations = [];
225
226
  state.doc.descendants(function (node, pos) {
227
+ var _provider$supportedBl;
228
+ var isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
226
229
  node.marks.filter(function (mark) {
227
230
  return mark.type === state.schema.marks.annotation;
228
231
  }).forEach(function (mark) {
@@ -231,10 +234,18 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
231
234
  var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
232
235
  return selectedAnnotation.id === mark.attrs.id;
233
236
  }));
234
- focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
235
- class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
236
- nodeName: 'span'
237
- }));
237
+ if (isSupportedBlockNode) {
238
+ focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
239
+ class: "".concat((0, _nodeviews.getBlockAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
240
+ }, {
241
+ key: _utils.decorationKey.block
242
+ }));
243
+ } else {
244
+ focusDecorations.push(_view.Decoration.inline(pos, pos + node.nodeSize, {
245
+ class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved),
246
+ nodeName: 'span'
247
+ }));
248
+ }
238
249
  }
239
250
  });
240
251
  });
@@ -24,7 +24,7 @@ var _default = exports.default = function _default(pluginState, action) {
24
24
  mouseData: mouseData
25
25
  });
26
26
  case _types.ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
27
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes);
27
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
28
28
  case _types.ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
29
29
  return _objectSpread(_objectSpread({}, pluginState), {}, {
30
30
  dirtyAnnotations: false,
@@ -32,7 +32,8 @@ var _default = exports.default = function _default(pluginState, action) {
32
32
  });
33
33
  case _types.ACTIONS.CLOSE_COMPONENT:
34
34
  return _objectSpread(_objectSpread({}, pluginState), {}, {
35
- isInlineCommentViewClosed: true
35
+ isInlineCommentViewClosed: true,
36
+ isDrafting: false
36
37
  });
37
38
  case _types.ACTIONS.ADD_INLINE_COMMENT:
38
39
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -59,13 +60,15 @@ var _default = exports.default = function _default(pluginState, action) {
59
60
  return pluginState;
60
61
  }
61
62
  };
62
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes) {
63
+ function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
63
64
  var draftDecorationSet = pluginState.draftDecorationSet;
64
65
  if (!draftDecorationSet || !drafting) {
65
66
  draftDecorationSet = _view.DecorationSet.empty;
66
67
  }
67
68
  var newState = _objectSpread(_objectSpread({}, pluginState), {}, {
68
- draftDecorationSet: draftDecorationSet
69
+ draftDecorationSet: draftDecorationSet,
70
+ isDrafting: drafting,
71
+ targetNodeId: targetNodeId
69
72
  });
70
73
  newState.bookmark = undefined;
71
74
  if (drafting && editorState) {
@@ -86,7 +86,7 @@ export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (st
86
86
  }
87
87
  return true;
88
88
  };
89
- const getDraftCommandAction = (drafting, targetType, isCommentOnMediaOn, supportedBlockNodes) => {
89
+ const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) => {
90
90
  return editorState => {
91
91
  // validate selection only when entering draft mode
92
92
  if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
@@ -99,7 +99,8 @@ const getDraftCommandAction = (drafting, targetType, isCommentOnMediaOn, support
99
99
  editorState,
100
100
  targetType,
101
101
  isCommentOnMediaOn,
102
- supportedBlockNodes
102
+ supportedBlockNodes,
103
+ targetNodeId
103
104
  }
104
105
  };
105
106
  };
@@ -136,8 +137,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => node
136
137
  }
137
138
  return false;
138
139
  };
139
- export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false) => {
140
- const commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
140
+ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false, targetNodeId = undefined) => {
141
+ const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
141
142
  return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
142
143
  };
143
144
  export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
- import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
3
+ import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
4
4
  export class AnnotationNodeView extends ReactNodeView {
5
5
  createDomRef() {
6
6
  return document.createElement('span');
@@ -28,4 +28,10 @@ export const getAnnotationViewClassname = (isUnresolved, hasFocus) => {
28
28
  return;
29
29
  }
30
30
  return hasFocus ? AnnotationSharedClassNames.focus : AnnotationSharedClassNames.blur;
31
+ };
32
+ export const getBlockAnnotationViewClassname = (isUnresolved, hasFocus) => {
33
+ if (!isUnresolved) {
34
+ return;
35
+ }
36
+ return hasFocus ? BlockAnnotationSharedClassNames.focus : BlockAnnotationSharedClassNames.blur;
31
37
  };
@@ -3,8 +3,8 @@ import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
5
5
  import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
6
- import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
7
- import { getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
6
+ import { AnnotationNodeView, getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
7
+ import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
8
8
  import { createPluginState } from './plugin-factory';
9
9
  const fetchProviderStates = async (provider, annotationIds) => {
10
10
  const data = await provider.getState(annotationIds);
@@ -39,7 +39,8 @@ const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) =>
39
39
  isInlineCommentViewClosed: false,
40
40
  isVisible: true,
41
41
  skipSelectionHandling: false,
42
- featureFlagsPluginState
42
+ featureFlagsPluginState,
43
+ isDrafting: false
43
44
  };
44
45
  };
45
46
  const hideToolbar = (state, dispatch) => () => {
@@ -163,14 +164,24 @@ export const inlineCommentPlugin = options => {
163
164
  let decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
164
165
  const focusDecorations = [];
165
166
  state.doc.descendants((node, pos) => {
167
+ var _provider$supportedBl;
168
+ const isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
166
169
  node.marks.filter(mark => mark.type === state.schema.marks.annotation).forEach(mark => {
167
170
  if (isVisible) {
168
171
  const isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
169
172
  const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
170
- focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
171
- class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
172
- nodeName: 'span'
173
- }));
173
+ if (isSupportedBlockNode) {
174
+ focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
175
+ class: `${getBlockAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`
176
+ }, {
177
+ key: decorationKey.block
178
+ }));
179
+ } else {
180
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
181
+ class: `${getAnnotationViewClassname(isUnresolved, isSelected)} ${isUnresolved}`,
182
+ nodeName: 'span'
183
+ }));
184
+ }
174
185
  }
175
186
  });
176
187
  });
@@ -18,7 +18,7 @@ export default ((pluginState, action) => {
18
18
  mouseData
19
19
  };
20
20
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
21
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes);
21
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
22
22
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
23
23
  return {
24
24
  ...pluginState,
@@ -28,7 +28,8 @@ export default ((pluginState, action) => {
28
28
  case ACTIONS.CLOSE_COMPONENT:
29
29
  return {
30
30
  ...pluginState,
31
- isInlineCommentViewClosed: true
31
+ isInlineCommentViewClosed: true,
32
+ isDrafting: false
32
33
  };
33
34
  case ACTIONS.ADD_INLINE_COMMENT:
34
35
  const updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -63,7 +64,7 @@ export default ((pluginState, action) => {
63
64
  return pluginState;
64
65
  }
65
66
  });
66
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes) {
67
+ function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
67
68
  let {
68
69
  draftDecorationSet
69
70
  } = pluginState;
@@ -72,7 +73,9 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
72
73
  }
73
74
  let newState = {
74
75
  ...pluginState,
75
- draftDecorationSet
76
+ draftDecorationSet,
77
+ isDrafting: drafting,
78
+ targetNodeId
76
79
  };
77
80
  newState.bookmark = undefined;
78
81
  if (drafting && editorState) {
@@ -93,7 +93,7 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
93
93
  return true;
94
94
  };
95
95
  };
96
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes) {
96
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
97
97
  return function (editorState) {
98
98
  // validate selection only when entering draft mode
99
99
  if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
@@ -106,7 +106,8 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
106
106
  editorState: editorState,
107
107
  targetType: targetType,
108
108
  isCommentOnMediaOn: isCommentOnMediaOn,
109
- supportedBlockNodes: supportedBlockNodes
109
+ supportedBlockNodes: supportedBlockNodes,
110
+ targetNodeId: targetNodeId
110
111
  }
111
112
  };
112
113
  };
@@ -156,7 +157,8 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
156
157
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
157
158
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
158
159
  var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
159
- var commandAction = getDraftCommandAction(drafting, targetType, isCommentOnMediaOn, supportedBlockNodes);
160
+ var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
161
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
160
162
  return createCommand(commandAction, transform.addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, inputMethod));
161
163
  };
162
164
  };
@@ -7,7 +7,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
7
7
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
8
  import React from 'react';
9
9
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
10
- import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
10
+ import { AnnotationSharedClassNames, BlockAnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
11
11
  export var AnnotationNodeView = /*#__PURE__*/function (_ReactNodeView) {
12
12
  _inherits(AnnotationNodeView, _ReactNodeView);
13
13
  var _super = _createSuper(AnnotationNodeView);
@@ -49,4 +49,10 @@ export var getAnnotationViewClassname = function getAnnotationViewClassname(isUn
49
49
  return;
50
50
  }
51
51
  return hasFocus ? AnnotationSharedClassNames.focus : AnnotationSharedClassNames.blur;
52
+ };
53
+ export var getBlockAnnotationViewClassname = function getBlockAnnotationViewClassname(isUnresolved, hasFocus) {
54
+ if (!isUnresolved) {
55
+ return;
56
+ }
57
+ return hasFocus ? BlockAnnotationSharedClassNames.focus : BlockAnnotationSharedClassNames.blur;
52
58
  };
@@ -6,8 +6,8 @@ import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
6
6
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
7
7
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
9
- import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
10
- import { getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
9
+ import { AnnotationNodeView, getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
10
+ import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
11
11
  import { createPluginState } from './plugin-factory';
12
12
  var fetchProviderStates = /*#__PURE__*/function () {
13
13
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
@@ -81,7 +81,8 @@ var initialState = function initialState() {
81
81
  isInlineCommentViewClosed: false,
82
82
  isVisible: true,
83
83
  skipSelectionHandling: false,
84
- featureFlagsPluginState: featureFlagsPluginState
84
+ featureFlagsPluginState: featureFlagsPluginState,
85
+ isDrafting: false
85
86
  };
86
87
  };
87
88
  var hideToolbar = function hideToolbar(state, dispatch) {
@@ -216,6 +217,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
216
217
  var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
217
218
  var focusDecorations = [];
218
219
  state.doc.descendants(function (node, pos) {
220
+ var _provider$supportedBl;
221
+ var isSupportedBlockNode = node.isBlock && ((_provider$supportedBl = provider.supportedBlockNodes) === null || _provider$supportedBl === void 0 ? void 0 : _provider$supportedBl.includes(node.type.name));
219
222
  node.marks.filter(function (mark) {
220
223
  return mark.type === state.schema.marks.annotation;
221
224
  }).forEach(function (mark) {
@@ -224,10 +227,18 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
224
227
  var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
225
228
  return selectedAnnotation.id === mark.attrs.id;
226
229
  }));
227
- focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
228
- class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
229
- nodeName: 'span'
230
- }));
230
+ if (isSupportedBlockNode) {
231
+ focusDecorations.push(Decoration.node(pos, pos + node.nodeSize, {
232
+ class: "".concat(getBlockAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved)
233
+ }, {
234
+ key: decorationKey.block
235
+ }));
236
+ } else {
237
+ focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
238
+ class: "".concat(getAnnotationViewClassname(isUnresolved, isSelected), " ").concat(isUnresolved),
239
+ nodeName: 'span'
240
+ }));
241
+ }
231
242
  }
232
243
  });
233
244
  });
@@ -17,7 +17,7 @@ export default (function (pluginState, action) {
17
17
  mouseData: mouseData
18
18
  });
19
19
  case ACTIONS.SET_INLINE_COMMENT_DRAFT_STATE:
20
- return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes);
20
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.isCommentOnMediaOn, action.data.supportedBlockNodes, action.data.targetNodeId);
21
21
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
22
22
  return _objectSpread(_objectSpread({}, pluginState), {}, {
23
23
  dirtyAnnotations: false,
@@ -25,7 +25,8 @@ export default (function (pluginState, action) {
25
25
  });
26
26
  case ACTIONS.CLOSE_COMPONENT:
27
27
  return _objectSpread(_objectSpread({}, pluginState), {}, {
28
- isInlineCommentViewClosed: true
28
+ isInlineCommentViewClosed: true,
29
+ isDrafting: false
29
30
  });
30
31
  case ACTIONS.ADD_INLINE_COMMENT:
31
32
  var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
@@ -52,13 +53,15 @@ export default (function (pluginState, action) {
52
53
  return pluginState;
53
54
  }
54
55
  });
55
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes) {
56
+ function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
56
57
  var draftDecorationSet = pluginState.draftDecorationSet;
57
58
  if (!draftDecorationSet || !drafting) {
58
59
  draftDecorationSet = DecorationSet.empty;
59
60
  }
60
61
  var newState = _objectSpread(_objectSpread({}, pluginState), {}, {
61
- draftDecorationSet: draftDecorationSet
62
+ draftDecorationSet: draftDecorationSet,
63
+ isDrafting: drafting,
64
+ targetNodeId: targetNodeId
62
65
  });
63
66
  newState.bookmark = undefined;
64
67
  if (drafting && editorState) {
@@ -13,7 +13,7 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
13
13
  * return false if the node has no comments or no unresolved comments.
14
14
  */
15
15
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command;
16
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
16
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
17
17
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
18
18
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
19
19
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -68,7 +68,7 @@ declare const _default: {
68
68
  }, import("@atlaskit/editor-common/types").FeatureFlags>>];
69
69
  actions: {
70
70
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
71
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
71
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
72
72
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command;
73
73
  };
74
74
  }, import("../types").AnnotationProviders | undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
@@ -9,3 +9,4 @@ export declare class AnnotationNodeView extends ReactNodeView {
9
9
  render(_props: {}, forwardRef: ForwardRef): JSX.Element;
10
10
  }
11
11
  export declare const getAnnotationViewClassname: (isUnresolved: boolean, hasFocus: boolean) => string | undefined;
12
+ export declare const getBlockAnnotationViewClassname: (isUnresolved: boolean, hasFocus: boolean) => string | undefined;
@@ -40,6 +40,7 @@ export type InlineCommentAction = {
40
40
  targetType?: TargetType;
41
41
  isCommentOnMediaOn?: boolean;
42
42
  supportedBlockNodes?: string[];
43
+ targetNodeId?: string;
43
44
  };
44
45
  } | {
45
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -81,4 +82,6 @@ export type InlineCommentPluginState = {
81
82
  isVisible: boolean;
82
83
  skipSelectionHandling: boolean;
83
84
  featureFlagsPluginState?: FeatureFlags;
85
+ isDrafting: boolean;
86
+ targetNodeId?: string;
84
87
  };
@@ -24,7 +24,7 @@ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineComment
24
24
  /** @default 'inline' */
25
25
  targetType?: TargetType,
26
26
  /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
27
- isCommentOnMediaOn?: boolean) => Command;
27
+ isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
28
28
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
29
29
  pluginConfiguration: AnnotationProviders | undefined;
30
30
  sharedState: InlineCommentPluginState | undefined;
@@ -13,7 +13,7 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
13
13
  * return false if the node has no comments or no unresolved comments.
14
14
  */
15
15
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null) => Command;
16
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean) => Command;
16
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
17
17
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
18
18
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
19
19
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -82,7 +82,7 @@ declare const _default: {
82
82
  ];
83
83
  actions: {
84
84
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
85
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined) => import("@atlaskit/editor-common/types").Command;
85
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
86
86
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null) => import("@atlaskit/editor-common/types").Command;
87
87
  };
88
88
  }, import("../types").AnnotationProviders | undefined>,
@@ -9,3 +9,4 @@ export declare class AnnotationNodeView extends ReactNodeView {
9
9
  render(_props: {}, forwardRef: ForwardRef): JSX.Element;
10
10
  }
11
11
  export declare const getAnnotationViewClassname: (isUnresolved: boolean, hasFocus: boolean) => string | undefined;
12
+ export declare const getBlockAnnotationViewClassname: (isUnresolved: boolean, hasFocus: boolean) => string | undefined;
@@ -40,6 +40,7 @@ export type InlineCommentAction = {
40
40
  targetType?: TargetType;
41
41
  isCommentOnMediaOn?: boolean;
42
42
  supportedBlockNodes?: string[];
43
+ targetNodeId?: string;
43
44
  };
44
45
  } | {
45
46
  type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE;
@@ -81,4 +82,6 @@ export type InlineCommentPluginState = {
81
82
  isVisible: boolean;
82
83
  skipSelectionHandling: boolean;
83
84
  featureFlagsPluginState?: FeatureFlags;
85
+ isDrafting: boolean;
86
+ targetNodeId?: string;
84
87
  };
@@ -24,7 +24,7 @@ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineComment
24
24
  /** @default 'inline' */
25
25
  targetType?: TargetType,
26
26
  /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
27
- isCommentOnMediaOn?: boolean) => Command;
27
+ isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
28
28
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
29
29
  pluginConfiguration: AnnotationProviders | undefined;
30
30
  sharedState: InlineCommentPluginState | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.5.8",
3
+ "version": "1.5.10",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,8 +32,8 @@
32
32
  ".": "./src/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@atlaskit/adf-schema": "^35.8.0",
36
- "@atlaskit/editor-common": "^78.26.0",
35
+ "@atlaskit/adf-schema": "^35.9.0",
36
+ "@atlaskit/editor-common": "^78.29.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",