@atlaskit/editor-plugin-annotation 2.7.4 → 2.7.6
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 +19 -0
- package/dist/cjs/annotationPlugin.js +22 -10
- package/dist/cjs/pm-plugins/annotation-manager-hooks.js +3 -1
- package/dist/cjs/pm-plugins/toolbar.js +6 -1
- package/dist/cjs/ui/InlineCommentView.js +54 -46
- package/dist/es2019/annotationPlugin.js +22 -10
- package/dist/es2019/pm-plugins/annotation-manager-hooks.js +3 -1
- package/dist/es2019/pm-plugins/toolbar.js +6 -1
- package/dist/es2019/ui/InlineCommentView.js +50 -39
- package/dist/esm/annotationPlugin.js +23 -11
- package/dist/esm/pm-plugins/annotation-manager-hooks.js +3 -1
- package/dist/esm/pm-plugins/toolbar.js +6 -1
- package/dist/esm/ui/InlineCommentView.js +54 -46
- package/dist/types/pm-plugins/toolbar.d.ts +2 -1
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 2.7.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#142925](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/142925)
|
|
8
|
+
[`e013698350bef`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e013698350bef) -
|
|
9
|
+
This updates the renderer to use the new annotation manager create comment APIs and disables the
|
|
10
|
+
use of the old create hooks. This should be backward compatible and can be controled by a FG
|
|
11
|
+
- [#151999](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/151999)
|
|
12
|
+
[`daf7c638efb95`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/daf7c638efb95) -
|
|
13
|
+
Refactor to use sharedPluginStateHookMigratorFactory
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.7.5
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.7.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -99,14 +99,17 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
99
99
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
100
100
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
101
101
|
var _api$analytics4;
|
|
102
|
-
var
|
|
102
|
+
var _annotationProviders$ = annotationProviders.inlineComment,
|
|
103
|
+
isToolbarAbove = _annotationProviders$.isToolbarAbove,
|
|
104
|
+
onCommentButtonMount = _annotationProviders$.onCommentButtonMount;
|
|
103
105
|
var toolbarConfig = (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)({
|
|
104
106
|
state: state,
|
|
105
107
|
intl: intl,
|
|
106
108
|
isToolbarAbove: isToolbarAbove,
|
|
107
109
|
api: api,
|
|
108
110
|
createCommentExperience: annotationProviders.createCommentExperience,
|
|
109
|
-
annotationManager: annotationProviders.annotationManager
|
|
111
|
+
annotationManager: annotationProviders.annotationManager,
|
|
112
|
+
onCommentButtonMount: onCommentButtonMount
|
|
110
113
|
});
|
|
111
114
|
if (!toolbarConfig) {
|
|
112
115
|
return undefined;
|
|
@@ -133,20 +136,29 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
133
136
|
}
|
|
134
137
|
};
|
|
135
138
|
};
|
|
139
|
+
var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
140
|
+
var isVisible = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible');
|
|
141
|
+
return {
|
|
142
|
+
isVisible: isVisible,
|
|
143
|
+
annotationState: undefined
|
|
144
|
+
};
|
|
145
|
+
}, function (api) {
|
|
146
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
|
|
147
|
+
annotationState = _useSharedPluginState.annotationState;
|
|
148
|
+
return {
|
|
149
|
+
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
150
|
+
annotationState: annotationState
|
|
151
|
+
};
|
|
152
|
+
});
|
|
136
153
|
function AnnotationContentComponent(_ref4) {
|
|
137
154
|
var _api$analytics5;
|
|
138
155
|
var api = _ref4.api,
|
|
139
156
|
editorView = _ref4.editorView,
|
|
140
157
|
annotationProviders = _ref4.annotationProviders,
|
|
141
158
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
annotationState = _useSharedPluginState.annotationState;
|
|
146
|
-
var isVisibleSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isVisible', {
|
|
147
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
148
|
-
});
|
|
149
|
-
var isVisible = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
|
|
159
|
+
var _useAnnotationContent = useAnnotationContentComponentPluginState(api),
|
|
160
|
+
isVisible = _useAnnotationContent.isVisible,
|
|
161
|
+
annotationState = _useAnnotationContent.annotationState;
|
|
150
162
|
if (annotationState && !isVisible && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
|
|
151
163
|
return null;
|
|
152
164
|
}
|
|
@@ -147,7 +147,9 @@ var applyDraft = exports.applyDraft = function applyDraft(editorView, options) {
|
|
|
147
147
|
return {
|
|
148
148
|
success: true,
|
|
149
149
|
// Get the dom element from the newly created annotation and return it here.
|
|
150
|
-
targetElement: targetElement
|
|
150
|
+
targetElement: targetElement,
|
|
151
|
+
// In Editor this is undefined, because the editor will update the document.
|
|
152
|
+
actionResult: undefined
|
|
151
153
|
};
|
|
152
154
|
};
|
|
153
155
|
};
|
|
@@ -63,7 +63,8 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
63
63
|
_supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
|
|
64
64
|
api = _ref2.api,
|
|
65
65
|
createCommentExperience = _ref2.createCommentExperience,
|
|
66
|
-
annotationManager = _ref2.annotationManager
|
|
66
|
+
annotationManager = _ref2.annotationManager,
|
|
67
|
+
onCommentButtonMount = _ref2.onCommentButtonMount;
|
|
67
68
|
var schema = state.schema;
|
|
68
69
|
var selectionValid = (0, _utils2.isSelectionValid)(state);
|
|
69
70
|
var isMediaSelected = (0, _mediaSingle.currentMediaNodeWithPos)(state);
|
|
@@ -89,6 +90,10 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
89
90
|
title: createCommentMessage,
|
|
90
91
|
onMount: function onMount() {
|
|
91
92
|
var _getRangeInlineNodeNa;
|
|
93
|
+
if ((0, _platformFeatureFlags.fg)('confluence_frontend_preload_inline_comment_editor')) {
|
|
94
|
+
onCommentButtonMount && onCommentButtonMount();
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
// Check if the selection includes an non-text inline node
|
|
93
98
|
var inlineCommentPluginState = (0, _utils2.getPluginState)(state);
|
|
94
99
|
var inlineNodeNames = (_getRangeInlineNodeNa = (0, _utils.getRangeInlineNodeNames)({
|
|
@@ -9,11 +9,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
13
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
13
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
15
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
-
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
17
17
|
var _editorCommands = require("../editor-commands");
|
|
18
18
|
var _utils3 = require("../pm-plugins/utils");
|
|
19
19
|
var _types = require("../types");
|
|
@@ -34,53 +34,66 @@ var findPosForDOM = function findPosForDOM(sel) {
|
|
|
34
34
|
}
|
|
35
35
|
return from;
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
var useInlineCommentViewPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (_ref) {
|
|
38
|
+
var api = _ref.api;
|
|
39
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
40
|
+
var bookmark = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.bookmark');
|
|
41
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
|
+
var selectedAnnotations = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectedAnnotations');
|
|
43
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
44
|
+
var annotations = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.annotations');
|
|
45
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
46
|
+
var isInlineCommentViewClosed = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isInlineCommentViewClosed');
|
|
47
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
|
+
var isOpeningMediaCommentFromToolbar = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.isOpeningMediaCommentFromToolbar');
|
|
49
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
50
|
+
var selectAnnotationMethod = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'annotation.selectAnnotationMethod');
|
|
51
|
+
return {
|
|
52
|
+
bookmark: bookmark,
|
|
53
|
+
selectedAnnotations: selectedAnnotations,
|
|
54
|
+
annotations: annotations,
|
|
55
|
+
isInlineCommentViewClosed: isInlineCommentViewClosed,
|
|
56
|
+
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
|
|
57
|
+
selectAnnotationMethod: selectAnnotationMethod
|
|
58
|
+
};
|
|
59
|
+
}, function (_ref2) {
|
|
60
|
+
var state = _ref2.state;
|
|
61
|
+
var inlineCommentState = (0, _utils3.getPluginState)(state);
|
|
62
|
+
return {
|
|
63
|
+
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
64
|
+
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
65
|
+
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
66
|
+
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
67
|
+
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
68
|
+
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
function InlineCommentView(_ref3) {
|
|
72
|
+
var providers = _ref3.providers,
|
|
73
|
+
editorView = _ref3.editorView,
|
|
74
|
+
editorAnalyticsAPI = _ref3.editorAnalyticsAPI,
|
|
75
|
+
editorAPI = _ref3.editorAPI,
|
|
76
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
43
77
|
// As inlineComment is the only annotation present, this function is not generic
|
|
44
78
|
var inlineCommentProvider = providers.inlineComment;
|
|
45
79
|
var state = editorView.state,
|
|
46
80
|
dispatch = editorView.dispatch;
|
|
47
81
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
48
82
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
60
|
-
});
|
|
61
|
-
var selectedAnnotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
|
|
62
|
-
|
|
63
|
-
// annotations
|
|
64
|
-
var annotationsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.annotations', {
|
|
65
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
66
|
-
});
|
|
67
|
-
var annotations = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
|
|
68
|
-
|
|
69
|
-
// isInlineCommentViewClosed
|
|
70
|
-
var isInlineCommentViewClosedSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.isInlineCommentViewClosed', {
|
|
71
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
72
|
-
});
|
|
73
|
-
var isInlineCommentViewClosed = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
|
|
74
|
-
|
|
75
|
-
// isOpeningMediaCommentFromToolbar
|
|
76
|
-
var isOpeningMediaCommentFromToolbarSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
|
|
77
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
78
|
-
});
|
|
79
|
-
var isOpeningMediaCommentFromToolbar = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
|
|
83
|
+
var _useInlineCommentView = useInlineCommentViewPluginState({
|
|
84
|
+
api: editorAPI,
|
|
85
|
+
state: state
|
|
86
|
+
}),
|
|
87
|
+
annotations = _useInlineCommentView.annotations,
|
|
88
|
+
bookmark = _useInlineCommentView.bookmark,
|
|
89
|
+
isInlineCommentViewClosed = _useInlineCommentView.isInlineCommentViewClosed,
|
|
90
|
+
isOpeningMediaCommentFromToolbar = _useInlineCommentView.isOpeningMediaCommentFromToolbar,
|
|
91
|
+
selectAnnotationMethod = _useInlineCommentView.selectAnnotationMethod,
|
|
92
|
+
selectedAnnotations = _useInlineCommentView.selectedAnnotations;
|
|
80
93
|
var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
|
|
81
|
-
var selection = (0, _utils3.getSelectionPositions)(state,
|
|
94
|
+
var selection = (0, _utils3.getSelectionPositions)(state, {
|
|
82
95
|
bookmark: bookmark
|
|
83
|
-
}
|
|
96
|
+
});
|
|
84
97
|
var position = findPosForDOM(selection);
|
|
85
98
|
var dom;
|
|
86
99
|
try {
|
|
@@ -106,11 +119,6 @@ function InlineCommentView(_ref) {
|
|
|
106
119
|
dispatchAnalyticsEvent(payload);
|
|
107
120
|
}
|
|
108
121
|
}
|
|
109
|
-
|
|
110
|
-
// selectAnnotationMethod
|
|
111
|
-
var selectAnnotationMethodSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'annotation.selectAnnotationMethod', {
|
|
112
|
-
disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
|
|
113
|
-
});
|
|
114
122
|
if (!dom) {
|
|
115
123
|
return null;
|
|
116
124
|
}
|
|
@@ -175,7 +183,7 @@ function InlineCommentView(_ref) {
|
|
|
175
183
|
attributes: {
|
|
176
184
|
overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
|
|
177
185
|
targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
|
|
178
|
-
method:
|
|
186
|
+
method: selectAnnotationMethod
|
|
179
187
|
}
|
|
180
188
|
};
|
|
181
189
|
dispatchAnalyticsEvent(payload);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
3
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -90,7 +90,8 @@ export const annotationPlugin = ({
|
|
|
90
90
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
91
91
|
var _api$analytics4;
|
|
92
92
|
const {
|
|
93
|
-
isToolbarAbove
|
|
93
|
+
isToolbarAbove,
|
|
94
|
+
onCommentButtonMount
|
|
94
95
|
} = annotationProviders.inlineComment;
|
|
95
96
|
const toolbarConfig = buildToolbar(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)({
|
|
96
97
|
state,
|
|
@@ -98,7 +99,8 @@ export const annotationPlugin = ({
|
|
|
98
99
|
isToolbarAbove,
|
|
99
100
|
api,
|
|
100
101
|
createCommentExperience: annotationProviders.createCommentExperience,
|
|
101
|
-
annotationManager: annotationProviders.annotationManager
|
|
102
|
+
annotationManager: annotationProviders.annotationManager,
|
|
103
|
+
onCommentButtonMount
|
|
102
104
|
});
|
|
103
105
|
if (!toolbarConfig) {
|
|
104
106
|
return undefined;
|
|
@@ -127,6 +129,21 @@ export const annotationPlugin = ({
|
|
|
127
129
|
}
|
|
128
130
|
};
|
|
129
131
|
};
|
|
132
|
+
const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
|
|
133
|
+
const isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
|
|
134
|
+
return {
|
|
135
|
+
isVisible,
|
|
136
|
+
annotationState: undefined
|
|
137
|
+
};
|
|
138
|
+
}, api => {
|
|
139
|
+
const {
|
|
140
|
+
annotationState
|
|
141
|
+
} = useSharedPluginState(api, ['annotation']);
|
|
142
|
+
return {
|
|
143
|
+
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
144
|
+
annotationState
|
|
145
|
+
};
|
|
146
|
+
});
|
|
130
147
|
function AnnotationContentComponent({
|
|
131
148
|
api,
|
|
132
149
|
editorView,
|
|
@@ -135,14 +152,9 @@ function AnnotationContentComponent({
|
|
|
135
152
|
}) {
|
|
136
153
|
var _api$analytics5;
|
|
137
154
|
const {
|
|
155
|
+
isVisible,
|
|
138
156
|
annotationState
|
|
139
|
-
} =
|
|
140
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
|
|
141
|
-
});
|
|
142
|
-
const isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
|
|
143
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
144
|
-
});
|
|
145
|
-
const isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
|
|
157
|
+
} = useAnnotationContentComponentPluginState(api);
|
|
146
158
|
if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
147
159
|
return null;
|
|
148
160
|
}
|
|
@@ -139,7 +139,9 @@ export const applyDraft = (editorView, options) => id => {
|
|
|
139
139
|
return {
|
|
140
140
|
success: true,
|
|
141
141
|
// Get the dom element from the newly created annotation and return it here.
|
|
142
|
-
targetElement
|
|
142
|
+
targetElement,
|
|
143
|
+
// In Editor this is undefined, because the editor will update the document.
|
|
144
|
+
actionResult: undefined
|
|
143
145
|
};
|
|
144
146
|
};
|
|
145
147
|
export const getDraft = (editorView, options) => () => {
|
|
@@ -59,7 +59,8 @@ export const buildToolbar = editorAnalyticsAPI => ({
|
|
|
59
59
|
_supportedNodes = [],
|
|
60
60
|
api,
|
|
61
61
|
createCommentExperience,
|
|
62
|
-
annotationManager
|
|
62
|
+
annotationManager,
|
|
63
|
+
onCommentButtonMount
|
|
63
64
|
}) => {
|
|
64
65
|
var _api$connectivity, _api$connectivity$sha, _api$connectivity$sha2;
|
|
65
66
|
const {
|
|
@@ -89,6 +90,10 @@ export const buildToolbar = editorAnalyticsAPI => ({
|
|
|
89
90
|
title: createCommentMessage,
|
|
90
91
|
onMount: () => {
|
|
91
92
|
var _getRangeInlineNodeNa;
|
|
93
|
+
if (fg('confluence_frontend_preload_inline_comment_editor')) {
|
|
94
|
+
onCommentButtonMount && onCommentButtonMount();
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
// Check if the selection includes an non-text inline node
|
|
93
98
|
const inlineCommentPluginState = getPluginState(state);
|
|
94
99
|
const inlineNodeNames = (_getRangeInlineNodeNa = getRangeInlineNodeNames({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
6
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
6
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
9
9
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
|
|
10
10
|
import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
|
|
11
11
|
import { AnnotationTestIds } from '../types';
|
|
@@ -26,6 +26,42 @@ const findPosForDOM = sel => {
|
|
|
26
26
|
}
|
|
27
27
|
return from;
|
|
28
28
|
};
|
|
29
|
+
const useInlineCommentViewPluginState = sharedPluginStateHookMigratorFactory(({
|
|
30
|
+
api
|
|
31
|
+
}) => {
|
|
32
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
33
|
+
const bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
|
|
34
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
+
const selectedAnnotations = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations');
|
|
36
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
37
|
+
const annotations = useSharedPluginStateSelector(api, 'annotation.annotations');
|
|
38
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
39
|
+
const isInlineCommentViewClosed = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed');
|
|
40
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
|
+
const isOpeningMediaCommentFromToolbar = useSharedPluginStateSelector(api, 'annotation.isOpeningMediaCommentFromToolbar');
|
|
42
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
43
|
+
const selectAnnotationMethod = useSharedPluginStateSelector(api, 'annotation.selectAnnotationMethod');
|
|
44
|
+
return {
|
|
45
|
+
bookmark,
|
|
46
|
+
selectedAnnotations,
|
|
47
|
+
annotations,
|
|
48
|
+
isInlineCommentViewClosed,
|
|
49
|
+
isOpeningMediaCommentFromToolbar,
|
|
50
|
+
selectAnnotationMethod
|
|
51
|
+
};
|
|
52
|
+
}, ({
|
|
53
|
+
state
|
|
54
|
+
}) => {
|
|
55
|
+
const inlineCommentState = getPluginState(state);
|
|
56
|
+
return {
|
|
57
|
+
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
58
|
+
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
59
|
+
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
60
|
+
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
61
|
+
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
62
|
+
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
|
|
63
|
+
};
|
|
64
|
+
});
|
|
29
65
|
export function InlineCommentView({
|
|
30
66
|
providers,
|
|
31
67
|
editorView,
|
|
@@ -45,41 +81,21 @@ export function InlineCommentView({
|
|
|
45
81
|
createComponent: CreateComponent,
|
|
46
82
|
viewComponent: ViewComponent
|
|
47
83
|
} = inlineCommentProvider;
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
59
|
-
});
|
|
60
|
-
const selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
|
|
61
|
-
|
|
62
|
-
// annotations
|
|
63
|
-
const annotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.annotations', {
|
|
64
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
65
|
-
});
|
|
66
|
-
const annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
|
|
67
|
-
|
|
68
|
-
// isInlineCommentViewClosed
|
|
69
|
-
const isInlineCommentViewClosedSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isInlineCommentViewClosed', {
|
|
70
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
71
|
-
});
|
|
72
|
-
const isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
|
|
73
|
-
|
|
74
|
-
// isOpeningMediaCommentFromToolbar
|
|
75
|
-
const isOpeningMediaCommentFromToolbarSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
|
|
76
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
84
|
+
const {
|
|
85
|
+
annotations,
|
|
86
|
+
bookmark,
|
|
87
|
+
isInlineCommentViewClosed,
|
|
88
|
+
isOpeningMediaCommentFromToolbar,
|
|
89
|
+
selectAnnotationMethod,
|
|
90
|
+
selectedAnnotations
|
|
91
|
+
} = useInlineCommentViewPluginState({
|
|
92
|
+
api: editorAPI,
|
|
93
|
+
state
|
|
77
94
|
});
|
|
78
|
-
const isOpeningMediaCommentFromToolbar = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
|
|
79
95
|
const annotationsList = getAllAnnotations(editorView.state.doc);
|
|
80
|
-
const selection = getSelectionPositions(state,
|
|
96
|
+
const selection = getSelectionPositions(state, {
|
|
81
97
|
bookmark
|
|
82
|
-
}
|
|
98
|
+
});
|
|
83
99
|
const position = findPosForDOM(selection);
|
|
84
100
|
let dom;
|
|
85
101
|
try {
|
|
@@ -105,11 +121,6 @@ export function InlineCommentView({
|
|
|
105
121
|
dispatchAnalyticsEvent(payload);
|
|
106
122
|
}
|
|
107
123
|
}
|
|
108
|
-
|
|
109
|
-
// selectAnnotationMethod
|
|
110
|
-
const selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
|
|
111
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
112
|
-
});
|
|
113
124
|
if (!dom) {
|
|
114
125
|
return null;
|
|
115
126
|
}
|
|
@@ -172,7 +183,7 @@ export function InlineCommentView({
|
|
|
172
183
|
attributes: {
|
|
173
184
|
overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
|
|
174
185
|
targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
|
|
175
|
-
method:
|
|
186
|
+
method: selectAnnotationMethod
|
|
176
187
|
}
|
|
177
188
|
};
|
|
178
189
|
dispatchAnalyticsEvent(payload);
|
|
@@ -2,7 +2,7 @@ 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 React from 'react';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -92,14 +92,17 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
92
92
|
var pluginState = getPluginState(state);
|
|
93
93
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
94
94
|
var _api$analytics4;
|
|
95
|
-
var
|
|
95
|
+
var _annotationProviders$ = annotationProviders.inlineComment,
|
|
96
|
+
isToolbarAbove = _annotationProviders$.isToolbarAbove,
|
|
97
|
+
onCommentButtonMount = _annotationProviders$.onCommentButtonMount;
|
|
96
98
|
var toolbarConfig = buildToolbar(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)({
|
|
97
99
|
state: state,
|
|
98
100
|
intl: intl,
|
|
99
101
|
isToolbarAbove: isToolbarAbove,
|
|
100
102
|
api: api,
|
|
101
103
|
createCommentExperience: annotationProviders.createCommentExperience,
|
|
102
|
-
annotationManager: annotationProviders.annotationManager
|
|
104
|
+
annotationManager: annotationProviders.annotationManager,
|
|
105
|
+
onCommentButtonMount: onCommentButtonMount
|
|
103
106
|
});
|
|
104
107
|
if (!toolbarConfig) {
|
|
105
108
|
return undefined;
|
|
@@ -126,20 +129,29 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
126
129
|
}
|
|
127
130
|
};
|
|
128
131
|
};
|
|
132
|
+
var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
133
|
+
var isVisible = useSharedPluginStateSelector(api, 'annotation.isVisible');
|
|
134
|
+
return {
|
|
135
|
+
isVisible: isVisible,
|
|
136
|
+
annotationState: undefined
|
|
137
|
+
};
|
|
138
|
+
}, function (api) {
|
|
139
|
+
var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
|
|
140
|
+
annotationState = _useSharedPluginState.annotationState;
|
|
141
|
+
return {
|
|
142
|
+
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
143
|
+
annotationState: annotationState
|
|
144
|
+
};
|
|
145
|
+
});
|
|
129
146
|
function AnnotationContentComponent(_ref4) {
|
|
130
147
|
var _api$analytics5;
|
|
131
148
|
var api = _ref4.api,
|
|
132
149
|
editorView = _ref4.editorView,
|
|
133
150
|
annotationProviders = _ref4.annotationProviders,
|
|
134
151
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
annotationState = _useSharedPluginState.annotationState;
|
|
139
|
-
var isVisibleSelector = useSharedPluginStateSelector(api, 'annotation.isVisible', {
|
|
140
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
141
|
-
});
|
|
142
|
-
var isVisible = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isVisibleSelector : annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible;
|
|
152
|
+
var _useAnnotationContent = useAnnotationContentComponentPluginState(api),
|
|
153
|
+
isVisible = _useAnnotationContent.isVisible,
|
|
154
|
+
annotationState = _useAnnotationContent.annotationState;
|
|
143
155
|
if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
144
156
|
return null;
|
|
145
157
|
}
|
|
@@ -141,7 +141,9 @@ export var applyDraft = function applyDraft(editorView, options) {
|
|
|
141
141
|
return {
|
|
142
142
|
success: true,
|
|
143
143
|
// Get the dom element from the newly created annotation and return it here.
|
|
144
|
-
targetElement: targetElement
|
|
144
|
+
targetElement: targetElement,
|
|
145
|
+
// In Editor this is undefined, because the editor will update the document.
|
|
146
|
+
actionResult: undefined
|
|
145
147
|
};
|
|
146
148
|
};
|
|
147
149
|
};
|
|
@@ -56,7 +56,8 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
56
56
|
_supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
|
|
57
57
|
api = _ref2.api,
|
|
58
58
|
createCommentExperience = _ref2.createCommentExperience,
|
|
59
|
-
annotationManager = _ref2.annotationManager
|
|
59
|
+
annotationManager = _ref2.annotationManager,
|
|
60
|
+
onCommentButtonMount = _ref2.onCommentButtonMount;
|
|
60
61
|
var schema = state.schema;
|
|
61
62
|
var selectionValid = isSelectionValid(state);
|
|
62
63
|
var isMediaSelected = currentMediaNodeWithPos(state);
|
|
@@ -82,6 +83,10 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
82
83
|
title: createCommentMessage,
|
|
83
84
|
onMount: function onMount() {
|
|
84
85
|
var _getRangeInlineNodeNa;
|
|
86
|
+
if (fg('confluence_frontend_preload_inline_comment_editor')) {
|
|
87
|
+
onCommentButtonMount && onCommentButtonMount();
|
|
88
|
+
}
|
|
89
|
+
|
|
85
90
|
// Check if the selection includes an non-text inline node
|
|
86
91
|
var inlineCommentPluginState = getPluginState(state);
|
|
87
92
|
var inlineNodeNames = (_getRangeInlineNodeNa = getRangeInlineNodeNames({
|
|
@@ -2,11 +2,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory } from '@atlaskit/editor-common/hooks';
|
|
5
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
7
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
10
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../editor-commands';
|
|
11
11
|
import { getAllAnnotations, getAnnotationViewKey, getPluginState, getSelectionPositions } from '../pm-plugins/utils';
|
|
12
12
|
import { AnnotationTestIds } from '../types';
|
|
@@ -27,53 +27,66 @@ var findPosForDOM = function findPosForDOM(sel) {
|
|
|
27
27
|
}
|
|
28
28
|
return from;
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
var useInlineCommentViewPluginState = sharedPluginStateHookMigratorFactory(function (_ref) {
|
|
31
|
+
var api = _ref.api;
|
|
32
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
33
|
+
var bookmark = useSharedPluginStateSelector(api, 'annotation.bookmark');
|
|
34
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
+
var selectedAnnotations = useSharedPluginStateSelector(api, 'annotation.selectedAnnotations');
|
|
36
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
37
|
+
var annotations = useSharedPluginStateSelector(api, 'annotation.annotations');
|
|
38
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
39
|
+
var isInlineCommentViewClosed = useSharedPluginStateSelector(api, 'annotation.isInlineCommentViewClosed');
|
|
40
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
|
+
var isOpeningMediaCommentFromToolbar = useSharedPluginStateSelector(api, 'annotation.isOpeningMediaCommentFromToolbar');
|
|
42
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
43
|
+
var selectAnnotationMethod = useSharedPluginStateSelector(api, 'annotation.selectAnnotationMethod');
|
|
44
|
+
return {
|
|
45
|
+
bookmark: bookmark,
|
|
46
|
+
selectedAnnotations: selectedAnnotations,
|
|
47
|
+
annotations: annotations,
|
|
48
|
+
isInlineCommentViewClosed: isInlineCommentViewClosed,
|
|
49
|
+
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
|
|
50
|
+
selectAnnotationMethod: selectAnnotationMethod
|
|
51
|
+
};
|
|
52
|
+
}, function (_ref2) {
|
|
53
|
+
var state = _ref2.state;
|
|
54
|
+
var inlineCommentState = getPluginState(state);
|
|
55
|
+
return {
|
|
56
|
+
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
57
|
+
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
58
|
+
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
59
|
+
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
60
|
+
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
61
|
+
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
export function InlineCommentView(_ref3) {
|
|
65
|
+
var providers = _ref3.providers,
|
|
66
|
+
editorView = _ref3.editorView,
|
|
67
|
+
editorAnalyticsAPI = _ref3.editorAnalyticsAPI,
|
|
68
|
+
editorAPI = _ref3.editorAPI,
|
|
69
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
36
70
|
// As inlineComment is the only annotation present, this function is not generic
|
|
37
71
|
var inlineCommentProvider = providers.inlineComment;
|
|
38
72
|
var state = editorView.state,
|
|
39
73
|
dispatch = editorView.dispatch;
|
|
40
74
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
41
75
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
53
|
-
});
|
|
54
|
-
var selectedAnnotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? selectedAnnotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations;
|
|
55
|
-
|
|
56
|
-
// annotations
|
|
57
|
-
var annotationsSelector = useSharedPluginStateSelector(editorAPI, 'annotation.annotations', {
|
|
58
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
59
|
-
});
|
|
60
|
-
var annotations = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? annotationsSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations;
|
|
61
|
-
|
|
62
|
-
// isInlineCommentViewClosed
|
|
63
|
-
var isInlineCommentViewClosedSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isInlineCommentViewClosed', {
|
|
64
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
65
|
-
});
|
|
66
|
-
var isInlineCommentViewClosed = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isInlineCommentViewClosedSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed;
|
|
67
|
-
|
|
68
|
-
// isOpeningMediaCommentFromToolbar
|
|
69
|
-
var isOpeningMediaCommentFromToolbarSelector = useSharedPluginStateSelector(editorAPI, 'annotation.isOpeningMediaCommentFromToolbar', {
|
|
70
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
71
|
-
});
|
|
72
|
-
var isOpeningMediaCommentFromToolbar = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? isOpeningMediaCommentFromToolbarSelector : inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar;
|
|
76
|
+
var _useInlineCommentView = useInlineCommentViewPluginState({
|
|
77
|
+
api: editorAPI,
|
|
78
|
+
state: state
|
|
79
|
+
}),
|
|
80
|
+
annotations = _useInlineCommentView.annotations,
|
|
81
|
+
bookmark = _useInlineCommentView.bookmark,
|
|
82
|
+
isInlineCommentViewClosed = _useInlineCommentView.isInlineCommentViewClosed,
|
|
83
|
+
isOpeningMediaCommentFromToolbar = _useInlineCommentView.isOpeningMediaCommentFromToolbar,
|
|
84
|
+
selectAnnotationMethod = _useInlineCommentView.selectAnnotationMethod,
|
|
85
|
+
selectedAnnotations = _useInlineCommentView.selectedAnnotations;
|
|
73
86
|
var annotationsList = getAllAnnotations(editorView.state.doc);
|
|
74
|
-
var selection = getSelectionPositions(state,
|
|
87
|
+
var selection = getSelectionPositions(state, {
|
|
75
88
|
bookmark: bookmark
|
|
76
|
-
}
|
|
89
|
+
});
|
|
77
90
|
var position = findPosForDOM(selection);
|
|
78
91
|
var dom;
|
|
79
92
|
try {
|
|
@@ -99,11 +112,6 @@ export function InlineCommentView(_ref) {
|
|
|
99
112
|
dispatchAnalyticsEvent(payload);
|
|
100
113
|
}
|
|
101
114
|
}
|
|
102
|
-
|
|
103
|
-
// selectAnnotationMethod
|
|
104
|
-
var selectAnnotationMethodSelector = useSharedPluginStateSelector(editorAPI, 'annotation.selectAnnotationMethod', {
|
|
105
|
-
disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
|
|
106
|
-
});
|
|
107
115
|
if (!dom) {
|
|
108
116
|
return null;
|
|
109
117
|
}
|
|
@@ -168,7 +176,7 @@ export function InlineCommentView(_ref) {
|
|
|
168
176
|
attributes: {
|
|
169
177
|
overlap: activeAnnotations.length ? activeAnnotations.length - 1 : 0,
|
|
170
178
|
targetNodeType: (_editorView$state$doc = editorView.state.doc.nodeAt(position)) === null || _editorView$state$doc === void 0 ? void 0 : _editorView$state$doc.type.name,
|
|
171
|
-
method:
|
|
179
|
+
method: selectAnnotationMethod
|
|
172
180
|
}
|
|
173
181
|
};
|
|
174
182
|
dispatchAnalyticsEvent(payload);
|
|
@@ -16,6 +16,7 @@ interface BuildToolbarOptions {
|
|
|
16
16
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
17
17
|
createCommentExperience?: AnnotationProviders['createCommentExperience'];
|
|
18
18
|
annotationManager?: AnnotationProviders['annotationManager'];
|
|
19
|
+
onCommentButtonMount?: () => void;
|
|
19
20
|
}
|
|
20
21
|
export declare const getValidNodes: (state: EditorState) => NodeType[];
|
|
21
22
|
type ShouldSuppressFloatingToolbarOptions = {
|
|
@@ -35,7 +36,7 @@ export declare const buildSuppressedToolbar: (state: EditorState) => {
|
|
|
35
36
|
title: string;
|
|
36
37
|
__suppressAllToolbars: boolean;
|
|
37
38
|
};
|
|
38
|
-
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, }: BuildToolbarOptions) => {
|
|
39
|
+
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, onCommentButtonMount, }: BuildToolbarOptions) => {
|
|
39
40
|
title: string;
|
|
40
41
|
nodeType: NodeType[];
|
|
41
42
|
items: FloatingToolbarButton<Command>[];
|
|
@@ -102,6 +102,7 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
102
102
|
* Note 2: text is supported by default.
|
|
103
103
|
*/
|
|
104
104
|
supportedBlockNodes?: string[];
|
|
105
|
+
onCommentButtonMount?: () => void;
|
|
105
106
|
};
|
|
106
107
|
export interface AnnotationProviders {
|
|
107
108
|
inlineComment: InlineCommentAnnotationProvider;
|
|
@@ -199,6 +200,7 @@ export type InlineCommentCompoundExperience = {
|
|
|
199
200
|
}) => void;
|
|
200
201
|
complete: () => void;
|
|
201
202
|
debug: ExperienceDebugFunction;
|
|
203
|
+
debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
|
|
202
204
|
};
|
|
203
205
|
draftToPublishExperience: {
|
|
204
206
|
start: () => void;
|
|
@@ -16,6 +16,7 @@ interface BuildToolbarOptions {
|
|
|
16
16
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
17
17
|
createCommentExperience?: AnnotationProviders['createCommentExperience'];
|
|
18
18
|
annotationManager?: AnnotationProviders['annotationManager'];
|
|
19
|
+
onCommentButtonMount?: () => void;
|
|
19
20
|
}
|
|
20
21
|
export declare const getValidNodes: (state: EditorState) => NodeType[];
|
|
21
22
|
type ShouldSuppressFloatingToolbarOptions = {
|
|
@@ -35,7 +36,7 @@ export declare const buildSuppressedToolbar: (state: EditorState) => {
|
|
|
35
36
|
title: string;
|
|
36
37
|
__suppressAllToolbars: boolean;
|
|
37
38
|
};
|
|
38
|
-
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, }: BuildToolbarOptions) => {
|
|
39
|
+
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, onCommentButtonMount, }: BuildToolbarOptions) => {
|
|
39
40
|
title: string;
|
|
40
41
|
nodeType: NodeType[];
|
|
41
42
|
items: FloatingToolbarButton<Command>[];
|
|
@@ -102,6 +102,7 @@ export type InlineCommentAnnotationProvider = AnnotationTypeProvider<AnnotationT
|
|
|
102
102
|
* Note 2: text is supported by default.
|
|
103
103
|
*/
|
|
104
104
|
supportedBlockNodes?: string[];
|
|
105
|
+
onCommentButtonMount?: () => void;
|
|
105
106
|
};
|
|
106
107
|
export interface AnnotationProviders {
|
|
107
108
|
inlineComment: InlineCommentAnnotationProvider;
|
|
@@ -199,6 +200,7 @@ export type InlineCommentCompoundExperience = {
|
|
|
199
200
|
}) => void;
|
|
200
201
|
complete: () => void;
|
|
201
202
|
debug: ExperienceDebugFunction;
|
|
203
|
+
debugPoint: (message: string, attributes?: ExperienceAttributes) => void;
|
|
202
204
|
};
|
|
203
205
|
draftToPublishExperience: {
|
|
204
206
|
start: () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^11.0.0",
|
|
36
|
-
"@atlaskit/editor-common": "^104.
|
|
36
|
+
"@atlaskit/editor-common": "^104.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
38
38
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^1.4.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
42
|
-
"@atlaskit/icon": "^
|
|
42
|
+
"@atlaskit/icon": "^26.0.0",
|
|
43
43
|
"@atlaskit/onboarding": "^14.0.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
45
|
+
"@atlaskit/tmp-editor-statsig": "^4.19.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -120,6 +120,9 @@
|
|
|
120
120
|
},
|
|
121
121
|
"confluence_frontend_handle_annotation_error": {
|
|
122
122
|
"type": "boolean"
|
|
123
|
+
},
|
|
124
|
+
"confluence_frontend_preload_inline_comment_editor": {
|
|
125
|
+
"type": "boolean"
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
}
|