@atlaskit/editor-plugin-annotation 1.23.2 → 1.23.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-annotation
2
2
 
3
+ ## 1.23.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#158723](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158723)
8
+ [`8ff5b01b0d37f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8ff5b01b0d37f) -
9
+ [ED-24682] Cleanup feature flag for commenting on media in the renderer
10
+
11
+ **@atlaskit/editor-plugin-media**: Add optional checks for the api in Comment Badges on media
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 1.23.2
4
16
 
5
17
  ### Patch Changes
@@ -112,10 +112,10 @@ var removeInlineCommentNearSelection = exports.removeInlineCommentNearSelection
112
112
  return true;
113
113
  };
114
114
  };
115
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
115
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes) {
116
116
  return function (editorState) {
117
117
  // validate selection only when entering draft mode
118
- if (drafting && (0, _utils.isSelectionValid)(editorState, isCommentOnMediaOn) !== _types2.AnnotationSelectionType.VALID) {
118
+ if (drafting && (0, _utils.isSelectionValid)(editorState) !== _types2.AnnotationSelectionType.VALID) {
119
119
  return false;
120
120
  }
121
121
  return {
@@ -124,7 +124,6 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
124
124
  drafting: drafting,
125
125
  editorState: editorState,
126
126
  targetType: targetType,
127
- isCommentOnMediaOn: isCommentOnMediaOn,
128
127
  supportedBlockNodes: supportedBlockNodes,
129
128
  targetNodeId: targetNodeId
130
129
  }
@@ -176,9 +175,8 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
176
175
  return function (drafting) {
177
176
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
178
177
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
179
- var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
180
- var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
181
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
178
+ var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
179
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes);
182
180
  return (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
183
181
  };
184
182
  };
@@ -92,7 +92,6 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
92
92
  state: state,
93
93
  intl: intl,
94
94
  isToolbarAbove: isToolbarAbove,
95
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
96
95
  api: api
97
96
  });
98
97
  }
@@ -55,7 +55,6 @@ var shouldClearBookMarkCheck = exports.shouldClearBookMarkCheck = function shoul
55
55
  };
56
56
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
57
57
  return function (tr, pluginState) {
58
- var _pluginState$featureF;
59
58
  if (pluginState.skipSelectionHandling) {
60
59
  return _objectSpread(_objectSpread({}, pluginState), {}, {
61
60
  skipSelectionHandling: false
@@ -63,7 +62,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
63
62
  isInlineCommentViewClosed: false
64
63
  });
65
64
  }
66
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
65
+ if (
67
66
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
68
67
  // we keep it as it is so that we can show comment view component with the newly created comment
69
68
  (0, _utils2.isBlockNodeAnnotationsSelected)(tr.selection, pluginState.selectedAnnotations)) {
@@ -99,28 +98,25 @@ var _pluginFactory = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _
99
98
  onDocChanged: handleDocChanged,
100
99
  mapping: function mapping(tr, pluginState, editorState) {
101
100
  var draftDecorationSet = pluginState.draftDecorationSet,
102
- bookmark = pluginState.bookmark,
103
- featureFlagsPluginState = pluginState.featureFlagsPluginState;
101
+ bookmark = pluginState.bookmark;
104
102
  var mappedDecorationSet = _view.DecorationSet.empty,
105
103
  mappedBookmark;
106
104
  var hasMappedDecorations = false;
107
105
  if (draftDecorationSet) {
108
106
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
109
107
  }
110
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
111
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
112
- return Object.values(_utils2.decorationKey).includes(spec.key);
113
- }).length > 0;
108
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
109
+ return Object.values(_utils2.decorationKey).includes(spec.key);
110
+ }).length > 0;
114
111
 
115
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
116
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
117
- // We only perform this change when document selection has changed.
118
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
119
- return _objectSpread(_objectSpread({}, pluginState), {}, {
120
- draftDecorationSet: mappedDecorationSet,
121
- bookmark: undefined
122
- });
123
- }
112
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
113
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
114
+ // We only perform this change when document selection has changed.
115
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
116
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
117
+ draftDecorationSet: mappedDecorationSet,
118
+ bookmark: undefined
119
+ });
124
120
  }
125
121
  if (bookmark) {
126
122
  mappedBookmark = bookmark.map(tr.mapping);
@@ -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, action.data.targetNodeId);
27
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, 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,
@@ -62,7 +62,7 @@ var _default = exports.default = function _default(pluginState, action) {
62
62
  return pluginState;
63
63
  }
64
64
  };
65
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
65
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId) {
66
66
  var draftDecorationSet = pluginState.draftDecorationSet;
67
67
  if (!draftDecorationSet || !drafting) {
68
68
  draftDecorationSet = _view.DecorationSet.empty;
@@ -75,9 +75,9 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
75
75
  newState.bookmark = undefined;
76
76
  if (drafting && editorState) {
77
77
  newState.bookmark = editorState.selection.getBookmark();
78
- var _ref = isCommentOnMediaOn ? (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc),
79
- from = _ref.from,
80
- to = _ref.to;
78
+ var _resolveDraftBookmark = (0, _utils.resolveDraftBookmark)(editorState, newState.bookmark, supportedBlockNodes),
79
+ from = _resolveDraftBookmark.from,
80
+ to = _resolveDraftBookmark.to;
81
81
  var draftDecoration = (0, _utils.addDraftDecoration)(from, to, targetType);
82
82
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
83
83
  }
@@ -55,13 +55,12 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
55
55
  intl = _ref2.intl,
56
56
  _ref2$isToolbarAbove = _ref2.isToolbarAbove,
57
57
  isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
58
- isCommentOnMediaOn = _ref2.isCommentOnMediaOn,
59
58
  _ref2$_supportedNodes = _ref2._supportedNodes,
60
59
  _supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
61
60
  api = _ref2.api;
62
61
  var schema = state.schema;
63
- var selectionValid = (0, _utils2.isSelectionValid)(state, isCommentOnMediaOn);
64
- var isMediaSelected = isCommentOnMediaOn && (0, _mediaSingle.currentMediaNodeWithPos)(state);
62
+ var selectionValid = (0, _utils2.isSelectionValid)(state);
63
+ var isMediaSelected = (0, _mediaSingle.currentMediaNodeWithPos)(state);
65
64
 
66
65
  // comments on media can only be added via media floating toolbar
67
66
  if (isMediaSelected || selectionValid === _types.AnnotationSelectionType.INVALID) {
package/dist/cjs/utils.js CHANGED
@@ -315,15 +315,15 @@ var getDraftCommandAnalyticsPayload = exports.getDraftCommandAnalyticsPayload =
315
315
  };
316
316
  return payload;
317
317
  };
318
- var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
318
+ var isSelectionValid = exports.isSelectionValid = function isSelectionValid(state) {
319
319
  var _currentMediaNodeWith;
320
- var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
320
+ var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
321
321
  var selection = state.selection;
322
322
  var _ref4 = getPluginState(state) || {},
323
323
  disallowOnWhitespace = _ref4.disallowOnWhitespace;
324
324
 
325
325
  // Allow media so that it can enter draft mode
326
- if (isCommentOnMediaOn && (_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
326
+ if ((_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
327
327
  return _types.AnnotationSelectionType.VALID;
328
328
  }
329
329
  if (selection.empty || !(selection instanceof _state.TextSelection || selection instanceof _state.AllSelection)) {
@@ -94,10 +94,10 @@ export const removeInlineCommentNearSelection = (id, supportedNodes = []) => (st
94
94
  }
95
95
  return true;
96
96
  };
97
- const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) => {
97
+ const getDraftCommandAction = (drafting, targetType, targetNodeId, supportedBlockNodes) => {
98
98
  return editorState => {
99
99
  // validate selection only when entering draft mode
100
- if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
100
+ if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
101
101
  return false;
102
102
  }
103
103
  return {
@@ -106,7 +106,6 @@ const getDraftCommandAction = (drafting, targetType, targetNodeId, isCommentOnMe
106
106
  drafting,
107
107
  editorState,
108
108
  targetType,
109
- isCommentOnMediaOn,
110
109
  supportedBlockNodes,
111
110
  targetNodeId
112
111
  }
@@ -146,8 +145,8 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
146
145
  }
147
146
  return false;
148
147
  };
149
- export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false, targetNodeId = undefined) => {
150
- const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
148
+ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined) => {
149
+ const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes);
151
150
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
152
151
  };
153
152
  export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
@@ -81,7 +81,6 @@ export const annotationPlugin = ({
81
81
  state,
82
82
  intl,
83
83
  isToolbarAbove,
84
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
85
84
  api
86
85
  });
87
86
  }
@@ -45,7 +45,6 @@ export const shouldClearBookMarkCheck = (tr, editorState, bookmark) => {
45
45
  return true;
46
46
  };
47
47
  const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
48
- var _pluginState$featureF;
49
48
  if (pluginState.skipSelectionHandling) {
50
49
  return {
51
50
  ...pluginState,
@@ -55,7 +54,7 @@ const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
55
54
  })
56
55
  };
57
56
  }
58
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
57
+ if (
59
58
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
60
59
  // we keep it as it is so that we can show comment view component with the newly created comment
61
60
  isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
@@ -102,8 +101,7 @@ export const {
102
101
  mapping: (tr, pluginState, editorState) => {
103
102
  let {
104
103
  draftDecorationSet,
105
- bookmark,
106
- featureFlagsPluginState
104
+ bookmark
107
105
  } = pluginState;
108
106
  let mappedDecorationSet = DecorationSet.empty,
109
107
  mappedBookmark;
@@ -111,19 +109,17 @@ export const {
111
109
  if (draftDecorationSet) {
112
110
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
113
111
  }
114
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
115
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, spec => Object.values(decorationKey).includes(spec.key)).length > 0;
112
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, spec => Object.values(decorationKey).includes(spec.key)).length > 0;
116
113
 
117
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
118
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
119
- // We only perform this change when document selection has changed.
120
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
121
- return {
122
- ...pluginState,
123
- draftDecorationSet: mappedDecorationSet,
124
- bookmark: undefined
125
- };
126
- }
114
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
115
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
116
+ // We only perform this change when document selection has changed.
117
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
118
+ return {
119
+ ...pluginState,
120
+ draftDecorationSet: mappedDecorationSet,
121
+ bookmark: undefined
122
+ };
127
123
  }
128
124
  if (bookmark) {
129
125
  mappedBookmark = bookmark.map(tr.mapping);
@@ -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, action.data.targetNodeId);
21
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, action.data.supportedBlockNodes, action.data.targetNodeId);
22
22
  case ACTIONS.INLINE_COMMENT_CLEAR_DIRTY_MARK:
23
23
  return {
24
24
  ...pluginState,
@@ -66,7 +66,7 @@ export default ((pluginState, action) => {
66
66
  return pluginState;
67
67
  }
68
68
  });
69
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
69
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId) {
70
70
  let {
71
71
  draftDecorationSet
72
72
  } = pluginState;
@@ -85,7 +85,7 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
85
85
  const {
86
86
  from,
87
87
  to
88
- } = isCommentOnMediaOn ? resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc);
88
+ } = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes);
89
89
  const draftDecoration = addDraftDecoration(from, to, targetType);
90
90
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
91
91
  }
@@ -45,15 +45,14 @@ export const buildToolbar = editorAnalyticsAPI => ({
45
45
  state,
46
46
  intl,
47
47
  isToolbarAbove = false,
48
- isCommentOnMediaOn,
49
48
  _supportedNodes = [],
50
49
  api
51
50
  }) => {
52
51
  const {
53
52
  schema
54
53
  } = state;
55
- const selectionValid = isSelectionValid(state, isCommentOnMediaOn);
56
- const isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
54
+ const selectionValid = isSelectionValid(state);
55
+ const isMediaSelected = currentMediaNodeWithPos(state);
57
56
 
58
57
  // comments on media can only be added via media floating toolbar
59
58
  if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
@@ -278,7 +278,7 @@ export const getDraftCommandAnalyticsPayload = (drafting, inputMethod) => {
278
278
  };
279
279
  return payload;
280
280
  };
281
- export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []) => {
281
+ export const isSelectionValid = (state, _supportedNodes = []) => {
282
282
  var _currentMediaNodeWith;
283
283
  const {
284
284
  selection
@@ -288,7 +288,7 @@ export const isSelectionValid = (state, isCommentOnMediaOn, _supportedNodes = []
288
288
  } = getPluginState(state) || {};
289
289
 
290
290
  // Allow media so that it can enter draft mode
291
- if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
291
+ if ((_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
292
292
  return AnnotationSelectionType.VALID;
293
293
  }
294
294
  if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
@@ -105,10 +105,10 @@ export var removeInlineCommentNearSelection = function removeInlineCommentNearSe
105
105
  return true;
106
106
  };
107
107
  };
108
- var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes) {
108
+ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes) {
109
109
  return function (editorState) {
110
110
  // validate selection only when entering draft mode
111
- if (drafting && isSelectionValid(editorState, isCommentOnMediaOn) !== AnnotationSelectionType.VALID) {
111
+ if (drafting && isSelectionValid(editorState) !== AnnotationSelectionType.VALID) {
112
112
  return false;
113
113
  }
114
114
  return {
@@ -117,7 +117,6 @@ var getDraftCommandAction = function getDraftCommandAction(drafting, targetType,
117
117
  drafting: drafting,
118
118
  editorState: editorState,
119
119
  targetType: targetType,
120
- isCommentOnMediaOn: isCommentOnMediaOn,
121
120
  supportedBlockNodes: supportedBlockNodes,
122
121
  targetNodeId: targetNodeId
123
122
  }
@@ -169,9 +168,8 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
169
168
  return function (drafting) {
170
169
  var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
171
170
  var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
172
- var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
173
- var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
174
- var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
171
+ var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
172
+ var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes);
175
173
  return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
176
174
  };
177
175
  };
@@ -79,7 +79,6 @@ export var annotationPlugin = function annotationPlugin(_ref) {
79
79
  state: state,
80
80
  intl: intl,
81
81
  isToolbarAbove: isToolbarAbove,
82
- isCommentOnMediaOn: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.commentsOnMedia,
83
82
  api: api
84
83
  });
85
84
  }
@@ -48,7 +48,6 @@ export var shouldClearBookMarkCheck = function shouldClearBookMarkCheck(tr, edit
48
48
  };
49
49
  var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
50
50
  return function (tr, pluginState) {
51
- var _pluginState$featureF;
52
51
  if (pluginState.skipSelectionHandling) {
53
52
  return _objectSpread(_objectSpread({}, pluginState), {}, {
54
53
  skipSelectionHandling: false
@@ -56,7 +55,7 @@ var getSelectionChangedHandler = function getSelectionChangedHandler(reopenComme
56
55
  isInlineCommentViewClosed: false
57
56
  });
58
57
  }
59
- if ((_pluginState$featureF = pluginState.featureFlagsPluginState) !== null && _pluginState$featureF !== void 0 && _pluginState$featureF.commentsOnMedia &&
58
+ if (
60
59
  // If pluginState.selectedAnnotations is annotations of block node, i.e. when a new comment is created,
61
60
  // we keep it as it is so that we can show comment view component with the newly created comment
62
61
  isBlockNodeAnnotationsSelected(tr.selection, pluginState.selectedAnnotations)) {
@@ -92,28 +91,25 @@ var _pluginFactory = pluginFactory(inlineCommentPluginKey, reducer, {
92
91
  onDocChanged: handleDocChanged,
93
92
  mapping: function mapping(tr, pluginState, editorState) {
94
93
  var draftDecorationSet = pluginState.draftDecorationSet,
95
- bookmark = pluginState.bookmark,
96
- featureFlagsPluginState = pluginState.featureFlagsPluginState;
94
+ bookmark = pluginState.bookmark;
97
95
  var mappedDecorationSet = DecorationSet.empty,
98
96
  mappedBookmark;
99
97
  var hasMappedDecorations = false;
100
98
  if (draftDecorationSet) {
101
99
  mappedDecorationSet = draftDecorationSet.map(tr.mapping, tr.doc);
102
100
  }
103
- if (featureFlagsPluginState !== null && featureFlagsPluginState !== void 0 && featureFlagsPluginState.commentsOnMedia) {
104
- hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
105
- return Object.values(decorationKey).includes(spec.key);
106
- }).length > 0;
101
+ hasMappedDecorations = mappedDecorationSet.find(undefined, undefined, function (spec) {
102
+ return Object.values(decorationKey).includes(spec.key);
103
+ }).length > 0;
107
104
 
108
- // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
109
- // we need to reset bookmark to hide create component and to avoid invalid draft being published
110
- // We only perform this change when document selection has changed.
111
- if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
112
- return _objectSpread(_objectSpread({}, pluginState), {}, {
113
- draftDecorationSet: mappedDecorationSet,
114
- bookmark: undefined
115
- });
116
- }
105
+ // When changes to decoration target make decoration invalid (e.g. delete text, add mark to node),
106
+ // we need to reset bookmark to hide create component and to avoid invalid draft being published
107
+ // We only perform this change when document selection has changed.
108
+ if (!hasMappedDecorations && shouldClearBookMarkCheck(tr, editorState, bookmark)) {
109
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
110
+ draftDecorationSet: mappedDecorationSet,
111
+ bookmark: undefined
112
+ });
117
113
  }
118
114
  if (bookmark) {
119
115
  mappedBookmark = bookmark.map(tr.mapping);
@@ -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, action.data.targetNodeId);
20
+ return getNewDraftState(pluginState, action.data.drafting, action.data.editorState, action.data.targetType, 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,
@@ -55,7 +55,7 @@ export default (function (pluginState, action) {
55
55
  return pluginState;
56
56
  }
57
57
  });
58
- function getNewDraftState(pluginState, drafting, editorState, targetType, isCommentOnMediaOn, supportedBlockNodes, targetNodeId) {
58
+ function getNewDraftState(pluginState, drafting, editorState, targetType, supportedBlockNodes, targetNodeId) {
59
59
  var draftDecorationSet = pluginState.draftDecorationSet;
60
60
  if (!draftDecorationSet || !drafting) {
61
61
  draftDecorationSet = DecorationSet.empty;
@@ -68,9 +68,9 @@ function getNewDraftState(pluginState, drafting, editorState, targetType, isComm
68
68
  newState.bookmark = undefined;
69
69
  if (drafting && editorState) {
70
70
  newState.bookmark = editorState.selection.getBookmark();
71
- var _ref = isCommentOnMediaOn ? resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes) : newState.bookmark.resolve(editorState.doc),
72
- from = _ref.from,
73
- to = _ref.to;
71
+ var _resolveDraftBookmark = resolveDraftBookmark(editorState, newState.bookmark, supportedBlockNodes),
72
+ from = _resolveDraftBookmark.from,
73
+ to = _resolveDraftBookmark.to;
74
74
  var draftDecoration = addDraftDecoration(from, to, targetType);
75
75
  newState.draftDecorationSet = draftDecorationSet.add(editorState.doc, [draftDecoration]);
76
76
  }
@@ -48,13 +48,12 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
48
48
  intl = _ref2.intl,
49
49
  _ref2$isToolbarAbove = _ref2.isToolbarAbove,
50
50
  isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
51
- isCommentOnMediaOn = _ref2.isCommentOnMediaOn,
52
51
  _ref2$_supportedNodes = _ref2._supportedNodes,
53
52
  _supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
54
53
  api = _ref2.api;
55
54
  var schema = state.schema;
56
- var selectionValid = isSelectionValid(state, isCommentOnMediaOn);
57
- var isMediaSelected = isCommentOnMediaOn && currentMediaNodeWithPos(state);
55
+ var selectionValid = isSelectionValid(state);
56
+ var isMediaSelected = currentMediaNodeWithPos(state);
58
57
 
59
58
  // comments on media can only be added via media floating toolbar
60
59
  if (isMediaSelected || selectionValid === AnnotationSelectionType.INVALID) {
package/dist/esm/utils.js CHANGED
@@ -288,15 +288,15 @@ export var getDraftCommandAnalyticsPayload = function getDraftCommandAnalyticsPa
288
288
  };
289
289
  return payload;
290
290
  };
291
- export var isSelectionValid = function isSelectionValid(state, isCommentOnMediaOn) {
291
+ export var isSelectionValid = function isSelectionValid(state) {
292
292
  var _currentMediaNodeWith;
293
- var _supportedNodes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
293
+ var _supportedNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
294
294
  var selection = state.selection;
295
295
  var _ref4 = getPluginState(state) || {},
296
296
  disallowOnWhitespace = _ref4.disallowOnWhitespace;
297
297
 
298
298
  // Allow media so that it can enter draft mode
299
- if (isCommentOnMediaOn && (_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
299
+ if ((_currentMediaNodeWith = currentMediaNodeWithPos(state)) !== null && _currentMediaNodeWith !== void 0 && _currentMediaNodeWith.node) {
300
300
  return AnnotationSelectionType.VALID;
301
301
  }
302
302
  if (selection.empty || !(selection instanceof TextSelection || selection instanceof AllSelection)) {
@@ -14,7 +14,7 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
14
14
  * return false if the node has no comments or no unresolved comments.
15
15
  */
16
16
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD) => Command;
17
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
17
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined) => Command;
18
18
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
19
19
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
20
20
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -112,7 +112,7 @@ declare const _default: {
112
112
  }, import("@atlaskit/editor-plugin-engagement-platform").EngagementPlatformPluginConfig>>];
113
113
  actions: {
114
114
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
115
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
115
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
116
116
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined) => import("@atlaskit/editor-common/types").Command;
117
117
  };
118
118
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -38,7 +38,6 @@ export type InlineCommentAction = {
38
38
  drafting: boolean;
39
39
  editorState: EditorState;
40
40
  targetType?: TargetType;
41
- isCommentOnMediaOn?: boolean;
42
41
  supportedBlockNodes?: string[];
43
42
  targetNodeId?: string;
44
43
  };
@@ -11,5 +11,5 @@ interface BuildToolbarOptions {
11
11
  _supportedNodes?: string[];
12
12
  api?: ExtractInjectionAPI<AnnotationPlugin>;
13
13
  }
14
- export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, isCommentOnMediaOn, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
14
+ export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
15
15
  export {};
@@ -23,9 +23,7 @@ export type TargetType = 'block' | 'inline';
23
23
  export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
24
24
  type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
25
25
  /** @default 'inline' */
26
- targetType?: TargetType,
27
- /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
28
- isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string) => Command;
29
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
30
28
  pluginConfiguration: AnnotationProviders | undefined;
31
29
  sharedState: InlineCommentPluginState | undefined;
@@ -34,7 +34,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
34
34
  * get payload for the open/close analytics event
35
35
  */
36
36
  export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
37
- export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
37
+ export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType;
38
38
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
39
39
  export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean;
40
40
  /**
@@ -14,7 +14,7 @@ export declare const removeInlineCommentNearSelection: (id: string, supportedNod
14
14
  * return false if the node has no comments or no unresolved comments.
15
15
  */
16
16
  export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD) => Command;
17
- export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, isCommentOnMediaOn?: boolean, targetNodeId?: string | undefined) => Command;
17
+ export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined) => Command;
18
18
  export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
19
19
  export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
20
20
  export declare const setSelectedAnnotation: (id: string) => Command;
@@ -134,7 +134,7 @@ declare const _default: {
134
134
  ];
135
135
  actions: {
136
136
  stripNonExistingAnnotations: (slice: import("prosemirror-model").Slice, state: EditorState) => boolean | undefined;
137
- setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, isCommentOnMediaOn?: boolean | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
137
+ setInlineCommentDraftState: (drafting: boolean, inputMethod: InlineCommentInputMethod, targetType?: import("../types").TargetType | undefined, targetNodeId?: string | undefined) => import("@atlaskit/editor-common/types").Command;
138
138
  showCommentForBlockNode: (node: import("prosemirror-model").Node | null, viewMethod?: import("@atlaskit/editor-common/analytics").VIEW_METHOD | undefined) => import("@atlaskit/editor-common/types").Command;
139
139
  };
140
140
  }> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
@@ -38,7 +38,6 @@ export type InlineCommentAction = {
38
38
  drafting: boolean;
39
39
  editorState: EditorState;
40
40
  targetType?: TargetType;
41
- isCommentOnMediaOn?: boolean;
42
41
  supportedBlockNodes?: string[];
43
42
  targetNodeId?: string;
44
43
  };
@@ -11,5 +11,5 @@ interface BuildToolbarOptions {
11
11
  _supportedNodes?: string[];
12
12
  api?: ExtractInjectionAPI<AnnotationPlugin>;
13
13
  }
14
- export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, isCommentOnMediaOn, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
14
+ export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, }: BuildToolbarOptions) => FloatingToolbarConfig | undefined;
15
15
  export {};
@@ -23,9 +23,7 @@ export type TargetType = 'block' | 'inline';
23
23
  export type InlineCommentInputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT | INPUT_METHOD.FLOATING_TB;
24
24
  type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod,
25
25
  /** @default 'inline' */
26
- targetType?: TargetType,
27
- /** check for confluence.frontend.fabric.editor.comments-on-media feature flag */
28
- isCommentOnMediaOn?: boolean, targetNodeId?: string) => Command;
26
+ targetType?: TargetType, targetNodeId?: string) => Command;
29
27
  export type AnnotationPlugin = NextEditorPlugin<'annotation', {
30
28
  pluginConfiguration: AnnotationProviders | undefined;
31
29
  sharedState: InlineCommentPluginState | undefined;
@@ -34,7 +34,7 @@ export declare const getPluginState: (state: EditorState) => InlineCommentPlugin
34
34
  * get payload for the open/close analytics event
35
35
  */
36
36
  export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback;
37
- export declare const isSelectionValid: (state: EditorState, isCommentOnMediaOn?: boolean, _supportedNodes?: string[]) => AnnotationSelectionType;
37
+ export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType;
38
38
  export declare const hasInvalidNodes: (state: EditorState) => boolean;
39
39
  export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean;
40
40
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-annotation",
3
- "version": "1.23.2",
3
+ "version": "1.23.3",
4
4
  "description": "Annotation plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/icon": "^22.24.0",
42
42
  "@atlaskit/onboarding": "^12.0.0",
43
43
  "@atlaskit/platform-feature-flags": "^0.3.0",
44
- "@atlaskit/tmp-editor-statsig": "^2.10.0",
44
+ "@atlaskit/tmp-editor-statsig": "^2.11.0",
45
45
  "@babel/runtime": "^7.0.0"
46
46
  },
47
47
  "peerDependencies": {