@atlaskit/editor-plugin-annotation 2.5.0 → 2.5.1
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 +9 -0
- package/dist/cjs/annotationPlugin.js +16 -1
- package/dist/cjs/pm-plugins/inline-comment.js +25 -11
- package/dist/cjs/pm-plugins/toolbar.js +47 -11
- package/dist/es2019/annotationPlugin.js +17 -2
- package/dist/es2019/pm-plugins/inline-comment.js +16 -0
- package/dist/es2019/pm-plugins/toolbar.js +45 -2
- package/dist/esm/annotationPlugin.js +17 -2
- package/dist/esm/pm-plugins/inline-comment.js +25 -11
- package/dist/esm/pm-plugins/toolbar.js +47 -11
- package/dist/types/pm-plugins/toolbar.d.ts +19 -1
- package/dist/types/pm-plugins/types.d.ts +3 -1
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/toolbar.d.ts +19 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +3 -1
- package/dist/types-ts4.5/types/index.d.ts +5 -0
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 2.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#140758](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/140758)
|
|
8
|
+
[`02525232cc778`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/02525232cc778) -
|
|
9
|
+
[ux] ED-27140 suppress toolbars when inline commenting
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.5.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -8,6 +8,7 @@ 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 _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _editorCommands = require("./editor-commands");
|
|
13
14
|
var _annotationMark = require("./nodeviews/annotationMark");
|
|
@@ -57,7 +58,8 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
57
58
|
dispatch: dispatch,
|
|
58
59
|
provider: annotationProviders.inlineComment,
|
|
59
60
|
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
60
|
-
featureFlagsPluginState: featureFlags
|
|
61
|
+
featureFlagsPluginState: featureFlags,
|
|
62
|
+
selectCommentExperience: annotationProviders.selectCommentExperience
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
return;
|
|
@@ -74,6 +76,19 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
74
76
|
}];
|
|
75
77
|
},
|
|
76
78
|
pluginsOptions: {
|
|
79
|
+
floatingToolbar: function floatingToolbar(state) {
|
|
80
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_fix_toolbar_comment_jump')) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
var pluginState = (0, _utils.getPluginState)(state);
|
|
84
|
+
var bookmark = pluginState === null || pluginState === void 0 ? void 0 : pluginState.bookmark;
|
|
85
|
+
if ((0, _toolbar.shouldSuppressFloatingToolbar)({
|
|
86
|
+
state: state,
|
|
87
|
+
bookmark: bookmark
|
|
88
|
+
})) {
|
|
89
|
+
return (0, _toolbar.buildSuppressedToolbar)(state);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
77
92
|
selectionToolbar: function selectionToolbar(state, intl) {
|
|
78
93
|
if (!annotationProviders) {
|
|
79
94
|
return;
|
|
@@ -216,8 +216,22 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
216
216
|
editorView.root.addEventListener('mouseup', mouseUp);
|
|
217
217
|
return {
|
|
218
218
|
update: function update(view, _prevState) {
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
if ((0, _platformFeatureFlags.fg)('confluence_comments_select_comment_experience')) {
|
|
220
|
+
var _prevSelectedAnnotati;
|
|
221
|
+
var _ref4 = (0, _utils.getPluginState)(view.state) || {},
|
|
222
|
+
selectedAnnotations = _ref4.selectedAnnotations;
|
|
223
|
+
var _ref5 = (0, _utils.getPluginState)(_prevState) || {},
|
|
224
|
+
prevSelectedAnnotations = _ref5.selectedAnnotations;
|
|
225
|
+
|
|
226
|
+
// If the new state has a selected annotation, and it's different from the previous one
|
|
227
|
+
// then we mark the select annotation experience as complete
|
|
228
|
+
if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
|
|
229
|
+
var _options$selectCommen;
|
|
230
|
+
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
var _ref6 = (0, _utils.getPluginState)(view.state) || {},
|
|
234
|
+
dirtyAnnotations = _ref6.dirtyAnnotations;
|
|
221
235
|
if (!dirtyAnnotations) {
|
|
222
236
|
return;
|
|
223
237
|
}
|
|
@@ -270,8 +284,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
270
284
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
271
285
|
return false;
|
|
272
286
|
}
|
|
273
|
-
var
|
|
274
|
-
annotations =
|
|
287
|
+
var _ref7 = pluginState || {},
|
|
288
|
+
annotations = _ref7.annotations;
|
|
275
289
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
276
290
|
if (!isUnresolved) {
|
|
277
291
|
return false;
|
|
@@ -282,13 +296,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
282
296
|
},
|
|
283
297
|
decorations: function decorations(state) {
|
|
284
298
|
// highlight comments, depending on state
|
|
285
|
-
var
|
|
286
|
-
draftDecorationSet =
|
|
287
|
-
annotations =
|
|
288
|
-
selectedAnnotations =
|
|
289
|
-
isVisible =
|
|
290
|
-
isInlineCommentViewClosed =
|
|
291
|
-
hoveredAnnotations =
|
|
299
|
+
var _ref8 = (0, _utils.getPluginState)(state) || {},
|
|
300
|
+
draftDecorationSet = _ref8.draftDecorationSet,
|
|
301
|
+
annotations = _ref8.annotations,
|
|
302
|
+
selectedAnnotations = _ref8.selectedAnnotations,
|
|
303
|
+
isVisible = _ref8.isVisible,
|
|
304
|
+
isInlineCommentViewClosed = _ref8.isInlineCommentViewClosed,
|
|
305
|
+
hoveredAnnotations = _ref8.hoveredAnnotations;
|
|
292
306
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
|
|
293
307
|
var focusDecorations = [];
|
|
294
308
|
state.doc.descendants(function (node, pos) {
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.buildToolbar = void 0;
|
|
7
|
+
exports.shouldSuppressFloatingToolbar = exports.getValidNodes = exports.buildToolbar = exports.buildSuppressedToolbar = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
@@ -16,17 +16,53 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
16
16
|
var _editorCommands = require("../editor-commands");
|
|
17
17
|
var _types = require("../types");
|
|
18
18
|
var _utils2 = require("./utils");
|
|
19
|
+
var getValidNodes = exports.getValidNodes = function getValidNodes(state) {
|
|
20
|
+
var schema = state.schema;
|
|
21
|
+
var annotation = schema.marks.annotation;
|
|
22
|
+
return Object.keys(schema.nodes).reduce(function (acc, current) {
|
|
23
|
+
var type = schema.nodes[current];
|
|
24
|
+
if (type.allowsMarkType(annotation)) {
|
|
25
|
+
acc.push(type);
|
|
26
|
+
}
|
|
27
|
+
return acc;
|
|
28
|
+
}, []);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Should suppress toolbars when the user is creating an inline comment
|
|
32
|
+
* This only applies when the selection range exactly matches the bookmark range
|
|
33
|
+
* which should be the case immediately after the comment button is clicked
|
|
34
|
+
* if the user creates a different selection range, the floating toolbar should still be shown
|
|
35
|
+
*/
|
|
36
|
+
var shouldSuppressFloatingToolbar = exports.shouldSuppressFloatingToolbar = function shouldSuppressFloatingToolbar(_ref) {
|
|
37
|
+
var state = _ref.state,
|
|
38
|
+
bookmark = _ref.bookmark;
|
|
39
|
+
if (!bookmark) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
var tr = state.tr;
|
|
43
|
+
var resolvedBookmark = bookmark.resolve(tr.doc);
|
|
44
|
+
var isSelectionMatchingBookmark = resolvedBookmark.to === tr.selection.to && resolvedBookmark.from === tr.selection.from;
|
|
45
|
+
return isSelectionMatchingBookmark;
|
|
46
|
+
};
|
|
47
|
+
var buildSuppressedToolbar = exports.buildSuppressedToolbar = function buildSuppressedToolbar(state) {
|
|
48
|
+
return {
|
|
49
|
+
items: [],
|
|
50
|
+
nodeType: getValidNodes(state),
|
|
51
|
+
title: 'Annotation suppressed toolbar',
|
|
52
|
+
__suppressAllToolbars: true
|
|
53
|
+
};
|
|
54
|
+
};
|
|
19
55
|
var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
20
|
-
return function (
|
|
56
|
+
return function (_ref2) {
|
|
21
57
|
var _api$connectivity;
|
|
22
|
-
var state =
|
|
23
|
-
intl =
|
|
24
|
-
|
|
25
|
-
isToolbarAbove =
|
|
26
|
-
|
|
27
|
-
_supportedNodes =
|
|
28
|
-
api =
|
|
29
|
-
createCommentExperience =
|
|
58
|
+
var state = _ref2.state,
|
|
59
|
+
intl = _ref2.intl,
|
|
60
|
+
_ref2$isToolbarAbove = _ref2.isToolbarAbove,
|
|
61
|
+
isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
|
|
62
|
+
_ref2$_supportedNodes = _ref2._supportedNodes,
|
|
63
|
+
_supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
|
|
64
|
+
api = _ref2.api,
|
|
65
|
+
createCommentExperience = _ref2.createCommentExperience;
|
|
30
66
|
var schema = state.schema;
|
|
31
67
|
var selectionValid = (0, _utils2.isSelectionValid)(state);
|
|
32
68
|
var isMediaSelected = (0, _mediaSingle.currentMediaNodeWithPos)(state);
|
|
@@ -114,7 +150,7 @@ var buildToolbar = exports.buildToolbar = function buildToolbar(editorAnalyticsA
|
|
|
114
150
|
var onPositionCalculated = calcToolbarPosition(toolbarTitle);
|
|
115
151
|
return {
|
|
116
152
|
title: toolbarTitle,
|
|
117
|
-
nodeType: validNodes,
|
|
153
|
+
nodeType: (0, _platformFeatureFlags.fg)('platform_editor_fix_toolbar_comment_jump') ? getValidNodes(state) : validNodes,
|
|
118
154
|
items: [createComment],
|
|
119
155
|
onPositionCalculated: onPositionCalculated,
|
|
120
156
|
pluginName: 'annotation'
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
5
|
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
|
|
5
6
|
import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
6
7
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
7
8
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
|
-
import { buildToolbar } from './pm-plugins/toolbar';
|
|
9
|
+
import { buildSuppressedToolbar, buildToolbar, shouldSuppressFloatingToolbar } from './pm-plugins/toolbar';
|
|
9
10
|
import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
10
11
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
11
12
|
export const annotationPlugin = ({
|
|
@@ -48,7 +49,8 @@ export const annotationPlugin = ({
|
|
|
48
49
|
dispatch,
|
|
49
50
|
provider: annotationProviders.inlineComment,
|
|
50
51
|
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
51
|
-
featureFlagsPluginState: featureFlags
|
|
52
|
+
featureFlagsPluginState: featureFlags,
|
|
53
|
+
selectCommentExperience: annotationProviders.selectCommentExperience
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
return;
|
|
@@ -64,6 +66,19 @@ export const annotationPlugin = ({
|
|
|
64
66
|
}
|
|
65
67
|
}],
|
|
66
68
|
pluginsOptions: {
|
|
69
|
+
floatingToolbar(state) {
|
|
70
|
+
if (!fg('platform_editor_fix_toolbar_comment_jump')) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const pluginState = getPluginState(state);
|
|
74
|
+
const bookmark = pluginState === null || pluginState === void 0 ? void 0 : pluginState.bookmark;
|
|
75
|
+
if (shouldSuppressFloatingToolbar({
|
|
76
|
+
state,
|
|
77
|
+
bookmark
|
|
78
|
+
})) {
|
|
79
|
+
return buildSuppressedToolbar(state);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
67
82
|
selectionToolbar(state, intl) {
|
|
68
83
|
if (!annotationProviders) {
|
|
69
84
|
return;
|
|
@@ -150,6 +150,22 @@ export const inlineCommentPlugin = options => {
|
|
|
150
150
|
editorView.root.addEventListener('mouseup', mouseUp);
|
|
151
151
|
return {
|
|
152
152
|
update(view, _prevState) {
|
|
153
|
+
if (fg('confluence_comments_select_comment_experience')) {
|
|
154
|
+
var _prevSelectedAnnotati;
|
|
155
|
+
const {
|
|
156
|
+
selectedAnnotations
|
|
157
|
+
} = getPluginState(view.state) || {};
|
|
158
|
+
const {
|
|
159
|
+
selectedAnnotations: prevSelectedAnnotations
|
|
160
|
+
} = getPluginState(_prevState) || {};
|
|
161
|
+
|
|
162
|
+
// If the new state has a selected annotation, and it's different from the previous one
|
|
163
|
+
// then we mark the select annotation experience as complete
|
|
164
|
+
if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 ? void 0 : (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
|
|
165
|
+
var _options$selectCommen;
|
|
166
|
+
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 ? void 0 : _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
153
169
|
const {
|
|
154
170
|
dirtyAnnotations
|
|
155
171
|
} = getPluginState(view.state) || {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { ToolTipContent, addInlineComment } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
5
5
|
import { annotationMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
@@ -9,6 +9,49 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
9
9
|
import { setInlineCommentDraftState } from '../editor-commands';
|
|
10
10
|
import { AnnotationSelectionType, AnnotationTestIds } from '../types';
|
|
11
11
|
import { getPluginState, isSelectionValid, resolveDraftBookmark } from './utils';
|
|
12
|
+
export const getValidNodes = state => {
|
|
13
|
+
const {
|
|
14
|
+
schema
|
|
15
|
+
} = state;
|
|
16
|
+
const {
|
|
17
|
+
annotation
|
|
18
|
+
} = schema.marks;
|
|
19
|
+
return Object.keys(schema.nodes).reduce((acc, current) => {
|
|
20
|
+
const type = schema.nodes[current];
|
|
21
|
+
if (type.allowsMarkType(annotation)) {
|
|
22
|
+
acc.push(type);
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Should suppress toolbars when the user is creating an inline comment
|
|
29
|
+
* This only applies when the selection range exactly matches the bookmark range
|
|
30
|
+
* which should be the case immediately after the comment button is clicked
|
|
31
|
+
* if the user creates a different selection range, the floating toolbar should still be shown
|
|
32
|
+
*/
|
|
33
|
+
export const shouldSuppressFloatingToolbar = ({
|
|
34
|
+
state,
|
|
35
|
+
bookmark
|
|
36
|
+
}) => {
|
|
37
|
+
if (!bookmark) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
tr
|
|
42
|
+
} = state;
|
|
43
|
+
const resolvedBookmark = bookmark.resolve(tr.doc);
|
|
44
|
+
const isSelectionMatchingBookmark = resolvedBookmark.to === tr.selection.to && resolvedBookmark.from === tr.selection.from;
|
|
45
|
+
return isSelectionMatchingBookmark;
|
|
46
|
+
};
|
|
47
|
+
export const buildSuppressedToolbar = state => {
|
|
48
|
+
return {
|
|
49
|
+
items: [],
|
|
50
|
+
nodeType: getValidNodes(state),
|
|
51
|
+
title: 'Annotation suppressed toolbar',
|
|
52
|
+
__suppressAllToolbars: true
|
|
53
|
+
};
|
|
54
|
+
};
|
|
12
55
|
export const buildToolbar = editorAnalyticsAPI => ({
|
|
13
56
|
state,
|
|
14
57
|
intl,
|
|
@@ -107,7 +150,7 @@ export const buildToolbar = editorAnalyticsAPI => ({
|
|
|
107
150
|
const onPositionCalculated = calcToolbarPosition(toolbarTitle);
|
|
108
151
|
return {
|
|
109
152
|
title: toolbarTitle,
|
|
110
|
-
nodeType: validNodes,
|
|
153
|
+
nodeType: fg('platform_editor_fix_toolbar_comment_jump') ? getValidNodes(state) : validNodes,
|
|
111
154
|
items: [createComment],
|
|
112
155
|
onPositionCalculated,
|
|
113
156
|
pluginName: 'annotation'
|
|
@@ -3,12 +3,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
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
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { setInlineCommentDraftState, showInlineCommentForBlockNode } from './editor-commands';
|
|
8
9
|
import { annotationWithToDOMFix } from './nodeviews/annotationMark';
|
|
9
10
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
10
11
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
11
|
-
import { buildToolbar } from './pm-plugins/toolbar';
|
|
12
|
+
import { buildSuppressedToolbar, buildToolbar, shouldSuppressFloatingToolbar } from './pm-plugins/toolbar';
|
|
12
13
|
import { getPluginState, hasAnyUnResolvedAnnotationInPage, stripNonExistingAnnotations } from './pm-plugins/utils';
|
|
13
14
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
14
15
|
export var annotationPlugin = function annotationPlugin(_ref) {
|
|
@@ -50,7 +51,8 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
50
51
|
dispatch: dispatch,
|
|
51
52
|
provider: annotationProviders.inlineComment,
|
|
52
53
|
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
53
|
-
featureFlagsPluginState: featureFlags
|
|
54
|
+
featureFlagsPluginState: featureFlags,
|
|
55
|
+
selectCommentExperience: annotationProviders.selectCommentExperience
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
return;
|
|
@@ -67,6 +69,19 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
67
69
|
}];
|
|
68
70
|
},
|
|
69
71
|
pluginsOptions: {
|
|
72
|
+
floatingToolbar: function floatingToolbar(state) {
|
|
73
|
+
if (!fg('platform_editor_fix_toolbar_comment_jump')) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
var pluginState = getPluginState(state);
|
|
77
|
+
var bookmark = pluginState === null || pluginState === void 0 ? void 0 : pluginState.bookmark;
|
|
78
|
+
if (shouldSuppressFloatingToolbar({
|
|
79
|
+
state: state,
|
|
80
|
+
bookmark: bookmark
|
|
81
|
+
})) {
|
|
82
|
+
return buildSuppressedToolbar(state);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
70
85
|
selectionToolbar: function selectionToolbar(state, intl) {
|
|
71
86
|
if (!annotationProviders) {
|
|
72
87
|
return;
|
|
@@ -209,8 +209,22 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
209
209
|
editorView.root.addEventListener('mouseup', mouseUp);
|
|
210
210
|
return {
|
|
211
211
|
update: function update(view, _prevState) {
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
if (fg('confluence_comments_select_comment_experience')) {
|
|
213
|
+
var _prevSelectedAnnotati;
|
|
214
|
+
var _ref4 = getPluginState(view.state) || {},
|
|
215
|
+
selectedAnnotations = _ref4.selectedAnnotations;
|
|
216
|
+
var _ref5 = getPluginState(_prevState) || {},
|
|
217
|
+
prevSelectedAnnotations = _ref5.selectedAnnotations;
|
|
218
|
+
|
|
219
|
+
// If the new state has a selected annotation, and it's different from the previous one
|
|
220
|
+
// then we mark the select annotation experience as complete
|
|
221
|
+
if (selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id !== (prevSelectedAnnotations === null || prevSelectedAnnotations === void 0 || (_prevSelectedAnnotati = prevSelectedAnnotations[0]) === null || _prevSelectedAnnotati === void 0 ? void 0 : _prevSelectedAnnotati.id)) {
|
|
222
|
+
var _options$selectCommen;
|
|
223
|
+
(_options$selectCommen = options.selectCommentExperience) === null || _options$selectCommen === void 0 || _options$selectCommen.selectAnnotation.complete(selectedAnnotations[0].id);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
var _ref6 = getPluginState(view.state) || {},
|
|
227
|
+
dirtyAnnotations = _ref6.dirtyAnnotations;
|
|
214
228
|
if (!dirtyAnnotations) {
|
|
215
229
|
return;
|
|
216
230
|
}
|
|
@@ -263,8 +277,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
263
277
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
264
278
|
return false;
|
|
265
279
|
}
|
|
266
|
-
var
|
|
267
|
-
annotations =
|
|
280
|
+
var _ref7 = pluginState || {},
|
|
281
|
+
annotations = _ref7.annotations;
|
|
268
282
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
269
283
|
if (!isUnresolved) {
|
|
270
284
|
return false;
|
|
@@ -275,13 +289,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
275
289
|
},
|
|
276
290
|
decorations: function decorations(state) {
|
|
277
291
|
// highlight comments, depending on state
|
|
278
|
-
var
|
|
279
|
-
draftDecorationSet =
|
|
280
|
-
annotations =
|
|
281
|
-
selectedAnnotations =
|
|
282
|
-
isVisible =
|
|
283
|
-
isInlineCommentViewClosed =
|
|
284
|
-
hoveredAnnotations =
|
|
292
|
+
var _ref8 = getPluginState(state) || {},
|
|
293
|
+
draftDecorationSet = _ref8.draftDecorationSet,
|
|
294
|
+
annotations = _ref8.annotations,
|
|
295
|
+
selectedAnnotations = _ref8.selectedAnnotations,
|
|
296
|
+
isVisible = _ref8.isVisible,
|
|
297
|
+
isInlineCommentViewClosed = _ref8.isInlineCommentViewClosed,
|
|
298
|
+
hoveredAnnotations = _ref8.hoveredAnnotations;
|
|
285
299
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
|
|
286
300
|
var focusDecorations = [];
|
|
287
301
|
state.doc.descendants(function (node, pos) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import {
|
|
3
|
+
import { ToolTipContent, addInlineComment } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
5
5
|
import { annotationMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead, getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
@@ -9,17 +9,53 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
9
9
|
import { setInlineCommentDraftState } from '../editor-commands';
|
|
10
10
|
import { AnnotationSelectionType, AnnotationTestIds } from '../types';
|
|
11
11
|
import { getPluginState, isSelectionValid, resolveDraftBookmark } from './utils';
|
|
12
|
+
export var getValidNodes = function getValidNodes(state) {
|
|
13
|
+
var schema = state.schema;
|
|
14
|
+
var annotation = schema.marks.annotation;
|
|
15
|
+
return Object.keys(schema.nodes).reduce(function (acc, current) {
|
|
16
|
+
var type = schema.nodes[current];
|
|
17
|
+
if (type.allowsMarkType(annotation)) {
|
|
18
|
+
acc.push(type);
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Should suppress toolbars when the user is creating an inline comment
|
|
25
|
+
* This only applies when the selection range exactly matches the bookmark range
|
|
26
|
+
* which should be the case immediately after the comment button is clicked
|
|
27
|
+
* if the user creates a different selection range, the floating toolbar should still be shown
|
|
28
|
+
*/
|
|
29
|
+
export var shouldSuppressFloatingToolbar = function shouldSuppressFloatingToolbar(_ref) {
|
|
30
|
+
var state = _ref.state,
|
|
31
|
+
bookmark = _ref.bookmark;
|
|
32
|
+
if (!bookmark) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
var tr = state.tr;
|
|
36
|
+
var resolvedBookmark = bookmark.resolve(tr.doc);
|
|
37
|
+
var isSelectionMatchingBookmark = resolvedBookmark.to === tr.selection.to && resolvedBookmark.from === tr.selection.from;
|
|
38
|
+
return isSelectionMatchingBookmark;
|
|
39
|
+
};
|
|
40
|
+
export var buildSuppressedToolbar = function buildSuppressedToolbar(state) {
|
|
41
|
+
return {
|
|
42
|
+
items: [],
|
|
43
|
+
nodeType: getValidNodes(state),
|
|
44
|
+
title: 'Annotation suppressed toolbar',
|
|
45
|
+
__suppressAllToolbars: true
|
|
46
|
+
};
|
|
47
|
+
};
|
|
12
48
|
export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
13
|
-
return function (
|
|
49
|
+
return function (_ref2) {
|
|
14
50
|
var _api$connectivity;
|
|
15
|
-
var state =
|
|
16
|
-
intl =
|
|
17
|
-
|
|
18
|
-
isToolbarAbove =
|
|
19
|
-
|
|
20
|
-
_supportedNodes =
|
|
21
|
-
api =
|
|
22
|
-
createCommentExperience =
|
|
51
|
+
var state = _ref2.state,
|
|
52
|
+
intl = _ref2.intl,
|
|
53
|
+
_ref2$isToolbarAbove = _ref2.isToolbarAbove,
|
|
54
|
+
isToolbarAbove = _ref2$isToolbarAbove === void 0 ? false : _ref2$isToolbarAbove,
|
|
55
|
+
_ref2$_supportedNodes = _ref2._supportedNodes,
|
|
56
|
+
_supportedNodes = _ref2$_supportedNodes === void 0 ? [] : _ref2$_supportedNodes,
|
|
57
|
+
api = _ref2.api,
|
|
58
|
+
createCommentExperience = _ref2.createCommentExperience;
|
|
23
59
|
var schema = state.schema;
|
|
24
60
|
var selectionValid = isSelectionValid(state);
|
|
25
61
|
var isMediaSelected = currentMediaNodeWithPos(state);
|
|
@@ -107,7 +143,7 @@ export var buildToolbar = function buildToolbar(editorAnalyticsAPI) {
|
|
|
107
143
|
var onPositionCalculated = calcToolbarPosition(toolbarTitle);
|
|
108
144
|
return {
|
|
109
145
|
title: toolbarTitle,
|
|
110
|
-
nodeType: validNodes,
|
|
146
|
+
nodeType: fg('platform_editor_fix_toolbar_comment_jump') ? getValidNodes(state) : validNodes,
|
|
111
147
|
items: [createComment],
|
|
112
148
|
onPositionCalculated: onPositionCalculated,
|
|
113
149
|
pluginName: 'annotation'
|
|
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { PopupPosition } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { SelectionBookmark, type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
9
9
|
import { AnnotationProviders } from '../types';
|
|
@@ -16,6 +16,24 @@ interface BuildToolbarOptions {
|
|
|
16
16
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
17
17
|
createCommentExperience?: AnnotationProviders['createCommentExperience'];
|
|
18
18
|
}
|
|
19
|
+
export declare const getValidNodes: (state: EditorState) => NodeType[];
|
|
20
|
+
type ShouldSuppressFloatingToolbarOptions = {
|
|
21
|
+
state: EditorState;
|
|
22
|
+
bookmark?: SelectionBookmark;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Should suppress toolbars when the user is creating an inline comment
|
|
26
|
+
* This only applies when the selection range exactly matches the bookmark range
|
|
27
|
+
* which should be the case immediately after the comment button is clicked
|
|
28
|
+
* if the user creates a different selection range, the floating toolbar should still be shown
|
|
29
|
+
*/
|
|
30
|
+
export declare const shouldSuppressFloatingToolbar: ({ state, bookmark, }: ShouldSuppressFloatingToolbarOptions) => boolean;
|
|
31
|
+
export declare const buildSuppressedToolbar: (state: EditorState) => {
|
|
32
|
+
items: never[];
|
|
33
|
+
nodeType: NodeType[];
|
|
34
|
+
title: string;
|
|
35
|
+
__suppressAllToolbars: boolean;
|
|
36
|
+
};
|
|
19
37
|
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, }: BuildToolbarOptions) => {
|
|
20
38
|
title: string;
|
|
21
39
|
nodeType: NodeType[];
|
|
@@ -3,7 +3,7 @@ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { AnnotationInfo, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
6
|
+
import type { AnnotationInfo, AnnotationProviders, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
7
7
|
export declare enum ACTIONS {
|
|
8
8
|
UPDATE_INLINE_COMMENT_STATE = 0,
|
|
9
9
|
SET_INLINE_COMMENT_DRAFT_STATE = 1,
|
|
@@ -20,6 +20,7 @@ export interface InlineCommentPluginOptions {
|
|
|
20
20
|
provider: InlineCommentAnnotationProvider;
|
|
21
21
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
22
22
|
featureFlagsPluginState?: FeatureFlags;
|
|
23
|
+
selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
|
|
23
24
|
}
|
|
24
25
|
export interface InlineCommentMouseData {
|
|
25
26
|
isSelecting: boolean;
|
|
@@ -93,4 +94,5 @@ export type InlineCommentPluginState = {
|
|
|
93
94
|
targetNodeId?: string;
|
|
94
95
|
selectAnnotationMethod?: VIEW_METHOD;
|
|
95
96
|
isOpeningMediaCommentFromToolbar?: boolean;
|
|
97
|
+
selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
|
|
96
98
|
};
|
|
@@ -121,6 +121,11 @@ export interface AnnotationProviders {
|
|
|
121
121
|
start: () => void;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
+
selectCommentExperience?: {
|
|
125
|
+
selectAnnotation: {
|
|
126
|
+
complete: (annotationId: string) => void;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
124
129
|
annotationManager?: AnnotationManager;
|
|
125
130
|
}
|
|
126
131
|
export declare enum AnnotationSelectionType {
|
|
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { PopupPosition } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import type { NodeType } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
import { type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { SelectionBookmark, type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
9
9
|
import { AnnotationProviders } from '../types';
|
|
@@ -16,6 +16,24 @@ interface BuildToolbarOptions {
|
|
|
16
16
|
api?: ExtractInjectionAPI<AnnotationPlugin>;
|
|
17
17
|
createCommentExperience?: AnnotationProviders['createCommentExperience'];
|
|
18
18
|
}
|
|
19
|
+
export declare const getValidNodes: (state: EditorState) => NodeType[];
|
|
20
|
+
type ShouldSuppressFloatingToolbarOptions = {
|
|
21
|
+
state: EditorState;
|
|
22
|
+
bookmark?: SelectionBookmark;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Should suppress toolbars when the user is creating an inline comment
|
|
26
|
+
* This only applies when the selection range exactly matches the bookmark range
|
|
27
|
+
* which should be the case immediately after the comment button is clicked
|
|
28
|
+
* if the user creates a different selection range, the floating toolbar should still be shown
|
|
29
|
+
*/
|
|
30
|
+
export declare const shouldSuppressFloatingToolbar: ({ state, bookmark, }: ShouldSuppressFloatingToolbarOptions) => boolean;
|
|
31
|
+
export declare const buildSuppressedToolbar: (state: EditorState) => {
|
|
32
|
+
items: never[];
|
|
33
|
+
nodeType: NodeType[];
|
|
34
|
+
title: string;
|
|
35
|
+
__suppressAllToolbars: boolean;
|
|
36
|
+
};
|
|
19
37
|
export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, }: BuildToolbarOptions) => {
|
|
20
38
|
title: string;
|
|
21
39
|
nodeType: NodeType[];
|
|
@@ -3,7 +3,7 @@ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
|
3
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { EditorState, SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
|
-
import type { AnnotationInfo, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
6
|
+
import type { AnnotationInfo, AnnotationProviders, InlineCommentAnnotationProvider, TargetType } from '../types';
|
|
7
7
|
export declare enum ACTIONS {
|
|
8
8
|
UPDATE_INLINE_COMMENT_STATE = 0,
|
|
9
9
|
SET_INLINE_COMMENT_DRAFT_STATE = 1,
|
|
@@ -20,6 +20,7 @@ export interface InlineCommentPluginOptions {
|
|
|
20
20
|
provider: InlineCommentAnnotationProvider;
|
|
21
21
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
22
22
|
featureFlagsPluginState?: FeatureFlags;
|
|
23
|
+
selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
|
|
23
24
|
}
|
|
24
25
|
export interface InlineCommentMouseData {
|
|
25
26
|
isSelecting: boolean;
|
|
@@ -93,4 +94,5 @@ export type InlineCommentPluginState = {
|
|
|
93
94
|
targetNodeId?: string;
|
|
94
95
|
selectAnnotationMethod?: VIEW_METHOD;
|
|
95
96
|
isOpeningMediaCommentFromToolbar?: boolean;
|
|
97
|
+
selectCommentExperience?: AnnotationProviders['selectCommentExperience'];
|
|
96
98
|
};
|
|
@@ -121,6 +121,11 @@ export interface AnnotationProviders {
|
|
|
121
121
|
start: () => void;
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
+
selectCommentExperience?: {
|
|
125
|
+
selectAnnotation: {
|
|
126
|
+
complete: (annotationId: string) => void;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
124
129
|
annotationManager?: AnnotationManager;
|
|
125
130
|
}
|
|
126
131
|
export declare enum AnnotationSelectionType {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
|
-
"@atlaskit/editor-common": "^103.
|
|
35
|
+
"@atlaskit/editor-common": "^103.6.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-connectivity": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^2.0.0",
|
|
@@ -108,11 +108,17 @@
|
|
|
108
108
|
"platform_editor_listen_for_annotation_clicks": {
|
|
109
109
|
"type": "boolean"
|
|
110
110
|
},
|
|
111
|
+
"platform_editor_fix_toolbar_comment_jump": {
|
|
112
|
+
"type": "boolean"
|
|
113
|
+
},
|
|
111
114
|
"platform_editor_annotation_selected_annotation": {
|
|
112
115
|
"type": "boolean"
|
|
113
116
|
},
|
|
114
117
|
"platform_editor_listen_for_focussed_query_param": {
|
|
115
118
|
"type": "boolean"
|
|
119
|
+
},
|
|
120
|
+
"confluence_comments_select_comment_experience": {
|
|
121
|
+
"type": "boolean"
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
}
|