@atlaskit/editor-plugin-annotation 3.0.0 → 3.0.2
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 +15 -0
- package/dist/cjs/annotationPlugin.js +14 -15
- package/dist/cjs/ui/InlineCommentView.js +42 -42
- package/dist/es2019/annotationPlugin.js +15 -17
- package/dist/es2019/ui/InlineCommentView.js +31 -30
- package/dist/esm/annotationPlugin.js +15 -16
- package/dist/esm/ui/InlineCommentView.js +43 -43
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 3.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#183109](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/183109)
|
|
8
|
+
[`3fd4ff5c71ef7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3fd4ff5c71ef7) -
|
|
9
|
+
Migrate to useSharedPluginStateWithSelector
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.0.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 3.0.0
|
|
4
19
|
|
|
5
20
|
### Major Changes
|
|
@@ -8,7 +8,6 @@ exports.annotationPlugin = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
-
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
13
12
|
var _editorCommands = require("./editor-commands");
|
|
14
13
|
var _annotationMark = require("./nodeviews/annotationMark");
|
|
@@ -133,19 +132,21 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
133
132
|
}
|
|
134
133
|
};
|
|
135
134
|
};
|
|
136
|
-
var
|
|
137
|
-
var
|
|
135
|
+
var selector = function selector(states) {
|
|
136
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3;
|
|
138
137
|
return {
|
|
139
|
-
isVisible: isVisible,
|
|
140
|
-
annotationState:
|
|
138
|
+
isVisible: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.isVisible,
|
|
139
|
+
selectedAnnotations: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.selectedAnnotations,
|
|
140
|
+
annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
|
|
141
141
|
};
|
|
142
|
+
};
|
|
143
|
+
var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
|
|
144
|
+
var annotationState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], selector);
|
|
145
|
+
return annotationState;
|
|
142
146
|
}, function (api) {
|
|
143
147
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['annotation']),
|
|
144
148
|
annotationState = _useSharedPluginState.annotationState;
|
|
145
|
-
return
|
|
146
|
-
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
147
|
-
annotationState: annotationState
|
|
148
|
-
};
|
|
149
|
+
return annotationState;
|
|
149
150
|
});
|
|
150
151
|
function AnnotationContentComponent(_ref4) {
|
|
151
152
|
var _api$analytics5;
|
|
@@ -153,15 +154,13 @@ function AnnotationContentComponent(_ref4) {
|
|
|
153
154
|
editorView = _ref4.editorView,
|
|
154
155
|
annotationProviders = _ref4.annotationProviders,
|
|
155
156
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
annotationState = _useAnnotationContent.annotationState;
|
|
159
|
-
if (annotationState && !isVisible && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
|
|
157
|
+
var annotationState = useAnnotationContentComponentPluginState(api);
|
|
158
|
+
if (annotationState && !annotationState.isVisible && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
|
|
160
159
|
return null;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
// need to
|
|
164
|
-
if (isVisible === false && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)) {
|
|
162
|
+
// need to explicitly check for false as undefined is also a valid value to continue
|
|
163
|
+
if ((annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible) === false && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)) {
|
|
165
164
|
return null;
|
|
166
165
|
}
|
|
167
166
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -37,49 +37,49 @@ var findPosForDOM = function findPosForDOM(sel) {
|
|
|
37
37
|
}
|
|
38
38
|
return from;
|
|
39
39
|
};
|
|
40
|
-
var
|
|
40
|
+
var selector = function selector(states) {
|
|
41
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3, _states$annotationSta4, _states$annotationSta5, _states$annotationSta6, _states$annotationSta7;
|
|
42
|
+
return {
|
|
43
|
+
annotations: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.annotations,
|
|
44
|
+
bookmark: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.bookmark,
|
|
45
|
+
isInlineCommentViewClosed: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.isInlineCommentViewClosed,
|
|
46
|
+
isOpeningMediaCommentFromToolbar: (_states$annotationSta4 = states.annotationState) === null || _states$annotationSta4 === void 0 ? void 0 : _states$annotationSta4.isOpeningMediaCommentFromToolbar,
|
|
47
|
+
selectAnnotationMethod: (_states$annotationSta5 = states.annotationState) === null || _states$annotationSta5 === void 0 ? void 0 : _states$annotationSta5.selectAnnotationMethod,
|
|
48
|
+
selectedAnnotations: (_states$annotationSta6 = states.annotationState) === null || _states$annotationSta6 === void 0 ? void 0 : _states$annotationSta6.selectedAnnotations,
|
|
49
|
+
isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
var useAnnotationContentComponentPluginState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (_ref) {
|
|
41
53
|
var api = _ref.api;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
var annotationState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['annotation'], selector);
|
|
55
|
+
return annotationState;
|
|
56
|
+
}, function (_ref2) {
|
|
57
|
+
var _getPluginState;
|
|
58
|
+
var state = _ref2.state;
|
|
59
|
+
var _ref3 = (_getPluginState = (0, _utils3.getPluginState)(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {},
|
|
60
|
+
annotations = _ref3.annotations,
|
|
61
|
+
bookmark = _ref3.bookmark,
|
|
62
|
+
isInlineCommentViewClosed = _ref3.isInlineCommentViewClosed,
|
|
63
|
+
isOpeningMediaCommentFromToolbar = _ref3.isOpeningMediaCommentFromToolbar,
|
|
64
|
+
selectAnnotationMethod = _ref3.selectAnnotationMethod,
|
|
65
|
+
selectedAnnotations = _ref3.selectedAnnotations,
|
|
66
|
+
isAnnotationManagerEnabled = _ref3.isAnnotationManagerEnabled;
|
|
55
67
|
return {
|
|
56
|
-
bookmark: bookmark,
|
|
57
|
-
selectedAnnotations: selectedAnnotations,
|
|
58
68
|
annotations: annotations,
|
|
69
|
+
bookmark: bookmark,
|
|
59
70
|
isInlineCommentViewClosed: isInlineCommentViewClosed,
|
|
60
71
|
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
|
|
61
72
|
selectAnnotationMethod: selectAnnotationMethod,
|
|
73
|
+
selectedAnnotations: selectedAnnotations,
|
|
62
74
|
isAnnotationManagerEnabled: isAnnotationManagerEnabled
|
|
63
75
|
};
|
|
64
|
-
}, function (_ref2) {
|
|
65
|
-
var state = _ref2.state;
|
|
66
|
-
var inlineCommentState = (0, _utils3.getPluginState)(state);
|
|
67
|
-
return {
|
|
68
|
-
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
69
|
-
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
70
|
-
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
71
|
-
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
72
|
-
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
73
|
-
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod,
|
|
74
|
-
isAnnotationManagerEnabled: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isAnnotationManagerEnabled
|
|
75
|
-
};
|
|
76
76
|
});
|
|
77
|
-
function InlineCommentView(
|
|
78
|
-
var providers =
|
|
79
|
-
editorView =
|
|
80
|
-
editorAnalyticsAPI =
|
|
81
|
-
editorAPI =
|
|
82
|
-
dispatchAnalyticsEvent =
|
|
77
|
+
function InlineCommentView(_ref4) {
|
|
78
|
+
var providers = _ref4.providers,
|
|
79
|
+
editorView = _ref4.editorView,
|
|
80
|
+
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
81
|
+
editorAPI = _ref4.editorAPI,
|
|
82
|
+
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
83
83
|
// As inlineComment is the only annotation present, this function is not generic
|
|
84
84
|
var inlineCommentProvider = providers.inlineComment;
|
|
85
85
|
var state = editorView.state,
|
|
@@ -87,17 +87,17 @@ function InlineCommentView(_ref3) {
|
|
|
87
87
|
var lastSelectedAnnotationId = (0, _react.useRef)();
|
|
88
88
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
89
89
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
90
|
-
var
|
|
90
|
+
var _useAnnotationContent = useAnnotationContentComponentPluginState({
|
|
91
91
|
api: editorAPI,
|
|
92
92
|
state: state
|
|
93
93
|
}),
|
|
94
|
-
annotations =
|
|
95
|
-
bookmark =
|
|
96
|
-
isInlineCommentViewClosed =
|
|
97
|
-
isOpeningMediaCommentFromToolbar =
|
|
98
|
-
selectAnnotationMethod =
|
|
99
|
-
selectedAnnotations =
|
|
100
|
-
isAnnotationManagerEnabled =
|
|
94
|
+
annotations = _useAnnotationContent.annotations,
|
|
95
|
+
bookmark = _useAnnotationContent.bookmark,
|
|
96
|
+
isInlineCommentViewClosed = _useAnnotationContent.isInlineCommentViewClosed,
|
|
97
|
+
isOpeningMediaCommentFromToolbar = _useAnnotationContent.isOpeningMediaCommentFromToolbar,
|
|
98
|
+
selectAnnotationMethod = _useAnnotationContent.selectAnnotationMethod,
|
|
99
|
+
selectedAnnotations = _useAnnotationContent.selectedAnnotations,
|
|
100
|
+
isAnnotationManagerEnabled = _useAnnotationContent.isAnnotationManagerEnabled;
|
|
101
101
|
var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
|
|
102
102
|
var selection = (0, _utils3.getSelectionPositions)(state, {
|
|
103
103
|
bookmark: bookmark
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
4
|
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
|
|
6
5
|
import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
@@ -126,20 +125,22 @@ export const annotationPlugin = ({
|
|
|
126
125
|
}
|
|
127
126
|
};
|
|
128
127
|
};
|
|
129
|
-
const
|
|
130
|
-
|
|
128
|
+
const selector = states => {
|
|
129
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3;
|
|
131
130
|
return {
|
|
132
|
-
isVisible,
|
|
133
|
-
annotationState:
|
|
131
|
+
isVisible: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.isVisible,
|
|
132
|
+
selectedAnnotations: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.selectedAnnotations,
|
|
133
|
+
annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
|
|
134
134
|
};
|
|
135
|
+
};
|
|
136
|
+
const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(api => {
|
|
137
|
+
const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
|
|
138
|
+
return annotationState;
|
|
135
139
|
}, api => {
|
|
136
140
|
const {
|
|
137
141
|
annotationState
|
|
138
142
|
} = useSharedPluginState(api, ['annotation']);
|
|
139
|
-
return
|
|
140
|
-
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
141
|
-
annotationState
|
|
142
|
-
};
|
|
143
|
+
return annotationState;
|
|
143
144
|
});
|
|
144
145
|
function AnnotationContentComponent({
|
|
145
146
|
api,
|
|
@@ -148,16 +149,13 @@ function AnnotationContentComponent({
|
|
|
148
149
|
dispatchAnalyticsEvent
|
|
149
150
|
}) {
|
|
150
151
|
var _api$analytics5;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
annotationState
|
|
154
|
-
} = useAnnotationContentComponentPluginState(api);
|
|
155
|
-
if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
152
|
+
const annotationState = useAnnotationContentComponentPluginState(api);
|
|
153
|
+
if (annotationState && !annotationState.isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
156
154
|
return null;
|
|
157
155
|
}
|
|
158
156
|
|
|
159
|
-
// need to
|
|
160
|
-
if (isVisible === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
|
|
157
|
+
// need to explicitly check for false as undefined is also a valid value to continue
|
|
158
|
+
if ((annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible) === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
|
|
161
159
|
return null;
|
|
162
160
|
}
|
|
163
161
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useRef } 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
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
5
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
6
6
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -27,44 +27,45 @@ const findPosForDOM = sel => {
|
|
|
27
27
|
}
|
|
28
28
|
return from;
|
|
29
29
|
};
|
|
30
|
-
const
|
|
30
|
+
const selector = states => {
|
|
31
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3, _states$annotationSta4, _states$annotationSta5, _states$annotationSta6, _states$annotationSta7;
|
|
32
|
+
return {
|
|
33
|
+
annotations: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.annotations,
|
|
34
|
+
bookmark: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.bookmark,
|
|
35
|
+
isInlineCommentViewClosed: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.isInlineCommentViewClosed,
|
|
36
|
+
isOpeningMediaCommentFromToolbar: (_states$annotationSta4 = states.annotationState) === null || _states$annotationSta4 === void 0 ? void 0 : _states$annotationSta4.isOpeningMediaCommentFromToolbar,
|
|
37
|
+
selectAnnotationMethod: (_states$annotationSta5 = states.annotationState) === null || _states$annotationSta5 === void 0 ? void 0 : _states$annotationSta5.selectAnnotationMethod,
|
|
38
|
+
selectedAnnotations: (_states$annotationSta6 = states.annotationState) === null || _states$annotationSta6 === void 0 ? void 0 : _states$annotationSta6.selectedAnnotations,
|
|
39
|
+
isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(({
|
|
31
43
|
api
|
|
32
44
|
}) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
|
-
const isOpeningMediaCommentFromToolbar = useSharedPluginStateSelector(api, 'annotation.isOpeningMediaCommentFromToolbar');
|
|
43
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
44
|
-
const selectAnnotationMethod = useSharedPluginStateSelector(api, 'annotation.selectAnnotationMethod');
|
|
45
|
-
const isAnnotationManagerEnabled = useSharedPluginStateSelector(api, 'annotation.isAnnotationManagerEnabled');
|
|
46
|
-
return {
|
|
45
|
+
const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
|
|
46
|
+
return annotationState;
|
|
47
|
+
}, ({
|
|
48
|
+
state
|
|
49
|
+
}) => {
|
|
50
|
+
var _getPluginState;
|
|
51
|
+
const {
|
|
52
|
+
annotations,
|
|
47
53
|
bookmark,
|
|
54
|
+
isInlineCommentViewClosed,
|
|
55
|
+
isOpeningMediaCommentFromToolbar,
|
|
56
|
+
selectAnnotationMethod,
|
|
48
57
|
selectedAnnotations,
|
|
58
|
+
isAnnotationManagerEnabled
|
|
59
|
+
} = (_getPluginState = getPluginState(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {};
|
|
60
|
+
return {
|
|
49
61
|
annotations,
|
|
62
|
+
bookmark,
|
|
50
63
|
isInlineCommentViewClosed,
|
|
51
64
|
isOpeningMediaCommentFromToolbar,
|
|
52
65
|
selectAnnotationMethod,
|
|
66
|
+
selectedAnnotations,
|
|
53
67
|
isAnnotationManagerEnabled
|
|
54
68
|
};
|
|
55
|
-
}, ({
|
|
56
|
-
state
|
|
57
|
-
}) => {
|
|
58
|
-
const inlineCommentState = getPluginState(state);
|
|
59
|
-
return {
|
|
60
|
-
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
61
|
-
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
62
|
-
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
63
|
-
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
64
|
-
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
65
|
-
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod,
|
|
66
|
-
isAnnotationManagerEnabled: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isAnnotationManagerEnabled
|
|
67
|
-
};
|
|
68
69
|
});
|
|
69
70
|
export function InlineCommentView({
|
|
70
71
|
providers,
|
|
@@ -94,7 +95,7 @@ export function InlineCommentView({
|
|
|
94
95
|
selectAnnotationMethod,
|
|
95
96
|
selectedAnnotations,
|
|
96
97
|
isAnnotationManagerEnabled
|
|
97
|
-
} =
|
|
98
|
+
} = useAnnotationContentComponentPluginState({
|
|
98
99
|
api: editorAPI,
|
|
99
100
|
state
|
|
100
101
|
});
|
|
@@ -2,8 +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 { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
-
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
7
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
7
|
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
|
|
9
8
|
import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
@@ -126,19 +125,21 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
126
125
|
}
|
|
127
126
|
};
|
|
128
127
|
};
|
|
129
|
-
var
|
|
130
|
-
var
|
|
128
|
+
var selector = function selector(states) {
|
|
129
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3;
|
|
131
130
|
return {
|
|
132
|
-
isVisible: isVisible,
|
|
133
|
-
annotationState:
|
|
131
|
+
isVisible: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.isVisible,
|
|
132
|
+
selectedAnnotations: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.selectedAnnotations,
|
|
133
|
+
annotations: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.annotations
|
|
134
134
|
};
|
|
135
|
+
};
|
|
136
|
+
var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (api) {
|
|
137
|
+
var annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
|
|
138
|
+
return annotationState;
|
|
135
139
|
}, function (api) {
|
|
136
140
|
var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
|
|
137
141
|
annotationState = _useSharedPluginState.annotationState;
|
|
138
|
-
return
|
|
139
|
-
isVisible: annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible,
|
|
140
|
-
annotationState: annotationState
|
|
141
|
-
};
|
|
142
|
+
return annotationState;
|
|
142
143
|
});
|
|
143
144
|
function AnnotationContentComponent(_ref4) {
|
|
144
145
|
var _api$analytics5;
|
|
@@ -146,15 +147,13 @@ function AnnotationContentComponent(_ref4) {
|
|
|
146
147
|
editorView = _ref4.editorView,
|
|
147
148
|
annotationProviders = _ref4.annotationProviders,
|
|
148
149
|
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
annotationState = _useAnnotationContent.annotationState;
|
|
152
|
-
if (annotationState && !isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
150
|
+
var annotationState = useAnnotationContentComponentPluginState(api);
|
|
151
|
+
if (annotationState && !annotationState.isVisible && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
153
152
|
return null;
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
// need to
|
|
157
|
-
if (isVisible === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
|
|
155
|
+
// need to explicitly check for false as undefined is also a valid value to continue
|
|
156
|
+
if ((annotationState === null || annotationState === void 0 ? void 0 : annotationState.isVisible) === false && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
|
|
158
157
|
return null;
|
|
159
158
|
}
|
|
160
159
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React, { useRef } 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
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
7
|
import { getAnnotationInlineNodeTypes, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -28,49 +28,49 @@ var findPosForDOM = function findPosForDOM(sel) {
|
|
|
28
28
|
}
|
|
29
29
|
return from;
|
|
30
30
|
};
|
|
31
|
-
var
|
|
31
|
+
var selector = function selector(states) {
|
|
32
|
+
var _states$annotationSta, _states$annotationSta2, _states$annotationSta3, _states$annotationSta4, _states$annotationSta5, _states$annotationSta6, _states$annotationSta7;
|
|
33
|
+
return {
|
|
34
|
+
annotations: (_states$annotationSta = states.annotationState) === null || _states$annotationSta === void 0 ? void 0 : _states$annotationSta.annotations,
|
|
35
|
+
bookmark: (_states$annotationSta2 = states.annotationState) === null || _states$annotationSta2 === void 0 ? void 0 : _states$annotationSta2.bookmark,
|
|
36
|
+
isInlineCommentViewClosed: (_states$annotationSta3 = states.annotationState) === null || _states$annotationSta3 === void 0 ? void 0 : _states$annotationSta3.isInlineCommentViewClosed,
|
|
37
|
+
isOpeningMediaCommentFromToolbar: (_states$annotationSta4 = states.annotationState) === null || _states$annotationSta4 === void 0 ? void 0 : _states$annotationSta4.isOpeningMediaCommentFromToolbar,
|
|
38
|
+
selectAnnotationMethod: (_states$annotationSta5 = states.annotationState) === null || _states$annotationSta5 === void 0 ? void 0 : _states$annotationSta5.selectAnnotationMethod,
|
|
39
|
+
selectedAnnotations: (_states$annotationSta6 = states.annotationState) === null || _states$annotationSta6 === void 0 ? void 0 : _states$annotationSta6.selectedAnnotations,
|
|
40
|
+
isAnnotationManagerEnabled: (_states$annotationSta7 = states.annotationState) === null || _states$annotationSta7 === void 0 ? void 0 : _states$annotationSta7.isAnnotationManagerEnabled
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var useAnnotationContentComponentPluginState = sharedPluginStateHookMigratorFactory(function (_ref) {
|
|
32
44
|
var api = _ref.api;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
var annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
|
|
46
|
+
return annotationState;
|
|
47
|
+
}, function (_ref2) {
|
|
48
|
+
var _getPluginState;
|
|
49
|
+
var state = _ref2.state;
|
|
50
|
+
var _ref3 = (_getPluginState = getPluginState(state)) !== null && _getPluginState !== void 0 ? _getPluginState : {},
|
|
51
|
+
annotations = _ref3.annotations,
|
|
52
|
+
bookmark = _ref3.bookmark,
|
|
53
|
+
isInlineCommentViewClosed = _ref3.isInlineCommentViewClosed,
|
|
54
|
+
isOpeningMediaCommentFromToolbar = _ref3.isOpeningMediaCommentFromToolbar,
|
|
55
|
+
selectAnnotationMethod = _ref3.selectAnnotationMethod,
|
|
56
|
+
selectedAnnotations = _ref3.selectedAnnotations,
|
|
57
|
+
isAnnotationManagerEnabled = _ref3.isAnnotationManagerEnabled;
|
|
46
58
|
return {
|
|
47
|
-
bookmark: bookmark,
|
|
48
|
-
selectedAnnotations: selectedAnnotations,
|
|
49
59
|
annotations: annotations,
|
|
60
|
+
bookmark: bookmark,
|
|
50
61
|
isInlineCommentViewClosed: isInlineCommentViewClosed,
|
|
51
62
|
isOpeningMediaCommentFromToolbar: isOpeningMediaCommentFromToolbar,
|
|
52
63
|
selectAnnotationMethod: selectAnnotationMethod,
|
|
64
|
+
selectedAnnotations: selectedAnnotations,
|
|
53
65
|
isAnnotationManagerEnabled: isAnnotationManagerEnabled
|
|
54
66
|
};
|
|
55
|
-
}, function (_ref2) {
|
|
56
|
-
var state = _ref2.state;
|
|
57
|
-
var inlineCommentState = getPluginState(state);
|
|
58
|
-
return {
|
|
59
|
-
bookmark: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.bookmark,
|
|
60
|
-
selectedAnnotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectedAnnotations,
|
|
61
|
-
annotations: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.annotations,
|
|
62
|
-
isInlineCommentViewClosed: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isInlineCommentViewClosed,
|
|
63
|
-
isOpeningMediaCommentFromToolbar: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isOpeningMediaCommentFromToolbar,
|
|
64
|
-
selectAnnotationMethod: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.selectAnnotationMethod,
|
|
65
|
-
isAnnotationManagerEnabled: inlineCommentState === null || inlineCommentState === void 0 ? void 0 : inlineCommentState.isAnnotationManagerEnabled
|
|
66
|
-
};
|
|
67
67
|
});
|
|
68
|
-
export function InlineCommentView(
|
|
69
|
-
var providers =
|
|
70
|
-
editorView =
|
|
71
|
-
editorAnalyticsAPI =
|
|
72
|
-
editorAPI =
|
|
73
|
-
dispatchAnalyticsEvent =
|
|
68
|
+
export function InlineCommentView(_ref4) {
|
|
69
|
+
var providers = _ref4.providers,
|
|
70
|
+
editorView = _ref4.editorView,
|
|
71
|
+
editorAnalyticsAPI = _ref4.editorAnalyticsAPI,
|
|
72
|
+
editorAPI = _ref4.editorAPI,
|
|
73
|
+
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
74
74
|
// As inlineComment is the only annotation present, this function is not generic
|
|
75
75
|
var inlineCommentProvider = providers.inlineComment;
|
|
76
76
|
var state = editorView.state,
|
|
@@ -78,17 +78,17 @@ export function InlineCommentView(_ref3) {
|
|
|
78
78
|
var lastSelectedAnnotationId = useRef();
|
|
79
79
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
80
80
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
81
|
-
var
|
|
81
|
+
var _useAnnotationContent = useAnnotationContentComponentPluginState({
|
|
82
82
|
api: editorAPI,
|
|
83
83
|
state: state
|
|
84
84
|
}),
|
|
85
|
-
annotations =
|
|
86
|
-
bookmark =
|
|
87
|
-
isInlineCommentViewClosed =
|
|
88
|
-
isOpeningMediaCommentFromToolbar =
|
|
89
|
-
selectAnnotationMethod =
|
|
90
|
-
selectedAnnotations =
|
|
91
|
-
isAnnotationManagerEnabled =
|
|
85
|
+
annotations = _useAnnotationContent.annotations,
|
|
86
|
+
bookmark = _useAnnotationContent.bookmark,
|
|
87
|
+
isInlineCommentViewClosed = _useAnnotationContent.isInlineCommentViewClosed,
|
|
88
|
+
isOpeningMediaCommentFromToolbar = _useAnnotationContent.isOpeningMediaCommentFromToolbar,
|
|
89
|
+
selectAnnotationMethod = _useAnnotationContent.selectAnnotationMethod,
|
|
90
|
+
selectedAnnotations = _useAnnotationContent.selectedAnnotations,
|
|
91
|
+
isAnnotationManagerEnabled = _useAnnotationContent.isAnnotationManagerEnabled;
|
|
92
92
|
var annotationsList = getAllAnnotations(editorView.state.doc);
|
|
93
93
|
var selection = getSelectionPositions(state, {
|
|
94
94
|
bookmark: bookmark
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^3.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^2.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
|
-
"@atlaskit/icon": "^27.
|
|
40
|
+
"@atlaskit/icon": "^27.3.0",
|
|
41
41
|
"@atlaskit/onboarding": "^14.2.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
43
|
+
"@atlaskit/tmp-editor-statsig": "^9.1.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/editor-common": "^107.
|
|
47
|
+
"@atlaskit/editor-common": "^107.7.0",
|
|
48
48
|
"react": "^18.2.0",
|
|
49
49
|
"react-dom": "^18.2.0"
|
|
50
50
|
},
|