@atlaskit/editor-plugin-annotation 28.0.0 → 28.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/annotationPlugin.js +15 -8
- package/dist/cjs/editor-commands/index.js +29 -9
- package/dist/es2019/annotationPlugin.js +10 -3
- package/dist/es2019/editor-commands/index.js +29 -10
- package/dist/esm/annotationPlugin.js +15 -8
- package/dist/esm/editor-commands/index.js +29 -9
- package/dist/types/annotationPluginType.d.ts +9 -0
- package/dist/types/editor-commands/index.d.ts +2 -2
- package/dist/types/types/index.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-annotation
|
|
2
2
|
|
|
3
|
+
## 28.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`0dacb94545d03`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0dacb94545d03) -
|
|
8
|
+
Behind cc_maui_annotations_on_extensions: fire the cc_maui_comments_on_charts_exp exposure only
|
|
9
|
+
where the chart Comment button can show. Adds an optional viewModeEditorToolbarItems UiConfig
|
|
10
|
+
hook, used by MAUI charts to show Comment in the view-mode toolbar (live pages), and a
|
|
11
|
+
getAddCommentPermission annotation plugin action, used to disable the chart Comment button without
|
|
12
|
+
comment permission. The full-page renderer checks extension comment creation on first hover or
|
|
13
|
+
focus instead of while rendering.
|
|
14
|
+
- [`98f39b65e08a9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/98f39b65e08a9) -
|
|
15
|
+
Track new Remix inline comment drafts through the configured creation experience under
|
|
16
|
+
cc_maui_annotations_on_extensions.
|
|
17
|
+
|
|
3
18
|
## 28.0.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -97,6 +97,13 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
97
97
|
var _annotationProviders$, _annotationProviders$2;
|
|
98
98
|
return (0, _fg.fg)('cc_maui_annotations_on_extensions') && (annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$ = (_annotationProviders$2 = annotationProviders.inlineComment).isBlockNodeSupported) === null || _annotationProviders$ === void 0 ? void 0 : _annotationProviders$.call(_annotationProviders$2, node)) === true;
|
|
99
99
|
},
|
|
100
|
+
getAddCommentPermission: function getAddCommentPermission() {
|
|
101
|
+
var _annotationProviders$3, _annotationProviders$4, _annotationProviders$5;
|
|
102
|
+
return {
|
|
103
|
+
canAddComments: (_annotationProviders$3 = annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = (_annotationProviders$5 = annotationProviders.inlineComment).getCanAddComments) === null || _annotationProviders$4 === void 0 ? void 0 : _annotationProviders$4.call(_annotationProviders$5)) !== null && _annotationProviders$3 !== void 0 ? _annotationProviders$3 : true,
|
|
104
|
+
contentType: annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.contentType
|
|
105
|
+
};
|
|
106
|
+
},
|
|
100
107
|
hasAnyUnResolvedAnnotationInPage: _utils.hasAnyUnResolvedAnnotationInPage,
|
|
101
108
|
requestCloseInlineComment: requestCloseInlineComment,
|
|
102
109
|
stripNonExistingAnnotations: _utils.stripNonExistingAnnotations,
|
|
@@ -105,10 +112,10 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
105
112
|
return (0, _editorCommands.createAnnotation)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, _annotation.AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
106
113
|
},
|
|
107
114
|
removeInlineCommentAnnotation: function removeInlineCommentAnnotation(annotationId) {
|
|
108
|
-
var _api$analytics2, _annotationProviders$
|
|
109
|
-
return (0, _editorCommands.removeInlineCommentFromDoc)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$
|
|
115
|
+
var _api$analytics2, _annotationProviders$6;
|
|
116
|
+
return (0, _editorCommands.removeInlineCommentFromDoc)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$6 = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$6 !== void 0 ? _annotationProviders$6 : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
110
117
|
},
|
|
111
|
-
setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
118
|
+
setInlineCommentDraftState: (0, _editorCommands.setInlineCommentDraftState)(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.createCommentExperience),
|
|
112
119
|
showCommentForBlockNode: (0, _editorCommands.showInlineCommentForBlockNode)(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
113
120
|
setSelectedAnnotation: _editorCommands.setSelectedAnnotation,
|
|
114
121
|
setPendingSelectedAnnotation: _editorCommands.setPendingSelectedAnnotation
|
|
@@ -175,11 +182,11 @@ var annotationPlugin = exports.annotationPlugin = function annotationPlugin(_ref
|
|
|
175
182
|
var pluginState = (0, _utils.getPluginState)(state);
|
|
176
183
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
177
184
|
var _api$analytics5;
|
|
178
|
-
var _annotationProviders$
|
|
179
|
-
isToolbarAbove = _annotationProviders$
|
|
180
|
-
onCommentButtonMount = _annotationProviders$
|
|
181
|
-
getCanAddComments = _annotationProviders$
|
|
182
|
-
contentType = _annotationProviders$
|
|
185
|
+
var _annotationProviders$7 = annotationProviders.inlineComment,
|
|
186
|
+
isToolbarAbove = _annotationProviders$7.isToolbarAbove,
|
|
187
|
+
onCommentButtonMount = _annotationProviders$7.onCommentButtonMount,
|
|
188
|
+
getCanAddComments = _annotationProviders$7.getCanAddComments,
|
|
189
|
+
contentType = _annotationProviders$7.contentType;
|
|
183
190
|
var toolbarConfig = (0, _toolbar.buildToolbar)(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)({
|
|
184
191
|
state: state,
|
|
185
192
|
intl: intl,
|
|
@@ -9,7 +9,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _annotation = require("@atlaskit/adf-schema/annotation");
|
|
10
10
|
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
11
11
|
var _inlineCommentEvents = require("@atlaskit/editor-common/analytics/types/inline-comment-events");
|
|
12
|
+
var _manifestHelpers = require("@atlaskit/editor-common/extensions/manifest-helpers");
|
|
12
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
+
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
13
15
|
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
14
16
|
var _types = require("../pm-plugins/types");
|
|
15
17
|
var _utils = require("../pm-plugins/utils");
|
|
@@ -250,16 +252,35 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
|
|
|
250
252
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
251
253
|
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
252
254
|
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
255
|
+
var createCommentExperience = arguments.length > 4 ? arguments[4] : undefined;
|
|
253
256
|
return function (drafting) {
|
|
254
257
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _enums.INPUT_METHOD.TOOLBAR;
|
|
255
258
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
256
259
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
257
260
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
258
261
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
+
var draftCommand = !(api !== null && api !== void 0 && api.toolbar) ? (0, _pluginFactory.createCommand)(commandAction, _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)) : undefined;
|
|
263
|
+
return function (state, dispatch, view) {
|
|
264
|
+
// Start tracking only when a valid draft is dispatched, never during dry runs.
|
|
265
|
+
var dispatchDraft = dispatch && drafting && targetType === 'block' && state.selection instanceof _state.NodeSelection && state.selection.node.type.name === 'extension' && state.selection.node.attrs.extensionKey === "".concat(_manifestHelpers.NATIVE_EMBED_EXTENSION_KEY, ":maui") && (0, _fg.fg)('cc_maui_annotations_on_extensions') ? function (tr) {
|
|
266
|
+
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
|
|
267
|
+
attributes: {
|
|
268
|
+
pageClass: 'editor',
|
|
269
|
+
commentType: 'block',
|
|
270
|
+
blockType: 'extension',
|
|
271
|
+
commentTargetType: 'remixEmbed',
|
|
272
|
+
entryPoint: 'highlightActions'
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.initExperience.start();
|
|
276
|
+
dispatch(tr);
|
|
277
|
+
} : dispatch;
|
|
278
|
+
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
262
279
|
var newPluginState = commandAction(state);
|
|
280
|
+
if (!newPluginState) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
var tr = _transform.default.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
263
284
|
if (tr && newPluginState) {
|
|
264
285
|
tr.setMeta(_utils.inlineCommentPluginKey, newPluginState);
|
|
265
286
|
if (drafting) {
|
|
@@ -267,17 +288,16 @@ var setInlineCommentDraftState = exports.setInlineCommentDraftState = function s
|
|
|
267
288
|
} else {
|
|
268
289
|
(0, _utils2.resetUserIntent)(api, tr);
|
|
269
290
|
}
|
|
270
|
-
if (
|
|
271
|
-
|
|
291
|
+
if (dispatchDraft) {
|
|
292
|
+
dispatchDraft(tr);
|
|
272
293
|
}
|
|
273
294
|
} else {
|
|
274
295
|
return false;
|
|
275
296
|
}
|
|
276
297
|
return true;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
298
|
+
}
|
|
299
|
+
return draftCommand ? draftCommand(state, dispatchDraft, view) : false;
|
|
300
|
+
};
|
|
281
301
|
};
|
|
282
302
|
};
|
|
283
303
|
var addInlineComment = exports.addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -65,6 +65,13 @@ export const annotationPlugin = ({
|
|
|
65
65
|
var _annotationProviders$, _annotationProviders$2;
|
|
66
66
|
return fg('cc_maui_annotations_on_extensions') && (annotationProviders === null || annotationProviders === void 0 ? void 0 : (_annotationProviders$ = (_annotationProviders$2 = annotationProviders.inlineComment).isBlockNodeSupported) === null || _annotationProviders$ === void 0 ? void 0 : _annotationProviders$.call(_annotationProviders$2, node)) === true;
|
|
67
67
|
},
|
|
68
|
+
getAddCommentPermission: () => {
|
|
69
|
+
var _annotationProviders$3, _annotationProviders$4, _annotationProviders$5;
|
|
70
|
+
return {
|
|
71
|
+
canAddComments: (_annotationProviders$3 = annotationProviders === null || annotationProviders === void 0 ? void 0 : (_annotationProviders$4 = (_annotationProviders$5 = annotationProviders.inlineComment).getCanAddComments) === null || _annotationProviders$4 === void 0 ? void 0 : _annotationProviders$4.call(_annotationProviders$5)) !== null && _annotationProviders$3 !== void 0 ? _annotationProviders$3 : true,
|
|
72
|
+
contentType: annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.contentType
|
|
73
|
+
};
|
|
74
|
+
},
|
|
68
75
|
hasAnyUnResolvedAnnotationInPage,
|
|
69
76
|
requestCloseInlineComment,
|
|
70
77
|
stripNonExistingAnnotations,
|
|
@@ -73,10 +80,10 @@ export const annotationPlugin = ({
|
|
|
73
80
|
return createAnnotation(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
74
81
|
},
|
|
75
82
|
removeInlineCommentAnnotation: annotationId => {
|
|
76
|
-
var _api$analytics2, _annotationProviders$
|
|
77
|
-
return removeInlineCommentFromDoc(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$
|
|
83
|
+
var _api$analytics2, _annotationProviders$6;
|
|
84
|
+
return removeInlineCommentFromDoc(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$6 = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$6 !== void 0 ? _annotationProviders$6 : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
78
85
|
},
|
|
79
|
-
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
86
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.createCommentExperience),
|
|
80
87
|
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
81
88
|
setSelectedAnnotation,
|
|
82
89
|
setPendingSelectedAnnotation
|
|
@@ -3,7 +3,9 @@ import { AnnotationTypes } from '@atlaskit/adf-schema/annotation';
|
|
|
3
3
|
|
|
4
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
5
5
|
import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics/types/inline-comment-events';
|
|
6
|
+
import { NATIVE_EMBED_EXTENSION_KEY } from '@atlaskit/editor-common/extensions/manifest-helpers';
|
|
6
7
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
7
9
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
8
10
|
import { ACTIONS } from '../pm-plugins/types';
|
|
9
11
|
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../pm-plugins/utils';
|
|
@@ -204,12 +206,30 @@ export const showInlineCommentForBlockNode = (supportedBlockNodes = [], isBlockN
|
|
|
204
206
|
}
|
|
205
207
|
return false;
|
|
206
208
|
};
|
|
207
|
-
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = [], api, isBlockNodeSupported) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
209
|
+
export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNodes = [], api, isBlockNodeSupported, createCommentExperience) => (drafting, inputMethod = INPUT_METHOD.TOOLBAR, targetType = 'inline', targetNodeId = undefined, isOpeningMediaCommentFromToolbar) => {
|
|
208
210
|
const commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
const draftCommand = !(api !== null && api !== void 0 && api.toolbar) ? createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)) : undefined;
|
|
212
|
+
return (state, dispatch, view) => {
|
|
213
|
+
// Start tracking only when a valid draft is dispatched, never during dry runs.
|
|
214
|
+
const dispatchDraft = dispatch && drafting && targetType === 'block' && state.selection instanceof NodeSelection && state.selection.node.type.name === 'extension' && state.selection.node.attrs.extensionKey === `${NATIVE_EMBED_EXTENSION_KEY}:maui` && fg('cc_maui_annotations_on_extensions') ? tr => {
|
|
215
|
+
createCommentExperience === null || createCommentExperience === void 0 ? void 0 : createCommentExperience.start({
|
|
216
|
+
attributes: {
|
|
217
|
+
pageClass: 'editor',
|
|
218
|
+
commentType: 'block',
|
|
219
|
+
blockType: 'extension',
|
|
220
|
+
commentTargetType: 'remixEmbed',
|
|
221
|
+
entryPoint: 'highlightActions'
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
createCommentExperience === null || createCommentExperience === void 0 ? void 0 : createCommentExperience.initExperience.start();
|
|
225
|
+
dispatch(tr);
|
|
226
|
+
} : dispatch;
|
|
227
|
+
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
212
228
|
const newPluginState = commandAction(state);
|
|
229
|
+
if (!newPluginState) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
const tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
213
233
|
if (tr && newPluginState) {
|
|
214
234
|
tr.setMeta(inlineCommentPluginKey, newPluginState);
|
|
215
235
|
if (drafting) {
|
|
@@ -217,17 +237,16 @@ export const setInlineCommentDraftState = (editorAnalyticsAPI, supportedBlockNod
|
|
|
217
237
|
} else {
|
|
218
238
|
resetUserIntent(api, tr);
|
|
219
239
|
}
|
|
220
|
-
if (
|
|
221
|
-
|
|
240
|
+
if (dispatchDraft) {
|
|
241
|
+
dispatchDraft(tr);
|
|
222
242
|
}
|
|
223
243
|
} else {
|
|
224
244
|
return false;
|
|
225
245
|
}
|
|
226
246
|
return true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
247
|
+
}
|
|
248
|
+
return draftCommand ? draftCommand(state, dispatchDraft, view) : false;
|
|
249
|
+
};
|
|
231
250
|
};
|
|
232
251
|
export const addInlineComment = (editorAnalyticsAPI, editorAPI) => (id, supportedBlockNodes, isBlockNodeSupported) => {
|
|
233
252
|
const commandAction = editorState => ({
|
|
@@ -90,6 +90,13 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
90
90
|
var _annotationProviders$, _annotationProviders$2;
|
|
91
91
|
return fg('cc_maui_annotations_on_extensions') && (annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$ = (_annotationProviders$2 = annotationProviders.inlineComment).isBlockNodeSupported) === null || _annotationProviders$ === void 0 ? void 0 : _annotationProviders$.call(_annotationProviders$2, node)) === true;
|
|
92
92
|
},
|
|
93
|
+
getAddCommentPermission: function getAddCommentPermission() {
|
|
94
|
+
var _annotationProviders$3, _annotationProviders$4, _annotationProviders$5;
|
|
95
|
+
return {
|
|
96
|
+
canAddComments: (_annotationProviders$3 = annotationProviders === null || annotationProviders === void 0 || (_annotationProviders$4 = (_annotationProviders$5 = annotationProviders.inlineComment).getCanAddComments) === null || _annotationProviders$4 === void 0 ? void 0 : _annotationProviders$4.call(_annotationProviders$5)) !== null && _annotationProviders$3 !== void 0 ? _annotationProviders$3 : true,
|
|
97
|
+
contentType: annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.contentType
|
|
98
|
+
};
|
|
99
|
+
},
|
|
93
100
|
hasAnyUnResolvedAnnotationInPage: hasAnyUnResolvedAnnotationInPage,
|
|
94
101
|
requestCloseInlineComment: requestCloseInlineComment,
|
|
95
102
|
stripNonExistingAnnotations: stripNonExistingAnnotations,
|
|
@@ -98,10 +105,10 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
98
105
|
return createAnnotation(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, api)(annotationId, AnnotationTypes.INLINE_COMMENT, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
99
106
|
},
|
|
100
107
|
removeInlineCommentAnnotation: function removeInlineCommentAnnotation(annotationId) {
|
|
101
|
-
var _api$analytics2, _annotationProviders$
|
|
102
|
-
return removeInlineCommentFromDoc(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$
|
|
108
|
+
var _api$analytics2, _annotationProviders$6;
|
|
109
|
+
return removeInlineCommentFromDoc(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(annotationId, (_annotationProviders$6 = annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes) !== null && _annotationProviders$6 !== void 0 ? _annotationProviders$6 : [], annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported);
|
|
103
110
|
},
|
|
104
|
-
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
111
|
+
setInlineCommentDraftState: setInlineCommentDraftState(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, undefined, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.createCommentExperience),
|
|
105
112
|
showCommentForBlockNode: showInlineCommentForBlockNode(annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.supportedBlockNodes, annotationProviders === null || annotationProviders === void 0 ? void 0 : annotationProviders.inlineComment.isBlockNodeSupported),
|
|
106
113
|
setSelectedAnnotation: setSelectedAnnotation,
|
|
107
114
|
setPendingSelectedAnnotation: setPendingSelectedAnnotation
|
|
@@ -168,11 +175,11 @@ export var annotationPlugin = function annotationPlugin(_ref) {
|
|
|
168
175
|
var pluginState = getPluginState(state);
|
|
169
176
|
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
170
177
|
var _api$analytics5;
|
|
171
|
-
var _annotationProviders$
|
|
172
|
-
isToolbarAbove = _annotationProviders$
|
|
173
|
-
onCommentButtonMount = _annotationProviders$
|
|
174
|
-
getCanAddComments = _annotationProviders$
|
|
175
|
-
contentType = _annotationProviders$
|
|
178
|
+
var _annotationProviders$7 = annotationProviders.inlineComment,
|
|
179
|
+
isToolbarAbove = _annotationProviders$7.isToolbarAbove,
|
|
180
|
+
onCommentButtonMount = _annotationProviders$7.onCommentButtonMount,
|
|
181
|
+
getCanAddComments = _annotationProviders$7.getCanAddComments,
|
|
182
|
+
contentType = _annotationProviders$7.contentType;
|
|
176
183
|
var toolbarConfig = buildToolbar(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)({
|
|
177
184
|
state: state,
|
|
178
185
|
intl: intl,
|
|
@@ -4,7 +4,9 @@ import { AnnotationTypes } from '@atlaskit/adf-schema/annotation';
|
|
|
4
4
|
|
|
5
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
6
6
|
import { RESOLVE_METHOD } from '@atlaskit/editor-common/analytics/types/inline-comment-events';
|
|
7
|
+
import { NATIVE_EMBED_EXTENSION_KEY } from '@atlaskit/editor-common/extensions/manifest-helpers';
|
|
7
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
10
|
import { createCommand } from '../pm-plugins/plugin-factory';
|
|
9
11
|
import { ACTIONS } from '../pm-plugins/types';
|
|
10
12
|
import { getPluginState, inlineCommentPluginKey, isSelectionValid, isSupportedBlockNode } from '../pm-plugins/utils';
|
|
@@ -243,16 +245,35 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
|
|
|
243
245
|
var supportedBlockNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
244
246
|
var api = arguments.length > 2 ? arguments[2] : undefined;
|
|
245
247
|
var isBlockNodeSupported = arguments.length > 3 ? arguments[3] : undefined;
|
|
248
|
+
var createCommentExperience = arguments.length > 4 ? arguments[4] : undefined;
|
|
246
249
|
return function (drafting) {
|
|
247
250
|
var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INPUT_METHOD.TOOLBAR;
|
|
248
251
|
var targetType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'inline';
|
|
249
252
|
var targetNodeId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
250
253
|
var isOpeningMediaCommentFromToolbar = arguments.length > 4 ? arguments[4] : undefined;
|
|
251
254
|
var commandAction = getDraftCommandAction(drafting, targetType, targetNodeId, supportedBlockNodes, isBlockNodeSupported, isOpeningMediaCommentFromToolbar);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
var draftCommand = !(api !== null && api !== void 0 && api.toolbar) ? createCommand(commandAction, transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)) : undefined;
|
|
256
|
+
return function (state, dispatch, view) {
|
|
257
|
+
// Start tracking only when a valid draft is dispatched, never during dry runs.
|
|
258
|
+
var dispatchDraft = dispatch && drafting && targetType === 'block' && state.selection instanceof NodeSelection && state.selection.node.type.name === 'extension' && state.selection.node.attrs.extensionKey === "".concat(NATIVE_EMBED_EXTENSION_KEY, ":maui") && fg('cc_maui_annotations_on_extensions') ? function (tr) {
|
|
259
|
+
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.start({
|
|
260
|
+
attributes: {
|
|
261
|
+
pageClass: 'editor',
|
|
262
|
+
commentType: 'block',
|
|
263
|
+
blockType: 'extension',
|
|
264
|
+
commentTargetType: 'remixEmbed',
|
|
265
|
+
entryPoint: 'highlightActions'
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
createCommentExperience === null || createCommentExperience === void 0 || createCommentExperience.initExperience.start();
|
|
269
|
+
dispatch(tr);
|
|
270
|
+
} : dispatch;
|
|
271
|
+
if (Boolean(api === null || api === void 0 ? void 0 : api.toolbar)) {
|
|
255
272
|
var newPluginState = commandAction(state);
|
|
273
|
+
if (!newPluginState) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
var tr = transform.handleDraftState(editorAnalyticsAPI)(drafting, inputMethod)(state.tr, state);
|
|
256
277
|
if (tr && newPluginState) {
|
|
257
278
|
tr.setMeta(inlineCommentPluginKey, newPluginState);
|
|
258
279
|
if (drafting) {
|
|
@@ -260,17 +281,16 @@ export var setInlineCommentDraftState = function setInlineCommentDraftState(edit
|
|
|
260
281
|
} else {
|
|
261
282
|
resetUserIntent(api, tr);
|
|
262
283
|
}
|
|
263
|
-
if (
|
|
264
|
-
|
|
284
|
+
if (dispatchDraft) {
|
|
285
|
+
dispatchDraft(tr);
|
|
265
286
|
}
|
|
266
287
|
} else {
|
|
267
288
|
return false;
|
|
268
289
|
}
|
|
269
290
|
return true;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
291
|
+
}
|
|
292
|
+
return draftCommand ? draftCommand(state, dispatchDraft, view) : false;
|
|
293
|
+
};
|
|
274
294
|
};
|
|
275
295
|
};
|
|
276
296
|
export var addInlineComment = function addInlineComment(editorAnalyticsAPI, editorAPI) {
|
|
@@ -40,6 +40,15 @@ export type AnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
|
40
40
|
* @returns A command that returns true when the draft is applied.
|
|
41
41
|
*/
|
|
42
42
|
applyInlineCommentDraft: (annotationId: string) => Command;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the current user can add comments, from the provider's
|
|
45
|
+
* `getCanAddComments` (defaults to true), and the provider's content type
|
|
46
|
+
* for the no-permission message.
|
|
47
|
+
*/
|
|
48
|
+
getAddCommentPermission: () => {
|
|
49
|
+
canAddComments: boolean;
|
|
50
|
+
contentType?: string;
|
|
51
|
+
};
|
|
43
52
|
hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;
|
|
44
53
|
/** Whether the configured provider supports block comments on this node. */
|
|
45
54
|
isBlockNodeSupported: (node: Node) => boolean;
|
|
@@ -6,7 +6,7 @@ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types/next-edi
|
|
|
6
6
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
7
|
import type { AnnotationPlugin } from '../annotationPluginType';
|
|
8
8
|
import type { InlineCommentMap, InlineCommentMouseData } from '../pm-plugins/types';
|
|
9
|
-
import type { InlineCommentAnnotationProvider, InlineCommentInputMethod, TargetType } from '../types';
|
|
9
|
+
import type { AnnotationProviders, InlineCommentAnnotationProvider, InlineCommentInputMethod, TargetType } from '../types';
|
|
10
10
|
export declare const updateInlineCommentResolvedState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (partialNewState: InlineCommentMap, resolveMethod?: RESOLVE_METHOD) => Command;
|
|
11
11
|
export declare const closeComponent: () => Command;
|
|
12
12
|
export declare const clearDirtyMark: () => Command;
|
|
@@ -22,7 +22,7 @@ export declare const removeInlineCommentFromDoc: (editorAnalyticsAPI: EditorAnal
|
|
|
22
22
|
* @example
|
|
23
23
|
*/
|
|
24
24
|
export declare const showInlineCommentForBlockNode: (supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (node: PMNode | null, viewMethod?: VIEW_METHOD, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
25
|
-
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>, isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
25
|
+
export declare const setInlineCommentDraftState: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, supportedBlockNodes?: string[], api?: ExtractInjectionAPI<AnnotationPlugin>, isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported'], createCommentExperience?: AnnotationProviders['createCommentExperience']) => (drafting: boolean, inputMethod?: InlineCommentInputMethod, targetType?: TargetType, targetNodeId?: string | undefined, isOpeningMediaCommentFromToolbar?: boolean) => Command;
|
|
26
26
|
export declare const addInlineComment: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorAPI?: ExtractInjectionAPI<AnnotationPlugin> | undefined) => (id: string, supportedBlockNodes?: string[], isBlockNodeSupported?: InlineCommentAnnotationProvider['isBlockNodeSupported']) => Command;
|
|
27
27
|
export declare const updateMouseState: (mouseData: InlineCommentMouseData) => Command;
|
|
28
28
|
export declare const setSelectedAnnotation: (id: string) => Command;
|
|
@@ -138,7 +138,8 @@ export interface AnnotationProviders {
|
|
|
138
138
|
pageClass: 'editor';
|
|
139
139
|
} | {
|
|
140
140
|
annotationId?: undefined;
|
|
141
|
-
blockType: 'media';
|
|
141
|
+
blockType: 'media' | 'extension';
|
|
142
|
+
commentTargetType?: 'remixEmbed';
|
|
142
143
|
commentType: 'block';
|
|
143
144
|
entryPoint?: 'highlightActions';
|
|
144
145
|
pageClass: 'editor';
|