@atlaskit/editor-plugin-annotation 1.10.1 → 1.10.3
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 +22 -0
- package/dist/cjs/commands/index.js +1 -1
- package/dist/cjs/commands/transform.js +24 -1
- package/dist/cjs/ui/InlineCommentView.js +15 -8
- package/dist/cjs/utils.js +9 -1
- package/dist/es2019/commands/index.js +1 -1
- package/dist/es2019/commands/transform.js +19 -1
- package/dist/es2019/ui/InlineCommentView.js +8 -1
- package/dist/es2019/utils.js +9 -1
- package/dist/esm/commands/index.js +1 -1
- package/dist/esm/commands/transform.js +24 -1
- package/dist/esm/ui/InlineCommentView.js +8 -1
- package/dist/esm/utils.js +9 -1
- package/dist/types/commands/transform.d.ts +9 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types-ts4.5/commands/transform.d.ts +9 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/package.json +105 -105
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 1.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#110714](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110714)
|
|
8
|
+
[`9e5e71458aec6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9e5e71458aec6) -
|
|
9
|
+
[ED-23281] Explictly opt out scrollIntoView when adding annotation mark as it is handled by
|
|
10
|
+
scrolling comment sidebar into view instead
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 1.10.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#111460](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111460)
|
|
18
|
+
[`c7cfc31d4a7b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c7cfc31d4a7b6) -
|
|
19
|
+
ED-23707 fix issue where comment ui was not triggered on commented node selections.
|
|
20
|
+
- [#110966](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110966)
|
|
21
|
+
[`31348c335b4b3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/31348c335b4b3) -
|
|
22
|
+
ED-23690 - add inlineNodeTypes property to AnnotationComponentProps
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 1.10.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -179,7 +179,7 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
|
|
|
179
179
|
var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
180
180
|
var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
181
181
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
|
|
182
|
-
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.
|
|
182
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -42,7 +42,7 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
42
42
|
var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
43
43
|
return function (id, supportedBlockNodes) {
|
|
44
44
|
return function (transaction, state) {
|
|
45
|
-
var _editorAPI$editorView;
|
|
45
|
+
var _editorAPI$editorView, _pluginState$featureF;
|
|
46
46
|
var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
47
47
|
editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
48
48
|
|
|
@@ -50,6 +50,12 @@ var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI)
|
|
|
50
50
|
tr = addInsertAnalytics(editorAnalyticsAPI)(tr, state);
|
|
51
51
|
// add close analytics step to transaction
|
|
52
52
|
tr = addOpenCloseAnalytics(editorAnalyticsAPI)(false, _analytics.INPUT_METHOD.TOOLBAR)(tr, state);
|
|
53
|
+
var pluginState = (0, _utils2.getPluginState)(state);
|
|
54
|
+
var isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 || (_pluginState$featureF = pluginState.featureFlagsPluginState) === null || _pluginState$featureF === void 0 ? void 0 : _pluginState$featureF.commentsOnMediaAutoscrollInEditor;
|
|
55
|
+
if (isAutoScrollBugFixEnabled) {
|
|
56
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
57
|
+
tr.setMeta('scrollIntoView', false);
|
|
58
|
+
}
|
|
53
59
|
return tr;
|
|
54
60
|
};
|
|
55
61
|
};
|
|
@@ -64,6 +70,22 @@ var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
|
|
|
64
70
|
};
|
|
65
71
|
};
|
|
66
72
|
};
|
|
73
|
+
var handleDraftState = function handleDraftState(editorAnalyticsAPI) {
|
|
74
|
+
return function (drafting) {
|
|
75
|
+
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
76
|
+
return function (transaction, state) {
|
|
77
|
+
var _pluginState$featureF2;
|
|
78
|
+
var tr = addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, method)(transaction, state);
|
|
79
|
+
var pluginState = (0, _utils2.getPluginState)(state);
|
|
80
|
+
var isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 || (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaAutoscrollInEditor;
|
|
81
|
+
if (isAutoScrollBugFixEnabled) {
|
|
82
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
83
|
+
tr.setMeta('scrollIntoView', false);
|
|
84
|
+
}
|
|
85
|
+
return tr;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
67
89
|
var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
|
|
68
90
|
return function (transaction, state) {
|
|
69
91
|
var analyticsEvent = {
|
|
@@ -109,6 +131,7 @@ var addResolveAnalytics = function addResolveAnalytics(editorAnalyticsAPI) {
|
|
|
109
131
|
var _default = exports.default = {
|
|
110
132
|
addAnnotationMark: addAnnotationMark,
|
|
111
133
|
addInlineComment: addInlineComment,
|
|
134
|
+
handleDraftState: handleDraftState,
|
|
112
135
|
addOpenCloseAnalytics: addOpenCloseAnalytics,
|
|
113
136
|
addInsertAnalytics: addInsertAnalytics,
|
|
114
137
|
addResolveAnalytics: addResolveAnalytics
|
|
@@ -9,10 +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 _utils = require("@atlaskit/editor-
|
|
12
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
14
|
var _commands = require("../commands");
|
|
14
15
|
var _types = require("../types");
|
|
15
|
-
var
|
|
16
|
+
var _utils3 = require("../utils");
|
|
16
17
|
var _AnnotationViewWrapper = require("./AnnotationViewWrapper");
|
|
17
18
|
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; }
|
|
18
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -44,18 +45,18 @@ function InlineCommentView(_ref) {
|
|
|
44
45
|
dispatch = editorView.dispatch;
|
|
45
46
|
var CreateComponent = inlineCommentProvider.createComponent,
|
|
46
47
|
ViewComponent = inlineCommentProvider.viewComponent;
|
|
47
|
-
var inlineCommentState = (0,
|
|
48
|
+
var inlineCommentState = (0, _utils3.getPluginState)(state);
|
|
48
49
|
var _ref2 = inlineCommentState || {},
|
|
49
50
|
bookmark = _ref2.bookmark,
|
|
50
51
|
selectedAnnotations = _ref2.selectedAnnotations,
|
|
51
52
|
annotations = _ref2.annotations,
|
|
52
53
|
isInlineCommentViewClosed = _ref2.isInlineCommentViewClosed;
|
|
53
|
-
var annotationsList = (0,
|
|
54
|
-
var selection = (0,
|
|
54
|
+
var annotationsList = (0, _utils3.getAllAnnotations)(editorView.state.doc);
|
|
55
|
+
var selection = (0, _utils3.getSelectionPositions)(state, inlineCommentState);
|
|
55
56
|
var position = findPosForDOM(selection);
|
|
56
57
|
var dom;
|
|
57
58
|
try {
|
|
58
|
-
dom = (0,
|
|
59
|
+
dom = (0, _utils2.findDomRefAtPos)(position, editorView.domAtPos.bind(editorView));
|
|
59
60
|
} catch (error) {
|
|
60
61
|
// eslint-disable-next-line no-console
|
|
61
62
|
console.warn(error);
|
|
@@ -78,6 +79,10 @@ function InlineCommentView(_ref) {
|
|
|
78
79
|
if (!dom) {
|
|
79
80
|
return null;
|
|
80
81
|
}
|
|
82
|
+
var inlineNodeTypes = (0, _utils.getRangeInlineNodeNames)({
|
|
83
|
+
doc: state.doc,
|
|
84
|
+
pos: selection
|
|
85
|
+
});
|
|
81
86
|
|
|
82
87
|
// Create Component
|
|
83
88
|
if (bookmark) {
|
|
@@ -100,7 +105,8 @@ function InlineCommentView(_ref) {
|
|
|
100
105
|
onClose: function onClose() {
|
|
101
106
|
(0, _commands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
102
107
|
!editorView.hasFocus() && editorView.focus();
|
|
103
|
-
}
|
|
108
|
+
},
|
|
109
|
+
inlineNodeTypes: inlineNodeTypes
|
|
104
110
|
}));
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -142,11 +148,12 @@ function InlineCommentView(_ref) {
|
|
|
142
148
|
return /*#__PURE__*/_react.default.createElement(_AnnotationViewWrapper.AnnotationViewWrapper, {
|
|
143
149
|
"data-editor-popup": "true",
|
|
144
150
|
"data-testid": _types.AnnotationTestIds.floatingComponent,
|
|
145
|
-
key: (0,
|
|
151
|
+
key: (0, _utils3.getAnnotationViewKey)(activeAnnotations),
|
|
146
152
|
onViewed: onAnnotationViewed
|
|
147
153
|
}, /*#__PURE__*/_react.default.createElement(ViewComponent, {
|
|
148
154
|
annotationsList: annotationsList,
|
|
149
155
|
annotations: activeAnnotations,
|
|
156
|
+
inlineNodeTypes: inlineNodeTypes,
|
|
150
157
|
dom: dom,
|
|
151
158
|
onDelete: function onDelete(id) {
|
|
152
159
|
return (0, _commands.removeInlineCommentNearSelection)(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
|
package/dist/cjs/utils.js
CHANGED
|
@@ -173,7 +173,15 @@ var findAnnotationsInSelection = exports.findAnnotationsInSelection = function f
|
|
|
173
173
|
anchor = selection.anchor;
|
|
174
174
|
// Only detect annotations on caret selection
|
|
175
175
|
if (!empty || !doc) {
|
|
176
|
-
|
|
176
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
|
|
177
|
+
if (selection instanceof _state.NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
|
|
178
|
+
// Inline comments on these nodes are supported -- so we continue to find annotations
|
|
179
|
+
} else {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
177
185
|
}
|
|
178
186
|
var node = doc.nodeAt(anchor);
|
|
179
187
|
var nodeBefore = $anchor.nodeBefore;
|
|
@@ -148,7 +148,7 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
|
|
|
148
148
|
};
|
|
149
149
|
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', isCommentOnMediaOn = false, targetNodeId = undefined) => {
|
|
150
150
|
const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
|
|
151
|
-
return createCommand(commandAction, transform.
|
|
151
|
+
return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
152
152
|
};
|
|
153
153
|
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
|
|
154
154
|
const commandAction = editorState => ({
|
|
@@ -34,7 +34,7 @@ const addAnnotationMark = (id, supportedBlockNodes) => (transaction, state) => {
|
|
|
34
34
|
return tr;
|
|
35
35
|
};
|
|
36
36
|
const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => (transaction, state) => {
|
|
37
|
-
var _editorAPI$editorView;
|
|
37
|
+
var _editorAPI$editorView, _pluginState$featureF;
|
|
38
38
|
let tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
39
39
|
editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 ? void 0 : _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
40
40
|
|
|
@@ -42,6 +42,12 @@ const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockN
|
|
|
42
42
|
tr = addInsertAnalytics(editorAnalyticsAPI)(tr, state);
|
|
43
43
|
// add close analytics step to transaction
|
|
44
44
|
tr = addOpenCloseAnalytics(editorAnalyticsAPI)(false, INPUT_METHOD.TOOLBAR)(tr, state);
|
|
45
|
+
const pluginState = getPluginState(state);
|
|
46
|
+
const isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$featureF = pluginState.featureFlagsPluginState) === null || _pluginState$featureF === void 0 ? void 0 : _pluginState$featureF.commentsOnMediaAutoscrollInEditor;
|
|
47
|
+
if (isAutoScrollBugFixEnabled) {
|
|
48
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
49
|
+
tr.setMeta('scrollIntoView', false);
|
|
50
|
+
}
|
|
45
51
|
return tr;
|
|
46
52
|
};
|
|
47
53
|
const addOpenCloseAnalytics = editorAnalyticsAPI => (drafting, method = INPUT_METHOD.TOOLBAR) => (transaction, state) => {
|
|
@@ -49,6 +55,17 @@ const addOpenCloseAnalytics = editorAnalyticsAPI => (drafting, method = INPUT_ME
|
|
|
49
55
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(draftingPayload)(transaction);
|
|
50
56
|
return transaction;
|
|
51
57
|
};
|
|
58
|
+
const handleDraftState = editorAnalyticsAPI => (drafting, method = INPUT_METHOD.TOOLBAR) => (transaction, state) => {
|
|
59
|
+
var _pluginState$featureF2;
|
|
60
|
+
const tr = addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, method)(transaction, state);
|
|
61
|
+
const pluginState = getPluginState(state);
|
|
62
|
+
const isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 ? void 0 : (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaAutoscrollInEditor;
|
|
63
|
+
if (isAutoScrollBugFixEnabled) {
|
|
64
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
65
|
+
tr.setMeta('scrollIntoView', false);
|
|
66
|
+
}
|
|
67
|
+
return tr;
|
|
68
|
+
};
|
|
52
69
|
const addInsertAnalytics = editorAnalyticsAPI => (transaction, state) => {
|
|
53
70
|
const analyticsEvent = {
|
|
54
71
|
action: ACTION.INSERTED,
|
|
@@ -89,6 +106,7 @@ const addResolveAnalytics = editorAnalyticsAPI => method => (transaction, state)
|
|
|
89
106
|
export default {
|
|
90
107
|
addAnnotationMark,
|
|
91
108
|
addInlineComment,
|
|
109
|
+
handleDraftState,
|
|
92
110
|
addOpenCloseAnalytics,
|
|
93
111
|
addInsertAnalytics,
|
|
94
112
|
addResolveAnalytics
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
|
|
6
7
|
import { AnnotationTestIds } from '../types';
|
|
@@ -76,6 +77,10 @@ export function InlineCommentView({
|
|
|
76
77
|
if (!dom) {
|
|
77
78
|
return null;
|
|
78
79
|
}
|
|
80
|
+
const inlineNodeTypes = getRangeInlineNodeNames({
|
|
81
|
+
doc: state.doc,
|
|
82
|
+
pos: selection
|
|
83
|
+
});
|
|
79
84
|
|
|
80
85
|
// Create Component
|
|
81
86
|
if (bookmark) {
|
|
@@ -98,7 +103,8 @@ export function InlineCommentView({
|
|
|
98
103
|
onClose: () => {
|
|
99
104
|
setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
100
105
|
!editorView.hasFocus() && editorView.focus();
|
|
101
|
-
}
|
|
106
|
+
},
|
|
107
|
+
inlineNodeTypes: inlineNodeTypes
|
|
102
108
|
}));
|
|
103
109
|
}
|
|
104
110
|
|
|
@@ -145,6 +151,7 @@ export function InlineCommentView({
|
|
|
145
151
|
}, /*#__PURE__*/React.createElement(ViewComponent, {
|
|
146
152
|
annotationsList: annotationsList,
|
|
147
153
|
annotations: activeAnnotations,
|
|
154
|
+
inlineNodeTypes: inlineNodeTypes,
|
|
148
155
|
dom: dom,
|
|
149
156
|
onDelete: id => removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch),
|
|
150
157
|
onResolve: id => updateInlineCommentResolvedState(editorAnalyticsAPI)({
|
package/dist/es2019/utils.js
CHANGED
|
@@ -136,7 +136,15 @@ export const findAnnotationsInSelection = (selection, doc, isCommentsOnMediaMedi
|
|
|
136
136
|
} = selection;
|
|
137
137
|
// Only detect annotations on caret selection
|
|
138
138
|
if (!empty || !doc) {
|
|
139
|
-
|
|
139
|
+
if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
|
|
140
|
+
if (selection instanceof NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
|
|
141
|
+
// Inline comments on these nodes are supported -- so we continue to find annotations
|
|
142
|
+
} else {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
140
148
|
}
|
|
141
149
|
const node = doc.nodeAt(anchor);
|
|
142
150
|
const nodeBefore = $anchor.nodeBefore;
|
|
@@ -172,7 +172,7 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
|
|
|
172
172
|
var isCommentOnMediaOn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
173
173
|
var targetNodeId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
174
174
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, isCommentOnMediaOn, supportedBlockNodes);
|
|
175
|
-
return createCommand(commandAction, transform.
|
|
175
|
+
return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
176
176
|
};
|
|
177
177
|
};
|
|
178
178
|
export var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -36,7 +36,7 @@ var addAnnotationMark = function addAnnotationMark(id, supportedBlockNodes) {
|
|
|
36
36
|
var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
37
37
|
return function (id, supportedBlockNodes) {
|
|
38
38
|
return function (transaction, state) {
|
|
39
|
-
var _editorAPI$editorView;
|
|
39
|
+
var _editorAPI$editorView, _pluginState$featureF;
|
|
40
40
|
var tr = addAnnotationMark(id, supportedBlockNodes)(transaction, state);
|
|
41
41
|
editorAPI === null || editorAPI === void 0 || (_editorAPI$editorView = editorAPI.editorViewMode) === null || _editorAPI$editorView === void 0 || _editorAPI$editorView.actions.applyViewModeStepAt(tr);
|
|
42
42
|
|
|
@@ -44,6 +44,12 @@ var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI)
|
|
|
44
44
|
tr = addInsertAnalytics(editorAnalyticsAPI)(tr, state);
|
|
45
45
|
// add close analytics step to transaction
|
|
46
46
|
tr = addOpenCloseAnalytics(editorAnalyticsAPI)(false, INPUT_METHOD.TOOLBAR)(tr, state);
|
|
47
|
+
var pluginState = getPluginState(state);
|
|
48
|
+
var isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 || (_pluginState$featureF = pluginState.featureFlagsPluginState) === null || _pluginState$featureF === void 0 ? void 0 : _pluginState$featureF.commentsOnMediaAutoscrollInEditor;
|
|
49
|
+
if (isAutoScrollBugFixEnabled) {
|
|
50
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
51
|
+
tr.setMeta('scrollIntoView', false);
|
|
52
|
+
}
|
|
47
53
|
return tr;
|
|
48
54
|
};
|
|
49
55
|
};
|
|
@@ -58,6 +64,22 @@ var addOpenCloseAnalytics = function addOpenCloseAnalytics(editorAnalyticsAPI) {
|
|
|
58
64
|
};
|
|
59
65
|
};
|
|
60
66
|
};
|
|
67
|
+
var handleDraftState = function handleDraftState(editorAnalyticsAPI) {
|
|
68
|
+
return function (drafting) {
|
|
69
|
+
var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
70
|
+
return function (transaction, state) {
|
|
71
|
+
var _pluginState$featureF2;
|
|
72
|
+
var tr = addOpenCloseAnalytics(editorAnalyticsAPI)(drafting, method)(transaction, state);
|
|
73
|
+
var pluginState = getPluginState(state);
|
|
74
|
+
var isAutoScrollBugFixEnabled = pluginState === null || pluginState === void 0 || (_pluginState$featureF2 = pluginState.featureFlagsPluginState) === null || _pluginState$featureF2 === void 0 ? void 0 : _pluginState$featureF2.commentsOnMediaAutoscrollInEditor;
|
|
75
|
+
if (isAutoScrollBugFixEnabled) {
|
|
76
|
+
// Explicitly disable scrollIntoView as scrolling is handled by CommentSidebar
|
|
77
|
+
tr.setMeta('scrollIntoView', false);
|
|
78
|
+
}
|
|
79
|
+
return tr;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
61
83
|
var addInsertAnalytics = function addInsertAnalytics(editorAnalyticsAPI) {
|
|
62
84
|
return function (transaction, state) {
|
|
63
85
|
var analyticsEvent = {
|
|
@@ -103,6 +125,7 @@ var addResolveAnalytics = function addResolveAnalytics(editorAnalyticsAPI) {
|
|
|
103
125
|
export default {
|
|
104
126
|
addAnnotationMark: addAnnotationMark,
|
|
105
127
|
addInlineComment: addInlineComment,
|
|
128
|
+
handleDraftState: handleDraftState,
|
|
106
129
|
addOpenCloseAnalytics: addOpenCloseAnalytics,
|
|
107
130
|
addInsertAnalytics: addInsertAnalytics,
|
|
108
131
|
addResolveAnalytics: addResolveAnalytics
|
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, CONTENT_COMPONENT, EVENT_TYPE, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { getRangeInlineNodeNames } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
8
9
|
import { closeComponent, createAnnotation, removeInlineCommentNearSelection, setInlineCommentDraftState, updateInlineCommentResolvedState } from '../commands';
|
|
9
10
|
import { AnnotationTestIds } from '../types';
|
|
@@ -71,6 +72,10 @@ export function InlineCommentView(_ref) {
|
|
|
71
72
|
if (!dom) {
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
75
|
+
var inlineNodeTypes = getRangeInlineNodeNames({
|
|
76
|
+
doc: state.doc,
|
|
77
|
+
pos: selection
|
|
78
|
+
});
|
|
74
79
|
|
|
75
80
|
// Create Component
|
|
76
81
|
if (bookmark) {
|
|
@@ -93,7 +98,8 @@ export function InlineCommentView(_ref) {
|
|
|
93
98
|
onClose: function onClose() {
|
|
94
99
|
setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
95
100
|
!editorView.hasFocus() && editorView.focus();
|
|
96
|
-
}
|
|
101
|
+
},
|
|
102
|
+
inlineNodeTypes: inlineNodeTypes
|
|
97
103
|
}));
|
|
98
104
|
}
|
|
99
105
|
|
|
@@ -140,6 +146,7 @@ export function InlineCommentView(_ref) {
|
|
|
140
146
|
}, /*#__PURE__*/React.createElement(ViewComponent, {
|
|
141
147
|
annotationsList: annotationsList,
|
|
142
148
|
annotations: activeAnnotations,
|
|
149
|
+
inlineNodeTypes: inlineNodeTypes,
|
|
143
150
|
dom: dom,
|
|
144
151
|
onDelete: function onDelete(id) {
|
|
145
152
|
return removeInlineCommentNearSelection(id, inlineCommentProvider.supportedBlockNodes)(state, dispatch);
|
package/dist/esm/utils.js
CHANGED
|
@@ -146,7 +146,15 @@ export var findAnnotationsInSelection = function findAnnotationsInSelection(sele
|
|
|
146
146
|
anchor = selection.anchor;
|
|
147
147
|
// Only detect annotations on caret selection
|
|
148
148
|
if (!empty || !doc) {
|
|
149
|
-
|
|
149
|
+
if (getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz')) {
|
|
150
|
+
if (selection instanceof NodeSelection && ['inlineCard', 'emoji', 'date', 'mention', 'status'].includes(selection.node.type.name)) {
|
|
151
|
+
// Inline comments on these nodes are supported -- so we continue to find annotations
|
|
152
|
+
} else {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
150
158
|
}
|
|
151
159
|
var node = doc.nodeAt(anchor);
|
|
152
160
|
var nodeBefore = $anchor.nodeBefore;
|
|
@@ -49,6 +49,10 @@ declare const _default: {
|
|
|
49
49
|
to: number;
|
|
50
50
|
mark: import("prosemirror-model").Mark;
|
|
51
51
|
}) => boolean;
|
|
52
|
+
addInlineCommentNodeMark: (props: {
|
|
53
|
+
pos: number;
|
|
54
|
+
mark: import("prosemirror-model").Mark;
|
|
55
|
+
}) => boolean;
|
|
52
56
|
isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
|
|
53
57
|
};
|
|
54
58
|
}, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>];
|
|
@@ -115,6 +119,10 @@ declare const _default: {
|
|
|
115
119
|
to: number;
|
|
116
120
|
mark: import("prosemirror-model").Mark;
|
|
117
121
|
}) => boolean;
|
|
122
|
+
addInlineCommentNodeMark: (props: {
|
|
123
|
+
pos: number;
|
|
124
|
+
mark: import("prosemirror-model").Mark;
|
|
125
|
+
}) => boolean;
|
|
118
126
|
isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
|
|
119
127
|
};
|
|
120
128
|
}, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>];
|
|
@@ -133,6 +141,7 @@ declare const _default: {
|
|
|
133
141
|
pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
134
142
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
135
143
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>]> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
144
|
+
handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
136
145
|
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
137
146
|
addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
138
147
|
addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ type AnnotationComponentProps = {
|
|
|
61
61
|
* Indicates that a draft comment was discarded/cancelled
|
|
62
62
|
*/
|
|
63
63
|
onClose?: () => void;
|
|
64
|
+
/** List of inline node types, which are wrapped by the annotation. */
|
|
65
|
+
inlineNodeTypes: string[] | undefined;
|
|
64
66
|
};
|
|
65
67
|
export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
|
|
66
68
|
/**
|
|
@@ -60,6 +60,10 @@ declare const _default: {
|
|
|
60
60
|
to: number;
|
|
61
61
|
mark: import("prosemirror-model").Mark;
|
|
62
62
|
}) => boolean;
|
|
63
|
+
addInlineCommentNodeMark: (props: {
|
|
64
|
+
pos: number;
|
|
65
|
+
mark: import("prosemirror-model").Mark;
|
|
66
|
+
}) => boolean;
|
|
63
67
|
isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
|
|
64
68
|
};
|
|
65
69
|
}, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
|
|
@@ -139,6 +143,10 @@ declare const _default: {
|
|
|
139
143
|
to: number;
|
|
140
144
|
mark: import("prosemirror-model").Mark;
|
|
141
145
|
}) => boolean;
|
|
146
|
+
addInlineCommentNodeMark: (props: {
|
|
147
|
+
pos: number;
|
|
148
|
+
mark: import("prosemirror-model").Mark;
|
|
149
|
+
}) => boolean;
|
|
142
150
|
isRemoteReplaceDocumentTransaction: (tr: Transaction) => boolean;
|
|
143
151
|
};
|
|
144
152
|
}, import("@atlaskit/editor-plugin-collab-edit").PrivateCollabEditOptions>
|
|
@@ -160,6 +168,7 @@ declare const _default: {
|
|
|
160
168
|
sharedState: import("@atlaskit/editor-common/types").FeatureFlags;
|
|
161
169
|
}, import("@atlaskit/editor-common/types").FeatureFlags>>
|
|
162
170
|
]> | undefined) => (id: string, supportedBlockNodes?: string[] | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
171
|
+
handleDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
163
172
|
addOpenCloseAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (drafting: boolean, method?: InlineCommentInputMethod) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
164
173
|
addInsertAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
165
174
|
addResolveAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (method?: RESOLVE_METHOD | undefined) => (transaction: Transaction, state: EditorState) => Transaction;
|
|
@@ -61,6 +61,8 @@ type AnnotationComponentProps = {
|
|
|
61
61
|
* Indicates that a draft comment was discarded/cancelled
|
|
62
62
|
*/
|
|
63
63
|
onClose?: () => void;
|
|
64
|
+
/** List of inline node types, which are wrapped by the annotation. */
|
|
65
|
+
inlineNodeTypes: string[] | undefined;
|
|
64
66
|
};
|
|
65
67
|
export type InlineCommentCreateComponentProps = AnnotationComponentProps & {
|
|
66
68
|
/**
|
package/package.json
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
2
|
+
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
+
"version": "1.10.3",
|
|
4
|
+
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Editor: AI",
|
|
12
|
+
"singleton": true,
|
|
13
|
+
"releaseModel": "continuous",
|
|
14
|
+
"runReact18": false
|
|
15
|
+
},
|
|
16
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
17
|
+
"main": "dist/cjs/index.js",
|
|
18
|
+
"module": "dist/esm/index.js",
|
|
19
|
+
"module:es2019": "dist/es2019/index.js",
|
|
20
|
+
"types": "dist/types/index.d.ts",
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
">=4.5 <4.9": {
|
|
23
|
+
"*": [
|
|
24
|
+
"dist/types-ts4.5/*",
|
|
25
|
+
"dist/types-ts4.5/index.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"atlaskit:src": "src/index.ts",
|
|
31
|
+
"af:exports": {
|
|
32
|
+
".": "./src/index.ts"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@atlaskit/adf-schema": "^36.10.7",
|
|
36
|
+
"@atlaskit/editor-common": "^82.9.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
38
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^1.2.0",
|
|
39
|
+
"@atlaskit/editor-plugin-feature-flags": "^1.1.0",
|
|
40
|
+
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
41
|
+
"@atlaskit/icon": "^22.4.0",
|
|
42
|
+
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
43
|
+
"@babel/runtime": "^7.0.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^16.8.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@af/integration-testing": "*",
|
|
50
|
+
"@af/visual-regression": "*",
|
|
51
|
+
"@atlaskit/ssr": "*",
|
|
52
|
+
"@atlaskit/visual-regression": "*",
|
|
53
|
+
"@atlassian/feature-flags-test-utils": "^0.2.0",
|
|
54
|
+
"@testing-library/react": "^12.1.5",
|
|
55
|
+
"react-dom": "^16.8.0",
|
|
56
|
+
"typescript": "~5.4.2",
|
|
57
|
+
"wait-for-expect": "^1.2.0"
|
|
58
|
+
},
|
|
59
|
+
"techstack": {
|
|
60
|
+
"@atlassian/frontend": {
|
|
61
|
+
"import-structure": [
|
|
62
|
+
"atlassian-conventions"
|
|
63
|
+
],
|
|
64
|
+
"circular-dependencies": [
|
|
65
|
+
"file-and-folder-level"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"@repo/internal": {
|
|
69
|
+
"dom-events": "use-bind-event-listener",
|
|
70
|
+
"analytics": [
|
|
71
|
+
"analytics-next"
|
|
72
|
+
],
|
|
73
|
+
"design-tokens": [
|
|
74
|
+
"color"
|
|
75
|
+
],
|
|
76
|
+
"theming": [
|
|
77
|
+
"react-context"
|
|
78
|
+
],
|
|
79
|
+
"ui-components": [
|
|
80
|
+
"lite-mode"
|
|
81
|
+
],
|
|
82
|
+
"deprecation": "no-deprecated-imports",
|
|
83
|
+
"styling": [
|
|
84
|
+
"emotion",
|
|
85
|
+
"emotion"
|
|
86
|
+
],
|
|
87
|
+
"imports": [
|
|
88
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"platform-feature-flags": {
|
|
93
|
+
"platform.editor.enable-selection-toolbar_ucdwd": {
|
|
94
|
+
"type": "boolean"
|
|
95
|
+
},
|
|
96
|
+
"platform.editor.allow-inline-comments-for-inline-nodes": {
|
|
97
|
+
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"platform.editor.allow-inline-comments-for-inline-nodes-round-2_ctuxz": {
|
|
100
|
+
"type": "boolean"
|
|
101
|
+
},
|
|
102
|
+
"platform.editor.comments-on-media.bug.preserve-draft_i3vqb": {
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|