@atlaskit/editor-plugin-annotation 4.0.4 → 4.0.5
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 +8 -0
- package/dist/cjs/annotationPlugin.js +5 -6
- package/dist/cjs/editor-commands/index.js +40 -2
- package/dist/cjs/editor-commands/utils.js +18 -0
- package/dist/cjs/pm-plugins/annotation-manager-hooks.js +2 -2
- package/dist/cjs/pm-plugins/inline-comment.js +59 -36
- package/dist/cjs/pm-plugins/keymap.js +3 -2
- package/dist/cjs/ui/CommentButton/utils.js +1 -1
- package/dist/cjs/ui/InlineCommentView.js +1 -1
- package/dist/es2019/annotationPlugin.js +5 -6
- package/dist/es2019/editor-commands/index.js +40 -3
- package/dist/es2019/editor-commands/utils.js +12 -0
- package/dist/es2019/pm-plugins/annotation-manager-hooks.js +2 -2
- package/dist/es2019/pm-plugins/inline-comment.js +28 -2
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/es2019/ui/CommentButton/utils.js +1 -1
- package/dist/es2019/ui/InlineCommentView.js +1 -1
- package/dist/esm/annotationPlugin.js +5 -6
- package/dist/esm/editor-commands/index.js +40 -2
- package/dist/esm/editor-commands/utils.js +12 -0
- package/dist/esm/pm-plugins/annotation-manager-hooks.js +2 -2
- package/dist/esm/pm-plugins/inline-comment.js +47 -24
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/esm/ui/CommentButton/utils.js +1 -1
- package/dist/esm/ui/InlineCommentView.js +1 -1
- package/dist/types/annotationPluginType.d.ts +3 -1
- package/dist/types/editor-commands/index.d.ts +1 -1
- package/dist/types/editor-commands/utils.d.ts +5 -0
- package/dist/types/pm-plugins/keymap.d.ts +3 -2
- package/dist/types-ts4.5/annotationPluginType.d.ts +3 -1
- package/dist/types-ts4.5/editor-commands/index.d.ts +1 -1
- package/dist/types-ts4.5/editor-commands/utils.d.ts +5 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 4.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a8630c1107c3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a8630c1107c3d) -
|
|
8
|
+
[ED-28781] Hide inline text toolbar when other popups are open
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 4.0.4
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -79,8 +79,7 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
79
79
|
name: 'annotationKeymap',
|
|
80
80
|
plugin: function plugin() {
|
|
81
81
|
if (annotationProviders) {
|
|
82
|
-
|
|
83
|
-
return (0, _keymap.keymapPlugin)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
82
|
+
return (0, _keymap.keymapPlugin)(api);
|
|
84
83
|
}
|
|
85
84
|
return;
|
|
86
85
|
}
|
|
@@ -106,13 +105,13 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
106
105
|
}
|
|
107
106
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
108
107
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
109
|
-
var _api$
|
|
108
|
+
var _api$analytics3;
|
|
110
109
|
var _annotationProviders$ = annotationProviders.inlineComment,
|
|
111
110
|
isToolbarAbove = _annotationProviders$.isToolbarAbove,
|
|
112
111
|
onCommentButtonMount = _annotationProviders$.onCommentButtonMount,
|
|
113
112
|
getCanAddComments = _annotationProviders$.getCanAddComments,
|
|
114
113
|
contentType = _annotationProviders$.contentType;
|
|
115
|
-
var toolbarConfig = (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$
|
|
114
|
+
var toolbarConfig = (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
|
|
116
115
|
state: state,
|
|
117
116
|
intl: intl,
|
|
118
117
|
isToolbarAbove: isToolbarAbove,
|
|
@@ -157,7 +156,7 @@ var selector = function selector(states) {
|
|
|
157
156
|
};
|
|
158
157
|
};
|
|
159
158
|
function AnnotationContentComponent(_ref4) {
|
|
160
|
-
var _api$
|
|
159
|
+
var _api$analytics4;
|
|
161
160
|
var api = _ref4.api,
|
|
162
161
|
editorView = _ref4.editorView,
|
|
163
162
|
annotationProviders = _ref4.annotationProviders,
|
|
@@ -177,7 +176,7 @@ function AnnotationContentComponent(_ref4) {
|
|
|
177
176
|
providers: annotationProviders,
|
|
178
177
|
editorView: editorView,
|
|
179
178
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
180
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
179
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
181
180
|
editorAPI: api
|
|
182
181
|
}));
|
|
183
182
|
}
|
|
@@ -9,11 +9,14 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
14
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
13
15
|
var _types = require("../pm-plugins/types");
|
|
14
16
|
var _utils = require("../pm-plugins/utils");
|
|
15
17
|
var _types2 = require("../types");
|
|
16
18
|
var _transform = _interopRequireDefault(require("./transform"));
|
|
19
|
+
var _utils2 = require("./utils");
|
|
17
20
|
var updateInlineCommentResolvedState = exports.updateInlineCommentResolvedState = function updateInlineCommentResolvedState(editorAnalyticsAPI) {
|
|
18
21
|
return function (partialNewState, resolveMethod) {
|
|
19
22
|
var command = {
|
|
@@ -233,13 +236,35 @@ var showInlineCommentForBlockNode = exports.showInlineCommentForBlockNode = func
|
|
|
233
236
|
};
|
|
234
237
|
var setInlineCommentDraftState = exports.setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
235
238
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
239
|
+
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
236
240
|
return function (drafting) {
|
|
237
241
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
238
242
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
239
243
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
240
244
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
241
245
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
242
|
-
|
|
246
|
+
if ((0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
247
|
+
return function (state, dispatch) {
|
|
248
|
+
var tr = _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
249
|
+
var newPluginState = commandAction(state);
|
|
250
|
+
if (tr && newPluginState) {
|
|
251
|
+
tr.setMeta(_utils.inlineCommentPluginKey, newPluginState);
|
|
252
|
+
if (drafting) {
|
|
253
|
+
(0, _utils2.setUserIntent)(api, tr);
|
|
254
|
+
} else {
|
|
255
|
+
(0, _utils2.resetUserIntent)(api, tr);
|
|
256
|
+
}
|
|
257
|
+
if (dispatch) {
|
|
258
|
+
dispatch(tr);
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
};
|
|
265
|
+
} else {
|
|
266
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
267
|
+
}
|
|
243
268
|
};
|
|
244
269
|
};
|
|
245
270
|
var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -260,7 +285,20 @@ var addInlineComment = exports.addInlineComment = function addInlineComment(edit
|
|
|
260
285
|
}
|
|
261
286
|
};
|
|
262
287
|
};
|
|
263
|
-
|
|
288
|
+
if ((0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
289
|
+
return function (state, dispatch) {
|
|
290
|
+
var tr = _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
291
|
+
tr.setMeta(_utils.inlineCommentPluginKey, commandAction(state));
|
|
292
|
+
(0, _utils2.resetUserIntent)(editorAPI, tr);
|
|
293
|
+
if (dispatch) {
|
|
294
|
+
dispatch(tr);
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
return false;
|
|
298
|
+
};
|
|
299
|
+
} else {
|
|
300
|
+
return (0, _pluginFactory.createCommand)(commandAction, _transform.default.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
301
|
+
}
|
|
264
302
|
};
|
|
265
303
|
};
|
|
266
304
|
var updateMouseState = exports.updateMouseState = function updateMouseState(mouseData) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setUserIntent = exports.resetUserIntent = void 0;
|
|
7
|
+
var setUserIntent = exports.setUserIntent = function setUserIntent(api, tr) {
|
|
8
|
+
var _api$userIntent;
|
|
9
|
+
return api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.commands) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.setCurrentUserIntent('commenting')({
|
|
10
|
+
tr: tr
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var resetUserIntent = exports.resetUserIntent = function resetUserIntent(api, tr) {
|
|
14
|
+
var _api$userIntent2;
|
|
15
|
+
return api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.commands) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.setCurrentUserIntent('default')({
|
|
16
|
+
tr: tr
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -75,7 +75,7 @@ var startDraft = exports.startDraft = function startDraft(editorView, options) {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI)(true)(editorView.state, editorView.dispatch);
|
|
78
|
+
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI, undefined, options.api)(true)(editorView.state, editorView.dispatch);
|
|
79
79
|
var _ref3 = _utils3.inlineCommentPluginKey.getState(editorView.state) || {},
|
|
80
80
|
draftDecorationSet = _ref3.draftDecorationSet;
|
|
81
81
|
var decorations = draftDecorationSet === null || draftDecorationSet === void 0 ? void 0 : draftDecorationSet.find();
|
|
@@ -131,7 +131,7 @@ var clearDraft = exports.clearDraft = function clearDraft(editorView, options) {
|
|
|
131
131
|
reason: ERROR_REASON_DRAFT_NOT_STARTED
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
134
|
+
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI, undefined, options.api)(false)(editorView.state, editorView.dispatch);
|
|
135
135
|
!editorView.hasFocus() && editorView.focus();
|
|
136
136
|
return {
|
|
137
137
|
success: true
|
|
@@ -14,11 +14,15 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
14
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
17
19
|
var _editorCommands = require("../editor-commands");
|
|
20
|
+
var _utils2 = require("../editor-commands/utils");
|
|
18
21
|
var _nodeviews = require("../nodeviews");
|
|
19
22
|
var _annotationManagerHooks = require("./annotation-manager-hooks");
|
|
20
23
|
var _pluginFactory = require("./plugin-factory");
|
|
21
|
-
var
|
|
24
|
+
var _toolbar = require("./toolbar");
|
|
25
|
+
var _utils3 = require("./utils");
|
|
22
26
|
var fetchProviderStates = /*#__PURE__*/function () {
|
|
23
27
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(provider, annotationIds) {
|
|
24
28
|
var data, result;
|
|
@@ -137,7 +141,7 @@ var onUnResolve = function onUnResolve(editorAnalyticsAPI) {
|
|
|
137
141
|
};
|
|
138
142
|
var onMouseUp = function onMouseUp(state, dispatch) {
|
|
139
143
|
return function (e) {
|
|
140
|
-
var _ref3 = (0,
|
|
144
|
+
var _ref3 = (0, _utils3.getPluginState)(state) || {},
|
|
141
145
|
mouseData = _ref3.mouseData;
|
|
142
146
|
if (mouseData !== null && mouseData !== void 0 && mouseData.isSelecting) {
|
|
143
147
|
(0, _editorCommands.updateMouseState)({
|
|
@@ -165,7 +169,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
165
169
|
featureFlagsPluginState = options.featureFlagsPluginState,
|
|
166
170
|
annotationManager = options.annotationManager;
|
|
167
171
|
return new _safePlugin.SafePlugin({
|
|
168
|
-
key:
|
|
172
|
+
key: _utils3.inlineCommentPluginKey,
|
|
169
173
|
state: (0, _pluginFactory.createPluginState)(options.dispatch, initialState(provider.disallowOnWhitespace, featureFlagsPluginState, !!annotationManager)),
|
|
170
174
|
view: function view(editorView) {
|
|
171
175
|
var allowAnnotationFn;
|
|
@@ -196,7 +200,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
196
200
|
}
|
|
197
201
|
// Get initial state
|
|
198
202
|
// Need to pass `editorView` to mitigate editor state going stale
|
|
199
|
-
fetchState(provider, (0,
|
|
203
|
+
fetchState(provider, (0, _utils3.getAllAnnotations)(editorView.state.doc), editorView, options.editorAnalyticsAPI);
|
|
200
204
|
var resolve = function resolve(annotationId) {
|
|
201
205
|
return onResolve(options.editorAnalyticsAPI)(editorView.state, editorView.dispatch)(annotationId);
|
|
202
206
|
};
|
|
@@ -210,7 +214,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
210
214
|
return onSetVisibility(editorView)(isVisible);
|
|
211
215
|
};
|
|
212
216
|
var setSelectedAnnotationFn = function setSelectedAnnotationFn(annotationId) {
|
|
213
|
-
var pluginState = (0,
|
|
217
|
+
var pluginState = (0, _utils3.getPluginState)(editorView.state);
|
|
214
218
|
if ((0, _platformFeatureFlags.fg)('platform_editor_listen_for_focussed_query_param')) {
|
|
215
219
|
// When feature flag is true, only close if no annotationId
|
|
216
220
|
if (!annotationId) {
|
|
@@ -260,10 +264,12 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
260
264
|
return {
|
|
261
265
|
update: function update(view, _prevState) {
|
|
262
266
|
var _prevSelectedAnnotati;
|
|
263
|
-
var _ref4 = (0,
|
|
267
|
+
var _ref4 = (0, _utils3.getPluginState)(view.state) || {},
|
|
264
268
|
selectedAnnotations = _ref4.selectedAnnotations,
|
|
265
|
-
annotations = _ref4.annotations
|
|
266
|
-
|
|
269
|
+
annotations = _ref4.annotations,
|
|
270
|
+
isDrafting = _ref4.isDrafting,
|
|
271
|
+
bookmark = _ref4.bookmark;
|
|
272
|
+
var _ref5 = (0, _utils3.getPluginState)(_prevState) || {},
|
|
267
273
|
prevSelectedAnnotations = _ref5.selectedAnnotations;
|
|
268
274
|
var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
|
|
269
275
|
|
|
@@ -284,6 +290,23 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
284
290
|
(_options$viewInlineCo = options.viewInlineCommentTraceUFOPress) === null || _options$viewInlineCo === void 0 || _options$viewInlineCo.call(options);
|
|
285
291
|
}
|
|
286
292
|
}
|
|
293
|
+
var api = options.api;
|
|
294
|
+
if (isDrafting && !view.state.selection.eq(_prevState.selection) && (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
295
|
+
// It is possible that user update selection while having a active draft,
|
|
296
|
+
// so we need to reset the user intent to allow inline text toolbar to be visible
|
|
297
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
|
|
298
|
+
var tr = _ref6.tr;
|
|
299
|
+
if ((0, _toolbar.shouldSuppressFloatingToolbar)({
|
|
300
|
+
state: view.state,
|
|
301
|
+
bookmark: bookmark
|
|
302
|
+
})) {
|
|
303
|
+
(0, _utils2.setUserIntent)(api, tr);
|
|
304
|
+
} else {
|
|
305
|
+
(0, _utils2.resetUserIntent)(api, tr);
|
|
306
|
+
}
|
|
307
|
+
return tr;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
287
310
|
if (annotationManager) {
|
|
288
311
|
// In the Editor, Annotations can be selected in three ways:
|
|
289
312
|
// 1. By clicking on the annotation in the editor
|
|
@@ -293,25 +316,25 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
293
316
|
// at a time when changing the selection could cause data loss.
|
|
294
317
|
// The following preemptive check is designed to cover these items.
|
|
295
318
|
|
|
296
|
-
var
|
|
297
|
-
pendingSelectedAnnotations =
|
|
298
|
-
pendingSelectedAnnotationsUpdateCount =
|
|
299
|
-
var
|
|
300
|
-
prevPendingSelectedAnnotationsUpdateCount =
|
|
319
|
+
var _ref7 = (0, _utils3.getPluginState)(view.state) || {},
|
|
320
|
+
pendingSelectedAnnotations = _ref7.pendingSelectedAnnotations,
|
|
321
|
+
pendingSelectedAnnotationsUpdateCount = _ref7.pendingSelectedAnnotationsUpdateCount;
|
|
322
|
+
var _ref8 = (0, _utils3.getPluginState)(_prevState) || {},
|
|
323
|
+
prevPendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
|
|
301
324
|
if (!isPreemptiveGateActive && pendingSelectedAnnotationsUpdateCount !== prevPendingSelectedAnnotationsUpdateCount && !!(pendingSelectedAnnotations !== null && pendingSelectedAnnotations !== void 0 && pendingSelectedAnnotations.length)) {
|
|
302
325
|
// Need to set a lock to avoid calling gate multiple times. The lock will be released
|
|
303
326
|
// when the preemptive gate is complete.
|
|
304
327
|
isPreemptiveGateActive = true;
|
|
305
328
|
annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
|
|
306
|
-
var
|
|
307
|
-
isDrafting =
|
|
308
|
-
latestPendingSelectedAnnotations =
|
|
309
|
-
latestSelectedAnnotations =
|
|
329
|
+
var _ref9 = (0, _utils3.getPluginState)(view.state) || {},
|
|
330
|
+
isDrafting = _ref9.isDrafting,
|
|
331
|
+
latestPendingSelectedAnnotations = _ref9.pendingSelectedAnnotations,
|
|
332
|
+
latestSelectedAnnotations = _ref9.selectedAnnotations;
|
|
310
333
|
if (canSelectAnnotation) {
|
|
311
334
|
if (isDrafting) {
|
|
312
335
|
// The user must have chosen to discard there draft. So before we flush the pending selections
|
|
313
336
|
// we need to clear the draft if there is one.
|
|
314
|
-
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI)(false)(view.state, view.dispatch);
|
|
337
|
+
(0, _editorCommands.setInlineCommentDraftState)(options.editorAnalyticsAPI, undefined, options.api)(false)(view.state, view.dispatch);
|
|
315
338
|
}
|
|
316
339
|
|
|
317
340
|
// Flush the pending selections into the selected annotations list.
|
|
@@ -333,9 +356,9 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
333
356
|
});
|
|
334
357
|
|
|
335
358
|
// Notify the annotation manager that the pending selection has changed.
|
|
336
|
-
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (
|
|
359
|
+
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref0) {
|
|
337
360
|
var _getAnnotationInlineN2;
|
|
338
|
-
var id =
|
|
361
|
+
var id = _ref0.id;
|
|
339
362
|
annotationManager.emit({
|
|
340
363
|
name: 'annotationSelectionChanged',
|
|
341
364
|
data: {
|
|
@@ -359,13 +382,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
359
382
|
});
|
|
360
383
|
}
|
|
361
384
|
}
|
|
362
|
-
var
|
|
363
|
-
dirtyAnnotations =
|
|
385
|
+
var _ref1 = (0, _utils3.getPluginState)(view.state) || {},
|
|
386
|
+
dirtyAnnotations = _ref1.dirtyAnnotations;
|
|
364
387
|
if (!dirtyAnnotations) {
|
|
365
388
|
return;
|
|
366
389
|
}
|
|
367
390
|
(0, _editorCommands.clearDirtyMark)()(view.state, view.dispatch);
|
|
368
|
-
fetchState(provider, (0,
|
|
391
|
+
fetchState(provider, (0, _utils3.getAllAnnotations)(view.state.doc), view, options.editorAnalyticsAPI);
|
|
369
392
|
},
|
|
370
393
|
destroy: function destroy() {
|
|
371
394
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -389,7 +412,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
389
412
|
props: {
|
|
390
413
|
handleDOMEvents: {
|
|
391
414
|
mousedown: function mousedown(view) {
|
|
392
|
-
var pluginState = (0,
|
|
415
|
+
var pluginState = (0, _utils3.getPluginState)(view.state);
|
|
393
416
|
if (!(pluginState !== null && pluginState !== void 0 && pluginState.mouseData.isSelecting)) {
|
|
394
417
|
hideToolbar(view.state, view.dispatch)();
|
|
395
418
|
}
|
|
@@ -414,7 +437,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
414
437
|
if (!annotationId) {
|
|
415
438
|
return false;
|
|
416
439
|
}
|
|
417
|
-
var pluginState = (0,
|
|
440
|
+
var pluginState = (0, _utils3.getPluginState)(view.state);
|
|
418
441
|
var isSelected = pluginState === null || pluginState === void 0 || (_pluginState$selected = pluginState.selectedAnnotations) === null || _pluginState$selected === void 0 ? void 0 : _pluginState$selected.some(function (selectedAnnotation) {
|
|
419
442
|
return selectedAnnotation.id === annotationId;
|
|
420
443
|
});
|
|
@@ -423,8 +446,8 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
423
446
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
424
447
|
return false;
|
|
425
448
|
}
|
|
426
|
-
var
|
|
427
|
-
annotations =
|
|
449
|
+
var _ref10 = pluginState || {},
|
|
450
|
+
annotations = _ref10.annotations;
|
|
428
451
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
429
452
|
if (!isUnresolved) {
|
|
430
453
|
return false;
|
|
@@ -452,13 +475,13 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
452
475
|
},
|
|
453
476
|
decorations: function decorations(state) {
|
|
454
477
|
// highlight comments, depending on state
|
|
455
|
-
var
|
|
456
|
-
draftDecorationSet =
|
|
457
|
-
annotations =
|
|
458
|
-
selectedAnnotations =
|
|
459
|
-
isVisible =
|
|
460
|
-
isInlineCommentViewClosed =
|
|
461
|
-
hoveredAnnotations =
|
|
478
|
+
var _ref11 = (0, _utils3.getPluginState)(state) || {},
|
|
479
|
+
draftDecorationSet = _ref11.draftDecorationSet,
|
|
480
|
+
annotations = _ref11.annotations,
|
|
481
|
+
selectedAnnotations = _ref11.selectedAnnotations,
|
|
482
|
+
isVisible = _ref11.isVisible,
|
|
483
|
+
isInlineCommentViewClosed = _ref11.isInlineCommentViewClosed,
|
|
484
|
+
hoveredAnnotations = _ref11.hoveredAnnotations;
|
|
462
485
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : _view.DecorationSet.empty;
|
|
463
486
|
var focusDecorations = [];
|
|
464
487
|
|
|
@@ -488,7 +511,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
488
511
|
focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
489
512
|
class: "".concat((0, _nodeviews.getBlockAnnotationViewClassname)(isUnresolved, isSelected), " ").concat(isUnresolved)
|
|
490
513
|
}, {
|
|
491
|
-
key:
|
|
514
|
+
key: _utils3.decorationKey.block
|
|
492
515
|
}));
|
|
493
516
|
} else {
|
|
494
517
|
if ((0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')) {
|
|
@@ -501,7 +524,7 @@ var inlineCommentPlugin = exports.inlineCommentPlugin = function inlineCommentPl
|
|
|
501
524
|
focusDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
502
525
|
class: "".concat((0, _nodeviews.getAnnotationViewClassname)(isUnresolved, isSelected, isHovered), " ").concat(isUnresolved)
|
|
503
526
|
}, {
|
|
504
|
-
key:
|
|
527
|
+
key: _utils3.decorationKey.block
|
|
505
528
|
}));
|
|
506
529
|
}
|
|
507
530
|
} else {
|
|
@@ -8,11 +8,12 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
8
8
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
9
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
10
|
var _editorCommands = require("../editor-commands");
|
|
11
|
-
function keymapPlugin(
|
|
11
|
+
function keymapPlugin(api) {
|
|
12
|
+
var _api$analytics;
|
|
12
13
|
var list = {};
|
|
13
14
|
(0, _keymaps.bindKeymapWithCommand)(
|
|
14
15
|
// Ignored via go/ees005
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
16
|
-
_keymaps.addInlineComment.common, (0, _editorCommands.setInlineCommentDraftState)(
|
|
17
|
+
_keymaps.addInlineComment.common, (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, undefined, api)(true, _analytics.INPUT_METHOD.SHORTCUT), list);
|
|
17
18
|
return (0, _keymap.keymap)(list);
|
|
18
19
|
}
|
|
@@ -117,6 +117,6 @@ var startCommentExperience = exports.startCommentExperience = function startComm
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 || _annotationProviders$4.initExperience.start();
|
|
120
|
-
return (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(true)(state, dispatch);
|
|
120
|
+
return (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, undefined, api)(true)(state, dispatch);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
@@ -143,7 +143,7 @@ function InlineCommentView(_ref) {
|
|
|
143
143
|
},
|
|
144
144
|
onClose: function onClose() {
|
|
145
145
|
if (!isAnnotationManagerEnabled) {
|
|
146
|
-
(0, _editorCommands.setInlineCommentDraftState)(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
146
|
+
(0, _editorCommands.setInlineCommentDraftState)(editorAnalyticsAPI, undefined, editorAPI)(false)(editorView.state, editorView.dispatch);
|
|
147
147
|
!editorView.hasFocus() && editorView.focus();
|
|
148
148
|
}
|
|
149
149
|
},
|
|
@@ -70,8 +70,7 @@ export const annotationPlugin = ({
|
|
|
70
70
|
name: 'annotationKeymap',
|
|
71
71
|
plugin: () => {
|
|
72
72
|
if (annotationProviders) {
|
|
73
|
-
|
|
74
|
-
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
73
|
+
return keymapPlugin(api);
|
|
75
74
|
}
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
@@ -96,14 +95,14 @@ export const annotationPlugin = ({
|
|
|
96
95
|
}
|
|
97
96
|
const pluginState = getPluginState(state);
|
|
98
97
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
99
|
-
var _api$
|
|
98
|
+
var _api$analytics3;
|
|
100
99
|
const {
|
|
101
100
|
isToolbarAbove,
|
|
102
101
|
onCommentButtonMount,
|
|
103
102
|
getCanAddComments,
|
|
104
103
|
contentType
|
|
105
104
|
} = annotationProviders.inlineComment;
|
|
106
|
-
const toolbarConfig = buildToolbar(api === null || api === void 0 ? void 0 : (_api$
|
|
105
|
+
const toolbarConfig = buildToolbar(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
|
|
107
106
|
state,
|
|
108
107
|
intl,
|
|
109
108
|
isToolbarAbove,
|
|
@@ -155,7 +154,7 @@ function AnnotationContentComponent({
|
|
|
155
154
|
annotationProviders,
|
|
156
155
|
dispatchAnalyticsEvent
|
|
157
156
|
}) {
|
|
158
|
-
var _api$
|
|
157
|
+
var _api$analytics4;
|
|
159
158
|
const annotationState = useSharedPluginStateWithSelector(api, ['annotation'], selector);
|
|
160
159
|
if (annotationState && !annotationState.isVisible && expValEquals('platform_editor_usesharedpluginstatewithselector', 'isEnabled', false)) {
|
|
161
160
|
return null;
|
|
@@ -171,7 +170,7 @@ function AnnotationContentComponent({
|
|
|
171
170
|
providers: annotationProviders,
|
|
172
171
|
editorView: editorView,
|
|
173
172
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
174
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$
|
|
173
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
175
174
|
editorAPI: api
|
|
176
175
|
}));
|
|
177
176
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { INPUT_METHOD, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
4
6
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
5
7
|
import { ACTIONS } from '../pm-plugins/types';
|
|
6
8
|
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../pm-plugins/utils';
|
|
7
9
|
import { AnnotationSelectionType } from '../types';
|
|
8
10
|
import transform from './transform';
|
|
11
|
+
import { resetUserIntent, setUserIntent } from './utils';
|
|
9
12
|
export const updateInlineCommentResolvedState = editorAnalyticsAPI => (partialNewState, resolveMethod) => {
|
|
10
13
|
const command = {
|
|
11
14
|
type: ACTIONS.UPDATE_INLINE_COMMENT_STATE,
|
|
@@ -195,9 +198,30 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = []) => (node
|
|
|
195
198
|
}
|
|
196
199
|
return false;
|
|
197
200
|
};
|
|
198
|
-
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = []) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
201
|
+
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = [], api) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
199
202
|
const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
200
|
-
|
|
203
|
+
if (editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
204
|
+
return (state, dispatch) => {
|
|
205
|
+
const tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
206
|
+
const newPluginState = commandAction(state);
|
|
207
|
+
if (tr && newPluginState) {
|
|
208
|
+
tr.setMeta(inlineCommentPluginKey, newPluginState);
|
|
209
|
+
if (drafting) {
|
|
210
|
+
setUserIntent(api, tr);
|
|
211
|
+
} else {
|
|
212
|
+
resetUserIntent(api, tr);
|
|
213
|
+
}
|
|
214
|
+
if (dispatch) {
|
|
215
|
+
dispatch(tr);
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
};
|
|
222
|
+
} else {
|
|
223
|
+
return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
224
|
+
}
|
|
201
225
|
};
|
|
202
226
|
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes) => {
|
|
203
227
|
const commandAction = editorState => ({
|
|
@@ -216,7 +240,20 @@ export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supporte
|
|
|
216
240
|
editorState
|
|
217
241
|
}
|
|
218
242
|
});
|
|
219
|
-
|
|
243
|
+
if (editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
244
|
+
return (state, dispatch) => {
|
|
245
|
+
const tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
246
|
+
tr.setMeta(inlineCommentPluginKey, commandAction(state));
|
|
247
|
+
resetUserIntent(editorAPI, tr);
|
|
248
|
+
if (dispatch) {
|
|
249
|
+
dispatch(tr);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
};
|
|
254
|
+
} else {
|
|
255
|
+
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
256
|
+
}
|
|
220
257
|
};
|
|
221
258
|
export const updateMouseState = mouseData => createCommand({
|
|
222
259
|
type: ACTIONS.INLINE_COMMENT_UPDATE_MOUSE_STATE,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const setUserIntent = (api, tr) => {
|
|
2
|
+
var _api$userIntent, _api$userIntent$comma;
|
|
3
|
+
return api === null || api === void 0 ? void 0 : (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 ? void 0 : (_api$userIntent$comma = _api$userIntent.commands) === null || _api$userIntent$comma === void 0 ? void 0 : _api$userIntent$comma.setCurrentUserIntent('commenting')({
|
|
4
|
+
tr
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export const resetUserIntent = (api, tr) => {
|
|
8
|
+
var _api$userIntent2, _api$userIntent2$comm;
|
|
9
|
+
return api === null || api === void 0 ? void 0 : (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 ? void 0 : (_api$userIntent2$comm = _api$userIntent2.commands) === null || _api$userIntent2$comm === void 0 ? void 0 : _api$userIntent2$comm.setCurrentUserIntent('default')({
|
|
10
|
+
tr
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -68,7 +68,7 @@ export const startDraft = (editorView, options) => () => {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(true)(editorView.state, editorView.dispatch);
|
|
71
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(true)(editorView.state, editorView.dispatch);
|
|
72
72
|
const {
|
|
73
73
|
draftDecorationSet
|
|
74
74
|
} = inlineCommentPluginKey.getState(editorView.state) || {};
|
|
@@ -124,7 +124,7 @@ export const clearDraft = (editorView, options) => () => {
|
|
|
124
124
|
reason: ERROR_REASON_DRAFT_NOT_STARTED
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
127
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(false)(editorView.state, editorView.dispatch);
|
|
128
128
|
!editorView.hasFocus() && editorView.focus();
|
|
129
129
|
return {
|
|
130
130
|
success: true
|
|
@@ -4,10 +4,14 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
4
4
|
import { getAnnotationInlineNodeTypes } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
9
|
import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState } from '../editor-commands';
|
|
10
|
+
import { resetUserIntent, setUserIntent } from '../editor-commands/utils';
|
|
8
11
|
import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
|
|
9
12
|
import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
|
|
10
13
|
import { createPluginState } from './plugin-factory';
|
|
14
|
+
import { shouldSuppressFloatingToolbar } from './toolbar';
|
|
11
15
|
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
|
|
12
16
|
const fetchProviderStates = async (provider, annotationIds) => {
|
|
13
17
|
if ((!provider || !provider.getState) && fg('use_comments_data_annotation_updater')) {
|
|
@@ -195,7 +199,9 @@ export const inlineCommentPlugin = options => {
|
|
|
195
199
|
var _prevSelectedAnnotati;
|
|
196
200
|
const {
|
|
197
201
|
selectedAnnotations,
|
|
198
|
-
annotations
|
|
202
|
+
annotations,
|
|
203
|
+
isDrafting,
|
|
204
|
+
bookmark
|
|
199
205
|
} = getPluginState(view.state) || {};
|
|
200
206
|
const {
|
|
201
207
|
selectedAnnotations: prevSelectedAnnotations
|
|
@@ -219,6 +225,26 @@ export const inlineCommentPlugin = options => {
|
|
|
219
225
|
(_options$viewInlineCo = options.viewInlineCommentTraceUFOPress) === null || _options$viewInlineCo === void 0 ? void 0 : _options$viewInlineCo.call(options);
|
|
220
226
|
}
|
|
221
227
|
}
|
|
228
|
+
const {
|
|
229
|
+
api
|
|
230
|
+
} = options;
|
|
231
|
+
if (isDrafting && !view.state.selection.eq(_prevState.selection) && editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
232
|
+
// It is possible that user update selection while having a active draft,
|
|
233
|
+
// so we need to reset the user intent to allow inline text toolbar to be visible
|
|
234
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
235
|
+
tr
|
|
236
|
+
}) => {
|
|
237
|
+
if (shouldSuppressFloatingToolbar({
|
|
238
|
+
state: view.state,
|
|
239
|
+
bookmark
|
|
240
|
+
})) {
|
|
241
|
+
setUserIntent(api, tr);
|
|
242
|
+
} else {
|
|
243
|
+
resetUserIntent(api, tr);
|
|
244
|
+
}
|
|
245
|
+
return tr;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
222
248
|
if (annotationManager) {
|
|
223
249
|
// In the Editor, Annotations can be selected in three ways:
|
|
224
250
|
// 1. By clicking on the annotation in the editor
|
|
@@ -249,7 +275,7 @@ export const inlineCommentPlugin = options => {
|
|
|
249
275
|
if (isDrafting) {
|
|
250
276
|
// The user must have chosen to discard there draft. So before we flush the pending selections
|
|
251
277
|
// we need to clear the draft if there is one.
|
|
252
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(false)(view.state, view.dispatch);
|
|
278
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(false)(view.state, view.dispatch);
|
|
253
279
|
}
|
|
254
280
|
|
|
255
281
|
// Flush the pending selections into the selected annotations list.
|
|
@@ -2,11 +2,12 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { addInlineComment, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
4
|
import { setInlineCommentDraftState } from '../editor-commands';
|
|
5
|
-
export function keymapPlugin(
|
|
5
|
+
export function keymapPlugin(api) {
|
|
6
|
+
var _api$analytics;
|
|
6
7
|
const list = {};
|
|
7
8
|
bindKeymapWithCommand(
|
|
8
9
|
// Ignored via go/ees005
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
-
addInlineComment.common, setInlineCommentDraftState(
|
|
11
|
+
addInlineComment.common, setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, undefined, api)(true, INPUT_METHOD.SHORTCUT), list);
|
|
11
12
|
return keymap(list);
|
|
12
13
|
}
|
|
@@ -117,6 +117,6 @@ export const startCommentExperience = ({
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
annotationProviders === null || annotationProviders === void 0 ? void 0 : (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 ? void 0 : _annotationProviders$4.initExperience.start();
|
|
120
|
-
return setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(true)(state, dispatch);
|
|
120
|
+
return setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, undefined, api)(true)(state, dispatch);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
@@ -141,7 +141,7 @@ export function InlineCommentView({
|
|
|
141
141
|
},
|
|
142
142
|
onClose: () => {
|
|
143
143
|
if (!isAnnotationManagerEnabled) {
|
|
144
|
-
setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
144
|
+
setInlineCommentDraftState(editorAnalyticsAPI, undefined, editorAPI)(false)(editorView.state, editorView.dispatch);
|
|
145
145
|
!editorView.hasFocus() && editorView.focus();
|
|
146
146
|
}
|
|
147
147
|
},
|
|
@@ -72,8 +72,7 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
72
72
|
name: 'annotationKeymap',
|
|
73
73
|
plugin: function plugin() {
|
|
74
74
|
if (annotationProviders) {
|
|
75
|
-
|
|
76
|
-
return keymapPlugin(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
75
|
+
return keymapPlugin(api);
|
|
77
76
|
}
|
|
78
77
|
return;
|
|
79
78
|
}
|
|
@@ -99,13 +98,13 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
99
98
|
}
|
|
100
99
|
var pluginState = getPluginState(state);
|
|
101
100
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
102
|
-
var _api$
|
|
101
|
+
var _api$analytics3;
|
|
103
102
|
var _annotationProviders$ = annotationProviders.inlineComment,
|
|
104
103
|
isToolbarAbove = _annotationProviders$.isToolbarAbove,
|
|
105
104
|
onCommentButtonMount = _annotationProviders$.onCommentButtonMount,
|
|
106
105
|
getCanAddComments = _annotationProviders$.getCanAddComments,
|
|
107
106
|
contentType = _annotationProviders$.contentType;
|
|
108
|
-
var toolbarConfig = buildToolbar(api === null || api === void 0 || (_api$
|
|
107
|
+
var toolbarConfig = buildToolbar(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)({
|
|
109
108
|
state: state,
|
|
110
109
|
intl: intl,
|
|
111
110
|
isToolbarAbove: isToolbarAbove,
|
|
@@ -150,7 +149,7 @@ var selector = function selector(states) {
|
|
|
150
149
|
};
|
|
151
150
|
};
|
|
152
151
|
function AnnotationContentComponent(_ref4) {
|
|
153
|
-
var _api$
|
|
152
|
+
var _api$analytics4;
|
|
154
153
|
var api = _ref4.api,
|
|
155
154
|
editorView = _ref4.editorView,
|
|
156
155
|
annotationProviders = _ref4.annotationProviders,
|
|
@@ -170,7 +169,7 @@ function AnnotationContentComponent(_ref4) {
|
|
|
170
169
|
providers: annotationProviders,
|
|
171
170
|
editorView: editorView,
|
|
172
171
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
173
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$
|
|
172
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions,
|
|
174
173
|
editorAPI: api
|
|
175
174
|
}));
|
|
176
175
|
}
|
|
@@ -2,11 +2,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
3
|
import { INPUT_METHOD, RESOLVE_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
6
8
|
import { ACTIONS } from '../pm-plugins/types';
|
|
7
9
|
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../pm-plugins/utils';
|
|
8
10
|
import { AnnotationSelectionType } from '../types';
|
|
9
11
|
import transform from './transform';
|
|
12
|
+
import { resetUserIntent, setUserIntent } from './utils';
|
|
10
13
|
export var updateInlineCommentResolvedState = function updateInlineCommentResolvedState(editorAnalyticsAPI) {
|
|
11
14
|
return function (partialNewState, resolveMethod) {
|
|
12
15
|
var command = {
|
|
@@ -226,13 +229,35 @@ export var showInlineCommentForBlockNode = function showInlineCommentForBlockNod
|
|
|
226
229
|
};
|
|
227
230
|
export var setInlineCommentDraftState = function setInlineCommentDraftState(editorAnalyticsAPI) {
|
|
228
231
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
232
|
+
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
229
233
|
return function (drafting) {
|
|
230
234
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
231
235
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
232
236
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
233
237
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
234
238
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isOpeningMediaCommentFromToolbar);
|
|
235
|
-
|
|
239
|
+
if (editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
240
|
+
return function (state, dispatch) {
|
|
241
|
+
var tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
242
|
+
var newPluginState = commandAction(state);
|
|
243
|
+
if (tr && newPluginState) {
|
|
244
|
+
tr.setMeta(inlineCommentPluginKey, newPluginState);
|
|
245
|
+
if (drafting) {
|
|
246
|
+
setUserIntent(api, tr);
|
|
247
|
+
} else {
|
|
248
|
+
resetUserIntent(api, tr);
|
|
249
|
+
}
|
|
250
|
+
if (dispatch) {
|
|
251
|
+
dispatch(tr);
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return true;
|
|
257
|
+
};
|
|
258
|
+
} else {
|
|
259
|
+
return createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod));
|
|
260
|
+
}
|
|
236
261
|
};
|
|
237
262
|
};
|
|
238
263
|
export var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -253,7 +278,20 @@ export var addInlineComment = function addInlineComment(editorAnalyticsAPI, edit
|
|
|
253
278
|
}
|
|
254
279
|
};
|
|
255
280
|
};
|
|
256
|
-
|
|
281
|
+
if (editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
282
|
+
return function (state, dispatch) {
|
|
283
|
+
var tr = transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes)(state.tr, state);
|
|
284
|
+
tr.setMeta(inlineCommentPluginKey, commandAction(state));
|
|
285
|
+
resetUserIntent(editorAPI, tr);
|
|
286
|
+
if (dispatch) {
|
|
287
|
+
dispatch(tr);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
};
|
|
292
|
+
} else {
|
|
293
|
+
return createCommand(commandAction, transform.addInlineComment(editorAnalyticsAPI, editorAPI)(id, supportedBlockNodes));
|
|
294
|
+
}
|
|
257
295
|
};
|
|
258
296
|
};
|
|
259
297
|
export var updateMouseState = function updateMouseState(mouseData) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var setUserIntent = function setUserIntent(api, tr) {
|
|
2
|
+
var _api$userIntent;
|
|
3
|
+
return api === null || api === void 0 || (_api$userIntent = api.userIntent) === null || _api$userIntent === void 0 || (_api$userIntent = _api$userIntent.commands) === null || _api$userIntent === void 0 ? void 0 : _api$userIntent.setCurrentUserIntent('commenting')({
|
|
4
|
+
tr: tr
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export var resetUserIntent = function resetUserIntent(api, tr) {
|
|
8
|
+
var _api$userIntent2;
|
|
9
|
+
return api === null || api === void 0 || (_api$userIntent2 = api.userIntent) === null || _api$userIntent2 === void 0 || (_api$userIntent2 = _api$userIntent2.commands) === null || _api$userIntent2 === void 0 ? void 0 : _api$userIntent2.setCurrentUserIntent('default')({
|
|
10
|
+
tr: tr
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -69,7 +69,7 @@ export var startDraft = function startDraft(editorView, options) {
|
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(true)(editorView.state, editorView.dispatch);
|
|
72
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(true)(editorView.state, editorView.dispatch);
|
|
73
73
|
var _ref3 = inlineCommentPluginKey.getState(editorView.state) || {},
|
|
74
74
|
draftDecorationSet = _ref3.draftDecorationSet;
|
|
75
75
|
var decorations = draftDecorationSet === null || draftDecorationSet === void 0 ? void 0 : draftDecorationSet.find();
|
|
@@ -125,7 +125,7 @@ export var clearDraft = function clearDraft(editorView, options) {
|
|
|
125
125
|
reason: ERROR_REASON_DRAFT_NOT_STARTED
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
128
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(false)(editorView.state, editorView.dispatch);
|
|
129
129
|
!editorView.hasFocus() && editorView.focus();
|
|
130
130
|
return {
|
|
131
131
|
success: true
|
|
@@ -7,10 +7,14 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
7
7
|
import { getAnnotationInlineNodeTypes } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
12
|
import { clearDirtyMark, closeComponent, setHoveredAnnotation, setInlineCommentsVisibility, setSelectedAnnotation, flushPendingSelections, updateInlineCommentResolvedState, updateMouseState, setPendingSelectedAnnotation, setInlineCommentDraftState } from '../editor-commands';
|
|
13
|
+
import { resetUserIntent, setUserIntent } from '../editor-commands/utils';
|
|
11
14
|
import { getAnnotationViewClassname, getBlockAnnotationViewClassname } from '../nodeviews';
|
|
12
15
|
import { allowAnnotation, applyDraft, clearDraft, clearAnnotation, getDraft, setIsAnnotationHovered, setIsAnnotationSelected, startDraft } from './annotation-manager-hooks';
|
|
13
16
|
import { createPluginState } from './plugin-factory';
|
|
17
|
+
import { shouldSuppressFloatingToolbar } from './toolbar';
|
|
14
18
|
import { decorationKey, getAllAnnotations, getPluginState, inlineCommentPluginKey } from './utils';
|
|
15
19
|
var fetchProviderStates = /*#__PURE__*/function () {
|
|
16
20
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(provider, annotationIds) {
|
|
@@ -255,7 +259,9 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
255
259
|
var _prevSelectedAnnotati;
|
|
256
260
|
var _ref4 = getPluginState(view.state) || {},
|
|
257
261
|
selectedAnnotations = _ref4.selectedAnnotations,
|
|
258
|
-
annotations = _ref4.annotations
|
|
262
|
+
annotations = _ref4.annotations,
|
|
263
|
+
isDrafting = _ref4.isDrafting,
|
|
264
|
+
bookmark = _ref4.bookmark;
|
|
259
265
|
var _ref5 = getPluginState(_prevState) || {},
|
|
260
266
|
prevSelectedAnnotations = _ref5.selectedAnnotations;
|
|
261
267
|
var selectedAnnotationId = selectedAnnotations && selectedAnnotations.length !== 0 && selectedAnnotations[0].id ? selectedAnnotations[0].id : undefined;
|
|
@@ -277,6 +283,23 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
277
283
|
(_options$viewInlineCo = options.viewInlineCommentTraceUFOPress) === null || _options$viewInlineCo === void 0 || _options$viewInlineCo.call(options);
|
|
278
284
|
}
|
|
279
285
|
}
|
|
286
|
+
var api = options.api;
|
|
287
|
+
if (isDrafting && !view.state.selection.eq(_prevState.selection) && editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_2', 'isEnabled', true)) {
|
|
288
|
+
// It is possible that user update selection while having a active draft,
|
|
289
|
+
// so we need to reset the user intent to allow inline text toolbar to be visible
|
|
290
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
|
|
291
|
+
var tr = _ref6.tr;
|
|
292
|
+
if (shouldSuppressFloatingToolbar({
|
|
293
|
+
state: view.state,
|
|
294
|
+
bookmark: bookmark
|
|
295
|
+
})) {
|
|
296
|
+
setUserIntent(api, tr);
|
|
297
|
+
} else {
|
|
298
|
+
resetUserIntent(api, tr);
|
|
299
|
+
}
|
|
300
|
+
return tr;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
280
303
|
if (annotationManager) {
|
|
281
304
|
// In the Editor, Annotations can be selected in three ways:
|
|
282
305
|
// 1. By clicking on the annotation in the editor
|
|
@@ -286,25 +309,25 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
286
309
|
// at a time when changing the selection could cause data loss.
|
|
287
310
|
// The following preemptive check is designed to cover these items.
|
|
288
311
|
|
|
289
|
-
var
|
|
290
|
-
pendingSelectedAnnotations =
|
|
291
|
-
pendingSelectedAnnotationsUpdateCount =
|
|
292
|
-
var
|
|
293
|
-
prevPendingSelectedAnnotationsUpdateCount =
|
|
312
|
+
var _ref7 = getPluginState(view.state) || {},
|
|
313
|
+
pendingSelectedAnnotations = _ref7.pendingSelectedAnnotations,
|
|
314
|
+
pendingSelectedAnnotationsUpdateCount = _ref7.pendingSelectedAnnotationsUpdateCount;
|
|
315
|
+
var _ref8 = getPluginState(_prevState) || {},
|
|
316
|
+
prevPendingSelectedAnnotationsUpdateCount = _ref8.pendingSelectedAnnotationsUpdateCount;
|
|
294
317
|
if (!isPreemptiveGateActive && pendingSelectedAnnotationsUpdateCount !== prevPendingSelectedAnnotationsUpdateCount && !!(pendingSelectedAnnotations !== null && pendingSelectedAnnotations !== void 0 && pendingSelectedAnnotations.length)) {
|
|
295
318
|
// Need to set a lock to avoid calling gate multiple times. The lock will be released
|
|
296
319
|
// when the preemptive gate is complete.
|
|
297
320
|
isPreemptiveGateActive = true;
|
|
298
321
|
annotationManager.checkPreemptiveGate().then(function (canSelectAnnotation) {
|
|
299
|
-
var
|
|
300
|
-
isDrafting =
|
|
301
|
-
latestPendingSelectedAnnotations =
|
|
302
|
-
latestSelectedAnnotations =
|
|
322
|
+
var _ref9 = getPluginState(view.state) || {},
|
|
323
|
+
isDrafting = _ref9.isDrafting,
|
|
324
|
+
latestPendingSelectedAnnotations = _ref9.pendingSelectedAnnotations,
|
|
325
|
+
latestSelectedAnnotations = _ref9.selectedAnnotations;
|
|
303
326
|
if (canSelectAnnotation) {
|
|
304
327
|
if (isDrafting) {
|
|
305
328
|
// The user must have chosen to discard there draft. So before we flush the pending selections
|
|
306
329
|
// we need to clear the draft if there is one.
|
|
307
|
-
setInlineCommentDraftState(options.editorAnalyticsAPI)(false)(view.state, view.dispatch);
|
|
330
|
+
setInlineCommentDraftState(options.editorAnalyticsAPI, undefined, options.api)(false)(view.state, view.dispatch);
|
|
308
331
|
}
|
|
309
332
|
|
|
310
333
|
// Flush the pending selections into the selected annotations list.
|
|
@@ -326,9 +349,9 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
326
349
|
});
|
|
327
350
|
|
|
328
351
|
// Notify the annotation manager that the pending selection has changed.
|
|
329
|
-
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (
|
|
352
|
+
latestPendingSelectedAnnotations === null || latestPendingSelectedAnnotations === void 0 || latestPendingSelectedAnnotations.forEach(function (_ref0) {
|
|
330
353
|
var _getAnnotationInlineN2;
|
|
331
|
-
var id =
|
|
354
|
+
var id = _ref0.id;
|
|
332
355
|
annotationManager.emit({
|
|
333
356
|
name: 'annotationSelectionChanged',
|
|
334
357
|
data: {
|
|
@@ -352,8 +375,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
352
375
|
});
|
|
353
376
|
}
|
|
354
377
|
}
|
|
355
|
-
var
|
|
356
|
-
dirtyAnnotations =
|
|
378
|
+
var _ref1 = getPluginState(view.state) || {},
|
|
379
|
+
dirtyAnnotations = _ref1.dirtyAnnotations;
|
|
357
380
|
if (!dirtyAnnotations) {
|
|
358
381
|
return;
|
|
359
382
|
}
|
|
@@ -416,8 +439,8 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
416
439
|
if (isSelected && !(pluginState !== null && pluginState !== void 0 && pluginState.isInlineCommentViewClosed)) {
|
|
417
440
|
return false;
|
|
418
441
|
}
|
|
419
|
-
var
|
|
420
|
-
annotations =
|
|
442
|
+
var _ref10 = pluginState || {},
|
|
443
|
+
annotations = _ref10.annotations;
|
|
421
444
|
var isUnresolved = annotations && annotations[annotationId] === false;
|
|
422
445
|
if (!isUnresolved) {
|
|
423
446
|
return false;
|
|
@@ -445,13 +468,13 @@ export var inlineCommentPlugin = function inlineCommentPlugin(options) {
|
|
|
445
468
|
},
|
|
446
469
|
decorations: function decorations(state) {
|
|
447
470
|
// highlight comments, depending on state
|
|
448
|
-
var
|
|
449
|
-
draftDecorationSet =
|
|
450
|
-
annotations =
|
|
451
|
-
selectedAnnotations =
|
|
452
|
-
isVisible =
|
|
453
|
-
isInlineCommentViewClosed =
|
|
454
|
-
hoveredAnnotations =
|
|
471
|
+
var _ref11 = getPluginState(state) || {},
|
|
472
|
+
draftDecorationSet = _ref11.draftDecorationSet,
|
|
473
|
+
annotations = _ref11.annotations,
|
|
474
|
+
selectedAnnotations = _ref11.selectedAnnotations,
|
|
475
|
+
isVisible = _ref11.isVisible,
|
|
476
|
+
isInlineCommentViewClosed = _ref11.isInlineCommentViewClosed,
|
|
477
|
+
hoveredAnnotations = _ref11.hoveredAnnotations;
|
|
455
478
|
var decorations = draftDecorationSet !== null && draftDecorationSet !== void 0 ? draftDecorationSet : DecorationSet.empty;
|
|
456
479
|
var focusDecorations = [];
|
|
457
480
|
|
|
@@ -2,11 +2,12 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
2
2
|
import { addInlineComment, bindKeymapWithCommand } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
4
|
import { setInlineCommentDraftState } from '../editor-commands';
|
|
5
|
-
export function keymapPlugin(
|
|
5
|
+
export function keymapPlugin(api) {
|
|
6
|
+
var _api$analytics;
|
|
6
7
|
var list = {};
|
|
7
8
|
bindKeymapWithCommand(
|
|
8
9
|
// Ignored via go/ees005
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10
|
-
addInlineComment.common, setInlineCommentDraftState(
|
|
11
|
+
addInlineComment.common, setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, undefined, api)(true, INPUT_METHOD.SHORTCUT), list);
|
|
11
12
|
return keymap(list);
|
|
12
13
|
}
|
|
@@ -111,6 +111,6 @@ export var startCommentExperience = function startCommentExperience(_ref6) {
|
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = annotationProviders.createCommentExperience) === null || _annotationProviders$4 === void 0 || _annotationProviders$4.initExperience.start();
|
|
114
|
-
return setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(true)(state, dispatch);
|
|
114
|
+
return setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions, undefined, api)(true)(state, dispatch);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
@@ -134,7 +134,7 @@ export function InlineCommentView(_ref) {
|
|
|
134
134
|
},
|
|
135
135
|
onClose: function onClose() {
|
|
136
136
|
if (!isAnnotationManagerEnabled) {
|
|
137
|
-
setInlineCommentDraftState(editorAnalyticsAPI)(false)(editorView.state, editorView.dispatch);
|
|
137
|
+
setInlineCommentDraftState(editorAnalyticsAPI, undefined, editorAPI)(false)(editorView.state, editorView.dispatch);
|
|
138
138
|
!editorView.hasFocus() && editorView.focus();
|
|
139
139
|
}
|
|
140
140
|
},
|
|
@@ -5,6 +5,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
|
|
|
5
5
|
import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
|
|
6
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
7
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
8
|
+
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
8
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
import type { showInlineCommentForBlockNode } from './editor-commands';
|
|
@@ -20,7 +21,8 @@ export type AnnotationPluginDependencies = [
|
|
|
20
21
|
OptionalPlugin<EditorViewModePlugin>,
|
|
21
22
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
22
23
|
OptionalPlugin<ConnectivityPlugin>,
|
|
23
|
-
OptionalPlugin<ToolbarPlugin
|
|
24
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
25
|
+
OptionalPlugin<UserIntentPlugin>
|
|
24
26
|
];
|
|
25
27
|
export type AnnotationPluginOptions = AnnotationProviders;
|
|
26
28
|
export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
@@ -20,7 +20,7 @@ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnal
|
|
|
20
20
|
* @example
|
|
21
21
|
*/
|
|
22
22
|
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
23
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
23
|
+
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
24
24
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
|
|
25
25
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
26
26
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
4
|
+
export declare const setUserIntent: (api: ExtractInjectionAPI<AnnotationPlugin> | undefined, tr: Transaction) => Transaction | null | undefined;
|
|
5
|
+
export declare const resetUserIntent: (api: ExtractInjectionAPI<AnnotationPlugin> | undefined, tr: Transaction) => Transaction | null | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
4
|
+
export declare function keymapPlugin(api: ExtractInjectionAPI<AnnotationPlugin> | undefined): SafePlugin;
|
|
@@ -5,6 +5,7 @@ import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmo
|
|
|
5
5
|
import type { EditorViewModeEffectsPlugin } from '@atlaskit/editor-plugin-editor-viewmode-effects';
|
|
6
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
7
7
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
8
|
+
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
8
9
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
import type { showInlineCommentForBlockNode } from './editor-commands';
|
|
@@ -20,7 +21,8 @@ export type AnnotationPluginDependencies = [
|
|
|
20
21
|
OptionalPlugin<EditorViewModePlugin>,
|
|
21
22
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
22
23
|
OptionalPlugin<ConnectivityPlugin>,
|
|
23
|
-
OptionalPlugin<ToolbarPlugin
|
|
24
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
25
|
+
OptionalPlugin<UserIntentPlugin>
|
|
24
26
|
];
|
|
25
27
|
export type AnnotationPluginOptions = AnnotationProviders;
|
|
26
28
|
export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
@@ -20,7 +20,7 @@ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnal
|
|
|
20
20
|
* @example
|
|
21
21
|
*/
|
|
22
22
|
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[]) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
23
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[]) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
23
|
+
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
24
24
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[]) => Command;
|
|
25
25
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
26
26
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
4
|
+
export declare const setUserIntent: (api: ExtractInjectionAPI<AnnotationPlugin> | undefined, tr: Transaction) => Transaction | null | undefined;
|
|
5
|
+
export declare const resetUserIntent: (api: ExtractInjectionAPI<AnnotationPlugin> | undefined, tr: Transaction) => Transaction | null | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
1
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
4
|
+
export declare function keymapPlugin(api: ExtractInjectionAPI<AnnotationPlugin> | undefined): SafePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-annotation",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Annotation plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"@atlaskit/editor-plugin-editor-viewmode-effects": "^4.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-feature-flags": "^3.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-toolbar": "^1.1.0",
|
|
37
|
+
"@atlaskit/editor-plugin-user-intent": "^2.0.0",
|
|
37
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
38
39
|
"@atlaskit/editor-toolbar": "^0.8.0",
|
|
39
40
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/editor-common": "^108.
|
|
49
|
+
"@atlaskit/editor-common": "^108.5.0",
|
|
49
50
|
"react": "^18.2.0",
|
|
50
51
|
"react-dom": "^18.2.0"
|
|
51
52
|
},
|