@atlaskit/editor-plugin-annotation 5.1.0 → 5.2.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 +12 -0
- package/dist/cjs/ui/CommentButton/CommentButton.js +32 -12
- package/dist/cjs/ui/CommentButton/utils.js +16 -6
- package/dist/es2019/ui/CommentButton/CommentButton.js +33 -12
- package/dist/es2019/ui/CommentButton/utils.js +12 -4
- package/dist/esm/ui/CommentButton/CommentButton.js +32 -12
- package/dist/esm/ui/CommentButton/utils.js +15 -6
- package/dist/types/ui/CommentButton/hooks.d.ts +1 -1
- package/dist/types/ui/CommentButton/utils.d.ts +4 -3
- package/dist/types-ts4.5/ui/CommentButton/hooks.d.ts +1 -1
- package/dist/types-ts4.5/ui/CommentButton/utils.d.ts +4 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 5.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`66414cddf2784`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/66414cddf2784) -
|
|
8
|
+
Add new platform_editor_toolbar_aifc_fix_editor_view experiment, replace destructured objects with
|
|
9
|
+
direct property access
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 5.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -13,17 +13,20 @@ var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
|
13
13
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
14
14
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
17
|
var _utils = require("../../pm-plugins/utils");
|
|
17
18
|
var _types = require("../../types");
|
|
18
19
|
var _hooks = require("./hooks");
|
|
19
20
|
var _utils2 = require("./utils");
|
|
20
21
|
var CommentButton = exports.CommentButton = function CommentButton(_ref) {
|
|
22
|
+
var _annotationProviders$;
|
|
21
23
|
var api = _ref.api,
|
|
22
24
|
annotationProviders = _ref.annotationProviders;
|
|
23
25
|
var isVisible = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible');
|
|
24
26
|
var bookmark = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.bookmark');
|
|
25
27
|
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
26
28
|
editorView = _useEditorToolbar.editorView;
|
|
29
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
27
30
|
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
28
31
|
state: null,
|
|
29
32
|
dispatch: null
|
|
@@ -31,8 +34,11 @@ var CommentButton = exports.CommentButton = function CommentButton(_ref) {
|
|
|
31
34
|
state = _ref2.state,
|
|
32
35
|
dispatch = _ref2.dispatch;
|
|
33
36
|
var annotationSelectionType = state ? (0, _utils.isSelectionValid)(state) : _types.AnnotationSelectionType.INVALID;
|
|
37
|
+
var _ref3 = (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : {},
|
|
38
|
+
getCanAddComments = _ref3.getCanAddComments,
|
|
39
|
+
contentType = _ref3.contentType;
|
|
34
40
|
(0, _hooks.useCommentButtonMount)({
|
|
35
|
-
state: state,
|
|
41
|
+
state: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
36
42
|
annotationProviders: annotationProviders,
|
|
37
43
|
api: api,
|
|
38
44
|
annotationSelectionType: annotationSelectionType,
|
|
@@ -40,34 +46,48 @@ var CommentButton = exports.CommentButton = function CommentButton(_ref) {
|
|
|
40
46
|
});
|
|
41
47
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
42
48
|
var onClick = function onClick() {
|
|
43
|
-
if (!api || !state || !dispatch || !annotationProviders) {
|
|
49
|
+
if (!api || !state || !dispatch || !annotationProviders || !(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
44
50
|
return;
|
|
45
51
|
}
|
|
46
52
|
(0, _utils2.fireOnClickAnalyticsEvent)({
|
|
47
53
|
api: api
|
|
48
54
|
});
|
|
49
|
-
(0,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
56
|
+
(0, _utils2.startCommentExperience)({
|
|
57
|
+
annotationProviders: annotationProviders,
|
|
58
|
+
api: api,
|
|
59
|
+
state: editorView.state,
|
|
60
|
+
dispatch: editorView.dispatch
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
(0, _utils2.startCommentExperience)({
|
|
64
|
+
annotationProviders: annotationProviders,
|
|
65
|
+
api: api,
|
|
66
|
+
state: state,
|
|
67
|
+
dispatch: dispatch
|
|
68
|
+
});
|
|
69
|
+
}
|
|
55
70
|
};
|
|
56
71
|
if (!(0, _utils2.shouldShowCommentButton)({
|
|
57
|
-
state: state,
|
|
72
|
+
state: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
58
73
|
isVisible: isVisible,
|
|
59
74
|
annotationSelectionType: annotationSelectionType
|
|
60
75
|
})) {
|
|
61
76
|
return null;
|
|
62
77
|
}
|
|
78
|
+
var canAddComments = (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) && getCanAddComments ? getCanAddComments() : true;
|
|
63
79
|
var commentMessage = intl.formatMessage(_messages.annotationMessages.createComment);
|
|
64
80
|
var commentDisabledMessage = intl.formatMessage((0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes') ? _messages.annotationMessages.createCommentDisabled : _messages.annotationMessages.createCommentInvalid);
|
|
81
|
+
var noPermissionToAddCommentMessage = intl.formatMessage(_messages.annotationMessages.noPermissionToAddComment, {
|
|
82
|
+
contentType: contentType
|
|
83
|
+
});
|
|
65
84
|
var isDisabled = (0, _utils2.isButtonDisabled)({
|
|
66
|
-
state: state,
|
|
67
|
-
api: api
|
|
85
|
+
state: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
86
|
+
api: api,
|
|
87
|
+
canAddComments: canAddComments
|
|
68
88
|
});
|
|
69
89
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
70
|
-
content: isDisabled ? commentDisabledMessage : /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
90
|
+
content: isDisabled ? !canAddComments ? noPermissionToAddCommentMessage : commentDisabledMessage : /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
71
91
|
description: commentMessage,
|
|
72
92
|
keymap: _keymaps.addInlineComment
|
|
73
93
|
})
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.startCommentExperience = exports.shouldShowCommentButton = exports.isButtonDisabled = exports.fireOnClickAnalyticsEvent = exports.fireCommentButtonViewedAnalyticsEvent = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
10
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
12
|
var _editorCommands = require("../../editor-commands");
|
|
10
13
|
var _utils = require("../../pm-plugins/utils");
|
|
11
14
|
var _types = require("../../types");
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
12
17
|
var isButtonDisabled = exports.isButtonDisabled = function isButtonDisabled(_ref) {
|
|
13
18
|
var _api$connectivity;
|
|
14
19
|
var state = _ref.state,
|
|
15
|
-
api = _ref.api
|
|
20
|
+
api = _ref.api,
|
|
21
|
+
canAddComments = _ref.canAddComments;
|
|
16
22
|
var annotationSelectionType = state ? (0, _utils.isSelectionValid)(state) : _types.AnnotationSelectionType.INVALID;
|
|
17
|
-
return annotationSelectionType === _types.AnnotationSelectionType.DISABLED || (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
|
|
23
|
+
return !canAddComments || annotationSelectionType === _types.AnnotationSelectionType.DISABLED || (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
|
|
18
24
|
};
|
|
19
25
|
var shouldShowCommentButton = exports.shouldShowCommentButton = function shouldShowCommentButton(_ref2) {
|
|
20
26
|
var state = _ref2.state,
|
|
@@ -85,10 +91,12 @@ var startCommentExperience = exports.startCommentExperience = function startComm
|
|
|
85
91
|
if (canStartDraft) {
|
|
86
92
|
var _annotationProviders$, _annotationProviders$2;
|
|
87
93
|
(_annotationProviders$ = annotationProviders.createCommentExperience) === null || _annotationProviders$ === void 0 || _annotationProviders$.start({
|
|
88
|
-
attributes: {
|
|
94
|
+
attributes: _objectSpread({
|
|
89
95
|
pageClass: 'editor',
|
|
90
96
|
commentType: 'inline'
|
|
91
|
-
}
|
|
97
|
+
}, (0, _platformFeatureFlags.fg)('cc_comments_create_inline_experience_entry_point') ? {
|
|
98
|
+
entryPoint: 'highlightActions'
|
|
99
|
+
} : {})
|
|
92
100
|
});
|
|
93
101
|
(_annotationProviders$2 = annotationProviders.createCommentExperience) === null || _annotationProviders$2 === void 0 || _annotationProviders$2.initExperience.start();
|
|
94
102
|
var result = annotationManager.startDraft();
|
|
@@ -111,10 +119,12 @@ var startCommentExperience = exports.startCommentExperience = function startComm
|
|
|
111
119
|
} else {
|
|
112
120
|
var _annotationProviders$3, _annotationProviders$4, _api$analytics4;
|
|
113
121
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$3 = annotationProviders.createCommentExperience) === null || _annotationProviders$3 === void 0 || _annotationProviders$3.start({
|
|
114
|
-
attributes: {
|
|
122
|
+
attributes: _objectSpread({
|
|
115
123
|
pageClass: 'editor',
|
|
116
124
|
commentType: 'inline'
|
|
117
|
-
}
|
|
125
|
+
}, (0, _platformFeatureFlags.fg)('cc_comments_create_inline_experience_entry_point') ? {
|
|
126
|
+
entryPoint: 'highlightActions'
|
|
127
|
+
} : {})
|
|
118
128
|
});
|
|
119
129
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 || _annotationProviders$4.initExperience.start();
|
|
120
130
|
return (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, undefined, api)(true)(state, dispatch);
|
|
@@ -6,6 +6,7 @@ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { ToolbarButton, CommentIcon as NewCommentIcon, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { isSelectionValid } from '../../pm-plugins/utils';
|
|
10
11
|
import { AnnotationSelectionType, AnnotationTestIds } from '../../types';
|
|
11
12
|
import { useCommentButtonMount } from './hooks';
|
|
@@ -14,11 +15,13 @@ export const CommentButton = ({
|
|
|
14
15
|
api,
|
|
15
16
|
annotationProviders
|
|
16
17
|
}) => {
|
|
18
|
+
var _annotationProviders$;
|
|
17
19
|
const isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
|
|
18
20
|
const bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
|
|
19
21
|
const {
|
|
20
22
|
editorView
|
|
21
23
|
} = useEditorToolbar();
|
|
24
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
22
25
|
const {
|
|
23
26
|
state,
|
|
24
27
|
dispatch
|
|
@@ -27,8 +30,12 @@ export const CommentButton = ({
|
|
|
27
30
|
dispatch: null
|
|
28
31
|
};
|
|
29
32
|
const annotationSelectionType = state ? isSelectionValid(state) : AnnotationSelectionType.INVALID;
|
|
33
|
+
const {
|
|
34
|
+
getCanAddComments,
|
|
35
|
+
contentType
|
|
36
|
+
} = (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : {};
|
|
30
37
|
useCommentButtonMount({
|
|
31
|
-
state,
|
|
38
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
32
39
|
annotationProviders,
|
|
33
40
|
api,
|
|
34
41
|
annotationSelectionType,
|
|
@@ -36,34 +43,48 @@ export const CommentButton = ({
|
|
|
36
43
|
});
|
|
37
44
|
const intl = useIntl();
|
|
38
45
|
const onClick = () => {
|
|
39
|
-
if (!api || !state || !dispatch || !annotationProviders) {
|
|
46
|
+
if (!api || !state || !dispatch || !annotationProviders || !(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
40
47
|
return;
|
|
41
48
|
}
|
|
42
49
|
fireOnClickAnalyticsEvent({
|
|
43
50
|
api
|
|
44
51
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
53
|
+
startCommentExperience({
|
|
54
|
+
annotationProviders,
|
|
55
|
+
api,
|
|
56
|
+
state: editorView.state,
|
|
57
|
+
dispatch: editorView.dispatch
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
startCommentExperience({
|
|
61
|
+
annotationProviders,
|
|
62
|
+
api,
|
|
63
|
+
state,
|
|
64
|
+
dispatch
|
|
65
|
+
});
|
|
66
|
+
}
|
|
51
67
|
};
|
|
52
68
|
if (!shouldShowCommentButton({
|
|
53
|
-
state,
|
|
69
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
54
70
|
isVisible,
|
|
55
71
|
annotationSelectionType
|
|
56
72
|
})) {
|
|
57
73
|
return null;
|
|
58
74
|
}
|
|
75
|
+
const canAddComments = expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) && getCanAddComments ? getCanAddComments() : true;
|
|
59
76
|
const commentMessage = intl.formatMessage(annotationMessages.createComment);
|
|
60
77
|
const commentDisabledMessage = intl.formatMessage(fg('editor_inline_comments_on_inline_nodes') ? annotationMessages.createCommentDisabled : annotationMessages.createCommentInvalid);
|
|
78
|
+
const noPermissionToAddCommentMessage = intl.formatMessage(annotationMessages.noPermissionToAddComment, {
|
|
79
|
+
contentType
|
|
80
|
+
});
|
|
61
81
|
const isDisabled = isButtonDisabled({
|
|
62
|
-
state,
|
|
63
|
-
api
|
|
82
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
83
|
+
api,
|
|
84
|
+
canAddComments
|
|
64
85
|
});
|
|
65
86
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
66
|
-
content: isDisabled ? commentDisabledMessage : /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
87
|
+
content: isDisabled ? !canAddComments ? noPermissionToAddCommentMessage : commentDisabledMessage : /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
67
88
|
description: commentMessage,
|
|
68
89
|
keymap: addInlineComment
|
|
69
90
|
})
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { setInlineCommentDraftState } from '../../editor-commands';
|
|
4
5
|
import { isSelectionValid } from '../../pm-plugins/utils';
|
|
5
6
|
import { AnnotationSelectionType } from '../../types';
|
|
6
7
|
export const isButtonDisabled = ({
|
|
7
8
|
state,
|
|
8
|
-
api
|
|
9
|
+
api,
|
|
10
|
+
canAddComments
|
|
9
11
|
}) => {
|
|
10
12
|
var _api$connectivity, _api$connectivity$sha, _api$connectivity$sha2;
|
|
11
13
|
const annotationSelectionType = state ? isSelectionValid(state) : AnnotationSelectionType.INVALID;
|
|
12
|
-
return annotationSelectionType === AnnotationSelectionType.DISABLED || (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState) === null || _api$connectivity$sha === void 0 ? void 0 : (_api$connectivity$sha2 = _api$connectivity$sha.currentState()) === null || _api$connectivity$sha2 === void 0 ? void 0 : _api$connectivity$sha2.mode) === 'offline';
|
|
14
|
+
return !canAddComments || annotationSelectionType === AnnotationSelectionType.DISABLED || (api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState) === null || _api$connectivity$sha === void 0 ? void 0 : (_api$connectivity$sha2 = _api$connectivity$sha.currentState()) === null || _api$connectivity$sha2 === void 0 ? void 0 : _api$connectivity$sha2.mode) === 'offline';
|
|
13
15
|
};
|
|
14
16
|
export const shouldShowCommentButton = ({
|
|
15
17
|
state,
|
|
@@ -87,7 +89,10 @@ export const startCommentExperience = ({
|
|
|
87
89
|
(_annotationProviders$ = annotationProviders.createCommentExperience) === null || _annotationProviders$ === void 0 ? void 0 : _annotationProviders$.start({
|
|
88
90
|
attributes: {
|
|
89
91
|
pageClass: 'editor',
|
|
90
|
-
commentType: 'inline'
|
|
92
|
+
commentType: 'inline',
|
|
93
|
+
...(fg('cc_comments_create_inline_experience_entry_point') ? {
|
|
94
|
+
entryPoint: 'highlightActions'
|
|
95
|
+
} : {})
|
|
91
96
|
}
|
|
92
97
|
});
|
|
93
98
|
(_annotationProviders$2 = annotationProviders.createCommentExperience) === null || _annotationProviders$2 === void 0 ? void 0 : _annotationProviders$2.initExperience.start();
|
|
@@ -113,7 +118,10 @@ export const startCommentExperience = ({
|
|
|
113
118
|
annotationProviders === null || annotationProviders === void 0 ? void 0 : (_annotationProviders$3 = annotationProviders.createCommentExperience) === null || _annotationProviders$3 === void 0 ? void 0 : _annotationProviders$3.start({
|
|
114
119
|
attributes: {
|
|
115
120
|
pageClass: 'editor',
|
|
116
|
-
commentType: 'inline'
|
|
121
|
+
commentType: 'inline',
|
|
122
|
+
...(fg('cc_comments_create_inline_experience_entry_point') ? {
|
|
123
|
+
entryPoint: 'highlightActions'
|
|
124
|
+
} : {})
|
|
117
125
|
}
|
|
118
126
|
});
|
|
119
127
|
annotationProviders === null || annotationProviders === void 0 ? void 0 : (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 ? void 0 : _annotationProviders$4.initExperience.start();
|
|
@@ -6,17 +6,20 @@ import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { ToolbarButton, CommentIcon as NewCommentIcon, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
10
|
import { isSelectionValid } from '../../pm-plugins/utils';
|
|
10
11
|
import { AnnotationSelectionType, AnnotationTestIds } from '../../types';
|
|
11
12
|
import { useCommentButtonMount } from './hooks';
|
|
12
13
|
import { fireOnClickAnalyticsEvent, isButtonDisabled, shouldShowCommentButton, startCommentExperience } from './utils';
|
|
13
14
|
export var CommentButton = function CommentButton(_ref) {
|
|
15
|
+
var _annotationProviders$;
|
|
14
16
|
var api = _ref.api,
|
|
15
17
|
annotationProviders = _ref.annotationProviders;
|
|
16
18
|
var isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
|
|
17
19
|
var bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
|
|
18
20
|
var _useEditorToolbar = useEditorToolbar(),
|
|
19
21
|
editorView = _useEditorToolbar.editorView;
|
|
22
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
20
23
|
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
21
24
|
state: null,
|
|
22
25
|
dispatch: null
|
|
@@ -24,8 +27,11 @@ export var CommentButton = function CommentButton(_ref) {
|
|
|
24
27
|
state = _ref2.state,
|
|
25
28
|
dispatch = _ref2.dispatch;
|
|
26
29
|
var annotationSelectionType = state ? isSelectionValid(state) : AnnotationSelectionType.INVALID;
|
|
30
|
+
var _ref3 = (_annotationProviders$ = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment) !== null && _annotationProviders$ !== void 0 ? _annotationProviders$ : {},
|
|
31
|
+
getCanAddComments = _ref3.getCanAddComments,
|
|
32
|
+
contentType = _ref3.contentType;
|
|
27
33
|
useCommentButtonMount({
|
|
28
|
-
state: state,
|
|
34
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
29
35
|
annotationProviders: annotationProviders,
|
|
30
36
|
api: api,
|
|
31
37
|
annotationSelectionType: annotationSelectionType,
|
|
@@ -33,34 +39,48 @@ export var CommentButton = function CommentButton(_ref) {
|
|
|
33
39
|
});
|
|
34
40
|
var intl = useIntl();
|
|
35
41
|
var onClick = function onClick() {
|
|
36
|
-
if (!api || !state || !dispatch || !annotationProviders) {
|
|
42
|
+
if (!api || !state || !dispatch || !annotationProviders || !(editorView !== null && editorView !== void 0 && editorView.state) || !(editorView !== null && editorView !== void 0 && editorView.dispatch)) {
|
|
37
43
|
return;
|
|
38
44
|
}
|
|
39
45
|
fireOnClickAnalyticsEvent({
|
|
40
46
|
api: api
|
|
41
47
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
49
|
+
startCommentExperience({
|
|
50
|
+
annotationProviders: annotationProviders,
|
|
51
|
+
api: api,
|
|
52
|
+
state: editorView.state,
|
|
53
|
+
dispatch: editorView.dispatch
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
startCommentExperience({
|
|
57
|
+
annotationProviders: annotationProviders,
|
|
58
|
+
api: api,
|
|
59
|
+
state: state,
|
|
60
|
+
dispatch: dispatch
|
|
61
|
+
});
|
|
62
|
+
}
|
|
48
63
|
};
|
|
49
64
|
if (!shouldShowCommentButton({
|
|
50
|
-
state: state,
|
|
65
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
51
66
|
isVisible: isVisible,
|
|
52
67
|
annotationSelectionType: annotationSelectionType
|
|
53
68
|
})) {
|
|
54
69
|
return null;
|
|
55
70
|
}
|
|
71
|
+
var canAddComments = expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) && getCanAddComments ? getCanAddComments() : true;
|
|
56
72
|
var commentMessage = intl.formatMessage(annotationMessages.createComment);
|
|
57
73
|
var commentDisabledMessage = intl.formatMessage(fg('editor_inline_comments_on_inline_nodes') ? annotationMessages.createCommentDisabled : annotationMessages.createCommentInvalid);
|
|
74
|
+
var noPermissionToAddCommentMessage = intl.formatMessage(annotationMessages.noPermissionToAddComment, {
|
|
75
|
+
contentType: contentType
|
|
76
|
+
});
|
|
58
77
|
var isDisabled = isButtonDisabled({
|
|
59
|
-
state: state,
|
|
60
|
-
api: api
|
|
78
|
+
state: expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true) ? editorView === null || editorView === void 0 ? void 0 : editorView.state : state,
|
|
79
|
+
api: api,
|
|
80
|
+
canAddComments: canAddComments
|
|
61
81
|
});
|
|
62
82
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
63
|
-
content: isDisabled ? commentDisabledMessage : /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
83
|
+
content: isDisabled ? !canAddComments ? noPermissionToAddCommentMessage : commentDisabledMessage : /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
64
84
|
description: commentMessage,
|
|
65
85
|
keymap: addInlineComment
|
|
66
86
|
})
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE } from '@atlaskit/editor-common/analytics';
|
|
2
5
|
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
7
|
import { setInlineCommentDraftState } from '../../editor-commands';
|
|
4
8
|
import { isSelectionValid } from '../../pm-plugins/utils';
|
|
5
9
|
import { AnnotationSelectionType } from '../../types';
|
|
6
10
|
export var isButtonDisabled = function isButtonDisabled(_ref) {
|
|
7
11
|
var _api$connectivity;
|
|
8
12
|
var state = _ref.state,
|
|
9
|
-
api = _ref.api
|
|
13
|
+
api = _ref.api,
|
|
14
|
+
canAddComments = _ref.canAddComments;
|
|
10
15
|
var annotationSelectionType = state ? isSelectionValid(state) : AnnotationSelectionType.INVALID;
|
|
11
|
-
return annotationSelectionType === AnnotationSelectionType.DISABLED || (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
|
|
16
|
+
return !canAddComments || annotationSelectionType === AnnotationSelectionType.DISABLED || (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
|
|
12
17
|
};
|
|
13
18
|
export var shouldShowCommentButton = function shouldShowCommentButton(_ref2) {
|
|
14
19
|
var state = _ref2.state,
|
|
@@ -79,10 +84,12 @@ export var startCommentExperience = function startCommentExperience(_ref6) {
|
|
|
79
84
|
if (canStartDraft) {
|
|
80
85
|
var _annotationProviders$, _annotationProviders$2;
|
|
81
86
|
(_annotationProviders$ = annotationProviders.createCommentExperience) === null || _annotationProviders$ === void 0 || _annotationProviders$.start({
|
|
82
|
-
attributes: {
|
|
87
|
+
attributes: _objectSpread({
|
|
83
88
|
pageClass: 'editor',
|
|
84
89
|
commentType: 'inline'
|
|
85
|
-
}
|
|
90
|
+
}, fg('cc_comments_create_inline_experience_entry_point') ? {
|
|
91
|
+
entryPoint: 'highlightActions'
|
|
92
|
+
} : {})
|
|
86
93
|
});
|
|
87
94
|
(_annotationProviders$2 = annotationProviders.createCommentExperience) === null || _annotationProviders$2 === void 0 || _annotationProviders$2.initExperience.start();
|
|
88
95
|
var result = annotationManager.startDraft();
|
|
@@ -105,10 +112,12 @@ export var startCommentExperience = function startCommentExperience(_ref6) {
|
|
|
105
112
|
} else {
|
|
106
113
|
var _annotationProviders$3, _annotationProviders$4, _api$analytics4;
|
|
107
114
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$3 = annotationProviders.createCommentExperience) === null || _annotationProviders$3 === void 0 || _annotationProviders$3.start({
|
|
108
|
-
attributes: {
|
|
115
|
+
attributes: _objectSpread({
|
|
109
116
|
pageClass: 'editor',
|
|
110
117
|
commentType: 'inline'
|
|
111
|
-
}
|
|
118
|
+
}, fg('cc_comments_create_inline_experience_entry_point') ? {
|
|
119
|
+
entryPoint: 'highlightActions'
|
|
120
|
+
} : {})
|
|
112
121
|
});
|
|
113
122
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 || _annotationProviders$4.initExperience.start();
|
|
114
123
|
return setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, undefined, api)(true)(state, dispatch);
|
|
@@ -8,5 +8,5 @@ export declare const useCommentButtonMount: ({ state, annotationProviders, api,
|
|
|
8
8
|
annotationSelectionType: AnnotationSelectionType;
|
|
9
9
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
10
10
|
bookmark?: SelectionBookmark;
|
|
11
|
-
state: EditorState | null;
|
|
11
|
+
state: EditorState | null | undefined;
|
|
12
12
|
}) => void;
|
|
@@ -3,14 +3,15 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { AnnotationPlugin } from '../../annotationPluginType';
|
|
5
5
|
import { AnnotationSelectionType, type AnnotationProviders } from '../../types';
|
|
6
|
-
export declare const isButtonDisabled: ({ state, api, }: {
|
|
6
|
+
export declare const isButtonDisabled: ({ state, api, canAddComments, }: {
|
|
7
7
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
8
|
-
|
|
8
|
+
canAddComments: boolean;
|
|
9
|
+
state: EditorState | null | undefined;
|
|
9
10
|
}) => boolean;
|
|
10
11
|
export declare const shouldShowCommentButton: ({ state, isVisible, annotationSelectionType, }: {
|
|
11
12
|
annotationSelectionType: AnnotationSelectionType;
|
|
12
13
|
isVisible?: boolean;
|
|
13
|
-
state: EditorState | null;
|
|
14
|
+
state: EditorState | null | undefined;
|
|
14
15
|
}) => boolean;
|
|
15
16
|
export declare const fireOnClickAnalyticsEvent: ({ api, }: {
|
|
16
17
|
api: ExtractInjectionAPI<AnnotationPlugin>;
|
|
@@ -8,5 +8,5 @@ export declare const useCommentButtonMount: ({ state, annotationProviders, api,
|
|
|
8
8
|
annotationSelectionType: AnnotationSelectionType;
|
|
9
9
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
10
10
|
bookmark?: SelectionBookmark;
|
|
11
|
-
state: EditorState | null;
|
|
11
|
+
state: EditorState | null | undefined;
|
|
12
12
|
}) => void;
|
|
@@ -3,14 +3,15 @@ import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import type { AnnotationPlugin } from '../../annotationPluginType';
|
|
5
5
|
import { AnnotationSelectionType, type AnnotationProviders } from '../../types';
|
|
6
|
-
export declare const isButtonDisabled: ({ state, api, }: {
|
|
6
|
+
export declare const isButtonDisabled: ({ state, api, canAddComments, }: {
|
|
7
7
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
8
|
-
|
|
8
|
+
canAddComments: boolean;
|
|
9
|
+
state: EditorState | null | undefined;
|
|
9
10
|
}) => boolean;
|
|
10
11
|
export declare const shouldShowCommentButton: ({ state, isVisible, annotationSelectionType, }: {
|
|
11
12
|
annotationSelectionType: AnnotationSelectionType;
|
|
12
13
|
isVisible?: boolean;
|
|
13
|
-
state: EditorState | null;
|
|
14
|
+
state: EditorState | null | undefined;
|
|
14
15
|
}) => boolean;
|
|
15
16
|
export declare const fireOnClickAnalyticsEvent: ({ api, }: {
|
|
16
17
|
api: ExtractInjectionAPI<AnnotationPlugin>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
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": "^28.1.0",
|
|
42
42
|
"@atlaskit/onboarding": "^14.4.0",
|
|
43
43
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
44
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^12.15.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
47
47
|
},
|