@atlaskit/editor-plugin-annotation 1.0.2 → 1.1.0
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 +6 -0
- package/dist/cjs/pm-plugins/inline-comment.js +1 -4
- package/dist/cjs/pm-plugins/plugin-factory.js +1 -33
- package/dist/cjs/pm-plugins/reducer.js +3 -9
- package/dist/cjs/ui/InlineCommentView.js +1 -2
- package/dist/es2019/pm-plugins/inline-comment.js +1 -2
- package/dist/es2019/pm-plugins/plugin-factory.js +1 -33
- package/dist/es2019/pm-plugins/reducer.js +3 -12
- package/dist/es2019/ui/InlineCommentView.js +1 -2
- package/dist/esm/pm-plugins/inline-comment.js +1 -4
- package/dist/esm/pm-plugins/plugin-factory.js +1 -33
- package/dist/esm/pm-plugins/reducer.js +3 -9
- package/dist/esm/ui/InlineCommentView.js +1 -2
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#78363](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78363) [`3a8e207fbf7c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3a8e207fbf7c) - EDF-27 Cleaned up platform.editor.annotation.decouple-inline-comment-closed_flmox FF. This decouples selected annotation logic from logic to close the inline comment view by default. This fixed a bug where the inline comment view can be unexpectedly opened from doc changes (through remote editors or non-selection altering changes such as expanding / collapsing expand blocks)
|
|
8
|
+
|
|
3
9
|
## 1.0.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -12,7 +12,6 @@ var _adfSchema = require("@atlaskit/adf-schema");
|
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
14
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _commands = require("../commands");
|
|
17
16
|
var _nodeviews = require("../nodeviews");
|
|
18
17
|
var _utils = require("../utils");
|
|
@@ -224,9 +223,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
224
223
|
node.marks.filter(function (mark) {
|
|
225
224
|
return mark.type === state.schema.marks.annotation;
|
|
226
225
|
}).forEach(function (mark) {
|
|
227
|
-
var isSelected =
|
|
228
|
-
return selectedAnnotation.id === mark.attrs.id;
|
|
229
|
-
})) : !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
226
|
+
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
230
227
|
return selectedAnnotation.id === mark.attrs.id;
|
|
231
228
|
}));
|
|
232
229
|
var isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
@@ -7,52 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.createPluginState = exports.createCommand = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _utils2 = require("../utils");
|
|
12
11
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
13
12
|
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; }
|
|
14
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
14
|
var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
|
|
16
15
|
if (!tr.getMeta('replaceDocument')) {
|
|
17
|
-
return
|
|
16
|
+
return getSelectionChangedHandler(false)(tr, prevPluginState);
|
|
18
17
|
}
|
|
19
18
|
return _objectSpread(_objectSpread({}, prevPluginState), {}, {
|
|
20
19
|
dirtyAnnotations: true
|
|
21
20
|
});
|
|
22
21
|
};
|
|
23
|
-
var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
|
|
24
|
-
if (pluginState.skipSelectionHandling) {
|
|
25
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
26
|
-
skipSelectionHandling: false
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
var selectedAnnotations = (0, _utils2.findAnnotationsInSelection)(tr.selection, tr.doc);
|
|
30
|
-
var changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(function (annotationInfo) {
|
|
31
|
-
return !pluginState.selectedAnnotations.some(function (aInfo) {
|
|
32
|
-
return aInfo.type === annotationInfo.id;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
if (changed) {
|
|
36
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
37
|
-
selectedAnnotations: selectedAnnotations
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return pluginState;
|
|
41
|
-
};
|
|
42
22
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
43
23
|
return function (tr, pluginState) {
|
|
44
|
-
/**
|
|
45
|
-
* If feature flag is **OFF** we want to keep the old behavior. Note that
|
|
46
|
-
* reopenCommentView is not relevant here when using old behaviour.
|
|
47
|
-
*
|
|
48
|
-
* Feature flag is evaluated here rather than directly in onSelectionChanged where it is assigned
|
|
49
|
-
* to prevent the plugin from setting up the handler before the feature flag is evaluated.
|
|
50
|
-
*
|
|
51
|
-
* This comment / logic can be cleaned up once the feature flag is removed.
|
|
52
|
-
*/
|
|
53
|
-
if (!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox')) {
|
|
54
|
-
return handleSelectionChanged(tr, pluginState);
|
|
55
|
-
}
|
|
56
24
|
if (pluginState.skipSelectionHandling) {
|
|
57
25
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
58
26
|
skipSelectionHandling: false
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
11
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
11
|
var _utils = require("../utils");
|
|
13
12
|
var _types = require("./types");
|
|
14
13
|
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; }
|
|
@@ -32,17 +31,14 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
32
31
|
annotations: {}
|
|
33
32
|
});
|
|
34
33
|
case _types.ACTIONS.CLOSE_COMPONENT:
|
|
35
|
-
return
|
|
34
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
36
35
|
isInlineCommentViewClosed: true
|
|
37
|
-
}) : _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
|
-
selectedAnnotations: []
|
|
39
36
|
});
|
|
40
37
|
case _types.ACTIONS.ADD_INLINE_COMMENT:
|
|
41
38
|
var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
42
39
|
return _objectSpread(_objectSpread({}, updatedPluginState), {}, {
|
|
43
40
|
selectedAnnotations: [].concat((0, _toConsumableArray2.default)(updatedPluginState.selectedAnnotations), (0, _toConsumableArray2.default)(action.data.selectedAnnotations)),
|
|
44
|
-
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments)
|
|
45
|
-
}, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
|
|
41
|
+
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
|
|
46
42
|
isInlineCommentViewClosed: false
|
|
47
43
|
});
|
|
48
44
|
case _types.ACTIONS.INLINE_COMMENT_SET_VISIBLE:
|
|
@@ -56,9 +52,7 @@ var _default = exports.default = function _default(pluginState, action) {
|
|
|
56
52
|
case _types.ACTIONS.SET_SELECTED_ANNOTATION:
|
|
57
53
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
58
54
|
selectedAnnotations: (0, _toConsumableArray2.default)(action.data.selectedAnnotations),
|
|
59
|
-
skipSelectionHandling: true
|
|
60
|
-
}, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
|
|
61
|
-
// if selecting annotation explicitly, reopen the comment view
|
|
55
|
+
skipSelectionHandling: true,
|
|
62
56
|
isInlineCommentViewClosed: false
|
|
63
57
|
});
|
|
64
58
|
default:
|
|
@@ -9,7 +9,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
12
|
var _commands = require("../commands");
|
|
14
13
|
var _types = require("../types");
|
|
15
14
|
var _utils2 = require("../utils");
|
|
@@ -125,7 +124,7 @@ function InlineCommentView(_ref) {
|
|
|
125
124
|
};
|
|
126
125
|
dispatchAnalyticsEvent(payload);
|
|
127
126
|
};
|
|
128
|
-
if (
|
|
127
|
+
if (isInlineCommentViewClosed || !selectedAnnotations) {
|
|
129
128
|
return null;
|
|
130
129
|
}
|
|
131
130
|
return /*#__PURE__*/_react.default.createElement(_AnnotationViewWrapper.AnnotationViewWrapper, {
|
|
@@ -2,7 +2,6 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
|
2
2
|
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
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
|
|
7
6
|
import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
|
|
8
7
|
import { getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
|
|
@@ -163,7 +162,7 @@ export const inlineCommentPlugin = options => {
|
|
|
163
162
|
const focusDecorations = [];
|
|
164
163
|
state.doc.descendants((node, pos) => {
|
|
165
164
|
node.marks.filter(mark => mark.type === state.schema.marks.annotation).forEach(mark => {
|
|
166
|
-
const isSelected =
|
|
165
|
+
const isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(selectedAnnotation => selectedAnnotation.id === mark.attrs.id));
|
|
167
166
|
const isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
168
167
|
if (isVisible) {
|
|
169
168
|
focusDecorations.push(Decoration.inline(pos, pos + node.nodeSize, {
|
|
@@ -1,48 +1,16 @@
|
|
|
1
1
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { findAnnotationsInSelection, inlineCommentPluginKey, isSelectedAnnotationsChanged } from '../utils';
|
|
4
3
|
import reducer from './reducer';
|
|
5
4
|
const handleDocChanged = (tr, prevPluginState) => {
|
|
6
5
|
if (!tr.getMeta('replaceDocument')) {
|
|
7
|
-
return
|
|
6
|
+
return getSelectionChangedHandler(false)(tr, prevPluginState);
|
|
8
7
|
}
|
|
9
8
|
return {
|
|
10
9
|
...prevPluginState,
|
|
11
10
|
dirtyAnnotations: true
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
const handleSelectionChanged = (tr, pluginState) => {
|
|
15
|
-
if (pluginState.skipSelectionHandling) {
|
|
16
|
-
return {
|
|
17
|
-
...pluginState,
|
|
18
|
-
skipSelectionHandling: false
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
22
|
-
const changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(annotationInfo => {
|
|
23
|
-
return !pluginState.selectedAnnotations.some(aInfo => aInfo.type === annotationInfo.id);
|
|
24
|
-
});
|
|
25
|
-
if (changed) {
|
|
26
|
-
return {
|
|
27
|
-
...pluginState,
|
|
28
|
-
selectedAnnotations
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return pluginState;
|
|
32
|
-
};
|
|
33
13
|
const getSelectionChangedHandler = reopenCommentView => (tr, pluginState) => {
|
|
34
|
-
/**
|
|
35
|
-
* If feature flag is **OFF** we want to keep the old behavior. Note that
|
|
36
|
-
* reopenCommentView is not relevant here when using old behaviour.
|
|
37
|
-
*
|
|
38
|
-
* Feature flag is evaluated here rather than directly in onSelectionChanged where it is assigned
|
|
39
|
-
* to prevent the plugin from setting up the handler before the feature flag is evaluated.
|
|
40
|
-
*
|
|
41
|
-
* This comment / logic can be cleaned up once the feature flag is removed.
|
|
42
|
-
*/
|
|
43
|
-
if (!getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox')) {
|
|
44
|
-
return handleSelectionChanged(tr, pluginState);
|
|
45
|
-
}
|
|
46
14
|
if (pluginState.skipSelectionHandling) {
|
|
47
15
|
return {
|
|
48
16
|
...pluginState,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
2
|
import { addDraftDecoration } from '../utils';
|
|
4
3
|
import { ACTIONS } from './types';
|
|
5
4
|
export default ((pluginState, action) => {
|
|
@@ -27,12 +26,9 @@ export default ((pluginState, action) => {
|
|
|
27
26
|
annotations: {}
|
|
28
27
|
};
|
|
29
28
|
case ACTIONS.CLOSE_COMPONENT:
|
|
30
|
-
return
|
|
29
|
+
return {
|
|
31
30
|
...pluginState,
|
|
32
31
|
isInlineCommentViewClosed: true
|
|
33
|
-
} : {
|
|
34
|
-
...pluginState,
|
|
35
|
-
selectedAnnotations: []
|
|
36
32
|
};
|
|
37
33
|
case ACTIONS.ADD_INLINE_COMMENT:
|
|
38
34
|
const updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
@@ -43,9 +39,7 @@ export default ((pluginState, action) => {
|
|
|
43
39
|
...pluginState.annotations,
|
|
44
40
|
...action.data.inlineComments
|
|
45
41
|
},
|
|
46
|
-
|
|
47
|
-
isInlineCommentViewClosed: false
|
|
48
|
-
})
|
|
42
|
+
isInlineCommentViewClosed: false
|
|
49
43
|
};
|
|
50
44
|
case ACTIONS.INLINE_COMMENT_SET_VISIBLE:
|
|
51
45
|
const {
|
|
@@ -63,10 +57,7 @@ export default ((pluginState, action) => {
|
|
|
63
57
|
...pluginState,
|
|
64
58
|
selectedAnnotations: [...action.data.selectedAnnotations],
|
|
65
59
|
skipSelectionHandling: true,
|
|
66
|
-
|
|
67
|
-
// if selecting annotation explicitly, reopen the comment view
|
|
68
|
-
isInlineCommentViewClosed: false
|
|
69
|
-
})
|
|
60
|
+
isInlineCommentViewClosed: false
|
|
70
61
|
};
|
|
71
62
|
default:
|
|
72
63
|
return pluginState;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
|
|
6
5
|
import { AnnotationTestIds } from '../types';
|
|
7
6
|
import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../utils';
|
|
@@ -123,7 +122,7 @@ export function InlineCommentView({
|
|
|
123
122
|
};
|
|
124
123
|
dispatchAnalyticsEvent(payload);
|
|
125
124
|
};
|
|
126
|
-
if (
|
|
125
|
+
if (isInlineCommentViewClosed || !selectedAnnotations) {
|
|
127
126
|
return null;
|
|
128
127
|
}
|
|
129
128
|
return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
|
|
@@ -5,7 +5,6 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
|
5
5
|
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
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { clearDirtyMark, closeComponent, setInlineCommentsVisibility, setSelectedAnnotation, updateInlineCommentResolvedState, updateMouseState } from '../commands';
|
|
10
9
|
import { AnnotationNodeView, getAnnotationViewClassname } from '../nodeviews';
|
|
11
10
|
import { getAllAnnotations, getPluginState, inlineCommentPluginKey } from '../utils';
|
|
@@ -217,9 +216,7 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
217
216
|
node.marks.filter(function (mark) {
|
|
218
217
|
return mark.type === state.schema.marks.annotation;
|
|
219
218
|
}).forEach(function (mark) {
|
|
220
|
-
var isSelected =
|
|
221
|
-
return selectedAnnotation.id === mark.attrs.id;
|
|
222
|
-
})) : !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
219
|
+
var isSelected = !isInlineCommentViewClosed && !!(selectedAnnotations !== null && selectedAnnotations !== void 0 && selectedAnnotations.some(function (selectedAnnotation) {
|
|
223
220
|
return selectedAnnotation.id === mark.attrs.id;
|
|
224
221
|
}));
|
|
225
222
|
var isUnresolved = !!annotations && annotations[mark.attrs.id] === false;
|
|
@@ -2,50 +2,18 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { findAnnotationsInSelection, inlineCommentPluginKey, isSelectedAnnotationsChanged } from '../utils';
|
|
7
6
|
import reducer from './reducer';
|
|
8
7
|
var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
|
|
9
8
|
if (!tr.getMeta('replaceDocument')) {
|
|
10
|
-
return
|
|
9
|
+
return getSelectionChangedHandler(false)(tr, prevPluginState);
|
|
11
10
|
}
|
|
12
11
|
return _objectSpread(_objectSpread({}, prevPluginState), {}, {
|
|
13
12
|
dirtyAnnotations: true
|
|
14
13
|
});
|
|
15
14
|
};
|
|
16
|
-
var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
|
|
17
|
-
if (pluginState.skipSelectionHandling) {
|
|
18
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
19
|
-
skipSelectionHandling: false
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
23
|
-
var changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(function (annotationInfo) {
|
|
24
|
-
return !pluginState.selectedAnnotations.some(function (aInfo) {
|
|
25
|
-
return aInfo.type === annotationInfo.id;
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
if (changed) {
|
|
29
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
30
|
-
selectedAnnotations: selectedAnnotations
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return pluginState;
|
|
34
|
-
};
|
|
35
15
|
var getSelectionChangedHandler = function getSelectionChangedHandler(reopenCommentView) {
|
|
36
16
|
return function (tr, pluginState) {
|
|
37
|
-
/**
|
|
38
|
-
* If feature flag is **OFF** we want to keep the old behavior. Note that
|
|
39
|
-
* reopenCommentView is not relevant here when using old behaviour.
|
|
40
|
-
*
|
|
41
|
-
* Feature flag is evaluated here rather than directly in onSelectionChanged where it is assigned
|
|
42
|
-
* to prevent the plugin from setting up the handler before the feature flag is evaluated.
|
|
43
|
-
*
|
|
44
|
-
* This comment / logic can be cleaned up once the feature flag is removed.
|
|
45
|
-
*/
|
|
46
|
-
if (!getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox')) {
|
|
47
|
-
return handleSelectionChanged(tr, pluginState);
|
|
48
|
-
}
|
|
49
17
|
if (pluginState.skipSelectionHandling) {
|
|
50
18
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
51
19
|
skipSelectionHandling: false
|
|
@@ -3,7 +3,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
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; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { addDraftDecoration } from '../utils';
|
|
8
7
|
import { ACTIONS } from './types';
|
|
9
8
|
export default (function (pluginState, action) {
|
|
@@ -25,17 +24,14 @@ export default (function (pluginState, action) {
|
|
|
25
24
|
annotations: {}
|
|
26
25
|
});
|
|
27
26
|
case ACTIONS.CLOSE_COMPONENT:
|
|
28
|
-
return
|
|
27
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
29
28
|
isInlineCommentViewClosed: true
|
|
30
|
-
}) : _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
31
|
-
selectedAnnotations: []
|
|
32
29
|
});
|
|
33
30
|
case ACTIONS.ADD_INLINE_COMMENT:
|
|
34
31
|
var updatedPluginState = getNewDraftState(pluginState, action.data.drafting, action.data.editorState);
|
|
35
32
|
return _objectSpread(_objectSpread({}, updatedPluginState), {}, {
|
|
36
33
|
selectedAnnotations: [].concat(_toConsumableArray(updatedPluginState.selectedAnnotations), _toConsumableArray(action.data.selectedAnnotations)),
|
|
37
|
-
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments)
|
|
38
|
-
}, getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
|
|
34
|
+
annotations: _objectSpread(_objectSpread({}, pluginState.annotations), action.data.inlineComments),
|
|
39
35
|
isInlineCommentViewClosed: false
|
|
40
36
|
});
|
|
41
37
|
case ACTIONS.INLINE_COMMENT_SET_VISIBLE:
|
|
@@ -49,9 +45,7 @@ export default (function (pluginState, action) {
|
|
|
49
45
|
case ACTIONS.SET_SELECTED_ANNOTATION:
|
|
50
46
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
51
47
|
selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations),
|
|
52
|
-
skipSelectionHandling: true
|
|
53
|
-
}, getBooleanFF('platform.editor.annotation.decouple-inline-comment-closed_flmox') && {
|
|
54
|
-
// if selecting annotation explicitly, reopen the comment view
|
|
48
|
+
skipSelectionHandling: true,
|
|
55
49
|
isInlineCommentViewClosed: false
|
|
56
50
|
});
|
|
57
51
|
default:
|
|
@@ -2,7 +2,6 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
|
|
7
6
|
import { AnnotationTestIds } from '../types';
|
|
8
7
|
import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../utils';
|
|
@@ -118,7 +117,7 @@ export function InlineCommentView(_ref) {
|
|
|
118
117
|
};
|
|
119
118
|
dispatchAnalyticsEvent(payload);
|
|
120
119
|
};
|
|
121
|
-
if (
|
|
120
|
+
if (isInlineCommentViewClosed || !selectedAnnotations) {
|
|
122
121
|
return null;
|
|
123
122
|
}
|
|
124
123
|
return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -93,9 +93,6 @@
|
|
|
93
93
|
},
|
|
94
94
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
95
95
|
"platform-feature-flags": {
|
|
96
|
-
"platform.editor.annotation.decouple-inline-comment-closed_flmox": {
|
|
97
|
-
"type": "boolean"
|
|
98
|
-
},
|
|
99
96
|
"platform.editor.enable-selection-toolbar_ucdwd": {
|
|
100
97
|
"type": "boolean"
|
|
101
98
|
}
|