@atlaskit/editor-plugin-annotation 2.9.2 → 2.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/pm-plugins/annotation-manager-hooks.js +1 -2
- package/dist/cjs/pm-plugins/inline-comment.js +30 -30
- package/dist/cjs/pm-plugins/plugin-factory.js +5 -3
- package/dist/cjs/pm-plugins/reducer.js +2 -2
- package/dist/cjs/pm-plugins/toolbar.js +1 -1
- package/dist/cjs/ui/InlineCommentView.js +1 -2
- package/dist/es2019/pm-plugins/annotation-manager-hooks.js +1 -2
- package/dist/es2019/pm-plugins/inline-comment.js +19 -20
- package/dist/es2019/pm-plugins/plugin-factory.js +5 -3
- package/dist/es2019/pm-plugins/reducer.js +2 -2
- package/dist/es2019/pm-plugins/toolbar.js +1 -1
- package/dist/esm/pm-plugins/annotation-manager-hooks.js +1 -2
- package/dist/esm/pm-plugins/inline-comment.js +30 -30
- package/dist/esm/pm-plugins/plugin-factory.js +5 -3
- package/dist/esm/pm-plugins/reducer.js +2 -2
- package/dist/esm/pm-plugins/toolbar.js +1 -1
- package/dist/types/pm-plugins/types.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +4 -0
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 2.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#163361](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/163361)
|
|
8
|
+
[`76c3619bccda1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/76c3619bccda1) -
|
|
9
|
+
Changed the annotation manager feature gate to instead use the existance of the manager rather
|
|
10
|
+
then a gate
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 2.9.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -7,7 +7,6 @@ exports.startDraft = exports.setIsAnnotationSelected = exports.setIsAnnotationHo
|
|
|
7
7
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
8
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
9
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _editorCommands = require("../editor-commands");
|
|
12
11
|
var _types = require("../types");
|
|
13
12
|
var _utils3 = require("./utils");
|
|
@@ -58,7 +57,7 @@ var startDraft = exports.startDraft = function startDraft(editorView, options) {
|
|
|
58
57
|
reason: ERROR_REASON_DRAFT_IN_PROGRESS
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
|
-
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)
|
|
60
|
+
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
|
|
62
61
|
// if there are selected annotations when starting a draft, we need to clear the selected annotations
|
|
63
62
|
// before we start the draft.
|
|
64
63
|
(0, _editorCommands.closeComponent)()(editorView.state, editorView.dispatch);
|
|
@@ -93,6 +93,7 @@ var fetchState = /*#__PURE__*/function () {
|
|
|
93
93
|
var initialState = function initialState() {
|
|
94
94
|
var disallowOnWhitespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
95
95
|
var featureFlagsPluginState = arguments.length > 1 ? arguments[1] : undefined;
|
|
96
|
+
var isAnnotationManagerEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
96
97
|
return {
|
|
97
98
|
annotations: {},
|
|
98
99
|
selectedAnnotations: [],
|
|
@@ -107,7 +108,8 @@ var initialState = function initialState() {
|
|
|
107
108
|
featureFlagsPluginState: featureFlagsPluginState,
|
|
108
109
|
isDrafting: false,
|
|
109
110
|
pendingSelectedAnnotations: [],
|
|
110
|
-
pendingSelectedAnnotationsUpdateCount: 0
|
|
111
|
+
pendingSelectedAnnotationsUpdateCount: 0,
|
|
112
|
+
isAnnotationManagerEnabled: isAnnotationManagerEnabled
|
|
111
113
|
};
|
|
112
114
|
};
|
|
113
115
|
var hideToolbar = function hideToolbar(state, dispatch) {
|
|
@@ -164,7 +166,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
164
166
|
annotationManager = options.annotationManager;
|
|
165
167
|
return new _safePlugin.SafePlugin({
|
|
166
168
|
key: _utils2.inlineCommentPluginKey,
|
|
167
|
-
state: (0, _pluginFactory.createPluginState)(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState)),
|
|
169
|
+
state: (0, _pluginFactory.createPluginState)(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
|
|
168
170
|
view: function view(editorView) {
|
|
169
171
|
var allowAnnotationFn;
|
|
170
172
|
var startDraftFn;
|
|
@@ -174,25 +176,23 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
174
176
|
var setIsAnnotationSelectedFn;
|
|
175
177
|
var setIsAnnotationHoveredFn;
|
|
176
178
|
var clearAnnotationFn;
|
|
177
|
-
if (annotationManager
|
|
179
|
+
if (annotationManager) {
|
|
178
180
|
allowAnnotationFn = (0, _annotationManagerHooks.allowAnnotation)(editorView, options);
|
|
179
181
|
startDraftFn = (0, _annotationManagerHooks.startDraft)(editorView, options);
|
|
180
182
|
clearDraftFn = (0, _annotationManagerHooks.clearDraft)(editorView, options);
|
|
181
183
|
applyDraftFn = (0, _annotationManagerHooks.applyDraft)(editorView, options);
|
|
182
184
|
getDraftFn = (0, _annotationManagerHooks.getDraft)(editorView, options);
|
|
185
|
+
setIsAnnotationSelectedFn = (0, _annotationManagerHooks.setIsAnnotationSelected)(editorView, options);
|
|
186
|
+
setIsAnnotationHoveredFn = (0, _annotationManagerHooks.setIsAnnotationHovered)(editorView, options);
|
|
187
|
+
clearAnnotationFn = (0, _annotationManagerHooks.clearAnnotation)(editorView, options);
|
|
183
188
|
annotationManager.hook('allowAnnotation', allowAnnotationFn);
|
|
184
189
|
annotationManager.hook('startDraft', startDraftFn);
|
|
185
190
|
annotationManager.hook('clearDraft', clearDraftFn);
|
|
186
191
|
annotationManager.hook('applyDraft', applyDraftFn);
|
|
187
192
|
annotationManager.hook('getDraft', getDraftFn);
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
clearAnnotationFn = (0, _annotationManagerHooks.clearAnnotation)(editorView, options);
|
|
192
|
-
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
193
|
-
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
194
|
-
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
195
|
-
}
|
|
193
|
+
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
194
|
+
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
195
|
+
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
196
196
|
}
|
|
197
197
|
// Get initial state
|
|
198
198
|
// Need to pass `editorView` to mitigate editor state going stale
|
|
@@ -277,7 +277,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
277
277
|
// The selectComponentExperience is using a simplified object, which is why it's type asserted.
|
|
278
278
|
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
|
|
279
279
|
}
|
|
280
|
-
if (
|
|
280
|
+
if (annotationManager) {
|
|
281
281
|
// In the Editor, Annotations can be selected in three ways:
|
|
282
282
|
// 1. By clicking on the annotation in the editor
|
|
283
283
|
// 2. By using the annotation manager to select the annotation
|
|
@@ -295,7 +295,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
295
295
|
// Need to set a lock to avoid calling gate multiple times. The lock will be released
|
|
296
296
|
// when the preemptive gate is complete.
|
|
297
297
|
isPreemptiveGateActive = true;
|
|
298
|
-
annotationManager
|
|
298
|
+
annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
|
|
299
299
|
var _ref8 = (0, _utils2.getPluginState)(view.state) || {},
|
|
300
300
|
isDrafting = _ref8.isDrafting,
|
|
301
301
|
latestPendingSelectedAnnotations = _ref8.pendingSelectedAnnotations,
|
|
@@ -314,8 +314,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
314
314
|
return pendingAnnotation.id === annotation.id;
|
|
315
315
|
})) === -1;
|
|
316
316
|
}).forEach(function (annotation) {
|
|
317
|
-
var
|
|
318
|
-
|
|
317
|
+
var _getAnnotationInlineN;
|
|
318
|
+
annotationManager.emit({
|
|
319
319
|
name: 'annotationSelectionChanged',
|
|
320
320
|
data: {
|
|
321
321
|
annotationId: annotation.id,
|
|
@@ -327,9 +327,9 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
327
327
|
|
|
328
328
|
// Notify the annotation manager that the pending selection has changed.
|
|
329
329
|
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref9) {
|
|
330
|
-
var
|
|
330
|
+
var _getAnnotationInlineN2;
|
|
331
331
|
var id = _ref9.id;
|
|
332
|
-
|
|
332
|
+
annotationManager.emit({
|
|
333
333
|
name: 'annotationSelectionChanged',
|
|
334
334
|
data: {
|
|
335
335
|
annotationId: id,
|
|
@@ -352,8 +352,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
var
|
|
356
|
-
dirtyAnnotations =
|
|
355
|
+
var _ref0 = (0, _utils2.getPluginState)(view.state) || {},
|
|
356
|
+
dirtyAnnotations = _ref0.dirtyAnnotations;
|
|
357
357
|
if (!dirtyAnnotations) {
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
@@ -366,7 +366,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
366
366
|
if (updateSubscriber) {
|
|
367
367
|
updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
|
|
368
368
|
}
|
|
369
|
-
if (annotationManager
|
|
369
|
+
if (annotationManager) {
|
|
370
370
|
annotationManager.unhook('allowAnnotation', allowAnnotationFn);
|
|
371
371
|
annotationManager.unhook('startDraft', startDraftFn);
|
|
372
372
|
annotationManager.unhook('clearDraft', clearDraftFn);
|
|
@@ -416,13 +416,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
416
416
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
417
417
|
return false;
|
|
418
418
|
}
|
|
419
|
-
var
|
|
420
|
-
annotations =
|
|
419
|
+
var _ref1 = pluginState || {},
|
|
420
|
+
annotations = _ref1.annotations;
|
|
421
421
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
422
422
|
if (!isUnresolved) {
|
|
423
423
|
return false;
|
|
424
424
|
}
|
|
425
|
-
if (
|
|
425
|
+
if (annotationManager) {
|
|
426
426
|
var _pluginState$pendingS;
|
|
427
427
|
// The manager disable setting the selected annotation on click because in the editor this is already
|
|
428
428
|
// handled by the selection update handler. When the manager is enabled, and a selection changes it's pushed into
|
|
@@ -445,13 +445,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
445
445
|
},
|
|
446
446
|
decorations: function decorations(state) {
|
|
447
447
|
// highlight comments, depending on state
|
|
448
|
-
var
|
|
449
|
-
draftDecorationSet =
|
|
450
|
-
annotations =
|
|
451
|
-
selectedAnnotations =
|
|
452
|
-
isVisible =
|
|
453
|
-
isInlineCommentViewClosed =
|
|
454
|
-
hoveredAnnotations =
|
|
448
|
+
var _ref10 = (0, _utils2.getPluginState)(state) || {},
|
|
449
|
+
draftDecorationSet = _ref10.draftDecorationSet,
|
|
450
|
+
annotations = _ref10.annotations,
|
|
451
|
+
selectedAnnotations = _ref10.selectedAnnotations,
|
|
452
|
+
isVisible = _ref10.isVisible,
|
|
453
|
+
isInlineCommentViewClosed = _ref10.isInlineCommentViewClosed,
|
|
454
|
+
hoveredAnnotations = _ref10.hoveredAnnotations;
|
|
455
455
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
|
|
456
456
|
var focusDecorations = [];
|
|
457
457
|
|
|
@@ -9,7 +9,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
11
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
14
13
|
var _utils2 = require("./utils");
|
|
15
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -111,7 +110,6 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
|
|
|
111
110
|
|
|
112
111
|
// NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
|
|
113
112
|
// if the selection is empty. If this is no longer needed, we can remove this code.
|
|
114
|
-
// clean up with platform_editor_comments_api_manager_select
|
|
115
113
|
// if (selectedAnnotations.length === 0) {
|
|
116
114
|
// return {
|
|
117
115
|
// ...pluginState,
|
|
@@ -140,7 +138,11 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
|
|
|
140
138
|
};
|
|
141
139
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
142
140
|
return function (tr, pluginState) {
|
|
143
|
-
return
|
|
141
|
+
return pluginState.isAnnotationManagerEnabled ?
|
|
142
|
+
// if platform_editor_comments_api_manager == true
|
|
143
|
+
getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) :
|
|
144
|
+
// else if platform_editor_comments_api_manager == false
|
|
145
|
+
getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
|
|
144
146
|
};
|
|
145
147
|
};
|
|
146
148
|
var _pluginFactory = (0, _utils.pluginFactory)(_utils2.inlineCommentPluginKey, _reducer.default, {
|
|
@@ -38,7 +38,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
38
38
|
isOpeningMediaCommentFromToolbar: false
|
|
39
39
|
}, (0, _platformFeatureFlags.fg)('platform_editor_annotation_selected_annotation') && {
|
|
40
40
|
selectedAnnotations: []
|
|
41
|
-
}),
|
|
41
|
+
}), pluginState.isAnnotationManagerEnabled && {
|
|
42
42
|
selectedAnnotations: []
|
|
43
43
|
});
|
|
44
44
|
case _types.ACTIONS.ADD_INLINE_COMMENT:
|
|
@@ -48,7 +48,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
48
48
|
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
|
|
49
49
|
isInlineCommentViewClosed: false,
|
|
50
50
|
selectAnnotationMethod: undefined
|
|
51
|
-
},
|
|
51
|
+
}, pluginState.isAnnotationManagerEnabled && {
|
|
52
52
|
skipSelectionHandling: true
|
|
53
53
|
});
|
|
54
54
|
case _types.ACTIONS.INLINE_COMMENT_SET_VISIBLE:
|
|
@@ -133,7 +133,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
133
133
|
pageMode: 'edit'
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
-
if (annotationManager
|
|
136
|
+
if (annotationManager) {
|
|
137
137
|
annotationManager.checkPreemptiveGate().then(function (canStartDraft) {
|
|
138
138
|
if (canStartDraft) {
|
|
139
139
|
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
|
|
@@ -20,8 +20,7 @@ var _editorCommands = require("../editor-commands");
|
|
|
20
20
|
var _utils3 = require("../pm-plugins/utils");
|
|
21
21
|
var _types = require("../types");
|
|
22
22
|
var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
|
|
23
|
-
function
|
|
24
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
25
24
|
var findPosForDOM = function findPosForDOM(sel) {
|
|
26
25
|
var $from = sel.$from,
|
|
27
26
|
from = sel.from;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { setInlineCommentDraftState, createAnnotation, setSelectedAnnotation, closeComponent, setHoveredAnnotation, removeInlineCommentFromDoc } from '../editor-commands';
|
|
6
5
|
import { AnnotationSelectionType } from '../types';
|
|
7
6
|
import { inlineCommentPluginKey, isSelectionValid } from './utils';
|
|
@@ -51,7 +50,7 @@ export const startDraft = (editorView, options) => () => {
|
|
|
51
50
|
reason: ERROR_REASON_DRAFT_IN_PROGRESS
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
|
-
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)
|
|
53
|
+
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
|
|
55
54
|
// if there are selected annotations when starting a draft, we need to clear the selected annotations
|
|
56
55
|
// before we start the draft.
|
|
57
56
|
closeComponent()(editorView.state, editorView.dispatch);
|
|
@@ -37,7 +37,7 @@ const fetchState = async (provider, annotationIds, editorView, editorAnalyticsAP
|
|
|
37
37
|
updateInlineCommentResolvedState(editorAnalyticsAPI)(inlineCommentStates)(editorView.state, editorView.dispatch);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) => {
|
|
40
|
+
const initialState = (disallowOnWhitespace = false, featureFlagsPluginState, isAnnotationManagerEnabled = false) => {
|
|
41
41
|
return {
|
|
42
42
|
annotations: {},
|
|
43
43
|
selectedAnnotations: [],
|
|
@@ -52,7 +52,8 @@ const initialState = (disallowOnWhitespace = false, featureFlagsPluginState) =>
|
|
|
52
52
|
featureFlagsPluginState,
|
|
53
53
|
isDrafting: false,
|
|
54
54
|
pendingSelectedAnnotations: [],
|
|
55
|
-
pendingSelectedAnnotationsUpdateCount: 0
|
|
55
|
+
pendingSelectedAnnotationsUpdateCount: 0,
|
|
56
|
+
isAnnotationManagerEnabled
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
59
|
const hideToolbar = (state, dispatch) => () => {
|
|
@@ -104,7 +105,7 @@ export const inlineCommentPlugin = options => {
|
|
|
104
105
|
} = options;
|
|
105
106
|
return new SafePlugin({
|
|
106
107
|
key: inlineCommentPluginKey,
|
|
107
|
-
state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState)),
|
|
108
|
+
state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
|
|
108
109
|
view(editorView) {
|
|
109
110
|
let allowAnnotationFn;
|
|
110
111
|
let startDraftFn;
|
|
@@ -114,25 +115,23 @@ export const inlineCommentPlugin = options => {
|
|
|
114
115
|
let setIsAnnotationSelectedFn;
|
|
115
116
|
let setIsAnnotationHoveredFn;
|
|
116
117
|
let clearAnnotationFn;
|
|
117
|
-
if (annotationManager
|
|
118
|
+
if (annotationManager) {
|
|
118
119
|
allowAnnotationFn = allowAnnotation(editorView, options);
|
|
119
120
|
startDraftFn = startDraft(editorView, options);
|
|
120
121
|
clearDraftFn = clearDraft(editorView, options);
|
|
121
122
|
applyDraftFn = applyDraft(editorView, options);
|
|
122
123
|
getDraftFn = getDraft(editorView, options);
|
|
124
|
+
setIsAnnotationSelectedFn = setIsAnnotationSelected(editorView, options);
|
|
125
|
+
setIsAnnotationHoveredFn = setIsAnnotationHovered(editorView, options);
|
|
126
|
+
clearAnnotationFn = clearAnnotation(editorView, options);
|
|
123
127
|
annotationManager.hook('allowAnnotation', allowAnnotationFn);
|
|
124
128
|
annotationManager.hook('startDraft', startDraftFn);
|
|
125
129
|
annotationManager.hook('clearDraft', clearDraftFn);
|
|
126
130
|
annotationManager.hook('applyDraft', applyDraftFn);
|
|
127
131
|
annotationManager.hook('getDraft', getDraftFn);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
clearAnnotationFn = clearAnnotation(editorView, options);
|
|
132
|
-
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
133
|
-
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
134
|
-
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
135
|
-
}
|
|
132
|
+
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
133
|
+
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
134
|
+
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
136
135
|
}
|
|
137
136
|
// Get initial state
|
|
138
137
|
// Need to pass `editorView` to mitigate editor state going stale
|
|
@@ -213,7 +212,7 @@ export const inlineCommentPlugin = options => {
|
|
|
213
212
|
// The selectComponentExperience is using a simplified object, which is why it's type asserted.
|
|
214
213
|
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 ? void 0 : _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
|
|
215
214
|
}
|
|
216
|
-
if (
|
|
215
|
+
if (annotationManager) {
|
|
217
216
|
// In the Editor, Annotations can be selected in three ways:
|
|
218
217
|
// 1. By clicking on the annotation in the editor
|
|
219
218
|
// 2. By using the annotation manager to select the annotation
|
|
@@ -233,7 +232,7 @@ export const inlineCommentPlugin = options => {
|
|
|
233
232
|
// Need to set a lock to avoid calling gate multiple times. The lock will be released
|
|
234
233
|
// when the preemptive gate is complete.
|
|
235
234
|
isPreemptiveGateActive = true;
|
|
236
|
-
annotationManager
|
|
235
|
+
annotationManager.checkPreemptiveGate().then(canSelectAnnotation => {
|
|
237
236
|
const {
|
|
238
237
|
isDrafting,
|
|
239
238
|
pendingSelectedAnnotations: latestPendingSelectedAnnotations,
|
|
@@ -249,8 +248,8 @@ export const inlineCommentPlugin = options => {
|
|
|
249
248
|
// Flush the pending selections into the selected annotations list.
|
|
250
249
|
flushPendingSelections(options.editorAnalyticsAPI)(true)(view.state, view.dispatch);
|
|
251
250
|
latestSelectedAnnotations === null || latestSelectedAnnotations === void 0 ? void 0 : latestSelectedAnnotations.filter(annotation => (latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 ? void 0 : latestPendingSelectedAnnotations.findIndex(pendingAnnotation => pendingAnnotation.id === annotation.id)) === -1).forEach(annotation => {
|
|
252
|
-
var
|
|
253
|
-
|
|
251
|
+
var _getAnnotationInlineN;
|
|
252
|
+
annotationManager.emit({
|
|
254
253
|
name: 'annotationSelectionChanged',
|
|
255
254
|
data: {
|
|
256
255
|
annotationId: annotation.id,
|
|
@@ -264,8 +263,8 @@ export const inlineCommentPlugin = options => {
|
|
|
264
263
|
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 ? void 0 : latestPendingSelectedAnnotations.forEach(({
|
|
265
264
|
id
|
|
266
265
|
}) => {
|
|
267
|
-
var
|
|
268
|
-
|
|
266
|
+
var _getAnnotationInlineN2;
|
|
267
|
+
annotationManager.emit({
|
|
269
268
|
name: 'annotationSelectionChanged',
|
|
270
269
|
data: {
|
|
271
270
|
annotationId: id,
|
|
@@ -303,7 +302,7 @@ export const inlineCommentPlugin = options => {
|
|
|
303
302
|
if (updateSubscriber) {
|
|
304
303
|
updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
|
|
305
304
|
}
|
|
306
|
-
if (annotationManager
|
|
305
|
+
if (annotationManager) {
|
|
307
306
|
annotationManager.unhook('allowAnnotation', allowAnnotationFn);
|
|
308
307
|
annotationManager.unhook('startDraft', startDraftFn);
|
|
309
308
|
annotationManager.unhook('clearDraft', clearDraftFn);
|
|
@@ -358,7 +357,7 @@ export const inlineCommentPlugin = options => {
|
|
|
358
357
|
if (!isUnresolved) {
|
|
359
358
|
return false;
|
|
360
359
|
}
|
|
361
|
-
if (
|
|
360
|
+
if (annotationManager) {
|
|
362
361
|
var _pluginState$pendingS;
|
|
363
362
|
// The manager disable setting the selected annotation on click because in the editor this is already
|
|
364
363
|
// handled by the selection update handler. When the manager is enabled, and a selection changes it's pushed into
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import reducer from './reducer';
|
|
6
5
|
import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from './utils';
|
|
7
6
|
const handleDocChanged = (tr, prevPluginState) => {
|
|
@@ -111,7 +110,6 @@ const getSelectionChangeHandlerNew = reopenCommentView => (tr, pluginState) => {
|
|
|
111
110
|
|
|
112
111
|
// NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
|
|
113
112
|
// if the selection is empty. If this is no longer needed, we can remove this code.
|
|
114
|
-
// clean up with platform_editor_comments_api_manager_select
|
|
115
113
|
// if (selectedAnnotations.length === 0) {
|
|
116
114
|
// return {
|
|
117
115
|
// ...pluginState,
|
|
@@ -141,7 +139,11 @@ const getSelectionChangeHandlerNew = reopenCommentView => (tr, pluginState) => {
|
|
|
141
139
|
selectAnnotationMethod: undefined
|
|
142
140
|
};
|
|
143
141
|
};
|
|
144
|
-
const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) =>
|
|
142
|
+
const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => pluginState.isAnnotationManagerEnabled ?
|
|
143
|
+
// if platform_editor_comments_api_manager == true
|
|
144
|
+
getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) :
|
|
145
|
+
// else if platform_editor_comments_api_manager == false
|
|
146
|
+
getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
|
|
145
147
|
export const {
|
|
146
148
|
createPluginState,
|
|
147
149
|
createCommand
|
|
@@ -35,7 +35,7 @@ export default ((pluginState, action) => {
|
|
|
35
35
|
...(fg('platform_editor_annotation_selected_annotation') && {
|
|
36
36
|
selectedAnnotations: []
|
|
37
37
|
}),
|
|
38
|
-
...(
|
|
38
|
+
...(pluginState.isAnnotationManagerEnabled && {
|
|
39
39
|
selectedAnnotations: []
|
|
40
40
|
})
|
|
41
41
|
};
|
|
@@ -50,7 +50,7 @@ export default ((pluginState, action) => {
|
|
|
50
50
|
},
|
|
51
51
|
isInlineCommentViewClosed: false,
|
|
52
52
|
selectAnnotationMethod: undefined,
|
|
53
|
-
...(
|
|
53
|
+
...(pluginState.isAnnotationManagerEnabled && {
|
|
54
54
|
skipSelectionHandling: true
|
|
55
55
|
})
|
|
56
56
|
};
|
|
@@ -131,7 +131,7 @@ export const buildToolbar = editorAnalyticsAPI => ({
|
|
|
131
131
|
pageMode: 'edit'
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
if (annotationManager
|
|
134
|
+
if (annotationManager) {
|
|
135
135
|
annotationManager.checkPreemptiveGate().then(canStartDraft => {
|
|
136
136
|
if (canStartDraft) {
|
|
137
137
|
createCommentExperience === null || createCommentExperience === void 0 ? void 0 : createCommentExperience.start({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { setInlineCommentDraftState, createAnnotation, setSelectedAnnotation, closeComponent, setHoveredAnnotation, removeInlineCommentFromDoc } from '../editor-commands';
|
|
6
5
|
import { AnnotationSelectionType } from '../types';
|
|
7
6
|
import { inlineCommentPluginKey, isSelectionValid } from './utils';
|
|
@@ -52,7 +51,7 @@ export var startDraft = function startDraft(editorView, options) {
|
|
|
52
51
|
reason: ERROR_REASON_DRAFT_IN_PROGRESS
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
|
-
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)
|
|
54
|
+
if (!!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.length)) {
|
|
56
55
|
// if there are selected annotations when starting a draft, we need to clear the selected annotations
|
|
57
56
|
// before we start the draft.
|
|
58
57
|
closeComponent()(editorView.state, editorView.dispatch);
|
|
@@ -86,6 +86,7 @@ var fetchState = /*#__PURE__*/function () {
|
|
|
86
86
|
var initialState = function initialState() {
|
|
87
87
|
var disallowOnWhitespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
88
88
|
var featureFlagsPluginState = arguments.length > 1 ? arguments[1] : undefined;
|
|
89
|
+
var isAnnotationManagerEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
89
90
|
return {
|
|
90
91
|
annotations: {},
|
|
91
92
|
selectedAnnotations: [],
|
|
@@ -100,7 +101,8 @@ var initialState = function initialState() {
|
|
|
100
101
|
featureFlagsPluginState: featureFlagsPluginState,
|
|
101
102
|
isDrafting: false,
|
|
102
103
|
pendingSelectedAnnotations: [],
|
|
103
|
-
pendingSelectedAnnotationsUpdateCount: 0
|
|
104
|
+
pendingSelectedAnnotationsUpdateCount: 0,
|
|
105
|
+
isAnnotationManagerEnabled: isAnnotationManagerEnabled
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
var hideToolbar = function hideToolbar(state, dispatch) {
|
|
@@ -157,7 +159,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
157
159
|
annotationManager = options.annotationManager;
|
|
158
160
|
return new SafePlugin({
|
|
159
161
|
key: inlineCommentPluginKey,
|
|
160
|
-
state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState)),
|
|
162
|
+
state: createPluginState(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
|
|
161
163
|
view: function view(editorView) {
|
|
162
164
|
var allowAnnotationFn;
|
|
163
165
|
var startDraftFn;
|
|
@@ -167,25 +169,23 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
167
169
|
var setIsAnnotationSelectedFn;
|
|
168
170
|
var setIsAnnotationHoveredFn;
|
|
169
171
|
var clearAnnotationFn;
|
|
170
|
-
if (annotationManager
|
|
172
|
+
if (annotationManager) {
|
|
171
173
|
allowAnnotationFn = allowAnnotation(editorView, options);
|
|
172
174
|
startDraftFn = startDraft(editorView, options);
|
|
173
175
|
clearDraftFn = clearDraft(editorView, options);
|
|
174
176
|
applyDraftFn = applyDraft(editorView, options);
|
|
175
177
|
getDraftFn = getDraft(editorView, options);
|
|
178
|
+
setIsAnnotationSelectedFn = setIsAnnotationSelected(editorView, options);
|
|
179
|
+
setIsAnnotationHoveredFn = setIsAnnotationHovered(editorView, options);
|
|
180
|
+
clearAnnotationFn = clearAnnotation(editorView, options);
|
|
176
181
|
annotationManager.hook('allowAnnotation', allowAnnotationFn);
|
|
177
182
|
annotationManager.hook('startDraft', startDraftFn);
|
|
178
183
|
annotationManager.hook('clearDraft', clearDraftFn);
|
|
179
184
|
annotationManager.hook('applyDraft', applyDraftFn);
|
|
180
185
|
annotationManager.hook('getDraft', getDraftFn);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
clearAnnotationFn = clearAnnotation(editorView, options);
|
|
185
|
-
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
186
|
-
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
187
|
-
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
188
|
-
}
|
|
186
|
+
annotationManager.hook('setIsAnnotationSelected', setIsAnnotationSelectedFn);
|
|
187
|
+
annotationManager.hook('setIsAnnotationHovered', setIsAnnotationHoveredFn);
|
|
188
|
+
annotationManager.hook('clearAnnotation', clearAnnotationFn);
|
|
189
189
|
}
|
|
190
190
|
// Get initial state
|
|
191
191
|
// Need to pass `editorView` to mitigate editor state going stale
|
|
@@ -270,7 +270,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
270
270
|
// The selectComponentExperience is using a simplified object, which is why it's type asserted.
|
|
271
271
|
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotationId);
|
|
272
272
|
}
|
|
273
|
-
if (
|
|
273
|
+
if (annotationManager) {
|
|
274
274
|
// In the Editor, Annotations can be selected in three ways:
|
|
275
275
|
// 1. By clicking on the annotation in the editor
|
|
276
276
|
// 2. By using the annotation manager to select the annotation
|
|
@@ -288,7 +288,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
288
288
|
// Need to set a lock to avoid calling gate multiple times. The lock will be released
|
|
289
289
|
// when the preemptive gate is complete.
|
|
290
290
|
isPreemptiveGateActive = true;
|
|
291
|
-
annotationManager
|
|
291
|
+
annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
|
|
292
292
|
var _ref8 = getPluginState(view.state) || {},
|
|
293
293
|
isDrafting = _ref8.isDrafting,
|
|
294
294
|
latestPendingSelectedAnnotations = _ref8.pendingSelectedAnnotations,
|
|
@@ -307,8 +307,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
307
307
|
return pendingAnnotation.id === annotation.id;
|
|
308
308
|
})) === -1;
|
|
309
309
|
}).forEach(function (annotation) {
|
|
310
|
-
var
|
|
311
|
-
|
|
310
|
+
var _getAnnotationInlineN;
|
|
311
|
+
annotationManager.emit({
|
|
312
312
|
name: 'annotationSelectionChanged',
|
|
313
313
|
data: {
|
|
314
314
|
annotationId: annotation.id,
|
|
@@ -320,9 +320,9 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
320
320
|
|
|
321
321
|
// Notify the annotation manager that the pending selection has changed.
|
|
322
322
|
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref9) {
|
|
323
|
-
var
|
|
323
|
+
var _getAnnotationInlineN2;
|
|
324
324
|
var id = _ref9.id;
|
|
325
|
-
|
|
325
|
+
annotationManager.emit({
|
|
326
326
|
name: 'annotationSelectionChanged',
|
|
327
327
|
data: {
|
|
328
328
|
annotationId: id,
|
|
@@ -345,8 +345,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
345
345
|
});
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
var
|
|
349
|
-
dirtyAnnotations =
|
|
348
|
+
var _ref0 = getPluginState(view.state) || {},
|
|
349
|
+
dirtyAnnotations = _ref0.dirtyAnnotations;
|
|
350
350
|
if (!dirtyAnnotations) {
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
@@ -359,7 +359,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
359
359
|
if (updateSubscriber) {
|
|
360
360
|
updateSubscriber.off('resolve', resolve).off('delete', resolve).off('unresolve', unResolve).off('create', unResolve).off('setvisibility', setVisibility).off('setselectedannotation', setSelectedAnnotationFn).off('sethoveredannotation', setHoveredAnnotationFn).off('removehoveredannotation', removeHoveredannotationFn).off('closeinlinecomment', closeInlineCommentFn);
|
|
361
361
|
}
|
|
362
|
-
if (annotationManager
|
|
362
|
+
if (annotationManager) {
|
|
363
363
|
annotationManager.unhook('allowAnnotation', allowAnnotationFn);
|
|
364
364
|
annotationManager.unhook('startDraft', startDraftFn);
|
|
365
365
|
annotationManager.unhook('clearDraft', clearDraftFn);
|
|
@@ -409,13 +409,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
409
409
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
410
410
|
return false;
|
|
411
411
|
}
|
|
412
|
-
var
|
|
413
|
-
annotations =
|
|
412
|
+
var _ref1 = pluginState || {},
|
|
413
|
+
annotations = _ref1.annotations;
|
|
414
414
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
415
415
|
if (!isUnresolved) {
|
|
416
416
|
return false;
|
|
417
417
|
}
|
|
418
|
-
if (
|
|
418
|
+
if (annotationManager) {
|
|
419
419
|
var _pluginState$pendingS;
|
|
420
420
|
// The manager disable setting the selected annotation on click because in the editor this is already
|
|
421
421
|
// handled by the selection update handler. When the manager is enabled, and a selection changes it's pushed into
|
|
@@ -438,13 +438,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
438
438
|
},
|
|
439
439
|
decorations: function decorations(state) {
|
|
440
440
|
// highlight comments, depending on state
|
|
441
|
-
var
|
|
442
|
-
draftDecorationSet =
|
|
443
|
-
annotations =
|
|
444
|
-
selectedAnnotations =
|
|
445
|
-
isVisible =
|
|
446
|
-
isInlineCommentViewClosed =
|
|
447
|
-
hoveredAnnotations =
|
|
441
|
+
var _ref10 = getPluginState(state) || {},
|
|
442
|
+
draftDecorationSet = _ref10.draftDecorationSet,
|
|
443
|
+
annotations = _ref10.annotations,
|
|
444
|
+
selectedAnnotations = _ref10.selectedAnnotations,
|
|
445
|
+
isVisible = _ref10.isVisible,
|
|
446
|
+
isInlineCommentViewClosed = _ref10.isInlineCommentViewClosed,
|
|
447
|
+
hoveredAnnotations = _ref10.hoveredAnnotations;
|
|
448
448
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
|
|
449
449
|
var focusDecorations = [];
|
|
450
450
|
|
|
@@ -4,7 +4,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import reducer from './reducer';
|
|
9
8
|
import { decorationKey, findAnnotationsInSelection, inlineCommentPluginKey, isBlockNodeAnnotationsSelected, isSelectedAnnotationsChanged } from './utils';
|
|
10
9
|
var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
|
|
@@ -104,7 +103,6 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
|
|
|
104
103
|
|
|
105
104
|
// NOTE: I've left this commented code here as a reference that the previous old code would reset the selected annotations
|
|
106
105
|
// if the selection is empty. If this is no longer needed, we can remove this code.
|
|
107
|
-
// clean up with platform_editor_comments_api_manager_select
|
|
108
106
|
// if (selectedAnnotations.length === 0) {
|
|
109
107
|
// return {
|
|
110
108
|
// ...pluginState,
|
|
@@ -133,7 +131,11 @@ var getSelectionChangeHandlerNew = function getSelectionChangeHandlerNew(reopenC
|
|
|
133
131
|
};
|
|
134
132
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
135
133
|
return function (tr, pluginState) {
|
|
136
|
-
return
|
|
134
|
+
return pluginState.isAnnotationManagerEnabled ?
|
|
135
|
+
// if platform_editor_comments_api_manager == true
|
|
136
|
+
getSelectionChangeHandlerNew(reopenCommentView)(tr, pluginState) :
|
|
137
|
+
// else if platform_editor_comments_api_manager == false
|
|
138
|
+
getSelectionChangeHandlerOld(reopenCommentView)(tr, pluginState);
|
|
137
139
|
};
|
|
138
140
|
};
|
|
139
141
|
var _pluginFactory = pluginFactory(inlineCommentPluginKey, reducer, {
|
|
@@ -31,7 +31,7 @@ export default (function (pluginState, action) {
|
|
|
31
31
|
isOpeningMediaCommentFromToolbar: false
|
|
32
32
|
}, fg('platform_editor_annotation_selected_annotation') && {
|
|
33
33
|
selectedAnnotations: []
|
|
34
|
-
}),
|
|
34
|
+
}), pluginState.isAnnotationManagerEnabled && {
|
|
35
35
|
selectedAnnotations: []
|
|
36
36
|
});
|
|
37
37
|
case ACTIONS.ADD_INLINE_COMMENT:
|
|
@@ -41,7 +41,7 @@ export default (function (pluginState, action) {
|
|
|
41
41
|
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
|
|
42
42
|
isInlineCommentViewClosed: false,
|
|
43
43
|
selectAnnotationMethod: undefined
|
|
44
|
-
},
|
|
44
|
+
}, pluginState.isAnnotationManagerEnabled && {
|
|
45
45
|
skipSelectionHandling: true
|
|
46
46
|
});
|
|
47
47
|
case ACTIONS.INLINE_COMMENT_SET_VISIBLE:
|
|
@@ -126,7 +126,7 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
126
126
|
pageMode: 'edit'
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
|
-
if (annotationManager
|
|
129
|
+
if (annotationManager) {
|
|
130
130
|
annotationManager.checkPreemptiveGate().then(function (canStartDraft) {
|
|
131
131
|
if (canStartDraft) {
|
|
132
132
|
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
|
|
@@ -162,4 +162,8 @@ export type InlineCommentPluginState = {
|
|
|
162
162
|
* if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
|
|
163
163
|
*/
|
|
164
164
|
pendingSelectedAnnotationsUpdateCount: number;
|
|
165
|
+
/**
|
|
166
|
+
* A simple toggle to indicate if the annotation manager is enabled.
|
|
167
|
+
*/
|
|
168
|
+
isAnnotationManagerEnabled: boolean;
|
|
165
169
|
};
|
|
@@ -162,4 +162,8 @@ export type InlineCommentPluginState = {
|
|
|
162
162
|
* if the pendingSelectedAnnotations has been updated since the last time it was flushed to selectedAnnotations.
|
|
163
163
|
*/
|
|
164
164
|
pendingSelectedAnnotationsUpdateCount: number;
|
|
165
|
+
/**
|
|
166
|
+
* A simple toggle to indicate if the annotation manager is enabled.
|
|
167
|
+
*/
|
|
168
|
+
isAnnotationManagerEnabled: boolean;
|
|
165
169
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
36
|
-
"@atlaskit/editor-common": "^106.
|
|
36
|
+
"@atlaskit/editor-common": "^106.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@atlaskit/icon": "^26.4.0",
|
|
43
43
|
"@atlaskit/onboarding": "^14.2.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^5.
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^5.7.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -97,9 +97,6 @@
|
|
|
97
97
|
"platform_editor_comments_api_manager": {
|
|
98
98
|
"type": "boolean"
|
|
99
99
|
},
|
|
100
|
-
"platform_editor_comments_api_manager_select": {
|
|
101
|
-
"type": "boolean"
|
|
102
|
-
},
|
|
103
100
|
"editor_inline_comments_on_inline_nodes": {
|
|
104
101
|
"type": "boolean"
|
|
105
102
|
},
|